FiberBundleHDF5  FiberHDF5 Documentation, Revision 2026
High-Performance Fiber Bundle Data Model for Scientific Visualization
Loading...
Searching...
No Matches
F5Bchart.c File Reference
#include "F5Bchart.h"
#include "F5F.h"
#include "F5X.h"
#include "F5defs.h"
#include "F5types.h"
#include "F5A.h"
#include "F5private.h"
#include "F5coordinates.h"
#include "F5T.h"
#include <string.h>
#include <stdlib.h>
#include <assert.h>

Go to the source code of this file.

Macros

#define new(type, size)
#define delete(ptr)
#define true   1
#define false   0
#define SAVE_MEMORDER_WITH_TYPE
#define FIBER_HDF5_ANONYMOUS_TYPENAME   "F5::TypeName%04u"

Functions

const int * F5B_fortran_permute_vector ()
hsize_t * F5B_permute_dimensions (hsize_t *target_dims, int rank, const hsize_t *source_dims, int perm_vector[FIBER_MAX_RANK], int perm_vector_size)
ChartDomain_IDsF5B_new_global_domain (const char *coordnames[], int dimension, const char *name, const int perm_vector[], int cell_dimensionality, hid_t SinglePrecisionType, hid_t DoublePrecisionType)
void F5B_init_tangential_types (F5_ChartPrecisionTypes *IDs, const char *coordnames[], int dimension, hid_t coord_type)
void F5Bchart_add_tangential_types (F5_ChartPrecisionTypes *IDs, const char *coordnames[], int dimension, hid_t coord_type)
int F5B_inject_precision_type (F5_ChartPrecisionTypes *IDs, hid_t type_id)
ChartDomain_IDsF5B_new_global_float_chart (const char *coordnames[], int dimension, const char *name, const int perm_vector[FIBER_MAX_RANK])
ChartDomain_IDsF5B_new_global_int_chart (const char *coordnames[], int dimension, const char *name, const int perm_vector[FIBER_MAX_RANK])
ChartDomain_IDsF5B_new_global_int_domain (const char *coordnames[], int dimension, const char *name, const int perm_vector[FIBER_MAX_RANK], int cell_dimensionality)
ChartDomain_IDsF5B_new_global_fragment_neighbour_domain (const char *coordnames[], int dimension, const char *name, const int perm_vector[], int cell_dimensionality)
ChartDomain_IDsF5B_new_global_fractional_domain (const char *coordnames[], int dimension, const char *name, const int perm_vector[], int cell_dimensionality)
void F5Binsert_tensor_type (ChartDomain_IDs *This, F5Ttensor_t *T)
void F5B_delete_tangential_types (F5_ChartPrecisionTypes *ID)
void F5B_delete_global_chart (ChartDomain_IDs *ID)
void F5Bchart_read_tangential_types (F5_ChartPrecisionTypes *H5Types, hid_t location)
ChartDomain_IDsF5B_read_global_chart (hid_t ChartsID, const char *name)
ChartDomain_IDsF5B_read_chart_domain (hid_t ChartDomainLocationID, const char *DefaultChartName)
ChartDomain_IDsF5B_save_global_chart (const ChartDomain_IDs *MemoryIDs, hid_t Domain_hid)
ChartDomain_IDsF5Bcopy_chart_domain (const ChartDomain_IDs *srcIDs)
void F5T_save_perm_vector (hid_t location, int rank, int perm_vector[])
int F5Bget_chart_dims (const ChartDomain_IDs *IDs)
F5_ChartPrecisionTypesF5Bget_precision_by_size (ChartDomain_IDs *CD, int TypeSize)
F5_ChartPrecisionTypesF5Bget_precision_by_type (ChartDomain_IDs *CD, hid_t type_id)
hid_t F5file_type (F5Path *fpath, hid_t fieldtype)

Macro Definition Documentation

◆ delete

#define delete ( ptr)
Value:
if (ptr) free(ptr)
free(name)

Definition at line 30 of file F5Bchart.c.

◆ false

#define false   0

Definition at line 33 of file F5Bchart.c.

◆ FIBER_HDF5_ANONYMOUS_TYPENAME

#define FIBER_HDF5_ANONYMOUS_TYPENAME   "F5::TypeName%04u"

Referenced by F5file_type().

◆ new

#define new ( type,
size )
Value:
(type*)calloc(size, sizeof(type))

Definition at line 29 of file F5Bchart.c.

◆ SAVE_MEMORDER_WITH_TYPE

#define SAVE_MEMORDER_WITH_TYPE

Definition at line 671 of file F5Bchart.c.

◆ true

#define true   1

Definition at line 32 of file F5Bchart.c.

Function Documentation

◆ F5B_delete_global_chart()

void F5B_delete_global_chart ( ChartDomain_IDs * ID)

Free the memory resources that are associated with a certain coordinate system.

Definition at line 632 of file F5Bchart.c.

633{
634 if (ID && --ID->refs == 0)
635 {
636 free( (void*)ID->domain_name);
642 free(ID);
643 }
644}
void F5B_delete_tangential_types(F5_ChartPrecisionTypes *ID)
Definition F5Bchart.c:610
F5_ChartPrecisionTypes DoublePrecision
Definition F5Bchart.h:148
F5_ChartPrecisionTypes HalfPrecision
Definition F5Bchart.h:146
const char * domain_name
Definition F5Bchart.h:112
F5_ChartPrecisionTypes SinglePrecision
Definition F5Bchart.h:147
F5_ChartPrecisionTypes OneBytePrecision
Definition F5Bchart.h:145
F5_ChartPrecisionTypes ExtendedPrecision
Definition F5Bchart.h:149
unsigned refs
Definition F5Bchart.h:114

References ChartDomain_IDs::domain_name, ChartDomain_IDs::DoublePrecision, ChartDomain_IDs::ExtendedPrecision, F5B_delete_tangential_types(), free(), ChartDomain_IDs::HalfPrecision, ChartDomain_IDs::OneBytePrecision, ChartDomain_IDs::refs, and ChartDomain_IDs::SinglePrecision.

Referenced by F5Bcoordinate_cleanup(), and F5close().

◆ F5B_delete_tangential_types()

void F5B_delete_tangential_types ( F5_ChartPrecisionTypes * IDs)

Destructor for F5_ChartPrecisionTypes.

Definition at line 610 of file F5Bchart.c.

611{
612int i;
613 assert(ID);
614
622
625
627 {
628 F5Tclose( ID->AdditionalFileTypes[ i ] );
629 }
630}
@ F5ChartPrecisionMaxNumberOfFileTypes
Definition F5Bchart.h:22
void F5Tclose(hid_t type_id)
Definition F5T.c:49
hid_t AdditionalFileTypes[F5ChartPrecisionMaxNumberOfFileTypes]
Definition F5Bchart.h:68

References _F5_ChartPrecisionTypes::AdditionalFileTypes, _F5_ChartPrecisionTypes::Bicovector_hid_t, _F5_ChartPrecisionTypes::Bivector_hid_t, _F5_ChartPrecisionTypes::Cometric_hid_t, _F5_ChartPrecisionTypes::Covector_hid_t, F5ChartPrecisionMaxNumberOfFileTypes, F5Tclose(), _F5_ChartPrecisionTypes::Metric_hid_t, _F5_ChartPrecisionTypes::Point_hid_t, _F5_ChartPrecisionTypes::Pseudocoscalar_hid_t, _F5_ChartPrecisionTypes::Pseudoscalar_hid_t, and _F5_ChartPrecisionTypes::Vector_hid_t.

Referenced by F5B_delete_global_chart().

◆ F5B_fortran_permute_vector()

const int * F5B_fortran_permute_vector ( )

Return a (static) permutation vector for fortran memory layout. It always has FIBER_MAX_RANK entries, i.e. is of the form { FIBER_MAX_RANK-1, FIBER_MAX_RANK-2, ..., 2,1,0 }

Definition at line 36 of file F5Bchart.c.

37{
38static int vals[FIBER_MAX_RANK];
39static int init = 0;
40 if (!init)
41 {
42 int i;
43 for(i=0; i< FIBER_MAX_RANK; i++)
44 {
45 vals[i] = FIBER_MAX_RANK - 1 - i;
46 }
47
48 init = 1;
49 }
50
51 return vals;
52}
#define FIBER_MAX_RANK
Definition F5defs.h:105

