FiberBundleHDF5  FiberHDF5 Documentation, Revision 2026
High-Performance Fiber Bundle Data Model for Scientific Visualization
Loading...
Searching...
No Matches
F5T.c File Reference
#include "F5T.h"
#include "F5A.h"
#include "F5private.h"

Go to the source code of this file.

Functions

hid_t F5Tcommit (hid_t save_location, const char *name, hid_t TransientTypeID)
hid_t F5Tappend (hid_t loc_id, const char *name, hid_t type_id)
void F5Tclose (hid_t type_id)
const char * F5Tget_precision_name (int TypeSize)
hid_t F5Tsave_tensor (hid_t Domain_hid, const char *domain_name, const char *type_name, hid_t transient_type, int rank, int indices[], int grade)
hid_t F5Tmake_precise_tensor (F5Path *fpath, const char *type_name, int TypeBytePrecision, hid_t transient_type, int rank, int indices[], int grade)

Function Documentation

◆ F5Tappend()

hid_t F5Tappend ( hid_t loc_id,
const char * name,
hid_t type_id )

Open some type if it exists, otherwise create one.

Definition at line 25 of file F5T.c.

26{
27hid_t FileType_id;
28 H5E_BEGIN_TRY
29 FileType_id = H5Topen2(loc_id, name, H5P_DEFAULT);
30 H5E_END_TRY
31
32
33 if (FileType_id<0)
34 {
35 FileType_id = F5Tcommit(loc_id, name, type_id);
36 }
37 else
38 {
39 F5printf(1,"F5Tappend(,name=%s,)", name);
40
41 if (H5Tequal(FileType_id, type_id) != 1)
42 return 0;
43 }
44 return FileType_id;
45}
name
Definition F5P.c:82
hid_t F5Tcommit(hid_t save_location, const char *name, hid_t TransientTypeID)
Definition F5T.c:6
#define F5printf(verbosity,...)
Definition F5private.h:60

References F5printf, F5Tcommit(), and name.

Referenced by F5file_type().

◆ F5Tclose()

void F5Tclose ( hid_t type_id)

Close a HDF5 Type ID if it's a valid identifier, otherwise silently ignore.

Definition at line 49 of file F5T.c.

50{
51 if (type_id>0)
52 H5Tclose(type_id);
53}
H5Tclose(type_id)

References H5Tclose().

Referenced by F5B_delete_tangential_types().

◆ F5Tcommit()

hid_t F5Tcommit ( hid_t save_location,
const char * name,
hid_t TransientTypeID )

Save a type to a file and return a copy of the type ID.

Note
The returned HDF5 id must be released via H5Tclose().
Parameters
save_locationWhere to save the type, must be some group ID
nameThe name of the type
TransientTypeIDThe intrinsic type ID
Returns
A type Id which is bound to the file to which save_location belongs

Definition at line 6 of file F5T.c.

7{
8hid_t hid = H5Tcopy( TransientTypeID );
9herr_t herr;
10
11/* printf("F5Tcommit(): %s\n", name); */
12 H5E_BEGIN_TRY
13 herr = H5Tcommit2 (save_location, name, hid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT);
14 H5E_END_TRY
15
16 if (herr<0)
17 {
18/* printf("F5Tcommit(): %s FAILED\n", name); */
19 H5Tclose( hid );
20 hid = H5Topen2(save_location, name, H5P_DEFAULT);
21 }
22 return hid;
23}

References H5Tclose(), and name.

Referenced by F5Tappend(), and F5Tsave_tensor().

◆ F5Tget_precision_name()

const char * F5Tget_precision_name ( int TypeSize)

Retrieve a string corresponding to the type size, used for coordinate sub-precision.

Definition at line 56 of file F5T.c.

57{
58 switch(TypeSize)
59 {
61 case 2: return FIBER_HDF5_CHART_HALF_PRECISION ;
65
66 default: return 0;
67 }
68}
#define FIBER_HDF5_CHART_HALF_PRECISION
Definition F5T.h:18
#define FIBER_HDF5_CHART_EXTENDED_PRECISION
Definition F5T.h:21
#define FIBER_HDF5_CHART_DOUBLE_PRECISION
Definition F5T.h:20
#define FIBER_HDF5_CHART_ONEBYTE_PRECISION
Definition F5T.h:17
#define FIBER_HDF5_CHART_SINGLE_PRECISION
Definition F5T.h:19

References FIBER_HDF5_CHART_DOUBLE_PRECISION, FIBER_HDF5_CHART_EXTENDED_PRECISION, FIBER_HDF5_CHART_HALF_PRECISION, FIBER_HDF5_CHART_ONEBYTE_PRECISION, and FIBER_HDF5_CHART_SINGLE_PRECISION.

Referenced by F5Tmake_precise_tensor().

◆ F5Tmake_precise_tensor()

hid_t F5Tmake_precise_tensor ( F5Path * fpath,
const char * type_name,
int TypeBytePrecision,
hid_t transient_type,
int rank,
int indices[],
int grade )

Definition at line 115 of file F5T.c.

