From a7b96218504661c4608f84a4617adfd4f0ad7460 Mon Sep 17 00:00:00 2001 From: Achim Gsell Date: Fri, 20 May 2011 13:01:14 +0000 Subject: [PATCH] h5t_openclose* renamed to h5t_model*, some functions moved from file to files --- .gitattributes | 8 +- src/h5core/Makefile.am | 10 +- src/h5core/h5t_core_private.h | 2 +- src/h5core/{h5t_openclose.c => h5t_model.c} | 175 ------------------ ...penclose_private.h => h5t_model_private.h} | 4 +- src/h5core/h5t_model_tetm.c | 103 +++++++++++ src/h5core/h5t_model_trim.c | 102 ++++++++++ src/h5core/h5t_store.c | 29 --- src/include/h5core/h5t_core.h | 2 +- .../h5core/{h5t_openclose.h => h5t_model.h} | 14 +- src/include/h5core/h5t_storemesh.h | 10 - 11 files changed, 231 insertions(+), 228 deletions(-) rename src/h5core/{h5t_openclose.c => h5t_model.c} (74%) rename src/h5core/{h5t_openclose_private.h => h5t_model_private.h} (89%) create mode 100644 src/h5core/h5t_model_tetm.c create mode 100644 src/h5core/h5t_model_trim.c rename src/include/h5core/{h5t_openclose.h => h5t_model.h} (64%) diff --git a/.gitattributes b/.gitattributes index 33c0fa5..16d4b8f 100644 --- a/.gitattributes +++ b/.gitattributes @@ -444,8 +444,10 @@ src/h5core/h5t_hsearch_private.h -text src/h5core/h5t_inquiry.c -text src/h5core/h5t_map.c -text src/h5core/h5t_map_private.h -text -src/h5core/h5t_openclose.c -text -src/h5core/h5t_openclose_private.h -text +src/h5core/h5t_model.c -text +src/h5core/h5t_model_private.h -text +src/h5core/h5t_model_tetm.c -text +src/h5core/h5t_model_trim.c -text src/h5core/h5t_readwrite.c -text src/h5core/h5t_readwrite_private.h -text src/h5core/h5t_readwrite_tetm.c -text @@ -500,7 +502,7 @@ src/include/h5core/h5t_adjacencies.h -text src/include/h5core/h5t_core.h -text src/include/h5core/h5t_inquiry.h -text src/include/h5core/h5t_map.h -text -src/include/h5core/h5t_openclose.h -text +src/include/h5core/h5t_model.h -text src/include/h5core/h5t_readwrite.h -text src/include/h5core/h5t_ref_elements.h -text src/include/h5core/h5t_retrieve.h -text diff --git a/src/h5core/Makefile.am b/src/h5core/Makefile.am index cf946bb..0c81a6b 100644 --- a/src/h5core/Makefile.am +++ b/src/h5core/Makefile.am @@ -26,7 +26,7 @@ EXTRA_HEADERS = \ ../include/h5core/h5t_core.h \ ../include/h5core/h5t_inquiry.h \ ../include/h5core/h5t_map.h \ - ../include/h5core/h5t_openclose.h \ + ../include/h5core/h5t_model.h \ ../include/h5core/h5t_readwrite.h \ ../include/h5core/h5t_ref_elements.h \ ../include/h5core/h5t_retrieve.h \ @@ -50,12 +50,11 @@ EXTRA_HEADERS = \ h5b_types_private.h \ h5t_access_private.h \ h5t_adjacencies_private.h \ - h5t_consts_private.h \ h5t_core_private.h \ h5t_errorhandling_private.h \ h5t_hsearch_private.h \ h5t_map_private.h \ - h5t_openclose_private.h \ + h5t_model_private.h \ h5t_readwrite_private.h \ h5t_ref_elements_private.h \ h5t_retrieve_private.h \ @@ -101,12 +100,13 @@ ___lib_libH5hut_a_SOURCES = \ h5t_adjacencies.c \ h5t_adjacencies_tetm.c \ h5t_adjacencies_trim.c \ - h5t_consts.c \ h5t_errorhandling.c \ h5t_hsearch.c \ h5t_inquiry.c \ h5t_map.c \ - h5t_openclose.c \ + h5t_model.c \ + h5t_model_tetm.c \ + h5t_model_trim.c \ h5t_readwrite.c \ h5t_readwrite_trim.c \ h5t_readwrite_tetm.c \ diff --git a/src/h5core/h5t_core_private.h b/src/h5core/h5t_core_private.h index 71e3f74..530c46e 100644 --- a/src/h5core/h5t_core_private.h +++ b/src/h5core/h5t_core_private.h @@ -13,7 +13,7 @@ #include "h5t_adjacencies_private.h" #include "h5t_hsearch_private.h" #include "h5t_map_private.h" -#include "h5t_openclose_private.h" +#include "h5t_model_private.h" #include "h5t_ref_elements_private.h" #include "h5t_readwrite_private.h" #include "h5t_retrieve_private.h" diff --git a/src/h5core/h5t_openclose.c b/src/h5core/h5t_model.c similarity index 74% rename from src/h5core/h5t_openclose.c rename to src/h5core/h5t_model.c index d1f2272..e6fea34 100644 --- a/src/h5core/h5t_openclose.c +++ b/src/h5core/h5t_model.c @@ -3,22 +3,6 @@ #include "h5core/h5_core.h" #include "h5_core_private.h" -static struct h5t_methods tet_funcs = { - &h5tpriv_read_tetm_methods, - &h5tpriv_tetm_store_methods, - &h5tpriv_tetm_retrieve_methods, - &h5tpriv_access_tetm_methods, - &h5tpriv_tetm_adjacency_methods -}; - -static struct h5t_methods tri_funcs = { - &h5tpriv_read_trim_methods, - &h5tpriv_trim_store_methods, - &h5tpriv_trim_retrieve_methods, - &h5tpriv_access_trim_methods, - &h5tpriv_trim_adjacency_methods -}; - /* create several HDF5 types */ @@ -362,169 +346,10 @@ h5tpriv_close_step ( H5_PRIV_API_RETURN (H5_SUCCESS); } - -static inline h5_err_t -open_topo_group ( - h5_file_t * const f - ) { - h5t_fdata_t* t = f->t; - if (t->topo_gid == 0 || t->topo_gid == -1) { - return (t->topo_gid = h5priv_open_group (f, f->root_gid, H5T_CONTAINER_GRPNAME)); - } - return (t->topo_gid); -} - -static inline h5_err_t -open_tetmeshes_group ( - h5_file_t* const f - ) { - H5_PRIV_FUNC_ENTER (h5_err_t); - h5t_fdata_t* t = f->t; - - if (t->topo_gid < 0) { - TRY (open_topo_group (f)); - } - TRY (t->meshes_gid = h5priv_open_group ( - f, - t->topo_gid, - TETRAHEDRAL_MESHES_GRPNAME)); - t->mesh_type = H5_OID_TETRAHEDRON; - H5_PRIV_FUNC_RETURN (H5_SUCCESS); -} - -static inline h5_err_t -open_trimeshes_group ( - h5_file_t* const f - ) { - H5_PRIV_FUNC_ENTER (h5_err_t); - h5t_fdata_t* t = f->t; - - if (t->topo_gid < 0) { - TRY (open_topo_group (f)); - } - TRY (t->meshes_gid = h5priv_open_group ( - f, - t->topo_gid, - TRIANGLE_MESHES_GRPNAME)); - t->mesh_type = H5_OID_TRIANGLE; - H5_PRIV_FUNC_RETURN (H5_SUCCESS); -} - /* Open HDF5 group with specific mesh */ -static inline h5_err_t -open_tetmesh_group ( - h5_file_t* const f, - const h5_id_t id - ) { - H5_PRIV_FUNC_ENTER (h5_err_t); - h5t_fdata_t* t = f->t; - - if (t->meshes_gid < 0) { - TRY (open_tetmeshes_group (f)); - } - snprintf (t->mesh_name, sizeof (t->mesh_name), "%lld", (long long)id); - - TRY (t->mesh_gid = h5priv_open_group ( - f, - t->meshes_gid, - t->mesh_name)); - t->cur_mesh = id; - H5_PRIV_API_RETURN (H5_SUCCESS); -} - -static inline h5_err_t -open_trimesh_group ( - h5_file_t* const f, - const h5_id_t id - ) { - H5_PRIV_FUNC_ENTER (h5_err_t); - h5t_fdata_t* t = f->t; - - if (t->meshes_gid < 0) { - TRY (open_trimeshes_group (f)); - } - snprintf (t->mesh_name, sizeof (t->mesh_name), "%lld", (long long)id); - - TRY (t->mesh_gid = h5priv_open_group ( - f, - t->meshes_gid, - t->mesh_name)); - t->cur_mesh = id; - H5_PRIV_API_RETURN (H5_SUCCESS); -} - -/* - If the value of parameter \c id is \c -1, a new mesh will be appended. -*/ -h5_err_t -h5t_open_tetrahedral_mesh ( - h5_file_t* const f, - h5_id_t id - ) { - H5_CORE_API_ENTER2 (h5_err_t, "f=0x%p, id=%lld", f, (long long)id); - h5t_fdata_t* t = f->t; - - TRY (h5t_close_mesh (f)); - - if (t->num_meshes < 0) { - h5_size_t result = h5t_get_num_tetmeshes (f); - t->num_meshes = (result > 0 ? result : 0); - } - if ((id < -1) || (id >= t->num_meshes)) { - H5_CORE_API_LEAVE (HANDLE_H5_OUT_OF_RANGE_ERR ("mesh", id)); - } - t->dsinfo_elems.type_id = t->dtypes.h5_tet_t; - t->methods = tet_funcs; - t->ref_elem = &h5t_tet_ref_elem; - TRY (open_tetmesh_group (f, id)); - - if (id == -1) { // append new - id = t->num_meshes; - t->num_meshes++; - t->mesh_changed = id; - t->num_leaf_levels = 0; - } else { // read existing - TRY (h5tpriv_read_mesh (f)); - } - H5_CORE_API_RETURN (H5_SUCCESS); -} - -h5_err_t -h5t_open_triangle_mesh ( - h5_file_t* const f, - h5_id_t id - ) { - H5_CORE_API_ENTER2 (h5_err_t, "f=0x%p, id=%lld", f, (long long)id); - h5t_fdata_t* t = f->t; - - TRY (h5t_close_mesh (f)); - - if (t->num_meshes < 0) { - h5_size_t result = h5t_get_num_trimeshes (f); - t->num_meshes = (result > 0 ? result : 0); - } - if ((id < -1) || (id >= t->num_meshes)) { - H5_CORE_API_LEAVE (HANDLE_H5_OUT_OF_RANGE_ERR ("mesh", id)); - } - t->dsinfo_elems.type_id = t->dtypes.h5_triangle_t; - t->methods = tri_funcs; - t->ref_elem = &h5t_tri_ref_elem; - TRY (open_trimesh_group (f, id)); - - if (id == -1) { // append new - id = t->num_meshes; - t->num_meshes++; - t->mesh_changed = id; - t->num_leaf_levels = 0; - } else { // read existing - TRY (h5tpriv_read_mesh (f)); - } - H5_CORE_API_RETURN (H5_SUCCESS); -} - static h5_err_t release_elems ( h5_file_t* const f diff --git a/src/h5core/h5t_openclose_private.h b/src/h5core/h5t_model_private.h similarity index 89% rename from src/h5core/h5t_openclose_private.h rename to src/h5core/h5t_model_private.h index 935b495..e7b2ccb 100644 --- a/src/h5core/h5t_openclose_private.h +++ b/src/h5core/h5t_model_private.h @@ -1,5 +1,5 @@ -#ifndef __H5T_OPENCLOSE_PRIVATE_H -#define __H5T_OPENCLOSE_PRIVATE_H +#ifndef __H5T_MODEL_PRIVATE_H +#define __H5T_MODEL_PRIVATE_H h5_err_t h5tpriv_open_file ( diff --git a/src/h5core/h5t_model_tetm.c b/src/h5core/h5t_model_tetm.c new file mode 100644 index 0000000..970e7a3 --- /dev/null +++ b/src/h5core/h5t_model_tetm.c @@ -0,0 +1,103 @@ +#include "h5core/h5_core.h" +#include "h5_core_private.h" + +static struct h5t_methods tet_funcs = { + &h5tpriv_read_tetm_methods, + &h5tpriv_tetm_store_methods, + &h5tpriv_tetm_retrieve_methods, + &h5tpriv_access_tetm_methods, + &h5tpriv_tetm_adjacency_methods +}; + +static inline h5_err_t +open_tetmeshes_group ( + h5_file_t* const f + ) { + H5_PRIV_FUNC_ENTER (h5_err_t); + h5t_fdata_t* t = f->t; + + if (t->topo_gid == 0 || t->topo_gid == -1) { + TRY (t->topo_gid = h5priv_open_group ( + f, f->root_gid, H5T_CONTAINER_GRPNAME)); + } + TRY (t->meshes_gid = h5priv_open_group ( + f, + t->topo_gid, + TETRAHEDRAL_MESHES_GRPNAME)); + t->mesh_type = H5_OID_TETRAHEDRON; + H5_PRIV_FUNC_RETURN (H5_SUCCESS); +} + +static inline h5_err_t +open_tetmesh_group ( + h5_file_t* const f, + const h5_id_t id + ) { + H5_PRIV_FUNC_ENTER (h5_err_t); + h5t_fdata_t* t = f->t; + + if (t->meshes_gid < 0) { + TRY (open_tetmeshes_group (f)); + } + snprintf (t->mesh_name, sizeof (t->mesh_name), "%lld", (long long)id); + + TRY (t->mesh_gid = h5priv_open_group ( + f, + t->meshes_gid, + t->mesh_name)); + t->cur_mesh = id; + H5_PRIV_API_RETURN (H5_SUCCESS); +} + +/* + If the value of parameter \c id is \c -1, a new mesh will be appended. +*/ +h5_err_t +h5t_open_tetrahedral_mesh ( + h5_file_t* const f, + h5_id_t id + ) { + H5_CORE_API_ENTER2 (h5_err_t, "f=0x%p, id=%lld", f, (long long)id); + h5t_fdata_t* t = f->t; + + TRY (h5t_close_mesh (f)); + + if (t->num_meshes < 0) { + h5_size_t result = h5t_get_num_tetmeshes (f); + t->num_meshes = (result > 0 ? result : 0); + } + if ((id < -1) || (id >= t->num_meshes)) { + H5_CORE_API_LEAVE (HANDLE_H5_OUT_OF_RANGE_ERR ("mesh", id)); + } + t->dsinfo_elems.type_id = t->dtypes.h5_tet_t; + t->methods = tet_funcs; + t->ref_elem = &h5t_tet_ref_elem; + TRY (open_tetmesh_group (f, id)); + + if (id == -1) { // append new + id = t->num_meshes; + t->num_meshes++; + t->mesh_changed = id; + t->num_leaf_levels = 0; + } else { // read existing + TRY (h5tpriv_read_mesh (f)); + } + H5_CORE_API_RETURN (H5_SUCCESS); +} + +/*! + Add new mesh + + \return mesh id +*/ +h5_id_t +h5t_add_tetrahedral_mesh ( + h5_file_t* const f + ) { + H5_CORE_API_ENTER1 (h5_id_t, "f=0x%p", f); + h5_id_t mesh_id = 0; + TRY (mesh_id = h5t_open_tetrahedral_mesh (f, -1)); + TRY (h5t_add_level (f)); + f->t->mesh_changed = 1; + H5_CORE_API_RETURN (mesh_id); +} diff --git a/src/h5core/h5t_model_trim.c b/src/h5core/h5t_model_trim.c new file mode 100644 index 0000000..dbd3c20 --- /dev/null +++ b/src/h5core/h5t_model_trim.c @@ -0,0 +1,102 @@ +#include "h5core/h5_core.h" +#include "h5_core_private.h" + +static struct h5t_methods tri_funcs = { + &h5tpriv_read_trim_methods, + &h5tpriv_trim_store_methods, + &h5tpriv_trim_retrieve_methods, + &h5tpriv_access_trim_methods, + &h5tpriv_trim_adjacency_methods +}; + + +static inline h5_err_t +open_trimeshes_group ( + h5_file_t* const f + ) { + H5_PRIV_FUNC_ENTER (h5_err_t); + h5t_fdata_t* t = f->t; + + if (t->topo_gid < 0) { + TRY (open_topo_group (f)); + } + TRY (t->meshes_gid = h5priv_open_group ( + f, + t->topo_gid, + TRIANGLE_MESHES_GRPNAME)); + t->mesh_type = H5_OID_TRIANGLE; + H5_PRIV_FUNC_RETURN (H5_SUCCESS); +} + +static inline h5_err_t +open_trimesh_group ( + h5_file_t* const f, + const h5_id_t id + ) { + H5_PRIV_FUNC_ENTER (h5_err_t); + h5t_fdata_t* t = f->t; + + if (t->topo_gid == 0 || t->topo_gid == -1) { + TRY (t->topo_gid = h5priv_open_group ( + f, f->root_gid, H5T_CONTAINER_GRPNAME)); + } + snprintf (t->mesh_name, sizeof (t->mesh_name), "%lld", (long long)id); + + TRY (t->mesh_gid = h5priv_open_group ( + f, + t->meshes_gid, + t->mesh_name)); + t->cur_mesh = id; + H5_PRIV_API_RETURN (H5_SUCCESS); +} + +h5_err_t +h5t_open_triangle_mesh ( + h5_file_t* const f, + h5_id_t id + ) { + H5_CORE_API_ENTER2 (h5_err_t, "f=0x%p, id=%lld", f, (long long)id); + h5t_fdata_t* t = f->t; + + TRY (h5t_close_mesh (f)); + + if (t->num_meshes < 0) { + h5_size_t result = h5t_get_num_trimeshes (f); + t->num_meshes = (result > 0 ? result : 0); + } + if ((id < -1) || (id >= t->num_meshes)) { + H5_CORE_API_LEAVE (HANDLE_H5_OUT_OF_RANGE_ERR ("mesh", id)); + } + t->dsinfo_elems.type_id = t->dtypes.h5_triangle_t; + t->methods = tri_funcs; + t->ref_elem = &h5t_tri_ref_elem; + TRY (open_trimesh_group (f, id)); + + if (id == -1) { // append new + id = t->num_meshes; + t->num_meshes++; + t->mesh_changed = id; + t->num_leaf_levels = 0; + } else { // read existing + TRY (h5tpriv_read_mesh (f)); + } + H5_CORE_API_RETURN (H5_SUCCESS); +} + + +/*! + Add new mesh + + \return mesh id +*/ +h5_id_t +h5t_add_triangle_mesh ( + h5_file_t* const f + ) { + H5_CORE_API_ENTER1 (h5_id_t, "f=0x%p", f); + h5_id_t mesh_id = 0; + TRY (mesh_id = h5t_open_triangle_mesh (f, -1)); + TRY (h5t_add_level (f)); + f->t->mesh_changed = 1; + H5_CORE_API_RETURN (mesh_id); +} diff --git a/src/h5core/h5t_store.c b/src/h5core/h5t_store.c index f257f9d..39f77b7 100644 --- a/src/h5core/h5t_store.c +++ b/src/h5core/h5t_store.c @@ -3,35 +3,6 @@ #include "h5core/h5_core.h" #include "h5_core_private.h" -/*! - Add new mesh - - \return mesh id -*/ -h5_id_t -h5t_add_tetrahedral_mesh ( - h5_file_t* const f - ) { - H5_CORE_API_ENTER1 (h5_id_t, "f=0x%p", f); - h5_id_t mesh_id = 0; - TRY (mesh_id = h5t_open_tetrahedral_mesh (f, -1)); - TRY (h5t_add_level (f)); - f->t->mesh_changed = 1; - H5_CORE_API_RETURN (mesh_id); -} - -h5_id_t -h5t_add_triangle_mesh ( - h5_file_t* const f - ) { - H5_CORE_API_ENTER1 (h5_id_t, "f=0x%p", f); - h5_id_t mesh_id = 0; - TRY (mesh_id = h5t_open_triangle_mesh (f, -1)); - TRY (h5t_add_level (f)); - f->t->mesh_changed = 1; - H5_CORE_API_RETURN (mesh_id); -} - /* Assign unique global indices to vertices. */ diff --git a/src/include/h5core/h5t_core.h b/src/include/h5core/h5t_core.h index 21d456f..7f63322 100644 --- a/src/include/h5core/h5t_core.h +++ b/src/include/h5core/h5t_core.h @@ -7,7 +7,7 @@ #include "h5t_adjacencies.h" #include "h5t_inquiry.h" #include "h5t_map.h" -#include "h5t_openclose.h" +#include "h5t_model.h" #include "h5t_readwrite.h" #include "h5t_ref_elements.h" #include "h5t_retrieve.h" diff --git a/src/include/h5core/h5t_openclose.h b/src/include/h5core/h5t_model.h similarity index 64% rename from src/include/h5core/h5t_openclose.h rename to src/include/h5core/h5t_model.h index 8cefac1..175a5f9 100644 --- a/src/include/h5core/h5t_openclose.h +++ b/src/include/h5core/h5t_model.h @@ -1,5 +1,5 @@ -#ifndef __H5T_OPENCLOSE_H -#define __H5T_OPENCLOSE_H +#ifndef __H5T_MODEL_H +#define __H5T_MODEL_H h5_err_t h5t_open_tetrahedral_mesh ( h5_file_t * const f, @@ -11,6 +11,16 @@ h5_err_t h5t_open_triangle_mesh ( const h5_id_t id ); +h5_id_t +h5t_add_tetrahedral_mesh ( + h5_file_t * const f + ); + +h5_id_t +h5t_add_triangle_mesh ( + h5_file_t * const f + ); + h5_err_t h5t_set_level ( h5_file_t * const f, const h5t_lvl_idx_t id diff --git a/src/include/h5core/h5t_storemesh.h b/src/include/h5core/h5t_storemesh.h index d96bb98..92c6713 100644 --- a/src/include/h5core/h5t_storemesh.h +++ b/src/include/h5core/h5t_storemesh.h @@ -1,16 +1,6 @@ #ifndef __H5T_STOREMESH_H #define __H5T_STOREMESH_H -h5_id_t -h5t_add_tetrahedral_mesh ( - h5_file_t * const f - ); - -h5_id_t -h5t_add_triangle_mesh ( - h5_file_t * const f - ); - h5t_lvl_idx_t h5t_add_level ( h5_file_t * const f