FiberBundleHDF5  FiberHDF5 Documentation, Revision 2026
High-Performance Fiber Bundle Data Model for Scientific Visualization
Loading...
Searching...
No Matches
Low-Level Field Operations

Functions

F5_API void F5close (F5Path *f)
F5_API int F5Fread_linear (F5Path *fpath, hsize_t *dims, hid_t fieldtype, void *base, void *delta)
F5_API hid_t F5Lcreate (hid_t R_id, const char *fieldname, int dimension, const hsize_t *dims, hid_t fieldtype, hid_t property_id)
F5_API hid_t F5LTcreate_topology (hid_t Grid_hid, const char *TopologyName, int IndexDepth, int SkeletonDimensionality, int DataspaceDimensionality, const hsize_t *refinement)
F5_API int F5LTset_maximal_grid_refinement (hid_t ContentsGroup_id, const char *gridname, int IndexDepth, int Dimensionality, const hsize_t *refinement)
F5_API int F5LTget_maximal_grid_refinement (hid_t ContentsGroup_id, const char *gridname, hsize_t *refinement)
F5_API int F5LTget_maximal_skeleton_refinement (hid_t ContentsGroup_id, const char *gridname, hsize_t *refinement, int IndexDepth, int Dimensionality)
F5_API int F5LTget_index_depth (hid_t Top_hid)
F5_API hid_t F5Lwrite (hid_t R_id, const char *fieldname, int dimension, const hsize_t *dims, hid_t fieldtype, hid_t memtype, const void *dataPtr, hid_t enum_type, hid_t property_id)
F5_API hid_t F5LwriteS (hid_t Container_id, const char *name, int dimension, const hsize_t *dims, hid_t fieldtype, hid_t memtype, const void *dataPtr, hid_t enum_type, hid_t dcpl_id)
F5_API int F5LreadS (hid_t Container_id, hid_t memtype, void *dataPtr, hid_t ElementLoadID)
F5_API hid_t F5Lwrite_fraction (hid_t R_id, const char *fieldname, int dimension, const hsize_t *full_dims, const hsize_t *datasize, hid_t fieldtype, hid_t memtype, const void *dataPtr, const hsize_t *datastart, const hsize_t *start_border, const hsize_t *end_border, const char *fraction_name, hid_t enum_type, hid_t property_id)
F5_API hid_t F5LSwrite_fraction (hid_t R_id, const char *fieldname, int dimension, const hsize_t *full_dims, const hsize_t *datasize, hid_t fieldtype, hid_t memtype, const void *const *dataPtr, const hsize_t *datastart, const hsize_t *start_border, const hsize_t *end_border, const char *fraction_name, hid_t enum_type, hid_t property_id)
F5_API 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)
F5_API hid_t F5Lwrite_linear (hid_t R_id, const char *fieldname, int dimension, const hsize_t *dataspace_dims, hid_t fieldtype, const void *base, const void *delta)
F5_API hid_t F5Lread_linear (hid_t F_id, hsize_t *dims, hid_t fieldtype, void *base, void *delta)
F5_API hid_t F5Lwrite_entity (hid_t R_id, const char *fieldname, hid_t fieldtype, const void *value)
F5_API hid_t F5Lwrites (hid_t F_id, const char *fieldname, int dimension, const hsize_t *dims, hid_t fieldtype, hid_t memtype, const void *const *dataPtr, hid_t enum_type, hid_t property_id)
F5_API hid_t F5Lget_type (hid_t Field_hid, int FieldIDisGroup, hid_t elink_fapl_id)
F5_API int F5Lget_field_dimension_and_type (hid_t Representation_hid, const char *fieldname, hsize_t dims[FIBER_MAX_RANK], hid_t *type_id)
F5_API int F5LAsave_dimensions (hid_t Field_id, const char *aname, int rank, const hsize_t *dims)
F5_API int F5LAget_dimensions (hid_t Field_id, const char *aname, hsize_t dims[FIBER_MAX_RANK])
F5_API int F5Lset_space (hid_t Field_id, int rank, const hsize_t *dims)
F5_API int F5Lget_compound_extent_dims (hid_t CompoundGroupID, hsize_t *dims)
F5_API hid_t F5Lget_compound_space (hid_t CompoundGroupID)
F5PathF5LTcreateV (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)
F5PathF5LTcreate (hid_t File_id, const double *time, const char *gridname, ChartDomain_IDs *ChartDomain, ChartDomain_IDs *coord_creator(), const char *coordinate_system, const char *TopologyName, int IndexDepth, int SkeletonDimensionality, int Dimensionality, const hsize_t *refinement)
F5_API F5PathF5LTcreate (hid_t File_id, const double *time, const char *gridname, ChartDomain_IDs *ChartDomain, new_global_chart_f coord_creator, const char *coordinate_system, const char *TopologyName, int IndexDepth, int SkeletonDimensionality, int DataspaceDimensionality, const hsize_t *refinement)

Detailed Description

Todo
Separate these functions into F5-Dataset functions, with prefix F5D, of the form:
  1. Functions taking contigous compounds (data given as void*), zero components not supported:
    • F5Dcreate()
    • F5Dwrite()
    • F5Dsave() (convenience function: create + write with same field type, no I/O type conversion)
    • F5Dis()
    • F5Dopen()
    • F5Dread()
    • F5Dload() (convenience function: open + read)
  2. Functions taking separated compounds (data given as void**), missing components supported:
    • F5DS...() (6 functions)
  3. Special datasets:
    • F5D*_fraction()
    • F5D*_linear()
    • F5D*_entity()
  4. Utility functions:
    • F5Dget_type()
    • F5Dget_space()
  5. Low-level functions:

Function Documentation

◆ F5close()

F5_API void F5close ( F5Path * f)

Remove a F5Path object.

Definition at line 186 of file F5B.c.

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}
void F5B_delete_global_chart(ChartDomain_IDs *ID)
Definition F5Bchart.c:632
int F5Fis_group(const F5Path *fpath)
Definition F5F.c:126
H5Tclose(type_id)
void deleteF5Path(F5Path *f)
Definition F5Path.c:18
#define F5printf(verbosity,...)
Definition F5private.h:60
#define H5Gclose(x)
Definition F5X.h:144
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

References F5Path::Chart_hid, F5Path::Charts_hid, F5Path::ContentsGroup_hid, deleteF5Path(), F5B_delete_global_chart(), F5Fis_group(), F5printf, F5Path::field_enum_type_hid, F5Path::Field_hid, F5Path::FileIDs, F5Path::GlobalChart_hid, F5Path::Grid_hid, H5Gclose, H5Tclose(), F5Path::myChart, F5Path::Representation_hid, F5Path::Slice_hid, and F5Path::Topology_hid.

Referenced by F5closep(), F5Cwrite_regular_surface(), F5Fwrite_uniform_cartesian3D(), F5Fwrite_uniform_cartesian3Ds(), F5iterate_timeslices(), F5Rcreate_rectilinear(), F5write_particle_cartesian3Dv(), F5write_particle_cartesian3DvU(), F5write_particle_double_cartesian3Dv(), F5write_particle_positions(), F5write_uniform_cartesian3Dv(), F5write_uniform_cartesian3Dvs(), and saveF5image().

◆ F5Fread_linear()

F5_API int F5Fread_linear ( F5Path * fpath,
hsize_t * dims,
hid_t fieldtype,
void * base,
void * delta )

Try to read a field which is a linear mapping of a base (origin) and delta value. The fpath object gets the the field identifier set to the opened field (which is available to retrieve additional user-defined attributes and such).

@params dims The dimensions of integer coordinates.

Returns
zero, if the entry could not be opened, non-zero if successfull.

Definition at line 1517 of file F5F.c.

1520{
1521hid_t field_id;
1522int rank;
1523hsize_t file_dims[FIBER_MAX_RANK];
1524
1525 F5printf(40, "F5Fread_linear()");
1526/* F5Fclose( fpath ); */
1527
1528/* field_id = F5Lread_linear(fpath->Representation_hid, fieldname, */
1529
1530 field_id = F5Lread_linear(fpath->Field_hid,
1531 file_dims,
1532 fieldtype,
1533 base, delta);
1534
1535 if (field_id < 0 )
1536 return 0;
1537
1538 if (dims)
1539 {
1540 rank = H5Tget_nmembers( fieldtype );
1542 F5Tpermute_dimensions(fpath, rank, dims, file_dims );
1544 }
1545
1546 F5printf(40, "~F5Fread_linear()");
1547 return 1;
1548}
F5_API hsize_t * F5Tpermute_dimensions(F5Path *fpath, int rank, hsize_t *target_dims, const hsize_t *source_dims)
Definition F5F.c:277
#define FIBER_MAX_RANK
Definition F5defs.h:105
int F5printf_indent
Definition F5private.c:349
hid_t F5Lread_linear(hid_t F_id, hsize_t *dims, hid_t fieldtype, void *base, void *delta)
Definition F5L.c:911

References F5Lread_linear(), F5printf, F5printf_indent, F5Tpermute_dimensions(), FIBER_MAX_RANK, and F5Path::Field_hid.

◆ F5LAget_dimensions()

F5_API int F5LAget_dimensions ( hid_t Field_id,
const char * aname,
hsize_t dims[FIBER_MAX_RANK] )

Read an n-dimensional attribute.

Parameters
dimsThe n values, maximally FIBER_MAX_RANK
Returns
The actual rank.

Definition at line 233 of file F5A.c.

234{
235 hid_t attr_id;
236/*int rank = -1, i, UADims[FIBER_MAX_RANK]; */
237
238 F5printf(50, "-- F5LAget_dimensions(,aname=%s,)", aname);
239
240 H5E_BEGIN_TRY
241 attr_id = F5Aopen_name(Field_id, aname);
242 H5E_END_TRY
243
244 if (attr_id>0)
245 {
246 hid_t space_id = H5Aget_space(attr_id);
247 int rank = H5Sget_simple_extent_npoints(space_id);
248 assert (space_id > 0);
249
250 F_H5Aread(attr_id, H5T_NATIVE_HSIZE, dims, aname );
251 H5Aclose(attr_id);
252 H5Sclose(space_id);
253/*
254 //for(i=0; i<rank; i++)
255 // dims[i] = UADims[i];
256*/
257 return rank;
258 }
259 return -1;
260}
herr_t F_H5Aread(hid_t attr_id, hid_t mem_type_id, void *buf, const char *name)
Definition F5private.c:332
hid_t F5Aopen_name(hid_t location, const char *name)
Definition F5A.c:34

References F5Aopen_name(), F5printf, F_H5Aread(), and FIBER_MAX_RANK.

Referenced by F5Lget_dimensions(), F5LTexpand_dataspace(), F5LTget_maximal_grid_refinement(), F5LTget_maximal_skeleton_refinement(), F5LTset_dataspace(), F5LTset_maximal_grid_refinement(), and F5Tget_space().

◆ F5LAsave_dimensions()

F5_API int F5LAsave_dimensions ( hid_t Field_id,
const char * aname,
int rank,
const hsize_t * dims )

Save dimensional information to a certain location.

Returns
1 if successfull, 0 if some problem occurred during writing.

Definition at line 192 of file F5A.c.