References FIBER_MAX_RANK.

◆ F5B_init_tangential_types()

void F5B_init_tangential_types ( F5_ChartPrecisionTypes * H5Types,
const char * coordnames[],
int dimension,
hid_t coord_type )

Initializes the Poind_hit_t with some newly constructed transient HDF5 type while setting all other entries to 0.

Definition at line 290 of file F5Bchart.c.

294{
295size_t Tsize = H5Tget_size(coord_type);
296int i;
297
298 IDs->Point_hid_t = H5Tcreate(H5T_COMPOUND, dimension*Tsize );
299 // F5printf(40, "F5B_init_tangential_types, IDs->Point_hid_t = %lli\n", IDs->Point_hid_t);
300 for(i=0; i<dimension; i++)
301 {
302 H5Tinsert(IDs->Point_hid_t, coordnames[i], i*Tsize, coord_type);
303 }
304 // F5printf(40, "F5B_init_tangential_types, IDs->Point_hid_t = %lli inserted hid_t %lli\n", IDs->Point_hid_t, coord_type);
305 IDs->Vector_hid_t = 0;
306 IDs->Covector_hid_t = 0;
307 IDs->Bivector_hid_t = 0;
308 IDs->Bicovector_hid_t = 0;
309
310 IDs->Pseudoscalar_hid_t = 0;
311 IDs->Pseudocoscalar_hid_t = 0;
312
313 IDs->Metric_hid_t = 0;
314 IDs->Cometric_hid_t = 0;
315
317 IDs->AdditionalFileTypes[ i ] = 0;
318}

References _F5_ChartPrecisionTypes::AdditionalFileTypes, _F5_ChartPrecisionTypes::Bicovector_hid_t, _F5_ChartPrecisionTypes::Bivector_hid_t, _F5_ChartPrecisionTypes::Cometric_hid_t, _F5_ChartPrecisionTypes::Covector_hid_t, F5ChartPrecisionMaxNumberOfFileTypes, _F5_ChartPrecisionTypes::Metric_hid_t, _F5_ChartPrecisionTypes::Point_hid_t, _F5_ChartPrecisionTypes::Pseudocoscalar_hid_t, _F5_ChartPrecisionTypes::Pseudoscalar_hid_t, and _F5_ChartPrecisionTypes::Vector_hid_t.

Referenced by F5B_new_global_domain().

◆ F5B_inject_precision_type()

int F5B_inject_precision_type ( F5_ChartPrecisionTypes * IDs,
hid_t type_id )

Add a type ID to the additional file types, ready to be deleted by F5B_delete_tangential_types(F5_ChartPrecisionTypes*IDs);

Definition at line 477 of file F5Bchart.c.

479{
480int i;
481
483 {
484 if (!IDs->AdditionalFileTypes[ i ])
485 {
486 IDs->AdditionalFileTypes[ i ] = type_id;
487 return 1;
488 }
489 }
490 return 0;
491}

References _F5_ChartPrecisionTypes::AdditionalFileTypes, and F5ChartPrecisionMaxNumberOfFileTypes.

Referenced by F5file_type().

◆ F5B_new_global_domain()

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 )

Creates a new chart domain object that holds just a "point" type, but no tangential types.

Definition at line 212 of file F5Bchart.c.

219{
220ChartDomain_IDs *IDs = (ChartDomain_IDs*)malloc(sizeof(ChartDomain_IDs));
221int i;
222 memset (IDs, 0, sizeof (ChartDomain_IDs));
223
224 IDs->domain_name = strdup(name);
225
226 IDs->refs = 1;
227 IDs->cell_dimensionality = cell_dimensionality;
228
229 F5printf(40, "F5B_new_global_domain(,dims=%d,,name=%s,perm_vector=%p,cell_dims=%d)\n",
230 dimension, name, perm_vector, cell_dimensionality);
231
232 if (perm_vector == F5_FORTRAN_ORDER)
233 {
234 for(i = 0; i<cell_dimensionality; i++)
235 {
236 IDs->perm_vector[i] = cell_dimensionality - 1 - i;
237 }
238 }
239 else if (perm_vector == F5_C_ORDER)
240 {
241 for(i = 0; i<cell_dimensionality; i++)
242 {
243 IDs->perm_vector[i] = i;
244 }
245 }
246 else
247 {
248 for(i = 0; i<cell_dimensionality; i++)
249 {
250 IDs->perm_vector[i] = perm_vector[i];
251 }
252 }
253
254 /*
255 Set unused dimensions to -1
256 */
257 if (IDs->perm_vector)
258 for(i = cell_dimensionality; i<FIBER_MAX_RANK; i++)
259 {
260 IDs->perm_vector[i] = -1;
261 }
262
264 coordnames,
265 dimension,
266 SinglePrecisionType);
267
269 coordnames,
270 dimension,
271 DoublePrecisionType);
272
273 IDs->TensorTypes = NULL;
274 /*
275 IDs->Point_hid_t = H5Tcreate(H5T_COMPOUND, dimension*Tsize );
276 for(i=0; i<dimension; i++)
277 {
278 H5Tinsert(IDs->Point_hid_t, coordnames[i], i*Tsize, coord_type);
279 }
280
281 IDs->Vector_hid_t = -1;
282 IDs->Covector_hid_t = -1;
283 IDs->Metric_hid_t = -1;
284 IDs->Bilinearform_hid_t = -1;
285 IDs->TensorTypes = NULL;
286 */
287 return IDs;
288}
void F5B_init_tangential_types(F5_ChartPrecisionTypes *IDs, const char *coordnames[], int dimension, hid_t coord_type)
Definition F5Bchart.c:290
#define F5_C_ORDER
Definition F5Bchart.h:268
#define F5_FORTRAN_ORDER
Definition F5Bchart.h:267
name
Definition F5P.c:82
#define F5printf(verbosity,...)
Definition F5private.h:60
int cell_dimensionality
Definition F5Bchart.h:142
int perm_vector[FIBER_MAX_RANK]
Definition F5Bchart.h:141
F5Ttensor_t ** TensorTypes
Definition F5Bchart.h:155

References ChartDomain_IDs::cell_dimensionality, ChartDomain_IDs::domain_name, ChartDomain_IDs::DoublePrecision, F5_C_ORDER, F5_FORTRAN_ORDER, F5B_init_tangential_types(), F5printf, FIBER_MAX_RANK, name, ChartDomain_IDs::perm_vector, ChartDomain_IDs::refs, ChartDomain_IDs::SinglePrecision, and ChartDomain_IDs::TensorTypes.

Referenced by F5B_new_global_float_chart(), F5B_new_global_fractional_domain(), F5B_new_global_fragment_neighbour_domain(), F5B_new_global_int_chart(), F5B_new_global_int_domain(), and F5Bcopy_chart_domain().

◆ F5B_new_global_float_chart()

ChartDomain_IDs * F5B_new_global_float_chart ( const char * coordnames[],
int dimension,
const char * name,
const int perm_vector[FIBER_MAX_RANK] )

Construct a new coordinate type.

Parameters
coordnamesArray of names for each coordinate.
dimensionDimensionality of this coordinate system.
nameSome naming for all instances of this coordinate systems.
Todo
Reorder argument list. @TODO Add complementary cleanup function.

Creates a chart with floating point types.

Only the creation of homogeneous coordinates is supported through this interface.

Definition at line 496 of file F5Bchart.c.

500{
502 dimension,
503 name,
504 perm_vector,
505 dimension,
506 H5T_NATIVE_FLOAT, H5T_NATIVE_DOUBLE);
507
508 F5Bchart_add_tangential_types(&IDs->SinglePrecision, coordnames, dimension, H5T_NATIVE_FLOAT);
509 F5Bchart_add_tangential_types(&IDs->DoublePrecision, coordnames, dimension, H5T_NATIVE_DOUBLE);
510
511 return IDs;
512}
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 F5Bchart_add_tangential_types(F5_ChartPrecisionTypes *IDs, const char *coordnames[], int dimension, hid_t coord_type)
Definition F5Bchart.c:326

References ChartDomain_IDs::DoublePrecision, F5B_new_global_domain(), F5Bchart_add_tangential_types(), FIBER_MAX_RANK, name, and ChartDomain_IDs::SinglePrecision.

