OpenRadioss 2025.1.11
OpenRadioss project
Loading...
Searching...
No Matches
c_h3d_create_sph_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
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
63extern "C"
64/*=================================================================*/
65{
66
67/*=================================================================*/
68/* C_H3D_CREATE_sph_SCALAR_DATATYPE */
69/*=================================================================*/
70
71void c_h3d_create_sph_scalar_datatype_(int *cpt_data, char *name1, int *size1, int *info, char *name2, int *size2, int *nuvar,
72 char *comment, int *s_comment, int *id, int *mode)
73{
74 char *cname,*cname2,*ccomment;
75 int cname_len,cname_len1,ccomment_len;
76 int i,cpt_size;
77 float node[3];
78 H3D_ID node_id;
79 unsigned int elem_count = 1;
80
81 cname_len = *size1 + 1;
82 cname=(char*) malloc(sizeof(char)*cname_len);
83 for(i=0;i<*size1;i++) cname[i] = name1[i];
84
85 cpt_size = 0;
86 for(i=0;i<*size1;i++)
87 {
88 if(name1[i] != ' ') cpt_size = i;
89 }
90 cname[cpt_size+1]='\0';
91
92 ccomment_len = *s_comment + 1;
93 ccomment=(char*) malloc(sizeof(char)*ccomment_len);
94 for(i=0;i<*s_comment;i++) ccomment[i] = comment[i];
95 ccomment[*s_comment]='\0';
96
97 char * LAYERPOOL = new char [100];
98 LAYERPOOL[0] ='\0';
99 char * LAYER_STRING = new char [100];
100 LAYER_STRING[0] ='\0';
101 char * NUVAR_STRING = new char [100];
102 NUVAR_STRING[0] ='\0';
103 char * IR_STRING = new char [100];
104 IR_STRING[0] ='\0';
105 char * IS_STRING = new char [100];
106 IS_STRING[0] ='\0';
107 char * IT_STRING = new char [100];
108 IT_STRING[0] ='\0';
109 char * MID_STRING = new char [100];
110 MID_STRING[0] ='\0';
111 char * RES_STRING = new char [100];
112 RES_STRING[0] ='\0';
113 char * ID_STRING = new char [100];
114 ID_STRING[0] ='\0';
115 char *MODE_STRING = new char[100];
116 ID_STRING[0] = '\0';
117
118 H3D_ID layer_pool_id = H3D_NULL_ID;
119
120
121#ifdef _WIN64
122 strcat_s(RES_STRING,100,cname);
123#else
124 RES_STRING = strcat(RES_STRING,cname);
125#endif
126 if(*nuvar > 0)
127 {
128 sprintf(NUVAR_STRING, " %d ",*nuvar);
129#ifdef _WIN64
130 strcat_s(RES_STRING,100,NUVAR_STRING);
131#else
132 RES_STRING = strcat(RES_STRING,NUVAR_STRING);
133#endif
134 }
135
136
137 char edata_type[100];
138//
139
140 //printf( "scalar %d info = %d %s\n", *cpt_data , *info1, name);
141 //fflush(stdout);
142
143 try {
144 // create result data types
145 dt_count++;
146
148 if( !rc ) throw rc;
149
150 pool_count = 2;
151
152 dt_id++;
153 sprintf(edata_type, RES_STRING, H3D_DT_DELIMITER);
154
155 rc = Hyper3DDatatypeWrite(h3d_file, edata_type, *cpt_data , H3D_DS_SCALAR,
156 H3D_DS_ELEM, pool_count);
157 if( !rc ) throw rc;
158
159 if (strlen(ccomment) != 0)
160 {
161 rc = Hyper3DDatatypeDescriptionWrite(h3d_file, *cpt_data, ccomment);
162 if( !rc ) throw rc;
163 }
164
167 if( !rc ) throw rc;
168
171 if( !rc ) throw rc;
172
174 if( !rc ) throw rc;
175
176 } // end of try
177
178 catch(...) {
180 }
181 delete [] LAYERPOOL;
182 delete [] LAYER_STRING;
183 delete [] NUVAR_STRING;
184 delete [] IR_STRING;
185 delete [] IS_STRING;
186 delete [] IT_STRING;
187 delete [] MID_STRING;
188 delete [] RES_STRING;
189 delete [] MODE_STRING;
190 free(cname);
191 free(ccomment);
192
193}
194
195
196
197void _FCALL C_H3D_CREATE_SPH_SCALAR_DATATYPE(int *cpt_data, char *name1, int *size1, int *info, char *name2, int *size2, int *nuvar,
198 char *comment, int *s_comment, int *id, int *mode)
199{c_h3d_create_sph_scalar_datatype_ (cpt_data, name1, size1, info, name2, size2, nuvar, comment, s_comment, id, mode);}
200
201void c_h3d_create_sph_scalar_datatype__ (int *cpt_data, char *name1, int *size1, int *info, char *name2, int *size2, int *nuvar,
202 char *comment, int *s_comment, int *id, int *mode)
203{c_h3d_create_sph_scalar_datatype_ (cpt_data, name1, size1, info, name2, size2, nuvar, comment, s_comment, id, mode);}
204
205void c_create_sph_scalar_datatype (int *cpt_data, char *name1, int *size1, int *info, char *name2, int *size2, int *nuvar,
206 char *comment, int *s_comment, int *id, int *mode)
207{c_h3d_create_sph_scalar_datatype_ (cpt_data, name1, size1, info, name2, size2, nuvar, comment, s_comment, id, mode);}
208}
void c_h3d_create_sph_scalar_datatype_(int *cpt_data, char *name1, int *size1, int *info, char *name2, int *size2, int *nuvar, char *comment, int *s_comment, int *id, int *mode)
void _FCALL C_H3D_CREATE_SPH_SCALAR_DATATYPE(int *cpt_data, char *name1, int *size1, int *info, char *name2, int *size2, int *nuvar, char *comment, int *s_comment, int *id, int *mode)
void c_create_sph_scalar_datatype(int *cpt_data, char *name1, int *size1, int *info, char *name2, int *size2, int *nuvar, char *comment, int *s_comment, int *id, int *mode)
void c_h3d_create_sph_scalar_datatype__(int *cpt_data, char *name1, int *size1, int *info, char *name2, int *size2, int *nuvar, char *comment, int *s_comment, int *id, int *mode)
H3DFileInfo * h3d_file
unsigned int pool_count
unsigned int dt_count
bool has_corners
bool rc
float poisson
H3D_ID * layername_ids
H3D_ID sphcell_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 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