FiberBundleHDF5  FiberHDF5 Documentation, Revision 2026
High-Performance Fiber Bundle Data Model for Scientific Visualization
Loading...
Searching...
No Matches
F5LT.c
Go to the documentation of this file.
1#include "F5L.h"
2#include "F5B.h"
3#include "F5X.h"
4#include "F5T.h"
5#include "F5A.h"
6#include "F5defs.h"
7#include "F5private.h"
8#include "F5coordinates.h"
9/* #if defined(__APPLE__) && defined(__MACH__) && defined(__POWERPC__) */
10#include <stdlib.h>
11/* #else */
12/* #include <malloc.h> */
13/* #endif */
14
15#include <assert.h>
16#include <string.h>
17
19
20
21int F5LTget_index_depth(hid_t Top_hid)
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}
33
35{
37 if (F5Aget_ints(Top_hid, FIBER_HDF5_SKELETON_DIMENSIONALITY_ATTRIB, &result, 1) <= 0)
38 F5printf(5," *Warning* F5LTget_F5LTget_skeleton_dimensionality() could not find skeleton dimensionality,setting unknown -1");
39
40 return result;
41}
42
43int F5LTset_dataspace(F5Path*f, int rank, hsize_t*dims)
44{
45hsize_t current_dims[FIBER_MAX_RANK];
46int current_rank, Mrank = -1;
47
48 if (!f)
49 {
50 return 0;
51 }
52
53 F5printf(30, "F5LTset_dataspace(,rank=%d,)", rank);
54
56 if (Mrank<0)
57 {
58 F5printf(30, "F5LTset_dataspace(,%d,): INVALID FILE: RANK attribute is not integer - cannot set dataspace!", rank);
59 return 0;
60 }
61
62 if (Mrank>=1)
63 {
64 if (Mrank != rank)
65 {
66 if (rank==4)
67 F5printf(0, "F5LTset_dataspace(,%d,): Dimensions %dx%dx%dx%d incompatible with RANK attribute %d - inconsistent dataspace!",
68 rank, (int)dims[0],(int)dims[1],(int)dims[2],(int)dims[3],
69 Mrank);
70 else
71 F5printf(0, "F5LTset_dataspace(,%d,): Dimensions incompatible with RANK attribute %d - inconsistent dataspace!", rank, Mrank);
72
73 return 0;
74 }
75 }
76
77 current_rank = F5LAget_dimensions(f->Topology_hid,
79 current_dims);
80
81 if (current_rank>0)
82 {
83 int i;
84 if (rank != current_rank)
85 {
86 puts("F5LTset_dataspace(): Set DATAPACE: Inconsistent rank with DATASPACE_DIMENSIONS!");
87 return 0;
88 }
89
90 for(i=0; i<rank; i++)
91 {
92 if (current_dims[i] != dims[i])
93 {
94 F5printf(5, "F5LTset_dataspace(,rank=%d,): new dimensions[%d] is %d, but already set to %d in the file as %dx%dx%dx%d - aborting.",
95 rank, i, (int)(current_dims[i]), (int)(dims[i]),
96 rank>0?(int)dims[0]:1, rank>1?(int)dims[1]:1, rank>2?(int)dims[2]:1, rank>3?(int)dims[3]:1);
97 return 0;
98 }
99 }
100 F5printf(5, "F5LTset_dataspace(,rank=%d,): dimensions are ok.", rank);
101 return 1;
102 }
103 {int i;
104 for(i=0; i<rank; i++)
105 {
106 if (dims[i] < 1)
107 {
108 F5printf(10, "F5LTset_dataspace(,rank=%d,): do NOT set new topology dimensions, because dims[%d]=%d\n", rank, i, (int)dims[i] );
109 return 0;
110 }
111 }
112 }
113
115 F5printf(30, "F5LTset_dataspace(,rank=%d,): set new dimensions to skeleton as %dx%dx%dx%d.", rank,
116 rank>0?(int)dims[0]:1, rank>1?(int)dims[1]:1, rank>2?(int)dims[2]:1, rank>3?(int)dims[3]:1);
117 return 1;
118}
119
120int F5LTexpand_dataspace(F5Path*f, int rank, hsize_t*dims)
121{
122hsize_t current_dims[FIBER_MAX_RANK];
123int current_rank, Mrank;
124int i;
125
126 F5printf(30, "F5LTexpand_dataspace(,%d,)", rank);
127 if (!f)
128 return 1;
129
131 if (Mrank<0)
132 {
133 F5printf(30, "F5LTexpand_dataspace(,%d,): INVALID FILE: RANK attribute is not integer - cannot set dataspace!", rank);
134 return 0;
135 }
136 if (Mrank>=0)
137 {
138 if (Mrank != rank)
139 {
140 F5printf(30, "F5LTexpand_dataspace(,%d,): Dimensions incompatible with RANK attribute %d - inconsistent dataspace!", rank, Mrank);
141 puts("Set DATAPACE: Inconsistent rank!");
142 return 0;
143 }
144 }
145
146 current_rank = F5LAget_dimensions(f->Topology_hid,
148 current_dims);
149
150 if (current_rank>0)
151 {
152 if (rank != current_rank)
153 {
154 puts("Set DATAPACE: Inconsistent rank!");
155 return 0;
156 }
157
158 for(i=0; i<rank; i++)
159 {
160 if (current_dims[i] < dims[i])
161 current_dims[i] = dims[i];
162 }
163 }
164 else
165 for(i=0; i<rank; i++)
166 current_dims[i] = dims[i];
167
169 F5printf(30, "F5LTexpand_dataspace(,rank=%d,): expand dimensions of topology.", rank);
170
171 for(i=0; i<rank; i++)
172 dims[i] = current_dims[i];
173
174 return 1;
175}
176
177
178
180{
181 if (!fpath) return 0;
182 if (fpath->field_enum_type_hid<=0)
183 {
184 assert(fpath->ContentsGroup_hid);
185 F5printf(30, " F5LTmake_enum_type() - save type.");
187 F5printf(30, " F5LTmake_enum_type() - DONE saving type.");
188 }
189 return fpath->field_enum_type_hid;
190}
191
192int F5LTget_maximal_grid_refinement(hid_t ContentsGroup_id,
193 const char*gridname,
194 hsize_t*refinement)
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}
210
211int F5LTget_maximal_skeleton_refinement(hid_t ContentsGroup_id,
212 const char*gridname,
213 hsize_t*refinement,
214 int IndexDepth,
215 int Dimensionality)
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}
238
239
240int F5LTset_maximal_grid_refinement(hid_t ContentsGroup_id,
241 const char*gridname,
242 int IndexDepth,
243 int Dimensionality,
244 const hsize_t*refinement)
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}
324
325/*
326 Create a Topology group on the lowest level,
327 i.e. create an HDF5 group with some attributes.
328 */
329hid_t F5LTcreate_topology(hid_t Grid_hid,
330 const char*TopologyName,
331 int IndexDepth,
332 int SkeletonDimensionality,
333 int DataspaceDimensionality,
334 const hsize_t*refinement)
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}
397
398/* F5B_new_global_cartesian_chart4D() */
399
400/**\ingroup F5L
401 The central F5Path constructor for write access:
402 Creates the basic F5 structures in the file and sets up an
403 F5Path object for subsequent use.
404 Basically, all the information contained in an F5Path object can
405 be created from the given parameters, however, some complexity
406 arises when modifying some file that already has some structure.
407 In such a case, it must re-use any found structures in a consistent
408 way, especcially it has to use named types instead of intrinsic ones.
409 */
410F5Path* F5LTcreateV(hid_t File_id, const double*time,
411 const char*gridname,
412 ChartDomain_IDs*ChartDomain,
413 ChartDomain_IDs*coord_creator(void*udata),
414 void*udata,
415 const char*coordinate_system,
416 const char*TopologyName,
417 int IndexDepth, int SkeletonDimensionality,
418 int Dimensionality,
419 const hsize_t*refinement)
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 }
673 else
674 {
675 F5printf(1, "F5 Creating a Topological %d-dimensional Skeleton of Index Depth=%d, "
676 "Info - No chart used for %s, seems to be a relative representation in [%s]"
677 , Dimensionality, IndexDepth
678 , TopologyName, coordinate_system);
679 }
680
682
683 F5printf(30, "~F5LTcreate(%s)<%d>, %dD, [%s]", TopologyName, IndexDepth, Dimensionality, coordinate_system);
684
686
687 return f;
688}
689
690
691
692static ChartDomain_IDs*coord_domain_creator(void*udata)
693{
694ChartDomain_IDs* (*coord_creator)() = (ChartDomain_IDs*(*)() )udata;
695 assert( coord_creator );
696 return coord_creator();
697}
698
699
700
701/**\ingroup F5L
702 Create a Topology of the given name with a representation in
703 the certain coordinate system.
704 If the ChartDomain has not been set yet, then
705 the types in the newly created chart domain (F5Path->myChart) will
706 contain valid types for the Points and tangential types,
707 as they are created by the specified coord_creator().
708 Note that the coord_create() specifies the \em type of the
709 coordinate system, while the coordinate_system parameter specifies
710 the actual object that is of this respective type.
711 */
712F5Path* F5LTcreate(hid_t File_id, const double*time,
713 const char*gridname,
714 ChartDomain_IDs*ChartDomain,
715 ChartDomain_IDs*coord_creator(),
716 const char*coordinate_system,
717 const char*TopologyName,
718 int IndexDepth, int SkeletonDimensionality,
719 int Dimensionality,
720 const hsize_t*refinement)
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}
long F5Aget_ints(hid_t loc_id, const char *name, int *data, hsize_t n)
Definition F5A.c:406
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
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
hid_t F5LTmake_enum_type(F5Path *fpath)
Definition F5LT.c:179
int F5LTget_skeleton_dimensionality(hid_t Top_hid)
Definition F5LT.c:34
int F5LTexpand_dataspace(F5Path *f, int rank, hsize_t *dims)
Definition F5LT.c:120
int F5LTset_dataspace(F5Path *f, int rank, hsize_t *dims)
Definition F5LT.c:43
F5Path * newF5Path(hid_t File_id)
Definition F5Path.c:5
void deleteF5Path(F5Path *f)
Definition F5Path.c:18
void TopologyName(char *name, int nlength, const hsize_t *level, int Centering, int dims)
Definition F5R.c:300
#define FIBER_HDF5_CHARTS_PER_GRID
Definition F5defs.h:110
#define FIBER_HDF5_INDEXDEPTH_ATTRIB
Definition F5defs.h:228
#define FIBER_HDF5_SKELETON_DIMENSIONALITY_ATTRIB
Definition F5defs.h:256
#define FIBER_HDF5_INVALID_SKELETON_DIMENSIONALITY
Definition F5defs.h:261
#define F5_INVALID_INDEX_DEPTH
Definition F5defs.h:233
#define FIBER_MAX_RANK
Definition F5defs.h:105
#define FIBER_HDF5_GLOBAL_CHARTS
Definition F5defs.h:109
#define FIBER_HDF5_REFINEMENT_INFO
Definition F5defs.h:72
#define FIBER_HDF5_GLOBALCHART_COORDINATES
Definition F5defs.h:112
#define FIBER_FIELD_DATASPACE_DIMENSIONS_ATTRIBUTE
Definition F5defs.h:153
#define FIBER_CONTENT_GRIDS
Definition F5defs.h:24
#define FIBER_HDF5_RANK_ATTRIBUTE
Definition F5defs.h:147
#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
int F5printf_indent
Definition F5private.c:349
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
#define F5printf(verbosity,...)
Definition F5private.h:60
hid_t F5Tsave_F5field_enum(hid_t loc_id)
Definition F5types.c:222
int F5LAsave_dimensions(hid_t Field_id, const char *aname, int rank, const hsize_t *dims)
Definition F5A.c:192
int F5LTset_maximal_grid_refinement(hid_t ContentsGroup_id, const char *gridname, int IndexDepth, int Dimensionality, const hsize_t *refinement)
Definition F5LT.c:240
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
int F5LAget_dimensions(hid_t Field_id, const char *aname, hsize_t dims[FIBER_MAX_RANK])
Definition F5A.c:233
int F5LTget_maximal_skeleton_refinement(hid_t ContentsGroup_id, const char *gridname, hsize_t *refinement, int IndexDepth, int Dimensionality)
Definition F5LT.c:211
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
int F5LTget_index_depth(hid_t Top_hid)
Definition F5LT.c:21
int F5LTget_maximal_grid_refinement(hid_t ContentsGroup_id, const char *gridname, hsize_t *refinement)
Definition F5LT.c:192
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)
Definition F5LT.c:712
F5_API hid_t F5Bappend_slice(hid_t file_id, const double *time)
Definition F5Bslice.c:140
#define H5Gclose(x)
Definition F5X.h:144
int F5Gexist(hid_t location, const char *name)
Definition F5X.c:307
hid_t F5Gtry_to_open(hid_t location, const char *name)
Definition F5X.c:297
hid_t F5Gappend(hid_t loc_id, const char *name)
Definition F5X.c:59
const char * domain_name
Definition F5Bchart.h:112
unsigned refs
Definition F5Bchart.h:114
hid_t GlobalChart_hid
Definition F5Path.h:54
hid_t Grid_hid
Definition F5Path.h:53
ChartDomain_IDs * FileIDs
Definition F5Path.h:35
hid_t field_enum_type_hid
Definition F5Path.h:48
hid_t Charts_hid
Definition F5Path.h:55
hid_t Representation_hid
Definition F5Path.h:58
hid_t ContentsGroup_hid
Definition F5Path.h:51
hid_t Slice_hid
Definition F5Path.h:52
hid_t Topology_hid
Definition F5Path.h:57
hid_t Chart_hid
Definition F5Path.h:56
ChartDomain_IDs * myChart
Definition F5Path.h:33