- boundary mesh iterators implemented

- #pragma replaced with macro
- several minor changes
This commit is contained in:
2010-12-14 10:24:33 +00:00
parent f5ace232e8
commit 8d21236264
40 changed files with 1208 additions and 861 deletions
+1 -1
View File
@@ -47,6 +47,6 @@ H5FedLinkMeshToStep (
h5_file_t* const f,
const h5_id_t mesh_id
) {
#pragma unused mesh_id
UNUSED_ARGUMENT (mesh_id);
return h5_error_not_implemented (f, __FILE__, __func__, __LINE__);
}
+18 -8
View File
@@ -31,27 +31,27 @@
\return H5_SUCCESS or error code
*/
h5t_entity_iterator_t*
h5t_iterator_t*
H5FedBeginTraverseEntities (
h5_file_t* const f,
const int codim
) {
h5t_entity_iterator_t* iter;
h5t_iterator_t* iter;
H5_ENTER_API (f, __func__);
if (h5t_alloc_entity_iterator (f, &iter, codim) < 0) {
if (h5t_create_mesh_iterator (f, &iter, codim) < 0) {
return (void*)H5_ERR;
}
return iter;
}
h5t_entity_iterator_t*
h5t_iterator_t*
H5FedBeginTraverseBoundaryFaces (
h5_file_t* const f,
const int codim
) {
h5t_entity_iterator_t* iter;
h5t_iterator_t* iter;
H5_ENTER_API (f, __func__);
if (h5t_alloc_boundary_face_iterator (f, &iter, codim) < 0) {
if (h5t_create_boundary_face_iterator (f, &iter, codim) < 0) {
return (void*)H5_ERR;
}
return iter;
@@ -70,7 +70,7 @@ H5FedBeginTraverseBoundaryFaces (
h5_id_t
H5FedTraverseEntities (
h5_file_t* const f,
h5t_entity_iterator_t* iter
h5t_iterator_t* iter
) {
H5_ENTER_API (f, __func__);
return h5t_iterate_entities (f, iter);
@@ -87,7 +87,7 @@ H5FedTraverseEntities (
h5_err_t
H5FedEndTraverseEntities (
h5_file_t* const f,
h5t_entity_iterator_t* iter
h5t_iterator_t* iter
) {
H5_ENTER_API (f, __func__);
return h5t_release_entity_iterator (f, iter);
@@ -143,6 +143,16 @@ H5FedGetVertexIndicesOfTriangle (
return h5t_get_vertex_indices_of_triangle (f, entity_id, vertex_indices);
}
h5_err_t
H5FedGetVertexIndicesOfTriangleCClockwise (
h5_file_t* const f,
h5_id_t entity_id,
h5_id_t* vertex_indices
) {
H5_ENTER_API (f, __func__);
return h5t_get_vertex_indices_of_triangle_cclockwise (f, entity_id, vertex_indices);
}
h5_err_t
H5FedGetVertexIndicesOfTet (
h5_file_t* const f,
+2
View File
@@ -42,6 +42,8 @@
if ((int64_t)(ptrdiff_t)(func) <= (int64_t)H5_ERR) \
return H5_ERR;
#define UNUSED_ARGUMENT(x) (void)x
#ifdef IPL_XT3
# define SEEK_END 2
#endif
+1 -1
View File
@@ -620,7 +620,7 @@ get_class_type_name (
h5_file_t* const f,
hid_t base_type_id
) {
#pragma unused f
UNUSED_ARGUMENT(f);
if (base_type_id == H5_COMPOUND_T) return "H5_COMPOUND_T";
return "[unknown]";
+16 -8
View File
@@ -175,7 +175,7 @@ h5priv_hsearch (
unsigned int hval;
unsigned int idx;
/* Compute an value for the given string. Perhaps use a better method. */
/* Compute an value for the given key. Perhaps use a better method. */
hval = (*htab->compute_hash)(item);
/* First hash function: simply take the modul but prevent zero. */
@@ -186,8 +186,10 @@ h5priv_hsearch (
value. */
if (htab->table[idx].used == hval
&& ((*htab->compare) (item, htab->table[idx].entry) == 0) ) {
*retval = htab->table[idx].entry;
return H5_SUCCESS;
if (retval && *retval) {
*retval = htab->table[idx].entry;
}
return H5_SUCCESS;
}
/* Second hash function, as suggested in [Knuth] */
@@ -211,7 +213,9 @@ h5priv_hsearch (
if (htab->table[idx].used == hval
&& ((*htab->compare) (
item, htab->table[idx].entry) == 0) ) {
*retval = htab->table[idx].entry;
if (retval && *retval) {
*retval = htab->table[idx].entry;
}
return H5_SUCCESS;
}
} while (htab->table[idx].used);
@@ -223,7 +227,9 @@ h5priv_hsearch (
with error. */
if (htab->filled == htab->size) {
h5_error_internal (f, __FILE__, __func__, __LINE__);
*retval = NULL;
if (retval) {
*retval = NULL;
}
return H5_ERR;
}
@@ -232,7 +238,9 @@ h5priv_hsearch (
++htab->filled;
*retval = htab->table[idx].entry;
if (retval && *retval) {
*retval = htab->table[idx].entry;
}
return H5_SUCCESS;
} else if (action == H5_REMOVE) {
htab->table[idx].used = 0; /* mark as unused, but */
@@ -240,8 +248,8 @@ h5priv_hsearch (
return H5_SUCCESS;
}
*retval = NULL;
h5_error (f, H5_ERR_INVAL, "Key not found in hash table.");
return H5_ERR;
h5_debug (f, "Key not found in hash table.");
return H5_NOK;
}
h5_err_t
+3 -3
View File
@@ -23,7 +23,7 @@ h5priv_free_idlist_items (
h5_file_t* const f,
h5_idlist_t* list
) {
#pragma unused f
UNUSED_ARGUMENT (f);
if (list->items != NULL) free (list->items);
list->items = NULL;
list->size = 0;
@@ -107,7 +107,7 @@ h5priv_sort_idlist_by_eid (
h5_file_t* const f,
h5_idlist_t* list
) {
#pragma unused f
UNUSED_ARGUMENT (f);
qsort (
list->items,
list->num_items,
@@ -126,7 +126,7 @@ h5priv_find_idlist (
h5_idlist_t* list,
h5_loc_id_t item
) {
#pragma unused f
UNUSED_ARGUMENT (f);
register h5_loc_idx_t low = 0;
register h5_loc_idx_t high = list->num_items - 1;
while (low <= high) {
+6 -6
View File
@@ -45,7 +45,7 @@ h5priv_error_handler (
hid_t estack_id,
void* __f
) {
#pragma unused __f
UNUSED_ARGUMENT (__f);
if (h5_get_debuglevel() >= 5) {
H5Eprint (estack_id, stderr);
}
@@ -145,7 +145,7 @@ open_file (
) {
#if !defined(PARALLEL_IO)
#pragma unused comm
UNUSED_ARGUMENT (f);
#endif
h5_info (f, "Opening file %s.", filename);
@@ -415,10 +415,10 @@ h5_get_stepname_fmt (
int l_name, /*!< length of buffer name */
int* width /*!< OUT: Width of the number */
) {
#pragma unused f
#pragma unused name
#pragma unused l_name
#pragma unused width
UNUSED_ARGUMENT (f);
UNUSED_ARGUMENT (name);
UNUSED_ARGUMENT (l_name);
UNUSED_ARGUMENT (width);
return h5_error_not_implemented (f, __FILE__, __func__, __LINE__);
}
+15 -1
View File
@@ -1,5 +1,6 @@
#include <stdlib.h>
#include <search.h>
#include <strings.h>
#include "h5core/h5_core.h"
#include "h5_core_private.h"
@@ -36,6 +37,19 @@ h5priv_calloc (
return ptr;
}
char*
h5priv_strdup (
h5_file_t* const f,
const char* s1
) {
char* s2 = strdup (s1);
if (s2 == NULL) {
h5_error (f, H5_ERR_NOMEM, "Out of memory.");
return (void*)(H5_ERR);
}
return s2;
}
h5_err_t
h5priv_free (
h5_file_t* const f,
@@ -70,7 +84,7 @@ h5priv_tfind (
void* const* rootp,
int (*compar) (const void* key1, const void* key2)
) {
#pragma unused f
UNUSED_ARGUMENT (f);
void* ptr = tfind (key, rootp, compar);
if (ptr == NULL) {
return (void*)(H5_ERR);
+5
View File
@@ -21,6 +21,11 @@ h5priv_free (
void* ptr
);
char*
h5priv_strdup (
h5_file_t* const f,
const char* s1
);
void*
h5priv_tsearch (
h5_file_t* const f,
+67
View File
@@ -1,6 +1,73 @@
#ifndef __H5T_ACCESS_PRIVATE_H
#define __H5T_ACCESS_PRIVATE_H
struct h5t_access_methods {
h5_generic_loc_elem_t* (*get_loc_elem)(
h5_file_t* const, const h5_loc_idx_t);
h5_loc_idx_t (*get_loc_elem_parent_idx)(
h5_file_t* const, const h5_loc_idx_t);
h5_loc_idx_t (*set_loc_elem_parent_idx)(
h5_file_t* const, const h5_loc_idx_t, const h5_loc_idx_t);
h5_loc_id_t (*get_loc_elem_child_idx)(
h5_file_t* const, const h5_loc_idx_t);
h5_loc_id_t (*set_loc_elem_child_idx)(
h5_file_t* const, const h5_loc_idx_t, const h5_loc_idx_t);
h5t_lvl_idx_t (*get_loc_elem_level_idx)(
h5_file_t* const, const h5_loc_idx_t);
h5t_lvl_idx_t (*set_loc_elem_level_idx)(
h5_file_t* const, const h5_loc_idx_t, const h5t_lvl_idx_t);
h5_loc_idx_t* (*get_loc_elem_vertex_indices)(
h5_file_t* const, const h5_loc_idx_t);
h5_loc_idx_t (*get_loc_elem_vertex_idx)(
h5_file_t* const, const h5_loc_idx_t, const h5_loc_idx_t);
h5_loc_idx_t (*set_loc_elem_vertex_idx)(
h5_file_t* const,
const h5_loc_idx_t, const h5_loc_idx_t, const h5_loc_idx_t);
h5_loc_idx_t* (*get_loc_elem_neighbor_indices)(
h5_file_t* const, const h5_loc_idx_t);
h5_loc_idx_t (*get_loc_elem_neighbor_idx)(
h5_file_t* const, const h5_loc_idx_t, const h5_loc_idx_t);
h5_loc_idx_t (*set_loc_elem_neighbor_idx)(
h5_file_t* const,
const h5_loc_idx_t, const h5_loc_idx_t, const h5_loc_idx_t);
h5_generic_glb_elem_t* (*get_glb_elem)(
h5_file_t* const, const h5_loc_idx_t);
h5_glb_id_t (*get_glb_elem_idx)(
h5_file_t* const, const h5_loc_id_t);
h5_glb_id_t (*set_glb_elem_idx)(
h5_file_t* const, const h5_loc_idx_t, const h5_glb_idx_t);
h5_glb_idx_t (*get_glb_elem_parent_idx)(
h5_file_t* const, const h5_loc_id_t);
h5_glb_idx_t (*set_glb_elem_parent_idx)(
h5_file_t* const, const h5_loc_idx_t, const h5_glb_idx_t);
h5_glb_idx_t (*get_glb_elem_child_idx)(
h5_file_t* const, const h5_loc_idx_t);
h5_glb_idx_t (*set_glb_elem_child_idx)(
h5_file_t* const, const h5_loc_idx_t, const h5_glb_idx_t);
h5_glb_idx_t* (*get_glb_elem_vertex_indices)(
h5_file_t* const, const h5_loc_idx_t);
h5_glb_idx_t (*get_glb_elem_vertex_idx)(
h5_file_t* const, const h5_loc_idx_t, const h5_loc_idx_t);
h5_glb_id_t (*set_glb_elem_vertex_idx)(
h5_file_t* const,
const h5_loc_idx_t, const h5_loc_idx_t, const h5_glb_idx_t);
h5_glb_idx_t* (*get_glb_elem_neighbor_indices)(
h5_file_t* const, const h5_loc_idx_t);
h5_glb_idx_t (*get_glb_elem_neighbor_idx)(
h5_file_t* const, const h5_loc_idx_t, const h5_loc_idx_t);
h5_glb_idx_t (*set_glb_elem_neighbor_idx)(
h5_file_t* const,
const h5_loc_idx_t, const h5_loc_idx_t, const h5_glb_idx_t);
h5_err_t (*set_boundary_elem_flag)(h5_file_t* const, const h5_loc_idx_t);
h5_err_t (*clear_boundary_elem_flag)(h5_file_t* const, const h5_loc_idx_t);
h5_err_t (*set_boundary_facet_flag)(h5_file_t* const, const h5_loc_idx_t);
h5_err_t (*clear_boundary_facet_flag)(h5_file_t* const, const h5_loc_idx_t);
int (*is_boundary_elem)(h5_file_t* const, const h5_loc_idx_t);
int (*is_boundary_facet)(h5_file_t* const, const h5_loc_idx_t, const h5_loc_idx_t);
int (*is_boundary_face)(h5_file_t* const, const int, const h5_loc_idx_t, const h5_loc_idx_t);
};
extern struct h5t_access_methods h5tpriv_access_trim_methods;
extern struct h5t_access_methods h5tpriv_access_tetm_methods;
+24 -4
View File
@@ -249,6 +249,15 @@ set_boundary_elem_flag (
return H5_SUCCESS;
}
static h5_err_t
set_boundary_facet_flag (
h5_file_t* const f,
h5_loc_idx_t elem_idx
) {
f->t->loc_elems.tets[elem_idx].flags |= H5T_BOUNDARY_FACET_FLAG;
return H5_SUCCESS;
}
static h5_err_t
clear_boundary_elem_flag (
h5_file_t* const f,
@@ -258,6 +267,14 @@ clear_boundary_elem_flag (
return H5_SUCCESS;
}
static h5_err_t
clear_boundary_facet_flag (
h5_file_t* const f,
h5_loc_idx_t elem_idx
) {
f->t->loc_elems.tets[elem_idx].flags &= ~H5T_BOUNDARY_FACET_FLAG;
return H5_SUCCESS;
}
static int
is_boundary_elem (
@@ -283,10 +300,11 @@ is_boundary_face (
const h5_loc_idx_t elem_idx,
const h5_loc_idx_t facet_idx
) {
#pragma unused f
#pragma unused dim
#pragma unused elem_idx
#pragma unused facet_idx
UNUSED_ARGUMENT (f);
UNUSED_ARGUMENT (dim);
UNUSED_ARGUMENT (elem_idx);
UNUSED_ARGUMENT (facet_idx);
return h5_error_internal (f, __FILE__, __func__, __LINE__);
}
@@ -319,6 +337,8 @@ struct h5t_access_methods h5tpriv_access_tetm_methods = {
set_glb_elem_neighbor_idx,
set_boundary_elem_flag,
clear_boundary_elem_flag,
set_boundary_facet_flag,
clear_boundary_facet_flag,
is_boundary_elem,
is_boundary_facet,
is_boundary_face,
+23 -5
View File
@@ -240,7 +240,6 @@ set_glb_elem_neighbor_idx (
return neighbor_idx;
}
static h5_err_t
set_boundary_elem_flag (
h5_file_t* const f,
@@ -250,6 +249,15 @@ set_boundary_elem_flag (
return H5_SUCCESS;
}
static h5_err_t
set_boundary_facet_flag (
h5_file_t* const f,
h5_loc_idx_t elem_idx
) {
f->t->loc_elems.tris[elem_idx].flags |= H5T_BOUNDARY_FACET_FLAG;
return H5_SUCCESS;
}
static h5_err_t
clear_boundary_elem_flag (
h5_file_t* const f,
@@ -259,6 +267,14 @@ clear_boundary_elem_flag (
return H5_SUCCESS;
}
static h5_err_t
clear_boundary_facet_flag (
h5_file_t* const f,
h5_loc_idx_t elem_idx
) {
f->t->loc_elems.tris[elem_idx].flags &= ~H5T_BOUNDARY_FACET_FLAG;
return H5_SUCCESS;
}
static int
is_boundary_elem (
@@ -284,10 +300,10 @@ is_boundary_face (
const h5_loc_idx_t elem_idx,
const h5_loc_idx_t facet_idx
) {
#pragma unused f
#pragma unused dim
#pragma unused elem_idx
#pragma unused facet_idx
UNUSED_ARGUMENT (f);
UNUSED_ARGUMENT (dim);
UNUSED_ARGUMENT (elem_idx);
UNUSED_ARGUMENT (facet_idx);
return h5_error_internal (f, __FILE__, __func__, __LINE__);
}
@@ -320,6 +336,8 @@ struct h5t_access_methods h5tpriv_access_trim_methods = {
set_glb_elem_neighbor_idx,
set_boundary_elem_flag,
clear_boundary_elem_flag,
set_boundary_facet_flag,
clear_boundary_facet_flag,
is_boundary_elem,
is_boundary_facet,
is_boundary_face,
+8
View File
@@ -1,6 +1,14 @@
#ifndef __H5T_ADJACENCIES_PRIVATE_H
#define __H5T_ADJACENCIES_PRIVATE_H
struct h5t_adjacency_methods {
h5_err_t (*update_internal_structs)(h5_file_t* const, h5t_lvl_idx_t);
h5_err_t (*release_internal_structs)(h5_file_t* const);
h5_err_t (*get_adjacencies)(
h5_file_t * const,
const h5_loc_id_t, const h5_int32_t, h5_idlist_t**);
};
extern struct h5t_adjacency_methods h5tpriv_trim_adjacency_methods;
extern struct h5t_adjacency_methods h5tpriv_tetm_adjacency_methods;
+6 -6
View File
@@ -84,7 +84,7 @@ static inline h5_err_t
release_te (
h5_file_t* const f
) {
#pragma unused f
UNUSED_ARGUMENT (f);
// @@@ TBD @@@
return H5_SUCCESS;
}
@@ -117,7 +117,7 @@ static inline h5_err_t
release_td (
h5_file_t* const f
) {
#pragma unused f
UNUSED_ARGUMENT (f);
// @@@ TBD @@@
return H5_SUCCESS;
}
@@ -824,13 +824,13 @@ get_adjacencies (
) {
h5_loc_id_t entity_type = h5tpriv_get_entity_type (entity_id);
switch (entity_type) {
case H5T_ETYPE_VERTEX:
case H5T_TYPE_VERTEX:
return get_adjacencies_to_vertex (f, entity_id, dim, list);
case H5T_ETYPE_EDGE:
case H5T_TYPE_EDGE:
return get_adjacencies_to_edge (f, entity_id, dim, list);
case H5T_ETYPE_TRIANGLE:
case H5T_TYPE_TRIANGLE:
return get_adjacencies_to_triangle (f, entity_id, dim, list);
case H5T_ETYPE_TET:
case H5T_TYPE_TET:
return get_adjacencies_to_tet (f, entity_id, dim, list);
default:
break;
+37 -6
View File
@@ -86,7 +86,7 @@ static inline h5_err_t
release_te (
h5_file_t* const f
) {
#pragma unused f
UNUSED_ARGUMENT (f);
// @@@ TBD @@@
return H5_SUCCESS;
}
@@ -276,7 +276,9 @@ get_triangles_uadj_to_vertex (
if ( h5tpriv_elem_is_on_cur_level ( f, el ) == H5_NOK ) {
continue;
}
TRY ( h5priv_search_idlist ( f, *list, elem_idx ) );
TRY( h5priv_search_idlist (f, *list,
h5tpriv_build_entity_id (
H5T_TYPE_TRIANGLE, 0, elem_idx)) );
}
return H5_SUCCESS;
}
@@ -295,13 +297,40 @@ 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, elem_idx ) );
TRY( h5priv_search_idlist (f, *list,
h5tpriv_build_entity_id(
H5T_TYPE_TRIANGLE, 0, elem_idx)) );
}
TRY ( h5priv_free_idlist( f, &children ) );
return H5_SUCCESS;
}
static inline h5_err_t
get_edges_adj_to_edge (
h5_file_t * const f,
const h5_loc_id_t entity_id,
h5_idlist_t **list
) {
TRY( h5priv_alloc_idlist (f, list, 8) );
h5_idlist_t *children;
TRY( h5priv_alloc_idlist (f, &children, 8) );
TRY( compute_sections_of_edge ( f, entity_id, children ) );
TRY( h5priv_alloc_idlist (f, list, 8) );
h5_loc_id_t* edge_id = children->items;
h5_loc_id_t* end = children->items+children->num_items;
h5_idlist_t* te;
for (; edge_id < end; edge_id++) {
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_free_idlist(f, &children) );
return H5_SUCCESS;
}
static inline h5_err_t
get_vertices_dadj_to_edge (
h5_file_t * const f,
@@ -426,6 +455,8 @@ get_adjacencies_to_edge (
switch (dim) {
case 0:
return get_vertices_dadj_to_edge(f, entity_id, list);
case 1:
return get_edges_adj_to_edge(f, entity_id, list);
case 2:
return get_triangles_uadj_to_edge(f, entity_id, list);
default:
@@ -459,11 +490,11 @@ get_adjacencies (
) {
h5_loc_id_t entity_type = h5tpriv_get_entity_type (entity_id);
switch (entity_type) {
case H5T_ETYPE_VERTEX:
case H5T_TYPE_VERTEX:
return get_adjacencies_to_vertex (f, entity_id, dim, list);
case H5T_ETYPE_EDGE:
case H5T_TYPE_EDGE:
return get_adjacencies_to_edge (f, entity_id, dim, list);
case H5T_ETYPE_TRIANGLE:
case H5T_TYPE_TRIANGLE:
return get_adjacencies_to_triangle (f, entity_id, dim, list);
default:
break;
+28 -16
View File
@@ -46,14 +46,13 @@
*/
#define H5T_ELEM_MASK ( (h5_id_t) (ULLONG_MAX >> 8) )
#define H5T_ETYPE_MASK ( 7ull << (sizeof(h5_id_t)*8-4) )
#define H5T_COMPONENT_MASK (~H5T_ELEM_MASK)
#define H5T_COMPONENT_ID_MASK (15ull << (sizeof(h5_id_t)*7) )
#define H5T_TYPE_MASK ( 7ull << (sizeof(h5_id_t)*7+4) )
#define H5T_FACE_MASK (15ull << (sizeof(h5_id_t)*7) )
#define H5T_ETYPE_VERTEX (1)
#define H5T_ETYPE_EDGE (2)
#define H5T_ETYPE_TRIANGLE (3)
#define H5T_ETYPE_TET (4)
#define H5T_TYPE_VERTEX (1)
#define H5T_TYPE_EDGE (2)
#define H5T_TYPE_TRIANGLE (3)
#define H5T_TYPE_TET (4)
#define h5tpriv_set_entity_type( type, elem_idx ) \
( \
@@ -61,35 +60,48 @@
((h5_id_t)(elem_idx)) \
)
#define h5tpriv_get_entity_type( entity_id ) \
((entity_id & H5T_ETYPE_MASK) >> (sizeof(h5_id_t)*8-4))
((entity_id & H5T_TYPE_MASK) >> (sizeof(h5_id_t)*8-4))
#define h5tpriv_build_id( type, face_idx, elem_idx ) \
#define h5tpriv_build_entity_id( type, face_idx, elem_idx ) \
( \
((h5_id_t)(type) << (sizeof(h5_id_t)*8-4)) | \
((h5_id_t)(face_idx) << (sizeof(h5_id_t)*7)) | \
((h5_id_t)(elem_idx) & H5T_ELEM_MASK) \
)
#define h5tpriv_build_entity_id2( face_id, elem_idx ) \
( \
((h5_id_t)(face_id) << (sizeof(h5_id_t)*7)) | \
((h5_id_t)(elem_idx) & H5T_ELEM_MASK) \
)
#define h5tpriv_build_face_id( type_id, face_idx ) \
(type_id << 4 | face_idx)
#define h5tpriv_build_vertex_id( face_idx, elem_idx ) \
( h5tpriv_build_id ( H5T_ETYPE_VERTEX, face_idx, elem_idx ) )
( h5tpriv_build_entity_id ( H5T_TYPE_VERTEX, face_idx, elem_idx ) )
#define h5tpriv_build_edge_id( face_idx, elem_idx ) \
( h5tpriv_build_id ( H5T_ETYPE_EDGE, face_idx, elem_idx ) )
( h5tpriv_build_entity_id ( H5T_TYPE_EDGE, face_idx, elem_idx ) )
#define h5tpriv_build_triangle_id( face_idx, elem_idx ) \
( h5tpriv_build_id ( H5T_ETYPE_TRIANGLE, face_idx, elem_idx ) )
( h5tpriv_build_entity_id ( H5T_TYPE_TRIANGLE, face_idx, elem_idx ) )
#define h5tpriv_build_elem_id( elem_idx ) \
( h5tpriv_build_id ( f->t->mesh_type, 0, elem_idx ) )
( h5tpriv_build_entity_id ( f->t->mesh_type, 0, elem_idx ) )
#define h5tpriv_get_face_idx( entity_id ) \
( (entity_id & H5T_COMPONENT_ID_MASK) >> (sizeof(h5_id_t)*7) )
( (entity_id & H5T_FACE_MASK) >> (sizeof(h5_id_t)*7) )
#define h5tpriv_get_elem_idx( entity_id ) \
#define h5tpriv_get_face_id( entity_id ) \
( (entity_id & (H5T_TYPE_MASK|H5T_FACE_MASK)) >> (sizeof(h5_id_t)*7) )
#define h5tpriv_get_elem_idx( entity_id ) \
( entity_id & H5T_ELEM_MASK )
#define H5T_BOUNDARY_ELEM_FLAG 1
#define H5T_BOUNDARY_FACET_FLAG 2
#endif
+13
View File
@@ -28,6 +28,19 @@ h5tpriv_error_local_elem_nexist (
return h5_error (f, H5_ERR_NOENTRY, ERR_ELEM_NEXIST, s);
}
static inline h5_err_t
h5tpriv_inval_codim (
h5_file_t * const f,
int codim,
int min_codim,
int max_codim
) {
return h5_error (f, H5_ERR_INVAL,
"Co-dimension %d requested, "
"but must be between %d and %d",
codim, min_codim, max_codim);
}
#define h5tpriv_error_undef_mesh( f ) \
h5_error( \
f, \
+2 -2
View File
@@ -85,7 +85,7 @@ h5t_get_num_elems (
h5_file_t* const f,
const h5_id_t cnode
) {
#pragma unused cnode
UNUSED_ARGUMENT (cnode);
h5t_fdata_t* t = f->t;
if (t->cur_mesh < 0) {
@@ -115,7 +115,7 @@ h5t_get_num_vertices (
h5_file_t* const f,
h5_id_t cnode
) {
#pragma unused cnode
UNUSED_ARGUMENT (cnode);
h5t_fdata_t* t = f->t;
if (t->cur_mesh < 0) {
+16
View File
@@ -290,6 +290,22 @@ h5t_get_vertex_indices_of_triangle (
f, face_idx, elem_idx, vertex_indices);
}
h5_err_t
h5t_get_vertex_indices_of_triangle_cclockwise (
h5_file_t* const f,
const h5_loc_id_t entity_id,
h5_loc_idx_t* vertex_indices
) {
TRY( h5t_get_vertex_indices_of_triangle (f, entity_id, vertex_indices) );
h5_float64_t P0[3];
h5_float64_t P1[3];
h5_float64_t P2[3];
TRY( h5t_get_vertex_coords_by_index (f, vertex_indices[0], P0) );
TRY( h5t_get_vertex_coords_by_index (f, vertex_indices[1], P1) );
TRY( h5t_get_vertex_coords_by_index (f, vertex_indices[2], P2) );
}
h5_err_t
h5t_get_vertex_indices_of_triangle2 (
h5_file_t* const f,
+2 -2
View File
@@ -365,7 +365,7 @@ h5_err_t
h5tpriv_init_step (
h5_file_t* const f
) {
#pragma unused f
UNUSED_ARGUMENT (f);
return H5_SUCCESS;
}
@@ -378,7 +378,7 @@ h5_err_t
h5tpriv_close_step (
h5_file_t* const f
) {
#pragma unused f
UNUSED_ARGUMENT (f);
return H5_SUCCESS;
}
+11 -11
View File
@@ -6,8 +6,8 @@ open_space_all (
h5_file_t* const f,
const hid_t dataset_id
) {
#pragma unused f
#pragma unused dataset_id
UNUSED_ARGUMENT (f);
UNUSED_ARGUMENT (dataset_id);
return H5S_ALL;
}
@@ -125,8 +125,8 @@ open_mem_space_vertices (
h5_file_t* const f,
hid_t dataset_id
) {
#pragma unused f
#pragma unused dataset_id
UNUSED_ARGUMENT (f);
UNUSED_ARGUMENT (dataset_id);
return H5S_ALL;
}
@@ -135,8 +135,8 @@ open_file_space_vertices (
h5_file_t* const f,
hid_t dataset_id
) {
#pragma unused f
#pragma unused dataset_id
UNUSED_ARGUMENT (f);
UNUSED_ARGUMENT (dataset_id);
return H5S_ALL;
}
@@ -218,8 +218,8 @@ open_mem_space_elems (
h5_file_t* const f,
hid_t dataset_id
) {
#pragma unused f
#pragma unused dataset_id
UNUSED_ARGUMENT (f);
UNUSED_ARGUMENT (dataset_id);
return H5S_ALL;
}
@@ -228,8 +228,8 @@ open_file_space_elems (
h5_file_t* const f,
hid_t dataset_id
) {
#pragma unused f
#pragma unused dataset_id
UNUSED_ARGUMENT (f);
UNUSED_ARGUMENT (dataset_id);
return H5S_ALL;
}
@@ -281,7 +281,7 @@ h5tpriv_read_mesh (
TRY( read_elems (f) );
TRY( h5tpriv_rebuild_elem_indices_mapping (f) );
TRY( h5tpriv_init_loc_elems_struct (f) );
TRY( h5tpriv_init_loc_elems_struct (f, 0) );
TRY( h5tpriv_update_adjacency_structs (f, 0) );
TRY( h5tpriv_init_geom_boundary_info (f, 0) );
+11 -4
View File
@@ -1,6 +1,14 @@
#ifndef __H5T_READWRITE_PRIVATE_H
#define __H5T_READWRITE_PRIVATE_H
struct h5t_read_methods {
h5_err_t (*init_loc_elems_struct)(h5_file_t* const, h5t_lvl_idx_t);
h5_err_t (*init_geom_boundary_info)(h5_file_t* const, h5t_lvl_idx_t);
};
extern struct h5t_read_methods h5tpriv_read_trim_methods;
extern struct h5t_read_methods h5tpriv_read_tetm_methods;
h5_err_t
h5tpriv_write_obj (
h5_file_t * f,
@@ -22,14 +30,13 @@ h5tpriv_write_mesh (
h5_file_t * const f
);
extern struct h5t_read_methods h5tpriv_read_trim_methods;
extern struct h5t_read_methods h5tpriv_read_tetm_methods;
static inline h5_err_t
h5tpriv_init_loc_elems_struct (
h5_file_t* const f
h5_file_t* const f,
const h5t_lvl_idx_t from_lvl
) {
return (*f->t->methods.read->init_loc_elems_struct) (f);
return (*f->t->methods.read->init_loc_elems_struct) (f, from_lvl);
}
static inline h5_err_t
+13 -6
View File
@@ -6,7 +6,8 @@
*/
static h5_err_t
init_loc_elems_struct (
h5_file_t* const f
h5_file_t* const f,
const h5t_lvl_idx_t from_lvl
) {
h5t_fdata_t* const t = f->t;
h5_loc_idx_t elem_idx = 0;
@@ -17,7 +18,7 @@ init_loc_elems_struct (
h5_loc_tet_t* loc_elem = t->loc_elems.tets;
h5_glb_tet_t* glb_elem = t->glb_elems.tets;
for (elem_idx = 0;
for (elem_idx = (from_lvl <= 0) ? 0 : t->num_elems[from_lvl-1];
elem_idx < num_elems; elem_idx++, loc_elem++, glb_elem++) {
// global element index
loc_elem->glb_idx = glb_elem->idx;
@@ -48,7 +49,9 @@ init_loc_elems_struct (
glb_elem->neighbor_indices,
num_facets,
loc_elem->neighbor_indices) );
// on boundary?
#if 0
// done in function below
// on boundary?
int i;
for (i=0; i < num_facets; i++) {
if (loc_elem->neighbor_indices[i] == -1) {
@@ -56,6 +59,7 @@ init_loc_elems_struct (
break;
}
}
#endif
}
return H5_SUCCESS;
}
@@ -109,11 +113,14 @@ init_geom_boundary_info (
// get vertices of edge i
h5_loc_idx_t face_idx;
face_idx = t->ref_elem->map[2][i][0];
vertex_indices[0] = h5tpriv_get_loc_elem_vertex_idx (f, elem_idx, face_idx);
vertex_indices[0] = h5tpriv_get_loc_elem_vertex_idx (
f, elem_idx, face_idx);
face_idx = t->ref_elem->map[2][i][1];
vertex_indices[1] = h5tpriv_get_loc_elem_vertex_idx (f, elem_idx, face_idx);
vertex_indices[1] = h5tpriv_get_loc_elem_vertex_idx (
f, elem_idx, face_idx);
face_idx = t->ref_elem->map[2][i][2];
vertex_indices[2] = h5tpriv_get_loc_elem_vertex_idx (f, elem_idx, face_idx);
vertex_indices[2] = h5tpriv_get_loc_elem_vertex_idx (
f, elem_idx, face_idx);
num_vertices = 3;
}
// mark elements
+8 -4
View File
@@ -6,10 +6,11 @@
*/
static h5_err_t
init_loc_elems_struct (
h5_file_t* const f
h5_file_t* const f,
const h5t_lvl_idx_t from_lvl
) {
h5t_fdata_t* const t = f->t;
h5_loc_idx_t idx = 0;
h5_loc_idx_t elem_idx = 0;
const h5_loc_idx_t num_elems = t->num_elems[t->num_levels-1];
h5t_lvl_idx_t level_idx = 0;
int num_vertices = h5tpriv_ref_elem_get_num_vertices (t);
@@ -17,7 +18,8 @@ init_loc_elems_struct (
h5_loc_triangle_t* loc_elem = t->loc_elems.tris;
h5_glb_triangle_t* glb_elem = t->glb_elems.tris;
for (idx = 0; idx < num_elems; idx++, loc_elem++, glb_elem++) {
for (elem_idx = (from_lvl <= 0) ? 0 : t->num_elems[from_lvl-1];
elem_idx < num_elems; elem_idx++, loc_elem++, glb_elem++) {
// global element index
loc_elem->glb_idx = glb_elem->idx;
// local parent index
@@ -29,7 +31,7 @@ init_loc_elems_struct (
h5t_map_glb_elem_idx2loc (f, glb_elem->child_idx) );
// level idx
if (idx >= t->num_elems[level_idx]) {
if (elem_idx >= t->num_elems[level_idx]) {
level_idx++;
}
loc_elem->level_idx = level_idx;
@@ -47,6 +49,7 @@ init_loc_elems_struct (
glb_elem->neighbor_indices,
num_facets,
loc_elem->neighbor_indices) );
#if 0
// on boundary?
int i;
for (i=0; i < num_facets; i++) {
@@ -55,6 +58,7 @@ init_loc_elems_struct (
break;
}
}
#endif
}
return H5_SUCCESS;
}
+7 -7
View File
@@ -32,9 +32,9 @@
const h5t_ref_elem_t h5t_tri_ref_elem = {
2, // dimension
{
H5T_ETYPE_VERTEX,
H5T_ETYPE_EDGE,
H5T_ETYPE_TRIANGLE,
H5T_TYPE_VERTEX,
H5T_TYPE_EDGE,
H5T_TYPE_TRIANGLE,
},
{
3, // #vertices
@@ -94,10 +94,10 @@ const h5t_ref_elem_t h5t_tri_ref_elem = {
const h5t_ref_elem_t h5t_tet_ref_elem = {
3, // dimension
{
H5T_ETYPE_VERTEX,
H5T_ETYPE_EDGE,
H5T_ETYPE_TRIANGLE,
H5T_ETYPE_TET,
H5T_TYPE_VERTEX,
H5T_TYPE_EDGE,
H5T_TYPE_TRIANGLE,
H5T_TYPE_TET,
},
{
4, // #vertices
+117 -102
View File
@@ -3,53 +3,31 @@
#include "h5core/h5_core.h"
#include "h5_core_private.h"
#define num_elems_on_cur_level f->t->num_elems[f->t->cur_level]
/*
Skip elements which have been refined on a level <= the current one.
*/
h5_err_t
h5tpriv_skip_to_next_elem_on_level (
static h5_err_t
skip_to_next_elem_on_level (
h5_file_t* f,
h5t_entity_iterator_t* iter
h5t_mesh_iterator_t* iter
) {
h5_generic_loc_elem_t* el;
do {
iter->elem_idx++;
if (iter->elem_idx >= num_elems_on_cur_level) {
if (iter->elem_idx >= f->t->num_elems[iter->level_idx]) {
return H5_NOK;
}
el = h5tpriv_get_loc_elem (f, iter->elem_idx);
} while (h5tpriv_elem_is_on_cur_level (f, el) == H5_NOK);
} while (h5tpriv_elem_is_on_level (f, el, iter->level_idx) == H5_NOK);
return H5_SUCCESS;
}
/*
Test whether given element is on current level. This is the case, if
- the level_id of the element is <= the current level
- and, if any, the direct children is on a level > the current level
*/
h5_err_t
h5tpriv_elem_is_on_cur_level (
h5_file_t* const f,
h5_generic_loc_elem_t *el // ptr to local element
) {
h5t_fdata_t* t = f->t;
if ( (el->level_idx > t->cur_level) ||
(el->child_idx >= 0 && el->child_idx < num_elems_on_cur_level) ) {
return H5_NOK;
}
return H5_SUCCESS;
}
static h5_loc_id_t
iterate_elems (
h5_file_t* const f,
h5t_entity_iterator_t* iter
h5t_mesh_iterator_t* iter
) {
if ( h5tpriv_skip_to_next_elem_on_level (f, iter) == H5_NOK) {
if ( skip_to_next_elem_on_level (f, iter) == H5_NOK) {
h5_debug ( f, "Traversing done!" );
return H5_NOK;
}
@@ -59,10 +37,10 @@ iterate_elems (
static h5_loc_id_t
iterate_boundary_elems (
h5_file_t* const f,
h5t_entity_iterator_t* iter
h5t_mesh_iterator_t* iter
) {
do {
if ( h5tpriv_skip_to_next_elem_on_level (f, iter) == H5_NOK) {
if ( skip_to_next_elem_on_level (f, iter) == H5_NOK) {
h5_debug ( f, "Traversing done!" );
return H5_NOK;
}
@@ -78,7 +56,7 @@ iterate_boundary_elems (
static h5_loc_id_t
iterate_boundary_facets (
h5_file_t* const f,
h5t_entity_iterator_t* iter
h5t_mesh_iterator_t* iter
) {
int num_facets = h5tpriv_ref_elem_get_num_facets (iter) - 1;
int dim = h5tpriv_ref_elem_get_dim (iter) - iter->codim;
@@ -96,7 +74,7 @@ iterate_boundary_facets (
}
} while (! h5tpriv_is_boundary_facet (f, iter->elem_idx, iter->face_idx));
int type = h5tpriv_ref_elem_get_entity_type (iter->ref_elem, dim);
return h5tpriv_build_id (type, iter->face_idx, iter->elem_idx );
return h5tpriv_build_entity_id (type, iter->face_idx, iter->elem_idx );
}
/*!
@@ -105,7 +83,7 @@ iterate_boundary_facets (
static h5_loc_id_t
iterate_faces (
h5_file_t* const f,
h5t_entity_iterator_t* iter
h5t_mesh_iterator_t* iter
) {
h5_idlist_t* entry;
int dim = h5tpriv_ref_elem_get_dim (iter) - iter->codim;
@@ -113,7 +91,7 @@ iterate_faces (
int i = -1;
do {
if (iter->face_idx >= num_faces) {
if (h5tpriv_skip_to_next_elem_on_level (f, iter) == H5_NOK) {
if (skip_to_next_elem_on_level (f, iter) == H5_NOK) {
h5_debug (f, "Traversing done!");
return H5_NOK;
}
@@ -134,7 +112,7 @@ iterate_faces (
i++;
h5_loc_idx_t idx = h5tpriv_get_elem_idx (entry->items[i]);
el = h5tpriv_get_loc_elem (f, idx);
} while (h5tpriv_elem_is_on_cur_level (f, el) == H5_NOK);
} while (h5tpriv_elem_is_on_level (f, el, iter->level_idx) == H5_NOK);
// 3. Face already visited if
} while (iter->elem_idx > h5tpriv_get_elem_idx(entry->items[i]));
@@ -153,7 +131,7 @@ iterate_faces (
static h5_loc_id_t
iterate_boundary_faces (
h5_file_t* const f,
h5t_entity_iterator_t* iter
h5t_mesh_iterator_t* iter
) {
// TODO!!!
int dim = h5tpriv_ref_elem_get_dim (iter) - iter->codim;
@@ -173,87 +151,123 @@ iterate_boundary_faces (
} else {
iter->face_idx++;
}
} while (! h5tpriv_is_boundary_face (f, dim, iter->elem_idx, iter->face_idx));
} while (! h5tpriv_is_boundary_face (
f, dim, iter->elem_idx, iter->face_idx));
// Skip already visited faces
} while (0);
return h5_error_internal (f, __FILE__, __func__, __LINE__);
}
h5_err_t
h5t_alloc_entity_iterator (
h5_file_t* f,
h5t_entity_iterator_t** iter,
int codim
static h5_loc_id_t
iterate_tags (
h5_file_t* const f,
h5t_tag_iterator_t* iter
) {
TRY( *iter = h5priv_alloc (f, NULL, sizeof (h5t_entity_iterator_t)) );
return h5t_begin_iterate_entities (f, *iter, codim);
UNUSED_ARGUMENT (f);
#if 0
h5t_tagsel_t* tags;
do {
if (iter->subentity_idx >= 14) {
iter->elem_idx++;
iter->subentity_idx = 0;
} else {
iter->subentity_idx++;
}
tags = iter->tagset->elems[iter->elem_idx];
} while ((tags == NULL) || (tags->idx[iter->subentity_idx]));
#endif
return 0;
}
h5_err_t
h5t_alloc_boundary_face_iterator (
h5t_init_mesh_iterator (
h5_file_t* f,
h5t_entity_iterator_t** iter,
h5t_iterator_t* iter,
int codim
) {
TRY( *iter = h5priv_alloc (f, NULL, sizeof (h5t_entity_iterator_t)) );
return h5t_begin_iterate_boundary_faces (f, *iter, codim);
h5t_mesh_iterator_t* it = (h5t_mesh_iterator_t*)iter;
it->face_idx = 999;
it->elem_idx = -1;
it->codim = codim;
it->level_idx = f->t->cur_level;
it->ref_elem = f->t->ref_elem;
if (it->codim > 0) {
it->iter = iterate_faces;
} else if (it->codim == 0) {
it->iter = iterate_elems;
}
return H5_SUCCESS;
}
h5_err_t
h5t_create_mesh_iterator (
h5_file_t* f,
h5t_iterator_t** iter,
int codim
) {
h5t_mesh_iterator_t* it;
TRY( it = h5priv_calloc (f, 1, sizeof (h5t_mesh_iterator_t)) );
TRY( h5t_init_mesh_iterator (f, (h5t_iterator_t*)it, codim) );
*iter = (h5t_iterator_t*)it;
return H5_SUCCESS;
}
h5_err_t
h5t_create_boundary_face_iterator (
h5_file_t* f,
h5t_iterator_t** iter,
int codim
) {
h5t_mesh_iterator_t* it;
TRY( it = h5priv_calloc (f, 1, sizeof (h5t_mesh_iterator_t)) );
it->face_idx = 999; // just a high enough number
it->elem_idx = -1;
it->codim = codim;
it->level_idx = f->t->cur_level;
it->ref_elem = f->t->ref_elem;
if (it->codim <= 0 || it->codim > it->ref_elem->dim) {
return h5tpriv_inval_codim (f, codim, 1, it->ref_elem->dim);
} else if (it->codim == 1) {
it->iter = iterate_boundary_facets;
}
else if (it->codim > 1) {
it->iter = iterate_boundary_faces;
}
*iter = (h5t_iterator_t*)it;
return H5_SUCCESS;
}
h5_err_t
h5t_create_mtag_iterator (
h5_file_t* f,
h5t_iterator_t** iter,
const char* name
) {
h5t_tag_iterator_t* it;
TRY( it = h5priv_calloc (f, 1, sizeof (h5t_tag_iterator_t)) );
h5t_open_mtagset (f, name, &it->tagset);
it->elem_idx = -1;
it->subentity_idx = 999;
it->level_idx = f->t->cur_level;
it->iter = iterate_tags;
*iter = (h5t_iterator_t*)it;
return H5_SUCCESS;
}
h5_err_t
h5t_release_entity_iterator (
h5_file_t* const f,
h5t_entity_iterator_t* iter
h5t_iterator_t* iter
) {
return h5priv_free (f, iter);
}
h5_err_t
h5t_begin_iterate_entities (
h5_file_t* f,
h5t_entity_iterator_t* iter,
const int codim
) {
iter->face_idx = -1;
iter->elem_idx = -1;
iter->codim = codim;
iter->ref_elem = f->t->ref_elem;
if (iter->codim > 0) {
iter->iter = iterate_faces;
} else if (iter->codim == 0) {
iter->iter = iterate_elems;
}
return h5tpriv_init_iterator (f, iter, codim);
}
h5_err_t
h5t_begin_iterate_boundary_faces (
h5_file_t* f,
h5t_entity_iterator_t* iter,
const int codim
) {
iter->face_idx = 999; // just a high enough number
iter->elem_idx = -1;
iter->codim = codim;
iter->ref_elem = f->t->ref_elem;
if (iter->codim <= 0 || iter->codim > iter->ref_elem->dim) {
return h5_error (f, H5_ERR_INVAL,
"Co-dimension requested %d, but must be between %d and %d",
codim, 1, iter->ref_elem->dim);
} else if (iter->codim == 1) {
iter->iter = iterate_boundary_facets;
}
else if (iter->codim > 1) {
iter->iter = iterate_boundary_faces;
}
return H5_SUCCESS;
}
h5_loc_id_t
h5t_iterate_entities (
h5_file_t* const f,
h5t_entity_iterator_t* iter
h5t_iterator_t* iter
) {
return (iter->iter (f, iter));
}
@@ -261,15 +275,16 @@ h5t_iterate_entities (
h5_err_t
h5t_end_iterate_entities (
h5_file_t* const f,
h5t_entity_iterator_t* iter
h5t_iterator_t* iter
) {
#pragma unused f
iter->face_idx = -1;
iter->elem_idx = -1;
iter->codim = -1;
iter->ref_elem = NULL;
iter->find = NULL;
iter->iter = NULL;
UNUSED_ARGUMENT (f);
h5t_mesh_iterator_t* it = (h5t_mesh_iterator_t*)iter;
it->face_idx = -1;
it->elem_idx = -1;
it->codim = -1;
it->ref_elem = NULL;
it->find = NULL;
it->iter = NULL;
return H5_SUCCESS;
}
+89 -8
View File
@@ -1,28 +1,109 @@
#ifndef __H5T_RETRIEVE_PRIVATE_H
#define __H5T_RETRIEVE_PRIVATE_H
h5_err_t
h5tpriv_skip_to_next_elem_on_level (
h5_file_t* f,
h5t_entity_iterator_t* iter
);
#include <assert.h>
/*
TODO: define as union of iterator types
*/
struct h5t_iterator {
h5_loc_id_t (*iter)(
h5_file_t *const f,
struct h5t_iterator* iter);
/*
const h5t_ref_elem_t* ref_elem; // pointer to reference element
h5_id_t elem_idx; // local element id
h5_id_t face_idx; // face id according reference element
int codim; // dimension of entities to traverse
h5_err_t (*find)(
h5_file_t *const f,
h5_id_t face_idx,
h5_id_t elem_idx,
h5_idlist_t **retval);
*/};
typedef struct h5t_mesh_iterator {
h5_loc_id_t (*iter)(
h5_file_t *const f,
struct h5t_mesh_iterator* iter);
h5t_lvl_idx_t level_idx;
const h5t_ref_elem_t* ref_elem;
h5_loc_idx_t elem_idx;
h5_loc_idx_t face_idx; // face id according reference element
int codim; // dimension of entities to traverse
h5_err_t (*find)(
h5_file_t *const f,
h5_id_t face_idx,
h5_id_t elem_idx,
h5_idlist_t **retval);
} h5t_mesh_iterator_t;
typedef struct h5t_tag_iterator {
h5_loc_id_t (*iter)(
h5_file_t *const f,
struct h5t_tag_iterator* iter);
h5t_lvl_idx_t level_idx;
h5t_tagset_t* tagset;
h5_loc_idx_t elem_idx;
int subentity_idx;
} h5t_tag_iterator_t;
/*
h5_err_t
h5tpriv_elem_is_on_cur_level (
h5_file_t* const f,
h5_generic_loc_elem_t* el
);
*/
struct h5t_retrieve_methods {
h5_err_t (*init_entity_iterator)(
h5_file_t* const, h5t_mesh_iterator_t*, const int);
};
extern struct h5t_retrieve_methods h5tpriv_trim_retrieve_methods;
extern struct h5t_retrieve_methods h5tpriv_tetm_retrieve_methods;
/*
Test whether given element is on current level. This is the case, if
- the level_id of the element is <= the current level
- and, if any, the direct children is on a level > the current level
*/
static inline h5_err_t
h5tpriv_init_iterator (
h5tpriv_elem_is_on_cur_level (
h5_file_t* const f,
h5_generic_loc_elem_t *el // ptr to local element
) {
h5t_fdata_t* t = f->t;
if ( (el->level_idx > t->cur_level) ||
(el->child_idx >= 0 && el->child_idx < f->t->num_elems[f->t->cur_level]) ) {
return H5_NOK;
}
return H5_SUCCESS;
}
static inline h5_err_t
h5tpriv_elem_is_on_level (
h5_file_t* const f,
h5_generic_loc_elem_t *el, // ptr to local element
const h5t_lvl_idx_t level_idx
) {
assert ( level_idx < f->t->num_levels );
if ( (el->level_idx > level_idx) ||
(el->child_idx >= 0 && el->child_idx < f->t->num_elems[level_idx]) ) {
return H5_NOK;
}
return H5_SUCCESS;
}
static inline h5_err_t
h5tpriv_init_entity_iterator (
h5_file_t* f,
h5t_entity_iterator_t* const iter,
h5t_mesh_iterator_t* const iter,
const int codim
) {
return (*f->t->methods.retrieve->init_iterator) (f, iter, codim);
return (*f->t->methods.retrieve->init_entity_iterator) (f, iter, codim);
}
#endif
+6 -5
View File
@@ -6,25 +6,26 @@
static h5_err_t
begin_iterate_entities (
h5_file_t* f,
h5t_entity_iterator_t* const iter,
h5t_mesh_iterator_t* const iter,
const int codim
) {
switch (iter->ref_elem->dim - codim) {
case 0: // iterate vertices
iter->find = h5tpriv_find_tv2;
return h5tpriv_skip_to_next_elem_on_level (f, iter);
break;
case 1: // iterate edges
iter->find = h5tpriv_find_te2;
return h5tpriv_skip_to_next_elem_on_level (f, iter);
break;
case 2: // iterate faces
iter->find = h5tpriv_find_td2;
return h5tpriv_skip_to_next_elem_on_level (f, iter);
break;
case 3: // iterate elems
iter->find = NULL;
return H5_SUCCESS;
break;
default:
return h5_error_internal (f, __FILE__, __func__, __LINE__);
}
return H5_SUCCESS;
}
struct h5t_retrieve_methods h5tpriv_tetm_retrieve_methods = {
+5 -4
View File
@@ -6,22 +6,23 @@
static h5_err_t
begin_iterate_entities (
h5_file_t* f,
h5t_entity_iterator_t* iter,
h5t_mesh_iterator_t* iter,
const int codim
) {
switch (h5tpriv_ref_elem_get_dim (iter) - codim) {
case 0: // iterate vertices
iter->find = h5tpriv_find_tv2;
return h5tpriv_skip_to_next_elem_on_level (f, iter);
break;
case 1: // iterate edges
iter->find = h5tpriv_find_te2;
return h5tpriv_skip_to_next_elem_on_level (f, iter);
break;
case 2: // iterate elems
iter->find = NULL;
return H5_SUCCESS;
break;
default:
return h5_error_internal (f, __FILE__, __func__, __LINE__);
}
return H5_SUCCESS;
}
struct h5t_retrieve_methods h5tpriv_trim_retrieve_methods = {
+19 -4
View File
@@ -453,8 +453,23 @@ h5t_end_refine_elems (
return H5_SUCCESS;
}
h5_err_t
h5t_create_index_set (
h5_file_t* const f
) {
int codim;
int dim = h5tpriv_ref_elem_get_dim (f->t);
// todo: check tagset already exist
TRY( h5t_add_mtagset (f, "__IndexSet__", H5_INT64_T) );
for (codim = 0; codim <= dim; codim++) {
h5_glb_idx_t idx = 0;
h5t_mesh_iterator_t it;
h5_glb_id_t entity_id;
TRY( h5t_init_mesh_iterator (f, (h5t_iterator_t*)&it, codim) );
while ((entity_id = it.iter(f,&it)) >= 0) {
TRY( h5t_set_mtag_by_name (f, "__IndexSet__", entity_id, 1, &idx) );
}
}
return H5_SUCCESS;
}
+9
View File
@@ -1,6 +1,15 @@
#ifndef __H5T_STOREMESH_PRIVATE_H
#define __H5T_STOREMESH_PRIVATE_H
struct h5t_store_methods {
h5_err_t (*alloc_elems)(h5_file_t* const, const size_t, const size_t);
h5_loc_idx_t (*refine_elem)(h5_file_t* const, const h5_loc_idx_t);
h5_err_t (*end_store_elems)(h5_file_t* const);
h5_err_t (*get_direct_children_of_edge)(
h5_file_t* const, const h5_loc_idx_t, const h5_loc_idx_t,
h5_loc_id_t*);
};
extern struct h5t_store_methods h5tpriv_trim_store_methods;
extern struct h5t_store_methods h5tpriv_tetm_store_methods;
+524 -470
View File
File diff suppressed because it is too large Load Diff
+29 -26
View File
@@ -29,53 +29,56 @@ ToDo
/*
Structure to store a tag value
All tags of an element are stored in an array of the below defined
structure
*/
typedef struct {
int32_t subent_id; /* sub-entitiy id */
int32_t size;
union {
h5_float64_t f;
h5_int64_t i;
} vals[1];
} item;
} h5t_tagval_t;
/*
Structure with pointers to the tag values of a given tagset of an element.
We use idx as an index into valp:
valp[idx[0]] ... valp[idx[3]] are pointing to the tag values of vertex 0 ... 3
valp[idx[4]] ... valp[idx[9]] are pointing to the tag values of edge 0 ... 5
valp[idx[10]] ... valp[idx[13]] are pointing to the tag values of triangle 0 ... 3
valp[idx[14]] points to the tag value of the elements itself.
If idx[k] is equal -1, no tag has been assigned to the appropriate entity.
*/
typedef struct {
signed char idx[15];
signed char size; /* size of valp */
h5t_tagval_t *valp[1];
} h5t_tagsel_t;
int16_t face_id; // face id: type and face index
uint16_t val_dim; // dim of value for this entity
uint32_t val_idx; // index of first value
} h5t_taginfo_t;
typedef struct {
int32_t num_tags;
h5t_taginfo_t ti[1];
} h5t_tageleminfo_t;
struct h5t_tagset {
char * name;
unsigned int changed; /* flag tagset changed, ... */
unsigned int num_elems;
h5_id_t type; /* int64 or float64 */
h5t_tagsel_t *elems[1];
char* name; // name of tagset
unsigned int changed; // flag tagset changed, ...
struct {
h5t_lvl_idx_t min_level;
h5t_lvl_idx_t max_level;
} scope;
h5_id_t type; // int64 or float64
h5_loc_idx_t num_entities;// number of tagged entities
h5_loc_idx_t num_values;// number of values
h5_loc_idx_t num_elems; // number of elements in tagset
h5t_tagval_t* values; // ptr to array of tag values
h5t_tageleminfo_t* elems[1]; // per element structure
};
/*
Structure for hash table of tagsets
*/
typedef struct {
unsigned int changed; /* flag container changed */
struct h5t_tagcontainer {
unsigned int changed; // flag container changed
hid_t group_id;
hsize_t num_sets; /* number of tagsets */
char **names; /* fast access via index */
h5_hashtable_t sets;
} h5t_tagcontainer_t;
hsize_t num_sets; // number of tagsets
char** names; // fast access via index
h5_hashtable_t sets; // hash table
};
typedef struct {
+11 -94
View File
@@ -24,7 +24,8 @@ typedef struct h5_loc_triangle {
h5_loc_idx_t parent_idx;
h5_loc_idx_t child_idx;
h5t_lvl_idx_t level_idx;
h5t_elem_flags_t flags;
h5t_lvl_idx_t refinement_level;
h5t_elem_flags_t flags;
h5_loc_idx_t vertex_indices[3];
h5_loc_idx_t neighbor_indices[3];
} h5_loc_triangle_t;
@@ -43,7 +44,8 @@ typedef struct h5_loc_tetrahedron {
h5_loc_idx_t parent_idx;
h5_loc_idx_t child_idx;
h5t_lvl_idx_t level_idx;
h5t_elem_flags_t flags;
h5t_lvl_idx_t refinement_level;
h5t_elem_flags_t flags;
h5_loc_idx_t vertex_indices[4];
h5_loc_idx_t neighbor_indices[4];
} h5_loc_tetrahedron_t;
@@ -61,7 +63,8 @@ typedef struct h5_generic_loc_elem {
h5_loc_idx_t parent_idx;
h5_loc_idx_t child_idx;
h5_int32_t level_idx;
h5_int32_t flags;
h5t_lvl_idx_t refinement_level;
h5t_elem_flags_t flags;
h5_loc_idx_t indices[1];
} h5_generic_loc_elem_t;
@@ -101,97 +104,11 @@ typedef struct h5t_adjacencies {
h5_hashtable_t td_hash;
} h5t_adjacencies_t;
struct h5t_store_methods {
h5_err_t (*alloc_elems)(h5_file_t* const, const size_t, const size_t);
h5_loc_idx_t (*refine_elem)(h5_file_t* const, const h5_loc_idx_t);
h5_err_t (*end_store_elems)(h5_file_t* const);
h5_err_t (*get_direct_children_of_edge)(
h5_file_t* const, const h5_loc_idx_t, const h5_loc_idx_t,
h5_loc_id_t*);
};
struct h5t_retrieve_methods {
h5_err_t (*init_iterator)(
h5_file_t* const, h5t_entity_iterator_t*, const int);
};
struct h5t_access_methods {
h5_generic_loc_elem_t* (*get_loc_elem)(
h5_file_t* const, const h5_loc_idx_t);
h5_loc_idx_t (*get_loc_elem_parent_idx)(
h5_file_t* const, const h5_loc_idx_t);
h5_loc_idx_t (*set_loc_elem_parent_idx)(
h5_file_t* const, const h5_loc_idx_t, const h5_loc_idx_t);
h5_loc_id_t (*get_loc_elem_child_idx)(
h5_file_t* const, const h5_loc_idx_t);
h5_loc_id_t (*set_loc_elem_child_idx)(
h5_file_t* const, const h5_loc_idx_t, const h5_loc_idx_t);
h5t_lvl_idx_t (*get_loc_elem_level_idx)(
h5_file_t* const, const h5_loc_idx_t);
h5t_lvl_idx_t (*set_loc_elem_level_idx)(
h5_file_t* const, const h5_loc_idx_t, const h5t_lvl_idx_t);
h5_loc_idx_t* (*get_loc_elem_vertex_indices)(
h5_file_t* const, const h5_loc_idx_t);
h5_loc_idx_t (*get_loc_elem_vertex_idx)(
h5_file_t* const, const h5_loc_idx_t, const h5_loc_idx_t);
h5_loc_idx_t (*set_loc_elem_vertex_idx)(
h5_file_t* const,
const h5_loc_idx_t, const h5_loc_idx_t, const h5_loc_idx_t);
h5_loc_idx_t* (*get_loc_elem_neighbor_indices)(
h5_file_t* const, const h5_loc_idx_t);
h5_loc_idx_t (*get_loc_elem_neighbor_idx)(
h5_file_t* const, const h5_loc_idx_t, const h5_loc_idx_t);
h5_loc_idx_t (*set_loc_elem_neighbor_idx)(
h5_file_t* const,
const h5_loc_idx_t, const h5_loc_idx_t, const h5_loc_idx_t);
h5_generic_glb_elem_t* (*get_glb_elem)(
h5_file_t* const, const h5_loc_idx_t);
h5_glb_id_t (*get_glb_elem_idx)(
h5_file_t* const, const h5_loc_id_t);
h5_glb_id_t (*set_glb_elem_idx)(
h5_file_t* const, const h5_loc_idx_t, const h5_glb_idx_t);
h5_glb_idx_t (*get_glb_elem_parent_idx)(
h5_file_t* const, const h5_loc_id_t);
h5_glb_idx_t (*set_glb_elem_parent_idx)(
h5_file_t* const, const h5_loc_idx_t, const h5_glb_idx_t);
h5_glb_idx_t (*get_glb_elem_child_idx)(
h5_file_t* const, const h5_loc_idx_t);
h5_glb_idx_t (*set_glb_elem_child_idx)(
h5_file_t* const, const h5_loc_idx_t, const h5_glb_idx_t);
h5_glb_idx_t* (*get_glb_elem_vertex_indices)(
h5_file_t* const, const h5_loc_idx_t);
h5_glb_idx_t (*get_glb_elem_vertex_idx)(
h5_file_t* const, const h5_loc_idx_t, const h5_loc_idx_t);
h5_glb_id_t (*set_glb_elem_vertex_idx)(
h5_file_t* const,
const h5_loc_idx_t, const h5_loc_idx_t, const h5_glb_idx_t);
h5_glb_idx_t* (*get_glb_elem_neighbor_indices)(
h5_file_t* const, const h5_loc_idx_t);
h5_glb_idx_t (*get_glb_elem_neighbor_idx)(
h5_file_t* const, const h5_loc_idx_t, const h5_loc_idx_t);
h5_glb_idx_t (*set_glb_elem_neighbor_idx)(
h5_file_t* const,
const h5_loc_idx_t, const h5_loc_idx_t, const h5_glb_idx_t);
h5_err_t (*set_boundary_elem_flag)(h5_file_t* const, const h5_loc_idx_t);
h5_err_t (*clear_boundary_elem_flag)(h5_file_t* const, const h5_loc_idx_t);
int (*is_boundary_elem)(h5_file_t* const, const h5_loc_idx_t);
int (*is_boundary_facet)(h5_file_t* const, const h5_loc_idx_t, const h5_loc_idx_t);
int (*is_boundary_face)(h5_file_t* const, const int, const h5_loc_idx_t, const h5_loc_idx_t);
};
struct h5t_read_methods {
h5_err_t (*init_loc_elems_struct)(h5_file_t* const);
h5_err_t (*init_geom_boundary_info)(h5_file_t* const, h5t_lvl_idx_t);
};
struct h5t_adjacency_methods {
h5_err_t (*update_internal_structs)(h5_file_t* const, h5t_lvl_idx_t);
h5_err_t (*release_internal_structs)(h5_file_t* const);
h5_err_t (*get_adjacencies)(
h5_file_t * const,
const h5_loc_id_t, const h5_int32_t, h5_idlist_t**);
};
struct h5t_read_methods;
struct h5t_store_methods;
struct h5t_retrieve_methods;
struct h5t_access_methods;
struct h5t_adjacency_methods;
typedef struct h5t_methods {
struct h5t_read_methods *read;
+1 -1
View File
@@ -115,7 +115,7 @@ h5u_set_num_particles (
}
#ifndef PARALLEL_IO
#pragma unused total
UNUSED_ARGUMENT (total);
count = u->nparticles;
TRY( u->shape = h5priv_create_hdf5_dataspace(f, 1, &count, NULL) );
u->viewstart = 0;
+11 -4
View File
@@ -15,12 +15,12 @@
#ifndef __H5FED_RETRIEVE_H
#define __H5FED_RETRIEVE_H
h5t_entity_iterator_t*
h5t_iterator_t*
H5FedBeginTraverseEntities (
h5_file_t* const f,
int codim
);
h5t_entity_iterator_t*
h5t_iterator_t*
H5FedBeginTraverseBoundaryFaces (
h5_file_t* const f,
int codim
@@ -28,12 +28,12 @@ H5FedBeginTraverseBoundaryFaces (
h5_loc_id_t
H5FedTraverseEntities (
h5_file_t* const f,
h5t_entity_iterator_t* iter
h5t_iterator_t* iter
);
h5_err_t
H5FedEndTraverseEntities (
h5_file_t* const f,
h5t_entity_iterator_t* iter
h5t_iterator_t* iter
);
h5_err_t
H5FedGetVertexCoordsByIndex (
@@ -62,6 +62,13 @@ H5FedGetVertexIndicesOfTriangle (
h5_loc_idx_t* const vertex_indices
);
h5_err_t
H5FedGetVertexIndicesOfTriangleCClockwise (
h5_file_t* const f,
h5_loc_id_t entity_id,
h5_loc_idx_t* const vertex_indices
);
h5_err_t
H5FedGetVertexIndicesOfTet (
h5_file_t* const f,
+1 -1
View File
@@ -39,7 +39,7 @@ typedef __int64 int64_t;
typedef int64_t h5_int64_t;
typedef int32_t h5_int32_t;
typedef int64_t h5_id_t;
typedef h5_int32_t h5t_lvl_idx_t;
typedef int16_t h5t_lvl_idx_t;
typedef h5_int32_t h5t_elem_flags_t;
typedef int64_t h5_glb_idx_t; // type for a global index
typedef int64_t h5_loc_idx_t; // type for a local index
+7
View File
@@ -66,6 +66,13 @@ h5t_get_vertex_indices_of_triangle (
h5_loc_idx_t* vertex_indices
);
h5_err_t
h5t_get_vertex_indices_of_triangle_cclockwise (
h5_file_t* const f,
const h5_loc_id_t entity_id,
h5_loc_idx_t* vertex_indices
);
h5_err_t
h5t_get_vertex_indices_of_triangle2 (
h5_file_t* const f,
+22 -35
View File
@@ -1,65 +1,52 @@
#ifndef __H5T_RETRIEVE_H
#define __H5T_RETRIEVE_H
typedef struct h5t_entity_iterator {
h5_id_t elem_idx; // local element id
h5_id_t face_idx; // face id according reference element
int codim; // dimension of entities to traverse
const h5t_ref_elem_t* ref_elem; // pointer to reference element
h5_err_t (*find)(
h5_file_t *const f,
h5_id_t face_idx,
h5_id_t elem_idx,
h5_idlist_t **retval);
h5_loc_id_t (*iter)(
h5_file_t *const f,
struct h5t_entity_iterator* iter);
} h5t_entity_iterator_t;
typedef struct h5t_iterator h5t_iterator_t;
h5_err_t
h5t_alloc_entity_iterator (
h5t_init_mesh_iterator (
h5_file_t* f,
h5t_entity_iterator_t** iter,
h5t_iterator_t* iter,
const int codim
);
h5_err_t
h5t_alloc_boundary_face_iterator (
h5t_create_mesh_iterator (
h5_file_t* f,
h5t_entity_iterator_t** iter,
h5t_iterator_t** iter,
const int codim
);
h5_err_t
h5t_create_boundary_face_iterator (
h5_file_t* f,
h5t_iterator_t** iter,
const int codim
);
h5_err_t
h5t_create_mtag_iterator (
h5_file_t* f,
h5t_iterator_t** iter,
const char* name
);
h5_err_t
h5t_release_entity_iterator (
h5_file_t* const f,
h5t_entity_iterator_t* iter
);
h5_err_t
h5t_begin_iterate_entities (
h5_file_t* f,
h5t_entity_iterator_t* iter,
const int codim
);
h5_err_t
h5t_begin_iterate_boundary_faces (
h5_file_t* f,
h5t_entity_iterator_t* iter,
const int codim
h5t_iterator_t* iter
);
h5_id_t
h5t_iterate_entities (
h5_file_t * const f,
h5t_entity_iterator_t *iter
h5t_iterator_t *iter
);
h5_err_t
h5t_end_iterate_entities (
h5_file_t * const f,
h5t_entity_iterator_t *iter
h5t_iterator_t *iter
);
+14 -6
View File
@@ -1,23 +1,31 @@
#ifndef __H5T_TAGS_H
#define __H5T_TAGS_H
typedef struct h5t_tagset H5T_Tagset;
typedef struct h5t_tagset h5t_tagset_t;
typedef struct h5t_tagcontainer h5t_tagcontainer_t;
h5_err_t
h5t_mtagset_exists (
h5_file_t* const f,
h5t_tagcontainer_t* ctn,
char* name
);
h5_err_t
h5t_add_mtagset (
h5_file_t* const f,
char name[],
h5_id_t id
h5_id_t type
);
h5_err_t
h5t_remove_mtagset (
h5_file_t* const f,
const char name[]
);
h5_err_t h5t_open_mtagset (
h5_err_t
h5t_open_mtagset (
h5_file_t* const f,
const char *name,
H5T_Tagset** retval
h5t_tagset_t** retval
);
h5_ssize_t
h5t_get_num_mtagsets (
@@ -68,7 +76,7 @@ h5t_remove_mtag_by_name (
h5_ssize_t
h5t_get_tag (
h5_file_t *const f,
const H5T_Tagset *tagset,
const h5t_tagset_t *tagset,
const h5_loc_id_t entity_id,
size_t* const dim,
void* const vals
@@ -77,7 +85,7 @@ h5t_get_tag (
h5_err_t
h5t_remove_mtag (
h5_file_t* const f,
H5T_Tagset* tagset,
h5t_tagset_t* tagset,
const h5_loc_id_t entity_id
);