From 8030a7246b377e36997693d9bc2050395e469d53 Mon Sep 17 00:00:00 2001 From: Achim Gsell Date: Fri, 17 Jun 2011 15:03:14 +0000 Subject: [PATCH] H5Fed C-API inlined --- .gitattributes | 5 - src/C/H5Fed_adjacency.c | 46 --------- src/C/H5Fed_inquiry.c | 154 ----------------------------- src/C/H5Fed_retrieve.c | 176 --------------------------------- src/C/H5Fed_store.c | 168 ------------------------------- src/C/H5Fed_tags.c | 154 ----------------------------- src/C/Makefile.am | 7 +- src/include/H5Fed_adjacency.h | 22 +++-- src/include/H5Fed_inquiry.h | 139 ++++++++++++++++++++++++-- src/include/H5Fed_retrieve.h | 155 ++++++++++++++++++++++------- src/include/H5Fed_store.h | 180 +++++++++++++++++++++++++--------- src/include/H5Fed_tags.h | 135 +++++++++++++++++++++---- src/include/h5core/h5_core.h | 7 -- 13 files changed, 521 insertions(+), 827 deletions(-) delete mode 100644 src/C/H5Fed_adjacency.c delete mode 100644 src/C/H5Fed_inquiry.c delete mode 100644 src/C/H5Fed_retrieve.c delete mode 100644 src/C/H5Fed_store.c delete mode 100644 src/C/H5Fed_tags.c diff --git a/.gitattributes b/.gitattributes index 64a1246..0a776fc 100644 --- a/.gitattributes +++ b/.gitattributes @@ -368,11 +368,6 @@ src/C++/Makefile.am -text src/C/H5.c -text src/C/H5Block.c -text src/C/H5Block_readwrite.c -text -src/C/H5Fed_adjacency.c -text -src/C/H5Fed_inquiry.c -text -src/C/H5Fed_retrieve.c -text -src/C/H5Fed_store.c -text -src/C/H5Fed_tags.c -text src/C/H5Part.c -text src/C/H5_attachments.c -text src/C/H5_attribs.c -text diff --git a/src/C/H5Fed_adjacency.c b/src/C/H5Fed_adjacency.c deleted file mode 100644 index ae87a07..0000000 --- a/src/C/H5Fed_adjacency.c +++ /dev/null @@ -1,46 +0,0 @@ -/* - Copyright 2006-2010 - Paul Scherrer Institut, Villigen, Switzerland; - Benedikt Oswald; - Achim Gsell - All rights reserved. - - Authors - Achim Gsell - - Warning - This code is under development. - - */ - -#include "h5core/h5_core.h" -#include "H5Fed.h" - -/****** UPWARD ADJACENCY routines *********************************************/ - -/*! - \return number of upward adjacent edges - */ -h5_err_t -H5FedGetAdjacencies ( - h5_file_t* const f, - const h5_loc_id_t entity_id, - const h5_int32_t dim, - h5_loc_idlist_t** list - ) { - H5_API_ENTER4 (h5_err_t, - "f=0x%p, entity_id=%lld, dim=%d, list=0x%p", - f, (long long)entity_id, dim, list); - H5_API_RETURN (h5t_get_adjacencies (f, entity_id, dim, list)); -} - -h5_err_t -H5FedReleaseListOfAdjacencies ( - h5_file_t* const f, - h5_loc_idlist_t** list - ) { - H5_API_ENTER2 (h5_err_t, - "f=0x%p, list=0x%p", - f, list); - H5_API_RETURN (h5t_release_list_of_adjacencies (f, list)); -} diff --git a/src/C/H5Fed_inquiry.c b/src/C/H5Fed_inquiry.c deleted file mode 100644 index 77dd2d9..0000000 --- a/src/C/H5Fed_inquiry.c +++ /dev/null @@ -1,154 +0,0 @@ -/* - Copyright 2007-2008 - Paul Scherrer Institut, Villigen, Switzerland; - Benedikt Oswald; - Achim Gsell - All rights reserved. - - Authors - Achim Gsell - - Warning - This code is under development. - - */ -/*! - \ingroup h5fed_c_api - \defgroup h5fed_mesh_inquiry -*/ - -#include "h5core/h5_core.h" -#include "H5Fed.h" - - -/*! - Get the number of hierarchical mesh levels. - - \param[in] f File handle - - \return Number of hierarchical mesh levels or error code. - */ -h5_ssize_t -H5FedGetNumLevels ( - h5_file_t* const f - ) { - H5_API_ENTER1 (h5_ssize_t, "f=0x%p", f); - H5_API_RETURN (h5t_get_num_leaf_levels (f)); -} - -/*! - Get current mesh levels. - - \param[in] f File handle - - \return ID of current mesh levels or error code. - */ -h5t_lvl_idx_t -H5FedGetLevel ( - h5_file_t* const f - ) { - H5_API_ENTER1 (h5t_lvl_idx_t, "f=0x%p", f); - H5_API_RETURN (h5t_get_level (f)); -} - -/*! - Returns the number of vertices used for defining the (sub-)mesh - at current level on this compute node. - - \param[in] f file handle - - \return Number of vertices or error code. -*/ -h5_ssize_t -H5FedGetNumVertices ( - h5_file_t* const f /*!< file handle */ - ) { - H5_API_ENTER1 (h5_ssize_t, "f=0x%p", f); - H5_API_RETURN (h5t_get_num_vertices (f, -1)); -} - -/*! - Returns the number of vertices used for defining the (sub-)mesh - at current level on compute node \c cnode. - - \param[in] f file handle - \param[in] cnode compute node - - \return Number of vertices or error code. -*/ -h5_ssize_t -H5FedGetNumVerticesCnode ( - h5_file_t* const f, - const int cnode - ) { - H5_API_ENTER2 (h5_ssize_t, "f=0x%p, cnode=%d", f, cnode); - H5_API_RETURN (h5t_get_num_vertices (f, cnode)); -} - -/*! - Returns the number of vertices used for defining the (sub-)mesh - at current level overl all compute nodes. - - \param[in] f file handle - - \return Total number of vertices or error code. -*/ -h5_ssize_t -H5FedGetNumVerticesTotal ( - h5_file_t* const f - ) { - H5_API_ENTER1 (h5_ssize_t, "f=0x%p", f); - H5_API_RETURN (h5t_get_num_vertices (f, -1)); -} - -/*! - Returns the number of elements present in the (sub-)mesh - at current level on this compute node. - - \param[in] f file handle - - \return Number of elements or error code. -*/ -h5_ssize_t -H5FedGetNumElements ( - h5_file_t* const f - ) { - H5_API_ENTER1 (h5_ssize_t, "f=0x%p", f); - // MLH: can't use field from opaque h5_file_t! - //h5_ssize_t num = h5t_get_num_elems (f, f->myproc); - H5_API_RETURN (h5t_get_num_elems (f, -1)); -} - -/*! - Returns the number of elements present in the (sub-)mesh - at current level on compute node \c cnode. - - \param[in] f file handle - \param[in] cnode Compute node - - \return Number of elements or error code. -*/ -h5_ssize_t -H5FedGetNumElementsCnode ( - h5_file_t* const f, - const int cnode - ) { - H5_API_ENTER2 (h5_ssize_t, "f=0x%p, cnode=%d", f, cnode); - H5_API_RETURN (h5t_get_num_elems (f, cnode)); -} - -/*! - Returns the number of elements present in the mesh - at current level over all compute nodes. - - \param[in] f File handle. - - \return Number of elements or error code. -*/ -h5_ssize_t -H5FedGetNumElementsTotal ( - h5_file_t* const f - ) { - H5_API_ENTER1 (h5_ssize_t, "f=0x%p", f); - H5_API_RETURN (h5t_get_num_elems (f, -1)); -} diff --git a/src/C/H5Fed_retrieve.c b/src/C/H5Fed_retrieve.c deleted file mode 100644 index a379938..0000000 --- a/src/C/H5Fed_retrieve.c +++ /dev/null @@ -1,176 +0,0 @@ -/****** RETRIEVAL routines **************************************************/ -/* - Copyright 2007-2008 - Paul Scherrer Institut, Villigen, Switzerland; - Benedikt Oswald; - Achim Gsell - All rights reserved. - - Authors - Achim Gsell - - Warning - This code is under development. - - */ - -#include "h5core/h5_core.h" -#include "H5Fed.h" - -/*! - Begin traverse over all entities on this compute node. - Initialize internal data structures. - - \remark - Entities might be on processor boundaries! Therefore the same entity might be - processed on several compute nodes. - - \param[in] f file handle - \param[in] codim co-dimension of entity to traverse - - \return H5_SUCCESS or error code -*/ - -h5t_iterator_p -H5FedBeginTraverseEntities ( - h5_file_t* const f, - const int codim - ) { - H5_API_ENTER2 (h5t_iterator_p, "f=0x%p, codim=%d", f, codim); - h5t_iterator_p iter; - TRY2 (iter = h5_calloc (1, sizeof (*iter))); - TRY2 (h5t_init_leaf_iterator (f, iter, codim)); - H5_API_RETURN (iter); -} - -h5t_iterator_p -H5FedBeginTraverseBoundaryFaces ( - h5_file_t* const f, - const int codim - ) { - H5_API_ENTER2 (h5t_iterator_p, "f=0x%p, codim=%d", f, codim); - h5t_iterator_p iter; - TRY2 (iter = h5_calloc (1, sizeof (*iter))); - TRY2 (h5t_init_boundary_face_iterator (f, iter, codim)); - H5_API_RETURN (iter); -} - -/*! - Get next local entity ID. - - \param[in] f file handle - \param[in/out] iter iterator - - \return Local entity ID - \return -1, if done - \return error code on error - */ -h5_loc_id_t -H5FedTraverseEntities ( - h5_file_t* const f, - h5t_iterator_t* iter - ) { - H5_API_ENTER2 (h5_loc_id_t, "f=0x%p, iter=0x%p", f, iter); - H5_API_RETURN (h5t_iterate_entities (f, iter)); -} - -/*! - End of traversing. Release internal data structures. - - \param[in] f File handle - - \return H5_SUCCESS or error code - - */ -h5_err_t -H5FedEndTraverseEntities ( - h5_file_t* const f, - h5t_iterator_t* iter - ) { - H5_API_ENTER2 (h5_err_t, "f=0x%p, iter=0x%p", f, iter); - H5_API_RETURN (h5t_release_entity_iterator (f, iter)); -} - - -/*! - Get coordinates of vertex given by local index - - \param[in] f file handle - \param[in] vertex_idx local index of vertex - \param[out] P 3-dimensional coordinates - - \return H5_SUCCESS or error code - */ -h5_err_t -H5FedGetVertexCoordsByIndex ( - h5_file_t* const f, - h5_loc_idx_t vertex_index, - h5_float64_t P[3] - ) { - H5_API_ENTER3 (h5_err_t, - "f=0x%p, vertex_index=%lld, P=0x%p", - f, (long long)vertex_index, P); - H5_API_RETURN (h5t_get_vertex_coords_by_index (f, vertex_index, P)); -} - -h5_err_t -H5FedGetVertexCoordsByID ( - h5_file_t* const f, - h5_loc_id_t vertex_id, - h5_float64_t P[3] - ) { - H5_API_ENTER3 (h5_err_t, - "f=0x%p, vertex_id=%lld, P=0x%p", - f, (long long)vertex_id, P); - H5_API_RETURN (h5t_get_vertex_coords_by_id (f, vertex_id, P)); -} - -h5_err_t -H5FedGetVertexIndicesOfEdge ( - h5_file_t* const f, - h5_loc_id_t entity_id, - h5_loc_idx_t* vertex_indices - ) { - H5_API_ENTER3 (h5_err_t, - "f=0x%p, entity_id=%lld, vertex_indices=0x%p", - f, (long long)entity_id, vertex_indices); - H5_API_RETURN (h5t_get_vertex_indices_of_edge (f, entity_id, vertex_indices)); -} - -h5_err_t -H5FedGetVertexIndicesOfTriangle ( - h5_file_t* const f, - h5_loc_id_t entity_id, - h5_loc_idx_t* vertex_indices - ) { - H5_API_ENTER3 (h5_err_t, - "f=0x%p, entity_id=%lld, vertex_indices=0x%p", - f, (long long)entity_id, vertex_indices); - H5_API_RETURN (h5t_get_vertex_indices_of_triangle (f, entity_id, vertex_indices)); -} - -h5_err_t -H5FedGetVertexIndicesOfTet ( - h5_file_t* const f, - h5_loc_id_t entity_id, - h5_loc_idx_t* vertex_indices - ) { - H5_API_ENTER3 (h5_err_t, - "f=0x%p, entity_id=%lld, vertex_indices=0x%p", - f, (long long)entity_id, vertex_indices); - H5_API_RETURN (h5t_get_vertex_indices_of_tet (f, entity_id, vertex_indices)); -} - -h5_err_t -H5FedGetVertexIndicesOfEntity ( - h5_file_t* const f, - h5_loc_id_t entity_id, - h5_loc_idx_t* vertex_indices - ) { - H5_API_ENTER3 (h5_err_t, - "f=0x%p, entity_id=%lld, vertex_indices=0x%p", - f, (long long)entity_id, vertex_indices); - H5_API_RETURN (h5t_get_vertex_indices_of_entity (f, entity_id, vertex_indices)); -} - - diff --git a/src/C/H5Fed_store.c b/src/C/H5Fed_store.c deleted file mode 100644 index 79ef7fc..0000000 --- a/src/C/H5Fed_store.c +++ /dev/null @@ -1,168 +0,0 @@ -/* - Copyright 2007-2008 - Paul Scherrer Institut, Villigen, Switzerland; - Benedikt Oswald; - Achim Gsell - All rights reserved. - - Authors - Achim Gsell - - Warning - This code is under development. - - */ - -#include "h5core/h5_core.h" -#include "H5Fed.h" - - - -/*! - \ingroup h5fed_c_api - - Add a new level with \c num_elems elements. The number of elements must be the - real number of elements to add the level. If you want to refine \c n tetrahedra - \c n*8 elements must be added. - - \param[in] f File handle. - \param[in] num_elems_to_refine Number of elements which will be refined. - - \return ID of new level. - - \note - values for f->t.num_levels: - \c -1 unknown: after opening the file. This is equivalent to - "topological data has not been initialized". - \c 0 no levels: HDF5 group for meshes may already exist but must not! - \c > 0 number of mesh levels - -*/ -h5t_lvl_idx_t -H5FedAddLevel ( - h5_file_t* const f - ) { - H5_API_ENTER1 (h5t_lvl_idx_t, "f=0x%p", f); - H5_API_RETURN (h5t_add_level (f)); -} - -h5_err_t -H5FedBeginStoreVertices ( - h5_file_t* const f, - const h5_size_t num - ) { - H5_API_ENTER2 (h5_err_t, - "f=0x%p, num=%llu", - f, (long long unsigned)num); - H5_API_RETURN (h5t_begin_store_vertices (f, num)); -} - -/*! - \ingroup h5fed_c_api - - Stores the the coordinates of a specific vertex at level \c level - with id \c vertex_id of the tetrahedral mesh. - - \return local vertex id on success - \return errno on error -*/ -h5_loc_idx_t -H5FedStoreVertex ( - h5_file_t* const f, /*!< file handle */ - const h5_glb_id_t vertex_id, /*!< id from mesher or -1 */ - const h5_float64_t P[3] /*!< coordinates */ - ) { - H5_API_ENTER3 (h5_loc_idx_t, - "f=0x%p, vertex_id=%lld, P=0x%p", - f, (long long)vertex_id, P); - if (h5t_get_level (f) != 0) { - H5_API_LEAVE ( - h5_error ( - H5_ERR_INVAL, - "Vertices can be added to level 0 only!")); - } - H5_API_RETURN (h5t_store_vertex (f, vertex_id, P)); -} - -h5_err_t -H5FedEndStoreVertices ( - h5_file_t* const f - ) { - H5_API_ENTER1 (h5_err_t, "f=0x%p", f); - H5_API_RETURN (h5t_end_store_vertices (f)); -} - -h5_err_t -H5FedBeginStoreElements ( - h5_file_t* const f, - const h5_size_t num - ) { - H5_API_ENTER2 (h5_err_t, - "f=0x%p, num=%llu", - f, (long long unsigned)num); - H5_API_RETURN (h5t_begin_store_elems (f, num)); -} - -/*! - \ingroup h5fed_c_api - - Stores the 4-tuple, that contains the specific indices describing - a tetrahedron with id \c tet_id at level \c level of the tetrahedral - mesh. - - Errors: - * current level not yet defined - * to many tets stored on level - - \return local tetrahedron id - \return \c errno on error -*/ -h5_loc_idx_t -H5FedStoreElement ( - h5_file_t* const f, /*!< file handle */ - const h5_loc_idx_t local_vids[] /*!< tuple with vertex id's */ - ) { - H5_API_ENTER2 (h5_loc_idx_t, "f=0x%p, local_vids=0x%p", f, local_vids); - if (h5t_get_level (f) != 0) { - H5_API_LEAVE ( - h5_error ( - H5_ERR_INVAL, - "Elements can be added to level 0 only!")); - } - H5_API_RETURN (h5t_store_elem (f, -1, local_vids)); -} - -h5_err_t -H5FedEndStoreElements ( - h5_file_t* const f - ) { - H5_API_ENTER1 (h5_err_t, "f=0x%p", f); - H5_API_RETURN (h5t_end_store_elems (f)); -} - -h5_err_t -H5FedBeginRefineElements ( - h5_file_t* const f - ) { - H5_API_ENTER1 (h5_err_t, "f=0x%p", f); - H5_API_RETURN (h5t_begin_refine_elems (f)); -} - -h5_loc_idx_t -H5FedRefineElement ( - h5_file_t* const f, /*!< file handle */ - const h5_loc_id_t local_eid /*!< local element id */ - ) { - H5_API_ENTER2 (h5_loc_idx_t, - "f=0x%p, local_eid=%lld", - f, (long long)local_eid); - H5_API_RETURN (h5t_mark_entity (f, local_eid)); -} - -h5_err_t -H5FedEndRefineElements ( - h5_file_t* const f - ) { - H5_API_ENTER1 (h5_err_t, "f=0x%p", f); - H5_API_RETURN (h5t_end_refine_elems (f)); -} diff --git a/src/C/H5Fed_tags.c b/src/C/H5Fed_tags.c deleted file mode 100644 index 17b5524..0000000 --- a/src/C/H5Fed_tags.c +++ /dev/null @@ -1,154 +0,0 @@ -/* - Copyright 2007-2011 - Paul Scherrer Institut, Villigen, Switzerland; - Achim Gsell - All rights reserved. - - Authors - Achim Gsell - - Warning - This code is under development. - - */ -#include "h5core/h5_core.h" -#include "H5Fed.h" - -/*! - Add a tagset to the current mesh. - - \param[in] f file handle - \param[in] name name of tagset - \param[in] type data type of tagset - - \return H5_SUCCESS or error code - */ -h5_err_t -H5FedAddMTagset ( - h5_file_t* const f, - char* name, - h5_id_t type - ) { - H5_API_ENTER3 (h5_err_t, "f=0x%p, name=\"%s\", type=%lld", - f, name, (long long)type); - H5_API_RETURN (h5t_add_mtagset (f, name, type)); -} - -/*! - Remove a tagset from the current mesh. - - \param[in] f file handle - \param[in] name name of tagset to remove - - \return H5_SUCCESS or error code - */ -h5_err_t -H5FedRemoveMTagset ( - h5_file_t* const f, - char name[] - ) { - H5_API_ENTER2 (h5_err_t, "f=0x%p, name=\"%s\"", f, name); - H5_API_RETURN (h5t_remove_mtagset (f, name)); -} - -/*! - Get available tagsets in current mesh. - - \param[in] f file handle - \param[out] names names of available tagsets - - \return Number of tagsets or error code - */ -h5_ssize_t -H5FedGetMTagsets ( - h5_file_t* const f, - char** names[] - ) { - H5_API_ENTER2 (h5_ssize_t, "f=0x%p, names=0x%p", f, names); - H5_API_RETURN (h5t_get_mtagsets (f, names)); -} - -/*! - Get type of tagset in current mesh. - - \param[in] f file handle - \param[in] name name of tagset - - \return H5_SUCCESS or error code - */ -h5_id_t -H5FedGetTypeOfMTagset ( - h5_file_t* const f, - char name[] - ) { - H5_API_ENTER2 (h5_err_t, "f=0x%p, name=\"%s\"", f, name); - H5_API_RETURN (h5t_get_mtagset_type_by_name (f, name)); -} - -/*! - Set tag for entity in current mesh. - - \param[in] f file handle - \param[in] name names of tagset - \param[in] id id of entity - \param[in] dim dimension of value - \param[in] val tag value - - \return H5_SUCCESS or error code - */ -h5_err_t -H5FedSetMTag ( - h5_file_t* const f, - char name[], - h5_loc_id_t id, - const size_t dim, - void* buffer - ) { - H5_API_ENTER5 (h5_err_t, - "f=0x%p, name=\"%s\", id=%lld, dim=%lld, val=0x%p", - f, name, (long long)id, (long long)dim, buffer); - H5_API_RETURN (h5t_set_mtag_by_name (f, name, id, dim, buffer)); -} - -/*! - Set tag for entity in current mesh. - - \param[in] f file handle - \param[in] name names of tagset - \param[in] id id of entity - \param[out] dim dimension of value - \param[out] val tag value - - \return H5_SUCCESS or error code - */ -h5_err_t -H5FedGetMTag ( - h5_file_t* const f, - const char name[], - const h5_loc_id_t id, - size_t* dim, - void* buffer - ) { - H5_API_ENTER5 (h5_err_t, - "f=0x%p, name=\"%s\", id=%lld, dim=0x%p, val=0x%p", - f, name, (long long)id, dim, buffer); - H5_API_RETURN (h5t_get_mtag_by_name (f, name, id, dim, buffer)); -} - -/*! - Remove tag for entity in current mesh. - - \param[in] f file handle - \param[in] name names of tagset - \param[in] id id of entity -*/ -h5_err_t -H5FedRemoveMTag ( - h5_file_t* const f, - const char name[], - const h5_loc_id_t id - ) { - H5_API_ENTER3 (h5_err_t, "f=0x%p, name=\"%s\", id=%lld", - f, name, (long long)id); - H5_API_RETURN (h5t_remove_mtag_by_name (f, name, id)); -} diff --git a/src/C/Makefile.am b/src/C/Makefile.am index f176c9d..e937eaa 100644 --- a/src/C/Makefile.am +++ b/src/C/Makefile.am @@ -37,12 +37,7 @@ ___lib_libH5hutC_a_SOURCES = \ H5_attachments.c \ H5Part.c \ H5Block.c \ - H5Block_readwrite.c \ - H5Fed_adjacency.c \ - H5Fed_inquiry.c \ - H5Fed_retrieve.c \ - H5Fed_store.c \ - H5Fed_tags.c + H5Block_readwrite.c all: all-am diff --git a/src/include/H5Fed_adjacency.h b/src/include/H5Fed_adjacency.h index c52a262..994e86a 100644 --- a/src/include/H5Fed_adjacency.h +++ b/src/include/H5Fed_adjacency.h @@ -5,19 +5,29 @@ extern "C" { #endif -h5_err_t +static inline h5_err_t H5FedGetAdjacencies ( h5_file_t* const f, const h5_loc_id_t entity_id, const h5_int32_t dim, h5_loc_idlist_t** list - ); + ) { + H5_API_ENTER4 (h5_err_t, + "f=0x%p, entity_id=%lld, dim=%d, list=0x%p", + f, (long long)entity_id, dim, list); + H5_API_RETURN (h5t_get_adjacencies (f, entity_id, dim, list)); +} -h5_err_t +static inline h5_err_t H5FedReleaseListOfAdjacencies ( - h5_file_t * const f, - h5_loc_idlist_t **list - ); + h5_file_t* const f, + h5_loc_idlist_t** list + ) { + H5_API_ENTER2 (h5_err_t, + "f=0x%p, list=0x%p", + f, list); + H5_API_RETURN (h5t_release_list_of_adjacencies (f, list)); +} #ifdef __cplusplus } diff --git a/src/include/H5Fed_inquiry.h b/src/include/H5Fed_inquiry.h index 9db9e33..c7ea021 100644 --- a/src/include/H5Fed_inquiry.h +++ b/src/include/H5Fed_inquiry.h @@ -46,14 +46,137 @@ H5FedGetNumTriangleMeshes ( H5_API_RETURN (h5t_get_num_trimeshes (f)); } -h5_ssize_t H5FedGetNumLevels ( h5_file_t * const f ); -h5t_lvl_idx_t H5FedGetLevel ( h5_file_t * const f ); -h5_ssize_t H5FedGetNumVertices ( h5_file_t * const f ); -h5_ssize_t H5FedGetNumVerticesCnode ( h5_file_t * const f, const int cnode ); -h5_ssize_t H5FedGetNumVerticesTotal ( h5_file_t * const f ); -h5_ssize_t H5FedGetNumElements ( h5_file_t * const f ); -h5_ssize_t H5FedGetNumElementsCnode ( h5_file_t * const f, const int cnode ); -h5_ssize_t H5FedGetNumElementsTotal ( h5_file_t * const f ); +/*! + Get the number of hierarchical mesh levels. + + \param[in] f File handle + + \return Number of hierarchical mesh levels or error code. + */ +static inline h5_ssize_t +H5FedGetNumLevels ( + h5_file_t* const f + ) { + H5_API_ENTER1 (h5_ssize_t, "f=0x%p", f); + H5_API_RETURN (h5t_get_num_leaf_levels (f)); +} + +/*! + Get current mesh levels. + + \param[in] f File handle + + \return ID of current mesh levels or error code. + */ +static inline h5t_lvl_idx_t +H5FedGetLevel ( + h5_file_t* const f + ) { + H5_API_ENTER1 (h5t_lvl_idx_t, "f=0x%p", f); + H5_API_RETURN (h5t_get_level (f)); +} + +/*! + Returns the number of vertices used for defining the (sub-)mesh + at current level on this compute node. + + \param[in] f file handle + + \return Number of vertices or error code. +*/ +static inline h5_ssize_t +H5FedGetNumVertices ( + h5_file_t* const f /*!< file handle */ + ) { + H5_API_ENTER1 (h5_ssize_t, "f=0x%p", f); + H5_API_RETURN (h5t_get_num_vertices (f, -1)); +} + +/*! + Returns the number of vertices used for defining the (sub-)mesh + at current level on compute node \c cnode. + + \param[in] f file handle + \param[in] cnode compute node + + \return Number of vertices or error code. +*/ +static inline h5_ssize_t +H5FedGetNumVerticesCnode ( + h5_file_t* const f, + const int cnode + ) { + H5_API_ENTER2 (h5_ssize_t, "f=0x%p, cnode=%d", f, cnode); + H5_API_RETURN (h5t_get_num_vertices (f, cnode)); +} + +/*! + Returns the number of vertices used for defining the (sub-)mesh + at current level overl all compute nodes. + + \param[in] f file handle + + \return Total number of vertices or error code. +*/ +static inline h5_ssize_t +H5FedGetNumVerticesTotal ( + h5_file_t* const f + ) { + H5_API_ENTER1 (h5_ssize_t, "f=0x%p", f); + H5_API_RETURN (h5t_get_num_vertices (f, -1)); +} + +/*! + Returns the number of elements present in the (sub-)mesh + at current level on this compute node. + + \param[in] f file handle + + \return Number of elements or error code. +*/ +static inline h5_ssize_t +H5FedGetNumElements ( + h5_file_t* const f + ) { + H5_API_ENTER1 (h5_ssize_t, "f=0x%p", f); + // MLH: can't use field from opaque h5_file_t! + //h5_ssize_t num = h5t_get_num_elems (f, f->myproc); + H5_API_RETURN (h5t_get_num_elems (f, -1)); +} + +/*! + Returns the number of elements present in the (sub-)mesh + at current level on compute node \c cnode. + + \param[in] f file handle + \param[in] cnode Compute node + + \return Number of elements or error code. +*/ +static inline h5_ssize_t +H5FedGetNumElementsCnode ( + h5_file_t* const f, + const int cnode + ) { + H5_API_ENTER2 (h5_ssize_t, "f=0x%p, cnode=%d", f, cnode); + H5_API_RETURN (h5t_get_num_elems (f, cnode)); +} + +/*! + Returns the number of elements present in the mesh + at current level over all compute nodes. + + \param[in] f File handle. + + \return Number of elements or error code. +*/ +static inline h5_ssize_t +H5FedGetNumElementsTotal ( + h5_file_t* const f + ) { + H5_API_ENTER1 (h5_ssize_t, "f=0x%p", f); + H5_API_RETURN (h5t_get_num_elems (f, -1)); +} #ifdef __cplusplus } diff --git a/src/include/H5Fed_retrieve.h b/src/include/H5Fed_retrieve.h index f19ea84..541cdfb 100644 --- a/src/include/H5Fed_retrieve.h +++ b/src/include/H5Fed_retrieve.h @@ -19,73 +19,162 @@ extern "C" { #endif -h5t_iterator_t* + +/*! + Begin traverse over all entities on this compute node. + Initialize internal data structures. + + \remark + Entities might be on processor boundaries! Therefore the same entity might be + processed on several compute nodes. + + \param[in] f file handle + \param[in] codim co-dimension of entity to traverse + + \return H5_SUCCESS or error code +*/ + +static inline h5t_iterator_p H5FedBeginTraverseEntities ( h5_file_t* const f, - int codim - ); -h5t_iterator_t* + const int codim + ) { + H5_API_ENTER2 (h5t_iterator_p, "f=0x%p, codim=%d", f, codim); + h5t_iterator_p iter; + TRY2 (iter = h5_calloc (1, sizeof (*iter))); + TRY2 (h5t_init_leaf_iterator (f, iter, codim)); + H5_API_RETURN (iter); +} + +static inline h5t_iterator_p H5FedBeginTraverseBoundaryFaces ( h5_file_t* const f, - int codim - ); -h5_loc_id_t + const int codim + ) { + H5_API_ENTER2 (h5t_iterator_p, "f=0x%p, codim=%d", f, codim); + h5t_iterator_p iter; + TRY2 (iter = h5_calloc (1, sizeof (*iter))); + TRY2 (h5t_init_boundary_face_iterator (f, iter, codim)); + H5_API_RETURN (iter); +} + +/*! + Get next local entity ID. + + \param[in] f file handle + \param[in/out] iter iterator + + \return Local entity ID + \return -1, if done + \return error code on error + */ +static inline h5_loc_id_t H5FedTraverseEntities ( h5_file_t* const f, h5t_iterator_t* iter - ); -h5_err_t + ) { + H5_API_ENTER2 (h5_loc_id_t, "f=0x%p, iter=0x%p", f, iter); + H5_API_RETURN (h5t_iterate_entities (f, iter)); +} + +/*! + End of traversing. Release internal data structures. + + \param[in] f File handle + + \return H5_SUCCESS or error code + + */ +static inline h5_err_t H5FedEndTraverseEntities ( h5_file_t* const f, h5t_iterator_t* iter - ); -h5_err_t + ) { + H5_API_ENTER2 (h5_err_t, "f=0x%p, iter=0x%p", f, iter); + H5_API_RETURN (h5t_release_entity_iterator (f, iter)); +} + + +/*! + Get coordinates of vertex given by local index + + \param[in] f file handle + \param[in] vertex_idx local index of vertex + \param[out] P 3-dimensional coordinates + + \return H5_SUCCESS or error code + */ +static inline h5_err_t H5FedGetVertexCoordsByIndex ( h5_file_t* const f, h5_loc_idx_t vertex_index, h5_float64_t P[3] - ); -h5_err_t + ) { + H5_API_ENTER3 (h5_err_t, + "f=0x%p, vertex_index=%lld, P=0x%p", + f, (long long)vertex_index, P); + H5_API_RETURN (h5t_get_vertex_coords_by_index (f, vertex_index, P)); +} + +static inline h5_err_t H5FedGetVertexCoordsByID ( h5_file_t* const f, h5_loc_id_t vertex_id, h5_float64_t P[3] - ); + ) { + H5_API_ENTER3 (h5_err_t, + "f=0x%p, vertex_id=%lld, P=0x%p", + f, (long long)vertex_id, P); + H5_API_RETURN (h5t_get_vertex_coords_by_id (f, vertex_id, P)); +} -h5_err_t +static inline h5_err_t H5FedGetVertexIndicesOfEdge ( h5_file_t* const f, h5_loc_id_t entity_id, - h5_loc_idx_t* const vertex_indices - ); + h5_loc_idx_t* vertex_indices + ) { + H5_API_ENTER3 (h5_err_t, + "f=0x%p, entity_id=%lld, vertex_indices=0x%p", + f, (long long)entity_id, vertex_indices); + H5_API_RETURN (h5t_get_vertex_indices_of_edge (f, entity_id, vertex_indices)); +} -h5_err_t +static inline h5_err_t H5FedGetVertexIndicesOfTriangle ( h5_file_t* const f, h5_loc_id_t entity_id, - h5_loc_idx_t* const vertex_indices - ); + h5_loc_idx_t* vertex_indices + ) { + H5_API_ENTER3 (h5_err_t, + "f=0x%p, entity_id=%lld, vertex_indices=0x%p", + f, (long long)entity_id, vertex_indices); + H5_API_RETURN (h5t_get_vertex_indices_of_triangle (f, entity_id, 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 +static inline h5_err_t H5FedGetVertexIndicesOfTet ( h5_file_t* const f, h5_loc_id_t entity_id, - h5_loc_idx_t* const vertex_indices - ); + h5_loc_idx_t* vertex_indices + ) { + H5_API_ENTER3 (h5_err_t, + "f=0x%p, entity_id=%lld, vertex_indices=0x%p", + f, (long long)entity_id, vertex_indices); + H5_API_RETURN (h5t_get_vertex_indices_of_tet (f, entity_id, vertex_indices)); +} -h5_err_t +static inline h5_err_t H5FedGetVertexIndicesOfEntity ( h5_file_t* const f, h5_loc_id_t entity_id, - h5_loc_idx_t* const vertex_indices - ); + h5_loc_idx_t* vertex_indices + ) { + H5_API_ENTER3 (h5_err_t, + "f=0x%p, entity_id=%lld, vertex_indices=0x%p", + f, (long long)entity_id, vertex_indices); + H5_API_RETURN (h5t_get_vertex_indices_of_entity (f, entity_id, vertex_indices)); +} #ifdef __cplusplus } diff --git a/src/include/H5Fed_store.h b/src/include/H5Fed_store.h index c7073a9..b1e423c 100644 --- a/src/include/H5Fed_store.h +++ b/src/include/H5Fed_store.h @@ -39,62 +39,154 @@ H5FedAddTriangleMesh ( H5_API_RETURN (h5t_add_triangle_mesh (f)); } -h5t_lvl_idx_t +/*! + \ingroup h5fed_c_api + + Add a new level with \c num_elems elements. The number of elements must be the + real number of elements to add the level. If you want to refine \c n tetrahedra + \c n*8 elements must be added. + + \param[in] f File handle. + \param[in] num_elems_to_refine Number of elements which will be refined. + + \return ID of new level. + + \note + values for f->t.num_levels: + \c -1 unknown: after opening the file. This is equivalent to + "topological data has not been initialized". + \c 0 no levels: HDF5 group for meshes may already exist but must not! + \c > 0 number of mesh levels + +*/ +static inline h5t_lvl_idx_t H5FedAddLevel ( - h5_file_t * const f - ); + h5_file_t* const f + ) { + H5_API_ENTER1 (h5t_lvl_idx_t, "f=0x%p", f); + H5_API_RETURN (h5t_add_level (f)); +} -h5_err_t +static inline h5_err_t H5FedBeginStoreVertices ( - h5_file_t * const f, - const h5_size_t num - ); - -h5_loc_idx_t -H5FedStoreVertex ( - h5_file_t * const f, - const h5_glb_idx_t id, - const h5_float64_t P[3] - ); - -h5_err_t -H5FedEndStoreVertices ( - h5_file_t * const f - ); - -h5_err_t -H5FedBeginStoreElements ( - h5_file_t * const f, - const h5_size_t num - ); - - -h5_loc_idx_t -H5FedStoreElement ( h5_file_t* const f, - const h5_loc_idx_t local_vids[] - ); + const h5_size_t num + ) { + H5_API_ENTER2 (h5_err_t, + "f=0x%p, num=%llu", + f, (long long unsigned)num); + H5_API_RETURN (h5t_begin_store_vertices (f, num)); +} -h5_err_t +/*! + \ingroup h5fed_c_api + + Stores the the coordinates of a specific vertex at level \c level + with id \c vertex_id of the tetrahedral mesh. + + \return local vertex id on success + \return errno on error +*/ +static inline h5_loc_idx_t +H5FedStoreVertex ( + h5_file_t* const f, /*!< file handle */ + const h5_glb_id_t vertex_id, /*!< id from mesher or -1 */ + const h5_float64_t P[3] /*!< coordinates */ + ) { + H5_API_ENTER3 (h5_loc_idx_t, + "f=0x%p, vertex_id=%lld, P=0x%p", + f, (long long)vertex_id, P); + if (h5t_get_level (f) != 0) { + H5_API_LEAVE ( + h5_error ( + H5_ERR_INVAL, + "Vertices can be added to level 0 only!")); + } + H5_API_RETURN (h5t_store_vertex (f, vertex_id, P)); +} + +static inline h5_err_t +H5FedEndStoreVertices ( + h5_file_t* const f + ) { + H5_API_ENTER1 (h5_err_t, "f=0x%p", f); + H5_API_RETURN (h5t_end_store_vertices (f)); +} + +static inline h5_err_t +H5FedBeginStoreElements ( + h5_file_t* const f, + const h5_size_t num + ) { + H5_API_ENTER2 (h5_err_t, + "f=0x%p, num=%llu", + f, (long long unsigned)num); + H5_API_RETURN (h5t_begin_store_elems (f, num)); +} + +/*! + \ingroup h5fed_c_api + + Stores the 4-tuple, that contains the specific indices describing + a tetrahedron with id \c tet_id at level \c level of the tetrahedral + mesh. + + Errors: + * current level not yet defined + * to many tets stored on level + + \return local tetrahedron id + \return \c errno on error +*/ +static inline h5_loc_idx_t +H5FedStoreElement ( + h5_file_t* const f, /*!< file handle */ + const h5_loc_idx_t local_vids[] /*!< tuple with vertex id's */ + ) { + H5_API_ENTER2 (h5_loc_idx_t, "f=0x%p, local_vids=0x%p", f, local_vids); + if (h5t_get_level (f) != 0) { + H5_API_LEAVE ( + h5_error ( + H5_ERR_INVAL, + "Elements can be added to level 0 only!")); + } + H5_API_RETURN (h5t_store_elem (f, -1, local_vids)); +} + +static inline h5_err_t H5FedEndStoreElements ( - h5_file_t * const f - ); + h5_file_t* const f + ) { + H5_API_ENTER1 (h5_err_t, "f=0x%p", f); + H5_API_RETURN (h5t_end_store_elems (f)); +} -h5_err_t +static inline h5_err_t H5FedBeginRefineElements ( - h5_file_t * const f - ); + h5_file_t* const f + ) { + H5_API_ENTER1 (h5_err_t, "f=0x%p", f); + H5_API_RETURN (h5t_begin_refine_elems (f)); +} -h5_loc_idx_t +static inline h5_loc_idx_t H5FedRefineElement ( - h5_file_t * const f, - const h5_loc_idx_t elem_idx - ); + h5_file_t* const f, /*!< file handle */ + const h5_loc_id_t local_eid /*!< local element id */ + ) { + H5_API_ENTER2 (h5_loc_idx_t, + "f=0x%p, local_eid=%lld", + f, (long long)local_eid); + H5_API_RETURN (h5t_mark_entity (f, local_eid)); +} -h5_err_t +static inline h5_err_t H5FedEndRefineElements ( - h5_file_t * const f - ); + h5_file_t* const f + ) { + H5_API_ENTER1 (h5_err_t, "f=0x%p", f); + H5_API_RETURN (h5t_end_refine_elems (f)); +} #ifdef __cplusplus } diff --git a/src/include/H5Fed_tags.h b/src/include/H5Fed_tags.h index ea59e6a..e858c09 100644 --- a/src/include/H5Fed_tags.h +++ b/src/include/H5Fed_tags.h @@ -5,49 +5,144 @@ extern "C" { #endif -h5_err_t +/*! + Add a tagset to the current mesh. + + \param[in] f file handle + \param[in] name name of tagset + \param[in] type data type of tagset + + \return H5_SUCCESS or error code + */ +static inline h5_err_t H5FedAddMTagset ( h5_file_t* const f, char* name, h5_id_t type - ); -h5_err_t + ) { + H5_API_ENTER3 (h5_err_t, "f=0x%p, name=\"%s\", type=%lld", + f, name, (long long)type); + H5_API_RETURN (h5t_add_mtagset (f, name, type)); +} + +/*! + Remove a tagset from the current mesh. + + \param[in] f file handle + \param[in] name name of tagset to remove + + \return H5_SUCCESS or error code + */ +static inline h5_err_t H5FedRemoveMTagset ( h5_file_t* const f, char name[] - ); -h5_ssize_t + ) { + H5_API_ENTER2 (h5_err_t, "f=0x%p, name=\"%s\"", f, name); + H5_API_RETURN (h5t_remove_mtagset (f, name)); +} + +/*! + Get available tagsets in current mesh. + + \param[in] f file handle + \param[out] names names of available tagsets + + \return Number of tagsets or error code + */ +static inline h5_ssize_t H5FedGetMTagsets ( h5_file_t* const f, char** names[] - ); -h5_id_t + ) { + H5_API_ENTER2 (h5_ssize_t, "f=0x%p, names=0x%p", f, names); + H5_API_RETURN (h5t_get_mtagsets (f, names)); +} + +/*! + Get type of tagset in current mesh. + + \param[in] f file handle + \param[in] name name of tagset + + \return H5_SUCCESS or error code + */ +static inline h5_id_t H5FedGetTypeOfMTagset ( h5_file_t* const f, char name[] - ); -h5_err_t + ) { + H5_API_ENTER2 (h5_err_t, "f=0x%p, name=\"%s\"", f, name); + H5_API_RETURN (h5t_get_mtagset_type_by_name (f, name)); +} + +/*! + Set tag for entity in current mesh. + + \param[in] f file handle + \param[in] name names of tagset + \param[in] id id of entity + \param[in] dim dimension of value + \param[in] val tag value + + \return H5_SUCCESS or error code + */ +static inline h5_err_t H5FedSetMTag ( h5_file_t* const f, char name[], - h5_loc_id_t entity_id, - const size_t dims, - void* val - ); -h5_err_t + h5_loc_id_t id, + const size_t dim, + void* buffer + ) { + H5_API_ENTER5 (h5_err_t, + "f=0x%p, name=\"%s\", id=%lld, dim=%lld, val=0x%p", + f, name, (long long)id, (long long)dim, buffer); + H5_API_RETURN (h5t_set_mtag_by_name (f, name, id, dim, buffer)); +} + +/*! + Set tag for entity in current mesh. + + \param[in] f file handle + \param[in] name names of tagset + \param[in] id id of entity + \param[out] dim dimension of value + \param[out] val tag value + + \return H5_SUCCESS or error code + */ +static inline h5_err_t H5FedGetMTag ( h5_file_t* const f, const char name[], - const h5_loc_id_t id, - size_t* dims, - void* val - ); -h5_err_t + const h5_loc_id_t id, + size_t* dim, + void* buffer + ) { + H5_API_ENTER5 (h5_err_t, + "f=0x%p, name=\"%s\", id=%lld, dim=0x%p, val=0x%p", + f, name, (long long)id, dim, buffer); + H5_API_RETURN (h5t_get_mtag_by_name (f, name, id, dim, buffer)); +} + +/*! + Remove tag for entity in current mesh. + + \param[in] f file handle + \param[in] name names of tagset + \param[in] id id of entity +*/ +static inline h5_err_t H5FedRemoveMTag ( h5_file_t* const f, const char name[], const h5_loc_id_t id - ); + ) { + H5_API_ENTER3 (h5_err_t, "f=0x%p, name=\"%s\", id=%lld", + f, name, (long long)id); + H5_API_RETURN (h5t_remove_mtag_by_name (f, name, id)); +} #ifdef __cplusplus } diff --git a/src/include/h5core/h5_core.h b/src/include/h5core/h5_core.h index 87f412d..dcc02b6 100644 --- a/src/include/h5core/h5_core.h +++ b/src/include/h5core/h5_core.h @@ -180,13 +180,6 @@ done: \ goto done; \ } -#define TRY3( expr, ret_val ) \ - if ((int64_t)(ptrdiff_t)(expr) <= (int64_t)H5_ERR) { \ - ret_value = ret_val; \ - goto done; \ - } -#define ON_ERROR - #ifdef __cplusplus } #endif