ID-list structure changed
This commit is contained in:
@@ -50,7 +50,7 @@ H5FedGetNumLevels (
|
||||
h5_file_t* const f
|
||||
) {
|
||||
H5_API_ENTER;
|
||||
h5_ssize_t num = h5t_get_num_levels (f);
|
||||
h5_ssize_t num = h5t_get_num_leaf_levels (f);
|
||||
H5_API_RETURN (num);
|
||||
}
|
||||
|
||||
|
||||
+47
-109
@@ -4,33 +4,12 @@
|
||||
#include "h5core/h5_core.h"
|
||||
#include "h5_core_private.h"
|
||||
|
||||
static inline h5_err_t
|
||||
alloc_idlist_items (
|
||||
h5_file_t* const f,
|
||||
h5_idlist_t* list,
|
||||
const h5_size_t size // new size of list
|
||||
) {
|
||||
int new = (list->items == NULL);
|
||||
size_t size_in_bytes = size * sizeof (list->items[0]);
|
||||
TRY( list->items = h5_alloc (f, list->items, size_in_bytes) );
|
||||
list->size = size;
|
||||
if (new) list->num_items = 0;
|
||||
return H5_SUCCESS;
|
||||
}
|
||||
|
||||
h5_err_t
|
||||
h5priv_free_idlist_items (
|
||||
h5_file_t* const f,
|
||||
h5_idlist_t* list
|
||||
) {
|
||||
UNUSED_ARGUMENT (f);
|
||||
if (list->items != NULL) free (list->items);
|
||||
list->items = NULL;
|
||||
list->size = 0;
|
||||
list->num_items = 0;
|
||||
return H5_SUCCESS;
|
||||
}
|
||||
/*
|
||||
Functions for ID-list handling.
|
||||
|
||||
ID-lists are data blobs to store ID or indices.
|
||||
*/
|
||||
/*
|
||||
Allocate new/empty id-list
|
||||
*/
|
||||
@@ -40,9 +19,7 @@ h5priv_alloc_idlist (
|
||||
h5_idlist_t** list,
|
||||
const h5_size_t size
|
||||
) {
|
||||
TRY( (*list = h5_calloc (f, 1, sizeof (**list))) );
|
||||
size_t size_in_bytes = size * sizeof ((*list)->items[0]);
|
||||
TRY( (*list)->items = h5_alloc (f, (*list)->items, size_in_bytes) );
|
||||
TRY( *list = h5_calloc (f, 1, sizeof (**list)+size*sizeof ((*list)->items[0])) );
|
||||
(*list)->size = size;
|
||||
return H5_SUCCESS;
|
||||
}
|
||||
@@ -53,70 +30,55 @@ h5priv_free_idlist (
|
||||
h5_idlist_t** list
|
||||
) {
|
||||
if (*list == NULL) return H5_SUCCESS;
|
||||
TRY( h5priv_free_idlist_items (f, *list) );
|
||||
TRY( h5_free( f, *list) );
|
||||
*list = NULL;
|
||||
return H5_SUCCESS;
|
||||
}
|
||||
|
||||
h5_err_t
|
||||
h5priv_append_to_idlist (
|
||||
static inline h5_err_t
|
||||
grow_idlist (
|
||||
h5_file_t* const f,
|
||||
h5_idlist_t* list,
|
||||
h5_loc_id_t id
|
||||
h5_idlist_t** list,
|
||||
size_t num_items
|
||||
) {
|
||||
if (list->num_items == list->size) {
|
||||
h5_size_t size = list->size;
|
||||
size_t size = sizeof (**list) + (num_items-1)*sizeof((*list)->items[0]);
|
||||
TRY( *list = h5_alloc (f, *list, size) );
|
||||
return H5_SUCCESS;
|
||||
}
|
||||
|
||||
/*
|
||||
Add item to list at position given by \c idx.
|
||||
*/
|
||||
h5_loc_idx_t
|
||||
h5priv_insert_idlist (
|
||||
h5_file_t* const f,
|
||||
h5_idlist_t** list,
|
||||
h5_loc_id_t id,
|
||||
h5_loc_idx_t idx
|
||||
) {
|
||||
if (*list == NULL) {
|
||||
TRY( h5priv_alloc_idlist (f, list, 2) );
|
||||
} else if ((*list)->num_items == (*list)->size) {
|
||||
h5_size_t size = (*list)->size;
|
||||
if (size == 0) {
|
||||
size = 2;
|
||||
size = 16;
|
||||
} else {
|
||||
size *= 2;
|
||||
}
|
||||
TRY( alloc_idlist_items (f, list, size) );
|
||||
TRY( grow_idlist (f, list, size) );
|
||||
}
|
||||
list->items[list->num_items++] = id;
|
||||
return H5_SUCCESS;
|
||||
}
|
||||
|
||||
int
|
||||
h5priv_cmp_ids_by_eid (
|
||||
const void* _id1,
|
||||
const void* _id2
|
||||
) {
|
||||
h5_loc_id_t id1 = h5tpriv_get_elem_idx (*(h5_loc_id_t*)_id1);
|
||||
h5_loc_id_t id2 = h5tpriv_get_elem_idx (*(h5_loc_id_t*)_id2);
|
||||
|
||||
if (id1 < id2) return -1;
|
||||
if (id1 > id2) return 1;
|
||||
return 0;
|
||||
}
|
||||
|
||||
int
|
||||
h5priv_cmp_ids (
|
||||
const void* _id1,
|
||||
const void* _id2
|
||||
) {
|
||||
h5_loc_id_t *id1 = (h5_loc_id_t*)_id1;
|
||||
h5_loc_id_t *id2 = (h5_loc_id_t*)_id2;
|
||||
|
||||
if (*id1 < *id2) return -1;
|
||||
if (*id1 > *id2) return 1;
|
||||
return 0;
|
||||
}
|
||||
|
||||
h5_err_t
|
||||
h5priv_sort_idlist_by_eid (
|
||||
h5_file_t* const f,
|
||||
h5_idlist_t* list
|
||||
) {
|
||||
UNUSED_ARGUMENT (f);
|
||||
qsort (
|
||||
list->items,
|
||||
list->num_items,
|
||||
sizeof (list->items[0]),
|
||||
h5priv_cmp_ids_by_eid);
|
||||
|
||||
return H5_SUCCESS;
|
||||
h5_idlist_t* l = *list;
|
||||
if (idx == -1) {
|
||||
idx = l->num_items;
|
||||
} else {
|
||||
memmove (
|
||||
&l->items[idx+1],
|
||||
&l->items[idx],
|
||||
(l->num_items - idx) * sizeof (l->items[0]));
|
||||
}
|
||||
l->items[idx] = id;
|
||||
l->num_items++;
|
||||
return idx;
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -129,6 +91,9 @@ h5priv_find_idlist (
|
||||
h5_loc_id_t item
|
||||
) {
|
||||
UNUSED_ARGUMENT (f);
|
||||
if (!list) {
|
||||
return -1;
|
||||
}
|
||||
register h5_loc_idx_t low = 0;
|
||||
register h5_loc_idx_t high = list->num_items - 1;
|
||||
while (low <= high) {
|
||||
@@ -144,33 +109,6 @@ h5priv_find_idlist (
|
||||
return -(low+1); // not found
|
||||
}
|
||||
|
||||
/*
|
||||
Add item to list at position given by \c idx.
|
||||
*/
|
||||
h5_loc_idx_t
|
||||
h5priv_insert_idlist (
|
||||
h5_file_t* const f,
|
||||
h5_idlist_t* list,
|
||||
h5_loc_id_t item,
|
||||
h5_loc_idx_t idx
|
||||
) {
|
||||
if (list->num_items == list->size) {
|
||||
h5_size_t size = list->size;
|
||||
if (size == 0) {
|
||||
size = 16;
|
||||
} else {
|
||||
size *= 2;
|
||||
}
|
||||
TRY( alloc_idlist_items (f, list, size) );
|
||||
}
|
||||
memmove (
|
||||
&list->items[idx+1],
|
||||
&list->items[idx],
|
||||
(list->num_items - idx) * sizeof (list->items[0]));
|
||||
list->items[idx] = item;
|
||||
list->num_items++;
|
||||
return idx;
|
||||
}
|
||||
|
||||
/*
|
||||
Search in sorted list. If item is not in list, add it.
|
||||
@@ -178,10 +116,10 @@ h5priv_insert_idlist (
|
||||
h5_loc_idx_t
|
||||
h5priv_search_idlist (
|
||||
h5_file_t* const f,
|
||||
h5_idlist_t* list,
|
||||
h5_idlist_t** list,
|
||||
h5_loc_id_t item
|
||||
) {
|
||||
h5_loc_idx_t idx = h5priv_find_idlist (f, list, item);
|
||||
h5_loc_idx_t idx = h5priv_find_idlist (f, *list, item);
|
||||
if (idx < 0) {
|
||||
idx = -(idx+1);
|
||||
idx = h5priv_insert_idlist (f, list, item, idx);
|
||||
|
||||
@@ -14,48 +14,17 @@ h5priv_free_idlist (
|
||||
h5_idlist_t **list
|
||||
);
|
||||
|
||||
h5_err_t
|
||||
h5priv_free_idlist_items (
|
||||
h5_file_t * const f,
|
||||
h5_idlist_t *list
|
||||
);
|
||||
|
||||
h5_err_t
|
||||
h5priv_append_to_idlist (
|
||||
h5_file_t * const f,
|
||||
h5_idlist_t *list,
|
||||
h5_loc_id_t id
|
||||
);
|
||||
|
||||
int
|
||||
h5priv_cmp_ids_by_eid (
|
||||
const void *_id1,
|
||||
const void *_id2
|
||||
);
|
||||
|
||||
int
|
||||
h5priv_cmp_ids (
|
||||
const void *_id1,
|
||||
const void *_id2
|
||||
);
|
||||
|
||||
h5_err_t
|
||||
h5priv_sort_idlist_by_eid (
|
||||
h5_file_t * const f,
|
||||
h5_idlist_t *list
|
||||
);
|
||||
|
||||
h5_loc_id_t
|
||||
h5priv_find_idlist (
|
||||
h5_file_t * const f,
|
||||
h5_idlist_t *list,
|
||||
h5_idlist_t* list,
|
||||
h5_loc_id_t item
|
||||
);
|
||||
|
||||
h5_loc_idx_t
|
||||
h5priv_insert_idlist (
|
||||
h5_file_t * const f,
|
||||
h5_idlist_t *list,
|
||||
h5_idlist_t** list,
|
||||
h5_loc_id_t item,
|
||||
h5_loc_idx_t idx
|
||||
);
|
||||
@@ -63,10 +32,11 @@ h5priv_insert_idlist (
|
||||
h5_loc_idx_t
|
||||
h5priv_search_idlist (
|
||||
h5_file_t * const f,
|
||||
h5_idlist_t *list,
|
||||
h5_idlist_t** list,
|
||||
h5_loc_id_t item
|
||||
);
|
||||
|
||||
|
||||
h5_err_t
|
||||
h5priv_alloc_idxmap (
|
||||
h5_file_t * const f,
|
||||
|
||||
@@ -43,7 +43,7 @@ release_tv (
|
||||
h5_loc_idx_t idx = 0;
|
||||
h5_loc_idx_t last = t->num_vertices[t->num_leaf_levels-1];
|
||||
for (; idx < last; idx++) {
|
||||
TRY( h5priv_free_idlist_items (f, &adj->tv.v[idx]) );
|
||||
TRY( h5priv_free_idlist (f, &adj->tv.v[idx]) );
|
||||
}
|
||||
TRY( h5_free (f, adj->tv.v) );
|
||||
adj->tv.v = NULL;
|
||||
@@ -71,10 +71,11 @@ compute_elems_of_vertices (
|
||||
int num_faces = h5tpriv_ref_elem_get_num_vertices(t);
|
||||
for (face_idx = 0; face_idx < num_faces; face_idx++) {
|
||||
h5_loc_idx_t vidx = el->vertex_indices[face_idx];
|
||||
TRY( h5priv_append_to_idlist (
|
||||
TRY( h5priv_insert_idlist (
|
||||
f,
|
||||
&t->adjacencies.tv.v[vidx],
|
||||
h5tpriv_build_vertex_id (face_idx, idx)) );
|
||||
h5tpriv_build_vertex_id (face_idx, idx),
|
||||
-1) );
|
||||
}
|
||||
}
|
||||
return H5_SUCCESS;
|
||||
@@ -94,7 +95,6 @@ static inline h5_err_t
|
||||
release_te (
|
||||
h5_file_t* const f
|
||||
) {
|
||||
UNUSED_ARGUMENT (f);
|
||||
TRY( h5priv_hwalk (f, &f->t->adjacencies.te_hash, free_idlist) );
|
||||
return H5_SUCCESS;
|
||||
}
|
||||
@@ -127,8 +127,7 @@ static inline h5_err_t
|
||||
release_td (
|
||||
h5_file_t* const f
|
||||
) {
|
||||
UNUSED_ARGUMENT (f);
|
||||
TRY( h5priv_hwalk (f, &f->t->adjacencies.td_hash, free_idlist) );
|
||||
TRY( h5priv_hwalk (f, &f->t->adjacencies.te_hash, free_idlist) );
|
||||
return H5_SUCCESS;
|
||||
}
|
||||
|
||||
@@ -175,7 +174,7 @@ compute_children_of_edge (
|
||||
h5_loc_idx_t face_idx = h5tpriv_get_face_idx (*edge);
|
||||
h5_loc_tet_t* tet = &t->loc_elems.tets[elem_idx];
|
||||
if (h5tpriv_is_leaf_elem (f, (h5_generic_loc_elem_t*)tet) == H5_OK ) {
|
||||
TRY( h5priv_append_to_idlist (f, children, *edge) );
|
||||
TRY( h5priv_insert_idlist (f, &children, *edge, -1) );
|
||||
} else {
|
||||
h5_loc_id_t kids[2];
|
||||
TRY( h5tpriv_get_direct_children_of_edge (
|
||||
@@ -227,7 +226,7 @@ compute_sections_of_edge (
|
||||
}
|
||||
}
|
||||
if (! refined) {
|
||||
TRY( h5priv_append_to_idlist (f, children, te->items[0]) );
|
||||
TRY( h5priv_insert_idlist (f, &children, te->items[0], -1) );
|
||||
}
|
||||
return H5_SUCCESS;
|
||||
}
|
||||
@@ -268,7 +267,7 @@ compute_direct_children_of_triangle (
|
||||
h5_file_t* const f,
|
||||
h5_loc_idx_t face_idx,
|
||||
h5_loc_idx_t elem_idx,
|
||||
h5_loc_id_t children[4]
|
||||
h5_loc_id_t* children
|
||||
) {
|
||||
h5_loc_idx_t map[4][4][2] = {
|
||||
{{0,0},{0,1},{0,2},{0,5}},
|
||||
@@ -313,9 +312,9 @@ compute_children_of_triangle (
|
||||
h5_loc_idx_t face_idx = h5tpriv_get_face_idx (*tri);
|
||||
h5_generic_loc_elem_t* tet = (h5_generic_loc_elem_t*)&t->loc_elems.tets[eid];
|
||||
if (h5tpriv_is_leaf_elem (f, tet) == H5_OK) {
|
||||
TRY( h5priv_append_to_idlist (f, children, *tri) );
|
||||
TRY( h5priv_insert_idlist (f, &children, *tri, -1) );
|
||||
} else {
|
||||
h5_loc_id_t dids[4];
|
||||
h5_loc_id_t dids[4] = {-1,-1,-1,-1};
|
||||
TRY( compute_direct_children_of_triangle (
|
||||
f,
|
||||
face_idx,
|
||||
@@ -352,7 +351,7 @@ compute_sections_of_triangle (
|
||||
h5_generic_loc_elem_t* tet = (h5_generic_loc_elem_t*)&t->loc_elems.tets[eid];
|
||||
if (! h5tpriv_is_leaf_elem (f, tet) == H5_OK) {
|
||||
refined = 1;
|
||||
h5_loc_id_t dids[4];
|
||||
h5_loc_id_t dids[4] = {-1,-1,-1,-1};
|
||||
TRY( compute_direct_children_of_triangle (
|
||||
f,
|
||||
face_idx,
|
||||
@@ -365,7 +364,7 @@ compute_sections_of_triangle (
|
||||
}
|
||||
}
|
||||
if (! refined) {
|
||||
TRY( h5priv_append_to_idlist (f, children, td->items[0]) );
|
||||
TRY( h5priv_insert_idlist (f, &children, td->items[0], -1) );
|
||||
}
|
||||
return H5_SUCCESS;
|
||||
}
|
||||
@@ -382,7 +381,7 @@ add_edge (
|
||||
) {
|
||||
h5_idlist_t* te;
|
||||
TRY( h5tpriv_find_te2 (f, face_idx, elem_idx, &te) );
|
||||
TRY( h5priv_search_idlist (f, list, te->items[0]) );
|
||||
TRY( h5priv_search_idlist (f, &list, te->items[0]) );
|
||||
return H5_SUCCESS;
|
||||
}
|
||||
|
||||
@@ -400,11 +399,11 @@ get_edges_uadj_to_vertex (
|
||||
h5t_fdata_t* const t = f->t;
|
||||
h5_loc_idx_t idx;
|
||||
TRY( h5t_get_vertex_index_of_vertex (f, id, &idx) );
|
||||
h5_idlist_t* tv = &t->adjacencies.tv.v[idx];
|
||||
h5_idlist_t** tv = &t->adjacencies.tv.v[idx];
|
||||
h5_size_t i;
|
||||
|
||||
h5_loc_id_t* vidp = tv->items; // ptr to upward adjacent elements
|
||||
for (i = 0; i < tv->num_items; i++, vidp++) {
|
||||
h5_loc_id_t* vidp = (*tv)->items; // ptr to upward adjacent elements
|
||||
for (i = 0; i < (*tv)->num_items; i++, vidp++) {
|
||||
h5_loc_idx_t elem_idx = h5tpriv_get_elem_idx (*vidp);
|
||||
h5_loc_idx_t face_idx = h5tpriv_get_face_idx (*vidp);
|
||||
h5_generic_loc_elem_t* tet = (h5_generic_loc_elem_t*)&t->loc_elems.tets[elem_idx];
|
||||
@@ -432,7 +431,7 @@ add_triangle (
|
||||
) {
|
||||
h5_idlist_t* td;
|
||||
TRY( h5tpriv_find_td2 (f, face_idx, elem_idx, &td) );
|
||||
TRY( h5priv_search_idlist (f, list, td->items[0]) );
|
||||
TRY( h5priv_search_idlist (f, &list, td->items[0]) );
|
||||
|
||||
return H5_SUCCESS;
|
||||
}
|
||||
@@ -453,11 +452,11 @@ get_triangles_uadj_to_vertex (
|
||||
h5t_fdata_t* t = f->t;
|
||||
h5_loc_idx_t idx;
|
||||
TRY( h5t_get_vertex_index_of_vertex (f, id, &idx) );
|
||||
h5_idlist_t* tv = &t->adjacencies.tv.v[idx];
|
||||
h5_idlist_t** tv = &t->adjacencies.tv.v[idx];
|
||||
|
||||
h5_size_t i;
|
||||
h5_loc_id_t* vidp = tv->items;
|
||||
for (i = 0; i < tv->num_items; i++, vidp++) {
|
||||
h5_loc_id_t* vidp = (*tv)->items;
|
||||
for (i = 0; i < (*tv)->num_items; i++, vidp++) {
|
||||
h5_loc_idx_t elem_idx = h5tpriv_get_elem_idx (*vidp);
|
||||
h5_loc_idx_t face_idx = h5tpriv_get_face_idx (*vidp);
|
||||
h5_generic_loc_elem_t* tet = (h5_generic_loc_elem_t*)&t->loc_elems.tets[elem_idx];
|
||||
@@ -487,11 +486,11 @@ get_tets_uadj_to_vertex (
|
||||
h5t_fdata_t* t = f->t;
|
||||
h5_loc_idx_t idx;
|
||||
TRY( h5t_get_vertex_index_of_vertex (f, id, &idx) );
|
||||
h5_idlist_t* tv = &t->adjacencies.tv.v[idx];
|
||||
h5_idlist_t** tv = &t->adjacencies.tv.v[idx];
|
||||
h5_size_t i;
|
||||
|
||||
h5_loc_id_t* vidp = tv->items;
|
||||
for (i = 0; i < tv->num_items; i++, vidp++) {
|
||||
h5_loc_id_t* vidp = (*tv)->items;
|
||||
for (i = 0; i < (*tv)->num_items; i++, vidp++) {
|
||||
h5_loc_idx_t elem_idx = h5tpriv_get_elem_idx (*vidp);
|
||||
h5_generic_loc_elem_t* tet = (h5_generic_loc_elem_t*)&t->loc_elems.tets[elem_idx];
|
||||
|
||||
@@ -499,7 +498,7 @@ get_tets_uadj_to_vertex (
|
||||
continue;
|
||||
}
|
||||
// add to result
|
||||
TRY( h5priv_search_idlist (f, *list, elem_idx) );
|
||||
TRY( h5priv_search_idlist (f, list, elem_idx) );
|
||||
}
|
||||
return H5_SUCCESS;
|
||||
}
|
||||
@@ -542,7 +541,7 @@ get_tets_uadj_to_edge (
|
||||
h5_loc_id_t* kidp = children->items;
|
||||
for (i = 0; i < children->num_items; i++, kidp++) {
|
||||
h5_loc_idx_t elem_idx = h5tpriv_get_elem_idx (*kidp);
|
||||
TRY( h5priv_search_idlist (f, *list, elem_idx) );
|
||||
TRY( h5priv_search_idlist (f, list, elem_idx) );
|
||||
}
|
||||
TRY( h5priv_free_idlist (f, &children) );
|
||||
return H5_SUCCESS;
|
||||
@@ -562,7 +561,7 @@ get_tets_uadj_to_triangle (
|
||||
h5_loc_id_t *didp = children->items;
|
||||
for (i = 0; i < children->num_items; i++ , didp++) {
|
||||
h5_loc_idx_t elem_idx = h5tpriv_get_elem_idx (*didp);
|
||||
TRY( h5priv_search_idlist (f, *list, elem_idx) );
|
||||
TRY( h5priv_search_idlist (f, list, elem_idx) );
|
||||
}
|
||||
TRY( h5priv_free_idlist (f, &children) );
|
||||
return H5_SUCCESS;
|
||||
@@ -583,8 +582,8 @@ get_vertices_dadj_to_edge (
|
||||
for (i = 0; i < children->num_items; i++, kidp++) {
|
||||
h5_loc_idx_t vertex_indices[2];
|
||||
TRY( h5t_get_vertex_indices_of_edge (f, *kidp, vertex_indices) );
|
||||
TRY( h5priv_search_idlist (f, *list, vertex_indices[0]) );
|
||||
TRY( h5priv_search_idlist (f, *list, vertex_indices[1]) );
|
||||
TRY( h5priv_search_idlist (f, list, vertex_indices[0]) );
|
||||
TRY( h5priv_search_idlist (f, list, vertex_indices[1]) );
|
||||
}
|
||||
TRY( h5priv_free_idlist(f, &children) );
|
||||
return H5_SUCCESS;
|
||||
@@ -618,8 +617,8 @@ get_vertices_dadj_to_triangle (
|
||||
for (i = 0; i < children->num_items; i++, kid++) {
|
||||
h5_loc_idx_t vertex_indices[2];
|
||||
TRY( h5t_get_vertex_indices_of_edge (f, *kid, vertex_indices) );
|
||||
TRY( h5priv_search_idlist (f, *list, vertex_indices[0]) );
|
||||
TRY( h5priv_search_idlist (f, *list, vertex_indices[1]) );
|
||||
TRY( h5priv_search_idlist (f, list, vertex_indices[0]) );
|
||||
TRY( h5priv_search_idlist (f, list, vertex_indices[1]) );
|
||||
}
|
||||
TRY( h5priv_free_idlist(f, &children) );
|
||||
return H5_SUCCESS;
|
||||
@@ -650,8 +649,8 @@ get_vertices_dadj_to_tet (
|
||||
for (i = 0; i < children->num_items; i++, kid++) {
|
||||
h5_loc_idx_t vertex_indices[2];
|
||||
TRY( h5t_get_vertex_indices_of_edge (f, *kid, vertex_indices) );
|
||||
TRY( h5priv_search_idlist (f, *list, vertex_indices[0]) );
|
||||
TRY( h5priv_search_idlist (f, *list, vertex_indices[1]) );
|
||||
TRY( h5priv_search_idlist (f, list, vertex_indices[0]) );
|
||||
TRY( h5priv_search_idlist (f, list, vertex_indices[1]) );
|
||||
}
|
||||
TRY( h5priv_free_idlist(f, &children) );
|
||||
return H5_SUCCESS;
|
||||
@@ -680,7 +679,7 @@ get_edges_dadj_to_triangle (
|
||||
TRY( h5priv_alloc_idlist (f, list, 8) );
|
||||
h5_loc_id_t *kid = children->items;
|
||||
for (i = 0; i < children->num_items; i++, kid++) {
|
||||
TRY( h5priv_search_idlist (f, *list, *kid) );
|
||||
TRY( h5priv_search_idlist (f, list, *kid) );
|
||||
}
|
||||
TRY( h5priv_free_idlist (f, &children) );
|
||||
return H5_SUCCESS;
|
||||
@@ -706,7 +705,7 @@ get_edges_dadj_to_tet (
|
||||
TRY( h5priv_alloc_idlist (f, list, 8) );
|
||||
h5_loc_id_t* kid = children->items;
|
||||
for (i = 0; i < children->num_items; i++, kid++) {
|
||||
TRY( h5priv_search_idlist (f, *list, *kid) );
|
||||
TRY( h5priv_search_idlist (f, list, *kid) );
|
||||
}
|
||||
TRY( h5priv_free_idlist (f, &children) );
|
||||
return H5_SUCCESS;
|
||||
@@ -732,7 +731,7 @@ get_triangles_dadj_to_tet (
|
||||
TRY( h5priv_alloc_idlist (f, list, 8) );
|
||||
h5_loc_id_t* did = children->items;
|
||||
for (i = 0; i < children->num_items; i++, did++) {
|
||||
TRY( h5priv_search_idlist (f, *list, *did) );
|
||||
TRY( h5priv_search_idlist (f, list, *did) );
|
||||
}
|
||||
TRY( h5priv_free_idlist (f, &children) );
|
||||
return H5_SUCCESS;
|
||||
@@ -877,10 +876,11 @@ static h5_err_t
|
||||
release_internal_structs (
|
||||
h5_file_t * const f
|
||||
) {
|
||||
h5t_fdata_t* t = f->t;
|
||||
TRY( release_tv (f) );
|
||||
TRY( release_te (f) );
|
||||
TRY( release_td (f) );
|
||||
|
||||
bzero (&t->adjacencies, sizeof (t->adjacencies));
|
||||
return H5_SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
@@ -42,7 +42,7 @@ release_tv (
|
||||
h5_loc_idx_t idx = 0;
|
||||
h5_loc_idx_t last = t->num_vertices[t->num_leaf_levels-1];
|
||||
for (; idx < last; idx++) {
|
||||
TRY( h5priv_free_idlist_items (f, &adj->tv.v[idx]) );
|
||||
TRY( h5priv_free_idlist (f, &adj->tv.v[idx]) );
|
||||
}
|
||||
TRY( h5_free (f, adj->tv.v) );
|
||||
adj->tv.v = NULL;
|
||||
@@ -71,11 +71,11 @@ compute_elems_of_vertices (
|
||||
int num_faces = h5tpriv_ref_elem_get_num_vertices (t);
|
||||
for (face_idx = 0; face_idx < num_faces; face_idx++) {
|
||||
h5_loc_idx_t vidx = el->vertex_indices[face_idx];
|
||||
TRY( h5priv_append_to_idlist (
|
||||
TRY( h5priv_insert_idlist (
|
||||
f,
|
||||
&t->adjacencies.tv.v[vidx],
|
||||
h5tpriv_build_vertex_id (
|
||||
face_idx, idx)) );
|
||||
face_idx, idx), -1) );
|
||||
}
|
||||
}
|
||||
h5_debug (f, "%s (%lld): done", __func__, (long long)from_lvl);
|
||||
@@ -96,7 +96,6 @@ static inline h5_err_t
|
||||
release_te (
|
||||
h5_file_t* const f
|
||||
) {
|
||||
UNUSED_ARGUMENT (f);
|
||||
TRY( h5priv_hwalk (f, &f->t->adjacencies.te_hash, free_idlist) );
|
||||
return H5_SUCCESS;
|
||||
}
|
||||
@@ -149,9 +148,7 @@ compute_children_of_edge (
|
||||
h5_loc_idx_t face_idx = h5tpriv_get_face_idx ( *edge );
|
||||
h5_generic_loc_elem_t *el = (h5_generic_loc_elem_t*)&t->loc_elems.tris[elem_idx];
|
||||
if ( h5tpriv_is_leaf_elem ( f, el ) == H5_OK ) {
|
||||
TRY ( h5priv_append_to_idlist (
|
||||
f, children, *edge )
|
||||
);
|
||||
TRY( h5priv_insert_idlist (f, &children, *edge, -1) );
|
||||
} else {
|
||||
h5_loc_id_t kids[2];
|
||||
TRY ( h5tpriv_get_direct_children_of_edge (
|
||||
@@ -208,7 +205,7 @@ compute_sections_of_edge (
|
||||
}
|
||||
}
|
||||
if ( ! refined ) {
|
||||
TRY ( h5priv_append_to_idlist ( f, children, te->items[0] ) );
|
||||
TRY( h5priv_insert_idlist (f, &children, te->items[0], -1) );
|
||||
}
|
||||
return H5_SUCCESS;
|
||||
}
|
||||
@@ -227,7 +224,7 @@ add_edge (
|
||||
) {
|
||||
h5_idlist_t *te;
|
||||
TRY ( h5tpriv_find_te2 ( f, face_idx, elem_idx, &te ) );
|
||||
TRY ( h5priv_search_idlist ( f, list, te->items[0] ) );
|
||||
TRY ( h5priv_search_idlist ( f, &list, te->items[0] ) );
|
||||
return H5_SUCCESS;
|
||||
}
|
||||
|
||||
@@ -243,7 +240,7 @@ get_edges_uadj_to_vertex (
|
||||
h5t_fdata_t* t = f->t;
|
||||
h5_loc_idx_t idx;
|
||||
TRY( h5t_get_vertex_index_of_vertex (f, entity_id, &idx) );
|
||||
h5_idlist_t* tv = &t->adjacencies.tv.v[idx];
|
||||
h5_idlist_t* tv = t->adjacencies.tv.v[idx];
|
||||
|
||||
h5_size_t i;
|
||||
h5_loc_id_t* vertex_idp = tv->items;
|
||||
@@ -275,7 +272,7 @@ get_triangles_uadj_to_vertex (
|
||||
h5t_fdata_t *t = f->t;
|
||||
h5_loc_idx_t idx;
|
||||
TRY( h5t_get_vertex_index_of_vertex (f, entity_id, &idx) );
|
||||
h5_idlist_t* tv = &t->adjacencies.tv.v[idx];
|
||||
h5_idlist_t* tv = t->adjacencies.tv.v[idx];
|
||||
|
||||
h5_size_t i;
|
||||
h5_loc_id_t *vertex_idp = tv->items;
|
||||
@@ -286,7 +283,7 @@ get_triangles_uadj_to_vertex (
|
||||
if ( h5tpriv_is_leaf_elem ( f, el ) == H5_NOK ) {
|
||||
continue;
|
||||
}
|
||||
TRY( h5priv_search_idlist (f, *list,
|
||||
TRY( h5priv_search_idlist (f, list,
|
||||
h5tpriv_build_entity_id (
|
||||
H5T_TYPE_TRIANGLE, 0, elem_idx)) );
|
||||
}
|
||||
@@ -307,7 +304,7 @@ get_triangles_uadj_to_edge (
|
||||
h5_loc_id_t *end = children->items+children->num_items;
|
||||
for ( ; edge_id < end; edge_id++ ) {
|
||||
h5_loc_idx_t elem_idx = h5tpriv_get_elem_idx ( *edge_id );
|
||||
TRY( h5priv_search_idlist (f, *list,
|
||||
TRY( h5priv_search_idlist (f, list,
|
||||
h5tpriv_build_entity_id(
|
||||
H5T_TYPE_TRIANGLE, 0, elem_idx)) );
|
||||
}
|
||||
@@ -334,7 +331,7 @@ get_edges_adj_to_edge (
|
||||
h5_loc_idx_t face_idx = h5tpriv_get_face_idx(*edge_id);
|
||||
h5_loc_idx_t elem_idx = h5tpriv_get_elem_idx(*edge_id);
|
||||
TRY( h5tpriv_find_te2 (f, face_idx, elem_idx, &te) );
|
||||
TRY( h5priv_search_idlist (f, *list, te->items[0]) );
|
||||
TRY( h5priv_search_idlist (f, list, te->items[0]) );
|
||||
}
|
||||
|
||||
TRY( h5priv_free_idlist(f, &children) );
|
||||
@@ -356,8 +353,8 @@ get_vertices_dadj_to_edge (
|
||||
for ( i = 0; i < children->num_items; i++, edge_id++ ) {
|
||||
h5_loc_idx_t vertex_indices[2];
|
||||
TRY ( h5t_get_vertex_indices_of_edge ( f, *edge_id, vertex_indices ) );
|
||||
TRY ( h5priv_search_idlist ( f, *list, vertex_indices[0] ) );
|
||||
TRY ( h5priv_search_idlist ( f, *list, vertex_indices[1] ) );
|
||||
TRY ( h5priv_search_idlist ( f, list, vertex_indices[0] ) );
|
||||
TRY ( h5priv_search_idlist ( f, list, vertex_indices[1] ) );
|
||||
}
|
||||
TRY ( h5priv_free_idlist( f, &children ) );
|
||||
return H5_SUCCESS;
|
||||
@@ -391,8 +388,8 @@ get_vertices_dadj_to_triangle (
|
||||
for ( i = 0; i < children->num_items; i++, edge_idp++ ) {
|
||||
h5_loc_idx_t vertex_indices[2];
|
||||
TRY ( h5t_get_vertex_indices_of_edge ( f, *edge_idp, vertex_indices ) );
|
||||
TRY ( h5priv_search_idlist ( f, *list, vertex_indices[0] ) );
|
||||
TRY ( h5priv_search_idlist ( f, *list, vertex_indices[1] ) );
|
||||
TRY ( h5priv_search_idlist ( f, list, vertex_indices[0] ) );
|
||||
TRY ( h5priv_search_idlist ( f, list, vertex_indices[1] ) );
|
||||
}
|
||||
TRY ( h5priv_free_idlist(f, &children) );
|
||||
return H5_SUCCESS;
|
||||
@@ -421,7 +418,7 @@ get_edges_dadj_to_triangle (
|
||||
h5_loc_id_t *edge_idp = children->items;
|
||||
int i;
|
||||
for (i = 0; i < children->num_items; i++, edge_idp++) {
|
||||
TRY ( h5priv_search_idlist (f, *list, *edge_idp) );
|
||||
TRY ( h5priv_search_idlist (f, list, *edge_idp) );
|
||||
}
|
||||
TRY ( h5priv_free_idlist(f, &children) );
|
||||
return H5_SUCCESS;
|
||||
@@ -536,9 +533,10 @@ static inline h5_err_t
|
||||
release_internal_structs (
|
||||
h5_file_t* const f
|
||||
) {
|
||||
h5t_fdata_t *t = f->t;
|
||||
TRY( release_tv (f) );
|
||||
TRY( release_te (f) );
|
||||
|
||||
bzero (&t->adjacencies, sizeof (t->adjacencies));
|
||||
return H5_SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
+29
-28
@@ -63,7 +63,7 @@ h5tpriv_search_te2 (
|
||||
h5_file_t* const f,
|
||||
h5_loc_idx_t face_idx,
|
||||
h5_loc_idx_t elem_idx,
|
||||
h5_idlist_t** retval
|
||||
h5_idlist_t** idlist
|
||||
) {
|
||||
h5t_fdata_t* t = f->t;
|
||||
h5t_adjacencies_t* a = &t->adjacencies;
|
||||
@@ -104,11 +104,13 @@ h5tpriv_search_te2 (
|
||||
f,
|
||||
&te_entry->value,
|
||||
h5tpriv_build_edge_id (face_idx, elem_idx)) );
|
||||
if (entry->value.num_items > 1) {
|
||||
/* search returned an existing entry */
|
||||
if (te_entry->value->num_items > 1) {
|
||||
/* search returned existing entry */
|
||||
TRY( h5_free (f, entry) );
|
||||
}
|
||||
*retval = &te_entry->value;
|
||||
if (idlist) {
|
||||
*idlist = te_entry->value;
|
||||
}
|
||||
return H5_SUCCESS;
|
||||
}
|
||||
|
||||
@@ -120,8 +122,8 @@ h5tpriv_search_te2 (
|
||||
h5_err_t
|
||||
h5tpriv_find_te (
|
||||
h5_file_t* const f,
|
||||
h5t_te_entry_t* item,
|
||||
h5_idlist_t** retval
|
||||
h5t_te_entry_t* item, // in: item to find
|
||||
h5_idlist_t** idlist // out:
|
||||
) {
|
||||
void* __entry;
|
||||
TRY( h5priv_hsearch (
|
||||
@@ -132,10 +134,11 @@ h5tpriv_find_te (
|
||||
&f->t->adjacencies.te_hash) );
|
||||
h5t_te_entry_t* entry = (h5t_te_entry_t*)__entry;
|
||||
if (entry ==NULL) {
|
||||
// not found
|
||||
return H5_NOK;
|
||||
return H5_NOK; // not found
|
||||
}
|
||||
if (idlist) {
|
||||
*idlist = entry->value;
|
||||
}
|
||||
*retval = &entry->value;
|
||||
return H5_SUCCESS;
|
||||
}
|
||||
|
||||
@@ -147,9 +150,9 @@ h5tpriv_find_te (
|
||||
h5_err_t
|
||||
h5tpriv_find_te2 (
|
||||
h5_file_t* const f,
|
||||
h5_loc_idx_t face_idx,
|
||||
h5_loc_idx_t elem_idx,
|
||||
h5_idlist_t** retval
|
||||
h5_loc_idx_t face_idx, // in
|
||||
h5_loc_idx_t elem_idx, // in
|
||||
h5_idlist_t** idlist // out
|
||||
) {
|
||||
h5t_te_entry_t item;
|
||||
TRY( h5t_get_vertex_indices_of_edge2 (
|
||||
@@ -157,7 +160,7 @@ h5tpriv_find_te2 (
|
||||
face_idx,
|
||||
elem_idx,
|
||||
item.key.vids) );
|
||||
return h5tpriv_find_te (f, &item, retval);
|
||||
return h5tpriv_find_te (f, &item, idlist);
|
||||
}
|
||||
|
||||
static int
|
||||
@@ -220,7 +223,7 @@ h5tpriv_search_td2 (
|
||||
h5_file_t* const f,
|
||||
h5_loc_idx_t face_idx,
|
||||
h5_loc_idx_t elem_idx,
|
||||
h5_idlist_t** retval
|
||||
h5_idlist_t** idlist // out
|
||||
) {
|
||||
h5t_fdata_t* t = f->t;
|
||||
h5t_adjacencies_t* a = &f->t->adjacencies;
|
||||
@@ -255,11 +258,12 @@ h5tpriv_search_td2 (
|
||||
f,
|
||||
&td_entry->value,
|
||||
h5tpriv_build_triangle_id (face_idx, elem_idx)) );
|
||||
if (td_entry->value.num_items > 1) {
|
||||
if (td_entry->value->num_items > 1) {
|
||||
TRY( h5_free (f, entry) );
|
||||
}
|
||||
*retval = &td_entry->value;
|
||||
|
||||
if (idlist) {
|
||||
*idlist = td_entry->value;
|
||||
}
|
||||
return H5_SUCCESS;
|
||||
}
|
||||
|
||||
@@ -267,7 +271,7 @@ h5_err_t
|
||||
h5tpriv_find_td (
|
||||
h5_file_t* const f,
|
||||
h5t_td_entry_t* item,
|
||||
h5_idlist_t** retval
|
||||
h5_idlist_t** idlist // out
|
||||
) {
|
||||
void* __entry;
|
||||
h5priv_hsearch (
|
||||
@@ -280,7 +284,7 @@ h5tpriv_find_td (
|
||||
return h5tpriv_error_local_triangle_nexist (f, item->key.vids);
|
||||
}
|
||||
h5t_td_entry_t* entry = (h5t_td_entry_t*)__entry;
|
||||
*retval = &entry->value;
|
||||
*idlist = entry->value;
|
||||
return H5_SUCCESS;
|
||||
}
|
||||
|
||||
@@ -289,7 +293,7 @@ h5tpriv_find_td2 (
|
||||
h5_file_t* const f,
|
||||
h5_loc_idx_t face_idx,
|
||||
h5_loc_idx_t elem_idx,
|
||||
h5_idlist_t** retval
|
||||
h5_idlist_t** idlist
|
||||
) {
|
||||
h5t_td_entry_t item;
|
||||
TRY( h5t_get_vertex_indices_of_triangle2 (
|
||||
@@ -297,7 +301,7 @@ h5tpriv_find_td2 (
|
||||
face_idx,
|
||||
elem_idx,
|
||||
item.key.vids) );
|
||||
return h5tpriv_find_td (f, &item, retval);
|
||||
return h5tpriv_find_td (f, &item, idlist);
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -308,14 +312,11 @@ h5tpriv_find_tv2 (
|
||||
h5_file_t* const f,
|
||||
h5_loc_idx_t face_idx,
|
||||
h5_loc_idx_t elem_idx,
|
||||
h5_idlist_t** retval
|
||||
h5_idlist_t** idlist
|
||||
) {
|
||||
|
||||
h5_loc_idx_t idx = h5tpriv_get_loc_elem_vertex_idx (
|
||||
f, elem_idx, face_idx);
|
||||
*retval = &f->t->adjacencies.tv.v[idx];
|
||||
h5_loc_idx_t idx;
|
||||
TRY( idx = h5tpriv_get_loc_elem_vertex_idx (f, elem_idx, face_idx) );
|
||||
*idlist = f->t->adjacencies.tv.v[idx];
|
||||
|
||||
return H5_SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -18,17 +18,17 @@ typedef struct h5t_idlisthash_key {
|
||||
The face is specified by its local vertex IDs.
|
||||
*/
|
||||
typedef struct h5_te_entry {
|
||||
h5_idlist_t value;
|
||||
h5_idlist_t* value;
|
||||
h5t_te_entry_key_t key;
|
||||
} h5t_te_entry_t;
|
||||
|
||||
typedef struct h5_td_entry {
|
||||
h5_idlist_t value;
|
||||
h5_idlist_t* value;
|
||||
h5t_td_entry_key_t key;
|
||||
} h5t_td_entry_t;
|
||||
|
||||
typedef struct h5t_idlisthash_entry {
|
||||
h5_idlist_t value;
|
||||
h5_idlist_t* value;
|
||||
h5t_idlisthash_key_t key;
|
||||
} h5t_idlisthash_entry_t;
|
||||
|
||||
|
||||
@@ -221,8 +221,12 @@ init_fdata (
|
||||
h5t_fdata_t* t = f->t;
|
||||
|
||||
memset (t->mesh_name, 0, sizeof (t->mesh_name));
|
||||
t->num_meshes = -1;
|
||||
memset (t->mesh_label, 0, sizeof (t->mesh_label));
|
||||
t->mesh_type = 0;
|
||||
t->ref_elem = NULL;
|
||||
t->cur_mesh = -1;
|
||||
t->mesh_changed = 0;
|
||||
t->num_meshes = -1;
|
||||
t->num_leaf_levels = -1;
|
||||
t->leaf_level = -1;
|
||||
t->last_stored_vid = -1;
|
||||
@@ -497,10 +501,15 @@ release_elems (
|
||||
) {
|
||||
h5t_fdata_t* t = f->t;
|
||||
TRY( h5_free (f, t->glb_elems.data) );
|
||||
t->glb_elems.data = NULL;
|
||||
TRY( h5_free (f, t->loc_elems.data) );
|
||||
t->loc_elems.data = NULL;
|
||||
TRY( h5_free (f, t->num_elems) );
|
||||
t->num_elems = NULL;
|
||||
TRY( h5_free (f, t->num_elems_on_leaf_level) );
|
||||
t->num_elems_on_leaf_level = NULL;
|
||||
TRY( h5_free (f, t->map_elem_g2l.items) );
|
||||
t->map_elem_g2l.items = NULL;
|
||||
|
||||
return H5_SUCCESS;
|
||||
}
|
||||
@@ -511,8 +520,11 @@ release_vertices (
|
||||
) {
|
||||
h5t_fdata_t* t = f->t;
|
||||
TRY( h5_free (f, t->vertices) );
|
||||
t->vertices = NULL;
|
||||
TRY( h5_free (f, t->num_vertices) );
|
||||
t->num_vertices = NULL;
|
||||
TRY( h5_free (f, t->map_vertex_g2l.items) );
|
||||
t->map_vertex_g2l.items = NULL;
|
||||
|
||||
return H5_SUCCESS;
|
||||
}
|
||||
@@ -525,7 +537,6 @@ release_memory (
|
||||
TRY( h5tpriv_release_adjacency_structs (f) );
|
||||
TRY( release_elems (f) );
|
||||
TRY( release_vertices (f) );
|
||||
|
||||
return H5_SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
@@ -304,14 +304,9 @@ h5t_store_elem (
|
||||
/* add edges to map edges -> elements */
|
||||
h5_loc_idx_t face_idx;
|
||||
int num_faces = h5tpriv_ref_elem_get_num_edges (t);
|
||||
h5_idlist_t* retval;
|
||||
for (face_idx = 0; face_idx < num_faces; face_idx++) {
|
||||
// add edges to neighbour struct
|
||||
TRY( h5tpriv_search_te2 (
|
||||
f,
|
||||
face_idx,
|
||||
elem_idx,
|
||||
&retval) );
|
||||
TRY( h5tpriv_search_te2 (f, face_idx, elem_idx, NULL) );
|
||||
}
|
||||
return elem_idx;
|
||||
}
|
||||
@@ -350,7 +345,7 @@ h5t_mark_entity (
|
||||
const h5_loc_id_t entity_id
|
||||
) {
|
||||
h5t_fdata_t* const t = f->t;
|
||||
return h5priv_append_to_idlist (f, t->marked_entities, entity_id);
|
||||
return h5priv_insert_idlist (f, &t->marked_entities, entity_id, -1);
|
||||
}
|
||||
|
||||
/*
|
||||
|
||||
@@ -98,7 +98,7 @@ typedef struct h5_dtypes {
|
||||
typedef struct h5t_adjacencies {
|
||||
struct {
|
||||
// h5_size_t size;
|
||||
h5_idlist_t* v;
|
||||
h5_idlist_t** v;
|
||||
} tv;
|
||||
h5_hashtable_t te_hash;
|
||||
h5_hashtable_t td_hash;
|
||||
|
||||
@@ -78,7 +78,7 @@ typedef unsigned long MPI_Datatype;
|
||||
typedef struct h5_idlist {
|
||||
int32_t size; /* allocated space in number of items */
|
||||
int32_t num_items; /* stored items */
|
||||
h5_id_t *items;
|
||||
h5_id_t items[1];
|
||||
} h5_idlist_t;
|
||||
|
||||
struct h5_idxmap;
|
||||
|
||||
@@ -8,7 +8,7 @@ h5t_get_num_meshes (
|
||||
);
|
||||
|
||||
h5_size_t
|
||||
h5t_get_num_levels (
|
||||
h5t_get_num_leaf_levels (
|
||||
h5_file_t * const f
|
||||
);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user