- refactored variable names local_ prefix removed in some files

- test existence of vertices while refining via adjecencies
This commit is contained in:
2009-08-14 13:03:48 +00:00
parent e047595885
commit 0228c69cfa
23 changed files with 742 additions and 1111 deletions
+2
View File
@@ -52,6 +52,7 @@ EXTRA_HEADERS = \
h5t_boundaries_private.h \
h5t_consts_private.h \
h5t_errorhandling_private.h \
h5t_hsearch_private.h \
h5t_inquiry.h \
h5t_map.h \
h5t_openclose.h \
@@ -98,6 +99,7 @@ libH5_core_a_SOURCES = \
h5t_boundaries.c \
h5t_consts.c \
h5t_errorhandling.c \
h5t_hsearch.c \
h5t_inquiry.c \
h5t_map.c \
h5t_openclose.c \
+1
View File
@@ -21,6 +21,7 @@
#include "h5t_boundaries_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_private.h"
+1 -1
View File
@@ -333,7 +333,7 @@ h5_set_funcname (
h5_file_t * const f,
const char * const fname
) {
f->__funcname = (char * const) fname;
f->__funcname = (char *) fname;
}
/*!
+10 -4
View File
@@ -64,8 +64,8 @@ _h5_hcreate_r (
h5_file_t * const f,
size_t nel,
h5_hashtable_t *htab,
int (*compare)(const void*, const void*),
unsigned int (*compute_hash)(const void*)
int (*compare)(void*, void*),
unsigned int (*compute_hash)(void*)
) {
/* Test for correct arguments. */
if (htab == NULL || htab->table != NULL) {
@@ -89,6 +89,10 @@ _h5_hcreate_r (
return H5_SUCCESS;
}
/*
Grow hash table. Do nothing if requested number of elements is less than
or equal the current size.
*/
h5_err_t
_h5_hresize_r (
h5_file_t * const f,
@@ -98,12 +102,14 @@ _h5_hresize_r (
if ( htab == NULL || htab->table == NULL ) {
h5_error_internal ( f, __FILE__, __func__, __LINE__ );
}
if ( htab->size >= nel ) return H5_SUCCESS;
h5_hashtable_t __htab;
memset ( &__htab, 0, sizeof ( __htab ) );
nel += htab->size;
h5_debug ( f, "Resize hash table from %u to %lu elements.",
htab->size, nel );
TRY ( _h5_hcreate_r ( f, nel, &__htab, htab->compare, htab->compute_hash ) );
TRY ( _h5_hcreate_r (
f, nel, &__htab, htab->compare, htab->compute_hash ) );
unsigned int idx;
for ( idx = 1; idx <= htab->size; idx++ ) {
if ( htab->table[idx].used ) {
@@ -234,7 +240,7 @@ void
_h5_hwalk_r (
h5_file_t* f,
struct hsearch_data *htab,
void (*visit)(void *item)
void (*visit)(const void *item)
) {
unsigned int idx = 1;
for ( idx = 1; idx < htab->size; idx++ ) {
+3 -3
View File
@@ -27,8 +27,8 @@ _h5_hcreate_r (
h5_file_t* const f,
size_t __nel,
struct hsearch_data *__htab,
int (*compare)(const void*, const void*),
unsigned int (*compute_hash)(const void*)
int (*compare)(void*, void*),
unsigned int (*compute_hash)(void*)
);
extern h5_err_t
@@ -48,6 +48,6 @@ extern void
_h5_hwalk_r (
h5_file_t* f,
struct hsearch_data *__htab,
void (*visit)(void *__item)
void (*visit)(const void *__item)
);
#endif
+9
View File
@@ -117,6 +117,9 @@ _h5_sort_idlist_by_eid (
return H5_SUCCESS;
}
/*
Find ID in sorted list
*/
h5_id_t
_h5_find_idlist (
h5_file_t * const f,
@@ -138,6 +141,9 @@ _h5_find_idlist (
return -(low+1); // not found
}
/*
Add item to list at position given by \c idx.
*/
h5_id_t
_h5_insert_idlist (
h5_file_t * const f,
@@ -163,6 +169,9 @@ _h5_insert_idlist (
return idx;
}
/*
Search in sorted list. If item is not in list, add it.
*/
h5_id_t
_h5_search_idlist (
h5_file_t * const f,
+8 -3
View File
@@ -39,10 +39,15 @@ typedef int64_t h5_err_t;
typedef double h5_float64_t;
typedef float h5_float32_t;
struct h5_complex {
typedef struct h5_complex {
h5_float64_t r,i;
};
typedef struct h5_complex h5_complex_t;
} h5_complex_t;
typedef h5_id_t h5_2id_t[2];
typedef h5_id_t h5_3id_t[3];
typedef h5_id_t h5_4id_t[4];
typedef h5_float64_t h5_coord3d_t[3];
struct h5_file;
typedef h5_err_t (*h5_errorhandler_t)(
+154 -453
View File
@@ -20,149 +20,29 @@
#include "h5_core/h5_core_private.h"
/*
compute T(V)
compute T(V) from current level up to highest levels.
*/
static h5_err_t
_compute_tets_of_vertices (
h5_file_t * const f
) {
h5t_fdata_t *t = f->t;
h5_elem_ldta_t *tet;
h5_id_t local_tid;
h5_id_t local_vid;
int i;
for ( local_tid = 0, tet = &t->elems_ldta[0];
local_tid < t->num_elems[t->num_levels-1];
local_tid++, tet++ ) {
h5_id_t eid = (t->cur_level <= 0 ) ? 0 : t->num_elems[t->cur_level-1];
h5_elem_ldta_t *tet = tet = &t->elems_ldta[eid];
h5_id_t num_elems = t->num_elems[t->num_levels-1];
for ( ;eid < num_elems; eid++, tet++ ) {
int i;
for ( i = 0; i < 4; i++ ) {
local_vid = tet->local_vids[i];
h5_id_t vid = tet->local_vids[i];
TRY ( _h5_append_to_idlist (
f,
&t->vertices_data[local_vid].tv,
_h5t_build_vertex_id( i, local_tid ) ) );
&t->vertices_data[vid].tv,
_h5t_build_vertex_id( i, eid ) ) );
}
}
return H5_SUCCESS;
}
static int
_cmp_te_entries (
const void *__a,
const void *__b
) {
return memcmp ( __a, __b, sizeof(h5_2id_t) );
}
static unsigned int
_compute_te_hashval (
const void *__item
) {
h5_te_entry_t *item = (h5_te_entry_t*)__item;
char *key = (char *)item->key.vids;
unsigned int count = 2 * sizeof ( item->key.vids[0] );
unsigned int hval = count;
while ( count-- > 0 ) {
if ( key[count] ) {
hval <<= 4;
hval += key[count];
}
}
return hval;
}
h5_err_t
_h5t_search_te2 (
h5_file_t * const f,
h5_id_t face_id,
h5_id_t local_eid,
h5_te_entry_t **entry
) {
h5t_fdata_t *t = f->t;
h5t_adjacencies_t *a = &t->adjacencies;
void *__retval;
if ( *entry == NULL ) {
TRY ( *entry = _h5_calloc ( f, 1, sizeof(**entry) ) );
}
_h5t_get_local_vids_of_edge (
&t->elems_ldta[local_eid],
face_id,
(*entry)->key.vids );
TRY ( _h5_hsearch_r (
f,
*entry,
H5_ENTER,
&__retval,
&a->te_hash ) );
h5_te_entry_t *retval = (h5_te_entry_t *)__retval;
TRY ( _h5_append_to_idlist (
f,
&retval->value,
_h5t_build_edge_id ( face_id, local_eid ) ) );
if ( retval->value.num_items == 1 ) {
*entry = NULL;
}
return H5_SUCCESS;
}
/*
Find item in the T(E) hash table.
Passing item with type entry type.
*/
h5_err_t
_h5t_find_te (
h5_file_t * const f,
h5_te_entry_t *item,
h5_te_entry_t **retval
) {
void *__ret;
TRY ( _h5_hsearch_r (
f,
item,
H5_FIND,
&__ret,
&f->t->adjacencies.te_hash ) );
*retval = (h5_te_entry_t *)__ret;
return H5_SUCCESS;
}
/*
Find item in the T(E) hash table.
Passing item with face and local element ID.
*/
h5_err_t
_h5t_find_te2 (
h5_file_t * const f,
h5_id_t face_id,
h5_id_t local_eid,
h5_te_entry_t **retval
) {
h5_te_entry_t item;
_h5t_get_local_vids_of_edge (
&f->t->elems_ldta[local_eid],
face_id,
item.key.vids
);
return _h5t_find_te ( f, &item, retval );
}
static void
_sort_telist (
const void *_entry
) {
h5_te_entry_t *entry = *(h5_te_entry_t **)_entry;
h5_idlist_t *list = &entry->value;
qsort (
list->items,
list->num_items,
sizeof(list->items[0]),
_h5_cmp_ids_by_eid );
}
/*
Compute T(E) from current level up to highest levels.
*/
@@ -171,191 +51,36 @@ _compute_tets_of_edges (
h5_file_t * const f
) {
h5t_fdata_t *t = f->t;
h5t_adjacencies_t *a = &t->adjacencies;
h5_te_entry_t *entry = NULL;
h5_elem_ldta_t *tet = &t->elems_ldta[0];
h5_id_t cur_lvl = t->cur_level < 0 ? 0 : t->cur_level;
h5_id_t eid = (t->cur_level <= 0 ) ? 0 : t->num_elems[t->cur_level-1];
h5_elem_ldta_t *tet = tet = &t->elems_ldta[eid];
h5_id_t num_elems = t->num_elems[t->num_levels-1];
h5_id_t local_eid = (cur_lvl == 0 ) ? 0 : t->num_elems[cur_lvl-1];
TRY ( _h5_hcreate_r (
f,
5*(num_elems - local_eid),
&a->te_hash,
_cmp_te_entries,
_compute_te_hashval ) );
for ( ; local_eid < num_elems; local_eid++, tet++ ) {
h5_id_t face_id;
for ( face_id = 0; face_id < 6; face_id++ ) {
if ( (a->te_hash.size*6) <= (a->te_hash.filled<<3) ) {
TRY ( _h5_hresize_r (
f,
3*(num_elems - local_eid),
&a->te_hash ) );
}
TRY ( _h5t_search_te2 (
f,
face_id,
local_eid,
&entry ) );
h5_te_entry_t *retval = NULL;
TRY ( _h5t_resize_te_htab ( f, 4*(num_elems-eid) ) );
for ( ; eid < num_elems; eid++, tet++ ) {
h5_id_t face;
for ( face = 0; face < 6; face++ ) {
TRY ( _h5t_search_te2 ( f, face, eid, &retval ) );
}
}
_h5_hwalk_r ( f, &a->te_hash, _sort_telist );
if ( entry && entry->value.items == NULL ) {
_h5_free ( f, entry );
}
return H5_SUCCESS;
}
static int
_cmp_td_entries (
const void *__a,
const void *__b
) {
return memcmp ( __a, __b, sizeof(h5_3id_t) );
}
static unsigned int
_compute_td_hashval (
const void *__item
) {
h5_te_entry_t *item = (h5_te_entry_t*)__item;
char *key = (char *)item->key.vids;
unsigned int count = sizeof ( h5_3id_t );
unsigned int hval = count;
while ( count-- > 0 ) {
if ( key[count] ) {
hval <<= 4;
hval += key[count];
}
}
return hval;
}
h5_err_t
_h5t_search_td2 (
h5_file_t * const f,
h5_id_t face_id,
h5_id_t local_eid,
h5_td_entry_t **entry
) {
void *__retval;
if ( *entry == NULL ) {
TRY ( *entry = _h5_calloc ( f, 1, sizeof(**entry) ) );
}
_h5t_get_local_vids_of_triangle (
&f->t->elems_ldta[local_eid],
face_id,
(*entry)->key.vids );
TRY ( _h5_hsearch_r (
f,
*entry,
H5_ENTER,
&__retval,
&f->t->adjacencies.td_hash ) );
h5_td_entry_t *retval = (h5_td_entry_t *)__retval;
TRY ( _h5_append_to_idlist (
f,
&retval->value,
_h5t_build_triangle_id ( face_id, local_eid ) ) );
if ( retval->value.num_items == 1 ) {
*entry = NULL;
}
return H5_SUCCESS;
}
h5_err_t
_h5t_find_td (
h5_file_t * const f,
h5_td_entry_t *item,
h5_td_entry_t **retval
) {
void *__ret;
_h5_hsearch_r (
f,
item,
H5_FIND,
&__ret,
&f->t->adjacencies.td_hash );
if ( __ret == NULL ) {
return _h5t_error_local_triangle_nexist( f, item->key.vids );
}
*retval = (h5_td_entry_t *)__ret;
return H5_SUCCESS;
}
h5_err_t
_h5t_find_td2 (
h5_file_t * const f,
h5_id_t face_id,
h5_id_t local_eid,
h5_td_entry_t **retval
) {
h5_td_entry_t item;
_h5t_get_local_vids_of_triangle (
&f->t->elems_ldta[local_eid],
face_id,
item.key.vids );
return _h5t_find_td ( f, &item, retval );
}
/*
Sort ID list according their tetrahedra ID.
Called by twalk().
*/
static void
_sort_tdlist (
const void *_entry
) {
h5_td_entry_t *entry = *(h5_td_entry_t **)_entry;
h5_idlist_t *list = &entry->value;
qsort (
list->items,
list->num_items,
sizeof(list->items[0]),
_h5_cmp_ids_by_eid );
}
static h5_err_t
_compute_tets_of_triangles (
h5_file_t * const f
) {
h5t_fdata_t *t = f->t;
h5t_adjacencies_t *a = &t->adjacencies;
h5_td_entry_t *entry = NULL;
h5_elem_ldta_t *tet = &t->elems_ldta[0];
h5_id_t cur_lvl = t->cur_level < 0 ? 0 : t->cur_level;
h5_size_t num_elems = t->num_elems[t->num_levels-1];
h5_id_t local_eid = (cur_lvl == 0 ) ? 0 : t->num_elems[cur_lvl-1];
TRY ( _h5_hcreate_r (
f,
5*(num_elems-local_eid),
&a->td_hash,
_cmp_td_entries,
_compute_td_hashval ) );
for ( ; local_eid < num_elems; local_eid++, tet++ ) {
h5_id_t face_id;
for ( face_id = 0; face_id < 4; face_id++ ) {
if ( (a->td_hash.size*6) <= (a->td_hash.filled<<3) ) {
TRY ( _h5_hresize_r (
f,
3*(num_elems-local_eid),
&a->td_hash ) );
}
TRY (
_h5t_search_td2 (
f,
face_id,
local_eid,
&entry )
);
h5_id_t eid = (t->cur_level <= 0 ) ? 0 : t->num_elems[t->cur_level-1];
h5_elem_ldta_t *tet = tet = &t->elems_ldta[eid];
h5_id_t num_elems = t->num_elems[t->num_levels-1];
h5_td_entry_t *retval = NULL;
TRY ( _h5t_resize_td_htab ( f, 4*(num_elems-eid) ) );
for ( ; eid < num_elems; eid++, tet++ ) {
h5_id_t face;
for ( face = 0; face < 4; face++ ) {
TRY ( _h5t_search_td2 ( f, face, eid, &retval ) );
}
}
_h5_hwalk_r ( f, &a->td_hash, _sort_tdlist );
if ( entry && entry->value.items == NULL ) {
_h5_free ( f, entry );
}
return H5_SUCCESS;
}
@@ -382,34 +107,10 @@ _h5t_rebuild_adj_data (
return H5_SUCCESS;
}
/*!
\param[in] f file handle
\param[in] local_kid local edge ID we search children of
\param[in] local_eid local element ID of first children
\param[out] kids direct children
*/
h5_err_t
_compute_direct_children_of_edge (
h5_file_t * const f,
h5_id_t face_id,
h5_id_t local_eid,
h5_id_t kids[2]
) {
int off[6][2] = { {0,1}, {1,2}, {0,2}, {0,3}, {1,3}, {2,3} };
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;
}
static h5_err_t
_compute_children_of_edge (
h5_file_t * const f,
h5_id_t local_kid,
h5_id_t kid,
h5_idlist_t *children
) {
h5t_fdata_t *t = f->t;
@@ -417,31 +118,31 @@ _compute_children_of_edge (
TRY ( _h5t_find_te2 (
f,
_h5t_get_face_id ( local_kid ),
_h5t_get_elem_id ( local_kid ),
_h5t_get_face_id ( kid ),
_h5t_get_elem_id ( kid ),
&te )
);
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 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];
h5_elem_ldta_t *tet = &t->elems_ldta[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 (
h5_id_t kids[2];
TRY ( _h5t_compute_direct_children_of_edge (
f,
face_id,
tet->local_child_eid,
local_kids ) );
kids ) );
TRY ( _compute_children_of_edge (
f, local_kids[0], children ) );
f, kids[0], children ) );
TRY ( _compute_children_of_edge (
f, local_kids[1], children ) );
f, kids[1], children ) );
}
}
return H5_SUCCESS;
@@ -453,7 +154,7 @@ _compute_children_of_edge (
static h5_err_t
_compute_sections_of_edge (
h5_file_t * const f,
h5_id_t local_kid,
h5_id_t kid,
h5_idlist_t *children
) {
h5t_fdata_t *t = f->t;
@@ -461,29 +162,29 @@ _compute_sections_of_edge (
TRY ( _h5t_find_te2 (
f,
_h5t_get_face_id ( local_kid ),
_h5t_get_elem_id ( local_kid ),
_h5t_get_face_id ( kid ),
_h5t_get_elem_id ( kid ),
&te )
);
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 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];
h5_elem_ldta_t *tet = &t->elems_ldta[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 (
h5_id_t kids[2];
TRY ( _h5t_compute_direct_children_of_edge (
f,
face_id,
tet->local_child_eid,
local_kids ) );
kids ) );
TRY ( _compute_sections_of_edge (
f, local_kids[0], children ) );
f, kids[0], children ) );
TRY ( _compute_sections_of_edge (
f, local_kids[1], children ) );
f, kids[1], children ) );
}
}
if ( ! refined ) {
@@ -496,7 +197,7 @@ 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 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} };
@@ -504,17 +205,17 @@ _compute_direct_children_of_triangle (
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] );
dids[0] = _h5t_build_edge_id ( face_id, eid+off[face_id][0] );
dids[1] = _h5t_build_edge_id ( face_id, eid+off[face_id][1] );
dids[2] = _h5t_build_edge_id ( face_id, eid+off[face_id][2] );
dids[3] = _h5t_build_edge_id ( face_id, eid+off[face_id][3] );
return H5_SUCCESS;
}
h5_err_t
_compute_children_of_triangle (
h5_file_t * const f,
h5_id_t local_did,
h5_id_t did,
h5_idlist_t *children
) {
@@ -523,35 +224,35 @@ _compute_children_of_triangle (
TRY ( _h5t_find_td2 (
f,
_h5t_get_face_id ( local_did ),
_h5t_get_elem_id ( local_did ),
_h5t_get_face_id ( did ),
_h5t_get_elem_id ( did ),
&td
) );
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 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];
h5_elem_ldta_t *tet = &t->elems_ldta[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];
h5_id_t dids[4];
TRY ( _compute_direct_children_of_triangle (
f,
face_id,
tet->local_child_eid,
local_dids ) );
dids ) );
TRY ( _compute_children_of_triangle (
f, local_dids[0], children ) );
f, dids[0], children ) );
TRY ( _compute_children_of_triangle (
f, local_dids[1], children ) );
f, dids[1], children ) );
TRY ( _compute_children_of_triangle (
f, local_dids[2], children ) );
f, dids[2], children ) );
TRY ( _compute_children_of_triangle (
f, local_dids[3], children ) );
f, dids[3], children ) );
}
}
return H5_SUCCESS;
@@ -560,7 +261,7 @@ _compute_children_of_triangle (
static h5_err_t
_compute_sections_of_triangle (
h5_file_t * const f,
h5_id_t local_did,
h5_id_t did,
h5_idlist_t *children
) {
h5t_fdata_t *t = f->t;
@@ -568,31 +269,31 @@ _compute_sections_of_triangle (
TRY ( _h5t_find_td2 (
f,
_h5t_get_face_id ( local_did ),
_h5t_get_elem_id ( local_did ), &td ) );
_h5t_get_face_id ( did ),
_h5t_get_elem_id ( did ), &td ) );
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 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];
h5_elem_ldta_t *tet = &t->elems_ldta[eid];
if ( ! _h5t_elem_is_on_cur_level ( f, tet ) == H5_OK ) {
refined = 1;
h5_id_t local_dids[4];
h5_id_t dids[4];
TRY ( _compute_direct_children_of_triangle (
f,
face_id,
tet->local_child_eid,
local_dids ) );
dids ) );
TRY ( _compute_sections_of_triangle (
f, local_dids[0], children ) );
f, dids[0], children ) );
TRY ( _compute_sections_of_triangle (
f, local_dids[1], children ) );
f, dids[1], children ) );
TRY ( _compute_sections_of_triangle (
f, local_dids[2], children ) );
f, dids[2], children ) );
TRY ( _compute_sections_of_triangle (
f, local_dids[3], children ) );
f, dids[3], children ) );
}
}
@@ -610,10 +311,10 @@ _add_edge (
h5_file_t * const f,
h5_idlist_t *list,
h5_id_t face_id,
h5_id_t local_eid
h5_id_t eid
) {
h5_te_entry_t *te;
TRY ( _h5t_find_te2 ( f, face_id, local_eid, &te ) );
TRY ( _h5t_find_te2 ( f, face_id, eid, &te ) );
TRY ( _h5_search_idlist ( f, list, te->value.items[0] ) );
return H5_SUCCESS;
}
@@ -622,28 +323,28 @@ _add_edge (
h5_err_t
h5t_get_edges_upadjacent_to_vertex (
h5_file_t * const f,
const h5_id_t local_vid,
const h5_id_t vid,
h5_idlist_t **list
) {
TRY ( _h5_alloc_idlist ( f, list, 8 ) );
h5t_fdata_t *t = f->t;
h5_idlist_t *tv = &t->vertices_data[local_vid].tv;
h5_idlist_t *tv = &t->vertices_data[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];
h5_id_t *vidp = tv->items;
for ( i = 0; i < tv->num_items; i++, vidp++ ) {
h5_id_t eid = _h5t_get_elem_id ( *vidp );
h5_id_t face = _h5t_get_face_id ( *vidp );
h5_elem_ldta_t *tet = &t->elems_ldta[eid];
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} };
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 ) );
int map[4][3] = { {0,2,3}, {0,1,4}, {2,1,5}, {3,4,5} };
TRY ( _add_edge ( f, *list, map[face][0], eid ) );
TRY ( _add_edge ( f, *list, map[face][1], eid ) );
TRY ( _add_edge ( f, *list, map[face][2], eid ) );
}
return H5_SUCCESS;
}
@@ -652,11 +353,11 @@ static h5_err_t
_add_triangle (
h5_file_t * const f,
h5_idlist_t *list,
h5_id_t face_id,
h5_id_t local_eid
h5_id_t face,
h5_id_t eid
) {
h5_td_entry_t *td;
TRY ( _h5t_find_td2 ( f, face_id, local_eid, &td ) );
TRY ( _h5t_find_td2 ( f, face, eid, &td ) );
TRY ( _h5_search_idlist ( f, list, td->value.items[0] ) );
return H5_SUCCESS;
@@ -665,27 +366,27 @@ _add_triangle (
h5_err_t
h5t_get_triangles_upadjacent_to_vertex (
h5_file_t * const f,
const h5_id_t local_vid,
const h5_id_t vid,
h5_idlist_t **list
) {
TRY ( _h5_alloc_idlist ( f, list, 8 ) );
h5t_fdata_t *t = f->t;
h5_idlist_t *tv = &t->vertices_data[local_vid].tv;
h5_idlist_t *tv = &t->vertices_data[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];
h5_id_t *vidp = tv->items;
for ( i = 0; i < tv->num_items; i++, vidp++ ) {
h5_id_t eid = _h5t_get_elem_id ( *vidp );
h5_id_t face = _h5t_get_face_id ( *vidp );
h5_elem_ldta_t *tet = &t->elems_ldta[eid];
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} };
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 ) );
int map[4][3] = { {1,2,3}, {0,2,3}, {0,1,3}, {0,1,2} };
TRY ( _add_triangle ( f, *list, map[face][0], eid ) );
TRY ( _add_triangle ( f, *list, map[face][1], eid ) );
TRY ( _add_triangle ( f, *list, map[face][2], eid ) );
}
return H5_SUCCESS;
}
@@ -693,23 +394,23 @@ h5t_get_triangles_upadjacent_to_vertex (
h5_err_t
h5t_get_tets_upadjacent_to_vertex (
h5_file_t * const f,
const h5_id_t local_vid,
const h5_id_t vid,
h5_idlist_t **list
) {
TRY ( _h5_alloc_idlist ( f, list, 8 ) );
h5t_fdata_t *t = f->t;
h5_idlist_t *tv = &t->vertices_data[local_vid].tv;
h5_idlist_t *tv = &t->vertices_data[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];
h5_id_t *vidp = tv->items;
for ( i = 0; i < tv->num_items; i++, vidp++ ) {
h5_id_t eid = _h5t_get_elem_id ( *vidp );
h5_elem_ldta_t *tet = &t->elems_ldta[eid];
if ( _h5t_elem_is_on_cur_level ( f, tet ) == H5_NOK ) {
continue;
}
TRY ( _h5_search_idlist ( f, *list, local_eid ) );
TRY ( _h5_search_idlist ( f, *list, eid ) );
}
return H5_SUCCESS;
}
@@ -717,21 +418,21 @@ h5t_get_tets_upadjacent_to_vertex (
h5_err_t
h5t_get_triangles_upadjacent_to_edge (
h5_file_t * const f,
const h5_id_t local_kid,
const h5_id_t 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 ( _compute_children_of_edge ( f, 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 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 ( _add_triangle ( f, *list, map[face_id][0], eid ) );
TRY ( _add_triangle ( f, *list, map[face_id][1], eid ) );
}
TRY ( _h5_free_idlist( f, &children ) );
@@ -741,18 +442,18 @@ h5t_get_triangles_upadjacent_to_edge (
h5_err_t
h5t_get_tets_upadjacent_to_edge (
h5_file_t * const f,
const h5_id_t local_kid,
const h5_id_t 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( _compute_children_of_edge ( f, 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_id_t local_eid = _h5t_get_elem_id ( *kid );
TRY ( _h5_search_idlist ( f, *list, local_eid ) );
h5_id_t *kidp = children->items;
for ( i = 0; i < children->num_items; i++, kidp++ ) {
h5_id_t eid = _h5t_get_elem_id ( *kidp );
TRY ( _h5_search_idlist ( f, *list, eid ) );
}
TRY ( _h5_free_idlist( f, &children ) );
return H5_SUCCESS;
@@ -761,18 +462,18 @@ h5t_get_tets_upadjacent_to_edge (
h5_err_t
h5t_get_tets_upadjacent_to_triangle (
h5_file_t * const f,
const h5_id_t local_did,
const h5_id_t 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( _compute_children_of_triangle ( f, 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 ) );
h5_id_t *didp = children->items;
for ( i = 0; i < children->num_items; i++ , didp++) {
h5_id_t eid = _h5t_get_elem_id ( *didp );
TRY ( _h5_search_idlist ( f, *list, eid ) );
}
TRY ( _h5_free_idlist( f, &children ) );
return H5_SUCCESS;
@@ -782,20 +483,20 @@ h5t_get_tets_upadjacent_to_triangle (
h5_err_t
h5t_get_vertices_downadjacent_to_edge (
h5_file_t * const f,
const h5_id_t local_kid,
const h5_id_t 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( _compute_sections_of_edge ( f, 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] ) );
h5_id_t *kidp = children->items;
for ( i = 0; i < children->num_items; i++, kidp++ ) {
h5_id_t vids[2];
TRY ( h5t_get_local_vids_of_edge ( f, *kidp, vids ) );
TRY ( _h5_search_idlist ( f, *list, vids[0] ) );
TRY ( _h5_search_idlist ( f, *list, vids[1] ) );
}
TRY ( _h5_free_idlist( f, &children ) );
return H5_SUCCESS;
@@ -807,30 +508,30 @@ h5t_get_vertices_downadjacent_to_edge (
h5_err_t
h5t_get_vertices_downadjacent_to_triangle (
h5_file_t * const f,
const h5_id_t local_did,
const h5_id_t 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 face = _h5t_get_face_id ( did );
h5_id_t eid = _h5t_get_elem_id ( 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 ),
_h5t_build_edge_id ( map[face][i], 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] ) );
h5_id_t vids[2];
TRY ( h5t_get_local_vids_of_edge ( f, *kid, vids ) );
TRY ( _h5_search_idlist ( f, *list, vids[0] ) );
TRY ( _h5_search_idlist ( f, *list, vids[1] ) );
}
TRY ( _h5_free_idlist( f, &children ) );
return H5_SUCCESS;
@@ -842,7 +543,7 @@ h5t_get_vertices_downadjacent_to_triangle (
h5_err_t
h5t_get_vertices_downadjacent_to_tet (
h5_file_t * const f,
const h5_id_t local_eid,
const h5_id_t eid,
h5_idlist_t **list
) {
h5_idlist_t *children;
@@ -852,16 +553,16 @@ h5t_get_vertices_downadjacent_to_tet (
for ( i = 0; i < 6; i++ ) {
TRY( _compute_sections_of_edge (
f,
_h5t_build_edge_id ( i, local_eid ),
_h5t_build_edge_id ( i, 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] ) );
h5_id_t vids[2];
TRY ( h5t_get_local_vids_of_edge ( f, *kid, vids ) );
TRY ( _h5_search_idlist ( f, *list, vids[0] ) );
TRY ( _h5_search_idlist ( f, *list, vids[1] ) );
}
TRY ( _h5_free_idlist( f, &children ) );
return H5_SUCCESS;
@@ -870,21 +571,21 @@ h5t_get_vertices_downadjacent_to_tet (
h5_err_t
h5t_get_edges_downadjacent_to_triangle (
h5_file_t * const f,
const h5_id_t local_did,
const h5_id_t 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 face_id = _h5t_get_face_id ( did );
h5_id_t eid = _h5t_get_elem_id ( 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 ),
_h5t_build_edge_id ( map[face_id][i], eid ),
children ) );
}
TRY ( _h5_alloc_idlist ( f, list, 8 ) );
@@ -899,7 +600,7 @@ h5t_get_edges_downadjacent_to_triangle (
h5_err_t
h5t_get_edges_downadjacent_to_tet (
h5_file_t * const f,
const h5_id_t local_eid,
const h5_id_t eid,
h5_idlist_t **list
) {
h5_idlist_t *children;
@@ -909,7 +610,7 @@ h5t_get_edges_downadjacent_to_tet (
for ( i = 0; i < 6; i++ ) {
TRY( _compute_sections_of_edge (
f,
_h5t_build_edge_id ( i, local_eid ),
_h5t_build_edge_id ( i, eid ),
children ) );
}
TRY ( _h5_alloc_idlist ( f, list, 8 ) );
@@ -924,7 +625,7 @@ h5t_get_edges_downadjacent_to_tet (
h5_err_t
h5t_get_triangles_downadjacent_to_tet (
h5_file_t * const f,
const h5_id_t local_eid,
const h5_id_t eid,
h5_idlist_t **list
) {
h5_idlist_t *children;
@@ -934,7 +635,7 @@ h5t_get_triangles_downadjacent_to_tet (
for ( i = 0; i < 4; i++ ) {
TRY( _compute_sections_of_triangle (
f,
_h5t_build_edge_id ( i, local_eid ),
_h5t_build_edge_id ( i, eid ),
children ) );
}
TRY ( _h5_alloc_idlist ( f, list, 8 ) );
-22
View File
@@ -6,26 +6,4 @@ _h5t_rebuild_adj_data (
h5_file_t * const f
);
h5_err_t
_h5t_find_te2 (
h5_file_t * const f,
h5_id_t face_id,
h5_id_t local_eid,
h5_te_entry_t **retval
);
h5_err_t
_h5t_find_td (
h5_file_t * const f,
h5_td_entry_t *item,
h5_td_entry_t **retval
);
h5_err_t
_h5t_find_td2 (
h5_file_t * const f,
h5_id_t face_id,
h5_id_t local_eid,
h5_td_entry_t **rentry
);
#endif
-20
View File
@@ -242,26 +242,6 @@ h5t_store_boundaryface (
f, __FILE__, __func__, __LINE__ );
}
h5_id_t
h5t_store_boundaryface_global_id (
h5_file_t * const f,
const h5_id_t global_fid
) {
struct h5t_fdata *t = f->t;
switch ( t->mesh_type ) {
case H5_OID_TETRAHEDRON: {
h5_id_t local_tid = h5t_map_global_triangle_id2local (
f, global_fid );
if ( local_tid < 0 ) return local_tid;
return h5t_store_boundaryface_local_id ( f, local_tid );
}
default:
return h5_error_not_implemented (
f, __FILE__, __func__, __LINE__ );
}
}
h5_id_t
h5t_store_boundaryface_local_id (
h5_file_t * const f,
-6
View File
@@ -29,12 +29,6 @@ h5t_store_boundaryface (
h5_id_t * const vertices
);
h5_id_t
h5t_store_boundaryface_global_id (
h5_file_t * const f,
const h5_id_t global_fid
);
h5_id_t
h5t_store_boundaryface_local_id (
h5_file_t * const f,
+80 -114
View File
@@ -9,10 +9,18 @@
#include "h5_core/h5_core.h"
#include "h5_core/h5_core_private.h"
/*!
Get number of meshes of given type.
\param[in] f File handle
\param[in] type_id Type of mesh we want the number of.
\return Number of meshes of type \c type_id or error code.
*/
h5_size_t
h5t_get_num_meshes (
h5_file_t * const f,
const enum h5_oid type
const enum h5_oid type_id
) {
struct h5t_fdata *t = f->t;
@@ -24,17 +32,22 @@ h5t_get_num_meshes (
}
TRY( t->num_meshes = (h5_size_t)hdf5_get_num_objects (
t->topo_gid,
_h5t_meshes_grpnames[type],
_h5t_meshes_grpnames[type_id],
H5G_GROUP ) );
return t->num_meshes;
}
/*
/*!
Get the number of hierarchical mesh levels.
\param[in] f File handle
\return Number of hierarchical mesh levels or error code.
*/
h5_size_t
h5t_get_num_levels (
h5_file_t * f
h5_file_t * const f
) {
h5t_fdata_t *t = f->t;
@@ -44,122 +57,75 @@ h5t_get_num_levels (
return t->num_levels;
}
/*!
Get current level.
/*
query number of topological elems:
\param[in] f File handle.
* on this cnode on current level
H5FedGetNumXXX(), h5t_get_num_elems()
* on given cnode on current level
H5FedGetNumXXXCnode(), h5t_get_num_elems_cnode()
* on this cnode on current level total (internal)
_h5t_get_num_elems_total()
* on given cnode on current level total (internal)
* on all cnodes on current level
H5FedGetNumXXXCnodeTotal()
* on all cnodes on current level total (internal)
* on this cnode on given level
H5FedGetNumXXXOnLevel()
* on this cnode on given level total (internal)
* on given cnode on given level
H5FedGetNumXXXCnodeOnLevel()
* on given cnode on given level total (internal)
* on all cnodes on given level
H5FedGetNumXXXTotalOnLevel()
* on all cnodes on given level total (internal)
* on this cnode on last level (internal)
* on given cnode on last level (internal)
* on this cnode on last level total (internal)
* on given cnode on last level total (internal)
* on all cnodes on last level (internal)
* on all cnodes on last level total (internal)
\return Current level ID.
*/
/*!
Return number of elems on compute node \c cnode_id
and level \c level_id. If \cnode_id is equal \c -1 return the
number of elems in the entire mesh. If \level_id is equal \c -1
return the number of elems in the last level.
\remark
Refined elems are *not* counted.
*/
h5_size_t
h5t_get_num_elems (
h5_file_t * f,
h5_id_t cnode_id,
h5_id_t level_id
) {
h5t_fdata_t *t = f->t;
if ( t->cur_mesh < 0 ) {
return _h5t_error_undef_mesh ( 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_on_level[level_id];
}
/*!
Return number of all elems on compute node \c cnode_id
and level \c level_id including refined elems. If
\cnode_id is equal \c -1 return the number of elems
in the entire mesh. If \level_id is equal \c -1
return the number of elems in the last level.
*/
h5_size_t
h5t_get_num_elems_total (
h5_file_t * f,
h5_id_t cnode_id,
h5_id_t level_id
) {
h5t_fdata_t *t = f->t;
if ( t->cur_mesh < 0 ) {
return _h5t_error_undef_mesh ( 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];
}
/*!
Return number of vertices on compute node \c cnode_id
and level \c level_id. If \cnode_id is equal \c -1 return the
number of vertices in the entire mesh. If \level_id is equal \c -1
return the number of vertices in the last level.
\remark
There is nothing like "refined vertices".
*/
h5_size_t
h5t_get_num_vertices (
h5_file_t * f,
h5_id_t cnode_id,
h5_id_t level_id
) {
h5t_fdata_t *t = f->t;
if ( t->cur_mesh < 0 ) {
return _h5t_error_undef_mesh ( 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];
}
h5_id_t
h5t_get_level (
h5_file_t * f
) {
return f->t->cur_level;
}
/*!
Return number of elems on compute node \c cnode_id on
current level. If \cnode_id is equal \c -1 return the
number of elements in the entire mesh.
\remark
Refined elems are *not* counted.
\param[in] f File handle.
\param[in] cnode Compute node
\return Number of elements or error code.
*/
h5_size_t
h5t_get_num_elems (
h5_file_t * const f,
const h5_id_t cnode
) {
h5t_fdata_t *t = f->t;
if ( t->cur_mesh < 0 ) {
return _h5t_error_undef_mesh ( f );
}
if ( t->cur_level < 0 ) {
return _h5t_error_undef_level ( f );
}
return t->num_elems_on_level[t->cur_level];
}
/*!
Return number of vertices on compute node \c cnode_id
on current level. If \cnode_id is equal \c -1 return the
number of vertices in the entire mesh.
\remark
There is nothing like "refined vertices".
\param[in] f File handle.
\param[in] cnode Compute node
\return Number of vertices or error code.
*/
h5_size_t
h5t_get_num_vertices (
h5_file_t * f,
h5_id_t cnode
) {
h5t_fdata_t *t = f->t;
if ( t->cur_mesh < 0 ) {
return _h5t_error_undef_mesh ( f );
}
if ( t->cur_level < 0 ) {
return _h5t_error_undef_level ( f );
}
return t->num_vertices[t->cur_level];
}
+7 -18
View File
@@ -3,40 +3,29 @@
h5_size_t
h5t_get_num_meshes (
h5_file_t * f,
h5_file_t * const f,
const enum h5_oid type
);
h5_size_t
h5t_get_num_levels (
h5_file_t * f
h5_file_t * const f
);
h5_size_t
h5t_get_num_elems (
h5_file_t * f,
h5_id_t cnode_id,
h5_id_t level_id
);
h5_size_t
h5t_get_num_elems_total (
h5_file_t * f,
h5_id_t cnode_id,
h5_id_t level_id
h5_file_t * const f,
const h5_id_t cnode_id
);
h5_size_t
h5t_get_num_vertices (
h5_file_t * f,
h5_id_t cnode_id,
h5_id_t level_id
h5_file_t * const f,
const h5_id_t cnode_id
);
h5_id_t
h5t_get_level (
h5_file_t * f
h5_file_t * const f
);
#endif
+72 -135
View File
@@ -113,8 +113,8 @@ _h5t_get_local_vid (
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)
#define _get_vertex_of_elem( f, i, eid ) \
(f->t->vertices[ f->t->elems_ldta[eid].local_vids[i] ].P)
@@ -272,33 +272,6 @@ _h5t_sort_local_vids (
return H5_SUCCESS;
}
h5_err_t
_h5t_sort_global_vids (
h5_file_t * const f,
h5_id_t * const global_vids, /* IN/OUT: global vertex ids */
const h5_size_t size /* size of array */
) {
h5_id_t local_vids[H5_MAX_VERTICES_PER_ELEM];
const h5_id_t *global_vid = global_vids;
h5_id_t *local_vid = local_vids;
h5_id_t i;
for ( i = 0; i < size; i++, local_vid++, global_vid++ ) {
TRY(
*local_vid = h5t_map_global_vid2local(
f, *global_vid )
);
}
TRY( _h5t_sort_local_vids ( f, local_vids, size ) );
for ( i = 0; i < size; i++ ) {
global_vids[i] = h5t_map_local_vid2global (
f, local_vids[i] );
}
return H5_SUCCESS;
}
/*!
Binary search an element given by its local vertex ids.
@@ -348,6 +321,18 @@ h5t_get_local_eid (
return t->sorted_elems[0].items[local_eid];
}
h5_id_t
h5t_map_local_vid2global (
h5_file_t *f,
const h5_id_t local_vid
) {
struct h5t_fdata *t = f->t;
if ( local_vid < 0 || local_vid > t->num_vertices[t->num_levels-1] )
return HANDLE_H5_OUT_OF_RANGE_ERR ( f, "vertex", local_vid );
return t->vertices[local_vid].global_vid;
}
/*!
Map a global vertex id to corresponding local vertex id.
*/
@@ -364,18 +349,6 @@ h5t_map_global_vid2local (
return local_id;
}
h5_id_t
h5t_map_local_vid2global (
h5_file_t *f,
const h5_id_t local_vid
) {
struct h5t_fdata *t = f->t;
if ( local_vid < 0 || local_vid > t->num_vertices[t->num_levels-1] )
return HANDLE_H5_OUT_OF_RANGE_ERR ( f, "vertex", local_vid );
return t->vertices[local_vid].global_vid;
}
h5_err_t
h5t_map_global_vids2local (
h5_file_t *f,
@@ -384,14 +357,9 @@ h5t_map_global_vids2local (
h5_id_t * const local_vids
) {
h5_id_t i;
for ( i = 0; i < size; i++ ) {
local_vids[i] = h5t_map_global_vid2local (
f, global_vids[i] );
if ( local_vids[i] < 0 )
return _h5t_error_global_id_nexist (
f,
"vertex", global_vids[i] );
TRY ( ( local_vids[i] = h5t_map_global_vid2local (
f, global_vids[i] ) ) );
}
return H5_SUCCESS;
}
@@ -420,27 +388,6 @@ h5t_map_local_eid2global (
}
}
/*!
Get global id of elem given by global vertex id's
*/
h5_id_t
h5t_get_global_eid (
h5_file_t *f,
const h5_id_t * const global_vids /* global vertex id's */
) {
struct h5t_fdata *t = f->t;
h5_id_t local_vids[H5_MAX_VERTICES_PER_ELEM];
TRY ( h5t_map_global_vids2local (
f,
global_vids,
t->mesh_type,
local_vids ) );
h5_id_t local_eid;
TRY ( local_eid = h5t_get_local_eid ( f, local_vids ) );
return h5t_map_local_eid2global ( f, local_eid );
}
/*!
Get local element id for an element given by its global id.
@@ -564,78 +511,68 @@ _h5t_rebuild_global_2_local_map_of_elems (
return H5_SUCCESS;
}
h5_id_t *
_h5t_get_local_vids_of_edge (
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_local_vids_of_triangle (
const h5_elem_ldta_t *tet,
const h5_id_t face_id,
h5_id_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;
}
/*!
\param[in] f file handle
\param[in] local_id local ID of entity
\param[out] local_vids array of local vertex IDs of entity
/*
Get the local ID of the vertices of an elemet. Element is either a
triangle or a tetrahedron.
*/
h5_err_t
h5t_get_local_vids_of_entity (
h5t_get_local_vids_of_edge (
h5_file_t * const f,
h5_id_t local_id,
h5_id_t *local_vids
const h5_id_t id,
h5_id_t *edge
) {
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_elem_ldta_t *tet_dta = &t->elems_ldta[local_eid];
switch ( _h5t_get_entity_type ( local_id ) ) {
case H5T_ELEM_TYPE_VERTEX: {
local_vids[0] = tet_dta->local_vids[face_id];
return H5_SUCCESS;
}
case H5T_ELEM_TYPE_EDGE: {
_h5t_get_local_vids_of_edge (tet_dta, face_id, local_vids);
return H5_SUCCESS;
}
case H5T_ELEM_TYPE_TRIANGLE: {
_h5t_get_local_vids_of_triangle (tet_dta, face_id, local_vids);
return H5_SUCCESS;
}
case 0:
case H5T_ELEM_TYPE_TET: {
memcpy ( local_vids, tet_dta->local_vids, sizeof(h5_id_t)*4 );
return H5_SUCCESS;
}
default:
return h5_error_internal (
f, __FILE__, __func__, __LINE__ );
}
h5_id_t face_id = _h5t_get_face_id ( id );
h5_id_t el_id = _h5t_get_elem_id ( id );
return h5t_get_local_vids_of_edge2 ( f, face_id, el_id, edge );
}
h5_id_t
h5t_map_local_vids_to_entity_id (
h5_err_t
h5t_get_local_vids_of_edge2 (
h5_file_t * const f,
h5_id_t *local_vids,
h5_oid_t etype
const h5_id_t face,
const h5_id_t id,
h5_id_t *edge
) {
return h5_error_not_implemented ( f, __FILE__, __func__, __LINE__ );
int map[6][2] = { { 0,1 }, {1,2}, {0,2}, {0,3}, {1,3}, {2,3} };
h5_elem_ldta_t *el = &f->t->elems_ldta[id];
edge[0] = el->local_vids[map[face][0]];
edge[1] = el->local_vids[map[face][1]];
return H5_SUCCESS;
}
h5_err_t
h5t_get_local_vids_of_triangle (
h5_file_t * const f,
const h5_id_t id,
h5_id_t *vids
) {
h5_id_t face = _h5t_get_face_id ( id );
h5_id_t el_id = _h5t_get_elem_id ( id );
return h5t_get_local_vids_of_triangle2 ( f, face, el_id, vids );
}
h5_err_t
h5t_get_local_vids_of_triangle2 (
h5_file_t * const f,
const h5_id_t face,
const h5_id_t id,
h5_id_t *vids
) {
int map[4][3] = { {1,2,3}, {0,2,3}, {0,1,3}, {0,1,2} };
h5_elem_ldta_t *el = &f->t->elems_ldta[id];
vids[0] = el->local_vids[map[face][0]];
vids[1] = el->local_vids[map[face][1]];
vids[2] = el->local_vids[map[face][2]];
return H5_SUCCESS;
}
h5_err_t
h5t_get_local_vids_of_tet (
h5_file_t * const f,
const h5_id_t id,
h5_id_t *vids
) {
h5_elem_ldta_t *el = &f->t->elems_ldta[id];
memcpy ( vids, el->local_vids, 4*sizeof(*vids) );
return H5_SUCCESS;
}
+30 -17
View File
@@ -3,7 +3,7 @@
h5_id_t
h5t_map_global_vid2local (
h5_file_t *f,
h5_file_t * const f,
h5_id_t global_vid
);
@@ -57,29 +57,42 @@ h5t_get_local_eid (
h5_id_t * const local_vids
);
h5_id_t
h5t_get_global_eid (
h5_file_t *f,
const h5_id_t * const global_vids
);
h5_id_t
h5t_get_global_triangle_id (
h5_err_t
h5t_get_local_vids_of_edge (
h5_file_t * const f,
h5_id_t * const global_vids
const h5_id_t id,
h5_id_t *edge
);
h5_err_t
h5t_get_local_vids_of_entity (
h5t_get_local_vids_of_edge2 (
h5_file_t * const f,
h5_id_t local_id,
h5_id_t *local_vids
const h5_id_t face,
const h5_id_t id,
h5_id_t *vids
);
h5_id_t
h5t_map_local_vids_to_entity_id (
h5_err_t
h5t_get_local_vids_of_triangle (
h5_file_t * const f,
h5_id_t *local_vids,
h5_oid_t etype
const h5_id_t id,
h5_id_t *vids
);
h5_err_t
h5t_get_local_vids_of_triangle2 (
h5_file_t * const f,
const h5_id_t face,
const h5_id_t id,
h5_id_t *vids
);
h5_err_t
h5t_get_local_vids_of_tet (
h5_file_t * const f,
const h5_id_t id,
h5_id_t *vids
);
#endif
-21
View File
@@ -1,13 +1,6 @@
#ifndef __H5T_MAP_PRIVATE_H
#define __H5T_MAP_PRIVATE_H
h5_err_t
_h5t_sort_global_vids (
h5_file_t * const f,
h5_id_t * const global_vids,
const h5_size_t size
);
h5_err_t
_h5t_sort_local_vids (
h5_file_t * const f,
@@ -35,18 +28,4 @@ _h5t_rebuild_global_2_local_map_of_elems (
h5_file_t * const f
);
h5_id_t *
_h5t_get_local_vids_of_edge (
const h5_elem_ldta_t *tet,
const h5_id_t face_id,
h5_2id_t edge
);
h5_id_t *
_h5t_get_local_vids_of_triangle (
const h5_elem_ldta_t *tet,
const h5_id_t face_id,
h5_2id_t tri
);
#endif
+15 -2
View File
@@ -10,6 +10,18 @@
#include "h5_core/h5_core.h"
#include "h5_core/h5_core_private.h"
static struct h5t_methods tet_funcs = {
_h5t_alloc_tets,
_h5t_store_tet,
_h5t_refine_tet
};
static struct h5t_methods tri_funcs = {
_h5t_alloc_tris,
_h5t_store_tri,
_h5t_refine_tri
};
/*
create several HDF5 types
*/
@@ -431,13 +443,14 @@ h5t_open_mesh (
switch( type ) {
case H5_OID_TETRAHEDRON:
t->elem_tid = t->dtypes.h5_tet_t;
t->methods = tet_funcs;
break;
case H5_OID_TRIANGLE:
t->elem_tid = t->dtypes.h5_triangle_t;
t->methods = tri_funcs;
break;
default:
return h5_error_internal (
f, __FILE__, __func__, __LINE__ );
return h5_error_internal ( f, __FILE__, __func__, __LINE__ );
}
TRY( _h5t_open_mesh_group ( f ) );
+2 -2
View File
@@ -285,7 +285,6 @@ _build_elems_ldta (
}
el_data->level_id = level_id;
}
return H5_SUCCESS;
}
@@ -295,7 +294,7 @@ _read_elems (
) {
h5t_fdata_t *t = f->t;
TRY( _h5t_alloc_num_elems ( f, 0, t->num_elems[t->num_levels-1] ) );
TRY( (*t->methods._alloc_elems)( f, 0, t->num_elems[t->num_levels-1] ) );
TRY( _h5_read (
f,
t->mesh_gid,
@@ -306,6 +305,7 @@ _read_elems (
TRY ( _h5t_sort_elems ( f ) );
TRY ( _h5t_rebuild_global_2_local_map_of_elems ( f ) );
TRY ( _build_elems_ldta ( f ) );
TRY ( _h5t_rebuild_adj_data ( f ) );
return H5_SUCCESS;
+1 -26
View File
@@ -22,8 +22,7 @@ h5t_begin_traverse_vertices (
h5_id_t
h5t_traverse_vertices (
h5_file_t * f, /*!< file handle */
h5_id_t * const id, /*!< OUT: global vertex id */
h5_file_t * const f, /*!< file handle */
h5_float64_t P[3] /*!< OUT: coordinates */
) {
h5t_fdata_t *t = f->t;
@@ -34,7 +33,6 @@ h5t_traverse_vertices (
return H5_NOK;
}
h5_vertex_t *vertex = &t->vertices[++iter->cur_vid];
*id = vertex->global_vid;
memcpy ( P, &vertex->P, sizeof ( vertex->P ) );
return iter->cur_vid;
@@ -229,20 +227,15 @@ h5t_begin_traverse_elems (
/*!
\param[in] f file handle
\param[out] global_eid Global element id
\param[out] local_parent_id Local parent id
\param[out] vids Local vertex id
*/
h5_id_t
h5t_traverse_elems (
h5_file_t * const f,
h5_id_t * const global_eid,
h5_id_t * const local_parent_id,
h5_id_t *local_vids
) {
h5t_fdata_t *t = f->t;
h5t_elem_iterator_t *iter = &t->iters.elem;
h5_elem_t *elem;
h5_elem_ldta_t *elem_data;
h5_id_t local_child_eid;
h5_id_t refined_on_level = -1;
@@ -265,24 +258,6 @@ h5t_traverse_elems (
}
while ( refined_on_level <= t->cur_level );
switch ( t->mesh_type ) {
case H5_OID_TETRAHEDRON:
elem = (h5_elem_t*)&t->elems.tets[iter->cur_eid];
break;
case H5_OID_TRIANGLE:
elem = (h5_elem_t*)&t->elems.tris[iter->cur_eid];
break;
default:
return h5_error_internal (
f, __FILE__, __func__, __LINE__ );
}
if ( iter->cur_eid >= t->num_elems[t->cur_level] ) {
return h5_error_internal (
f, __FILE__, __func__, __LINE__ );
}
*global_eid = elem->global_eid;
*local_parent_id = elem_data->local_parent_eid;
memcpy (
local_vids,
elem_data->local_vids,
+12 -65
View File
@@ -1,72 +1,19 @@
#ifndef __H5T_RETRIEVE_H
#define __H5T_RETRIEVE_H
h5_err_t
h5t_begin_traverse_vertices (
h5_file_t * f
);
h5_err_t h5t_begin_traverse_vertices ( h5_file_t * const f );
h5_id_t h5t_traverse_vertices ( h5_file_t * const f, h5_float64_t P[3] );
h5_err_t h5t_end_traverse_vertices ( h5_file_t * f );
h5_id_t
h5t_traverse_vertices (
h5_file_t * f,
h5_id_t * const id,
h5_float64_t P[3]
);
h5_err_t
h5t_end_traverse_vertices (
h5_file_t * f
);
h5_err_t
h5t_begin_traverse_edges (
h5_file_t * const f
);
h5_id_t
h5t_traverse_edges (
h5_file_t * const f,
h5_id_t *local_vids
);
h5_err_t
h5t_end_traverse_edges (
h5_file_t * f
);
h5_err_t
h5t_begin_traverse_triangles (
h5_file_t * const f
);
h5_id_t
h5t_traverse_triangles (
h5_file_t * const f,
h5_id_t *local_vids
);
h5_err_t
h5t_end_traverse_triangles (
h5_file_t * f
);
h5_err_t
h5t_begin_traverse_elems (
h5_file_t * f
);
h5_id_t
h5t_traverse_elems (
h5_file_t * f,
h5_id_t * const id,
h5_id_t * const parent_id,
h5_id_t * vids
);
h5_err_t
h5t_end_traverse_elems (
h5_file_t * const f
);
h5_err_t h5t_begin_traverse_edges ( h5_file_t * const f );
h5_id_t h5t_traverse_edges ( h5_file_t * const f, h5_id_t * const vids );
h5_err_t h5t_end_traverse_edges ( h5_file_t * f );
h5_err_t h5t_begin_traverse_triangles ( h5_file_t * const f );
h5_id_t h5t_traverse_triangles ( h5_file_t * const f, h5_id_t * const vids );
h5_err_t h5t_end_traverse_triangles ( h5_file_t * const f );
h5_err_t h5t_begin_traverse_elems ( h5_file_t * const f );
h5_id_t h5t_traverse_elems ( h5_file_t * const f, h5_id_t * const vids );
h5_err_t h5t_end_traverse_elems ( h5_file_t * const f );
#endif
+271 -149
View File
@@ -126,7 +126,8 @@ h5t_add_level (
TRY ( t->num_elems = _h5_alloc ( f, t->num_elems, num_bytes ) );
t->num_elems[t->cur_level] = -1;
TRY ( t->num_elems_on_level = _h5_alloc ( f, t->num_elems_on_level, num_bytes ) );
TRY ( t->num_elems_on_level = _h5_alloc (
f, t->num_elems_on_level, num_bytes ) );
t->num_elems_on_level[t->cur_level] = -1;
t->new_level = t->cur_level;
@@ -201,9 +202,8 @@ h5t_store_vertex (
t->level_changed = 1;
h5_id_t local_id = ++t->last_stored_vid;
h5_vertex_t *vertex = &t->vertices[local_id];
vertex->global_vid = global_vid; /* global id from mesher,replaced later!*/
vertex->global_vid = global_vid; /* ID from mesher, replaced later!*/
memcpy ( &vertex->P, P, sizeof ( vertex->P ) );
return local_id;
}
@@ -218,86 +218,146 @@ h5t_end_store_vertices (
TRY ( _h5t_assign_global_vertex_ids ( f ) );
TRY ( _h5t_sort_vertices ( f ) );
TRY ( _h5t_rebuild_global_2_local_map_of_vertices ( f ) );
return H5_SUCCESS;
}
h5_err_t
_h5t_alloc_num_elems (
_h5t_alloc_tris (
h5_file_t * const f,
const size_t cur_num_elems,
const size_t new_num_elems
const size_t cur,
const size_t new
) {
h5t_fdata_t *t = f->t;
size_t sizeof_elem = _h5t_sizeof_elem[t->mesh_type];
const size_t nvertices = 3;
/* alloc mem for elements */
TRY ( t->elems.data = _h5_alloc (
TRY ( t->elems.tris = _h5_alloc (
f,
t->elems.data,
new_num_elems * sizeof_elem ) );
t->elems.tris,
new * sizeof(t->elems.tris[0]) ) );
memset (
(void*)t->elems.data + cur_num_elems*sizeof_elem,
t->elems.tris + cur,
-1,
(new_num_elems-cur_num_elems)*sizeof_elem );
(new-cur) * sizeof(t->elems.tris[0]) );
/* 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] ) ) );
new * sizeof (t->elems_ldta[0]) ) );
memset (
t->elems_ldta+cur_num_elems,
t->elems_ldta + cur,
-1,
(new_num_elems-cur_num_elems)*sizeof ( t->elems_ldta[0] ) );
(new-cur) * 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 ) );
new * sizeof(t->elems_lvids[0]) * nvertices ) );
memset (
t->elems_lvids + cur_num_elems*sizeof(t->elems_lvids[0])*t->mesh_type,
t->elems_lvids + cur * sizeof(t->elems_lvids[0]) * nvertices,
-1,
(new_num_elems-cur_num_elems)*sizeof(t->elems_lvids[0])*t->mesh_type );
(new-cur) * sizeof(t->elems_lvids[0]) * nvertices );
/* 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 ) {
for ( id = 0; id < new; id++, p+=nvertices ) {
t->elems_ldta[id].local_vids = p;
}
/* alloc mem for global to local ID mapping */
TRY ( _h5_alloc_idmap ( f, &t->map_elem_g2l, new_num_elems ) );
TRY ( _h5_alloc_idmap ( f, &t->map_elem_g2l, new ) );
return H5_SUCCESS;
}
h5_err_t
_h5t_alloc_tets (
h5_file_t * const f,
const size_t cur,
const size_t new
) {
h5t_fdata_t *t = f->t;
const size_t nvertices = 4;
/* alloc mem for elements */
TRY ( t->elems.tets = _h5_alloc (
f,
t->elems.tets,
new * sizeof(t->elems.tets[0]) ) );
memset (
t->elems.tets + cur,
-1,
(new-cur) * sizeof(t->elems.tets[0]) );
/* alloc mem for local data of elements */
TRY ( t->elems_ldta = _h5_alloc (
f,
t->elems_ldta,
new * sizeof (t->elems_ldta[0]) ) );
memset (
t->elems_ldta + cur,
-1,
(new-cur) * sizeof (t->elems_ldta[0]) );
/* alloc mem for local vertex IDs of elements */
TRY ( t->elems_lvids = _h5_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_vids = p;
}
/* alloc mem for global to local ID mapping */
TRY ( _h5_alloc_idmap ( f, &t->map_elem_g2l, new ) );
return H5_SUCCESS;
}
/*!
Initialize everything so that we can begin to store elements.
\param[in] f file handle
\param[in] num number of elements to add
*/
h5_err_t
h5t_begin_store_elems (
h5_file_t * const f,
const h5_size_t num
) {
struct h5t_fdata *t = f->t;
h5t_fdata_t *t = f->t;
t->storing_data = 1;
size_t cur_num_elems = t->cur_level > 0 ?
t->num_elems[t->cur_level-1] : 0;
size_t new_num_elems = t->cur_level > 0 ?
num + t->num_elems[t->cur_level-1] : num;
t->num_elems[t->cur_level] = new_num_elems;
t->dsinfo_elems.dims[0] = new_num_elems;
size_t cur = t->cur_level > 0 ? t->num_elems[t->cur_level-1] : 0;
size_t new = num + cur;
t->num_elems[t->cur_level] = new;
t->dsinfo_elems.dims[0] = new;
t->num_elems_on_level[t->cur_level] = t->cur_level > 0 ?
num + t->num_elems_on_level[t->cur_level-1] : num;
return _h5t_alloc_num_elems ( f, cur_num_elems, new_num_elems );
/*
We allocate a hash table for a minimum of 2^21 edges to
prevent resizing.
*/
size_t nel = 2097152 > 5*new ? 2097152 : 5*new;
TRY ( _h5t_resize_te_htab ( f, nel ) );
return (*t->methods._alloc_elems) ( f, cur, new );
}
/*!
\param[in] local_parent_eid local parent id of element if level \c >0 else \c -1
\param[in] local_parent_eid local parent id of element
if level \c >0 else \c -1
\param[in] local_vids local vertex id's defining the element
*/
h5_id_t
@@ -331,7 +391,7 @@ h5t_store_elem (
local_parent_eid );
}
return _h5t_store_elem ( f, local_parent_eid, local_vids );
return (*t->methods._store_elem)( f, local_parent_eid, local_vids );
}
/*!
@@ -342,7 +402,7 @@ h5t_store_elem (
\param[in] local_vids Local vertex id's defining the tetrahedron.
*/
h5_id_t
_h5t_store_elem (
_h5t_store_tet (
h5_file_t * const f,
const h5_id_t local_parent_eid,
const h5_id_t *local_vids
@@ -359,6 +419,45 @@ _h5t_store_elem (
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 );
h5_id_t face_id;
h5_te_entry_t *retval;
for ( face_id = 0; face_id < 6; face_id++ ) {
TRY ( _h5t_search_te2 (
f,
face_id,
local_eid,
&retval ) );
}
return local_eid;
}
h5_id_t
_h5t_store_tri (
h5_file_t * const f,
const h5_id_t local_parent_eid,
const h5_id_t *local_vids
) {
h5t_fdata_t *t = f->t;
t->level_changed = 1;
h5_id_t local_eid = ++t->last_stored_eid;
h5_elem_ldta_t *elem_ldta = &t->elems_ldta[local_eid];
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 );
h5_id_t face_id;
h5_te_entry_t *retval;
for ( face_id = 0; face_id < 3; face_id++ ) {
TRY ( _h5t_search_te2 (
f,
face_id,
local_eid,
&retval ) );
}
return local_eid;
}
@@ -371,8 +470,10 @@ h5t_end_store_elems (
t->num_elems[t->cur_level] = t->last_stored_eid+1;
TRY ( _assign_global_elem_ids ( f ) );
TRY ( _h5t_sort_elems ( f ) );
TRY ( _h5t_rebuild_global_2_local_map_of_elems ( f ) );
return H5_SUCCESS;
}
@@ -383,21 +484,28 @@ h5t_begin_refine_elems (
const h5_size_t num_elems_to_refine
) {
h5_size_t num_elems_to_add = 0;
h5t_fdata_t *t = f->t;
h5_size_t num_vertices_to_add = 0;
t->storing_data = 1;
switch ( t->mesh_type ) {
f->t->storing_data = 1;
/*
Now we have to guess the number of vertices ...
If we are going to refine one tetrahedron, we have 8 new tetrahedra
and 6 new vertices. Thus the numbers below are definitely upper
limits!
*/
switch ( f->t->mesh_type ) {
case H5_OID_TETRAHEDRON:
num_vertices_to_add = num_elems_to_refine*6;
num_elems_to_add = num_elems_to_refine*8;
break;
case H5_OID_TRIANGLE:
num_vertices_to_add = num_elems_to_refine*3;
num_elems_to_add = num_elems_to_refine*4;
break;
default:
return h5_error_internal ( f, __FILE__, __func__, __LINE__ );
}
h5_size_t num_vertices = (num_elems_to_add>>2)*3; /* this is an upper limit */
TRY ( h5t_begin_store_vertices ( f, num_vertices ) );
TRY ( h5t_begin_store_vertices ( f, num_vertices_to_add ) );
TRY ( h5t_begin_store_elems ( f, num_elems_to_add ) );
return H5_SUCCESS;
@@ -424,24 +532,57 @@ h5t_end_refine_elems (
h5_id_t
_h5t_bisect_edge (
h5_file_t * const f,
h5_id_t local_vid0,
h5_id_t local_vid1
h5_id_t face_id,
h5_id_t el_id
) {
struct h5t_fdata *t = f->t;
h5_id_t local_vid = -1;
h5_float64_t *P0 = t->vertices[local_vid0].P;
h5_float64_t *P1 = t->vertices[local_vid1].P;
h5t_fdata_t *t = f->t;
h5_te_entry_t item;
h5_id_t *vids = item.key.vids;
h5_te_entry_t *retval;
/*
get all elements sharing the given edge
*/
TRY ( h5t_get_local_vids_of_edge2 ( f, face_id, el_id, vids ) );
TRY ( _h5t_find_te ( f, &item, &retval ) );
/*
check wether one of these elements has been refined
*/
size_t i;
for ( i = 0; i < retval->value.num_items; i++ ) {
h5_id_t local_id = _h5t_get_elem_id ( retval->value.items[i] );
h5_elem_ldta_t *tet = &t->elems_ldta[local_id];
if ( tet->local_child_eid >= 0 ) {
/*
this element has been refined!
return bisecting point
*/
h5_id_t face_id = _h5t_get_face_id ( retval->value.items[i] );
h5_id_t kids[2], edge0[2], edge1[2];
TRY ( _h5t_compute_direct_children_of_edge (
f,
face_id,
tet->local_child_eid,
kids ) );
TRY ( h5t_get_local_vids_of_edge ( f, kids[0], edge0 ) );
TRY ( h5t_get_local_vids_of_edge ( f, kids[1], edge1 ) );
if ( (edge0[0] == edge1[0]) || (edge0[0] == edge1[1]) )
return edge0[0];
else
return edge0[1];
}
}
/*
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_float64_t P[3];
P[0] = ( P0[0] + P1[0] ) / 2.0;
P[1] = ( P0[1] + P1[1] ) / 2.0;
P[2] = ( P0[2] + P1[2] ) / 2.0;
/* add vertex if not already exist */
if ( (local_vid = _h5t_get_local_vid( f, P )) < 0 ) {
TRY ( local_vid = h5t_store_vertex ( f, -1, P ) );
}
return local_vid;
return h5t_store_vertex ( f, -1, P );
}
/*!
@@ -454,16 +595,8 @@ h5t_refine_elem (
h5_file_t * const f,
const h5_id_t local_eid
) {
struct h5t_fdata *t = f->t;
switch ( t->mesh_type ) {
case H5_OID_TETRAHEDRON:
return _h5t_refine_tet ( f, local_eid );
case H5_OID_TRIANGLE:
return _h5t_refine_triangle ( f, local_eid );
default:
return h5_error_internal (
f, __FILE__, __func__, __LINE__ );
}
return (*f->t->methods._refine_elem)( f, local_eid );
}
/*!
@@ -472,70 +605,84 @@ h5t_refine_elem (
\return Local id of first new triangle or \c -1
*/
h5_id_t
_h5t_refine_triangle (
_h5t_refine_tri (
h5_file_t * const f,
const h5_id_t local_eid
) {
h5t_fdata_t *t = f->t;
h5_id_t local_vids[3];
h5_id_t local_vids[6];
h5_id_t local_child_eid;
h5_elem_ldta_t *el = &t->elems_ldta[local_eid];
local_vids[0] = _h5t_bisect_edge(
f,
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_ldta[local_eid].local_vids[0],
t->elems_ldta[local_eid].local_vids[2] );
local_vids[2] = _h5t_bisect_edge(
f,
t->elems_ldta[local_eid].local_vids[1],
t->elems_ldta[local_eid].local_vids[2] );
if ( el->local_child_eid >= 0 )
return h5_error (
f,
H5_ERR_INVAL,
"Tetrahedron %lld already refined.",
local_eid );
local_vids[0] = el->local_vids[0];
local_vids[1] = el->local_vids[1];
local_vids[2] = el->local_vids[2];
h5_id_t elem_local_vids[4];
local_vids[3] = _h5t_bisect_edge( f, 0, local_eid ); /* 1,2 */
local_vids[4] = _h5t_bisect_edge( f, 1, local_eid ); /* 0,2 */
local_vids[5] = _h5t_bisect_edge( f, 2, local_eid ); /* 0,1 */
h5_id_t new_el[3];
/* 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_elem (
f,
local_eid, elem_local_vids ) );
if ( local_eid >= 0 ) {
t->elems.tris[local_eid].global_child_eid = local_child_eid;
t->elems_ldta[local_eid].local_child_eid = local_child_eid;
t->num_elems_on_level[t->cur_level]--;
}
new_el[0] = local_vids[0];
new_el[1] = local_vids[4];
new_el[2] = local_vids[5];
TRY ( local_child_eid = _h5t_store_tri ( f, local_eid, new_el ) );
/* 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_elem (
f,
local_eid, elem_local_vids ) );
new_el[0] = local_vids[1];
new_el[1] = local_vids[3];
new_el[2] = local_vids[5];
TRY ( _h5t_store_tri ( f, local_eid, new_el ) );
/* 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_elem (
f,
local_eid, elem_local_vids ) );
new_el[0] = local_vids[2];
new_el[1] = local_vids[3];
new_el[2] = local_vids[4];
TRY ( _h5t_store_tri ( f, local_eid, new_el ) );
/* 3 */
elem_local_vids[0] = local_vids[0];
elem_local_vids[1] = local_vids[1];
elem_local_vids[2] = local_vids[2];
TRY ( _h5t_store_elem (
f,
local_eid, elem_local_vids ) );
new_el[0] = local_vids[3];
new_el[1] = local_vids[4];
new_el[2] = local_vids[5];
TRY ( _h5t_store_tri ( f, local_eid, new_el ) );
return local_child_eid;
}
/*!
\param[in] f file handle
\param[in] local_kid local edge ID we search children of
\param[in] local_eid local element ID of first children
\param[out] kids direct children
*/
h5_err_t
_h5t_compute_direct_children_of_edge (
h5_file_t * const f,
h5_id_t face_id,
h5_id_t local_eid,
h5_id_t kids[2]
) {
int off[6][2] = { {0,1}, {1,2}, {0,2}, {0,3}, {1,3}, {2,3} };
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;
}
/*!
Refine tetrahedron \c local_eid
@@ -549,50 +696,25 @@ _h5t_refine_tet (
h5t_fdata_t *t = f->t;
h5_id_t local_vids[10];
h5_id_t local_child_eid;
h5_elem_ldta_t *tet = &t->elems_ldta[local_eid];
if ( t->elems.tets[local_eid].global_child_eid >= 0 )
if ( tet->local_child_eid >= 0 )
return h5_error (
f,
H5_ERR_INVAL,
"Tetrahedron %lld already refined.",
local_eid );
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[0] = tet->local_vids[0];
local_vids[1] = tet->local_vids[1];
local_vids[2] = tet->local_vids[2];
local_vids[3] = tet->local_vids[3];
/*
get adjacent tets to the edges we have to refine
if one of the tets have been refined
get vertex id
else
add new vertex
*/
local_vids[4] = _h5t_bisect_edge(
f,
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_ldta[local_eid].local_vids[0],
t->elems_ldta[local_eid].local_vids[2] );
local_vids[6] = _h5t_bisect_edge(
f,
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_ldta[local_eid].local_vids[1],
t->elems_ldta[local_eid].local_vids[2] );
local_vids[8] = _h5t_bisect_edge(
f,
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_ldta[local_eid].local_vids[2],
t->elems_ldta[local_eid].local_vids[3] );
local_vids[4] = _h5t_bisect_edge( f, 0, local_eid );
local_vids[5] = _h5t_bisect_edge( f, 2, local_eid );
local_vids[6] = _h5t_bisect_edge( f, 3, local_eid );
local_vids[7] = _h5t_bisect_edge( f, 1, local_eid );
local_vids[8] = _h5t_bisect_edge( f, 4, local_eid );
local_vids[9] = _h5t_bisect_edge( f, 5, local_eid );
/*
add new tets
@@ -604,7 +726,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_elem (
TRY ( local_child_eid = _h5t_store_tet (
f, local_eid, new_tet_local_vids ) );
/* 1 */
@@ -612,49 +734,49 @@ _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_elem ( f, local_eid, new_tet_local_vids ) );
TRY ( _h5t_store_tet ( 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_elem ( f, local_eid, new_tet_local_vids ) );
TRY ( _h5t_store_tet ( 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_elem ( f, local_eid, new_tet_local_vids ) );
TRY ( _h5t_store_tet ( 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_elem ( f, local_eid, new_tet_local_vids ) );
TRY ( _h5t_store_tet ( 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_elem ( f, local_eid, new_tet_local_vids ) );
TRY ( _h5t_store_tet ( 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_elem ( f, local_eid, new_tet_local_vids ) );
TRY ( _h5t_store_tet ( 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_elem ( f, local_eid, new_tet_local_vids ) );
TRY ( _h5t_store_tet ( f, local_eid, new_tet_local_vids ) );
t->elems.tets[local_eid].global_child_eid = local_child_eid;
t->elems_ldta[local_eid].local_child_eid = local_child_eid;
+27 -5
View File
@@ -8,26 +8,48 @@ _h5t_alloc_num_vertices (
);
h5_err_t
_h5t_alloc_num_elems (
_h5t_alloc_tris (
h5_file_t * const f,
const size_t cur_num_elems,
const size_t new_num_elems
const size_t cur,
const size_t new
);
h5_err_t
_h5t_alloc_tets (
h5_file_t * const f,
const size_t cur,
const size_t new
);
h5_id_t
_h5t_store_elem (
_h5t_store_tri (
h5_file_t * const f,
const h5_id_t local_parent_eid,
const h5_id_t vids[]
);
h5_id_t
_h5t_store_tet (
h5_file_t * const f,
const h5_id_t local_parent_eid,
const h5_id_t vids[]
);
h5_err_t
_h5t_close_level (
h5_file_t * const f
);
h5_err_t
_h5t_compute_direct_children_of_edge (
h5_file_t * const f,
h5_id_t face_id,
h5_id_t local_eid,
h5_id_t kids[2]
);
h5_id_t
_h5t_refine_triangle (
_h5t_refine_tri (
h5_file_t * const f,
const h5_id_t local_eid
);
+37 -45
View File
@@ -1,69 +1,63 @@
#ifndef __H5T_TYPES_PRIVATE_H
#define __H5T_TYPES_PRIVATE_H
typedef h5_id_t h5_2id_t[2];
typedef h5_id_t h5_3id_t[3];
typedef h5_id_t h5_4id_t[4];
typedef h5_float64_t h5_coord3d_t[3];
struct h5_vertex {
struct h5t_methods {
h5_err_t (*_alloc_elems)(h5_file_t * const, const size_t, const size_t);
h5_id_t (*_store_elem)(h5_file_t * const, const h5_id_t, const h5_id_t*);
h5_id_t (*_refine_elem)(h5_file_t * const, const h5_id_t);
};
typedef struct h5_vertex {
h5_id_t global_vid;
h5_coord3d_t P;
};
typedef struct h5_vertex h5_vertex_t;
} h5_vertex_t;
struct h5_vertex_data {
typedef struct h5_vertex_data {
h5_idlist_t tv;
};
typedef struct h5_vertex_data h5_vertex_data_t;
} h5_vertex_data_t;
struct h5_triangle {
typedef struct h5_triangle {
h5_id_t global_eid;
h5_id_t global_parent_eid;
h5_id_t global_child_eid;
h5_3id_t global_vids;
};
typedef struct h5_triangle h5_triangle_t;
} h5_triangle_t;
struct h5_tetrahedron {
typedef struct h5_tetrahedron {
h5_id_t global_eid;
h5_id_t global_parent_eid;
h5_id_t global_child_eid;
h5_4id_t global_vids;
};
} h5_tetrahedron_t;
typedef h5_tetrahedron_t h5_tet_t;
struct h5_elem {
typedef struct h5_elem {
h5_id_t global_eid;
h5_id_t global_parent_eid;
h5_id_t global_child_eid;
h5_id_t global_vids[1];
};
} h5_elem_t;
typedef struct h5_tetrahedron h5_tetrahedron_t;
typedef struct h5_tetrahedron h5_tet_t;
typedef struct h5_elem h5_elem_t;
struct h5_elem_ldta {
typedef struct h5_elem_ldta {
h5_id_t local_parent_eid;
h5_id_t local_child_eid;
h5_id_t level_id;
h5_id_t *local_vids;
};
typedef struct h5_elem_ldta h5_elem_ldta_t;
} h5_elem_ldta_t;
union h5_elems {
typedef union h5_elems {
h5_tet_t *tets;
h5_triangle_t *tris;
void *data;
};
typedef union h5_elems h5_elems_t;
} h5_elems_t;
/*
information about HDF5 dataset
*/
struct h5_dataset_info {
typedef struct h5_dataset_info {
char name[256];
int rank;
hsize_t dims[4];
@@ -72,11 +66,10 @@ struct h5_dataset_info {
hid_t *type_id;
hid_t create_prop;
hid_t access_prop;
};
typedef struct h5_dataset_info h5_dataset_info_t;
} h5_dataset_info_t;
struct boundary {
typedef struct boundary {
char name[16];
char label[256];
h5_id_t id; /* name of boundary as integer */
@@ -90,8 +83,7 @@ struct boundary {
h5_id_t last_accessed_face;
h5_dataset_info_t dsinfo;
};
typedef struct boundary boundary_t;
} boundary_t;
/*** type ids' for compound types ***/
typedef struct h5_dtypes {
@@ -107,7 +99,7 @@ typedef struct h5_dtypes {
} h5_dtypes_t;
typedef struct h5_te_entry_key {
h5_2id_t vids;
h5_id_t vids[2];
} h5_te_entry_key_t;
typedef struct h5_te_entry {
@@ -124,24 +116,22 @@ typedef struct h5_td_entry {
h5_idlist_t value;
} h5_td_entry_t;
struct hsearch_data {
typedef struct hsearch_data {
struct _ENTRY *table;
unsigned int size;
unsigned int filled;
int (*compare)(const void*, const void*);
unsigned int (*compute_hash)(const void*);
};
typedef struct hsearch_data h5_hashtable_t;
int (*compare)(void*, void*);
unsigned int (*compute_hash)(void*);
} h5_hashtable_t;
typedef struct h5t_adjacencies {
struct hsearch_data te_hash;
struct hsearch_data td_hash;
} h5t_adjacencies_t;
struct h5t_elem_iterator {
typedef struct h5t_elem_iterator {
h5_id_t cur_eid;
};
typedef struct h5t_elem_iterator h5t_elem_iterator_t;
} h5t_elem_iterator_t;
typedef struct h5t_vertex_iterator {
h5_id_t cur_vid;
@@ -159,7 +149,7 @@ typedef struct h5t_iterators {
h5t_elem_iterator_t elem;
} h5t_iterators_t;
struct h5t_fdata {
typedef struct h5t_fdata {
/*** book-keeping ***/
char mesh_name[16];
char mesh_label[256];
@@ -184,6 +174,9 @@ struct h5t_fdata {
h5t_iterators_t iters; /* "build-in" iterators */
/*** functions to handle differnt mesh types ***/
struct h5t_methods methods;
/*** vertices ***/
h5_vertex_t *vertices;
h5_vertex_data_t *vertices_data;
@@ -224,7 +217,6 @@ struct h5t_fdata {
h5t_adjacencies_t adjacencies;
};
typedef struct h5t_fdata h5t_fdata_t;
} h5t_fdata_t;
#endif