diff --git a/src/H5Fed_retrieve.c b/src/H5Fed_retrieve.c index 5b8d52e..85baad3 100644 --- a/src/H5Fed_retrieve.c +++ b/src/H5Fed_retrieve.c @@ -97,6 +97,6 @@ h5_id_t H5FedEndTraverseElements ( h5_file_t * const f ) { - h5t_end_traverse_elems ( f ); + return h5t_end_traverse_elems ( f ); } diff --git a/src/H5Fed_store.c b/src/H5Fed_store.c index c8f9432..537e385 100644 --- a/src/H5Fed_store.c +++ b/src/H5Fed_store.c @@ -22,11 +22,10 @@ h5_id_t H5FedAddMesh ( h5_file_t * const f, - const h5_size_t num_elems, const h5_oid_t mesh_type_id ) { SET_FNAME ( f, __func__ ); - return h5t_add_mesh ( f, num_elems, mesh_type_id ); + return h5t_add_mesh ( f, mesh_type_id ); } /*! @@ -51,13 +50,31 @@ H5FedAddMesh ( */ h5_id_t H5FedAddLevel ( - h5_file_t * const f, - const h5_size_t num_elems_to_refine + h5_file_t * const f ) { SET_FNAME ( f, __func__ ); - return h5t_add_level ( f, num_elems_to_refine ); + return h5t_add_level ( f ); } +h5_err_t +H5FedAddNumVertices ( + h5_file_t * f, + const h5_size_t num + ) { + SET_FNAME ( f, __func__ ); + return h5t_add_num_vertices ( f, num ); +} + +h5_err_t +H5FedAddNumElements ( + h5_file_t * f, + const h5_size_t num + ) { + SET_FNAME ( f, __func__ ); + return h5t_add_num_elems ( f, num ); +} + + /*! \ingroup h5fed_c_api @@ -113,6 +130,15 @@ H5FedStoreElement ( return h5t_store_elem ( f, -1, local_vids ); } +h5_err_t +H5FedRefineNumElements ( + h5_file_t * const f, + const h5_size_t num + ) { + SET_FNAME ( f, __func__ ); + return h5t_refine_num_elems ( f, num ); +} + h5_id_t H5FedRefineElement ( h5_file_t * const f, /*!< file handle */ diff --git a/src/H5Fed_store.h b/src/H5Fed_store.h index 6991d0f..5a4f525 100644 --- a/src/H5Fed_store.h +++ b/src/H5Fed_store.h @@ -22,14 +22,12 @@ h5_id_t H5FedAddMesh ( h5_file_t * const f, - const h5_size_t num_elems, const h5_oid_t mesh_type_id ); h5_id_t H5FedAddLevel ( - h5_file_t * f, - const h5_size_t num_elems + h5_file_t * f ); h5_err_t @@ -57,6 +55,12 @@ H5FedStoreElement ( const h5_id_t local_vids[] ); +h5_err_t +H5FedRefineNumElements ( + h5_file_t * f, + const h5_size_t num + ); + h5_id_t H5FedRefineElement ( h5_file_t * const f, diff --git a/src/h5_core/h5_errorhandling.h b/src/h5_core/h5_errorhandling.h index 9fe12ad..0666869 100644 --- a/src/h5_core/h5_errorhandling.h +++ b/src/h5_core/h5_errorhandling.h @@ -3,8 +3,7 @@ #define SET_FNAME( f, fname ) h5_set_funcname( f, fname ); #define CHECK_FILEHANDLE( f ) \ - if ( f == NULL ) \ - return HANDLE_H5_BADFD_ERR( f ); + TRY ( h5_check_filehandle ( f ) ); #define CHECK_WRITABLE_MODE( f ) \ if ( f->mode==H5_O_RDONLY ) \ diff --git a/src/h5_core/h5_errorhandling_private.h b/src/h5_core/h5_errorhandling_private.h index 994ca32..66008da 100644 --- a/src/h5_core/h5_errorhandling_private.h +++ b/src/h5_core/h5_errorhandling_private.h @@ -36,12 +36,6 @@ /**************** H5 *********************/ -#define HANDLE_H5_BADFD_ERR( f ) \ - h5_error( \ - f, \ - H5_ERR_BADFD, \ - "Called with bad filehandle." ); - #define _h5_handle_file_mode_error( f, mode_id ) \ h5_error( \ f, \ diff --git a/src/h5_core/h5_maps.c b/src/h5_core/h5_maps.c index d7c80c1..3841f00 100644 --- a/src/h5_core/h5_maps.c +++ b/src/h5_core/h5_maps.c @@ -14,7 +14,7 @@ _h5_alloc_smap ( ) { int new = ( map->items == NULL ); size_t size_in_bytes = size * sizeof ( map->items[0] ); - TRY( map->items = _h5_alloc ( f, map->items, size_in_bytes ) ); + TRY ( map->items = _h5_alloc ( f, map->items, size_in_bytes ) ); map->size = size; if ( new ) map->num_items = 0; return H5_SUCCESS; @@ -28,7 +28,7 @@ _h5_alloc_idmap ( ) { int new = ( map->items == NULL ); size_t size_in_bytes = size * sizeof ( map->items[0] ); - TRY( map->items = _h5_alloc ( f, map->items, size_in_bytes ) ); + TRY ( map->items = _h5_alloc ( f, map->items, size_in_bytes ) ); map->size = size; if ( new ) map->num_items = 0; return H5_SUCCESS; diff --git a/src/h5_core/h5_openclose.c b/src/h5_core/h5_openclose.c index 190184c..fa1df44 100644 --- a/src/h5_core/h5_openclose.c +++ b/src/h5_core/h5_openclose.c @@ -27,15 +27,15 @@ h5_check_filehandle ( h5_file_t * const f /*!< filehandle to check validity of */ ) { - if ( f == NULL ) - return HANDLE_H5_BADFD_ERR( f ); - if ( f->file == 0 ) - return HANDLE_H5_BADFD_ERR( f ); - + if ( f == NULL || f->file == 0 ) { + return h5_error ( + f, + H5_ERR_BADFD, + "Called with bad filehandle." ); + } return H5_SUCCESS; } - /*! Initialize H5Part */ @@ -92,7 +92,6 @@ _h5b_open_file ( ) { h5b_fdata_t *b; - if ( (f == 0) || (f->file == 0) ) return HANDLE_H5_BADFD_ERR( f ); if ( f->b ) return H5_SUCCESS; TRY ( f->b = (h5b_fdata_t*) _h5_alloc ( f, NULL, sizeof (*f->b) ) ); diff --git a/src/h5_core/h5t_storemesh.c b/src/h5_core/h5t_storemesh.c index 2ec4892..e5c618a 100644 --- a/src/h5_core/h5t_storemesh.c +++ b/src/h5_core/h5t_storemesh.c @@ -15,13 +15,12 @@ h5_id_t h5t_add_mesh ( h5_file_t * const f, - const h5_size_t num_elems, const h5_oid_t mesh_type ) { h5_id_t mesh_id = 0; TRY( (mesh_id = h5t_open_mesh ( f, -1, mesh_type )) ); - TRY( _h5t_add_level ( f, num_elems+3, num_elems ) ); + TRY( h5t_add_level ( f ) ); f->t->mesh_changed = 1; @@ -82,30 +81,12 @@ _h5t_close_level ( return H5_SUCCESS; } +#if 0 + +#endif h5_id_t h5t_add_level ( - h5_file_t * const f, - h5_size_t num_elems - ) { - switch ( f->t->mesh_type ) { - case H5_OID_TETRAHEDRON: - num_elems += 8; - break; - case H5_OID_TRIANGLE: - num_elems += 4; - break; - default: - return h5_error_internal ( f, __FILE__, __func__, __LINE__ ); - } - h5_id_t num_vertices = (num_elems>>2)*3; /* this is an upper limit */ - return _h5t_add_level ( f, num_vertices, num_elems ); -} - -h5_id_t -_h5t_add_level ( - h5_file_t * const f, - const h5_size_t num_vertices, - const h5_size_t num_elems + h5_file_t * const f ) { h5t_fdata_t *t = f->t; @@ -141,9 +122,6 @@ _h5t_add_level ( t->last_stored_eid = -1; } - TRY( _h5t_add_num_vertices ( f, num_vertices ) ); - TRY( _h5t_add_num_elems ( f, num_elems ) ); - return t->cur_level; } @@ -166,7 +144,7 @@ _h5t_alloc_num_vertices ( Allocate memory for (more) vertices. */ h5_err_t -_h5t_add_num_vertices ( +h5t_add_num_vertices ( h5_file_t * const f, const h5_size_t num ) { @@ -250,7 +228,7 @@ _h5t_alloc_num_elems ( } h5_err_t -_h5t_add_num_elems ( +h5t_add_num_elems ( h5_file_t * const f, const h5_size_t num ) { @@ -383,6 +361,28 @@ _h5t_store_triangle ( } +h5_err_t +h5t_refine_num_elems ( + h5_file_t * const f, + const h5_size_t num_elems_to_refine + ) { + h5_size_t num_elems_to_add = 0; + switch ( f->t->mesh_type ) { + case H5_OID_TETRAHEDRON: + num_elems_to_add = num_elems_to_refine*8; + break; + case H5_OID_TRIANGLE: + num_elems_to_add = num_elems_to_refine*4; + break; + default: + return h5_error_internal ( f, __FILE__, __func__, __LINE__ ); + } + h5_size_t num_vertices = (num_elems_to_add>>2)*3; /* this is an upper limit */ + TRY ( h5t_add_num_vertices ( f, num_vertices ) ); + TRY ( h5t_add_num_elems ( f, num_elems_to_add ) ); + + return H5_SUCCESS; +} /*! Refine edge. Store vertex, if new. diff --git a/src/h5_core/h5t_storemesh.h b/src/h5_core/h5t_storemesh.h index d3d340f..378fe1f 100644 --- a/src/h5_core/h5t_storemesh.h +++ b/src/h5_core/h5t_storemesh.h @@ -4,14 +4,24 @@ h5_id_t h5t_add_mesh ( h5_file_t * const f, - const h5_size_t num_elems, const h5_oid_t mesh_type ); h5_id_t h5t_add_level ( + h5_file_t * const f + ); + +h5_size_t +h5t_add_num_vertices ( h5_file_t * const f, - const h5_size_t num_elems + const h5_size_t num + ); + +h5_err_t +h5t_add_num_elems ( + h5_file_t * const f, + const h5_size_t num ); h5_id_t @@ -21,18 +31,6 @@ h5t_store_vertex ( const h5_float64_t P[3] ); -h5_err_t -h5_add_num_tets ( - h5_file_t * const f, - const h5_size_t num - ); - -h5_err_t -h5_add_num_triangles ( - h5_file_t * const f, - const h5_size_t num - ); - h5_id_t h5t_store_elem ( h5_file_t * const f, @@ -40,18 +38,10 @@ h5t_store_elem ( const h5_id_t local_vids[] ); -h5_id_t -_h5t_store_triangle ( +h5_err_t +h5t_refine_num_elems ( h5_file_t * const f, - const h5_id_t local_parent_eid, - const h5_id_t vids[3] - ); - -h5_id_t -_h5t_store_tet ( - h5_file_t * const f, - const h5_id_t local_parent_eid, - const h5_id_t vids[4] + const h5_size_t num_elems_to_refine ); h5_id_t @@ -60,15 +50,4 @@ h5t_refine_elem ( const h5_id_t local_eid ); -h5_id_t -_h5t_refine_triangle ( - h5_file_t * const f, - const h5_id_t local_eid - ); - -h5_id_t -_h5t_refine_tet ( - h5_file_t * const f, - const h5_id_t local_eid - ); #endif diff --git a/src/h5_core/h5t_storemesh_private.h b/src/h5_core/h5t_storemesh_private.h index 0a0a996..ef9ff7e 100644 --- a/src/h5_core/h5t_storemesh_private.h +++ b/src/h5_core/h5t_storemesh_private.h @@ -1,31 +1,12 @@ #ifndef __H5T_STOREMESH_PRIVATE_H #define __H5T_STOREMESH_PRIVATE_H -h5_id_t -_h5t_add_level ( - h5_file_t * const f, - const h5_size_t num_vertices, - const h5_size_t num_elems - ); - h5_err_t _h5t_alloc_num_vertices ( h5_file_t * const f, const h5_size_t num_vertices ); -h5_size_t -_h5t_add_num_vertices ( - h5_file_t * const f, - const h5_size_t num - ); - -h5_err_t -_h5t_add_num_elems ( - h5_file_t * const f, - const h5_size_t num - ); - h5_err_t _h5t_alloc_num_elems ( h5_file_t * const f, @@ -33,8 +14,35 @@ _h5t_alloc_num_elems ( const size_t new_num_elems ); +h5_id_t +_h5t_store_triangle ( + h5_file_t * const f, + const h5_id_t local_parent_eid, + const h5_id_t vids[3] + ); + +h5_id_t +_h5t_store_tet ( + h5_file_t * const f, + const h5_id_t local_parent_eid, + const h5_id_t vids[4] + ); + + h5_err_t _h5t_close_level ( h5_file_t * const f ); +h5_id_t +_h5t_refine_triangle ( + h5_file_t * const f, + const h5_id_t local_eid + ); + +h5_id_t +_h5t_refine_tet ( + h5_file_t * const f, + const h5_id_t local_eid + ); + #endif