193{
194int UADims[FIBER_MAX_RANK];
195int i;
196hsize_t Sdims = rank;
197hid_t space_hid = H5Screate_simple(1, &Sdims, &Sdims);
198hid_t attr_hid;
199
200 F5printf(50, "-- F5LAsave_dimensions(,aname=%s, rank=%d,)", aname, rank);
201
202
203 H5E_BEGIN_TRY
204 attr_hid = H5Acreate2(Field_id, aname, H5T_NATIVE_INT, space_hid, H5P_DEFAULT, H5P_DEFAULT);
205 H5E_END_TRY
206
207 if (attr_hid<0)
208 {
209 H5E_BEGIN_TRY
210 attr_hid = H5Aopen_name(Field_id, aname);
211 H5E_END_TRY
212 }
213 if (attr_hid<0)
214 return 0;
215
216 for(i=0; i<rank; i++)
217 UADims[i] = dims[i];
218
219 if (H5Awrite(attr_hid, H5T_NATIVE_INT, UADims )<0)
220 {
221 fprintf(stderr, "F5LAsave_dimensions: CANNOT WRITE %s attribute\n", aname);
222
223 H5Aclose(attr_hid);
224 H5Sclose(space_hid);
225 return 0;
226 }
227
228 H5Aclose(attr_hid);
229 H5Sclose(space_hid);
230 return 1;
231}

References F5printf, and FIBER_MAX_RANK.

Referenced by F5Fwrite_linear(), F5Fwrite_linear_fraction(), F5Fwrite_linear_fraction_overlap(), F5Lset_space(), F5LSwrite_fraction(), F5LTcreate_topology(), F5LTexpand_dataspace(), F5LTset_dataspace(), F5LTset_maximal_grid_refinement(), F5Lwrite_fraction(), F5Lwrite_fraction_external(), and F5Lwrite_fractionS().

◆ F5Lcreate()

F5_API hid_t F5Lcreate ( hid_t R_id,
const char * fieldname,
int dimension,
const hsize_t * dims,
hid_t fieldtype,
hid_t property_id )
 Create an HDF5 dataset for further treatment with raw HDF5 functions, e.g.
 to write an hyperslab instead of the full dataset at once.
Returns
A HDF5 dataset ID. The caller must issue H5Dclose() on the returned identifier.
Parameters
property_idAn HDF5 dataset property ID. If it is negative, then a default property will be created locally via
H5Pcreate(H5P_DATASET_CREATE)
.
dataspace_idPointer to an HDF5 identifier, that will be used to store a shared dataspace. It may be NULL, in which case a local dataspace is created. Until shared dataspaces are implemented in HDF5, this will make no difference in the actual HDF5 file.
R_idThe group ID where the field shall be inserted, preferably a representation group ID that has been created by an F5create_representation() call.
fieldnameThe name of the field. It may be chosen arbitrarily, but must not contain slashes "/". It is furthermore recommended to avoid special characters - even if they work - and to keep the name short and concise).
dimensionThe dimensionality of the data set.
dimsThe extension of the data set.
fieldtypeAn HDF5 type identifier.

Definition at line 60 of file F5L.c.

62{
63hid_t ds_id, creator_id, id;
64
65 if (fieldtype<0)
66 {
67 F5printf(30, "F5Lcreate(%s): INVALID field type %d!?", fieldname, (int)fieldtype);
68 return -1;
69 }
70
71 ds_id = H5Screate_simple(dimension, dims, NULL); /* F5Lcreate() */
72 if (ds_id<0)
73 {
74 F5printf(30, "F5Lcreate(): cannot create dataset!?");
75 return -1;
76 }
77
78/* H5Sselect_order (dataspace_id, perm_vector); */
79
80 creator_id = dataset_creation_property_id<0 ? H5Pcreate(H5P_DATASET_CREATE) : dataset_creation_property_id;
81 id = F5Dcreate(R_id, fieldname, fieldtype, ds_id, creator_id);
82 if (id<0)
83 {
84 F5printf(30, "F5Lcreate(): F5Dappend(loc=%d,%s,dims=%d,,type=%d...) FAILED!\n",
85 (int)R_id, fieldname, dimension, (int)fieldtype );
86 }
87 else
88 {
89 F5printf(40, "F5Lcreate(): F5Dappend(%d,%s,...) DONE!\n", (int)R_id, fieldname);
90 }
91
92 /*H5Dwrite(id, fieldtype, H5S_ALL, H5S_ALL, H5P_DEFAULT, dataPtr); */
93
94 H5Sclose(ds_id);
95
96 /*
97 Review this "auto-closing" feature of property lists,this is unlikely to be good. WB SEP 2016
98 */
99 if (dataset_creation_property_id<0)
100 H5Pclose(creator_id);
101
102 return id;
103}
hid_t F5Dcreate(hid_t loc_id, const char *name, hid_t type_id, hid_t space_id, hid_t create_plist_id)
Definition F5X.c:278

References F5Dcreate(), and F5printf.

Referenced by F5Fcreate(), and F5Lwrite().

◆ F5Lget_compound_extent_dims()

F5_API int F5Lget_compound_extent_dims ( hid_t CompoundGroupID,
hsize_t * dims )

Get the dataspace extension from a compound group.

Definition at line 302 of file F5L.c.

303{
304hid_t type_id = F5Lget_type( CompoundGroupID, 1, 0);
305int nComponents = H5Tget_nmembers( type_id );
306int rank = -1;
307int i;
308
309 for(i=0; i<nComponents; i++)
310 {
311 char * comp_name = H5Tget_member_name( type_id, i );
312 hid_t sep_id = H5Dopen2(CompoundGroupID, comp_name, H5P_DEFAULT);
313 H5free_memory( comp_name );
314
315 hid_t space_id = H5Dget_space( sep_id );
316
317 rank = H5Sget_simple_extent_dims(space_id, dims, NULL);
318
319 H5Dclose(sep_id);
320 H5Sclose(space_id);
321 break;
322 }
323 H5Tclose( type_id );
324 return rank;
325}
hid_t F5Lget_type(hid_t Field_hid, int FieldIDisGroup, hid_t fapl_id)
Definition F5L.c:173

References F5Lget_type(), and H5Tclose().

◆ F5Lget_compound_space()

F5_API hid_t F5Lget_compound_space ( hid_t CompoundGroupID)

Get the dataspace of a compound group.

Definition at line 327 of file F5L.c.

328{
329hid_t type_id = F5Lget_type( CompoundGroupID, 1, 0);
330int nComponents = H5Tget_nmembers( type_id );
331hid_t space_id = -1;
332int i;
333 for(i=0; i<nComponents; i++)
334 {
335 char * comp_name = H5Tget_member_name( type_id, i );
336 hid_t sep_id = H5Dopen2(CompoundGroupID, comp_name, H5P_DEFAULT);
337 H5free_memory( comp_name );
338
339 space_id = H5Dget_space( sep_id );
340
341 H5Dclose(sep_id);
342 H5Sclose(space_id);
343 break;
344 }
345 H5Tclose( type_id );
346 return space_id;
347}

References F5Lget_type(), and H5Tclose().

◆ F5Lget_field_dimension_and_type()

F5_API int F5Lget_field_dimension_and_type ( hid_t Representation_hid,
const char * fieldname,
hsize_t dims[FIBER_MAX_RANK],
hid_t * type_id )

Retrieve dimensional and type information for a specific field.

Definition at line 449 of file F5uniform.c.

452{
453/*
454 should use F5LAget_dimensions() here...
455 */
456
457 hid_t Field_id, attr_id, space_id;
458int rank = -1, i, UADims[FIBER_MAX_RANK];
459
460 H5E_BEGIN_TRY
461 Field_id = H5Dopen2(Representation_hid, fieldname, H5P_DEFAULT);
462 H5E_END_TRY
463
464 if (Field_id>0)
465 {
466 space_id = H5Dget_space(Field_id);
467 rank = H5Sget_simple_extent_dims(space_id, dims, NULL);
468 H5Sclose(space_id);
469
470 if (type_id)
471 *type_id = F5Lget_type(Field_id, 0, 0);
472
473 H5Dclose(Field_id);
474 }
475 else
476 {
477 Field_id = H5Gopen2(Representation_hid, fieldname, H5P_DEFAULT);
478
480 space_id = H5Aget_space(attr_id);
481 rank = H5Sget_simple_extent_npoints(space_id);
482
483 H5Aread(attr_id, H5T_NATIVE_INT, UADims );
484 H5Aclose(attr_id);
485 H5Sclose(space_id);
486
487 for(i=0; i<rank; i++)
488 dims[i] = UADims[i];
489
490 if (type_id)
491 *type_id = F5Lget_type(Field_id, 1, 0);
492
493 H5Gclose(Field_id);
494 }
495
496 return rank;
497}
#define FIBER_FIELD_DATASPACE_DIMENSIONS_ATTRIBUTE
Definition F5defs.h:153

References F5Aopen_name(), F5Lget_type(), FIBER_FIELD_DATASPACE_DIMENSIONS_ATTRIBUTE, FIBER_MAX_RANK, and H5Gclose.

◆ F5Lget_type()

F5_API hid_t F5Lget_type ( hid_t Field_hid,
int FieldIDisGroup,
hid_t elink_fapl_id )

Retrieve type information for a specific field.

Definition at line 173 of file F5L.c.

