OpenRadioss 2025.1.11
OpenRadioss project
Loading...
Searching...
No Matches
c_h3d_create_shell_scalar_datatype.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#include <ctype.h>
30
31#ifdef _WIN32
32/* Windows includes */
33#include <windows.h>
34#include <process.h>
35#include <io.h>
36#include <sys\types.h>
37#include <sys/stat.h>
38
39#elif 1
40
41/* Linux includes */
42#include <sys/resource.h>
43#include <sys/types.h>
44#include <time.h>
45#include <sys/stat.h>
46#include <unistd.h>
47#include <dlfcn.h>
48#define _FCALL
49#include <math.h>
50#include <stdbool.h>
51
52#endif
53
54#include "h3dpublic_defs.h"
55#include "h3dpublic_export.h"
56
57#define _FCALL
58
59#include "h3d_values.h"
60
61extern "C"
62/*=================================================================*/
63{
64
65 /*=================================================================*/
66 /* C_H3D_CREATE_SHELL_SCALAR_DATATYPE */
67 /*=================================================================*/
68
69 void c_h3d_create_shell_scalar_datatype_(int *cpt_data, char *name1, int *size1, int *info1, int *info2, char *name2, int *size2,
70 int *layer, int *ipt, int *ply, int *nuvar, int *gauss, int *idMds, int *idMdsVar,
71 int *idMatMds, char *comment, int *s_comment, char *mdsUvarName, int *sizeMdsUvarName,
72 int *id, int *mode)
73 {
74 char *cname, *cname2, *ccomment, *cmdsuvar;
75 int cname_len, cname_len1, ccomment_len, cmdsuvar_len;
76 int i, cpt_size, cptBlank;
77 bool isBlankVar = false;
78 float node[3];
79 H3D_ID node_id;
80 unsigned int elem_count = 1;
81
82 cname_len = *size1 + 1;
83 cname = (char *)malloc(sizeof(char) * cname_len);
84 for (i = 0; i < *size1; i++)
85 cname[i] = name1[i];
86
87 cpt_size = 0;
88 for (i = 0; i < *size1; i++)
89 {
90 if (name1[i] != ' ')
91 cpt_size = i;
92 }
93 cname[cpt_size + 1] = '\0';
94
95 ccomment_len = *s_comment + 1;
96 ccomment = (char *)malloc(sizeof(char) * ccomment_len);
97 for (i = 0; i < *s_comment; i++)
98 ccomment[i] = comment[i];
99 ccomment[*s_comment] = '\0';
100 cptBlank = 0;
101 cmdsuvar_len = *sizeMdsUvarName + 1;
102 cmdsuvar = (char *)malloc(sizeof(char) * cmdsuvar_len);
103 for (i = 0; i < *sizeMdsUvarName; i++)
104 cmdsuvar[i] = mdsUvarName[i];
105 for (i = 0; i < *sizeMdsUvarName; i++)
106 if (isblank(cmdsuvar[i]))
107 cptBlank = cptBlank + 1;
108 if (cptBlank == *sizeMdsUvarName)
109 isBlankVar = true;
110 cmdsuvar[*sizeMdsUvarName] = '\0';
111
112 char *LAYERPOOL = new char[100];
113 LAYERPOOL[0] = '\0';
114 char *LAYER_STRING = new char[100];
115 LAYER_STRING[0] = '\0';
116 char *IPT_STRING = new char[100];
117 IPT_STRING[0] = '\0';
118 char *GAUSS_STRING = new char[100];
119 GAUSS_STRING[0] = '\0';
120 char *PLY_STRING = new char[100];
121 PLY_STRING[0] = '\0';
122 char *NUVAR_STRING = new char[100];
123 NUVAR_STRING[0] = '\0';
124 char *MID_STRING = new char[100];
125 MID_STRING[0] = '\0';
126 char *RES_STRING = new char[100];
127 RES_STRING[0] = '\0';
128 char *ID_STRING = new char[100];
129 ID_STRING[0] = '\0';
130 char *MODE_STRING = new char[100];
131 MODE_STRING[0] = '\0';
132
133 H3D_ID layer_pool_id = H3D_NULL_ID;
134
135#ifdef _WIN64
136 strcat_s(RES_STRING, 100, cname);
137#else
138 RES_STRING = strcat(RES_STRING, cname);
139#endif
140
141
142 if (*idMdsVar > 0 && *idMds > 0)
143 {
144 sprintf(NUVAR_STRING, " LAW %d", *idMatMds);
145#ifdef _WIN64
146 strcat_s(RES_STRING, 100, NUVAR_STRING);
147#else
148 RES_STRING = strcat(RES_STRING, NUVAR_STRING);
149#endif
150 if (isBlankVar)
151 {
152 sprintf(NUVAR_STRING, ": _");
153#ifdef _WIN64
154 strcat_s(RES_STRING, 100, NUVAR_STRING);
155#else
156 RES_STRING = strcat(RES_STRING, NUVAR_STRING);
157#endif
158 }
159 else
160 {
161 sprintf(NUVAR_STRING, ": %s ", cmdsuvar);
162#ifdef _WIN64
163 strcat_s(RES_STRING, 100, NUVAR_STRING);
164#else
165 RES_STRING = strcat(RES_STRING, NUVAR_STRING);
166#endif
167 }
168 // a commenter pour test
169 // sprintf(NUVAR_STRING, " (%d) \0",*idMdsVar);
170 // RES_STRING = strcat(RES_STRING,NUVAR_STRING);
171 }
172 else if (*nuvar > 0)
173 {
174 sprintf(NUVAR_STRING, " %d ", *nuvar);
175#ifdef _WIN64
176 strcat_s(RES_STRING, 100, NUVAR_STRING);
177#else
178 RES_STRING = strcat(RES_STRING, NUVAR_STRING);
179#endif
180 }
181
182 // printf("String en sortie : %s \n",RES_STRING);
183 // fflush(stdout);
184
185 if (*layer > 0 || *ipt > 0 || *ply > 0 || *gauss > 0)
186 {
187
188 if (*layer > 0 && *ipt > 0)
189 {
190 sprintf(LAYER_STRING, "LAYER/IPT %d %d ", *layer, *ipt);
191#ifdef _WIN64
192 strcat_s(LAYERPOOL, 100, LAYER_STRING);
193#else
194 LAYERPOOL = strcat(LAYERPOOL, LAYER_STRING);
195#endif
196 }
197 else if (*layer > 0)
198 {
199 sprintf(LAYER_STRING, "LAYER %d ", *layer);
200#ifdef _WIN64
201 strcat_s(LAYERPOOL, 100, LAYER_STRING);
202#else
203 LAYERPOOL = strcat(LAYERPOOL, LAYER_STRING);
204#endif
205 }
206 else if (*ply > 0 && *ipt > 0)
207 {
208 sprintf(PLY_STRING, "PLY/IPT %d %d", *ply, *ipt);
209#ifdef _WIN64
210 strcat_s(LAYERPOOL, 100, PLY_STRING);
211#else
212 LAYERPOOL = strcat(LAYERPOOL, PLY_STRING);
213#endif
214 }
215 else if (*ply > 0 && *ipt == -4)
216 {
217 sprintf(PLY_STRING, "PLY/MEMB %d", *ply);
218#ifdef _WIN64
219 strcat_s(LAYERPOOL, 100, PLY_STRING);
220#else
221 LAYERPOOL = strcat(LAYERPOOL, PLY_STRING);
222#endif
223 }
224 else if (*ipt > 0)
225 {
226 sprintf(IPT_STRING, "IPT %d ", *ipt);
227#ifdef _WIN64
228 strcat_s(LAYERPOOL, 100, IPT_STRING);
229#else
230 LAYERPOOL = strcat(LAYERPOOL, IPT_STRING);
231#endif
232 }
233 else if (*ply > 0)
234 {
235 sprintf(IPT_STRING, "PLY %d ", *ply);
236#ifdef _WIN64
237 strcat_s(LAYERPOOL, 100, IPT_STRING);
238#else
239 LAYERPOOL = strcat(LAYERPOOL, IPT_STRING);
240#endif
241 }
242 }
243 else if (*layer < -1 || *ipt < -1)
244 {
245 if (*layer == -2)
246 {
247 sprintf(LAYER_STRING, "Layer Lower ");
248#ifdef _WIN64
249 strcat_s(LAYERPOOL, 100, LAYER_STRING);
250#else
251 LAYERPOOL = strcat(LAYERPOOL, LAYER_STRING);
252#endif
253 }
254 if (*layer == -3)
255 {
256 sprintf(LAYER_STRING, "Layer Upper ");
257#ifdef _WIN64
258 strcat_s(LAYERPOOL, 100, LAYER_STRING);
259#else
260 LAYERPOOL = strcat(LAYERPOOL, LAYER_STRING);
261#endif
262 }
263 if (*ipt == -2)
264 {
265 sprintf(IPT_STRING, "npt Lower ");
266#ifdef _WIN64
267 strcat_s(LAYERPOOL, 100, IPT_STRING);
268#else
269 LAYERPOOL = strcat(LAYERPOOL, IPT_STRING);
270#endif
271 }
272 if (*ipt == -3)
273 {
274 sprintf(IPT_STRING, "npt Upper ");
275#ifdef _WIN64
276 strcat_s(LAYERPOOL, 100, IPT_STRING);
277#else
278 LAYERPOOL = strcat(LAYERPOOL, IPT_STRING);
279#endif
280 }
281 if (*ipt == -4)
282 {
283 sprintf(IPT_STRING, "npt Membrane ");
284#ifdef _WIN64
285 strcat_s(LAYERPOOL, 100, IPT_STRING);
286#else
287 LAYERPOOL = strcat(LAYERPOOL, IPT_STRING);
288#endif
289 }
290 }
291 else
292 {
293 sprintf(IPT_STRING, "Mid");
294#ifdef _WIN64
295 strcat_s(LAYERPOOL, 100, IPT_STRING);
296#else
297 LAYERPOOL = strcat(LAYERPOOL, IPT_STRING);
298#endif
299 }
300 rc = Hyper3DAddString(h3d_file, LAYERPOOL, &layer_pool_id);
301
302 char edata_type[100];
303 //
304
305 // printf("String en sortie : %s %d \n",RES_STRING,*sizeMdsUvarName);
306 // fflush(stdout);
307
308 // printf("String layer : %s \n",LAYERPOOL);
309 // fflush(stdout);
310
311 // printf( "scalar %d info = %d %s\n", *cpt_data , *info1, name);
312 // fflush(stdout);
313
314 try
315 {
316 // create result data types
317 dt_count++;
318
320 if (!rc)
321 throw rc;
322
323 pool_count = 2;
324
325 dt_id++;
326#ifdef _WIN64
327 strcpy_s(edata_type, 100, RES_STRING);
328#else
329 strcpy(edata_type, RES_STRING);
330#endif
331 rc = Hyper3DDatatypeWrite(h3d_file, edata_type, *cpt_data, H3D_DS_SCALAR,
332 H3D_DS_ELEM, pool_count);
333 if (!rc)
334 throw rc;
335
336 if (strlen(ccomment) != 0)
337 {
338 rc = Hyper3DDatatypeDescriptionWrite(h3d_file, *cpt_data, ccomment);
339 if (!rc)
340 throw rc;
341 }
342
344 &layer_pool_id, has_corners, tensor_type, poisson);
345 if (!rc)
346 throw rc;
347
349 &layer_pool_id, has_corners, tensor_type, poisson);
350 if (!rc)
351 throw rc;
352
354 if (!rc)
355 throw rc;
356
357 } // end of try
358
359 catch (...)
360 {
362 }
363
364 delete[] LAYERPOOL;
365 delete[] LAYER_STRING;
366 delete[] IPT_STRING;
367 delete[] GAUSS_STRING;
368 delete[] PLY_STRING;
369 delete[] NUVAR_STRING;
370 delete[] MID_STRING;
371 delete[] RES_STRING;
372 delete[] MODE_STRING;
373 free(cname);
374 free(ccomment);
375 free(cmdsuvar);
376 }
377
378 void _FCALL C_H3D_CREATE_SHELL_SCALAR_DATATYPE(int *cpt_data, char *name1, int *size1, int *info1, int *info2, char *name2, int *size2,
379 int *layer, int *ipt, int *ply, int *nuvar, int *gauss, int *idMds, int *idMdsVar, int *idMatMds,
380 char *comment, int *s_comment, char *mdsUvarName, int *sizeMdsUvarName, int *id, int *mode)
381 {
382 c_h3d_create_shell_scalar_datatype_(cpt_data, name1, size1, info1, info2, name2, size2, layer, ipt, ply, nuvar, gauss, idMds, idMdsVar, idMatMds, comment, s_comment,
383 mdsUvarName, sizeMdsUvarName, id, mode);
384 }
385
386 void c_h3d_create_shell_scalar_datatype__(int *cpt_data, char *name1, int *size1, int *info1, int *info2, char *name2, int *size2,
387 int *layer, int *ipt, int *ply, int *nuvar, int *gauss, int *idMds, int *idMdsVar, int *idMatMds,
388 char *comment, int *s_comment, char *mdsUvarName, int *sizeMdsUvarName, int *id, int *mode)
389 {
390 c_h3d_create_shell_scalar_datatype_(cpt_data, name1, size1, info1, info2, name2, size2, layer, ipt, ply, nuvar, gauss, idMds, idMdsVar, idMatMds, comment, s_comment,
391 mdsUvarName, sizeMdsUvarName, id, mode);
392 }
393
394 void c_create_shell_scalar_datatype(int *cpt_data, char *name1, int *size1, int *info1, int *info2, char *name2, int *size2,
395 int *layer, int *ipt, int *ply, int *nuvar, int *gauss, int *idMds, int *idMdsVar, int *idMatMds,
396 char *comment, int *s_comment, char *mdsUvarName, int *sizeMdsUvarName, int *id, int *mode)
397 {
398 c_h3d_create_shell_scalar_datatype_(cpt_data, name1, size1, info1, info2, name2, size2, layer, ipt, ply, nuvar, gauss, idMds, idMdsVar, idMatMds, comment, s_comment,
399 mdsUvarName, sizeMdsUvarName, id, mode);
400 }
401}
void _FCALL C_H3D_CREATE_SHELL_SCALAR_DATATYPE(int *cpt_data, char *name1, int *size1, int *info1, int *info2, char *name2, int *size2, int *layer, int *ipt, int *ply, int *nuvar, int *gauss, int *idMds, int *idMdsVar, int *idMatMds, char *comment, int *s_comment, char *mdsUvarName, int *sizeMdsUvarName, int *id, int *mode)
void c_create_shell_scalar_datatype(int *cpt_data, char *name1, int *size1, int *info1, int *info2, char *name2, int *size2, int *layer, int *ipt, int *ply, int *nuvar, int *gauss, int *idMds, int *idMdsVar, int *idMatMds, char *comment, int *s_comment, char *mdsUvarName, int *sizeMdsUvarName, int *id, int *mode)
void c_h3d_create_shell_scalar_datatype__(int *cpt_data, char *name1, int *size1, int *info1, int *info2, char *name2, int *size2, int *layer, int *ipt, int *ply, int *nuvar, int *gauss, int *idMds, int *idMdsVar, int *idMatMds, char *comment, int *s_comment, char *mdsUvarName, int *sizeMdsUvarName, int *id, int *mode)
void c_h3d_create_shell_scalar_datatype_(int *cpt_data, char *name1, int *size1, int *info1, int *info2, char *name2, int *size2, int *layer, int *ipt, int *ply, int *nuvar, int *gauss, int *idMds, int *idMdsVar, int *idMatMds, char *comment, int *s_comment, char *mdsUvarName, int *sizeMdsUvarName, int *id, int *mode)
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 dt_id
char edata_type[50]
H3D_TENSOR_TYPE tensor_type
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 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
#define _FCALL