src/H5Fed_store.c
* rudimental write functions for vertices and tets added
This commit is contained in:
+122
-33
@@ -18,22 +18,83 @@
|
||||
#include "h5/h5_types.h"
|
||||
#include "H5Fed.h"
|
||||
|
||||
h5_int_t H5FedSetNumVertices (
|
||||
h5_file * fh, /*!< file handle */
|
||||
const h5_id_t level, /*!< mesh level */
|
||||
const h5_size_t num_vertices /*!< number of verices at level
|
||||
\c level */
|
||||
/*!
|
||||
Add a 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
|
||||
|
||||
\note
|
||||
write new level:
|
||||
H5FedAddLevel( f );
|
||||
H5FedSetNumVertices( f, nv );
|
||||
H5FedSetNumTetrahedra( f, nt );
|
||||
*/
|
||||
|
||||
h5_id_t H5FedAddLevel (
|
||||
h5_file * f /*!< file handle */
|
||||
) {
|
||||
return -1;
|
||||
struct h5t_fdata *t = &f->t;
|
||||
|
||||
if ( f->mode == H5_O_RDONLY ) {
|
||||
return -1;
|
||||
}
|
||||
if ( t->num_levels == -1 ) { /* unknown number of levels */
|
||||
/* determine number of levels */
|
||||
return -1; /* not implemented */
|
||||
}
|
||||
t->cur_level = t->num_levels++;
|
||||
|
||||
ssize_t num_bytes = t->num_levels*sizeof ( t->levels[0] );
|
||||
t->levels = realloc ( t->levels, num_bytes );
|
||||
|
||||
struct h5t_fdata_level *level = t->levels[t->cur_level];
|
||||
|
||||
memset ( level, 0, sizeof ( *level ) );
|
||||
|
||||
level->new_level = 1;
|
||||
level->last_stored_vertex = -1;
|
||||
level->last_stored_tet = -1;
|
||||
|
||||
return t->cur_level;
|
||||
}
|
||||
|
||||
h5_int_t H5FedSetNumTetrahedra (
|
||||
/*!
|
||||
Set number of vertices in current step and level
|
||||
*/
|
||||
h5_int_t
|
||||
H5FedSetNumVertices (
|
||||
h5_file * f, /*!< file handle */
|
||||
const h5_size_t num_vertices /*!< number of verices at level */
|
||||
) {
|
||||
struct h5t_fdata_level *level = &f->t.levels[f->t.cur_level];
|
||||
ssize_t num_bytes;
|
||||
|
||||
level->num_vertices = num_vertices;
|
||||
num_bytes = num_vertices * sizeof( level->vertices[0] );
|
||||
level->vertices = realloc ( level->vertices, num_bytes );
|
||||
|
||||
return num_vertices;
|
||||
}
|
||||
|
||||
h5_int_t
|
||||
H5FedSetNumTetrahedra (
|
||||
h5_file * fh, /*!< file handle */
|
||||
const h5_id_t level, /*!< mesh level */
|
||||
const h5_size_t num_tet /*!< number of tetrahedra at
|
||||
const h5_size_t num_tets /*!< number of tetrahedra at
|
||||
level \c level */
|
||||
) {
|
||||
return -1;
|
||||
struct h5t_fdata_level *level = &f->t.levels[f->t.cur_level];
|
||||
ssize_t num_bytes;
|
||||
|
||||
level->num_tets = num_tets;
|
||||
num_bytes = num_tets * sizeof( level->tets[0] );
|
||||
level->tets = realloc ( level->tets, num_bytes );
|
||||
|
||||
return num_tets;
|
||||
}
|
||||
|
||||
/*!
|
||||
@@ -42,16 +103,30 @@ h5_int_t H5FedSetNumTetrahedra (
|
||||
Stores the the coordinates of a specific vertex at level \c level
|
||||
with id \c vertex_id of the tetrahedral mesh.
|
||||
|
||||
\return value \c >=0 on success
|
||||
\return local vertex id on success
|
||||
\return \c -1 on error
|
||||
*/
|
||||
h5_int_t H5FedStoreVertexCoordinate (
|
||||
h5_file * fh, /*!< file handle */
|
||||
const h5_id_t level, /*!< mesh level */
|
||||
h5_id_t
|
||||
H5FedStoreVertex (
|
||||
h5_file * f, /*!< file handle */
|
||||
const h5_id_t vertex_id, /*!< global vertex id */
|
||||
const h5_vertex * const vertex /*!< 3-tuple of coordinates */
|
||||
const h5_float64_t P[3] /*!< coordinates */
|
||||
) {
|
||||
return -1;
|
||||
|
||||
struct h5t_fdata *t = &f->t
|
||||
|
||||
if ( t->cur_level < 0 ) return -1;
|
||||
|
||||
struct h5t_fdata_level *level = t->levels[t->cur_level];
|
||||
if ( level->last_stored_vertex+1 >= level->num_vertices )
|
||||
return -1;
|
||||
|
||||
h5_vertex *vertex = level->vertices[++level->last_stored_vertex];
|
||||
vertex->id = vertex_id;
|
||||
vertex->level = t->cur_level;
|
||||
memcpy ( vertex->P, P, sizeof ( P ) );
|
||||
|
||||
return level->last_stored_vertex;
|
||||
}
|
||||
|
||||
/*!
|
||||
@@ -60,16 +135,16 @@ h5_int_t H5FedStoreVertexCoordinate (
|
||||
Stores the 2-tuple, that contains the specific indices describing
|
||||
an edge with id \c edge_id at level \c level of the tetrahedral mesh.
|
||||
|
||||
\return value \c >=0 on success
|
||||
\return local edge id
|
||||
\return \c -1 on error
|
||||
*/
|
||||
h5_int_t H5FedStoreEdge (
|
||||
h5_id_t
|
||||
H5FedStoreEdge (
|
||||
h5_file * fh, /*!< file handle */
|
||||
const h5_id_t level, /*!< mesh level */
|
||||
const h5_id_t edge_id, /*!< global edge id */
|
||||
const h5_id_t parent_id, /*!< parent id if level \c >0
|
||||
else \x -1 */
|
||||
const h5_edge * const edge /*!< 2-tuple with vertex id's */
|
||||
const h5_id_t edge[2] /*!< tuple with vertex id's */
|
||||
) {
|
||||
return -1;
|
||||
}
|
||||
@@ -80,16 +155,16 @@ h5_int_t H5FedStoreEdge (
|
||||
Stores the 3-tuple, that contains the specific indices describing a
|
||||
triangle with id \c triangle_id at level \c level of the tetrahedral mesh.
|
||||
|
||||
\return value \c >=0 on success
|
||||
\return local triangle id
|
||||
\return \c -1 on error
|
||||
*/
|
||||
h5_int_t H5FedStoreTriangle (
|
||||
h5_int_t
|
||||
H5FedStoreTriangle (
|
||||
h5_file * fh, /*!< file handle */
|
||||
const h5_id_t level, /*!< mesh level */
|
||||
const h5_id_t triangle_id, /*!< global triangle id */
|
||||
const h5_id_t parent_id, /*!< parent id if level \c >0
|
||||
else \x -1 */
|
||||
const h5_triangle * const triangle/*!< 3-tuple with vertex id's */
|
||||
const h5_id triangle[3] /*!< tuple with vertex id's */
|
||||
) {
|
||||
return -1;
|
||||
}
|
||||
@@ -101,18 +176,33 @@ h5_int_t H5FedStoreTriangle (
|
||||
a tetrahedron with id \c tet_id at level \c level of the tetrahedral
|
||||
mesh.
|
||||
|
||||
\return value \c >=0 on success
|
||||
\return local tetrahedron id
|
||||
\return \c -1 on error
|
||||
*/
|
||||
h5_int_t H5FedStoreTetrahedron (
|
||||
h5_int_t
|
||||
H5FedStoreTetrahedron (
|
||||
h5_file * fh, /*!< file handle */
|
||||
const h5_id_t level, /*!< mesh level */
|
||||
const h5_id_t tet_id, /*!< global tetrahedron id */
|
||||
const h5_id_t parent_id, /*!< parent id if level \c >0
|
||||
else \x -1 */
|
||||
const h5_tetrahedron * const tet/*!< 4-tuple with vertex id's */
|
||||
else \x -1 */
|
||||
const h5_id_t tet[4]; /*!< tuple with vertex id's */
|
||||
) {
|
||||
return -1;
|
||||
|
||||
struct h5t_fdata *t = &f->t
|
||||
|
||||
if ( t->cur_level < 0 ) return -1;
|
||||
|
||||
struct h5t_fdata_level *level = t->levels[t->cur_level];
|
||||
if ( level->last_stored_tet+1 >= level->num_tets )
|
||||
return -1;
|
||||
|
||||
h5_tetrahedron *tet = level->tets[++level->last_stored_tet];
|
||||
tet->id = tet_id;
|
||||
tet->level = t->cur_level;
|
||||
memcpy ( tet->vertex_ids, tet, sizeof ( tet ) );
|
||||
|
||||
return level->last_stored_vertex;
|
||||
|
||||
}
|
||||
|
||||
/*!
|
||||
@@ -122,16 +212,15 @@ h5_int_t H5FedStoreTetrahedron (
|
||||
a boundary triangle \c btriangle with id \c btriangle_id at level
|
||||
\c level of the tetrahedral mesh.
|
||||
|
||||
\return value \c >=0 on success
|
||||
\return local boundary triangle id
|
||||
\return \c -1 on error
|
||||
*/
|
||||
h5_int_t H5FedStoreBoundaryTriangle (
|
||||
h5_file * fh, /*!< file handle */
|
||||
const h5_id_t level, /*!< mesh level */
|
||||
const h5_id_t btriangle_id, /*!< global boundary triangle id*/
|
||||
const h5_id_t parent_id, /*!< parent id if level \c >0
|
||||
else \c -1 */
|
||||
const h5_triangle * const btriangle/*!< 3-tuple with vertex id's*/
|
||||
const h5_id_t btriangle[3] /*!< tuple with vertex id's*/
|
||||
) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user