diff --git a/src/h5_core/Makefile.am b/src/h5_core/Makefile.am index 949ca20..9348e97 100644 --- a/src/h5_core/Makefile.am +++ b/src/h5_core/Makefile.am @@ -47,9 +47,7 @@ EXTRA_HEADERS = \ h5_types.h \ h5b_errorhandling_private.h \ h5t_adjacencies.h \ - h5t_adjacencies_private.h \ - h5t_boundaries.h \ - h5t_boundaries_private.h \ + h5t_tetm_adjacencies_private.h \ h5t_consts_private.h \ h5t_errorhandling_private.h \ h5t_hsearch_private.h \ @@ -98,7 +96,7 @@ libH5_core_a_SOURCES = \ h5_readwrite.c \ h5_syscall.c \ h5t_adjacencies.c \ - h5t_boundaries.c \ + h5t_tetm_adjacencies.c \ h5t_consts.c \ h5t_errorhandling.c \ h5t_hsearch.c \ diff --git a/src/h5_core/h5_attribs.c b/src/h5_core/h5_attribs.c index 67744e4..5fde660 100644 --- a/src/h5_core/h5_attribs.c +++ b/src/h5_core/h5_attribs.c @@ -38,15 +38,15 @@ h5_read_attrib ( hid_t mytype; hsize_t nelem; - TRY ( attrib_id = _hdf_open_attribute ( f, id, attrib_name ) ); - TRY ( mytype = _hdf_get_attribute_type ( f, attrib_id ) ); - TRY ( space_id = _hdf_get_attribute_dataspace ( f, attrib_id ) ); - TRY ( nelem = _hdf_get_npoints_of_dataspace ( f, space_id ) ); + TRY ( attrib_id = h5priv_open_hdf5_attribute ( f, id, attrib_name ) ); + TRY ( mytype = h5priv_get_hdf5_attribute_type ( f, attrib_id ) ); + TRY ( space_id = h5priv_get_hdf5_attribute_dataspace ( f, attrib_id ) ); + TRY ( nelem = h5priv_get_npoints_of_hdf5_dataspace ( f, space_id ) ); TRY ( type_id = h5_normalize_h5_type ( f, mytype ) ); - TRY ( _hdf_read_attribute ( f, attrib_id, type_id, attrib_value ) ); - TRY ( _hdf_close_dataspace( f, space_id ) ); - TRY ( _hdf_close_type( f, mytype ) ); - TRY ( _hdf_close_attribute ( f, attrib_id ) ); + TRY ( h5priv_read_hdf5_attribute ( f, attrib_id, type_id, attrib_value ) ); + TRY ( h5priv_close_hdf5_dataspace( f, space_id ) ); + TRY ( h5priv_close_hdf5_type( f, mytype ) ); + TRY ( h5priv_close_hdf5_attribute ( f, attrib_id ) ); return H5_SUCCESS; } @@ -70,8 +70,8 @@ h5_write_attrib ( hid_t space_id; hid_t attrib_id; - TRY ( space_id = _hdf_create_dataspace ( f, 1, &attrib_nelem, NULL) ); - TRY ( attrib_id = _hdf_create_attribute ( + TRY ( space_id = h5priv_create_hdf5_dataspace ( f, 1, &attrib_nelem, NULL) ); + TRY ( attrib_id = h5priv_create_hdf5_attribute ( f, id, attrib_name, @@ -79,9 +79,9 @@ h5_write_attrib ( space_id, H5P_DEFAULT, H5P_DEFAULT ) ); - TRY ( _hdf_write_attribute ( f, attrib_id, attrib_type, attrib_value ) ); - TRY ( _hdf_close_attribute ( f, attrib_id ) ); - TRY ( _hdf_close_dataspace ( f, space_id ) ); + TRY ( h5priv_write_hdf5_attribute ( f, attrib_id, attrib_type, attrib_value ) ); + TRY ( h5priv_close_hdf5_attribute ( f, attrib_id ) ); + TRY ( h5priv_close_hdf5_dataspace ( f, space_id ) ); return H5_SUCCESS; } @@ -107,30 +107,30 @@ h5_get_attrib_info ( hid_t mytype; hid_t space_id; - TRY ( attrib_id = _hdf_open_attribute_idx ( + TRY ( attrib_id = h5priv_open_hdf5_attribute_idx ( f, id, (unsigned int)attrib_idx ) ); if ( attrib_nelem ) { - TRY ( space_id = _hdf_get_attribute_dataspace ( f, attrib_id ) ); - TRY ( *attrib_nelem = _hdf_get_npoints_of_dataspace ( + TRY ( space_id = h5priv_get_hdf5_attribute_dataspace ( f, attrib_id ) ); + TRY ( *attrib_nelem = h5priv_get_npoints_of_hdf5_dataspace ( f, space_id ) ); - TRY( _hdf_close_dataspace( f, space_id ) ); + TRY( h5priv_close_hdf5_dataspace( f, space_id ) ); } if ( attrib_name ) { - TRY ( _hdf_get_attribute_name ( + TRY ( h5priv_get_hdf5_attribute_name ( f, attrib_id, (size_t)len_attrib_name, attrib_name ) ); } if ( attrib_type ) { - TRY ( mytype = _hdf_get_attribute_type ( f, attrib_id ) ); + TRY ( mytype = h5priv_get_hdf5_attribute_type ( f, attrib_id ) ); TRY ( *attrib_type = h5_normalize_h5_type ( f, mytype ) ); - TRY ( _hdf_close_type( f, mytype ) ); + TRY ( h5priv_close_hdf5_type( f, mytype ) ); } - TRY ( _hdf_close_attribute ( f, attrib_id ) ); + TRY ( h5priv_close_hdf5_attribute ( f, attrib_id ) ); return H5_SUCCESS; } @@ -148,5 +148,5 @@ h5_get_num_attribs ( const hid_t id ) { CHECK_FILEHANDLE ( f ); - return _hdf_get_num_attributes ( f, id ); + return h5priv_get_num_hdf5_attribute ( f, id ); } diff --git a/src/h5_core/h5_errorhandling.c b/src/h5_core/h5_errorhandling.c index fe7026b..4206395 100644 --- a/src/h5_core/h5_errorhandling.c +++ b/src/h5_core/h5_errorhandling.c @@ -9,8 +9,8 @@ #include "h5_core.h" #include "h5_core_private.h" -static h5_errorhandler_t _h5_errhandler = h5_report_errorhandler; -static h5_int32_t _h5_debuglevel = 0; +static h5_errorhandler_t h5priv_errhandler = h5_report_errorhandler; +static h5_int32_t h5priv_debuglevel = 0; /*! \ingroup h5_core @@ -44,7 +44,7 @@ h5_set_debuglevel ( h5_id_t debuglevel /*!< debug level */ ) { if ( debuglevel < 0 || debuglevel > 5 ) return H5_ERR_INVAL; - _h5_debuglevel = debuglevel; + h5priv_debuglevel = debuglevel; return H5_SUCCESS; } @@ -59,7 +59,7 @@ h5_id_t h5_get_debuglevel ( void ) { - return _h5_debuglevel; + return h5priv_debuglevel; } /*! @@ -73,7 +73,7 @@ h5_err_t h5_set_errorhandler ( h5_errorhandler_t handler ) { - _h5_errhandler = handler; + h5priv_errhandler = handler; return H5_SUCCESS; } @@ -88,7 +88,7 @@ h5_errorhandler_t h5_get_errorhandler ( void ) { - return _h5_errhandler; + return h5priv_errhandler; } /*! @@ -136,7 +136,7 @@ h5_report_errorhandler ( va_list ap ) { - if ( _h5_debuglevel > 0 ) { + if ( h5priv_debuglevel > 0 ) { h5_verror ( f, fmt, ap ); } return f->__errno; @@ -155,7 +155,7 @@ h5_abort_errorhandler ( va_list ap ) { - if ( _h5_debuglevel > 0 ) { + if ( h5priv_debuglevel > 0 ) { h5_verror ( f, fmt, ap ); } exit (-(int)f->__errno); @@ -197,7 +197,7 @@ h5_error ( va_list ap; va_start ( ap, fmt ); - (*_h5_errhandler)( f, fmt, ap ); + (*h5priv_errhandler)( f, fmt, ap ); va_end ( ap ); return f->__errno; @@ -215,7 +215,7 @@ h5_verror ( va_list ap ) { - if ( _h5_debuglevel < 1 ) return; + if ( h5priv_debuglevel < 1 ) return; _vprintf ( stderr, "E", f->__funcname, fmt, ap ); } @@ -232,7 +232,7 @@ h5_vwarn ( va_list ap ) { - if ( _h5_debuglevel < 2 ) return; + if ( h5priv_debuglevel < 2 ) return; _vprintf ( stderr, "W", f->__funcname, fmt, ap ); } @@ -266,7 +266,7 @@ h5_vinfo ( va_list ap ) { - if ( _h5_debuglevel < 3 ) return; + if ( h5priv_debuglevel < 3 ) return; _vprintf ( stdout, "I", f->__funcname, fmt, ap ); } @@ -300,7 +300,7 @@ h5_vdebug ( va_list ap ) { - if ( _h5_debuglevel < 4 ) return; + if ( h5priv_debuglevel < 4 ) return; _vprintf ( stdout, "D", f->__funcname, fmt, ap ); } diff --git a/src/h5_core/h5_errorhandling_private.h b/src/h5_core/h5_errorhandling_private.h index 97d8b64..ea815c8 100644 --- a/src/h5_core/h5_errorhandling_private.h +++ b/src/h5_core/h5_errorhandling_private.h @@ -30,7 +30,7 @@ /**************** H5 *********************/ -#define _h5_handle_file_mode_error( f, mode_id ) \ +#define h5priv_handle_file_mode_error( f, mode_id ) \ h5_error( \ f, \ H5_ERR_BADF, \ diff --git a/src/h5_core/h5_fcmp.c b/src/h5_core/h5_fcmp.c index bdde14c..898f4fe 100644 --- a/src/h5_core/h5_fcmp.c +++ b/src/h5_core/h5_fcmp.c @@ -9,7 +9,7 @@ for a detailed explanation. */ h5_int64_t -_h5_fcmp ( +h5priv_fcmp ( h5_float64_t A, h5_float64_t B, h5_int32_t maxUlps ) { diff --git a/src/h5_core/h5_fcmp_private.h b/src/h5_core/h5_fcmp_private.h index e08fdab..863c87d 100644 --- a/src/h5_core/h5_fcmp_private.h +++ b/src/h5_core/h5_fcmp_private.h @@ -2,7 +2,7 @@ #define __H5_FCMP_H h5_int64_t -_h5_fcmp ( +h5priv_fcmp ( h5_float64_t A, h5_float64_t B, h5_int32_t maxUlps ); diff --git a/src/h5_core/h5_hdf5.c b/src/h5_core/h5_hdf5.c index af18064..a95bfda 100644 --- a/src/h5_core/h5_hdf5.c +++ b/src/h5_core/h5_hdf5.c @@ -6,7 +6,7 @@ /****** G r o u p ************************************************************/ hid_t -_hdf_open_group ( +h5priv_open_hdf5_group ( h5_file_t * f, const hid_t loc_id, const char * const group_name @@ -23,12 +23,13 @@ _hdf_open_group ( } hid_t -_hdf_create_group ( +h5priv_create_hdf5_group ( h5_file_t * f, const hid_t loc_id, const char * const group_name ) { - hid_t group_id = H5Gcreate ( loc_id, group_name, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT ); + hid_t group_id = H5Gcreate ( + loc_id, group_name, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT ); if ( group_id < 0 ) return h5_error ( f, @@ -47,7 +48,7 @@ _hdf_create_group ( \param[in] group_name name of group to open */ hid_t -_h5_open_group ( +h5priv_open_group ( h5_file_t * f, const hid_t loc_id, const char * const group_name @@ -100,7 +101,7 @@ _h5_open_group ( \param[in] group_id id of group to close */ h5_err_t -_hdf_close_group ( +h5priv_close_hdf5_group ( h5_file_t * const f, const hid_t group_id ) { @@ -116,7 +117,7 @@ _hdf_close_group ( } hsize_t -_hdf_get_num_objs_in_group ( +h5priv_get_num_objs_in_hdf5_group ( h5_file_t * const f, const hid_t group_id ) { @@ -132,7 +133,7 @@ _hdf_get_num_objs_in_group ( } h5_err_t -_hdf_get_objname_by_idx_in_group ( +h5priv_get_objname_by_idx_in_hdf5_group ( h5_file_t * const f, hid_t loc_id, hsize_t idx, @@ -142,7 +143,7 @@ _hdf_get_objname_by_idx_in_group ( size = H5Gget_objname_by_idx ( loc_id, idx, NULL, 0 ) + 1; if ( size < 0 ) goto error; - *name = _h5_calloc ( f, 1, size ); + *name = h5priv_calloc ( f, 1, size ); if ( *name == NULL ) goto error; size = H5Gget_objname_by_idx ( loc_id, idx, *name, size ); @@ -168,7 +169,7 @@ error: \param[in] dataset_name name of dataset to open */ hid_t -_hdf_open_dataset ( +h5priv_open_hdf5_dataset ( h5_file_t * const f, const hid_t loc_id, const char * const dataset_name @@ -200,7 +201,7 @@ _hdf_open_dataset ( */ hid_t -_hdf_create_dataset ( +h5priv_create_hdf5_dataset ( h5_file_t * const f, hid_t loc_id, const char * dataset_name, @@ -233,7 +234,7 @@ _hdf_create_dataset ( \param[in] dataset_id id of dataset to close */ herr_t -_hdf_close_dataset ( +h5priv_close_hdf5_dataset ( h5_file_t * const f, const hid_t dset_id ) { @@ -257,7 +258,7 @@ _hdf_close_dataset ( */ hid_t -_hdf_get_dataset_space ( +h5priv_get_hdf5_dataset_space ( h5_file_t * const f, const hid_t dataset_id ) { @@ -285,7 +286,7 @@ _hdf_get_dataset_space ( */ herr_t -_hdf_write_dataset ( +h5priv_write_hdf5_dataset ( h5_file_t * const f, const hid_t dataset_id, const hid_t type_id, @@ -315,7 +316,7 @@ _hdf_write_dataset ( Wrapper for H5Dread */ h5_err_t -_hdf_read_dataset ( +h5priv_read_hdf5_dataset ( h5_file_t * const f, const hid_t dataset_id, const hid_t type_id, @@ -342,7 +343,7 @@ _hdf_read_dataset ( } hid_t -_hdf_get_dataset_type ( +h5priv_get_hdf5_dataset_type ( h5_file_t * const f, const hid_t dataset_id ) { @@ -358,7 +359,7 @@ _hdf_get_dataset_type ( herr_t -_hdf_set_dataset_extent ( +h5priv_set_hdf5_dataset_extent ( h5_file_t * const f, hid_t dset_id, const hsize_t *size @@ -376,29 +377,29 @@ _hdf_set_dataset_extent ( } hssize_t -_hdf_get_npoints_of_dataset ( +h5priv_get_npoints_of_hdf5_dataset ( h5_file_t * const f, hid_t dset_id ) { hid_t dspace_id; hsize_t size; - TRY ( dspace_id = _hdf_get_dataset_space ( f, dset_id ) ); - TRY ( size = _hdf_get_npoints_of_dataspace ( f, dspace_id ) ); - TRY ( _hdf_close_dataspace( f, dspace_id ) ); + TRY ( dspace_id = h5priv_get_hdf5_dataset_space ( f, dset_id ) ); + TRY ( size = h5priv_get_npoints_of_hdf5_dataspace ( f, dspace_id ) ); + TRY ( h5priv_close_hdf5_dataspace( f, dspace_id ) ); return size; } hssize_t -_hdf_get_npoints_of_dataset_by_name ( +h5priv_get_npoints_of_hdf5_dataset_by_name ( h5_file_t * const f, hid_t loc_id, char * name ) { hid_t dset_id; hsize_t size; - TRY ( dset_id = _hdf_open_dataset ( f, loc_id, name ) ); - TRY ( size = _hdf_get_npoints_of_dataset ( f, dset_id ) ); - TRY ( _hdf_close_dataset ( f, dset_id ) ); + TRY ( dset_id = h5priv_open_hdf5_dataset ( f, loc_id, name ) ); + TRY ( size = h5priv_get_npoints_of_hdf5_dataset ( f, dset_id ) ); + TRY ( h5priv_close_hdf5_dataset ( f, dset_id ) ); return size; } @@ -414,7 +415,7 @@ _hdf_get_npoints_of_dataset_by_name ( */ hid_t -_hdf_create_dataspace ( +h5priv_create_hdf5_dataspace ( h5_file_t * const f, const int rank, const hsize_t * dims, @@ -431,7 +432,7 @@ _hdf_create_dataspace ( } herr_t -_hdf_select_hyperslab_of_dataspace ( +h5priv_select_hyperslab_of_hdf5_dataspace ( h5_file_t * const f, hid_t space_id, H5S_seloper_t op, @@ -457,7 +458,7 @@ _hdf_select_hyperslab_of_dataspace ( } hssize_t -_hdf_get_selected_npoints_of_dataspace ( +h5priv_get_selected_npoints_of_hdf5_dataspace ( h5_file_t * const f, hid_t space_id ) { @@ -471,7 +472,7 @@ _hdf_get_selected_npoints_of_dataspace ( } hssize_t -_hdf_get_npoints_of_dataspace ( +h5priv_get_npoints_of_hdf5_dataspace ( h5_file_t * const f, hid_t space_id ) { @@ -485,7 +486,7 @@ _hdf_get_npoints_of_dataspace ( } int -_hdf_get_dims_of_dataspace ( +h5priv_get_dims_of_hdf5_dataspace ( h5_file_t * const f, hid_t space_id, hsize_t *dims, @@ -508,7 +509,7 @@ _hdf_get_dims_of_dataspace ( \param[in] dataspace_id id of space to close */ herr_t -_hdf_close_dataspace ( +h5priv_close_hdf5_dataspace ( h5_file_t * const f, const hid_t dataspace_id ) { @@ -529,7 +530,7 @@ _hdf_close_dataspace ( /****** D a t a t y p e ******************************************************/ static const char* -_get_base_type_name ( +get_base_type_name ( h5_file_t * const f, hid_t base_type_id ) { @@ -542,7 +543,7 @@ _get_base_type_name ( } static const char* -_get_class_type_name ( +get_class_type_name ( h5_file_t * const f, hid_t base_type_id ) { @@ -560,7 +561,7 @@ _get_class_type_name ( \param[in] dims dimensions */ hid_t -_hdf_create_array_type ( +h5priv_create_hdf5_array_type ( h5_file_t * const f, hid_t base_type_id, int rank, @@ -573,14 +574,14 @@ _hdf_create_array_type ( H5_ERR_HDF5, "Can't create array datatype object with base " "type %s and rank %d", - _get_base_type_name ( f, base_type_id ), + get_base_type_name ( f, base_type_id ), rank ); } return type_id; } hid_t -_hdf_create_type ( +h5priv_create_hdf5_type ( h5_file_t * const f, H5T_class_t class, const size_t size @@ -591,14 +592,14 @@ _hdf_create_type ( f, H5_ERR_HDF5, "Can't create datatype object of class %s.", - _get_class_type_name ( f, class ) + get_class_type_name ( f, class ) ); } return type_id; } herr_t -_hdf_insert_type ( +h5priv_insert_hdf5_type ( h5_file_t * const f, hid_t dtype_id, const char * name, @@ -616,7 +617,7 @@ _hdf_insert_type ( } herr_t -_hdf_close_type ( +h5priv_close_hdf5_type ( h5_file_t * const f, hid_t dtype_id ) { @@ -632,7 +633,7 @@ _hdf_close_type ( /****** P r o p e r t y ******************************************************/ hid_t -_hdf_create_property ( +h5priv_create_hdf5_property ( h5_file_t * const f, hid_t cls_id ) { @@ -646,7 +647,7 @@ _hdf_create_property ( } herr_t -_hdf_set_chunk_property ( +h5priv_set_hdf5_chunk_property ( h5_file_t * const f, hid_t plist, int rank, @@ -663,7 +664,7 @@ _hdf_set_chunk_property ( #ifdef PARALLEL_IO h5_err_t -_hdf_set_fapl_mpio_property ( +h5priv_set_hdf5_fapl_mpio_property ( h5_file_t * const f, hid_t fapl_id, MPI_Comm comm, @@ -681,7 +682,7 @@ _hdf_set_fapl_mpio_property ( #endif h5_err_t -_hdf_close_property ( +h5priv_close_hdf5_property ( h5_file_t * const f, hid_t prop ) { @@ -697,7 +698,7 @@ _hdf_close_property ( /****** F i l e **************************************************************/ herr_t -_hdf_close_file ( +h5priv_close_hdf5_file ( h5_file_t * const f, hid_t fileid ) { @@ -713,7 +714,7 @@ _hdf_close_file ( /****** E r r o r h a n d l i n g ********************************************/ herr_t -_hdf_set_errorhandler ( +h5priv_set_hdf5_errorhandler ( h5_file_t * const f, hid_t estack_id, H5E_auto_t func, @@ -730,7 +731,7 @@ _hdf_set_errorhandler ( /****** A t t r i b u t e ****************************************************/ hid_t -_hdf_open_attribute ( +h5priv_open_hdf5_attribute ( h5_file_t * const f, hid_t loc_id, const char *attr_name @@ -747,7 +748,7 @@ _hdf_open_attribute ( } hid_t -_hdf_open_attribute_idx ( +h5priv_open_hdf5_attribute_idx ( h5_file_t * const f, hid_t loc_id, unsigned int idx @@ -764,7 +765,7 @@ _hdf_open_attribute_idx ( } hid_t -_hdf_open_attribute_by_name ( +h5priv_open_hdf5_attribute_by_name ( h5_file_t * const f, hid_t loc_id, const char *obj_name, @@ -787,7 +788,7 @@ _hdf_open_attribute_by_name ( } hid_t -_hdf_create_attribute ( +h5priv_create_hdf5_attribute ( h5_file_t * const f, hid_t loc_id, const char *attr_name, @@ -814,7 +815,7 @@ _hdf_create_attribute ( } herr_t -_hdf_read_attribute ( +h5priv_read_hdf5_attribute ( h5_file_t * const f, hid_t attr_id, hid_t mem_type_id, @@ -835,7 +836,7 @@ _hdf_read_attribute ( Wrapper for H5Awrite. */ herr_t -_hdf_write_attribute ( +h5priv_write_hdf5_attribute ( h5_file_t * const f, hid_t attr_id, hid_t mem_type_id, @@ -853,7 +854,7 @@ _hdf_write_attribute ( } ssize_t -_hdf_get_attribute_name ( +h5priv_get_hdf5_attribute_name ( h5_file_t * const f, hid_t attr_id, size_t buf_size, @@ -869,7 +870,7 @@ _hdf_get_attribute_name ( } hid_t -_hdf_get_attribute_type ( +h5priv_get_hdf5_attribute_type ( h5_file_t * const f, hid_t attr_id ) { @@ -884,7 +885,7 @@ _hdf_get_attribute_type ( } hid_t -_hdf_get_attribute_dataspace ( +h5priv_get_hdf5_attribute_dataspace ( h5_file_t * const f, hid_t attr_id ) { @@ -899,7 +900,7 @@ _hdf_get_attribute_dataspace ( } int -_hdf_get_num_attributes ( +h5priv_get_num_hdf5_attribute ( h5_file_t * const f, hid_t loc_id ) { @@ -915,7 +916,7 @@ _hdf_get_num_attributes ( herr_t -_hdf_close_attribute ( +h5priv_close_hdf5_attribute ( h5_file_t * const f, hid_t attr_id ) { @@ -929,3 +930,22 @@ _hdf_close_attribute ( return H5_SUCCESS; } + + +herr_t +h5priv_delete_hdf5_link ( + h5_file_t * const f, + hid_t loc_id, + const char *name, + hid_t lapl_id + ) { + herr_t herr = H5Ldelete ( loc_id, name, lapl_id ); + if ( herr < 0 ) + return h5_error ( + f, + H5_ERR_HDF5, + "Cannot remove link %s/%s.", + h5_get_objname( loc_id ), name ); + + return H5_SUCCESS; +} diff --git a/src/h5_core/h5_hdf5_private.h b/src/h5_core/h5_hdf5_private.h index be315d7..ad8fb50 100644 --- a/src/h5_core/h5_hdf5_private.h +++ b/src/h5_core/h5_hdf5_private.h @@ -3,40 +3,40 @@ /*** group ***/ hid_t -_hdf_open_group ( +h5priv_open_hdf5_group ( h5_file_t *f, const hid_t loc_id, const char * const group_name ); hid_t -_hdf_create_group ( +h5priv_create_hdf5_group ( h5_file_t * f, const hid_t loc_id, const char * const group_name ); hid_t -_h5_open_group ( +h5priv_open_group ( h5_file_t *f, const hid_t loc_id, const char * const group_name ); h5_err_t -_hdf_close_group ( +h5priv_close_hdf5_group ( h5_file_t * const f, const hid_t group_id ); hsize_t -_hdf_get_num_objs_in_group ( +h5priv_get_num_objs_in_hdf5_group ( h5_file_t * const f, const hid_t group_id ); h5_err_t -_hdf_get_objname_by_idx_in_group ( +h5priv_get_objname_by_idx_in_hdf5_group ( h5_file_t * const f, hid_t loc_id, hsize_t idx, @@ -44,14 +44,14 @@ _hdf_get_objname_by_idx_in_group ( /*** dataset ***/ hid_t -_hdf_open_dataset ( +h5priv_open_hdf5_dataset ( h5_file_t * const f, const hid_t gid, const char * const dataset_name ); hid_t -_hdf_create_dataset ( +h5priv_create_hdf5_dataset ( h5_file_t * const f, hid_t loc_id, const char * dataset_name, @@ -61,14 +61,14 @@ _hdf_create_dataset ( ); herr_t -_hdf_close_dataset ( +h5priv_close_hdf5_dataset ( h5_file_t * const f, const hid_t dataset_id ); herr_t -_hdf_write_dataset ( +h5priv_write_hdf5_dataset ( h5_file_t * const f, const hid_t dataset_id, const hid_t type_id, @@ -79,7 +79,7 @@ _hdf_write_dataset ( ); h5_err_t -_hdf_read_dataset ( +h5priv_read_hdf5_dataset ( h5_file_t * const f, const hid_t dataset_id, const hid_t type_id, @@ -89,26 +89,26 @@ _hdf_read_dataset ( void * const buf ); hid_t -_hdf_get_dataset_type ( +h5priv_get_hdf5_dataset_type ( h5_file_t * const f, const hid_t dataset_id ); herr_t -_hdf_set_dataset_extent ( +h5priv_set_hdf5_dataset_extent ( h5_file_t * const f, hid_t dset_id, const hsize_t *size ); hssize_t -_hdf_get_npoints_of_dataset ( +h5priv_get_npoints_of_hdf5_dataset ( h5_file_t * const f, hid_t dset_id ); hssize_t -_hdf_get_npoints_of_dataset_by_name ( +h5priv_get_npoints_of_hdf5_dataset_by_name ( h5_file_t * const f, hid_t loc_id, char * name @@ -116,7 +116,7 @@ _hdf_get_npoints_of_dataset_by_name ( /*** dataspace ***/ hid_t -_hdf_create_dataspace ( +h5priv_create_hdf5_dataspace ( h5_file_t * const f, const int rank, const hsize_t * dims, @@ -124,13 +124,13 @@ _hdf_create_dataspace ( ); hid_t -_hdf_get_dataset_space ( +h5priv_get_hdf5_dataset_space ( h5_file_t * const f, const hid_t dataset_id ); herr_t -_hdf_select_hyperslab_of_dataspace ( +h5priv_select_hyperslab_of_hdf5_dataspace ( h5_file_t * const f, hid_t space_id, H5S_seloper_t op, @@ -141,25 +141,25 @@ _hdf_select_hyperslab_of_dataspace ( ); hssize_t -_hdf_get_selected_npoints_of_dataspace ( +h5priv_get_selected_npoints_of_hdf5_dataspace ( h5_file_t * const f, hid_t space_id ); hssize_t -_hdf_get_npoints_of_dataspace ( +h5priv_get_npoints_of_hdf5_dataspace ( h5_file_t * const f, hid_t space_id ); herr_t -_hdf_close_dataspace ( +h5priv_close_hdf5_dataspace ( h5_file_t * const f, const hid_t dataspace_id ); int -_hdf_get_dims_of_dataspace ( +h5priv_get_dims_of_hdf5_dataspace ( h5_file_t * const f, hid_t space_id, hsize_t *dims, @@ -168,7 +168,7 @@ _hdf_get_dims_of_dataspace ( /*** type ***/ hid_t -_hdf_create_array_type ( +h5priv_create_hdf5_array_type ( h5_file_t * const f, hid_t base_type_id, int rank, @@ -176,14 +176,14 @@ _hdf_create_array_type ( ); hid_t -_hdf_create_type ( +h5priv_create_hdf5_type ( h5_file_t * const f, H5T_class_t _class, const size_t size ); herr_t -_hdf_insert_type ( +h5priv_insert_hdf5_type ( h5_file_t * const f, hid_t dtype_id, const char * name, @@ -192,20 +192,20 @@ _hdf_insert_type ( ); herr_t -_hdf_close_type ( +h5priv_close_hdf5_type ( h5_file_t * const f, hid_t dtype_id ); /*** property ***/ hid_t -_hdf_create_property ( +h5priv_create_hdf5_property ( h5_file_t * const f, hid_t cls_id ); herr_t -_hdf_set_chunk_property ( +h5priv_set_hdf5_chunk_property ( h5_file_t * const f, hid_t plist, int ndims, @@ -214,7 +214,7 @@ _hdf_set_chunk_property ( #ifdef PARALLEL_IO h5_err_t -_hdf_set_fapl_mpio_property ( +h5priv_set_hdf5_fapl_mpio_property ( h5_file_t * const f, hid_t fapl_id, MPI_Comm comm, @@ -223,21 +223,21 @@ _hdf_set_fapl_mpio_property ( #endif h5_err_t -_hdf_close_property ( +h5priv_close_hdf5_property ( h5_file_t * const f, hid_t prop ); /*** file ***/ herr_t -_hdf_close_file ( +h5priv_close_hdf5_file ( h5_file_t * const f, hid_t fileid ); /*** error handling ***/ herr_t -_hdf_set_errorhandler ( +h5priv_set_hdf5_errorhandler ( h5_file_t * const f, hid_t estack_id, H5E_auto_t func, @@ -246,21 +246,21 @@ _hdf_set_errorhandler ( /*** attributes ***/ hid_t -_hdf_open_attribute ( +h5priv_open_hdf5_attribute ( h5_file_t * const f, hid_t loc_id, const char *attr_name ); hid_t -_hdf_open_attribute_idx ( +h5priv_open_hdf5_attribute_idx ( h5_file_t * const f, hid_t loc_id, unsigned int idx ); hid_t -_hdf_open_attribute_by_name ( +h5priv_open_hdf5_attribute_by_name ( h5_file_t * const f, hid_t loc_id, const char *obj_name, @@ -268,19 +268,7 @@ _hdf_open_attribute_by_name ( ); hid_t -_hdf_open_attribute_by_idx ( - h5_file_t * const f, - hid_t loc_id, - const char *obj_name, - H5_index_t idx_type, - H5_iter_order_t order, - hsize_t n, - hid_t aapl_id, - hid_t lapl_id - ); - -hid_t -_hdf_create_attribute ( +h5priv_create_hdf5_attribute ( h5_file_t * const f, hid_t loc_id, const char *attr_name, @@ -291,7 +279,7 @@ _hdf_create_attribute ( ); herr_t -_hdf_read_attribute ( +h5priv_read_hdf5_attribute ( h5_file_t * const f, hid_t attr_id, hid_t mem_type_id, @@ -299,7 +287,7 @@ _hdf_read_attribute ( ); herr_t -_hdf_write_attribute ( +h5priv_write_hdf5_attribute ( h5_file_t * const f, hid_t attr_id, hid_t mem_type_id, @@ -307,7 +295,7 @@ _hdf_write_attribute ( ); ssize_t -_hdf_get_attribute_name ( +h5priv_get_hdf5_attribute_name ( h5_file_t * const f, hid_t attr_id, size_t buf_size, @@ -315,26 +303,35 @@ _hdf_get_attribute_name ( ); hid_t -_hdf_get_attribute_type ( +h5priv_get_hdf5_attribute_type ( h5_file_t * const f, hid_t attr_id ); hid_t -_hdf_get_attribute_dataspace ( +h5priv_get_hdf5_attribute_dataspace ( h5_file_t * const f, hid_t attr_id ); int -_hdf_get_num_attributes ( +h5priv_get_num_hdf5_attribute ( h5_file_t * const f, hid_t loc_id ); herr_t -_hdf_close_attribute ( +h5priv_close_hdf5_attribute ( h5_file_t * const f, hid_t attr_id ); + +/*** link ***/ +herr_t +h5priv_delete_hdf5_link ( + h5_file_t * const f, + hid_t loc_id, + const char *name, + hid_t lapl_id + ); #endif diff --git a/src/h5_core/h5_hsearch.c b/src/h5_core/h5_hsearch.c index 2228f9a..7bee90b 100644 --- a/src/h5_core/h5_hsearch.c +++ b/src/h5_core/h5_hsearch.c @@ -60,7 +60,7 @@ isprime (const unsigned int number) { The contents of the table is zeroed, especially the field used becomes zero. */ h5_err_t -_h5_hcreate ( +h5priv_hcreate ( h5_file_t * const f, size_t nel, h5_hashtable_t *htab, @@ -82,7 +82,7 @@ _h5_hcreate ( htab->compute_hash = compute_hash; /* allocate memory and zero out */ - TRY ( (htab->table = (_ENTRY *) _h5_calloc ( + TRY ( (htab->table = (_ENTRY *) h5priv_calloc ( f, htab->size + 1, sizeof (_ENTRY)) ) ); /* everything went alright */ @@ -94,7 +94,7 @@ _h5_hcreate ( or equal the current size. */ h5_err_t -_h5_hresize ( +h5priv_hresize ( h5_file_t * const f, size_t nel, h5_hashtable_t *htab @@ -108,13 +108,13 @@ _h5_hresize ( nel += htab->size; h5_debug ( f, "Resize hash table from %u to %lu elements.", htab->size, nel ); - TRY ( _h5_hcreate ( + TRY ( h5priv_hcreate ( f, nel, &__htab, htab->compare, htab->compute_hash ) ); unsigned int idx; for ( idx = 1; idx <= htab->size; idx++ ) { if ( htab->table[idx].used ) { void *ventry; - _h5_hsearch ( + h5priv_hsearch ( f, htab->table[idx].entry, H5_ENTER, @@ -122,14 +122,15 @@ _h5_hresize ( &__htab ); } } - TRY ( _h5_hdestroy ( f, htab ) ); + TRY ( h5priv_hdestroy ( f, htab ) ); *htab = __htab; return H5_SUCCESS; } + /* After using the hash table it has to be destroyed. The used memory can be freed and the local static variable can be marked as not used. */ h5_err_t -_h5_hdestroy ( +h5priv_hdestroy ( h5_file_t * const f, struct hsearch_data *htab ) { @@ -139,7 +140,7 @@ _h5_hdestroy ( } /* Free used memory. */ - TRY ( _h5_free ( f, htab->table ) ); + TRY ( h5priv_free ( f, htab->table ) ); /* the sign for an existing table is an value != NULL in htable */ htab->table = NULL; @@ -162,7 +163,7 @@ _h5_hdestroy ( equality of the stored and the parameter value. This helps to prevent unnecessary expensive calls of strcmp. */ h5_err_t -_h5_hsearch ( +h5priv_hsearch ( h5_file_t * const f, void *item, const h5_action_t action, @@ -215,7 +216,7 @@ _h5_hsearch ( } /* An empty bucket has been found. */ - if (action == H5_ENTER) { + if ( action == H5_ENTER ) { /* If table is full and another entry should be entered return with error. */ if (htab->filled == htab->size) { @@ -231,6 +232,10 @@ _h5_hsearch ( *retval = htab->table[idx].entry; return H5_SUCCESS; + } else if ( action == H5_REMOVE ) { + htab->table[idx].used = 0; /* mark as unused, but */ + *retval = htab->table[idx].entry; /* return ptr to entry */ + return H5_SUCCESS; } *retval = NULL; h5_error ( f, H5_ERR_INVAL, "Key not found in hash table." ); @@ -238,7 +243,7 @@ _h5_hsearch ( } h5_err_t -_h5_hwalk ( +h5priv_hwalk ( h5_file_t* f, struct hsearch_data *htab, h5_err_t (*visit)(h5_file_t*const f, const void *item) @@ -282,12 +287,12 @@ _hcompute_string_keyed ( } h5_err_t -_h5_hcreate_string_keyed ( +h5priv_hcreate_string_keyed ( h5_file_t * const f, size_t nel, h5_hashtable_t *htab ) { - return _h5_hcreate ( f, nel, htab, + return h5priv_hcreate ( f, nel, htab, _hcmp_string_keyed, _hcompute_string_keyed ); } @@ -316,11 +321,11 @@ _hcompute_id_keyed ( } h5_err_t -_h5_hcreate_id_keyed ( +h5priv_hcreate_id_keyed ( h5_file_t * const f, size_t nel, h5_hashtable_t *htab ) { - return _h5_hcreate ( f, nel, htab, + return h5priv_hcreate ( f, nel, htab, _hcmp_id_keyed, _hcompute_id_keyed ); } diff --git a/src/h5_core/h5_hsearch_private.h b/src/h5_core/h5_hsearch_private.h index 0412b38..7e83691 100644 --- a/src/h5_core/h5_hsearch_private.h +++ b/src/h5_core/h5_hsearch_private.h @@ -12,7 +12,8 @@ typedef struct hsearch_data { /* Action which shall be performed in the call to hsearch. */ typedef enum { H5_FIND, - H5_ENTER + H5_ENTER, + H5_REMOVE } h5_action_t; typedef struct h5_entry { @@ -22,7 +23,7 @@ typedef struct h5_entry { /* Reentrant versions which can handle multiple hashing tables at the same time. */ extern h5_err_t -_h5_hsearch ( +h5priv_hsearch ( h5_file_t * const f, void *item, const h5_action_t action, @@ -31,7 +32,7 @@ _h5_hsearch ( ); extern h5_err_t -_h5_hcreate ( +h5priv_hcreate ( h5_file_t* const f, size_t __nel, h5_hashtable_t *__htab, @@ -40,34 +41,34 @@ _h5_hcreate ( ); extern h5_err_t -_h5_hresize ( +h5priv_hresize ( h5_file_t * const f, size_t nel, h5_hashtable_t *htab ); extern h5_err_t -_h5_hdestroy ( +h5priv_hdestroy ( h5_file_t* f, h5_hashtable_t *__htab ); extern h5_err_t -_h5_hwalk ( +h5priv_hwalk ( h5_file_t* f, h5_hashtable_t *__htab, h5_err_t (*visit)(h5_file_t*const f, const void *__item) ); extern h5_err_t -_h5_hcreate_string_keyed ( +h5priv_hcreate_string_keyed ( h5_file_t * const f, size_t nel, h5_hashtable_t *htab ); h5_err_t -_h5_hcreate_id_keyed ( +h5priv_hcreate_id_keyed ( h5_file_t * const f, size_t nel, h5_hashtable_t *htab diff --git a/src/h5_core/h5_maps.c b/src/h5_core/h5_maps.c index 09fcc97..605f0f5 100644 --- a/src/h5_core/h5_maps.c +++ b/src/h5_core/h5_maps.c @@ -7,21 +7,21 @@ #include "h5_core_private.h" h5_err_t -_h5_alloc_idlist_items ( +h5priv_alloc_idlist_items ( h5_file_t * const f, h5_idlist_t *list, const h5_size_t size ) { int new = ( list->items == NULL ); size_t size_in_bytes = size * sizeof ( list->items[0] ); - TRY ( list->items = _h5_alloc ( f, list->items, size_in_bytes ) ); + TRY ( list->items = h5priv_alloc ( f, list->items, size_in_bytes ) ); list->size = size; if ( new ) list->num_items = 0; return H5_SUCCESS; } h5_err_t -_h5_free_idlist_items ( +h5priv_free_idlist_items ( h5_file_t * const f, h5_idlist_t *list ) { @@ -33,33 +33,33 @@ _h5_free_idlist_items ( } h5_err_t -_h5_alloc_idlist ( +h5priv_alloc_idlist ( h5_file_t * const f, h5_idlist_t **list, const h5_size_t size ) { - TRY ( ( *list = _h5_alloc ( f, NULL, sizeof (**list) ) ) ); + TRY ( ( *list = h5priv_alloc ( f, NULL, sizeof (**list) ) ) ); memset ( *list, 0, sizeof(**list) ); size_t size_in_bytes = size * sizeof ( (*list)->items[0] ); - TRY ( (*list)->items = _h5_alloc ( f, (*list)->items, size_in_bytes ) ); + TRY ( (*list)->items = h5priv_alloc ( f, (*list)->items, size_in_bytes ) ); (*list)->size = size; return H5_SUCCESS; } h5_err_t -_h5_free_idlist ( +h5priv_free_idlist ( h5_file_t * const f, h5_idlist_t **list ) { if ( *list == NULL ) return H5_SUCCESS; - TRY ( _h5_free_idlist_items ( f, *list ) ); - TRY ( _h5_free( f, *list ) ); + TRY ( h5priv_free_idlist_items ( f, *list ) ); + TRY ( h5priv_free( f, *list ) ); *list = NULL; return H5_SUCCESS; } h5_err_t -_h5_append_to_idlist ( +h5priv_append_to_idlist ( h5_file_t * const f, h5_idlist_t *list, h5_id_t id @@ -71,19 +71,19 @@ _h5_append_to_idlist ( } else { size *= 2; } - TRY ( _h5_alloc_idlist_items ( f, list, size ) ); + TRY ( h5priv_alloc_idlist_items ( f, list, size ) ); } list->items[list->num_items++] = id; return H5_SUCCESS; } int -_h5_cmp_ids_by_eid ( +h5priv_cmp_ids_by_eid ( const void *_id1, const void *_id2 ) { - h5_id_t id1 = _h5t_get_elem_idx ( *(h5_id_t*)_id1 ); - h5_id_t id2 = _h5t_get_elem_idx ( *(h5_id_t*)_id2 ); + h5_id_t id1 = h5tpriv_get_elem_idx ( *(h5_id_t*)_id1 ); + h5_id_t id2 = h5tpriv_get_elem_idx ( *(h5_id_t*)_id2 ); if ( id1 < id2 ) return -1; if ( id1 > id2 ) return 1; @@ -91,7 +91,7 @@ _h5_cmp_ids_by_eid ( } int -_h5_cmp_ids ( +h5priv_cmp_ids ( const void *_id1, const void *_id2 ) { @@ -104,7 +104,7 @@ _h5_cmp_ids ( } h5_err_t -_h5_sort_idlist_by_eid ( +h5priv_sort_idlist_by_eid ( h5_file_t * const f, h5_idlist_t *list ) { @@ -112,7 +112,7 @@ _h5_sort_idlist_by_eid ( list->items, list->num_items, sizeof(list->items[0]), - _h5_cmp_ids_by_eid ); + h5priv_cmp_ids_by_eid ); return H5_SUCCESS; } @@ -121,7 +121,7 @@ _h5_sort_idlist_by_eid ( Find ID in sorted list */ h5_id_t -_h5_find_idlist ( +h5priv_find_idlist ( h5_file_t * const f, h5_idlist_t *list, h5_id_t item @@ -145,7 +145,7 @@ _h5_find_idlist ( Add item to list at position given by \c idx. */ h5_id_t -_h5_insert_idlist ( +h5priv_insert_idlist ( h5_file_t * const f, h5_idlist_t *list, h5_id_t item, @@ -158,7 +158,7 @@ _h5_insert_idlist ( } else { size *= 2; } - TRY ( _h5_alloc_idlist_items ( f, list, size ) ); + TRY ( h5priv_alloc_idlist_items ( f, list, size ) ); } memmove ( &list->items[idx+1], @@ -173,35 +173,35 @@ _h5_insert_idlist ( Search in sorted list. If item is not in list, add it. */ h5_id_t -_h5_search_idlist ( +h5priv_search_idlist ( h5_file_t * const f, h5_idlist_t *list, h5_id_t item ) { - h5_id_t idx = _h5_find_idlist ( f, list, item ); + h5_id_t idx = h5priv_find_idlist ( f, list, item ); if ( idx < 0 ) { idx = -(idx+1); - idx = _h5_insert_idlist ( f, list, item, idx ); + idx = h5priv_insert_idlist ( f, list, item, idx ); } return idx; } h5_err_t -_h5_alloc_idmap ( +h5priv_alloc_idmap ( h5_file_t * const f, h5_idmap_t *map, const h5_size_t size ) { 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 = h5priv_alloc ( f, map->items, size_in_bytes ) ); map->size = size; if ( new ) map->num_items = 0; return H5_SUCCESS; } h5_err_t -_h5_insert_idmap ( +h5priv_insert_idmap ( h5_file_t * const f, h5_idmap_t *map, h5_id_t global_id, @@ -211,7 +211,7 @@ _h5_insert_idmap ( if ( map->num_items == map->size ) return HANDLE_H5_OVERFLOW_ERR( f, "g2lmap", map->size ); - h5_id_t i = _h5_search_idmap ( map, global_id ); + h5_id_t i = h5priv_search_idmap ( map, global_id ); if ( i >= 0 ) /* global id already in use ? */ return -1; @@ -239,7 +239,7 @@ _h5_insert_idmap ( */ h5_id_t -_h5_search_idmap ( +h5priv_search_idmap ( h5_idmap_t *map, h5_id_t value ) { @@ -274,7 +274,7 @@ _cmp_idmap_items ( } h5_err_t -_h5_sort_idmap ( +h5priv_sort_idmap ( h5_idmap_t *map ) { qsort ( diff --git a/src/h5_core/h5_maps.h b/src/h5_core/h5_maps.h index 7853637..79641bf 100644 --- a/src/h5_core/h5_maps.h +++ b/src/h5_core/h5_maps.h @@ -2,65 +2,65 @@ #define __H5_MAPS_H h5_err_t -_h5_alloc_idlist ( +h5priv_alloc_idlist ( h5_file_t * const f, h5_idlist_t **list, const h5_size_t size ); h5_err_t -_h5_free_idlist ( +h5priv_free_idlist ( h5_file_t * const f, h5_idlist_t **list ); h5_err_t -_h5_alloc_idlist_items ( +h5priv_alloc_idlist_items ( h5_file_t * const f, h5_idlist_t *list, const h5_size_t size ); h5_err_t -_h5_free_idlist_items ( +h5priv_free_idlist_items ( h5_file_t * const f, h5_idlist_t *list ); h5_err_t -_h5_append_to_idlist ( +h5priv_append_to_idlist ( h5_file_t * const f, h5_idlist_t *list, h5_id_t id ); int -_h5_cmp_ids_by_eid ( +h5priv_cmp_ids_by_eid ( const void *_id1, const void *_id2 ); int -_h5_cmp_ids ( +h5priv_cmp_ids ( const void *_id1, const void *_id2 ); h5_err_t -_h5_sort_idlist_by_eid ( +h5priv_sort_idlist_by_eid ( h5_file_t * const f, h5_idlist_t *list ); h5_id_t -_h5_find_idlist ( +h5priv_find_idlist ( h5_file_t * const f, h5_idlist_t *list, h5_id_t item ); h5_id_t -_h5_insert_idlist ( +h5priv_insert_idlist ( h5_file_t * const f, h5_idlist_t *list, h5_id_t item, @@ -68,21 +68,21 @@ _h5_insert_idlist ( ); h5_id_t -_h5_search_idlist ( +h5priv_search_idlist ( h5_file_t * const f, h5_idlist_t *list, h5_id_t item ); h5_err_t -_h5_alloc_idmap ( +h5priv_alloc_idmap ( h5_file_t * const f, h5_idmap_t *map, const h5_size_t size ); h5_err_t -_h5_insert_idmap ( +h5priv_insert_idmap ( h5_file_t * const f, h5_idmap_t *map, h5_id_t global_id, @@ -90,13 +90,13 @@ _h5_insert_idmap ( ); h5_id_t -_h5_search_idmap ( +h5priv_search_idmap ( h5_idmap_t *map, h5_id_t value ); h5_err_t -_h5_sort_idmap ( +h5priv_sort_idmap ( h5_idmap_t *map ); diff --git a/src/h5_core/h5_mpi.c b/src/h5_core/h5_mpi.c index d96865f..112471b 100644 --- a/src/h5_core/h5_mpi.c +++ b/src/h5_core/h5_mpi.c @@ -5,7 +5,7 @@ #ifdef PARALLEL_IO h5_err_t -_h5_mpi_allgather ( +h5priv_mpi_allgather ( h5_file_t * const f, void * sendbuf, const int sendcount, @@ -32,7 +32,7 @@ _h5_mpi_allgather ( } h5_err_t -_h5_mpi_comm_size ( +h5priv_mpi_comm_size ( h5_file_t * const f, MPI_Comm comm, int *size @@ -49,7 +49,7 @@ _h5_mpi_comm_size ( h5_err_t -_h5_mpi_comm_rank ( +h5priv_mpi_comm_rank ( h5_file_t * const f, MPI_Comm comm, int *rank diff --git a/src/h5_core/h5_mpi_private.h b/src/h5_core/h5_mpi_private.h index b81dc6f..f83e43f 100644 --- a/src/h5_core/h5_mpi_private.h +++ b/src/h5_core/h5_mpi_private.h @@ -3,7 +3,7 @@ #ifdef PARALLEL_IO h5_err_t -_h5_mpi_allgather ( +h5priv_mpi_allgather ( h5_file_t * const f, void * sendbuf, const int sendcount, @@ -15,14 +15,14 @@ _h5_mpi_allgather ( ); h5_err_t -_h5_mpi_comm_size ( +h5priv_mpi_comm_size ( h5_file_t * const f, MPI_Comm comm, int *size ); h5_err_t -_h5_mpi_comm_rank ( +h5priv_mpi_comm_rank ( h5_file_t * const f, MPI_Comm comm, int *rank diff --git a/src/h5_core/h5_openclose.c b/src/h5_core/h5_openclose.c index 1ba87a5..9e507b2 100644 --- a/src/h5_core/h5_openclose.c +++ b/src/h5_core/h5_openclose.c @@ -40,7 +40,7 @@ h5_check_filehandle ( Initialize H5Part */ static herr_t -_h5_error_handler ( +h5priv_error_handler ( hid_t estack_id, void* __f ) { @@ -60,10 +60,10 @@ _h5_error_handler ( \return H5_SUCCESS or error code */ static h5_int64_t -_h5u_open_file ( +h5upriv_open_file ( h5_file_t *f /*!< IN: file handle */ ) { - TRY ( f->u = (h5u_fdata_t*) _h5_alloc( f, NULL, sizeof (*f->u) ) ); + TRY ( f->u = (h5u_fdata_t*) h5priv_alloc( f, NULL, sizeof (*f->u) ) ); h5u_fdata_t *u = f->u; u->shape = 0; @@ -72,7 +72,7 @@ _h5u_open_file ( u->viewstart = -1; u->viewend = -1; size_t size = f->nprocs * sizeof (h5_int64_t); - TRY ( u->pnparticles = _h5_alloc ( f, NULL, size ) ); + TRY ( u->pnparticles = h5priv_alloc ( f, NULL, size ) ); return H5_SUCCESS; } @@ -87,22 +87,22 @@ _h5u_open_file ( \return H5_SUCCESS or error code */ static h5_int64_t -_h5b_open_file ( +h5bpriv_open_block ( h5_file_t *f /*!< IN: file handle */ ) { h5b_fdata_t *b; if ( f->b ) return H5_SUCCESS; - TRY ( f->b = (h5b_fdata_t*) _h5_alloc ( f, NULL, sizeof (*f->b) ) ); + TRY ( f->b = (h5b_fdata_t*) h5priv_alloc ( f, NULL, sizeof (*f->b) ) ); b = f->b; memset ( b, 0, sizeof (*b) ); size_t size = f->nprocs * sizeof (b->user_layout[0]); - TRY ( b->user_layout = _h5_alloc ( f, NULL, size ) ); + TRY ( b->user_layout = h5priv_alloc ( f, NULL, size ) ); size = f->nprocs * sizeof (b->write_layout[0]); - TRY ( b->write_layout = _h5_alloc ( f, NULL, size ) ); + TRY ( b->write_layout = h5priv_alloc ( f, NULL, size ) ); b->step_idx = -1; b->blockgroup = -1; @@ -126,7 +126,7 @@ _h5b_open_file ( */ h5_err_t -_h5_open_file ( +h5priv_open_file ( h5_file_t * const f, const char *filename, /*!< The name of the data file to open. */ h5_int32_t flags, /*!< The access mode for the file. */ @@ -134,7 +134,7 @@ _h5_open_file ( ) { h5_info ( f, "Opening file %s.", filename ); - TRY ( _hdf_set_errorhandler ( f, H5E_DEFAULT, _h5_error_handler, NULL ) ); + TRY ( h5priv_set_hdf5_errorhandler ( f, H5E_DEFAULT, h5priv_error_handler, NULL ) ); TRY ( h5_set_stepname_fmt ( f, H5PART_GROUPNAME_STEP, 0 ) ); f->xfer_prop = f->create_prop = f->access_prop = H5P_DEFAULT; @@ -145,8 +145,8 @@ _h5_open_file ( #ifdef PARALLEL_IO f->comm = comm; - TRY ( _h5_mpi_comm_size ( f, comm, &f->nprocs ) ); - TRY ( _h5_mpi_comm_rank ( f, comm, &f->myproc ) ); + TRY ( h5priv_mpi_comm_size ( f, comm, &f->nprocs ) ); + TRY ( h5priv_mpi_comm_rank ( f, comm, &f->myproc ) ); /* for the SP2... perhaps different for linux */ MPI_Info info = MPI_INFO_NULL; @@ -154,17 +154,17 @@ _h5_open_file ( /* ks: IBM_large_block_io */ MPI_Info_create(&info); MPI_Info_set(info, "IBM_largeblock_io", "true" ); - TRY ( _hdf_set_fapl_mpio_property ( f, f->access_prop, comm, info ) ); + TRY ( h5priv_set_hdf5_fapl_mpio_property ( f, f->access_prop, comm, info ) ); MPI_Info_free(&info); - TRY ( f->access_prop = _hdf_create_property ( f, H5P_FILE_ACCESS ) ); + TRY ( f->access_prop = h5priv_create_hdf5_property ( f, H5P_FILE_ACCESS ) ); - /*TRY ( f->create_prop = _hdf_create_property ( f, H5P_FILE_CREATE) );*/ + /*TRY ( f->create_prop = h5priv_create_hdf5_property ( f, H5P_FILE_CREATE) );*/ f->create_prop = H5P_DEFAULT; /* xfer_prop: also used for parallel I/O, during actual writes rather than the access_prop which is for file creation. */ - TRY ( f->xfer_prop = _hdf_create_property ( f, H5P_DATASET_XFER ) ); + TRY ( f->xfer_prop = h5priv_create_hdf5_property ( f, H5P_DATASET_XFER ) ); #ifdef COLLECTIVE_IO if (H5Pset_dxpl_mpio (f->xfer_prop,H5FD_MPIO_COLLECTIVE) < 0) { @@ -208,7 +208,7 @@ _h5_open_file ( H5_ERR_HDF5, "Cannot open file \"%s\" with mode \"%d\"", filename, flags ); - TRY ( f->root_gid = _h5_open_group ( f, f->file, "/" ) ); + TRY ( f->root_gid = h5priv_open_group ( f, f->file, "/" ) ); f->mode = flags; f->step_gid = -1; @@ -217,9 +217,9 @@ _h5_open_file ( "%s#%0*lld", f->prefix_step_name, f->width_step_idx, (long long) f->step_idx ); - TRY ( _h5u_open_file ( f ) ); - TRY ( _h5b_open_file ( f ) ); - TRY ( _h5t_open_file ( f ) ); + TRY ( h5upriv_open_file ( f ) ); + TRY ( h5bpriv_open_block ( f ) ); + TRY ( h5tpriv_open_file ( f ) ); return H5_SUCCESS; } @@ -245,7 +245,7 @@ h5_open_file ( } memset (f, 0, sizeof (h5_file_t)); f->__funcname = funcname; - if ( _h5_open_file( f, filename, flags, comm ) < 0 ) { + if ( h5priv_open_file( f, filename, flags, comm ) < 0 ) { if (f != NULL ) { /* Oops, cannot open file. We release the memory allocated for f only, there is most likely more allocated memory we do @@ -270,22 +270,22 @@ h5_open_file ( \return H5_SUCCESS or error code */ static h5_int64_t -_h5u_close_file ( +h5upriv_close_file ( h5_file_t *f /*!< file handle */ ) { struct h5u_fdata *u = f->u; f->__errno = H5_SUCCESS; if( u->shape > 0 ) { - TRY( _hdf_close_dataspace( f, u->shape ) ); + TRY( h5priv_close_hdf5_dataspace( f, u->shape ) ); u->shape = 0; } if( u->diskshape != H5S_ALL ) { - TRY( _hdf_close_dataspace( f, u->diskshape ) ); + TRY( h5priv_close_hdf5_dataspace( f, u->diskshape ) ); u->diskshape = 0; } if( u->memshape != H5S_ALL ) { - TRY( _hdf_close_dataspace( f, u->memshape ) ); + TRY( h5priv_close_hdf5_dataspace( f, u->memshape ) ); u->memshape = 0; } if( u->pnparticles ) { @@ -305,15 +305,15 @@ _h5u_close_file ( \return H5_SUCCESS or error code */ static h5_int64_t -_h5b_close_file ( +h5bpriv_close_block ( h5_file_t *f /*!< IN: file handle */ ) { struct h5b_fdata *b = f->b; - TRY ( _hdf_close_group( f, b->blockgroup ) ); - TRY ( _hdf_close_dataspace( f, b->shape ) ); - TRY ( _hdf_close_dataspace( f, b->diskshape ) ); - TRY ( _hdf_close_dataspace( f, b->memshape ) ); + TRY ( h5priv_close_hdf5_group( f, b->blockgroup ) ); + TRY ( h5priv_close_hdf5_dataspace( f, b->shape ) ); + TRY ( h5priv_close_hdf5_dataspace( f, b->diskshape ) ); + TRY ( h5priv_close_hdf5_dataspace( f, b->memshape ) ); free ( f->b ); f->b = NULL; @@ -337,16 +337,16 @@ h5_close_file ( CHECK_FILEHANDLE ( f ); - TRY( _h5_close_step ( f ) ); - TRY( _h5u_close_file ( f ) ); - TRY( _h5b_close_file ( f ) ); - TRY( _h5t_close_file ( f ) ); - TRY( _hdf_close_group( f, f->step_gid ) ); - TRY( _hdf_close_property ( f, f->xfer_prop ) ); - TRY( _hdf_close_property ( f, f->access_prop ) ); - TRY( _hdf_close_property ( f, f->create_prop ) ); - TRY( _hdf_close_group ( f, f->root_gid ) ); - TRY( _hdf_close_file ( f, f->file ) ); + TRY( h5priv_close_step ( f ) ); + TRY( h5upriv_close_file ( f ) ); + TRY( h5bpriv_close_block ( f ) ); + TRY( h5tpriv_close_file ( f ) ); + TRY( h5priv_close_hdf5_group( f, f->step_gid ) ); + TRY( h5priv_close_hdf5_property ( f, f->xfer_prop ) ); + TRY( h5priv_close_hdf5_property ( f, f->access_prop ) ); + TRY( h5priv_close_hdf5_property ( f, f->create_prop ) ); + TRY( h5priv_close_hdf5_group ( f, f->root_gid ) ); + TRY( h5priv_close_hdf5_file ( f, f->file ) ); free( f ); diff --git a/src/h5_core/h5_openclose.h b/src/h5_core/h5_openclose.h index decfed1..3b89d69 100644 --- a/src/h5_core/h5_openclose.h +++ b/src/h5_core/h5_openclose.h @@ -35,7 +35,7 @@ h5_get_stepname_fmt ( ); h5_err_t -_h5_close_step ( +h5priv_close_step ( h5_file_t * const f ); diff --git a/src/h5_core/h5_qsort.c b/src/h5_core/h5_qsort.c index b37e1e1..71c5956 100644 --- a/src/h5_core/h5_qsort.c +++ b/src/h5_core/h5_qsort.c @@ -106,11 +106,11 @@ __unused #ifdef I_AM_QSORT_R void -_h5_qsort_r(void *a, size_t n, size_t es, void *thunk, cmp_t *cmp) +h5priv_qsort_r(void *a, size_t n, size_t es, void *thunk, cmp_t *cmp) #else #define thunk NULL void -_h5_qsort(void *a, size_t n, size_t es, cmp_t *cmp) +h5priv_qsort(void *a, size_t n, size_t es, cmp_t *cmp) #endif { char *pa, *pb, *pc, *pd, *pl, *pm, *pn; @@ -182,9 +182,9 @@ loop: SWAPINIT(a, es); vecswap(pb, pn - r, r); if ((r = pb - pa) > es) #ifdef I_AM_QSORT_R - _h5_qsort_r(a, r / es, es, thunk, cmp); + h5priv_qsort_r(a, r / es, es, thunk, cmp); #else - _h5_qsort(a, r / es, es, cmp); + h5priv_qsort(a, r / es, es, cmp); #endif if ((r = pd - pc) > es) { /* Iterate rather than recurse to save stack space */ diff --git a/src/h5_core/h5_qsort_private.h b/src/h5_core/h5_qsort_private.h index c3565ff..f72d40b 100644 --- a/src/h5_core/h5_qsort_private.h +++ b/src/h5_core/h5_qsort_private.h @@ -2,7 +2,7 @@ #define __H5_QSORT_PRIVATE_H void -_h5_qsort_r ( +h5priv_qsort_r ( void *a, size_t n, size_t es, @@ -11,7 +11,7 @@ _h5_qsort_r ( ); void -_h5_qsort ( +h5priv_qsort ( void *a, size_t n, size_t es, diff --git a/src/h5_core/h5_readwrite.c b/src/h5_core/h5_readwrite.c index 47375aa..6369a50 100644 --- a/src/h5_core/h5_readwrite.c +++ b/src/h5_core/h5_readwrite.c @@ -26,14 +26,14 @@ h5_write_data ( hid_t dset_id; h5_info ( f, "Writing dataset %s/%s.", h5_get_objname(group_id), name ); - TRY ( dset_id = _hdf_create_dataset ( + TRY ( dset_id = h5priv_create_hdf5_dataset ( f, group_id, name, type_id, diskspace_id, H5P_DEFAULT ) ); - TRY ( _hdf_write_dataset ( + TRY ( h5priv_write_hdf5_dataset ( f, dset_id, type_id, @@ -41,7 +41,7 @@ h5_write_data ( diskspace_id, f->xfer_prop, array ) ); - TRY ( _hdf_close_dataset( f, dset_id ) ); + TRY ( h5priv_close_hdf5_dataset( f, dset_id ) ); f->empty = 0; @@ -57,7 +57,7 @@ h5_write_data ( - Close dataset */ h5_err_t -_h5_write_dataset_by_name ( +h5priv_write_dataset_by_name ( h5_file_t * const f, const hid_t loc_id, h5_dsinfo_t *dsinfo, @@ -79,7 +79,7 @@ _h5_write_dataset_by_name ( h5_warn ( f, "Dataset %s/%s already exist.", h5_get_objname ( loc_id ), dsinfo->name ); - return _h5_handle_file_mode_error( f, f->mode ); + return h5priv_handle_file_mode_error( f, f->mode ); } /* @@ -92,26 +92,26 @@ _h5_write_dataset_by_name ( if ( herr >= 0 ) { /* overwrite dataset */ - TRY ( (dset_id = _hdf_open_dataset ( + TRY ( (dset_id = h5priv_open_hdf5_dataset ( f, loc_id, dsinfo->name ) ) ); - TRY ( (dataspace_id = _hdf_get_dataset_space ( + TRY ( (dataspace_id = h5priv_get_hdf5_dataset_space ( f, dset_id ) ) ); - TRY ( _hdf_set_dataset_extent ( + TRY ( h5priv_set_hdf5_dataset_extent ( f, dset_id, dsinfo->dims ) ); /* exten dataset? */ } else { /* create dataset */ - TRY ( dataspace_id = _hdf_create_dataspace ( + TRY ( dataspace_id = h5priv_create_hdf5_dataspace ( f, dsinfo->rank, dsinfo->dims, dsinfo->max_dims ) ); - TRY ( dset_id = _hdf_create_dataset ( + TRY ( dset_id = h5priv_create_hdf5_dataset ( f, loc_id, dsinfo->name, @@ -121,7 +121,7 @@ _h5_write_dataset_by_name ( } TRY ( memspace_id = (*set_memspace)( f, 0 ) ); TRY ( diskspace_id = (*set_diskspace)( f, dataspace_id ) ); - TRY ( _hdf_write_dataset ( + TRY ( h5priv_write_hdf5_dataset ( f, dset_id, dsinfo->type_id, @@ -129,9 +129,9 @@ _h5_write_dataset_by_name ( diskspace_id, f->xfer_prop, data ) ); - TRY ( _hdf_close_dataspace ( f, diskspace_id ) ); - TRY ( _hdf_close_dataspace ( f, memspace_id ) ); - TRY ( _hdf_close_dataset( f, dset_id ) ); + TRY ( h5priv_close_hdf5_dataspace ( f, diskspace_id ) ); + TRY ( h5priv_close_hdf5_dataspace ( f, memspace_id ) ); + TRY ( h5priv_close_hdf5_dataset( f, dset_id ) ); f->empty = 0; @@ -139,7 +139,7 @@ _h5_write_dataset_by_name ( } h5_err_t -_h5_read_dataset ( +h5priv_read_dataset ( h5_file_t * const f, hid_t dset_id, h5_dsinfo_t *dsinfo, @@ -153,7 +153,7 @@ _h5_read_dataset ( TRY ( (mspace_id = (*set_mspace)( f, dset_id ) ) ); TRY ( (dspace_id = (*set_dspace)( f, dset_id ) ) ); - TRY ( _hdf_read_dataset ( + TRY ( h5priv_read_hdf5_dataset ( f, dset_id, dsinfo->type_id, @@ -161,14 +161,14 @@ _h5_read_dataset ( dspace_id, f->xfer_prop, data ) ); - TRY ( _hdf_close_dataspace ( f, dspace_id ) ); - TRY ( _hdf_close_dataspace ( f, mspace_id ) ); + TRY ( h5priv_close_hdf5_dataspace ( f, dspace_id ) ); + TRY ( h5priv_close_hdf5_dataspace ( f, mspace_id ) ); return H5_SUCCESS; } h5_err_t -_h5_read_dataset_by_name ( +h5priv_read_dataset_by_name ( h5_file_t * const f, hid_t loc_id, h5_dsinfo_t *dsinfo, @@ -178,13 +178,13 @@ _h5_read_dataset_by_name ( ) { hid_t dset_id; - TRY ( (dset_id = _hdf_open_dataset ( + TRY ( (dset_id = h5priv_open_hdf5_dataset ( f, loc_id, dsinfo->name ) ) ); - TRY ( _h5_read_dataset ( f, dset_id, dsinfo, set_mspace, set_dspace, + TRY ( h5priv_read_dataset ( f, dset_id, dsinfo, set_mspace, set_dspace, data ) ); - TRY ( _hdf_close_dataset ( f, dset_id ) ); + TRY ( h5priv_close_hdf5_dataset ( f, dset_id ) ); return H5_SUCCESS; } @@ -194,19 +194,19 @@ static h5_err_t _init_step ( h5_file_t * f ) { - TRY ( _h5t_init_step ( f ) ); + TRY ( h5tpriv_init_step ( f ) ); return H5_SUCCESS; } h5_err_t -_h5_close_step ( +h5priv_close_step ( h5_file_t * f ) { if ( f->step_gid < 0 ) return H5_SUCCESS; - TRY ( _h5t_close_step ( f ) ); - TRY ( _hdf_close_group ( f, f->step_gid ) ); + TRY ( h5tpriv_close_step ( f ) ); + TRY ( h5priv_close_hdf5_group ( f, f->step_gid ) ); f->step_gid = -1; @@ -230,7 +230,7 @@ _set_step ( f->myproc, (long long)f->step_idx, (long long)(size_t) f ); - TRY ( f->step_gid = _h5_open_group ( f, f->file, f->step_name ) ); + TRY ( f->step_gid = h5priv_open_group ( f, f->file, f->step_name ) ); return H5_SUCCESS; } @@ -241,7 +241,7 @@ h5_set_step ( const h5_int64_t step_idx /*!< [in] Step to set. */ ) { - TRY ( _h5_close_step ( f ) ); + TRY ( h5priv_close_step ( f ) ); TRY ( _set_step ( f, step_idx ) ); TRY ( _init_step ( f ) ); @@ -288,11 +288,11 @@ h5_get_dataset_type( hid_t dset_id; hid_t hdf5_type; - TRY( dset_id = _hdf_open_dataset ( f, group_id, dset_name ) ); - TRY ( hdf5_type = _hdf_get_dataset_type ( f, dset_id ) ); + TRY( dset_id = h5priv_open_hdf5_dataset ( f, group_id, dset_name ) ); + TRY ( hdf5_type = h5priv_get_hdf5_dataset_type ( f, dset_id ) ); h5_int64_t type = (h5_int64_t) h5_normalize_h5_type ( f, hdf5_type ); - TRY( _hdf_close_type( f, hdf5_type ) ); - TRY( _hdf_close_dataset( f, dset_id ) ); + TRY( h5priv_close_hdf5_type( f, hdf5_type ) ); + TRY( h5priv_close_hdf5_dataset( f, dset_id ) ); return type; } diff --git a/src/h5_core/h5_readwrite_private.h b/src/h5_core/h5_readwrite_private.h index d626070..b43aac4 100644 --- a/src/h5_core/h5_readwrite_private.h +++ b/src/h5_core/h5_readwrite_private.h @@ -16,7 +16,7 @@ typedef struct h5_dataset_info { } h5_dsinfo_t; h5_err_t -_h5_write_dataset_by_name ( +h5priv_write_dataset_by_name ( h5_file_t * const f, hid_t loc_id, h5_dsinfo_t *ds_info, @@ -26,7 +26,7 @@ _h5_write_dataset_by_name ( ); h5_err_t -_h5_read_dataset ( +h5priv_read_dataset ( h5_file_t * const f, hid_t dset_id, h5_dsinfo_t *ds_info, @@ -36,7 +36,7 @@ _h5_read_dataset ( ); h5_err_t -_h5_read_dataset_by_name ( +h5priv_read_dataset_by_name ( h5_file_t * const f, hid_t loc_id, h5_dsinfo_t *ds_info, diff --git a/src/h5_core/h5_syscall.c b/src/h5_core/h5_syscall.c index 3575be5..efae298 100644 --- a/src/h5_core/h5_syscall.c +++ b/src/h5_core/h5_syscall.c @@ -5,7 +5,7 @@ #include "h5_core_private.h" void * -_h5_alloc ( +h5priv_alloc ( h5_file_t * const f, void *ptr, const size_t size @@ -23,7 +23,7 @@ _h5_alloc ( } void * -_h5_calloc ( +h5priv_calloc ( h5_file_t * const f, const size_t count, const size_t size @@ -41,7 +41,7 @@ _h5_calloc ( } h5_err_t -_h5_free ( +h5priv_free ( h5_file_t * const f, void *ptr ) { @@ -50,7 +50,7 @@ _h5_free ( } void * -_h5_tsearch ( +h5priv_tsearch ( h5_file_t * const f, const void *key, void **rootp, @@ -68,7 +68,7 @@ _h5_tsearch ( } void * -_h5_tfind ( +h5priv_tfind ( h5_file_t * const f, const void *key, void *const *rootp, diff --git a/src/h5_core/h5_syscall_private.h b/src/h5_core/h5_syscall_private.h index e01ab0f..5e98e14 100644 --- a/src/h5_core/h5_syscall_private.h +++ b/src/h5_core/h5_syscall_private.h @@ -2,27 +2,27 @@ #define __H5_SYSCALL_H void * -_h5_alloc ( +h5priv_alloc ( h5_file_t * const f, void *ptr, const size_t size ); void * -_h5_calloc ( +h5priv_calloc ( h5_file_t * const f, const size_t count, const size_t size ); h5_err_t -_h5_free ( +h5priv_free ( h5_file_t * const f, void *ptr ); void * -_h5_tsearch ( +h5priv_tsearch ( h5_file_t * const f, const void *key, void **rootp, @@ -30,7 +30,7 @@ _h5_tsearch ( ); void * -_h5_tfind ( +h5priv_tfind ( h5_file_t * const f, const void *key, void *const *rootp, diff --git a/src/h5_core/h5t_adjacencies.c b/src/h5_core/h5t_adjacencies.c index ed2d11c..6241e40 100644 --- a/src/h5_core/h5t_adjacencies.c +++ b/src/h5_core/h5t_adjacencies.c @@ -1,5 +1,5 @@ /* - Copyright 2006-2009 + Copyright 2006-2010 Paul Scherrer Institut, Villigen, Switzerland; Achim Gsell All rights reserved. @@ -19,632 +19,124 @@ #include "h5_core/h5_core.h" #include "h5_core/h5_core_private.h" -/* - compute T(V) from current level up to highest levels. -*/ -static h5_err_t -_compute_tets_of_vertices ( - h5_file_t * const f - ) { - h5t_fdata_t *t = f->t; - h5_id_t eid = (t->cur_level <= 0 ) ? 0 : t->num_elems[t->cur_level-1]; - h5_elem_ldta_t *tet = tet = &t->elems_ldta[eid]; - h5_id_t num_elems = t->num_elems[t->num_levels-1]; - for ( ;eid < num_elems; eid++, tet++ ) { - int i; - for ( i = 0; i < 4; i++ ) { - h5_id_t vid = tet->local_vids[i]; - TRY ( _h5_append_to_idlist ( - f, - &t->vertices_data[vid].tv, - _h5t_build_vertex_id( i, eid ) ) ); - } - } - return H5_SUCCESS; -} - -/* - Compute T(E) from current level up to highest levels. - */ -static h5_err_t -_compute_tets_of_edges ( - h5_file_t * const f - ) { - h5t_fdata_t *t = f->t; - h5_id_t eid = (t->cur_level <= 0 ) ? 0 : t->num_elems[t->cur_level-1]; - h5_elem_ldta_t *tet = tet = &t->elems_ldta[eid]; - h5_id_t num_elems = t->num_elems[t->num_levels-1]; - h5t_te_entry_t *retval = NULL; - TRY ( _h5t_resize_te_htab ( f, 4*(num_elems-eid) ) ); - for ( ; eid < num_elems; eid++, tet++ ) { - h5_id_t face; - for ( face = 0; face < 6; face++ ) { - TRY ( _h5t_search_te2 ( f, face, eid, &retval ) ); - } - } - return H5_SUCCESS; -} - -static h5_err_t -_compute_tets_of_triangles ( - h5_file_t * const f - ) { - h5t_fdata_t *t = f->t; - h5_id_t eid = (t->cur_level <= 0 ) ? 0 : t->num_elems[t->cur_level-1]; - h5_elem_ldta_t *tet = tet = &t->elems_ldta[eid]; - h5_id_t num_elems = t->num_elems[t->num_levels-1]; - h5t_td_entry_t *retval = NULL; - TRY ( _h5t_resize_td_htab ( f, 4*(num_elems-eid) ) ); - for ( ; eid < num_elems; eid++, tet++ ) { - h5_id_t face; - for ( face = 0; face < 4; face++ ) { - TRY ( _h5t_search_td2 ( f, face, eid, &retval ) ); - } - } - return H5_SUCCESS; -} - -h5_err_t -_h5t_rebuild_adj_data ( - h5_file_t * const f - ) { - clock_t t1 = clock(); - TRY ( _compute_tets_of_vertices ( f ) ); - clock_t t2 = clock(); - fprintf ( stderr, "_compute_tets_of_vertices(): %f\n", - (float)(t2-t1)/CLOCKS_PER_SEC ); - t1 = clock(); - TRY ( _compute_tets_of_edges ( f ) ); - t2 = clock(); - fprintf ( stderr, "_compute_tets_of_edge(): %f\n", - (float)(t2-t1)/CLOCKS_PER_SEC ); - t1 = clock(); - TRY ( _compute_tets_of_triangles ( f ) ); - t2 = clock(); - fprintf ( stderr, "_compute_tets_of_triangle(): %f\n", - (float)(t2-t1)/CLOCKS_PER_SEC ); - - return H5_SUCCESS; -} - -static h5_err_t -_compute_children_of_edge ( - h5_file_t * const f, - h5_id_t kid, - h5_idlist_t *children - ) { - h5t_fdata_t *t = f->t; - h5t_te_entry_t *te; - - TRY ( _h5t_find_te2 ( - f, - _h5t_get_face_id ( kid ), - _h5t_get_elem_idx ( kid ), - &te ) - ); - h5_id_t *edge = te->value.items; - h5_id_t *end = te->value.items+te->value.num_items; - for ( ; edge < end; edge++ ) { - h5_id_t eid = _h5t_get_elem_idx ( *edge ); - h5_id_t face_id = _h5t_get_face_id ( *edge ); - h5_elem_ldta_t *tet = &t->elems_ldta[eid]; - if ( _h5t_elem_is_on_cur_level ( f, tet ) == H5_OK ) { - TRY ( _h5_append_to_idlist ( - f, children, *edge ) - ); - } else { - h5_id_t kids[2]; - TRY ( _h5t_compute_direct_children_of_edge ( - f, - face_id, - tet->local_child_eid, - kids ) ); - TRY ( _compute_children_of_edge ( - f, kids[0], children ) ); - TRY ( _compute_children_of_edge ( - f, kids[1], children ) ); - } - } - return H5_SUCCESS; -} - -/* - Compute all sections of an edge. -*/ -static h5_err_t -_compute_sections_of_edge ( - h5_file_t * const f, - h5_id_t kid, - h5_idlist_t *children - ) { - h5t_fdata_t *t = f->t; - h5t_te_entry_t *te; - - TRY ( _h5t_find_te2 ( - f, - _h5t_get_face_id ( kid ), - _h5t_get_elem_idx ( kid ), - &te ) - ); - h5_id_t *edge = te->value.items; - h5_id_t *end = te->value.items+te->value.num_items; - int refined = 0; - for ( ; edge < end; edge++ ) { - h5_id_t eid = _h5t_get_elem_idx ( *edge ); - h5_id_t face_id = _h5t_get_face_id ( *edge ); - h5_elem_ldta_t *tet = &t->elems_ldta[eid]; - if ( ! _h5t_elem_is_on_cur_level ( f, tet ) == H5_OK ) { - refined = 1; - h5_id_t kids[2]; - TRY ( _h5t_compute_direct_children_of_edge ( - f, - face_id, - tet->local_child_eid, - kids ) ); - TRY ( _compute_sections_of_edge ( - f, kids[0], children ) ); - TRY ( _compute_sections_of_edge ( - f, kids[1], children ) ); - } - } - if ( ! refined ) { - TRY ( _h5_append_to_idlist ( f, children, te->value.items[0] ) ); - } - return H5_SUCCESS; -} - -h5_err_t -_compute_direct_children_of_triangle ( - h5_file_t * const f, - h5_id_t face_id, - h5_id_t eid, - h5_id_t dids[4] - ) { - int off[4][4] = { {1,2,3,7}, {0,2,3,6}, {0,1,3,4}, {0,1,2,5} }; - - if ( ( face_id < 0 ) || ( face_id >= 4 ) ) { - return h5_error_internal ( f, __FILE__, __func__, __LINE__ ); - } - dids[0] = _h5t_build_edge_id ( face_id, eid+off[face_id][0] ); - dids[1] = _h5t_build_edge_id ( face_id, eid+off[face_id][1] ); - dids[2] = _h5t_build_edge_id ( face_id, eid+off[face_id][2] ); - dids[3] = _h5t_build_edge_id ( face_id, eid+off[face_id][3] ); - return H5_SUCCESS; -} - -h5_err_t -_compute_children_of_triangle ( - h5_file_t * const f, - h5_id_t did, - h5_idlist_t *children - ) { - - h5t_fdata_t *t = f->t; - h5t_td_entry_t *td; - - TRY ( _h5t_find_td2 ( - f, - _h5t_get_face_id ( did ), - _h5t_get_elem_idx ( did ), - &td - ) ); - h5_id_t *tri = td->value.items; - h5_id_t *end = td->value.items+td->value.num_items; - for ( ; tri < end; tri++ ) { - h5_id_t eid = _h5t_get_elem_idx ( *tri ); - h5_id_t face_id = _h5t_get_face_id ( *tri ); - h5_elem_ldta_t *tet = &t->elems_ldta[eid]; - if ( _h5t_elem_is_on_cur_level ( f, tet ) == H5_OK ) { - TRY ( _h5_append_to_idlist ( - f, children, *tri ) - ); - } else { - h5_id_t dids[4]; - TRY ( _compute_direct_children_of_triangle ( - f, - face_id, - tet->local_child_eid, - dids ) ); - TRY ( _compute_children_of_triangle ( - f, dids[0], children ) ); - TRY ( _compute_children_of_triangle ( - f, dids[1], children ) ); - TRY ( _compute_children_of_triangle ( - f, dids[2], children ) ); - TRY ( _compute_children_of_triangle ( - f, dids[3], children ) ); - } - } - return H5_SUCCESS; -} - -static h5_err_t -_compute_sections_of_triangle ( - h5_file_t * const f, - h5_id_t did, - h5_idlist_t *children - ) { - h5t_fdata_t *t = f->t; - h5t_td_entry_t *td; - - TRY ( _h5t_find_td2 ( - f, - _h5t_get_face_id ( did ), - _h5t_get_elem_idx ( did ), &td ) ); - h5_id_t *tri = td->value.items; - h5_id_t *end = td->value.items+td->value.num_items; - int refined = 0; - for ( ; tri < end; tri++ ) { - h5_id_t eid = _h5t_get_elem_idx ( *tri ); - h5_id_t face_id = _h5t_get_face_id ( *tri ); - h5_elem_ldta_t *tet = &t->elems_ldta[eid]; - if ( ! _h5t_elem_is_on_cur_level ( f, tet ) == H5_OK ) { - refined = 1; - h5_id_t dids[4]; - TRY ( _compute_direct_children_of_triangle ( - f, - face_id, - tet->local_child_eid, - dids ) ); - TRY ( _compute_sections_of_triangle ( - f, dids[0], children ) ); - TRY ( _compute_sections_of_triangle ( - f, dids[1], children ) ); - TRY ( _compute_sections_of_triangle ( - f, dids[2], children ) ); - TRY ( _compute_sections_of_triangle ( - f, dids[3], children ) ); - - } - } - if ( ! refined ) { - TRY ( _h5_append_to_idlist ( f, children, td->value.items[0] ) ); - } - return H5_SUCCESS; -} -/* - map edge ID to unique ID - if unique ID not in list: add -*/ -static h5_err_t -_add_edge ( - h5_file_t * const f, - h5_idlist_t *list, - h5_id_t face_id, - h5_id_t eid - ) { - h5t_te_entry_t *te; - TRY ( _h5t_find_te2 ( f, face_id, eid, &te ) ); - TRY ( _h5_search_idlist ( f, list, te->value.items[0] ) ); - return H5_SUCCESS; -} - - h5_err_t h5t_get_edges_upadjacent_to_vertex ( h5_file_t * const f, - const h5_id_t vid, + const h5_id_t local_vid, h5_idlist_t **list ) { - TRY ( _h5_alloc_idlist ( f, list, 8 ) ); - - h5t_fdata_t *t = f->t; - h5_idlist_t *tv = &t->vertices_data[vid].tv; - h5_size_t i; - - h5_id_t *vidp = tv->items; - for ( i = 0; i < tv->num_items; i++, vidp++ ) { - h5_id_t eid = _h5t_get_elem_idx ( *vidp ); - h5_id_t face = _h5t_get_face_id ( *vidp ); - h5_elem_ldta_t *tet = &t->elems_ldta[eid]; - - if ( _h5t_elem_is_on_cur_level ( f, tet ) == H5_NOK ) { - continue; - } - int map[4][3] = { {0,2,3}, {0,1,4}, {2,1,5}, {3,4,5} }; - TRY ( _add_edge ( f, *list, map[face][0], eid ) ); - TRY ( _add_edge ( f, *list, map[face][1], eid ) ); - TRY ( _add_edge ( f, *list, map[face][2], eid ) ); - } - return H5_SUCCESS; -} - -static h5_err_t -_add_triangle ( - h5_file_t * const f, - h5_idlist_t *list, - h5_id_t face, - h5_id_t eid - ) { - h5t_td_entry_t *td; - TRY ( _h5t_find_td2 ( f, face, eid, &td ) ); - TRY ( _h5_search_idlist ( f, list, td->value.items[0] ) ); - - return H5_SUCCESS; + return (*f->t->methods.adjacency->get_edges_upadjacent_to_vertex)( + f, local_vid, list); } h5_err_t h5t_get_triangles_upadjacent_to_vertex ( h5_file_t * const f, - const h5_id_t vid, + const h5_id_t local_id, h5_idlist_t **list ) { - TRY ( _h5_alloc_idlist ( f, list, 8 ) ); - - h5t_fdata_t *t = f->t; - h5_idlist_t *tv = &t->vertices_data[vid].tv; - h5_size_t i; - h5_id_t *vidp = tv->items; - for ( i = 0; i < tv->num_items; i++, vidp++ ) { - h5_id_t eid = _h5t_get_elem_idx ( *vidp ); - h5_id_t face = _h5t_get_face_id ( *vidp ); - h5_elem_ldta_t *tet = &t->elems_ldta[eid]; - - if ( _h5t_elem_is_on_cur_level ( f, tet ) == H5_NOK ) { - continue; - } - int map[4][3] = { {1,2,3}, {0,2,3}, {0,1,3}, {0,1,2} }; - TRY ( _add_triangle ( f, *list, map[face][0], eid ) ); - TRY ( _add_triangle ( f, *list, map[face][1], eid ) ); - TRY ( _add_triangle ( f, *list, map[face][2], eid ) ); - } - return H5_SUCCESS; + return (*f->t->methods.adjacency->get_triangles_upadjacent_to_vertex)( + f, local_id, list); } h5_err_t h5t_get_tets_upadjacent_to_vertex ( h5_file_t * const f, - const h5_id_t vid, + const h5_id_t local_id, h5_idlist_t **list ) { - TRY ( _h5_alloc_idlist ( f, list, 8 ) ); - - h5t_fdata_t *t = f->t; - h5_idlist_t *tv = &t->vertices_data[vid].tv; - h5_size_t i; - h5_id_t *vidp = tv->items; - for ( i = 0; i < tv->num_items; i++, vidp++ ) { - h5_id_t eid = _h5t_get_elem_idx ( *vidp ); - h5_elem_ldta_t *tet = &t->elems_ldta[eid]; - - if ( _h5t_elem_is_on_cur_level ( f, tet ) == H5_NOK ) { - continue; - } - TRY ( _h5_search_idlist ( f, *list, eid ) ); - } - return H5_SUCCESS; + return (*f->t->methods.adjacency->get_tets_upadjacent_to_vertex)( + f, local_id, list); } h5_err_t h5t_get_triangles_upadjacent_to_edge ( h5_file_t * const f, - const h5_id_t kid, + const h5_id_t local_id, h5_idlist_t **list ) { - h5_idlist_t *children; - TRY ( _h5_alloc_idlist ( f, &children, 8 ) ); - TRY ( _compute_children_of_edge ( f, kid, children ) ); - TRY ( _h5_alloc_idlist ( f, list, 8 ) ); - h5_id_t *edge = children->items; - h5_id_t *end = children->items+children->num_items; - int map[6][2] = { {2,3}, {0,3}, {1,3}, {1,2}, {0,2}, {0,1} }; - for ( ; edge < end; edge++ ) { - h5_id_t eid = _h5t_get_elem_idx ( *edge ); - h5_id_t face_id = _h5t_get_face_id ( *edge ); - TRY ( _add_triangle ( f, *list, map[face_id][0], eid ) ); - TRY ( _add_triangle ( f, *list, map[face_id][1], eid ) ); - } - TRY ( _h5_free_idlist( f, &children ) ); - - return H5_SUCCESS; + return (*f->t->methods.adjacency->get_triangles_upadjacent_to_edge)( + f, local_id, list); } h5_err_t h5t_get_tets_upadjacent_to_edge ( h5_file_t * const f, - const h5_id_t kid, + const h5_id_t local_id, h5_idlist_t **list ) { - h5_idlist_t *children; - TRY ( _h5_alloc_idlist ( f, &children, 8 ) ); - TRY( _compute_children_of_edge ( f, kid, children ) ); - TRY ( _h5_alloc_idlist ( f, list, 8 ) ); - int i; - h5_id_t *kidp = children->items; - for ( i = 0; i < children->num_items; i++, kidp++ ) { - h5_id_t eid = _h5t_get_elem_idx ( *kidp ); - TRY ( _h5_search_idlist ( f, *list, eid ) ); - } - TRY ( _h5_free_idlist( f, &children ) ); - return H5_SUCCESS; + return (*f->t->methods.adjacency->get_tets_upadjacent_to_edge)( + f, local_id, list); } h5_err_t h5t_get_tets_upadjacent_to_triangle ( h5_file_t * const f, - const h5_id_t did, + const h5_id_t local_id, h5_idlist_t **list ) { - h5_idlist_t *children; - TRY ( _h5_alloc_idlist ( f, &children, 8 ) ); - TRY( _compute_children_of_triangle ( f, did, children ) ); - TRY ( _h5_alloc_idlist ( f, list, 8 ) ); - int i; - h5_id_t *didp = children->items; - for ( i = 0; i < children->num_items; i++ , didp++) { - h5_id_t eid = _h5t_get_elem_idx ( *didp ); - TRY ( _h5_search_idlist ( f, *list, eid ) ); - } - TRY ( _h5_free_idlist( f, &children ) ); - return H5_SUCCESS; + return (*f->t->methods.adjacency->get_tets_upadjacent_to_triangle)( + f, local_id, list); } - h5_err_t h5t_get_vertices_downadjacent_to_edge ( h5_file_t * const f, - const h5_id_t kid, + const h5_id_t local_id, h5_idlist_t **list ) { - h5_idlist_t *children; - TRY ( _h5_alloc_idlist ( f, &children, 8 ) ); - TRY( _compute_sections_of_edge ( f, kid, children ) ); - TRY ( _h5_alloc_idlist ( f, list, 8 ) ); - int i; - h5_id_t *kidp = children->items; - for ( i = 0; i < children->num_items; i++, kidp++ ) { - h5_id_t vids[2]; - TRY ( h5t_get_local_vids_of_edge ( f, *kidp, vids ) ); - TRY ( _h5_search_idlist ( f, *list, vids[0] ) ); - TRY ( _h5_search_idlist ( f, *list, vids[1] ) ); - } - TRY ( _h5_free_idlist( f, &children ) ); - return H5_SUCCESS; + return (*f->t->methods.adjacency->get_vertices_downadjacent_to_edge)( + f, local_id, list); } -/* - Compute downward adjacent vertices of all edges of triangle. - */ h5_err_t h5t_get_vertices_downadjacent_to_triangle ( h5_file_t * const f, - const h5_id_t did, + const h5_id_t local_id, h5_idlist_t **list ) { - h5_idlist_t *children; - TRY ( _h5_alloc_idlist ( f, &children, 8 ) ); - - int map[4][3] = { {1,4,5}, {2,3,5}, {0,3,4}, {0,1,2} }; - h5_id_t face = _h5t_get_face_id ( did ); - h5_id_t eid = _h5t_get_elem_idx ( did ); - - h5_id_t i; - for ( i = 0; i < 3; i++ ) { - TRY( _compute_sections_of_edge ( - f, - _h5t_build_edge_id ( map[face][i], eid ), - children ) ); - } - TRY ( _h5_alloc_idlist ( f, list, 8 ) ); - h5_id_t *kid = children->items; - for ( i = 0; i < children->num_items; i++, kid++ ) { - h5_id_t vids[2]; - TRY ( h5t_get_local_vids_of_edge ( f, *kid, vids ) ); - TRY ( _h5_search_idlist ( f, *list, vids[0] ) ); - TRY ( _h5_search_idlist ( f, *list, vids[1] ) ); - } - TRY ( _h5_free_idlist( f, &children ) ); - return H5_SUCCESS; + return (*f->t->methods.adjacency->get_vertices_downadjacent_to_triangle)( + f, local_id, list); } -/* - Compute downward adjacent vertices of all edges of tetrahedron. - */ h5_err_t h5t_get_vertices_downadjacent_to_tet ( h5_file_t * const f, - const h5_id_t eid, + const h5_id_t local_id, h5_idlist_t **list ) { - h5_idlist_t *children; - TRY ( _h5_alloc_idlist ( f, &children, 8 ) ); - - h5_id_t i; - for ( i = 0; i < 6; i++ ) { - TRY( _compute_sections_of_edge ( - f, - _h5t_build_edge_id ( i, eid ), - children ) ); - } - TRY ( _h5_alloc_idlist ( f, list, 8 ) ); - h5_id_t *kid = children->items; - for ( i = 0; i < children->num_items; i++, kid++ ) { - h5_id_t vids[2]; - TRY ( h5t_get_local_vids_of_edge ( f, *kid, vids ) ); - TRY ( _h5_search_idlist ( f, *list, vids[0] ) ); - TRY ( _h5_search_idlist ( f, *list, vids[1] ) ); - } - TRY ( _h5_free_idlist( f, &children ) ); - return H5_SUCCESS; + return (*f->t->methods.adjacency->get_vertices_downadjacent_to_tet)( + f, local_id, list); } h5_err_t h5t_get_edges_downadjacent_to_triangle ( h5_file_t * const f, - const h5_id_t did, + const h5_id_t local_id, h5_idlist_t **list ) { - h5_idlist_t *children; - TRY ( _h5_alloc_idlist ( f, &children, 8 ) ); - - int map[4][3] = { {1,4,5}, {2,3,5}, {0,3,4}, {0,1,2} }; - h5_id_t face_id = _h5t_get_face_id ( did ); - h5_id_t eid = _h5t_get_elem_idx ( did ); - - h5_id_t i; - for ( i = 0; i < 3; i++ ) { - TRY( _compute_sections_of_edge ( - f, - _h5t_build_edge_id ( map[face_id][i], eid ), - children ) ); - } - TRY ( _h5_alloc_idlist ( f, list, 8 ) ); - h5_id_t *kid = children->items; - for ( i = 0; i < children->num_items; i++, kid++ ) { - TRY ( _h5_search_idlist ( f, *list, *kid ) ); - } - TRY ( _h5_free_idlist( f, &children ) ); - return H5_SUCCESS; + return (*f->t->methods.adjacency->get_edges_downadjacent_to_triangle)( + f, local_id, list); } h5_err_t h5t_get_edges_downadjacent_to_tet ( h5_file_t * const f, - const h5_id_t eid, + const h5_id_t local_id, h5_idlist_t **list ) { - h5_idlist_t *children; - TRY ( _h5_alloc_idlist ( f, &children, 8 ) ); - - h5_id_t i; - for ( i = 0; i < 6; i++ ) { - TRY( _compute_sections_of_edge ( - f, - _h5t_build_edge_id ( i, eid ), - children ) ); - } - TRY ( _h5_alloc_idlist ( f, list, 8 ) ); - h5_id_t *kid = children->items; - for ( i = 0; i < children->num_items; i++, kid++ ) { - TRY ( _h5_search_idlist ( f, *list, *kid ) ); - } - TRY ( _h5_free_idlist( f, &children ) ); - return H5_SUCCESS; + return (*f->t->methods.adjacency->get_edges_downadjacent_to_tet)( + f, local_id, list); } h5_err_t h5t_get_triangles_downadjacent_to_tet ( h5_file_t * const f, - const h5_id_t eid, + const h5_id_t local_id, h5_idlist_t **list ) { - h5_idlist_t *children; - TRY ( _h5_alloc_idlist ( f, &children, 8 ) ); - - h5_id_t i; - for ( i = 0; i < 4; i++ ) { - TRY( _compute_sections_of_triangle ( - f, - _h5t_build_edge_id ( i, eid ), - children ) ); - } - TRY ( _h5_alloc_idlist ( f, list, 8 ) ); - h5_id_t *did = children->items; - for ( i = 0; i < children->num_items; i++, did++ ) { - TRY ( _h5_search_idlist ( f, *list, *did ) ); - } - TRY ( _h5_free_idlist( f, &children ) ); - return H5_SUCCESS; + return (*f->t->methods.adjacency->get_triangles_downadjacent_to_tet)( + f, local_id, list); } h5_err_t @@ -652,14 +144,8 @@ h5t_release_list_of_adjacencies ( h5_file_t * const f, h5_idlist_t **list ) { - TRY ( _h5_free_idlist ( f, list ) ); + TRY ( h5priv_free_idlist ( f, list ) ); return H5_SUCCESS; } -h5_err_t -_h5t_release_adjacencies ( - h5_file_t * const f - ) { - /* TO BE WRITTEN @@@ */ - return H5_SUCCESS; -} + diff --git a/src/h5_core/h5t_consts.c b/src/h5_core/h5t_consts.c index 0294f31..996f3cb 100644 --- a/src/h5_core/h5t_consts.c +++ b/src/h5_core/h5t_consts.c @@ -3,7 +3,7 @@ #include "h5t_types_private.h" const char * -_h5t_oid_names[] = { +h5tpriv_oid_names[] = { "N.N.", "vertex", "edge", @@ -12,7 +12,7 @@ _h5t_oid_names[] = { }; const char * -_h5t_meshes_grpnames[] = { +h5tpriv_meshes_grpnames[] = { "N.N.", "N.N.", "N.N.", @@ -21,7 +21,7 @@ _h5t_meshes_grpnames[] = { }; const size_t -_h5t_sizeof_elem[] = { +h5tpriv_sizeof_elem[] = { 0, 0, 0, @@ -30,11 +30,11 @@ _h5t_sizeof_elem[] = { }; const char * -_h5t_map_oid2str ( +h5tpriv_map_oid2str ( h5_oid_t oid ) { - if ( oid < 0 || oid >= sizeof(_h5t_oid_names)/sizeof(char*) ) { + if ( oid < 0 || oid >= sizeof(h5tpriv_oid_names)/sizeof(char*) ) { return "[invalid oid]"; } - return _h5t_oid_names[oid]; + return h5tpriv_oid_names[oid]; } diff --git a/src/h5_core/h5t_consts_private.h b/src/h5_core/h5t_consts_private.h index 3dde026..c1d2f05 100644 --- a/src/h5_core/h5t_consts_private.h +++ b/src/h5_core/h5t_consts_private.h @@ -1,10 +1,10 @@ #ifndef __H5T_CONSTS_PRIVATE_H #define __H5T_CONSTS_PRIVATE_H -extern const char * _h5t_oid_names[]; -extern const char * _h5t_meshes_grpnames[]; -extern const size_t _h5t_sizeof_elem[]; +extern const char * h5tpriv_oid_names[]; +extern const char * h5tpriv_meshes_grpnames[]; +extern const size_t h5tpriv_sizeof_elem[]; -const char *_h5t_map_oid2str ( h5_oid_t oid ); +const char *h5tpriv_map_oid2str ( h5_oid_t oid ); #endif diff --git a/src/h5_core/h5t_core.h b/src/h5_core/h5t_core.h index 3c2e278..c6ff207 100644 --- a/src/h5_core/h5t_core.h +++ b/src/h5_core/h5t_core.h @@ -2,7 +2,6 @@ #define __H5T_CORE_H #include "h5t_adjacencies.h" -#include "h5t_boundaries.h" #include "h5t_inquiry.h" #include "h5t_map.h" #include "h5t_openclose.h" @@ -41,39 +40,39 @@ #define H5T_ETYPE_TRIANGLE ((h5_id_t)3) #define H5T_ETYPE_TET ((h5_id_t)4) -#define _h5t_set_entity_type( type, elem_idx ) \ +#define h5tpriv_set_entity_type( type, elem_idx ) \ ( \ ((h5_id_t)(type) << (sizeof(h5_id_t)*8-4)) | \ ((h5_id_t)(elem_idx)) \ ) -#define _h5t_get_entity_type( entity_id ) \ +#define h5tpriv_get_entity_type( entity_id ) \ ((entity_id & H5T_ETYPE_MASK) >> (sizeof(h5_id_t)*8-4)) -#define _h5t_build_id( type, comp_idx, elem_idx ) \ +#define h5tpriv_build_id( type, comp_idx, elem_idx ) \ ( \ ((h5_id_t)(type) << (sizeof(h5_id_t)*8-4)) | \ ((h5_id_t)(comp_idx) << (sizeof(h5_id_t)*7)) | \ ((h5_id_t)(elem_idx) & H5T_ELEM_MASK) \ ) -#define _h5t_build_vertex_id( comp_idx, elem_idx ) \ - ( _h5t_build_id ( H5T_ETYPE_VERTEX, comp_idx, elem_idx ) ) +#define h5tpriv_build_vertex_id( comp_idx, elem_idx ) \ + ( h5tpriv_build_id ( H5T_ETYPE_VERTEX, comp_idx, elem_idx ) ) -#define _h5t_build_edge_id( comp_idx, elem_idx ) \ - ( _h5t_build_id ( H5T_ETYPE_EDGE, comp_idx, elem_idx ) ) +#define h5tpriv_build_edge_id( comp_idx, elem_idx ) \ + ( h5tpriv_build_id ( H5T_ETYPE_EDGE, comp_idx, elem_idx ) ) -#define _h5t_build_triangle_id( comp_idx, elem_idx ) \ - ( _h5t_build_id ( H5T_ETYPE_TRIANGLE, comp_idx, elem_idx ) ) +#define h5tpriv_build_triangle_id( comp_idx, elem_idx ) \ + ( h5tpriv_build_id ( H5T_ETYPE_TRIANGLE, comp_idx, elem_idx ) ) -#define _h5t_build_elem_id( elem_idx ) \ - ( _h5t_build_id ( f->t->mesh_type, 0, elem_idx ) ) +#define h5tpriv_build_elem_id( elem_idx ) \ + ( h5tpriv_build_id ( f->t->mesh_type, 0, elem_idx ) ) -#define _h5t_get_face_id( entity_id ) \ +#define h5tpriv_get_face_id( entity_id ) \ ( (entity_id & H5T_COMPONENT_ID_MASK) >> (sizeof(h5_id_t)*7) ) -#define _h5t_get_elem_idx( entity_id ) \ +#define h5tpriv_get_elem_idx( entity_id ) \ ( entity_id & H5T_ELEM_MASK ) #endif diff --git a/src/h5_core/h5t_core_private.h b/src/h5_core/h5t_core_private.h index 7f62865..a2e62ae 100644 --- a/src/h5_core/h5t_core_private.h +++ b/src/h5_core/h5t_core_private.h @@ -3,8 +3,7 @@ #define H5T_CONTAINER_GRPNAME "Topo" -#include "h5t_adjacencies_private.h" -#include "h5t_boundaries_private.h" +#include "h5t_tetm_adjacencies_private.h" #include "h5t_consts_private.h" #include "h5t_errorhandling_private.h" #include "h5t_hsearch_private.h" diff --git a/src/h5_core/h5t_errorhandling.c b/src/h5_core/h5t_errorhandling.c index f6a8827..1286eb2 100644 --- a/src/h5_core/h5t_errorhandling.c +++ b/src/h5_core/h5t_errorhandling.c @@ -11,28 +11,28 @@ h5_err_t -_h5t_error_local_elem_nexist ( +h5tpriv_error_local_elem_nexist ( h5_file_t * const f, h5_id_t local_vids[] ) { - switch ( f->t->mesh_type ) { - case H5_OID_TETRAHEDRON: - return h5_error ( - f, - H5_ERR_NOENTRY, - "Tetrahedron with local vertex IDs " - "(%lld,%lld,%lld,%lld) doesn't exist!", - local_vids[0], local_vids[1], - local_vids[2], local_vids[3] ); - case H5_OID_TRIANGLE: - return h5_error ( - f, - H5_ERR_NOENTRY, - "Triangle with local vertex IDs " - "(%lld,%lld,%lld) doesn't exist!", - local_vids[0], local_vids[1], local_vids[2] ); - default: - return h5_error_internal( f, __FILE__, __func__, __LINE__ ); + char s[1024]; + + int num_chars_printed = snprintf (s, sizeof(s), "%lld,", local_vids[0]); + int i; + for (i = 1; i < f->t->mesh_type; i++) { + num_chars_printed += snprintf ( + s+num_chars_printed, sizeof(s)-num_chars_printed, + "%lld,", local_vids[i]); + if ((sizeof(s) - num_chars_printed) < 32) { + h5_error_internal ( f, __FILE__, __func__, __LINE__ ); + } } + + return h5_error ( + f, + H5_ERR_NOENTRY, + "Element with local vertex IDs " + "(%s) doesn't exist!", + s ); } diff --git a/src/h5_core/h5t_errorhandling_private.h b/src/h5_core/h5t_errorhandling_private.h index b1a2089..830a318 100644 --- a/src/h5_core/h5t_errorhandling_private.h +++ b/src/h5_core/h5t_errorhandling_private.h @@ -2,31 +2,31 @@ #define __H5T_ERRORHANDLING_PRIVATE_H h5_err_t -_h5t_error_local_elem_nexist ( +h5tpriv_error_local_elem_nexist ( h5_file_t * const f, h5_id_t local_vids[] ); -#define _h5t_error_undef_mesh( f ) \ +#define h5tpriv_error_undef_mesh( f ) \ h5_error( \ f, \ H5_ERR_INVAL, \ "Mesh not yet defined." ); -#define _h5t_error_undef_level( f ) \ +#define h5tpriv_error_undef_level( f ) \ h5_error( \ f, \ H5_ERR_INVAL, \ "Level not defined." ); -#define _h5t_error_nexist_level( f, level_id ) \ +#define h5tpriv_error_nexist_level( f, level_id ) \ h5_error( \ f, \ H5_ERR_INVAL, \ "Level %lld doesn't exist.", level_id ); -#define _h5t_error_global_id_nexist( f, name, id ) \ +#define h5tpriv_error_global_id_nexist( f, name, id ) \ h5_error( \ f, \ H5_ERR_NOENTRY, \ @@ -34,14 +34,14 @@ _h5t_error_local_elem_nexist ( name, id ); -#define _h5t_error_global_triangle_id_nexist( f, vids ) \ +#define h5tpriv_error_global_triangle_id_nexist( f, vids ) \ h5_error( \ f, \ H5_ERR_NOENTRY, \ "Triangle with global vertex ids (%lld,%lld,%lld) doesn't exist!", \ vids[0], vids[1], vids[2] ); -#define _h5t_error_local_triangle_nexist( f, local_vids ) \ +#define h5tpriv_error_local_triangle_nexist( f, local_vids ) \ h5_error( \ f, \ H5_ERR_NOENTRY, \ @@ -49,7 +49,7 @@ _h5t_error_local_elem_nexist ( local_vids[0], local_vids[1], local_vids[2] ); -#define _h5t_error_store_boundaryface_local_id( f, local_fid ) \ +#define h5tpriv_error_store_boundaryface_local_id( f, local_fid ) \ h5_error( \ f, \ H5_ERR_INVAL, \ diff --git a/src/h5_core/h5t_hsearch.c b/src/h5_core/h5t_hsearch.c index 804e122..d8c6e65 100644 --- a/src/h5_core/h5t_hsearch.c +++ b/src/h5_core/h5t_hsearch.c @@ -29,12 +29,12 @@ _compute_te_hashval ( } h5_err_t -_h5t_create_te_htab ( +h5tpriv_create_te_htab ( h5_file_t * const f, size_t nel ) { h5t_adjacencies_t *a = &f->t->adjacencies; - return _h5_hcreate ( + return h5priv_hcreate ( f, nel, &a->te_hash, @@ -43,21 +43,21 @@ _h5t_create_te_htab ( } h5_err_t -_h5t_resize_te_htab ( +h5tpriv_resize_te_htab ( h5_file_t * const f, size_t nel ) { h5t_adjacencies_t *a = &f->t->adjacencies; if ( a->te_hash.size == 0 ) { - TRY ( _h5t_create_te_htab ( f, nel ) ); + TRY ( h5tpriv_create_te_htab ( f, nel ) ); } else if ( a->te_hash.size < nel ) { - TRY ( _h5_hresize ( f, nel, &a->te_hash ) ); + TRY ( h5priv_hresize ( f, nel, &a->te_hash ) ); } return H5_SUCCESS; } h5_err_t -_h5t_search_te2 ( +h5tpriv_search_te2 ( h5_file_t * const f, h5_id_t face, h5_id_t eid, @@ -67,7 +67,7 @@ _h5t_search_te2 ( h5t_adjacencies_t *a = &t->adjacencies; void *__retval; - TRY ( *entry = _h5_calloc ( f, 1, sizeof(**entry) ) ); + TRY ( *entry = h5priv_calloc ( f, 1, sizeof(**entry) ) ); TRY ( h5t_get_local_vids_of_edge2 ( f, @@ -79,25 +79,25 @@ _h5t_search_te2 ( */ if ( (a->te_hash.size*6) <= (a->te_hash.filled<<3) ) { h5_id_t num_elems = t->num_elems[t->num_levels-1]; - TRY ( _h5_hresize ( + TRY ( h5priv_hresize ( f, 3*(num_elems - eid), &a->te_hash ) ); } - TRY ( _h5_hsearch ( + TRY ( h5priv_hsearch ( f, *entry, H5_ENTER, &__retval, &a->te_hash ) ); h5t_te_entry_t *retval = (h5t_te_entry_t *)__retval; - TRY ( _h5_search_idlist ( + TRY ( h5priv_search_idlist ( f, &retval->value, - _h5t_build_edge_id ( face, eid ) ) ); + h5tpriv_build_edge_id ( face, eid ) ) ); if ( retval->value.num_items > 1 ) { /* search returned an existing entry */ - TRY ( _h5_free ( f, *entry ) ); + TRY ( h5priv_free ( f, *entry ) ); } return H5_SUCCESS; } @@ -108,13 +108,13 @@ _h5t_search_te2 ( Passing item with type entry type. */ h5_err_t -_h5t_find_te ( +h5tpriv_find_te ( h5_file_t * const f, h5t_te_entry_t *item, h5t_te_entry_t **retval ) { void *__ret; - TRY ( _h5_hsearch ( + TRY ( h5priv_hsearch ( f, item, H5_FIND, @@ -130,7 +130,7 @@ _h5t_find_te ( Passing item with face and local element ID. */ h5_err_t -_h5t_find_te2 ( +h5tpriv_find_te2 ( h5_file_t * const f, h5_id_t face_id, h5_id_t local_eid, @@ -143,7 +143,7 @@ _h5t_find_te2 ( local_eid, item.key.vids ) ); - return _h5t_find_te ( f, &item, retval ); + return h5tpriv_find_te ( f, &item, retval ); } static int @@ -172,12 +172,12 @@ _compute_td_hashval ( } h5_err_t -_h5t_create_td_htab ( +h5tpriv_create_td_htab ( h5_file_t * const f, size_t nel ) { h5t_adjacencies_t *a = &f->t->adjacencies; - return _h5_hcreate ( + return h5priv_hcreate ( f, nel, &a->td_hash, @@ -186,21 +186,21 @@ _h5t_create_td_htab ( } h5_err_t -_h5t_resize_td_htab ( +h5tpriv_resize_td_htab ( h5_file_t * const f, size_t nel ) { h5t_adjacencies_t *a = &f->t->adjacencies; if ( a->td_hash.size == 0 ) { - TRY ( _h5t_create_td_htab ( f, nel ) ); + TRY ( h5tpriv_create_td_htab ( f, nel ) ); } else if ( a->td_hash.size < nel ) { - TRY ( _h5_hresize ( f, nel, &a->td_hash ) ); + TRY ( h5priv_hresize ( f, nel, &a->td_hash ) ); } return H5_SUCCESS; } h5_err_t -_h5t_search_td2 ( +h5tpriv_search_td2 ( h5_file_t * const f, h5_id_t face, h5_id_t eid, @@ -210,7 +210,7 @@ _h5t_search_td2 ( h5t_adjacencies_t *a = &f->t->adjacencies; void *__retval; - TRY ( *entry = _h5_calloc ( f, 1, sizeof(**entry) ) ); + TRY ( *entry = h5priv_calloc ( f, 1, sizeof(**entry) ) ); TRY ( h5t_get_local_vids_of_triangle2 ( f, @@ -222,51 +222,51 @@ _h5t_search_td2 ( */ if ( (a->td_hash.size*6) <= (a->td_hash.filled<<3) ) { h5_id_t num_elems = t->num_elems[t->num_levels-1]; - TRY ( _h5_hresize ( + TRY ( h5priv_hresize ( f, 3*(num_elems-eid), &a->td_hash ) ); } - TRY ( _h5_hsearch ( + TRY ( h5priv_hsearch ( f, *entry, H5_ENTER, &__retval, &a->td_hash ) ); h5t_td_entry_t *retval = (h5t_td_entry_t *)__retval; - TRY ( _h5_search_idlist ( + TRY ( h5priv_search_idlist ( f, &retval->value, - _h5t_build_triangle_id ( face, eid ) ) ); + h5tpriv_build_triangle_id ( face, eid ) ) ); if ( retval->value.num_items > 1 ) { - TRY ( _h5_free ( f, *entry ) ); + TRY ( h5priv_free ( f, *entry ) ); } return H5_SUCCESS; } h5_err_t -_h5t_find_td ( +h5tpriv_find_td ( h5_file_t * const f, h5t_td_entry_t *item, h5t_td_entry_t **retval ) { void *__ret; - _h5_hsearch ( + h5priv_hsearch ( f, item, H5_FIND, &__ret, &f->t->adjacencies.td_hash ); if ( __ret == NULL ) { - return _h5t_error_local_triangle_nexist( f, item->key.vids ); + return h5tpriv_error_local_triangle_nexist( f, item->key.vids ); } *retval = (h5t_td_entry_t *)__ret; return H5_SUCCESS; } h5_err_t -_h5t_find_td2 ( +h5tpriv_find_td2 ( h5_file_t * const f, h5_id_t face_id, h5_id_t local_eid, @@ -278,11 +278,11 @@ _h5t_find_td2 ( face_id, local_eid, item.key.vids ) ); - return _h5t_find_td ( f, &item, retval ); + return h5tpriv_find_td ( f, &item, retval ); } h5_err_t -_h5t_find_tv2 ( +h5tpriv_find_tv2 ( h5_file_t * const f, h5_id_t cid, h5_id_t el_idx, diff --git a/src/h5_core/h5t_hsearch_private.h b/src/h5_core/h5t_hsearch_private.h index f86be8f..6d80065 100644 --- a/src/h5_core/h5t_hsearch_private.h +++ b/src/h5_core/h5t_hsearch_private.h @@ -21,19 +21,19 @@ typedef struct h5_td_entry { h5_err_t -_h5t_create_te_htab ( +h5tpriv_create_te_htab ( h5_file_t * const f, size_t nel ); h5_err_t -_h5t_resize_te_htab ( +h5tpriv_resize_te_htab ( h5_file_t * const f, size_t nel ); h5_err_t -_h5t_search_te2 ( +h5tpriv_search_te2 ( h5_file_t * const f, h5_id_t face_id, h5_id_t local_eid, @@ -41,14 +41,14 @@ _h5t_search_te2 ( ); h5_err_t -_h5t_find_te ( +h5tpriv_find_te ( h5_file_t * const f, h5t_te_entry_t *item, h5t_te_entry_t **retval ); h5_err_t -_h5t_find_te2 ( +h5tpriv_find_te2 ( h5_file_t * const f, h5_id_t face_id, h5_id_t local_eid, @@ -57,19 +57,19 @@ _h5t_find_te2 ( h5_err_t -_h5t_create_td_htab ( +h5tpriv_create_td_htab ( h5_file_t * const f, size_t nel ); h5_err_t -_h5t_resize_td_htab ( +h5tpriv_resize_td_htab ( h5_file_t * const f, size_t nel ); h5_err_t -_h5t_search_td2 ( +h5tpriv_search_td2 ( h5_file_t * const f, h5_id_t face_id, h5_id_t local_eid, @@ -77,14 +77,14 @@ _h5t_search_td2 ( ); h5_err_t -_h5t_find_td ( +h5tpriv_find_td ( h5_file_t * const f, h5t_td_entry_t *item, h5t_td_entry_t **retval ); h5_err_t -_h5t_find_td2 ( +h5tpriv_find_td2 ( h5_file_t * const f, h5_id_t face_id, h5_id_t local_eid, @@ -92,7 +92,7 @@ _h5t_find_td2 ( ); h5_err_t -_h5t_find_tv2 ( +h5tpriv_find_tv2 ( h5_file_t * const f, h5_id_t cid, h5_id_t el_idx, diff --git a/src/h5_core/h5t_inquiry.c b/src/h5_core/h5t_inquiry.c index e764a10..795ab42 100644 --- a/src/h5_core/h5t_inquiry.c +++ b/src/h5_core/h5t_inquiry.c @@ -28,11 +28,11 @@ h5t_get_num_meshes ( return t->num_meshes; } if ( t->topo_gid < 0 ) { - TRY( _h5t_open_topo_group ( f ) ); + TRY( h5tpriv_open_topo_group ( f ) ); } TRY( t->num_meshes = (h5_size_t)hdf5_get_num_objects ( t->topo_gid, - _h5t_meshes_grpnames[type_id], + h5tpriv_meshes_grpnames[type_id], H5G_GROUP ) ); return t->num_meshes; @@ -52,7 +52,7 @@ h5t_get_num_levels ( h5t_fdata_t *t = f->t; if ( t->cur_mesh < 0 ) { - return _h5t_error_undef_mesh ( f ); + return h5tpriv_error_undef_mesh ( f ); } return t->num_levels; } @@ -92,10 +92,10 @@ h5t_get_num_elems ( h5t_fdata_t *t = f->t; if ( t->cur_mesh < 0 ) { - return _h5t_error_undef_mesh ( f ); + return h5tpriv_error_undef_mesh ( f ); } if ( t->cur_level < 0 ) { - return _h5t_error_undef_level ( f ); + return h5tpriv_error_undef_level ( f ); } return t->num_elems_on_level[t->cur_level]; } @@ -121,10 +121,10 @@ h5t_get_num_vertices ( h5t_fdata_t *t = f->t; if ( t->cur_mesh < 0 ) { - return _h5t_error_undef_mesh ( f ); + return h5tpriv_error_undef_mesh ( f ); } if ( t->cur_level < 0 ) { - return _h5t_error_undef_level ( f ); + return h5tpriv_error_undef_level ( f ); } return t->num_vertices[t->cur_level]; } diff --git a/src/h5_core/h5t_map.c b/src/h5_core/h5t_map.c index fb7c6a1..2f5c087 100644 --- a/src/h5_core/h5t_map.c +++ b/src/h5_core/h5t_map.c @@ -23,7 +23,7 @@ _cmp_vertices ( ) { int i; for ( i = 0; i < 3; i++ ) { - h5_int64_t diff = _h5_fcmp ( P0[i], P1[i], 10 ); + h5_int64_t diff = h5priv_fcmp ( P0[i], P1[i], 10 ); if ( diff < 0 ) return -1; else if ( diff > 0 ) return 1; } @@ -50,7 +50,7 @@ _qsort_cmp_vertices ( Sort vertices. Store local id's in a sorted array for binary search. */ h5_err_t -_h5t_sort_vertices ( +h5tpriv_sort_vertices ( h5_file_t * const f ) { h5t_fdata_t *t = f->t; @@ -65,7 +65,7 @@ _h5t_sort_vertices ( } t->sorted_lvertices.num_items = num_vertices; - _h5_qsort_r ( + h5priv_qsort_r ( t->sorted_lvertices.items, num_vertices, sizeof(t->sorted_lvertices.items[0]), @@ -83,7 +83,7 @@ _h5t_sort_vertices ( \return else negativ value */ h5_id_t -_h5t_get_local_vid ( +h5tpriv_get_local_vid ( h5_file_t * const f, h5_float64_t P[3] ) { @@ -210,7 +210,7 @@ _qsort_cmp_elems1 ( binary search. */ h5_err_t -_h5t_sort_elems ( +h5tpriv_sort_elems ( h5_file_t *f ) { h5t_fdata_t *t = f->t; @@ -221,20 +221,20 @@ _h5t_sort_elems ( int k; h5_id_t i; for ( k = 0; k < 2; k++ ) { - TRY( _h5_alloc_idlist_items ( f, &t->sorted_elems[k], num_elems ) ); + TRY( h5priv_alloc_idlist_items ( f, &t->sorted_elems[k], num_elems ) ); for ( i = local_eid; i < num_elems; i++ ) { t->sorted_elems[k].items[i] = i; } t->sorted_elems[k].num_items = num_elems; } - _h5_qsort_r ( + h5priv_qsort_r ( t->sorted_elems[0].items, num_elems, sizeof(t->sorted_elems[0].items[0]), f, _qsort_cmp_elems0 ); - _h5_qsort_r ( + h5priv_qsort_r ( t->sorted_elems[1].items, num_elems, sizeof(t->sorted_elems[1].items[0]), @@ -248,7 +248,7 @@ _h5t_sort_elems ( Sort (small) array of local vertex ids geometrically. */ h5_err_t -_h5t_sort_local_vids ( +h5tpriv_sort_local_vids ( h5_file_t * const f, h5_id_t * const local_vids, /* IN/OUT: local vertex ids */ const h5_size_t size /* size of array */ @@ -284,7 +284,7 @@ _search_elem ( ) { h5t_fdata_t *t = f->t; - _h5t_sort_local_vids ( f, local_vids, t->mesh_type ); + h5tpriv_sort_local_vids ( f, local_vids, t->mesh_type ); register h5_id_t low = 0; register h5_id_t high = t->sorted_elems[0].num_items - 1; @@ -302,7 +302,7 @@ _search_elem ( else return mid; // found } - return _h5t_error_local_elem_nexist ( f, local_vids ); + return h5tpriv_error_local_elem_nexist ( f, local_vids ); } /*! @@ -343,9 +343,9 @@ h5t_map_global_vid2local ( ) { struct h5t_fdata *t = f->t; - h5_id_t local_id = _h5_search_idmap ( &t->map_vertex_g2l, global_id ); + h5_id_t local_id = h5priv_search_idmap ( &t->map_vertex_g2l, global_id ); if ( local_id < 0 ) - return _h5t_error_global_id_nexist ( f, "vertex", global_id ); + return h5tpriv_error_global_id_nexist ( f, "vertex", global_id ); return local_id; } @@ -376,7 +376,7 @@ h5t_map_local_eid2global ( if ( local_eid < 0 || local_eid > t->num_elems[t->num_levels-1] ) return HANDLE_H5_OUT_OF_RANGE_ERR ( - f, _h5t_oid_names[t->mesh_type], local_eid ); + f, h5tpriv_oid_names[t->mesh_type], local_eid ); switch ( t->mesh_type ) { case H5_OID_TETRAHEDRON: @@ -402,9 +402,9 @@ h5t_map_global_eid2local ( const h5_id_t global_eid ) { struct h5t_fdata *t = f->t; - h5_id_t local_eid = _h5_search_idmap ( &t->map_elem_g2l, global_eid ); + h5_id_t local_eid = h5priv_search_idmap ( &t->map_elem_g2l, global_eid ); if ( local_eid < 0 ) - return _h5t_error_global_id_nexist ( f, "elem", global_eid ); + return h5tpriv_error_global_id_nexist ( f, "elem", global_eid ); return local_eid; } @@ -421,11 +421,11 @@ h5t_map_global_triangle_id2local ( struct h5t_fdata *t = f->t; switch ( t->mesh_type ) { case H5_OID_TETRAHEDRON: { - h5_id_t global_tet_id = _h5t_get_elem_idx ( global_tri_id ); + h5_id_t global_tet_id = h5tpriv_get_elem_idx ( global_tri_id ); h5_id_t local_tet_id = h5t_map_global_eid2local ( f, global_tet_id ); if ( local_tet_id < 0 ) - return _h5t_error_global_id_nexist ( + return h5tpriv_error_global_id_nexist ( f, "triangle", global_tri_id ); return local_tet_id | (global_tri_id & ~H5T_ELEM_MASK); } @@ -449,7 +449,7 @@ h5t_map_local_triangle_id2global ( struct h5t_fdata *t = f->t; switch ( t->mesh_type ) { case H5_OID_TETRAHEDRON: { - h5_id_t local_tet_id = _h5t_get_elem_idx ( local_tri_id ); + h5_id_t local_tet_id = h5tpriv_get_elem_idx ( local_tri_id ); h5_id_t global_tet_id = h5t_map_local_eid2global ( f, local_tet_id ); if ( global_tet_id < 0 ) @@ -466,7 +466,7 @@ h5t_map_local_triangle_id2global ( h5_err_t -_h5t_rebuild_global_2_local_map_of_vertices ( +h5tpriv_rebuild_global_2_local_map_of_vertices ( h5_file_t * const f ) { struct h5t_fdata *t = f->t; @@ -479,13 +479,13 @@ _h5t_rebuild_global_2_local_map_of_vertices ( t->map_vertex_g2l.items[local_vid].local_id = local_vid; t->map_vertex_g2l.num_items++; } - _h5_sort_idmap ( &t->map_vertex_g2l ); + h5priv_sort_idmap ( &t->map_vertex_g2l ); return H5_SUCCESS; } h5_err_t -_h5t_rebuild_global_2_local_map_of_elems ( +h5tpriv_rebuild_global_2_local_map_of_elems ( h5_file_t * const f ) { h5t_fdata_t *t = f->t; @@ -493,7 +493,7 @@ _h5t_rebuild_global_2_local_map_of_elems ( h5_id_t local_eid = t->cur_level > 0 ? t->num_elems[t->cur_level-1] : 0; h5_id_t num_elems = t->num_elems[t->num_levels-1]; h5_idmap_el_t *item = &t->map_elem_g2l.items[local_eid]; - size_t offset = _h5t_sizeof_elem[t->mesh_type]; + size_t offset = h5tpriv_sizeof_elem[t->mesh_type]; void *elemp = t->elems.data + local_eid*offset; for ( ; local_eid < num_elems; @@ -506,7 +506,7 @@ _h5t_rebuild_global_2_local_map_of_elems ( item->local_id = local_eid; t->map_elem_g2l.num_items++; } - _h5_sort_idmap ( &t->map_elem_g2l ); + h5priv_sort_idmap ( &t->map_elem_g2l ); return H5_SUCCESS; } @@ -521,22 +521,30 @@ h5t_get_local_vids_of_edge ( const h5_id_t id, h5_id_t *edge ) { - h5_id_t face_id = _h5t_get_face_id ( id ); - h5_id_t el_id = _h5t_get_elem_idx ( id ); + h5_id_t face_id = h5tpriv_get_face_id ( id ); + h5_id_t el_id = h5tpriv_get_elem_idx ( id ); return h5t_get_local_vids_of_edge2 ( f, face_id, el_id, edge ); } +/*! + Get local vertex ID's of an edge. The edge is specified by the local + element index and the sub-entity ID of the edge according the reference + element. + + This function can be used with tetrahedral and triangle meshes. + */ h5_err_t h5t_get_local_vids_of_edge2 ( h5_file_t * const f, - const h5_id_t face, - const h5_id_t id, - h5_id_t *edge + const h5_id_t edge_id, // edge id according reference element + const h5_id_t elem_idx, // local element index + h5_id_t *edge // OUT: vertex ID's ) { + // map edge id to corresponding vertex ID's of reference element int map[6][2] = { { 0,1 }, {1,2}, {0,2}, {0,3}, {1,3}, {2,3} }; - h5_elem_ldta_t *el = &f->t->elems_ldta[id]; - edge[0] = el->local_vids[map[face][0]]; - edge[1] = el->local_vids[map[face][1]]; + h5_elem_ldta_t *el = &f->t->elems_ldta[elem_idx]; + edge[0] = el->local_vids[map[edge_id][0]]; + edge[1] = el->local_vids[map[edge_id][1]]; return H5_SUCCESS; } @@ -546,8 +554,8 @@ h5t_get_local_vids_of_triangle ( const h5_id_t id, h5_id_t *vids ) { - h5_id_t face = _h5t_get_face_id ( id ); - h5_id_t el_id = _h5t_get_elem_idx ( id ); + h5_id_t face = h5tpriv_get_face_id ( id ); + h5_id_t el_id = h5tpriv_get_elem_idx ( id ); return h5t_get_local_vids_of_triangle2 ( f, face, el_id, vids ); } diff --git a/src/h5_core/h5t_map.h b/src/h5_core/h5t_map.h index 1274086..ac090e6 100644 --- a/src/h5_core/h5t_map.h +++ b/src/h5_core/h5t_map.h @@ -46,7 +46,7 @@ h5t_map_global_triangle_id2local ( ); h5_id_t -_h5t_get_local_vid ( +h5tpriv_get_local_vid ( h5_file_t * const f, h5_float64_t P[3] ); diff --git a/src/h5_core/h5t_map_private.h b/src/h5_core/h5t_map_private.h index 0225823..31259dd 100644 --- a/src/h5_core/h5t_map_private.h +++ b/src/h5_core/h5t_map_private.h @@ -2,29 +2,29 @@ #define __H5T_MAP_PRIVATE_H h5_err_t -_h5t_sort_local_vids ( +h5tpriv_sort_local_vids ( h5_file_t * const f, h5_id_t * const local_vids, const h5_size_t size ); h5_err_t -_h5t_sort_vertices ( +h5tpriv_sort_vertices ( h5_file_t * const f ); h5_err_t -_h5t_sort_elems ( +h5tpriv_sort_elems ( h5_file_t * const f ); h5_err_t -_h5t_rebuild_global_2_local_map_of_vertices ( +h5tpriv_rebuild_global_2_local_map_of_vertices ( h5_file_t * const f ); h5_err_t -_h5t_rebuild_global_2_local_map_of_elems ( +h5tpriv_rebuild_global_2_local_map_of_elems ( h5_file_t * const f ); diff --git a/src/h5_core/h5t_openclose.c b/src/h5_core/h5t_openclose.c index 142c0a0..565c39b 100644 --- a/src/h5_core/h5t_openclose.c +++ b/src/h5_core/h5t_openclose.c @@ -11,15 +11,16 @@ #include "h5_core/h5_core_private.h" static struct h5t_methods tet_funcs = { - _h5t_alloc_tets, - _h5t_store_tet, - _h5t_refine_tet + h5tpriv_alloc_tets, + h5tpriv_store_tet, + h5tpriv_refine_tet, + &h5tpriv_tetm_adjacency_methods }; static struct h5t_methods tri_funcs = { - _h5t_alloc_tris, - _h5t_store_tri, - _h5t_refine_tri + h5tpriv_alloc_tris, + h5tpriv_store_tri, + h5tpriv_refine_tri }; /* @@ -34,14 +35,14 @@ _create_array_types ( hsize_t dims[1] = { 3 }; TRY( - dtypes->h5_coord3d_t = _hdf_create_array_type ( + dtypes->h5_coord3d_t = h5priv_create_hdf5_array_type ( f, H5_FLOAT64_T, 1, dims ) ); TRY( - dtypes->h5_3id_t = _hdf_create_array_type ( + dtypes->h5_3id_t = h5priv_create_hdf5_array_type ( f, H5_ID_T, 1, @@ -49,7 +50,7 @@ _create_array_types ( ); dims[0] = 4; TRY( - dtypes->h5_4id_t = _hdf_create_array_type ( + dtypes->h5_4id_t = h5priv_create_hdf5_array_type ( f, H5_ID_T, 1, @@ -66,19 +67,19 @@ _create_vertex_type ( h5_dtypes_t *dtypes = &f->t->dtypes; TRY( - dtypes->h5_vertex_t = _hdf_create_type ( + dtypes->h5_vertex_t = h5priv_create_hdf5_type ( f, H5_COMPOUND_T, sizeof(struct h5_vertex) ) ); TRY( - _hdf_insert_type ( + h5priv_insert_hdf5_type ( f, dtypes->h5_vertex_t, "global_vid", HOFFSET(struct h5_vertex, global_vid), H5_ID_T ) ); TRY( - _hdf_insert_type ( + h5priv_insert_hdf5_type ( f, dtypes->h5_vertex_t, "P", @@ -95,33 +96,33 @@ _create_triangle_type ( h5_dtypes_t *dtypes = &f->t->dtypes; TRY( - dtypes->h5_triangle_t = _hdf_create_type ( + dtypes->h5_triangle_t = h5priv_create_hdf5_type ( f, H5_COMPOUND_T, sizeof(struct h5_triangle) ) ); TRY( - _hdf_insert_type ( + h5priv_insert_hdf5_type ( f, dtypes->h5_triangle_t, "global_eid", HOFFSET(struct h5_triangle, global_eid), H5_ID_T ) ); TRY( - _hdf_insert_type ( + h5priv_insert_hdf5_type ( f, dtypes->h5_triangle_t, "global_parent_eid", HOFFSET(struct h5_triangle, global_parent_eid), H5_ID_T ) ); TRY( - _hdf_insert_type ( + h5priv_insert_hdf5_type ( f, dtypes->h5_triangle_t, "global_child_eid", HOFFSET(struct h5_triangle, global_child_eid), H5_ID_T ) ); TRY( - _hdf_insert_type ( + h5priv_insert_hdf5_type ( f, dtypes->h5_triangle_t, "global_vids", @@ -138,19 +139,19 @@ _create_tag_types ( h5_dtypes_t *dtypes = &f->t->dtypes; TRY ( - dtypes->h5t_tag_idx_t = _hdf_create_type ( + dtypes->h5t_tag_idx_t = h5priv_create_hdf5_type ( f, H5_COMPOUND_T, sizeof(h5t_tag_idx_t) ) ); TRY ( - _hdf_insert_type ( + h5priv_insert_hdf5_type ( f, dtypes->h5t_tag_idx_t, "eid", HOFFSET(h5t_tag_idx_t, eid), H5_ID_T ) ); TRY ( - _hdf_insert_type ( + h5priv_insert_hdf5_type ( f, dtypes->h5t_tag_idx_t, "idx", @@ -167,33 +168,33 @@ _create_tet_type ( h5_dtypes_t *dtypes = &f->t->dtypes; TRY( - dtypes->h5_tet_t = _hdf_create_type ( + dtypes->h5_tet_t = h5priv_create_hdf5_type ( f, H5_COMPOUND_T, sizeof(struct h5_tetrahedron) ) ); TRY( - _hdf_insert_type ( + h5priv_insert_hdf5_type ( f, dtypes->h5_tet_t, "global_eid", HOFFSET(struct h5_tetrahedron, global_eid), H5_ID_T ) ); TRY( - _hdf_insert_type ( + h5priv_insert_hdf5_type ( f, dtypes->h5_tet_t, "global_parent_eid", HOFFSET(struct h5_tetrahedron, global_parent_eid), H5_ID_T ) ); TRY( - _hdf_insert_type ( + h5priv_insert_hdf5_type ( f, dtypes->h5_tet_t, "global_child_eid", HOFFSET(struct h5_tetrahedron, global_child_eid), H5T_NATIVE_INT32 ) ); TRY( - _hdf_insert_type ( + h5priv_insert_hdf5_type ( f, dtypes->h5_tet_t, "global_vids", @@ -206,7 +207,7 @@ _create_tet_type ( #if 0 h5_err_t -_h5_set_dataset_properties ( +h5priv_set_dataset_properties ( h5_dsinfo_t *dsinfo, const char *name, const hid_t type, @@ -246,10 +247,10 @@ _init_fdata ( t->dsinfo_vertices.max_dims[0] = H5S_UNLIMITED; t->dsinfo_vertices.chunk_dims[0] = 4096; t->dsinfo_vertices.type_id = t->dtypes.h5_vertex_t; - TRY( t->dsinfo_vertices.create_prop = _hdf_create_property ( + TRY( t->dsinfo_vertices.create_prop = h5priv_create_hdf5_property ( f, H5P_DATASET_CREATE ) ); - TRY( _hdf_set_chunk_property ( + TRY( h5priv_set_hdf5_chunk_property ( f, t->dsinfo_vertices.create_prop, t->dsinfo_vertices.rank, @@ -263,10 +264,10 @@ _init_fdata ( t->dsinfo_num_vertices.max_dims[0] = H5S_UNLIMITED; t->dsinfo_num_vertices.chunk_dims[0] = 4096; t->dsinfo_num_vertices.type_id = t->dtypes.h5_id_t; - TRY( t->dsinfo_num_vertices.create_prop = _hdf_create_property ( + TRY( t->dsinfo_num_vertices.create_prop = h5priv_create_hdf5_property ( f, H5P_DATASET_CREATE ) ); - TRY( _hdf_set_chunk_property ( + TRY( h5priv_set_hdf5_chunk_property ( f, t->dsinfo_num_vertices.create_prop, t->dsinfo_num_vertices.rank, @@ -279,10 +280,10 @@ _init_fdata ( t->dsinfo_elems.dims[0] = 0; t->dsinfo_elems.max_dims[0] = H5S_UNLIMITED; t->dsinfo_elems.chunk_dims[0] = 4096; - TRY( t->dsinfo_elems.create_prop = _hdf_create_property ( + TRY( t->dsinfo_elems.create_prop = h5priv_create_hdf5_property ( f, H5P_DATASET_CREATE ) ); - TRY( _hdf_set_chunk_property ( + TRY( h5priv_set_hdf5_chunk_property ( f, t->dsinfo_elems.create_prop, t->dsinfo_elems.rank, @@ -296,10 +297,10 @@ _init_fdata ( t->dsinfo_num_elems.max_dims[0] = H5S_UNLIMITED; t->dsinfo_num_elems.chunk_dims[0] = 4096; t->dsinfo_num_elems.type_id = t->dtypes.h5_id_t; - TRY( t->dsinfo_num_elems.create_prop = _hdf_create_property ( + TRY( t->dsinfo_num_elems.create_prop = h5priv_create_hdf5_property ( f, H5P_DATASET_CREATE ) ); - TRY( _hdf_set_chunk_property ( + TRY( h5priv_set_hdf5_chunk_property ( f, t->dsinfo_num_elems.create_prop, t->dsinfo_num_elems.rank, @@ -313,10 +314,10 @@ _init_fdata ( t->dsinfo_num_elems_on_level.max_dims[0] = H5S_UNLIMITED; t->dsinfo_num_elems_on_level.chunk_dims[0] = 4096; t->dsinfo_num_elems_on_level.type_id = t->dtypes.h5_id_t; - TRY( t->dsinfo_num_elems_on_level.create_prop = _hdf_create_property ( + TRY( t->dsinfo_num_elems_on_level.create_prop = h5priv_create_hdf5_property ( f, H5P_DATASET_CREATE ) ); - TRY( _hdf_set_chunk_property ( + TRY( h5priv_set_hdf5_chunk_property ( f, t->dsinfo_num_elems_on_level.create_prop, t->dsinfo_num_elems_on_level.rank, @@ -337,11 +338,11 @@ _init_fdata ( \return H5_SUCCESS or error code */ h5_err_t -_h5t_open_file ( +h5tpriv_open_file ( h5_file_t * f /*!< IN: file handle */ ) { - TRY( (f->t = _h5_alloc ( f, NULL, sizeof(*f->t) ) ) ); + TRY( (f->t = h5priv_alloc ( f, NULL, sizeof(*f->t) ) ) ); h5t_fdata_t *t = f->t; t->dtypes.h5_id_t = H5_INT64_T; @@ -369,16 +370,16 @@ _h5t_open_file ( \return H5_SUCCESS or error code */ h5_err_t -_h5t_close_file ( +h5tpriv_close_file ( h5_file_t *f /*!< IN: file handle */ ) { - TRY ( _h5t_close_mesh ( f ) ); + TRY ( h5tpriv_close_mesh ( f ) ); return H5_SUCCESS; } h5_err_t -_h5t_init_step ( +h5tpriv_init_step ( h5_file_t * const f ) { @@ -391,7 +392,7 @@ _h5t_init_step ( - free memory */ h5_err_t -_h5t_close_step ( +h5tpriv_close_step ( h5_file_t * f ) { @@ -400,42 +401,42 @@ _h5t_close_step ( h5_err_t -_h5t_open_topo_group ( +h5tpriv_open_topo_group ( h5_file_t * const f ) { struct h5t_fdata *t = f->t; - t->topo_gid = _h5_open_group ( f, f->root_gid, H5T_CONTAINER_GRPNAME ); + t->topo_gid = h5priv_open_group ( f, f->root_gid, H5T_CONTAINER_GRPNAME ); return t->topo_gid; } h5_err_t -_h5t_open_meshes_group ( +h5tpriv_open_meshes_group ( h5_file_t * const f ) { h5t_fdata_t *t = f->t; if ( t->topo_gid < 0 ) { - TRY ( _h5t_open_topo_group ( f ) ); + TRY ( h5tpriv_open_topo_group ( f ) ); } - TRY ( (t->meshes_gid = _h5_open_group ( + TRY ( (t->meshes_gid = h5priv_open_group ( f, t->topo_gid, - _h5t_meshes_grpnames[t->mesh_type] ) ) ); + h5tpriv_meshes_grpnames[t->mesh_type] ) ) ); return H5_SUCCESS; } h5_err_t -_h5t_open_mesh_group ( +h5tpriv_open_mesh_group ( h5_file_t * const f ) { h5t_fdata_t *t = f->t; if ( t->meshes_gid < 0 ) { - TRY ( _h5t_open_meshes_group ( f ) ); + TRY ( h5tpriv_open_meshes_group ( f ) ); } - TRY ( ( t->mesh_gid = _h5_open_group ( + TRY ( ( t->mesh_gid = h5priv_open_group ( f, t->meshes_gid, t->mesh_name ) ) ); @@ -453,7 +454,7 @@ h5t_open_mesh ( ) { h5t_fdata_t *t = f->t; - TRY( _h5t_close_mesh ( f ) ); + TRY( h5tpriv_close_mesh ( f ) ); if ( t->num_meshes < 0 ) { h5_size_t result = h5t_get_num_meshes ( f, type ); @@ -481,12 +482,12 @@ h5t_open_mesh ( return h5_error_internal ( f, __FILE__, __func__, __LINE__ ); } - TRY( _h5t_open_mesh_group ( f ) ); + TRY( h5tpriv_open_mesh_group ( f ) ); t->cur_mesh = id; if ( id != t->num_meshes ) { /* open existing */ - TRY ( _h5t_read_mesh ( f ) ); + TRY ( h5tpriv_read_mesh ( f ) ); } else { /* append new */ t->num_meshes++; @@ -503,11 +504,11 @@ _release_elems ( h5_file_t * const f ) { h5t_fdata_t *t = f->t; - TRY ( _h5_free ( f, t->elems.data ) ); - TRY( _h5_free ( f, t->num_elems ) ); - TRY ( _h5_free ( f, t->elems_ldta ) ); - TRY ( _h5_free ( f, t->num_elems_on_level ) ); - TRY ( _h5_free ( f, t->map_elem_g2l.items ) ); + TRY ( h5priv_free ( f, t->elems.data ) ); + TRY( h5priv_free ( f, t->num_elems ) ); + TRY ( h5priv_free ( f, t->elems_ldta ) ); + TRY ( h5priv_free ( f, t->num_elems_on_level ) ); + TRY ( h5priv_free ( f, t->map_elem_g2l.items ) ); return H5_SUCCESS; } @@ -517,31 +518,31 @@ _release_vertices ( h5_file_t * const f ) { h5t_fdata_t *t = f->t; - TRY ( _h5_free ( f, t->vertices ) ); - TRY ( _h5_free ( f, t->vertices_data ) ); - TRY ( _h5_free ( f, t->num_vertices ) ); - TRY ( _h5_free ( f, t->map_vertex_g2l.items ) ); + TRY ( h5priv_free ( f, t->vertices ) ); + TRY ( h5priv_free ( f, t->vertices_data ) ); + TRY ( h5priv_free ( f, t->num_vertices ) ); + TRY ( h5priv_free ( f, t->map_vertex_g2l.items ) ); return H5_SUCCESS; } static h5_err_t _release_memory ( - h5_file_t * const f + h5_file_t* const f ) { - TRY ( _h5t_release_tags ( f ) ); - TRY ( _h5t_release_adjacencies ( f ) ); - TRY ( _release_elems ( f ) ); - TRY ( _release_vertices ( f ) ); + TRY ( h5tpriv_release_tags (f) ); + TRY ( (*f->t->methods.adjacency->release_internal_structs) (f) ); + TRY ( _release_elems (f) ); + TRY ( _release_vertices (f) ); return H5_SUCCESS; } h5_err_t -_h5t_close_mesh ( +h5tpriv_close_mesh ( h5_file_t * const f ) { - TRY( _h5t_write_mesh ( f ) ); + TRY( h5tpriv_write_mesh ( f ) ); TRY( _release_memory ( f ) ); TRY( _init_fdata ( f ) ); @@ -563,7 +564,7 @@ h5t_open_level ( } herr_t -_hdf_set_chunk_property ( +h5priv_set_hdf5_chunk_property ( h5_file_t * const f, hid_t plist, int ndims, @@ -572,24 +573,24 @@ _hdf_set_chunk_property ( h5_err_t -_h5t_alloc_num_vertices ( +h5tpriv_alloc_num_vertices ( h5_file_t * const f, const h5_size_t num_vertices ) { h5t_fdata_t *t = f->t; ssize_t size = num_vertices * sizeof ( t->vertices[0] ); - TRY ( t->vertices = _h5_alloc ( f, t->vertices, size ) ); + TRY ( t->vertices = h5priv_alloc ( f, t->vertices, size ) ); size = num_vertices * sizeof ( t->vertices_data[0] ); - TRY ( t->vertices_data = _h5_alloc ( f, t->vertices_data, size ) ); - TRY( _h5_alloc_idmap ( f, &t->map_vertex_g2l, num_vertices ) ); - TRY( _h5_alloc_idlist_items ( f, &t->sorted_lvertices, num_vertices ) ); + TRY ( t->vertices_data = h5priv_alloc ( f, t->vertices_data, size ) ); + TRY( h5priv_alloc_idmap ( f, &t->map_vertex_g2l, num_vertices ) ); + TRY( h5priv_alloc_idlist_items ( f, &t->sorted_lvertices, num_vertices ) ); return H5_SUCCESS; } h5_err_t -_h5t_alloc_tris ( +h5tpriv_alloc_tris ( h5_file_t * const f, const size_t cur, const size_t new @@ -598,7 +599,7 @@ _h5t_alloc_tris ( const size_t nvertices = 3; /* alloc mem for elements */ - TRY ( t->elems.tris = _h5_alloc ( + TRY ( t->elems.tris = h5priv_alloc ( f, t->elems.tris, new * sizeof(t->elems.tris[0]) ) ); @@ -608,7 +609,7 @@ _h5t_alloc_tris ( (new-cur) * sizeof(t->elems.tris[0]) ); /* alloc mem for local data of elements */ - TRY ( t->elems_ldta = _h5_alloc ( + TRY ( t->elems_ldta = h5priv_alloc ( f, t->elems_ldta, new * sizeof (t->elems_ldta[0]) ) ); @@ -618,7 +619,7 @@ _h5t_alloc_tris ( (new-cur) * sizeof (t->elems_ldta[0]) ); /* alloc mem for local vertex IDs of elements */ - TRY ( t->elems_lvids = _h5_alloc ( + TRY ( t->elems_lvids = h5priv_alloc ( f, t->elems_lvids, new * sizeof(t->elems_lvids[0]) * nvertices ) ); @@ -635,13 +636,13 @@ _h5t_alloc_tris ( } /* alloc mem for global to local ID mapping */ - TRY ( _h5_alloc_idmap ( f, &t->map_elem_g2l, new ) ); + TRY ( h5priv_alloc_idmap ( f, &t->map_elem_g2l, new ) ); return H5_SUCCESS; } h5_err_t -_h5t_alloc_tets ( +h5tpriv_alloc_tets ( h5_file_t * const f, const size_t cur, const size_t new @@ -650,7 +651,7 @@ _h5t_alloc_tets ( const size_t nvertices = 4; /* alloc mem for elements */ - TRY ( t->elems.tets = _h5_alloc ( + TRY ( t->elems.tets = h5priv_alloc ( f, t->elems.tets, new * sizeof(t->elems.tets[0]) ) ); @@ -660,7 +661,7 @@ _h5t_alloc_tets ( (new-cur) * sizeof(t->elems.tets[0]) ); /* alloc mem for local data of elements */ - TRY ( t->elems_ldta = _h5_alloc ( + TRY ( t->elems_ldta = h5priv_alloc ( f, t->elems_ldta, new * sizeof (t->elems_ldta[0]) ) ); @@ -670,7 +671,7 @@ _h5t_alloc_tets ( (new-cur) * sizeof (t->elems_ldta[0]) ); /* alloc mem for local vertex IDs of elements */ - TRY ( t->elems_lvids = _h5_alloc ( + TRY ( t->elems_lvids = h5priv_alloc ( f, t->elems_lvids, new * sizeof(t->elems_lvids[0]) * nvertices ) ); @@ -687,7 +688,7 @@ _h5t_alloc_tets ( } /* alloc mem for global to local ID mapping */ - TRY ( _h5_alloc_idmap ( f, &t->map_elem_g2l, new ) ); + TRY ( h5priv_alloc_idmap ( f, &t->map_elem_g2l, new ) ); return H5_SUCCESS; } diff --git a/src/h5_core/h5t_openclose.h b/src/h5_core/h5t_openclose.h index f9aaf8c..212bf53 100644 --- a/src/h5_core/h5t_openclose.h +++ b/src/h5_core/h5t_openclose.h @@ -6,22 +6,22 @@ h5_err_t h5t_open_mesh ( h5_file_t * const f, const h5_id_t id, const h5_oid_t type ); h5_err_t h5t_open_level ( h5_file_t * const f, const h5_id_t id ); -h5_err_t _h5t_open_file ( h5_file_t * const f ); -h5_err_t _h5t_close_file ( h5_file_t * const f ); -h5_err_t _h5t_open_topo_group ( h5_file_t * const f ); -h5_err_t _h5t_open_meshes_group ( h5_file_t * const f ); -h5_err_t _h5t_open_mesh_group ( h5_file_t * const f ); -h5_err_t _h5t_close_mesh ( h5_file_t * const f ); -h5_err_t _h5t_close_step ( h5_file_t * const f ); +h5_err_t h5tpriv_open_file ( h5_file_t * const f ); +h5_err_t 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 ); +h5_err_t h5tpriv_open_mesh_group ( h5_file_t * const f ); +h5_err_t h5tpriv_close_mesh ( h5_file_t * const f ); +h5_err_t h5tpriv_close_step ( h5_file_t * const f ); -h5_err_t _h5t_init_fdata ( h5_file_t * const f ); -h5_err_t _h5t_init_step ( h5_file_t * const f ); +h5_err_t h5tpriv_init_fdata ( h5_file_t * const f ); +h5_err_t h5tpriv_init_step ( h5_file_t * const f ); -h5_err_t _h5t_alloc_num_vertices ( h5_file_t * const f, +h5_err_t h5tpriv_alloc_num_vertices ( h5_file_t * const f, const h5_size_t num_vertices ); -h5_err_t _h5t_alloc_tris ( h5_file_t * const f, const size_t cur, +h5_err_t h5tpriv_alloc_tris ( h5_file_t * const f, const size_t cur, const size_t new_size ); -h5_err_t _h5t_alloc_tets ( h5_file_t * const f, const size_t cur, +h5_err_t h5tpriv_alloc_tets ( h5_file_t * const f, const size_t cur, const size_t new_size ); #endif diff --git a/src/h5_core/h5t_readwrite.c b/src/h5_core/h5t_readwrite.c index 65032aa..b3c006e 100644 --- a/src/h5_core/h5t_readwrite.c +++ b/src/h5_core/h5t_readwrite.c @@ -34,17 +34,17 @@ _write_vertices ( if ( t->num_vertices <= 0 ) return H5_SUCCESS; /* ???? */ if ( t->mesh_gid < 0 ) { - TRY( _h5t_open_mesh_group ( f ) ); + TRY( h5tpriv_open_mesh_group ( f ) ); } t->dsinfo_vertices.dims[0] = t->num_vertices[t->cur_level]; - TRY( _h5_write_dataset_by_name ( + TRY( h5priv_write_dataset_by_name ( f, t->mesh_gid, &t->dsinfo_vertices, _open_space_all, _open_space_all, t->vertices ) ); - TRY( _h5_write_dataset_by_name ( + TRY( h5priv_write_dataset_by_name ( f, t->mesh_gid, &t->dsinfo_num_vertices, @@ -64,10 +64,10 @@ _write_elems ( if ( t->num_elems <= 0 ) return H5_SUCCESS; if ( t->mesh_gid < 0 ) { - TRY( _h5t_open_mesh_group ( f ) ); + TRY( h5tpriv_open_mesh_group ( f ) ); } - TRY ( _h5_write_dataset_by_name ( + TRY ( h5priv_write_dataset_by_name ( f, t->mesh_gid, &t->dsinfo_elems, @@ -75,7 +75,7 @@ _write_elems ( _open_space_all, t->elems.data ) ); - TRY ( _h5_write_dataset_by_name ( + TRY ( h5priv_write_dataset_by_name ( f, t->mesh_gid, &t->dsinfo_num_elems, @@ -83,7 +83,7 @@ _write_elems ( _open_space_all, t->num_elems ) ); - TRY ( _h5_write_dataset_by_name ( + TRY ( h5priv_write_dataset_by_name ( f, t->mesh_gid, &t->dsinfo_num_elems_on_level, @@ -95,7 +95,7 @@ _write_elems ( } h5_err_t -_h5t_write_mesh ( +h5tpriv_write_mesh ( h5_file_t * f ) { h5t_fdata_t *t = f->t; @@ -104,7 +104,7 @@ _h5t_write_mesh ( TRY( _write_elems( f ) ); } if ( t->mtags.changed ) { - TRY ( _h5t_write_mtags ( f ) ); + TRY ( h5tpriv_write_mtags ( f ) ); } return H5_SUCCESS; @@ -120,12 +120,12 @@ _read_num_levels ( hssize_t size; if ( t->cur_mesh < 0 ) { - return _h5t_error_undef_mesh ( f ); + return h5tpriv_error_undef_mesh ( f ); } - TRY ( dataset_id = _hdf_open_dataset ( f, t->mesh_gid, "NumVertices" ) ); - TRY ( diskspace_id = _hdf_get_dataset_space ( f, dataset_id ) ); - TRY ( size = _hdf_get_npoints_of_dataspace ( f, diskspace_id ) ); - TRY ( _hdf_close_dataspace( f, diskspace_id ) ); + TRY ( dataset_id = h5priv_open_hdf5_dataset ( f, t->mesh_gid, "NumVertices" ) ); + TRY ( diskspace_id = h5priv_get_hdf5_dataset_space ( f, dataset_id ) ); + TRY ( size = h5priv_get_npoints_of_hdf5_dataspace ( f, diskspace_id ) ); + TRY ( h5priv_close_hdf5_dataspace( f, diskspace_id ) ); t->num_levels = size; return size; @@ -155,11 +155,11 @@ _read_num_vertices ( struct h5t_fdata *t = f->t; if ( t->mesh_gid < 0 ) { - TRY ( _h5t_open_mesh_group ( f ) ); + TRY ( h5tpriv_open_mesh_group ( f ) ); } ssize_t num_bytes = t->num_levels*sizeof ( t->num_vertices[0] ); - TRY ( t->num_vertices = _h5_alloc ( f, t->num_vertices, num_bytes ) ); - TRY ( _h5_read_dataset_by_name ( + TRY ( t->num_vertices = h5priv_alloc ( f, t->num_vertices, num_bytes ) ); + TRY ( h5priv_read_dataset_by_name ( f, t->mesh_gid, &t->dsinfo_num_vertices, @@ -177,16 +177,16 @@ _read_vertices ( struct h5t_fdata *t = f->t; - TRY( _h5t_alloc_num_vertices ( f, t->num_vertices[t->num_levels-1] ) ); - TRY( _h5_read_dataset_by_name ( + TRY( h5tpriv_alloc_num_vertices ( f, t->num_vertices[t->num_levels-1] ) ); + TRY( h5priv_read_dataset_by_name ( f, t->mesh_gid, &t->dsinfo_vertices, _open_mem_space_vertices, _open_file_space_vertices, t->vertices ) ); - TRY ( _h5t_sort_vertices ( f ) ); - TRY ( _h5t_rebuild_global_2_local_map_of_vertices ( f ) ); + TRY ( h5tpriv_sort_vertices ( f ) ); + TRY ( h5tpriv_rebuild_global_2_local_map_of_vertices ( f ) ); return H5_SUCCESS; } @@ -200,12 +200,12 @@ _read_num_elems ( struct h5t_fdata *t = f->t; if ( t->mesh_gid < 0 ) { - TRY( _h5t_open_mesh_group ( f ) ); + TRY( h5tpriv_open_mesh_group ( f ) ); } size_t size = t->num_levels * sizeof ( t->num_elems[0] ); - TRY( t->num_elems = _h5_alloc ( f, NULL, size ) ); - TRY( t->num_elems_on_level = _h5_alloc ( f, NULL, size ) ); - TRY( _h5_read_dataset_by_name ( + TRY( t->num_elems = h5priv_alloc ( f, NULL, size ) ); + TRY( t->num_elems_on_level = h5priv_alloc ( f, NULL, size ) ); + TRY( h5priv_read_dataset_by_name ( f, t->mesh_gid, &t->dsinfo_num_elems, @@ -213,7 +213,7 @@ _read_num_elems ( _open_space_all, t->num_elems ) ); - TRY( _h5_read_dataset_by_name ( + TRY( h5priv_read_dataset_by_name ( f, t->mesh_gid, &t->dsinfo_num_elems_on_level, @@ -262,7 +262,7 @@ _build_elems_ldta ( for ( local_eid=0; local_eid < num_elems; - local_eid++, elp+=_h5t_sizeof_elem[t->mesh_type], el_data++ ) { + local_eid++, elp+=h5tpriv_sizeof_elem[t->mesh_type], el_data++ ) { el = (h5_elem_t*)elp; TRY( h5t_map_global_vids2local ( f, @@ -297,7 +297,7 @@ _read_elems ( h5t_fdata_t *t = f->t; TRY( (*t->methods._alloc_elems)( f, 0, t->num_elems[t->num_levels-1] ) ); - TRY( _h5_read_dataset_by_name ( + TRY( h5priv_read_dataset_by_name ( f, t->mesh_gid, &t->dsinfo_elems, @@ -305,11 +305,11 @@ _read_elems ( _open_file_space_elems, t->elems.data ) ); - TRY ( _h5t_sort_elems ( f ) ); - TRY ( _h5t_rebuild_global_2_local_map_of_elems ( f ) ); + TRY ( h5tpriv_sort_elems ( f ) ); + TRY ( h5tpriv_rebuild_global_2_local_map_of_elems ( f ) ); TRY ( _build_elems_ldta ( f ) ); - TRY ( _h5t_rebuild_adj_data ( f ) ); + TRY ( (*t->methods.adjacency->rebuild_internal_structs)( f ) ); return H5_SUCCESS; } @@ -318,16 +318,16 @@ _read_mtags ( h5_file_t *const f ) { h5t_fdata_t *t = f->t; - TRY ( t->mtags.group_id = _h5_open_group ( f, t->mesh_gid, "Tags" ) ); - return _h5t_read_tag_container ( f, &f->t->mtags ); + TRY ( t->mtags.group_id = h5priv_open_group ( f, t->mesh_gid, "Tags" ) ); + return h5tpriv_read_tag_container ( f, &f->t->mtags ); } h5_err_t -_h5t_read_mesh ( +h5tpriv_read_mesh ( h5_file_t *f ) { if ( f->t->mesh_gid < 0 ) { - TRY( _h5t_open_mesh_group ( f ) ); + TRY( h5tpriv_open_mesh_group ( f ) ); } TRY ( _read_num_levels ( f ) ); TRY ( _read_num_vertices ( f ) ); diff --git a/src/h5_core/h5t_readwrite_private.h b/src/h5_core/h5t_readwrite_private.h index feacedd..47d8ff9 100644 --- a/src/h5_core/h5t_readwrite_private.h +++ b/src/h5_core/h5t_readwrite_private.h @@ -2,7 +2,7 @@ #define __H5T_READWRITE_PRIVATE_H h5_err_t -_h5t_write_obj ( +h5tpriv_write_obj ( h5_file_t * f, const hid_t gid, const hsize_t current_dims, @@ -13,12 +13,12 @@ _h5t_write_obj ( ); h5_err_t -_h5t_read_mesh ( +h5tpriv_read_mesh ( h5_file_t * const f ); h5_err_t -_h5t_write_mesh ( +h5tpriv_write_mesh ( h5_file_t * const f ); diff --git a/src/h5_core/h5t_retrieve.c b/src/h5_core/h5t_retrieve.c index 6c2da22..e419619 100644 --- a/src/h5_core/h5t_retrieve.c +++ b/src/h5_core/h5t_retrieve.c @@ -27,7 +27,7 @@ _skip_to_next_elem_on_level ( f, __FILE__, __func__, __LINE__ ); } el_dta = &t->elems_ldta[*eid]; - } while ( _h5t_elem_is_on_cur_level ( f, el_dta ) == H5_NOK ); + } while ( h5tpriv_elem_is_on_cur_level ( f, el_dta ) == H5_NOK ); return *eid; } @@ -37,7 +37,7 @@ _skip_to_next_elem_on_level ( - and, if any, the direct children is on a level > the current level */ h5_err_t -_h5t_elem_is_on_cur_level ( +h5tpriv_elem_is_on_cur_level ( h5_file_t * const f, h5_elem_ldta_t *el_dta ) { @@ -84,22 +84,22 @@ h5t_traverse_vertices ( } else { iter->cur_cid++; } - TRY ( _h5t_find_tv2 ( f, iter->cur_cid, iter->cur_eid, &tv ) ); + TRY ( h5tpriv_find_tv2 ( f, iter->cur_cid, iter->cur_eid, &tv ) ); /* skip to first element which is on current level */ i = -1; h5_elem_ldta_t *el_dta; do { i++; - h5_id_t eid = _h5t_get_elem_idx ( tv->items[i] ); + h5_id_t eid = h5tpriv_get_elem_idx ( tv->items[i] ); el_dta = &t->elems_ldta[eid]; - } while ( _h5t_elem_is_on_cur_level ( f, el_dta ) == H5_NOK ); - } while ( iter->cur_eid != _h5t_get_elem_idx(tv->items[i]) ); + } while ( h5tpriv_elem_is_on_cur_level ( f, el_dta ) == H5_NOK ); + } while ( iter->cur_eid != h5tpriv_get_elem_idx(tv->items[i]) ); h5_id_t vidx = t->elems_ldta[iter->cur_eid].local_vids[iter->cur_cid]; h5_vertex_t *vertex = &t->vertices[vidx]; memcpy ( P, &vertex->P, sizeof ( vertex->P ) ); - return _h5t_build_vertex_id ( iter->cur_cid, iter->cur_eid ); + return h5tpriv_build_vertex_id ( iter->cur_cid, iter->cur_eid ); } h5_err_t @@ -148,17 +148,17 @@ h5t_traverse_edges ( } else { iter->cur_cid++; } - TRY ( _h5t_find_te2 ( + TRY ( h5tpriv_find_te2 ( f, iter->cur_cid, iter->cur_eid, &te ) ); /* skip to first element which is on current level */ i = -1; h5_elem_ldta_t *el_dta; do { i++; - h5_id_t eid = _h5t_get_elem_idx ( te->value.items[i] ); + h5_id_t eid = h5tpriv_get_elem_idx ( te->value.items[i] ); el_dta = &t->elems_ldta[eid]; - } while ( _h5t_elem_is_on_cur_level ( f, el_dta ) == H5_NOK ); - } while ( iter->cur_eid != _h5t_get_elem_idx(te->value.items[i]) ); + } while ( h5tpriv_elem_is_on_cur_level ( f, el_dta ) == H5_NOK ); + } while ( iter->cur_eid != h5tpriv_get_elem_idx(te->value.items[i]) ); memcpy ( local_vids, te->key.vids, 2*sizeof(h5_id_t) ); return te->value.items[0]; @@ -210,16 +210,16 @@ h5t_traverse_triangles ( } else { iter->cur_cid++; } - TRY ( _h5t_find_td2 ( f, iter->cur_cid, iter->cur_eid, &td ) ); + TRY ( h5tpriv_find_td2 ( f, iter->cur_cid, iter->cur_eid, &td ) ); /* skip to first element which is on current level */ i = -1; h5_elem_ldta_t *el_dta; do { i++; - h5_id_t eid = _h5t_get_elem_idx ( td->value.items[i] ); + h5_id_t eid = h5tpriv_get_elem_idx ( td->value.items[i] ); el_dta = &t->elems_ldta[eid]; - } while ( _h5t_elem_is_on_cur_level ( f, el_dta ) == H5_NOK ); - } while ( iter->cur_eid != _h5t_get_elem_idx(td->value.items[i]) ); + } while ( h5tpriv_elem_is_on_cur_level ( f, el_dta ) == H5_NOK ); + } while ( iter->cur_eid != h5tpriv_get_elem_idx(td->value.items[i]) ); memcpy ( local_vids, td->key.vids, 3*sizeof(h5_id_t) ); return td->value.items[0]; @@ -287,7 +287,7 @@ h5t_traverse_elems ( elem_data->local_vids, sizeof ( elem_data->local_vids[0] ) * t->mesh_type ); - return _h5t_build_elem_id ( iter->cur_eid ); + return h5tpriv_build_elem_id ( iter->cur_eid ); } h5_err_t diff --git a/src/h5_core/h5t_retrieve_private.h b/src/h5_core/h5t_retrieve_private.h index d9a30e9..dc4f150 100644 --- a/src/h5_core/h5t_retrieve_private.h +++ b/src/h5_core/h5t_retrieve_private.h @@ -2,7 +2,7 @@ #define __H5T_RETRIEVE_PRIVATE_H h5_err_t -_h5t_elem_is_on_cur_level ( +h5tpriv_elem_is_on_cur_level ( h5_file_t * const f, h5_elem_ldta_t *el_dta ); diff --git a/src/h5_core/h5t_storemesh.c b/src/h5_core/h5t_storemesh.c index 61adf77..530b140 100644 --- a/src/h5_core/h5t_storemesh.c +++ b/src/h5_core/h5t_storemesh.c @@ -33,7 +33,7 @@ h5t_add_mesh ( * Set the global vertex id's in element definitions. */ h5_err_t -_h5t_assign_global_vertex_ids ( +h5tpriv_assign_global_vertex_ids ( h5_file_t * const f ) { h5t_fdata_t *t = f->t; @@ -68,9 +68,9 @@ _assign_global_elem_ids ( /* simple in serial runs: global_id = local_id */ - for ( local_eid = (t->cur_level == 0) ? 0 : t->num_elems[t->cur_level-1]; + for (local_eid = (t->cur_level == 0) ? 0 : t->num_elems[t->cur_level-1]; local_eid < t->num_elems[t->cur_level]; - local_eid++ ) { + local_eid++) { h5_elem_t *elem; h5_elem_ldta_t *elem_ldta = &t->elems_ldta[local_eid]; switch ( t->mesh_type ) { @@ -119,12 +119,12 @@ h5t_add_level ( t->dsinfo_num_elems_on_level.dims[0] = t->num_levels; ssize_t num_bytes = t->num_levels*sizeof ( h5_size_t ); - TRY ( t->num_vertices = _h5_alloc ( f, t->num_vertices, num_bytes ) ); + TRY ( t->num_vertices = h5priv_alloc ( f, t->num_vertices, num_bytes ) ); t->num_vertices[t->cur_level] = -1; - TRY ( t->num_elems = _h5_alloc ( f, t->num_elems, num_bytes ) ); + TRY ( t->num_elems = h5priv_alloc ( f, t->num_elems, num_bytes ) ); t->num_elems[t->cur_level] = -1; - TRY ( t->num_elems_on_level = _h5_alloc ( + TRY ( t->num_elems_on_level = h5priv_alloc ( f, t->num_elems_on_level, num_bytes ) ); t->num_elems_on_level[t->cur_level] = -1; @@ -149,14 +149,14 @@ h5t_begin_store_vertices ( h5t_fdata_t *t = f->t; if ( t->cur_level < 0 ) { - return _h5t_error_undef_level( f ); + return h5tpriv_error_undef_level( f ); } t->storing_data = 1; h5_size_t cur_num_vertices = ( t->cur_level > 0 ? t->num_vertices[t->cur_level-1] : 0 ); t->num_vertices[t->cur_level] = cur_num_vertices+num; t->dsinfo_vertices.dims[0] = cur_num_vertices+num; - return _h5t_alloc_num_vertices ( f, cur_num_vertices+num ); + return h5tpriv_alloc_num_vertices ( f, cur_num_vertices+num ); } h5_id_t @@ -178,7 +178,7 @@ h5t_store_vertex ( missing call to add the first level */ if ( t->cur_level < 0 ) - return _h5t_error_undef_level( f ); + return h5tpriv_error_undef_level( f ); t->level_changed = 1; h5_id_t local_id = ++t->last_stored_vid; @@ -196,9 +196,9 @@ h5t_end_store_vertices ( t->storing_data = 0; t->num_vertices[t->cur_level] = t->last_stored_vid+1; - TRY ( _h5t_assign_global_vertex_ids ( f ) ); - TRY ( _h5t_sort_vertices ( f ) ); - TRY ( _h5t_rebuild_global_2_local_map_of_vertices ( f ) ); + TRY ( h5tpriv_assign_global_vertex_ids ( f ) ); + TRY ( h5tpriv_sort_vertices ( f ) ); + TRY ( h5tpriv_rebuild_global_2_local_map_of_vertices ( f ) ); return H5_SUCCESS; } @@ -228,7 +228,7 @@ h5t_begin_store_elems ( prevent resizing. */ size_t nel = 2097152 > 5*new ? 2097152 : 5*new; - TRY ( _h5t_resize_te_htab ( f, nel ) ); + TRY ( h5tpriv_resize_te_htab ( f, nel ) ); return (*t->methods._alloc_elems) ( f, cur, new ); } @@ -247,12 +247,12 @@ h5t_store_elem ( /* level set? */ if ( t->cur_level < 0 ) - return _h5t_error_undef_level( f ); + return h5tpriv_error_undef_level( f ); /* more than allocated? */ if ( t->last_stored_eid+1 >= t->num_elems[t->cur_level] ) return HANDLE_H5_OVERFLOW_ERR( - f, _h5t_map_oid2str(t->mesh_type), + f, h5tpriv_map_oid2str(t->mesh_type), t->num_elems[t->cur_level] ); /* check parent id */ @@ -264,7 +264,7 @@ h5t_store_elem ( ) { return HANDLE_H5_PARENT_ID_ERR ( f, - _h5t_map_oid2str(t->mesh_type), + h5tpriv_map_oid2str(t->mesh_type), local_parent_eid ); } @@ -279,7 +279,7 @@ h5t_store_elem ( \param[in] local_vids Local vertex id's defining the tetrahedron. */ h5_id_t -_h5t_store_tet ( +h5tpriv_store_tet ( h5_file_t * const f, const h5_id_t local_parent_eid, const h5_id_t *local_vids @@ -295,11 +295,11 @@ _h5t_store_tet ( elem_ldta->level_id = t->cur_level; memcpy ( elem_ldta->local_vids, local_vids, sizeof (*local_vids) * t->mesh_type ); - _h5t_sort_local_vids ( f, elem_ldta->local_vids, t->mesh_type ); + h5tpriv_sort_local_vids ( f, elem_ldta->local_vids, t->mesh_type ); h5_id_t face_id; h5t_te_entry_t *retval; for ( face_id = 0; face_id < 6; face_id++ ) { - TRY ( _h5t_search_te2 ( + TRY ( h5tpriv_search_te2 ( f, face_id, local_eid, @@ -309,7 +309,7 @@ _h5t_store_tet ( } h5_id_t -_h5t_store_tri ( +h5tpriv_store_tri ( h5_file_t * const f, const h5_id_t local_parent_eid, const h5_id_t *local_vids @@ -325,11 +325,11 @@ _h5t_store_tri ( elem_ldta->level_id = t->cur_level; memcpy ( elem_ldta->local_vids, local_vids, sizeof (*local_vids) * t->mesh_type ); - _h5t_sort_local_vids ( f, elem_ldta->local_vids, t->mesh_type ); + h5tpriv_sort_local_vids ( f, elem_ldta->local_vids, t->mesh_type ); h5_id_t face_id; h5t_te_entry_t *retval; for ( face_id = 0; face_id < 3; face_id++ ) { - TRY ( _h5t_search_te2 ( + TRY ( h5tpriv_search_te2 ( f, face_id, local_eid, @@ -348,8 +348,8 @@ h5t_end_store_elems ( t->num_elems[t->cur_level] = t->last_stored_eid+1; TRY ( _assign_global_elem_ids ( f ) ); - TRY ( _h5t_sort_elems ( f ) ); - TRY ( _h5t_rebuild_global_2_local_map_of_elems ( f ) ); + TRY ( h5tpriv_sort_elems ( f ) ); + TRY ( h5tpriv_rebuild_global_2_local_map_of_elems ( f ) ); return H5_SUCCESS; } @@ -404,10 +404,12 @@ h5t_end_refine_elems ( /*! Refine edge. Store vertex, if new. + Function can be used with tetrahedral and triangle meshes. + \return local id of vertex */ h5_id_t -_h5t_bisect_edge ( +h5tpriv_bisect_edge ( h5_file_t * const f, h5_id_t face_id, h5_id_t el_id @@ -420,23 +422,23 @@ _h5t_bisect_edge ( get all elements sharing the given edge */ TRY ( h5t_get_local_vids_of_edge2 ( f, face_id, el_id, vids ) ); - TRY ( _h5t_find_te ( f, &item, &retval ) ); + TRY ( h5tpriv_find_te ( f, &item, &retval ) ); /* - check wether one of these elements has been refined + check wether one of the found elements has been refined */ size_t i; for ( i = 0; i < retval->value.num_items; i++ ) { - h5_id_t local_id = _h5t_get_elem_idx ( retval->value.items[i] ); + h5_id_t local_id = h5tpriv_get_elem_idx ( retval->value.items[i] ); h5_elem_ldta_t *tet = &t->elems_ldta[local_id]; if ( tet->local_child_eid >= 0 ) { /* this element has been refined! return bisecting point */ - h5_id_t face_id = _h5t_get_face_id ( + h5_id_t face_id = h5tpriv_get_face_id ( retval->value.items[i] ); h5_id_t kids[2], edge0[2], edge1[2]; - TRY ( _h5t_compute_direct_children_of_edge ( + TRY ( h5tpriv_compute_direct_children_of_edge ( f, face_id, tet->local_child_eid, @@ -466,7 +468,7 @@ _h5t_bisect_edge ( /*! Refine element \c local_eid - \return Local id of first new element or \c -1 + \return local id of first new element or \c -1 */ h5_id_t h5t_refine_elem ( @@ -483,7 +485,7 @@ h5t_refine_elem ( \return Local id of first new triangle or \c -1 */ h5_id_t -_h5t_refine_tri ( +h5tpriv_refine_tri ( h5_file_t * const f, const h5_id_t local_eid ) { @@ -503,9 +505,9 @@ _h5t_refine_tri ( local_vids[1] = el->local_vids[1]; local_vids[2] = el->local_vids[2]; - local_vids[3] = _h5t_bisect_edge( f, 0, local_eid ); /* 1,2 */ - local_vids[4] = _h5t_bisect_edge( f, 1, local_eid ); /* 0,2 */ - local_vids[5] = _h5t_bisect_edge( f, 2, local_eid ); /* 0,1 */ + local_vids[3] = h5tpriv_bisect_edge( f, 0, local_eid ); /* 1,2 */ + local_vids[4] = h5tpriv_bisect_edge( f, 1, local_eid ); /* 0,2 */ + local_vids[5] = h5tpriv_bisect_edge( f, 2, local_eid ); /* 0,1 */ h5_id_t new_el[3]; @@ -513,25 +515,25 @@ _h5t_refine_tri ( new_el[0] = local_vids[0]; new_el[1] = local_vids[4]; new_el[2] = local_vids[5]; - TRY ( local_child_eid = _h5t_store_tri ( f, local_eid, new_el ) ); + TRY ( local_child_eid = h5tpriv_store_tri ( f, local_eid, new_el ) ); /* 1 */ new_el[0] = local_vids[1]; new_el[1] = local_vids[3]; new_el[2] = local_vids[5]; - TRY ( _h5t_store_tri ( f, local_eid, new_el ) ); + TRY ( h5tpriv_store_tri ( f, local_eid, new_el ) ); /* 2 */ new_el[0] = local_vids[2]; new_el[1] = local_vids[3]; new_el[2] = local_vids[4]; - TRY ( _h5t_store_tri ( f, local_eid, new_el ) ); + TRY ( h5tpriv_store_tri ( f, local_eid, new_el ) ); /* 3 */ new_el[0] = local_vids[3]; new_el[1] = local_vids[4]; new_el[2] = local_vids[5]; - TRY ( _h5t_store_tri ( f, local_eid, new_el ) ); + TRY ( h5tpriv_store_tri ( f, local_eid, new_el ) ); return local_child_eid; } @@ -544,7 +546,7 @@ _h5t_refine_tri ( */ h5_err_t -_h5t_compute_direct_children_of_edge ( +h5tpriv_compute_direct_children_of_edge ( h5_file_t * const f, h5_id_t face_id, h5_id_t local_eid, @@ -555,8 +557,8 @@ _h5t_compute_direct_children_of_edge ( if ( ( face_id < 0 ) || ( face_id >= 6 ) ) { return h5_error_internal ( f, __FILE__, __func__, __LINE__ ); } - kids[0] = _h5t_build_edge_id ( face_id, local_eid+off[face_id][0] ); - kids[1] = _h5t_build_edge_id ( face_id, local_eid+off[face_id][1] ); + kids[0] = h5tpriv_build_edge_id ( face_id, local_eid+off[face_id][0] ); + kids[1] = h5tpriv_build_edge_id ( face_id, local_eid+off[face_id][1] ); return H5_SUCCESS; } @@ -567,7 +569,7 @@ _h5t_compute_direct_children_of_edge ( \return Local id of first new tetrahedron or \c -1 */ h5_id_t -_h5t_refine_tet ( +h5tpriv_refine_tet ( h5_file_t * const f, const h5_id_t local_eid ) { @@ -587,12 +589,12 @@ _h5t_refine_tet ( local_vids[2] = tet->local_vids[2]; local_vids[3] = tet->local_vids[3]; - local_vids[4] = _h5t_bisect_edge( f, 0, local_eid ); - local_vids[5] = _h5t_bisect_edge( f, 2, local_eid ); - local_vids[6] = _h5t_bisect_edge( f, 3, local_eid ); - local_vids[7] = _h5t_bisect_edge( f, 1, local_eid ); - local_vids[8] = _h5t_bisect_edge( f, 4, local_eid ); - local_vids[9] = _h5t_bisect_edge( f, 5, local_eid ); + local_vids[4] = h5tpriv_bisect_edge( f, 0, local_eid ); + local_vids[5] = h5tpriv_bisect_edge( f, 2, local_eid ); + local_vids[6] = h5tpriv_bisect_edge( f, 3, local_eid ); + local_vids[7] = h5tpriv_bisect_edge( f, 1, local_eid ); + local_vids[8] = h5tpriv_bisect_edge( f, 4, local_eid ); + local_vids[9] = h5tpriv_bisect_edge( f, 5, local_eid ); /* add new tets @@ -604,7 +606,7 @@ _h5t_refine_tet ( new_tet_local_vids[1] = local_vids[6]; // (03) new_tet_local_vids[2] = local_vids[5]; // (02) new_tet_local_vids[3] = local_vids[4]; // (01) - TRY ( local_child_eid = _h5t_store_tet ( + TRY ( local_child_eid = h5tpriv_store_tet ( f, local_eid, new_tet_local_vids ) ); /* 1 */ @@ -612,49 +614,49 @@ _h5t_refine_tet ( new_tet_local_vids[1] = local_vids[8]; // (13) new_tet_local_vids[2] = local_vids[7]; // (12) new_tet_local_vids[3] = local_vids[1]; - TRY ( _h5t_store_tet ( f, local_eid, new_tet_local_vids ) ); + TRY ( h5tpriv_store_tet ( f, local_eid, new_tet_local_vids ) ); /* 2 */ new_tet_local_vids[0] = local_vids[5]; // (02) new_tet_local_vids[1] = local_vids[9]; // (23) new_tet_local_vids[2] = local_vids[2]; new_tet_local_vids[3] = local_vids[7]; // (12) - TRY ( _h5t_store_tet ( f, local_eid, new_tet_local_vids ) ); + TRY ( h5tpriv_store_tet ( f, local_eid, new_tet_local_vids ) ); /* 3 */ new_tet_local_vids[0] = local_vids[6]; // (03) new_tet_local_vids[1] = local_vids[3]; new_tet_local_vids[2] = local_vids[9]; // (23) new_tet_local_vids[3] = local_vids[8]; // (13) - TRY ( _h5t_store_tet ( f, local_eid, new_tet_local_vids ) ); + TRY ( h5tpriv_store_tet ( f, local_eid, new_tet_local_vids ) ); /* 4 */ new_tet_local_vids[0] = local_vids[6]; // (03) new_tet_local_vids[1] = local_vids[5]; // (02) new_tet_local_vids[2] = local_vids[4]; // (01) new_tet_local_vids[3] = local_vids[8]; // (13) - TRY ( _h5t_store_tet ( f, local_eid, new_tet_local_vids ) ); + TRY ( h5tpriv_store_tet ( f, local_eid, new_tet_local_vids ) ); /* 5 */ new_tet_local_vids[0] = local_vids[5]; // (02) new_tet_local_vids[1] = local_vids[4]; // (01) new_tet_local_vids[2] = local_vids[8]; // (13) new_tet_local_vids[3] = local_vids[7]; // (12) - TRY ( _h5t_store_tet ( f, local_eid, new_tet_local_vids ) ); + TRY ( h5tpriv_store_tet ( f, local_eid, new_tet_local_vids ) ); /* 6 */ new_tet_local_vids[0] = local_vids[6]; // (03) new_tet_local_vids[1] = local_vids[5]; // (02) new_tet_local_vids[2] = local_vids[9]; // (23) new_tet_local_vids[3] = local_vids[8]; // (13) - TRY ( _h5t_store_tet ( f, local_eid, new_tet_local_vids ) ); + TRY ( h5tpriv_store_tet ( f, local_eid, new_tet_local_vids ) ); /* 7 */ new_tet_local_vids[0] = local_vids[5]; // (02) new_tet_local_vids[1] = local_vids[9]; // (23) new_tet_local_vids[2] = local_vids[8]; // (13) new_tet_local_vids[3] = local_vids[7]; // (12) - TRY ( _h5t_store_tet ( f, local_eid, new_tet_local_vids ) ); + TRY ( h5tpriv_store_tet ( f, local_eid, new_tet_local_vids ) ); t->elems.tets[local_eid].global_child_eid = local_child_eid; t->elems_ldta[local_eid].local_child_eid = local_child_eid; diff --git a/src/h5_core/h5t_storemesh_private.h b/src/h5_core/h5t_storemesh_private.h index 3f8b782..81554c6 100644 --- a/src/h5_core/h5t_storemesh_private.h +++ b/src/h5_core/h5t_storemesh_private.h @@ -2,21 +2,21 @@ #define __H5T_STOREMESH_PRIVATE_H h5_id_t -_h5t_store_tri ( +h5tpriv_store_tri ( h5_file_t * const f, const h5_id_t local_parent_eid, const h5_id_t vids[] ); h5_id_t -_h5t_store_tet ( +h5tpriv_store_tet ( h5_file_t * const f, const h5_id_t local_parent_eid, const h5_id_t vids[] ); h5_err_t -_h5t_compute_direct_children_of_edge ( +h5tpriv_compute_direct_children_of_edge ( h5_file_t * const f, h5_id_t face_id, h5_id_t local_eid, @@ -24,13 +24,13 @@ _h5t_compute_direct_children_of_edge ( ); h5_id_t -_h5t_refine_tri ( +h5tpriv_refine_tri ( h5_file_t * const f, const h5_id_t local_eid ); h5_id_t -_h5t_refine_tet ( +h5tpriv_refine_tet ( h5_file_t * const f, const h5_id_t local_eid ); diff --git a/src/h5_core/h5t_tags.c b/src/h5_core/h5t_tags.c index 77d89be..7c18915 100644 --- a/src/h5_core/h5t_tags.c +++ b/src/h5_core/h5t_tags.c @@ -18,17 +18,17 @@ static h5_err_t _init_container ( h5_file_t * const f, const size_t ntags, - h5t_tagcontainer_t * container + h5t_tagcontainer_t * ctn ) { - container->names = _h5_calloc ( f, ntags, sizeof(char*) ); - TRY ( _h5_hcreate_string_keyed ( f, ntags, &container->sets ) ); + ctn->names = h5priv_calloc ( f, ntags, sizeof(char*) ); + TRY ( h5priv_hcreate_string_keyed ( f, ntags, &ctn->sets ) ); return H5_SUCCESS; } /* Initialize tag container for current mesh and level. */ h5_err_t -_h5t_init_mtagsets ( +h5tpriv_init_mtagsets ( h5_file_t * const f, size_t ntags ) { @@ -45,7 +45,7 @@ _release_tagvals_of_elem ( ) { unsigned int i = 0; for ( i = 0; i < el_vals->size; i++ ) { - TRY ( _h5_free ( f, el_vals->valp[i] ) ); + TRY ( h5priv_free ( f, el_vals->valp[i] ) ); } return H5_SUCCESS; } @@ -58,15 +58,15 @@ _release_tagset ( h5_file_t * const f, const void *__set ) { - h5t_tagset_t *set = *(h5t_tagset_t**)__set; + H5T_Tagset *set = *(H5T_Tagset**)__set; unsigned int i; for ( i = 0; i < set->num_elems; i++ ) { if ( set->elems[i] != NULL ) { TRY ( _release_tagvals_of_elem ( f, set->elems[i] ) ); } } - TRY ( _h5_free ( f, set->name ) ); - TRY ( _h5_free ( f, set ) ); + TRY ( h5priv_free ( f, set->name ) ); + TRY ( h5priv_free ( f, set ) ); return H5_SUCCESS; } @@ -76,10 +76,10 @@ _release_tagset ( static h5_err_t _release_container ( h5_file_t * const f, - h5t_tagcontainer_t * container + h5t_tagcontainer_t * ctn ) { - TRY ( _h5_hwalk ( f, &container->sets, _release_tagset ) ); - TRY ( _h5_free ( f, container->names ) ); + TRY ( h5priv_hwalk ( f, &ctn->sets, _release_tagset ) ); + TRY ( h5priv_free ( f, ctn->names ) ); return H5_SUCCESS; } @@ -88,7 +88,7 @@ _release_container ( Release mesh tag-sets */ h5_err_t -_h5t_release_tags ( +h5tpriv_release_tags ( h5_file_t * const f ) { h5t_fdata_t *t = f->t; @@ -108,11 +108,11 @@ _h5t_release_tags ( \return H5_SUCCESS or error code */ h5_err_t -_h5t_add_mtagset ( +h5tpriv_add_mtagset ( h5_file_t * const f, char * name, h5_id_t type, - h5t_tagset_t **rtagset + H5T_Tagset **rtagset ) { h5t_fdata_t *t = f->t; @@ -120,7 +120,7 @@ _h5t_add_mtagset ( Initialize data structure for m-tagsets, if not already done. */ if ( t->mtags.names == NULL ) { - TRY ( _h5t_init_mtagsets ( f, 521 ) ); + TRY ( h5tpriv_init_mtagsets ( f, 521 ) ); } /* ToDo: Resize! @@ -143,12 +143,12 @@ _h5t_add_mtagset ( /* create new tagset */ - h5t_tagset_t *tagset = NULL; + H5T_Tagset *tagset = NULL; size_t size = (t->num_elems[t->num_levels-1] - 1) * sizeof(*tagset->elems) + sizeof(*tagset); - TRY ( (tagset = _h5_calloc ( f, 1, size ) ) ); + TRY ( (tagset = h5priv_calloc ( f, 1, size ) ) ); - TRY ( ( tagset->name = _h5_calloc ( f, 1, strlen(name)+1 ) ) ); + TRY ( ( tagset->name = h5priv_calloc ( f, 1, strlen(name)+1 ) ) ); strcpy ( tagset->name, name ); tagset->type = type; tagset->num_elems = t->num_elems[t->num_levels-1]; @@ -156,7 +156,7 @@ _h5t_add_mtagset ( add tagset to hash of tagsets */ void *__retval = NULL; - TRY ( _h5_hsearch ( f, tagset, H5_ENTER, &__retval, &t->mtags.sets ) ); + TRY ( h5priv_hsearch ( f, tagset, H5_ENTER, &__retval, &t->mtags.sets ) ); t->mtags.changed = 1; t->mtags.names[t->mtags.num_sets] = tagset->name; @@ -172,7 +172,65 @@ h5t_add_mtagset ( char * name, h5_id_t type ) { - return _h5t_add_mtagset ( f, name, type, 0 ); + return h5tpriv_add_mtagset ( f, name, type, 0 ); +} + + +/*! + 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 h5_err_t +_remove_tagset ( + h5_file_t *const f, + h5t_tagcontainer_t *ctn, + const char name[] + ) { + h5t_fdata_t *t = f->t; + + /* + remove tagset with NAME from m-tagsets dictionary + */ + void *__retval = NULL; + TRY ( h5priv_hsearch ( f, &name, H5_REMOVE, &__retval, &ctn->sets ) ); + H5T_Tagset *tagset = (H5T_Tagset*)__retval; + if ( tagset == NULL ) return H5_SUCCESS; + + size_t el_idx, i; + size_t num_elems = t->num_elems[t->num_levels-1]; + for ( el_idx = 0; el_idx < num_elems; el_idx++ ) { + h5t_tagsel_t *tags_of_elem = tagset->elems[el_idx]; + /* + release all m-tags for this element + */ + for ( i = 0; i < tags_of_elem->size; i++ ) { + TRY ( h5priv_free ( f, tags_of_elem->valp[i] ) ); + } + /* + release m-tag object for this element + */ + TRY ( h5priv_free ( f, tags_of_elem ) ); + } + /* + release tagset object + */ + TRY ( h5priv_free ( f, tagset ) ); + /* + remove HDF5 datasets and group for this tagset + */ + hid_t loc_id; + TRY ( loc_id = h5priv_open_group ( f, ctn->group_id, name ) ); + TRY ( h5priv_delete_hdf5_link ( f, loc_id, "elems", H5P_DEFAULT ) ); + TRY ( h5priv_delete_hdf5_link ( f, loc_id, "entities", H5P_DEFAULT ) ); + TRY ( h5priv_delete_hdf5_link ( f, loc_id, "values", H5P_DEFAULT ) ); + TRY ( h5priv_close_hdf5_group ( f, loc_id ) ); + TRY ( h5priv_delete_hdf5_link ( f, ctn->group_id, name, H5P_DEFAULT ) ); + + return H5_SUCCESS; } /*! @@ -186,19 +244,17 @@ h5t_add_mtagset ( h5_err_t h5t_remove_mtagset ( h5_file_t *const f, - char name[] + const char name[] ) { - /* - - release all m-tags - - release pointer array - - remove tagset with NAME from m-tagsets dictionary - - remove HDF5 dataset - */ - return -2; + h5t_fdata_t *t = f->t; + + TRY ( t->mtags.group_id = h5priv_open_group ( f, t->mesh_gid, "Tags" ) ); + TRY ( _remove_tagset ( f, &t->mtags, name ) ); + TRY ( h5priv_close_hdf5_group ( f, t->mtags.group_id ) ); + return H5_SUCCESS; } - -h5_size_t +h5_ssize_t h5t_get_num_mtagsets ( h5_file_t *const f ) { @@ -214,7 +270,7 @@ h5t_get_num_mtagsets ( \return Number of mesh tag-sets */ -h5_size_t +h5_ssize_t h5t_get_mtagsets ( h5_file_t *const f, char **names[] @@ -228,13 +284,13 @@ h5_err_t h5t_open_mtagset ( h5_file_t *const f, const char *name, - h5t_tagset_t **retval + H5T_Tagset **retval ) { h5t_fdata_t *t = f->t; void *__retval = NULL; - TRY ( _h5_hsearch ( f, &name, H5_FIND, &__retval, + TRY ( h5priv_hsearch ( f, &name, H5_FIND, &__retval, &t->mtags.sets ) ); - *retval = (h5t_tagset_t*)__retval; + *retval = (H5T_Tagset*)__retval; return H5_SUCCESS; } @@ -251,7 +307,7 @@ h5t_get_mtagset_type_by_name ( h5_file_t *const f, char *name ) { - h5t_tagset_t *tagset; + H5T_Tagset *tagset; TRY ( h5t_open_mtagset ( f, name, &tagset ) ); return tagset->type; } @@ -264,7 +320,7 @@ h5t_get_mtagset_type_by_name ( \param[out] name name of tag-set \param[out] type type of tag-set */ -h5_size_t +h5_ssize_t h5t_get_mtagset_info ( h5_file_t *const f, h5_id_t idx, @@ -274,9 +330,9 @@ h5t_get_mtagset_info ( h5t_fdata_t *t = f->t; *name = t->mtags.names[idx]; void *__retval = NULL; - _h5_hsearch ( f, t->mtags.names[idx], H5_FIND, &__retval, + h5priv_hsearch ( f, t->mtags.names[idx], H5_FIND, &__retval, &t->mtags.sets ); - h5t_tagset_t *retval = (h5t_tagset_t*)__retval; + H5T_Tagset *retval = (H5T_Tagset*)__retval; *type = retval->type; return H5_SUCCESS; } @@ -293,23 +349,23 @@ h5t_get_mtagset_info ( \return H5_SUCCESS or error code */ h5_err_t -_h5t_set_mtag ( +h5tpriv_set_mtag ( h5_file_t *const f, - h5t_tagset_t *tagset, + H5T_Tagset *tagset, const h5_id_t id, const size_t size, void *val ) { size_t offs[5] = { 14, 0, 4, 10, 14 }; - h5_id_t el_idx = _h5t_get_elem_idx ( id ); - h5_id_t eoe_id = _h5t_get_face_id ( id ); - h5_id_t type_id = _h5t_get_entity_type ( id ); + h5_id_t el_idx = h5tpriv_get_elem_idx ( id ); + h5_id_t eoe_id = h5tpriv_get_face_id ( id ); + h5_id_t type_id = h5tpriv_get_entity_type ( id ); if ( tagset->elems[el_idx] == NULL ) { /* alloc new structure to store all tags for this element and the given name */ - TRY ( ( tagset->elems[el_idx] = _h5_calloc ( + TRY ( ( tagset->elems[el_idx] = h5priv_calloc ( f, 1, sizeof(*tagset->elems[el_idx] ) ) ) ); @@ -334,7 +390,7 @@ _h5t_set_mtag ( */ size_t num_bytes = sizeof(*tagselem) + (tagselem->size-1) * sizeof(void*); - TRY ( ( tagset->elems[el_idx] = _h5_alloc ( + TRY ( ( tagset->elems[el_idx] = h5priv_alloc ( f, tagselem, num_bytes ) ) ); tagselem = tagset->elems[el_idx]; /* @@ -348,7 +404,7 @@ _h5t_set_mtag ( */ size_t num_bytes = (size-1) * sizeof(h5_float64_t) + sizeof(h5t_tagval_t); size_t k = tagselem->idx[i]; - TRY ( ( tagselem->valp[k] = _h5_alloc ( + TRY ( ( tagselem->valp[k] = h5priv_alloc ( f, tagselem->valp[k], num_bytes ) ) ); h5t_tagval_t *tagval = tagselem->valp[k]; tagval->size = size; @@ -363,8 +419,8 @@ _h5t_set_mtag ( \param[in] f file handle \param[in] name names of tagset \param[in] id local id of entity - \param[in] size size of value \param[in] val tag value + \param[in] size size of value \return H5_SUCCESS or error code */ @@ -374,35 +430,23 @@ h5t_set_mtag_by_name ( char name[], const h5_id_t id, const size_t size, - void *val - ) { - h5t_tagset_t *tagset; - TRY ( h5t_open_mtagset ( f, name, &tagset ) ); - return _h5t_set_mtag ( f, tagset, id, size, val ); -} - -/*! - Get 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] size dimension of value - \param[out] val tag value - - \return H5_SUCCESS or error code - */ -h5_err_t -h5t_get_mtag ( - h5_file_t *const f, - const h5t_tagset_t *tagset, - const h5_id_t id, - size_t *size, void *val ) { - h5_id_t el_idx = _h5t_get_elem_idx ( id ); - h5_id_t subentity_id = _h5t_get_face_id ( id ); - h5_id_t type_id = _h5t_get_entity_type ( id ); + H5T_Tagset *tagset; + TRY ( h5t_open_mtagset ( f, name, &tagset ) ); + return h5tpriv_set_mtag ( f, tagset, id, size, val ); +} + +static h5_err_t +_get_tag_valp ( + h5_file_t *const f, + const H5T_Tagset *tagset, + const h5_id_t entity_id, + h5t_tagval_t **valp + ) { + h5_id_t el_idx = h5tpriv_get_elem_idx ( entity_id ); + h5_id_t subentity_id = h5tpriv_get_face_id ( entity_id ); + h5_id_t type_id = h5tpriv_get_entity_type ( entity_id ); if ( tagset->elems[el_idx] == NULL ) { return H5_NOK; /* no tags for this element */ @@ -415,14 +459,42 @@ h5t_get_mtag ( return H5_NOK; /* no value set for this subentity */ } size_t k = tagselem->idx[i]; - h5t_tagval_t *tagval = tagselem->valp[k]; - - *size = tagval->size; - memcpy ( val, &tagval->vals, *size * sizeof(h5_float64_t) ); + valp = &tagselem->valp[k]; return H5_SUCCESS; } +/*! + Get tag for entity in given tagset. + + \param[in] f file handle + \param[in] name names of tagset + \param[in] id id of entity + \param[out] size dimension of value + \param[out] val tag value + + \return H5_SUCCESS or error code + */ +h5_ssize_t +h5t_get_tag ( + h5_file_t *const f, + const H5T_Tagset *tagset, + const h5_id_t entity_id, + size_t *dim, + void *vals + ) { + h5t_tagval_t *tagval; + TRY ( _get_tag_valp ( f, tagset, entity_id, &tagval ) ); + + if ( (*dim > tagval->size) || (vals == NULL) ) { + *dim = tagval->size; + } + if ( vals != NULL ) { + memcpy ( vals, &tagval->vals, *dim * sizeof(h5_float64_t) ); + } + return tagval->size; +} + /*! Get tag for entity in current mesh. @@ -434,28 +506,35 @@ h5t_get_mtag ( \return H5_SUCCESS or error code */ -h5_err_t +h5_ssize_t h5t_get_mtag_by_name ( - h5_file_t *const f, + h5_file_t* const f, const char name[], const h5_id_t id, - size_t *size, - void *val + size_t* dim, + void* vals ) { - h5t_tagset_t *tagset; + H5T_Tagset* tagset; TRY ( h5t_open_mtagset ( f, name, &tagset ) ); - return h5t_get_mtag ( f, tagset, id, size, val ); + return h5t_get_tag ( f, tagset, id, dim, vals ); } +/*! + Remove tag for entity in current mesh. + + \param[in] f file handle + \param[in] tagset pointer to tagset + \param[in] id id of entity +*/ h5_err_t h5t_remove_mtag ( h5_file_t *const f, - h5t_tagset_t *tagset, + H5T_Tagset *tagset, const h5_id_t id ) { - h5_id_t el_idx = _h5t_get_elem_idx ( id ); - h5_id_t subentity_id = _h5t_get_face_id ( id ); - h5_id_t type_id = _h5t_get_entity_type ( id ); + h5_id_t el_idx = h5tpriv_get_elem_idx ( id ); + h5_id_t subentity_id = h5tpriv_get_face_id ( id ); + h5_id_t type_id = h5tpriv_get_entity_type ( id ); if ( tagset->elems[el_idx] == NULL ) { return H5_SUCCESS; /* no tags for this element */ @@ -469,7 +548,21 @@ h5t_remove_mtag ( } size_t k = tagselem->idx[i]; h5t_tagval_t *tagval = tagselem->valp[k]; - TRY ( _h5_free ( f, tagval ) ); + TRY ( h5priv_free ( f, tagval ) ); + /* + remove from array + */ + size_t n = ( tagselem->size-k-1) * sizeof(tagselem->valp[0]); + memmove ( tagselem->valp[k], tagselem->valp[k+1], n ); + tagselem->size--; + /* + adapt indices + */ + for ( i = 0; i < tagselem->size; i++ ) { + if ( tagselem->idx[i] > k ) { + tagselem->idx[i]--; + } + } return H5_SUCCESS; } @@ -486,7 +579,7 @@ h5t_remove_mtag_by_name ( const char name[], const h5_id_t id ) { - h5t_tagset_t *tagset; + H5T_Tagset *tagset; TRY ( h5t_open_mtagset ( f, name, &tagset ) ); return h5t_remove_mtag ( f, tagset, id ); } @@ -506,7 +599,7 @@ static h5_err_t _write_tagset ( h5_file_t * const f, hid_t loc_id, - h5t_tagset_t *tagset + H5T_Tagset *tagset ) { h5t_fdata_t *t = f->t; hid_t group_id; @@ -514,23 +607,23 @@ _write_tagset ( alloc memory */ h5t_tag_idx_t *elems; - size_t idx_elem; + size_t el_idx; size_t num_elems = t->num_elems[t->num_levels-1]; - TRY ( ( elems = _h5_calloc ( + TRY ( ( elems = h5priv_calloc ( f, num_elems+1, sizeof(*elems) ) ) ); h5t_tag_idx_t *entities; - size_t idx_entity = 0; + size_t ent_idx = 0; size_t num_entities = 0; size_t max_entities = num_elems+1; - TRY ( ( entities = _h5_calloc ( + TRY ( ( entities = h5priv_calloc ( f, max_entities, sizeof(*entities) ) ) ); h5_int64_t *vals; - size_t idx_val = 0; + size_t val_idx = 0; size_t num_vals = 0; size_t max_vals = num_elems; - TRY ( ( vals = _h5_calloc ( + TRY ( ( vals = h5priv_calloc ( f, max_vals, sizeof(*vals) ) ) ); h5_id_t tmap[15] = { H5T_ETYPE_VERTEX, H5T_ETYPE_VERTEX, @@ -549,12 +642,12 @@ _write_tagset ( /* build data structures in memory */ - for ( idx_elem = 0; idx_elem < num_elems; idx_elem++ ) { - h5t_tagsel_t *tags_of_elem = tagset->elems[idx_elem]; + for ( el_idx = 0; el_idx < num_elems; el_idx++ ) { + h5t_tagsel_t *tags_of_elem = tagset->elems[el_idx]; size_t num_subentities = 0; - h5_id_t start_idx_entities = idx_entity; + h5_id_t start_idx_entities = ent_idx; size_t i; - for ( i = 0; i < 15; i++ ) { + for ( i = 0; i < tags_of_elem->size; i++ ) { int k = tags_of_elem->idx[i]; if ( k == -1 ) continue; h5t_tagval_t *valp = tags_of_elem->valp[k]; @@ -562,53 +655,53 @@ _write_tagset ( /* append value to array of values */ - if ( idx_val + valp->size > max_vals ) { + if ( val_idx + valp->size > max_vals ) { max_vals += num_elems; - TRY ( ( vals = _h5_alloc ( + TRY ( ( vals = h5priv_alloc ( f, vals, max_vals*sizeof(*vals) ) ) ); } memcpy ( - vals+idx_val, + vals+val_idx, &valp->vals[0].i, valp->size*sizeof(*vals) ); /* append entity descriptor */ - if ( idx_entity >= max_entities ) { + if ( ent_idx >= max_entities ) { max_entities += num_elems; - TRY ( ( entities = _h5_alloc ( + TRY ( ( entities = h5priv_alloc ( f, entities, max_entities*sizeof(*entities) ) ) ); } h5_id_t type_id = tmap[i]; h5_id_t sentity_id = smap[i]; - entities[idx_entity].eid = _h5t_build_id ( - type_id, sentity_id, idx_elem ); - entities[idx_entity].idx = idx_val; - idx_val += valp->size; - idx_entity++; + entities[ent_idx].eid = h5tpriv_build_id ( + type_id, sentity_id, el_idx ); + entities[ent_idx].idx = val_idx; + val_idx += valp->size; + ent_idx++; } /* append element descriptor */ - elems[idx_elem].eid = idx_elem; - elems[idx_elem].idx = start_idx_entities; + elems[el_idx].eid = el_idx; + elems[el_idx].idx = start_idx_entities; start_idx_entities += num_subentities; } - num_entities = idx_entity; - num_vals = idx_val; + num_entities = ent_idx; + num_vals = val_idx; elems[num_elems].eid = -1; elems[num_elems].idx = num_entities; - entities[idx_entity].eid = -1; - entities[idx_entity].idx = num_vals; + entities[ent_idx].eid = -1; + entities[ent_idx].idx = num_vals; /* write data */ - TRY ( group_id = _h5_open_group ( f, loc_id, tagset->name ) ); + TRY ( group_id = h5priv_open_group ( f, loc_id, tagset->name ) ); h5_dsinfo_t dsinfo; memset ( &dsinfo, 0, sizeof(dsinfo) ); dsinfo.rank = 1; @@ -619,12 +712,12 @@ _write_tagset ( strcpy ( dsinfo.name, "elems" ); dsinfo.dims[0] = num_elems + 1; dsinfo.type_id = t->dtypes.h5t_tag_idx_t; - TRY( dsinfo.create_prop = _hdf_create_property ( f, + TRY( dsinfo.create_prop = h5priv_create_hdf5_property ( f, H5P_DATASET_CREATE ) ); - TRY( _hdf_set_chunk_property ( f, dsinfo.create_prop, dsinfo.rank, + TRY( h5priv_set_hdf5_chunk_property ( f, dsinfo.create_prop, dsinfo.rank, dsinfo.chunk_dims ) ); - TRY ( _h5_write_dataset_by_name ( + TRY ( h5priv_write_dataset_by_name ( f, group_id, &dsinfo, @@ -634,7 +727,7 @@ _write_tagset ( strcpy ( dsinfo.name, "entities" ); dsinfo.dims[0] = num_entities + 1; - TRY ( _h5_write_dataset_by_name ( + TRY ( h5priv_write_dataset_by_name ( f, group_id, &dsinfo, @@ -645,7 +738,7 @@ _write_tagset ( dsinfo.dims[0] = num_vals; dsinfo.type_id = t->dtypes.h5_int64_t; - TRY ( _h5_write_dataset_by_name ( + TRY ( h5priv_write_dataset_by_name ( f, group_id, &dsinfo, @@ -661,23 +754,23 @@ _write_tagset ( static h5_err_t _write_container ( h5_file_t * const f, - h5t_tagcontainer_t *container + h5t_tagcontainer_t *ctn ) { size_t idx; - for ( idx = 0; idx < container->num_sets; idx++ ) { + for ( idx = 0; idx < ctn->num_sets; idx++ ) { void *__retval; - TRY ( _h5_hsearch ( f, - &container->names[idx], + TRY ( h5priv_hsearch ( f, + &ctn->names[idx], H5_FIND, &__retval, - &container->sets ) ); - h5t_tagset_t *tagset = (h5t_tagset_t*)__retval; - if ( tagset->changed ) { - TRY ( _write_tagset ( - f, - container->group_id, - tagset ) ); - } + &ctn->sets ) ); + H5T_Tagset *tagset = (H5T_Tagset*)__retval; + if ( tagset->changed ) { + TRY ( _write_tagset ( + f, + ctn->group_id, + tagset ) ); + } } return H5_SUCCESS; } @@ -687,12 +780,14 @@ _write_container ( Store mesh tags container */ h5_err_t -_h5t_write_mtags ( +h5tpriv_write_mtags ( h5_file_t *const f ) { h5t_fdata_t *t = f->t; - TRY ( t->mtags.group_id = _h5_open_group ( f, t->mesh_gid, "Tags" ) ); - return _write_container ( f, &f->t->mtags ); + TRY ( t->mtags.group_id = h5priv_open_group ( f, t->mesh_gid, "Tags" ) ); + TRY ( _write_container ( f, &f->t->mtags ) ); + TRY ( h5priv_close_hdf5_group ( f, t->mtags.group_id ) ); + return H5_SUCCESS; } static h5_err_t @@ -706,8 +801,8 @@ _read_tagset ( h5_id_t type; hid_t group_id; hid_t dset_id; - TRY ( _hdf_get_objname_by_idx_in_group ( f, loc_id, idx, &name ) ); - TRY ( group_id = _hdf_open_group ( f, loc_id, name ) ); + TRY ( h5priv_get_objname_by_idx_in_hdf5_group ( f, loc_id, idx, &name ) ); + TRY ( group_id = h5priv_open_hdf5_group ( f, loc_id, name ) ); /* read datasets: "elems", "entities" and "values" @@ -715,59 +810,59 @@ _read_tagset ( h5t_tag_idx_t *elems; size_t num_elems = 0; - TRY ( dset_id = _hdf_open_dataset ( f, group_id, "elems" ) ); - TRY ( num_elems = _hdf_get_npoints_of_dataset ( f, dset_id ) ); - TRY ( elems = _h5_calloc ( f, num_elems, sizeof(*elems) ) ); + TRY ( dset_id = h5priv_open_hdf5_dataset ( f, group_id, "elems" ) ); + TRY ( num_elems = h5priv_get_npoints_of_hdf5_dataset ( f, dset_id ) ); + TRY ( elems = h5priv_calloc ( f, num_elems, sizeof(*elems) ) ); h5_dsinfo_t dsinfo; memset ( &dsinfo, 0, sizeof(dsinfo) ); dsinfo.type_id = t->dtypes.h5t_tag_idx_t; - TRY ( _h5_read_dataset ( + TRY ( h5priv_read_dataset ( f, dset_id, &dsinfo, _open_space_all, _open_space_all, elems ) ); - TRY ( _hdf_close_dataset ( f, dset_id ) ); + TRY ( h5priv_close_hdf5_dataset ( f, dset_id ) ); num_elems--; h5t_tag_idx_t *entities; - size_t idx_entity = 0; + size_t ent_idx = 0; size_t num_entities = 0; - TRY ( dset_id = _hdf_open_dataset ( f, group_id, "entities" ) ); - TRY ( num_entities = _hdf_get_npoints_of_dataset ( f, dset_id ) ); - TRY ( entities = _h5_calloc ( f, num_entities, sizeof(*entities) ) ); - TRY ( _h5_read_dataset ( + TRY ( dset_id = h5priv_open_hdf5_dataset ( f, group_id, "entities" ) ); + TRY ( num_entities = h5priv_get_npoints_of_hdf5_dataset ( f, dset_id ) ); + TRY ( entities = h5priv_calloc ( f, num_entities, sizeof(*entities) ) ); + TRY ( h5priv_read_dataset ( f, dset_id, &dsinfo, _open_space_all, _open_space_all, entities ) ); - TRY ( _hdf_close_dataset ( f, dset_id ) ); + TRY ( h5priv_close_hdf5_dataset ( f, dset_id ) ); num_entities--; h5_int64_t *vals; size_t num_vals = 0; - TRY ( dset_id = _hdf_open_dataset ( f, group_id, "values" ) ); - TRY ( num_vals = _hdf_get_npoints_of_dataset ( f, dset_id ) ); - TRY ( vals = _h5_calloc ( f, num_vals, sizeof(*vals) ) ); - TRY ( dsinfo.type_id = _hdf_get_dataset_type ( f, dset_id ) ); - TRY ( _h5_read_dataset ( + TRY ( dset_id = h5priv_open_hdf5_dataset ( f, group_id, "values" ) ); + TRY ( num_vals = h5priv_get_npoints_of_hdf5_dataset ( f, dset_id ) ); + TRY ( vals = h5priv_calloc ( f, num_vals, sizeof(*vals) ) ); + TRY ( dsinfo.type_id = h5priv_get_hdf5_dataset_type ( f, dset_id ) ); + TRY ( h5priv_read_dataset ( f, dset_id, &dsinfo, _open_space_all, _open_space_all, vals ) ); - TRY ( _hdf_close_dataset ( f, dset_id ) ); + TRY ( h5priv_close_hdf5_dataset ( f, dset_id ) ); type = h5_normalize_h5_type ( f, dsinfo.type_id ); /* add tagset and set values */ - h5t_tagset_t *tagset; - TRY ( _h5t_add_mtagset ( f, name, type, &tagset ) ); - for ( idx_entity = 0; idx_entity < num_entities; idx_entity++ ) { - h5t_tag_idx_t *entity = &entities[idx_entity]; + H5T_Tagset *tagset; + TRY ( h5tpriv_add_mtagset ( f, name, type, &tagset ) ); + for ( ent_idx = 0; ent_idx < num_entities; ent_idx++ ) { + h5t_tag_idx_t *entity = &entities[ent_idx]; size_t dim = (entity+1)->idx - entity->idx; - TRY ( _h5t_set_mtag ( + TRY ( h5tpriv_set_mtag ( f, tagset, entity->eid, @@ -779,19 +874,76 @@ _read_tagset ( } h5_err_t -_h5t_read_tag_container ( +h5tpriv_read_tag_container ( h5_file_t * const f, - h5t_tagcontainer_t *container + h5t_tagcontainer_t *ctn ) { size_t num_sets; - TRY ( ( num_sets = _hdf_get_num_objs_in_group ( - f, container->group_id ) ) ); + TRY ( ( num_sets = h5priv_get_num_objs_in_hdf5_group ( + f, ctn->group_id ) ) ); hsize_t idx; for ( idx = 0; idx < num_sets; idx++ ) { - TRY ( _read_tagset ( f, container->group_id, idx ) ); + TRY ( _read_tagset ( f, ctn->group_id, idx ) ); } return H5_SUCCESS; } +/* + Get m-tagset of given entity. Return the number of tagsets as result + of the function and the names in the pointer array \c name. To query the + number of tagsets, use \c NULL as value of \c name. If the actual number + of tagset is greater than \c dim, the first \c dim names found will be + returned. + + \remark + This functions performs with O(n) where n is the number of tagsets. + + \param[in] f file handle + \param[in] entity_id ID of entity we want to know the set tags + \param[out] names Array of ptr to tagset names + \param[in] dim dimension of array + + \return number of tagsets + */ +h5_ssize_t +h5tpriv_get_tagset_names_of_entity ( + h5_file_t * const f, + h5t_tagcontainer_t *ctn, + h5_id_t entity_id, + char *names[], + h5_size_t dim + ) { + size_t idx; + size_t _dim = 0; + for (idx = 0; idx < ctn->num_sets; idx++) { + void *__retval; + TRY (h5priv_hsearch (f, + &ctn->names[idx], + H5_FIND, + &__retval, + &ctn->sets)); + H5T_Tagset *tset = (H5T_Tagset*)__retval; + h5t_tagval_t *tval; + if (_get_tag_valp (f, tset, entity_id, &tval) != H5_SUCCESS) { + continue; + } + if ( (names != NULL) && (_dim <= dim) ) { + names[_dim] = ctn->names[idx]; + } + _dim++; + } + return _dim;; +} + +h5_ssize_t +h5t_get_mtagset_names_of_entity ( + h5_file_t * const f, + h5_id_t entity_id, + char *names[], + h5_size_t dim + ) { + return h5tpriv_get_tagset_names_of_entity ( + f, &f->t->mtags, entity_id, names, dim); +} diff --git a/src/h5_core/h5t_tags.h b/src/h5_core/h5t_tags.h index 6e7ae39..8170325 100644 --- a/src/h5_core/h5t_tags.h +++ b/src/h5_core/h5t_tags.h @@ -1,19 +1,25 @@ #ifndef __H5T_TAGS_H #define __H5T_TAGS_H -h5_err_t h5t_add_mtagset ( h5_file_t *const f, char name[], h5_id_t id ); -h5_err_t h5t_remove_mtagset ( h5_file_t *const f, char name[] ); -h5_size_t h5t_get_num_mtagsets ( h5_file_t *const f ); -h5_size_t h5t_get_mtagsets ( h5_file_t *const f, char **names[] ); -h5_err_t h5t_get_mtagset_info ( h5_file_t *const f, const h5_id_t idx, - char **names, h5_id_t *type ); -h5_id_t h5t_get_mtagset_type_by_name ( h5_file_t *const f, char name[] ); +typedef struct h5t_tagset H5T_Tagset; -h5_err_t h5t_set_mtag_by_name ( h5_file_t *const f, char name[], const h5_id_t id, - const size_t dims, void *value ); -h5_err_t h5t_get_mtag_by_name ( h5_file_t *const f, const char name[], - const h5_id_t id, size_t *dims, void *value ); -h5_err_t h5t_remove_mtag_by_name ( h5_file_t *const f, const char name[], +h5_err_t h5t_add_mtagset ( h5_file_t* const f, char name[], h5_id_t id ); +h5_err_t h5t_remove_mtagset ( h5_file_t* const f, const char name[] ); +h5_err_t h5t_open_mtagset ( h5_file_t* const f, const char *name, + H5T_Tagset** retval ); +h5_size_t h5t_get_num_mtagsets ( h5_file_t* const f ); +h5_size_t h5t_get_mtagsets ( h5_file_t* const f, char** names[] ); +h5_err_t h5t_get_mtagset_info ( h5_file_t* const f, const h5_id_t idx, + char** names, h5_id_t* type ); +h5_id_t h5t_get_mtagset_type_by_name ( h5_file_t* const f, char name[] ); + +h5_err_t h5t_set_mtag_by_name ( h5_file_t* const f, char name[], const h5_id_t id, + const size_t dim, void* value ); + +h5_err_t h5t_get_mtag_by_name ( h5_file_t* const f, const char name[], + const h5_id_t id, size_t* dim, void* vals ); + +h5_err_t h5t_remove_mtag_by_name ( h5_file_t* const f, const char name[], const h5_id_t id ); #endif diff --git a/src/h5_core/h5t_tags_private.h b/src/h5_core/h5t_tags_private.h index c813550..4f03b13 100644 --- a/src/h5_core/h5t_tags_private.h +++ b/src/h5_core/h5t_tags_private.h @@ -5,13 +5,16 @@ * Tags can be assigned to all entities of a mesh * Tag values are arrays of int64 or float64 * Complex numbers can be stored as array of float64 with even dimension - * Tags are addressed via a name and the entity. + * Tags are addressed via a name and the entity id. * Tags with the same name are called a "tagset" * Tagsets can be used to store time/step-constant data. These tagsets are called "m-tagsets" and are assigned directly to a mesh. * Tagsets can be used to store data which may change from step to step. These tagsets are called "s-tagsets" and are assigned to a mesh and a (time-)step. + +ToDo + * Scalar values */ @@ -29,7 +32,8 @@ Structure to store a tag value */ typedef struct { - size_t size; + int32_t subent_id; /* sub-entitiy id */ + int32_t size; union { h5_float64_t f; h5_int64_t i; @@ -48,19 +52,19 @@ typedef struct { If idx[k] is equal -1, no tag has been assigned to the appropriate entity. */ typedef struct { - signed char size; /* size of valp */ signed char idx[15]; + signed char size; /* size of valp */ h5t_tagval_t *valp[1]; } h5t_tagsel_t; -typedef struct h5t_tagset { +struct h5t_tagset { char * name; unsigned int changed; /* flag tagset changed, ... */ unsigned int num_elems; h5_id_t type; /* int64 or float64 */ h5t_tagsel_t *elems[1]; -} h5t_tagset_t; +}; /* Structure for hash table of tagsets @@ -79,8 +83,8 @@ typedef struct { h5_id_t idx; } h5t_tag_idx_t; -h5_err_t _h5t_write_mtags ( h5_file_t *const f ); -h5_err_t _h5t_release_tags ( h5_file_t * const f ); -h5_err_t _h5t_read_tag_container ( h5_file_t * const f, +h5_err_t h5tpriv_write_mtags ( h5_file_t *const f ); +h5_err_t h5tpriv_release_tags ( h5_file_t * const f ); +h5_err_t h5tpriv_read_tag_container ( h5_file_t * const f, h5t_tagcontainer_t *container ); #endif diff --git a/src/h5_core/h5t_types_private.h b/src/h5_core/h5t_types_private.h index 5a5ec04..d226334 100644 --- a/src/h5_core/h5t_types_private.h +++ b/src/h5_core/h5t_types_private.h @@ -1,11 +1,40 @@ #ifndef __H5T_TYPES_PRIVATE_H #define __H5T_TYPES_PRIVATE_H +struct h5t_adjacency_methods { + h5_err_t (*rebuild_internal_structs)(h5_file_t * const); + h5_err_t (*release_internal_structs)(h5_file_t * const); + h5_err_t (*get_edges_upadjacent_to_vertex)( + h5_file_t * const, const h5_id_t, h5_idlist_t**); + h5_err_t (*get_triangles_upadjacent_to_vertex)( + h5_file_t * const, const h5_id_t, h5_idlist_t**); + h5_err_t (*get_tets_upadjacent_to_vertex)( + h5_file_t * const, const h5_id_t, h5_idlist_t**); + h5_err_t (*get_triangles_upadjacent_to_edge)( + h5_file_t * const, const h5_id_t, h5_idlist_t**); + h5_err_t (*get_tets_upadjacent_to_edge)( + h5_file_t * const, const h5_id_t, h5_idlist_t**); + h5_err_t (*get_tets_upadjacent_to_triangle)( + h5_file_t * const, const h5_id_t, h5_idlist_t**); + h5_err_t (*get_vertices_downadjacent_to_edge)( + h5_file_t * const, const h5_id_t, h5_idlist_t**); + h5_err_t (*get_vertices_downadjacent_to_triangle)( + h5_file_t * const, const h5_id_t, h5_idlist_t**); + h5_err_t (*get_vertices_downadjacent_to_tet)( + h5_file_t * const, const h5_id_t, h5_idlist_t**); + h5_err_t (*get_edges_downadjacent_to_triangle)( + h5_file_t * const, const h5_id_t, h5_idlist_t**); + h5_err_t (*get_edges_downadjacent_to_tet)( + h5_file_t * const, const h5_id_t, h5_idlist_t**); + h5_err_t (*get_triangles_downadjacent_to_tet)( + h5_file_t * const, const h5_id_t, h5_idlist_t**); +}; struct h5t_methods { h5_err_t (*_alloc_elems)(h5_file_t * const, const size_t, const size_t); h5_id_t (*_store_elem)(h5_file_t * const, const h5_id_t, const h5_id_t*); h5_id_t (*_refine_elem)(h5_file_t * const, const h5_id_t); + struct h5t_adjacency_methods *adjacency; }; typedef struct h5_vertex { diff --git a/src/h5_core/h5u_readwrite.c b/src/h5_core/h5u_readwrite.c index 22305d1..d675502 100644 --- a/src/h5_core/h5u_readwrite.c +++ b/src/h5_core/h5u_readwrite.c @@ -24,7 +24,7 @@ _get_diskshape_for_reading ( struct h5u_fdata *u = f->u; hid_t space; - TRY( space = _hdf_get_dataset_space ( f, dataset ) ); + TRY( space = h5priv_get_hdf5_dataset_space ( f, dataset ) ); if ( h5u_has_view ( f ) ) { hsize_t stride; @@ -42,14 +42,14 @@ _get_diskshape_for_reading ( /* now we select a subset */ if ( u->diskshape > 0 ) { - TRY ( _hdf_select_hyperslab_of_dataspace ( + TRY ( h5priv_select_hyperslab_of_hdf5_dataspace ( f, u->diskshape, H5S_SELECT_SET, &start, &stride, &count, NULL ) ); } - TRY ( _hdf_select_hyperslab_of_dataspace ( + TRY ( h5priv_select_hyperslab_of_hdf5_dataspace ( f, space, H5S_SELECT_SET, @@ -76,7 +76,7 @@ _get_memshape_for_reading ( if ( h5u_has_view ( f ) ) { hsize_t dmax=H5S_UNLIMITED; hsize_t len = u->viewend - u->viewstart; - return _hdf_create_dataspace ( f, 1, &len, &dmax ); + return h5priv_create_hdf5_dataspace ( f, 1, &len, &dmax ); } else { return H5S_ALL; } @@ -104,19 +104,19 @@ h5u_get_num_elems ( H5G_DATASET, 0, dataset_name, sizeof (dataset_name) ) ); - TRY( dataset_id = _hdf_open_dataset ( f, f->step_gid, dataset_name ) ); + TRY( dataset_id = h5priv_open_hdf5_dataset ( f, f->step_gid, dataset_name ) ); TRY( space_id = _get_diskshape_for_reading ( f, dataset_id ) ); if ( h5u_has_view ( f ) ) { - TRY ( nparticles = _hdf_get_selected_npoints_of_dataspace ( + TRY ( nparticles = h5priv_get_selected_npoints_of_hdf5_dataspace ( f, space_id ) ); } else { - TRY ( nparticles = _hdf_get_npoints_of_dataspace ( + TRY ( nparticles = h5priv_get_npoints_of_hdf5_dataspace ( f, space_id ) ); } - TRY( _hdf_close_dataspace( f, space_id ) ); - TRY( _hdf_close_dataset( f, dataset_id ) ); + TRY( h5priv_close_hdf5_dataspace( f, space_id ) ); + TRY( h5priv_close_hdf5_dataset( f, dataset_id ) ); return (h5_int64_t) nparticles; } @@ -136,10 +136,10 @@ h5u_read_elems ( if ( f->step_gid < 0 ) { TRY( h5_set_step ( f, f->step_idx ) ); } - TRY( (dataset_id = _hdf_open_dataset ( f, f->step_gid, name ) ) ); + TRY( (dataset_id = h5priv_open_hdf5_dataset ( f, f->step_gid, name ) ) ); TRY( (space_id = _get_diskshape_for_reading ( f, dataset_id ) ) ); TRY( (memspace_id = _get_memshape_for_reading ( f, dataset_id ) ) ); - TRY( _hdf_read_dataset ( + TRY( h5priv_read_hdf5_dataset ( f, dataset_id, type, @@ -147,9 +147,9 @@ h5u_read_elems ( space_id, f->xfer_prop, array ) ); - TRY( _hdf_close_dataspace( f, space_id ) ); - TRY( _hdf_close_dataspace( f, memspace_id ) ); - TRY( _hdf_close_dataset ( f, dataset_id ) ); + TRY( h5priv_close_hdf5_dataspace( f, space_id ) ); + TRY( h5priv_close_hdf5_dataspace( f, memspace_id ) ); + TRY( h5priv_close_hdf5_dataset ( f, dataset_id ) ); return H5_SUCCESS; } @@ -173,15 +173,15 @@ h5u_set_num_elements ( return H5_SUCCESS; } #endif - TRY( _hdf_close_dataspace( f, u->diskshape ) ); - TRY( _hdf_close_dataspace( f, u->memshape ) ); - TRY( _hdf_close_dataspace( f, u->shape ) ); + TRY( h5priv_close_hdf5_dataspace( f, u->diskshape ) ); + TRY( h5priv_close_hdf5_dataspace( f, u->memshape ) ); + TRY( h5priv_close_hdf5_dataspace( f, u->shape ) ); u->diskshape = H5S_ALL; u->memshape = H5S_ALL; u->shape = H5S_ALL; u->nparticles =(hsize_t) nparticles; #ifndef PARALLEL_IO - TRY( u->shape = _hdf_create_dataspace ( + TRY( u->shape = h5priv_create_hdf5_dataspace ( f, 1, &(u->nparticles), @@ -210,7 +210,7 @@ h5u_set_num_elements ( acquire the number of particles to be written from each MPI process */ - TRY ( _h5_mpi_allgather ( + TRY ( h5priv_mpi_allgather ( f, &nparticles, 1, MPI_LONG_LONG, f->u->pnparticles, 1, MPI_LONG_LONG, @@ -239,17 +239,17 @@ h5u_set_num_elements ( } /* declare overall datasize */ - TRY ( f->u->shape = _hdf_create_dataspace ( f, 1, &total, &total ) ); + TRY ( f->u->shape = h5priv_create_hdf5_dataspace ( f, 1, &total, &total ) ); /* declare overall data size but then will select a subset */ - TRY ( f->u->diskshape = _hdf_create_dataspace ( f, 1, &total, &total) ); + TRY ( f->u->diskshape = h5priv_create_hdf5_dataspace ( f, 1, &total, &total) ); /* declare local memory datasize */ - TRY ( f->u->memshape = _hdf_create_dataspace ( + TRY ( f->u->memshape = h5priv_create_hdf5_dataspace ( f, 1, &(f->u->nparticles), &dmax ) ); count[0] = nparticles; - TRY ( _hdf_select_hyperslab_of_dataspace ( + TRY ( h5priv_select_hyperslab_of_hdf5_dataspace ( f, f->u->diskshape, H5S_SELECT_SET, @@ -295,11 +295,11 @@ h5u_reset_view ( u->viewstart = -1; u->viewend = -1; - TRY( _hdf_close_dataspace( f, u->shape ) ); + TRY( h5priv_close_hdf5_dataspace( f, u->shape ) ); u->shape = H5S_ALL; - TRY( _hdf_close_dataspace( f, u->diskshape ) ); + TRY( h5priv_close_hdf5_dataspace( f, u->diskshape ) ); u->diskshape = H5S_ALL; - TRY( _hdf_close_dataspace( f, u->memshape ) ); + TRY( h5priv_close_hdf5_dataspace( f, u->memshape ) ); u->memshape = H5S_ALL; return H5_SUCCESS; @@ -358,16 +358,16 @@ h5u_set_view ( u->nparticles = end - start + 1; /* declare overall datasize */ - TRY ( u->shape = _hdf_create_dataspace ( f, 1, &total, &total ) ); + TRY ( u->shape = h5priv_create_hdf5_dataspace ( f, 1, &total, &total ) ); /* declare overall data size but then will select a subset */ - TRY ( u->diskshape= _hdf_create_dataspace ( f, 1, &total, &total ) ); + TRY ( u->diskshape= h5priv_create_hdf5_dataspace ( f, 1, &total, &total ) ); /* declare local memory datasize */ - TRY ( u->memshape = _hdf_create_dataspace ( + TRY ( u->memshape = h5priv_create_hdf5_dataspace ( f, 1, &(u->nparticles), &dmax ) ); - TRY ( _hdf_select_hyperslab_of_dataspace ( + TRY ( h5priv_select_hyperslab_of_hdf5_dataspace ( f, u->diskshape, H5S_SELECT_SET,