FiberBundleHDF5  FiberHDF5 Documentation, Revision 2026
High-Performance Fiber Bundle Data Model for Scientific Visualization
Loading...
Searching...
No Matches
F5particles.c
Go to the documentation of this file.
1#include "F5particles.h"
2#include "F5B.h"
3#include "F5R.h"
4#include "F5F.h"
5#include "F5X.h"
6#include "F5Fmeta.h"
7
8#include "F5defs.h"
9#include "F5Bchart.h"
10#include "F5L.h"
11#include "F5private.h"
12
13#include <stdarg.h>
14#include <assert.h>
15
16F5ErrorCode F5write_particle_positions(hid_t File_id, double time,
17 const char*gridname,
18 const F5_vec3_point_t*Coords, int nCoords,
19 const char*coordinate_system)
20{
21F5Path*f = F5Rcreate_cartesian_nD(File_id, time, gridname, 0, coordinate_system);
22 assert(f);
23
25
26 F5close(f);
27
28 return rv;
29}
30
31
32/** Creates a grid object of a point cloud (vertices) and additional fields.
33 Additional fields can be added in the ellipses ( ... ) by specifying
34 the field name, the data type and the pointer to the data array:
35 e.g.: ( ... ,"Velocity", F5T_VEC3_FLOAT, V,
36 ,"Acceleration", F5T_VEC3_FLOAT, A, ... )
37*/
38int F5write_particle_cartesian3Dv(hid_t File_id, double time, const char*gridname,
39 const F5_vec3_point_t*Coords, int nCoords,
40 const char*coordinate_system,
41 ...)
42{
43const char* fieldname;
44hid_t fieldtype;
45const void* dataPtr;
46va_list vl;
47int NumOfWrittenFields = 0;
48 //const char* unittype;
49
50 /* Create the Field */
51F5Path*f = F5Rcreate_cartesian_nD(File_id, time, gridname, 0, coordinate_system);
52
53 assert(f);
54
55hid_t creator_hid = H5Pcreate(H5P_DATASET_CREATE);
57
58 F5printf(20, "F5write_particle_cartesian3Dv(): write positional information");
59
60 rv = F5Fwrite_1D( f, FIBER_HDF5_POSITIONS_STRING, nCoords, F5T_COORD3_FLOAT, F5T_COORD3_FLOAT, Coords, H5P_DEFAULT);
61
62 /* Init the step through the argument list */
63 va_start(vl, coordinate_system);
64
65 F5printf(20, "F5write_particle_cartesian3Dv(): Step through the argument list");
66 /* Step through the argument list */
67 for(;;)
68 {
69 hid_t file_type;
70
71 /* Get the Name of the field */
72 fieldname = va_arg(vl, const char*);
73 if (fieldname == NULL) break;
74
75 /* Get the type of the field */
76 fieldtype = va_arg(vl, hid_t);
77 /* Get the pointer to the field */
78 dataPtr = va_arg(vl, const void*);
79 /* Get the unit of the field*/
80 //unittype = va_arg(vl, const void*);
81 if (dataPtr == NULL) break;
82
83 F5printf(20, "F5write_particle_cartesian3Dv(): write data for field %s", fieldname);
84
85 file_type = F5file_type(f, fieldtype);
86
87 /* Write the stuff */
88
89 /* WHY NOT USE F5Fwrite here?? */
91 fieldname, nCoords, file_type, 0, dataPtr,
92 F5LTmake_enum_type(f), creator_hid);
93
94 F5I_add_field(f, fieldname);
95 H5Dclose(f->Field_hid);
96 f->Field_hid = 0;
97 NumOfWrittenFields++;
98 }
99
100 /* Close the Step through */
101 va_end(vl);
102
103 H5Pclose(creator_hid);
104
105 /* Close the field */
106 F5close(f);
107
108 return NumOfWrittenFields;
109}
110
111int F5write_particle_double_cartesian3Dv(hid_t File_id, double time, const char*gridname,
112 const F5_point3_double_t*Coords, int nCoords,
113 const char*coordinate_system,
114 ...)
115{
116const char* fieldname;
117hid_t fieldtype;
118const void* dataPtr;
119va_list vl;
120int NumOfWrittenFields = 0;
121 //const char* unittype;
122
123 /* Create the Field */
124F5Path*f = F5Rcreate_cartesian_nD(File_id, time, gridname, 0, coordinate_system);
125
126 assert(f);
127
128hid_t creator_hid = H5Pcreate(H5P_DATASET_CREATE);
129F5ErrorCode rv;
130
131 F5printf(20, "F5write_particle_cartesian3Dv(): write positional information");
132
133 rv = F5Fwrite_1D( f, FIBER_HDF5_POSITIONS_STRING, nCoords, F5T_COORD3_DOUBLE, F5T_COORD3_DOUBLE, Coords, H5P_DEFAULT);
134
135 /* Init the step through the argument list */
136 va_start(vl, coordinate_system);
137
138 F5printf(20, "F5write_particle_cartesian3Dv(): Step through the argument list");
139 /* Step through the argument list */
140 for(;;)
141 {
142 hid_t file_type;
143
144 /* Get the Name of the field */
145 fieldname = va_arg(vl, const char*);
146 /* Get the type of the field */
147 fieldtype = va_arg(vl, hid_t);
148 /* Get the pointer to the field */
149 dataPtr = va_arg(vl, const void*);
150 /* Get the unit of the field*/
151 //unittype = va_arg(vl, const void*);
152
153 /* Break? */
154 if ( (fieldname == NULL) || (dataPtr == NULL) )
155 break;
156
157 F5printf(20, "F5write_particle_cartesian3Dv(): write data");
158
159 file_type = F5file_type(f, fieldtype);
160
161 /* Write the stuff */
162
163 /* WHY NOT USE F5Fwrite here?? */
165 fieldname, nCoords, file_type, 0, dataPtr,
166 F5LTmake_enum_type(f), creator_hid);
167
168 F5I_add_field(f, fieldname);
169 H5Dclose(f->Field_hid);
170 f->Field_hid = 0;
171 NumOfWrittenFields++;
172 }
173
174 /* Close the Step through */
175 va_end(vl);
176
177 H5Pclose(creator_hid);
178
179 /* Close the field */
180 F5close(f);
181
182 return NumOfWrittenFields;
183}
184
185
186
187/** added unit support in convenience function */
188int F5write_particle_cartesian3DvU(hid_t File_id, double time, const char*gridname,
189 const F5_vec3_point_t*Coords, const char*CoordUnit, int nCoords,
190 const char*coordinate_system,
191 ...)
192{
193 const char* fieldname;
194 hid_t fieldtype;
195 const void* dataPtr;
196 va_list vl;
197 int NumOfWrittenFields = 0;
198 const char* unittype;
199
200
201 /* Create the Field */
202F5Path*f = F5Rcreate_cartesian_nD(File_id, time, gridname, 0, coordinate_system);
203
204hid_t creator_hid = H5Pcreate(H5P_DATASET_CREATE);
205
206 F5printf(20, "F5write_particle_cartesian3DvU(): write positional information");
207 F5Fwrite_1D( f, FIBER_HDF5_POSITIONS_STRING, nCoords, F5T_COORD3_FLOAT, F5T_COORD3_FLOAT, Coords, H5P_DEFAULT );
208
209 F5Fset_metric_unit_description(f, CoordUnit );
210
211#if 0
212 /* write the positional information.
213 yack. should use F5F functions here...!
214 */
215{
216hsize_t dims = nCoords;
217hid_t coord_ds = H5Screate_simple(1, &dims, NULL);
218hid_t id = F5Dappend(f->Representation_hid, FIBER_HDF5_POSITIONS_STRING, f->FileIDs->Point_hid_t, coord_ds, creator_hid);
219 H5Dwrite(id, f->FileIDs->Point_hid_t, H5S_ALL, H5S_ALL, H5P_DEFAULT, Coords);
220
221 f->Field_hid = id;
222 F5I_add_field(f, FIBER_HDF5_POSITIONS_STRING, FIBER_HDF5_SIMPLE_FIELD);
223 f->Field_hid = 0;
224 H5Dclose(id);
225 H5Sclose(coord_ds);
226}
227#endif
228
229 /* Init the step through the argument list */
230 va_start(vl, coordinate_system);
231
232 F5printf(20, "F5write_particle_cartesian3DvU(): Step through the argument list");
233 /* Step through the argument list */
234
235 for(;;)
236 {
237 hid_t file_type; // MSVC wants it to be at the beginning of the scope
238
239 F5printf(20, "F5write_particle_cartesian3DvU(): Step %d", NumOfWrittenFields);
240
241
242 /* Get the Name of the field */
243 fieldname = va_arg(vl, const char*);
244 /* Get the type of the field */
245 fieldtype = va_arg(vl, hid_t);
246 /* Get the pointer to the field */
247 dataPtr = va_arg(vl, const void*);
248 /* Get the unit of the field*/
249 unittype = (const char*)va_arg(vl, const void*);
250
251 /* Break? */
252 if ( (fieldname == NULL) || (dataPtr == NULL) || unittype == NULL )
253 break;
254
255 F5printf(20, "F5write_particle_cartesian3DvU(): write data");
256
257 file_type = F5file_type(f, fieldtype);
258
259 /* Write the stuff */
260
261 /* WHY NOT USE F5Fwrite here?? */
263 fieldname, nCoords, file_type, 0, dataPtr,
264 F5LTmake_enum_type(f), creator_hid);
265
266 F5I_add_field(f, fieldname);
267
268 F5Fset_metric_unit_description(f, unittype );
269
270 H5Dclose(f->Field_hid);
271
272
273
274 f->Field_hid = 0;
275
276 F5printf(20, "F5write_particle_cartesian3DvU():4 fieldid=%d", (int)f->Field_hid );
277 NumOfWrittenFields++;
278 }
279
280 /* Close the Step through */
281 va_end(vl);
282
283 H5Pclose(creator_hid);
284
285 /* Close the field */
286 F5close(f);
287
288 return NumOfWrittenFields;
289}
hid_t F5file_type(F5Path *fpath, hid_t fieldtype)
Definition F5Bchart.c:941
F5_API F5ErrorCode F5Fwrite_1D(F5Path *fpath, const char *fieldname, hsize_t nElements, hid_t fieldtype, hid_t memtype, const void *dataPtr, hid_t property_id)
Definition F5F.c:631
enum F5ErrorCode_type F5ErrorCode
Definition F5F.h:267
F5_API int F5Fset_metric_unit_description(F5Path *f, const char *unit)
Definition F5Fmeta.c:967
hid_t F5LTmake_enum_type(F5Path *fpath)
Definition F5LT.c:179
F5_point3f_t F5_vec3_point_t
#define F5T_COORD3_FLOAT
#define F5T_COORD3_DOUBLE
#define FIBER_HDF5_POSITIONS_STRING
Definition F5defs.h:63
void F5I_add_field(F5Path *fpath, const char *fieldname)
Definition F5private.c:178
#define F5printf(verbosity,...)
Definition F5private.h:60
void F5close(F5Path *f)
Definition F5B.c:186
hid_t F5Lwrite1D(hid_t R_id, const char *fieldname, hsize_t nElements, hid_t fieldtype, hid_t memtype, const void *dataPtr, hid_t enum_type, hid_t property_id)
Definition F5L.c:408
F5Path * F5Rcreate_cartesian_nD(hid_t File_id, double time, const char *gridname, int Dims, const char *coordinate_system)
Definition F5R.c:116
hid_t F5Dappend(hid_t loc_id, const char *name, hid_t type_id, hid_t space_id, hid_t create_plist_id)
Definition F5X.c:239
F5ErrorCode F5write_particle_positions(hid_t File_id, double time, const char *gridname, const F5_vec3_point_t *Coords, int nCoords, const char *coordinate_system)
Definition F5particles.c:16
int F5write_particle_cartesian3Dv(hid_t File_id, double time, const char *gridname, const F5_vec3_point_t *Coords, int nCoords, const char *coordinate_system,...)
Definition F5particles.c:38
int F5write_particle_cartesian3DvU(hid_t File_id, double time, const char *gridname, const F5_vec3_point_t *Coords, const char *CoordUnit, int nCoords, const char *coordinate_system,...)
int F5write_particle_double_cartesian3Dv(hid_t File_id, double time, const char *gridname, const F5_point3_double_t *Coords, int nCoords, const char *coordinate_system,...)
ChartDomain_IDs * FileIDs
Definition F5Path.h:35
hid_t Representation_hid
Definition F5Path.h:58
hid_t Field_hid
Definition F5Path.h:59