OpenRadioss 2025.1.11
OpenRadioss project
Loading...
Searching...
No Matches
c_h3d_update_nodes.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
76/*=================================================================*/
77/* C_H3D_UPDATE_H3DFILE_NODES */
78/*=================================================================*/
79
80void c_h3d_update_nodes_(char *name, int *size, my_real *TT,int *IH3D, int *ITAB, int *NUMNOD, my_real *D, int *NRWALL, int *MAX_NOD_ID,
81 my_real *XWL, my_real *YWL, my_real *ZWL, my_real *V1, my_real *V2, my_real *V3,
82 my_real *VV1, my_real *VV2, my_real *VV3, int *KXSP, int *NISP, int *NUMSPH, int *TAGNOD, int *NPRW)
83{
84 char *cname;
85 int cname_len;
86 int i;
87 float time = (float) *TT;
88 float node[3];
89 H3D_ID node_id;
90 unsigned int elem_count = 1;
91//
92 cname_len = *size + 1;
93 cname=(char*) malloc(sizeof(char)*cname_len);
94 for(i=0;i<*size;i++) cname[i] = name[i];
95 cname[*size]='\0';
96//
97 // initialize
98
99 try {
100 // create Subcase (Loadcase)
101 unsigned int max_sims = 10;
102 unsigned int sub_count = 1;
103
104 // create Simulations
105 H3D_SIM_IDX sim_idx;
107 if( !rc ) throw rc;
108 sim_idx=*IH3D;
109 char name[32];
110 sprintf(name,"Time = %f",time);
111
112 if(*size != 0) rc = Hyper3DSimulationWrite(h3d_file, sim_idx, cname,time);
113 if(*size == 0) rc = Hyper3DSimulationWrite(h3d_file, sim_idx, name,time);
114 if( !rc ) throw rc;
115
117 if( !rc ) throw rc;
118
119 // create Result Data sets
120 unsigned int num_corners = 0;
121 unsigned int num_modes = 0;
122 bool complex = false;
123
124 H3D_ID dt_id = 2; // the displacement data type
125 sim_idx = *IH3D;
126 if( *NUMNOD != 0)
127 {
128 rc = Hyper3DDatasetBegin(h3d_file, *NUMNOD , sim_idx, subcase_id, H3D_DS_NODE,
129 H3D_DS_VECTOR, num_corners, num_modes, dt_id,
130 H3D_DS_NO_LAYER, node_poolname_id, complex);
131 if( !rc ) throw rc;
132
133 for( i = 0; i < *NUMNOD; i++ ) {
134 if( TAGNOD[i] == 1 )
135 {
136 node[0] = D[3*i ];
137 node[1] = D[3*i + 1];
138 node[2] = D[3*i + 2];
139 node_id = ITAB[i];
140 if (node_id != 0 ) rc = Hyper3DDatasetWrite(h3d_file, node_id, node);
141 if( !rc ) throw rc;
142 }
143 }
144
146 if( !rc ) throw rc;
147
148 node_id = *MAX_NOD_ID;
149
150 for(i = 0 ; i< *NRWALL; i++ )
151 {
152 int ityp = NPRW[i + *NRWALL*3];
153
154 if( ityp == 1 || ityp == 4)
155 {
156
157 rc = Hyper3DDatasetBegin(h3d_file, 4 , sim_idx, subcase_id, H3D_DS_NODE,
158 H3D_DS_VECTOR, num_corners, num_modes, dt_id,
159 H3D_DS_NO_LAYER, node_poolname_id, complex);
160
161 node[0] = XWL[i] + V1[i];
162 node[1] = YWL[i] + V2[i];
163 node[2] = ZWL[i] + V3[i];
164 node_id = node_id + 1 ;
165
166 rc = Hyper3DDatasetWrite(h3d_file, node_id, node);
167 if( !rc ) throw rc;
168
169
170 node[0] = XWL[i] + VV1[i];
171 node[1] = YWL[i] + VV2[i];
172 node[2] = ZWL[i] + VV3[i];
173 node_id = node_id + 1 ;
174
175 rc = Hyper3DDatasetWrite(h3d_file, node_id, node);
176 if( !rc ) throw rc;
177
178 node[0] = XWL[i] - V1[i];
179 node[1] = YWL[i] - V2[i];
180 node[2] = ZWL[i] - V3[i];
181 node_id = node_id + 1 ;
182
183 rc = Hyper3DDatasetWrite(h3d_file, node_id, node);
184 if( !rc ) throw rc;
185
186 node[0] = XWL[i] - VV1[i];
187 node[1] = YWL[i] - VV2[i];
188 node[2] = ZWL[i] - VV3[i];
189 node_id = node_id + 1 ;
190
191 rc = Hyper3DDatasetWrite(h3d_file, node_id, node);
192 if( !rc ) throw rc;
193
195 if( !rc ) throw rc;
196 }
197 else if(ityp == 2)
198 {
199 rc = Hyper3DDatasetBegin(h3d_file, 48 , sim_idx, subcase_id, H3D_DS_NODE,
200 H3D_DS_VECTOR, num_corners, num_modes, dt_id,
201 H3D_DS_NO_LAYER, node_poolname_id, complex);
202 for(int ii=0;ii<48;ii++)
203 {
204 node[0] = XWL[i] + V1[i];
205 node[1] = YWL[i] + V2[i];
206 node[2] = ZWL[i] + V3[i];
207 node_id = node_id + 1 ;
208
209 rc = Hyper3DDatasetWrite(h3d_file, node_id, node);
210 if( !rc ) throw rc;
211 }
212
214 if( !rc ) throw rc;
215
216 }
217
218 else if(ityp == 3)
219 {
220 rc = Hyper3DDatasetBegin(h3d_file, 294 , sim_idx, subcase_id, H3D_DS_NODE,
221 H3D_DS_VECTOR, num_corners, num_modes, dt_id,
222 H3D_DS_NO_LAYER, node_poolname_id, complex);
223 for(int ii=0;ii<294;ii++)
224 {
225 node[0] = XWL[i] + V1[i];
226 node[1] = YWL[i] + V2[i];
227 node[2] = ZWL[i] + V3[i];
228 node_id = node_id + 1 ;
229
230 rc = Hyper3DDatasetWrite(h3d_file, node_id, node);
231 if( !rc ) throw rc;
232 }
233
235 if( !rc ) throw rc;
236
237 }
238
239 }
240 }
241
242 } // end of try
243
244 catch(...) {
246 }
247}
248
249void _FCALL C_H3D_UPDATE_NODES(char *name, int *size, my_real *TT, int *IH3D, int *ITAB, int *NUMNOD, my_real *D, int *NRWALL, int *MAX_NOD_ID,
250 my_real *XWL, my_real *YWL , my_real *ZWL, my_real *V1, my_real *V2, my_real *V3,
251 my_real *VV1, my_real *VV2 , my_real *VV3, int *KXSP, int *NISP, int *NUMSPH, int *TAGNOD, int *NPRW)
252{c_h3d_update_nodes_ (name,size,TT,IH3D,ITAB,NUMNOD,D, NRWALL, MAX_NOD_ID,
253 XWL, YWL, ZWL, V1, V2, V3, VV1, VV2 , VV3, KXSP, NISP, NUMSPH, TAGNOD, NPRW);}
254
255void c_h3d_update_nodes__ (char *name, int *size, my_real *TT, int *IH3D, int *ITAB, int *NUMNOD, my_real *D, int *NRWALL, int *MAX_NOD_ID,
256 my_real *XWL, my_real *YWL , my_real *ZWL, my_real *V1, my_real *V2, my_real *V3,
257 my_real *VV1, my_real *VV2 , my_real *VV3, int *KXSP, int *NISP, int *NUMSPH, int *TAGNOD, int *NPRW )
258{c_h3d_update_nodes_ (name,size,TT,IH3D,ITAB,NUMNOD,D, NRWALL, MAX_NOD_ID,
259 XWL, YWL, ZWL, V1, V2, V3, VV1, VV2 , VV3, KXSP, NISP, NUMSPH, TAGNOD, NPRW);}
260
261void c_h3d_update_h3dfile_nodes (char *name, int *size, my_real *TT, int *IH3D, int *ITAB, int *NUMNOD, my_real *D, int *NRWALL, int *MAX_NOD_ID,
262 my_real *XWL, my_real *YWL , my_real *ZWL, my_real *V1, my_real *V2, my_real *V3,
263 my_real *VV1, my_real *VV2 , my_real *VV3, int *KXSP, int *NISP, int *NUMSPH, int *TAGNOD, int *NPRW )
264{c_h3d_update_nodes_ (name,size,TT,IH3D,ITAB,NUMNOD,D, NRWALL, MAX_NOD_ID,
265 XWL, YWL, ZWL, V1, V2, V3, VV1, VV2 , VV3, KXSP, NISP, NUMSPH, TAGNOD, NPRW);}
266
267}
H3DFileInfo * h3d_file
H3D_ID node_poolname_id
bool rc
H3D_SIM_IDX sim_idx
H3D_ID subcase_id
H3D_ID dt_id
void c_h3d_update_nodes__(char *name, int *size, my_real *TT, int *IH3D, int *ITAB, int *NUMNOD, my_real *D, int *NRWALL, int *MAX_NOD_ID, my_real *XWL, my_real *YWL, my_real *ZWL, my_real *V1, my_real *V2, my_real *V3, my_real *VV1, my_real *VV2, my_real *VV3, int *KXSP, int *NISP, int *NUMSPH, int *TAGNOD, int *NPRW)
void _FCALL C_H3D_UPDATE_NODES(char *name, int *size, my_real *TT, int *IH3D, int *ITAB, int *NUMNOD, my_real *D, int *NRWALL, int *MAX_NOD_ID, my_real *XWL, my_real *YWL, my_real *ZWL, my_real *V1, my_real *V2, my_real *V3, my_real *VV1, my_real *VV2, my_real *VV3, int *KXSP, int *NISP, int *NUMSPH, int *TAGNOD, int *NPRW)
void c_h3d_update_h3dfile_nodes(char *name, int *size, my_real *TT, int *IH3D, int *ITAB, int *NUMNOD, my_real *D, int *NRWALL, int *MAX_NOD_ID, my_real *XWL, my_real *YWL, my_real *ZWL, my_real *V1, my_real *V2, my_real *V3, my_real *VV1, my_real *VV2, my_real *VV3, int *KXSP, int *NISP, int *NUMSPH, int *TAGNOD, int *NPRW)
void c_h3d_update_nodes_(char *name, int *size, my_real *TT, int *IH3D, int *ITAB, int *NUMNOD, my_real *D, int *NRWALL, int *MAX_NOD_ID, my_real *XWL, my_real *YWL, my_real *ZWL, my_real *V1, my_real *V2, my_real *V3, my_real *VV1, my_real *VV2, my_real *VV3, int *KXSP, int *NISP, int *NUMSPH, int *TAGNOD, int *NPRW)
#define my_real
Definition cppsort.cpp:32
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 Hyper3DSimulationWrite(H3DFileInfo *h3d_file, H3D_SIM_IDX idx, const char *label, float syncValue)
Definition h3d_dl.c:1292
bool Hyper3DExportClearError(H3DFileInfo *h3d_file)
Definition h3d_dl.c:939
bool Hyper3DDatasetEnd(H3DFileInfo *h3d_file)
Definition h3d_dl.c:1400
bool Hyper3DSimulationEnd(H3DFileInfo *h3d_file)
Definition h3d_dl.c:1299
bool Hyper3DSimulationBegin(H3DFileInfo *h3d_file, unsigned int count, H3D_ID subcase_id)
Definition h3d_dl.c:1285
bool Hyper3DDatasetWrite(H3DFileInfo *h3d_file, H3D_ID id, const float *data)
Definition h3d_dl.c:1372
#define _FCALL