diff --git a/src/h5_core/h5_core_private.h b/src/h5_core/h5_core_private.h index 763f98f..dcf99a6 100644 --- a/src/h5_core/h5_core_private.h +++ b/src/h5_core/h5_core_private.h @@ -91,7 +91,7 @@ ( entity_id & H5T_ELEM_MASK ) #define TRY( func ) \ - if ( (int64_t)(ptrdiff_t)(func) < (int64_t)0 ) \ + if ( (int64_t)(ptrdiff_t)(func) <= (int64_t)H5_ERR ) \ return H5_ERR; /*! diff --git a/src/h5_core/h5t_adjacencies.c b/src/h5_core/h5t_adjacencies.c index b86f3fe..950dbca 100644 --- a/src/h5_core/h5t_adjacencies.c +++ b/src/h5_core/h5t_adjacencies.c @@ -18,6 +18,33 @@ #include "h5_core/h5_core.h" #include "h5_core/h5_core_private.h" +h5_id_t * +_h5t_get_edge_of_tet ( + const h5_elem_ldta_t *tet, + const h5_id_t face_id, + h5_2id_t edge + ) { + int map[6][2] = { { 0,1 }, {1,2}, {0,2}, {0,3}, {1,3}, {2,3} }; + + edge[0] = tet->local_vids[map[face_id][0]]; + edge[1] = tet->local_vids[map[face_id][1]]; + return edge; +} + +h5_id_t * +_h5t_get_triangle_of_tet ( + const h5_elem_ldta_t *tet, + const h5_id_t face_id, + h5_2id_t tri + ) { + int map[4][3] = { { 1, 2, 3 }, { 0, 2, 3 }, { 0, 1, 3 }, { 0, 1, 2} }; + + tri[0] = tet->local_vids[map[face_id][0]]; + tri[1] = tet->local_vids[map[face_id][1]]; + tri[2] = tet->local_vids[map[face_id][2]]; + return tri; +} + /* compute T(V) @@ -27,13 +54,13 @@ _calc_tets_of_vertices ( h5_file_t * const f ) { h5t_fdata_t *t = f->t; - h5_tet_data_t *tet; + h5_elem_ldta_t *tet; h5_id_t local_tid; h5_id_t local_vid; int i; - for ( local_tid = 0, tet = &t->elems_data.tets[0]; + for ( local_tid = 0, tet = &t->elems_ldta[0]; local_tid < t->num_elems[t->num_levels-1]; local_tid++, tet++ ) { for ( i = 0; i < 4; i++ ) { @@ -77,7 +104,7 @@ _search_te2 ( h5t_adjacencies_t *a = &t->adjacencies; void *vnode; - h5_tet_data_t *tet_data = &t->elems_data.tets[local_eid]; + h5_elem_ldta_t *tet_data = &t->elems_ldta[local_eid]; h5_id_t vid; int map[6][2] = { { 0,1 }, {1,2}, {0,2}, {0,3}, {1,3}, {2,3} }; @@ -109,8 +136,8 @@ _search_te2 ( return H5_SUCCESS; } -static h5_err_t -_find_te ( +h5_err_t +_h5t_find_te ( h5_file_t * const f, h5_te_node_t **rnode, h5_2id_t edge @@ -146,7 +173,7 @@ _h5t_find_te2 ( h5_te_node_t node; void *vnode = &node; - h5_tet_data_t *tet_data = &t->elems_data.tets[local_eid]; + h5_elem_ldta_t *tet_data = &t->elems_ldta[local_eid]; h5_id_t *edge = node.key.vids; int map[6][2] = { { 0,1 }, {1,2}, {0,2}, {0,3}, {1,3}, {2,3} }; @@ -197,7 +224,7 @@ _calc_tets_of_edges ( h5_id_t local_eid; h5_size_t num_tets = t->num_elems[t->num_levels-1]; h5_te_node_t *node = NULL; - h5_tet_data_t *tet = &t->elems_data.tets[0]; + h5_elem_ldta_t *tet = &t->elems_ldta[0]; h5_id_t face_id; a->te_tree = NULL; @@ -254,7 +281,7 @@ _search_td2 ( h5t_adjacencies_t *a = &t->adjacencies; void *vnode; - h5_tet_data_t *tet_data = &t->elems_data.tets[local_eid]; + h5_elem_ldta_t *tet_data = &t->elems_ldta[local_eid]; h5_id_t vid; int map[4][3] = { { 1,2,3 }, {0,2,3}, {0,1,3}, {0,1,2} }; @@ -293,22 +320,8 @@ _search_td2 ( return H5_SUCCESS; } -h5_id_t * -_h5t_get_triangle_of_tet ( - const h5_tet_data_t *tet, - const h5_id_t face_id, - h5_2id_t tri - ) { - int map[4][3] = { { 1, 2, 3 }, { 0, 2, 3 }, { 0, 1, 3 }, { 0, 1, 2} }; - - tri[0] = tet->local_vids[map[face_id][0]]; - tri[1] = tet->local_vids[map[face_id][1]]; - tri[2] = tet->local_vids[map[face_id][2]]; - return tri; -} - -static h5_err_t -_find_td ( +h5_err_t +_h5t_find_td ( h5_file_t * const f, h5_td_node_t **rnode, h5_3id_t tri @@ -329,18 +342,22 @@ _find_td ( vid = tri[0]; tri[0] = tri[1]; tri[1] = vid; } memcpy ( node.key.vids, tri, 3*sizeof(*tri) ); - TRY ( vnode = _h5_tfind ( + vnode = _h5_tfind ( f, vnode, (void**)&a->td_tree, - _cmp_td_node ) ); + _cmp_td_node ); + if ( (h5_err_t)(ptrdiff_t)(vnode) == H5_ERR ) { + return _h5t_error_local_triangle_nexist( f, tri ); + } + *rnode = *(h5_td_node_t **)vnode; return H5_SUCCESS; } -static h5_err_t -_find_td2 ( +h5_err_t +_h5t_find_td2 ( h5_file_t * const f, h5_td_node_t **rnode, h5_id_t face_id, @@ -351,7 +368,7 @@ _find_td2 ( h5_td_node_t node; void *vnode = &node; - h5_tet_data_t *tet_data = &t->elems_data.tets[local_eid]; + h5_elem_ldta_t *tet_data = &t->elems_ldta[local_eid]; h5_id_t *tri = node.key.vids; _h5t_get_triangle_of_tet ( tet_data, face_id, tri ); @@ -366,11 +383,15 @@ _find_td2 ( if ( tri[0] > tri[1] ) { vid = tri[0]; tri[0] = tri[1]; tri[1] = vid; } - TRY ( vnode = _h5_tfind ( - f, - vnode, - (void**)&a->td_tree, - _cmp_td_node ) ); + vnode = _h5_tfind ( + f, + vnode, + (void**)&a->td_tree, + _cmp_td_node ); + if ( (h5_err_t)(ptrdiff_t)(vnode) == H5_ERR ) { + return _h5t_error_local_triangle_nexist( f, tri ); + } + *rnode = *(h5_td_node_t **)vnode; return H5_SUCCESS; @@ -408,7 +429,7 @@ _calc_tets_of_triangles ( h5_id_t local_eid; h5_size_t num_tets = t->num_elems[t->num_levels-1]; h5_td_node_t *node = NULL; - h5_tet_data_t *tet = &t->elems_data.tets[0]; + h5_elem_ldta_t *tet = &t->elems_ldta[0]; h5_id_t face_id; a->td_tree = NULL; @@ -453,50 +474,21 @@ _h5t_rebuild_adj_data ( h5_err_t _compute_direct_children_of_edge ( h5_file_t * const f, - h5_id_t local_kid, + h5_id_t face_id, h5_id_t local_eid, h5_id_t kids[2] ) { - h5_id_t face_id = _h5t_get_face_id ( local_kid ); + int off[6][2] = { {0,1}, {1,2}, {0,2}, {0,3}, {1,3}, {2,3} }; - if ( face_id == 0 ) { - kids[0] = _h5t_build_edge_id ( 0, local_eid+0 ); - kids[1] = _h5t_build_edge_id ( 0, local_eid+1 ); - } else if ( face_id == 1 ) { - kids[0] = _h5t_build_edge_id ( 1, local_eid+1 ); - kids[1] = _h5t_build_edge_id ( 1, local_eid+2 ); - } else if ( face_id == 2 ) { - kids[0] = _h5t_build_edge_id ( 2, local_eid+0 ); - kids[1] = _h5t_build_edge_id ( 2, local_eid+2 ); - } else if ( face_id == 3 ) { - kids[0] = _h5t_build_edge_id ( 3, local_eid+0 ); - kids[1] = _h5t_build_edge_id ( 3, local_eid+3 ); - } else if ( face_id == 4 ) { - kids[0] = _h5t_build_edge_id ( 4, local_eid+1 ); - kids[1] = _h5t_build_edge_id ( 4, local_eid+3 ); - } else if ( face_id == 5 ) { - kids[0] = _h5t_build_edge_id ( 5, local_eid+2 ); - kids[1] = _h5t_build_edge_id ( 5, local_eid+3 ); - } else { + if ( ( face_id < 0 ) || ( face_id >= 6 ) ) { return h5_error_internal ( f, __FILE__, __func__, __LINE__ ); } + kids[0] = _h5t_build_edge_id ( face_id, local_eid+off[face_id][0] ); + kids[1] = _h5t_build_edge_id ( face_id, local_eid+off[face_id][1] ); return H5_SUCCESS; } -/* -def _compute_children_of_edge ( E, children ): - for E' = in =T(E): - T' = tetrahedron bound to E' - if T' has no children on level ≤ L: next - (E'0, E'1) = _compute_direct_children_of edge ( E' ) - for i in [0,1]: - T'i = tetrahedron bound to D'i - if T'i has children on level ≤ L: - _compute_children_of_edge ( E'i, children ) - else: - children.append ( E'i ) -*/ -h5_err_t +static h5_err_t _compute_children_of_edge ( h5_file_t * const f, h5_id_t local_kid, @@ -504,7 +496,6 @@ _compute_children_of_edge ( ) { h5t_fdata_t *t = f->t; h5_te_node_t *te; - int i,k; TRY ( _h5t_find_te2 ( f, @@ -512,93 +503,96 @@ _compute_children_of_edge ( _h5t_get_face_id ( local_kid ), _h5t_get_elem_id ( local_kid ) ) ); - for ( k = 0; k < te->value.num_items; k++ ) { - h5_id_t local_eid = _h5t_get_elem_id ( te->value.items[k] ); - h5_tet_data_t *tet = &t->elems_data.tets[local_eid]; - - /* no children? */ - if ( tet->local_child_eid < 0 ) - continue; - /* no children on current level? */ - h5_tet_data_t *child_tet = &t->elems_data.tets[tet->local_child_eid]; - if ( child_tet->level_id > t->cur_level ) - continue; - - h5_id_t local_kids[2]; - TRY ( _compute_direct_children_of_edge ( - f, - te->value.items[k], /* parent edge */ - tet->local_child_eid, /* first children of element */ - local_kids ) ); /* result */ - for ( i = 0; i < 2; i++ ) { - local_eid = _h5t_get_elem_id ( local_kids[i] ); - tet = &t->elems_data.tets[local_eid]; - - /* no children? */ - h5_id_t l_chld_eid = tet->local_child_eid; - if ( ( l_chld_eid < 0 ) || - ( t->elems_data.tets[l_chld_eid].level_id > t->cur_level)) { - TRY ( _h5_append_to_idlist ( - f, children, local_kids[i] ) - ); - } else { - TRY ( _compute_children_of_edge ( - f, local_kids[i], children ) ); - } + h5_id_t *edge = te->value.items; + h5_id_t *end = te->value.items+te->value.num_items; + for ( ; edge < end; edge++ ) { + h5_id_t local_eid = _h5t_get_elem_id ( *edge ); + h5_id_t face_id = _h5t_get_face_id ( *edge ); + h5_elem_ldta_t *tet = &t->elems_ldta[local_eid]; + if ( _h5t_elem_is_on_cur_level ( f, tet ) == H5_OK ) { + TRY ( _h5_append_to_idlist ( + f, children, *edge ) + ); + } else { + h5_id_t local_kids[2]; + TRY ( _compute_direct_children_of_edge ( + f, + face_id, + tet->local_child_eid, + local_kids ) ); + TRY ( _compute_children_of_edge ( + f, local_kids[0], children ) ); + TRY ( _compute_children_of_edge ( + f, local_kids[1], children ) ); } } return H5_SUCCESS; } - -h5_err_t -_compute_direct_children_of_triangle ( +/* + Compute all sections of an edge. +*/ +static h5_err_t +_compute_sections_of_edge ( h5_file_t * const f, - h5_id_t local_did, - h5_id_t children_dids[4] + h5_id_t local_kid, + h5_idlist_t *children ) { + h5t_fdata_t *t = f->t; + h5_te_node_t *te; - h5_id_t local_eid = _h5t_get_elem_id ( local_did ); - h5_id_t face_id = _h5t_get_face_id ( local_did ); - if ( face_id == 0 ) { - children_dids[0] = _h5t_build_triangle_id ( 0, local_eid+1 ); - children_dids[1] = _h5t_build_triangle_id ( 0, local_eid+2 ); - children_dids[2] = _h5t_build_triangle_id ( 0, local_eid+3 ); - children_dids[3] = _h5t_build_triangle_id ( 0, local_eid+7 ); - } else if ( face_id == 1 ) { - children_dids[0] = _h5t_build_triangle_id ( 1, local_eid+0 ); - children_dids[1] = _h5t_build_triangle_id ( 1, local_eid+2 ); - children_dids[2] = _h5t_build_triangle_id ( 1, local_eid+3 ); - children_dids[3] = _h5t_build_triangle_id ( 1, local_eid+6 ); - } else if ( face_id == 2 ) { - children_dids[0] = _h5t_build_triangle_id ( 2, local_eid+0 ); - children_dids[1] = _h5t_build_triangle_id ( 2, local_eid+1 ); - children_dids[2] = _h5t_build_triangle_id ( 2, local_eid+3 ); - children_dids[3] = _h5t_build_triangle_id ( 2, local_eid+4 ); - } else if ( face_id == 3 ) { - children_dids[0] = _h5t_build_triangle_id ( 3, local_eid+0 ); - children_dids[1] = _h5t_build_triangle_id ( 3, local_eid+1 ); - children_dids[2] = _h5t_build_triangle_id ( 3, local_eid+2 ); - children_dids[3] = _h5t_build_triangle_id ( 3, local_eid+5 ); - } else { - return h5_error_internal ( f, __FILE__, __func__, __LINE__ ); + TRY ( _h5t_find_te2 ( + f, + &te, + _h5t_get_face_id ( local_kid ), + _h5t_get_elem_id ( local_kid ) ) + ); + h5_id_t *edge = te->value.items; + h5_id_t *end = te->value.items+te->value.num_items; + int refined = 0; + for ( ; edge < end; edge++ ) { + h5_id_t local_eid = _h5t_get_elem_id ( *edge ); + h5_id_t face_id = _h5t_get_face_id ( *edge ); + h5_elem_ldta_t *tet = &t->elems_ldta[local_eid]; + if ( ! _h5t_elem_is_on_cur_level ( f, tet ) == H5_OK ) { + refined = 1; + h5_id_t local_kids[2]; + TRY ( _compute_direct_children_of_edge ( + f, + face_id, + tet->local_child_eid, + local_kids ) ); + TRY ( _compute_sections_of_edge ( + f, local_kids[0], children ) ); + TRY ( _compute_sections_of_edge ( + f, local_kids[1], children ) ); + } + } + if ( ! refined ) { + TRY ( _h5_append_to_idlist ( f, children, te->value.items[0] ) ); } return H5_SUCCESS; } -/* -def _compute_children_of_triangle ( D, children ): - for D' in T(D): - T' = tetrahedron bound to D' - if T' has no children on level ≤ L: next - (D'0,D'1,D'2,D'3) = _compute_direct_children_of_triangle ( D' ) - for i in [0,1,2,3]: - T'i = tetrahedron bound to D'i - if T'i has children on level ≤ L: - _compute_children_of_triangle ( D'i, children ) - else: - children.append ( D'i) -*/ +h5_err_t +_compute_direct_children_of_triangle ( + h5_file_t * const f, + h5_id_t face_id, + h5_id_t local_eid, + h5_id_t dids[4] + ) { + int off[4][4] = { {1,2,3,7}, {0,2,3,6}, {0,1,3,4}, {0,1,2,5} }; + + if ( ( face_id < 0 ) || ( face_id >= 4 ) ) { + return h5_error_internal ( f, __FILE__, __func__, __LINE__ ); + } + dids[0] = _h5t_build_edge_id ( face_id, local_eid+off[face_id][0] ); + dids[1] = _h5t_build_edge_id ( face_id, local_eid+off[face_id][1] ); + dids[2] = _h5t_build_edge_id ( face_id, local_eid+off[face_id][2] ); + dids[3] = _h5t_build_edge_id ( face_id, local_eid+off[face_id][3] ); + return H5_SUCCESS; +} + h5_err_t _compute_children_of_triangle ( h5_file_t * const f, @@ -608,51 +602,89 @@ _compute_children_of_triangle ( h5t_fdata_t *t = f->t; h5_td_node_t *td; - int i, k; - TRY ( _find_td2 ( + TRY ( _h5t_find_td2 ( f, &td, _h5t_get_face_id ( local_did ), _h5t_get_elem_id ( local_did ) ) ); - for ( k = 0; k < td->value.num_items; k++ ) { - h5_id_t local_eid = _h5t_get_elem_id ( td->value.items[k] ); - h5_tet_data_t *tet = &t->elems_data.tets[local_eid]; - - /* no children? */ - if ( tet->local_child_eid < 0 ) - continue; - /* no children on current level? */ - h5_tet_data_t *child = &t->elems_data.tets[tet->local_child_eid]; - if ( child->level_id > t->cur_level ) - continue; - - h5_id_t local_dids[4]; - TRY ( _compute_direct_children_of_triangle ( - f, - td->value.items[k], /* parent triangle */ - local_dids ) ); /* result */ - for ( i = 0; i < 4; i++ ) { - local_eid = _h5t_get_elem_id ( local_dids[i] ); - tet = &t->elems_data.tets[local_eid]; - /* no children? */ - h5_id_t l_chld_eid = tet->local_child_eid; - if ( ( l_chld_eid < 0 ) || - ( t->elems_data.tets[l_chld_eid].level_id > t->cur_level)) { - TRY ( _h5_append_to_idlist ( - f, children, local_dids[i] ) - ); - } else { - TRY ( _compute_children_of_triangle ( - f, local_dids[i], children ) ); - } + h5_id_t *tri = td->value.items; + h5_id_t *end = td->value.items+td->value.num_items; + for ( ; tri < end; tri++ ) { + h5_id_t local_eid = _h5t_get_elem_id ( *tri ); + h5_id_t face_id = _h5t_get_face_id ( *tri ); + h5_elem_ldta_t *tet = &t->elems_ldta[local_eid]; + if ( _h5t_elem_is_on_cur_level ( f, tet ) == H5_OK ) { + TRY ( _h5_append_to_idlist ( + f, children, *tri ) + ); + } else { + h5_id_t local_dids[4]; + TRY ( _compute_direct_children_of_triangle ( + f, + face_id, + tet->local_child_eid, + local_dids ) ); + TRY ( _compute_children_of_triangle ( + f, local_dids[0], children ) ); + TRY ( _compute_children_of_triangle ( + f, local_dids[1], children ) ); + TRY ( _compute_children_of_triangle ( + f, local_dids[2], children ) ); + TRY ( _compute_children_of_triangle ( + f, local_dids[3], children ) ); } } - return H5_SUCCESS; } +static h5_err_t +_compute_sections_of_triangle ( + h5_file_t * const f, + h5_id_t local_did, + h5_idlist_t *children + ) { + h5t_fdata_t *t = f->t; + h5_td_node_t *td; + + TRY ( _h5t_find_td2 ( + f, + &td, + _h5t_get_face_id ( local_did ), + _h5t_get_elem_id ( local_did ) ) + ); + h5_id_t *tri = td->value.items; + h5_id_t *end = td->value.items+td->value.num_items; + int refined = 0; + for ( ; tri < end; tri++ ) { + h5_id_t local_eid = _h5t_get_elem_id ( *tri ); + h5_id_t face_id = _h5t_get_face_id ( *tri ); + h5_elem_ldta_t *tet = &t->elems_ldta[local_eid]; + if ( ! _h5t_elem_is_on_cur_level ( f, tet ) == H5_OK ) { + refined = 1; + h5_id_t local_dids[4]; + TRY ( _compute_direct_children_of_triangle ( + f, + face_id, + tet->local_child_eid, + local_dids ) ); + TRY ( _compute_sections_of_triangle ( + f, local_dids[0], children ) ); + TRY ( _compute_sections_of_triangle ( + f, local_dids[1], children ) ); + TRY ( _compute_sections_of_triangle ( + f, local_dids[2], children ) ); + TRY ( _compute_sections_of_triangle ( + f, local_dids[3], children ) ); + + } + } + if ( ! refined ) { + TRY ( _h5_append_to_idlist ( f, children, td->value.items[0] ) ); + } + return H5_SUCCESS; +} /* map edge ID to unique ID if unique ID not in list: add @@ -661,28 +693,16 @@ static h5_err_t _add_edge ( h5_file_t * const f, h5_idlist_t *list, - h5_2id_t edge + h5_id_t face_id, + h5_id_t local_eid ) { h5_te_node_t *te; - TRY ( _find_te ( f, &te, edge ) ); - /* search/add unique ID */ - _h5_search_idlist ( f, list, te->value.items[0] ); + TRY ( _h5t_find_te2 ( f, &te, face_id, local_eid ) ); + TRY ( _h5_search_idlist ( f, list, te->value.items[0] ) ); return H5_SUCCESS; } -h5_id_t * -_h5t_get_edge_of_tet ( - const h5_tet_data_t *tet, - const h5_id_t face_id, - h5_2id_t edge - ) { - int map[6][2] = { { 0,1 }, {1,2}, {0,2}, {0,3}, {1,3}, {2,3} }; - - edge[0] = tet->local_vids[map[face_id][0]]; - edge[1] = tet->local_vids[map[face_id][1]]; - return edge; -} h5_err_t h5t_get_edges_upadjacent_to_vertex ( @@ -696,22 +716,19 @@ h5t_get_edges_upadjacent_to_vertex ( h5_idlist_t *tv = &t->vertices_data[local_vid].tv; h5_size_t i; - for ( i = 0; i < tv->num_items; i++ ) { - h5_id_t local_eid = _h5t_get_elem_id ( tv->items[i] ); - h5_id_t vertex_id = _h5t_get_face_id ( tv->items[i] ); - h5_tet_data_t *tet = &t->elems_data.tets[local_eid]; + h5_id_t *vid = tv->items; + for ( i = 0; i < tv->num_items; i++, vid++ ) { + h5_id_t local_eid = _h5t_get_elem_id ( *vid ); + h5_id_t face_id = _h5t_get_face_id ( *vid ); + h5_elem_ldta_t *tet = &t->elems_ldta[local_eid]; - if ( _h5t_elem_is_on_cur_level ( f, (h5_element_data_t*)tet ) == H5_NOK ) { + if ( _h5t_elem_is_on_cur_level ( f, tet ) == H5_NOK ) { continue; } int map[4][3] = { { 0, 2, 3 }, { 0, 1, 4 }, { 2, 1, 5 }, { 3, 4, 5} }; - h5_2id_t edge; - TRY ( _add_edge ( f, *list, - _h5t_get_edge_of_tet(tet, map[vertex_id][0], edge) ) ); - TRY ( _add_edge ( f, *list, - _h5t_get_edge_of_tet(tet, map[vertex_id][1], edge) ) ); - TRY ( _add_edge ( f, *list, - _h5t_get_edge_of_tet(tet, map[vertex_id][2], edge) ) ); + TRY ( _add_edge ( f, *list, map[face_id][0], local_eid ) ); + TRY ( _add_edge ( f, *list, map[face_id][1], local_eid ) ); + TRY ( _add_edge ( f, *list, map[face_id][2], local_eid ) ); } return H5_SUCCESS; } @@ -720,10 +737,11 @@ static h5_err_t _add_triangle ( h5_file_t * const f, h5_idlist_t *list, - h5_3id_t tri + h5_id_t face_id, + h5_id_t local_eid ) { h5_td_node_t *td; - TRY ( _find_td ( f, &td, tri ) ); + TRY ( _h5t_find_td2 ( f, &td, face_id, local_eid ) ); TRY ( _h5_search_idlist ( f, list, td->value.items[0] ) ); return H5_SUCCESS; @@ -740,26 +758,19 @@ h5t_get_triangles_upadjacent_to_vertex ( h5t_fdata_t *t = f->t; h5_idlist_t *tv = &t->vertices_data[local_vid].tv; h5_size_t i; + h5_id_t *vid = tv->items; + for ( i = 0; i < tv->num_items; i++, vid++ ) { + h5_id_t local_eid = _h5t_get_elem_id ( *vid ); + h5_id_t face_id = _h5t_get_face_id ( *vid ); + h5_elem_ldta_t *tet = &t->elems_ldta[local_eid]; - for ( i = 0; i < tv->num_items; i++ ) { - h5_id_t local_eid = _h5t_get_elem_id ( tv->items[i] ); - h5_id_t vertex_id = _h5t_get_face_id ( tv->items[i] ); - h5_tet_data_t *tet = &t->elems_data.tets[local_eid]; - - if ( _h5t_elem_is_on_cur_level ( f, (h5_element_data_t*)tet ) == H5_NOK ) { + if ( _h5t_elem_is_on_cur_level ( f, tet ) == H5_NOK ) { continue; } int map[4][3] = { { 1, 2, 3 }, { 0, 2, 3 }, { 0, 1, 3 }, { 0, 1, 2} }; - h5_3id_t tri; - TRY ( _add_triangle ( - f, *list, - _h5t_get_triangle_of_tet(tet, map[vertex_id][0], tri) ) ); - TRY ( _add_triangle ( - f, *list, - _h5t_get_triangle_of_tet(tet, map[vertex_id][1], tri) ) ); - TRY ( _add_triangle ( - f, *list, - _h5t_get_triangle_of_tet(tet, map[vertex_id][2], tri) ) ); + TRY ( _add_triangle ( f, *list, map[face_id][0], local_eid ) ); + TRY ( _add_triangle ( f, *list, map[face_id][1], local_eid ) ); + TRY ( _add_triangle ( f, *list, map[face_id][2], local_eid ) ); } return H5_SUCCESS; } @@ -775,12 +786,12 @@ h5t_get_tets_upadjacent_to_vertex ( h5t_fdata_t *t = f->t; h5_idlist_t *tv = &t->vertices_data[local_vid].tv; h5_size_t i; + h5_id_t *vid = tv->items; + for ( i = 0; i < tv->num_items; i++, vid++ ) { + h5_id_t local_eid = _h5t_get_elem_id ( *vid ); + h5_elem_ldta_t *tet = &t->elems_ldta[local_eid]; - for ( i = 0; i < tv->num_items; i++ ) { - h5_id_t local_eid = _h5t_get_elem_id ( tv->items[i] ); - h5_tet_data_t *tet = &t->elems_data.tets[local_eid]; - - if ( _h5t_elem_is_on_cur_level ( f, (h5_element_data_t*)tet ) == H5_NOK ) { + if ( _h5t_elem_is_on_cur_level ( f, tet ) == H5_NOK ) { continue; } TRY ( _h5_search_idlist ( f, *list, local_eid ) ); @@ -788,21 +799,235 @@ h5t_get_tets_upadjacent_to_vertex ( return H5_SUCCESS; } +h5_err_t +h5t_get_triangles_upadjacent_to_edge ( + h5_file_t * const f, + const h5_id_t local_kid, + h5_idlist_t **list + ) { + h5_idlist_t *children; + TRY ( _h5_alloc_idlist ( f, &children, 8 ) ); + TRY ( _compute_children_of_edge ( f, local_kid, children ) ); + TRY ( _h5_alloc_idlist ( f, list, 8 ) ); + h5_id_t *edge = children->items; + h5_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 local_eid = _h5t_get_elem_id ( *edge ); + h5_id_t face_id = _h5t_get_face_id ( *edge ); + TRY ( _add_triangle ( f, *list, map[face_id][0], local_eid ) ); + TRY ( _add_triangle ( f, *list, map[face_id][1], local_eid ) ); + } + TRY ( _h5_free_idlist( f, &children ) ); + + return H5_SUCCESS; +} + h5_err_t h5t_get_tets_upadjacent_to_edge ( h5_file_t * const f, const h5_id_t local_kid, h5_idlist_t **list ) { - h5_idlist_t children; - memset ( &children, 0, sizeof(children) ); + h5_idlist_t *children; + TRY ( _h5_alloc_idlist ( f, &children, 8 ) ); + TRY( _compute_children_of_edge ( f, local_kid, children ) ); TRY ( _h5_alloc_idlist ( f, list, 8 ) ); - TRY( _compute_children_of_edge ( f, local_kid, &children ) ); int i; - for ( i = 0; i < children.num_items; i++ ) { - h5_id_t local_eid = _h5t_get_elem_id ( children.items[i] ); + h5_id_t *kid = children->items; + for ( i = 0; i < children->num_items; i++, kid++ ) { + h5_id_t local_eid = _h5t_get_elem_id ( *kid ); TRY ( _h5_search_idlist ( f, *list, local_eid ) ); } + TRY ( _h5_free_idlist( f, &children ) ); + return H5_SUCCESS; +} + +h5_err_t +h5t_get_tets_upadjacent_to_triangle ( + h5_file_t * const f, + const h5_id_t local_did, + h5_idlist_t **list + ) { + h5_idlist_t *children; + TRY ( _h5_alloc_idlist ( f, &children, 8 ) ); + TRY( _compute_children_of_triangle ( f, local_did, children ) ); + TRY ( _h5_alloc_idlist ( f, list, 8 ) ); + int i; + h5_id_t *did = children->items; + for ( i = 0; i < children->num_items; i++ , did++) { + h5_id_t local_eid = _h5t_get_elem_id ( *did ); + TRY ( _h5_search_idlist ( f, *list, local_eid ) ); + } + TRY ( _h5_free_idlist( f, &children ) ); + return H5_SUCCESS; +} + + +h5_err_t +h5t_get_vertices_downadjacent_to_edge ( + h5_file_t * const f, + const h5_id_t local_kid, + h5_idlist_t **list + ) { + h5_idlist_t *children; + TRY ( _h5_alloc_idlist ( f, &children, 8 ) ); + TRY( _compute_sections_of_edge ( f, local_kid, children ) ); + TRY ( _h5_alloc_idlist ( f, list, 8 ) ); + int i; + h5_id_t *kid = children->items; + for ( i = 0; i < children->num_items; i++, kid++ ) { + h5_2id_t local_vids; + TRY ( h5t_get_local_vids_of_entity ( f, *kid, local_vids ) ); + TRY ( _h5_search_idlist ( f, *list, local_vids[0] ) ); + TRY ( _h5_search_idlist ( f, *list, local_vids[1] ) ); + } + TRY ( _h5_free_idlist( f, &children ) ); + return H5_SUCCESS; +} + +/* + Compute downward adjacent vertices of all edges of triangle. + */ +h5_err_t +h5t_get_vertices_downadjacent_to_triangle ( + h5_file_t * const f, + const h5_id_t local_did, + h5_idlist_t **list + ) { + h5_idlist_t *children; + TRY ( _h5_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_id = _h5t_get_face_id ( local_did ); + h5_id_t local_eid = _h5t_get_elem_id ( local_did ); + + h5_id_t i; + for ( i = 0; i < 3; i++ ) { + TRY( _compute_sections_of_edge ( + f, + _h5t_build_edge_id ( map[face_id][i], local_eid ), + children ) ); + } + TRY ( _h5_alloc_idlist ( f, list, 8 ) ); + h5_id_t *kid = children->items; + for ( i = 0; i < children->num_items; i++, kid++ ) { + h5_2id_t local_vids; + TRY ( h5t_get_local_vids_of_entity ( f, *kid, local_vids ) ); + TRY ( _h5_search_idlist ( f, *list, local_vids[0] ) ); + TRY ( _h5_search_idlist ( f, *list, local_vids[1] ) ); + } + TRY ( _h5_free_idlist( f, &children ) ); + return H5_SUCCESS; +} + +/* + Compute downward adjacent vertices of all edges of tetrahedron. + */ +h5_err_t +h5t_get_vertices_downadjacent_to_tet ( + h5_file_t * const f, + const h5_id_t local_eid, + h5_idlist_t **list + ) { + h5_idlist_t *children; + TRY ( _h5_alloc_idlist ( f, &children, 8 ) ); + + h5_id_t i; + for ( i = 0; i < 6; i++ ) { + TRY( _compute_sections_of_edge ( + f, + _h5t_build_edge_id ( i, local_eid ), + children ) ); + } + TRY ( _h5_alloc_idlist ( f, list, 8 ) ); + h5_id_t *kid = children->items; + for ( i = 0; i < children->num_items; i++, kid++ ) { + h5_2id_t local_vids; + TRY ( h5t_get_local_vids_of_entity ( f, *kid, local_vids ) ); + TRY ( _h5_search_idlist ( f, *list, local_vids[0] ) ); + TRY ( _h5_search_idlist ( f, *list, local_vids[1] ) ); + } + TRY ( _h5_free_idlist( f, &children ) ); + return H5_SUCCESS; +} + +h5_err_t +h5t_get_edges_downadjacent_to_triangle ( + h5_file_t * const f, + const h5_id_t local_did, + h5_idlist_t **list + ) { + h5_idlist_t *children; + TRY ( _h5_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_id = _h5t_get_face_id ( local_did ); + h5_id_t local_eid = _h5t_get_elem_id ( local_did ); + + h5_id_t i; + for ( i = 0; i < 3; i++ ) { + TRY( _compute_sections_of_edge ( + f, + _h5t_build_edge_id ( map[face_id][i], local_eid ), + children ) ); + } + TRY ( _h5_alloc_idlist ( f, list, 8 ) ); + h5_id_t *kid = children->items; + for ( i = 0; i < children->num_items; i++, kid++ ) { + TRY ( _h5_search_idlist ( f, *list, *kid ) ); + } + TRY ( _h5_free_idlist( f, &children ) ); + return H5_SUCCESS; +} + +h5_err_t +h5t_get_edges_downadjacent_to_tet ( + h5_file_t * const f, + const h5_id_t local_eid, + h5_idlist_t **list + ) { + h5_idlist_t *children; + TRY ( _h5_alloc_idlist ( f, &children, 8 ) ); + + h5_id_t i; + for ( i = 0; i < 6; i++ ) { + TRY( _compute_sections_of_edge ( + f, + _h5t_build_edge_id ( i, local_eid ), + children ) ); + } + TRY ( _h5_alloc_idlist ( f, list, 8 ) ); + h5_id_t *kid = children->items; + for ( i = 0; i < children->num_items; i++, kid++ ) { + TRY ( _h5_search_idlist ( f, *list, *kid ) ); + } + TRY ( _h5_free_idlist( f, &children ) ); + return H5_SUCCESS; +} + +h5_err_t +h5t_get_triangles_downadjacent_to_tet ( + h5_file_t * const f, + const h5_id_t local_eid, + h5_idlist_t **list + ) { + h5_idlist_t *children; + TRY ( _h5_alloc_idlist ( f, &children, 8 ) ); + + h5_id_t i; + for ( i = 0; i < 4; i++ ) { + TRY( _compute_sections_of_triangle ( + f, + _h5t_build_edge_id ( i, local_eid ), + children ) ); + } + TRY ( _h5_alloc_idlist ( f, list, 8 ) ); + h5_id_t *did = children->items; + for ( i = 0; i < children->num_items; i++, did++ ) { + TRY ( _h5_search_idlist ( f, *list, *did ) ); + } + TRY ( _h5_free_idlist( f, &children ) ); return H5_SUCCESS; } diff --git a/src/h5_core/h5t_adjacencies.h b/src/h5_core/h5t_adjacencies.h index 7274cfd..f551556 100644 --- a/src/h5_core/h5t_adjacencies.h +++ b/src/h5_core/h5t_adjacencies.h @@ -22,6 +22,69 @@ h5t_get_tets_upadjacent_to_vertex ( h5_idlist_t **list ); +h5_err_t +h5t_get_triangles_upadjacent_to_edge ( + h5_file_t * const f, + const h5_id_t local_kid, + h5_idlist_t **list + ); + +h5_err_t +h5t_get_tets_upadjacent_to_edge ( + h5_file_t * const f, + const h5_id_t local_kid, + h5_idlist_t **list + ); + +h5_err_t +h5t_get_tets_upadjacent_to_triangle ( + h5_file_t * const f, + const h5_id_t local_did, + h5_idlist_t **list + ); + +h5_err_t +h5t_get_vertices_downadjacent_to_edge ( + h5_file_t * const f, + const h5_id_t local_kid, + h5_idlist_t **list + ); + +h5_err_t +h5t_get_vertices_downadjacent_to_triangle ( + h5_file_t * const f, + const h5_id_t local_did, + h5_idlist_t **list + ); + +h5_err_t +h5t_get_vertices_downadjacent_to_tet ( + h5_file_t * const f, + const h5_id_t local_tid, + h5_idlist_t **list + ); + +h5_err_t +h5t_get_edges_downadjacent_to_triangle ( + h5_file_t * const f, + const h5_id_t local_did, + h5_idlist_t **list + ); + +h5_err_t +h5t_get_edges_downadjacent_to_tet ( + h5_file_t * const f, + const h5_id_t local_tid, + h5_idlist_t **list + ); + +h5_err_t +h5t_get_triangles_downadjacent_to_tet ( + h5_file_t * const f, + const h5_id_t local_tid, + h5_idlist_t **list + ); + h5_err_t h5t_release_list_of_adjacencies ( h5_file_t * const f, diff --git a/src/h5_core/h5t_adjacencies_private.h b/src/h5_core/h5t_adjacencies_private.h index 03f2531..d37d50b 100644 --- a/src/h5_core/h5t_adjacencies_private.h +++ b/src/h5_core/h5t_adjacencies_private.h @@ -14,4 +14,18 @@ _h5t_find_te2 ( h5_id_t local_eid ); +h5_err_t +_h5t_find_td ( + h5_file_t * const f, + h5_td_node_t **rnode, + h5_3id_t tri + ); + +h5_err_t +_h5t_find_td2 ( + h5_file_t * const f, + h5_td_node_t **rnode, + h5_id_t face_id, + h5_id_t local_eid + ); #endif diff --git a/src/h5_core/h5t_boundaries.c b/src/h5_core/h5t_boundaries.c index 171b724..276be35 100644 --- a/src/h5_core/h5t_boundaries.c +++ b/src/h5_core/h5t_boundaries.c @@ -237,27 +237,9 @@ h5t_store_boundaryface ( h5_file_t * const f, h5_id_t * const global_vids ) { - struct h5t_fdata *t = f->t; - if ( t->vertices == NULL ) { - TRY ( _h5t_read_mesh ( f ) ); - } - - switch ( t->mesh_type ) { - case H5_OID_TETRAHEDRON: { - h5_id_t local_vids[3]; - h5_err_t h5err = h5t_map_global_vids2local ( - f, global_vids, 3, local_vids ); - if ( h5err < 0 ) return h5err; - h5_id_t local_tid = h5t_get_local_triangle_id ( f, local_vids ); - if ( local_tid < 0 ) - return _h5t_error_local_triangle_id_nexist( f, local_vids ); - return h5t_store_boundaryface_local_id ( f, local_tid ); - } - default: - return h5_error_not_implemented ( - f, __FILE__, __func__, __LINE__ ); - } + return h5_error_not_implemented ( + f, __FILE__, __func__, __LINE__ ); } h5_id_t diff --git a/src/h5_core/h5t_consts.c b/src/h5_core/h5t_consts.c index 26347f2..b4d704d 100644 --- a/src/h5_core/h5t_consts.c +++ b/src/h5_core/h5t_consts.c @@ -1,4 +1,6 @@ #include "h5_types.h" +#include "h5_types_private.h" +#include "h5t_types_private.h" const char * _h5t_oid_names[] = { "N.N.", @@ -16,6 +18,14 @@ const char * _h5t_meshes_grpnames[] = { "TetMeshes" }; +const size_t _h5t_sizeof_elem[] = { + 0, + 0, + 0, + sizeof(h5_triangle_t), + sizeof(h5_tetrahedron_t) +}; + const char * _h5t_map_oid2str ( h5_oid_t oid diff --git a/src/h5_core/h5t_consts_private.h b/src/h5_core/h5t_consts_private.h index 47bc73d..394adf0 100644 --- a/src/h5_core/h5t_consts_private.h +++ b/src/h5_core/h5t_consts_private.h @@ -3,6 +3,7 @@ extern char * _h5t_oid_names[]; extern char * _h5t_meshes_grpnames[]; +extern size_t _h5t_sizeof_elem[]; const char * _h5t_map_oid2str ( diff --git a/src/h5_core/h5t_errorhandling.c b/src/h5_core/h5t_errorhandling.c index d8fb814..f6a8827 100644 --- a/src/h5_core/h5t_errorhandling.c +++ b/src/h5_core/h5t_errorhandling.c @@ -8,27 +8,31 @@ #include "h5_core.h" #include "h5_core_private.h" - + + h5_err_t -_h5t_error_illegal_object_type ( +_h5t_error_local_elem_nexist ( h5_file_t * const f, - h5_oid_t oid ) { - struct h5t_fdata *t = f->t; - switch ( t->mesh_type ) { + h5_id_t local_vids[] + ) { + switch ( f->t->mesh_type ) { case H5_OID_TETRAHEDRON: - return h5_error_internal( f, __FILE__, __func__, __LINE__ ); + return h5_error ( + f, + H5_ERR_NOENTRY, + "Tetrahedron with local vertex IDs " + "(%lld,%lld,%lld,%lld) doesn't exist!", + local_vids[0], local_vids[1], + local_vids[2], local_vids[3] ); case H5_OID_TRIANGLE: - switch ( oid ) { - case H5_OID_TETRAHEDRON: - return h5_error ( - f, - H5_ERR_INVAL, - "Illegal topological entity tetrahedron" - " in triangle mesh." ); - default: - return h5_error_internal( f, __FILE__, __func__, __LINE__ ); - } + return h5_error ( + f, + H5_ERR_NOENTRY, + "Triangle with local vertex IDs " + "(%lld,%lld,%lld) doesn't exist!", + local_vids[0], local_vids[1], local_vids[2] ); default: return h5_error_internal( f, __FILE__, __func__, __LINE__ ); } } + diff --git a/src/h5_core/h5t_errorhandling_private.h b/src/h5_core/h5t_errorhandling_private.h index cb080fb..b1a2089 100644 --- a/src/h5_core/h5t_errorhandling_private.h +++ b/src/h5_core/h5t_errorhandling_private.h @@ -2,9 +2,10 @@ #define __H5T_ERRORHANDLING_PRIVATE_H h5_err_t -_h5t_error_illegal_object_type ( +_h5t_error_local_elem_nexist ( h5_file_t * const f, - h5_oid_t oid ); + h5_id_t local_vids[] + ); #define _h5t_error_undef_mesh( f ) \ h5_error( \ @@ -12,11 +13,18 @@ _h5t_error_illegal_object_type ( H5_ERR_INVAL, \ "Mesh not yet defined." ); -#define _h5t_error_undef_level( f ) \ +#define _h5t_error_undef_level( f ) \ h5_error( \ f, \ H5_ERR_INVAL, \ - "Level not yet defined." ); + "Level not defined." ); + + +#define _h5t_error_nexist_level( f, level_id ) \ + h5_error( \ + f, \ + H5_ERR_INVAL, \ + "Level %lld doesn't exist.", level_id ); #define _h5t_error_global_id_nexist( f, name, id ) \ h5_error( \ @@ -26,34 +34,6 @@ _h5t_error_illegal_object_type ( name, id ); -#define _h5t_error_global_tet_id_nexist( f, vids ) \ - h5_error( \ - f, \ - H5_ERR_NOENTRY, \ - "Tetrahedron with global vertex ids (%lld,%lld,%lld,%lld) doesn't exist!", \ - vids[0], vids[1], vids[2], vids[3] ); - -#define _h5t_error_global_tri_id_nexist( f, vids ) \ - h5_error( \ - f, \ - H5_ERR_NOENTRY, \ - "Triangle with global vertex ids (%lld,%lld,%lld) doesn't exist!", \ - vids[0], vids[1], vids[2] ); - -#define _h5t_error_local_tet_id_nexist( f, vids ) \ - h5_error( \ - f, \ - H5_ERR_NOENTRY, \ - "Tetrahedron with local vertex ids (%lld,%lld,%lld,%lld) doesn't exist!", \ - vids[0], vids[1], vids[2], vids[3] ); - -#define _h5t_error_local_triangle_id_nexist( f, vids ) \ - h5_error( \ - f, \ - H5_ERR_NOENTRY, \ - "Triangle with local vertex ids (%lld,%lld,%lld) doesn't exist!", \ - vids[0], vids[1], vids[2] ); - #define _h5t_error_global_triangle_id_nexist( f, vids ) \ h5_error( \ f, \ @@ -61,6 +41,14 @@ _h5t_error_illegal_object_type ( "Triangle with global vertex ids (%lld,%lld,%lld) doesn't exist!", \ vids[0], vids[1], vids[2] ); +#define _h5t_error_local_triangle_nexist( f, local_vids ) \ + h5_error( \ + f, \ + H5_ERR_NOENTRY, \ + "Triangle with global vertex ids (%lld,%lld,%lld) doesn't exist!", \ + local_vids[0], local_vids[1], local_vids[2] ); + + #define _h5t_error_store_boundaryface_local_id( f, local_fid ) \ h5_error( \ f, \ diff --git a/src/h5_core/h5t_inquiry.c b/src/h5_core/h5t_inquiry.c index 39e7ce2..c3d691d 100644 --- a/src/h5_core/h5t_inquiry.c +++ b/src/h5_core/h5t_inquiry.c @@ -16,7 +16,7 @@ h5t_get_num_meshes ( ) { struct h5t_fdata *t = f->t; - if ( t->num_meshes != -1 ) { + if ( t->num_meshes >= 0 ) { return t->num_meshes; } if ( t->topo_gid < 0 ) { @@ -36,25 +36,12 @@ h5_size_t h5t_get_num_levels ( h5_file_t * f ) { - struct h5t_fdata *t = f->t; - hid_t dataset_id; - hid_t diskspace_id; - hssize_t size; + h5t_fdata_t *t = f->t; - if ( t->num_levels >= 0 ) return t->num_levels; if ( t->cur_mesh < 0 ) { return _h5t_error_undef_mesh ( f ); } - if ( t->mesh_gid < 0 ) { - TRY( _h5t_open_mesh_group ( f ) ); - } - TRY ( dataset_id = _h5_open_dataset ( f, t->mesh_gid, "NumVertices" ) ); - TRY ( diskspace_id = _h5_get_dataset_space ( f, dataset_id ) ); - TRY ( size = _h5_get_npoints_of_space ( f, diskspace_id ) ); - TRY ( _h5_close_dataspace( f, diskspace_id ) ); - - t->num_levels = size; - return size; + return t->num_levels; } @@ -107,27 +94,18 @@ h5t_get_num_levels ( h5_size_t h5t_get_num_elems ( h5_file_t * f, - hid_t cnode_id, - hid_t level_id + h5_id_t cnode_id, + h5_id_t level_id ) { - struct h5t_fdata *t = f->t; + h5t_fdata_t *t = f->t; - if ( cnode_id < 0 ) { - cnode_id = f->nprocs; - } - if ( level_id < 0 ) { - level_id = f->t->num_levels-1; - } if ( t->cur_mesh < 0 ) { return _h5t_error_undef_mesh ( f ); } - if ( t->cur_level < 0 ) { - return _h5t_error_undef_level( f ); + if ( level_id < 0 || level_id >= t->num_levels ) { + return HANDLE_H5_OUT_OF_RANGE_ERR ( f, "Level", level_id ); } - if ( t->num_elems_on_level == NULL ) { - TRY( _h5t_read_num_elems ( f ) ); - } - return t->num_elems_on_level[t->cur_level]; + return t->num_elems_on_level[level_id]; } /*! @@ -140,22 +118,15 @@ h5t_get_num_elems ( h5_size_t h5t_get_num_elems_total ( h5_file_t * f, - hid_t cnode_id, - hid_t level_id + h5_id_t cnode_id, + h5_id_t level_id ) { - struct h5t_fdata *t = f->t; - - if ( cnode_id < 0 ) { - cnode_id = f->nprocs; - } - if ( level_id < 0 ) { - level_id = f->t->num_levels-1; - } + h5t_fdata_t *t = f->t; if ( t->cur_mesh < 0 ) { return _h5t_error_undef_mesh ( f ); } - if ( t->num_elems == NULL ) { - TRY( _h5t_read_num_elems ( f ) ); + if ( level_id < 0 || level_id >= t->num_levels ) { + return HANDLE_H5_OUT_OF_RANGE_ERR ( f, "Level", level_id ); } return t->num_elems[level_id]; } @@ -172,25 +143,16 @@ h5t_get_num_elems_total ( h5_size_t h5t_get_num_vertices ( h5_file_t * f, - hid_t cnode_id, - hid_t level_id + h5_id_t cnode_id, + h5_id_t level_id ) { - struct h5t_fdata *t = f->t; + h5t_fdata_t *t = f->t; - if ( cnode_id < 0 ) { - cnode_id = f->nprocs; - } - if ( level_id < 0 ) { - level_id = f->t->num_levels-1; - } if ( t->cur_mesh < 0 ) { return _h5t_error_undef_mesh ( f ); } - if ( t->cur_level < 0 ) { - return _h5t_error_undef_level( f ); - } - if ( t->num_vertices == NULL ) { - TRY( _h5t_read_num_vertices ( f ) ); + if ( level_id < 0 || level_id >= t->num_levels ) { + return HANDLE_H5_OUT_OF_RANGE_ERR ( f, "Level", level_id ); } return t->num_vertices[level_id]; } @@ -199,6 +161,5 @@ h5_id_t h5t_get_level ( h5_file_t * f ) { - struct h5t_fdata *t = f->t; - return t->cur_level; + return f->t->cur_level; } diff --git a/src/h5_core/h5t_inquiry.h b/src/h5_core/h5t_inquiry.h index ccd601e..87df0e5 100644 --- a/src/h5_core/h5t_inquiry.h +++ b/src/h5_core/h5t_inquiry.h @@ -15,22 +15,22 @@ h5t_get_num_levels ( h5_size_t h5t_get_num_elems ( h5_file_t * f, - hid_t cnode_id, - hid_t level_id + h5_id_t cnode_id, + h5_id_t level_id ); h5_size_t h5t_get_num_elems_total ( h5_file_t * f, - hid_t cnode_id, - hid_t level_id + h5_id_t cnode_id, + h5_id_t level_id ); h5_size_t h5t_get_num_vertices ( h5_file_t * f, - hid_t cnode_id, - hid_t level_id + h5_id_t cnode_id, + h5_id_t level_id ); h5_id_t diff --git a/src/h5_core/h5t_map.c b/src/h5_core/h5t_map.c index 0bd1e59..3b2d775 100644 --- a/src/h5_core/h5t_map.c +++ b/src/h5_core/h5t_map.c @@ -75,20 +75,19 @@ _h5t_sort_vertices ( return H5_SUCCESS; } + /*! - Search vertex in the sorted array of vertices. The vertex is given by its - coordinates. + Return local vertex id of a vertex given by its coordinates. - \return index of vertex in the sorted array or the negative value - of the index where it should be inserted. -*/ -static h5_id_t -_search_vertex ( + \return local vertex id if found + \return else negativ value + */ +h5_id_t +_h5t_get_local_vid ( h5_file_t * const f, - h5_float64_t P0[3] + h5_float64_t P[3] ) { - struct h5t_fdata *t = f->t; - + h5t_fdata_t *t = f->t; register h5_id_t low = 0; register h5_id_t high = t->sorted_lvertices.num_items - 1; while (low <= high) { @@ -96,101 +95,26 @@ _search_vertex ( h5_id_t local_vid = t->sorted_lvertices.items[mid]; h5_float64_t *P1 = t->vertices[local_vid].P; - int diff = _cmp_vertices ( P0, P1 ); + int diff = _cmp_vertices ( P, P1 ); if ( diff < 0 ) high = mid - 1; else if ( diff > 0 ) low = mid + 1; else - return mid; // found + return t->sorted_lvertices.items[mid]; // found } return -(low+1); // not found } -/*! - Return local vertex id of a vertex given by its coordinates. - - \return local vertex id if found - \return negativ value - */ -h5_id_t -_h5t_get_local_vid ( - h5_file_t * const f, - h5_float64_t P[3] - ) { - struct h5t_fdata *t = f->t; - - h5_id_t idx; - idx = _search_vertex ( f, P ); - if ( idx < 0 ) return idx; - return t->sorted_lvertices.items[idx]; -} - -/*! - Returns the local vertex id of the i-th vertex of an element. For triangles - i is in [0,1,2], for tetraheda i is in [0,1,2,3]. -*/ -static h5_id_t -_get_local_vid_of_elem ( - h5_file_t * f, - int ith_vertex, - h5_id_t local_eid - ) { - struct h5t_fdata *t = f->t; - - h5_id_t local_vid = -1; - h5_id_t global_vid = -1; - - switch ( t->mesh_type ) { - case H5_OID_TETRAHEDRON: { - local_vid = t->elems_data.tets[local_eid].local_vids[ith_vertex]; - if ( local_vid == -1 ) { - global_vid = - t->elems.tets[local_eid].global_vids[ith_vertex]; - local_vid = _h5_search_idmap ( - &t->map_vertex_g2l, global_vid ); - t->elems_data.tets[local_eid].local_vids[ith_vertex] = - local_vid; - } - break; - } - case H5_OID_TRIANGLE: { - local_vid = t->elems_data.tris[local_eid].local_vids[ith_vertex]; - if ( local_vid == -1 ) { - global_vid = - t->elems.tris[local_eid].global_vids[ith_vertex]; - local_vid = _h5_search_idmap ( - &t->map_vertex_g2l, global_vid ); - t->elems_data.tris[local_eid].local_vids[ith_vertex] = - local_vid; - } - break; - } - default: - return h5_error_internal ( f, __FILE__, __func__, __LINE__ ); - } - return local_vid; -} - /*! Return the coordinates of the i-th vertex of the element given by its local element id. For triangles \c i is in \c [0,1,2], for tetraheda \c i is in \c [0,1,2,3]. -*/ -static h5_float64_t* -_get_vertex_of_elem ( - h5_file_t * f, - int ith_vertex, - h5_id_t local_eid - ) { - struct h5t_fdata *t = f->t; - h5_id_t local_vid = _get_local_vid_of_elem ( - f, ith_vertex, local_eid ); - if ( local_vid == -1 ) - return NULL; - return t->vertices[local_vid].P; -} + t->elems_ldta[local_eid].local_vids[i] +*/ +#define _get_vertex_of_elem( f, i, local_eid ) \ + (f->t->vertices[ f->t->elems_ldta[local_eid].local_vids[i] ].P) @@ -385,7 +309,7 @@ _search_elem ( h5_file_t *f, h5_id_t * const local_vids /* local vertex ids */ ) { - struct h5t_fdata *t = f->t; + h5t_fdata_t *t = f->t; _h5t_sort_local_vids ( f, local_vids, t->mesh_type ); @@ -396,7 +320,7 @@ _search_elem ( register int mid = (low + high) / 2; h5_id_t local_eid = t->sorted_elems[0].items[mid]; - h5_id_t *elem2 = t->elems_data.tets[local_eid].local_vids; + h5_id_t *elem2 = t->elems_ldta[local_eid].local_vids; int diff = _vcmp_elems ( f, elem1, elem2 ); if ( diff < 0 ) high = mid - 1; @@ -405,15 +329,7 @@ _search_elem ( else return mid; // found } - switch ( t->mesh_type ) { - case H5_OID_TETRAHEDRON: - return _h5t_error_local_tet_id_nexist ( f, local_vids ); - case H5_OID_TRIANGLE: - return _h5t_error_local_triangle_id_nexist ( f, local_vids ); - default: - return h5_error_internal( f, __FILE__, __func__, __LINE__ ); - } - return -(low+1); // not found + return _h5t_error_local_elem_nexist ( f, local_vids ); } /*! @@ -425,7 +341,7 @@ h5t_get_local_eid ( h5_file_t *f, h5_id_t * const local_vids /* IN/OUT: local vertex id's */ ) { - struct h5t_fdata *t = f->t; + h5t_fdata_t *t = f->t; h5_id_t local_eid; TRY ( local_eid = _search_elem ( f, local_vids ) ); @@ -488,17 +404,16 @@ h5t_map_local_eid2global ( h5_file_t *f, const h5_id_t local_eid ) { - struct h5t_fdata *t = f->t; + h5t_fdata_t *t = f->t; + + if ( local_eid < 0 || local_eid > t->num_elems[t->num_levels-1] ) + return HANDLE_H5_OUT_OF_RANGE_ERR ( + f, _h5t_oid_names[t->mesh_type], local_eid ); switch ( t->mesh_type ) { case H5_OID_TETRAHEDRON: - if ( local_eid < 0 || local_eid > t->num_elems[t->num_levels-1] ) - return HANDLE_H5_OUT_OF_RANGE_ERR ( f, "tet", local_eid ); return t->elems.tets[local_eid].global_eid; case H5_OID_TRIANGLE: - if ( local_eid < 0 || local_eid > t->num_elems[t->num_levels-1] ) - return HANDLE_H5_OUT_OF_RANGE_ERR ( - f, "triangle", local_eid ); return t->elems.tris[local_eid].global_eid; default: return h5_error_internal ( f, __FILE__, __func__, __LINE__ ); @@ -516,9 +431,6 @@ h5t_get_global_eid ( struct h5t_fdata *t = f->t; h5_id_t local_vids[H5_MAX_VERTICES_PER_ELEM]; - if ( t->vertices == NULL ) { - TRY ( _h5t_read_mesh ( f ) ); - } TRY ( h5t_map_global_vids2local ( f, global_vids, @@ -529,130 +441,6 @@ h5t_get_global_eid ( return h5t_map_local_eid2global ( f, local_eid ); } -static int -_search_ith_vertex_in_elem ( - h5_file_t * const f, - const int i, - h5_id_t local_vid - ) { - struct h5t_fdata *t = f->t; - - register h5_id_t low = 0; - register h5_id_t high = t->sorted_elems[i].num_items - 1; - register h5_float64_t *vertex1 = t->vertices[local_vid].P; - - while (low <= high) { - register int mid = (low + high) / 2; - - h5_id_t local_eid = t->sorted_elems[i].items[mid]; - h5_id_t local_vid2 = t->elems_data.tets[local_eid].local_vids[i]; - h5_float64_t *vertex2 = t->vertices[local_vid2].P; - int diff = _cmp_vertices ( vertex1, vertex2 ); - - if ( diff < 0 ) - high = mid - 1; - else if ( diff > 0 ) - low = mid + 1; - else - return mid; // found - } - return -(low+1); // not found -} - -static h5_id_t -_tetm_contain_triangle ( - h5_file_t *f, - const h5_id_t * const local_vids, - int i, - h5_id_t local_eid - ) { - h5t_fdata_t *t = f->t; - - h5_id_t *local_vids_of_elem = t->elems_data.tets[local_eid].local_vids; - if ( i == 0 && - local_vids[1] == local_vids_of_elem[1] && - local_vids[2] == local_vids_of_elem[2] - ) return 0; - else if ( i == 0 && - local_vids[1] == local_vids_of_elem[1] && - local_vids[2] == local_vids_of_elem[3] - ) return 1; - else if ( i == 0 && - local_vids[1] == local_vids_of_elem[2] && - local_vids[2] == local_vids_of_elem[3] - ) return 2; - else if ( i == 1 && - local_vids[1] == local_vids_of_elem[2] && - local_vids[2] == local_vids_of_elem[3] - ) return 3; - return H5_NOK; -} - -/*! - Search for triangle given by local vertex id in tetrahdral mesh. - - \return unique local triangle id - */ -h5_id_t -_tetm_search_triangle ( - h5_file_t *f, - h5_id_t * const local_vids - ) { - struct h5t_fdata *t = f->t; - - _h5t_sort_local_vids ( f, local_vids, 3 ); - - /* - search for vid(tri,0) in the tuple of all 0th vertices of all tets - if there is one: - take the smallest tet with vid(tri,0) == vid(tet,0) - loop over all tets with vid(tri,0) == vid(tet,0) - until we find a tet the triangle is belonging to. - else - search for vid(tri,0) in the tuple of all 1st vertices of - all tets - if there is one: - take the smallest tet with - vid(tri,0) == vid(tet,0) - loop over all tets with - vid(tri,0) == vid(tet,0) - until we find a tet the triangle is belonging to. - */ - - int i; - h5_id_t idx[2]; - h5_id_t local_eid[2]; - h5_id_t tidx[2]; - for ( i = 0; i < 2; i++ ) { - idx[i] = _search_ith_vertex_in_elem ( f, i, local_vids[0] ); - - while ( idx[i] > 0 && /* get leftmost */ - local_vids[0] == _get_local_vid_of_elem ( - f, i, t->sorted_elems[0].items[idx[i]-1] ) ) - idx[i]--; - - do { - /* check whether triangle is in elem given by local id */ - local_eid[i] = t->sorted_elems[i].items[idx[i]]; - tidx[i] = _tetm_contain_triangle ( - f, local_vids, i, local_eid[i] ); - if ( tidx[i] >= 0 ) break; - idx[i]++; - } while ( local_vids[0] == _get_local_vid_of_elem ( - f, i, local_eid[i] ) ); - } - if ( idx[0] < 0 && idx[1] < 0 ) return -1; - if ( idx[0] < 0 ) return _h5t_build_triangle_id ( tidx[1], local_eid[1] ); - if ( idx[1] < 0 ) return _h5t_build_triangle_id ( tidx[0], local_eid[0] ); - - if ( _cmp_elems( f, local_eid[0], local_eid[1] ) < 0 ) - return _h5t_build_triangle_id ( tidx[0], local_eid[0] ); - else - return _h5t_build_triangle_id ( tidx[1], local_eid[1] ); - - return -1; -} - /*! */ @@ -663,10 +451,6 @@ h5t_get_global_triangle_id ( ) { struct h5t_fdata *t = f->t; - if ( t->vertices == NULL ) { - TRY ( _h5t_read_mesh ( f ) ); - } - switch ( t->mesh_type ) { case H5_OID_TETRAHEDRON: { h5_id_t local_vids[3]; @@ -693,17 +477,16 @@ h5t_get_local_triangle_id ( h5_file_t * const f, h5_id_t * const local_vids ) { - struct h5t_fdata *t = f->t; - if ( t->vertices == NULL ) { - TRY ( _h5t_read_mesh ( f ) ); - } + h5t_fdata_t *t = f->t; + switch ( t->mesh_type ) { case H5_OID_TETRAHEDRON: { - h5_id_t local_tid = _tetm_search_triangle ( f, local_vids ); - if ( local_tid == -1 ) { - return _h5t_error_local_triangle_id_nexist( f, local_vids ); - } - return local_tid; + h5_td_node_t *td; + TRY ( _h5t_find_td ( + f, + &td, + local_vids ) ); + return td->value.items[0]; } case H5_OID_TRIANGLE: return h5t_get_local_eid ( f, local_vids ); @@ -712,6 +495,31 @@ h5t_get_local_triangle_id ( } } +h5_id_t +h5t_get_local_triangle_id2 ( + h5_file_t * const f, + h5_id_t face_id, + h5_id_t local_eid + ) { + h5t_fdata_t *t = f->t; + + switch ( t->mesh_type ) { + case H5_OID_TETRAHEDRON: { + h5_td_node_t *td; + TRY ( _h5t_find_td2 ( + f, + &td, + face_id, + local_eid) ); + return td->value.items[0]; + } + case H5_OID_TRIANGLE: + return local_eid; + default: + return h5_error_internal ( f, __FILE__, __func__, __LINE__ ); + } +} + /*! Get local element id for an element given by its global id. @@ -817,117 +625,24 @@ _h5t_rebuild_global_2_local_map_of_elems ( h5_id_t local_eid = t->cur_level > 0 ? t->num_elems[t->cur_level-1] : 0; h5_id_t num_elems = t->num_elems[t->num_levels-1]; h5_idmap_el_t *item = &t->map_elem_g2l.items[local_eid]; - - switch ( t->mesh_type ) { - case H5_OID_TETRAHEDRON: { - h5_tet_t *elem = &t->elems.tets[local_eid]; - for ( ; local_eid < num_elems; local_eid++, item++, elem++ ) { - item->global_id = elem->global_eid; - item->local_id = local_eid; - t->map_elem_g2l.num_items++; - } - break; - } - case H5_OID_TRIANGLE: { - h5_triangle_t *elem = &t->elems.tris[local_eid]; - for ( ; local_eid < num_elems; local_eid++, item++, elem++ ) { - item->global_id = elem->global_eid; - item->local_id = local_eid; - t->map_elem_g2l.num_items++; - } - break; - } - default: - return h5_error_internal( f, __FILE__, __func__, __LINE__ ); + size_t offset = _h5t_sizeof_elem[t->mesh_type]; + void *elemp = t->elems.data + local_eid*offset; + for ( ; + local_eid < num_elems; + local_eid++, + item++, + elemp+=offset ) { + h5_elem_t *elem = (h5_elem_t*)elemp; + + item->global_id = elem->global_eid; + item->local_id = local_eid; + t->map_elem_g2l.num_items++; } _h5_sort_idmap ( &t->map_elem_g2l ); return H5_SUCCESS; } -/* - setup structure "elems_data" with local ids for each element: - - translate the global vertex id's of each element to their - local id's - - translate the global parent id of each element to the - corresponding local id. -*/ -h5_err_t -_h5t_rebuild_elems_data ( - h5_file_t * const f - ) { - h5t_fdata_t *t = f->t; - h5_id_t local_eid = 0; - h5_id_t num_elems = t->num_elems[t->num_levels-1]; - h5_id_t level_id = 0; - switch ( t->mesh_type ) { - case H5_OID_TETRAHEDRON: { - h5_tet_t *el; - h5_tet_data_t *el_data; - - for ( local_eid=0, el=t->elems.tets, el_data=t->elems_data.tets; - local_eid < num_elems; - local_eid++, el++, el_data++ ) { - - TRY( h5t_map_global_vids2local ( - f, - el->global_vids, - t->mesh_type, - el_data->local_vids - ) ); - if ( el->global_parent_eid >= 0 ) - TRY ( el_data->local_parent_eid = - h5t_map_global_eid2local ( - f, - el->global_parent_eid ) ); - - if ( el->global_child_eid >= 0 ) - TRY ( el_data->local_child_eid = - h5t_map_global_eid2local ( - f, - el->global_child_eid ) ); - - if ( local_eid >= t->num_elems[level_id] ) { - level_id++; - } - el_data->level_id = level_id; - } - break; - } - case H5_OID_TRIANGLE: { - h5_triangle_t *el; - h5_triangle_data_t *el_data; - - for ( local_eid=0, el=t->elems.tris, el_data=t->elems_data.tris; - local_eid < num_elems; - local_eid++, el++, el_data++ ) { - - TRY( h5t_map_global_vids2local ( - f, - el->global_vids, - t->mesh_type, - el_data->local_vids - ) ); - if ( el->global_parent_eid >= 0 ) - TRY ( el_data->local_parent_eid = - h5t_map_global_eid2local ( - f, - el->global_parent_eid ) ); - if ( local_eid > t->num_elems_on_level[level_id] ) { - level_id++; - } - el_data->level_id = level_id; - } - break; - } - default: - return h5_error_internal ( - f, __FILE__, __func__, __LINE__ ); - } - - return H5_SUCCESS; -} - /*! \param[in] f file handle \param[in] local_id local ID of entity @@ -942,7 +657,7 @@ h5t_get_local_vids_of_entity ( h5t_fdata_t *t = f->t; h5_id_t face_id = _h5t_get_face_id ( local_id ); h5_id_t local_eid = _h5t_get_elem_id ( local_id ); - h5_tet_data_t *tet_dta = &t->elems_data.tets[local_eid]; + h5_elem_ldta_t *tet_dta = &t->elems_ldta[local_eid]; switch ( _h5t_get_entity_type ( local_id ) ) { case H5T_ELEM_TYPE_VERTEX: { diff --git a/src/h5_core/h5t_map.h b/src/h5_core/h5t_map.h index d65f948..876965e 100644 --- a/src/h5_core/h5t_map.h +++ b/src/h5_core/h5t_map.h @@ -69,6 +69,13 @@ h5t_get_local_triangle_id ( h5_id_t * const local_vids ); +h5_id_t +h5t_get_local_triangle_id2 ( + h5_file_t * const f, + h5_id_t face_id, + h5_id_t local_eid + ); + h5_id_t h5t_get_global_triangle_id ( h5_file_t * const f, diff --git a/src/h5_core/h5t_map_private.h b/src/h5_core/h5t_map_private.h index 7672adc..fa3030f 100644 --- a/src/h5_core/h5t_map_private.h +++ b/src/h5_core/h5t_map_private.h @@ -35,9 +35,4 @@ _h5t_rebuild_global_2_local_map_of_elems ( h5_file_t * const f ); -h5_err_t -_h5t_rebuild_elems_data ( - h5_file_t * const f - ); - #endif diff --git a/src/h5_core/h5t_openclose.c b/src/h5_core/h5t_openclose.c index 3d1a7c7..0491c69 100644 --- a/src/h5_core/h5t_openclose.c +++ b/src/h5_core/h5t_openclose.c @@ -373,37 +373,33 @@ h5_err_t _h5t_open_meshes_group ( h5_file_t * const f ) { - struct h5t_fdata *t = f->t; + h5t_fdata_t *t = f->t; if ( t->topo_gid < 0 ) { - h5_err_t h5err = _h5t_open_topo_group ( f ); - if ( h5err < 0 ) return h5err; + TRY ( _h5t_open_topo_group ( f ) ); } - switch ( t->mesh_type) { - case H5_OID_TETRAHEDRON: - t->meshes_gid = _h5_open_group ( f, t->topo_gid, "TetMeshes" ); - break; - case H5_OID_TRIANGLE: - t->meshes_gid = _h5_open_group ( f, t->topo_gid, "TriangleMeshes" ); - break; - default: - t->meshes_gid = -1; - } - return (h5_err_t)t->meshes_gid; + TRY ( (t->meshes_gid = _h5_open_group ( + f, + t->topo_gid, + _h5t_meshes_grpnames[t->mesh_type] ) ) ); + + return H5_SUCCESS; } h5_err_t _h5t_open_mesh_group ( h5_file_t * const f ) { - struct h5t_fdata *t = f->t; + h5t_fdata_t *t = f->t; if ( t->meshes_gid < 0 ) { - h5_err_t h5err = _h5t_open_meshes_group ( f ); - if ( h5err < 0 ) return h5err; + TRY ( _h5t_open_meshes_group ( f ) ); } - t->mesh_gid = _h5_open_group ( f, t->meshes_gid, t->mesh_name ); - return (h5_err_t)t->mesh_gid; + TRY ( ( t->mesh_gid = _h5_open_group ( + f, + t->meshes_gid, + t->mesh_name ) ) ); + return H5_SUCCESS; } /* @@ -415,7 +411,7 @@ h5t_open_mesh ( h5_id_t id, const h5_oid_t type ) { - struct h5t_fdata *t = f->t; + h5t_fdata_t *t = f->t; TRY( _h5t_close_mesh ( f ) ); @@ -449,8 +445,8 @@ h5t_open_mesh ( t->cur_mesh = id; if ( id != t->num_meshes ) { /* open existing */ - t->num_levels = h5t_get_num_levels ( f ); - if ( t->num_levels < 0 ) return t->num_levels; + TRY ( _h5t_read_mesh ( f ) ); + } else { /* append new */ t->num_meshes++; t->mesh_changed = id; @@ -486,8 +482,8 @@ _release_memory ( _h5_free ( f, t->elems.data ); t->elems.data = NULL; _h5_free ( f, t->num_elems ); - _h5_free ( f, t->elems_data.data ); - t->elems_data.data = NULL; + _h5_free ( f, t->elems_ldta ); + t->elems_ldta = NULL; _h5_free ( f, t->num_elems_on_level ); t->num_elems_on_level = NULL; _h5_free ( f, t->map_elem_g2l.items ); diff --git a/src/h5_core/h5t_readwrite.c b/src/h5_core/h5t_readwrite.c index f526327..69d6104 100644 --- a/src/h5_core/h5t_readwrite.c +++ b/src/h5_core/h5t_readwrite.c @@ -108,6 +108,28 @@ _h5t_write_mesh ( return H5_SUCCESS; } +static h5_size_t +_read_num_levels ( + h5_file_t * f + ) { + h5t_fdata_t *t = f->t; + hid_t dataset_id; + hid_t diskspace_id; + hssize_t size; + + if ( t->cur_mesh < 0 ) { + return _h5t_error_undef_mesh ( f ); + } + TRY ( dataset_id = _h5_open_dataset ( f, t->mesh_gid, "NumVertices" ) ); + TRY ( diskspace_id = _h5_get_dataset_space ( f, dataset_id ) ); + TRY ( size = _h5_get_npoints_of_space ( f, diskspace_id ) ); + TRY ( _h5_close_dataspace( f, diskspace_id ) ); + + t->num_levels = size; + return size; +} + + static hid_t _open_mem_space_vertices ( h5_file_t * const f, @@ -124,8 +146,8 @@ _open_file_space_vertices ( return H5S_ALL; } -h5_err_t -_h5t_read_num_vertices ( +static h5_err_t +_read_num_vertices ( h5_file_t * const f ) { struct h5t_fdata *t = f->t; @@ -146,18 +168,12 @@ _h5t_read_num_vertices ( return H5_SUCCESS; } -h5_err_t -_h5t_read_vertices ( +static h5_err_t +_read_vertices ( h5_file_t * f ) { struct h5t_fdata *t = f->t; - if ( t->mesh_gid < 0 ) { - TRY( _h5t_open_mesh_group ( f ) ); - } - if ( t->num_vertices == NULL ) { - TRY( _h5t_read_num_vertices ( f ) ); - } TRY( _h5t_alloc_num_vertices ( f, t->num_vertices[t->num_levels-1] ) ); TRY( _h5_read ( @@ -175,8 +191,8 @@ _h5t_read_vertices ( -h5_err_t -_h5t_read_num_elems ( +static h5_err_t +_read_num_elems ( h5_file_t * const f ) { struct h5t_fdata *t = f->t; @@ -222,19 +238,62 @@ _open_file_space_elems ( return H5S_ALL; } -h5_err_t -_h5t_read_elems ( +/* + setup structure "elems_data" with local ids for each element: + - translate the global vertex id's of each element to their + local id's + - translate the global parent id of each element to the + corresponding local id. +*/ +static h5_err_t +_build_elems_ldta ( + h5_file_t * const f + ) { + h5t_fdata_t *t = f->t; + h5_id_t local_eid = 0; + h5_id_t num_elems = t->num_elems[t->num_levels-1]; + h5_id_t level_id = 0; + + void *elp = t->elems.data; + h5_elem_t *el; + h5_elem_ldta_t *el_data = t->elems_ldta; + + for ( local_eid=0; + local_eid < num_elems; + local_eid++, elp+=_h5t_sizeof_elem[t->mesh_type], el_data++ ) { + el = (h5_elem_t*)elp; + TRY( h5t_map_global_vids2local ( + f, + el->global_vids, + t->mesh_type, + el_data->local_vids + ) ); + if ( el->global_parent_eid >= 0 ) + TRY ( el_data->local_parent_eid = + h5t_map_global_eid2local ( + f, + el->global_parent_eid ) ); + + if ( el->global_child_eid >= 0 ) + TRY ( el_data->local_child_eid = + h5t_map_global_eid2local ( + f, + el->global_child_eid ) ); + + if ( local_eid >= t->num_elems[level_id] ) { + level_id++; + } + el_data->level_id = level_id; + } + + return H5_SUCCESS; +} + +static h5_err_t +_read_elems ( h5_file_t * f ) { - struct h5t_fdata *t = f->t; - - if ( t->mesh_gid < 0 ) { - TRY( _h5t_open_mesh_group ( f ) ); - } - - if ( t->num_elems == NULL ) { - TRY( _h5t_read_num_elems ( f ) ); - } + h5t_fdata_t *t = f->t; TRY( _h5t_alloc_num_elems ( f, 0, t->num_elems[t->num_levels-1] ) ); TRY( _h5_read ( @@ -247,7 +306,7 @@ _h5t_read_elems ( TRY ( _h5t_sort_elems ( f ) ); TRY ( _h5t_rebuild_global_2_local_map_of_elems ( f ) ); - TRY ( _h5t_rebuild_elems_data ( f ) ); + TRY ( _build_elems_ldta ( f ) ); TRY ( _h5t_rebuild_adj_data ( f ) ); return H5_SUCCESS; } @@ -256,10 +315,14 @@ h5_err_t _h5t_read_mesh ( h5_file_t *f ) { - - TRY ( _h5t_read_vertices ( f ) ); - TRY ( _h5t_read_elems ( f ) ); - + if ( f->t->mesh_gid < 0 ) { + TRY( _h5t_open_mesh_group ( f ) ); + } + TRY ( _read_num_levels ( f ) ); + TRY ( _read_num_vertices ( f ) ); + TRY ( _read_num_elems ( f ) ); + TRY ( _read_vertices ( f ) ); + TRY ( _read_elems ( f ) ); return H5_SUCCESS; } diff --git a/src/h5_core/h5t_readwrite.h b/src/h5_core/h5t_readwrite.h index e20d093..ffcaba9 100644 --- a/src/h5_core/h5t_readwrite.h +++ b/src/h5_core/h5t_readwrite.h @@ -1,19 +1,4 @@ #ifndef __H5T_READWRITE_H #define __H5T_READWRITE_H -h5_err_t -_h5t_write_mesh ( - h5_file_t * f - ); - -h5_err_t -_h5t_read_vertices ( - h5_file_t * f - ); - -h5_err_t -_h5t_read_elems ( - h5_file_t * f - ); - #endif diff --git a/src/h5_core/h5t_readwrite_private.h b/src/h5_core/h5t_readwrite_private.h index 5b016f8..feacedd 100644 --- a/src/h5_core/h5t_readwrite_private.h +++ b/src/h5_core/h5t_readwrite_private.h @@ -4,26 +4,21 @@ h5_err_t _h5t_write_obj ( h5_file_t * f, - const hid_t gid, - const hsize_t current_dims, - const hsize_t max_dims, - const hid_t tid, + const hid_t gid, + const hsize_t current_dims, + const hsize_t max_dims, + const hid_t tid, const void * const object, const char * const dsname ); h5_err_t _h5t_read_mesh ( - h5_file_t *f - ); - -h5_err_t -_h5t_read_num_elems ( h5_file_t * const f ); h5_err_t -_h5t_read_num_vertices ( +_h5t_write_mesh ( h5_file_t * const f ); diff --git a/src/h5_core/h5t_storemesh.c b/src/h5_core/h5t_storemesh.c index b5b4108..8fb0e56 100644 --- a/src/h5_core/h5t_storemesh.c +++ b/src/h5_core/h5t_storemesh.c @@ -56,14 +56,45 @@ _h5t_assign_global_vertex_ids ( } /*! - Assign unique global id's to elements. - - Nothing to do in serial case. + Assign unique global IDs to new elements. */ -h5_err_t -_h5t_assign_global_elem_ids ( +static h5_err_t +_assign_global_elem_ids ( h5_file_t * const f ) { + h5t_fdata_t *t = f->t; + h5_id_t local_eid; + + if ( t->cur_level < 0 ) return H5_SUCCESS; /* no level defined */ + + /* + simple in serial runs: global_id = local_id + */ + for ( local_eid = (t->cur_level == 0) ? 0 : t->num_elems[t->cur_level-1]; + local_eid < t->num_elems[t->cur_level]; + local_eid++ ) { + h5_elem_t *elem; + h5_elem_ldta_t *elem_ldta = &t->elems_ldta[local_eid]; + switch ( t->mesh_type ) { + case H5_OID_TETRAHEDRON: + elem = (h5_elem_t*)&t->elems.tets[local_eid]; + break; + case H5_OID_TRIANGLE: + elem = (h5_elem_t*)&t->elems.tris[local_eid]; + break; + default: + return h5_error_internal ( + f, __FILE__, __func__, __LINE__ ); + } + elem->global_eid = local_eid; + elem->global_parent_eid = elem_ldta->local_parent_eid; + elem->global_child_eid = elem_ldta->local_child_eid; + int i; + for ( i = 0; i < t->mesh_type; i++ ) { + elem->global_vids[i] = elem_ldta->local_vids[i]; + } + } + return H5_SUCCESS; } @@ -199,34 +230,49 @@ _h5t_alloc_num_elems ( ) { h5t_fdata_t *t = f->t; size_t sizeof_elem = 0; - size_t sizeof_lelem = 0; - switch ( t->mesh_type ) { - case H5_OID_TETRAHEDRON: - sizeof_elem = sizeof ( t->elems.tets[0] ); - sizeof_lelem = sizeof ( t->elems_data.tets[0] ); - break; - case H5_OID_TRIANGLE: - sizeof_elem = sizeof ( t->elems.tris[0] ); - sizeof_lelem = sizeof ( t->elems_data.tris[0] ); - break; - default: - return h5_error_internal ( - f, __FILE__, __func__, __LINE__ ); + /* allocl mem for elements */ + TRY ( t->elems.data = _h5_alloc ( + f, + t->elems.data, + new_num_elems * _h5t_sizeof_elem[t->mesh_type] ) ); + memset ( + t->elems.data+cur_num_elems*sizeof_elem, + -1, + (new_num_elems-cur_num_elems)*sizeof_elem ); + + /* alloc mem for local data of elements */ + TRY ( t->elems_ldta = _h5_alloc ( + f, + t->elems_ldta, + new_num_elems * sizeof ( t->elems_ldta[0] ) ) ); + memset ( + t->elems_ldta+cur_num_elems*sizeof ( t->elems_ldta[0] ), + -1, + (new_num_elems-cur_num_elems)*sizeof ( t->elems_ldta[0] ) ); + + /* alloc mem for local vertex IDs of elements */ + TRY ( t->elems_lvids = _h5_alloc ( + f, + t->elems_lvids, + new_num_elems*sizeof(t->elems_lvids[0])*t->mesh_type ) ); + memset ( + t->elems_lvids+cur_num_elems*sizeof(t->elems_lvids[0])*t->mesh_type, + -1, + (new_num_elems-cur_num_elems)*sizeof(t->elems_lvids[0])*t->mesh_type ); + + /* re-init pointer to local vertex id in local data structure */ + int offset = t->mesh_type; + h5_id_t *p = t->elems_lvids; + h5_id_t id; + for ( id = 0; id < new_num_elems; id++, p+=offset ) { + t->elems_ldta[id].local_vids = p; } - size_t size = new_num_elems * sizeof_elem; - TRY ( t->elems.data = _h5_alloc ( f, t->elems.data, size ) ); + /* alloc mem for global to local ID mapping */ + TRY ( _h5_alloc_idmap ( f, &t->map_elem_g2l, new_num_elems ) ); - size = new_num_elems * sizeof_lelem; - TRY ( t->elems_data.data = _h5_alloc ( f, t->elems_data.data, size ) ); - - memset ( - t->elems_data.data+cur_num_elems*sizeof_lelem, - -1, - (new_num_elems-cur_num_elems) * sizeof_lelem ); - - return _h5_alloc_idmap ( f, &t->map_elem_g2l, new_num_elems ); + return H5_SUCCESS; } h5_err_t @@ -285,15 +331,7 @@ h5t_store_elem ( local_parent_eid ); } - switch ( t->mesh_type ) { - case H5_OID_TETRAHEDRON: - return _h5t_store_tet ( f, local_parent_eid, local_vids ); - case H5_OID_TRIANGLE: - return _h5t_store_triangle ( f, local_parent_eid, local_vids ); - default: - return h5_error_internal ( - f, __FILE__, __func__, __LINE__ ); - } + return _h5t_store_elem ( f, local_parent_eid, local_vids ); } /*! @@ -304,50 +342,23 @@ h5t_store_elem ( \param[in] local_vids Local vertex id's defining the tetrahedron. */ h5_id_t -_h5t_store_tet ( +_h5t_store_elem ( h5_file_t * const f, const h5_id_t local_parent_eid, - const h5_id_t local_vids[4] + const h5_id_t *local_vids ) { - struct h5t_fdata *t = f->t; - t->level_changed = 1; - h5_id_t local_eid = ++t->last_stored_eid; - h5_tetrahedron_t *tet = &t->elems.tets[local_eid]; - h5_tet_data_t *tet_data = &t->elems_data.tets[local_eid]; - tet->global_eid = local_eid; - tet->global_parent_eid = local_parent_eid; - tet->global_child_eid = -1; - - memcpy ( &tet->global_vids, local_vids, sizeof ( tet->global_vids ) ); - _h5t_sort_local_vids ( f, tet->global_vids, 4 ); - memcpy ( &tet_data->local_vids, &tet->global_vids, - sizeof ( tet->global_vids ) ); - - return local_eid; -} - - -h5_id_t -_h5t_store_triangle ( - h5_file_t * const f, - const h5_id_t local_parent_eid, - const h5_id_t vids[3] - ) { - - struct h5t_fdata *t = f->t; + h5t_fdata_t *t = f->t; t->level_changed = 1; h5_id_t local_eid = ++t->last_stored_eid; - h5_triangle_t *tri = &t->elems.tris[local_eid]; - h5_triangle_data_t *tri_data = &t->elems_data.tris[local_eid]; - tri->global_eid = local_eid; - tri->global_parent_eid = local_parent_eid; - tri->global_child_eid = -1; + h5_elem_ldta_t *elem_ldta = &t->elems_ldta[local_eid]; - memcpy ( &tri->global_vids, vids, sizeof ( tri->global_vids ) ); - _h5t_sort_local_vids ( f, tri->global_vids, 3 ); - memcpy ( &tri_data->local_vids, &tri->global_vids, - sizeof ( tri->global_vids ) ); + elem_ldta->local_parent_eid = local_parent_eid; + elem_ldta->local_child_eid = -1; + elem_ldta->level_id = t->cur_level; + memcpy ( elem_ldta->local_vids, local_vids, + sizeof (*local_vids) * t->mesh_type ); + _h5t_sort_local_vids ( f, elem_ldta->local_vids, t->mesh_type ); return local_eid; } @@ -360,10 +371,9 @@ h5t_end_store_elems ( t->storing_data = 0; t->num_elems[t->cur_level] = t->last_stored_eid+1; - TRY ( _h5t_assign_global_elem_ids ( f ) ); + TRY ( _assign_global_elem_ids ( f ) ); TRY ( _h5t_sort_elems ( f ) ); TRY ( _h5t_rebuild_global_2_local_map_of_elems ( f ) ); - TRY ( _h5t_rebuild_elems_data ( f ) ); return H5_SUCCESS; } @@ -474,46 +484,46 @@ _h5t_refine_triangle ( local_vids[0] = _h5t_bisect_edge( f, - t->elems_data.tris[local_eid].local_vids[0], - t->elems_data.tris[local_eid].local_vids[1] ); + t->elems_ldta[local_eid].local_vids[0], + t->elems_ldta[local_eid].local_vids[1] ); local_vids[1] = _h5t_bisect_edge( f, - t->elems_data.tris[local_eid].local_vids[0], - t->elems_data.tris[local_eid].local_vids[2] ); + t->elems_ldta[local_eid].local_vids[0], + t->elems_ldta[local_eid].local_vids[2] ); local_vids[2] = _h5t_bisect_edge( f, - t->elems_data.tris[local_eid].local_vids[1], - t->elems_data.tris[local_eid].local_vids[2] ); + t->elems_ldta[local_eid].local_vids[1], + t->elems_ldta[local_eid].local_vids[2] ); h5_id_t elem_local_vids[4]; /* 0 */ - elem_local_vids[0] = t->elems_data.tets[local_eid].local_vids[0]; + elem_local_vids[0] = t->elems_ldta[local_eid].local_vids[0]; elem_local_vids[1] = local_vids[0]; elem_local_vids[2] = local_vids[1]; - TRY ( local_child_eid = _h5t_store_triangle ( + TRY ( local_child_eid = _h5t_store_elem ( f, local_eid, elem_local_vids ) ); if ( local_eid >= 0 ) { t->elems.tris[local_eid].global_child_eid = local_child_eid; - t->elems_data.tris[local_eid].local_child_eid = local_child_eid; + t->elems_ldta[local_eid].local_child_eid = local_child_eid; t->num_elems_on_level[t->cur_level]--; } /* 1 */ - elem_local_vids[0] = t->elems_data.tets[local_eid].local_vids[1]; + elem_local_vids[0] = t->elems_ldta[local_eid].local_vids[1]; elem_local_vids[1] = local_vids[0]; elem_local_vids[2] = local_vids[2]; - TRY ( _h5t_store_triangle ( + TRY ( _h5t_store_elem ( f, local_eid, elem_local_vids ) ); /* 2 */ - elem_local_vids[0] = t->elems_data.tets[local_eid].local_vids[2]; + elem_local_vids[0] = t->elems_ldta[local_eid].local_vids[2]; elem_local_vids[1] = local_vids[1]; elem_local_vids[2] = local_vids[2]; - TRY ( _h5t_store_triangle ( + TRY ( _h5t_store_elem ( f, local_eid, elem_local_vids ) ); @@ -521,7 +531,7 @@ _h5t_refine_triangle ( elem_local_vids[0] = local_vids[0]; elem_local_vids[1] = local_vids[1]; elem_local_vids[2] = local_vids[2]; - TRY ( _h5t_store_triangle ( + TRY ( _h5t_store_elem ( f, local_eid, elem_local_vids ) ); @@ -548,34 +558,34 @@ _h5t_refine_tet ( H5_ERR_INVAL, "Tetrahedron %lld already refined.", local_eid ); - local_vids[0] = t->elems_data.tets[local_eid].local_vids[0]; - local_vids[1] = t->elems_data.tets[local_eid].local_vids[1]; - local_vids[2] = t->elems_data.tets[local_eid].local_vids[2]; - local_vids[3] = t->elems_data.tets[local_eid].local_vids[3]; + local_vids[0] = t->elems_ldta[local_eid].local_vids[0]; + local_vids[1] = t->elems_ldta[local_eid].local_vids[1]; + local_vids[2] = t->elems_ldta[local_eid].local_vids[2]; + local_vids[3] = t->elems_ldta[local_eid].local_vids[3]; local_vids[4] = _h5t_bisect_edge( f, - t->elems_data.tets[local_eid].local_vids[0], - t->elems_data.tets[local_eid].local_vids[1] ); + t->elems_ldta[local_eid].local_vids[0], + t->elems_ldta[local_eid].local_vids[1] ); local_vids[5] = _h5t_bisect_edge( f, - t->elems_data.tets[local_eid].local_vids[0], - t->elems_data.tets[local_eid].local_vids[2] ); + t->elems_ldta[local_eid].local_vids[0], + t->elems_ldta[local_eid].local_vids[2] ); local_vids[6] = _h5t_bisect_edge( f, - t->elems_data.tets[local_eid].local_vids[0], - t->elems_data.tets[local_eid].local_vids[3] ); + t->elems_ldta[local_eid].local_vids[0], + t->elems_ldta[local_eid].local_vids[3] ); local_vids[7] = _h5t_bisect_edge( f, - t->elems_data.tets[local_eid].local_vids[1], - t->elems_data.tets[local_eid].local_vids[2] ); + t->elems_ldta[local_eid].local_vids[1], + t->elems_ldta[local_eid].local_vids[2] ); local_vids[8] = _h5t_bisect_edge( f, - t->elems_data.tets[local_eid].local_vids[1], - t->elems_data.tets[local_eid].local_vids[3] ); + t->elems_ldta[local_eid].local_vids[1], + t->elems_ldta[local_eid].local_vids[3] ); local_vids[9] = _h5t_bisect_edge( f, - t->elems_data.tets[local_eid].local_vids[2], - t->elems_data.tets[local_eid].local_vids[3] ); + t->elems_ldta[local_eid].local_vids[2], + t->elems_ldta[local_eid].local_vids[3] ); /* add new tets @@ -587,7 +597,7 @@ _h5t_refine_tet ( new_tet_local_vids[1] = local_vids[6]; // (03) new_tet_local_vids[2] = local_vids[5]; // (02) new_tet_local_vids[3] = local_vids[4]; // (01) - TRY ( local_child_eid = _h5t_store_tet ( + TRY ( local_child_eid = _h5t_store_elem ( f, local_eid, new_tet_local_vids ) ); /* 1 */ @@ -595,52 +605,52 @@ _h5t_refine_tet ( new_tet_local_vids[1] = local_vids[8]; // (13) new_tet_local_vids[2] = local_vids[7]; // (12) new_tet_local_vids[3] = local_vids[1]; - TRY ( _h5t_store_tet ( f, local_eid, new_tet_local_vids ) ); + TRY ( _h5t_store_elem ( f, local_eid, new_tet_local_vids ) ); /* 2 */ new_tet_local_vids[0] = local_vids[5]; // (02) new_tet_local_vids[1] = local_vids[9]; // (23) new_tet_local_vids[2] = local_vids[2]; new_tet_local_vids[3] = local_vids[7]; // (12) - TRY ( _h5t_store_tet ( f, local_eid, new_tet_local_vids ) ); + TRY ( _h5t_store_elem ( f, local_eid, new_tet_local_vids ) ); /* 3 */ new_tet_local_vids[0] = local_vids[6]; // (03) new_tet_local_vids[1] = local_vids[3]; new_tet_local_vids[2] = local_vids[9]; // (23) new_tet_local_vids[3] = local_vids[8]; // (13) - TRY ( _h5t_store_tet ( f, local_eid, new_tet_local_vids ) ); + TRY ( _h5t_store_elem ( f, local_eid, new_tet_local_vids ) ); /* 4 */ new_tet_local_vids[0] = local_vids[6]; // (03) new_tet_local_vids[1] = local_vids[5]; // (02) new_tet_local_vids[2] = local_vids[4]; // (01) new_tet_local_vids[3] = local_vids[8]; // (13) - TRY ( _h5t_store_tet ( f, local_eid, new_tet_local_vids ) ); + TRY ( _h5t_store_elem ( f, local_eid, new_tet_local_vids ) ); /* 5 */ new_tet_local_vids[0] = local_vids[5]; // (02) new_tet_local_vids[1] = local_vids[4]; // (01) new_tet_local_vids[2] = local_vids[8]; // (13) new_tet_local_vids[3] = local_vids[7]; // (12) - TRY ( _h5t_store_tet ( f, local_eid, new_tet_local_vids ) ); + TRY ( _h5t_store_elem ( f, local_eid, new_tet_local_vids ) ); /* 6 */ new_tet_local_vids[0] = local_vids[6]; // (03) new_tet_local_vids[1] = local_vids[5]; // (02) new_tet_local_vids[2] = local_vids[9]; // (23) new_tet_local_vids[3] = local_vids[8]; // (13) - TRY ( _h5t_store_tet ( f, local_eid, new_tet_local_vids ) ); + TRY ( _h5t_store_elem ( f, local_eid, new_tet_local_vids ) ); /* 7 */ new_tet_local_vids[0] = local_vids[5]; // (02) new_tet_local_vids[1] = local_vids[9]; // (23) new_tet_local_vids[2] = local_vids[8]; // (13) new_tet_local_vids[3] = local_vids[7]; // (12) - TRY ( _h5t_store_tet ( f, local_eid, new_tet_local_vids ) ); + TRY ( _h5t_store_elem ( f, local_eid, new_tet_local_vids ) ); t->elems.tets[local_eid].global_child_eid = local_child_eid; - t->elems_data.tets[local_eid].local_child_eid = local_child_eid; + t->elems_ldta[local_eid].local_child_eid = local_child_eid; t->num_elems_on_level[t->cur_level]--; return local_child_eid; diff --git a/src/h5_core/h5t_storemesh_private.h b/src/h5_core/h5t_storemesh_private.h index ef9ff7e..ed62b8a 100644 --- a/src/h5_core/h5t_storemesh_private.h +++ b/src/h5_core/h5t_storemesh_private.h @@ -15,17 +15,10 @@ _h5t_alloc_num_elems ( ); h5_id_t -_h5t_store_triangle ( +_h5t_store_elem ( h5_file_t * const f, const h5_id_t local_parent_eid, - const h5_id_t vids[3] - ); - -h5_id_t -_h5t_store_tet ( - h5_file_t * const f, - const h5_id_t local_parent_eid, - const h5_id_t vids[4] + const h5_id_t vids[] ); diff --git a/src/h5_core/h5t_types_private.h b/src/h5_core/h5t_types_private.h index 74a8b42..895847c 100644 --- a/src/h5_core/h5t_types_private.h +++ b/src/h5_core/h5t_types_private.h @@ -32,7 +32,7 @@ struct h5_tetrahedron { h5_4id_t global_vids; }; -struct h5_element { +struct h5_elem { h5_id_t global_eid; h5_id_t global_parent_eid; h5_id_t global_child_eid; @@ -41,31 +41,15 @@ struct h5_element { typedef struct h5_tetrahedron h5_tetrahedron_t; typedef struct h5_tetrahedron h5_tet_t; -typedef struct h5_element h5_element_t; +typedef struct h5_elem h5_elem_t; -struct h5_triangle_data { +struct h5_elem_ldta { h5_id_t local_parent_eid; h5_id_t local_child_eid; h5_id_t level_id; - h5_3id_t local_vids; + h5_id_t *local_vids; }; -typedef struct h5_triangle_data h5_triangle_data_t; - -struct h5_tet_data { - h5_id_t local_parent_eid; - h5_id_t local_child_eid; - h5_id_t level_id; - h5_4id_t local_vids; -}; -typedef struct h5_tet_data h5_tet_data_t; - -struct h5_element_data { - h5_id_t local_parent_eid; - h5_id_t local_child_eid; - h5_id_t level_id; - h5_id_t local_vids[1]; -}; -typedef struct h5_element_data h5_element_data_t; +typedef struct h5_elem_ldta h5_elem_ldta_t; union h5_elems { @@ -75,12 +59,6 @@ union h5_elems { }; typedef union h5_elems h5_elems_t; -union h5_elems_data { - h5_tet_data_t *tets; - h5_triangle_data_t *tris; - void *data; -}; -typedef union h5_elems_data h5_elems_data_t; /* information about HDF5 dataset @@ -220,7 +198,8 @@ struct h5t_fdata { /*** Elements ***/ h5_elems_t elems; - h5_elems_data_t elems_data; /* local, per element data */ + h5_elem_ldta_t *elems_ldta; /* local, per element data */ + h5_id_t *elems_lvids; h5_size_t *num_elems; h5_size_t *num_elems_on_level; h5_idmap_t map_elem_g2l; /* map global id to local id */