Referenced by F5B_new_global_axial_chart2D(), F5B_new_global_cartesian_chart1D(), F5B_new_global_cartesian_chart2D(), F5B_new_global_cartesian_chart3D(), F5B_new_global_cartesian_chart4D(), F5B_new_global_color_chart_rgba_real(), F5B_new_global_cylindrical_chart3D(), F5B_new_global_polar_chart2D(), F5B_new_global_polar_chart3D(), F5B_new_global_polar_chart4D(), F5B_new_global_spherical_chart1D(), F5B_new_global_spherical_chart2D(), F5B_new_global_t_polar2_chart3D(), F5B_new_global_texture_chart2D(), F5B_new_global_texture_chart3D(), and F5B_new_global_time_chart1D().

◆ F5B_new_global_fractional_domain()

ChartDomain_IDs * F5B_new_global_fractional_domain ( const char * coordnames[],
int dimension,
const char * name,
const int perm_vector[],
int cell_dimensionality )

Definition at line 571 of file F5Bchart.c.

576{
578 dimension,
579 name,
580 perm_vector,
581 cell_dimensionality,
584 return IDs;
585}
#define F5T_INT_FRACTION32
#define F5T_INT_FRACTION64

References F5B_new_global_domain(), F5T_INT_FRACTION32, F5T_INT_FRACTION64, and name.

Referenced by F5B_new_rational_regular_domain3D().

◆ F5B_new_global_fragment_neighbour_domain()

ChartDomain_IDs * F5B_new_global_fragment_neighbour_domain ( const char * coordnames[],
int dimension,
const char * name,
const int perm_vector[],
int cell_dimensionality )

Definition at line 551 of file F5Bchart.c.

556{
558 dimension,
559 name,
560 perm_vector,
561 cell_dimensionality,
562 H5T_NATIVE_CHAR,
563 H5T_NATIVE_CHAR);
564/*
565 F5Bchart_add_tangential_types(&IDs->SinglePrecision, coordnames, dimension, H5T_NATIVE_INT32);
566 F5Bchart_add_tangential_types(&IDs->DoublePrecision, coordnames, dimension, H5T_NATIVE_INT64);
567*/
568 return IDs;
569}

References F5B_new_global_domain(), and name.

Referenced by F5B_new_global_fragname().

◆ F5B_new_global_int_chart()

ChartDomain_IDs * F5B_new_global_int_chart ( const char * coordnames[],
int dimension,
const char * name,
const int perm_vector[FIBER_MAX_RANK] )

Definition at line 514 of file F5Bchart.c.

518{
519
520ChartDomain_IDs*IDs = F5B_new_global_domain(coordnames, dimension, name, perm_vector, dimension,
521 H5T_NATIVE_INT32, H5T_NATIVE_INT64);
522
523 F5Bchart_add_tangential_types(&IDs->SinglePrecision, coordnames, dimension, H5T_NATIVE_INT8);
524 F5Bchart_add_tangential_types(&IDs->DoublePrecision, coordnames, dimension, H5T_NATIVE_INT16);
525
526 return IDs;
527}

References ChartDomain_IDs::DoublePrecision, F5B_new_global_domain(), F5Bchart_add_tangential_types(), FIBER_MAX_RANK, name, and ChartDomain_IDs::SinglePrecision.

Referenced by F5B_new_global_color_chart_rgba_int().

◆ F5B_new_global_int_domain()

ChartDomain_IDs * F5B_new_global_int_domain ( const char * coordnames[],
int dimension,
const char * name,
const int perm_vector[FIBER_MAX_RANK],
int cell_dimensionality )

Create a domain with positions in n-dimensional integer coordinates, where 32bit and 64bit are available ( H5T_NATIVE_B32 and H5T_NATIVE_B64 in HDF5.)

Definition at line 529 of file F5Bchart.c.

534{
536 dimension,
537 name,
538 perm_vector,
539 cell_dimensionality,
540 H5T_NATIVE_INT32,
541 H5T_NATIVE_INT64);
542
543 F5Bchart_add_tangential_types(&IDs->OneBytePrecision,coordnames, dimension, H5T_NATIVE_INT8 );
544 F5Bchart_add_tangential_types(&IDs->HalfPrecision, coordnames, dimension, H5T_NATIVE_INT16);
545 F5Bchart_add_tangential_types(&IDs->SinglePrecision, coordnames, dimension, H5T_NATIVE_INT32);
546 F5Bchart_add_tangential_types(&IDs->DoublePrecision, coordnames, dimension, H5T_NATIVE_INT64);
547
548 return IDs;
549}

References ChartDomain_IDs::DoublePrecision, F5B_new_global_domain(), F5Bchart_add_tangential_types(), FIBER_MAX_RANK, ChartDomain_IDs::HalfPrecision, name, ChartDomain_IDs::OneBytePrecision, and ChartDomain_IDs::SinglePrecision.

Referenced by F5B_new_global_edge_cells(), F5B_new_global_hexahedral_cells(), F5B_new_global_quad_cells(), F5B_new_global_tetrahedral_cells(), F5B_new_global_triangle_cells(), F5B_new_global_triangle_cells_ijk(), F5B_new_integer_regular_domain3D(), and old_F5B_new_global_tetrahedral_cells().

◆ F5B_permute_dimensions()

hsize_t * F5B_permute_dimensions ( hsize_t * target_dims,
int rank,
const hsize_t * source_dims,
int perm_vector[FIBER_MAX_RANK],
int perm_vector_size )

Permute a given dimensions array according to the given permutation vector.

Parameters
source_dimsThe source dimensions.
target_dimsThe target dimensions array, may be identical to the source dimensions array.
Returns
A pointer to the target dimensions array.
Parameters
perm_vectorThe permutation vector, may be F5_FORTRAN_ORDER, F5_C_ORDER or an explicity integer array specifying an arbitrary reodering of indices.
See also
F5B_fortran_permute_vector()
Todo
Make the define F5_FORTRAN_ORDER identical to the return value of F5B_fortran_permute_vector(). This is a possible optimization, currently there are two equivalent ways of specifying FORTRAN ordering.

Definition at line 72 of file F5Bchart.c.

77{
78hsize_t tmp[FIBER_MAX_RANK];
79hsize_t* dst;
80
81 if (!source_dims)
82 {
83 int i;
84 for(i=0; i< rank; i++)
85 target_dims[i] = 0;
86 F5printf(10, "F5B_permute_dimensions(): No source dimensions provided!");
87 return NULL;
88 }
89
90 if (perm_vector == F5_C_ORDER)
91 {
92 int i;
93 F5printf(50, "F5B_permute_dimensions(): C order permutation vector!");
94 if (target_dims == source_dims)
95 return target_dims;
96
97 for(i=0; i< rank; i++)
98 target_dims[i] = source_dims[i];
99
100 return target_dims;
101 }
102
103 if (target_dims == source_dims)
104 {
105 if (rank<2)
106 {
107 F5printf(40, "F5B_permute_dimensions(): no permutation for 1D!");
108 /* no permutation possible for 1D data... */
109 return target_dims;
110 }
111 dst = tmp;
112 }
113 else
114 dst = target_dims;
115
116/* if (perm_vector == F5_FORTRAN_ORDER) */
117 if (is_fortran_permutation(perm_vector, perm_vector_size) )
118 {
119 int i;
120 F5printf(40, "F5B_permute_dimensions(): FORTRAN order permutation vector!");
121 for(i=0; i< rank; i++)
122 dst[i] = source_dims[rank-1-i];
123 }
124 else if (rank>1) /* only then it makes sense to copy stuff */
125 {
126 int i;
127 int cdims = perm_vector_size,
128 cd = rank - cdims;
129
130 assert(perm_vector);
131 F5printf(50, "F5B_permute_dimensions(): generic order permutation vector of size %d, data are size %d", cdims, rank);
132/*
133 for(i=0; i< cdims; i++)
134 {
135 int pv = perm_vector[i];
136 F5printf(10, " perm_vector[%d] = %d", i, pv );
137 }
138 for(i=0; i< rank; i++)
139 {
140 int pv = source_dims[i];
141 F5printf(10, " source_dims[%d] = %d", i, pv );
142 }
143*/
144
145 if (rank > cdims)
146 {
147 F5printf(50, "F5B_permute_dimensions(): permutation on %d-higher dimensional subspace!", cd);
148 assert( cd == 1 && "higher dimensional subspaces not supported yet!");
149
150 for(i=0; i<cd; i++)
151 {
152/* int pv = perm_vector[i+cd]; */
153 /*
154 Assume FORTRAN convention on subspace dimensions,
155 but should actually make use of the perm_vector here
156 as well within the subspace.
157 If the dimension exceeds the dimension of the subspace,
158 then things become interesting what to do then...
159 */
160 int pv = rank-1-i;
161 assert( pv < rank );
162 dst[i] = source_dims[ pv ];
163 }
164 for(; i<rank; i++)
165 {
166 int pv = perm_vector[i-cd];
167 assert( pv >= 0 );
168 assert( pv < rank );
169 dst[i] = source_dims[ pv ];
170/* F5printf(0, " MAP from %d => %d value %d", pv, i, dst[i] ); */
171 }
172/*
173 for(i=0; i<rank; i++)
174 {
175 int pv = dst[i];
176 F5printf(0, " target_dims[%d] = %d", i, pv );
177 }
178*/
179 }
180 else for(i=0; i< rank; i++)
181 {
182 int pv = perm_vector[i-cd];
183 /* F5printf(41, " perm_vector[%d] = %d\n", i-cd, pv ); */
184 /* printf(" perm_vector[%d] = %d (rank=%d, cdims=%d, cd=%d)\n", i-cd, pv, rank, cdims, cd );*/
185 assert( pv >= 0 );
186 assert( pv < rank );
187 dst[i] = source_dims[ pv ];
188 }
189 }
190 else if (rank==1)
191 {
192 target_dims[0] = source_dims[0];
193 F5printf(50, "~F5B_permute_dimensions() 1D");
194 return target_dims;
195 }
196
197 if (dst != target_dims)
198 {
199 int i;
200 F5printf(50, "F5B_permute_dimensions(): Copy back permutation vector!");
201 for(i=0; i< rank; i++)
202 target_dims[i] = dst[i];
203 }
204 F5printf(50, "~F5B_permute_dimensions()");
205 return target_dims;
206}

