OpenRadioss 2025.1.11
OpenRadioss project
Loading...
Searching...
No Matches
c_h3d_create_nodal_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_NODAL_SCALAR_DATATYPE */
69/*=================================================================*/
70
71void c_h3d_create_nodal_scalar_datatype_(int *cpt_data, char *name, int *size, int *info, char *name1, int *size1, int *INTER_ID,
72 char *comment, int *s_comment)
73{
74 char *cname,*cname1,*ccomment;
75 int cname_len,cname_len1,ccomment_len;
76 int i;
77 float node[3];
78 H3D_ID node_id;
79 unsigned int elem_count = 1;
80 char* edata_type;
81
82 char * CH_INTER_ID = new char [100];
83 CH_INTER_ID[0] ='\0';
84
85 cname_len = *size + 10;
86 cname=(char*) malloc(sizeof(char)*cname_len);
87 for(i=0;i<*size;i++) cname[i] = name[i];
88 cname[*size]='\0';
89
90
91 cname_len1 = *size1 + 1;
92 cname1=(char*) malloc(sizeof(char)*cname_len1);
93 for(i=0;i<*size1;i++) cname1[i] = name1[i];
94 cname1[*size1]='\0';
95
96 ccomment_len = *s_comment + 1;
97 ccomment=(char*) malloc(sizeof(char)*ccomment_len);
98 for(i=0;i<*s_comment;i++) ccomment[i] = comment[i];
99 ccomment[*s_comment]='\0';
100
101 char * LAYERPOOL = new char [*size1+11];
102 sprintf(LAYERPOOL, "%s %d" ,cname1,*info);
103 H3D_ID layer_pool_id = H3D_NULL_ID;
104 rc = Hyper3DAddString(h3d_file, LAYERPOOL, &layer_pool_id);
105
106//
107
108// printf( "scalar %d info = %d %s\n", *cpt_data , *info, cname);
109// fflush(stdout);
110
111 try {
112 // create result data types
113 dt_count++;
114
116 if( !rc ) throw rc;
117
118 pool_count = 2;
119
120 dt_id++;
121 if (*INTER_ID != 0)
122 {
123 sprintf(CH_INTER_ID, " %d",*INTER_ID );
124#ifdef _WIN64
125 strcat_s(cname,cname_len,CH_INTER_ID);
126#else
127 cname = strcat(cname,CH_INTER_ID);
128#endif
129 }
130 edata_type=(char*)malloc(sizeof(char)*(strlen(cname)+1));
131
132#ifdef _WIN64
133 strcpy_s(edata_type,strlen(cname)+1,cname);
134#else
135 strcpy(edata_type,cname);
136#endif
137
138 rc = Hyper3DDatatypeWrite(h3d_file, edata_type, *cpt_data , H3D_DS_SCALAR,
139 H3D_DS_NODE, pool_count);
140
141 free(edata_type);
142
143 if( !rc ) throw rc;
144
145 if (strlen(ccomment) != 0)
146 {
147 rc = Hyper3DDatatypeDescriptionWrite(h3d_file, *cpt_data, ccomment);
148 if( !rc ) throw rc;
149 }
150
151 if(*info != 0 && *cpt_data != 0)
152 {
154 &layer_pool_id, has_corners, tensor_type, poisson);
155 if( !rc ) throw rc;
156
157 }
158 else if (*cpt_data != 0)
159 {
162 if( !rc ) throw rc;
163
164 }
165
167 if( !rc ) throw rc;
168
169 } // end of try
170
171 catch(...) {
173 }
174 delete [] LAYERPOOL;
175 delete [] CH_INTER_ID;
176 free(cname);
177 free(cname1);
178 free(ccomment);
179
180}
181
182
183
184
185void _FCALL C_H3D_CREATE_NODAL_SCALAR_DATATYPE(int *cpt_data, char *name, int *size, int *info, char *name1, int *size1, int *inter_id,
186 char *comment, int *s_comment)
187{c_h3d_create_nodal_scalar_datatype_ (cpt_data, name, size, info, name1, size1, inter_id, comment, s_comment);}
188
189void c_h3d_create_nodal_scalar_datatype__ (int *cpt_data, char *name, int *size, int *info, char *name1, int *size1, int *inter_id,
190 char *comment, int *s_comment)
191{c_h3d_create_nodal_scalar_datatype_ (cpt_data, name, size, info, name1, size1, inter_id, comment, s_comment);}
192
193void c_create_nodal_scalar_datatype (int *cpt_data, char *name, int *size, int *info, char *name1, int *size1, int *inter_id,
194 char *comment, int *s_comment)
195{c_h3d_create_nodal_scalar_datatype_ (cpt_data, name, size, info, name1, size1, inter_id, comment, s_comment);}
196
197}
void _FCALL C_H3D_CREATE_NODAL_SCALAR_DATATYPE(int *cpt_data, char *name, int *size, int *info, char *name1, int *size1, int *inter_id, char *comment, int *s_comment)
void c_h3d_create_nodal_scalar_datatype_(int *cpt_data, char *name, int *size, int *info, char *name1, int *size1, int *INTER_ID, char *comment, int *s_comment)
void c_create_nodal_scalar_datatype(int *cpt_data, char *name, int *size, int *info, char *name1, int *size1, int *inter_id, char *comment, int *s_comment)
void c_h3d_create_nodal_scalar_datatype__(int *cpt_data, char *name, int *size, int *info, char *name1, int *size1, int *inter_id, char *comment, int *s_comment)
H3DFileInfo * h3d_file
unsigned int pool_count
unsigned int dt_count
bool has_corners
H3D_ID node_poolname_id
bool rc
float poisson
H3D_ID * layername_ids
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