OpenRadioss 2025.1.11
OpenRadioss project
Loading...
Searching...
No Matches
c_h3d_update_oned_tensor.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/*=================================================================*/
78/* C_H3D_UPDATE_H3DFILE_ONED_TENSOR */
79/*=================================================================*/
80
81void c_h3d_update_oned_tensor_(my_real *TT,int *IH3D, int *ITAB, int *NUMELT, int *NUMELP, int *NUMELR,
82 my_real *FUNC ,int *ID_ELEM,int *CPT_DATATYPE, int *ITY_ELEM, int *IS_WRITTEN)
83{
84 int i;
85 int offset;
86 H3D_ID elem_id;
87 H3D_ID comp_id;
88//
89 // initialize
90
91 try {
92 // create Subcase (Loadcase)
93 unsigned int max_sims = 10;
94 unsigned int sub_count = 1;
95 float elem_result[6] = { 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f };
96
97 // create Result Data sets
98 unsigned int num_corners = 0;
99 unsigned int num_modes = 0;
100 bool complex = false;
101 float value[1] ;
102
103 sim_idx = *IH3D;
104
105 char TRUSSPOOL[] = "TRUSS";
107 if( !rc ) throw rc;
108
109 char BEAMPOOL[] = "BEAM";
111 if( !rc ) throw rc;
112
113 char SPRINGPOOL[] = "SPRING";
115 if( !rc ) throw rc;
116
117
118
119 if( *NUMELT != 0)
120 {
121
122 rc = Hyper3DDatasetBegin(h3d_file, *NUMELT, sim_idx, subcase_id, H3D_DS_ELEM,
123 H3D_DS_TENSOR3D, num_corners, num_modes, *CPT_DATATYPE,
125 if( !rc ) throw rc;
126
127 offset = 0;
128
129 for( i = 0; i < *NUMELT + *NUMELP + *NUMELR; i++ )
130 {
131 if( ITY_ELEM[i] == 4 && IS_WRITTEN[i] == 1)
132 {
133 elem_id = ID_ELEM[i];
134 elem_result[0] = FUNC[6*i];
135 elem_result[1] = FUNC[6*i+1];
136 elem_result[2] = FUNC[6*i+2];
137 elem_result[3] = FUNC[6*i+3];
138 elem_result[4] = FUNC[6*i+4];
139 elem_result[5] = FUNC[6*i+5];
140 rc = Hyper3DDatasetWrite(h3d_file, elem_id, &elem_result[0]);
141 }
142 }
143
145 if( !rc ) throw rc;
146 }
147
148 if( *NUMELP != 0)
149 {
150
151 rc = Hyper3DDatasetBegin(h3d_file, *NUMELP, sim_idx, subcase_id, H3D_DS_ELEM,
152 H3D_DS_TENSOR3D, num_corners, num_modes, *CPT_DATATYPE,
154 if( !rc ) throw rc;
155
156 for( i = 0; i < *NUMELT + *NUMELP + *NUMELR; i++ )
157 {
158 if( ITY_ELEM[i] == 5 && IS_WRITTEN[i] == 1)
159 {
160 elem_id = ID_ELEM[i];
161 elem_result[0] = FUNC[6*i];
162 elem_result[1] = FUNC[6*i+1];
163 elem_result[2] = FUNC[6*i+2];
164 elem_result[3] = FUNC[6*i+3];
165 elem_result[4] = FUNC[6*i+4];
166 elem_result[5] = FUNC[6*i+5];
167 rc = Hyper3DDatasetWrite(h3d_file, elem_id, &elem_result[0]);
168 }
169 }
171 if( !rc ) throw rc;
172 }
173
174 if( *NUMELR != 0)
175 {
176
177 rc = Hyper3DDatasetBegin(h3d_file, *NUMELR, sim_idx, subcase_id, H3D_DS_ELEM,
178 H3D_DS_TENSOR3D, num_corners, num_modes, *CPT_DATATYPE,
180 if( !rc ) throw rc;
181
182 for( i = 0; i < *NUMELT + *NUMELP + *NUMELR; i++ )
183 {
184 if( ITY_ELEM[i] == 6 && IS_WRITTEN[i] == 1)
185 {
186 elem_id = ID_ELEM[i];
187 elem_result[0] = FUNC[6*i];
188 elem_result[1] = FUNC[6*i+1];
189 elem_result[2] = FUNC[6*i+2];
190 elem_result[3] = FUNC[6*i+3];
191 elem_result[4] = FUNC[6*i+4];
192 elem_result[5] = FUNC[6*i+5];
193 rc = Hyper3DDatasetWrite(h3d_file, elem_id, &elem_result[0]);
194 }
195 }
197 if( !rc ) throw rc;
198 }
199
200 } // end of try
201
202 catch(...) {
204 }
205}
206
207void _FCALL C_H3D_UPDATE_ONED_TENSOR(my_real *TT,int *IH3D, int *ITAB, int *NUMELT, int *NUMELP, int *NUMELR,
208 my_real *FUNC ,int *ID_ELEM,int *CPT_DATATYPE, int *ITY_ELEM, int *IS_WRITTEN)
209{c_h3d_update_oned_tensor_ (TT,IH3D,ITAB,NUMELT,NUMELP,NUMELR,FUNC,ID_ELEM,CPT_DATATYPE,ITY_ELEM,IS_WRITTEN);}
210
211void c_h3d_update_oned_tensor__ (my_real *TT,int *IH3D, int *ITAB, int *NUMELT, int *NUMELP, int *NUMELR,
212 my_real *FUNC ,int *ID_ELEM,int *CPT_DATATYPE, int *ITY_ELEM, int *IS_WRITTEN)
213{c_h3d_update_oned_tensor_ (TT,IH3D,ITAB,NUMELT,NUMELP,NUMELR,FUNC,ID_ELEM,CPT_DATATYPE,ITY_ELEM,IS_WRITTEN);}
214
215void c_h3d_update_oned_tensor (my_real *TT,int *IH3D, int *ITAB, int *NUMELT, int *NUMELP, int *NUMELR,
216 my_real *FUNC ,int *ID_ELEM,int *CPT_DATATYPE, int *ITY_ELEM, int *IS_WRITTEN)
217{c_h3d_update_oned_tensor_ (TT,IH3D,ITAB,NUMELT,NUMELP,NUMELR,FUNC,ID_ELEM,CPT_DATATYPE,ITY_ELEM,IS_WRITTEN);}
218
219}
H3DFileInfo * h3d_file
bool rc
H3D_ID spring_poolname_id
H3D_ID beam_poolname_id
H3D_ID comp_id
H3D_SIM_IDX sim_idx
H3D_ID subcase_id
H3D_ID truss_poolname_id
void _FCALL C_H3D_UPDATE_ONED_TENSOR(my_real *TT, int *IH3D, int *ITAB, int *NUMELT, int *NUMELP, int *NUMELR, my_real *FUNC, int *ID_ELEM, int *CPT_DATATYPE, int *ITY_ELEM, int *IS_WRITTEN)
void c_h3d_update_oned_tensor_(my_real *TT, int *IH3D, int *ITAB, int *NUMELT, int *NUMELP, int *NUMELR, my_real *FUNC, int *ID_ELEM, int *CPT_DATATYPE, int *ITY_ELEM, int *IS_WRITTEN)
void c_h3d_update_oned_tensor(my_real *TT, int *IH3D, int *ITAB, int *NUMELT, int *NUMELP, int *NUMELR, my_real *FUNC, int *ID_ELEM, int *CPT_DATATYPE, int *ITY_ELEM, int *IS_WRITTEN)
void c_h3d_update_oned_tensor__(my_real *TT, int *IH3D, int *ITAB, int *NUMELT, int *NUMELP, int *NUMELR, my_real *FUNC, int *ID_ELEM, int *CPT_DATATYPE, int *ITY_ELEM, int *IS_WRITTEN)
#define FUNC
Definition clamov.c:8
#define my_real
Definition cppsort.cpp:32
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 Hyper3DExportClearError(H3DFileInfo *h3d_file)
Definition h3d_dl.c:939
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