References F5_C_ORDER, F5printf, and FIBER_MAX_RANK.

Referenced by F5Fcreate(), and F5Tpermute_dimensions().

◆ F5B_read_chart_domain()

ChartDomain_IDs * F5B_read_chart_domain ( hid_t ChartDomainLocationID,
const char * DefaultChartName )
Todo

Make failsafe if a type definition does not exist.

Add support for dynamically defined types.

Definition at line 720 of file F5Bchart.c.

721{
722int Tdims;
723hid_t perm_id, precision_group;
724ChartDomain_IDs*FileID = 0;
725
726 FileID = (ChartDomain_IDs*)malloc(sizeof(ChartDomain_IDs));
727 memset (FileID, 0, sizeof (ChartDomain_IDs));
728
729 FileID->refs = 1;
730
731 precision_group = F5Gtry_to_open(ChartDomainLocationID, FIBER_HDF5_CHART_SINGLE_PRECISION);
732 if (precision_group>0)
733 {
734 F5Bchart_read_tangential_types( &FileID->SinglePrecision, precision_group);
735 H5Gclose(precision_group);
736 precision_group = H5Gopen2(ChartDomainLocationID, FIBER_HDF5_CHART_DOUBLE_PRECISION, H5P_DEFAULT);
737 F5Bchart_read_tangential_types( &FileID->DoublePrecision, precision_group);
738 H5Gclose(precision_group);
739 }
740 else
741 {
742 F5Bchart_read_tangential_types( &FileID->SinglePrecision, ChartDomainLocationID );
743 F5Bchart_read_tangential_types( &FileID->DoublePrecision, ChartDomainLocationID );
744 }
745
746 {
747 hid_t Point_hid_t = FileID->SinglePrecision.Point_hid_t;
748 if (Point_hid_t<0)
749 {
750 F5printf(0, "F5B_read_chart_domain() Invalid single precision point type!\n");
751 }
752 else
753 {
754 char*buf = (char*)malloc(256);
755 if (!F5Aget_string( Point_hid_t, FIBER_HDF5_CHART_DOMAIN, buf, 256 ) )
756 {
757 free(buf);
758 FileID->domain_name = strdup(DefaultChartName);
759 }
760 else
761 FileID->domain_name = buf;
762 }
763
764 Tdims = H5Tget_nmembers( Point_hid_t );
765
766
767/*#ifdef SAVE_MEMORDER_WITH_TYPE*/
768 perm_id = F5Atry_to_open(Point_hid_t, FIBER_HDF5_CHART_MEMLAYOUT);
769/*
770#else
771 perm_id = F5Atry_to_open(location, FIBER_HDF5_CHART_MEMLAYOUT);
772#endif
773*/
774 }
775
776 if (perm_id>0)
777 {
778 assert(FileID->perm_vector);
779 F_H5Aread(perm_id, H5T_NATIVE_INT, FileID->perm_vector, FIBER_HDF5_CHART_MEMLAYOUT);
780 H5Aclose(perm_id);
781 }
782 else /* NO MEMLAYOUT attribute: Default is a FORTRAN permutation vector */
783 {
784 int i;
785 assert(FileID->perm_vector);
786 for(i=0; i<Tdims; i++)
787 FileID->perm_vector[i] = Tdims - 1 - i;
788 }
789
790 F5printf(200, "~F5B_read_chart_domain(,%s) DONE\n", DefaultChartName);
791
792 return FileID;
793}
char * F5Aget_string(hid_t loc_id, const char *name, char *buf, size_t buflen)
Definition F5A.c:109
hid_t F5Atry_to_open(hid_t location, const char *name)
Definition F5A.c:23
void F5Bchart_read_tangential_types(F5_ChartPrecisionTypes *H5Types, hid_t location)
Definition F5Bchart.c:674
#define FIBER_HDF5_CHART_DOUBLE_PRECISION
Definition F5T.h:20
#define FIBER_HDF5_CHART_SINGLE_PRECISION
Definition F5T.h:19
#define FIBER_HDF5_CHART_MEMLAYOUT
Definition F5defs.h:125
#define FIBER_HDF5_CHART_DOMAIN
Definition F5defs.h:113
herr_t F_H5Aread(hid_t attr_id, hid_t mem_type_id, void *buf, const char *name)
Definition F5private.c:332
#define H5Gclose(x)
Definition F5X.h:144
hid_t F5Gtry_to_open(hid_t location, const char *name)
Definition F5X.c:297

References ChartDomain_IDs::domain_name, ChartDomain_IDs::DoublePrecision, F5Aget_string(), F5Atry_to_open(), F5Bchart_read_tangential_types(), F5Gtry_to_open(), F5printf, F_H5Aread(), FIBER_HDF5_CHART_DOMAIN, FIBER_HDF5_CHART_DOUBLE_PRECISION, FIBER_HDF5_CHART_MEMLAYOUT, FIBER_HDF5_CHART_SINGLE_PRECISION, free(), H5Gclose, ChartDomain_IDs::perm_vector, _F5_ChartPrecisionTypes::Point_hid_t, ChartDomain_IDs::refs, and ChartDomain_IDs::SinglePrecision.

Referenced by F5B_read_global_chart().

◆ F5B_read_global_chart()

ChartDomain_IDs * F5B_read_global_chart ( hid_t ChartsID,
const char * name )

Definition at line 696 of file F5Bchart.c.

697{
698hid_t location;
699ChartDomain_IDs*FileID = 0;
700
701 F5printf(200, "F5B_read_global_chart(,%s)\n", name);
702
703 location = H5Gopen2(ChartsID, name, H5P_DEFAULT);
704 if (location<0)
705 {
706 F5printf(0, "F5B_read_global_chart(,%s) FAILED\n", name);
707 return 0;
708 }
709
710 FileID = F5B_read_chart_domain(location, name);
711 H5Gclose(location);
712
713 return FileID;
714}
ChartDomain_IDs * F5B_read_chart_domain(hid_t ChartDomainLocationID, const char *DefaultChartName)
Definition F5Bchart.c:720

References F5B_read_chart_domain(), F5printf, H5Gclose, and name.

Referenced by F5FB_read_global_chart().

◆ F5B_save_global_chart()

ChartDomain_IDs * F5B_save_global_chart ( const ChartDomain_IDs * MemoryIDs,
hid_t Domain_hid )

Create File ID's from MemoryID's.

