API changed: now we have explicit function to open/add meshes of specific type

This commit is contained in:
2011-05-20 11:53:49 +00:00
parent 0dbb8f22e3
commit 1a8433681f
18 changed files with 223 additions and 213 deletions
-13
View File
@@ -15,19 +15,6 @@
#include "h5core/h5_core.h"
#include "H5Fed.h"
h5_err_t
H5FedOpenMesh (
h5_file_t* const f,
const h5_id_t mesh_id,
const h5_oid_t mesh_type_id
) {
H5_API_ENTER3 (h5_err_t,
"f=0x%p, mesh_id=%lld, mesh_type_id=%d",
f,
(long long)mesh_id,
mesh_type_id);
H5_API_RETURN (h5t_open_mesh (f, mesh_id, mesh_type_id));
}
h5_err_t
H5FedCloseMesh (
-16
View File
@@ -20,22 +20,6 @@
#include "h5core/h5_core.h"
#include "H5Fed.h"
/*!
Get number of meshes of given type.
\param[in] f File handle
\param[in] type_id Type of mesh we want the number of.
\return Number of meshes of type \c type_id or error code.
*/
h5_ssize_t
H5FedGetNumMeshes (
h5_file_t* const f,
const h5_oid_t type_id
) {
H5_API_ENTER2 (h5_err_t, "f=0x%p, type_id=%u", f, type_id);
H5_API_RETURN (h5t_get_num_meshes (f, type_id));
}
/*!
Get the number of hierarchical mesh levels.
-29
View File
@@ -17,35 +17,6 @@
#include "H5Fed.h"
/*
Depricated! Please use H5FedAddTetrahedralMesh() or H5FedAddTriangleMesh().
*/
h5_id_t
H5FedAddMesh (
h5_file_t* const f,
const h5_oid_t mesh_type_id
) {
H5_API_ENTER2 (h5_id_t, "f=0x%p, mesh_type_id=%u", f, mesh_type_id);
H5_API_RETURN (h5t_add_mesh (f, mesh_type_id));
}
h5_id_t
H5FedAddTetrahedralMesh (
h5_file_t* const f
) {
const h5_oid_t mesh_type_id = H5_TETRAHEDRAL_MESH;
H5_API_ENTER2 (h5_id_t, "f=0x%p, mesh_type_id=%u", f, mesh_type_id);
H5_API_RETURN (h5t_add_mesh (f, mesh_type_id));
}
h5_id_t
H5FedAddTriangleMesh (
h5_file_t* const f
) {
const h5_oid_t mesh_type_id = H5_TRIANGLE_MESH;
H5_API_ENTER2 (h5_id_t, "f=0x%p, mesh_type_id=%u", f, mesh_type_id);
H5_API_RETURN (h5t_add_mesh (f, mesh_type_id));
}
/*!
\ingroup h5fed_c_api
+5 -5
View File
@@ -34,16 +34,16 @@
(long long)idx, type, group_name );
#define HANDLE_H5_OVERFLOW_ERR( otype, max ) \
#define HANDLE_H5_OVERFLOW_ERR( max ) \
h5_error( \
H5_ERR_INVAL, \
"Cannot store more than %lld %s", (long long)max, otype );
"Cannot store more than %lld items", (long long)max );
#define HANDLE_H5_PARENT_ID_ERR( otype, parent_id ) \
#define HANDLE_H5_PARENT_ID_ERR( parent_id ) \
h5_error( \
H5_ERR_INVAL, \
"Impossible parent_id %lld for %s.", \
(long long)parent_id, otype );
"Wrong parent_id %lld.", \
(long long)parent_id );
#define HANDLE_H5_OUT_OF_RANGE_ERR( otype, oid ) \
h5_error( \
+1 -1
View File
@@ -179,7 +179,7 @@ h5priv_insert_idxmap (
if (map->num_items == map->size)
H5_PRIV_API_LEAVE (
HANDLE_H5_OVERFLOW_ERR (
"g2lmap", (long long)map->size));
(long long)map->size));
h5_loc_idx_t i = h5priv_search_idxmap (map, glb_idx);
if (i >= 0) /* global id already in use ? */
-26
View File
@@ -1,30 +1,4 @@
#include "h5core/h5_core.h"
#include "h5_core_private.h"
const char*
h5tpriv_oid_names[] = {
"N.N.",
"vertex",
"edge",
"triangle",
"tetrahedron"
};
const char*
h5tpriv_meshes_grpnames[] = {
"N.N.",
"N.N.",
"N.N.",
"TriangleMeshes",
"TetMeshes"
};
const char*
h5tpriv_map_oid2str (
h5_oid_t oid
) {
if ((oid < 0) || (oid >= sizeof (h5tpriv_oid_names) / sizeof (char*))) {
return "[invalid oid]";
}
return h5tpriv_oid_names[oid];
}
-5
View File
@@ -1,9 +1,4 @@
#ifndef __H5T_CONSTS_PRIVATE_H
#define __H5T_CONSTS_PRIVATE_H
extern const char * h5tpriv_oid_names[];
extern const char * h5tpriv_meshes_grpnames[];
const char *h5tpriv_map_oid2str ( h5_oid_t oid );
#endif
+2 -1
View File
@@ -2,6 +2,8 @@
#define __H5T_CORE_PRIVATE_H
#define H5T_CONTAINER_GRPNAME "Topo"
#define TETRAHEDRAL_MESHES_GRPNAME "TetMeshes"
#define TRIANGLE_MESHES_GRPNAME "TriangleMeshes"
#include "h5t_tags_private.h"
@@ -9,7 +11,6 @@
#include "h5t_access_private.h"
#include "h5t_adjacencies_private.h"
#include "h5t_consts_private.h"
#include "h5t_hsearch_private.h"
#include "h5t_map_private.h"
#include "h5t_openclose_private.h"
+22 -7
View File
@@ -9,13 +9,12 @@
\return Number of meshes of type \c type_id or error code.
*/
h5_ssize_t
h5t_get_num_meshes (
static inline h5_ssize_t
get_num_meshes (
h5_file_t* const f,
const h5_oid_t type_id
const char* grpname
) {
H5_CORE_API_ENTER2 (h5_ssize_t,
"f=0x%p, type_id=%d", f, type_id);
H5_PRIV_FUNC_ENTER (h5_ssize_t);
hid_t topo_gid = -1;
hid_t meshes_gid = -1;
@@ -25,10 +24,10 @@ h5t_get_num_meshes (
TRY (topo_gid = hdf5_open_group (f->root_gid, H5T_CONTAINER_GRPNAME));
TRY (exists = hdf5_link_exists (topo_gid, h5tpriv_meshes_grpnames[type_id]));
TRY (exists = hdf5_link_exists (topo_gid, grpname));
if (!exists) H5_CORE_API_LEAVE (0);
TRY (meshes_gid = hdf5_open_group (topo_gid, h5tpriv_meshes_grpnames[type_id]));
TRY (meshes_gid = hdf5_open_group (topo_gid, grpname));
h5_ssize_t num_meshes;
TRY (num_meshes = hdf5_get_num_groups (meshes_gid));
TRY (hdf5_close_group (meshes_gid) );
@@ -37,6 +36,22 @@ h5t_get_num_meshes (
H5_CORE_API_RETURN (num_meshes);
}
h5_ssize_t
h5t_get_num_tetmeshes (
h5_file_t* const f
) {
H5_CORE_API_ENTER1 (h5_ssize_t, "f=0x%p", f);
H5_CORE_API_RETURN (get_num_meshes (f, TETRAHEDRAL_MESHES_GRPNAME));
}
h5_ssize_t
h5t_get_num_trimeshes (
h5_file_t* const f
) {
H5_CORE_API_ENTER1 (h5_ssize_t, "f=0x%p", f);
H5_CORE_API_RETURN (get_num_meshes (f, TRIANGLE_MESHES_GRPNAME));
}
/*!
Get the number of hierarchical mesh levels for the current mesh.
+98 -52
View File
@@ -363,55 +363,88 @@ h5tpriv_close_step (
}
h5_err_t
h5tpriv_open_topo_group (
static inline h5_err_t
open_topo_group (
h5_file_t * const f
) {
H5_PRIV_API_ENTER1 (h5_err_t, "f=0x%p", f);
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));
return (t->topo_gid = h5priv_open_group (f, f->root_gid, H5T_CONTAINER_GRPNAME));
}
H5_PRIV_API_RETURN (t->topo_gid);
return (t->topo_gid);
}
h5_err_t
h5tpriv_open_meshes_group (
h5_file_t* const f,
const h5_oid_t type_id
static inline h5_err_t
open_tetmeshes_group (
h5_file_t* const f
) {
H5_PRIV_API_ENTER2 (h5_err_t, "f=0x%p, type_id=%d", f, type_id);
H5_PRIV_FUNC_ENTER (h5_err_t);
h5t_fdata_t* t = f->t;
if (t->topo_gid < 0) {
TRY (h5tpriv_open_topo_group (f));
TRY (open_topo_group (f));
}
TRY (t->meshes_gid = h5priv_open_group (
f,
t->topo_gid,
h5tpriv_meshes_grpnames[type_id]));
t->mesh_type = type_id;
TETRAHEDRAL_MESHES_GRPNAME));
t->mesh_type = H5_OID_TETRAHEDRON;
H5_PRIV_FUNC_RETURN (H5_SUCCESS);
}
H5_PRIV_API_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
*/
h5_err_t
h5tpriv_open_mesh_group (
static inline h5_err_t
open_tetmesh_group (
h5_file_t* const f,
const h5_oid_t type_id,
const h5_id_t id
) {
H5_PRIV_API_ENTER3 (h5_err_t,
"f=0x%p, type_id=%d, id=%lld",
f, type_id, (long long)id);
H5_PRIV_FUNC_ENTER (h5_err_t);
h5t_fdata_t* t = f->t;
if (t->meshes_gid < 0) {
TRY (h5tpriv_open_meshes_group (f, type_id));
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);
@@ -427,55 +460,68 @@ h5tpriv_open_mesh_group (
If the value of parameter \c id is \c -1, a new mesh will be appended.
*/
h5_err_t
h5t_open_mesh (
h5t_open_tetrahedral_mesh (
h5_file_t* const f,
h5_id_t id,
const h5_oid_t type_id
h5_id_t id
) {
H5_CORE_API_ENTER3 (h5_err_t,
"f=0x%p, id=%lld, type_id=%u",
f, (long long)id, type_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_meshes (f, type_id);
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));
}
if (id == -1) { /* append new mesh */
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;
}
switch (type_id) {
case H5_OID_TETRAHEDRON:
t->dsinfo_elems.type_id = t->dtypes.h5_tet_t;
t->methods = tet_funcs;
t->ref_elem = &h5t_tet_ref_elem;
break;
case H5_OID_TRIANGLE:
t->dsinfo_elems.type_id = t->dtypes.h5_triangle_t;
t->methods = tri_funcs;
t->ref_elem = &h5t_tri_ref_elem;
break;
default:
H5_CORE_API_LEAVE (
h5_error_internal ());
}
TRY (h5tpriv_open_mesh_group (f, type_id, id));
if (id != t->num_meshes) { /* open existing */
TRY (h5tpriv_read_mesh (f));
} else { /* append new */
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);
}
-15
View File
@@ -10,21 +10,6 @@ h5tpriv_close_file (
h5_file_t * const f
);
h5_err_t
h5tpriv_open_topo_group (
h5_file_t * const f
);
h5_err_t
h5tpriv_open_meshes_group (
h5_file_t * const f,
const h5_oid_t
);
h5_err_t
h5tpriv_open_mesh_group (
h5_file_t * const f,
const h5_oid_t,
const h5_id_t
);
h5_err_t
h5tpriv_close_step (
h5_file_t * const f
);
+20 -14
View File
@@ -9,22 +9,31 @@
\return mesh id
*/
h5_id_t
h5t_add_mesh (
h5_file_t* const f,
const h5_oid_t mesh_type
h5t_add_tetrahedral_mesh (
h5_file_t* const f
) {
H5_CORE_API_ENTER2 (h5_id_t,
"f=0x%p, mesh_type=%d", f, mesh_type);
H5_CORE_API_ENTER1 (h5_id_t, "f=0x%p", f);
h5_id_t mesh_id = 0;
TRY (mesh_id = h5t_open_mesh (f, -1, mesh_type));
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.
Assign unique global indices to vertices.
*/
static h5_err_t
assign_global_vertex_indices (
@@ -154,7 +163,7 @@ h5t_store_vertex (
*/
if (t->last_stored_vid+1 >= t->num_vertices[t->leaf_level])
H5_CORE_API_LEAVE (HANDLE_H5_OVERFLOW_ERR(
"vertex", t->num_vertices[t->leaf_level]));
t->num_vertices[t->leaf_level]));
/*
missing call to add the first level
@@ -245,9 +254,7 @@ h5t_store_elem (
/* more than allocated? */
if ( t->last_stored_eid+1 >= t->num_elems[t->leaf_level] )
H5_CORE_API_LEAVE (
HANDLE_H5_OVERFLOW_ERR(
h5tpriv_map_oid2str(t->mesh_type),
t->num_elems[t->leaf_level]));
HANDLE_H5_OVERFLOW_ERR (t->num_elems[t->leaf_level]));
/* check parent id */
if ((t->leaf_level == 0 && parent_idx != -1) ||
@@ -256,8 +263,7 @@ h5t_store_elem (
&& parent_idx >= t->num_elems[t->leaf_level-1])
) {
H5_CORE_API_LEAVE (
HANDLE_H5_PARENT_ID_ERR (
h5tpriv_map_oid2str (t->mesh_type), parent_idx));
HANDLE_H5_PARENT_ID_ERR (parent_idx));
}
/* store elem data (but neighbors) */
+17 -6
View File
@@ -31,12 +31,23 @@ extern "C" {
/****** General routines *****************************************************/
h5_err_t
H5FedOpenMesh (
h5_file_t * const f,
const h5_id_t mesh_id,
const h5_oid_t mesh_type_id
);
static inline h5_err_t
H5FedOpenTetrahedralMesh (
h5_file_t* const f,
const h5_id_t mesh_id
) {
H5_API_ENTER2 (h5_err_t, "f=0x%p, mesh_id=%lld", f, (long long)mesh_id);
H5_API_RETURN (h5t_open_tetrahedral_mesh (f, mesh_id));
}
static inline h5_err_t
H5FedOpenTriangleMesh (
h5_file_t* const f,
const h5_id_t mesh_id
) {
H5_API_ENTER2 (h5_err_t, "f=0x%p, mesh_id=%lld", f, (long long)mesh_id);
H5_API_RETURN (h5t_open_triangle_mesh (f, mesh_id));
}
h5_err_t
H5FedCloseMesh (
+24 -1
View File
@@ -22,7 +22,30 @@
extern "C" {
#endif
h5_ssize_t H5FedGetNumMeshes ( h5_file_t * const f, const h5_oid_t type_id );
/*!
Get number of meshes of given type.
\param[in] f File handle
\param[in] type_id Type of mesh we want the number of.
\return Number of meshes of type \c type_id or error code.
*/
static inline h5_ssize_t
H5FedGetNumTetrahedralMeshes (
h5_file_t* const f
) {
H5_API_ENTER1 (h5_err_t, "f=0x%p", f);
H5_API_RETURN (h5t_get_num_tetmeshes (f));
}
static inline h5_ssize_t
H5FedGetNumTriangleMeshes (
h5_file_t* const f
) {
H5_API_ENTER1 (h5_err_t, "f=0x%p", f);
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 );
+12 -13
View File
@@ -23,22 +23,21 @@
extern "C" {
#endif
/* depricated! use explicit versions */
h5_id_t
H5FedAddMesh (
h5_file_t * const f,
const h5_oid_t mesh_type_id
);
h5_id_t
static inline h5_id_t
H5FedAddTetrahedralMesh (
h5_file_t * const f
);
h5_file_t* const f
) {
H5_API_ENTER1 (h5_id_t, "f=0x%p", f);
H5_API_RETURN (h5t_add_tetrahedral_mesh (f));
}
h5_id_t
static inline h5_id_t
H5FedAddTriangleMesh (
h5_file_t * const f
);
h5_file_t* const f
) {
H5_API_ENTER1 (h5_id_t, "f=0x%p", f);
H5_API_RETURN (h5t_add_triangle_mesh (f));
}
h5t_lvl_idx_t
H5FedAddLevel (
+7 -3
View File
@@ -2,9 +2,13 @@
#define __H5T_INQUIRY_H
h5_ssize_t
h5t_get_num_meshes (
h5_file_t * const f,
const enum h5_oid type
h5t_get_num_tetmeshes (
h5_file_t * const f
);
h5_ssize_t
h5t_get_num_trimeshes (
h5_file_t * const f
);
h5_ssize_t
+8 -3
View File
@@ -1,11 +1,16 @@
#ifndef __H5T_OPENCLOSE_H
#define __H5T_OPENCLOSE_H
h5_err_t h5t_open_mesh (
h5_err_t h5t_open_tetrahedral_mesh (
h5_file_t * const f,
const h5_id_t id,
const h5_oid_t type
const h5_id_t id
);
h5_err_t h5t_open_triangle_mesh (
h5_file_t * const f,
const h5_id_t id
);
h5_err_t h5t_set_level (
h5_file_t * const f,
const h5t_lvl_idx_t id
+7 -3
View File
@@ -2,9 +2,13 @@
#define __H5T_STOREMESH_H
h5_id_t
h5t_add_mesh (
h5_file_t * const f,
const h5_oid_t mesh_type
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