OpenRadioss 2025.1.11
OpenRadioss project
Loading...
Searching...
No Matches
c_h3d_eroded_shell.cpp
Go to the documentation of this file.
1//Copyright> OpenRadioss
2//Copyright> Copyright (C) 1986-2025 Altair Engineering Inc.
3//Copyright>
4//Copyright> This program is free software: you can redistribute it and/or modify
5//Copyright> it under the terms of the GNU Affero General Public License as published by
6//Copyright> the Free Software Foundation, either version 3 of the License, or
7//Copyright> (at your option) any later version.
8//Copyright>
9//Copyright> This program is distributed in the hope that it will be useful,
10//Copyright> but WITHOUT ANY WARRANTY; without even the implied warranty of
11//Copyright> MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12//Copyright> GNU Affero General Public License for more details.
13//Copyright>
14//Copyright> You should have received a copy of the GNU Affero General Public License
15//Copyright> along with this program. If not, see <https://www.gnu.org/licenses/>.
16//Copyright>
17//Copyright>
18//Copyright> Commercial Alternative: Altair Radioss Software
19//Copyright>
20//Copyright> As an alternative to this open-source version, Altair also offers Altair Radioss
21//Copyright> software under a commercial license. Contact Altair to discuss further if the
22//Copyright> commercial version may interest you: https://www.altair.com/radioss/.
23//
24#include <stdio.h>
25#include <string.h>
26#include <stdlib.h>
27#include <math.h>
28#include <fcntl.h>
29
30
31
32#ifdef _WIN32
33/* Windows includes */
34#include <windows.h>
35#include <process.h>
36#include <io.h>
37#include <sys\types.h>
38#include <sys/stat.h>
39
40
41#elif 1
42
43/* Linux includes */
44#include <sys/resource.h>
45#include <sys/types.h>
46#include <time.h>
47#include <sys/stat.h>
48#include <unistd.h>
49#include <dlfcn.h>
50#define _FCALL
51#include <math.h>
52#include <stdbool.h>
53
54#endif
55
56#include "h3dpublic_defs.h"
57#include "h3dpublic_export.h"
58
59#define _FCALL
60
61#include "h3d_values.h"
62
63#ifdef MYREAL4
64#define my_real float
65#endif
66
67#ifdef MYREAL8
68#define my_real double
69#endif
70
71extern "C"
72/*=================================================================*/
73{
74/*=================================================================*/
75/* C_H3D_UPDATE_SHELL_SCALAR */
76/*=================================================================*/
77
78void c_h3d_eroded_shell_(my_real *TT,int *IH3D, int *ITAB, int *NUMNOD, int *IXC, int *NIXC, int *NUMELC, int *IPARTC,
79 int *IXTG, int *NIXTG, int *NUMELTG, int *IPARTTG, my_real *FUNC ,int *ID_ELEM,int *CPT_DATATYPE,
80 int *ITY_ELEM, int *NUMELS, int *NUMELQ , int *NUMELT , int *NUMELP , int *NUMELR)
81{
82 int i;
83 int offset;
84 H3D_ID elem_id;
85 H3D_ID comp_id;
86//
87 // initialize
88
89 try {
90 // create Subcase (Loadcase)
91 unsigned int max_sims = 10;
92 unsigned int sub_count = 1;
93 float elem_result[] = { 0.0f, 0.0f, 0.0f };
94
95 // create Result Data sets
96 unsigned int num_corners = 0;
97 unsigned int num_modes = 0;
98 bool complex = false;
99 float value[1] ;
100
101 sim_idx = *IH3D;
102
103 if(*NUMELC != 0)
104 {
105 rc = Hyper3DDatasetBegin(h3d_file, *NUMELC, sim_idx, subcase_id, H3D_DS_ELEM,
106 H3D_DS_EROSION, num_corners, num_modes, *CPT_DATATYPE,
108 if( !rc ) fflush(stdout);
109 if( !rc ) throw rc;
110
111
112 offset = 0;
113
114 for( i = 0; i < *NUMELC + *NUMELTG; i++ )
115 {
116 if( ITY_ELEM[i] == 3 )
117 {
118 elem_id = ID_ELEM[i];
119 elem_result[0] = 0.0f;
120 if( FUNC[i] == 0.0f )
121 {
122 elem_result[0] = 1.0f;
123 rc = Hyper3DDatasetWrite(h3d_file, elem_id, &elem_result[0]);
124 }
125 }
126 }
127
129 if( !rc ) throw rc;
130 }
131
132 offset = *NUMELC;
133
134 if(*NUMELTG != 0)
135 {
136 rc = Hyper3DDatasetBegin(h3d_file, *NUMELTG, sim_idx, subcase_id, H3D_DS_ELEM,
137 H3D_DS_EROSION, num_corners, num_modes, *CPT_DATATYPE,
139 if( !rc ) fflush(stdout);
140 if( !rc ) throw rc;
141
142 for( i = 0; i < *NUMELC + *NUMELTG; i++ )
143 {
144 if( ITY_ELEM[i] == 7)
145 {
146 elem_id = ID_ELEM[i];
147 elem_result[0] = 0.0f;
148 if( FUNC[i] == 0.0f )
149 {
150 elem_result[0] = 1.0f;
151 rc = Hyper3DDatasetWrite(h3d_file, elem_id, &elem_result[0]);
152 }
153 }
154 }
156 if( !rc ) throw rc;
157 }
158 } // end of try
159
160 catch(...) {
162 }
163}
164
165void _FCALL C_H3D_ERODED_SHELL(my_real *TT,int *IH3D, int *ITAB, int *NUMNOD, int *IXC, int *NIXC, int *NUMELC, int *IPARTC,
166 int *IXTG, int *NIXTG, int *NUMELTG, int *IPARTTG, my_real *FUNC ,int *ID_ELEM,int *CPT_DATATYPE,
167 int *ITY_ELEM, int *NUMELS, int *NUMELQ , int *NUMELT , int *NUMELP , int *NUMELR)
168{c_h3d_eroded_shell_ (TT,IH3D,ITAB,NUMNOD,IXC,NIXC,NUMELC,IPARTC,IXTG,NIXTG,NUMELTG,IPARTTG,FUNC,ID_ELEM,CPT_DATATYPE,ITY_ELEM,
169 NUMELS,NUMELQ,NUMELT,NUMELP,NUMELR);}
170
171void c_h3d_eroded_shell__ (my_real *TT,int *IH3D, int *ITAB, int *NUMNOD, int *IXC, int *NIXC, int *NUMELC, int *IPARTC,
172 int *IXTG, int *NIXTG, int *NUMELTG, int *IPARTTG, my_real *FUNC ,int *ID_ELEM,int *CPT_DATATYPE,
173 int *ITY_ELEM, int *NUMELS, int *NUMELQ , int *NUMELT , int *NUMELP , int *NUMELR)
174{c_h3d_eroded_shell_ (TT,IH3D,ITAB,NUMNOD,IXC,NIXC,NUMELC,IPARTC,IXTG,NIXTG,NUMELTG,IPARTTG,FUNC,ID_ELEM,CPT_DATATYPE,ITY_ELEM,
175 NUMELS,NUMELQ,NUMELT,NUMELP,NUMELR);}
176
177void c_h3d_eroded_shell (my_real *TT,int *IH3D, int *ITAB, int *NUMNOD, int *IXC, int *NIXC, int *NUMELC, int *IPARTC,
178 int *IXTG, int *NIXTG, int *NUMELTG, int *IPARTTG, my_real *FUNC ,int *ID_ELEM,int *CPT_DATATYPE,
179 int *ITY_ELEM, int *NUMELS, int *NUMELQ , int *NUMELT , int *NUMELP , int *NUMELR)
180{c_h3d_eroded_shell_ (TT,IH3D,ITAB,NUMNOD,IXC,NIXC,NUMELC,IPARTC,IXTG,NIXTG,NUMELTG,IPARTTG,FUNC,ID_ELEM,CPT_DATATYPE,ITY_ELEM,
181 NUMELS,NUMELQ,NUMELT,NUMELP,NUMELR);}
182
183
184void c_h3d_create_shell_eroded_(int *cpt_data, char *name, int *size, int *info, char *name1, int *size1)
185{
186 char *cname,*cname1;
187 int cname_len,cname_len1;
188 int i;
189 float node[3];
190 H3D_ID node_id;
191 unsigned int elem_count = 1;
192
193 cname_len = *size + 1;
194 cname=(char*) malloc(sizeof(char)*cname_len);
195 for(i=0;i<*size;i++) cname[i] = name[i];
196 cname[*size]='\0';
197
198 cname_len1 = *size1 + 1;
199 cname1=(char*) malloc(sizeof(char)*cname_len1);
200 for(i=0;i<*size1;i++) cname1[i] = name1[i];
201 cname1[*size1]='\0';
202
203 char * LAYERPOOL = new char [*size1+11];
204 sprintf(LAYERPOOL, "%s %d" ,cname1,*info);
205 H3D_ID layer_pool_id = H3D_NULL_ID;
206 rc = Hyper3DAddString(h3d_file, LAYERPOOL, &layer_pool_id);
207
208 char edata_type[30];
209//
210
211 //printf( "scalar %d info = %d %s\n", *cpt_data , *info, name);
212 //fflush(stdout);
213
214 try {
215 // create result data types
216 dt_count++;
217
219 if( !rc ) throw rc;
220
221 pool_count = 2;
222
223 dt_id++;
224 sprintf(edata_type, cname, H3D_DT_DELIMITER);
225 // snprintf(edata_type, sizeof(edata_type), cname, H3D_DT_DELIMITER);
226 rc = Hyper3DDatatypeWrite(h3d_file, edata_type, *cpt_data , H3D_DS_EROSION,
227 H3D_DS_ELEM, pool_count);
228 if( !rc ) throw rc;
229
230 rc = Hyper3DDatatypeDescriptionWrite(h3d_file,dt_id, "N/A : element not deleted");
231
234 if( !rc ) throw rc;
235
238 if( !rc ) throw rc;
239
241 if( !rc ) throw rc;
242
243 } // end of try
244
245 catch(...) {
247 }
248 delete [] LAYERPOOL;
249 free(cname);
250 free(cname1);
251
252}
253
254
255
256
257void _FCALL C_H3D_CREATE_SHELL_ERODED(int *cpt_data, char *name, int *size, int *info, char *name1, int *size1)
258{c_h3d_create_shell_eroded_ (cpt_data, name, size, info, name1, size1);}
259
260void c_h3d_create_shell_eroded__ (int *cpt_data, char *name, int *size, int *info, char *name1, int *size1)
261{c_h3d_create_shell_eroded_ (cpt_data, name, size, info, name1, size1);}
262
263void c_h3d_create_shell_eroded (int *cpt_data, char *name, int *size, int *info, char *name1, int *size1)
264{c_h3d_create_shell_eroded_ (cpt_data, name, size, info, name1, size1);}
265
266
267}
void c_h3d_eroded_shell(my_real *TT, int *IH3D, int *ITAB, int *NUMNOD, int *IXC, int *NIXC, int *NUMELC, int *IPARTC, int *IXTG, int *NIXTG, int *NUMELTG, int *IPARTTG, my_real *FUNC, int *ID_ELEM, int *CPT_DATATYPE, int *ITY_ELEM, int *NUMELS, int *NUMELQ, int *NUMELT, int *NUMELP, int *NUMELR)
void c_h3d_create_shell_eroded_(int *cpt_data, char *name, int *size, int *info, char *name1, int *size1)
void _FCALL C_H3D_CREATE_SHELL_ERODED(int *cpt_data, char *name, int *size, int *info, char *name1, int *size1)
void c_h3d_create_shell_eroded(int *cpt_data, char *name, int *size, int *info, char *name1, int *size1)
void c_h3d_eroded_shell__(my_real *TT, int *IH3D, int *ITAB, int *NUMNOD, int *IXC, int *NIXC, int *NUMELC, int *IPARTC, int *IXTG, int *NIXTG, int *NUMELTG, int *IPARTTG, my_real *FUNC, int *ID_ELEM, int *CPT_DATATYPE, int *ITY_ELEM, int *NUMELS, int *NUMELQ, int *NUMELT, int *NUMELP, int *NUMELR)
void c_h3d_create_shell_eroded__(int *cpt_data, char *name, int *size, int *info, char *name1, int *size1)
void _FCALL C_H3D_ERODED_SHELL(my_real *TT, int *IH3D, int *ITAB, int *NUMNOD, int *IXC, int *NIXC, int *NUMELC, int *IPARTC, int *IXTG, int *NIXTG, int *NUMELTG, int *IPARTTG, my_real *FUNC, int *ID_ELEM, int *CPT_DATATYPE, int *ITY_ELEM, int *NUMELS, int *NUMELQ, int *NUMELT, int *NUMELP, int *NUMELR)
void c_h3d_eroded_shell_(my_real *TT, int *IH3D, int *ITAB, int *NUMNOD, int *IXC, int *NIXC, int *NUMELC, int *IPARTC, int *IXTG, int *NIXTG, int *NUMELTG, int *IPARTTG, my_real *FUNC, int *ID_ELEM, int *CPT_DATATYPE, int *ITY_ELEM, int *NUMELS, int *NUMELQ, int *NUMELT, int *NUMELP, int *NUMELR)
H3DFileInfo * h3d_file
unsigned int pool_count
unsigned int dt_count
bool has_corners
bool rc
float poisson
H3D_ID sh4n_poolname_id
H3D_ID sh3n_poolname_id
H3D_ID comp_id
H3D_ID * layername_ids
H3D_SIM_IDX sim_idx
H3D_ID subcase_id
H3D_ID dt_id
char edata_type[50]
H3D_TENSOR_TYPE tensor_type
#define FUNC
Definition clamov.c:8
#define my_real
Definition cppsort.cpp:32
bool Hyper3DDatatypePools(H3DFileInfo *h3d_file, H3D_ID dt_id, H3D_ID poolname_id, unsigned int num_layers, H3D_ID *layername_ids, bool corners, H3D_TENSOR_TYPE tensor_type, float poisson)
Definition h3d_dl.c:1331
bool Hyper3DAddString(H3DFileInfo *h3d_file, const char *const string, H3D_ID *const str_id)
Definition h3d_dl.c:955
bool Hyper3DDatasetBegin(H3DFileInfo *h3d_file, unsigned int count, H3D_SIM_IDX idx, H3D_ID subcase_id, H3D_DS_TYPE type, H3D_DS_FORMAT format, unsigned int num_corners, unsigned int num_modes, H3D_ID dt_id, int layer_idx, H3D_ID data_poolname_id, bool complex)
Definition h3d_dl.c:1352
bool Hyper3DDatatypeEnd(H3DFileInfo *h3d_file)
Definition h3d_dl.c:1341
bool Hyper3DExportClearError(H3DFileInfo *h3d_file)
Definition h3d_dl.c:939
bool Hyper3DDatatypeDescriptionWrite(H3DFileInfo *h3d_file, H3D_ID dt_id, const char *description)
Definition h3d_dl.c:1324
bool Hyper3DDatatypeWrite(H3DFileInfo *h3d_file, const char *label, H3D_ID dt_id, H3D_DS_FORMAT format, H3D_DS_TYPE type, unsigned int num_pools)
Definition h3d_dl.c:1316
bool Hyper3DDatatypeBegin(H3DFileInfo *h3d_file, unsigned int count)
Definition h3d_dl.c:1310
bool Hyper3DDatasetEnd(H3DFileInfo *h3d_file)
Definition h3d_dl.c:1400
bool Hyper3DDatasetWrite(H3DFileInfo *h3d_file, H3D_ID id, const float *data)
Definition h3d_dl.c:1372
#define _FCALL