From ec8258e902082ee60807d83986bd472eb2843e86 Mon Sep 17 00:00:00 2001 From: Achim Gsell Date: Thu, 16 Dec 2010 14:25:15 +0000 Subject: [PATCH] 'num_levels', 'cur_level' and related functions refactored to 'num_leaf_levels' etc --- src/h5core/h5t_adjacencies_tetm.c | 28 +++++----- src/h5core/h5t_adjacencies_trim.c | 18 +++---- src/h5core/h5t_hsearch.c | 9 ++-- src/h5core/h5t_inquiry.c | 14 ++--- src/h5core/h5t_map.c | 12 ++--- src/h5core/h5t_openclose.c | 12 ++--- src/h5core/h5t_readwrite.c | 24 ++++----- src/h5core/h5t_readwrite_tetm.c | 4 +- src/h5core/h5t_readwrite_trim.c | 4 +- src/h5core/h5t_retrieve.c | 6 +-- src/h5core/h5t_retrieve_private.h | 15 ++---- src/h5core/h5t_store.c | 88 +++++++++++++++---------------- src/h5core/h5t_store_tetm.c | 12 ++--- src/h5core/h5t_store_trim.c | 12 ++--- src/h5core/h5t_tags.c | 20 +++---- src/h5core/h5t_types_private.h | 4 +- 16 files changed, 136 insertions(+), 146 deletions(-) diff --git a/src/h5core/h5t_adjacencies_tetm.c b/src/h5core/h5t_adjacencies_tetm.c index ddf9482..435f5ab 100644 --- a/src/h5core/h5t_adjacencies_tetm.c +++ b/src/h5core/h5t_adjacencies_tetm.c @@ -23,7 +23,7 @@ alloc_tv ( h5_file_t* const f ) { h5t_fdata_t* t = f->t; - h5_loc_idx_t num_vertices = t->num_vertices[t->num_levels-1]; + h5_loc_idx_t num_vertices = t->num_vertices[t->num_leaf_levels-1]; h5t_adjacencies_t* adj = &t->adjacencies; // allocate one ID list per vertex @@ -41,7 +41,7 @@ release_tv ( if (adj->tv.v == NULL) return H5_SUCCESS; h5_loc_idx_t idx = 0; - h5_loc_idx_t last = t->num_vertices[t->num_levels-1]; + h5_loc_idx_t last = t->num_vertices[t->num_leaf_levels-1]; for (; idx < last; idx++) { TRY( h5priv_free_idlist_items (f, &adj->tv.v[idx]) ); } @@ -64,7 +64,7 @@ compute_elems_of_vertices ( /* 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_loc_idx_t last = t->num_elems[t->num_leaf_levels-1]; h5_loc_tet_t *el = &t->loc_elems.tets[idx]; for (;idx < last; idx++, el++) { int face_idx; @@ -85,7 +85,7 @@ release_te ( h5_file_t* const f ) { UNUSED_ARGUMENT (f); - // @@@ TBD @@@ + // TODO return H5_SUCCESS; } @@ -99,7 +99,7 @@ compute_elems_of_edges ( ) { h5t_fdata_t *t = f->t; 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_loc_idx_t num_elems = t->num_elems[t->num_leaf_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++) { @@ -118,7 +118,7 @@ release_td ( h5_file_t* const f ) { UNUSED_ARGUMENT (f); - // @@@ TBD @@@ + // TODO return H5_SUCCESS; } @@ -129,7 +129,7 @@ compute_elems_of_triangles ( ) { h5t_fdata_t* t = f->t; 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_loc_idx_t num_elems = t->num_elems[t->num_leaf_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++) { @@ -164,7 +164,7 @@ compute_children_of_edge ( 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 ) { + if (h5tpriv_is_leaf_elem (f, (h5_generic_loc_elem_t*)tet) == H5_OK ) { TRY( h5priv_append_to_idlist (f, children, *edge) ); } else { h5_loc_id_t kids[2]; @@ -204,7 +204,7 @@ compute_sections_of_edge ( 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) { + if (! h5tpriv_is_leaf_elem (f, tet) == H5_OK) { refined = 1; h5_loc_id_t kids[2]; TRY( h5tpriv_get_direct_children_of_edge ( @@ -302,7 +302,7 @@ compute_children_of_triangle ( 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) { + if (h5tpriv_is_leaf_elem (f, tet) == H5_OK) { TRY( h5priv_append_to_idlist (f, children, *tri) ); } else { h5_loc_id_t dids[4]; @@ -340,7 +340,7 @@ compute_sections_of_triangle ( 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) { + if (! h5tpriv_is_leaf_elem (f, tet) == H5_OK) { refined = 1; h5_loc_id_t dids[4]; TRY( compute_direct_children_of_triangle ( @@ -399,7 +399,7 @@ get_edges_uadj_to_vertex ( 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 ) { + if (h5tpriv_is_leaf_elem (f, tet) == H5_NOK ) { continue; } h5_loc_idx_t edge_idx; @@ -452,7 +452,7 @@ get_triangles_uadj_to_vertex ( 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) { + if (h5tpriv_is_leaf_elem (f, tet) == H5_NOK) { continue; } h5_loc_idx_t facet_idx; @@ -485,7 +485,7 @@ get_tets_uadj_to_vertex ( 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) { + if (h5tpriv_is_leaf_elem (f, tet) == H5_NOK) { continue; } // add to result diff --git a/src/h5core/h5t_adjacencies_trim.c b/src/h5core/h5t_adjacencies_trim.c index 4d52ac0..72adcc1 100644 --- a/src/h5core/h5t_adjacencies_trim.c +++ b/src/h5core/h5t_adjacencies_trim.c @@ -22,7 +22,7 @@ alloc_tv ( h5_file_t* const f ) { h5t_fdata_t* t = f->t; - h5_loc_idx_t num_vertices = t->num_vertices[t->num_levels-1]; + h5_loc_idx_t num_vertices = t->num_vertices[t->num_leaf_levels-1]; h5t_adjacencies_t* adj = &t->adjacencies; // allocate one ID list per vertex @@ -40,7 +40,7 @@ release_tv ( if (adj->tv.v == NULL) return H5_SUCCESS; h5_loc_idx_t idx = 0; - h5_loc_idx_t last = t->num_vertices[t->num_levels-1]; + h5_loc_idx_t last = t->num_vertices[t->num_leaf_levels-1]; for (; idx < last; idx++) { TRY( h5priv_free_idlist_items (f, &adj->tv.v[idx]) ); } @@ -64,7 +64,7 @@ compute_elems_of_vertices ( /* 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_loc_idx_t last = t->num_elems[t->num_leaf_levels-1]; h5_loc_triangle_t *el = &t->loc_elems.tris[idx]; for (;idx < last; idx++, el++) { int face_idx; @@ -87,7 +87,7 @@ release_te ( h5_file_t* const f ) { UNUSED_ARGUMENT (f); - // @@@ TBD @@@ + // TODO return H5_SUCCESS; } @@ -102,7 +102,7 @@ compute_elems_of_edges ( h5_debug (f, "%s (%lld)", __func__, (long long)from_lvl); h5t_fdata_t *t = f->t; 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_loc_idx_t num_elems = t->num_elems[t->num_leaf_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++) { @@ -138,7 +138,7 @@ compute_children_of_edge ( 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 ) { + if ( h5tpriv_is_leaf_elem ( f, el ) == H5_OK ) { TRY ( h5priv_append_to_idlist ( f, children, *edge ) ); @@ -183,7 +183,7 @@ compute_sections_of_edge ( 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 ) { + if ( ! h5tpriv_is_leaf_elem ( f, el ) == H5_OK ) { refined = 1; h5_loc_id_t kids[2]; TRY ( h5tpriv_get_direct_children_of_edge ( @@ -242,7 +242,7 @@ get_edges_uadj_to_vertex ( 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 ) { + if ( h5tpriv_is_leaf_elem ( f, el ) == H5_NOK ) { continue; } h5_loc_idx_t edge_idx; @@ -273,7 +273,7 @@ get_triangles_uadj_to_vertex ( h5_loc_idx_t elem_idx = h5tpriv_get_elem_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 ) { + if ( h5tpriv_is_leaf_elem ( f, el ) == H5_NOK ) { continue; } TRY( h5priv_search_idlist (f, *list, diff --git a/src/h5core/h5t_hsearch.c b/src/h5core/h5t_hsearch.c index 9ed04b1..e95afbd 100644 --- a/src/h5core/h5t_hsearch.c +++ b/src/h5core/h5t_hsearch.c @@ -81,16 +81,13 @@ h5tpriv_search_te2 ( /* Grow the hash table by 3*(num_elems - elem_idx) entries. Why this number? We fill the hash table by looping over - all elements starting with 0. So if we have to grow, we + all elements starting with 0. If we have to grow, we still have num_elems-elem_idx elements to handle. Half the number of edges of the reference element times the number of remaining elements is a good enough guess for the number of edges we still have to add to the hash table. - - Thus for a tetrahedal mesh we 3 time the remaining elements! - @@@ */ - h5_loc_idx_t num_elems = t->num_elems[t->num_levels-1]; + h5_loc_idx_t num_elems = t->num_elems[t->num_leaf_levels-1]; TRY( h5priv_hresize ( f, 3*(num_elems - elem_idx), @@ -238,7 +235,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_loc_idx_t num_elems = t->num_elems[t->num_levels-1]; + h5_loc_idx_t num_elems = t->num_elems[t->num_leaf_levels-1]; TRY( h5priv_hresize ( f, 3*(num_elems-elem_idx), diff --git a/src/h5core/h5t_inquiry.c b/src/h5core/h5t_inquiry.c index 4b35d24..148f3ca 100644 --- a/src/h5core/h5t_inquiry.c +++ b/src/h5core/h5t_inquiry.c @@ -42,7 +42,7 @@ h5t_get_num_meshes ( \return Number of hierarchical mesh levels or error code. */ h5_size_t -h5t_get_num_levels ( +h5t_get_num_leaf_levels ( h5_file_t* const f ) { h5t_fdata_t* t = f->t; @@ -50,7 +50,7 @@ h5t_get_num_levels ( if (t->cur_mesh < 0) { return h5tpriv_error_undef_mesh (f); } - return t->num_levels; + return t->num_leaf_levels; } /*! @@ -64,7 +64,7 @@ h5t_lvl_idx_t h5t_get_level ( h5_file_t* const f ) { - return f->t->cur_level; + return f->t->leaf_level; } /*! @@ -91,10 +91,10 @@ h5t_get_num_elems ( if (t->cur_mesh < 0) { return h5tpriv_error_undef_mesh (f); } - if (t->cur_level < 0) { + if (t->leaf_level < 0) { return h5tpriv_error_undef_level (f); } - return t->num_elems_on_leaf_level[t->cur_level]; + return t->num_elems_on_leaf_level[t->leaf_level]; } /*! @@ -121,9 +121,9 @@ h5t_get_num_vertices ( if (t->cur_mesh < 0) { return h5tpriv_error_undef_mesh (f); } - if (t->cur_level < 0) { + if (t->leaf_level < 0) { return h5tpriv_error_undef_level (f); } - return t->num_vertices[t->cur_level]; + return t->num_vertices[t->leaf_level]; } diff --git a/src/h5core/h5t_map.c b/src/h5core/h5t_map.c index 8afd7ef..e3cbd6f 100644 --- a/src/h5core/h5t_map.c +++ b/src/h5core/h5t_map.c @@ -135,10 +135,10 @@ h5tpriv_rebuild_vertex_indices_mapping ( ) { h5_debug (f, "%s()", __func__); h5t_fdata_t* t = f->t; - if (t->num_levels <= 0) return H5_SUCCESS; + if (t->num_leaf_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_loc_idx_t loc_idx = t->leaf_level > 0 ? t->num_vertices[t->leaf_level-1] : 0; + h5_loc_idx_t num_loc_vertices = t->num_vertices[t->num_leaf_levels-1]; h5_idxmap_el_t *item = &t->map_vertex_g2l.items[loc_idx]; for (; loc_idx < num_loc_vertices; loc_idx++, item++) { @@ -160,10 +160,10 @@ h5tpriv_rebuild_elem_indices_mapping ( ) { h5_debug (f, "%s()", __func__); h5t_fdata_t* t = f->t; - if (t->num_levels <= 0) return H5_SUCCESS; + if (t->num_leaf_levels <= 0) return H5_SUCCESS; - 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_loc_idx_t loc_idx = t->leaf_level > 0 ? t->num_elems[t->leaf_level-1] : 0; + h5_loc_idx_t num_loc_elems = t->num_elems[t->num_leaf_levels-1]; h5_idxmap_el_t *item = &t->map_elem_g2l.items[loc_idx]; for (; loc_idx < num_loc_elems; loc_idx++, item++) { diff --git a/src/h5core/h5t_openclose.c b/src/h5core/h5t_openclose.c index 4256afd..fb71ae2 100644 --- a/src/h5core/h5t_openclose.c +++ b/src/h5core/h5t_openclose.c @@ -223,8 +223,8 @@ init_fdata ( memset (t->mesh_name, 0, sizeof (t->mesh_name)); t->num_meshes = -1; t->cur_mesh = -1; - t->num_levels = -1; - t->cur_level = -1; + t->num_leaf_levels = -1; + t->leaf_level = -1; t->last_stored_vid = -1; t->last_stored_eid = -1; t->topo_gid = -1; @@ -485,7 +485,7 @@ h5t_open_mesh ( } else { /* append new */ t->num_meshes++; t->mesh_changed = id; - t->num_levels = 0; + t->num_leaf_levels = 0; } return H5_SUCCESS; @@ -553,11 +553,11 @@ h5t_set_level ( ) { h5t_fdata_t* t = f->t; - if ((level_id < 0) || (level_id >= t->num_levels)) + if ((level_id < 0) || (level_id >= t->num_leaf_levels)) return HANDLE_H5_OUT_OF_RANGE_ERR (f, "Level", level_id); - h5t_lvl_idx_t prev_level = t->cur_level; - t->cur_level = level_id; + h5t_lvl_idx_t prev_level = t->leaf_level; + t->leaf_level = level_id; if (level_id >= t->num_loaded_levels) { TRY( (h5tpriv_update_adjacency_structs)(f, prev_level+1) ); diff --git a/src/h5core/h5t_readwrite.c b/src/h5core/h5t_readwrite.c index 9d8874b..d23e4fc 100644 --- a/src/h5core/h5t_readwrite.c +++ b/src/h5core/h5t_readwrite.c @@ -25,9 +25,9 @@ write_vertices ( ) { h5t_fdata_t *t = f->t; - if (t->num_vertices <= 0) return H5_SUCCESS; /* ???? */ + assert (t->num_leaf_levels > 0); - t->dsinfo_vertices.dims[0] = t->num_vertices[t->cur_level]; + t->dsinfo_vertices.dims[0] = t->num_vertices[t->num_leaf_levels-1]; TRY( h5priv_write_dataset_by_name ( f, t->mesh_gid, @@ -51,9 +51,9 @@ write_elems ( h5_file_t* const f ) { h5t_fdata_t* t = f->t; - - if (t->num_elems <= 0) return H5_SUCCESS; + assert (t->num_leaf_levels > 0); + t->dsinfo_elems.dims[0] = t->num_elems[t->num_leaf_levels-1]; TRY( h5priv_write_dataset_by_name ( f, t->mesh_gid, @@ -99,7 +99,7 @@ h5tpriv_write_mesh ( } static h5_size_t -read_num_levels ( +read_num_leaf_levels ( h5_file_t* const f ) { h5t_fdata_t* t = f->t; @@ -115,7 +115,7 @@ read_num_levels ( TRY( size = h5priv_get_npoints_of_hdf5_dataspace (f, diskspace_id) ); TRY( h5priv_close_hdf5_dataspace (f, diskspace_id) ); - t->num_levels = size; + t->num_leaf_levels = size; return size; } @@ -149,7 +149,7 @@ read_num_vertices ( if (t->mesh_gid < 0) { return h5_error_internal (f, __FILE__, __func__, __LINE__); } - ssize_t num_bytes = t->num_levels*sizeof (t->num_vertices[0]); + ssize_t num_bytes = t->num_leaf_levels*sizeof (t->num_vertices[0]); TRY( t->num_vertices = h5_alloc (f, t->num_vertices, num_bytes) ); TRY( h5priv_read_dataset_by_name ( f, @@ -168,7 +168,7 @@ read_vertices ( ) { h5t_fdata_t* t = f->t; - TRY( h5tpriv_alloc_num_vertices (f, t->num_vertices[t->num_levels-1]) ); + TRY( h5tpriv_alloc_num_vertices (f, t->num_vertices[t->num_leaf_levels-1]) ); TRY( h5priv_read_dataset_by_name ( f, t->mesh_gid, @@ -191,7 +191,7 @@ read_num_elems ( if (t->mesh_gid < 0) { return h5_error_internal (f, __FILE__, __func__, __LINE__); } - size_t size = t->num_levels * sizeof (t->num_elems[0]); + size_t size = t->num_leaf_levels * sizeof (t->num_elems[0]); TRY( t->num_elems = h5_calloc (f, 1, size) ); TRY( t->num_elems_on_leaf_level = h5_calloc (f, 1, size) ); TRY( h5priv_read_dataset_by_name ( @@ -239,7 +239,7 @@ read_elems ( ) { h5t_fdata_t* t = f->t; - TRY( h5tpriv_alloc_elems(f, 0, t->num_elems[t->num_levels-1]) ); + TRY( h5tpriv_alloc_elems(f, 0, t->num_elems[t->num_leaf_levels-1]) ); TRY( h5priv_read_dataset_by_name ( f, t->mesh_gid, @@ -272,7 +272,7 @@ h5tpriv_read_mesh ( if (t->mesh_gid < 0) { return h5_error_internal (f, __FILE__, __func__, __LINE__); } - TRY( read_num_levels (f) ); + TRY( read_num_leaf_levels (f) ); TRY( read_num_vertices (f) ); TRY( read_num_elems (f) ); @@ -286,6 +286,6 @@ h5tpriv_read_mesh ( TRY( h5tpriv_init_geom_boundary_info (f, 0) ); TRY( read_mtags (f) ); - t->num_loaded_levels = t->num_levels; + t->num_loaded_levels = t->num_leaf_levels; return H5_SUCCESS; } diff --git a/src/h5core/h5t_readwrite_tetm.c b/src/h5core/h5t_readwrite_tetm.c index 7321b3d..061bc97 100644 --- a/src/h5core/h5t_readwrite_tetm.c +++ b/src/h5core/h5t_readwrite_tetm.c @@ -11,7 +11,7 @@ init_loc_elems_struct ( ) { h5t_fdata_t* const t = f->t; h5_loc_idx_t elem_idx = 0; - const h5_loc_idx_t num_elems = t->num_elems[t->num_levels-1]; + const h5_loc_idx_t num_elems = t->num_elems[t->num_leaf_levels-1]; h5t_lvl_idx_t level_idx = 0; int num_vertices = h5tpriv_ref_elem_get_num_vertices (t); int num_facets = h5tpriv_ref_elem_get_num_faces (t, 2); @@ -68,7 +68,7 @@ init_geom_boundary_info ( ) { h5t_fdata_t* const t = f->t; h5_loc_idx_t elem_idx = 0; - const h5_loc_idx_t num_elems = t->num_elems[t->num_levels-1]; + const h5_loc_idx_t num_elems = t->num_elems[t->num_leaf_levels-1]; int num_facets = h5tpriv_ref_elem_get_num_faces (t, 2); h5_loc_tet_t* loc_elem = t->loc_elems.tets; h5_glb_tet_t* glb_elem = t->glb_elems.tets; diff --git a/src/h5core/h5t_readwrite_trim.c b/src/h5core/h5t_readwrite_trim.c index 16cbe8c..dd7ed18 100644 --- a/src/h5core/h5t_readwrite_trim.c +++ b/src/h5core/h5t_readwrite_trim.c @@ -11,7 +11,7 @@ init_loc_elems_struct ( ) { h5t_fdata_t* const t = f->t; h5_loc_idx_t elem_idx = 0; - const h5_loc_idx_t num_elems = t->num_elems[t->num_levels-1]; + const h5_loc_idx_t num_elems = t->num_elems[t->num_leaf_levels-1]; h5t_lvl_idx_t level_idx = 0; int num_vertices = h5tpriv_ref_elem_get_num_vertices (t); int num_facets = h5tpriv_ref_elem_get_num_faces (t,1); @@ -69,7 +69,7 @@ init_geom_boundary_info ( ) { h5t_fdata_t* const t = f->t; h5_loc_idx_t elem_idx = 0; - const h5_loc_idx_t num_elems = t->num_elems[t->num_levels-1]; + const h5_loc_idx_t num_elems = t->num_elems[t->num_leaf_levels-1]; int num_facets = h5tpriv_ref_elem_get_num_faces (t, 1); h5_loc_triangle_t* loc_elem = t->loc_elems.tris; h5_glb_triangle_t* glb_elem = t->glb_elems.tris; diff --git a/src/h5core/h5t_retrieve.c b/src/h5core/h5t_retrieve.c index 4b6aec9..be7c9d3 100644 --- a/src/h5core/h5t_retrieve.c +++ b/src/h5core/h5t_retrieve.c @@ -200,7 +200,7 @@ h5t_init_leaf_iterator ( it->face_idx = 999; it->elem_idx = -1; it->codim = codim; - it->leaf_level = f->t->cur_level; + it->leaf_level = f->t->leaf_level; it->ref_elem = f->t->ref_elem; if (it->codim > 0) { @@ -223,7 +223,7 @@ h5t_init_boundary_face_iterator ( it->face_idx = 999; // something > max number of faces it->elem_idx = -1; it->codim = codim; - it->leaf_level = f->t->cur_level; + it->leaf_level = f->t->leaf_level; it->ref_elem = f->t->ref_elem; if (it->codim <= 0 || it->codim > it->ref_elem->dim) { @@ -249,7 +249,7 @@ h5t_init_mtag_iterator ( TRY2( h5err = h5t_open_mtagset (f, name, &it->tagset) ); it->elem_idx = -1; it->subentity_idx = 999; - it->level_idx = f->t->cur_level; + it->level_idx = f->t->leaf_level; it->iter = iterate_tags; h5err = H5_SUCCESS; H5_CORE_API_RETURN (h5err); diff --git a/src/h5core/h5t_retrieve_private.h b/src/h5core/h5t_retrieve_private.h index 0aafc9f..a520d74 100644 --- a/src/h5core/h5t_retrieve_private.h +++ b/src/h5core/h5t_retrieve_private.h @@ -3,13 +3,6 @@ #include -/* -h5_err_t -h5tpriv_elem_is_on_cur_level ( - h5_file_t* const f, - h5_generic_loc_elem_t* el - ); -*/ struct h5t_retrieve_methods { h5_err_t (*init_entity_iterator)( h5_file_t* const, h5t_iterator_t*, const int); @@ -24,13 +17,13 @@ extern struct h5t_retrieve_methods h5tpriv_tetm_retrieve_methods; - and, if any, the direct children is on a level > the current level */ static inline h5_err_t -h5tpriv_elem_is_on_cur_level ( +h5tpriv_is_leaf_elem ( h5_file_t* const f, h5_generic_loc_elem_t *el // ptr to local element ) { h5t_fdata_t* t = f->t; - if ( (el->level_idx > t->cur_level) || - (el->child_idx >= 0 && el->child_idx < f->t->num_elems[f->t->cur_level]) ) { + if ( (el->level_idx > t->leaf_level) || + (el->child_idx >= 0 && el->child_idx < f->t->num_elems[f->t->leaf_level]) ) { return H5_NOK; } return H5_SUCCESS; @@ -42,7 +35,7 @@ h5tpriv_elem_is_on_level ( h5_generic_loc_elem_t *el, // ptr to local element const h5t_lvl_idx_t level_idx ) { - assert ( level_idx < f->t->num_levels ); + assert ( level_idx < f->t->num_leaf_levels ); if ( (el->level_idx > level_idx) || (el->child_idx >= 0 && el->child_idx < f->t->num_elems[level_idx]) ) { return H5_NOK; diff --git a/src/h5core/h5t_store.c b/src/h5core/h5t_store.c index 06c342c..2c5b99d 100644 --- a/src/h5core/h5t_store.c +++ b/src/h5core/h5t_store.c @@ -33,15 +33,15 @@ assign_global_vertex_indices ( ) { h5t_fdata_t* const t = f->t; - if (t->cur_level < 0) return H5_SUCCESS; /* no level defined */ + if (t->leaf_level < 0) return H5_SUCCESS; /* no level defined */ /* simple in serial runs: global_id = local_id */ - h5_loc_idx_t local_idx = (t->cur_level == 0) ? - 0 : t->num_vertices[t->cur_level-1]; + h5_loc_idx_t local_idx = (t->leaf_level == 0) ? + 0 : t->num_vertices[t->leaf_level-1]; for (local_idx = 0; - local_idx < t->num_vertices[t->num_levels-1]; + local_idx < t->num_vertices[t->num_leaf_levels-1]; local_idx++) { t->vertices[local_idx].idx = local_idx; } @@ -58,14 +58,14 @@ assign_glb_elem_indices ( ) { h5t_fdata_t* const t = f->t; - if (t->cur_level < 0) return H5_SUCCESS; /* no level defined */ + if (t->leaf_level < 0) return H5_SUCCESS; /* no level defined */ /* simple in serial runs: global index = local index */ - h5_loc_idx_t loc_idx = (t->cur_level == 0) ? 0 : t->num_elems[t->cur_level-1]; + h5_loc_idx_t loc_idx = (t->leaf_level == 0) ? 0 : t->num_elems[t->leaf_level-1]; - for (; loc_idx < t->num_elems[t->cur_level]; loc_idx++) { + for (; loc_idx < t->num_elems[t->leaf_level]; loc_idx++) { h5_generic_glb_elem_t *glb_elem = h5tpriv_get_glb_elem (f, loc_idx); glb_elem->idx = loc_idx; @@ -80,16 +80,16 @@ assign_glb_elem_data ( ) { h5t_fdata_t* const t = f->t; - if (t->cur_level < 0) return H5_SUCCESS; /* no level defined */ + if (t->leaf_level < 0) return H5_SUCCESS; /* no level defined */ /* simple in serial runs: global index = local index */ - h5_loc_idx_t loc_idx = (t->cur_level == 0) ? 0 : t->num_elems[t->cur_level-1]; + h5_loc_idx_t loc_idx = (t->leaf_level == 0) ? 0 : t->num_elems[t->leaf_level-1]; int num_vertices = h5tpriv_ref_elem_get_num_vertices (t); 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++) { + for (; loc_idx < t->num_elems[t->leaf_level]; 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); @@ -131,33 +131,33 @@ h5t_add_level ( return H5_ERR_INVAL; } - /* t->num_levels will be set to zero on file creation(!) */ - if ((t->cur_mesh < 0) || (t->num_levels == -1)) { + /* t->num_leaf_levels will be set to zero on file creation(!) */ + if ((t->cur_mesh < 0) || (t->num_leaf_levels == -1)) { return h5tpriv_error_undef_mesh (f); } - t->cur_level = t->num_levels++; - t->num_loaded_levels = t->num_levels; - t->dsinfo_num_vertices.dims[0] = t->num_levels; - t->dsinfo_num_elems.dims[0] = t->num_levels; - t->dsinfo_num_elems_on_leaf_level.dims[0] = t->num_levels; + t->leaf_level = t->num_leaf_levels++; + t->num_loaded_levels = t->num_leaf_levels; + t->dsinfo_num_vertices.dims[0] = t->num_leaf_levels; + t->dsinfo_num_elems.dims[0] = t->num_leaf_levels; + t->dsinfo_num_elems_on_leaf_level.dims[0] = t->num_leaf_levels; - ssize_t num_bytes = t->num_levels*sizeof (h5_size_t); + ssize_t num_bytes = t->num_leaf_levels*sizeof (h5_size_t); TRY( t->num_vertices = h5_alloc (f, t->num_vertices, num_bytes) ); - t->num_vertices[t->cur_level] = -1; + t->num_vertices[t->leaf_level] = -1; TRY( t->num_elems = h5_alloc (f, t->num_elems, num_bytes) ); - t->num_elems[t->cur_level] = -1; + t->num_elems[t->leaf_level] = -1; TRY( t->num_elems_on_leaf_level = h5_alloc ( f, t->num_elems_on_leaf_level, num_bytes) ); - t->num_elems_on_leaf_level[t->cur_level] = -1; + t->num_elems_on_leaf_level[t->leaf_level] = -1; - if (t->cur_level == 0) { + if (t->leaf_level == 0) { /* nothing stored yet */ t->last_stored_vid = -1; t->last_stored_eid = -1; } - return t->cur_level; + return t->leaf_level; } /*! @@ -170,12 +170,12 @@ h5t_begin_store_vertices ( ) { h5t_fdata_t* const t = f->t; - if (t->cur_level < 0) { + if (t->leaf_level < 0) { return h5tpriv_error_undef_level(f); } - h5_size_t cur_num_vertices = (t->cur_level > 0 ? - t->num_vertices[t->cur_level-1] : 0); - t->num_vertices[t->cur_level] = cur_num_vertices+num; + h5_size_t cur_num_vertices = (t->leaf_level > 0 ? + t->num_vertices[t->leaf_level-1] : 0); + t->num_vertices[t->leaf_level] = cur_num_vertices+num; t->dsinfo_vertices.dims[0] = cur_num_vertices+num; return h5tpriv_alloc_num_vertices (f, cur_num_vertices+num); } @@ -191,14 +191,14 @@ h5t_store_vertex ( /* more than allocated */ - if (t->last_stored_vid+1 >= t->num_vertices[t->cur_level]) + if (t->last_stored_vid+1 >= t->num_vertices[t->leaf_level]) return HANDLE_H5_OVERFLOW_ERR( - f, "vertex", t->num_vertices[t->cur_level]); + f, "vertex", t->num_vertices[t->leaf_level]); /* missing call to add the first level */ - if (t->cur_level < 0) + if (t->leaf_level < 0) return h5tpriv_error_undef_level(f); h5_loc_idx_t local_idx = ++t->last_stored_vid; @@ -214,7 +214,7 @@ h5t_end_store_vertices ( ) { h5t_fdata_t* const t = f->t; - t->num_vertices[t->cur_level] = t->last_stored_vid+1; + t->num_vertices[t->leaf_level] = t->last_stored_vid+1; TRY( assign_global_vertex_indices (f) ); TRY( h5tpriv_rebuild_vertex_indices_mapping (f) ); return H5_SUCCESS; @@ -233,13 +233,13 @@ h5t_begin_store_elems ( ) { h5t_fdata_t* const t = f->t; - size_t cur = t->cur_level > 0 ? t->num_elems[t->cur_level-1] : 0; + size_t cur = t->leaf_level > 0 ? t->num_elems[t->leaf_level-1] : 0; size_t new = num + cur; - t->num_elems[t->cur_level] = new; + t->num_elems[t->leaf_level] = new; t->dsinfo_elems.dims[0] = new; - t->num_elems_on_leaf_level[t->cur_level] = t->cur_level > 0 ? - num + t->num_elems_on_leaf_level[t->cur_level-1] : num; + t->num_elems_on_leaf_level[t->leaf_level] = t->leaf_level > 0 ? + num + t->num_elems_on_leaf_level[t->leaf_level-1] : num; /* We allocate a hash table for a minimum of 2^21 edges to avoid resizing. @@ -268,20 +268,20 @@ h5t_store_elem ( h5t_fdata_t* t = f->t; /* level set? */ - if (t->cur_level < 0) + if (t->leaf_level < 0) return h5tpriv_error_undef_level(f); /* more than allocated? */ - if ( t->last_stored_eid+1 >= t->num_elems[t->cur_level] ) + if ( t->last_stored_eid+1 >= t->num_elems[t->leaf_level] ) return HANDLE_H5_OVERFLOW_ERR( f, h5tpriv_map_oid2str(t->mesh_type), - t->num_elems[t->cur_level] ); + t->num_elems[t->leaf_level] ); /* check parent id */ - if ((t->cur_level == 0 && parent_idx != -1) || - (t->cur_level > 0 && parent_idx < 0) || - (t->cur_level > 0 - && parent_idx >= t->num_elems[t->cur_level-1]) + if ((t->leaf_level == 0 && parent_idx != -1) || + (t->leaf_level > 0 && parent_idx < 0) || + (t->leaf_level > 0 + && parent_idx >= t->num_elems[t->leaf_level-1]) ) { return HANDLE_H5_PARENT_ID_ERR ( f, h5tpriv_map_oid2str (t->mesh_type), parent_idx); @@ -291,7 +291,7 @@ h5t_store_elem ( 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); + h5tpriv_set_loc_elem_level_idx (f, elem_idx, t->leaf_level); // get ptr to local vertices store h5_loc_idx_t* loc_vertex_indices = h5tpriv_get_loc_elem_vertex_indices ( @@ -323,7 +323,7 @@ h5t_end_store_elems ( h5_debug (f, "%s ()", __func__); h5t_fdata_t* const t = f->t; - t->num_elems[t->cur_level] = t->last_stored_eid+1; + t->num_elems[t->leaf_level] = t->last_stored_eid+1; /* assign global indices to new indices */ TRY( assign_glb_elem_indices (f) ); diff --git a/src/h5core/h5t_store_tetm.c b/src/h5core/h5t_store_tetm.c index ccd08f1..86fe0d8 100644 --- a/src/h5core/h5t_store_tetm.c +++ b/src/h5core/h5t_store_tetm.c @@ -217,7 +217,7 @@ refine_tet ( // t->glb_elems.tets[elem_idx].child_idx = elem_idx_of_first_child; t->loc_elems.tets[elem_idx].child_idx = elem_idx_of_first_child; - t->num_elems_on_leaf_level[t->cur_level]--; + t->num_elems_on_leaf_level[t->leaf_level]--; return elem_idx_of_first_child; } @@ -275,10 +275,10 @@ compute_neighbors_of_elems ( h5t_lvl_idx_t level ) { h5t_fdata_t * const t = f->t; - if (level < 0 || level >= t->num_levels) { + if (level < 0 || level >= t->num_leaf_levels) { return h5_error (f, H5_ERR_INVAL, "level idx %lld out of bound, must be in [%lld,%lld]", - (long long)level, (long long)0, (long long)t->num_levels); + (long long)level, (long long)0, (long long)t->num_leaf_levels); } h5_loc_idx_t elem_idx = level == 0 ? 0 : t->num_elems[level-1]; const h5_loc_idx_t last_idx = t->num_elems[level] - 1; @@ -301,9 +301,9 @@ end_store_elems ( h5_file_t* const f ) { h5t_fdata_t* const t = f->t; - TRY( h5tpriv_update_adjacency_structs (f, t->cur_level) ); - TRY( compute_neighbors_of_elems (f, t->cur_level) ); - TRY( h5tpriv_init_geom_boundary_info (f, t->cur_level) ); + TRY( h5tpriv_update_adjacency_structs (f, t->leaf_level) ); + TRY( compute_neighbors_of_elems (f, t->leaf_level) ); + TRY( h5tpriv_init_geom_boundary_info (f, t->leaf_level) ); return H5_SUCCESS; } diff --git a/src/h5core/h5t_store_trim.c b/src/h5core/h5t_store_trim.c index 7a5d732..5e93619 100644 --- a/src/h5core/h5t_store_trim.c +++ b/src/h5core/h5t_store_trim.c @@ -181,7 +181,7 @@ refine_triangle ( t->glb_elems.tris[elem_idx].child_idx = elem_idx_of_first_child; t->loc_elems.tris[elem_idx].child_idx = elem_idx_of_first_child; - t->num_elems_on_leaf_level[t->cur_level]--; + t->num_elems_on_leaf_level[t->leaf_level]--; return elem_idx_of_first_child; } @@ -240,10 +240,10 @@ compute_neighbors_of_elems ( ) { h5_debug (f, "%s()", __func__); h5t_fdata_t * const t = f->t; - if (level < 0 || level >= t->num_levels) { + if (level < 0 || level >= t->num_leaf_levels) { return h5_error (f, H5_ERR_INVAL, "level idx %lld out of bound, must be in [%lld,%lld]", - (long long)level, (long long)0, (long long)t->num_levels); + (long long)level, (long long)0, (long long)t->num_leaf_levels); } h5_loc_idx_t elem_idx = level == 0 ? 0 : t->num_elems[level-1]; const h5_loc_idx_t last_idx = t->num_elems[level] - 1; @@ -268,9 +268,9 @@ end_store_elems ( h5_debug (f, "%s()", __func__); h5t_fdata_t* t = f->t; - TRY( h5tpriv_update_adjacency_structs (f, t->cur_level) ); - TRY( compute_neighbors_of_elems (f, t->cur_level) ); - TRY( h5tpriv_init_geom_boundary_info (f, t->cur_level) ); + TRY( h5tpriv_update_adjacency_structs (f, t->leaf_level) ); + TRY( compute_neighbors_of_elems (f, t->leaf_level) ); + TRY( h5tpriv_init_geom_boundary_info (f, t->leaf_level) ); return H5_SUCCESS; } diff --git a/src/h5core/h5t_tags.c b/src/h5core/h5t_tags.c index e9c390a..98cac5e 100644 --- a/src/h5core/h5t_tags.c +++ b/src/h5core/h5t_tags.c @@ -152,13 +152,13 @@ add_tagset ( // create new tagset h5t_tagset_t* tagset = NULL; - size_t size = (t->num_elems[t->num_levels-1] - 1) * sizeof(*tagset->elems) + size_t size = (t->num_elems[t->num_leaf_levels-1] - 1) * sizeof(*tagset->elems) + sizeof(*tagset); TRY( tagset = h5_calloc (f, 1, size) ); TRY( tagset->name = h5priv_strdup (f, name) ); tagset->type = type; - tagset->num_elems = t->num_elems[t->num_levels-1]; + tagset->num_elems = t->num_elems[t->num_leaf_levels-1]; // add tagset to hash of tagsets TRY( h5priv_hsearch (f, tagset, H5_ENTER, NULL, &ctn->sets) ); @@ -475,11 +475,11 @@ set_tag ( TRY( add_tag (f, tagset, -i-1, face_id, elem_idx, dim, val) ); tagset->num_entities++; } - if (f->t->cur_level < tagset->scope.min_level) { - tagset->scope.min_level = f->t->cur_level; + if (f->t->leaf_level < tagset->scope.min_level) { + tagset->scope.min_level = f->t->leaf_level; } - if (f->t->cur_level > tagset->scope.max_level) { - tagset->scope.max_level = f->t->cur_level; + if (f->t->leaf_level > tagset->scope.max_level) { + tagset->scope.max_level = f->t->leaf_level; } tagset->changed = 1; return H5_SUCCESS; @@ -511,8 +511,8 @@ get_tag ( size_t* const dim, void* const values ) { - if (f->t->cur_level < tagset->scope.min_level || - f->t->cur_level > tagset->scope.max_level) { + if (f->t->leaf_level < tagset->scope.min_level || + f->t->leaf_level > tagset->scope.max_level) { return H5_NOK; } if (tagset->elems[elem_idx] == NULL) { @@ -689,10 +689,10 @@ write_tagset ( h5_err_t h5err = H5_SUCCESS; - if (t->num_levels <= 0) { + if (t->num_leaf_levels <= 0) { goto cleanup; // nothing to do } - num_elems = t->num_elems[t->num_levels-1]; + num_elems = t->num_elems[t->num_leaf_levels-1]; if (num_elems == 0 || tagset->num_entities == 0) { goto cleanup; // nothing to do } diff --git a/src/h5core/h5t_types_private.h b/src/h5core/h5t_types_private.h index fc5eba2..6ba9fa2 100644 --- a/src/h5core/h5t_types_private.h +++ b/src/h5core/h5t_types_private.h @@ -128,8 +128,8 @@ typedef struct h5t_fdata { h5_id_t cur_mesh; /* id of current mesh */ h5_id_t mesh_changed; /* true if new or has been changed */ h5_id_t num_meshes; /* number of meshes */ - h5t_lvl_idx_t cur_level; /* idx of current level */ - h5t_lvl_idx_t num_levels; /* number of levels */ + h5t_lvl_idx_t leaf_level; /* idx of current level */ + h5t_lvl_idx_t num_leaf_levels;/* number of levels */ h5t_lvl_idx_t num_loaded_levels; /*** HDF5 IDs ***/