Todo
Possible optimization: Save only if perm_vector is not FORTRAN ordering .

Definition at line 801 of file F5Bchart.c.

802{
803int i;
804ChartDomain_IDs*FileID = (ChartDomain_IDs*)malloc(sizeof(ChartDomain_IDs));
805 memset (FileID, 0, sizeof (ChartDomain_IDs));
806
807 FileID->refs = 1;
808 for(i=0; i<FIBER_MAX_RANK; i++)
809 FileID->perm_vector[i] = MemoryIDs->perm_vector[i];
810
811 FileID->domain_name = strdup(MemoryIDs->domain_name);
812 FileID->cell_dimensionality = MemoryIDs->cell_dimensionality;
813
814 /* Save the memory layout ordering attribute */
815 /* Possible optimization: Save only if perm_vector is not FORTRAN ordering */
816
817 {
818 hid_t SinglePrecisionTypes = H5Gcreate2(Domain_hid, FIBER_HDF5_CHART_SINGLE_PRECISION,
819 H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT );
820
821 FileID->SinglePrecision.Point_hid_t = F5Tsave_tensor(SinglePrecisionTypes, MemoryIDs->domain_name,
823
824 H5Gclose( SinglePrecisionTypes );
825 }
826 {
827 hid_t DoublePrecisionTypes = H5Gcreate2(Domain_hid, FIBER_HDF5_CHART_DOUBLE_PRECISION,
828 H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT );
829
830 FileID->DoublePrecision.Point_hid_t = F5Tsave_tensor(DoublePrecisionTypes, MemoryIDs->domain_name,
832
833 H5Gclose( DoublePrecisionTypes );
834 }
835
836 /* by default, link to single precision type */
838 Domain_hid, FIBER_HDF5_CHART_POINT_TYPE, H5P_DEFAULT, H5P_DEFAULT );
839
840 {
841 int cd = FileID->cell_dimensionality;
844 }
845
846 F5T_save_perm_vector(FileID->SinglePrecision.Point_hid_t, H5Tget_nmembers( FileID->SinglePrecision.Point_hid_t ), FileID->perm_vector);
847 F5T_save_perm_vector(FileID->DoublePrecision.Point_hid_t, H5Tget_nmembers( FileID->DoublePrecision.Point_hid_t ), FileID->perm_vector);
848 return FileID;
849}
int F5Asave_ints(hid_t loc_id, const char *name, const int data[], hsize_t n)
Definition F5A.c:355
void F5T_save_perm_vector(hid_t location, int rank, int perm_vector[])
Definition F5Bchart.c:879
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
#define FIBER_HDF5_CELLDIMENSIONALITY
Definition F5defs.h:127
#define FIBER_HDF5_CHART_POINT_TYPE
Definition F5defs.h:129

References ChartDomain_IDs::cell_dimensionality, ChartDomain_IDs::domain_name, ChartDomain_IDs::DoublePrecision, F5Asave_ints(), F5T_save_perm_vector(), F5Tsave_tensor(), FIBER_HDF5_CELLDIMENSIONALITY, FIBER_HDF5_CHART_DOUBLE_PRECISION, FIBER_HDF5_CHART_POINT_TYPE, FIBER_HDF5_CHART_SINGLE_PRECISION, FIBER_MAX_RANK, H5Gclose, ChartDomain_IDs::perm_vector, _F5_ChartPrecisionTypes::Point_hid_t, ChartDomain_IDs::refs, and ChartDomain_IDs::SinglePrecision.

Referenced by F5LTcreateV().

◆ F5Bchart_add_tangential_types()

void F5Bchart_add_tangential_types ( F5_ChartPrecisionTypes * IDs,
const char * coordnames[],
int dimension,
hid_t coord_type )

Adds tangential types (vector, covector, metric) to a given chart domain. These types are derived from the specified coord_type.

Todo

Get dimension and coordnames from the chart domain's points.

CALL this function for various numerical precisions

Definition at line 326 of file F5Bchart.c.

330{
331size_t Tsize = H5Tget_size(coord_type);
332 IDs->Vector_hid_t = H5Tcreate(H5T_COMPOUND, dimension*Tsize );
333 // F5printf(40, "F5B_add_tangential_types, IDs->Vector_hid_t = %lli\n", IDs->Vector_hid_t);
334 {int i;
335 for(i=0; i<dimension; i++)
336 {
337 char buf[_FIBER_MAX_COORDNAME_LENGTH+2] = "D";
338 strcat(buf, coordnames[i]);
339 H5Tinsert(IDs->Vector_hid_t, buf, i*Tsize, coord_type);
340 }
341 }
342
343 IDs->Covector_hid_t = H5Tcreate(H5T_COMPOUND, dimension*Tsize );
344 {int i;
345 for(i=0; i<dimension; i++)
346 {
347 char buf[_FIBER_MAX_COORDNAME_LENGTH+2] = "d";
348 strcat(buf, coordnames[i]);
349 H5Tinsert(IDs->Covector_hid_t, buf, i*Tsize, coord_type);
350 }
351 }
352#if 0
353 /* needs revision: do permutation without repetition -> ( 2
354 D ) */
355 IDs->Bivector_hid_t = H5Tcreate(H5T_COMPOUND, dimension*dimension*Tsize );
356 {int i, j;
357 for(i=0; i<dimension; i++)
358 for(j=i; j<dimension; j++)
359 {
360 int L = i*dimension + j;
361 char buf[_FIBER_MAX_COORDNAME_LENGTH+2] = "D";
362 strcat(buf, coordnames[i]);
363 strcat(buf, coordnames[j]);
364
365 H5Tinsert(IDs->Bivector_hid_t, buf, L*Tsize, coord_type);
366 }
367 }
368#endif
369 if (dimension == 3)
370 {
371 IDs->Bivector_hid_t = H5Tcreate(H5T_COMPOUND, dimension*Tsize );
372
373 {
374 char buf[_FIBER_MAX_COORDNAME_LENGTH+2] = "D";
375 strcat(buf, coordnames[1]);
376 strcat(buf, "^D");
377 strcat(buf, coordnames[2]);
378
379 H5Tinsert(IDs->Bivector_hid_t, buf, 0*Tsize, coord_type);
380 }
381
382 {
383 char buf[_FIBER_MAX_COORDNAME_LENGTH+2] = "D";
384 strcat(buf, coordnames[2]);
385 strcat(buf, "^D");
386 strcat(buf, coordnames[0]);
387
388 H5Tinsert(IDs->Bivector_hid_t, buf, 1*Tsize, coord_type);
389 }
390
391 {
392 char buf[_FIBER_MAX_COORDNAME_LENGTH+2] = "D";
393 strcat(buf, coordnames[0]);
394 strcat(buf, "^D");
395 strcat(buf, coordnames[1]);
396
397 H5Tinsert(IDs->Bivector_hid_t, buf, 2*Tsize, coord_type);
398 }
399
400 }
401 IDs->Bicovector_hid_t = H5Tcreate(H5T_COMPOUND, dimension*dimension*Tsize );
402 {int i, j;
403 for(i=0; i<dimension; i++)
404 for(j=i; j<dimension; j++)
405 {
406 int L = i*dimension + j;
407 char buf[_FIBER_MAX_COORDNAME_LENGTH+2] = "d";
408 strcat(buf, coordnames[i]);
409 strcat(buf, coordnames[j]);
410
411 H5Tinsert(IDs->Bicovector_hid_t, buf, L*Tsize, coord_type);
412 }
413 }
414
415 IDs->Metric_hid_t = H5Tcreate(H5T_COMPOUND, dimension*(dimension+1)/2*Tsize );
416 {int i, j, ni, nj;
417 int indices[FIBER_MAX_RANK*FIBER_MAX_RANK];
418 int I = 0; /* the linear index */
419
420 for(ni=0, i=0; i<dimension; i++ )
421 {
422 for(nj=0, j=0; j<i; j++ )
423 {
424 indices[ni+j] = indices[nj+i] = I++;
425 nj += dimension;
426 }
427 indices[ni+i] = I++;
428 ni += dimension;
429 }
430
431
432 for(i=0; i<dimension; i++)
433 for(j=i; j<dimension; j++)
434 {
435 int L = i*dimension + j,
436 idx = indices[ L ];
437 char buf[_FIBER_MAX_COORDNAME_LENGTH+2] = "g";
438 strcat(buf, coordnames[i]);
439 strcat(buf, coordnames[j]);
440
441 H5Tinsert(IDs->Metric_hid_t, buf, idx*Tsize, coord_type);
442 }
443 }
444
445 IDs->Cometric_hid_t = H5Tcreate(H5T_COMPOUND, dimension*(dimension+1)/2*Tsize );
446 {int i, j, ni, nj;
447 int indices[FIBER_MAX_RANK*FIBER_MAX_RANK];
448 int I = 0; /* the linear index */
449
450 for(ni=0, i=0; i<dimension; i++ )
451 {
452 for(nj=0, j=0; j<i; j++ )
453 {
454 indices[ni+j] = indices[nj+i] = I++;
455 nj += dimension;
456 }
457 indices[ni+i] = I++;
458 ni += dimension;
459 }
460
461
462 for(i=0; i<dimension; i++)
463 for(j=i; j<dimension; j++)
464 {
465 int L = i*dimension + j,
466 idx = indices[ L ];
467 char buf[_FIBER_MAX_COORDNAME_LENGTH+2] = "G";
468 strcat(buf, coordnames[i]);
469 strcat(buf, coordnames[j]);
470
471 H5Tinsert(IDs->Cometric_hid_t, buf, idx*Tsize, coord_type);
472 }
473 }
474}
#define _FIBER_MAX_COORDNAME_LENGTH
Definition F5defs.h:96

References _FIBER_MAX_COORDNAME_LENGTH, _F5_ChartPrecisionTypes::Bicovector_hid_t, _F5_ChartPrecisionTypes::Bivector_hid_t, _F5_ChartPrecisionTypes::Cometric_hid_t, _F5_ChartPrecisionTypes::Covector_hid_t, FIBER_MAX_RANK, _F5_ChartPrecisionTypes::Metric_hid_t, and _F5_ChartPrecisionTypes::Vector_hid_t.

Referenced by F5B_new_global_float_chart(), F5B_new_global_int_chart(), and F5B_new_global_int_domain().

◆ F5Bchart_read_tangential_types()

void F5Bchart_read_tangential_types ( F5_ChartPrecisionTypes * H5Types,
hid_t location )

Definition at line 674 of file F5Bchart.c.

676{
677 assert( H5Types );
678
679 H5Types->Point_hid_t = H5Topen2( location, FIBER_HDF5_CHART_POINT_TYPE, H5P_DEFAULT);
680
681 H5E_BEGIN_TRY
682 H5Types->Vector_hid_t = H5Topen2( location, FIBER_HDF5_CHART_VECTOR_TYPE, H5P_DEFAULT);
683 H5Types->Covector_hid_t = H5Topen2( location, FIBER_HDF5_CHART_COVECTOR_TYPE, H5P_DEFAULT);
684
685 H5Types->Bivector_hid_t = H5Topen2( location, FIBER_HDF5_CHART_BIVECTOR_TYPE, H5P_DEFAULT);
686 H5Types->Bicovector_hid_t = H5Topen2( location, FIBER_HDF5_CHART_BICOVECTOR_TYPE, H5P_DEFAULT);
687
688 H5Types->Pseudoscalar_hid_t = H5Topen2( location, FIBER_HDF5_CHART_PSEUDOSCALAR_TYPE, H5P_DEFAULT);
689 H5Types->Pseudocoscalar_hid_t = H5Topen2( location, FIBER_HDF5_CHART_PSEUDOCOSCALAR_TYPE, H5P_DEFAULT);
690
691 H5Types->Metric_hid_t = H5Topen2( location, FIBER_HDF5_CHART_METRIC_TYPE, H5P_DEFAULT);
692 H5Types->Cometric_hid_t = H5Topen2( location, FIBER_HDF5_CHART_METRIC_TYPE, H5P_DEFAULT);
693 H5E_END_TRY
694}
#define FIBER_HDF5_CHART_METRIC_TYPE
Definition F5defs.h:135
#define FIBER_HDF5_CHART_PSEUDOCOSCALAR_TYPE
Definition F5defs.h:141
#define FIBER_HDF5_CHART_VECTOR_TYPE
Definition F5defs.h:130
#define FIBER_HDF5_CHART_BIVECTOR_TYPE
Definition F5defs.h:133
#define FIBER_HDF5_CHART_BICOVECTOR_TYPE
Definition F5defs.h:134
#define FIBER_HDF5_CHART_COVECTOR_TYPE
Definition F5defs.h:131
#define FIBER_HDF5_CHART_PSEUDOSCALAR_TYPE
Definition F5defs.h:140

References _F5_ChartPrecisionTypes::Bicovector_hid_t, _F5_ChartPrecisionTypes::Bivector_hid_t, _F5_ChartPrecisionTypes::Cometric_hid_t, _F5_ChartPrecisionTypes::Covector_hid_t, FIBER_HDF5_CHART_BICOVECTOR_TYPE, FIBER_HDF5_CHART_BIVECTOR_TYPE, FIBER_HDF5_CHART_COVECTOR_TYPE, FIBER_HDF5_CHART_METRIC_TYPE, FIBER_HDF5_CHART_POINT_TYPE, FIBER_HDF5_CHART_PSEUDOCOSCALAR_TYPE, FIBER_HDF5_CHART_PSEUDOSCALAR_TYPE, FIBER_HDF5_CHART_VECTOR_TYPE, _F5_ChartPrecisionTypes::Metric_hid_t, _F5_ChartPrecisionTypes::Point_hid_t, _F5_ChartPrecisionTypes::Pseudocoscalar_hid_t, _F5_ChartPrecisionTypes::Pseudoscalar_hid_t, and _F5_ChartPrecisionTypes::Vector_hid_t.

Referenced by F5B_read_chart_domain().

◆ F5Bcopy_chart_domain()

ChartDomain_IDs * F5Bcopy_chart_domain ( const ChartDomain_IDs * IDs)

Make a copy of a coordinate domain. All types are created from the existing information as if it were created from scratch. This function may be used to convert named data types into transient types. This is e.g. useful when reading a file. @TODO Add complementary cleanup function.

Definition at line 851 of file F5Bchart.c.

852{
853int i;
854const char*coordnames[FIBER_MAX_RANK];
855 assert( srcIDs );
856 {
857 int dimension = H5Tget_nmembers( srcIDs->SinglePrecision.Point_hid_t );
858/*hid_t coord_type = H5Tget_member_type( srcIDs->SinglePrecision.Point_hid_t, 0 ); */
859 ChartDomain_IDs*newID;
860 const char**cn = coordnames;
861
862 for(i=0; i<dimension; i++)
863 coordnames[i] = H5Tget_member_name( srcIDs->SinglePrecision.Point_hid_t, i );
864
865/* newID = F5B_new_global_chart(cn, dimension, coord_type, srcIDs->domain_name, srcIDs->perm_vector, srcIDs->cell_dimensionality); */
866 newID = F5B_new_global_domain(cn, dimension, srcIDs->domain_name, srcIDs->perm_vector, srcIDs->cell_dimensionality,
867 H5Tget_member_type( srcIDs->SinglePrecision.Point_hid_t, 0 ),
868 H5Tget_member_type( srcIDs->DoublePrecision.Point_hid_t, 0 )
869 );
870
871 for(i=0; i<dimension; i++)
872 H5free_memory( (char*)(coordnames[i]) );
873
874 return newID;
875 }
876}

References ChartDomain_IDs::cell_dimensionality, ChartDomain_IDs::domain_name, ChartDomain_IDs::DoublePrecision, F5B_new_global_domain(), FIBER_MAX_RANK, ChartDomain_IDs::perm_vector, _F5_ChartPrecisionTypes::Point_hid_t, and ChartDomain_IDs::SinglePrecision.

◆ F5Bget_chart_dims()

int F5Bget_chart_dims ( const ChartDomain_IDs * IDs)

Get the dimensionality of this chart. This information is taken from the number of elements of the associated point type.

Definition at line 899 of file F5Bchart.c.

900{
901 if (!IDs)
902 return -1;
903
904 return H5Tget_nmembers(IDs->SinglePrecision.Point_hid_t);
905}

References _F5_ChartPrecisionTypes::Point_hid_t, and ChartDomain_IDs::SinglePrecision.

Referenced by F5Fcreate(), and F5Tpermute_dimensions().

◆ F5Bget_precision_by_size()

F5_ChartPrecisionTypes * F5Bget_precision_by_size ( ChartDomain_IDs * CD,
int TypeSize )

Given the size of some type in byte, yield the appropriate precision type structur from a chart domain. The function will fail if the TypeSize is anything but 1,2,4,8 or 16.

Definition at line 916 of file F5Bchart.c.

917{
918 if (!CD) return 0;
919
920 switch(TypeSize)
921 {
922 case 1: return &CD->OneBytePrecision;
923 case 2: return &CD->HalfPrecision;
924 case 4: return &CD->SinglePrecision;
925 case 8: return &CD->DoublePrecision;
926 case 16: return &CD->ExtendedPrecision;
927 default: return 0;
928 }
929}

References ChartDomain_IDs::DoublePrecision, ChartDomain_IDs::ExtendedPrecision, ChartDomain_IDs::HalfPrecision, ChartDomain_IDs::OneBytePrecision, and ChartDomain_IDs::SinglePrecision.

Referenced by F5Bget_precision_by_type(), and F5file_type().

◆ F5Bget_precision_by_type()

F5_ChartPrecisionTypes * F5Bget_precision_by_type ( ChartDomain_IDs * CD,
hid_t type_id )

Given some compound type, yield the precision type corresponding to the compound type's first member. The function will fail if the provided type is not a compound type.

Definition at line 931 of file F5Bchart.c.

932{
933hid_t FirstCompoundType = H5Tget_member_type( type_id, 0);
934int CompoundSize = H5Tget_size( FirstCompoundType );
935 H5Tclose( FirstCompoundType );
936
937 return F5Bget_precision_by_size(CD, CompoundSize);
938}
F5_ChartPrecisionTypes * F5Bget_precision_by_size(ChartDomain_IDs *CD, int TypeSize)
Definition F5Bchart.c:916
H5Tclose(type_id)

References F5Bget_precision_by_size(), and H5Tclose().

◆ F5Binsert_tensor_type()

void F5Binsert_tensor_type ( ChartDomain_IDs * This,
F5Ttensor_t * T )

Definition at line 588 of file F5Bchart.c.

589{
590 assert(This);
591 if (!This->TensorTypes)
592 {
593 This->TensorTypes = new(F5Ttensor_t*, 2);
594 This->TensorTypes[0] = T;
595 This->TensorTypes[1] = NULL;
596 }
597 else
598 {
599 int i;
600 for(i=0; This->TensorTypes[i]; i++)
601 ;
602
603 This->TensorTypes = (F5Ttensor_t**)realloc(This->TensorTypes, i+1*sizeof(F5Ttensor_t*));
604 This->TensorTypes[i ] = T;
605 This->TensorTypes[i+1] = NULL;
606 }
607}

References ChartDomain_IDs::TensorTypes.

◆ F5file_type()

hid_t F5file_type ( F5Path * fpath,
hid_t fieldtype )

In F5, types are saved to the file to store certain information about datasets. The insufficiency in HDF5 is that a certain type can be saved to one file only, but not to many files, like a dataset. When a type is saved to a file, it becomes a "named type" - in contrast to "transient" types, which are not bound to a file. Only named types may carry attributes, transient types may not contain attributes.

Type attributes are used to describe properties of a type, in particular its tensorial properties, which is beyond the raw native type definition of e.g. float and dimension. We cannot store this information with a transient type, but must do it by our own ;-( .

Generic support would be desireable, but is not implemented right now. For now, only a limited set of pre-defined low-tensorial data types is hard-coded. By knowing this hard-coded type, also the tensorial type information is written into the file when saving the data type. Admittedly, this is not pretty, and a future revision will provide a more dynamically mechanism here.

The functionality is as follows:

Given a transient HDF5 type, return a named type that is suitable for the current file. The file ID's will be filled with the named data types.

@Note The file which is contained in fpath will be changed by this operation, because a new type might be created and saved into the file, so the fpath parameter cannot be const.

@Note This function currently only knows aboout point, vector and predefined tensor types in the ChartId. It is NOT fully generic. If it cannot convert some field type into a file type, it returns the transient type, i.e. we don't get a named type in this case.

Definition at line 941 of file F5Bchart.c.

942{
943 if (!fpath || !fpath->myChart)
944 {
945 F5printf(20, "F5file_type: No chart given, returning memory type.");
946 return fieldtype;
947 }
948
949 F5printf(40, "F5file_type(%p, %d): chart=%p", fpath, (int) fieldtype, fpath->myChart );
950
951 switch( H5Tget_class( fieldtype) )
952 {
953 default:
954 F5printf(20, "F5file_type query for unknown type (could be a native one).");
955 return fieldtype;
956
957 case H5T_INTEGER:
958 case H5T_FLOAT:
959 case H5T_STRING:
960 F5printf(20, "F5file_type query for integer/float/string type (could be a native one).");
961 return fieldtype;
962
963 case H5T_BITFIELD:
964 case H5T_OPAQUE:
965 case H5T_REFERENCE:
966 case H5T_ENUM:
967 case H5T_VLEN:
968 case H5T_ARRAY:
969 F5printf(20, "F5file_type query for unsupported type (could be a native one).");
970 return fieldtype;
971
972 case H5T_COMPOUND:
973 ;
974 }
975
976/*
977 The following code is executed once we know the fieldtype is a compound type.
978 */
979
980 {
981 hid_t FirstCompoundType = H5Tget_member_type( fieldtype, 0);
982 int CompoundPrecision = H5Tget_size( FirstCompoundType );
983
984 F5_ChartPrecisionTypes*IN = F5Bget_precision_by_size(fpath->myChart, CompoundPrecision),
985 *OUT = F5Bget_precision_by_size(fpath->FileIDs, CompoundPrecision);
986
987 H5Tclose( FirstCompoundType );
988
989 F5printf(20, "F5file_type query for compound type, precision %d.\n", CompoundPrecision);
990
991 assert(IN);
992 assert(OUT);
993 assert( fpath->myChart );
994 assert( fpath->FileIDs );
995
996 if (F5Tequal(fieldtype, IN->Point_hid_t) )
997 {
998 F5printf(20, "F5file_type query for point type.\n");
999 if (OUT->Point_hid_t<1)
1000 {
1001 F5printf(0, "F5file_type(): Possible internal error, point type not found in file!");
1002
1003 OUT->Point_hid_t = F5Tmake_precise_tensor(fpath, FIBER_HDF5_CHART_POINT_TYPE, CompoundPrecision,
1004 IN->Point_hid_t, 0,0, 0);
1005 {
1006 int cd = fpath->myChart->cell_dimensionality;
1007 printf("CELL Dimensionality: %d\n", cd);
1008 F5Asave_ints(OUT->Point_hid_t, FIBER_HDF5_CELLDIMENSIONALITY, &cd, 1);
1009 }
1010
1011#ifdef SAVE_MEMORDER_WITH_TYPE
1012 F5T_save_perm_vector(OUT->Point_hid_t,
1013 H5Tget_nmembers( OUT->Point_hid_t ),
1014 fpath->FileIDs->perm_vector);
1015#endif
1016 }
1017 return OUT->Point_hid_t;
1018 }
1019 else if (F5Tequal(fieldtype, IN->Vector_hid_t) )
1020 {
1021 F5printf(20, "F5file_type query for vector type %d", (int) IN->Vector_hid_t );
1022 if (OUT->Vector_hid_t<1)
1023 {
1024 int covariance[] = {1}; /* Tangential vectors have one upper index */
1025 OUT->Vector_hid_t =
1026 F5Tmake_precise_tensor(fpath, FIBER_HDF5_CHART_VECTOR_TYPE, CompoundPrecision,
1027 IN->Vector_hid_t, 1, covariance, 1);
1028 }
1029 return OUT->Vector_hid_t;
1030 }
1031 else if (F5Tequal(fieldtype, IN->Covector_hid_t) )
1032 {
1033 F5printf(20, "F5file_type query for covector type.\n");
1034 if (OUT->Covector_hid_t<1)
1035 {
1036 int covariance[] = {-1}; /* Co-vectors have one lower index */
1037 OUT->Covector_hid_t =
1039 IN->Covector_hid_t, 1, covariance, 1);
1040 }
1041 return OUT->Covector_hid_t;
1042 }
1043 else if (F5Tequal(fieldtype, IN->Bivector_hid_t) )
1044 {
1045 F5printf(20, "F5file_type query for bivector type.\n");
1046 if (OUT->Bivector_hid_t<1)
1047 {
1048 int covariance[] = {1,1}; /* bivectors have two upper indices */
1049 OUT->Bivector_hid_t =
1051 IN->Bivector_hid_t, 2, covariance, 2);
1052 }
1053 return OUT->Bivector_hid_t;
1054 }
1055 else if (F5Tequal(fieldtype, IN->Bicovector_hid_t) )
1056 {
1057 F5printf(20, "F5file_type query for bicovector type.\n");
1058 if (OUT->Bivector_hid_t<1)
1059 {
1060 int covariance[] = {-1,-1}; /* bicovectors have two lower indices */
1061 OUT->Bicovector_hid_t =
1063 IN->Bicovector_hid_t, 2, covariance, 2);
1064 }
1065 return OUT->Bicovector_hid_t;
1066 }
1067
1068 else if (F5Tequal(fieldtype, IN->Metric_hid_t) )
1069 {
1070 F5printf(20, "F5file_type query for metric type.\n");
1071 if (OUT->Metric_hid_t<1)
1072 {
1073 /* g_\mu\nu */
1074 int covariance[] = {-1, -1}; /* Metric tensors have two lower indices */
1075 OUT->Metric_hid_t =
1076 F5Tmake_precise_tensor(fpath, FIBER_HDF5_CHART_METRIC_TYPE, CompoundPrecision,
1077 IN->Metric_hid_t, 2, covariance, 0);
1078 }
1079 return OUT->Metric_hid_t;
1080 }
1081 else if (F5Tequal(fieldtype, IN->Cometric_hid_t) )
1082 {
1083 F5printf(20, "F5file_type query for cometric type.\n");
1084 if (OUT->Cometric_hid_t<1)
1085 {
1086 /* g^\mu\nu */
1087 int covariance[] = {1, 1}; /* Cometric tensors have two upper indices */
1088 OUT->Cometric_hid_t =
1090 IN->Cometric_hid_t, 2, covariance, 0);
1091 }
1092 return OUT->Cometric_hid_t;
1093 }
1094
1095
1096 F5printf(2, __FILE__ ": Warning: F5file_type() query could not identify file type.\n");
1097 {
1098 int TypeMembers = H5Tget_nmembers( fieldtype );
1099 const char*MultiplicityCategory;
1100 hid_t MultiplicityCategory_id;
1101 switch(TypeMembers)
1102 {
1103 case 1: MultiplicityCategory = "Chart-free compound types with one member"; break;
1104 case 2: MultiplicityCategory = "Chart-free compound types with two members"; break;
1105 case 3: MultiplicityCategory = "Chart-free compound types with three members"; break;
1106 case 4: MultiplicityCategory = "Chart-free compound types with four members"; break;
1107 default:MultiplicityCategory = "Chart-free compound types with many members"; break;
1108 }
1109 MultiplicityCategory_id = F5Gappend(fpath->GlobalChart_hid, MultiplicityCategory);
1110
1111 {
1112#define FIBER_HDF5_ANONYMOUS_TYPENAME "F5::TypeName%04u"
1113 char type_name[1024];
1114 unsigned nthType = 0;
1115 for(;nthType<10000;nthType++)
1116 {
1117 hid_t type_id;
1118 sprintf(type_name, FIBER_HDF5_ANONYMOUS_TYPENAME, nthType);
1119 type_id = F5Tappend(MultiplicityCategory_id, type_name, fieldtype);
1120
1121 if (type_id>0)
1122 {
1123 /*
1124 Inject This type to the chart file identifiers
1125 for the output file, for mere cleanup upon file
1126 closing. Otherwise This type ID will NOT be associated
1127 with the respective chart.
1128 */
1129 F5B_inject_precision_type(OUT, type_id);
1130 H5Gclose(MultiplicityCategory_id);
1131 return type_id;
1132 }
1133 }
1134 puts("F5file_type: Creating anonymous type name failed!");
1135 H5Gclose(MultiplicityCategory_id);
1136 return fieldtype;
1137 }
1138 }
1139 }
1140}
int F5B_inject_precision_type(F5_ChartPrecisionTypes *IDs, hid_t type_id)
Definition F5Bchart.c:477
#define FIBER_HDF5_ANONYMOUS_TYPENAME
struct _F5_ChartPrecisionTypes F5_ChartPrecisionTypes
Definition F5Bchart.h:71
hid_t F5Tappend(hid_t loc_id, const char *name, hid_t type_id)
Definition F5T.c:25
hid_t F5Tmake_precise_tensor(F5Path *fpath, const char *type_name, int TypeBytePrecision, hid_t transient_type, int rank, int indices[], int grade)
Definition F5T.c:115
#define FIBER_HDF5_CHART_COMETRIC_TYPE
Definition F5defs.h:136
hid_t F5Gappend(hid_t loc_id, const char *name)
Definition F5X.c:59
hid_t GlobalChart_hid
Definition F5Path.h:54
ChartDomain_IDs * FileIDs
Definition F5Path.h:35
ChartDomain_IDs * myChart
Definition F5Path.h:33