174{
175 F5printf(40, "F5Lget_type(%lu,%s)", (unsigned long)Field_hid, FieldIDisGroup?"Is group":"Is dataset");
176
177 if (Field_hid<1)
178 {
179 F5printf(40, "F5Lget_type(): no valid Field id specified");
180 return -1;
181 }
182
183 if (FieldIDisGroup)
184 {
185 hid_t attr_hid, Type_id = -1;
186
187 H5E_BEGIN_TRY
188 attr_hid = F5Aopen_name(Field_hid, FIBER_HDF5_TYPEID_ATTRIB);
189 H5E_END_TRY
190 if (attr_hid>0)
191 {
192 Type_id = H5Aget_type(attr_hid);
193 H5Aclose(attr_hid);
194 F5printf(40, "F5Lget_type(): found `%s' attribute, return its type.", FIBER_HDF5_TYPEID_ATTRIB);
195 return Type_id;
196 }
197 H5E_BEGIN_TRY
198 attr_hid = F5Aopen_name(Field_hid, FIBER_UNIFORMARRAY_BASE_ATTRIBUTE);
199 H5E_END_TRY
200
201 if (attr_hid>0)
202 {
203 Type_id = H5Aget_type(attr_hid);
204 H5Aclose(attr_hid);
205 F5printf(40, "F5Lget_type(): no `%s' attribute, but uniform base attribute %s found.",
207 return Type_id;
208 }
209 F5printf(1, "F5Lget_type(): no `%s' attribute, ** performance warning ** - identifying field type by iteration over field fragments!",
211 {
213 T.type_id = &Type_id;
214 T.fapl_id = fapl_id;
215 H5Giterate(Field_hid, ".", 0, get_type_by_iteration, &T);
216 return Type_id;
217 }
218 }
219 else
220 {
221 hid_t NCSA_image_version = F5Atry_to_open(Field_hid, "IMAGE_VERSION");
222 if (NCSA_image_version>0)
223 {
224 hid_t attr_hid = F5Atry_to_open(Field_hid, FIBER_HDF5_TYPEID_ATTRIB);
225 H5Aclose( NCSA_image_version );
226 if (attr_hid>0)
227 {
228 hid_t Type_id = H5Aget_type(attr_hid);
229 H5Aclose(attr_hid);
230 F5printf(40, "F5Lget_type(): found NCSA image with `%s' attribute, return its type.", FIBER_HDF5_TYPEID_ATTRIB);
231fprintf(stderr, "F5Lget_type(): found NCSA image with `%s' attribute, return its type.\n", FIBER_HDF5_TYPEID_ATTRIB);
232 return Type_id;
233 }
234 }
235#if 0
236 {
237 hid_t type_id = H5Dget_type(Field_hid);
238 if (H5Tis_commmitted(type_id)
239 {
240 int NAttribs = H5Aget_num_attrs( type_id );
241 F5printf(20, "HDF5 Type %lu has %d attributes", (unsigned long)type_id, NAttribs);
242 }
243 return type_id;
244 }
245#endif
246 return H5Dget_type(Field_hid);
247 }
248}
hid_t F5Atry_to_open(hid_t location, const char *name)
Definition F5A.c:23
#define FIBER_HDF5_TYPEID_ATTRIB
Definition F5defs.h:144
#define FIBER_UNIFORMARRAY_BASE_ATTRIBUTE
Definition F5defs.h:158

References F5Aopen_name(), F5Atry_to_open(), F5printf, TypeIterationParameters::fapl_id, FIBER_HDF5_TYPEID_ATTRIB, FIBER_UNIFORMARRAY_BASE_ATTRIBUTE, and TypeIterationParameters::type_id.

Referenced by F5Fget_type2(), F5Lget_compound_extent_dims(), F5Lget_compound_space(), F5Lget_field_dimension_and_type(), F5P_is_curvilinear(), and F5P_is_rectilinear().

◆ F5Lread_linear()

F5_API hid_t F5Lread_linear ( hid_t F_id,
hsize_t * dims,
hid_t fieldtype,
void * base,
void * delta )

Try to read a field as if it were a linear mapping of indices to some values.

Parameters
dimsThe extensions of an HDF5 dataspace.
Returns
An HDF5 group ID. The caller must issue H5Gclose() on the returned identifier.
Todo
Add error checkings if the used attributes do not exist.

Definition at line 911 of file F5L.c.

914{
915 /* A linear map must be a group, not a dataset. */
916int rank, i;
917hid_t attr_id, space_id;
918hssize_t file_rank;
919int UADims[FIBER_MAX_RANK];
920
921 if (F_id < 0)
922 return F_id;
923
924 /* If so, it must have a FIBER_FIELD_DATASPACE_DIMENSIONS_ATTRIBUTE,
925 which is an alias for the corresponding dataspace of this
926 field.
927 */
928
929 rank = H5Tget_nmembers( fieldtype );
930 H5E_BEGIN_TRY
932 H5E_END_TRY
933 if (attr_id<0)
934 {
935#ifdef F5_BACKWARD_COMPATIBILITY
936 /* OLD FILE SUPPORT */
937 attr_id = F5Aopen_name(F_id, "Size");
938 if (attr_id<0)
939 {
940 printf("F5Lread_linear(): ERROR: "FIBER_FIELD_DATASPACE_DIMENSIONS_ATTRIBUTE" or Size attribute not found!\n");
941#else
942 printf("F5Lread_linear(): ERROR: "FIBER_FIELD_DATASPACE_DIMENSIONS_ATTRIBUTE" attribute not found!\n");
943#endif
944 return -1;
945#ifdef F5_BACKWARD_COMPATIBILITY
946 }
947#endif
948 }
949 space_id = H5Aget_space(attr_id);
950 file_rank = H5Sget_simple_extent_npoints(space_id);
951 H5Sclose(space_id);
952
953 if (file_rank != rank)
954 {
955 printf("F5Lread_linear(): ERROR: "FIBER_FIELD_DATASPACE_DIMENSIONS_ATTRIBUTE" does not have %d elements, but %d!\n",
956 rank, (int)file_rank);
957 H5Gclose(F_id);
958 return -1;
959 }
960
961 /* Read the dimensional values, which corresponds to retrieving the
962 dataspace of this field. However, there is no true dataspace stored
963 in the HDF5 file, but it is formulated via a special F5-internal
964 attribute. */
965
966 F_H5Aread(attr_id, H5T_NATIVE_INT, UADims, FIBER_FIELD_DATASPACE_DIMENSIONS_ATTRIBUTE);
967 H5Aclose(attr_id);
968
969 for(i=0; i<rank; i++)
970 dims[i] = UADims[i];
971
972 /* Moreover, a linear field must contain a base attribute */
974 F_H5Aread(attr_id, fieldtype, base, FIBER_UNIFORMARRAY_BASE_ATTRIBUTE);
975 H5Aclose(attr_id);
976
977 /* and a delta attribute */
979 F_H5Aread(attr_id, fieldtype, delta, FIBER_UNIFORMARRAY_DELTA_ATTRIBUTE);
980 H5Aclose(attr_id);
981
982 return F_id;
983}
#define FIBER_UNIFORMARRAY_DELTA_ATTRIBUTE
Definition F5defs.h:159

References F5Aopen_name(), F_H5Aread(), FIBER_FIELD_DATASPACE_DIMENSIONS_ATTRIBUTE, FIBER_MAX_RANK, FIBER_UNIFORMARRAY_BASE_ATTRIBUTE, FIBER_UNIFORMARRAY_DELTA_ATTRIBUTE, and H5Gclose.

Referenced by F5Fread_linear(), and F5Fread_linear_fragment().

◆ F5LreadS()

F5_API int F5LreadS ( hid_t Container_id,
hid_t memtype,
void * dataPtr,
hid_t ElementLoadID )

Read a dataset stored as separated compound as a continiguous compound dataset, involving some data transformation. Internally, hyperslabs are used.

Definition at line 552 of file F5L.c.

554{
555int nDimensions = -1;
556int nComponents = H5Tget_nmembers( LoadID );
557hid_t dapl_id = H5P_DEFAULT;
558int read_ok = 0;
559int i;
560 for(i=0; i<nComponents; i++)
561 {
562 char * comp_name = H5Tget_member_name( LoadID, i );
563 hid_t comp_id = H5Dopen2(Container_id, comp_name, dapl_id);
564
565 hid_t space_id = H5Dget_space( comp_id );
566 hsize_t mem_dataspace[FIBER_MAX_RANK],
567 blocksize[FIBER_MAX_RANK];
568 hsize_t start [FIBER_MAX_RANK];
569 hsize_t stride[FIBER_MAX_RANK];
570 int subrank = H5Sget_simple_extent_dims(space_id, blocksize, NULL);
571 int k, FastestDimension;
572
573 if (i==0)
574 nDimensions = subrank;
575 else if (subrank != nDimensions)
576 {
577 F5printf(-1, "F5LreadS() Incompatible component subspace!?!!?");
578 }
579 FastestDimension = nDimensions-1;
580 for(k=0; k<nDimensions; k++)
581 {
582 mem_dataspace[k] = blocksize[k];
583 start[k] = 0;
584 stride[k] = 1;
585 }
586 mem_dataspace[FastestDimension] = nComponents*blocksize[FastestDimension];
587 start [FastestDimension] = i;
588 stride[FastestDimension] = nComponents;
589
590 /*
591 ** Create the HDF5 Hyperslab
592 */
593 {
594 hid_t mem_space_id = H5Screate_simple(subrank, mem_dataspace, NULL);
595 H5Sselect_hyperslab(mem_space_id, H5S_SELECT_SET, start, stride, blocksize, NULL);
596
597 {
598 herr_t read_error = H5Dread(comp_id, ElementLoadID, mem_space_id, space_id, H5P_DEFAULT, dataPtr);
599 if (read_error<0)
600 {
601 F5printf(0, "F5readS() Component subspace read error at %s", comp_name);
602 }
603 else
604 read_ok++;
605 }
606
607 H5free_memory( comp_name );
608
609 H5Dclose(comp_id);
610 H5Sclose(space_id);
611 H5Sclose(mem_space_id);
612 }
613 }
614
615 return read_ok;
616}

References F5printf, and FIBER_MAX_RANK.

◆ F5Lset_space()

F5_API int F5Lset_space ( hid_t Field_id,
int rank,
const hsize_t * dims )

Save dimensional information to a certain location.

Returns
1 if successfull, 0 if some problem occurred during writing.

Definition at line 292 of file F5L.c.

293{
295 if (!ok)
296 F5printf(20, " F5Lset_space(): field already has dimensions set or invalid Field id or write error.");
297 return ok;
298}
return ok
Definition F5P.c:95
int F5LAsave_dimensions(hid_t Field_id, const char *aname, int rank, const hsize_t *dims)
Definition F5A.c:192

References F5LAsave_dimensions(), F5printf, FIBER_FIELD_DATASPACE_DIMENSIONS_ATTRIBUTE, and ok.

Referenced by F5Fwrite_linear_fraction(), F5LSwrite_fraction(), F5Lwrite_fraction(), F5Lwrite_fraction_external(), F5Lwrite_fractionS(), and F5Lwrite_linear().

◆ F5LSwrite_fraction()

F5_API hid_t F5LSwrite_fraction ( hid_t R_id,
const char * fieldname,
int dimension,
const hsize_t * full_dims,
const hsize_t * datasize,
hid_t fieldtype,
hid_t memtype,
const void *const * dataPtr,
const hsize_t * datastart,
const hsize_t * start_border,
const hsize_t * end_border,
const char * fraction_name,
hid_t enum_type,
hid_t property_id )

Write a dataset of separate components that only cover a fraction of the entire representation's domain.

Parameters
dimensionThe dimension of the data set.
datastartThe (multidimensional) start index of the saved data set.
dataendThe (multidimensional) end index of the saved data set.
fraction_nameAn optional string to name this fraction. It may be NULL to use an internal default.
Note
Subsampling can not be specified here. Subsampled data need to go into another Topology group.
Returns
A HDF5 dataset ID. The caller must issue H5Dclose() on the returned identifier.

Definition at line 793 of file F5L.c.

801{
802hid_t F_id;
803hid_t B_id;
804
805 F5printf(10, "F5LSwrite_fraction(field=%s, fragment=%s)",
806 fieldname, fraction_name);
807
808 if (rank==3)
809 {
810 F5printf(60, " start=[%d,%d,%d] size=[%d,%d,%d] full=[%d,%d,%d]\n",
811 (int)full_dims[0], (int)full_dims[1], (int)full_dims[2],
812 (int)datastart[0], (int)datastart[1], (int)datastart[2],
813 (int)datasize[0], (int)datasize[1] , (int)datasize[2]
814 );
815 }
816
817
818 F_id = F5Gappend(R_id, fieldname);
819 {
820 char myBlockname[ MAX_BLOCKNAME ];
821 B_id = F5Lwrites(F_id, fraction_name?fraction_name:blockname(myBlockname, rank, datastart),
822 rank, datasize, fieldtype, memtype, dataPtr, enum_type, property_id);
823 }
824 F5Dset_type_attribute(F_id, fieldtype);
825
826 if (full_dims)
827 F5Lset_space(F_id, rank, full_dims);
828
830
831 if (start_border)
833
834 if (end_border)
836
837 F5Xclose(B_id);
838
839 F5printf(11, "~F5LSwrite_fraction(field=%s, fragment=%s)\n",
840 fieldname, fraction_name);
841
842 return F_id;
843}
int F5Dset_type_attribute(hid_t F_id, hid_t fieldtype)
Definition F5L.c:1052
#define MAX_BLOCKNAME
Definition F5L.c:623
#define FIBER_FRAGMENT_NOOVERLAP_START_ATTRIBUTE
Definition F5defs.h:175
#define FIBER_FRAGMENT_NOOVERLAP_END_ATTRIBUTE
Definition F5defs.h:176
#define FIBER_FRAGMENT_OFFSET_ATTRIBUTE
Definition F5defs.h:174
int F5Lset_space(hid_t Field_id, int rank, const hsize_t *dims)
Definition F5L.c:292
hid_t F5Lwrites(hid_t R_id, const char *fieldname, int dimension, const hsize_t *dims, hid_t fieldtype, hid_t memtype, const void *const *dataPtr, hid_t enum_type, hid_t property_id)
Definition F5L.c:1096
herr_t F5Xclose(hid_t obj_id)
Definition F5X.c:347
hid_t F5Gappend(hid_t loc_id, const char *name)
Definition F5X.c:59

References F5Dset_type_attribute(), F5Gappend(), F5LAsave_dimensions(), F5Lset_space(), F5Lwrites(), F5printf, F5Xclose(), FIBER_FRAGMENT_NOOVERLAP_END_ATTRIBUTE, FIBER_FRAGMENT_NOOVERLAP_START_ATTRIBUTE, FIBER_FRAGMENT_OFFSET_ATTRIBUTE, and MAX_BLOCKNAME.

Referenced by F5FSwrite_fraction().

◆ F5LTcreate() [1/2]

F5Path * F5LTcreate ( hid_t File_id,
const double * time,
const char * gridname,
ChartDomain_IDs * ChartDomain,
ChartDomain_IDs * coord_creator(),
const char * coordinate_system,
const char * TopologyName,
int IndexDepth,
int SkeletonDimensionality,
int Dimensionality,
const hsize_t * refinement )

Create a Topology of the given name with a representation in the certain coordinate system. If the ChartDomain has not been set yet, then the types in the newly created chart domain (F5Path->myChart) will contain valid types for the Points and tangential types, as they are created by the specified coord_creator(). Note that the coord_create() specifies the type of the coordinate system, while the coordinate_system parameter specifies the actual object that is of this respective type.

Examples
ObjtoF5.c.

Definition at line 712 of file F5LT.c.

721{
722ChartDomain_IDs*(*TheCoordCreator)(void*) = 0;
723/*ChartDomain_IDs*TheCoordCreator = 0; */
724
725 F5printf(30,"F5LTcreate(%s)\n", TopologyName);
726
727 if (coord_creator)
728 TheCoordCreator = coord_domain_creator; /* local function that calls coord_creator() */
729
730 return F5LTcreateV(File_id, time, gridname,
731 ChartDomain,
732 TheCoordCreator, /* local function that calls coord_creator() */
733 (void*)coord_creator, /* user data */
734 coordinate_system,
736 IndexDepth, SkeletonDimensionality,
737 Dimensionality,
738 refinement);
739}
void TopologyName(char *name, int nlength, const hsize_t *level, int Centering, int dims)
Definition F5R.c:300
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

References F5LTcreate(), F5LTcreateV(), F5printf, and TopologyName().

Referenced by F5LTcreate(), F5Rcreate_coordinate_topology(), F5Rcreate_edges_as_vertices_topology(), F5Rcreate_hexaedrons_as_vertices_topology(), F5Rcreate_relative_vertex_Irefinement3D(), F5Rcreate_relative_vertex_Qrefinement3D(), F5Rcreate_tetrahedrons_as_vertices_topology(), and F5Rcreate_triangles_as_vertices_topology().

◆ F5LTcreate() [2/2]

F5_API F5Path * F5LTcreate ( hid_t File_id,
const double * time,
const char * gridname,
ChartDomain_IDs * ChartDomain,
new_global_chart_f coord_creator,
const char * coordinate_system,
const char * TopologyName,
int IndexDepth,
int SkeletonDimensionality,
int DataspaceDimensionality,
const hsize_t * refinement )

Low-level creation function for F5Path objects.

Parameters
timePointer to the time instance of the current parameter space slices, or NULL if the data reside in a zero-dimensional parameter space, i.e. they are static. In a future extension, this may be a point to a multidimensional structure specifying the location in multidimensional parameter space.
SkeletonDimensionalityThe dimensionality of the k-cells that is described by this Skeleton of a Grid.
DataspaceDimensionalityThe dimensionality of the data that is used for the data on this Skeleton. This is best to be identical to the SkeletonDimensionality, but may differ, for instance one can store data in one-dimensional arrays over a 2D grid, or have some kind of irregular point distribution.

References F5_API, and TopologyName().

◆ F5LTcreate_topology()

F5_API hid_t F5LTcreate_topology ( hid_t Grid_hid,
const char * TopologyName,
int IndexDepth,
int SkeletonDimensionality,
int DataspaceDimensionality,
const hsize_t * refinement )

Definition at line 329 of file F5LT.c.

335{
336 if (Grid_hid<=0)
337 {
338 F5printf(0, "F5LTcreate_topology() - invalid Grid HDF5 ID, file not open?");
339 return -1;
340 }
341
342hid_t Topology_hid = F5Gappend(Grid_hid, TopologyName) ;
343/*hid_t attr_id;
344hid_t space_id = H5Screate(H5S_SCALAR);
345herr_t status;
346*/
347 if (Topology_hid<0)
348 return -2;
349
350 assert(Topology_hid>0);
351
352 F5printf(30, "F5LTcreate_topology(%s)<depth=%d>, rank=%d (using dataspace of rank %d)",
353 TopologyName, IndexDepth, SkeletonDimensionality, DataspaceDimensionality);
354/* printf( "F5LTcreate_topology(%s)<depth=%d>, rank=%d (using dataspace of rank %d)",
355 TopologyName, IndexDepth, SkeletonDimensionality, DataspaceDimensionality);
356*/
357
358 if (!F5Astore_integer(Topology_hid, FIBER_HDF5_INDEXDEPTH_ATTRIB, IndexDepth) )
359 {
360 F5printf(50, "Tried to re-create topology %s, ignored\n", TopologyName);
361 puts("CANNOT save index depth");
362 return Topology_hid;
363 }
364
365 if (!F5Astore_integer(Topology_hid, FIBER_HDF5_SKELETON_DIMENSIONALITY_ATTRIB, SkeletonDimensionality) )
366 {
367 F5printf(50, "Can't save dimensionality in %s, ignored\n", TopologyName);
368 puts("CANNOT save dimensionality");
369 return Topology_hid;
370 }
371
372 /* Dimensionality information */
373 if (DataspaceDimensionality>0)
374 {
375 if (!F5Asave_ints( Topology_hid, FIBER_HDF5_RANK_ATTRIBUTE, &DataspaceDimensionality, 1) )
376 {
377 F5printf(3, "F5LTcreate_topology(%s)<depth=%d>, rank=%dD: CANNOT SAVE RANK - aborted, more info with F5_VERBOSITY=10 to 50"
378 , TopologyName, IndexDepth, DataspaceDimensionality);
379 H5Gclose( Topology_hid );
380 return -1;
381 }
382 }
383
384 if( SkeletonDimensionality > 0 && refinement )
385 {
386 if (1 != F5LAsave_dimensions(Topology_hid, FIBER_HDF5_REFINEMENT_INFO, SkeletonDimensionality, refinement))
387 {
388 F5printf(3, "F5LTcreate_topology(%s)<depth=%d>, rank=%dD: CANNOT SAVE REFINEMENT - aborted", TopologyName, IndexDepth, DataspaceDimensionality);
389 H5Gclose( Topology_hid );
390 return -1;
391 }
392 }
393
394 F5printf(30, "~F5LTcreate_topology(%s)<depth=%d>, %dD", TopologyName, IndexDepth, DataspaceDimensionality);
395 return Topology_hid;
396}
int F5Astore_integer(hid_t loc_id, const char *name, int data)
Definition F5A.c:436
int F5Asave_ints(hid_t loc_id, const char *name, const int data[], hsize_t n)
Definition F5A.c:355
#define FIBER_HDF5_INDEXDEPTH_ATTRIB
Definition F5defs.h:228
#define FIBER_HDF5_SKELETON_DIMENSIONALITY_ATTRIB
Definition F5defs.h:256
#define FIBER_HDF5_REFINEMENT_INFO
Definition F5defs.h:72
#define FIBER_HDF5_RANK_ATTRIBUTE
Definition F5defs.h:147

References F5Asave_ints(), F5Astore_integer(), F5Gappend(), F5LAsave_dimensions(), F5printf, FIBER_HDF5_INDEXDEPTH_ATTRIB, FIBER_HDF5_RANK_ATTRIBUTE, FIBER_HDF5_REFINEMENT_INFO, FIBER_HDF5_SKELETON_DIMENSIONALITY_ATTRIB, H5Gclose, and TopologyName().

Referenced by F5LTcreateV().

◆ F5LTcreateV()

F5Path * F5LTcreateV ( hid_t File_id,
const double * time,
const char * gridname,
ChartDomain_IDs * ChartDomain,
ChartDomain_IDs * coord_creatorvoid *udata,
void * udata,
const char * coordinate_system,
const char * TopologyName,
int IndexDepth,
int SkeletonDimensionality,
int Dimensionality,
const hsize_t * refinement )

The central F5Path constructor for write access: Creates the basic F5 structures in the file and sets up an F5Path object for subsequent use. Basically, all the information contained in an F5Path object can be created from the given parameters, however, some complexity arises when modifying some file that already has some structure. In such a case, it must re-use any found structures in a consistent way, especcially it has to use named types instead of intrinsic ones.

Todo
Extend slice group creation to parameter spaces
Parameters
ChartDomainIf a chartdomain is given, i.e. it is used already or stems from another file opening, then we reuse this chart domain, otherwise a new one will be created. The ChartDomain describes all types of the fields in the respective representation group as they are transient in memory. It will become the F5Path's `myChart' member. Specifying the ChartDomain is optional: if it is not given, then the coord_creator() callback function will be used to create a new coordinate object.

Note that F5LTcreateV() is more general in this respect than F5LTcreate() and F5LTcreateT(): Via the callback function, it allows to create an arbitrary subset of types for the chart domain, whereas F5LTcreate() always assumes that the representation domain is a coordinate system and creates the point, vector, covector and subsequent types for the tangential space. F5LTcreateT(), in contrast, does not create any tangential types (they are set to -1 in the ChartDomain), but only the point type, thus is more suitable for topological representations (cells referring to points, points to refined points, ...). */ if (ChartDomain) { F5printf(31, " increment chart domain references"); f->myChart = ChartDomain; f->myChart->refs++; } else if (coord_creator) { assert(udata); F5printf(31, " using new coordinate creator"); f->myChart = coord_creator(udata);

if (f->myChart) { f->Chart_hid = F5Gappend(f->Charts_hid, coordinate_system); F5printf(31, " append %s\n", coordinate_system); } else F5printf(0, " no chart created, coordinate_system is %s", coordinate_system); } else { F5printf(1, "F5 On Grid [%s] creating a Topological Skeleton [%s] without coordinates and no chart domain [%s], this might be a relative representation.", gridname, TopologyName, coordinate_system); f->myChart = 0; }

if (f->myChart && f->Chart_hid) { hid_t Domain_hid; hid_t GlobalChartAnchor_hid;

char chart_anchor[1024] = "/" FIBER_HDF5_GLOBAL_CHARTS "/"; strcat(chart_anchor, f->myChart->domain_name); strcat(chart_anchor,"/"); strcat(chart_anchor, coordinate_system);

/* Creates an entry in the "global charts" group for all cartesian charts, this is the place to store the named types of cartesian charts.

NOTE: This coordinate/chart reference stuff is planned to be replaced by shared types. This revision will work without links.

Definition at line 410 of file F5LT.c.

420{
421F5Path* f = NULL;
422 if (File_id<0)
423 {
424 F5printf(1, "F5LTcreateV(): Invalid File!");
425 return NULL;
426 }
427
428 F5printf(30, "**F5LTcreateV(grid=`%s', topology=`%s')<%d>, Repr=%dD, [%s] %s %s",
429 gridname, TopologyName, IndexDepth, Dimensionality, coordinate_system,
430 ChartDomain?" Chart Domain given":"No chart Domain",
431 coord_creator?" Coordinate Creator available":" No Coordinate Creator" );
432
433 if (!gridname || !gridname[0])
434 {
435 return NULL;
436 }
437
438 /*
439 Should this be relaxed to allow zero dimensionality or negative?
440 What would this mean for refinements?
441
442 YES - because we need zero dimensionality to identify particle sets.
443 */
444 if (Dimensionality<0)
445 {
446 F5printf(0, "**F5LTcreateV(grid=`%s', topology=`%s')<%d>, %dD, [%s] - CANNOT create skeleton entry because dimensionality is lesser than zero!",
447 gridname, TopologyName, IndexDepth, Dimensionality, coordinate_system);
448 return NULL;
449 }
450
452
453 /* Create an empty F5Path structure */
454 f = newF5Path(File_id);
455
456 assert(coordinate_system);
457
458 /* Initialize contents property */
460 assert(f->ContentsGroup_hid>0);
461 F5printf(40, "F5LTcreateV(): Contents group is %d\n", (int)(f->ContentsGroup_hid) );
462
463 f->field_enum_type_hid = 0;
464
465 /* Prepare time slice group:
466 /T=1.0/
467 */
468 /** @todo Extend slice group creation to parameter spaces */
469 f->Slice_hid = F5Bappend_slice(File_id, time);
470 assert(f->Slice_hid>0);
471
472/* create the neccessary groups for appending the data to the dataset */
473
474 F5printf(30, "F5LTcreate(): append gridname `%s'\n", gridname);
475 /* /T=1.0/Gridname/ */
476 f->Grid_hid = F5Gappend(f->Slice_hid, gridname);
477 /* /T=1.0/Gridname/Charts/ */
479
480 /* register grid for reverse indexing ("on which time steps does this grid exist"?)
481 @todo Extend grid registration to parameter spaces.
482 */
483 F5I_add_grid(f, gridname, time);
484
485 /* register the given coordinate system per grid
486 /T=1.0/Gridname/Charts/Cartesian/
487 This is required such that we know which coordinate system exist
488 on this grid at all, therefore allowing a reading facility to request
489 a coordinate representation in one of those coordinate systems. It makes
490 no sense to request a representation in a coordinate system that is not
491 listed with a grid, because there will be no transformation information
492 available at all for this coordinate system. On the other hand, the
493 information which charts are possible cannot be stored with each
494 representation, because it is totally valid for a topology group to
495 have no representation in a transformable grid. Instead, this
496 transformation information is usually stored with the charts per grid
497 and may be employed for all topology groups - for procedural transformation.
498 In the case of numerical transformation rules, the transformation
499 matrices have to be stored explicitely with each topology.
500 Examples:
501 /T=1.0/Gridname/Charts/CartesianChart/
502 /T=1.0/Gridname/Charts/PolarChart/
503 /T=1.0/Gridname/Points/PolarChart/Positions/
504 allows to request
505 /T=1.0/Gridname/Points/CartesianChart/Positions/
506 although there is not yet such a representation in the file.
507 In this case, the intrinsic polar->cartesian coordinate transformation
508 rule is used. If there is an entry
509 /T=1.0/Gridname/Charts/PolarChart/CartesianChart/
510 then this group may contain more specific information on how to transform
511 from polar to cartesian coordinates, e.g. specifying some angle of the
512 polar axis, some offset of the polar coordinate origin, some mapping of
513 the angles etc.
514 */
515 if (ChartDomain) // only add true coordinate systems to the list of charts
516 f->Chart_hid = F5Gappend(f->Charts_hid, coordinate_system) ;
517 else
518 f->Chart_hid = 0;
519
520 /* Create a topology group under for the certain grid:
521 /T=1.0/Gridname/TopologyName
522 */
525 IndexDepth, SkeletonDimensionality,
526 Dimensionality,
527 refinement);
528
529 if (f->Topology_hid<0)
530 {
531 F5printf(0, "**F5LTcreateV(grid=`%s', topology=`%s')<%d>, %dD, [%s] Could not create Skeleton, different dataspace properties found in file, use F5_VERBOSITY=3 for more details.",
532 gridname, TopologyName, IndexDepth, Dimensionality, coordinate_system);
533 H5Gclose(f->Slice_hid );
534 H5Gclose(f->Grid_hid );
535 H5Gclose(f->Charts_hid );
536 if (f->Chart_hid) H5Gclose(f->Chart_hid );
537 deleteF5Path(f);
538 return NULL;
539 }
540
541 F5LTset_maximal_grid_refinement(f->ContentsGroup_hid, gridname, IndexDepth, SkeletonDimensionality, refinement);
542
543 assert(coordinate_system);
544 /* Create a representation group under for the certain grid:
545 /T=1.0/Gridname/TopologyName/RepresentationName
546 */
547 f->Representation_hid = F5Gappend(f->Topology_hid, coordinate_system);
548
549 /* preparing chart */
551
552 /**
553 @param ChartDomain
554 If a chartdomain is given, i.e. it is used already or stems from
555 another file opening, then we reuse this chart domain, otherwise
556 a new one will be created. The ChartDomain describes all types
557 of the fields in the respective representation group as they
558 are transient in memory. It will become the F5Path's `myChart'
559 member. Specifying the ChartDomain is optional: if it is not
560 given, then the coord_creator() callback function will be
561 used to create a new coordinate object.
562
563 Note that F5LTcreateV() is more general in this respect than
564 F5LTcreate() and F5LTcreateT(): Via the callback function, it
565 allows to create an arbitrary subset of types for the chart domain,
566 whereas F5LTcreate() always assumes that the representation domain
567 is a coordinate system and creates the point, vector, covector
568 and subsequent types for the tangential space. F5LTcreateT(),
569 in contrast, does not create any tangential types (they are set
570 to -1 in the ChartDomain), but only the point type, thus is
571 more suitable for topological representations (cells referring
572 to points, points to refined points, ...).
573 */
574 if (ChartDomain)
575 {
576 F5printf(31, " increment chart domain references");
577 f->myChart = ChartDomain;
578 f->myChart->refs++;
579 }
580 else if (coord_creator)
581 {
582 assert(udata);
583 F5printf(31, " using new coordinate creator");
584 f->myChart = coord_creator(udata);
585
586 if (f->myChart)
587 {
588 f->Chart_hid = F5Gappend(f->Charts_hid, coordinate_system);
589 F5printf(31, " append %s\n", coordinate_system);
590 }
591 else
592 F5printf(0, " no chart created, coordinate_system is %s", coordinate_system);
593 }
594 else
595 {
596 F5printf(1, "F5 On Grid [%s] creating a Topological Skeleton [%s] without coordinates and no chart domain [%s], this might be a relative representation.",
597 gridname, TopologyName, coordinate_system);
598 f->myChart = 0;
599 }
600
601 if (f->myChart && f->Chart_hid)
602 {
603 hid_t Domain_hid;
604 hid_t GlobalChartAnchor_hid;
605
606 char chart_anchor[1024] = "/" FIBER_HDF5_GLOBAL_CHARTS "/";
607 strcat(chart_anchor, f->myChart->domain_name);
608 strcat(chart_anchor,"/");
609 strcat(chart_anchor, coordinate_system);
610
611 /* Creates an entry in the "global charts" group for all cartesian charts,
612 this is the place to store the named types of cartesian charts.
613
614
615 NOTE: This coordinate/chart reference stuff is planned to be replaced by shared
616 types. This revision will work without links.
617 */
619 if (Domain_hid>0)
620 {
622
623 if (coordinate_system && F5Gexist(Domain_hid, coordinate_system) )
624 {
625 F5printf(10,"F5LTcreate(): Coordinate system %s already exists in domain %s, read global chart ID's...",
626 coordinate_system, f->myChart->domain_name);
627
628 /* still link from the local chart to the global chart */
629 F5Glink(f->Chart_hid, H5G_LINK_SOFT, chart_anchor, FIBER_HDF5_CHART_TO_GLOBALCHART_REF ) ;
630 H5Gclose(Domain_hid);
631 F5printf(10,"~F5LTcreate() got data from file.");
633 return f;
634 }
635 }
636 else
637 {
638 F5printf(10,"F5LTcreate(): Coordinate domain not found, creating file entry.");
639
640 /* Create an entry in the group of all (cartesian) charts for this specific coordinate system */
641 Domain_hid = H5Gcreate2(f->GlobalChart_hid, f->myChart->domain_name,
642 H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT);
643
644 /* save relevant information (named HDF5 types) for cartesian charts */
645 f->FileIDs = F5B_save_global_chart(f->myChart, Domain_hid);
646
647 F5printf(10,"F5LTcreate(): Coordinate domain not found, creating file entry. Done!");
648 }
649 GlobalChartAnchor_hid = H5Gcreate2(Domain_hid, coordinate_system,
650 H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT);
651
652 H5Gclose(Domain_hid);
653
654 /* TODO: Check if these links already exist, if they are consistent,
655 and create them ONLY if they are required to make new.
656 */
657
658 /* a link from the local chart to the global chart */
659 F5Glink(f->Chart_hid, H5G_LINK_SOFT, chart_anchor, FIBER_HDF5_CHART_TO_GLOBALCHART_REF ) ;
660
661 strcpy(chart_anchor, "/" FIBER_HDF5_GLOBAL_CHARTS "/");
662 strcat(chart_anchor, f->myChart->domain_name);
663
664 H5E_BEGIN_TRY
665 /* a link from the global chart to the coordinate type (cartesian coordinates) */
666 F5Glink(GlobalChartAnchor_hid, H5G_LINK_HARD,
667 chart_anchor,
669 H5E_END_TRY
670
671 H5Gclose(GlobalChartAnchor_hid);
672 }
ChartDomain_IDs * F5B_save_global_chart(const ChartDomain_IDs *MemoryIDs, hid_t Domain_hid)
Definition F5Bchart.c:801
ChartDomain_IDs * F5FB_read_global_chart(F5Path *f)
Definition F5B.c:14
F5Path * newF5Path(hid_t File_id)
Definition F5Path.c:5
#define FIBER_HDF5_CHARTS_PER_GRID
Definition F5defs.h:110
#define FIBER_HDF5_GLOBAL_CHARTS
Definition F5defs.h:109
#define FIBER_HDF5_GLOBALCHART_COORDINATES
Definition F5defs.h:112
#define FIBER_HDF5_CHART_TO_GLOBALCHART_REF
Definition F5defs.h:111
herr_t F5Glink(hid_t loc_id, H5G_link_t link_type, const char *current_name, const char *new_name)
Definition F5private.c:162
void F5I_add_grid(F5Path *fpath, const char *gridname, const double *time)
Definition F5private.c:230
hid_t F5I_create_contents(hid_t File_id)
Definition F5private.c:103
int F5LTset_maximal_grid_refinement(hid_t ContentsGroup_id, const char *gridname, int IndexDepth, int Dimensionality, const hsize_t *refinement)
Definition F5LT.c:240
hid_t F5LTcreate_topology(hid_t Grid_hid, const char *TopologyName, int IndexDepth, int SkeletonDimensionality, int DataspaceDimensionality, const hsize_t *refinement)
Definition F5LT.c:329
F5_API hid_t F5Bappend_slice(hid_t file_id, const double *time)
Definition F5Bslice.c:140
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

References F5Path::Chart_hid, F5Path::Charts_hid, F5Path::ContentsGroup_hid, deleteF5Path(), ChartDomain_IDs::domain_name, F5B_save_global_chart(), F5Bappend_slice(), F5FB_read_global_chart(), F5Gappend(), F5Gexist(), F5Glink(), F5Gtry_to_open(), F5I_add_grid(), F5I_create_contents(), F5LTcreate_topology(), F5LTset_maximal_grid_refinement(), F5printf, F5printf_indent, FIBER_HDF5_CHART_TO_GLOBALCHART_REF, FIBER_HDF5_CHARTS_PER_GRID, FIBER_HDF5_GLOBAL_CHARTS, FIBER_HDF5_GLOBALCHART_COORDINATES, F5Path::field_enum_type_hid, F5Path::FileIDs, F5Path::GlobalChart_hid, F5Path::Grid_hid, H5Gclose, F5Path::myChart, newF5Path(), ChartDomain_IDs::refs, F5Path::Representation_hid, F5Path::Slice_hid, F5Path::Topology_hid, and TopologyName().

Referenced by F5LTcreate().

◆ F5LTget_index_depth()

F5_API int F5LTget_index_depth ( hid_t Top_hid)

Get the index depth of a certain Topology ID.

Definition at line 21 of file F5LT.c.

22{
23int IndexDepth = 0;
24
25 if (F5Aget_ints(Top_hid, FIBER_HDF5_INDEXDEPTH_ATTRIB, &IndexDepth, 1) <= 0)
26 {
27 F5printf(5," *Warning* F5LTget_index_depth() could not find index depth attribute!");
29 }
30
31 return IndexDepth;
32}
long F5Aget_ints(hid_t loc_id, const char *name, int *data, hsize_t n)
Definition F5A.c:406
#define F5_INVALID_INDEX_DEPTH
Definition F5defs.h:233

References F5_INVALID_INDEX_DEPTH, F5Aget_ints(), F5printf, and FIBER_HDF5_INDEXDEPTH_ATTRIB.

◆ F5LTget_maximal_grid_refinement()

F5_API int F5LTget_maximal_grid_refinement ( hid_t ContentsGroup_id,
const char * gridname,
hsize_t * refinement )

Get the maximal refinement level for a certain Grid.

hsize_t MaxRefinement[ FIBER_MAX_RANK ];
int Dims;
Dims = F5LTget_maximal_grid_refinement(fpath->ContentsGroup_hid, "MyGridOfInterest", MaxRefinement);
F5_API int F5LTget_maximal_grid_refinement(hid_t ContentsGroup_id, const char *gridname, hsize_t *refinement)
Definition F5LT.c:192

Definition at line 192 of file F5LT.c.

195{
196hid_t GridsTable ;
197hid_t GridInfo ;
198int Dims;
199
200 if (!gridname || !refinement) return 0;
201 GridsTable = F5Gappend(ContentsGroup_id, FIBER_CONTENT_GRIDS);
202 GridInfo = F5Gappend(GridsTable, gridname);
203
204 Dims = F5LAget_dimensions(GridInfo, FIBER_HDF5_REFINEMENT_INFO, refinement );
205
206 H5Gclose(GridsTable);
207 H5Gclose(GridInfo);
208 return Dims;
209}
#define FIBER_CONTENT_GRIDS
Definition F5defs.h:24
int F5LAget_dimensions(hid_t Field_id, const char *aname, hsize_t dims[FIBER_MAX_RANK])
Definition F5A.c:233

References F5Gappend(), F5LAget_dimensions(), FIBER_CONTENT_GRIDS, FIBER_HDF5_REFINEMENT_INFO, and H5Gclose.

◆ F5LTget_maximal_skeleton_refinement()

F5_API int F5LTget_maximal_skeleton_refinement ( hid_t ContentsGroup_id,
const char * gridname,
hsize_t * refinement,
int IndexDepth,
int Dimensionality )

Get the maximal refinement level for a certain topological property of a Grid. For example, get the maximum refinement level for faces on a Grid:

hsize_t MaxRefinement[ FIBER_MAX_RANK ];
int Dims;
Dims = F5LTget_maximal_skeleton_refinement(fpath->ContentsGroup_hid, "MyGridOfInterest", MaxRefinement, 1, 2);
F5_API int F5LTget_maximal_skeleton_refinement(hid_t ContentsGroup_id, const char *gridname, hsize_t *refinement, int IndexDepth, int Dimensionality)
Definition F5LT.c:211

Definition at line 211 of file F5LT.c.

216{
217hid_t GridsTable ;
218hid_t GridInfo ;
219int Dims;
220char RefinementAttributeName[1024] = FIBER_HDF5_REFINEMENT_INFO;
221
222 if (!gridname || !refinement) return 0;
223 GridsTable = F5Gappend(ContentsGroup_id, FIBER_CONTENT_GRIDS);
224 GridInfo = F5Gappend(GridsTable, gridname);
225
226 if (IndexDepth!=0) // if not vertices
227 {
228 snprintf(RefinementAttributeName, sizeof(RefinementAttributeName),
229 FIBER_HDF5_REFINEMENT_INFO "<%d>[%d]", IndexDepth, Dimensionality);
230 }
231
232 Dims = F5LAget_dimensions(GridInfo, RefinementAttributeName, refinement );
233
234 H5Gclose(GridsTable);
235 H5Gclose(GridInfo);
236 return Dims;
237}

References F5Gappend(), F5LAget_dimensions(), FIBER_CONTENT_GRIDS, FIBER_HDF5_REFINEMENT_INFO, and H5Gclose.

◆ F5LTset_maximal_grid_refinement()

F5_API int F5LTset_maximal_grid_refinement ( hid_t ContentsGroup_id,
const char * gridname,
int IndexDepth,
int Dimensionality,
const hsize_t * refinement )

Update the maximal refinement level for a certain Grid.

Parameters
IndexDepthThere can be different levels of refinement depending on the topological type of the Skeleton. Usually refinement will only be relevant for vertices, thus IndexDepth=0, but it is also possible for higher dimensional skeletons such as edges, lines, triangles...

Definition at line 240 of file F5LT.c.

245{
246hid_t GridsTable ;
247hid_t GridInfo ;
248hsize_t CurrentRefinement[ FIBER_MAX_RANK ];
249int CurrentDimensionality, i;
250int AllFine = 0;
251char RefinementAttributeName[1024] = FIBER_HDF5_REFINEMENT_INFO;
252
253 F5printf(30, "int F5LTset_maximal_grid_refinement(F5Path*fpath,%s, %d, %p)\n", gridname, Dimensionality, refinement);
254
255 if (!gridname)
256 {
257 F5printf(35, "F5LTset_maximal_grid_refinement(f->ContentsGroup_hid, gridname, Dimensionality, refinement); - NO GRIDNAME");
258 return AllFine;
259 }
260 if (!refinement)
261 {
262 F5printf(35, "F5LTset_maximal_grid_refinement(f->ContentsGroup_hid, gridname, Dimensionality, refinement); - NO REFINEMENT");
263 return AllFine;
264 }
265
266 GridsTable = F5Gappend(ContentsGroup_id, FIBER_CONTENT_GRIDS);
267 GridInfo = F5Gappend(GridsTable, gridname);
268
269 if (IndexDepth!=0) // if not vertices
270 {
271 snprintf(RefinementAttributeName, sizeof(RefinementAttributeName),
272 FIBER_HDF5_REFINEMENT_INFO "<%d>[%d]", IndexDepth, Dimensionality);
273 }
274
275 CurrentDimensionality = F5LAget_dimensions(GridInfo, RefinementAttributeName, CurrentRefinement );
276
277 if (CurrentDimensionality<1)
278 {
279 F5printf(35, "F5LTset_maximal_grid_refinement(f->ContentsGroup_hid, gridname, Dimensionality, refinement); - SAVE NEW %d",
280 (int)refinement[0] );
281
282 F5LAsave_dimensions(GridInfo, RefinementAttributeName, Dimensionality, refinement);
283 AllFine = 1;
284 }
285 else
286 {
287 if (CurrentDimensionality==Dimensionality)
288 {
289 int UpdateRefinement = 0;
290
291 for(i=0; i<CurrentDimensionality; i++)
292 {
293 if (CurrentRefinement[i] < refinement[i] )
294 {
295 UpdateRefinement = 1;
296 CurrentRefinement[i] = refinement[i];
297 }
298 }
299
300 if (UpdateRefinement)
301 {
302 F5printf(35, "F5LTset_maximal_grid_refinement(f->ContentsGroup_hid, gridname, Dimensionality, refinement); - UPDATE to %d",
303 (int)CurrentRefinement[0] );
304 F5LAsave_dimensions(GridInfo, RefinementAttributeName, Dimensionality, CurrentRefinement);
305 }
306 else
307 {
308 F5printf(35, "F5LTset_maximal_grid_refinement(f->ContentsGroup_hid, gridname, Dimensionality, refinement); - NO UPDATE REQUIRED for %d",
309 (int)CurrentRefinement[0] );
310 }
311 AllFine = 1;
312 }
313 else
314 {
315 F5printf(0, "int F5LTset_maximal_grid_refinement(F5Path*fpath,%s, %dD, []): New refinement dimensions do not match stored ones (stored: %dD) - NOT UPDATED\n",
316 gridname, Dimensionality, CurrentDimensionality );
317 }
318 }
319
320 H5Gclose(GridsTable);
321 H5Gclose(GridInfo);
322 return AllFine;
323}

References F5Gappend(), F5LAget_dimensions(), F5LAsave_dimensions(), F5printf, FIBER_CONTENT_GRIDS, FIBER_HDF5_REFINEMENT_INFO, FIBER_MAX_RANK, and H5Gclose.

Referenced by F5LTcreateV().

◆ F5Lwrite()

F5_API hid_t F5Lwrite ( hid_t R_id,
const char * fieldname,
int dimension,
const hsize_t * dims,
hid_t fieldtype,
hid_t memtype,
const void * dataPtr,
hid_t enum_type,
hid_t dcpl_id )
Returns
A HDF5 dataset ID. The caller must issue H5Dclose() on the returned identifier.
Parameters
property_idAn HDF5 dataset property ID. If it is negative, then a default property will be created locally via
H5Pcreate(H5P_DATASET_CREATE)
.
dimensionThe dimensionality of the data set. You may use F5Lwrite1D() as a convenience shortcut for one-dimensional data sets.
dimsThe extension of the data set.
Note
Fields are always associated to certain coordinates system. The field type must be consistent with its coordinate system, e.g. one may not store a vector field in polar coordinates in a cartesian chart. Formally, this can be done because not all API functions have the ability to check for this consistency. However, a field type which is not part of a certain coordinate system will be treated as non-existent when reading the file later.
If a field is a structure made by separate data arrays, e.g. a vector field with components x,y,z stored as three arrays of floats, then use function F5Lwrites().
Parameters
enum_typeThe Atomic Field enumeration type that is associated with the current file. Get it via F5LTmake_enum_type(fpath).
Todo
Expose xfer_plist_id parameter
Returns
An HDF5 dataset ID. The caller must issue H5Dclose() on the returned identifier.

Definition at line 357 of file F5L.c.

360{
361hid_t id;
362 if (fieldtype<=0)
363 {
364 F5printf(3, "F5Lwrite(%d,%s,%d,...): INVALID field type %d!",
365 (int)R_id, fieldname, dimension, (int)fieldtype );
366 return -1;
367 }
368 if (!dataPtr) /* possibly create a null data space? */
369 {
370 F5printf(3, "F5Lwrite(%d,%s,%d,...): WARNING - NO DATA!\n",
371 (int)R_id, fieldname, dimension );
372 }
373
374 id = F5Lcreate(R_id, fieldname, dimension, dims, fieldtype, dcpl_id);
375 if (!F5Tcheck_committed(fieldtype))
376 F5printf(10, "F5 Warning: F5Lwrite(%s): type not committed!\n", fieldname);
377
378 if (id<0)
379 {
380 F5printf(3, "F5Lwrite(%d,%s,%d,...): Could not create field!",
381 (int)R_id, fieldname, dimension);
382 return -2;
383 }
384
385 F5printf(30, "F5Lwrite(): Field created, set enum");
386 F5Tset_field_enum(id, enum_type, Contiguous);
387
388 {
389 hid_t xfer_plist_id = H5P_DEFAULT;
390 if (dataPtr)
391 {
392 herr_t err = H5Dwrite(id, memtype>0?memtype:fieldtype, H5S_ALL, H5S_ALL, xfer_plist_id, dataPtr);
393
394 /* Returns a non-negative value if successful; otherwise returns a negative value. */
395 if (err<0)
396 {
397 F5printf(3, "F5Lwrite(%d,%s,%d,...): Could not write field!",
398 (int)R_id, fieldname, dimension);
399 H5Dclose( id );
400 return -3;
401 }
402 }
403 }
404
405 return id;
406}
int F5Tcheck_committed(hid_t fieldtype)
Definition F5L.c:34
@ Contiguous
Definition F5defs.h:269
herr_t F5Tset_field_enum(hid_t loc_id, hid_t enum_type_id, ArrayType what)
Definition F5types.c:268
hid_t F5Lcreate(hid_t R_id, const char *fieldname, int dimension, const hsize_t *dims, hid_t fieldtype, hid_t dataset_creation_property_id)
Definition F5L.c:60

References Contiguous, F5Lcreate(), F5printf, F5Tcheck_committed(), and F5Tset_field_enum().

Referenced by F5Fwrite_flexible(), F5Fwrite_fraction(), F5FwriteIMAGE(), F5Lwrite1D(), F5Lwrite_fraction(), F5Lwrite_fraction_external(), and F5Rcreate_uniform_sparse().

◆ F5Lwrite1D()

F5_API 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 )

Convenience function for writing one-dimensional data. Calls F5Lwrite();

Definition at line 408 of file F5L.c.

411{
412 return F5Lwrite(R_id, fieldname, 1, &nElements,
413 fieldtype, memtype, dataPtr, enum_type, property_id);
414
415}
hid_t F5Lwrite(hid_t R_id, const char *fieldname, int dimension, const hsize_t *dims, hid_t fieldtype, hid_t memtype, const void *dataPtr, hid_t enum_type, hid_t dcpl_id)
Definition F5L.c:357

References F5Lwrite().

Referenced by F5Fwrite_1D(), F5Rcreate_rectilinear(), F5write_particle_cartesian3Dv(), F5write_particle_cartesian3DvU(), and F5write_particle_double_cartesian3Dv().

◆ F5Lwrite_entity()

F5_API hid_t F5Lwrite_entity ( hid_t R_id,
const char * fieldname,
hid_t fieldtype,
const void * value )

Write a field that is a constant for all elements.

Returns
A HDF5 dataset ID. The caller must issue H5Dclose() on the returned identifier.

Definition at line 1029 of file F5L.c.

1032{
1033hid_t ds_id = H5Screate(H5S_SCALAR);
1034hid_t creator_id = H5Pcreate(H5P_DATASET_CREATE);
1035
1036hid_t F_id = H5Dcreate2(R_id, fieldname, fieldtype, ds_id, creator_id, H5P_DEFAULT, H5P_DEFAULT);
1037\
1038 H5Dwrite(F_id, fieldtype, H5S_ALL, H5S_ALL, H5P_DEFAULT, value);
1039
1040 H5Sclose(ds_id);
1041 H5Pclose(creator_id);
1042
1043 return F_id;
1044}

◆ F5Lwrite_fraction()

F5_API hid_t F5Lwrite_fraction ( hid_t R_id,
const char * fieldname,
int dimension,
const hsize_t * full_dims,
const hsize_t * datasize,
hid_t fieldtype,
hid_t memtype,
const void * dataPtr,
const hsize_t * datastart,
const hsize_t * start_border,
const hsize_t * end_border,
const char * fraction_name,
hid_t enum_type,
hid_t property_id )

Write a dataset which only covers a fraction of the entire representation's domain.

Parameters
dimensionThe dimension of the data set.
datastartThe (multidimensional) start index of the saved data set.
dataendThe (multidimensional) end index of the saved data set.
fraction_nameAn optional string to name this fraction. It may be NULL to use an internal default.
Note
Subsampling can not be specified here. Subsampled data need to go into another Topology group.
Returns
A HDF5 dataset ID. The caller must issue H5Dclose() on the returned identifier.

Definition at line 631 of file F5L.c.

639{
640hid_t F_id, B_id;
641
642 if (!datastart)
643 {
644 F5printf(0, "F5Lwrite_fraction() for field %s has no datastart given for fragment %s",
645 fieldname, fraction_name);
646 return -1;
647 }
648
649 F5printf(20, "F5Lwrite_fraction(rank=%d)", rank);
650 if (rank==3)
651 F5printf(20, "F5Lwrite_fraction(%lux%lux%lu)",
652 (long)datasize[0], (long)datasize[1], (long)datasize[2]);
653
654 F_id = F5Gappend(R_id, fieldname);
655 if (F_id<0)
656 {
657 F5printf(1, "F5Lwrite_fraction() - FAILED to append field fragment group.");
658 return F_id;
659 }
660
661 {
662 char myBlockname[ MAX_BLOCKNAME ];
663 B_id = F5Lwrite(F_id, fraction_name?fraction_name:blockname(myBlockname, rank, datastart),
664 rank, datasize, fieldtype, memtype, dataPtr, enum_type, property_id);
665 }
666 if (B_id<=0)
667 {
668 F5printf(1, "F5Lwrite_fraction() - FAILED to append field fragment data.");
669 F5Xclose(F_id);
670 return B_id;
671 }
672
673 if (full_dims)
674 F5Lset_space(F_id, rank, full_dims);
675
676 if (1 != F5LAsave_dimensions(B_id, FIBER_FRAGMENT_OFFSET_ATTRIBUTE, rank, datastart))
677 {
678 F5printf(1, "F5Lwrite_fraction() - FAILED to write FIBER_FRAGMENT_OFFSET_ATTRIBUTE");
679 }
680
681 if (start_border)
683
684 if (end_border)
686
687 F5Xclose(B_id);
688 return F_id;
689}

References F5Gappend(), F5LAsave_dimensions(), F5Lset_space(), F5Lwrite(), F5printf, F5Xclose(), FIBER_FRAGMENT_NOOVERLAP_END_ATTRIBUTE, FIBER_FRAGMENT_NOOVERLAP_START_ATTRIBUTE, FIBER_FRAGMENT_OFFSET_ATTRIBUTE, and MAX_BLOCKNAME.

Referenced by F5Fwrite_fraction().

◆ F5Lwrite_linear()

F5_API hid_t F5Lwrite_linear ( hid_t R_id,
const char * fieldname,
int dimension,
const hsize_t * dims,
hid_t fieldtype,
const void * base,
const void * delta )

Write a field that is a linear map from coordinate indices to some data value.

Todo
Remove dimension parameter, it is clear from the fieldtype's members.
Parameters
dimsThe extensions of an HDF5 dataspace.
Returns
A HDF5 group ID. The caller must issue H5Gclose() on the returned identifier.

Write a field that is a linear map from coordinate indices to some data value.

Returns
A HDF5 group ID. The caller must issue H5Gclose() on the returned identifier.

Definition at line 852 of file F5L.c.

855{
856hid_t F_id;
857hid_t space_hid;
858hid_t attr_hid;
859
860/*
861int rank = H5Tget_nmembers( fieldtype );
862 if (rank<1)
863 {
864 F5printf(5, "F5Lwrite_linear(%s): Unknown field type!\n", fieldname);
865 return -1;
866 }
867*/
868
869 H5E_BEGIN_TRY
870 F_id = F5Gcreate(R_id, fieldname, 0, 0);
871 H5E_END_TRY
872
873 if (F_id<0)
874 {
875 F5printf(50, "F5 Warning: F5Lwrite_linear(%s): cannot create group (already exists?)\n", fieldname);
876 return -1;
877 }
878
879 if (!F5Tcheck_committed(fieldtype))
880 printf("F5 Warning: F5Lwrite_linear(%s): type not committed!\n", fieldname);
881
882 /* Set the dataspace attribute */
883/* F5Lset_space(F_id, rank, dims); */
884
885 F5Lset_space(F_id, dimension, dims);
886
887 space_hid = H5Screate(H5S_SCALAR);
888
889 attr_hid = H5Acreate2(F_id, FIBER_UNIFORMARRAY_BASE_ATTRIBUTE, fieldtype, space_hid,
890 H5P_DEFAULT, H5P_DEFAULT);
891 /* Write scalar attribute. */
892 H5Awrite(attr_hid, fieldtype, base );
893 /* Close attribute. */
894 H5Aclose(attr_hid);
895
896
897 attr_hid = H5Acreate2(F_id, FIBER_UNIFORMARRAY_DELTA_ATTRIBUTE, fieldtype, space_hid,
898 H5P_DEFAULT, H5P_DEFAULT);
899 /* Write scalar attribute. */
900 H5Awrite(attr_hid, fieldtype, delta );
901 /* Close attribute. */
902 H5Aclose(attr_hid);
903
904 /* Close attribute dataspace. */
905 H5Sclose(space_hid);
906
907 return F_id;
908}
hid_t F5Gcreate(hid_t loc_id, const char *name, int est_num_entries, int est_name_len)
Definition F5X.c:65

References F5Gcreate(), F5Lset_space(), F5printf, F5Tcheck_committed(), FIBER_UNIFORMARRAY_BASE_ATTRIBUTE, and FIBER_UNIFORMARRAY_DELTA_ATTRIBUTE.

Referenced by F5Fwrite_linear(), and F5Fwrite_linear_fraction().

◆ F5LwriteS()

F5_API hid_t F5LwriteS ( hid_t Container_id,
const char * name,
int dimension,
const hsize_t * dims,
hid_t fieldtype,
hid_t memtype,
const void * dataPtr,
hid_t enum_type,
hid_t dcpl_id )

Write a contiguous compound data set as separated compound data into the file, which involves data transformation.

Returns
The ID of the group, i.e. Container_id -> name

Definition at line 418 of file F5L.c.

421{
422int nComponents;
423hid_t id;
424 if (fieldtype<=0)
425 {
426 F5printf(30, "F5LwriteS(%d,%s,%d,...): INVALID field type %d!",
427 (int)R_id, fieldname, dimension, (int)fieldtype );
428 return -1;
429 }
430
431 if ( H5Tget_class( fieldtype ) != H5T_COMPOUND )
432 {
433 F5printf(30, "F5LwriteS(%d,%s,%d,...): Not a compound type %d!",
434 (int)R_id, fieldname, dimension, (int)fieldtype );
435 return -1;
436 }
437 if (!F5Tcheck_committed(fieldtype))
438 printf("F5 Warning: F5LwriteS(%s): type not committed!\n", fieldname);
439
440
441 if (!dataPtr)
442 {
443 F5printf(30, "F5LwriteS(%d,%s,%d,...): WARNING - NO DATA!\n",
444 (int)R_id, fieldname, dimension );
445 }
446
447 nComponents = H5Tget_nmembers(fieldtype);
448
449 id = F5Gappend(R_id, fieldname);
450
451//OR id = F5Gcreate(R_id, fieldname, Ncomponents, 16);
452
453 if (id<0)
454 {
455 F5printf(30, "F5LwriteS(%d,%s,%d,...): Could not create compound group!",
456 (int)R_id, fieldname, dimension);
457 return -1;
458 }
459
460 F5printf(30, "F5Lwrite(): Field created, set enum");
461 F5Tset_field_enum(id, enum_type, SeparatedCompound);
462 F5Dset_type_attribute(id, fieldtype);
463
464 if (!dataPtr)
465 return id;
466
467 {
468 hid_t ds_id = H5Screate_simple(dimension, dims, NULL);
469 int comp;
470 herr_t herr;
471
472 for(comp=0; comp<nComponents; comp++)
473 {
474 char* ComponentName = H5Tget_member_name(fieldtype, comp);
475 hid_t ComponentType = H5Tget_member_type(fieldtype, comp);
476 hid_t MemComponentType;
477 if (memtype)
478 {
479 /* Retrieves the index of a compound or enumeration datatype member. */
480 int mem_idx = H5Tget_member_index(memtype, ComponentName);
481 if (mem_idx<0)
482 {
483 F5printf(10, "**F5LwriteS(%s) could not find memory equivalent "
484 " of save component %s!",
485 fieldname, ComponentName);
486 MemComponentType = ComponentType;
487 H5Iinc_ref( MemComponentType );
488 }
489 else
490 {
491 F5printf(10, "F5LwriteS(%s): member type %s : %d -> %d",
492 fieldname, ComponentName, mem_idx, comp);
493 MemComponentType = H5Tget_member_type(memtype, mem_idx);
494 }
495 }
496 else
497 {
498 MemComponentType = ComponentType;
499 H5Iinc_ref( MemComponentType );
500 }
501
502 hid_t D_id = H5Dcreate2(id, ComponentName, ComponentType, ds_id,
503 H5P_DEFAULT, /* link creation */
504 dcpl_id, /* dataset creation */
505 H5P_DEFAULT); /* dataset access */
506
507
508 /* setup hyperslab for data writing
509 */
510 {
511 hid_t xfer_plist_id = H5P_DEFAULT;
512 hid_t mem_space_id;
513 hsize_t mem_dataspace[FIBER_MAX_RANK];
514 hsize_t start [FIBER_MAX_RANK];
515 hsize_t stride[FIBER_MAX_RANK];
516
517 const int FastestDimension = dimension-1;
518 int k;
519 for(k=0; k<dimension; k++)
520 {
521 mem_dataspace[k] = dims[k];
522 start[k] = 0;
523 stride[k] = 1;
524 }
525 mem_dataspace[FastestDimension] = nComponents*dims[FastestDimension];
526 start [FastestDimension] = comp;
527 stride[FastestDimension] = nComponents; //nDimensions;
528
529 mem_space_id = H5Screate_simple(dimension, mem_dataspace, NULL);
530 H5Sselect_hyperslab(mem_space_id, H5S_SELECT_SET, start, stride, dims, NULL);
531
532 herr = H5Dwrite(D_id, MemComponentType, mem_space_id, H5S_ALL, xfer_plist_id, dataPtr);
533
534 if (herr<0)
535 F5printf(1, "**F5LwriteS(%s) could not save component %s!",
536 fieldname, ComponentName);
537 }
538
539 H5Dclose(D_id);
540 H5free_memory(ComponentName);
541 H5Tclose( ComponentType );
542 H5Tclose( MemComponentType );
543 }
544
545 H5Sclose( ds_id );
546 }
547
548 return id;
549}
@ SeparatedCompound
Definition F5defs.h:270

References F5Dset_type_attribute(), F5Gappend(), F5printf, F5Tcheck_committed(), F5Tset_field_enum(), FIBER_MAX_RANK, H5Tclose(), and SeparatedCompound.

Referenced by F5Lwrite_fractionS().

◆ F5Lwrites()

F5_API hid_t F5Lwrites ( hid_t R_id,
const char * fieldname,
int dimension,
const hsize_t * dims,
hid_t fieldtype,
hid_t memtype,
const void *const * dataPtr,
hid_t enum_type,
hid_t property_id )
Parameters
enum_typeThe Atomic Field enumeration type that is associated with the current file. Get it via F5LTmake_enum_type(fpath).
Returns
A HDF5 group ID. The caller must issue H5Gclose() on the returned identifier.
Todo
should be named F5DSwrite() instead
Returns
A HDF5 group ID. The caller must issue H5Gclose() on the returned identifier.
Note
If some component array is undefined (NULL), then its place will be left empty in the file.

Definition at line 1096 of file F5L.c.

1099{
1100hid_t ds_id = H5Screate_simple(dimension, dims, NULL);
1101hid_t creator_id = property_id<0 ? H5Pcreate(H5P_DATASET_CREATE) : property_id;
1102hid_t F_id = -1;
1103
1104 if (dimension==3)
1105 F5printf(10, "F5Lwrites(field=%s) %dx%dx%d",
1106 fieldname, (int)dims[0], (int)dims[1], (int)dims[2] );
1107 else
1108 F5printf(10, "F5Lwrites(field=%s)\n", fieldname);
1109
1110
1111 if (!F5Tcheck_committed(fieldtype))
1112 printf("F5 Warning: F5Lwrites(%s): type not committed!\n", fieldname);
1113
1114 switch( H5Tget_class( fieldtype ) )
1115 {
1116 case H5T_COMPOUND:
1117 {
1118 int comp;
1119 int Ncomponents = H5Tget_nmembers(fieldtype);
1120
1121 F_id = F5Gcreate(R_id, fieldname, Ncomponents, 16);
1122 if (F_id<0)
1123 F5printf(1, "**F5Lwrites(%s) could not create separated compound group!",
1124 fieldname);
1125
1126 F5Dset_type_attribute(F_id, fieldtype);
1127 F5Tset_field_enum(F_id, enum_type, SeparatedCompound);
1128
1129 for(comp=0; comp<Ncomponents; comp++)
1130 {
1131 hid_t id, ComponentType, MemComponentType;
1132 char * ComponentName;
1133 const void * data = dataPtr[comp];
1134 herr_t herr;
1135
1136 if (!data) continue;
1137 ComponentName = H5Tget_member_name(fieldtype, comp);
1138 ComponentType = H5Tget_member_type(fieldtype, comp);
1139 if (memtype)
1140 {
1141 /* Retrieves the index of a compound or enumeration datatype member. */
1142 int mem_idx = H5Tget_member_index(memtype, ComponentName);
1143 if (mem_idx<0)
1144 {
1145 F5printf(10, "**F5Lwrites(%s) could not find memory equivalent "
1146 " of save component %s!",
1147 fieldname, ComponentName);
1148 MemComponentType = ComponentType;
1149 H5Iinc_ref( MemComponentType );
1150 }
1151 else
1152 {
1153 F5printf(10, "F5Lwrites(%s): member type %s : %d -> %d",
1154 fieldname, ComponentName, mem_idx, comp);
1155
1156 data = dataPtr[mem_idx];
1157 MemComponentType = H5Tget_member_type(memtype, mem_idx);
1158 }
1159 }
1160 else
1161 {
1162 MemComponentType = ComponentType;
1163 H5Iinc_ref( MemComponentType );
1164 }
1165
1166 id = H5Dcreate2(F_id, ComponentName, ComponentType, ds_id, creator_id, H5P_DEFAULT, H5P_DEFAULT);
1167 herr = H5Dwrite(id, MemComponentType, H5S_ALL, H5S_ALL, H5P_DEFAULT, data);
1168 if (herr<0)
1169 F5printf(1, "**F5Lwrites(%s) could not save component %s!",
1170 fieldname, ComponentName);
1171
1172 H5Dclose(id);
1173 H5free_memory(ComponentName);
1174 H5Tclose(ComponentType);
1175 H5Tclose( MemComponentType );
1176 }
1177 break;
1178 }
1179
1180 case H5T_FLOAT:
1181 {
1182 F_id = H5Dcreate2(R_id, fieldname, fieldtype, ds_id, creator_id, H5P_DEFAULT, H5P_DEFAULT);
1183 H5Dwrite(F_id, memtype, H5S_ALL, H5S_ALL, H5P_DEFAULT, *dataPtr);
1184 F5Tset_field_enum(F_id, enum_type, Contiguous);
1185 break;
1186 }
1187
1188 default:
1189 F5printf(-1, "F5Lwrites(field=%s) CANNOT WRITE SPECIFIED FIELD TYPE as seperated compound, because it is not a compound\n", fieldname, F_id);
1190 break;
1191 }
1192 H5Sclose(ds_id);
1193
1194 if (property_id<0)
1195 H5Pclose(creator_id);
1196
1197 F5printf(10, "~F5Lwrites(field=%s), id=%d\n", fieldname, F_id);
1198 return F_id;
1199}

References Contiguous, F5Dset_type_attribute(), F5Gcreate(), F5printf, F5Tcheck_committed(), F5Tset_field_enum(), H5Tclose(), and SeparatedCompound.

Referenced by F5FSwrite_fraction(), F5Fwrites(), and F5LSwrite_fraction().