FiberBundleHDF5  FiberHDF5 Documentation, Revision 2026
High-Performance Fiber Bundle Data Model for Scientific Visualization
Loading...
Searching...
No Matches
F5P.c
Go to the documentation of this file.
1#include "F5P.h"
2#include "F5X.h"
3#include "F5uniform.h"
4/* #if defined(__APPLE__) && defined(__MACH__) && defined(__POWERPC__) */
5#include <stdlib.h>
6/* #else */
7/* #include <malloc.h> */
8/* #endif */
9
10int F5P_is_regular3D(F5Path*grid, const char*coordinate_system)
11{
12hsize_t dims[FIBER_MAX_RANK];
13int rank = F5get_extension(grid, dims);
14
15 if (rank==3)
16 return 1;
17
18 return 0;
19}
20
21int F5P_is_uniform(F5Path*grid, const char*coordinate_system)
22{
23hid_t Top_id, Rep_id;
24int ok;
25
26 if (!grid->Grid_hid)
27 return 0;
28
29 if (grid->Topology_hid)
30 Top_id = grid->Topology_hid;
31 else
32 Top_id = H5Gopen2(grid->Grid_hid, FIBER_HDF5_POINTS, H5P_DEFAULT);
33
34 Rep_id = H5Gopen2( Top_id, coordinate_system, H5P_DEFAULT );
35
37
38 H5Gclose( Rep_id );
39
40 if (!grid->Topology_hid)
41 H5Gclose( Top_id );
42
43 return ok;
44}
45
46
47/**
48 A grid is `Z-stacked' if its coordinates in a certain chart
49 are uniform in all coordinates but the last one, which is
50 given as a one-dimensional dataset.
51 */
52int F5P_is_Zstacked(F5Path*grid, const char*coordinate_system)
53{
54hid_t Top_id, Rep_id;
55int ok;
56hsize_t dims[FIBER_MAX_RANK];
57int rank;
58
59 if (!grid->Grid_hid)
60 return 0;
61
62 rank = F5get_extension(grid, dims);
63
64 if (rank!=3) return 0;
65
66 if (grid->Topology_hid)
67 Top_id = grid->Topology_hid;
68 else
69 Top_id = H5Gopen2(grid->Grid_hid, FIBER_HDF5_POINTS, H5P_DEFAULT);
70
71 Rep_id = H5Gopen2( Top_id, coordinate_system, H5P_DEFAULT );
72
74 if (ok)
75 {
76 char*name;
77 hid_t pos_id = H5Gopen2(Rep_id, FIBER_HDF5_POSITIONS_STRING, H5P_DEFAULT);
78 hid_t type_id = F5Lget_type(pos_id, 1, 0);
79 int n = H5Tget_nmembers(type_id);
80
81 /* Look for the last member */
82 name = H5Tget_member_name(type_id, n-1);
83 if (!F5Dexist(pos_id, name))
84 ok = 0;
86
87 H5Tclose(type_id);
88 H5Gclose(pos_id);
89 }
90 H5Gclose( Rep_id );
91
92 if (!grid->Topology_hid)
93 H5Gclose( Top_id );
94
95 return ok;
96}
97
98
99
100/*
101Rectilinear: The positions contains an base and delta attribute,
102like in the uniform case, but also exactly one dataset for each
103coordinate. The base and delta attributes are not used here; they
104are just to distinguish this case from the curvilinear case, where
105coordinates at each point are given via separate coordinate
106component fields, e.g. three scalar fields {x,y,z}.
107Another criteria is that here the three fields {x,y,z} are
108one-dimensional, while for curvilinear separated coordinates they
109might be n-dimensional datasets. However, we don't want to
110insist of saving n-dimensional datasets as n-dimensional HDF5
111datasets (maybe this should be changed?).
112*/
113int F5P_is_rectilinear(F5Path*grid, const char*coordinate_system)
114{
115hid_t Top_id, Rep_id;
116int ok;
117
118 if (!grid->Grid_hid)
119 return 0;
120
121 if (grid->Topology_hid)
122 Top_id = grid->Topology_hid;
123 else
124 Top_id = H5Gopen2(grid->Grid_hid, FIBER_HDF5_POINTS, H5P_DEFAULT);
125
126 Rep_id = H5Gopen2( Top_id, coordinate_system, H5P_DEFAULT );
127
129 if (ok)
130 {
131 int i, n;
132 char*name;
133 hid_t pos_id = H5Gopen2(Rep_id, FIBER_HDF5_POSITIONS_STRING, H5P_DEFAULT);
134 hid_t type_id = F5Lget_type(pos_id, 1, 0);
135 n = H5Tget_nmembers(type_id);
136 for(i=0; i<n; i++)
137 {
138 name = H5Tget_member_name(type_id, i);
139 if (!F5Dexist(pos_id, name))
140 {
141 ok = 0;
142 free(name);
143 break;
144 }
145 free(name);
146 }
147 H5Tclose(type_id);
148 H5Gclose(pos_id);
149 }
150 H5Gclose( Rep_id );
151
152 if (!grid->Topology_hid)
153 H5Gclose( Top_id );
154
155 return ok;
156}
157
158
159/** The grid is curvilinear if the positions is a dataset of rank n
160 with n>1 or it is a group with n scalar field that are named like
161 the coordinate entries.
162 */
163int F5P_is_curvilinear(F5Path*grid, const char*coordinate_system)
164{
165hid_t Top_id, Rep_id, type_id;
166hsize_t dims[FIBER_MAX_RANK];
167int rank;
168int ok = 0;
169
170 if (!grid->Grid_hid)
171 return 0;
172
173 rank = F5get_extension(grid, dims);
174
175 if (rank<2) return 0;
176
177 if (grid->Topology_hid)
178 Top_id = grid->Topology_hid;
179 else
180 Top_id = H5Gopen2(grid->Grid_hid, FIBER_HDF5_POINTS, H5P_DEFAULT);
181
182 Rep_id = H5Gopen2( Top_id, coordinate_system, H5P_DEFAULT );
183
185
186 if (!ok)
187 {
189 if (ok)
190 {
191 int i, n;
192 char*name;
193 hid_t pos_id = H5Gopen2(Rep_id, FIBER_HDF5_POSITIONS_STRING, H5P_DEFAULT);
194 type_id = F5Lget_type(pos_id, 1, 0);
195 n = H5Tget_nmembers(type_id);
196 for(i=0; i<n; i++)
197 {
198 name = H5Tget_member_name(type_id, i);
199 if (!F5Dexist(pos_id, name))
200 {
201 ok = 0;
202 break;
203 }
204 free(name);
205 }
206
207 H5Tclose(type_id);
208 H5Gclose(pos_id);
209 }
210 }
211
212 H5Gclose( Rep_id );
213
214 if (!grid->Topology_hid)
215 H5Gclose( Top_id );
216
217 return ok;
218}
219
220
221int F5P_is_triangular_surface(F5Path*grid, const char*coordinate_system)
222{
223hid_t Cell_Top_id, Cell_Vertices_id, Vertices_id, Vertices_Type_id;
224int ok;
225
226 if (!F5Gexist(grid->Grid_hid, FIBER_HDF5_CELLS) )
227 if( !F5Gexist(grid->Grid_hid, FIBER_HDF5_FACES) )
228 return 0;
229 else
230 Cell_Top_id = H5Gopen2(grid->Grid_hid, FIBER_HDF5_FACES, H5P_DEFAULT);
231 else
232 Cell_Top_id = H5Gopen2(grid->Grid_hid, FIBER_HDF5_CELLS, H5P_DEFAULT);
233
234 if (!F5Gexist(Cell_Top_id, FIBER_HDF5_POINTS) )
235 {
236 H5Gclose( Cell_Top_id );
237 return 0;
238 }
239
240 Cell_Vertices_id = F5Gtry_to_open(Cell_Top_id, FIBER_HDF5_POINTS);
241 if (Cell_Vertices_id<1)
242 {
243 H5Gclose( Cell_Top_id );
244 return 0;
245 }
246
247 Vertices_id = F5Dtry_to_open(Cell_Vertices_id, FIBER_HDF5_POSITIONS_STRING);
248 if (Vertices_id<1)
249 {
250 H5Gclose( Cell_Top_id );
251 H5Gclose( Cell_Vertices_id );
252 return 0;
253 }
254
255 Vertices_Type_id = H5Dget_type(Vertices_id);
256
257 if (H5Tequal(Vertices_Type_id, F5T_TRIANGLE32)>0 )
258 {
259 ok = 1;
260 }
261 else if (H5Tequal(Vertices_Type_id, F5T_TRIANGLE64)>0 )
262 {
263 ok = 1;
264 }
265 else
266 ok = 0;
267
268 H5Tclose( Vertices_Type_id );
269 H5Gclose( Cell_Top_id );
270 H5Gclose( Cell_Vertices_id );
271 H5Dclose( Vertices_id );
272 return ok;
273}
274
275/** No Connectivity information is given, and the dimensionality of
276 the Positions is 1.
277 */
278int F5P_is_particle_system(F5Path*grid, const char*coordinate_system)
279{
280hsize_t dims[FIBER_MAX_RANK];
281int rank = F5get_extension(grid, dims);
282
283 if (rank==1)
284 {
285 if (!grid->Grid_hid)
286 return 0;
287
288 if (!F5Gexist(grid->Grid_hid, FIBER_HDF5_CELLS) )
289 return 1;
290
291 return 0;
292 }
293
294 return 0;
295}
296
297
298/** Check if the grid has positions in the specified coordinate system */
299int F5P_has_vertices(F5Path*grid, const char*coordinate_system)
300{
301hid_t Top_id, Rep_id;
302int ok;
303
304 if (!grid->Grid_hid)
305 return 0;
306
307 if (grid->Topology_hid)
308 Top_id = grid->Topology_hid;
309 else
310 Top_id = H5Gopen2(grid->Grid_hid, FIBER_HDF5_POINTS, H5P_DEFAULT);
311
312 Rep_id = H5Gopen2( Top_id, coordinate_system, H5P_DEFAULT );
313
316
317 H5Gclose( Rep_id );
318
319 if (!grid->Topology_hid)
320 H5Gclose( Top_id );
321
322 return ok;
323}
324
325
326/** Check if the grid has some fields in the specified coordinate system */
327int F5P_has_vertex_fields(F5Path*grid, const char*coordinate_system);
328/** Check if the grid has some data fields defined on its cells */
329int F5P_has_cell_fields(F5Path*grid, const char*coordinate_system);
int F5Lis_linear(hid_t Rep_id, const char *fieldname)
Definition F5L.c:985
return ok
Definition F5P.c:95
int F5P_has_vertex_fields(F5Path *grid, const char *coordinate_system)
H5Tclose(type_id)
name
Definition F5P.c:82
int F5P_has_cell_fields(F5Path *grid, const char *coordinate_system)
int F5P_is_regular3D(F5Path *grid, const char *coordinate_system)
Definition F5P.c:10
free(name)
#define F5T_TRIANGLE64
#define F5T_TRIANGLE32
#define FIBER_MAX_RANK
Definition F5defs.h:105
#define FIBER_HDF5_FACES
Definition F5defs.h:60
#define FIBER_HDF5_POINTS
Definition F5defs.h:55
#define FIBER_HDF5_CELLS
Definition F5defs.h:57
#define FIBER_HDF5_POSITIONS_STRING
Definition F5defs.h:63
hid_t F5Lget_type(hid_t Field_hid, int FieldIDisGroup, hid_t fapl_id)
Definition F5L.c:173
#define H5Gclose(x)
Definition F5X.h:144
int F5Gexist(hid_t location, const char *name)
Definition F5X.c:307
int F5Dexist(hid_t location, const char *name)
Definition F5X.c:321
hid_t F5Dtry_to_open(hid_t location, const char *name)
Definition F5X.c:335
hid_t F5Gtry_to_open(hid_t location, const char *name)
Definition F5X.c:297
int F5P_is_rectilinear(F5Path *grid, const char *coordinate_system)
Definition F5P.c:113
int F5P_is_curvilinear(F5Path *grid, const char *coordinate_system)
Definition F5P.c:163
int F5P_is_uniform(F5Path *grid, const char *coordinate_system)
Definition F5P.c:21
F5_API int F5P_is_Zstacked(F5Path *grid, const char *coordinate_system)
int F5P_has_vertices(F5Path *grid, const char *coordinate_system)
Definition F5P.c:299
int F5P_is_triangular_surface(F5Path *grid, const char *coordinate_system)
Definition F5P.c:221
int F5P_is_particle_system(F5Path *grid, const char *coordinate_system)
Definition F5P.c:278
int F5get_extension(F5Path *grid, hsize_t dims[FIBER_MAX_RANK])
Definition F5uniform.c:522
hid_t Grid_hid
Definition F5Path.h:53
hid_t Topology_hid
Definition F5Path.h:57