References _F5_ChartPrecisionTypes::Bicovector_hid_t, _F5_ChartPrecisionTypes::Bivector_hid_t, ChartDomain_IDs::cell_dimensionality, _F5_ChartPrecisionTypes::Cometric_hid_t, _F5_ChartPrecisionTypes::Covector_hid_t, F5Asave_ints(), F5B_inject_precision_type(), F5Bget_precision_by_size(), F5Gappend(), F5printf, F5T_save_perm_vector(), F5Tappend(), F5Tmake_precise_tensor(), FIBER_HDF5_ANONYMOUS_TYPENAME, FIBER_HDF5_CELLDIMENSIONALITY, FIBER_HDF5_CHART_BICOVECTOR_TYPE, FIBER_HDF5_CHART_BIVECTOR_TYPE, FIBER_HDF5_CHART_COMETRIC_TYPE, FIBER_HDF5_CHART_COVECTOR_TYPE, FIBER_HDF5_CHART_METRIC_TYPE, FIBER_HDF5_CHART_POINT_TYPE, FIBER_HDF5_CHART_VECTOR_TYPE, F5Path::FileIDs, F5Path::GlobalChart_hid, H5Gclose, H5Tclose(), _F5_ChartPrecisionTypes::Metric_hid_t, F5Path::myChart, ChartDomain_IDs::perm_vector, _F5_ChartPrecisionTypes::Point_hid_t, and _F5_ChartPrecisionTypes::Vector_hid_t.

