FiberBundleHDF5  FiberHDF5 Documentation, Revision 2026
High-Performance Fiber Bundle Data Model for Scientific Visualization
Loading...
Searching...
No Matches
F5B.c
Go to the documentation of this file.
1#include "F5B.h"
2#include "F5X.h"
3#include "F5F.h"
4#include "F5defs.h"
5#include "F5coordinates.h"
6#include "F5private.h"
7
8
9#include <stdlib.h>
10
11#include <string.h>
12#include <assert.h>
13
18
19
21{
22 const char*name;
24};
25
26
27#if 0
28/**\ingroup F5L
29 Create a Topology of the given name with a representation in
30 another Topology.
31 The types in the chart domain (F5Path->myChart) will only contain a copy
32 of the domain_type in the Point_hid_t, all other types like the
33 Vector, Covector etc. types are invalid (-1).
34
35 @note A new ChartDomain object is created, even if there might
36 be one already somewhere in memory elsewhere.
37 @param domainname A description for the refinement type.
38 @param domain_type An hdf5 type that describes the pointwise refinement
39 @param representation_name The name of the representation reference, which
40 will be of the type domainname.
41 */
42F5Path* F5LTcreateT(hid_t File_id, const double*time,
43 const char*gridname,
44 const char*domainname,
45 hid_t domain_type,
46 const char*representation_name,
47 const char*TopologyName,
48 int IndexDepth,
49 int Dimensionality,
50 const hsize_t*refinement)
51{
52struct mkDomain D;
53 D.name = domainname;
55
56 return F5LTcreateV(File_id, time, gridname,
57 0,
59 &D,
60 representation_name,
62 IndexDepth,
63 Dimensionality,
64 refinement);
65}
66#endif
67
69{
70 if (ChartDomain)
71 ChartDomain->refs++;
72}
73
75 ChartDomain_IDs*ChartDomain)
76{
77F5Path *f;
78 if (File_id<1)
79 {
80 F5printf(10, "*F5Bopen_coordinate_domain(): Invalid file ID given!");
81 return NULL;
82 }
83
84 f = newF5Path(File_id);
85
86 F5printf(30, "F5Bopen_coordinate_domain()");
87
88 H5E_BEGIN_TRY
89 f->ContentsGroup_hid = H5Gopen2(File_id, FIBER_CONTENTS,H5P_DEFAULT);
90
91 if (f->ContentsGroup_hid<=0)
92 F5printf(10, "File contains no "FIBER_CONTENTS" contents group (old F5 file?).");
93
94 /* NOTE: This should actually retrieve the enum types plus
95 field versioning information from the file!
96 */
97 if (f->ContentsGroup_hid>=0)
98 {
99 f->field_enum_type_hid = H5Topen2(f->ContentsGroup_hid, FIBER_ARRAY_TYPE_ENUM, H5P_DEFAULT);
100 if (f->field_enum_type_hid < 0)
101 F5printf(10, "File Contents group contains no field enumeration type (old F5 file?)");
102 }
103 H5E_END_TRY
104
105 f->Slice_hid = 0;
106 f->Grid_hid = 0;
107 f->Charts_hid = 0;
108 f->Chart_hid = 0;
109 f->Topology_hid = 0;
110 f->Representation_hid = 0;
111
112 /* preparing chart */
113
115 if (f->GlobalChart_hid<0)
116 {
117 F5printf(10, "File contains no "FIBER_HDF5_GLOBAL_CHARTS" entry (invalid F5 file?)");
118 deleteF5Path(f);
119 F5printf(30, "~F5Bopen_coordinate_domain() failed");
120 return NULL;
121 }
122
123 assert(ChartDomain);
124 {
125 f->myChart = ChartDomain;
126 f->myChart->refs++;
127 }
128
129 /* Creates an entry in the "global charts" group for all cartesian charts,
130 this is the place to store the named types of cartesian charts.
131
132 NOTE: This coordinate/chart reference stuff is planned to be replaced by shared
133 types. This revision will work without links.
134 */
136 {
138 F5printf(30, "~F5Bopen_coordinate_domain() is ok");
139 return f;
140 }
141#if 1
142 F5printf(10, "F5Bopen_coordinate_domain() failed, but still trying to make sense out of this file.");
143 f->FileIDs = 0;
144 return f;
145#else
147 deleteF5Path(f);
148
149 F5printf(30, "~F5Bopen_coordinate_domain() failed");
150 return NULL;
151#endif
152}
153
154
155
157{
158/*const char*cs = coordinate_system ? coordinate_system : FIBER_HDF5_DEFAULT_CHART; */
159const char*cs = FIBER_HDF5_DEFAULT_CHART;
160ChartDomain_IDs*ChartDomain = (strcmp(cs, FIBER_HDF5_DEFAULT_CHART)==0) ? F5B_standard_cartesian_chart3D() : 0;
161
162F5Path*f = F5Bopen_coordinate_domain( File_id, ChartDomain);
163 if (!f) /* hack for backward compatibility. */
164 {
167
168 F5printf(10, "*F5Binitialize_path(): Could not initialize with "
170
171 f = F5Bopen_coordinate_domain(File_id, ChartDomain);
173
174 if (!f)
175 {
176 F5printf(10, "*F5Binitialize_path(): Could not initialize with "
177 FIBER_HDF5_DEPRECATED_OLD_CARTESIAN_DOMAIN " either... not good.");
178
180 }
181 }
182 return f;
183}
184
185
187{
188 if (!f) return;
189
193 F5printf(100, "F5close(): Closing representation... %d", f->Representation_hid );
195 F5printf(100, "F5close(): Closing global chart...");
197 F5printf(100, "F5close(): Closing chart group...");
198 if (f->Charts_hid) H5Gclose(f->Charts_hid);
199 F5printf(100, "F5close(): Closing chart...");
200 if (f->Chart_hid) H5Gclose(f->Chart_hid);
202 F5printf(100, "F5close(): Closing grid...");
203 if (f->Grid_hid) H5Gclose(f->Grid_hid);
204 F5printf(100, "F5close(): Closing slice...");
205 if (f->Slice_hid) H5Gclose(f->Slice_hid);
206 F5printf(100, "F5close(): Closing ContentsGroup...");
208
209 if (f->Field_hid>0)
210 {
211 F5printf(40, "F5close(): field is %s.", F5Fis_group(f)?"a group":"a dataset");
212
213 if (F5Fis_group(f) )
214 H5Gclose( f->Field_hid );
215 else
216 H5Dclose( f->Field_hid );
217 }
218
219 deleteF5Path(f);
220}
221
223{
224 if (!f) return;
225 if (!*f) return;
226 F5close(*f);
227 *f = NULL;
228}
229
230void F5Bswap_dims (int dimensions, const hsize_t* in, hsize_t* out)
231{
232int i;
233
234 for (i = 0; i < dimensions; i++) {
235 out[i] = in[dimensions - 1 - i];
236 }
237}
ChartDomain_IDs * F5FB_read_global_chart(F5Path *f)
Definition F5B.c:14
void F5Bincrement_domain_refs(ChartDomain_IDs *ChartDomain)
Definition F5B.c:68
void F5closep(F5Path **f)
Definition F5B.c:222
F5Path * F5Bopen_coordinate_domain(hid_t File_id, ChartDomain_IDs *ChartDomain)
Definition F5B.c:74
void F5Bswap_dims(int dimensions, const hsize_t *in, hsize_t *out)
Swap from C array order to Fortran array order and back.
Definition F5B.c:230
ChartDomain_IDs * F5B_new_global_domain(const char *coordnames[], int dimension, const char *name, const int perm_vector[], int cell_dimensionality, hid_t SinglePrecisionType, hid_t DoublePrecisionType)
Definition F5Bchart.c:212
void F5B_delete_global_chart(ChartDomain_IDs *ID)
Definition F5Bchart.c:632
ChartDomain_IDs * F5B_read_global_chart(hid_t ChartsID, const char *name)
Definition F5Bchart.c:696
int F5Fis_group(const F5Path *fpath)
Definition F5F.c:126
H5Tclose(type_id)
F5Path * newF5Path(hid_t File_id)
Definition F5Path.c:5
void deleteF5Path(F5Path *f)
Definition F5Path.c:18
void TopologyName(char *name, int nlength, const hsize_t *level, int Centering, int dims)
Definition F5R.c:300
#define FIBER_HDF5_CARTESIAN_CHART_DOMAIN
Definition F5defs.h:77
#define FIBER_HDF5_DEFAULT_CHART
Definition F5defs.h:74
#define FIBER_HDF5_GLOBAL_CHARTS
Definition F5defs.h:109
#define FIBER_HDF5_DEPRECATED_OLD_CARTESIAN_DOMAIN
Definition F5defs.h:89
#define FIBER_CONTENTS
Definition F5defs.h:23
#define FIBER_ARRAY_TYPE_ENUM
Definition F5defs.h:293
#define F5printf(verbosity,...)
Definition F5private.h:60
F5Path * F5LTcreateV(hid_t File_id, const double *time, const char *gridname, ChartDomain_IDs *ChartDomain, ChartDomain_IDs *coord_creator(void *udata), void *udata, const char *coordinate_system, const char *TopologyName, int IndexDepth, int SkeletonDimensionality, int Dimensionality, const hsize_t *refinement)
Definition F5LT.c:410
void F5close(F5Path *f)
Definition F5B.c:186
F5Path * F5Binitialize_path(hid_t File_id)
Definition F5B.c:156
ChartDomain_IDs * F5B_standard_cartesian_chart3D()
#define H5Gclose(x)
Definition F5X.h:144
int F5Gexist(hid_t location, const char *name)
Definition F5X.c:307
hid_t F5Gtry_to_open(hid_t location, const char *name)
Definition F5X.c:297
const char * domain_name
Definition F5Bchart.h:112
unsigned refs
Definition F5Bchart.h:114
hid_t GlobalChart_hid
Definition F5Path.h:54
hid_t Grid_hid
Definition F5Path.h:53
ChartDomain_IDs * FileIDs
Definition F5Path.h:35
hid_t field_enum_type_hid
Definition F5Path.h:48
hid_t Charts_hid
Definition F5Path.h:55
hid_t Representation_hid
Definition F5Path.h:58
hid_t ContentsGroup_hid
Definition F5Path.h:51
hid_t Slice_hid
Definition F5Path.h:52
hid_t Field_hid
Definition F5Path.h:59
hid_t Topology_hid
Definition F5Path.h:57
hid_t Chart_hid
Definition F5Path.h:56
ChartDomain_IDs * myChart
Definition F5Path.h:33
Definition F5B.c:21
hid_t domain_type
Definition F5B.c:23
const char * name
Definition F5B.c:22