117{
118const char*precision_name = F5Tget_precision_name( TypeBytePrecision );
119 if (!precision_name)
120 {
121 puts("F5Tmake_precise_tensor(): Invalid Precision byte size specified!");
122 return -1;
123 }
124
125 if (transient_type <= 0)
126 {
127 puts("F5Tmake_precise_tensor(): Invalid transient type given.");
128 return -1;
129 }
130
131 {
132 hid_t type_id;
133 hid_t Domain_hid = H5Gopen2(fpath->GlobalChart_hid, fpath->myChart->domain_name, H5P_DEFAULT);
134 hid_t Precision_hid;
135 if (Domain_hid<0)
136 {
137 puts("F5Tmake_precise_tensor(): Opening DOMAIN NAME failed!");
138 return -1;
139 }
140
141 Precision_hid = H5Gopen2(Domain_hid,precision_name, H5P_DEFAULT);
142 if (Precision_hid<0)
143 {
144 puts("F5Tmake_tensor(): Opening PRECISION DOMAIN failed!");
145 return -1;
146 }
147
148 F5printf(20, " F5Tmake_tensor(,%s, %x, rank=%d,, grade=%d)", type_name, transient_type, rank, grade);
149
150 type_id = F5Tsave_tensor(Precision_hid, fpath->myChart->domain_name, type_name, transient_type, rank, indices, grade);
151
152 H5Gclose(Precision_hid);
153 H5Gclose(Domain_hid);
154
155 return type_id;
156 }
157}
hid_t F5Tsave_tensor(hid_t Domain_hid, const char *domain_name, const char *type_name, hid_t transient_type, int rank, int indices[], int grade)
Definition F5T.c:74
const char * F5Tget_precision_name(int TypeSize)
Definition F5T.c:56
#define H5Gclose(x)
Definition F5X.h:144
const char * domain_name
Definition F5Bchart.h:112
hid_t GlobalChart_hid
Definition F5Path.h:54
ChartDomain_IDs * myChart
Definition F5Path.h:33

References ChartDomain_IDs::domain_name, F5printf, F5Tget_precision_name(), F5Tsave_tensor(), F5Path::GlobalChart_hid, H5Gclose, and F5Path::myChart.

Referenced by F5file_type().

◆ F5Tsave_tensor()

hid_t F5Tsave_tensor ( hid_t Domain_hid,
const char * domain_name,
const char * type_name,
hid_t transient_type,
int rank,
int indices[],
int grade )

@TODO Specify symmetricity of the indices. @TODO Specify non-tensorial transformation rules, e.g. Christoffel symbols

Definition at line 74 of file F5T.c.

77{
78hid_t type_id = F5Tcommit(Domain_hid, type_name, transient_type);
79
80 /*
81 THIS would be nice!
82 H5Glink(type_id, H5G_LINK_SOFT, FIBER_HDF5_CHART_DOMAIN, "/Charts/" domain_name);
83 */
84
85 F5Asave_string(type_id, FIBER_HDF5_CHART_DOMAIN, domain_name);
86
87 if (rank>0 && indices)
88 {
89 if (H5Aexists(type_id, FIBER_HDF5_CHART_TENSOR_TYPE) == 0)
90 {
91 hsize_t Tdims = rank;
92 hid_t index_ds = H5Screate_simple(1, &Tdims, &Tdims ) ;
93 hid_t Rank = H5Acreate2(type_id, FIBER_HDF5_CHART_TENSOR_TYPE, H5T_NATIVE_INT, index_ds, H5P_DEFAULT, H5P_DEFAULT);
94 H5Awrite(Rank, H5T_NATIVE_INT, indices );
95 H5Aclose(Rank);
96 H5Sclose(index_ds);
97 }
98 else
99 {
100 F5printf(20, " F5Tsave_tensor(domain_name=%s, type_name=%s, %x, rank=%d,, grade=%d): Attribute \"%s\" already exists!", domain_name, type_name, transient_type, rank, grade, FIBER_HDF5_CHART_TENSOR_TYPE);
101 }
102
103 }
104
105 if (rank>0 && grade>0)
106 {
107 F5Asave_ints( type_id, FIBER_HDF5_GRADE_ATTRIBUTE, &grade, 1);
108 }
109
110 return type_id;
111}
int F5Asave_string(hid_t loc_id, const char *name, const char *buf)
Definition F5A.c:45
int F5Asave_ints(hid_t loc_id, const char *name, const int data[], hsize_t n)
Definition F5A.c:355
#define FIBER_HDF5_CHART_DOMAIN
Definition F5defs.h:113
#define FIBER_HDF5_CHART_TENSOR_TYPE
Definition F5defs.h:138
#define FIBER_HDF5_GRADE_ATTRIBUTE
Definition F5defs.h:148

References F5Asave_ints(), F5Asave_string(), F5printf, F5Tcommit(), FIBER_HDF5_CHART_DOMAIN, FIBER_HDF5_CHART_TENSOR_TYPE, and FIBER_HDF5_GRADE_ATTRIBUTE.

Referenced by F5B_save_global_chart(), and F5Tmake_precise_tensor().