diff --git a/.gitattributes b/.gitattributes index 9095633..b8c9075 100644 --- a/.gitattributes +++ b/.gitattributes @@ -406,6 +406,7 @@ src/h5core/h5_hsearch_private.h -text src/h5core/h5_lustre.c -text src/h5core/h5_lustre_private.h -text src/h5core/h5_maps.c -text +src/h5core/h5_maps_private.h -text src/h5core/h5_model.c -text src/h5core/h5_mpi.c -text src/h5core/h5_mpi_private.h -text diff --git a/src/C/H5Fed.c b/src/C/H5Fed.c index 1f634fb..630817f 100644 --- a/src/C/H5Fed.c +++ b/src/C/H5Fed.c @@ -29,6 +29,7 @@ h5_err_t H5FedCloseMesh ( h5_file_t* const f ) { + SET_FNAME (f, __func__); return h5t_close_mesh (f); } diff --git a/src/C/H5Fed_adjacency.c b/src/C/H5Fed_adjacency.c index 728f6ba..6f49c16 100644 --- a/src/C/H5Fed_adjacency.c +++ b/src/C/H5Fed_adjacency.c @@ -38,5 +38,5 @@ H5FedReleaseListOfAdjacencies ( h5_idlist_t** list ) { SET_FNAME (f, __func__); - return h5priv_free_idlist (f, list); + return h5t_release_list_of_adjacencies (f, list); } diff --git a/src/C/H5Fed_tags.c b/src/C/H5Fed_tags.c index 7e03232..1c4eb75 100644 --- a/src/C/H5Fed_tags.c +++ b/src/C/H5Fed_tags.c @@ -107,58 +107,6 @@ H5FedSetMTag ( return h5t_set_mtag_by_name (f, name, id, dims, val); } -h5_err_t -H5FedSetMTagToVertex ( - h5_file_t* const f, - char name[], - h5_id_t id, - const size_t dims, - void* val - ) { - SET_FNAME (f, __func__); - id = h5tpriv_set_entity_type (H5T_ETYPE_VERTEX, id); - return h5t_set_mtag_by_name (f, name, id, dims, val); -} - -h5_err_t -H5FedSetMTagToEdge ( - h5_file_t* const f, - char name[], - h5_id_t id, - const size_t dims, - void* val - ) { - SET_FNAME (f, __func__); - id = h5tpriv_set_entity_type (H5T_ETYPE_EDGE, id); - return h5t_set_mtag_by_name (f, name, id, dims, val); -} - -h5_err_t -H5FedSetMTagToTriangle ( - h5_file_t* const f, - char name[], - h5_id_t id, - const size_t dims, - void* val - ) { - SET_FNAME (f, __func__); - id = h5tpriv_set_entity_type (H5T_ETYPE_TRIANGLE, id); - return h5t_set_mtag_by_name (f, name, id, dims, val); -} - -h5_err_t -H5FedSetMTagToTet ( - h5_file_t* const f, - char name[], - h5_id_t id, - const size_t dims, - void* val - ) { - SET_FNAME (f, __func__); - id = h5tpriv_set_entity_type (H5T_ETYPE_TET, id); - return h5t_set_mtag_by_name (f, name, id, dims, val); -} - /*! Set tag for entity in current mesh. diff --git a/src/h5core/h5_core_private.h b/src/h5core/h5_core_private.h index 92a4ada..7f46180 100644 --- a/src/h5core/h5_core_private.h +++ b/src/h5core/h5_core_private.h @@ -18,6 +18,7 @@ #include "h5_fcmp_private.h" #include "h5_hdf5_private.h" #include "h5_hsearch_private.h" +#include "h5_maps_private.h" #include "h5_mpi_private.h" #include "h5_qsort_private.h" #include "h5_readwrite_private.h" diff --git a/src/h5core/h5_errorhandling.c b/src/h5core/h5_errorhandling.c index bab11aa..00f1db3 100644 --- a/src/h5core/h5_errorhandling.c +++ b/src/h5core/h5_errorhandling.c @@ -6,7 +6,7 @@ #include "h5_core_private.h" static h5_errorhandler_t h5priv_errhandler = h5_report_errorhandler; -static h5_int32_t h5priv_debug_level = 1; +h5_int32_t h5priv_debug_level = 1; /*! \ingroup h5_core @@ -160,8 +160,8 @@ h5_abort_errorhandler ( return -(int)f->__errno; // never executed, just to supress a warning } -static void -_vprintf ( +void +h5priv_vprintf ( FILE* f, const char* prefix, const char* __funcname, @@ -216,7 +216,7 @@ h5_verror ( ) { if (h5priv_debug_level < 1) return; - _vprintf (stderr, "E", f->__funcname, fmt, ap); + h5priv_vprintf (stderr, "E", f->__funcname, fmt, ap); } @@ -232,7 +232,7 @@ h5_vwarn ( va_list ap ) { if (h5priv_debug_level < 2) return; - _vprintf (stderr, "W", f->__funcname, fmt, ap); + h5priv_vprintf (stderr, "W", f->__funcname, fmt, ap); } /*! @@ -252,69 +252,6 @@ h5_warn ( va_end (ap); } -/*! - \ingroup h5_core_errorhandling - - Print an informational message to \c stdout. -*/ -void -h5_vinfo ( - const h5_file_t* const f, - const char* fmt, - va_list ap - ) { - if (h5priv_debug_level < 3) return; - _vprintf (stdout, "I", f->__funcname, fmt, ap); -} - -/*! - \ingroup h5_core_errorhandling - - Print an informational message to \c stdout. -*/ -void -h5_info ( - const h5_file_t* const f, - const char* fmt, - ... - ) { - va_list ap; - va_start (ap, fmt); - h5_vinfo (f, fmt, ap); - va_end (ap); -} - -/*! - \ingroup h5_core_errorhandling - - Print a debug message to \c stdout. -*/ -void -h5_vdebug ( - const h5_file_t* const f, - const char* fmt, - va_list ap - ) { - if (h5priv_debug_level < 4) return; - _vprintf (stdout, "D", f->__funcname, fmt, ap); -} - -/*! - \ingroup h5_core_errorhandling - - Print a debug message to \c stdout. -*/ -void -h5_debug ( - const h5_file_t* const f, - const char* fmt, - ... - ) { - va_list ap; - va_start (ap, fmt); - h5_vdebug (f, fmt, ap); - va_end (ap); -} /*! \ingroup h5_core_errorhandling diff --git a/src/h5core/h5_hdf5.c b/src/h5core/h5_hdf5.c index 106f366..0e75048 100644 --- a/src/h5core/h5_hdf5.c +++ b/src/h5core/h5_hdf5.c @@ -13,6 +13,9 @@ h5priv_open_hdf5_group ( const hid_t loc_id, const char* const group_name ) { + h5_debug (f, "%s (loc_id=%lld, group_name=\"%s/%s\")", + __func__, (long long)loc_id, + h5_get_objname (loc_id), group_name); hid_t group_id = H5Gopen (loc_id, group_name, H5P_DEFAULT); if (group_id < 0) return h5_error ( @@ -21,6 +24,7 @@ h5priv_open_hdf5_group ( "Cannot open group \"%s/%s\".", h5_get_objname (loc_id), group_name); + h5_debug (f, "%s (): return group id: %lld", __func__, (long long)group_id); return group_id; } @@ -30,6 +34,9 @@ h5priv_create_hdf5_group ( const hid_t loc_id, const char* const group_name ) { + h5_debug (f, "%s (loc_id=%lld, group_name=\"%s/%s\")", + __func__, (long long)loc_id, + h5_get_objname (loc_id), group_name); hid_t group_id = H5Gcreate ( loc_id, group_name, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); if (group_id < 0) @@ -39,6 +46,7 @@ h5priv_create_hdf5_group ( "Cannot create group \"%s/%s\".", h5_get_objname (loc_id), group_name); + h5_debug (f, "%s (): return group id: %lld", __func__, (long long)group_id); return group_id; } @@ -69,29 +77,11 @@ h5priv_open_group ( h5_err_t exists; TRY( exists = h5priv_hdf5_link_exists(f, loc_id, group_name) ); if (exists > 0) { - h5_info ( - f, - "Opening group %s/%s.", - h5_get_objname (loc_id), - group_name); - group_id = H5Gopen (loc_id, group_name, H5P_DEFAULT); + TRY( group_id = h5priv_open_hdf5_group (f, loc_id, group_name) ); } else { CHECK_WRITABLE_MODE (f); - h5_info ( - f, - "Creating group %s/%s.", - h5_get_objname (loc_id), - group_name); - group_id = H5Gcreate (loc_id, group_name, 0, - H5P_DEFAULT, H5P_DEFAULT); + TRY( group_id = h5priv_create_hdf5_group (f, loc_id, group_name) ); } - if (group_id < 0) - return h5_error ( - f, - H5_ERR_HDF5, - "Cannot open or create group %s/%s.", - h5_get_objname (loc_id), - group_name); return group_id; } @@ -107,6 +97,12 @@ h5priv_close_hdf5_group ( h5_file_t* const f, const hid_t group_id ) { + h5_debug (f, "%s (group_id=%lld, group_name=\"%s\")", + __func__, + (long long)group_id, + h5_get_objname (group_id)); + + h5_debug (f, "%s (group_id=%lld)", __func__, (long long)group_id); if (group_id <= 0) return H5_SUCCESS; if (H5Gclose (group_id) < 0 ) { return h5_error ( @@ -187,6 +183,10 @@ h5priv_open_hdf5_dataset ( const hid_t loc_id, const char* const dataset_name ) { + h5_debug (f, "%s (loc_id=%lld, dataset_name=\"%s/%s\")", + __func__, (long long)loc_id, + h5_get_objname (loc_id), dataset_name); + hid_t dataset_id; dataset_id = H5Dopen ( @@ -198,7 +198,7 @@ h5priv_open_hdf5_dataset ( f, H5_ERR_HDF5, "Cannot open dataset \"%s\".", dataset_name); - + h5_debug (f, "%s (): return dataset id: %lld", __func__, (long long)dataset_id); return dataset_id; } @@ -222,6 +222,10 @@ h5priv_create_hdf5_dataset ( const hid_t dataspace_id, const hid_t create_proplist ) { + h5_debug (f, "%s (loc_id=%lld, dataset_name=\"%s/%s\")", + __func__, (long long)loc_id, + h5_get_objname (loc_id), dataset_name); + hid_t dataset_id = H5Dcreate ( loc_id, dataset_name, @@ -237,6 +241,7 @@ h5priv_create_hdf5_dataset ( "Cannot create dataset %s/%s", h5_get_objname (loc_id), dataset_name); + h5_debug (f, "%s (): return dataset id: %lld", __func__, (long long)dataset_id); return dataset_id; } @@ -252,6 +257,10 @@ h5priv_close_hdf5_dataset ( const hid_t dset_id ) { if (dset_id == 0 || dset_id == -1) return H5_SUCCESS; + h5_debug (f, "%s (dataset_id=%lld, dataset_name=\"%s\")", + __func__, + (long long)dset_id, + h5_get_objname (dset_id)); if (H5Dclose (dset_id) < 0) { return h5_error( diff --git a/src/h5core/h5_hsearch.c b/src/h5core/h5_hsearch.c index 365af29..25559cf 100644 --- a/src/h5core/h5_hsearch.c +++ b/src/h5core/h5_hsearch.c @@ -299,19 +299,19 @@ h5priv_hcreate_string_keyed ( } static int -_hcmp_id_keyed ( +hcmp_loc_id_keyed ( const void* __a, const void* __b ) { - return memcmp (__a, __b, sizeof(h5_id_t)); + return memcmp (__a, __b, sizeof(h5_loc_id_t)); } static unsigned int -_hcompute_id_keyed ( +hcompute_loc_id_keyed ( const void*__item ) { char* key = (char*)__item; - unsigned int count = sizeof (h5_id_t); + unsigned int count = sizeof (h5_loc_id_t); unsigned int hval = count; while (count-- > 0) { if (key[count]) { @@ -323,11 +323,11 @@ _hcompute_id_keyed ( } h5_err_t -h5priv_hcreate_id_keyed ( +h5priv_hcreate_loc_id_keyed ( h5_file_t* const f, size_t nel, h5_hashtable_t* htab ) { return h5priv_hcreate (f, nel, htab, - _hcmp_id_keyed, _hcompute_id_keyed); + hcmp_loc_id_keyed, hcompute_loc_id_keyed); } diff --git a/src/h5core/h5_hsearch_private.h b/src/h5core/h5_hsearch_private.h index fb7def1..f0b333a 100644 --- a/src/h5core/h5_hsearch_private.h +++ b/src/h5core/h5_hsearch_private.h @@ -68,7 +68,7 @@ h5priv_hcreate_string_keyed ( ); h5_err_t -h5priv_hcreate_id_keyed ( +h5priv_hcreate_loc_id_keyed ( h5_file_t* const f, size_t nel, h5_hashtable_t* htab diff --git a/src/h5core/h5_maps.c b/src/h5core/h5_maps.c index 97d8b0d..256b586 100644 --- a/src/h5core/h5_maps.c +++ b/src/h5core/h5_maps.c @@ -8,7 +8,7 @@ h5_err_t h5priv_alloc_idlist_items ( h5_file_t* const f, h5_idlist_t* list, - const h5_size_t size + const h5_size_t size // new size of list ) { int new = (list->items == NULL); size_t size_in_bytes = size * sizeof (list->items[0]); @@ -61,7 +61,7 @@ h5_err_t h5priv_append_to_idlist ( h5_file_t* const f, h5_idlist_t* list, - h5_id_t id + h5_loc_id_t id ) { if (list->num_items == list->size) { h5_size_t size = list->size; @@ -81,8 +81,8 @@ h5priv_cmp_ids_by_eid ( const void* _id1, const void* _id2 ) { - h5_id_t id1 = h5tpriv_get_elem_idx (*(h5_id_t*)_id1); - h5_id_t id2 = h5tpriv_get_elem_idx (*(h5_id_t*)_id2); + h5_loc_id_t id1 = h5tpriv_get_elem_idx (*(h5_loc_id_t*)_id1); + h5_loc_id_t id2 = h5tpriv_get_elem_idx (*(h5_loc_id_t*)_id2); if (id1 < id2) return -1; if (id1 > id2) return 1; @@ -94,8 +94,8 @@ h5priv_cmp_ids ( const void* _id1, const void* _id2 ) { - h5_id_t *id1 = (h5_id_t*)_id1; - h5_id_t *id2 = (h5_id_t*)_id2; + h5_loc_id_t *id1 = (h5_loc_id_t*)_id1; + h5_loc_id_t *id2 = (h5_loc_id_t*)_id2; if (*id1 < *id2) return -1; if (*id1 > *id2) return 1; @@ -120,18 +120,18 @@ h5priv_sort_idlist_by_eid ( /* Find ID in sorted list */ -h5_id_t +h5_loc_id_t h5priv_find_idlist ( h5_file_t* const f, h5_idlist_t* list, - h5_id_t item + h5_loc_id_t item ) { #pragma unused f - register h5_id_t low = 0; - register h5_id_t high = list->num_items - 1; + register h5_loc_idx_t low = 0; + register h5_loc_idx_t high = list->num_items - 1; while (low <= high) { - register h5_id_t mid = (low + high) / 2; - register h5_id_t diff = list->items[mid] - item; + register h5_loc_idx_t mid = (low + high) / 2; + register h5_loc_id_t diff = list->items[mid] - item; if ( diff > 0 ) high = mid - 1; else if ( diff < 0 ) @@ -145,12 +145,12 @@ h5priv_find_idlist ( /* Add item to list at position given by \c idx. */ -h5_id_t +h5_loc_idx_t h5priv_insert_idlist ( h5_file_t* const f, h5_idlist_t* list, - h5_id_t item, - h5_id_t idx + h5_loc_id_t item, + h5_loc_idx_t idx ) { if (list->num_items == list->size) { h5_size_t size = list->size; @@ -173,13 +173,13 @@ h5priv_insert_idlist ( /* Search in sorted list. If item is not in list, add it. */ -h5_id_t +h5_loc_idx_t h5priv_search_idlist ( h5_file_t* const f, h5_idlist_t* list, - h5_id_t item + h5_loc_id_t item ) { - h5_id_t idx = h5priv_find_idlist (f, list, item); + h5_loc_idx_t idx = h5priv_find_idlist (f, list, item); if (idx < 0) { idx = -(idx+1); idx = h5priv_insert_idlist (f, list, item, idx); @@ -187,10 +187,11 @@ h5priv_search_idlist ( return idx; } + h5_err_t -h5priv_alloc_idmap ( +h5priv_alloc_idxmap ( h5_file_t* const f, - h5_idmap_t* map, + h5_idxmap_t* map, const h5_size_t size ) { int new = (map->items == NULL); @@ -202,16 +203,16 @@ h5priv_alloc_idmap ( } h5_err_t -h5priv_insert_idmap ( +h5priv_insert_idxmap ( h5_file_t* const f, - h5_idmap_t* map, - h5_id_t global_id, - h5_id_t local_id + h5_idxmap_t* map, + h5_glb_idx_t glb_idx, + h5_loc_idx_t loc_idx ) { if (map->num_items == map->size) return HANDLE_H5_OVERFLOW_ERR (f, "g2lmap", (long long)map->size); - h5_id_t i = h5priv_search_idmap (map, global_id); + h5_loc_idx_t i = h5priv_search_idxmap (map, glb_idx); if (i >= 0) /* global id already in use ? */ return -1; @@ -221,8 +222,8 @@ h5priv_insert_idmap ( &map->items[i+1], &map->items[i], (map->num_items - i) * sizeof(map->items[0])); - map->items[i].global_id = global_id; - map->items[i].local_id = local_id; + map->items[i].glb_idx = glb_idx; + map->items[i].loc_idx = loc_idx; map->num_items++; return H5_SUCCESS; @@ -238,17 +239,17 @@ h5priv_insert_idmap ( where \c value must be inserted. */ -h5_id_t -h5priv_search_idmap ( - h5_idmap_t* map, - h5_id_t value +h5_loc_idx_t +h5priv_search_idxmap ( + h5_idxmap_t* map, + h5_glb_idx_t value ) { - register int low = 0; - register int high = map->num_items - 1; + register h5_loc_idx_t low = 0; + register h5_loc_idx_t high = map->num_items - 1; while (low <= high) { - register int mid = (low + high) / 2; - register h5_id_t diff = map->items[mid].global_id - value; + register h5_loc_idx_t mid = (low + high) / 2; + register h5_glb_idx_t diff = map->items[mid].glb_idx - value; if ( diff > 0 ) high = mid - 1; else if ( diff < 0 ) @@ -260,24 +261,24 @@ h5priv_search_idmap ( } static int -cmp_idmap_items ( +cmp_idxmap_items ( const void* _item1, const void* _item2 ) { - h5_idmap_el_t* item1 = (h5_idmap_el_t*)_item1; - h5_idmap_el_t* item2 = (h5_idmap_el_t*)_item2; + h5_idxmap_el_t* item1 = (h5_idxmap_el_t*)_item1; + h5_idxmap_el_t* item2 = (h5_idxmap_el_t*)_item2; - if (item1->global_id < item2->global_id) return -1; - if (item1->global_id > item2->global_id) return 1; + if (item1->glb_idx < item2->glb_idx) return -1; + if (item1->glb_idx > item2->glb_idx) return 1; return 0; } h5_err_t -h5priv_sort_idmap ( - h5_idmap_t* map +h5priv_sort_idxmap ( + h5_idxmap_t* map ) { qsort ( map->items, map->num_items, sizeof (map->items[0]), - cmp_idmap_items); + cmp_idxmap_items); return H5_SUCCESS; } diff --git a/src/h5core/h5_maps_private.h b/src/h5core/h5_maps_private.h new file mode 100644 index 0000000..df52e14 --- /dev/null +++ b/src/h5core/h5_maps_private.h @@ -0,0 +1,103 @@ +#ifndef __H5_MAPS_PRIVATE_H +#define __H5_MAPS_PRIVATE_H + +h5_err_t +h5priv_alloc_idlist ( + h5_file_t * const f, + h5_idlist_t **list, + const h5_size_t size + ); + +h5_err_t +h5priv_free_idlist ( + h5_file_t * const f, + h5_idlist_t **list + ); + +h5_err_t +h5priv_alloc_idlist_items ( + h5_file_t * const f, + h5_idlist_t *list, + const h5_size_t size + ); + +h5_err_t +h5priv_free_idlist_items ( + h5_file_t * const f, + h5_idlist_t *list + ); + +h5_err_t +h5priv_append_to_idlist ( + h5_file_t * const f, + h5_idlist_t *list, + h5_loc_id_t id + ); + +int +h5priv_cmp_ids_by_eid ( + const void *_id1, + const void *_id2 + ); + +int +h5priv_cmp_ids ( + const void *_id1, + const void *_id2 + ); + +h5_err_t +h5priv_sort_idlist_by_eid ( + h5_file_t * const f, + h5_idlist_t *list + ); + +h5_loc_id_t +h5priv_find_idlist ( + h5_file_t * const f, + h5_idlist_t *list, + h5_loc_id_t item + ); + +h5_loc_idx_t +h5priv_insert_idlist ( + h5_file_t * const f, + h5_idlist_t *list, + h5_loc_id_t item, + h5_loc_idx_t idx + ); + +h5_loc_idx_t +h5priv_search_idlist ( + h5_file_t * const f, + h5_idlist_t *list, + h5_loc_id_t item + ); + +h5_err_t +h5priv_alloc_idxmap ( + h5_file_t * const f, + h5_idxmap_t *map, + const h5_size_t size + ); + +h5_err_t +h5priv_insert_idxmap ( + h5_file_t * const f, + h5_idxmap_t *map, + h5_glb_idx_t glb_idx, + h5_loc_idx_t loc_idx + ); + +h5_loc_idx_t +h5priv_search_idxmap ( + h5_idxmap_t *map, + h5_glb_idx_t value + ); + +h5_err_t +h5priv_sort_idxmap ( + h5_idxmap_t *map + ); + +#endif diff --git a/src/h5core/h5_openclose.c b/src/h5core/h5_openclose.c index d48f0ae..71f1deb 100644 --- a/src/h5core/h5_openclose.c +++ b/src/h5core/h5_openclose.c @@ -351,6 +351,7 @@ h5_err_t h5_close_file ( h5_file_t* const f /*!< file handle */ ) { + h5_debug (f, "%s ()", __func__); f->__errno = H5_SUCCESS; CHECK_FILEHANDLE (f); @@ -369,7 +370,7 @@ h5_close_file ( TRY( h5priv_close_hdf5_file (f, f->file) ); free (f); - + h5_debug (f, "%s (): done", __func__); return H5_SUCCESS; } diff --git a/src/h5core/h5_types_private.h b/src/h5core/h5_types_private.h index df59eb0..3d2a264 100644 --- a/src/h5core/h5_types_private.h +++ b/src/h5core/h5_types_private.h @@ -44,15 +44,15 @@ struct h5_file { struct h5t_fdata *t; }; -struct h5_idmap_el { - h5_id_t global_id; - h5_id_t local_id; +struct h5_idxmap_el { + h5_glb_idx_t glb_idx; + h5_loc_idx_t loc_idx; }; -typedef struct h5_idmap_el h5_idmap_el_t; +typedef struct h5_idxmap_el h5_idxmap_el_t; -struct h5_idmap { +struct h5_idxmap { h5_size_t size; /* allocated space in number of items */ h5_size_t num_items; /* stored items */ - h5_idmap_el_t* items; + h5_idxmap_el_t* items; }; #endif diff --git a/src/h5core/h5t_access_private.h b/src/h5core/h5t_access_private.h index c5488b2..e0181b3 100644 --- a/src/h5core/h5t_access_private.h +++ b/src/h5core/h5t_access_private.h @@ -4,95 +4,253 @@ extern struct h5t_access_methods h5tpriv_access_trim_methods; extern struct h5t_access_methods h5tpriv_access_tetm_methods; -#define h5tpriv_get_loc_elem(f, elem_idx) \ - (*f->t->methods.access->get_loc_elem)(f, elem_idx) +static inline h5_generic_loc_elem_t* +h5tpriv_get_loc_elem ( + h5_file_t* const f, + const h5_loc_idx_t elem_idx + ) { + return (*f->t->methods.access->get_loc_elem)(f, elem_idx); +} -#define h5tpriv_get_loc_elem_idx(f, elem_idx) \ - (*f->t->methods.access->get_loc_elem_idx)(f, elem_idx) +static inline h5_loc_idx_t +h5tpriv_get_loc_elem_parent_idx ( + h5_file_t* const f, + const h5_loc_idx_t elem_idx + ) { + return (*f->t->methods.access->get_loc_elem_parent_idx)(f, elem_idx); +} -#define h5tpriv_set_loc_elem_idx(f, elem_idx, idx) \ - (*f->t->methods.access->set_loc_elem_idx)(f, elem_idx, idx) +static inline h5_loc_idx_t +h5tpriv_set_loc_elem_parent_idx ( + h5_file_t* const f, + const h5_loc_idx_t elem_idx, + const h5_loc_idx_t parent_idx + ) { + return (*f->t->methods.access->set_loc_elem_parent_idx)( + f, elem_idx, parent_idx); +} -#define h5tpriv_get_loc_elem_parent_idx(f, elem_idx) \ - (*f->t->methods.access->get_loc_elem_parent_idx)(f, elem_idx) +static inline h5_loc_idx_t +h5tpriv_get_loc_elem_child_idx ( + h5_file_t* const f, + const h5_loc_idx_t elem_idx + ) { + return (*f->t->methods.access->get_loc_elem_child_idx)( + f, elem_idx); +} -#define h5tpriv_set_loc_elem_parent_idx(f, elem_idx, idx) \ - (*f->t->methods.access->set_loc_elem_parent_idx)(f, elem_idx, idx) +static inline h5_loc_idx_t +h5tpriv_set_loc_elem_child_idx ( + h5_file_t* const f, + h5_loc_idx_t elem_idx, + h5_loc_idx_t child_idx) { + return (*f->t->methods.access->set_loc_elem_child_idx)( + f, elem_idx, child_idx); +} -#define h5tpriv_get_loc_elem_child_idx(f, elem_idx) \ - (*f->t->methods.access->get_loc_elem_child_idx)(f, elem_idx) +static inline h5_id_t +h5tpriv_get_loc_elem_level_idx ( + h5_file_t* const f, + h5_loc_idx_t elem_idx + ) { + return (*f->t->methods.access->get_loc_elem_level_idx)( + f, elem_idx); +} -#define h5tpriv_set_loc_elem_child_idx(f, elem_idx, idx) \ - (*f->t->methods.access->set_loc_elem_child_idx)(f, elem_idx, idx) +static inline h5_id_t +h5tpriv_set_loc_elem_level_idx ( + h5_file_t* const f, + h5_loc_idx_t elem_idx, + h5_id_t lvl_idx + ) { + return (*f->t->methods.access->set_loc_elem_level_idx)( + f, elem_idx, lvl_idx); +} -#define h5tpriv_get_loc_elem_level_idx(f, elem_idx) \ - (*f->t->methods.access->get_loc_elem_level_idx)(f, elem_idx) +static inline h5_loc_idx_t* +h5tpriv_get_loc_elem_vertex_indices ( + h5_file_t* const f, + h5_loc_idx_t elem_idx + ) { + return (*f->t->methods.access->get_loc_elem_vertex_indices)( + f, elem_idx); +} -#define h5tpriv_set_loc_elem_level_idx(f, elem_idx, idx) \ - (*f->t->methods.access->set_loc_elem_level_idx)(f, elem_idx, idx) +static inline h5_loc_idx_t +h5tpriv_get_loc_elem_vertex_idx ( + h5_file_t* const f, + h5_loc_idx_t elem_idx, + h5_loc_idx_t face_idx + ) { + return (*f->t->methods.access->get_loc_elem_vertex_idx)( + f, elem_idx, face_idx); +} -#define h5tpriv_get_loc_elem_vertex_indices(f, elem_idx) \ - (*f->t->methods.access->get_loc_elem_vertex_indices)(f, elem_idx) +static inline h5_loc_idx_t +h5tpriv_set_loc_elem_vertex_idx ( + h5_file_t* const f, + h5_loc_idx_t elem_idx, + h5_loc_idx_t face_idx, + h5_loc_idx_t vertex_idx + ) { + return (*f->t->methods.access->set_loc_elem_vertex_idx)( + f, elem_idx, face_idx, vertex_idx); +} -#define h5tpriv_get_loc_elem_vertex_idx(f, elem_idx, face_idx) \ - (*f->t->methods.access->get_loc_elem_vertex_idx)(f, elem_idx, face_idx) +static inline h5_loc_idx_t* +h5tpriv_get_loc_elem_neighbor_indices ( + h5_file_t* const f, + h5_loc_idx_t elem_idx + ) { + return (*f->t->methods.access->get_loc_elem_neighbor_indices)( + f, elem_idx); +} -#define h5tpriv_set_loc_elem_vertex_idx(f, elem_idx, face_idx, idx) \ - (*f->t->methods.access->get_loc_elem_vertex_idx)(f, elem_idx, face_idx, idx) +static inline h5_loc_idx_t +h5tpriv_get_loc_elem_neighbor_idx ( + h5_file_t* const f, + h5_loc_idx_t elem_idx, + h5_loc_idx_t face_idx + ) { + return (*f->t->methods.access->get_loc_elem_neighbor_idx)( + f, elem_idx, face_idx); +} -#define h5tpriv_get_loc_elem_neighbor_indices(f, elem_idx) \ - (*f->t->methods.access->get_loc_elem_neighbor_indices)(f, elem_idx) +static inline h5_loc_idx_t +h5tpriv_set_loc_elem_neighbor_idx ( + h5_file_t* const f, + h5_loc_idx_t elem_idx, + h5_loc_idx_t face_idx, + h5_loc_idx_t idx + ) { + return (*f->t->methods.access->set_loc_elem_neighbor_idx)( + f, elem_idx, face_idx, idx); +} -#define h5tpriv_get_loc_elem_neighbor_idx(f, elem_idx, face_idx) \ - (*f->t->methods.access->get_loc_elem_neighbor_idx)(f, elem_idx, face_idx) +static inline h5_generic_glb_elem_t* +h5tpriv_get_glb_elem ( + h5_file_t* const f, + h5_loc_idx_t elem_idx + ) { + return (*f->t->methods.access->get_glb_elem)( + f, elem_idx); +} -#define h5tpriv_set_loc_elem_neighbor_idx(f, elem_idx, face_idx, idx) \ - (*f->t->methods.access->get_loc_elem_neighbor_idx)(f, elem_idx, face_idx, idx) +static inline h5_glb_idx_t +h5tpriv_get_glb_elem_idx ( + h5_file_t* const f, + h5_loc_idx_t elem_idx + ) { + return (*f->t->methods.access->get_glb_elem_idx)( + f, elem_idx); +} -#define h5tpriv_get_glb_elem(f, elem_idx) \ - (*f->t->methods.access->get_glb_elem)(f, elem_idx) +static inline h5_glb_idx_t +h5tpriv_set_glb_elem_idx ( + h5_file_t* const f, + h5_loc_idx_t elem_idx, + h5_glb_idx_t idx + ) { + return (*f->t->methods.access->set_glb_elem_idx)( + f, elem_idx, idx); +} -#define h5tpriv_get_glb_elem_idx(f, elem_idx) \ - (*f->t->methods.access->get_glb_elem_idx)(f, elem_idx) +static inline h5_glb_idx_t +h5tpriv_get_glb_elem_parent_idx ( + h5_file_t* const f, + h5_loc_idx_t elem_idx + ) { + return (*f->t->methods.access->get_glb_elem_parent_idx)( + f, elem_idx); +} -#define h5tpriv_set_glb_elem_idx(f, elem_idx, idx) \ - (*f->t->methods.access->set_glb_elem_idx)(f, elem_idx, idx) +static inline h5_glb_idx_t +h5tpriv_set_glb_elem_parent_idx ( + h5_file_t* const f, + h5_loc_idx_t elem_idx, + h5_glb_idx_t idx + ) { + return (*f->t->methods.access->set_glb_elem_parent_idx)( + f, elem_idx, idx); +} -#define h5tpriv_get_glb_elem_parent_idx(f, elem_idx) \ - (*f->t->methods.access->get_glb_elem_parent_idx)(f, elem_idx) +static inline h5_glb_idx_t +h5tpriv_get_glb_elem_child_idx( + h5_file_t* const f, + h5_loc_idx_t elem_idx + ) { + return (*f->t->methods.access->get_glb_elem_child_idx)( + f, elem_idx); +} -#define h5tpriv_set_glb_elem_parent_idx(f, elem_idx, idx) \ - (*f->t->methods.access->set_glb_elem_parent_idx)(f, elem_idx, idx) +static inline h5_glb_idx_t +h5tpriv_set_glb_elem_child_idx ( + h5_file_t* const f, + h5_loc_idx_t elem_idx, + h5_glb_idx_t idx + ) { + return (*f->t->methods.access->set_glb_elem_child_idx)( + f, elem_idx, idx); +} -#define h5tpriv_get_glb_elem_child_idx(f, elem_idx) \ - (*f->t->methods.access->get_glb_elem_child_idx)(f, elem_idx) +static inline h5_glb_idx_t* +h5tpriv_get_glb_elem_vertex_indices ( + h5_file_t* const f, + h5_loc_idx_t elem_idx + ) { + return (*f->t->methods.access->get_glb_elem_vertex_indices)( + f, elem_idx); +} -#define h5tpriv_set_glb_elem_child_idx(f, elem_idx, idx) \ - (*f->t->methods.access->set_glb_elem_child_idx)(f, elem_idx, idx) +static inline h5_glb_idx_t +h5tpriv_get_glb_elem_vertex_idx( + h5_file_t* const f, + h5_loc_idx_t elem_idx, + h5_loc_idx_t face_idx + ) { + return (*f->t->methods.access->get_glb_elem_vertex_idx)( + f, elem_idx, face_idx); +} -#define h5tpriv_get_glb_elem_level_idx(f, elem_idx) \ - (*f->t->methods.access->get_glb_elem_level_idx)(f, elem_idx) +static inline h5_glb_idx_t + h5tpriv_set_glb_elem_vertex_idx( + h5_file_t* const f, + h5_loc_idx_t elem_idx, + h5_loc_idx_t face_idx, + h5_glb_idx_t idx + ) { + return (*f->t->methods.access->set_glb_elem_vertex_idx)( + f, elem_idx, face_idx, idx); +} -#define h5tpriv_set_glb_elem_level_idx(f, elem_idx, idx) \ - (*f->t->methods.access->set_glb_elem_level_idx)(f, elem_idx, idx) +static inline h5_glb_idx_t* +h5tpriv_get_glb_elem_neighbor_indices( + h5_file_t* const f, + h5_loc_idx_t elem_idx + ) { + return (*f->t->methods.access->get_glb_elem_neighbor_indices)( + f, elem_idx); +} -#define h5tpriv_get_glb_elem_vertex_indices(f, elem_idx) \ - (*f->t->methods.access->get_glb_elem_vertex_indices)(f, elem_idx) - -#define h5tpriv_get_glb_elem_vertex_idx(f, elem_idx, face_idx) \ - (*f->t->methods.access->get_glb_elem_vertex_idx)(f, elem_idx, face_idx) - -#define h5tpriv_set_glb_elem_vertex_idx(f, elem_idx, face_idx, idx) \ - (*f->t->methods.access->get_glb_elem_vertex_idx)(f, elem_idx, face_idx, idx) - -#define h5tpriv_get_glb_elem_neighbor_indices(f, elem_idx) \ - (*f->t->methods.access->get_glb_elem_neighbor_indices)(f, elem_idx) - -#define h5tpriv_get_glb_elem_neighbor_idx(f, elem_idx, face_idx) \ - (*f->t->methods.access->get_glb_elem_neighbor_idx)(f, elem_idx, face_idx) - -#define h5tpriv_set_glb_elem_neighbor_idx(f, elem_idx, face_idx, idx) \ - (*f->t->methods.access->get_glb_elem_neighbor_idx)(f, elem_idx, face_idx, idx) +static inline h5_glb_idx_t +h5tpriv_get_glb_elem_neighbor_idx ( + h5_file_t* const f, + h5_loc_idx_t elem_idx, + h5_loc_idx_t face_idx + ) { + return (*f->t->methods.access->get_glb_elem_neighbor_idx)( + f, elem_idx, face_idx); +} +static inline h5_glb_idx_t +h5tpriv_set_glb_elem_neighbor_idx ( + h5_file_t* const f, + h5_loc_idx_t elem_idx, + h5_loc_idx_t face_idx, + h5_glb_idx_t idx + ) { + return (*f->t->methods.access->set_glb_elem_neighbor_idx)( + f, elem_idx, face_idx, idx); +} #endif diff --git a/src/h5core/h5t_access_tetm.c b/src/h5core/h5t_access_tetm.c index 6a69837..81a38db 100644 --- a/src/h5core/h5t_access_tetm.c +++ b/src/h5core/h5t_access_tetm.c @@ -2,45 +2,45 @@ #include "h5_core_private.h" /*** op's on local elements ***/ -static h5_generic_elem_t* +static h5_generic_loc_elem_t* get_loc_elem ( h5_file_t* const f, - const h5_id_t elem_idx + const h5_loc_idx_t elem_idx ) { - return (h5_generic_elem_t*)&f->t->loc_elems.tets[elem_idx]; + return (h5_generic_loc_elem_t*)&f->t->loc_elems.tets[elem_idx]; } -static h5_id_t +static h5_loc_idx_t get_loc_elem_parent_idx ( h5_file_t* const f, - const h5_id_t elem_idx + const h5_loc_idx_t elem_idx ) { return f->t->loc_elems.tets[elem_idx].parent_idx; } -static h5_id_t +static h5_loc_idx_t set_loc_elem_parent_idx ( h5_file_t* const f, - const h5_id_t elem_idx, - const h5_id_t parent_idx + const h5_loc_idx_t elem_idx, + const h5_loc_idx_t parent_idx ) { f->t->loc_elems.tets[elem_idx].parent_idx = parent_idx; return parent_idx; } -static h5_id_t +static h5_loc_idx_t get_loc_elem_child_idx ( h5_file_t* const f, - const h5_id_t elem_idx + const h5_loc_idx_t elem_idx ) { return f->t->loc_elems.tets[elem_idx].child_idx; } -static h5_id_t +static h5_loc_idx_t set_loc_elem_child_idx ( h5_file_t* const f, - const h5_id_t elem_idx, - const h5_id_t child_idx + const h5_loc_idx_t elem_idx, + const h5_loc_idx_t child_idx ) { f->t->loc_elems.tets[elem_idx].child_idx = child_idx; return child_idx; @@ -49,7 +49,7 @@ set_loc_elem_child_idx ( static h5_id_t get_loc_elem_level_idx ( h5_file_t* const f, - const h5_id_t elem_idx + const h5_loc_idx_t elem_idx ) { return f->t->loc_elems.tets[elem_idx].idx; } @@ -57,64 +57,64 @@ get_loc_elem_level_idx ( static h5_id_t set_loc_elem_level_idx ( h5_file_t* const f, - const h5_id_t elem_idx, + const h5_loc_idx_t elem_idx, const h5_id_t level_idx ) { f->t->loc_elems.tets[elem_idx].idx = level_idx; return level_idx; } -static h5_id_t* +static h5_loc_idx_t* get_loc_elem_vertex_indices ( h5_file_t* const f, - const h5_id_t elem_idx + const h5_loc_idx_t elem_idx ) { return f->t->loc_elems.tets[elem_idx].vertex_indices; } -static h5_id_t +static h5_loc_idx_t get_loc_elem_vertex_idx ( h5_file_t* const f, - const h5_id_t elem_idx, - const h5_id_t face_idx + const h5_loc_idx_t elem_idx, + const h5_loc_idx_t face_idx ) { return f->t->loc_elems.tets[elem_idx].vertex_indices[face_idx]; } -static h5_id_t +static h5_loc_idx_t set_loc_elem_vertex_idx ( h5_file_t* const f, - const h5_id_t elem_idx, - const h5_id_t face_idx, - const h5_id_t vertex_idx + const h5_loc_idx_t elem_idx, + const h5_loc_idx_t face_idx, + const h5_loc_idx_t vertex_idx ) { f->t->loc_elems.tets[elem_idx].vertex_indices[face_idx] = vertex_idx; return vertex_idx; } -static h5_id_t* +static h5_loc_idx_t* get_loc_elem_neighbor_indices ( h5_file_t* const f, - const h5_id_t elem_idx + const h5_loc_idx_t elem_idx ) { return f->t->loc_elems.tets[elem_idx].neighbor_indices; } -static h5_id_t +static h5_loc_idx_t get_loc_elem_neighbor_idx ( h5_file_t* const f, - const h5_id_t elem_idx, - const h5_id_t face_idx + const h5_loc_idx_t elem_idx, + const h5_loc_idx_t face_idx ) { return f->t->loc_elems.tets[elem_idx].neighbor_indices[face_idx]; } -static h5_id_t +static h5_loc_idx_t set_loc_elem_neighbor_idx ( h5_file_t* const f, - const h5_id_t elem_idx, - const h5_id_t face_idx, - const h5_id_t neighbor_idx + const h5_loc_idx_t elem_idx, + const h5_loc_idx_t face_idx, + const h5_loc_idx_t neighbor_idx ) { f->t->loc_elems.tets[elem_idx].neighbor_indices[face_idx] = neighbor_idx; return neighbor_idx; @@ -122,119 +122,119 @@ set_loc_elem_neighbor_idx ( /*** op's on global elements ***/ -static h5_generic_elem_t* +static h5_generic_glb_elem_t* get_glb_elem ( h5_file_t* const f, - const h5_id_t elem_idx + const h5_loc_idx_t elem_idx ) { - return (h5_generic_elem_t*)&f->t->glb_elems.tets[elem_idx]; + return (h5_generic_glb_elem_t*)&f->t->glb_elems.tets[elem_idx]; } -static h5_id_t +static h5_glb_idx_t get_glb_elem_idx ( h5_file_t* const f, - const h5_id_t elem_idx + const h5_loc_idx_t elem_idx ) { return f->t->glb_elems.tets[elem_idx].idx; } -static h5_id_t +static h5_glb_idx_t set_glb_elem_idx ( h5_file_t* const f, - const h5_id_t elem_idx, - const h5_id_t idx + const h5_loc_idx_t elem_idx, + const h5_glb_idx_t idx ) { f->t->glb_elems.tets[elem_idx].idx = idx; return idx; } -static h5_id_t +static h5_glb_idx_t get_glb_elem_parent_idx ( h5_file_t* const f, - const h5_id_t elem_idx + const h5_loc_idx_t elem_idx ) { return f->t->glb_elems.tets[elem_idx].parent_idx; } -static h5_id_t +static h5_glb_idx_t set_glb_elem_parent_idx ( h5_file_t* const f, - const h5_id_t elem_idx, - const h5_id_t parent_idx + const h5_loc_idx_t elem_idx, + const h5_glb_idx_t parent_idx ) { f->t->glb_elems.tets[elem_idx].parent_idx = parent_idx; return parent_idx; } -static h5_id_t +static h5_glb_idx_t get_glb_elem_child_idx ( h5_file_t* const f, - const h5_id_t elem_idx + const h5_loc_idx_t elem_idx ) { return f->t->glb_elems.tets[elem_idx].child_idx; } -static h5_id_t +static h5_glb_idx_t set_glb_elem_child_idx ( h5_file_t* const f, - const h5_id_t elem_idx, - const h5_id_t child_idx + const h5_loc_idx_t elem_idx, + const h5_glb_idx_t child_idx ) { f->t->glb_elems.tets[elem_idx].child_idx = child_idx; return child_idx; } -static h5_id_t* +static h5_glb_idx_t* get_glb_elem_vertex_indices ( h5_file_t* const f, - const h5_id_t elem_idx + const h5_loc_idx_t elem_idx ) { return f->t->glb_elems.tets[elem_idx].vertex_indices; } -static h5_id_t +static h5_glb_idx_t get_glb_elem_vertex_idx ( h5_file_t* const f, - const h5_id_t elem_idx, - const h5_id_t face_idx + const h5_loc_idx_t elem_idx, + const h5_loc_idx_t face_idx ) { return f->t->glb_elems.tets[elem_idx].vertex_indices[face_idx]; } -static h5_id_t +static h5_glb_idx_t set_glb_elem_vertex_idx ( h5_file_t* const f, - const h5_id_t elem_idx, - const h5_id_t face_idx, - const h5_id_t vertex_idx + const h5_loc_idx_t elem_idx, + const h5_loc_idx_t face_idx, + const h5_glb_idx_t vertex_idx ) { f->t->glb_elems.tets[elem_idx].vertex_indices[face_idx] = vertex_idx; return vertex_idx; } -static h5_id_t* +static h5_glb_idx_t* get_glb_elem_neighbor_indices ( h5_file_t* const f, - const h5_id_t elem_idx + const h5_loc_idx_t elem_idx ) { return f->t->glb_elems.tets[elem_idx].neighbor_indices; } -static h5_id_t +static h5_glb_idx_t get_glb_elem_neighbor_idx ( h5_file_t* const f, - const h5_id_t elem_idx, - const h5_id_t face_idx + const h5_loc_idx_t elem_idx, + const h5_loc_idx_t face_idx ) { return f->t->glb_elems.tets[elem_idx].neighbor_indices[face_idx]; } -static h5_id_t +static h5_glb_idx_t set_glb_elem_neighbor_idx ( h5_file_t* const f, - const h5_id_t elem_idx, - const h5_id_t face_idx, - const h5_id_t neighbor_idx + const h5_loc_idx_t elem_idx, + const h5_loc_idx_t face_idx, + const h5_glb_idx_t neighbor_idx ) { f->t->glb_elems.tets[elem_idx].neighbor_indices[face_idx] = neighbor_idx; return neighbor_idx; diff --git a/src/h5core/h5t_access_trim.c b/src/h5core/h5t_access_trim.c index 7f66de8..2f2fe09 100644 --- a/src/h5core/h5t_access_trim.c +++ b/src/h5core/h5t_access_trim.c @@ -2,45 +2,45 @@ #include "h5_core_private.h" /*** op's on local elements ***/ -static h5_generic_elem_t* +static h5_generic_loc_elem_t* get_loc_elem ( h5_file_t* const f, - const h5_id_t elem_idx + const h5_loc_idx_t elem_idx ) { - return (h5_generic_elem_t*)&f->t->loc_elems.tris[elem_idx]; + return (h5_generic_loc_elem_t*)&f->t->loc_elems.tris[elem_idx]; } -static h5_id_t +static h5_loc_idx_t get_loc_elem_parent_idx ( h5_file_t* const f, - const h5_id_t elem_idx + const h5_loc_idx_t elem_idx ) { return f->t->loc_elems.tris[elem_idx].parent_idx; } -static h5_id_t +static h5_loc_idx_t set_loc_elem_parent_idx ( h5_file_t* const f, - const h5_id_t elem_idx, - const h5_id_t parent_idx + const h5_loc_idx_t elem_idx, + const h5_loc_idx_t parent_idx ) { f->t->loc_elems.tris[elem_idx].parent_idx = parent_idx; return parent_idx; } -static h5_id_t +static h5_loc_idx_t get_loc_elem_child_idx ( h5_file_t* const f, - const h5_id_t elem_idx + const h5_loc_idx_t elem_idx ) { return f->t->loc_elems.tris[elem_idx].child_idx; } -static h5_id_t +static h5_loc_idx_t set_loc_elem_child_idx ( h5_file_t* const f, - const h5_id_t elem_idx, - const h5_id_t child_idx + const h5_loc_idx_t elem_idx, + const h5_loc_idx_t child_idx ) { f->t->loc_elems.tris[elem_idx].child_idx = child_idx; return child_idx; @@ -49,7 +49,7 @@ set_loc_elem_child_idx ( static h5_id_t get_loc_elem_level_idx ( h5_file_t* const f, - const h5_id_t elem_idx + const h5_loc_idx_t elem_idx ) { return f->t->loc_elems.tris[elem_idx].idx; } @@ -57,64 +57,64 @@ get_loc_elem_level_idx ( static h5_id_t set_loc_elem_level_idx ( h5_file_t* const f, - const h5_id_t elem_idx, - const h5_id_t level_idx + const h5_loc_idx_t elem_idx, + const h5_loc_idx_t level_idx ) { f->t->loc_elems.tris[elem_idx].idx = level_idx; return level_idx; } -static h5_id_t* +static h5_loc_idx_t* get_loc_elem_vertex_indices ( h5_file_t* const f, - const h5_id_t elem_idx + const h5_loc_idx_t elem_idx ) { return f->t->loc_elems.tris[elem_idx].vertex_indices; } -static h5_id_t +static h5_loc_idx_t get_loc_elem_vertex_idx ( h5_file_t* const f, - const h5_id_t elem_idx, - const h5_id_t face_idx + const h5_loc_idx_t elem_idx, + const h5_loc_idx_t face_idx ) { return f->t->loc_elems.tris[elem_idx].vertex_indices[face_idx]; } -static h5_id_t +static h5_loc_idx_t set_loc_elem_vertex_idx ( h5_file_t* const f, - const h5_id_t elem_idx, - const h5_id_t face_idx, - const h5_id_t vertex_idx + const h5_loc_idx_t elem_idx, + const h5_loc_idx_t face_idx, + const h5_loc_idx_t vertex_idx ) { f->t->loc_elems.tris[elem_idx].vertex_indices[face_idx] = vertex_idx; return vertex_idx; } -static h5_id_t* +static h5_loc_idx_t* get_loc_elem_neighbor_indices ( h5_file_t* const f, - const h5_id_t elem_idx + const h5_loc_idx_t elem_idx ) { return f->t->loc_elems.tris[elem_idx].neighbor_indices; } -static h5_id_t +static h5_loc_idx_t get_loc_elem_neighbor_idx ( h5_file_t* const f, - const h5_id_t elem_idx, - const h5_id_t face_idx + const h5_loc_idx_t elem_idx, + const h5_loc_idx_t face_idx ) { return f->t->loc_elems.tris[elem_idx].neighbor_indices[face_idx]; } -static h5_id_t +static h5_loc_idx_t set_loc_elem_neighbor_idx ( h5_file_t* const f, - const h5_id_t elem_idx, - const h5_id_t face_idx, - const h5_id_t neighbor_idx + const h5_loc_idx_t elem_idx, + const h5_loc_idx_t face_idx, + const h5_loc_idx_t neighbor_idx ) { f->t->loc_elems.tris[elem_idx].neighbor_indices[face_idx] = neighbor_idx; return neighbor_idx; @@ -122,119 +122,119 @@ set_loc_elem_neighbor_idx ( /*** op's on global elements ***/ -static h5_generic_elem_t* +static h5_generic_glb_elem_t* get_glb_elem ( h5_file_t* const f, - const h5_id_t elem_idx + const h5_loc_idx_t elem_idx ) { - return (h5_generic_elem_t*)&f->t->glb_elems.tris[elem_idx]; + return (h5_generic_glb_elem_t*)&f->t->glb_elems.tris[elem_idx]; } -static h5_id_t +static h5_glb_idx_t get_glb_elem_idx ( h5_file_t* const f, - const h5_id_t elem_idx + const h5_loc_idx_t elem_idx ) { return f->t->glb_elems.tris[elem_idx].idx; } -static h5_id_t +static h5_glb_idx_t set_glb_elem_idx ( h5_file_t* const f, - const h5_id_t elem_idx, - const h5_id_t idx + const h5_loc_idx_t elem_idx, + const h5_glb_idx_t idx ) { f->t->glb_elems.tris[elem_idx].idx = idx; return idx; } -static h5_id_t +static h5_glb_idx_t get_glb_elem_parent_idx ( h5_file_t* const f, - const h5_id_t elem_idx + const h5_loc_idx_t elem_idx ) { return f->t->glb_elems.tris[elem_idx].parent_idx; } -static h5_id_t +static h5_glb_idx_t set_glb_elem_parent_idx ( h5_file_t* const f, - const h5_id_t elem_idx, - const h5_id_t parent_idx + const h5_loc_idx_t elem_idx, + const h5_glb_id_t parent_idx ) { f->t->glb_elems.tris[elem_idx].parent_idx = parent_idx; return parent_idx; } -static h5_id_t +static h5_glb_idx_t get_glb_elem_child_idx ( h5_file_t* const f, - const h5_id_t elem_idx + const h5_loc_idx_t elem_idx ) { return f->t->glb_elems.tris[elem_idx].child_idx; } -static h5_id_t +static h5_glb_idx_t set_glb_elem_child_idx ( h5_file_t* const f, - const h5_id_t elem_idx, - const h5_id_t child_idx + const h5_loc_idx_t elem_idx, + const h5_glb_idx_t child_idx ) { f->t->glb_elems.tris[elem_idx].child_idx = child_idx; return child_idx; } -static h5_id_t* +static h5_glb_idx_t* get_glb_elem_vertex_indices ( h5_file_t* const f, - const h5_id_t elem_idx + const h5_loc_idx_t elem_idx ) { return f->t->glb_elems.tris[elem_idx].vertex_indices; } -static h5_id_t +static h5_glb_idx_t get_glb_elem_vertex_idx ( h5_file_t* const f, - const h5_id_t elem_idx, - const h5_id_t face_idx + const h5_loc_idx_t elem_idx, + const h5_loc_idx_t face_idx ) { return f->t->glb_elems.tris[elem_idx].vertex_indices[face_idx]; } -static h5_id_t +static h5_glb_idx_t set_glb_elem_vertex_idx ( h5_file_t* const f, - const h5_id_t elem_idx, - const h5_id_t face_idx, - const h5_id_t vertex_idx + const h5_loc_idx_t elem_idx, + const h5_loc_idx_t face_idx, + const h5_glb_idx_t vertex_idx ) { f->t->glb_elems.tris[elem_idx].vertex_indices[face_idx] = vertex_idx; return vertex_idx; } -static h5_id_t* +static h5_glb_idx_t* get_glb_elem_neighbor_indices ( h5_file_t* const f, - const h5_id_t elem_idx + const h5_loc_idx_t elem_idx ) { return f->t->glb_elems.tris[elem_idx].neighbor_indices; } -static h5_id_t +static h5_glb_idx_t get_glb_elem_neighbor_idx ( h5_file_t* const f, - const h5_id_t elem_idx, - const h5_id_t face_idx + const h5_loc_idx_t elem_idx, + const h5_loc_idx_t face_idx ) { return f->t->glb_elems.tris[elem_idx].neighbor_indices[face_idx]; } -static h5_id_t +static h5_glb_idx_t set_glb_elem_neighbor_idx ( h5_file_t* const f, - const h5_id_t elem_idx, - const h5_id_t face_idx, - const h5_id_t neighbor_idx + const h5_loc_idx_t elem_idx, + const h5_loc_idx_t face_idx, + const h5_glb_idx_t neighbor_idx ) { f->t->glb_elems.tris[elem_idx].neighbor_indices[face_idx] = neighbor_idx; return neighbor_idx; diff --git a/src/h5core/h5t_adjacencies.c b/src/h5core/h5t_adjacencies.c index 385fe96..40d3cda 100644 --- a/src/h5core/h5t_adjacencies.c +++ b/src/h5core/h5t_adjacencies.c @@ -19,7 +19,7 @@ h5_err_t h5t_get_adjacencies ( h5_file_t* const f, - const h5_id_t entity_id, + const h5_loc_id_t entity_id, const h5_int32_t dim, h5_idlist_t** list ) { diff --git a/src/h5core/h5t_adjacencies_private.h b/src/h5core/h5t_adjacencies_private.h index f0f325e..46629ac 100644 --- a/src/h5core/h5t_adjacencies_private.h +++ b/src/h5core/h5t_adjacencies_private.h @@ -7,7 +7,7 @@ extern struct h5t_adjacency_methods h5tpriv_tetm_adjacency_methods; static inline h5_err_t h5tpriv_get_adjacencies ( h5_file_t* const f, - const h5_id_t entity_id, + const h5_loc_id_t entity_id, const h5_int32_t dim, h5_idlist_t** list ) { @@ -21,6 +21,7 @@ static inline h5_err_t h5tpriv_release_adjacency_structs ( h5_file_t* const f ) { + h5_debug (f, "%s ()", __func__); if (f->t->methods.adjacency == NULL) { return 0; } @@ -32,6 +33,7 @@ h5tpriv_update_adjacency_structs ( h5_file_t* const f, const h5_id_t level_id ) { + h5_debug (f, "%s (%lld)", __func__, level_id); return (*f->t->methods.adjacency->update_internal_structs)(f, level_id); } diff --git a/src/h5core/h5t_adjacencies_tetm.c b/src/h5core/h5t_adjacencies_tetm.c index 42c974c..0468d6d 100644 --- a/src/h5core/h5t_adjacencies_tetm.c +++ b/src/h5core/h5t_adjacencies_tetm.c @@ -20,20 +20,14 @@ static inline h5_err_t alloc_tv ( - h5_file_t* const f, - const h5_loc_idx_t level_idx - + h5_file_t* const f ) { h5t_fdata_t* t = f->t; - h5_loc_idx_t idx = (level_idx <= 0) ? 0 : t->num_vertices[level_idx-1]; - h5_loc_idx_t last = t->num_vertices[t->num_levels-1]; + h5_loc_idx_t num_vertices = t->num_vertices[t->num_levels-1]; h5t_adjacencies_t* adj = &t->adjacencies; - adj->tv.size = last; - size_t size = last * sizeof(adj->tv.v[0]); - TRY( adj->tv.v = h5priv_alloc (f, adj->tv.v, size) ); - size = (last-idx) * sizeof(adj->tv.v[0]); - memset (&adj->tv.v[idx], 0, size); + // allocate one ID list per vertex + TRY( adj->tv.v = h5priv_calloc (f, num_vertices, sizeof(*adj->tv.v)) ); return H5_SUCCESS; } @@ -65,18 +59,18 @@ compute_elems_of_vertices ( const h5_id_t from_lvl ) { /* expand structure */ - TRY( alloc_tv (f, from_lvl) ); + TRY( alloc_tv (f) ); /* loop over all elements in current level */ h5t_fdata_t* t = f->t; h5_loc_idx_t idx = (from_lvl <= 0) ? 0 : t->num_elems[from_lvl-1]; h5_loc_idx_t last = t->num_elems[t->num_levels-1]; - h5_tet_t *el = &t->loc_elems.tets[idx]; + h5_loc_tet_t *el = &t->loc_elems.tets[idx]; for (;idx < last; idx++, el++) { int face_idx; int num_faces = h5tpriv_ref_elem_get_num_vertices(t); for (face_idx = 0; face_idx < num_faces; face_idx++) { - h5_id_t vidx = el->vertex_indices[face_idx]; + h5_loc_idx_t vidx = el->vertex_indices[face_idx]; TRY( h5priv_append_to_idlist ( f, &t->adjacencies.tv.v[vidx], @@ -104,8 +98,8 @@ compute_elems_of_edges ( const h5_id_t from_lvl ) { h5t_fdata_t *t = f->t; - h5_id_t elem_idx = (from_lvl <= 0) ? 0 : t->num_elems[from_lvl-1]; - h5_id_t num_elems = t->num_elems[t->num_levels-1]; + h5_loc_idx_t elem_idx = (from_lvl <= 0) ? 0 : t->num_elems[from_lvl-1]; + h5_loc_idx_t num_elems = t->num_elems[t->num_levels-1]; h5_idlist_t *retval = NULL; TRY( h5tpriv_resize_te_htab (f, 4*(num_elems-elem_idx)) ); for (;elem_idx < num_elems; elem_idx++) { @@ -134,8 +128,8 @@ compute_elems_of_triangles ( const h5_id_t from_lvl ) { h5t_fdata_t* t = f->t; - h5_id_t elem_idx = (from_lvl <= 0) ? 0 : t->num_elems[from_lvl-1]; - h5_id_t num_elems = t->num_elems[t->num_levels-1]; + h5_loc_idx_t elem_idx = (from_lvl <= 0) ? 0 : t->num_elems[from_lvl-1]; + h5_loc_idx_t num_elems = t->num_elems[t->num_levels-1]; h5_idlist_t *retval = NULL; TRY( h5tpriv_resize_td_htab (f, 4*(num_elems-elem_idx)) ); for (;elem_idx < num_elems; elem_idx++) { @@ -152,7 +146,7 @@ compute_elems_of_triangles ( static inline h5_err_t compute_children_of_edge ( h5_file_t* const f, - h5_id_t kid, + h5_loc_id_t kid, h5_idlist_t* children ) { h5t_fdata_t* t = f->t; @@ -164,16 +158,16 @@ compute_children_of_edge ( h5tpriv_get_elem_idx (kid), &te ) ); - h5_id_t* edge = te->items; - h5_id_t* end = te->items+te->num_items; + h5_loc_id_t* edge = te->items; + h5_loc_id_t* end = te->items+te->num_items; for (; edge < end; edge++) { - h5_id_t elem_idx = h5tpriv_get_elem_idx (*edge); - h5_id_t face_idx = h5tpriv_get_face_idx (*edge); - h5_tet_t* tet = &t->loc_elems.tets[elem_idx]; - if (h5tpriv_elem_is_on_cur_level (f, (h5_generic_elem_t*)tet) == H5_OK ) { + h5_loc_idx_t elem_idx = h5tpriv_get_elem_idx (*edge); + h5_loc_idx_t face_idx = h5tpriv_get_face_idx (*edge); + h5_loc_tet_t* tet = &t->loc_elems.tets[elem_idx]; + if (h5tpriv_elem_is_on_cur_level (f, (h5_generic_loc_elem_t*)tet) == H5_OK ) { TRY( h5priv_append_to_idlist (f, children, *edge) ); } else { - h5_id_t kids[2]; + h5_loc_id_t kids[2]; TRY( h5tpriv_get_direct_children_of_edge ( f, face_idx, @@ -192,7 +186,7 @@ compute_children_of_edge ( static inline h5_err_t compute_sections_of_edge ( h5_file_t* const f, - h5_id_t kid, + h5_loc_id_t kid, h5_idlist_t* children ) { h5t_fdata_t* t = f->t; @@ -203,16 +197,16 @@ compute_sections_of_edge ( h5tpriv_get_face_idx (kid), h5tpriv_get_elem_idx (kid), &te ) ); - h5_id_t* edge = te->items; - h5_id_t* end = te->items+te->num_items; + h5_loc_id_t* edge = te->items; + h5_loc_id_t* end = te->items+te->num_items; int refined = 0; for (; edge < end; edge++) { - h5_id_t eid = h5tpriv_get_elem_idx (*edge); - h5_id_t face_id = h5tpriv_get_face_idx (*edge); - h5_generic_elem_t* tet = (h5_generic_elem_t*)&t->loc_elems.tets[eid]; + h5_loc_idx_t eid = h5tpriv_get_elem_idx (*edge); + h5_loc_idx_t face_id = h5tpriv_get_face_idx (*edge); + h5_generic_loc_elem_t* tet = (h5_generic_loc_elem_t*)&t->loc_elems.tets[eid]; if (! h5tpriv_elem_is_on_cur_level (f, tet) == H5_OK) { refined = 1; - h5_id_t kids[2]; + h5_loc_id_t kids[2]; TRY( h5tpriv_get_direct_children_of_edge ( f, face_id, @@ -262,11 +256,11 @@ compute_sections_of_edge ( static inline h5_err_t compute_direct_children_of_triangle ( h5_file_t* const f, - h5_id_t face_idx, - h5_id_t elem_idx, - h5_id_t children[4] + h5_loc_idx_t face_idx, + h5_loc_idx_t elem_idx, + h5_loc_id_t children[4] ) { - h5_id_t map[4][4][2] = { + h5_loc_idx_t map[4][4][2] = { {{0,0},{0,1},{0,2},{0,5}}, {{1,0},{1,1},{1,3},{2,4}}, {{2,0},{2,2},{2,3},{1,7}}, @@ -290,7 +284,7 @@ compute_direct_children_of_triangle ( static inline h5_err_t compute_children_of_triangle ( h5_file_t* const f, - h5_id_t did, + h5_loc_id_t did, h5_idlist_t* children ) { @@ -302,16 +296,16 @@ compute_children_of_triangle ( h5tpriv_get_face_idx (did), h5tpriv_get_elem_idx (did), &td) ); - h5_id_t* tri = td->items; - h5_id_t* end = td->items+td->num_items; + h5_loc_id_t* tri = td->items; + h5_loc_id_t* end = td->items+td->num_items; for (; tri < end; tri++) { - h5_id_t eid = h5tpriv_get_elem_idx (*tri); - h5_id_t face_idx = h5tpriv_get_face_idx (*tri); - h5_generic_elem_t* tet = (h5_generic_elem_t*)&t->loc_elems.tets[eid]; + h5_loc_idx_t eid = h5tpriv_get_elem_idx (*tri); + h5_loc_idx_t face_idx = h5tpriv_get_face_idx (*tri); + h5_generic_loc_elem_t* tet = (h5_generic_loc_elem_t*)&t->loc_elems.tets[eid]; if (h5tpriv_elem_is_on_cur_level (f, tet) == H5_OK) { TRY( h5priv_append_to_idlist (f, children, *tri) ); } else { - h5_id_t dids[4]; + h5_loc_id_t dids[4]; TRY( compute_direct_children_of_triangle ( f, face_idx, @@ -329,7 +323,7 @@ compute_children_of_triangle ( static inline h5_err_t compute_sections_of_triangle ( h5_file_t* const f, - h5_id_t did, + h5_loc_id_t did, h5_idlist_t* children ) { h5t_fdata_t* t = f->t; @@ -339,16 +333,16 @@ compute_sections_of_triangle ( f, h5tpriv_get_face_idx (did), h5tpriv_get_elem_idx (did), &td) ); - h5_id_t* tri = td->items; - h5_id_t* end = td->items+td->num_items; + h5_loc_id_t* tri = td->items; + h5_loc_id_t* end = td->items+td->num_items; int refined = 0; for (; tri < end; tri++) { - h5_id_t eid = h5tpriv_get_elem_idx (*tri); - h5_id_t face_idx = h5tpriv_get_face_idx (*tri); - h5_generic_elem_t* tet = (h5_generic_elem_t*)&t->loc_elems.tets[eid]; + h5_loc_idx_t eid = h5tpriv_get_elem_idx (*tri); + h5_loc_idx_t face_idx = h5tpriv_get_face_idx (*tri); + h5_generic_loc_elem_t* tet = (h5_generic_loc_elem_t*)&t->loc_elems.tets[eid]; if (! h5tpriv_elem_is_on_cur_level (f, tet) == H5_OK) { refined = 1; - h5_id_t dids[4]; + h5_loc_id_t dids[4]; TRY( compute_direct_children_of_triangle ( f, face_idx, @@ -399,11 +393,11 @@ get_edges_uadj_to_vertex ( h5_idlist_t* tv = &t->adjacencies.tv.v[idx]; h5_size_t i; - h5_id_t* vidp = tv->items; // ptr to upward adjacent elements + h5_loc_id_t* vidp = tv->items; // ptr to upward adjacent elements for (i = 0; i < tv->num_items; i++, vidp++) { h5_loc_idx_t elem_idx = h5tpriv_get_elem_idx (*vidp); h5_loc_idx_t face_idx = h5tpriv_get_face_idx (*vidp); - h5_generic_elem_t* tet = (h5_generic_elem_t*)&t->loc_elems.tets[elem_idx]; + h5_generic_loc_elem_t* tet = (h5_generic_loc_elem_t*)&t->loc_elems.tets[elem_idx]; if (h5tpriv_elem_is_on_cur_level (f, tet) == H5_NOK ) { continue; @@ -423,11 +417,11 @@ static inline h5_err_t add_triangle ( h5_file_t* const f, h5_idlist_t* list, - h5_id_t face, - h5_id_t eid + h5_loc_idx_t face_idx, + h5_loc_idx_t elem_idx ) { h5_idlist_t* td; - TRY( h5tpriv_find_td2 (f, face, eid, &td) ); + TRY( h5tpriv_find_td2 (f, face_idx, elem_idx, &td) ); TRY( h5priv_search_idlist (f, list, td->items[0]) ); return H5_SUCCESS; @@ -452,11 +446,11 @@ get_triangles_uadj_to_vertex ( h5_idlist_t* tv = &t->adjacencies.tv.v[idx]; h5_size_t i; - h5_id_t* vidp = tv->items; + h5_loc_id_t* vidp = tv->items; for (i = 0; i < tv->num_items; i++, vidp++) { - h5_id_t elem_idx = h5tpriv_get_elem_idx (*vidp); - h5_id_t face_idx = h5tpriv_get_face_idx (*vidp); - h5_generic_elem_t* tet = (h5_generic_elem_t*)&t->loc_elems.tets[elem_idx]; + h5_loc_idx_t elem_idx = h5tpriv_get_elem_idx (*vidp); + h5_loc_idx_t face_idx = h5tpriv_get_face_idx (*vidp); + h5_generic_loc_elem_t* tet = (h5_generic_loc_elem_t*)&t->loc_elems.tets[elem_idx]; if (h5tpriv_elem_is_on_cur_level (f, tet) == H5_NOK) { continue; @@ -486,10 +480,10 @@ get_tets_uadj_to_vertex ( h5_idlist_t* tv = &t->adjacencies.tv.v[idx]; h5_size_t i; - h5_id_t* vidp = tv->items; + h5_loc_id_t* vidp = tv->items; for (i = 0; i < tv->num_items; i++, vidp++) { - h5_id_t elem_idx = h5tpriv_get_elem_idx (*vidp); - h5_generic_elem_t* tet = (h5_generic_elem_t*)&t->loc_elems.tets[elem_idx]; + h5_loc_idx_t elem_idx = h5tpriv_get_elem_idx (*vidp); + h5_generic_loc_elem_t* tet = (h5_generic_loc_elem_t*)&t->loc_elems.tets[elem_idx]; if (h5tpriv_elem_is_on_cur_level (f, tet) == H5_NOK) { continue; @@ -503,21 +497,21 @@ get_tets_uadj_to_vertex ( static inline h5_err_t get_triangles_uadj_to_edge ( h5_file_t* const f, - const h5_id_t kid, + const h5_loc_id_t kid, h5_idlist_t** list ) { h5_idlist_t* children; TRY( h5priv_alloc_idlist (f, &children, 8) ); TRY( compute_children_of_edge (f, kid, children) ); TRY( h5priv_alloc_idlist (f, list, 8) ); - h5_id_t* edge = children->items; - h5_id_t* end = children->items+children->num_items; + h5_loc_id_t* edge = children->items; + h5_loc_id_t* end = children->items+children->num_items; int map[6][2] = { {2,3}, {0,3}, {1,3}, {1,2}, {0,2}, {0,1} }; for (; edge < end; edge++) { - h5_id_t eid = h5tpriv_get_elem_idx (*edge); - h5_id_t face_idx = h5tpriv_get_face_idx (*edge); - TRY( add_triangle (f, *list, map[face_idx][0], eid) ); - TRY( add_triangle (f, *list, map[face_idx][1], eid) ); + h5_loc_idx_t elem_idx = h5tpriv_get_elem_idx (*edge); + h5_loc_idx_t face_idx = h5tpriv_get_face_idx (*edge); + TRY( add_triangle (f, *list, map[face_idx][0], elem_idx) ); + TRY( add_triangle (f, *list, map[face_idx][1], elem_idx) ); } TRY( h5priv_free_idlist ( f, &children) ); @@ -527,7 +521,7 @@ get_triangles_uadj_to_edge ( static inline h5_err_t get_tets_uadj_to_edge ( h5_file_t* const f, - const h5_id_t kid, + const h5_loc_id_t kid, h5_idlist_t** list ) { h5_idlist_t* children; @@ -535,10 +529,10 @@ get_tets_uadj_to_edge ( TRY( compute_children_of_edge (f, kid, children) ); TRY( h5priv_alloc_idlist (f, list, 8) ); int i; - h5_id_t* kidp = children->items; + h5_loc_id_t* kidp = children->items; for (i = 0; i < children->num_items; i++, kidp++) { - h5_id_t eid = h5tpriv_get_elem_idx (*kidp); - TRY( h5priv_search_idlist (f, *list, eid) ); + h5_loc_idx_t elem_idx = h5tpriv_get_elem_idx (*kidp); + TRY( h5priv_search_idlist (f, *list, elem_idx) ); } TRY( h5priv_free_idlist (f, &children) ); return H5_SUCCESS; @@ -547,7 +541,7 @@ get_tets_uadj_to_edge ( static inline h5_err_t get_tets_uadj_to_triangle ( h5_file_t* const f, - const h5_id_t did, + const h5_loc_id_t did, h5_idlist_t** list ) { h5_idlist_t* children; @@ -555,10 +549,10 @@ get_tets_uadj_to_triangle ( TRY( compute_children_of_triangle (f, did, children) ); TRY( h5priv_alloc_idlist (f, list, 8) ); int i; - h5_id_t *didp = children->items; + h5_loc_id_t *didp = children->items; for (i = 0; i < children->num_items; i++ , didp++) { - h5_id_t eid = h5tpriv_get_elem_idx (*didp); - TRY( h5priv_search_idlist (f, *list, eid) ); + h5_loc_idx_t elem_idx = h5tpriv_get_elem_idx (*didp); + TRY( h5priv_search_idlist (f, *list, elem_idx) ); } TRY( h5priv_free_idlist (f, &children) ); return H5_SUCCESS; @@ -567,7 +561,7 @@ get_tets_uadj_to_triangle ( static inline h5_err_t get_vertices_dadj_to_edge ( h5_file_t* const f, - const h5_id_t kid, + const h5_loc_id_t kid, h5_idlist_t** list ) { h5_idlist_t* children; @@ -575,12 +569,12 @@ get_vertices_dadj_to_edge ( TRY( compute_sections_of_edge (f, kid, children) ); TRY( h5priv_alloc_idlist (f, list, 8) ); int i; - h5_id_t* kidp = children->items; + h5_loc_id_t* kidp = children->items; for (i = 0; i < children->num_items; i++, kidp++) { - h5_id_t vids[2]; - TRY( h5t_get_vertex_indices_of_edge (f, *kidp, vids) ); - TRY( h5priv_search_idlist (f, *list, vids[0]) ); - TRY( h5priv_search_idlist (f, *list, vids[1]) ); + h5_loc_idx_t vertex_indices[2]; + TRY( h5t_get_vertex_indices_of_edge (f, *kidp, vertex_indices) ); + TRY( h5priv_search_idlist (f, *list, vertex_indices[0]) ); + TRY( h5priv_search_idlist (f, *list, vertex_indices[1]) ); } TRY( h5priv_free_idlist(f, &children) ); return H5_SUCCESS; @@ -592,61 +586,62 @@ get_vertices_dadj_to_edge ( static inline h5_err_t get_vertices_dadj_to_triangle ( h5_file_t* const f, - const h5_id_t did, + const h5_loc_id_t did, h5_idlist_t** list ) { h5_idlist_t* children; TRY( h5priv_alloc_idlist (f, &children, 8) ); int map[4][3] = { {1,4,5}, {2,3,5}, {0,3,4}, {0,1,2} }; - h5_id_t face = h5tpriv_get_face_idx (did); - h5_id_t eid = h5tpriv_get_elem_idx (did); + h5_loc_idx_t elem_idx = h5tpriv_get_elem_idx (did); + h5_loc_idx_t face_idx = h5tpriv_get_face_idx (did); - h5_id_t i; + int i; for (i = 0; i < 3; i++) { TRY( compute_sections_of_edge ( f, - h5tpriv_build_edge_id (map[face][i], eid), + h5tpriv_build_edge_id (map[face_idx][i], elem_idx), children) ); } TRY( h5priv_alloc_idlist (f, list, 8) ); - h5_id_t* kid = children->items; + h5_loc_id_t* kid = children->items; for (i = 0; i < children->num_items; i++, kid++) { - h5_id_t vids[2]; - TRY( h5t_get_vertex_indices_of_edge (f, *kid, vids) ); - TRY( h5priv_search_idlist (f, *list, vids[0]) ); - TRY( h5priv_search_idlist (f, *list, vids[1]) ); + h5_loc_idx_t vertex_indices[2]; + TRY( h5t_get_vertex_indices_of_edge (f, *kid, vertex_indices) ); + TRY( h5priv_search_idlist (f, *list, vertex_indices[0]) ); + TRY( h5priv_search_idlist (f, *list, vertex_indices[1]) ); } TRY( h5priv_free_idlist(f, &children) ); return H5_SUCCESS; } /* - Compute downward adjacent vertices of all edges of tetrahedron. + Compute downward adjacent vertices to tetrahedron given by ID. */ static inline h5_err_t get_vertices_dadj_to_tet ( h5_file_t* const f, - const h5_id_t eid, + const h5_loc_id_t eid, h5_idlist_t** list ) { h5_idlist_t* children; + h5_loc_idx_t elem_idx = h5tpriv_get_elem_idx (eid); TRY( h5priv_alloc_idlist (f, &children, 8) ); - h5_id_t i; + int i; for (i = 0; i < 6; i++) { TRY( compute_sections_of_edge ( f, - h5tpriv_build_edge_id ( i, eid ), + h5tpriv_build_edge_id ( i, elem_idx ), children) ); } TRY( h5priv_alloc_idlist (f, list, 8) ); - h5_id_t *kid = children->items; + h5_loc_id_t *kid = children->items; for (i = 0; i < children->num_items; i++, kid++) { - h5_id_t vids[2]; - TRY( h5t_get_vertex_indices_of_edge (f, *kid, vids) ); - TRY( h5priv_search_idlist (f, *list, vids[0]) ); - TRY( h5priv_search_idlist (f, *list, vids[1]) ); + h5_loc_idx_t vertex_indices[2]; + TRY( h5t_get_vertex_indices_of_edge (f, *kid, vertex_indices) ); + TRY( h5priv_search_idlist (f, *list, vertex_indices[0]) ); + TRY( h5priv_search_idlist (f, *list, vertex_indices[1]) ); } TRY( h5priv_free_idlist(f, &children) ); return H5_SUCCESS; @@ -655,25 +650,25 @@ get_vertices_dadj_to_tet ( static inline h5_err_t get_edges_dadj_to_triangle ( h5_file_t* const f, - const h5_id_t did, + const h5_loc_id_t did, h5_idlist_t** list ) { h5_idlist_t* children; TRY( h5priv_alloc_idlist (f, &children, 8) ); int map[4][3] = { {1,4,5}, {2,3,5}, {0,3,4}, {0,1,2} }; - h5_id_t face_idx = h5tpriv_get_face_idx (did); - h5_id_t eid = h5tpriv_get_elem_idx (did); + h5_loc_idx_t face_idx = h5tpriv_get_face_idx (did); + h5_loc_idx_t elem_idx = h5tpriv_get_elem_idx (did); - h5_id_t i; + int i; for (i = 0; i < 3; i++) { TRY( compute_sections_of_edge ( f, - h5tpriv_build_edge_id ( map[face_idx][i], eid ), + h5tpriv_build_edge_id ( map[face_idx][i], elem_idx ), children) ); } TRY( h5priv_alloc_idlist (f, list, 8) ); - h5_id_t *kid = children->items; + h5_loc_id_t *kid = children->items; for (i = 0; i < children->num_items; i++, kid++) { TRY( h5priv_search_idlist (f, *list, *kid) ); } @@ -684,21 +679,22 @@ get_edges_dadj_to_triangle ( static inline h5_err_t get_edges_dadj_to_tet ( h5_file_t* const f, - const h5_id_t eid, + const h5_loc_id_t eid, h5_idlist_t** list ) { h5_idlist_t* children; TRY( h5priv_alloc_idlist (f, &children, 8) ); + h5_loc_idx_t elem_idx = h5tpriv_get_elem_idx (eid); - h5_id_t i; + int i; for (i = 0; i < 6; i++) { TRY( compute_sections_of_edge ( f, - h5tpriv_build_edge_id ( i, eid ), + h5tpriv_build_edge_id ( i, elem_idx ), children) ); } TRY( h5priv_alloc_idlist (f, list, 8) ); - h5_id_t* kid = children->items; + h5_loc_id_t* kid = children->items; for (i = 0; i < children->num_items; i++, kid++) { TRY( h5priv_search_idlist (f, *list, *kid) ); } @@ -709,21 +705,22 @@ get_edges_dadj_to_tet ( static inline h5_err_t get_triangles_dadj_to_tet ( h5_file_t* const f, - const h5_id_t eid, + const h5_loc_id_t eid, h5_idlist_t** list ) { h5_idlist_t* children; TRY( h5priv_alloc_idlist (f, &children, 8) ); + h5_loc_idx_t elem_idx = h5tpriv_get_elem_idx (eid); - h5_id_t i; + int i; for (i = 0; i < 4; i++) { TRY( compute_sections_of_triangle ( f, - h5tpriv_build_edge_id ( i, eid ), + h5tpriv_build_edge_id ( i, elem_idx ), children) ); } TRY( h5priv_alloc_idlist (f, list, 8) ); - h5_id_t* did = children->items; + h5_loc_id_t* did = children->items; for (i = 0; i < children->num_items; i++, did++) { TRY( h5priv_search_idlist (f, *list, *did) ); } @@ -745,7 +742,7 @@ dim_error( static inline h5_err_t get_adjacencies_to_vertex ( h5_file_t* const f, - const h5_id_t entity_id, + const h5_loc_id_t entity_id, const h5_int32_t dim, h5_idlist_t** list ) { @@ -764,7 +761,7 @@ get_adjacencies_to_vertex ( static inline h5_err_t get_adjacencies_to_edge ( h5_file_t* const f, - const h5_id_t entity_id, + const h5_loc_id_t entity_id, const h5_int32_t dim, h5_idlist_t** list ) { @@ -783,7 +780,7 @@ get_adjacencies_to_edge ( static inline h5_err_t get_adjacencies_to_triangle ( h5_file_t* const f, - const h5_id_t entity_id, + const h5_loc_id_t entity_id, const h5_int32_t dim, h5_idlist_t** list ) { @@ -802,7 +799,7 @@ get_adjacencies_to_triangle ( static inline h5_err_t get_adjacencies_to_tet ( h5_file_t* const f, - const h5_id_t entity_id, + const h5_loc_id_t entity_id, const h5_int32_t dim, h5_idlist_t** list ) { @@ -821,11 +818,11 @@ get_adjacencies_to_tet ( static h5_err_t get_adjacencies ( h5_file_t* const f, - const h5_id_t entity_id, + const h5_loc_id_t entity_id, const h5_int32_t dim, h5_idlist_t** list ) { - h5_id_t entity_type = h5tpriv_get_entity_type (entity_id); + h5_loc_id_t entity_type = h5tpriv_get_entity_type (entity_id); switch (entity_type) { case H5T_ETYPE_VERTEX: return get_adjacencies_to_vertex (f, entity_id, dim, list); diff --git a/src/h5core/h5t_adjacencies_trim.c b/src/h5core/h5t_adjacencies_trim.c index b73208c..52eccae 100644 --- a/src/h5core/h5t_adjacencies_trim.c +++ b/src/h5core/h5t_adjacencies_trim.c @@ -19,20 +19,14 @@ static inline h5_err_t alloc_tv ( - h5_file_t* const f, - const h5_loc_idx_t level_idx - + h5_file_t* const f ) { h5t_fdata_t* t = f->t; - h5_loc_idx_t idx = (level_idx <= 0) ? 0 : t->num_vertices[level_idx-1]; - h5_loc_idx_t last = t->num_vertices[t->num_levels-1]; + h5_loc_idx_t num_vertices = t->num_vertices[t->num_levels-1]; h5t_adjacencies_t* adj = &t->adjacencies; - adj->tv.size = last; - size_t size = last * sizeof(adj->tv.v[0]); - TRY( adj->tv.v = h5priv_alloc (f, adj->tv.v, size) ); - size = (last-idx) * sizeof(adj->tv.v[0]); - memset (&adj->tv.v[idx], 0, size); + // allocate one ID list per vertex + TRY( adj->tv.v = h5priv_calloc (f, num_vertices, sizeof(*adj->tv.v)) ); return H5_SUCCESS; } @@ -63,19 +57,20 @@ compute_elems_of_vertices ( h5_file_t* const f, const h5_id_t from_lvl ) { + h5_debug (f, "%s (%lld)", __func__, from_lvl); /* expand structure */ - TRY( alloc_tv (f, from_lvl) ); + TRY( alloc_tv (f) ); /* loop over all elements in current level */ h5t_fdata_t *t = f->t; h5_loc_idx_t idx = (from_lvl <= 0) ? 0 : t->num_elems[from_lvl-1]; h5_loc_idx_t last = t->num_elems[t->num_levels-1]; - h5_triangle_t *el = &t->loc_elems.tris[idx]; + h5_loc_triangle_t *el = &t->loc_elems.tris[idx]; for (;idx < last; idx++, el++) { int face_idx; int num_faces = h5tpriv_ref_elem_get_num_vertices (t); for (face_idx = 0; face_idx < num_faces; face_idx++) { - h5_id_t vidx = el->vertex_indices[face_idx]; + h5_loc_idx_t vidx = el->vertex_indices[face_idx]; TRY( h5priv_append_to_idlist ( f, &t->adjacencies.tv.v[vidx], @@ -83,6 +78,7 @@ compute_elems_of_vertices ( face_idx, idx)) ); } } + h5_debug (f, "%s (%lld): done", __func__, from_lvl); return H5_SUCCESS; } @@ -103,26 +99,28 @@ compute_elems_of_edges ( h5_file_t* const f, const h5_id_t from_lvl ) { + h5_debug (f, "%s (%lld)", __func__, from_lvl); h5t_fdata_t *t = f->t; - h5_id_t elem_idx = (from_lvl <= 0) ? 0 : t->num_elems[from_lvl-1]; - h5_id_t num_elems = t->num_elems[t->num_levels-1]; + h5_loc_idx_t elem_idx = (from_lvl <= 0) ? 0 : t->num_elems[from_lvl-1]; + h5_loc_idx_t num_elems = t->num_elems[t->num_levels-1]; h5_idlist_t *retval = NULL; TRY( h5tpriv_resize_te_htab (f, 4*(num_elems-elem_idx)) ); for (;elem_idx < num_elems; elem_idx++) { - int face_idx; - int num_faces = h5tpriv_ref_elem_get_num_edges (t); + h5_loc_idx_t face_idx; + h5_loc_idx_t num_faces = h5tpriv_ref_elem_get_num_edges (t); for (face_idx = 0; face_idx < num_faces; face_idx++) { TRY ( h5tpriv_search_te2 ( f, face_idx, elem_idx, &retval ) ); } } + h5_debug (f, "%s (%lld): done", __func__, from_lvl); return H5_SUCCESS; } static inline h5_err_t compute_children_of_edge ( h5_file_t * const f, - h5_id_t kid, + h5_loc_id_t kid, h5_idlist_t *children ) { h5t_fdata_t *t = f->t; @@ -134,18 +132,18 @@ compute_children_of_edge ( h5tpriv_get_elem_idx ( kid ), &te ) ); - h5_id_t *edge = te->items; - h5_id_t *end = te->items+te->num_items; + h5_loc_id_t *edge = te->items; + h5_loc_id_t *end = te->items+te->num_items; for ( ; edge < end; edge++ ) { - h5_id_t elem_idx = h5tpriv_get_elem_idx ( *edge ); - h5_id_t face_idx = h5tpriv_get_face_idx ( *edge ); - h5_generic_elem_t *el = (h5_generic_elem_t*)&t->loc_elems.tris[elem_idx]; + h5_loc_idx_t elem_idx = h5tpriv_get_elem_idx ( *edge ); + h5_loc_idx_t face_idx = h5tpriv_get_face_idx ( *edge ); + h5_generic_loc_elem_t *el = (h5_generic_loc_elem_t*)&t->loc_elems.tris[elem_idx]; if ( h5tpriv_elem_is_on_cur_level ( f, el ) == H5_OK ) { TRY ( h5priv_append_to_idlist ( f, children, *edge ) ); } else { - h5_id_t kids[2]; + h5_loc_id_t kids[2]; TRY ( h5tpriv_get_direct_children_of_edge ( f, face_idx, @@ -166,7 +164,7 @@ compute_children_of_edge ( static inline h5_err_t compute_sections_of_edge ( h5_file_t * const f, - h5_id_t kid, + h5_loc_id_t kid, h5_idlist_t *children ) { h5t_fdata_t *t = f->t; @@ -178,19 +176,19 @@ compute_sections_of_edge ( h5tpriv_get_elem_idx ( kid ), &te ) ); - h5_id_t *edge = te->items; - h5_id_t *end = te->items+te->num_items; + h5_loc_id_t *edge = te->items; + h5_loc_id_t *end = te->items+te->num_items; int refined = 0; for ( ; edge < end; edge++ ) { - h5_id_t eid = h5tpriv_get_elem_idx ( *edge ); - h5_id_t face_id = h5tpriv_get_face_idx ( *edge ); - h5_generic_elem_t *el = (h5_generic_elem_t*)&t->loc_elems.tris[eid]; + h5_loc_idx_t elem_idx = h5tpriv_get_elem_idx ( *edge ); + h5_loc_idx_t face_idx = h5tpriv_get_face_idx ( *edge ); + h5_generic_loc_elem_t *el = (h5_generic_loc_elem_t*)&t->loc_elems.tris[elem_idx]; if ( ! h5tpriv_elem_is_on_cur_level ( f, el ) == H5_OK ) { refined = 1; - h5_id_t kids[2]; + h5_loc_id_t kids[2]; TRY ( h5tpriv_get_direct_children_of_edge ( f, - face_id, + face_idx, el->child_idx, kids ) ); TRY ( compute_sections_of_edge ( @@ -214,8 +212,8 @@ static inline h5_err_t add_edge ( h5_file_t * const f, h5_idlist_t *list, - h5_id_t face_idx, - h5_id_t elem_idx + h5_loc_idx_t face_idx, + h5_loc_idx_t elem_idx ) { h5_idlist_t *te; TRY ( h5tpriv_find_te2 ( f, face_idx, elem_idx, &te ) ); @@ -227,7 +225,7 @@ add_edge ( static inline h5_err_t get_edges_uadj_to_vertex ( h5_file_t * const f, - const h5_id_t entity_id, + const h5_loc_id_t entity_id, h5_idlist_t **list ) { TRY ( h5priv_alloc_idlist ( f, list, 8 ) ); @@ -238,11 +236,11 @@ get_edges_uadj_to_vertex ( h5_idlist_t* tv = &t->adjacencies.tv.v[idx]; h5_size_t i; - h5_id_t* vertex_idp = tv->items; + h5_loc_id_t* vertex_idp = tv->items; for ( i = 0; i < tv->num_items; i++, vertex_idp++ ) { - h5_id_t elem_idx = h5tpriv_get_elem_idx ( *vertex_idp ); - h5_id_t face_idx = h5tpriv_get_face_idx ( *vertex_idp ); - h5_generic_elem_t* el = (h5_generic_elem_t*)&t->loc_elems.tris[elem_idx]; + h5_loc_idx_t elem_idx = h5tpriv_get_elem_idx ( *vertex_idp ); + h5_loc_idx_t face_idx = h5tpriv_get_face_idx ( *vertex_idp ); + h5_generic_loc_elem_t* el = (h5_generic_loc_elem_t*)&t->loc_elems.tris[elem_idx]; if ( h5tpriv_elem_is_on_cur_level ( f, el ) == H5_NOK ) { continue; @@ -259,7 +257,7 @@ get_edges_uadj_to_vertex ( static inline h5_err_t get_triangles_uadj_to_vertex ( h5_file_t * const f, - const h5_id_t entity_id, + const h5_loc_id_t entity_id, h5_idlist_t **list ) { TRY ( h5priv_alloc_idlist ( f, list, 8 ) ); @@ -270,10 +268,10 @@ get_triangles_uadj_to_vertex ( h5_idlist_t* tv = &t->adjacencies.tv.v[idx]; h5_size_t i; - h5_id_t *vertex_idp = tv->items; + h5_loc_id_t *vertex_idp = tv->items; for ( i = 0; i < tv->num_items; i++, vertex_idp++ ) { h5_loc_idx_t elem_idx = h5tpriv_get_elem_idx ( *vertex_idp ); - h5_generic_elem_t* el = (h5_generic_elem_t*)&t->loc_elems.tris[elem_idx]; + h5_generic_loc_elem_t* el = (h5_generic_loc_elem_t*)&t->loc_elems.tris[elem_idx]; if ( h5tpriv_elem_is_on_cur_level ( f, el ) == H5_NOK ) { continue; @@ -286,18 +284,18 @@ get_triangles_uadj_to_vertex ( static inline h5_err_t get_triangles_uadj_to_edge ( h5_file_t * const f, - const h5_id_t entity_id, + const h5_loc_id_t entity_id, h5_idlist_t **list ) { h5_idlist_t *children; TRY ( h5priv_alloc_idlist ( f, &children, 8 ) ); TRY ( compute_children_of_edge ( f, entity_id, children ) ); TRY ( h5priv_alloc_idlist ( f, list, 8 ) ); - h5_id_t *edge_id = children->items; - h5_id_t *end = children->items+children->num_items; + h5_loc_id_t *edge_id = children->items; + h5_loc_id_t *end = children->items+children->num_items; for ( ; edge_id < end; edge_id++ ) { - h5_id_t elem_id = h5tpriv_get_elem_idx ( *edge_id ); - TRY ( h5priv_search_idlist ( f, *list, elem_id ) ); + h5_loc_idx_t elem_idx = h5tpriv_get_elem_idx ( *edge_id ); + TRY ( h5priv_search_idlist ( f, *list, elem_idx ) ); } TRY ( h5priv_free_idlist( f, &children ) ); @@ -307,7 +305,7 @@ get_triangles_uadj_to_edge ( static inline h5_err_t get_vertices_dadj_to_edge ( h5_file_t * const f, - const h5_id_t entity_id, + const h5_loc_id_t entity_id, h5_idlist_t **list ) { h5_idlist_t *children; @@ -315,12 +313,12 @@ get_vertices_dadj_to_edge ( TRY( compute_sections_of_edge ( f, entity_id, children ) ); TRY ( h5priv_alloc_idlist ( f, list, 8 ) ); int i; - h5_id_t *edge_id = children->items; + h5_loc_id_t *edge_id = children->items; for ( i = 0; i < children->num_items; i++, edge_id++ ) { - h5_id_t vids[2]; - TRY ( h5t_get_vertex_indices_of_edge ( f, *edge_id, vids ) ); - TRY ( h5priv_search_idlist ( f, *list, vids[0] ) ); - TRY ( h5priv_search_idlist ( f, *list, vids[1] ) ); + h5_loc_idx_t vertex_indices[2]; + TRY ( h5t_get_vertex_indices_of_edge ( f, *edge_id, vertex_indices ) ); + TRY ( h5priv_search_idlist ( f, *list, vertex_indices[0] ) ); + TRY ( h5priv_search_idlist ( f, *list, vertex_indices[1] ) ); } TRY ( h5priv_free_idlist( f, &children ) ); return H5_SUCCESS; @@ -332,16 +330,16 @@ get_vertices_dadj_to_edge ( static inline h5_err_t get_vertices_dadj_to_triangle ( h5_file_t* const f, - const h5_id_t entity_id, + const h5_loc_id_t entity_id, h5_idlist_t** list ) { h5_idlist_t* children; TRY ( h5priv_alloc_idlist ( f, &children, 8 ) ); - h5_id_t elem_idx = h5tpriv_get_elem_idx ( entity_id ); + h5_loc_idx_t elem_idx = h5tpriv_get_elem_idx ( entity_id ); // loop over all edges of triangle - h5_id_t face_idx; - h5_id_t num_faces = h5tpriv_ref_elem_get_num_edges (f->t); + h5_loc_idx_t face_idx; + h5_loc_idx_t num_faces = h5tpriv_ref_elem_get_num_edges (f->t); for (face_idx = 0; face_idx < num_faces; face_idx++) { TRY( compute_sections_of_edge ( f, @@ -349,13 +347,13 @@ get_vertices_dadj_to_triangle ( children) ); } TRY ( h5priv_alloc_idlist (f, list, 8) ); - h5_id_t *edge_idp = children->items; + h5_loc_id_t *edge_idp = children->items; int i; for ( i = 0; i < children->num_items; i++, edge_idp++ ) { - h5_id_t vids[2]; - TRY ( h5t_get_vertex_indices_of_edge ( f, *edge_idp, vids ) ); - TRY ( h5priv_search_idlist ( f, *list, vids[0] ) ); - TRY ( h5priv_search_idlist ( f, *list, vids[1] ) ); + h5_loc_idx_t vertex_indices[2]; + TRY ( h5t_get_vertex_indices_of_edge ( f, *edge_idp, vertex_indices ) ); + TRY ( h5priv_search_idlist ( f, *list, vertex_indices[0] ) ); + TRY ( h5priv_search_idlist ( f, *list, vertex_indices[1] ) ); } TRY ( h5priv_free_idlist(f, &children) ); return H5_SUCCESS; @@ -364,16 +362,16 @@ get_vertices_dadj_to_triangle ( static inline h5_err_t get_edges_dadj_to_triangle ( h5_file_t* const f, - const h5_id_t entity_id, + const h5_loc_id_t entity_id, h5_idlist_t** list ) { h5_idlist_t* children; TRY ( h5priv_alloc_idlist (f, &children, 8) ); - h5_id_t elem_idx = h5tpriv_get_elem_idx (entity_id); + h5_loc_idx_t elem_idx = h5tpriv_get_elem_idx (entity_id); // loop over all edges of triangle - h5_id_t face_idx; - h5_id_t num_faces = h5tpriv_ref_elem_get_num_edges (f->t); + h5_loc_idx_t face_idx; + h5_loc_idx_t num_faces = h5tpriv_ref_elem_get_num_edges (f->t); for ( face_idx = 0; face_idx < num_faces; face_idx++ ) { TRY( compute_sections_of_edge ( f, @@ -381,7 +379,7 @@ get_edges_dadj_to_triangle ( children) ); } TRY ( h5priv_alloc_idlist (f, list, 8) ); - h5_id_t *edge_idp = children->items; + h5_loc_id_t *edge_idp = children->items; int i; for (i = 0; i < children->num_items; i++, edge_idp++) { TRY ( h5priv_search_idlist (f, *list, *edge_idp) ); @@ -404,7 +402,7 @@ dim_error( static inline h5_err_t get_adjacencies_to_vertex ( h5_file_t* const f, - const h5_id_t entity_id, + const h5_loc_id_t entity_id, const h5_int32_t dim, h5_idlist_t** list ) { @@ -421,7 +419,7 @@ get_adjacencies_to_vertex ( static inline h5_err_t get_adjacencies_to_edge ( h5_file_t* const f, - const h5_id_t entity_id, + const h5_loc_id_t entity_id, const h5_int32_t dim, h5_idlist_t** list ) { @@ -438,7 +436,7 @@ get_adjacencies_to_edge ( static inline h5_err_t get_adjacencies_to_triangle ( h5_file_t* const f, - const h5_id_t entity_id, + const h5_loc_id_t entity_id, const h5_int32_t dim, h5_idlist_t** list ) { @@ -455,11 +453,11 @@ get_adjacencies_to_triangle ( static h5_err_t get_adjacencies ( h5_file_t* const f, - const h5_id_t entity_id, + const h5_loc_id_t entity_id, const h5_int32_t dim, h5_idlist_t** list ) { - h5_id_t entity_type = h5tpriv_get_entity_type (entity_id); + h5_loc_id_t entity_type = h5tpriv_get_entity_type (entity_id); switch (entity_type) { case H5T_ETYPE_VERTEX: return get_adjacencies_to_vertex (f, entity_id, dim, list); @@ -478,6 +476,7 @@ update_internal_structs ( h5_file_t* const f, const h5_id_t from_lvl ) { + h5_debug (f, "%s (%lld)", __func__, (long long)from_lvl); clock_t t1 = clock(); TRY( compute_elems_of_vertices (f, from_lvl) ); clock_t t2 = clock(); @@ -488,7 +487,7 @@ update_internal_structs ( t2 = clock(); fprintf (stderr, "compute_elems_of_edge(): %f\n", (float)(t2-t1)/CLOCKS_PER_SEC); - + h5_debug (f, "%s (%lld): done", __func__, (long long)from_lvl); return H5_SUCCESS; } diff --git a/src/h5core/h5t_consts.c b/src/h5core/h5t_consts.c index 526ee5f..1b8783b 100644 --- a/src/h5core/h5t_consts.c +++ b/src/h5core/h5t_consts.c @@ -19,15 +19,6 @@ h5tpriv_meshes_grpnames[] = { "TetMeshes" }; -const size_t -h5tpriv_sizeof_elem[] = { - 0, - 0, - 0, - sizeof (h5_triangle_t), - sizeof (h5_tetrahedron_t) -}; - const char* h5tpriv_map_oid2str ( h5_oid_t oid diff --git a/src/h5core/h5t_consts_private.h b/src/h5core/h5t_consts_private.h index c1d2f05..20563b5 100644 --- a/src/h5core/h5t_consts_private.h +++ b/src/h5core/h5t_consts_private.h @@ -3,7 +3,6 @@ extern const char * h5tpriv_oid_names[]; extern const char * h5tpriv_meshes_grpnames[]; -extern const size_t h5tpriv_sizeof_elem[]; const char *h5tpriv_map_oid2str ( h5_oid_t oid ); diff --git a/src/h5core/h5t_core_private.h b/src/h5core/h5t_core_private.h index b042b7d..d9c6de3 100644 --- a/src/h5core/h5t_core_private.h +++ b/src/h5core/h5t_core_private.h @@ -10,7 +10,6 @@ #include "h5t_access_private.h" #include "h5t_adjacencies_private.h" #include "h5t_consts_private.h" -#include "h5t_errorhandling_private.h" #include "h5t_hsearch_private.h" #include "h5t_map_private.h" #include "h5t_openclose_private.h" @@ -19,4 +18,6 @@ #include "h5t_retrieve_private.h" #include "h5t_store_private.h" +#include "h5t_errorhandling_private.h" + #endif diff --git a/src/h5core/h5t_errorhandling.c b/src/h5core/h5t_errorhandling.c index 27983fb..f53ec2b 100644 --- a/src/h5core/h5t_errorhandling.c +++ b/src/h5core/h5t_errorhandling.c @@ -6,11 +6,12 @@ #include "h5core/h5_core.h" #include "h5_core_private.h" +#if 0 const char* ERR_ELEM_NEXIST = "Element with local vertex IDs (%s) doesn't exist!"; h5_err_t h5tpriv_error_local_elem_nexist ( h5_file_t* const f, - h5_id_t local_vertex_indices[] + h5_loc_idx_t local_vertex_indices[] ) { h5t_fdata_t* t = f->t; char s[1024]; @@ -30,5 +31,5 @@ h5tpriv_error_local_elem_nexist ( } return h5_error (f, H5_ERR_NOENTRY, ERR_ELEM_NEXIST, s); -} - +} +#endif diff --git a/src/h5core/h5t_errorhandling_private.h b/src/h5core/h5t_errorhandling_private.h index 649015b..733b45c 100644 --- a/src/h5core/h5t_errorhandling_private.h +++ b/src/h5core/h5t_errorhandling_private.h @@ -1,11 +1,32 @@ #ifndef __H5T_ERRORHANDLING_PRIVATE_H #define __H5T_ERRORHANDLING_PRIVATE_H -h5_err_t +#define ERR_ELEM_NEXIST "Element with local vertex IDs (%s) doesn't exist!" + +static inline h5_err_t h5tpriv_error_local_elem_nexist ( h5_file_t * const f, - h5_id_t local_vertex_indices[] - ); + h5_loc_idx_t vertex_indices[] + ) { + h5t_fdata_t* t = f->t; + char s[1024]; + + int num_chars_printed = snprintf (s, sizeof(s), "%lld,", + (long long)vertex_indices[0]); + int i; + int num_vertices = h5tpriv_ref_elem_get_num_vertices (t); + for (i = 1; i < num_vertices; i++) { + num_chars_printed += snprintf ( + s + num_chars_printed, sizeof (s) - num_chars_printed, + "%lld,", (long long)vertex_indices[i]); + if ((sizeof (s) - num_chars_printed) < 32) { + // buffer to small + return h5_error_internal (f, __FILE__, __func__, __LINE__); + } + } + + return h5_error (f, H5_ERR_NOENTRY, ERR_ELEM_NEXIST, s); +} #define h5tpriv_error_undef_mesh( f ) \ h5_error( \ diff --git a/src/h5core/h5t_hsearch.c b/src/h5core/h5t_hsearch.c index 7aabe7b..e395052 100644 --- a/src/h5core/h5t_hsearch.c +++ b/src/h5core/h5t_hsearch.c @@ -61,8 +61,8 @@ h5tpriv_resize_te_htab ( h5_err_t h5tpriv_search_te2 ( h5_file_t* const f, - h5_id_t face_idx, - h5_id_t elem_idx, + h5_loc_idx_t face_idx, + h5_loc_idx_t elem_idx, h5_idlist_t** retval ) { h5t_fdata_t* t = f->t; @@ -90,7 +90,7 @@ h5tpriv_search_te2 ( Thus for a tetrahedal mesh we 3 time the remaining elements! @@@ */ - h5_id_t num_elems = t->num_elems[t->num_levels-1]; + h5_loc_idx_t num_elems = t->num_elems[t->num_levels-1]; TRY( h5priv_hresize ( f, 3*(num_elems - elem_idx), @@ -150,8 +150,8 @@ h5tpriv_find_te ( h5_err_t h5tpriv_find_te2 ( h5_file_t* const f, - h5_id_t face_idx, - h5_id_t elem_idx, + h5_loc_idx_t face_idx, + h5_loc_idx_t elem_idx, h5_idlist_t** retval ) { h5t_te_entry_t item; @@ -221,8 +221,8 @@ h5tpriv_resize_td_htab ( h5_err_t h5tpriv_search_td2 ( h5_file_t* const f, - h5_id_t face_idx, - h5_id_t elem_idx, + h5_loc_idx_t face_idx, + h5_loc_idx_t elem_idx, h5_idlist_t** retval ) { h5t_fdata_t* t = f->t; @@ -238,7 +238,7 @@ h5tpriv_search_td2 ( resize hash table if more than 3/4 filled */ if ((a->td_hash.size*6) <= (a->td_hash.filled<<3)) { - h5_id_t num_elems = t->num_elems[t->num_levels-1]; + h5_loc_idx_t num_elems = t->num_elems[t->num_levels-1]; TRY( h5priv_hresize ( f, 3*(num_elems-elem_idx), @@ -290,8 +290,8 @@ h5tpriv_find_td ( h5_err_t h5tpriv_find_td2 ( h5_file_t* const f, - h5_id_t face_idx, - h5_id_t elem_idx, + h5_loc_idx_t face_idx, + h5_loc_idx_t elem_idx, h5_idlist_t** retval ) { h5t_td_entry_t item; @@ -309,12 +309,13 @@ h5tpriv_find_td2 ( h5_err_t h5tpriv_find_tv2 ( h5_file_t* const f, - h5_id_t face_idx, - h5_id_t elem_idx, + h5_loc_idx_t face_idx, + h5_loc_idx_t elem_idx, h5_idlist_t** retval ) { - h5_id_t idx = h5tpriv_get_loc_elem_vertex_idx (f, elem_idx, face_idx); + h5_loc_idx_t idx = h5tpriv_get_loc_elem_vertex_idx ( + f, elem_idx, face_idx); *retval = &f->t->adjacencies.tv.v[idx]; return H5_SUCCESS; diff --git a/src/h5core/h5t_hsearch_private.h b/src/h5core/h5t_hsearch_private.h index acb35d3..629621f 100644 --- a/src/h5core/h5t_hsearch_private.h +++ b/src/h5core/h5t_hsearch_private.h @@ -2,15 +2,15 @@ #define __H5T_HSEARCH_PRIVATE_H typedef struct h5t_te_entry_key { - h5_id_t vids[2]; + h5_loc_idx_t vids[2]; } h5t_te_entry_key_t; typedef struct h5t_td_entry_key { - h5_id_t vids[3]; + h5_loc_idx_t vids[3]; } h5t_td_entry_key_t; typedef struct h5t_idlisthash_key { - h5_id_t ids[1]; + h5_loc_id_t ids[1]; } h5t_idlisthash_key_t; /* @@ -47,8 +47,8 @@ h5tpriv_resize_te_htab ( h5_err_t h5tpriv_search_te2 ( h5_file_t * const f, - h5_id_t face_idx, - h5_id_t elem_idx, + h5_loc_idx_t face_idx, + h5_loc_idx_t elem_idx, h5_idlist_t **entry ); @@ -62,8 +62,8 @@ h5tpriv_find_te ( h5_err_t h5tpriv_find_te2 ( h5_file_t * const f, - h5_id_t face_idx, - h5_id_t elem_idx, + h5_loc_idx_t face_idx, + h5_loc_idx_t elem_idx, h5_idlist_t **retval ); @@ -83,8 +83,8 @@ h5tpriv_resize_td_htab ( h5_err_t h5tpriv_search_td2 ( h5_file_t * const f, - h5_id_t face_idx, - h5_id_t elem_idx, + h5_loc_idx_t face_idx, + h5_loc_idx_t elem_idx, h5_idlist_t **entry ); @@ -98,16 +98,16 @@ h5tpriv_find_td ( h5_err_t h5tpriv_find_td2 ( h5_file_t * const f, - h5_id_t face_idx, - h5_id_t elem_idx, + h5_loc_idx_t face_idx, + h5_loc_idx_t elem_idx, h5_idlist_t **rentry ); h5_err_t h5tpriv_find_tv2 ( h5_file_t * const f, - h5_id_t face_idx, - h5_id_t elem_idx, + h5_loc_idx_t face_idx, + h5_loc_idx_t elem_idx, h5_idlist_t **retval ); #endif diff --git a/src/h5core/h5t_inquiry.c b/src/h5core/h5t_inquiry.c index 0bb0cde..442c0fd 100644 --- a/src/h5core/h5t_inquiry.c +++ b/src/h5core/h5t_inquiry.c @@ -14,14 +14,24 @@ h5t_get_num_meshes ( h5_file_t* const f, const h5_oid_t type_id ) { - hid_t topo_gid; - hid_t meshes_gid; + hid_t topo_gid = -1; + hid_t meshes_gid = -1; - TRY( topo_gid = h5priv_open_group (f, f->root_gid, H5T_CONTAINER_GRPNAME) ); - TRY( meshes_gid = h5priv_open_group ( - f, topo_gid, h5tpriv_meshes_grpnames[type_id]) ); + h5_err_t exists; + TRY( exists = h5priv_hdf5_link_exists (f, f->root_gid, H5T_CONTAINER_GRPNAME) ); + if (!exists) return 0; - return h5_get_num_hdf5_groups (f, meshes_gid); + TRY( topo_gid = h5priv_open_hdf5_group (f, f->root_gid, H5T_CONTAINER_GRPNAME) ); + + TRY( exists = h5priv_hdf5_link_exists (f, topo_gid, h5tpriv_meshes_grpnames[type_id]) ); + if (!exists) return 0; + + TRY( meshes_gid = h5priv_open_hdf5_group (f, topo_gid, h5tpriv_meshes_grpnames[type_id]) ); + + h5_size_t num_meshes = h5_get_num_hdf5_groups (f, meshes_gid); + TRY( h5priv_close_hdf5_group (f, meshes_gid) ); + TRY( h5priv_close_hdf5_group (f, topo_gid) ); + return num_meshes; } /*! diff --git a/src/h5core/h5t_map.c b/src/h5core/h5t_map.c index 4407d3f..c2b9791 100644 --- a/src/h5core/h5t_map.c +++ b/src/h5core/h5t_map.c @@ -30,16 +30,16 @@ cmp_vertices ( static int qsort_cmp_vertices ( void* _f, - const void* _local_vid1, - const void* _local_vid2 + const void* _vertex_idx1, + const void* _vertex_idx2 ) { h5_file_t* f = (h5_file_t*)_f; - h5_id_t local_vid1 = *(h5_id_t*)_local_vid1; - h5_id_t local_vid2 = *(h5_id_t*)_local_vid2; + h5_loc_idx_t vertex_idx1 = *(h5_loc_idx_t*)_vertex_idx1; + h5_loc_idx_t vertex_idx2 = *(h5_loc_idx_t*)_vertex_idx2; return cmp_vertices ( - f->t->vertices[local_vid1].P, - f->t->vertices[local_vid2].P ); + f->t->vertices[vertex_idx1].P, + f->t->vertices[vertex_idx2].P ); } /*! @@ -52,12 +52,12 @@ h5tpriv_sort_vertices ( h5t_fdata_t* t = f->t; if (t->num_levels <= 0) return H5_SUCCESS; - h5_id_t local_vid = t->cur_level > 0 ? + h5_loc_idx_t vertex_idx = t->cur_level > 0 ? t->num_vertices[t->cur_level-1] : 0; - h5_id_t num_vertices = t->num_vertices[t->num_levels-1]; - for (; local_vid < num_vertices; local_vid++) { - t->sorted_lvertices.items[local_vid] = local_vid; + h5_loc_idx_t num_vertices = t->num_vertices[t->num_levels-1]; + for (; vertex_idx < num_vertices; vertex_idx++) { + t->sorted_lvertices.items[vertex_idx] = vertex_idx; } t->sorted_lvertices.num_items = num_vertices; @@ -73,24 +73,24 @@ h5tpriv_sort_vertices ( /*! - Return local vertex id of a vertex given by its coordinates. + Return local vertex index of a vertex given by its coordinates. - \return local vertex id if found + \return local vertex idx if found \return else negativ value */ -h5_id_t +h5_loc_idx_t h5tpriv_get_local_vid ( h5_file_t* const f, h5_float64_t P[3] ) { h5t_fdata_t*t = f->t; - register h5_id_t low = 0; - register h5_id_t high = t->sorted_lvertices.num_items - 1; + register h5_loc_idx_t low = 0; + register h5_loc_idx_t high = t->sorted_lvertices.num_items - 1; while (low <= high) { - register int mid = (low + high) / 2; + register h5_loc_idx_t mid = (low + high) / 2; - h5_id_t local_vid = t->sorted_lvertices.items[mid]; - h5_float64_t *P1 = t->vertices[local_vid].P; + h5_loc_idx_t vertex_idx = t->sorted_lvertices.items[mid]; + h5_float64_t *P1 = t->vertices[vertex_idx].P; int diff = cmp_vertices ( P, P1 ); if ( diff < 0 ) high = mid - 1; @@ -108,13 +108,13 @@ h5tpriv_get_local_vid ( static inline int cmp_elems ( h5_file_t* const f, - const h5_id_t elem_idx1, - const h5_id_t elem_idx2 + const h5_loc_idx_t elem_idx1, + const h5_loc_idx_t elem_idx2 ) { h5t_fdata_t* t = f->t; int num_vertices = h5tpriv_ref_elem_get_num_vertices (t); - h5_id_t* indices1 = h5tpriv_get_loc_elem_vertex_indices (f, elem_idx1); - h5_id_t* indices2 = h5tpriv_get_loc_elem_vertex_indices (f, elem_idx2); + h5_loc_idx_t* indices1 = h5tpriv_get_loc_elem_vertex_indices (f, elem_idx1); + h5_loc_idx_t* indices2 = h5tpriv_get_loc_elem_vertex_indices (f, elem_idx2); int i; for (i = 0; i < num_vertices; i++) { @@ -132,13 +132,13 @@ cmp_elems ( static inline int cmp_elems1 ( h5_file_t* f, - h5_id_t elem_idx1, - h5_id_t elem_idx2 + h5_loc_idx_t elem_idx1, + h5_loc_idx_t elem_idx2 ) { h5t_fdata_t *t = f->t; int num_vertices = h5tpriv_ref_elem_get_num_vertices (t); - h5_id_t* indices1 = h5tpriv_get_loc_elem_vertex_indices (f, elem_idx1); - h5_id_t* indices2 = h5tpriv_get_loc_elem_vertex_indices (f, elem_idx2); + h5_loc_idx_t* indices1 = h5tpriv_get_loc_elem_vertex_indices (f, elem_idx1); + h5_loc_idx_t* indices2 = h5tpriv_get_loc_elem_vertex_indices (f, elem_idx2); int imap[] = { 1, 0, 2, 3 }; int i; @@ -158,25 +158,25 @@ cmp_elems1 ( static int qsort_cmp_elems0 ( void* _f, - const void* _local_eid1, - const void* _local_eid2 + const void* _elem_idx1, + const void* _elem_idx2 ) { h5_file_t* f = (h5_file_t*)_f; - h5_id_t local_eid1 = *(h5_id_t*)_local_eid1; - h5_id_t local_eid2 = *(h5_id_t*)_local_eid2; - return cmp_elems (f, local_eid1, local_eid2); + h5_loc_idx_t elem_idx1 = *(h5_loc_idx_t*)_elem_idx1; + h5_loc_idx_t elem_idx2 = *(h5_loc_idx_t*)_elem_idx2; + return cmp_elems (f, elem_idx1, elem_idx2); } static int qsort_cmp_elems1 ( void* _f, - const void* _local_eid1, - const void* _local_eid2 + const void* _elem_idx1, + const void* _elem_idx2 ) { h5_file_t* f = (h5_file_t*)_f; - h5_id_t local_eid1 = *(h5_id_t*)_local_eid1; - h5_id_t local_eid2 = *(h5_id_t*)_local_eid2; - return cmp_elems1 (f, local_eid1, local_eid2); + h5_loc_idx_t elem_idx1 = *(h5_loc_idx_t*)_elem_idx1; + h5_loc_idx_t elem_idx2 = *(h5_loc_idx_t*)_elem_idx2; + return cmp_elems1 (f, elem_idx1, elem_idx2); } /*! @@ -189,14 +189,14 @@ h5tpriv_sort_loc_elems ( ) { h5t_fdata_t* t = f->t; if (t->num_levels <= 0) return H5_SUCCESS; - h5_id_t local_eid = t->cur_level > 0 ? t->num_elems[t->cur_level-1] : 0; - h5_size_t num_elems = t->num_elems[t->num_levels-1]; + h5_loc_idx_t elem_idx = t->cur_level > 0 ? t->num_elems[t->cur_level-1] : 0; + h5_loc_idx_t num_elems = t->num_elems[t->num_levels-1]; int k; - h5_id_t i; + h5_loc_idx_t i; for (k = 0; k < 2; k++) { TRY( h5priv_alloc_idlist_items (f, &t->sorted_elems[k], num_elems) ); - for (i = local_eid; i < num_elems; i++) { + for (i = elem_idx; i < num_elems; i++) { t->sorted_elems[k].items[i] = i; } t->sorted_elems[k].num_items = num_elems; @@ -224,16 +224,16 @@ h5tpriv_sort_loc_elems ( h5_err_t h5tpriv_sort_local_vertex_indices ( h5_file_t* const f, - h5_id_t* const indices, /* IN/OUT: local vertex indices */ + h5_loc_idx_t* const indices, /* IN/OUT: local vertex indices */ const h5_size_t size /* size of array */ ) { h5t_fdata_t* t = f->t; h5_size_t i; for (i = 1; i < size; ++i) { - h5_id_t idx = indices[i]; + h5_loc_idx_t idx = indices[i]; - h5_id_t j = i; + h5_size_t j = i; while ((j >= 1 ) && cmp_vertices ( t->vertices[idx].P, t->vertices[indices[j-1]].P @@ -249,14 +249,14 @@ h5tpriv_sort_local_vertex_indices ( /*! Map a global vertex index to corresponding local index. */ -h5_id_t +h5_loc_idx_t h5t_map_global_vertex_idx2local ( h5_file_t* const f, - const h5_id_t glb_idx + const h5_glb_idx_t glb_idx ) { if (glb_idx < 0) return -1; - h5_id_t loc_idx = h5priv_search_idmap (&f->t->map_vertex_g2l, glb_idx); + h5_loc_idx_t loc_idx = h5priv_search_idxmap (&f->t->map_vertex_g2l, glb_idx); if (loc_idx < 0) return h5tpriv_error_global_id_nexist (f, "vertex", glb_idx); return loc_idx; @@ -265,11 +265,11 @@ h5t_map_global_vertex_idx2local ( h5_err_t h5t_map_global_vertex_indices2local ( h5_file_t* const f, - const h5_id_t* const glb_indices, - const h5_id_t size, - h5_id_t* const loc_indices + const h5_glb_idx_t* const glb_indices, + const h5_size_t size, + h5_loc_idx_t* const loc_indices ) { - int i; + h5_size_t i; for (i = 0; i < size; i++) { TRY( (loc_indices[i] = h5t_map_global_vertex_idx2local (f, glb_indices[i])) ); @@ -285,31 +285,31 @@ h5t_map_global_vertex_indices2local ( \return Local element index or error code. */ -h5_id_t -h5t_map_global_elem_idx2local ( +h5_loc_idx_t +h5t_map_glb_elem_idx2loc ( h5_file_t* const f, - const h5_id_t glb_idx + const h5_glb_idx_t glb_idx ) { if (glb_idx < 0) return -1; - h5_id_t loc_idx = h5priv_search_idmap (&f->t->map_elem_g2l, glb_idx); + h5_loc_idx_t loc_idx = h5priv_search_idxmap (&f->t->map_elem_g2l, glb_idx); if (loc_idx < 0) return h5tpriv_error_global_id_nexist (f, "elem", glb_idx); return loc_idx; } h5_err_t -h5t_map_global_elem_indices2local ( +h5t_map_glb_elem_indices2loc ( h5_file_t* const f, - const h5_id_t* glb_indices, - const h5_id_t size, - h5_id_t* loc_indices + const h5_glb_idx_t* glb_indices, + const h5_size_t size, + h5_loc_idx_t* loc_indices ) { - const h5_id_t* end = glb_indices+size; + const h5_glb_idx_t* end = glb_indices+size; while (glb_indices < end) { TRY( (*loc_indices = - h5t_map_global_elem_idx2local (f, *glb_indices)) ); + h5t_map_glb_elem_idx2loc (f, *glb_indices)) ); loc_indices++; glb_indices++; } @@ -318,46 +318,51 @@ h5t_map_global_elem_indices2local ( /* - + rebuild mapping of global vertex indices to their local indices */ h5_err_t -h5tpriv_rebuild_global_2_local_map_of_vertices ( +h5tpriv_rebuild_vertex_indices_mapping ( h5_file_t* const f ) { + h5_debug (f, "%s()", __func__); h5t_fdata_t* t = f->t; if (t->num_levels <= 0) return H5_SUCCESS; h5_loc_idx_t loc_idx = t->cur_level > 0 ? t->num_vertices[t->cur_level-1] : 0; h5_loc_idx_t num_loc_vertices = t->num_vertices[t->num_levels-1]; - h5_idmap_el_t *item = &t->map_vertex_g2l.items[loc_idx]; + h5_idxmap_el_t *item = &t->map_vertex_g2l.items[loc_idx]; for (; loc_idx < num_loc_vertices; loc_idx++, item++) { - item->global_id = t->vertices[loc_idx].idx; - item->local_id = loc_idx; + item->glb_idx = t->vertices[loc_idx].idx; + item->loc_idx = loc_idx; t->map_vertex_g2l.num_items++; } - h5priv_sort_idmap (&t->map_vertex_g2l); + h5priv_sort_idxmap (&t->map_vertex_g2l); return H5_SUCCESS; } +/* + Rebuild mapping of global element indices to their local indices. +*/ h5_err_t -h5tpriv_rebuild_global_2_local_map_of_elems ( +h5tpriv_rebuild_elem_indices_mapping ( h5_file_t* const f ) { + h5_debug (f, "%s()", __func__); h5t_fdata_t* t = f->t; if (t->num_levels <= 0) return H5_SUCCESS; - h5_id_t loc_idx = t->cur_level > 0 ? t->num_elems[t->cur_level-1] : 0; - h5_id_t num_loc_elems = t->num_elems[t->num_levels-1]; - h5_idmap_el_t *item = &t->map_elem_g2l.items[loc_idx]; + h5_loc_idx_t loc_idx = t->cur_level > 0 ? t->num_elems[t->cur_level-1] : 0; + h5_loc_idx_t num_loc_elems = t->num_elems[t->num_levels-1]; + h5_idxmap_el_t *item = &t->map_elem_g2l.items[loc_idx]; for (; loc_idx < num_loc_elems; loc_idx++, item++) { - item->global_id = h5tpriv_get_glb_elem_idx (f, loc_idx); - item->local_id = loc_idx; + item->glb_idx = h5tpriv_get_glb_elem_idx (f, loc_idx); + item->loc_idx = loc_idx; t->map_elem_g2l.num_items++; } - h5priv_sort_idmap (&t->map_elem_g2l); + h5priv_sort_idxmap (&t->map_elem_g2l); return H5_SUCCESS; } @@ -366,8 +371,8 @@ h5tpriv_rebuild_global_2_local_map_of_elems ( h5_err_t h5t_get_vertex_indices_of_entity ( h5_file_t* const f, // in - const h5_id_t entity_id, // in - h5_id_t* vertex_indices // out + const h5_loc_id_t entity_id, // in + h5_loc_idx_t* vertex_indices // out ) { static int map_entity_type_to_dimension[] = { -1, @@ -377,11 +382,11 @@ h5t_get_vertex_indices_of_entity ( [H5_OID_TETRAHEDRON] = 3 }; - h5_id_t entity_type = h5tpriv_get_entity_type (entity_id); - h5_id_t face_idx = h5tpriv_get_face_idx (entity_id); - h5_id_t elem_idx = h5tpriv_get_elem_idx (entity_id); + h5_loc_id_t entity_type = h5tpriv_get_entity_type (entity_id); + h5_loc_idx_t face_idx = h5tpriv_get_face_idx (entity_id); + h5_loc_idx_t elem_idx = h5tpriv_get_elem_idx (entity_id); int dim = map_entity_type_to_dimension[entity_type]; - h5_id_t* indices = h5tpriv_get_loc_elem_vertex_indices (f, elem_idx); + h5_loc_idx_t* indices = h5tpriv_get_loc_elem_vertex_indices (f, elem_idx); const h5t_ref_elem_t* ref_elem = f->t->ref_elem; int num_vertices = ref_elem->num_vertices_of_face[dim][face_idx]; int i; @@ -395,11 +400,11 @@ h5t_get_vertex_indices_of_entity ( h5_err_t h5t_get_vertex_index_of_vertex ( h5_file_t* const f, - const h5_id_t entity_id, - h5_id_t* vertex_index + const h5_loc_id_t entity_id, + h5_loc_idx_t* vertex_index ) { - h5_id_t face_idx = h5tpriv_get_face_idx (entity_id); - h5_id_t elem_idx = h5tpriv_get_elem_idx (entity_id); + h5_loc_idx_t face_idx = h5tpriv_get_face_idx (entity_id); + h5_loc_idx_t elem_idx = h5tpriv_get_elem_idx (entity_id); return h5t_get_vertex_index_of_vertex2 ( f, face_idx, elem_idx, vertex_index); } @@ -407,9 +412,9 @@ h5t_get_vertex_index_of_vertex ( h5_err_t h5t_get_vertex_index_of_vertex2 ( h5_file_t* const f, - const h5_id_t face_idx, // vertex index according ref. element - const h5_id_t elem_idx, // local element index - h5_id_t* vertex_indices // OUT: vertex ID's + const h5_loc_idx_t face_idx, // vertex index according ref. element + const h5_loc_idx_t elem_idx, // local element index + h5_loc_idx_t* vertex_indices // OUT: vertex ID's ) { vertex_indices[0] = h5tpriv_get_loc_elem_vertex_idx (f, elem_idx, face_idx); return H5_SUCCESS; @@ -421,11 +426,11 @@ h5t_get_vertex_index_of_vertex2 ( h5_err_t h5t_get_vertex_indices_of_edge ( h5_file_t* const f, - const h5_id_t entity_id, - h5_id_t* vertex_indices + const h5_loc_id_t entity_id, + h5_loc_idx_t* vertex_indices ) { - h5_id_t face_idx = h5tpriv_get_face_idx (entity_id); - h5_id_t elem_idx = h5tpriv_get_elem_idx (entity_id); + h5_loc_idx_t face_idx = h5tpriv_get_face_idx (entity_id); + h5_loc_idx_t elem_idx = h5tpriv_get_elem_idx (entity_id); return h5t_get_vertex_indices_of_edge2 ( f, face_idx, elem_idx, vertex_indices); } @@ -440,11 +445,11 @@ h5t_get_vertex_indices_of_edge ( h5_err_t h5t_get_vertex_indices_of_edge2 ( h5_file_t* const f, - const h5_id_t face_idx, // edge index according ref. element - const h5_id_t elem_idx, // local element index - h5_id_t* vertex_indices // OUT: vertex ID's + const h5_loc_idx_t face_idx, // edge index according ref. element + const h5_loc_idx_t elem_idx, // local element index + h5_loc_idx_t* vertex_indices // OUT: vertex indices ) { - const h5_id_t* indices = h5tpriv_get_loc_elem_vertex_indices (f, elem_idx); + const h5_loc_idx_t* indices = h5tpriv_get_loc_elem_vertex_indices (f, elem_idx); const h5t_ref_elem_t* ref_elem = f->t->ref_elem; vertex_indices[0] = indices[ ref_elem->map[1][face_idx][0] ]; @@ -455,11 +460,11 @@ h5t_get_vertex_indices_of_edge2 ( h5_err_t h5t_get_vertex_indices_of_triangle ( h5_file_t* const f, - const h5_id_t entity_id, - h5_id_t* vertex_indices + const h5_loc_id_t entity_id, + h5_loc_idx_t* vertex_indices ) { - h5_id_t face_idx = h5tpriv_get_face_idx (entity_id); - h5_id_t elem_idx = h5tpriv_get_elem_idx (entity_id); + h5_loc_idx_t face_idx = h5tpriv_get_face_idx (entity_id); + h5_loc_idx_t elem_idx = h5tpriv_get_elem_idx (entity_id); return h5t_get_vertex_indices_of_triangle2 ( f, face_idx, elem_idx, vertex_indices); } @@ -467,11 +472,12 @@ h5t_get_vertex_indices_of_triangle ( h5_err_t h5t_get_vertex_indices_of_triangle2 ( h5_file_t* const f, - const h5_id_t face_idx, - const h5_id_t elem_idx, - h5_id_t* vertex_indices + const h5_loc_idx_t face_idx, + const h5_loc_idx_t elem_idx, + h5_loc_idx_t* vertex_indices ) { - const h5_id_t* indices = h5tpriv_get_loc_elem_vertex_indices (f, elem_idx); + const h5_loc_idx_t* indices = h5tpriv_get_loc_elem_vertex_indices ( + f, elem_idx); const h5t_ref_elem_t* ref_elem = f->t->ref_elem; vertex_indices[0] = indices[ ref_elem->map[2][face_idx][0] ]; @@ -484,11 +490,12 @@ h5t_get_vertex_indices_of_triangle2 ( h5_err_t h5t_get_vertex_indices_of_tet ( h5_file_t* const f, - const h5_id_t entity_id, - h5_id_t* vertex_indices + const h5_loc_id_t entity_id, + h5_loc_idx_t* vertex_indices ) { - const h5_id_t elem_idx = h5tpriv_get_elem_idx (entity_id); - const h5_id_t* indices = h5tpriv_get_loc_elem_vertex_indices (f, elem_idx); + const h5_loc_idx_t elem_idx = h5tpriv_get_elem_idx (entity_id); + const h5_loc_idx_t* indices = h5tpriv_get_loc_elem_vertex_indices ( + f, elem_idx); const h5t_ref_elem_t* ref_elem = f->t->ref_elem; vertex_indices[0] = indices[ ref_elem->map[3][0][0] ]; diff --git a/src/h5core/h5t_map_private.h b/src/h5core/h5t_map_private.h index 2c53a8e..02de2af 100644 --- a/src/h5core/h5t_map_private.h +++ b/src/h5core/h5t_map_private.h @@ -4,7 +4,7 @@ h5_err_t h5tpriv_sort_local_vertex_indices ( h5_file_t * const f, - h5_id_t * const indices, + h5_loc_idx_t * const indices, const h5_size_t size ); @@ -13,18 +13,24 @@ h5tpriv_sort_vertices ( h5_file_t * const f ); +h5_loc_idx_t +h5tpriv_get_local_vid ( + h5_file_t * const f, + h5_float64_t P[3] + ); + h5_err_t h5tpriv_sort_loc_elems ( h5_file_t * const f ); h5_err_t -h5tpriv_rebuild_global_2_local_map_of_vertices ( +h5tpriv_rebuild_vertex_indices_mapping ( h5_file_t * const f ); h5_err_t -h5tpriv_rebuild_global_2_local_map_of_elems ( +h5tpriv_rebuild_elem_indices_mapping ( h5_file_t * const f ); diff --git a/src/h5core/h5t_openclose.c b/src/h5core/h5t_openclose.c index aaa2e4c..50a263d 100644 --- a/src/h5core/h5t_openclose.c +++ b/src/h5core/h5t_openclose.c @@ -38,7 +38,7 @@ create_array_types ( dims) ); TRY( - dtypes->h5_3id_t = h5priv_create_hdf5_array_type ( + dtypes->h5_3glb_idx_t = h5priv_create_hdf5_array_type ( f, H5_ID_T, 1, @@ -46,7 +46,7 @@ create_array_types ( ); dims[0] = 4; TRY( - dtypes->h5_4id_t = h5priv_create_hdf5_array_type ( + dtypes->h5_4glb_idx_t = h5priv_create_hdf5_array_type ( f, H5_ID_T, 1, @@ -66,20 +66,20 @@ create_vertex_type ( dtypes->h5_vertex_t = h5priv_create_hdf5_type ( f, H5_COMPOUND_T, - sizeof (struct h5_vertex)) ); + sizeof (h5_glb_vertex_t)) ); TRY( h5priv_insert_hdf5_type ( f, dtypes->h5_vertex_t, "idx", - HOFFSET (struct h5_vertex, idx), + HOFFSET (h5_glb_vertex_t, idx), H5_ID_T) ); TRY( h5priv_insert_hdf5_type ( f, dtypes->h5_vertex_t, "P", - HOFFSET (struct h5_vertex, P), + HOFFSET (h5_glb_vertex_t, P), dtypes->h5_coord3d_t) ); return H5_SUCCESS; @@ -95,42 +95,42 @@ create_triangle_type ( dtypes->h5_triangle_t = h5priv_create_hdf5_type ( f, H5_COMPOUND_T, - sizeof (struct h5_triangle)) ); + sizeof (h5_glb_triangle_t)) ); TRY( h5priv_insert_hdf5_type ( f, dtypes->h5_triangle_t, "idx", - HOFFSET (struct h5_triangle, idx), + HOFFSET (h5_glb_triangle_t, idx), H5_ID_T) ); TRY( h5priv_insert_hdf5_type ( f, dtypes->h5_triangle_t, "parent_idx", - HOFFSET (struct h5_triangle, parent_idx), + HOFFSET (h5_glb_triangle_t, parent_idx), H5_ID_T) ); TRY( h5priv_insert_hdf5_type ( f, dtypes->h5_triangle_t, "child_idx", - HOFFSET(struct h5_triangle, child_idx), + HOFFSET(h5_glb_triangle_t, child_idx), H5_ID_T) ); TRY( h5priv_insert_hdf5_type ( f, dtypes->h5_triangle_t, "vertex_indices", - HOFFSET (struct h5_triangle, vertex_indices), - dtypes->h5_3id_t) ); + HOFFSET (h5_glb_triangle_t, vertex_indices), + dtypes->h5_3glb_idx_t) ); TRY( h5priv_insert_hdf5_type ( f, dtypes->h5_triangle_t, "neighbor_indices", - HOFFSET(struct h5_triangle, neighbor_indices), - dtypes->h5_3id_t) ); + HOFFSET(h5_glb_triangle_t, neighbor_indices), + dtypes->h5_3glb_idx_t) ); return H5_SUCCESS; } @@ -174,62 +174,46 @@ create_tet_type ( dtypes->h5_tet_t = h5priv_create_hdf5_type ( f, H5_COMPOUND_T, - sizeof (struct h5_tetrahedron)) ); + sizeof (h5_glb_tetrahedron_t)) ); TRY( h5priv_insert_hdf5_type ( f, dtypes->h5_tet_t, "idx", - HOFFSET (struct h5_tetrahedron, idx), + HOFFSET (h5_glb_tetrahedron_t, idx), H5_ID_T) ); TRY( h5priv_insert_hdf5_type ( f, dtypes->h5_tet_t, "parent_idx", - HOFFSET (struct h5_tetrahedron, parent_idx), + HOFFSET (h5_glb_tetrahedron_t, parent_idx), H5_ID_T) ); TRY( h5priv_insert_hdf5_type ( f, dtypes->h5_tet_t, "child_idx", - HOFFSET (struct h5_tetrahedron, child_idx), + HOFFSET (h5_glb_tetrahedron_t, child_idx), H5T_NATIVE_INT32) ); TRY( h5priv_insert_hdf5_type ( f, dtypes->h5_tet_t, "vertex_indices", - HOFFSET (struct h5_tetrahedron, vertex_indices), - dtypes->h5_4id_t) ); + HOFFSET (h5_glb_tetrahedron_t, vertex_indices), + dtypes->h5_4glb_idx_t) ); TRY( h5priv_insert_hdf5_type ( f, dtypes->h5_tet_t, "neighbor_indices", - HOFFSET (struct h5_tetrahedron, neighbor_indices), - dtypes->h5_4id_t) ); + HOFFSET (h5_glb_tetrahedron_t, neighbor_indices), + dtypes->h5_4glb_idx_t) ); return H5_SUCCESS; } - -#if 0 -h5_err_t -h5priv_set_dataset_properties ( - h5_dsinfo_t* dsinfo, - const char* name, - const hid_t type, - const int rank, - const hsize_t* dims, - const hsize_t* maxdims, - const hsize_t chunk_dims - ) { - return H5_SUCCESS; -} -#endif - static h5_err_t init_fdata ( h5_file_t* const f @@ -342,8 +326,6 @@ init_fdata ( t->dsinfo_num_elems_on_level.chunk_dims) ); t->dsinfo_num_elems_on_level.access_prop = H5P_DEFAULT; - - return H5_SUCCESS; } @@ -362,7 +344,7 @@ h5tpriv_open_file ( h5_file_t* const f /*!< IN: file handle */ ) { - TRY( (f->t = h5priv_alloc (f, NULL, sizeof (*f->t))) ); + TRY( (f->t = h5priv_calloc (f, 1, sizeof (*f->t))) ); h5t_fdata_t* t = f->t; t->dtypes.h5_id_t = H5_INT64_T; @@ -406,8 +388,9 @@ h5tpriv_open_topo_group ( h5_file_t * const f ) { h5t_fdata_t* t = f->t; - - t->topo_gid = h5priv_open_group (f, f->root_gid, H5T_CONTAINER_GRPNAME); + if (t->topo_gid == 0 || t->topo_gid == -1) { + t->topo_gid = h5priv_open_group (f, f->root_gid, H5T_CONTAINER_GRPNAME); + } return t->topo_gid; } @@ -464,6 +447,7 @@ h5t_open_mesh ( h5_id_t id, const h5_oid_t type_id ) { + h5_debug (f, "%s ()", __func__); h5t_fdata_t* t = f->t; TRY( h5t_close_mesh (f) ); @@ -549,12 +533,16 @@ h5_err_t h5t_close_mesh ( h5_file_t* const f ) { + h5_debug (f, "%s ()", __func__); if (!(f->mode & H5_O_RDONLY)) { TRY( h5tpriv_write_mesh (f) ); } + TRY( h5priv_close_hdf5_group (f, f->t->mesh_gid) ); + TRY( h5priv_close_hdf5_group (f, f->t->meshes_gid) ); + TRY( h5priv_close_hdf5_group (f, f->t->topo_gid) ); + TRY( release_memory (f) ); TRY( init_fdata (f) ); - return H5_SUCCESS; } @@ -589,7 +577,7 @@ h5tpriv_alloc_num_vertices ( ssize_t size = num * sizeof (t->vertices[0]); TRY( t->vertices = h5priv_alloc (f, t->vertices, size) ); - TRY( h5priv_alloc_idmap (f, &t->map_vertex_g2l, num) ); + TRY( h5priv_alloc_idxmap (f, &t->map_vertex_g2l, num) ); TRY( h5priv_alloc_idlist_items (f, &t->sorted_lvertices, num) ); return H5_SUCCESS; @@ -609,7 +597,9 @@ h5_err_t h5tpriv_close_file ( h5_file_t* const f /*!< IN: file handle */ ) { + h5_debug (f, "%s ()", __func__); TRY( h5t_close_mesh (f) ); + TRY( h5priv_close_hdf5_group (f, f->t->meshes_gid) ); return H5_SUCCESS; } diff --git a/src/h5core/h5t_openclose_private.h b/src/h5core/h5t_openclose_private.h index a7bee96..441a4b3 100644 --- a/src/h5core/h5t_openclose_private.h +++ b/src/h5core/h5t_openclose_private.h @@ -1,21 +1,57 @@ #ifndef __H5T_OPENCLOSE_PRIVATE_H #define __H5T_OPENCLOSE_PRIVATE_H -h5_err_t h5tpriv_open_file ( h5_file_t * const f ); -h5_err_t h5tpriv_close_file ( h5_file_t * const f ); -h5_err_t h5tpriv_open_topo_group ( h5_file_t * const f ); -h5_err_t h5tpriv_open_meshes_group ( h5_file_t * const f, const h5_oid_t ); -h5_err_t h5tpriv_open_mesh_group ( h5_file_t * const f, const h5_oid_t, const h5_id_t ); -h5_err_t h5tpriv_close_step ( h5_file_t * const f ); - -h5_err_t h5tpriv_init_fdata ( h5_file_t * const f ); -h5_err_t h5tpriv_init_step ( h5_file_t * const f ); - -h5_err_t h5tpriv_alloc_num_vertices ( h5_file_t * const f, - const h5_size_t num_vertices ); -h5_err_t h5tpriv_alloc_tris ( h5_file_t * const f, const size_t cur, - const size_t new_size ); -h5_err_t h5tpriv_alloc_tets ( h5_file_t * const f, const size_t cur, - const size_t new_size ); +h5_err_t +h5tpriv_open_file ( + h5_file_t * const f + ); +h5_err_t +h5tpriv_close_file ( + h5_file_t * const f + ); +h5_err_t +h5tpriv_open_topo_group ( + h5_file_t * const f + ); +h5_err_t +h5tpriv_open_meshes_group ( + h5_file_t * const f, + const h5_oid_t + ); +h5_err_t +h5tpriv_open_mesh_group ( + h5_file_t * const f, + const h5_oid_t, + const h5_id_t + ); +h5_err_t +h5tpriv_close_step ( + h5_file_t * const f + ); +h5_err_t +h5tpriv_init_fdata ( + h5_file_t * const f + ); +h5_err_t +h5tpriv_init_step ( + h5_file_t * const f + ); +h5_err_t +h5tpriv_alloc_num_vertices ( + h5_file_t * const f, + const h5_size_t num_vertices + ); +h5_err_t +h5tpriv_alloc_tris ( + h5_file_t * const f, + const size_t cur, + const size_t new_size + ); +h5_err_t +h5tpriv_alloc_tets ( + h5_file_t * const f, + const size_t cur, + const size_t new_size + ); #endif diff --git a/src/h5core/h5t_readwrite.c b/src/h5core/h5t_readwrite.c index 79fbee1..46859c8 100644 --- a/src/h5core/h5t_readwrite.c +++ b/src/h5core/h5t_readwrite.c @@ -85,6 +85,7 @@ h5_err_t h5tpriv_write_mesh ( h5_file_t* const f ) { + h5_debug (f, "%s ()", __func__); h5t_fdata_t* t = f->t; if (t->mesh_changed) { TRY( write_vertices (f) ); @@ -176,7 +177,7 @@ read_vertices ( open_file_space_vertices, t->vertices) ); TRY( h5tpriv_sort_vertices (f) ); - TRY( h5tpriv_rebuild_global_2_local_map_of_vertices (f) ); + TRY( h5tpriv_rebuild_vertex_indices_mapping (f) ); return H5_SUCCESS; } @@ -252,7 +253,7 @@ read_elems ( t->glb_elems.data) ); TRY( h5tpriv_sort_loc_elems (f) ); - TRY( h5tpriv_rebuild_global_2_local_map_of_elems (f) ); + TRY( h5tpriv_rebuild_elem_indices_mapping (f) ); TRY( h5tpriv_init_loc_elems_struct (f) ); return H5_SUCCESS; diff --git a/src/h5core/h5t_readwrite_tetm.c b/src/h5core/h5t_readwrite_tetm.c index 83dd9c5..b58aaca 100644 --- a/src/h5core/h5t_readwrite_tetm.c +++ b/src/h5core/h5t_readwrite_tetm.c @@ -9,25 +9,25 @@ init_loc_elems_struct ( h5_file_t* const f ) { h5t_fdata_t* const t = f->t; - h5_id_t idx = 0; - const h5_id_t num_elems = t->num_elems[t->num_levels-1]; + h5_loc_idx_t elem_idx = 0; + const h5_loc_idx_t num_elems = t->num_elems[t->num_levels-1]; h5_id_t level_idx = 0; int num_vertices = h5tpriv_ref_elem_get_num_vertices (t); int num_edges = h5tpriv_ref_elem_get_num_edges (t); - h5_tet_t* loc_elem = t->loc_elems.tets; - h5_tet_t* glb_elem = t->glb_elems.tets; + h5_loc_tet_t* loc_elem = t->loc_elems.tets; + h5_glb_tet_t* glb_elem = t->glb_elems.tets; - for (idx = 0; idx < num_elems; idx++, loc_elem++, glb_elem++) { + for (elem_idx = 0; elem_idx < num_elems; elem_idx++, loc_elem++, glb_elem++) { // local parent index TRY( loc_elem->parent_idx = - h5t_map_global_elem_idx2local (f, glb_elem->parent_idx) ); + h5t_map_glb_elem_idx2loc (f, glb_elem->parent_idx) ); // local child index TRY( loc_elem->child_idx = - h5t_map_global_elem_idx2local (f, glb_elem->child_idx) ); + h5t_map_glb_elem_idx2loc (f, glb_elem->child_idx) ); // level idx - if (idx >= t->num_elems[level_idx]) { + if (elem_idx >= t->num_elems[level_idx]) { level_idx++; } loc_elem->idx = level_idx; @@ -40,7 +40,7 @@ init_loc_elems_struct ( loc_elem->vertex_indices) ); // neighbor indices - TRY( h5t_map_global_elem_indices2local ( + TRY( h5t_map_glb_elem_indices2loc ( f, glb_elem->neighbor_indices, num_edges, diff --git a/src/h5core/h5t_readwrite_trim.c b/src/h5core/h5t_readwrite_trim.c index 773643a..3406f57 100644 --- a/src/h5core/h5t_readwrite_trim.c +++ b/src/h5core/h5t_readwrite_trim.c @@ -9,22 +9,22 @@ init_loc_elems_struct ( h5_file_t* const f ) { h5t_fdata_t* const t = f->t; - h5_id_t idx = 0; - const h5_id_t num_elems = t->num_elems[t->num_levels-1]; + h5_loc_idx_t idx = 0; + const h5_loc_idx_t num_elems = t->num_elems[t->num_levels-1]; h5_id_t level_idx = 0; int num_vertices = h5tpriv_ref_elem_get_num_vertices (t); int num_edges = h5tpriv_ref_elem_get_num_edges (t); - h5_triangle_t* loc_elem = t->loc_elems.tris; - h5_triangle_t* glb_elem = t->glb_elems.tris; + h5_loc_triangle_t* loc_elem = t->loc_elems.tris; + h5_glb_triangle_t* glb_elem = t->glb_elems.tris; for (idx = 0; idx < num_elems; idx++, loc_elem++, glb_elem++) { // local parent index TRY( loc_elem->parent_idx = - h5t_map_global_elem_idx2local (f, glb_elem->parent_idx) ); + h5t_map_glb_elem_idx2loc (f, glb_elem->parent_idx) ); // local child index TRY( loc_elem->child_idx = - h5t_map_global_elem_idx2local (f, glb_elem->child_idx) ); + h5t_map_glb_elem_idx2loc (f, glb_elem->child_idx) ); // level idx if (idx >= t->num_elems[level_idx]) { @@ -40,7 +40,7 @@ init_loc_elems_struct ( loc_elem->vertex_indices) ); // neighbor indices - TRY( h5t_map_global_elem_indices2local ( + TRY( h5t_map_glb_elem_indices2loc ( f, glb_elem->neighbor_indices, num_edges, diff --git a/src/h5core/h5t_retrieve.c b/src/h5core/h5t_retrieve.c index 3735505..9ed44d1 100644 --- a/src/h5core/h5t_retrieve.c +++ b/src/h5core/h5t_retrieve.c @@ -13,7 +13,7 @@ h5tpriv_skip_to_next_elem_on_level ( h5_file_t* f, h5t_entity_iterator_t* iter ) { - h5_generic_elem_t* el; + h5_generic_loc_elem_t* el; do { iter->elem_idx++; if (iter->elem_idx >= num_elems_on_cur_level) { @@ -33,7 +33,7 @@ h5tpriv_skip_to_next_elem_on_level ( h5_err_t h5tpriv_elem_is_on_cur_level ( h5_file_t* const f, - h5_generic_elem_t *el // ptr to local element + h5_generic_loc_elem_t *el // ptr to local element ) { h5t_fdata_t* t = f->t; if ( (el->idx > t->cur_level) || @@ -74,7 +74,7 @@ h5t_begin_iterate_entities ( /*! Travere entities with co-dim > 0 */ -static h5_id_t +static h5_loc_id_t iterate_faces ( h5_file_t* const f, h5t_entity_iterator_t* iter @@ -101,10 +101,10 @@ iterate_faces ( TRY( (iter->find)(f, iter->face_idx, iter->elem_idx, &entry) ); i = -1; - h5_generic_elem_t *el; + h5_generic_loc_elem_t *el; do { i++; - h5_id_t idx = h5tpriv_get_elem_idx (entry->items[i]); + h5_loc_idx_t idx = h5tpriv_get_elem_idx (entry->items[i]); el = h5tpriv_get_loc_elem (f, idx); } while (h5tpriv_elem_is_on_cur_level (f, el) == H5_NOK); } while (iter->elem_idx != h5tpriv_get_elem_idx(entry->items[i])); @@ -112,7 +112,7 @@ iterate_faces ( return entry->items[0]; } -static h5_id_t +static h5_loc_id_t iterate_elems ( h5_file_t* const f, h5t_entity_iterator_t*iter @@ -124,7 +124,7 @@ iterate_elems ( return h5tpriv_build_elem_id ( iter->elem_idx ); } -h5_id_t +h5_loc_id_t h5t_iterate_entities ( h5_file_t* const f, h5t_entity_iterator_t* iter @@ -155,10 +155,10 @@ h5t_end_iterate_entities ( h5_err_t h5t_get_vertex_coords_by_index ( h5_file_t* const f, - h5_id_t vertex_index, + h5_loc_idx_t vertex_index, h5_float64_t P[3] ) { - h5_vertex_t *vertex = &f->t->vertices[vertex_index]; + h5_loc_vertex_t *vertex = &f->t->vertices[vertex_index]; memcpy ( P, &vertex->P, sizeof ( vertex->P ) ); return H5_SUCCESS; } @@ -166,10 +166,10 @@ h5t_get_vertex_coords_by_index ( h5_err_t h5t_get_vertex_coords_by_id ( h5_file_t* const f, - h5_id_t vertex_id, + h5_loc_id_t vertex_id, h5_float64_t P[3] ) { - h5_id_t vertex_index; + h5_loc_idx_t vertex_index; h5t_get_vertex_index_of_vertex (f, vertex_id, &vertex_index ); h5t_get_vertex_coords_by_index (f, vertex_index, P); return H5_SUCCESS; diff --git a/src/h5core/h5t_retrieve_private.h b/src/h5core/h5t_retrieve_private.h index 5edb5b5..8ca2a14 100644 --- a/src/h5core/h5t_retrieve_private.h +++ b/src/h5core/h5t_retrieve_private.h @@ -10,7 +10,7 @@ h5tpriv_skip_to_next_elem_on_level ( h5_err_t h5tpriv_elem_is_on_cur_level ( h5_file_t* const f, - h5_generic_elem_t* el + h5_generic_loc_elem_t* el ); extern struct h5t_retrieve_methods h5tpriv_trim_retrieve_methods; diff --git a/src/h5core/h5t_store.c b/src/h5core/h5t_store.c index 5f6f67c..8ddeec7 100644 --- a/src/h5core/h5t_store.c +++ b/src/h5core/h5t_store.c @@ -38,7 +38,8 @@ assign_global_vertex_indices ( /* simple in serial runs: global_id = local_id */ - h5_id_t local_idx = (t->cur_level == 0) ? 0 : t->num_vertices[t->cur_level-1]; + h5_loc_idx_t local_idx = (t->cur_level == 0) ? + 0 : t->num_vertices[t->cur_level-1]; for (local_idx = 0; local_idx < t->num_vertices[t->num_levels-1]; local_idx++) { @@ -65,7 +66,7 @@ assign_glb_elem_indices ( h5_loc_idx_t loc_idx = (t->cur_level == 0) ? 0 : t->num_elems[t->cur_level-1]; for (; loc_idx < t->num_elems[t->cur_level]; loc_idx++) { - h5_generic_elem_t *glb_elem = h5tpriv_get_glb_elem (f, loc_idx); + h5_generic_glb_elem_t *glb_elem = h5tpriv_get_glb_elem (f, loc_idx); glb_elem->idx = loc_idx; } @@ -89,14 +90,14 @@ assign_glb_elem_data ( int dim = h5tpriv_ref_elem_get_dim (t) - 1; int num_faces = h5tpriv_ref_elem_get_num_faces(t, dim); for (; loc_idx < t->num_elems[t->cur_level]; loc_idx++) { - h5_generic_elem_t *loc_elem = h5tpriv_get_loc_elem (f, loc_idx); - h5_generic_elem_t *glb_elem = h5tpriv_get_glb_elem (f, loc_idx); + h5_generic_loc_elem_t *loc_elem = h5tpriv_get_loc_elem (f, loc_idx); + h5_generic_glb_elem_t *glb_elem = h5tpriv_get_glb_elem (f, loc_idx); glb_elem->parent_idx = loc_elem->parent_idx; if (loc_elem->parent_idx >= 0) { - h5_generic_elem_t *loc_parent = h5tpriv_get_loc_elem ( + h5_generic_loc_elem_t *loc_parent = h5tpriv_get_loc_elem ( f, loc_elem->parent_idx); - h5_generic_elem_t *glb_parent = h5tpriv_get_glb_elem ( + h5_generic_glb_elem_t *glb_parent = h5tpriv_get_glb_elem ( f, glb_elem->parent_idx); glb_parent->child_idx = loc_parent->child_idx; @@ -104,8 +105,8 @@ assign_glb_elem_data ( glb_elem->child_idx = loc_elem->child_idx; - h5_id_t* glb_indices = h5tpriv_get_glb_elem_vertex_indices (f, loc_idx); - h5_id_t* loc_indices = h5tpriv_get_loc_elem_vertex_indices (f, loc_idx); + h5_glb_idx_t* glb_indices = h5tpriv_get_glb_elem_vertex_indices (f, loc_idx); + h5_loc_idx_t* loc_indices = h5tpriv_get_loc_elem_vertex_indices (f, loc_idx); memcpy (glb_indices, loc_indices, num_vertices*sizeof(*glb_indices)); @@ -179,10 +180,10 @@ h5t_begin_store_vertices ( return h5tpriv_alloc_num_vertices (f, cur_num_vertices+num); } -h5_id_t +h5_loc_idx_t h5t_store_vertex ( h5_file_t* const f, /*!< file handle */ - const h5_id_t glb_idx, /*!< global vertex id or -1 */ + const h5_glb_idx_t glb_id, /*!< global vertex id from mesher or -1 */ const h5_float64_t P[3] /*!< coordinates */ ) { h5t_fdata_t* const t = f->t; @@ -200,9 +201,9 @@ h5t_store_vertex ( if (t->cur_level < 0) return h5tpriv_error_undef_level(f); - h5_id_t local_idx = ++t->last_stored_vid; - h5_vertex_t *vertex = &t->vertices[local_idx]; - vertex->idx = glb_idx; /* ID from mesher, replaced later!*/ + h5_loc_idx_t local_idx = ++t->last_stored_vid; + h5_loc_vertex_t *vertex = &t->vertices[local_idx]; + vertex->idx = glb_id; /* ID from mesher, replaced later!*/ memcpy (&vertex->P, P, sizeof (vertex->P)); return local_idx; } @@ -216,7 +217,7 @@ h5t_end_store_vertices ( t->num_vertices[t->cur_level] = t->last_stored_vid+1; TRY( assign_global_vertex_indices (f) ); TRY( h5tpriv_sort_vertices (f) ); - TRY( h5tpriv_rebuild_global_2_local_map_of_vertices (f) ); + TRY( h5tpriv_rebuild_vertex_indices_mapping (f) ); return H5_SUCCESS; } @@ -259,11 +260,11 @@ h5t_begin_store_elems ( \param[in] vertices Local vertex indices defining the tetrahedron. */ -h5_id_t +h5_loc_idx_t h5t_store_elem ( h5_file_t* const f, - const h5_id_t parent_idx, - const h5_id_t* vertex_indices + const h5_loc_idx_t parent_idx, + const h5_loc_idx_t* vertex_indices ) { h5t_fdata_t* t = f->t; @@ -288,18 +289,21 @@ h5t_store_elem ( } /* store elem data (but neighbors) */ - h5_id_t elem_idx = ++t->last_stored_eid; + h5_loc_idx_t elem_idx = ++t->last_stored_eid; h5tpriv_set_loc_elem_parent_idx (f, elem_idx, parent_idx); h5tpriv_set_loc_elem_child_idx (f, elem_idx, -1); h5tpriv_set_loc_elem_level_idx (f, elem_idx, t->cur_level); - h5_id_t* loc_vertex_indices = h5tpriv_get_loc_elem_vertex_indices (f, elem_idx); + // get ptr to local vertices store + h5_loc_idx_t* loc_vertex_indices = h5tpriv_get_loc_elem_vertex_indices ( + f, elem_idx); int num_vertices = h5tpriv_ref_elem_get_num_vertices (t); - memcpy (loc_vertex_indices, vertex_indices, sizeof (*vertex_indices)*num_vertices); + memcpy (loc_vertex_indices, vertex_indices, + sizeof (*vertex_indices)*num_vertices); h5tpriv_sort_local_vertex_indices (f, loc_vertex_indices, num_vertices); /* add edges to map edges -> elements */ - h5_id_t face_idx; + h5_loc_idx_t face_idx; int num_faces = h5tpriv_ref_elem_get_num_edges (t); h5_idlist_t* retval; for (face_idx = 0; face_idx < num_faces; face_idx++) { @@ -317,6 +321,7 @@ h5_err_t h5t_end_store_elems ( h5_file_t* const f ) { + h5_debug (f, "%s ()", __func__); h5t_fdata_t* const t = f->t; t->num_elems[t->cur_level] = t->last_stored_eid+1; @@ -327,7 +332,7 @@ h5t_end_store_elems ( TRY( assign_glb_elem_indices (f) ); /* rebuild map: global index -> local_index */ - TRY( h5tpriv_rebuild_global_2_local_map_of_elems (f) ); + TRY( h5tpriv_rebuild_elem_indices_mapping (f) ); /* mesh specific finalize */ TRY( (t->methods.store->end_store_elems)(f) ); @@ -335,6 +340,7 @@ h5t_end_store_elems ( /* setup global element data */ TRY( assign_glb_elem_data (f) ); + h5_debug (f, "%s (): done", __func__); return H5_SUCCESS; } @@ -344,7 +350,7 @@ h5t_end_store_elems ( h5_err_t h5t_mark_entity ( h5_file_t* const f, - const h5_id_t entity_id + const h5_loc_id_t entity_id ) { h5t_fdata_t* const t = f->t; return h5priv_append_to_idlist (f, &t->marked_entities, entity_id); diff --git a/src/h5core/h5t_store_private.h b/src/h5core/h5t_store_private.h index 2a7b842..5b4c12d 100644 --- a/src/h5core/h5t_store_private.h +++ b/src/h5core/h5t_store_private.h @@ -24,12 +24,12 @@ h5tpriv_alloc_elems ( return (*f->t->methods.store->alloc_elems) (f, cur, new); } -static inline h5_id_t +static inline h5_loc_idx_t h5tpriv_refine_elem ( h5_file_t * const f, - const h5_id_t local_eid + const h5_loc_idx_t elem_idx ) { - return (*f->t->methods.store->refine_elem)(f, local_eid); + return (*f->t->methods.store->refine_elem)(f, elem_idx); } #endif diff --git a/src/h5core/h5t_store_tetm.c b/src/h5core/h5t_store_tetm.c index 2ab3d93..7242124 100644 --- a/src/h5core/h5t_store_tetm.c +++ b/src/h5core/h5t_store_tetm.c @@ -32,7 +32,7 @@ alloc_tets ( (new-cur) * sizeof (t->loc_elems.tets[0]) ); /* alloc mem for global to local ID mapping */ - TRY ( h5priv_alloc_idmap ( f, &t->map_elem_g2l, new ) ); + TRY ( h5priv_alloc_idxmap ( f, &t->map_elem_g2l, new ) ); return H5_SUCCESS; } @@ -72,7 +72,7 @@ get_direct_children_of_edge ( \return local index of vertex */ -static h5_id_t +static h5_loc_idx_t bisect_edge ( h5_file_t* const f, const h5_loc_idx_t face_idx, @@ -89,8 +89,8 @@ bisect_edge ( */ size_t i; for (i = 0; i < retval->num_items; i++) { - h5_id_t idx = h5tpriv_get_elem_idx (retval->items[i]); - h5_id_t child_idx = h5tpriv_get_loc_elem_child_idx (f, idx); + h5_loc_idx_t idx = h5tpriv_get_elem_idx (retval->items[i]); + h5_loc_idx_t child_idx = h5tpriv_get_loc_elem_child_idx (f, idx); if (child_idx >= 0) { /* this element has been refined! @@ -134,7 +134,7 @@ bisect_edge ( \return Local id of first new tetrahedron or \c -1 */ -static h5_id_t +static h5_loc_idx_t refine_tet ( h5_file_t* const f, const h5_loc_idx_t elem_idx @@ -142,7 +142,7 @@ refine_tet ( h5t_fdata_t* t = f->t; h5_loc_idx_t vertices[10]; h5_loc_idx_t elem_idx_of_first_child; - h5_tet_t* el = &t->loc_elems.tets[elem_idx]; + h5_loc_tet_t* el = &t->loc_elems.tets[elem_idx]; if ( el->child_idx >= 0 ) return h5_error ( @@ -280,7 +280,7 @@ compute_neighbors_of_new_elems ( } h5_loc_idx_t elem_idx = t->cur_level == 0 ? 0 : t->num_elems[t->cur_level-1]; const h5_loc_idx_t last_idx = t->num_elems[t->cur_level] - 1; - h5_tet_t *el = &t->loc_elems.tets[elem_idx]; + h5_loc_tet_t *el = &t->loc_elems.tets[elem_idx]; while (elem_idx <= last_idx) { h5_loc_idx_t face_idx = 0; for (; face_idx < 4; face_idx++) { diff --git a/src/h5core/h5t_store_trim.c b/src/h5core/h5t_store_trim.c index 59763b6..88a27e5 100644 --- a/src/h5core/h5t_store_trim.c +++ b/src/h5core/h5t_store_trim.c @@ -32,7 +32,7 @@ alloc_triangles ( (new-cur) * sizeof (t->loc_elems.tris[0]) ); /* alloc mem for global to local ID mapping */ - TRY ( h5priv_alloc_idmap ( f, &t->map_elem_g2l, new ) ); + TRY ( h5priv_alloc_idxmap ( f, &t->map_elem_g2l, new ) ); return H5_SUCCESS; } @@ -140,7 +140,7 @@ refine_triangle ( h5t_fdata_t* const t = f->t; h5_loc_idx_t vertices[6]; // local vertex indices h5_loc_idx_t elem_idx_of_first_child; - h5_triangle_t* el = &t->loc_elems.tris[elem_idx]; + h5_loc_triangle_t* el = &t->loc_elems.tris[elem_idx]; if (el->child_idx >= 0) return h5_error ( @@ -237,6 +237,7 @@ static inline h5_err_t compute_neighbors_of_new_elems ( h5_file_t* const f ) { + h5_debug (f, "%s()", __func__); h5t_fdata_t * const t = f->t; if (t->cur_level < 0) { // or should we consider this as an error? @@ -244,7 +245,7 @@ compute_neighbors_of_new_elems ( } h5_loc_idx_t elem_idx = t->cur_level == 0 ? 0 : t->num_elems[t->cur_level-1]; const h5_loc_idx_t last_idx = t->num_elems[t->cur_level] - 1; - h5_triangle_t *el = &t->loc_elems.tris[elem_idx]; + h5_loc_triangle_t *el = &t->loc_elems.tris[elem_idx]; while (elem_idx <= last_idx) { h5_loc_idx_t face_idx = 0; for (; face_idx < 3; face_idx++) { @@ -262,6 +263,7 @@ static h5_err_t end_store_elems ( h5_file_t* const f ) { + h5_debug (f, "%s()", __func__); h5t_fdata_t* t = f->t; TRY( h5tpriv_update_adjacency_structs (f, t->cur_level) ); diff --git a/src/h5core/h5t_tags.c b/src/h5core/h5t_tags.c index fc07784..88519a5 100644 --- a/src/h5core/h5t_tags.c +++ b/src/h5core/h5t_tags.c @@ -351,14 +351,14 @@ static h5_err_t set_mtag ( h5_file_t *const f, H5T_Tagset *tagset, - const h5_id_t id, + const h5_loc_id_t id, const size_t size, void *val ) { size_t offs[5] = { 14, 0, 4, 10, 14 }; - h5_id_t el_idx = h5tpriv_get_elem_idx ( id ); - h5_id_t eoe_id = h5tpriv_get_face_idx ( id ); - h5_id_t type_id = h5tpriv_get_entity_type ( id ); + h5_loc_idx_t el_idx = h5tpriv_get_elem_idx ( id ); + h5_loc_idx_t eoe_id = h5tpriv_get_face_idx ( id ); + h5_loc_idx_t type_id = h5tpriv_get_entity_type ( id ); if ( tagset->elems[el_idx] == NULL ) { /* alloc new structure to store all tags for this element @@ -427,7 +427,7 @@ h5_err_t h5t_set_mtag_by_name ( h5_file_t *const f, char name[], - const h5_id_t id, + const h5_loc_id_t id, const size_t size, void *val ) { @@ -440,20 +440,20 @@ static h5_err_t get_tag_valp ( h5_file_t* const f, const H5T_Tagset* tagset, - const h5_id_t entity_id, + const h5_loc_id_t entity_id, h5t_tagval_t** const valp ) { #pragma unused f - h5_id_t el_idx = h5tpriv_get_elem_idx ( entity_id ); - h5_id_t subentity_id = h5tpriv_get_face_idx ( entity_id ); - h5_id_t type_id = h5tpriv_get_entity_type ( entity_id ); + h5_loc_idx_t el_idx = h5tpriv_get_elem_idx ( entity_id ); + h5_loc_idx_t face_idx = h5tpriv_get_face_idx ( entity_id ); + h5_loc_idx_t type_id = h5tpriv_get_entity_type ( entity_id ); if ( tagset->elems[el_idx] == NULL ) { return H5_NOK; /* no tags for this element */ } h5t_tagsel_t *tagselem = tagset->elems[el_idx]; size_t offs[5] = { 14, 0, 4, 10, 14 }; - size_t i = offs[type_id]+subentity_id; + size_t i = offs[type_id]+face_idx; if ( tagselem->idx[i] < 0 ) { return H5_NOK; /* no value set for this subentity */ @@ -479,7 +479,7 @@ h5_ssize_t h5t_get_tag ( h5_file_t *const f, const H5T_Tagset *tagset, - const h5_id_t entity_id, + const h5_loc_id_t entity_id, size_t* const dim, void* const vals ) { @@ -510,13 +510,13 @@ h5_ssize_t h5t_get_mtag_by_name ( h5_file_t* const f, const char name[], - const h5_id_t id, + const h5_loc_id_t entity_id, size_t* dim, void* vals ) { H5T_Tagset* tagset; TRY ( h5t_open_mtagset ( f, name, &tagset ) ); - return h5t_get_tag ( f, tagset, id, dim, vals ); + return h5t_get_tag ( f, tagset, entity_id, dim, vals ); } /*! @@ -530,18 +530,18 @@ h5_err_t h5t_remove_mtag ( h5_file_t* const f, H5T_Tagset* tagset, - const h5_id_t id + const h5_loc_id_t entity_id ) { - h5_id_t el_idx = h5tpriv_get_elem_idx ( id ); - h5_id_t subentity_id = h5tpriv_get_face_idx ( id ); - h5_id_t type_id = h5tpriv_get_entity_type ( id ); + h5_loc_idx_t el_idx = h5tpriv_get_elem_idx ( entity_id ); + h5_loc_idx_t face_idx = h5tpriv_get_face_idx ( entity_id ); + h5_loc_idx_t type_id = h5tpriv_get_entity_type ( entity_id ); if ( tagset->elems[el_idx] == NULL ) { return H5_SUCCESS; /* no tags for this element */ } h5t_tagsel_t *tagselem = tagset->elems[el_idx]; size_t offs[5] = { 14, 0, 4, 10, 14 }; - size_t i = offs[type_id]+subentity_id; + size_t i = offs[type_id]+face_idx; if ( tagselem->idx[i] < 0 ) { return H5_SUCCESS; /* no value set for this subentity */ @@ -577,11 +577,11 @@ h5_err_t h5t_remove_mtag_by_name ( h5_file_t *const f, const char name[], - const h5_id_t id + const h5_loc_id_t entity_id ) { H5T_Tagset *tagset; TRY ( h5t_open_mtagset ( f, name, &tagset ) ); - return h5t_remove_mtag ( f, tagset, id ); + return h5t_remove_mtag ( f, tagset, entity_id ); } static hid_t @@ -609,8 +609,8 @@ write_tagset ( alloc memory */ h5t_tag_idx_t *elems; - size_t el_idx; - size_t num_elems = t->num_elems[t->num_levels-1]; + h5_loc_idx_t el_idx; + h5_loc_idx_t num_elems = t->num_elems[t->num_levels-1]; TRY ( ( elems = h5priv_calloc ( f, num_elems+1, sizeof(*elems) ) ) ); @@ -628,26 +628,26 @@ write_tagset ( TRY ( ( vals = h5priv_calloc ( f, max_vals, sizeof(*vals) ) ) ); - h5_id_t tmap[15] = { H5T_ETYPE_VERTEX, H5T_ETYPE_VERTEX, - H5T_ETYPE_VERTEX, H5T_ETYPE_VERTEX, - H5T_ETYPE_EDGE, H5T_ETYPE_EDGE, - H5T_ETYPE_EDGE, H5T_ETYPE_EDGE, - H5T_ETYPE_EDGE, H5T_ETYPE_EDGE, - H5T_ETYPE_TRIANGLE, H5T_ETYPE_TRIANGLE, - H5T_ETYPE_TRIANGLE, H5T_ETYPE_TRIANGLE, - H5T_ETYPE_TET }; + h5_loc_id_t tmap[15] = { H5T_ETYPE_VERTEX, H5T_ETYPE_VERTEX, + H5T_ETYPE_VERTEX, H5T_ETYPE_VERTEX, + H5T_ETYPE_EDGE, H5T_ETYPE_EDGE, + H5T_ETYPE_EDGE, H5T_ETYPE_EDGE, + H5T_ETYPE_EDGE, H5T_ETYPE_EDGE, + H5T_ETYPE_TRIANGLE, H5T_ETYPE_TRIANGLE, + H5T_ETYPE_TRIANGLE, H5T_ETYPE_TRIANGLE, + H5T_ETYPE_TET }; /* sub-entity indices */ - h5_id_t smap[15] = { 0, 1, 2, 3, /* vertices */ - 0, 1, 2, 3, 4, 5, /* edges */ - 0, 1, 2, 3, /* triangles */ - 0 }; /* tetrahedron */ + int smap[15] = { 0, 1, 2, 3, /* vertices */ + 0, 1, 2, 3, 4, 5, /* edges */ + 0, 1, 2, 3, /* triangles */ + 0 }; /* tetrahedron */ /* build data structures in memory */ for ( el_idx = 0; el_idx < num_elems; el_idx++ ) { h5t_tagsel_t *tags_of_elem = tagset->elems[el_idx]; size_t num_subentities = 0; - h5_id_t start_idx_entities = ent_idx; + size_t start_idx_entities = ent_idx; size_t i; for ( i = 0; i < 15; i++ ) { int k = tags_of_elem->idx[i]; @@ -678,10 +678,11 @@ write_tagset ( max_entities*sizeof(*entities) ) ) ); } - h5_id_t type_id = tmap[i]; - h5_id_t sentity_id = smap[i]; + h5_glb_id_t type_id = tmap[i]; + h5_glb_id_t face_idx = smap[i]; + // TODO: map local elem idx to global index entities[ent_idx].eid = h5tpriv_build_id ( - type_id, sentity_id, el_idx ); + type_id, face_idx, el_idx ); entities[ent_idx].idx = val_idx; val_idx += valp->size; ent_idx++; @@ -916,7 +917,7 @@ static h5_ssize_t get_tagset_names_of_entity ( h5_file_t * const f, h5t_tagcontainer_t *ctn, - h5_id_t entity_id, + h5_loc_id_t entity_id, char *names[], h5_size_t dim ) { @@ -945,7 +946,7 @@ get_tagset_names_of_entity ( h5_ssize_t h5t_get_mtagset_names_of_entity ( h5_file_t* const f, - const h5_id_t entity_id, + const h5_loc_id_t entity_id, char *names[], const h5_size_t dim ) { diff --git a/src/h5core/h5t_tags_private.h b/src/h5core/h5t_tags_private.h index 4f03b13..7b2ba6e 100644 --- a/src/h5core/h5t_tags_private.h +++ b/src/h5core/h5t_tags_private.h @@ -79,8 +79,8 @@ typedef struct { typedef struct { - h5_id_t eid ; - h5_id_t idx; + h5_glb_id_t eid ; // global entity id + h5_glb_idx_t idx; // global index } h5t_tag_idx_t; h5_err_t h5tpriv_write_mtags ( h5_file_t *const f ); diff --git a/src/h5core/h5t_types_private.h b/src/h5core/h5t_types_private.h index 01e6922..ba92bd1 100644 --- a/src/h5core/h5t_types_private.h +++ b/src/h5core/h5t_types_private.h @@ -1,50 +1,88 @@ #ifndef __H5T_TYPES_PRIVATE_H #define __H5T_TYPES_PRIVATE_H -typedef struct h5_vertex { - h5_id_t idx; +typedef struct h5_glb_vertex { + h5_glb_idx_t idx; h5_coord3d_t P; -} h5_vertex_t; +} h5_glb_vertex_t; -typedef struct h5_triangle { - h5_id_t idx; - h5_id_t parent_idx; - h5_id_t child_idx; - h5_3id_t vertex_indices; - h5_3id_t neighbor_indices; -} h5_triangle_t; +typedef struct h5_loc_vertex { + h5_loc_idx_t idx; + h5_coord3d_t P; +} h5_loc_vertex_t; -typedef struct h5_tetrahedron { - h5_id_t idx; - h5_id_t parent_idx; - h5_id_t child_idx; - h5_4id_t vertex_indices; - h5_4id_t neighbor_indices; -} h5_tetrahedron_t; -typedef h5_tetrahedron_t h5_tet_t; +typedef struct h5_glb_triangle { + h5_glb_idx_t idx; + h5_glb_idx_t parent_idx; + h5_glb_idx_t child_idx; + h5_glb_idx_t vertex_indices[3]; + h5_glb_idx_t neighbor_indices[3]; +} h5_glb_triangle_t; -typedef struct h5_generic_elem { - h5_id_t idx; - h5_id_t parent_idx; - h5_id_t child_idx; - h5_id_t indices[1]; -} h5_generic_elem_t; +typedef struct h5_loc_triangle { + h5_loc_idx_t idx; + h5_loc_idx_t parent_idx; + h5_loc_idx_t child_idx; + h5_loc_idx_t vertex_indices[3]; + h5_loc_idx_t neighbor_indices[3]; +} h5_loc_triangle_t; +typedef struct h5_glb_tetrahedron { + h5_glb_idx_t idx; + h5_glb_idx_t parent_idx; + h5_glb_idx_t child_idx; + h5_glb_idx_t vertex_indices[4]; + h5_glb_idx_t neighbor_indices[4]; +} h5_glb_tetrahedron_t; +typedef h5_glb_tetrahedron_t h5_glb_tet_t; -typedef union h5_elems { - h5_tet_t *tets; - h5_triangle_t *tris; +typedef struct h5_loc_tetrahedron { + h5_loc_idx_t idx; + h5_loc_idx_t parent_idx; + h5_loc_idx_t child_idx; + h5_loc_idx_t vertex_indices[4]; + h5_loc_idx_t neighbor_indices[4]; +} h5_loc_tetrahedron_t; +typedef h5_loc_tetrahedron_t h5_loc_tet_t; + +typedef struct h5_generic_glb_elem { + h5_glb_idx_t idx; + h5_glb_idx_t parent_idx; + h5_glb_idx_t child_idx; + h5_glb_idx_t indices[1]; +} h5_generic_glb_elem_t; + +typedef struct h5_generic_loc_elem { + h5_loc_idx_t idx; + h5_loc_idx_t parent_idx; + h5_loc_idx_t child_idx; + h5_loc_idx_t indices[1]; +} h5_generic_loc_elem_t; + +typedef union h5_glb_elems { + h5_glb_tet_t *tets; + h5_glb_triangle_t *tris; void *data; -} h5_elems_t; +} h5_glb_elems_t; + +typedef union h5_loc_elems { + h5_loc_tet_t *tets; + h5_loc_triangle_t *tris; + void *data; +} h5_loc_elems_t; /*** type ids' for compound types ***/ typedef struct h5_dtypes { hid_t h5_id_t; /* ID's */ + + hid_t h5_glb_id_t; /* ID's */ + hid_t h5_glb_idx_t; /* ID's */ + hid_t h5_int64_t; /* 64 bit signed integer */ hid_t h5_float64_t; /* 64 bit floating point */ hid_t h5_coord3d_t; /* 3-tuple of 64-bit float */ - hid_t h5_3id_t; /* 3-tuple of ID's */ - hid_t h5_4id_t; /* 4-tuple of ID's */ + hid_t h5_3glb_idx_t; /* 3-tuple of indices */ + hid_t h5_4glb_idx_t; /* 4-tuple of indices */ hid_t h5_vertex_t; /* vertex structure */ hid_t h5_triangle_t; /* triangle structure */ hid_t h5_tet_t; /* tetrahedron structure */ @@ -53,8 +91,8 @@ typedef struct h5_dtypes { typedef struct h5t_adjacencies { struct { - h5_size_t size; - h5_idlist_t *v; + // h5_size_t size; + h5_idlist_t* v; } tv; h5_hashtable_t te_hash; h5_hashtable_t td_hash; @@ -62,69 +100,76 @@ typedef struct h5t_adjacencies { struct h5t_store_methods { h5_err_t (*alloc_elems)(h5_file_t* const, const size_t, const size_t); - h5_id_t (*refine_elem)(h5_file_t* const, const h5_id_t); + h5_loc_idx_t (*refine_elem)(h5_file_t* const, const h5_loc_idx_t); h5_err_t (*end_store_elems)(h5_file_t* const); - h5_id_t (*get_direct_children_of_edge)(h5_file_t* const, const h5_id_t, const h5_id_t, h5_id_t*); + h5_err_t (*get_direct_children_of_edge)( + h5_file_t* const, const h5_loc_idx_t, const h5_loc_idx_t, + h5_loc_id_t*); }; struct h5t_retrieve_methods { - h5_err_t (*init_iterator)(h5_file_t* const, h5t_entity_iterator_t*, const int); + h5_err_t (*init_iterator)( + h5_file_t* const, h5t_entity_iterator_t*, const int); }; struct h5t_access_methods { - h5_generic_elem_t* (*get_loc_elem)( - h5_file_t* const, const h5_id_t); - h5_id_t (*get_loc_elem_parent_idx)( - h5_file_t* const, const h5_id_t); - h5_id_t (*set_loc_elem_parent_idx)( - h5_file_t* const, const h5_id_t, const h5_id_t); - h5_id_t (*get_loc_elem_child_idx)( - h5_file_t* const, const h5_id_t); - h5_id_t (*set_loc_elem_child_idx)( - h5_file_t* const, const h5_id_t, const h5_id_t); + h5_generic_loc_elem_t* (*get_loc_elem)( + h5_file_t* const, const h5_loc_idx_t); + h5_loc_idx_t (*get_loc_elem_parent_idx)( + h5_file_t* const, const h5_loc_idx_t); + h5_loc_idx_t (*set_loc_elem_parent_idx)( + h5_file_t* const, const h5_loc_idx_t, const h5_loc_idx_t); + h5_loc_id_t (*get_loc_elem_child_idx)( + h5_file_t* const, const h5_loc_idx_t); + h5_loc_id_t (*set_loc_elem_child_idx)( + h5_file_t* const, const h5_loc_idx_t, const h5_loc_idx_t); h5_id_t (*get_loc_elem_level_idx)( - h5_file_t* const, const h5_id_t); + h5_file_t* const, const h5_loc_idx_t); h5_id_t (*set_loc_elem_level_idx)( - h5_file_t* const, const h5_id_t, const h5_id_t); - h5_id_t* (*get_loc_elem_vertex_indices)( - h5_file_t* const, const h5_id_t); - h5_id_t (*get_loc_elem_vertex_idx)( - h5_file_t* const, const h5_id_t, const h5_id_t); - h5_id_t (*set_loc_elem_vertex_idx)( - h5_file_t* const, const h5_id_t, const h5_id_t, const h5_id_t); - h5_id_t* (*get_loc_elem_neighbor_indices)( - h5_file_t* const, const h5_id_t); - h5_id_t (*get_loc_elem_neighbor_idx)( - h5_file_t* const, const h5_id_t, const h5_id_t); - h5_id_t (*set_loc_elem_neighbor_idx)( - h5_file_t* const, const h5_id_t, const h5_id_t, const h5_id_t); + h5_file_t* const, const h5_loc_idx_t, const h5_id_t); + h5_loc_idx_t* (*get_loc_elem_vertex_indices)( + h5_file_t* const, const h5_loc_idx_t); + h5_loc_idx_t (*get_loc_elem_vertex_idx)( + h5_file_t* const, const h5_loc_idx_t, const h5_loc_idx_t); + h5_loc_idx_t (*set_loc_elem_vertex_idx)( + h5_file_t* const, + const h5_loc_idx_t, const h5_loc_idx_t, const h5_loc_idx_t); + h5_loc_idx_t* (*get_loc_elem_neighbor_indices)( + h5_file_t* const, const h5_loc_idx_t); + h5_loc_idx_t (*get_loc_elem_neighbor_idx)( + h5_file_t* const, const h5_loc_idx_t, const h5_loc_idx_t); + h5_loc_idx_t (*set_loc_elem_neighbor_idx)( + h5_file_t* const, + const h5_loc_idx_t, const h5_loc_idx_t, const h5_loc_idx_t); - h5_generic_elem_t* (*get_glb_elem)( - h5_file_t* const, const h5_id_t); - h5_id_t (*get_glb_elem_idx)( - h5_file_t* const, const h5_id_t); - h5_id_t (*set_glb_elem_idx)( - h5_file_t* const, const h5_id_t, const h5_id_t); - h5_id_t (*get_glb_elem_parent_idx)( - h5_file_t* const, const h5_id_t); - h5_id_t (*set_glb_elem_parent_idx)( - h5_file_t* const, const h5_id_t, const h5_id_t); - h5_id_t (*get_glb_elem_child_idx)( - h5_file_t* const, const h5_id_t); - h5_id_t (*set_glb_elem_child_idx)( - h5_file_t* const, const h5_id_t, const h5_id_t); - h5_id_t* (*get_glb_elem_vertex_indices)( - h5_file_t* const, const h5_id_t); - h5_id_t (*get_glb_elem_vertex_idx)( - h5_file_t* const, const h5_id_t, const h5_id_t); - h5_id_t (*set_glb_elem_vertex_idx)( - h5_file_t* const, const h5_id_t, const h5_id_t, const h5_id_t); - h5_id_t* (*get_glb_elem_neighbor_indices)( - h5_file_t* const, const h5_id_t); - h5_id_t (*get_glb_elem_neighbor_idx)( - h5_file_t* const, const h5_id_t, const h5_id_t); - h5_id_t (*set_glb_elem_neighbor_idx)( - h5_file_t* const, const h5_id_t, const h5_id_t, const h5_id_t); + h5_generic_glb_elem_t* (*get_glb_elem)( + h5_file_t* const, const h5_loc_idx_t); + h5_glb_id_t (*get_glb_elem_idx)( + h5_file_t* const, const h5_loc_id_t); + h5_glb_id_t (*set_glb_elem_idx)( + h5_file_t* const, const h5_loc_idx_t, const h5_glb_idx_t); + h5_glb_idx_t (*get_glb_elem_parent_idx)( + h5_file_t* const, const h5_loc_id_t); + h5_glb_idx_t (*set_glb_elem_parent_idx)( + h5_file_t* const, const h5_loc_idx_t, const h5_glb_idx_t); + h5_glb_idx_t (*get_glb_elem_child_idx)( + h5_file_t* const, const h5_loc_idx_t); + h5_glb_idx_t (*set_glb_elem_child_idx)( + h5_file_t* const, const h5_loc_idx_t, const h5_glb_idx_t); + h5_glb_idx_t* (*get_glb_elem_vertex_indices)( + h5_file_t* const, const h5_loc_idx_t); + h5_glb_idx_t (*get_glb_elem_vertex_idx)( + h5_file_t* const, const h5_loc_idx_t, const h5_loc_idx_t); + h5_glb_id_t (*set_glb_elem_vertex_idx)( + h5_file_t* const, + const h5_loc_idx_t, const h5_loc_idx_t, const h5_glb_idx_t); + h5_glb_idx_t* (*get_glb_elem_neighbor_indices)( + h5_file_t* const, const h5_loc_idx_t); + h5_glb_idx_t (*get_glb_elem_neighbor_idx)( + h5_file_t* const, const h5_loc_idx_t, const h5_loc_idx_t); + h5_glb_idx_t (*set_glb_elem_neighbor_idx)( + h5_file_t* const, + const h5_loc_idx_t, const h5_loc_idx_t, const h5_glb_idx_t); }; struct h5t_read_methods { @@ -135,7 +180,8 @@ struct h5t_adjacency_methods { h5_err_t (*update_internal_structs)(h5_file_t* const, h5_id_t); h5_err_t (*release_internal_structs)(h5_file_t* const); h5_err_t (*get_adjacencies)( - h5_file_t * const, const h5_id_t, const h5_int32_t, h5_idlist_t**); + h5_file_t * const, + const h5_loc_id_t, const h5_int32_t, h5_idlist_t**); }; typedef struct h5t_methods { @@ -173,22 +219,22 @@ typedef struct h5t_fdata { struct h5t_methods methods; /*** vertices ***/ - h5_vertex_t *vertices; + h5_loc_vertex_t *vertices; h5_size_t *num_vertices; - h5_idmap_t map_vertex_g2l; /* map global to local idx */ + h5_idxmap_t map_vertex_g2l; /* map global to local idx */ h5_idlist_t sorted_lvertices; - h5_id_t last_stored_vid; + h5_loc_idx_t last_stored_vid; h5_dsinfo_t dsinfo_vertices; h5_dsinfo_t dsinfo_num_vertices; /*** Elements ***/ - h5_elems_t glb_elems; - h5_elems_t loc_elems; + h5_glb_elems_t glb_elems; + h5_loc_elems_t loc_elems; h5_size_t *num_elems; h5_size_t *num_elems_on_level; - h5_idmap_t map_elem_g2l; /* map global id to local id */ + h5_idxmap_t map_elem_g2l; /* map global id to local id */ /* array with geometrically sorted local entitiy ids @@ -198,7 +244,7 @@ typedef struct h5t_fdata { */ h5_idlist_t sorted_elems[H5_MAX_VERTICES_PER_ELEM]; - h5_id_t last_stored_eid; + h5_loc_idx_t last_stored_eid; h5_dsinfo_t dsinfo_elems; h5_dsinfo_t dsinfo_num_elems; h5_dsinfo_t dsinfo_num_elems_on_level; diff --git a/src/include/H5Fed_adjacency.h b/src/include/H5Fed_adjacency.h index 42873b2..b0eebe7 100644 --- a/src/include/H5Fed_adjacency.h +++ b/src/include/H5Fed_adjacency.h @@ -4,7 +4,7 @@ h5_err_t H5FedGetAdjacencies ( h5_file_t* const f, - const h5_id_t entity_id, + const h5_loc_id_t entity_id, const h5_int32_t dim, h5_idlist_t** list ); diff --git a/src/include/H5Fed_retrieve.h b/src/include/H5Fed_retrieve.h index 0d457a9..3901ce2 100644 --- a/src/include/H5Fed_retrieve.h +++ b/src/include/H5Fed_retrieve.h @@ -20,7 +20,7 @@ H5FedBeginTraverseEntities ( h5_file_t* const f, int codim ); -h5_id_t +h5_loc_id_t H5FedTraverseEntities ( h5_file_t* const f, h5t_entity_iterator_t* iter @@ -33,41 +33,41 @@ H5FedEndTraverseEntities ( h5_err_t H5FedGetVertexCoordsByIndex ( h5_file_t* const f, - h5_id_t vertex_index, + h5_loc_idx_t vertex_index, h5_float64_t P[3] ); h5_err_t H5FedGetVertexCoordsByID ( h5_file_t* const f, - h5_id_t vertex_id, + h5_loc_id_t vertex_id, h5_float64_t P[3] ); h5_err_t H5FedGetVertexIndicesOfEdge ( h5_file_t* const f, - h5_id_t entity_id, - h5_id_t* const vertex_indices + h5_loc_id_t entity_id, + h5_loc_idx_t* const vertex_indices ); h5_err_t H5FedGetVertexIndicesOfTriangle ( h5_file_t* const f, - h5_id_t entity_id, - h5_id_t* const vertex_indices + h5_loc_id_t entity_id, + h5_loc_idx_t* const vertex_indices ); h5_err_t H5FedGetVertexIndicesOfTet ( h5_file_t* const f, - h5_id_t entity_id, - h5_id_t* const vertex_indices + h5_loc_id_t entity_id, + h5_loc_idx_t* const vertex_indices ); h5_err_t H5FedGetVertexIndicesOfEntity ( h5_file_t* const f, - h5_id_t entity_id, - h5_id_t* const vertex_indices + h5_loc_id_t entity_id, + h5_loc_idx_t* const vertex_indices ); #endif diff --git a/src/include/H5Fed_store.h b/src/include/H5Fed_store.h index 1a33bf3..21b2c96 100644 --- a/src/include/H5Fed_store.h +++ b/src/include/H5Fed_store.h @@ -36,10 +36,10 @@ H5FedBeginStoreVertices ( const h5_size_t num ); -h5_id_t +h5_loc_idx_t H5FedStoreVertex ( h5_file_t * const f, - const h5_id_t id, + const h5_glb_idx_t id, const h5_float64_t P[3] ); @@ -55,10 +55,10 @@ H5FedBeginStoreElements ( ); -h5_id_t +h5_err_t H5FedStoreElement ( h5_file_t * const f, - const h5_id_t local_vids[] + const h5_loc_idx_t vertex_indices[] ); h5_err_t @@ -71,10 +71,10 @@ H5FedBeginRefineElements ( h5_file_t * const f ); -h5_id_t +h5_loc_idx_t H5FedRefineElement ( h5_file_t * const f, - const h5_id_t eid + const h5_loc_idx_t elem_idx ); h5_err_t @@ -82,11 +82,4 @@ H5FedEndRefineElements ( h5_file_t * const f ); -h5_err_t -H5FedMarkRefineElement ( - h5_file_t * const f, - const h5_id_t eid - ); - - #endif diff --git a/src/include/H5Fed_tags.h b/src/include/H5Fed_tags.h index aa880aa..7f502dd 100644 --- a/src/include/H5Fed_tags.h +++ b/src/include/H5Fed_tags.h @@ -1,40 +1,47 @@ #ifndef __H5FED_TAGS_H #define __H5FED_TAGS_H -h5_err_t H5FedAddMTagset ( h5_file_t * const f, - char * name, - h5_id_t type ); -h5_err_t H5FedRemoveMTagset ( h5_file_t *const f, - char name[] ); -h5_size_t H5FedGetMTagsets ( h5_file_t *const f, - char **names[] ); -h5_id_t H5FedGetTypeOfMTagset ( h5_file_t *const f, - char name[] ); -h5_err_t H5FedSetMTag ( h5_file_t *const f, - char name[], h5_id_t id, - const size_t dims, void *val ); -h5_err_t H5FedSetMTagToVertex ( h5_file_t *const f, - char name[], h5_id_t id, - const size_t dims, void *val ); -h5_err_t H5FedSetMTagToEdge ( h5_file_t *const f, - char name[], h5_id_t id, - const size_t dims, void *val ); -h5_err_t H5FedSetMTagToTriangle ( h5_file_t *const f, - char name[], h5_id_t id, - const size_t dims, void *val ); -h5_err_t H5FedSetMTagToTet ( h5_file_t *const f, - char name[], h5_id_t id, - const size_t dims, void *val ); +h5_err_t +H5FedAddMTagset ( + h5_file_t* const f, + char* name, + h5_id_t type + ); +h5_err_t +H5FedRemoveMTagset ( + h5_file_t* const f, + char name[] + ); +h5_size_t +H5FedGetMTagsets ( + h5_file_t* const f, + char** names[] + ); +h5_id_t +H5FedGetTypeOfMTagset ( + h5_file_t* const f, + char name[] + ); +h5_err_t +H5FedSetMTag ( + h5_file_t* const f, + char name[], + h5_loc_id_t entity_id, + const size_t dims, + void* val + ); +h5_err_t +H5FedGetMTag ( + h5_file_t* const f, + const char name[], + const h5_loc_id_t id, + size_t* dims, + void* val + ); +h5_err_t +H5FedRemoveMTag ( + h5_file_t* const f, + const char name[], + const h5_loc_id_t id + ); -h5_err_t H5FedGetMTag ( h5_file_t *const f, - const char name[], const h5_id_t id, - size_t *dims, void *val ); -h5_err_t H5FedRemoveMTag ( h5_file_t *const f, - const char name[], const h5_id_t id ); - -/* - Get descriptor for a tagset - Get tag value by descriptor - get size of value - Get tagset names for specific entity -*/ #endif diff --git a/src/include/h5core/h5_core.h b/src/include/h5core/h5_core.h index 15aea82..691575a 100644 --- a/src/include/h5core/h5_core.h +++ b/src/include/h5core/h5_core.h @@ -5,7 +5,6 @@ #include "h5_errno.h" #include "h5_attribs.h" -#include "h5_errorhandling.h" #include "h5_hdf5.h" #include "h5_maps.h" #include "h5_openclose.h" @@ -20,4 +19,6 @@ #include "h5t_core.h" +#include "h5_errorhandling.h" + #endif diff --git a/src/include/h5core/h5_errorhandling.h b/src/include/h5core/h5_errorhandling.h index 210d660..74d7e0f 100644 --- a/src/include/h5core/h5_errorhandling.h +++ b/src/include/h5core/h5_errorhandling.h @@ -1,7 +1,8 @@ #ifndef __H5_ERRORHANDLING_H #define __H5_ERRORHANDLING_H -#define SET_FNAME( f, fname ) h5_set_funcname( f, fname ); +extern h5_int32_t h5priv_debug_level; + #define CHECK_FILEHANDLE( f ) \ if ( h5_check_filehandle ( f ) != H5_SUCCESS ) \ return h5_get_errno( f ); @@ -88,6 +89,21 @@ h5_abort_errorhandler ( va_list ap ); +void +h5priv_vprintf ( + FILE* f, + const char* prefix, + const char* __funcname, + const char* fmt, + va_list ap + ); + +const char * +h5_get_funcname ( + const h5_file_t * const f + ); + + h5_err_t h5_error ( h5_file_t * const f, @@ -125,14 +141,12 @@ __attribute__ ((format (printf, 2, 3))) #endif ; -void -h5_vinfo ( - const h5_file_t * const f, - const char *fmt, - va_list ap - ); +/*! + \ingroup h5_core_errorhandling -void + Print an informational message to \c stdout. +*/ +static inline void h5_info ( const h5_file_t * const f, const char *fmt, @@ -142,15 +156,32 @@ h5_info ( __attribute__ ((format (printf, 2, 3))) #endif ; +static inline void +h5_info ( + const h5_file_t* const f, + const char* fmt, + ... + ) { + if (h5priv_debug_level >= 3) { + va_list ap; + va_start (ap, fmt); + h5priv_vprintf (stdout, "I", h5_get_funcname(f), fmt, ap); + va_end (ap); + } +} -void -h5_vdebug ( - const h5_file_t * const f, - const char *fmt, - va_list ap - ); +/*! + \ingroup h5_core_errorhandling -void + Print a debug message to \c stdout. +*/ +#if defined(HAVE__VA_ARGS__) +#define h5_debug(f, ...) \ + if (h5priv_debug_level >= 4) { \ + h5priv_vprintf (stdout, "D", h5_get_funcname(f), __VA_ARGS__); \ + } +#else +static inline void h5_debug ( const h5_file_t * const f, const char *fmt, @@ -159,7 +190,22 @@ h5_debug ( #ifdef __GNUC__ __attribute__ ((format (printf, 2, 3))) #endif -; + ; + +static inline void +h5_debug ( + const h5_file_t * const f, + const char *fmt, + ... + ) { + if (h5priv_debug_level >= 4) { + va_list ap; + va_start (ap, fmt); + h5priv_vprintf (stdout, "D", h5_get_funcname(f), fmt, ap); + va_end (ap); + } +} +#endif void h5_set_funcname ( @@ -167,9 +213,13 @@ h5_set_funcname ( const char * const fname ); -const char * -h5_get_funcname ( - const h5_file_t * const f - ); +static inline void +SET_FNAME ( + h5_file_t* const f, + const char* const fname + ) { + h5_set_funcname( f, fname ); + h5_debug (f, "%s", " "); // just print the function name +} #endif diff --git a/src/include/h5core/h5_maps.h b/src/include/h5core/h5_maps.h index 79641bf..7603ee4 100644 --- a/src/include/h5core/h5_maps.h +++ b/src/include/h5core/h5_maps.h @@ -1,103 +1,4 @@ #ifndef __H5_MAPS_H #define __H5_MAPS_H -h5_err_t -h5priv_alloc_idlist ( - h5_file_t * const f, - h5_idlist_t **list, - const h5_size_t size - ); - -h5_err_t -h5priv_free_idlist ( - h5_file_t * const f, - h5_idlist_t **list - ); - -h5_err_t -h5priv_alloc_idlist_items ( - h5_file_t * const f, - h5_idlist_t *list, - const h5_size_t size - ); - -h5_err_t -h5priv_free_idlist_items ( - h5_file_t * const f, - h5_idlist_t *list - ); - -h5_err_t -h5priv_append_to_idlist ( - h5_file_t * const f, - h5_idlist_t *list, - h5_id_t id - ); - -int -h5priv_cmp_ids_by_eid ( - const void *_id1, - const void *_id2 - ); - -int -h5priv_cmp_ids ( - const void *_id1, - const void *_id2 - ); - -h5_err_t -h5priv_sort_idlist_by_eid ( - h5_file_t * const f, - h5_idlist_t *list - ); - -h5_id_t -h5priv_find_idlist ( - h5_file_t * const f, - h5_idlist_t *list, - h5_id_t item - ); - -h5_id_t -h5priv_insert_idlist ( - h5_file_t * const f, - h5_idlist_t *list, - h5_id_t item, - h5_id_t idx - ); - -h5_id_t -h5priv_search_idlist ( - h5_file_t * const f, - h5_idlist_t *list, - h5_id_t item - ); - -h5_err_t -h5priv_alloc_idmap ( - h5_file_t * const f, - h5_idmap_t *map, - const h5_size_t size - ); - -h5_err_t -h5priv_insert_idmap ( - h5_file_t * const f, - h5_idmap_t *map, - h5_id_t global_id, - h5_id_t local_id - ); - -h5_id_t -h5priv_search_idmap ( - h5_idmap_t *map, - h5_id_t value - ); - -h5_err_t -h5priv_sort_idmap ( - h5_idmap_t *map - ); - #endif diff --git a/src/include/h5core/h5_types.h b/src/include/h5core/h5_types.h index 1cac714..d7da223 100644 --- a/src/include/h5core/h5_types.h +++ b/src/include/h5core/h5_types.h @@ -79,8 +79,8 @@ typedef struct h5_idlist { h5_id_t *items; } h5_idlist_t; -struct h5_idmap; -typedef struct h5_idmap h5_idmap_t; +struct h5_idxmap; +typedef struct h5_idxmap h5_idxmap_t; enum h5_oid { diff --git a/src/include/h5core/h5t_adjacencies.h b/src/include/h5core/h5t_adjacencies.h index 9a67749..e8e20ac 100644 --- a/src/include/h5core/h5t_adjacencies.h +++ b/src/include/h5core/h5t_adjacencies.h @@ -4,7 +4,7 @@ h5_err_t h5t_get_adjacencies ( h5_file_t * const f, - const h5_id_t entity_id, + const h5_loc_id_t entity_id, const h5_int32_t dim, h5_idlist_t **list ); diff --git a/src/include/h5core/h5t_core.h b/src/include/h5core/h5t_core.h index 26caf71..a6e05ef 100644 --- a/src/include/h5core/h5t_core.h +++ b/src/include/h5core/h5t_core.h @@ -49,7 +49,7 @@ #define H5T_ETYPE_TRIANGLE ((h5_id_t)3) #define H5T_ETYPE_TET ((h5_id_t)4) -#define h5tpriv_set_entity_type( type, elem_idx ) \ +#define h5tpriv_set_entity_type( type, elem_idx ) \ ( \ ((h5_id_t)(type) << (sizeof(h5_id_t)*8-4)) | \ ((h5_id_t)(elem_idx)) \ @@ -58,7 +58,6 @@ ((entity_id & H5T_ETYPE_MASK) >> (sizeof(h5_id_t)*8-4)) - #define h5tpriv_build_id( type, comp_idx, elem_idx ) \ ( \ ((h5_id_t)(type) << (sizeof(h5_id_t)*8-4)) | \ diff --git a/src/include/h5core/h5t_map.h b/src/include/h5core/h5t_map.h index a777280..674a0af 100644 --- a/src/include/h5core/h5t_map.h +++ b/src/include/h5core/h5t_map.h @@ -4,106 +4,88 @@ h5_id_t h5t_map_global_vertex_idx2local ( h5_file_t * const f, - h5_id_t global_idx + h5_glb_idx_t glb_idx ); h5_err_t h5t_map_global_vertex_indices2local ( h5_file_t* f, - const h5_id_t* const glb_indices, - const h5_id_t size, - h5_id_t* const loc_indices + const h5_glb_id_t* const glb_indices, + const h5_size_t size, + h5_loc_idx_t* const loc_indices ); -h5_id_t -h5t_map_local_vid2global ( - h5_file_t *f, - h5_id_t local_vid - ); - -h5_id_t -h5t_map_global_elem_idx2local ( +h5_loc_idx_t +h5t_map_glb_elem_idx2loc ( h5_file_t * const f, - const h5_id_t global_idx + const h5_glb_idx_t glb_idx ); -h5_id_t -h5t_map_global_elem_indices2local ( +h5_err_t +h5t_map_glb_elem_indices2loc ( h5_file_t * const f, - const h5_id_t* glb_indices, - const h5_id_t size, - h5_id_t* loc_indices - ); - -h5_id_t -h5tpriv_get_local_vid ( - h5_file_t * const f, - h5_float64_t P[3] - ); - -h5_id_t -h5t_get_local_eid ( - h5_file_t *f, - h5_id_t * const local_vids + const h5_glb_idx_t* glb_indices, + const h5_size_t size, + h5_loc_idx_t* loc_indices ); h5_err_t h5t_get_vertex_index_of_vertex ( h5_file_t* const f, - const h5_id_t entity_id, + const h5_loc_id_t entity_id, h5_id_t* vertex_index ); h5_err_t h5t_get_vertex_index_of_vertex2 ( h5_file_t* const f, - const h5_id_t face_idx, - const h5_id_t elem_idx, - h5_id_t* vertex_indices + const h5_loc_idx_t face_idx, + const h5_loc_idx_t elem_idx, + h5_loc_idx_t* vertex_indices ); h5_err_t h5t_get_vertex_indices_of_edge ( h5_file_t* const f, - const h5_id_t entity_id, - h5_id_t *vertex_indices + const h5_loc_id_t entity_id, + h5_loc_idx_t *vertex_indices ); h5_err_t h5t_get_vertex_indices_of_edge2 ( h5_file_t* const f, - const h5_id_t face_idx, - const h5_id_t elem_id, - h5_id_t* vertex_indices + const h5_loc_idx_t face_idx, + const h5_loc_idx_t elem_id, + h5_loc_idx_t* vertex_indices ); h5_err_t h5t_get_vertex_indices_of_triangle ( h5_file_t* const f, - const h5_id_t entity_id, - h5_id_t* vertex_indices + const h5_loc_id_t entity_id, + h5_loc_idx_t* vertex_indices ); h5_err_t h5t_get_vertex_indices_of_triangle2 ( h5_file_t* const f, - const h5_id_t face_idx, - const h5_id_t elem_idx, - h5_id_t* vertex_indices + const h5_loc_idx_t face_idx, + const h5_loc_idx_t elem_idx, + h5_loc_idx_t* vertex_indices ); h5_err_t h5t_get_vertex_indices_of_tet ( h5_file_t* const f, - const h5_id_t entity_id, - h5_id_t *vertex_indices + const h5_loc_id_t entity_id, + h5_loc_idx_t *vertex_indices ); h5_err_t h5t_get_vertex_indices_of_entity ( h5_file_t * const f, - const h5_id_t entity_id, - h5_id_t *vertex_indices + const h5_loc_id_t entity_id, + h5_loc_idx_t *vertex_indices ); #endif diff --git a/src/include/h5core/h5t_openclose.h b/src/include/h5core/h5t_openclose.h index 24a96d3..581a84e 100644 --- a/src/include/h5core/h5t_openclose.h +++ b/src/include/h5core/h5t_openclose.h @@ -1,29 +1,17 @@ #ifndef __H5T_OPENCLOSE_H #define __H5T_OPENCLOSE_H - -h5_err_t h5t_open_mesh ( h5_file_t * const f, const h5_id_t id, - const h5_oid_t type ); -h5_err_t h5t_set_level ( h5_file_t * const f, const h5_id_t id ); -h5_err_t h5t_close_mesh ( h5_file_t * const f ); - -#if 0 -h5_err_t h5tpriv_open_file ( h5_file_t * const f ); -h5_err_t h5tpriv_close_file ( h5_file_t * const f ); -h5_err_t h5tpriv_open_topo_group ( h5_file_t * const f ); -h5_err_t h5tpriv_open_meshes_group ( h5_file_t * const f ); -h5_err_t h5tpriv_open_mesh_group ( h5_file_t * const f ); -h5_err_t h5tpriv_close_step ( h5_file_t * const f ); - -h5_err_t h5tpriv_init_fdata ( h5_file_t * const f ); -h5_err_t h5tpriv_init_step ( h5_file_t * const f ); - -h5_err_t h5tpriv_alloc_num_vertices ( h5_file_t * const f, - const h5_size_t num_vertices ); -h5_err_t h5tpriv_alloc_tris ( h5_file_t * const f, const size_t cur, - const size_t new_size ); -h5_err_t h5tpriv_alloc_tets ( h5_file_t * const f, const size_t cur, - const size_t new_size ); +h5_err_t h5t_open_mesh ( + h5_file_t * const f, + const h5_id_t id, + const h5_oid_t type + ); +h5_err_t h5t_set_level ( + h5_file_t * const f, + const h5_id_t id + ); +h5_err_t h5t_close_mesh ( + h5_file_t * const f + ); #endif -#endif diff --git a/src/include/h5core/h5t_retrieve.h b/src/include/h5core/h5t_retrieve.h index 5f882fc..eeb2ae9 100644 --- a/src/include/h5core/h5t_retrieve.h +++ b/src/include/h5core/h5t_retrieve.h @@ -48,14 +48,14 @@ h5t_end_iterate_entities ( h5_err_t h5t_get_vertex_coords_by_index ( h5_file_t* const f, - h5_id_t vertex_index, + h5_loc_idx_t vertex_idx, h5_float64_t P[3] ); h5_err_t h5t_get_vertex_coords_by_id ( h5_file_t* const f, - h5_id_t vertex_id, + h5_loc_id_t vertex_id, h5_float64_t P[3] ); #endif diff --git a/src/include/h5core/h5t_storemesh.h b/src/include/h5core/h5t_storemesh.h index 149d555..3257b46 100644 --- a/src/include/h5core/h5t_storemesh.h +++ b/src/include/h5core/h5t_storemesh.h @@ -21,7 +21,7 @@ h5t_begin_store_vertices ( h5_id_t h5t_store_vertex ( h5_file_t * const f, - const h5_id_t mesher_vid, + const h5_glb_id_t glb_id, const h5_float64_t P[3] ); @@ -36,11 +36,11 @@ h5t_begin_store_elems ( const h5_size_t num ); -h5_id_t +h5_loc_idx_t h5t_store_elem ( h5_file_t * const f, - const h5_id_t local_parent_eid, - const h5_id_t local_vids[] + const h5_loc_idx_t parent_idx, + const h5_loc_idx_t* vertex_indices ); h5_err_t @@ -66,7 +66,7 @@ h5t_end_refine_elems ( h5_err_t h5t_mark_entity ( h5_file_t* const f, - const h5_id_t entity_id + const h5_loc_id_t entity_id ); h5_err_t diff --git a/src/include/h5core/h5t_tags.h b/src/include/h5core/h5t_tags.h index e31f28c..2380e06 100644 --- a/src/include/h5core/h5t_tags.h +++ b/src/include/h5core/h5t_tags.h @@ -3,34 +3,73 @@ typedef struct h5t_tagset H5T_Tagset; -h5_err_t h5t_add_mtagset ( h5_file_t* const f, char name[], h5_id_t id ); -h5_err_t h5t_remove_mtagset ( h5_file_t* const f, const char name[] ); -h5_err_t h5t_open_mtagset ( h5_file_t* const f, const char *name, - H5T_Tagset** retval ); -h5_ssize_t h5t_get_num_mtagsets ( h5_file_t* const f ); -h5_ssize_t h5t_get_mtagsets ( h5_file_t* const f, char** names[] ); -h5_err_t h5t_get_mtagset_info ( h5_file_t* const f, const h5_id_t idx, - char** names, h5_id_t* type ); -h5_id_t h5t_get_mtagset_type_by_name ( h5_file_t* const f, char name[] ); +h5_err_t +h5t_add_mtagset ( + h5_file_t* const f, + char name[], + h5_id_t id + ); +h5_err_t +h5t_remove_mtagset ( + h5_file_t* const f, + const char name[] + ); +h5_err_t h5t_open_mtagset ( + h5_file_t* const f, + const char *name, + H5T_Tagset** retval + ); +h5_ssize_t +h5t_get_num_mtagsets ( + h5_file_t* const f + ); +h5_ssize_t +h5t_get_mtagsets ( + h5_file_t* const f, + char** names[] + ); +h5_err_t +h5t_get_mtagset_info ( + h5_file_t* const f, + const h5_id_t idx, + char** names, + h5_id_t* type + ); +h5_id_t +h5t_get_mtagset_type_by_name ( + h5_file_t* const f, + char name[] + ); -h5_err_t h5t_set_mtag_by_name ( h5_file_t* const f, char name[], const h5_id_t id, - const size_t dim, void* value ); +h5_err_t +h5t_set_mtag_by_name ( + h5_file_t* const f, + char name[], + const h5_loc_id_t entity_id, + const size_t dim, + void* value + ); -h5_err_t h5t_get_mtag_by_name ( h5_file_t* const f, const char name[], - const h5_id_t id, size_t* dim, void* vals ); +h5_err_t +h5t_get_mtag_by_name ( + h5_file_t* const f, + const char name[], + const h5_loc_id_t entity_id, + size_t* dim, + void* vals ); h5_err_t h5t_remove_mtag_by_name ( h5_file_t* const f, const char name[], - const h5_id_t id + const h5_loc_id_t entity_id ); h5_ssize_t h5t_get_tag ( h5_file_t *const f, const H5T_Tagset *tagset, - const h5_id_t entity_id, + const h5_loc_id_t entity_id, size_t* const dim, void* const vals ); @@ -39,13 +78,13 @@ h5_err_t h5t_remove_mtag ( h5_file_t* const f, H5T_Tagset* tagset, - const h5_id_t id + const h5_loc_id_t entity_id ); h5_ssize_t h5t_get_mtagset_names_of_entity ( h5_file_t* const f, - const h5_id_t entity_id, + const h5_loc_id_t entity_id, char *names[], const h5_size_t dim );