diff --git a/src/h5core/h5_hdf5.c b/src/h5core/h5_hdf5.c index 0c53e1d..0b9f6c9 100644 --- a/src/h5core/h5_hdf5.c +++ b/src/h5core/h5_hdf5.c @@ -1088,7 +1088,7 @@ h5priv_write_hdf5_attribute ( return H5_SUCCESS; } -ssize_t +h5_ssize_t h5priv_get_hdf5_attribute_name ( h5_file_t * const f, hid_t attr_id, @@ -1101,7 +1101,7 @@ h5priv_get_hdf5_attribute_name ( f, H5_ERR_HDF5, "Cannot get attribute name." ); - return size; + return (h5_size_t)size; } hid_t diff --git a/src/h5core/h5t_adjacencies_tetm.c b/src/h5core/h5t_adjacencies_tetm.c index 1bdcc98..8fd0b0e 100644 --- a/src/h5core/h5t_adjacencies_tetm.c +++ b/src/h5core/h5t_adjacencies_tetm.c @@ -25,19 +25,18 @@ compute_elems_of_vertices ( const h5_id_t from_lvl ) { h5t_fdata_t* t = f->t; - h5_id_t elem_idx = (from_lvl <= 0) ? 0 : t->num_elems[from_lvl-1]; - h5_elem_ldta_t *el = &t->elems_ldta[elem_idx]; + h5_id_t idx = (from_lvl <= 0) ? 0 : t->num_elems[from_lvl-1]; + h5_tet_t *el = &t->loc_elems.tets[idx]; h5_id_t num_elems = t->num_elems[t->num_levels-1]; - for (;elem_idx < num_elems; elem_idx++, el++) { + for (;idx < num_elems; idx++, el++) { int face_idx; - int num_faces = t->ref_element->num_faces[0]; + int num_faces = t->ref_elem->num_faces[0]; for (face_idx = 0; face_idx < num_faces; face_idx++) { - h5_id_t vidx = el->local_vertex_indices[face_idx]; + h5_id_t vidx = el->vertex_indices[face_idx]; TRY( h5priv_append_to_idlist ( f, &t->vertices_data[vidx].tv, - h5tpriv_build_vertex_id ( - face_idx, elem_idx)) ); + h5tpriv_build_vertex_id (face_idx, idx)) ); } } return H5_SUCCESS; @@ -53,13 +52,12 @@ compute_elems_of_edges ( ) { h5t_fdata_t *t = f->t; h5_id_t elem_idx = (from_lvl <= 0) ? 0 : t->num_elems[from_lvl-1]; - h5_elem_ldta_t *el = &t->elems_ldta[elem_idx]; h5_id_t num_elems = t->num_elems[t->num_levels-1]; h5_idlist_t *retval = NULL; TRY( h5tpriv_resize_te_htab (f, 4*(num_elems-elem_idx)) ); - for (;elem_idx < num_elems; elem_idx++, el++) { + for (;elem_idx < num_elems; elem_idx++) { int face_idx; - int num_faces = t->ref_element->num_faces[1]; + int num_faces = t->ref_elem->num_faces[1]; for (face_idx = 0; face_idx < num_faces; face_idx++) { TRY( h5tpriv_search_te2 ( f, face_idx, elem_idx, &retval) ); @@ -75,13 +73,12 @@ compute_elems_of_triangles ( ) { h5t_fdata_t* t = f->t; h5_id_t elem_idx = (from_lvl <= 0) ? 0 : t->num_elems[from_lvl-1]; - h5_elem_ldta_t *el = &t->elems_ldta[elem_idx]; h5_id_t num_elems = t->num_elems[t->num_levels-1]; h5_idlist_t *retval = NULL; TRY( h5tpriv_resize_te_htab (f, 4*(num_elems-elem_idx)) ); - for (;elem_idx < num_elems; elem_idx++, el++) { + for (;elem_idx < num_elems; elem_idx++) { int face_idx; - int num_faces = t->ref_element->num_faces[1]; + int num_faces = t->ref_elem->num_faces[1]; for (face_idx = 0; face_idx < num_faces; face_idx++) { TRY( h5tpriv_search_td2 ( f, face_idx, elem_idx, &retval) ); @@ -110,15 +107,15 @@ compute_children_of_edge ( for (; edge < end; edge++) { h5_id_t elem_idx = h5tpriv_get_elem_idx (*edge); h5_id_t face_idx = h5tpriv_get_face_idx (*edge); - h5_elem_ldta_t* tet = &t->elems_ldta[elem_idx]; - if (h5tpriv_elem_is_on_cur_level (f, tet) == H5_OK ) { + h5_tet_t* tet = &t->loc_elems.tets[elem_idx]; + if (h5tpriv_elem_is_on_cur_level (f, (h5_generic_elem_t*)tet) == H5_OK ) { TRY( h5priv_append_to_idlist (f, children, *edge) ); } else { h5_id_t kids[2]; TRY( t->methods.store->get_direct_children_of_edge ( f, face_idx, - tet->local_child_idx, + tet->child_idx, kids) ); TRY( compute_children_of_edge (f, kids[0], children) ); TRY( compute_children_of_edge (f, kids[1], children) ); @@ -150,14 +147,14 @@ compute_sections_of_edge ( for (; edge < end; edge++) { h5_id_t eid = h5tpriv_get_elem_idx (*edge); h5_id_t face_id = h5tpriv_get_face_idx (*edge); - h5_elem_ldta_t* tet = &t->elems_ldta[eid]; + h5_generic_elem_t* tet = (h5_generic_elem_t*)&t->loc_elems.tets[eid]; if (! h5tpriv_elem_is_on_cur_level (f, tet) == H5_OK) { refined = 1; h5_id_t kids[2]; TRY( t->methods.store->get_direct_children_of_edge ( f, face_id, - tet->local_child_idx, + tet->child_idx, kids) ); TRY( compute_sections_of_edge (f, kids[0], children) ); TRY( compute_sections_of_edge (f, kids[1], children) ); @@ -213,7 +210,7 @@ compute_direct_children_of_triangle ( {{2,0},{2,2},{2,3},{1,7}}, {{3,1},{3,2},{3,3},{3,6}} }; - int num_faces = f->t->ref_element->num_faces[2]; + int num_faces = f->t->ref_elem->num_faces[2]; if ((face_idx < 0) || (face_idx >= num_faces)) { return h5_error_internal (f, __FILE__, __func__, __LINE__); } @@ -248,7 +245,7 @@ compute_children_of_triangle ( for (; tri < end; tri++) { h5_id_t eid = h5tpriv_get_elem_idx (*tri); h5_id_t face_idx = h5tpriv_get_face_idx (*tri); - h5_elem_ldta_t *tet = &t->elems_ldta[eid]; + h5_generic_elem_t* tet = (h5_generic_elem_t*)&t->loc_elems.tets[eid]; if (h5tpriv_elem_is_on_cur_level (f, tet) == H5_OK) { TRY( h5priv_append_to_idlist (f, children, *tri) ); } else { @@ -256,7 +253,7 @@ compute_children_of_triangle ( TRY( compute_direct_children_of_triangle ( f, face_idx, - tet->local_child_idx, + tet->child_idx, dids) ); TRY( compute_children_of_triangle (f, dids[0], children) ); TRY( compute_children_of_triangle (f, dids[1], children) ); @@ -286,14 +283,14 @@ compute_sections_of_triangle ( for (; tri < end; tri++) { h5_id_t eid = h5tpriv_get_elem_idx (*tri); h5_id_t face_idx = h5tpriv_get_face_idx (*tri); - h5_elem_ldta_t *tet = &t->elems_ldta[eid]; + h5_generic_elem_t* tet = (h5_generic_elem_t*)&t->loc_elems.tets[eid]; if (! h5tpriv_elem_is_on_cur_level (f, tet) == H5_OK) { refined = 1; h5_id_t dids[4]; TRY( compute_direct_children_of_triangle ( f, face_idx, - tet->local_child_idx, + tet->child_idx, dids) ); TRY( compute_sections_of_triangle (f, dids[0], children) ); TRY( compute_sections_of_triangle (f, dids[1], children) ); @@ -340,7 +337,7 @@ get_edges_upadjacent_to_vertex ( for (i = 0; i < tv->num_items; i++, vidp++) { h5_id_t eid = h5tpriv_get_elem_idx (*vidp); h5_id_t face = h5tpriv_get_face_idx (*vidp); - h5_elem_ldta_t* tet = &t->elems_ldta[eid]; + h5_generic_elem_t* tet = (h5_generic_elem_t*)&t->loc_elems.tets[eid]; if (h5tpriv_elem_is_on_cur_level (f, tet) == H5_NOK ) { continue; @@ -382,7 +379,7 @@ get_triangles_upadjacent_to_vertex ( for (i = 0; i < tv->num_items; i++, vidp++) { h5_id_t eid = h5tpriv_get_elem_idx (*vidp); h5_id_t face = h5tpriv_get_face_idx (*vidp); - h5_elem_ldta_t* tet = &t->elems_ldta[eid]; + h5_generic_elem_t* tet = (h5_generic_elem_t*)&t->loc_elems.tets[eid]; if (h5tpriv_elem_is_on_cur_level (f, tet) == H5_NOK) { continue; @@ -409,7 +406,7 @@ get_tets_upadjacent_to_vertex ( h5_id_t* vidp = tv->items; for (i = 0; i < tv->num_items; i++, vidp++) { h5_id_t eid = h5tpriv_get_elem_idx (*vidp); - h5_elem_ldta_t* tet = &t->elems_ldta[eid]; + h5_generic_elem_t* tet = (h5_generic_elem_t*)&t->loc_elems.tets[eid]; if (h5tpriv_elem_is_on_cur_level (f, tet) == H5_NOK) { continue; diff --git a/src/h5core/h5t_adjacencies_trim.c b/src/h5core/h5t_adjacencies_trim.c index 0e9d11f..c258906 100644 --- a/src/h5core/h5t_adjacencies_trim.c +++ b/src/h5core/h5t_adjacencies_trim.c @@ -26,13 +26,13 @@ compute_elems_of_vertices ( ) { h5t_fdata_t *t = f->t; h5_id_t elem_idx = (from_lvl <= 0) ? 0 : t->num_elems[from_lvl-1]; - h5_elem_ldta_t *el = &t->elems_ldta[elem_idx]; + h5_triangle_t *el = &t->loc_elems.tris[elem_idx]; h5_id_t num_elems = t->num_elems[t->num_levels-1]; for (;elem_idx < num_elems; elem_idx++, el++) { int face_idx; - int num_faces = t->ref_element->num_faces[0]; + int num_faces = t->ref_elem->num_faces[0]; for (face_idx = 0; face_idx < num_faces; face_idx++) { - h5_id_t vidx = el->local_vertex_indices[face_idx]; + h5_id_t vidx = el->vertex_indices[face_idx]; TRY( h5priv_append_to_idlist ( f, &t->vertices_data[vidx].tv, @@ -53,13 +53,12 @@ compute_elems_of_edges ( ) { h5t_fdata_t *t = f->t; h5_id_t elem_idx = (from_lvl <= 0) ? 0 : t->num_elems[from_lvl-1]; - h5_elem_ldta_t *el = &t->elems_ldta[elem_idx]; h5_id_t num_elems = t->num_elems[t->num_levels-1]; h5_idlist_t *retval = NULL; TRY( h5tpriv_resize_te_htab (f, 4*(num_elems-elem_idx)) ); - for (;elem_idx < num_elems; elem_idx++, el++) { + for (;elem_idx < num_elems; elem_idx++) { int face_idx; - int num_faces = t->ref_element->num_faces[1]; + int num_faces = t->ref_elem->num_faces[1]; for (face_idx = 0; face_idx < num_faces; face_idx++) { TRY ( h5tpriv_search_te2 ( f, face_idx, elem_idx, &retval ) ); @@ -88,7 +87,7 @@ compute_children_of_edge ( for ( ; edge < end; edge++ ) { h5_id_t elem_idx = h5tpriv_get_elem_idx ( *edge ); h5_id_t face_idx = h5tpriv_get_face_idx ( *edge ); - h5_elem_ldta_t *el = &t->elems_ldta[elem_idx]; + h5_generic_elem_t *el = (h5_generic_elem_t*)&t->loc_elems.tris[elem_idx]; if ( h5tpriv_elem_is_on_cur_level ( f, el ) == H5_OK ) { TRY ( h5priv_append_to_idlist ( f, children, *edge ) @@ -98,7 +97,7 @@ compute_children_of_edge ( TRY ( t->methods.store->get_direct_children_of_edge ( f, face_idx, - el->local_child_idx, + el->child_idx, kids ) ); TRY ( compute_children_of_edge ( f, kids[0], children ) ); @@ -133,14 +132,14 @@ compute_sections_of_edge ( for ( ; edge < end; edge++ ) { h5_id_t eid = h5tpriv_get_elem_idx ( *edge ); h5_id_t face_id = h5tpriv_get_face_idx ( *edge ); - h5_elem_ldta_t *el = &t->elems_ldta[eid]; + h5_generic_elem_t *el = (h5_generic_elem_t*)&t->loc_elems.tris[eid]; if ( ! h5tpriv_elem_is_on_cur_level ( f, el ) == H5_OK ) { refined = 1; h5_id_t kids[2]; TRY ( t->methods.store->get_direct_children_of_edge ( f, face_id, - el->local_child_idx, + el->child_idx, kids ) ); TRY ( compute_sections_of_edge ( f, kids[0], children ) ); @@ -181,15 +180,15 @@ get_edges_upadjacent_to_vertex ( ) { TRY ( h5priv_alloc_idlist ( f, list, 8 ) ); - h5t_fdata_t *t = f->t; - h5_idlist_t *tv = &t->vertices_data[entity_id].tv; + h5t_fdata_t* t = f->t; + h5_idlist_t* tv = &t->vertices_data[entity_id].tv; h5_size_t i; - h5_id_t *vertex_idp = tv->items; + h5_id_t* vertex_idp = tv->items; for ( i = 0; i < tv->num_items; i++, vertex_idp++ ) { h5_id_t elem_idx = h5tpriv_get_elem_idx ( *vertex_idp ); h5_id_t face_idx = h5tpriv_get_face_idx ( *vertex_idp ); - h5_elem_ldta_t *el = &t->elems_ldta[elem_idx]; + h5_generic_elem_t* el = (h5_generic_elem_t*)&t->loc_elems.tris[elem_idx]; if ( h5tpriv_elem_is_on_cur_level ( f, el ) == H5_NOK ) { continue; @@ -221,7 +220,7 @@ get_triangles_upadjacent_to_vertex ( h5_id_t *vertex_id = tv->items; for ( i = 0; i < tv->num_items; i++, vertex_id++ ) { h5_id_t elem_id = h5tpriv_get_elem_idx ( *vertex_id ); - h5_elem_ldta_t *el = &t->elems_ldta[elem_id]; + h5_generic_elem_t* el = (h5_generic_elem_t*)&t->loc_elems.tris[elem_id]; if ( h5tpriv_elem_is_on_cur_level ( f, el ) == H5_NOK ) { continue; @@ -289,7 +288,7 @@ get_vertices_downadjacent_to_triangle ( h5_id_t elem_idx = h5tpriv_get_elem_idx ( entity_id ); // loop over all edges of triangle h5_id_t face_idx; - h5_id_t num_faces = f->t->ref_element->num_faces[1]; + h5_id_t num_faces = f->t->ref_elem->num_faces[1]; for (face_idx = 0; face_idx < num_faces; face_idx++) { TRY( compute_sections_of_edge ( f, @@ -321,7 +320,7 @@ get_edges_downadjacent_to_triangle ( h5_id_t elem_idx = h5tpriv_get_elem_idx (entity_id); // loop over all edges of triangle h5_id_t face_idx; - h5_id_t num_faces = f->t->ref_element->num_faces[1]; + h5_id_t num_faces = f->t->ref_elem->num_faces[1]; for ( face_idx = 0; face_idx < num_faces; face_idx++ ) { TRY( compute_sections_of_edge ( f, diff --git a/src/h5core/h5t_core_private.h b/src/h5core/h5t_core_private.h index e013063..6a93314 100644 --- a/src/h5core/h5t_core_private.h +++ b/src/h5core/h5t_core_private.h @@ -3,25 +3,20 @@ #define H5T_CONTAINER_GRPNAME "Topo" -#include "h5t_openclose_private.h" -#include "h5t_adjacencies_tetm_private.h" -#include "h5t_adjacencies_trim_private.h" +#include "h5t_openclose_private.h" +#include "h5t_adjacencies_private.h" #include "h5t_consts_private.h" #include "h5t_errorhandling_private.h" #include "h5t_hsearch_private.h" #include "h5t_map_private.h" #include "h5t_readwrite_private.h" -#include "h5t_retrieve_tetm_private.h" -#include "h5t_retrieve_trim_private.h" #include "h5t_store_private.h" -#include "h5t_store_tetm_private.h" -#include "h5t_store_trim_private.h" #include "h5t_tags_private.h" #include "h5t_types_private.h" +#include "h5t_access_private.h" #include "h5t_retrieve_private.h" - #endif diff --git a/src/h5core/h5t_errorhandling.c b/src/h5core/h5t_errorhandling.c index b5b6984..a24f1f5 100644 --- a/src/h5core/h5t_errorhandling.c +++ b/src/h5core/h5t_errorhandling.c @@ -1,6 +1,8 @@ +#include +#include +#include /* va_arg - System dependent ?! */ #include #include - #include "h5core/h5_core.h" #include "h5_core_private.h" @@ -16,7 +18,7 @@ h5tpriv_error_local_elem_nexist ( int num_chars_printed = snprintf (s, sizeof(s), "%lld,", (long long)local_vertex_indices[0]); int i; - int num_vertices = t->ref_element->num_faces[0]; + int num_vertices = t->ref_elem->num_faces[0]; for (i = 1; i < num_vertices; i++) { num_chars_printed += snprintf ( s + num_chars_printed, sizeof (s) - num_chars_printed, @@ -29,4 +31,4 @@ h5tpriv_error_local_elem_nexist ( return h5_error (f, H5_ERR_NOENTRY, ERR_ELEM_NEXIST, s); } - + diff --git a/src/h5core/h5t_hsearch.c b/src/h5core/h5t_hsearch.c index 183ca6e..fb35de3 100644 --- a/src/h5core/h5t_hsearch.c +++ b/src/h5core/h5t_hsearch.c @@ -299,6 +299,9 @@ h5tpriv_find_td2 ( return h5tpriv_find_td (f, &item, retval); } +/* + Return list of elements sharing the same vertex. + */ h5_err_t h5tpriv_find_tv2 ( h5_file_t* const f, @@ -306,11 +309,11 @@ h5tpriv_find_tv2 ( h5_id_t elem_idx, h5_idlist_t** retval ) { - /* - map (cid,el_idx) to local index of vertex - */ - h5_id_t vertex_idx = f->t->elems_ldta[elem_idx].local_vertex_indices[face_idx]; - *retval = &f->t->vertices_data[vertex_idx].tv; + + h5_id_t idx = h5tpriv_get_loc_elem_vertex_idx (f, elem_idx, face_idx); + *retval = &f->t->vertices_data[idx].tv; return H5_SUCCESS; } + + diff --git a/src/h5core/h5t_map.c b/src/h5core/h5t_map.c index 6dcb3b6..3e77490 100644 --- a/src/h5core/h5t_map.c +++ b/src/h5core/h5t_map.c @@ -102,60 +102,29 @@ h5tpriv_get_local_vid ( return -(low+1); // not found } -/*! - 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]. - - -*/ -#define get_vertex_of_elem( f, i, eid ) \ - (f->t->vertices[ f->t->elems_ldta[eid].local_vertex_indices[i] ].P) - - - -/*! - Compare two elems given by their local vertex ids -*/ -static int -vcmp_elems ( - h5_file_t* const f, - const h5_id_t* e1, - const h5_id_t* e2 - ) { - h5t_fdata_t* t = f->t; - int i; - - int num_vertices = t->ref_element->num_faces[0]; - - for (i = 0; i < num_vertices; i++) { - int r = cmp_vertices ( - t->vertices[e1[i]].P, - t->vertices[e2[i]].P ); - if (r < 0) return -1; - else if (r > 0) return 1; - } - return 0; -} - /*! compare two elems given by their local id */ static int cmp_elems ( h5_file_t* const f, - const h5_id_t local_eid1, - const h5_id_t local_eid2 + const h5_id_t elem_idx1, + const h5_id_t elem_idx2 ) { h5t_fdata_t* t = f->t; - int num_vertices = t->ref_element->num_faces[0]; + int num_vertices = t->ref_elem->num_faces[0]; + h5_id_t* indices1 = h5tpriv_get_loc_elem_vertex_indices (f, elem_idx1); + h5_id_t* indices2 = h5tpriv_get_loc_elem_vertex_indices (f, elem_idx2); + int i; for (i = 0; i < num_vertices; i++) { - int r = cmp_vertices ( - get_vertex_of_elem (f, i, local_eid1), - get_vertex_of_elem (f, i, local_eid2)); - if (r < 0) return -1; - else if (r > 0) return 1; + h5_float64_t* v1 = t->vertices[indices1[i]].P; + h5_float64_t* v2 = t->vertices[indices2[i]].P; + int r = cmp_vertices (v1, v2); + if (r < 0) + return -1; + else if (r > 0) + return 1; } return 0; } @@ -163,19 +132,24 @@ cmp_elems ( static int cmp_elems1 ( h5_file_t* f, - h5_id_t local_eid1, - h5_id_t local_eid2 + h5_id_t elem_idx1, + h5_id_t elem_idx2 ) { - struct h5t_fdata *t = f->t; - int num_vertices = t->ref_element->num_faces[0]; + h5t_fdata_t *t = f->t; + int num_vertices = t->ref_elem->num_faces[0]; + h5_id_t* indices1 = h5tpriv_get_loc_elem_vertex_indices (f, elem_idx1); + h5_id_t* indices2 = h5tpriv_get_loc_elem_vertex_indices (f, elem_idx2); + int imap[] = { 1, 0, 2, 3 }; int i; for ( i = 0; i < num_vertices; i++ ) { - int r = cmp_vertices ( - get_vertex_of_elem ( f, imap[i], local_eid1 ), - get_vertex_of_elem ( f, imap[i], local_eid2 ) ); - if ( r < 0 ) return -1; - else if ( r > 0 ) return 1; + h5_float64_t* v1 = t->vertices[ indices1[imap[i]] ].P; + h5_float64_t* v2 = t->vertices[ indices2[imap[i]] ].P; + int r = cmp_vertices (v1, v2); + if (r < 0) + return -1; + else if (r > 0) + return 1; } return 0; } @@ -272,39 +246,6 @@ h5tpriv_sort_local_vertex_indices ( return H5_SUCCESS; } -/*! - Binary search an element given by its local vertex ids. - - \result index in t->map_elem_s2l[0].items - */ -static h5_id_t -search_elem ( - h5_file_t* const f, - h5_id_t* const vertex_indices /* local vertex ids */ - ) { - h5t_fdata_t* t = f->t; - int num_vertices = t->ref_element->num_faces[0]; - h5tpriv_sort_local_vertex_indices ( f, vertex_indices, num_vertices ); - - register h5_id_t low = 0; - register h5_id_t high = t->sorted_elems[0].num_items - 1; - register h5_id_t *elem1 = vertex_indices; - while (low <= high) { - register int mid = (low + high) / 2; - - h5_id_t local_eid = t->sorted_elems[0].items[mid]; - h5_id_t *elem2 = t->elems_ldta[local_eid].local_vertex_indices; - int diff = vcmp_elems ( f, elem1, elem2 ); - if (diff < 0) - high = mid - 1; - else if (diff > 0) - low = mid + 1; - else - return mid; // found - } - return h5tpriv_error_local_elem_nexist (f, vertex_indices); -} - /*! Map a global vertex index to corresponding local index. */ @@ -381,20 +322,14 @@ h5tpriv_rebuild_global_2_local_map_of_elems ( ) { h5t_fdata_t* t = f->t; if (t->num_levels <= 0) return H5_SUCCESS; - h5_id_t local_eid = t->cur_level > 0 ? t->num_elems[t->cur_level-1] : 0; + + h5_id_t idx = 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]; - size_t offset = h5tpriv_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_idx; - item->local_id = local_eid; + h5_idmap_el_t *item = &t->map_elem_g2l.items[idx]; + + for (; idx < num_elems; idx++, item++) { + item->global_id = h5tpriv_get_glb_elem_idx (f, idx); + item->local_id = idx; t->map_elem_g2l.num_items++; } h5priv_sort_idmap (&t->map_elem_g2l); @@ -402,31 +337,32 @@ h5tpriv_rebuild_global_2_local_map_of_elems ( return H5_SUCCESS; } -static int -map_entity_type_to_dimension[] = { -1, - [H5_OID_VERTEX] = 0, - [H5_OID_EDGE] = 1, - [H5_OID_TRIANGLE] = 2, - [H5_OID_TETRAHEDRON] = 3 -}; h5_err_t h5t_get_vertex_indices_of_entity ( - h5_file_t* const f, - const h5_id_t entity_id, - h5_id_t* vertex_indices + h5_file_t* const f, // in + const h5_id_t entity_id, // in + h5_id_t* vertex_indices // out ) { + static int map_entity_type_to_dimension[] = { + -1, + [H5_OID_VERTEX] = 0, + [H5_OID_EDGE] = 1, + [H5_OID_TRIANGLE] = 2, + [H5_OID_TETRAHEDRON] = 3 + }; + h5_id_t entity_type = h5tpriv_get_entity_type (entity_id); h5_id_t face_idx = h5tpriv_get_face_idx (entity_id); h5_id_t elem_idx = h5tpriv_get_elem_idx (entity_id); int dim = map_entity_type_to_dimension[entity_type]; - h5_elem_ldta_t *el = &f->t->elems_ldta[elem_idx]; - const h5t_ref_element_t* ref_element = f->t->ref_element; - int num_vertices = ref_element->num_vertices_of_face[dim][face_idx]; + h5_id_t* indices = h5tpriv_get_loc_elem_vertex_indices (f, elem_idx); + const h5t_ref_elem_t* ref_elem = f->t->ref_elem; + int num_vertices = ref_elem->num_vertices_of_face[dim][face_idx]; int i; for (i = 0; i < num_vertices; i++) { - int idx = ref_element->map[dim][face_idx][i]; - vertex_indices[i] = el->local_vertex_indices[idx]; + int idx = ref_elem->map[dim][face_idx][i]; + vertex_indices[i] = indices[idx]; } return H5_SUCCESS; } @@ -450,10 +386,7 @@ h5t_get_vertex_index_of_vertex2 ( const h5_id_t elem_idx, // local element index h5_id_t* vertex_indices // OUT: vertex ID's ) { - const h5t_ref_element_t* ref_element = f->t->ref_element; - h5_elem_ldta_t *el = &f->t->elems_ldta[elem_idx]; - - vertex_indices[0] = el->local_vertex_indices[ref_element->map[0][face_idx][0]]; + vertex_indices[0] = h5tpriv_get_loc_elem_vertex_idx (f, elem_idx, face_idx); return H5_SUCCESS; } @@ -486,11 +419,11 @@ h5t_get_vertex_indices_of_edge2 ( const h5_id_t elem_idx, // local element index h5_id_t* vertex_indices // OUT: vertex ID's ) { - const h5t_ref_element_t* ref_element = f->t->ref_element; - h5_elem_ldta_t* el = &f->t->elems_ldta[elem_idx]; + const h5_id_t* indices = h5tpriv_get_loc_elem_vertex_indices (f, elem_idx); + const h5t_ref_elem_t* ref_elem = f->t->ref_elem; - vertex_indices[0] = el->local_vertex_indices[ref_element->map[1][face_idx][0]]; - vertex_indices[1] = el->local_vertex_indices[ref_element->map[1][face_idx][1]]; + vertex_indices[0] = indices[ ref_elem->map[1][face_idx][0] ]; + vertex_indices[1] = indices[ ref_elem->map[1][face_idx][1] ]; return H5_SUCCESS; } @@ -513,12 +446,12 @@ h5t_get_vertex_indices_of_triangle2 ( const h5_id_t elem_idx, h5_id_t* vertex_indices ) { - const h5t_ref_element_t* ref_element = f->t->ref_element; - h5_elem_ldta_t* el = &f->t->elems_ldta[elem_idx]; + const h5_id_t* indices = h5tpriv_get_loc_elem_vertex_indices (f, elem_idx); + const h5t_ref_elem_t* ref_elem = f->t->ref_elem; - vertex_indices[0] = el->local_vertex_indices[ref_element->map[2][face_idx][0]]; - vertex_indices[1] = el->local_vertex_indices[ref_element->map[2][face_idx][1]]; - vertex_indices[2] = el->local_vertex_indices[ref_element->map[2][face_idx][2]]; + vertex_indices[0] = indices[ ref_elem->map[2][face_idx][0] ]; + vertex_indices[1] = indices[ ref_elem->map[2][face_idx][1] ]; + vertex_indices[2] = indices[ ref_elem->map[2][face_idx][2] ]; return H5_SUCCESS; } @@ -529,14 +462,14 @@ h5t_get_vertex_indices_of_tet ( const h5_id_t entity_id, h5_id_t* vertex_indices ) { - h5_id_t elem_idx = h5tpriv_get_elem_idx (entity_id); - const h5t_ref_element_t* ref_element = f->t->ref_element; - h5_elem_ldta_t* el = &f->t->elems_ldta[elem_idx]; + const h5_id_t elem_idx = h5tpriv_get_elem_idx (entity_id); + const h5_id_t* indices = h5tpriv_get_loc_elem_vertex_indices (f, elem_idx); + const h5t_ref_elem_t* ref_elem = f->t->ref_elem; - vertex_indices[0] = el->local_vertex_indices[ref_element->map[3][0][0]]; - vertex_indices[1] = el->local_vertex_indices[ref_element->map[3][0][1]]; - vertex_indices[2] = el->local_vertex_indices[ref_element->map[3][0][2]]; - vertex_indices[3] = el->local_vertex_indices[ref_element->map[3][0][3]]; + vertex_indices[0] = indices[ ref_elem->map[3][0][0] ]; + vertex_indices[1] = indices[ ref_elem->map[3][0][1] ]; + vertex_indices[2] = indices[ ref_elem->map[3][0][2] ]; + vertex_indices[3] = indices[ ref_elem->map[3][0][3] ]; return H5_SUCCESS; } diff --git a/src/h5core/h5t_openclose.c b/src/h5core/h5t_openclose.c index 0b4690a..d3585f9 100644 --- a/src/h5core/h5t_openclose.c +++ b/src/h5core/h5t_openclose.c @@ -4,14 +4,18 @@ #include "h5_core_private.h" static struct h5t_methods tet_funcs = { + &h5tpriv_read_tetm_methods, &h5tpriv_tetm_store_methods, &h5tpriv_tetm_retrieve_methods, + &h5tpriv_access_tetm_methods, &h5tpriv_tetm_adjacency_methods }; static struct h5t_methods tri_funcs = { + &h5tpriv_read_trim_methods, &h5tpriv_trim_store_methods, &h5tpriv_trim_retrieve_methods, + &h5tpriv_access_trim_methods, &h5tpriv_trim_adjacency_methods }; @@ -96,29 +100,36 @@ create_triangle_type ( h5priv_insert_hdf5_type ( f, dtypes->h5_triangle_t, - "global_idx", - HOFFSET (struct h5_triangle, global_idx), + "idx", + HOFFSET (struct h5_triangle, idx), H5_ID_T) ); TRY( h5priv_insert_hdf5_type ( f, dtypes->h5_triangle_t, - "global_parent_idx", - HOFFSET (struct h5_triangle, global_parent_idx), + "parent_idx", + HOFFSET (struct h5_triangle, parent_idx), H5_ID_T) ); TRY( h5priv_insert_hdf5_type ( f, dtypes->h5_triangle_t, - "global_child_idx", - HOFFSET(struct h5_triangle, global_child_idx), + "child_idx", + HOFFSET(struct h5_triangle, child_idx), H5_ID_T) ); TRY( h5priv_insert_hdf5_type ( f, dtypes->h5_triangle_t, - "global_vertex_indices", - HOFFSET (struct h5_triangle, global_vertex_indices), + "vertex_indices", + HOFFSET (struct h5_triangle, vertex_indices), + dtypes->h5_3id_t) ); + TRY( + h5priv_insert_hdf5_type ( + f, + dtypes->h5_triangle_t, + "neighbor_indices", + HOFFSET(struct h5_triangle, neighbor_indices), dtypes->h5_3id_t) ); return H5_SUCCESS; @@ -168,29 +179,36 @@ create_tet_type ( h5priv_insert_hdf5_type ( f, dtypes->h5_tet_t, - "global_idx", - HOFFSET (struct h5_tetrahedron, global_idx), + "idx", + HOFFSET (struct h5_tetrahedron, idx), H5_ID_T) ); TRY( h5priv_insert_hdf5_type ( f, dtypes->h5_tet_t, - "global_parent_idx", - HOFFSET (struct h5_tetrahedron, global_parent_idx), + "parent_idx", + HOFFSET (struct h5_tetrahedron, parent_idx), H5_ID_T) ); TRY( h5priv_insert_hdf5_type ( f, dtypes->h5_tet_t, - "global_child_idx", - HOFFSET (struct h5_tetrahedron, global_child_idx), + "child_idx", + HOFFSET (struct h5_tetrahedron, child_idx), H5T_NATIVE_INT32) ); TRY( h5priv_insert_hdf5_type ( f, dtypes->h5_tet_t, - "global_vertex_indices", - HOFFSET (struct h5_tetrahedron, global_vertex_indices), + "vertex_indices", + HOFFSET (struct h5_tetrahedron, vertex_indices), + dtypes->h5_4id_t) ); + TRY( + h5priv_insert_hdf5_type ( + f, + dtypes->h5_triangle_t, + "neighbor_indices", + HOFFSET(struct h5_triangle, neighbor_indices), dtypes->h5_4id_t) ); return H5_SUCCESS; @@ -229,6 +247,18 @@ init_fdata ( t->meshes_gid = -1; t->mesh_gid = -1; + /* initialize pointers */ + t->glb_elems.data = NULL; + t->loc_elems.data = NULL; + t->num_elems = NULL; + t->num_elems_on_level = NULL; + t->map_elem_g2l.items = NULL; + t->vertices = NULL; + t->vertices_data = NULL; + t->num_vertices = NULL; + t->map_vertex_g2l.items = NULL; + t->mtags.names = NULL; + /* vertices */ strcpy (t->dsinfo_vertices.name, "Vertices"); t->dsinfo_vertices.rank = 1; @@ -313,17 +343,7 @@ init_fdata ( t->dsinfo_num_elems_on_level.chunk_dims) ); t->dsinfo_num_elems_on_level.access_prop = H5P_DEFAULT; - /* initialize pointers */ - t->elems.data = NULL; - t->num_elems = NULL; - t->elems_ldta = NULL; - t->num_elems_on_level = NULL; - t->map_elem_g2l.items = NULL; - t->vertices = NULL; - t->vertices_data = NULL; - t->num_vertices = NULL; - t->map_vertex_g2l.items = NULL; - t->mtags.names = NULL; + return H5_SUCCESS; } @@ -454,12 +474,12 @@ h5t_open_mesh ( case H5_OID_TETRAHEDRON: t->dsinfo_elems.type_id = t->dtypes.h5_tet_t; t->methods = tet_funcs; - t->ref_element = &h5t_tet_ref_element; + t->ref_elem = &h5t_tet_ref_elem; break; case H5_OID_TRIANGLE: t->dsinfo_elems.type_id = t->dtypes.h5_triangle_t; t->methods = tri_funcs; - t->ref_element = &h5t_tri_ref_element; + t->ref_elem = &h5t_tri_ref_elem; break; default: return h5_error_internal (f, __FILE__, __func__, __LINE__); @@ -486,9 +506,9 @@ release_elems ( h5_file_t* const f ) { h5t_fdata_t* t = f->t; - TRY( h5priv_free (f, t->elems.data) ); + TRY( h5priv_free (f, t->glb_elems.data) ); + TRY( h5priv_free (f, t->loc_elems.data) ); TRY( h5priv_free (f, t->num_elems) ); - TRY( h5priv_free (f, t->elems_ldta) ); TRY( h5priv_free (f, t->num_elems_on_level) ); TRY( h5priv_free (f, t->map_elem_g2l.items) ); @@ -590,5 +610,3 @@ h5tpriv_close_file ( return H5_SUCCESS; } - - diff --git a/src/h5core/h5t_readwrite.c b/src/h5core/h5t_readwrite.c index 5bde170..392643a 100644 --- a/src/h5core/h5t_readwrite.c +++ b/src/h5core/h5t_readwrite.c @@ -65,7 +65,7 @@ write_elems ( &t->dsinfo_elems, open_space_all, open_space_all, - t->elems.data) ); + t->glb_elems.data) ); TRY( h5priv_write_dataset_by_name ( f, @@ -231,52 +231,7 @@ open_file_space_elems ( return H5S_ALL; } -/* - 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; - int num_vertices = t->ref_element->num_faces[0]; - for (local_eid=0; - local_eid < num_elems; - local_eid++, elp+=h5tpriv_sizeof_elem[t->mesh_type], el_data++) { - el = (h5_elem_t*)elp; - TRY( h5t_map_global_vertex_indices2local ( - f, - el->global_vertex_indices, - num_vertices, - el_data->local_vertex_indices) ); - if (el->global_parent_idx >= 0) - TRY( el_data->local_parent_idx = - h5t_map_global_elem_idx2local ( - f, el->global_parent_idx) ); - - if (el->global_child_idx >= 0) - TRY( el_data->local_child_idx = - h5t_map_global_elem_idx2local ( - f, el->global_child_idx) ); - - 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 ( @@ -292,11 +247,11 @@ read_elems ( &t->dsinfo_elems, open_mem_space_elems, open_file_space_elems, - t->elems.data) ); + t->glb_elems.data) ); TRY( h5tpriv_sort_elems (f) ); TRY( h5tpriv_rebuild_global_2_local_map_of_elems (f) ); - TRY( build_elems_ldta (f) ); + TRY( (*f->t->methods.read->init_loc_elems_struct) (f) ); return H5_SUCCESS; } diff --git a/src/h5core/h5t_readwrite_private.h b/src/h5core/h5t_readwrite_private.h index 47d8ff9..648eb50 100644 --- a/src/h5core/h5t_readwrite_private.h +++ b/src/h5core/h5t_readwrite_private.h @@ -22,4 +22,7 @@ h5tpriv_write_mesh ( h5_file_t * const f ); +extern struct h5t_read_methods h5tpriv_read_trim_methods; +extern struct h5t_read_methods h5tpriv_read_tetm_methods; + #endif diff --git a/src/h5core/h5t_ref_elements.c b/src/h5core/h5t_ref_elements.c index 8777d15..1e52897 100644 --- a/src/h5core/h5t_ref_elements.c +++ b/src/h5core/h5t_ref_elements.c @@ -1,6 +1,6 @@ #include "h5core/h5_core.h" -const h5t_ref_element_t h5t_tri_ref_element = { +const h5t_ref_elem_t h5t_tri_ref_elem = { 2, {3, 3, 1}, // #vertices, #edges, #triangles { @@ -16,7 +16,7 @@ const h5t_ref_element_t h5t_tri_ref_element = { {{0.0, 0.0}, {1.0, 0.0}, {0.0, 1.0}}, }; -const h5t_ref_element_t h5t_tet_ref_element = { +const h5t_ref_elem_t h5t_tet_ref_elem = { 3, {4, 6, 4, 1}, // #vertices, #edges, #triangles, #tetrahedra { diff --git a/src/h5core/h5t_retrieve.c b/src/h5core/h5t_retrieve.c index d072253..9efc176 100644 --- a/src/h5core/h5t_retrieve.c +++ b/src/h5core/h5t_retrieve.c @@ -3,6 +3,8 @@ #include "h5core/h5_core.h" #include "h5_core_private.h" +#define num_elems_on_cur_level f->t->num_elems[f->t->cur_level] + /* Skip elements which have been refined on a level <= the current one. */ @@ -11,19 +13,18 @@ h5tpriv_skip_to_next_elem_on_level ( h5_file_t* f, h5t_entity_iterator_t* iter ) { - h5t_fdata_t* t = f->t; - h5_elem_ldta_t* el_dta; - int num_elems = t->num_elems[t->cur_level]; + h5_generic_elem_t* el; do { iter->elem_idx++; - if (iter->elem_idx >= num_elems) { + if (iter->elem_idx >= num_elems_on_cur_level) { return H5_NOK; } - el_dta = &t->elems_ldta[iter->elem_idx]; - } while (h5tpriv_elem_is_on_cur_level (f, el_dta) == H5_NOK); + el = h5tpriv_get_loc_elem (f, iter->elem_idx); + } while (h5tpriv_elem_is_on_cur_level (f, el) == H5_NOK); return H5_SUCCESS; } + /* Test whether given element is on current level. This is the case, if - the level_id of the element is <= the current level @@ -32,12 +33,11 @@ h5tpriv_skip_to_next_elem_on_level ( h5_err_t h5tpriv_elem_is_on_cur_level ( h5_file_t* const f, - h5_elem_ldta_t *el_dta + h5_generic_elem_t *el ) { h5t_fdata_t* t = f->t; - if ( (el_dta->level_id > t->cur_level) || - ( (el_dta->local_child_idx >= 0) && - (el_dta->local_child_idx < t->num_elems[t->cur_level]) ) ) { + if ( (el->level_idx > t->cur_level) || + (el->child_idx >= 0 && el->child_idx < num_elems_on_cur_level) ) { return H5_NOK; } return H5_SUCCESS; @@ -79,11 +79,10 @@ iterate_faces ( h5_file_t* const f, h5t_entity_iterator_t* iter ) { - h5t_fdata_t* t = f->t; h5_idlist_t* entry; h5_size_t i; - int dim = iter->ref_element->dim - iter->codim; - int num_faces = iter->ref_element->num_faces[dim] - 1; + int dim = iter->ref_elem->dim - iter->codim; + int num_faces = iter->ref_elem->num_faces[dim] - 1; do { if (iter->face_idx >= num_faces) { if (h5tpriv_skip_to_next_elem_on_level (f, iter) == H5_NOK) { @@ -102,12 +101,12 @@ iterate_faces ( TRY( (iter->find)(f, iter->face_idx, iter->elem_idx, &entry) ); i = -1; - h5_elem_ldta_t *el_dta; + h5_generic_elem_t *el; do { i++; - h5_id_t eid = h5tpriv_get_elem_idx (entry->items[i]); - el_dta = &t->elems_ldta[eid]; - } while (h5tpriv_elem_is_on_cur_level (f, el_dta) == H5_NOK); + h5_id_t idx = h5tpriv_get_elem_idx (entry->items[i]); + el = h5tpriv_get_loc_elem (f, idx); + } while (h5tpriv_elem_is_on_cur_level (f, el) == H5_NOK); } while (iter->elem_idx != h5tpriv_get_elem_idx(entry->items[i])); return entry->items[0]; @@ -147,7 +146,7 @@ h5t_end_iterate_entities ( iter->face_idx = -1; iter->elem_idx = -1; iter->codim = -1; - iter->ref_element = NULL; + iter->ref_elem = NULL; iter->find = NULL; return H5_SUCCESS; } @@ -164,7 +163,7 @@ h5t_get_vertex_coords_by_index ( } h5_err_t -h5t_get_vertrex_coords_by_id ( +h5t_get_vertex_coords_by_id ( h5_file_t* const f, h5_id_t vertex_id, h5_float64_t P[3] diff --git a/src/h5core/h5t_retrieve_private.h b/src/h5core/h5t_retrieve_private.h index aee309b..6c35f77 100644 --- a/src/h5core/h5t_retrieve_private.h +++ b/src/h5core/h5t_retrieve_private.h @@ -9,8 +9,11 @@ h5tpriv_skip_to_next_elem_on_level ( h5_err_t h5tpriv_elem_is_on_cur_level ( - h5_file_t * const f, - h5_elem_ldta_t *el_dta + h5_file_t* const f, + h5_generic_elem_t* el ); +extern struct h5t_retrieve_methods h5tpriv_trim_retrieve_methods; +extern struct h5t_retrieve_methods h5tpriv_tetm_retrieve_methods; + #endif diff --git a/src/h5core/h5t_retrieve_tetm.c b/src/h5core/h5t_retrieve_tetm.c index 29dd827..e8f0df0 100644 --- a/src/h5core/h5t_retrieve_tetm.c +++ b/src/h5core/h5t_retrieve_tetm.c @@ -6,14 +6,14 @@ static h5_err_t begin_iterate_entities ( h5_file_t* f, - h5t_entity_iterator_t* iter, + h5t_entity_iterator_t* const iter, const int codim ) { iter->face_idx = -1; iter->elem_idx = -1; iter->codim = codim; - iter->ref_element = f->t->ref_element; - switch (iter->ref_element->dim - codim) { + iter->ref_elem = f->t->ref_elem; + switch (iter->ref_elem->dim - codim) { case 0: // iterate vertices iter->find = h5tpriv_find_tv2; return h5tpriv_skip_to_next_elem_on_level (f, iter); @@ -31,7 +31,7 @@ begin_iterate_entities ( } } -struct h5t_retrieve_methods h5tpriv_tetm_retrieve_methods = { - begin_iterate_entities +struct h5t_retrieve_methods h5tpriv_trim_retrieve_methods = { + begin_iterate_entities, }; diff --git a/src/h5core/h5t_retrieve_trim.c b/src/h5core/h5t_retrieve_trim.c index 03c6684..a214ee7 100644 --- a/src/h5core/h5t_retrieve_trim.c +++ b/src/h5core/h5t_retrieve_trim.c @@ -12,8 +12,8 @@ begin_iterate_entities ( iter->face_idx = -1; iter->elem_idx = -1; iter->codim = codim; - iter->ref_element = f->t->ref_element; - switch (iter->ref_element->dim - codim) { + iter->ref_elem = f->t->ref_elem; + switch (iter->ref_elem->dim - codim) { case 0: // iterate vertices iter->find = h5tpriv_find_tv2; return h5tpriv_skip_to_next_elem_on_level (f, iter); @@ -29,5 +29,5 @@ begin_iterate_entities ( } struct h5t_retrieve_methods h5tpriv_trim_retrieve_methods = { - begin_iterate_entities + begin_iterate_entities, }; diff --git a/src/h5core/h5t_store.c b/src/h5core/h5t_store.c index d042e70..f977515 100644 --- a/src/h5core/h5t_store.c +++ b/src/h5core/h5t_store.c @@ -63,28 +63,26 @@ assign_global_elem_indices ( simple in serial runs: global index = local index */ h5_id_t local_idx = (t->cur_level == 0) ? 0 : t->num_elems[t->cur_level-1]; - + int num_vertices = t->ref_elem->num_faces[0]; + for (; local_idx < t->num_elems[t->cur_level]; local_idx++) { - h5_elem_t *elem; - h5_elem_ldta_t *elem_ldta = &t->elems_ldta[local_idx]; - switch ( t->mesh_type ) { - case H5_OID_TETRAHEDRON: - elem = (h5_elem_t*)&t->elems.tets[local_idx]; - break; - case H5_OID_TRIANGLE: - elem = (h5_elem_t*)&t->elems.tris[local_idx]; - break; - default: - return h5_error_internal (f,__FILE__,__func__,__LINE__); - } - elem->global_idx = local_idx; - elem->global_parent_idx = elem_ldta->local_parent_idx; - elem->global_child_idx = elem_ldta->local_child_idx; - int i; - int num_vertices = t->ref_element->num_faces[0]; - for (i = 0; i < num_vertices; i++) { - elem->global_vertex_indices[i] = elem_ldta->local_vertex_indices[i]; - } + h5_generic_elem_t *loc_elem = h5tpriv_get_loc_elem (f, local_idx); + h5_generic_elem_t *glb_elem = h5tpriv_get_glb_elem (f, local_idx); + + glb_elem->idx = local_idx; + glb_elem->parent_idx = loc_elem->parent_idx; + glb_elem->child_idx = loc_elem->child_idx; + + h5_id_t* glb_indices = h5tpriv_get_glb_elem_vertex_indices (f, local_idx); + h5_id_t* loc_indices = h5tpriv_get_loc_elem_vertex_indices (f, local_idx); + + memcpy (glb_indices, loc_indices, num_vertices*sizeof(*glb_indices)); + + glb_indices = h5tpriv_get_glb_elem_neighbor_indices (f, local_idx); + loc_indices = h5tpriv_get_loc_elem_neighbor_indices (f, local_idx); + + memcpy (glb_indices, loc_indices, num_vertices*sizeof(*glb_indices)); + } return H5_SUCCESS; @@ -232,8 +230,8 @@ h5t_begin_store_elems ( h5_id_t h5t_store_elem ( h5_file_t* const f, - const h5_id_t elem_idx_of_parent, - const h5_id_t* vertices + const h5_id_t parent_idx, + const h5_id_t* vertex_indices ) { h5t_fdata_t* t = f->t; @@ -248,29 +246,30 @@ h5t_store_elem ( t->num_elems[t->cur_level] ); /* check parent id */ - if ((t->cur_level == 0 && elem_idx_of_parent != -1) || - (t->cur_level > 0 && elem_idx_of_parent < 0) || + if ((t->cur_level == 0 && parent_idx != -1) || + (t->cur_level > 0 && parent_idx < 0) || (t->cur_level > 0 - && elem_idx_of_parent >= t->num_elems[t->cur_level-1]) + && parent_idx >= t->num_elems[t->cur_level-1]) ) { return HANDLE_H5_PARENT_ID_ERR ( - f, - h5tpriv_map_oid2str (t->mesh_type), - elem_idx_of_parent); + f, h5tpriv_map_oid2str (t->mesh_type), parent_idx); } - h5_id_t elem_idx = ++t->last_stored_eid; - h5_elem_ldta_t* elem_ldta = &t->elems_ldta[elem_idx]; - elem_ldta->local_parent_idx = elem_idx_of_parent; - elem_ldta->local_child_idx = -1; - elem_ldta->level_id = t->cur_level; - int num_vertices = t->ref_element->num_faces[0]; - memcpy (elem_ldta->local_vertex_indices, vertices, - sizeof (*vertices) * num_vertices); - h5tpriv_sort_local_vertex_indices (f, elem_ldta->local_vertex_indices, - num_vertices); + /* store elem data (but neighbors) */ + h5_id_t elem_idx = ++t->last_stored_eid; + h5tpriv_set_loc_elem_idx (f, elem_idx, elem_idx); + h5tpriv_set_loc_elem_parent_idx (f, elem_idx, parent_idx); + h5tpriv_set_loc_elem_child_idx (f, elem_idx, -1); + h5tpriv_set_loc_elem_level_idx (f, elem_idx, t->cur_level); + + h5_id_t* loc_elem_vertex_indices = h5tpriv_get_loc_elem_vertex_indices (f, elem_idx); + int num_vertices = t->ref_elem->num_faces[0]; + memcpy (loc_elem_vertex_indices, vertex_indices, sizeof (*vertex_indices) * num_vertices); + h5tpriv_sort_local_vertex_indices (f, loc_elem_vertex_indices, num_vertices); + + /* add edges to directory which maps edges to elements */ h5_id_t face_idx; - int num_faces = t->ref_element->num_faces[1]; + int num_faces = t->ref_elem->num_faces[1]; h5_idlist_t* retval; for (face_idx = 0; face_idx < num_faces; face_idx++) { // add edges to neighbour struct @@ -294,7 +293,8 @@ h5t_end_store_elems ( TRY( h5tpriv_sort_elems (f) ); TRY( h5tpriv_rebuild_global_2_local_map_of_elems (f) ); - TRY( (t->methods.adjacency->update_internal_structs)(f, t->cur_level) ); + + TRY( (t->methods.store->end_store_elems)(f) ); return H5_SUCCESS; } diff --git a/src/h5core/h5t_store_private.h b/src/h5core/h5t_store_private.h index 8e63d1b..c36aa78 100644 --- a/src/h5core/h5t_store_private.h +++ b/src/h5core/h5t_store_private.h @@ -1,4 +1,7 @@ #ifndef __H5T_STOREMESH_PRIVATE_H #define __H5T_STOREMESH_PRIVATE_H +extern struct h5t_store_methods h5tpriv_trim_store_methods; +extern struct h5t_store_methods h5tpriv_tetm_store_methods; + #endif diff --git a/src/h5core/h5t_store_tetm.c b/src/h5core/h5t_store_tetm.c index f9ea607..0004e60 100644 --- a/src/h5core/h5t_store_tetm.c +++ b/src/h5core/h5t_store_tetm.c @@ -10,44 +10,26 @@ alloc_tets ( const size_t new ) { h5t_fdata_t *t = f->t; - const size_t nvertices = 4; /* alloc mem for elements */ - TRY ( t->elems.tets = h5priv_alloc ( + TRY ( t->glb_elems.tets = h5priv_alloc ( f, - t->elems.tets, - new * sizeof(t->elems.tets[0]) ) ); + t->glb_elems.tets, + new * sizeof(t->glb_elems.tets[0]) ) ); memset ( - t->elems.tets + cur, + t->glb_elems.tets + cur, -1, - (new-cur) * sizeof(t->elems.tets[0]) ); + (new-cur) * sizeof(t->glb_elems.tets[0]) ); /* alloc mem for local data of elements */ - TRY ( t->elems_ldta = h5priv_alloc ( + TRY ( t->loc_elems.tets = h5priv_alloc ( f, - t->elems_ldta, - new * sizeof (t->elems_ldta[0]) ) ); + t->loc_elems.tets, + new * sizeof (t->loc_elems.tets[0]) ) ); memset ( - t->elems_ldta + cur, + t->loc_elems.tets + cur, -1, - (new-cur) * sizeof (t->elems_ldta[0]) ); - - /* alloc mem for local vertex IDs of elements */ - TRY ( t->elems_lvids = h5priv_alloc ( - f, - t->elems_lvids, - new * sizeof(t->elems_lvids[0]) * nvertices ) ); - memset ( - t->elems_lvids + cur * nvertices, - -1, - (new-cur) * sizeof(t->elems_lvids[0]) * nvertices ); - - /* re-init pointer to local vertex id in local data structure */ - h5_id_t *p = t->elems_lvids; - h5_id_t id; - for ( id = 0; id < new; id++, p+=nvertices ) { - t->elems_ldta[id].local_vertex_indices = p; - } + (new-cur) * sizeof (t->loc_elems.tets[0]) ); /* alloc mem for global to local ID mapping */ TRY ( h5priv_alloc_idmap ( f, &t->map_elem_g2l, new ) ); @@ -74,7 +56,7 @@ get_direct_children_of_edge ( {1,3}, // edge 4 {2,3} // edge 5 }; - int num_faces = f->t->ref_element->num_faces[1]; + int num_faces = f->t->ref_elem->num_faces[1]; if ((face_idx < 0) || ( face_idx >= num_faces)) { return h5_error_internal (f, __FILE__, __func__, __LINE__); } @@ -93,24 +75,23 @@ get_direct_children_of_edge ( static h5_id_t bisect_edge ( h5_file_t* const f, - h5_id_t face_id, - h5_id_t elem_id + const h5_id_t face_idx, + const h5_id_t elem_idx ) { - h5t_fdata_t *t = f->t; - h5_id_t vids[2]; - h5_idlist_t *retval; + h5t_fdata_t* t = f->t; + h5_idlist_t* retval; /* get all elements sharing the given edge */ - TRY( h5tpriv_find_te2 (f, face_id, elem_id, &retval) ); + TRY( h5tpriv_find_te2 (f, face_idx, elem_idx, &retval) ); /* check wether one of the found elements has been refined */ size_t i; for ( i = 0; i < retval->num_items; i++ ) { - h5_id_t local_id = h5tpriv_get_elem_idx ( retval->items[i] ); - h5_elem_ldta_t *tet = &t->elems_ldta[local_id]; - if ( tet->local_child_idx >= 0 ) { + h5_id_t idx = h5tpriv_get_elem_idx ( retval->items[i] ); + h5_id_t child_idx = h5tpriv_get_loc_elem_child_idx (f, idx); + if ( child_idx >= 0 ) { /* this element has been refined! return bisecting point @@ -121,7 +102,7 @@ bisect_edge ( TRY( get_direct_children_of_edge ( f, face_id, - tet->local_child_idx, + child_idx, kids) ); TRY( h5t_get_vertex_indices_of_edge (f, kids[0], edge0) ); TRY( h5t_get_vertex_indices_of_edge (f, kids[1], edge1) ); @@ -134,8 +115,10 @@ bisect_edge ( /* None of the elements has been refined -> add new vertex. */ - h5_float64_t *P0 = t->vertices[vids[0]].P; - h5_float64_t *P1 = t->vertices[vids[1]].P; + h5_id_t indices[2]; + TRY( h5t_get_vertex_indices_of_edge2 (f, face_idx, elem_idx, indices) ); + h5_float64_t *P0 = t->vertices[indices[0]].P; + h5_float64_t *P1 = t->vertices[indices[1]].P; h5_float64_t P[3]; P[0] = ( P0[0] + P1[0] ) / 2.0; @@ -158,18 +141,18 @@ refine_tet ( h5t_fdata_t* t = f->t; h5_id_t vertices[10]; h5_id_t elem_idx_of_first_child; - h5_elem_ldta_t *tet = &t->elems_ldta[elem_idx]; + h5_tet_t* el = &t->loc_elems.tets[elem_idx]; - if ( tet->local_child_idx >= 0 ) + if ( el->child_idx >= 0 ) return h5_error ( f, H5_ERR_INVAL, "Tetrahedron %lld already refined.", (long long)elem_idx ); - vertices[0] = tet->local_vertex_indices[0]; - vertices[1] = tet->local_vertex_indices[1]; - vertices[2] = tet->local_vertex_indices[2]; - vertices[3] = tet->local_vertex_indices[3]; + vertices[0] = el->vertex_indices[0]; + vertices[1] = el->vertex_indices[1]; + vertices[2] = el->vertex_indices[2]; + vertices[3] = el->vertex_indices[3]; vertices[4] = bisect_edge (f, 0, elem_idx); vertices[5] = bisect_edge (f, 1, elem_idx); @@ -231,15 +214,23 @@ refine_tet ( new_elem[3] = vertices[9]; TRY( h5t_store_elem (f, elem_idx, new_elem) ); - t->elems.tets[elem_idx].global_child_idx = elem_idx_of_first_child; - t->elems_ldta[elem_idx].local_child_idx = elem_idx_of_first_child; + 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_level[t->cur_level]--; return elem_idx_of_first_child; } +h5_err_t +end_store_elems ( + h5_file_t* f + ) { + return H5_SUCCESS; +} + struct h5t_store_methods h5tpriv_tetm_store_methods = { alloc_tets, refine_tet, + end_store_elems, get_direct_children_of_edge }; diff --git a/src/h5core/h5t_store_trim.c b/src/h5core/h5t_store_trim.c index ac4289a..ab88159 100644 --- a/src/h5core/h5t_store_trim.c +++ b/src/h5core/h5t_store_trim.c @@ -10,44 +10,26 @@ alloc_triangles ( const size_t new ) { h5t_fdata_t *t = f->t; - const size_t nvertices = 3; /* alloc mem for elements */ - TRY ( t->elems.tris = h5priv_alloc ( + TRY ( t->glb_elems.tris = h5priv_alloc ( f, - t->elems.tris, - new * sizeof(t->elems.tris[0]) ) ); + t->glb_elems.tris, + new * sizeof(t->glb_elems.tris[0]) ) ); memset ( - t->elems.tris + cur, + t->glb_elems.tris + cur, -1, - (new-cur) * sizeof(t->elems.tris[0]) ); + (new-cur) * sizeof(t->glb_elems.tris[0]) ); /* alloc mem for local data of elements */ - TRY ( t->elems_ldta = h5priv_alloc ( + TRY ( t->loc_elems.tris = h5priv_alloc ( f, - t->elems_ldta, - new * sizeof (t->elems_ldta[0]) ) ); + t->loc_elems.tris, + new * sizeof (t->loc_elems.tris[0]) ) ); memset ( - t->elems_ldta + cur, + t->glb_elems.tris + cur, -1, - (new-cur) * sizeof (t->elems_ldta[0]) ); - - /* alloc mem for local vertex IDs of elements */ - TRY ( t->elems_lvids = h5priv_alloc ( - f, - t->elems_lvids, - new * sizeof(t->elems_lvids[0]) * nvertices ) ); - memset ( - t->elems_lvids + cur * sizeof(t->elems_lvids[0]) * nvertices, - -1, - (new-cur) * sizeof(t->elems_lvids[0]) * nvertices ); - - /* re-init pointer to local vertex id in local data structure */ - h5_id_t *p = t->elems_lvids; - h5_id_t id; - for ( id = 0; id < new; id++, p+=nvertices ) { - t->elems_ldta[id].local_vertex_indices = p; - } + (new-cur) * sizeof (t->loc_elems.tris[0]) ); /* alloc mem for global to local ID mapping */ TRY ( h5priv_alloc_idmap ( f, &t->map_elem_g2l, new ) ); @@ -62,7 +44,7 @@ get_direct_children_of_edge ( const h5_id_t elem_idx, // index of the first child! h5_id_t children[2] ) { - int num_faces = f->t->ref_element->num_faces[1]; + int num_faces = f->t->ref_elem->num_faces[1]; /* Please note: The face index of the children and the father is always the same. The only think we have to know, is the offset @@ -89,12 +71,12 @@ get_direct_children_of_edge ( static h5_id_t bisect_edge ( - h5_file_t * const f, - h5_id_t face_idx, - h5_id_t elem_idx + h5_file_t* const f, + const h5_id_t face_idx, + const h5_id_t elem_idx ) { - h5t_fdata_t *t = f->t; - h5_idlist_t *retval; + h5t_fdata_t* t = f->t; + h5_idlist_t* retval; /* get all elements sharing the given edge */ @@ -104,9 +86,9 @@ bisect_edge ( */ size_t i; for ( i = 0; i < retval->num_items; i++ ) { - h5_id_t local_id = h5tpriv_get_elem_idx ( retval->items[i] ); - h5_elem_ldta_t *tet = &t->elems_ldta[local_id]; - if ( tet->local_child_idx >= 0 ) { + h5_id_t idx = h5tpriv_get_elem_idx ( retval->items[i] ); + h5_id_t child_idx = h5tpriv_get_loc_elem_child_idx (f, idx); + if ( child_idx >= 0 ) { /* this element has been refined! return bisecting point @@ -117,7 +99,7 @@ bisect_edge ( TRY ( get_direct_children_of_edge ( f, face_id, - tet->local_child_idx, + child_idx, kids ) ); TRY ( h5t_get_vertex_indices_of_edge ( f, kids[0], edge0 ) ); TRY ( h5t_get_vertex_indices_of_edge ( f, kids[1], edge1 ) ); @@ -130,10 +112,10 @@ bisect_edge ( /* None of the elements has been refined -> add new vertex. */ - h5_id_t vindices[2]; - TRY( h5t_get_vertex_indices_of_edge2 (f, face_idx, elem_idx, vindices) ); - h5_float64_t *P0 = t->vertices[vindices[0]].P; - h5_float64_t *P1 = t->vertices[vindices[1]].P; + h5_id_t indices[2]; + TRY( h5t_get_vertex_indices_of_edge2 (f, face_idx, elem_idx, indices) ); + h5_float64_t *P0 = t->vertices[indices[0]].P; + h5_float64_t *P1 = t->vertices[indices[1]].P; h5_float64_t P[3]; P[0] = ( P0[0] + P1[0] ) / 2.0; @@ -156,18 +138,18 @@ refine_triangle ( h5t_fdata_t *t = f->t; h5_id_t vertices[6]; // local vertex indices h5_id_t elem_idx_of_first_child; - h5_elem_ldta_t *el = &t->elems_ldta[elem_idx]; + h5_triangle_t *el = &t->loc_elems.tris[elem_idx]; - if ( el->local_child_idx >= 0 ) + if ( el->child_idx >= 0 ) return h5_error ( f, H5_ERR_INVAL, "Element %lld already refined.", (long long)elem_idx ); - vertices[0] = el->local_vertex_indices[0]; - vertices[1] = el->local_vertex_indices[1]; - vertices[2] = el->local_vertex_indices[2]; + vertices[0] = el->vertex_indices[0]; + vertices[1] = el->vertex_indices[1]; + vertices[2] = el->vertex_indices[2]; vertices[3] = bisect_edge( f, 0, elem_idx ); vertices[4] = bisect_edge( f, 1, elem_idx ); @@ -195,15 +177,78 @@ refine_triangle ( new_elem[2] = vertices[5]; TRY( h5t_store_elem (f, elem_idx, new_elem) ); - t->elems.tris[elem_idx].global_child_idx = elem_idx_of_first_child; - t->elems_ldta[elem_idx].local_child_idx = elem_idx_of_first_child; + 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_level[t->cur_level]--; return elem_idx_of_first_child; } +/* + Compute the neighbors in the macro-grid. + */ +static h5_err_t +compute_neighbors_in_macrogrid ( + h5_file_t* const f + ) { + h5t_fdata_t *t = f->t; + h5_id_t elem_idx = 0; + h5_triangle_t *el = &t->loc_elems.tris[0]; + h5_id_t num_elems = t->num_elems[0]; + for (;elem_idx < num_elems; elem_idx++, el++) { + int face_idx = 0; + for (; face_idx < 3; face_idx++) { + h5_idlist_t* te; + + TRY( h5tpriv_find_te2 ( + f, + face_idx, + elem_idx, + &te) ); + if (te == NULL) { + } else { + } + } + } + return H5_SUCCESS; +} + +static h5_err_t +compute_neighbors_for_refined_elems ( + h5_file_t* const f + ) { + h5t_fdata_t *t = f->t; + return H5_SUCCESS; +} + +static h5_err_t +compute_neighbors ( + h5_file_t* const f + ) { + h5t_fdata_t *t = f->t; + + if (t->cur_level == 0) { + TRY( compute_neighbors_in_macrogrid (f) ); + } else { + TRY( compute_neighbors_for_refined_elems (f) ); + } + return H5_SUCCESS; +} + +static h5_err_t +end_store_elems ( + h5_file_t* const f + ) { + h5t_fdata_t *t = f->t; + + TRY( (t->methods.adjacency->update_internal_structs)(f, t->cur_level) ); + TRY( compute_neighbors (f) ); + return H5_SUCCESS; +} + struct h5t_store_methods h5tpriv_trim_store_methods = { alloc_triangles, refine_triangle, + end_store_elems, get_direct_children_of_edge }; diff --git a/src/h5core/h5t_store_trim_private.h b/src/h5core/h5t_store_trim_private.h index c51f1c8..ff91e35 100644 --- a/src/h5core/h5t_store_trim_private.h +++ b/src/h5core/h5t_store_trim_private.h @@ -1,5 +1,4 @@ #ifndef __H5T_TRIM_STORE_PRIVATE_H #define __H5T_TRIM_STORE_PRIVATE_H -extern struct h5t_store_methods h5tpriv_trim_store_methods; #endif diff --git a/src/h5core/h5t_types_private.h b/src/h5core/h5t_types_private.h index aed208d..57e1e94 100644 --- a/src/h5core/h5t_types_private.h +++ b/src/h5core/h5t_types_private.h @@ -1,9 +1,72 @@ #ifndef __H5T_TYPES_PRIVATE_H #define __H5T_TYPES_PRIVATE_H +typedef struct h5_vertex { + h5_id_t global_idx; + h5_coord3d_t P; +} h5_vertex_t; + +typedef struct h5_vertex_data { + h5_idlist_t tv; +} h5_vertex_data_t; + +typedef struct h5_triangle { + h5_id_t idx; + h5_id_t parent_idx; + h5_id_t child_idx; + h5_id_t level_idx; + h5_3id_t vertex_indices; + h5_3id_t neighbor_indices; +} h5_triangle_t; + +typedef struct h5_tetrahedron { + h5_id_t idx; + h5_id_t parent_idx; + h5_id_t child_idx; + h5_id_t level_idx; + h5_4id_t vertex_indices; + h5_4id_t neighbor_indices; +} h5_tetrahedron_t; +typedef h5_tetrahedron_t h5_tet_t; + +typedef struct h5_generic_elem { + h5_id_t idx; + h5_id_t parent_idx; + h5_id_t child_idx; + h5_id_t level_idx; + h5_id_t indices[1]; +} h5_generic_elem_t; + + +typedef union h5_elems { + h5_tet_t *tets; + h5_triangle_t *tris; + void *data; +} h5_elems_t; + +/*** type ids' for compound types ***/ +typedef struct h5_dtypes { + hid_t h5_id_t; /* ID's */ + hid_t h5_int64_t; /* 64 bit signed integer */ + hid_t h5_float64_t; /* 64 bit floating point */ + hid_t h5_coord3d_t; /* 3-tuple of 64-bit float */ + hid_t h5_3id_t; /* 3-tuple of ID's */ + hid_t h5_4id_t; /* 4-tuple of ID's */ + hid_t h5_vertex_t; /* vertex structure */ + hid_t h5_triangle_t; /* triangle structure */ + hid_t h5_tet_t; /* tetrahedron structure */ + hid_t h5t_tag_idx_t; +} h5_dtypes_t; + +typedef struct h5t_adjacencies { + h5_hashtable_t te_hash; + h5_hashtable_t td_hash; +} h5t_adjacencies_t; + struct h5t_store_methods { h5_err_t (*alloc_elems)(h5_file_t* const, const size_t, const size_t); h5_id_t (*refine_elem)(h5_file_t* const, const h5_id_t); + h5_err_t (*end_store_elems)(h5_file_t* const); h5_id_t (*get_direct_children_of_edge)(h5_file_t* const, const h5_id_t, const h5_id_t, h5_id_t*); }; @@ -11,6 +74,76 @@ struct h5t_retrieve_methods { h5_err_t (*init_iterator)(h5_file_t* const, h5t_entity_iterator_t*, const int); }; + +struct h5t_access_methods { + h5_generic_elem_t* (*get_loc_elem)( + h5_file_t* const, const h5_id_t); + h5_id_t (*get_loc_elem_idx)( + h5_file_t* const, const h5_id_t); + h5_id_t (*set_loc_elem_idx)( + h5_file_t* const, const h5_id_t, const h5_id_t); + h5_id_t (*get_loc_elem_parent_idx)( + h5_file_t* const, const h5_id_t); + h5_id_t (*set_loc_elem_parent_idx)( + h5_file_t* const, const h5_id_t, const h5_id_t); + h5_id_t (*get_loc_elem_child_idx)( + h5_file_t* const, const h5_id_t); + h5_id_t (*set_loc_elem_child_idx)( + h5_file_t* const, const h5_id_t, const h5_id_t); + h5_id_t (*get_loc_elem_level_idx)( + h5_file_t* const, const h5_id_t); + h5_id_t (*set_loc_elem_level_idx)( + h5_file_t* const, const h5_id_t, const h5_id_t); + h5_id_t* (*get_loc_elem_vertex_indices)( + h5_file_t* const, const h5_id_t); + h5_id_t (*get_loc_elem_vertex_idx)( + h5_file_t* const, const h5_id_t, const h5_id_t); + h5_id_t (*set_loc_elem_vertex_idx)( + h5_file_t* const, const h5_id_t, const h5_id_t, const h5_id_t); + h5_id_t* (*get_loc_elem_neighbor_indices)( + h5_file_t* const, const h5_id_t); + h5_id_t (*get_loc_elem_neighbor_idx)( + h5_file_t* const, const h5_id_t, const h5_id_t); + h5_id_t (*set_loc_elem_neighbor_idx)( + h5_file_t* const, const h5_id_t, const h5_id_t, const h5_id_t); + + h5_generic_elem_t* (*get_glb_elem)( + h5_file_t* const, const h5_id_t); + h5_id_t (*get_glb_elem_idx)( + h5_file_t* const, const h5_id_t); + h5_id_t (*set_glb_elem_idx)( + h5_file_t* const, const h5_id_t, const h5_id_t); + h5_id_t (*get_glb_elem_parent_idx)( + h5_file_t* const, const h5_id_t); + h5_id_t (*set_glb_elem_parent_idx)( + h5_file_t* const, const h5_id_t, const h5_id_t); + h5_id_t (*get_glb_elem_child_idx)( + h5_file_t* const, const h5_id_t); + h5_id_t (*set_glb_elem_child_idx)( + h5_file_t* const, const h5_id_t, const h5_id_t); + h5_id_t (*get_glb_elem_level_idx)( + h5_file_t* const, const h5_id_t); + h5_id_t (*set_glb_elem_level_idx)( + h5_file_t* const, const h5_id_t, const h5_id_t); + h5_id_t* (*get_glb_elem_vertex_indices)( + h5_file_t* const, const h5_id_t); + h5_id_t (*get_glb_elem_vertex_idx)( + h5_file_t* const, const h5_id_t, const h5_id_t); + h5_id_t (*set_glb_elem_vertex_idx)( + h5_file_t* const, const h5_id_t, const h5_id_t, const h5_id_t); + h5_id_t* (*get_glb_elem_neighbor_indices)( + h5_file_t* const, const h5_id_t); + h5_id_t (*get_glb_elem_neighbor_idx)( + h5_file_t* const, const h5_id_t, const h5_id_t); + h5_id_t (*set_glb_elem_neighbor_idx)( + h5_file_t* const, const h5_id_t, const h5_id_t, const h5_id_t); + +}; + +struct h5t_read_methods { + h5_err_t (*init_loc_elems_struct)(h5_file_t* const); +}; + struct h5t_adjacency_methods { h5_err_t (*update_internal_structs)(h5_file_t* const, h5_id_t); h5_err_t (*release_internal_structs)(h5_file_t* const); @@ -40,101 +173,21 @@ struct h5t_adjacency_methods { h5_file_t * const, const h5_id_t, h5_idlist_t**); }; -struct h5t_methods { +typedef struct h5t_methods { + struct h5t_read_methods *read; struct h5t_store_methods *store; struct h5t_retrieve_methods *retrieve; + struct h5t_access_methods *access; struct h5t_adjacency_methods *adjacency; -}; +} h5t_methods_t; -typedef struct h5_vertex { - h5_id_t global_idx; - h5_coord3d_t P; -} h5_vertex_t; - -typedef struct h5_vertex_data { - h5_idlist_t tv; -} h5_vertex_data_t; - -typedef struct h5_triangle { - h5_id_t global_idx; - h5_id_t global_parent_idx; - h5_id_t global_child_idx; - h5_3id_t global_vertex_indices; -} h5_triangle_t; - -typedef struct h5_tetrahedron { - h5_id_t global_idx; - h5_id_t global_parent_idx; - h5_id_t global_child_idx; - h5_4id_t global_vertex_indices; -} h5_tetrahedron_t; -typedef h5_tetrahedron_t h5_tet_t; - -typedef struct h5_elem { - h5_id_t global_idx; - h5_id_t global_parent_idx; - h5_id_t global_child_idx; - h5_id_t global_vertex_indices[1]; -} h5_elem_t; - -typedef struct h5_elem_ldta { - h5_id_t local_parent_idx; - h5_id_t local_child_idx; - h5_id_t level_id; - h5_id_t *local_vertex_indices; -} h5_elem_ldta_t; - - -typedef union h5_elems { - h5_tet_t *tets; - h5_triangle_t *tris; - void *data; -} h5_elems_t; - - - - -typedef struct boundary { - char name[16]; - char label[256]; - h5_id_t id; /* name of boundary as integer */ - h5_id_t changed; /* true if boundary is new or - has been changed */ - h5_id_t gid; /* hdf5 grp id boundary */ - h5_id_t *faces; - h5_id_t *lfaces; - h5_size_t *num_faces; /* addit. num of faces per level */ - h5_size_t *num_faces_on_level; /* real num of faces per level */ - - h5_id_t last_accessed_face; - h5_dsinfo_t dsinfo; -} boundary_t; - -/*** type ids' for compound types ***/ -typedef struct h5_dtypes { - hid_t h5_id_t; /* ID's */ - hid_t h5_int64_t; /* 64 bit signed integer */ - hid_t h5_float64_t; /* 64 bit floating point */ - hid_t h5_coord3d_t; /* 3-tuple of 64-bit float */ - hid_t h5_3id_t; /* 3-tuple of ID's */ - hid_t h5_4id_t; /* 4-tuple of ID's */ - hid_t h5_vertex_t; /* vertex structure */ - hid_t h5_triangle_t; /* triangle structure */ - hid_t h5_tet_t; /* tetrahedron structure */ - hid_t h5t_tag_idx_t; -} h5_dtypes_t; - -typedef struct h5t_adjacencies { - h5_hashtable_t te_hash; - h5_hashtable_t td_hash; -} h5t_adjacencies_t; typedef struct h5t_fdata { /*** book-keeping ***/ char mesh_name[16]; char mesh_label[256]; h5_oid_t mesh_type; /* object id of element type */ - const h5t_ref_element_t* ref_element; + const h5t_ref_elem_t* ref_elem; 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 */ @@ -166,9 +219,9 @@ typedef struct h5t_fdata { /*** Elements ***/ - h5_elems_t elems; - h5_elem_ldta_t *elems_ldta; /* local, per element data */ - h5_id_t *elems_lvids; + h5_elems_t glb_elems; + h5_elems_t loc_elems; + h5_size_t *num_elems; h5_size_t *num_elems_on_level; h5_idmap_t map_elem_g2l; /* map global id to local id */ @@ -188,13 +241,6 @@ typedef struct h5t_fdata { h5_idlist_t marked_entities; -#if 0 - /*** Boundary Meshes ***/ - h5_id_t num_boundaries; /* number of boundaries */ - h5_id_t boundaries_gid; /* hdf5 grp id container group */ - - boundary_t boundary; -#endif /*** Adjacencies ***/ h5t_adjacencies_t adjacencies;