Referenced by F5Fcreate(), F5FSwrite_fraction(), F5Fwrite_1D(), F5Fwrite_flexible(), F5Fwrite_fraction(), F5Fwrite_fraction_external(), F5Fwrite_fractionS(), F5Fwrite_linear(), F5Fwrite_linear_fraction(), F5FwriteIMAGE(), F5Fwrites(), F5FwriteX(), F5Rcreate_uniform_sparse(), F5write_particle_cartesian3Dv(), F5write_particle_cartesian3DvU(), and F5write_particle_double_cartesian3Dv().

◆ F5T_save_perm_vector()

void F5T_save_perm_vector ( hid_t location,
int rank,
int perm_vector[] )

Definition at line 879 of file F5Bchart.c.

880{
881 if (!perm_vector)
882 {
883 puts("F5T_save_perm_vector()");
884 return;
885 }
886
887 /* Save the memory layout ordering attribute */
888 /* Possible optimization: Save only if perm_vector is not FORTRAN ordering */
889 {
890 hsize_t Tdims = rank;
891 hid_t index_ds = H5Screate_simple(1, &Tdims, &Tdims ) ;
892 hid_t Rank_id = F5Acreate(location, FIBER_HDF5_CHART_MEMLAYOUT, H5T_NATIVE_INT, index_ds, 0);
893 H5Awrite(Rank_id, H5T_NATIVE_INT, perm_vector );
894 H5Aclose(Rank_id);
895 H5Sclose(index_ds);
896 }
897}
hid_t F5Acreate(hid_t loc_id, const char *name, hid_t type_id, hid_t space_id, hid_t create_plist)
Definition F5private.c:11

References F5Acreate(), and FIBER_HDF5_CHART_MEMLAYOUT.

Referenced by F5B_save_global_chart(), and F5file_type().