From c47c0cfc6eaedaddb65fc5ff55cc0b35ed565b95 Mon Sep 17 00:00:00 2001 From: Achim Gsell Date: Fri, 20 Aug 2010 15:54:01 +0000 Subject: [PATCH] - neighbor information management added to elements - prefix 'global' removed form global element struct - global and local element data now have the same struct - and several other changes --- .gitattributes | 1 + src/h5core/Makefile.am | 7 + src/h5core/h5_errorhandling.c | 10 +- src/h5core/h5_fcmp.c | 1 + src/h5core/h5_hdf5.c | 10 +- src/h5core/h5_hsearch.c | 6 +- src/h5core/h5_maps.c | 9 +- src/h5core/h5_openclose.c | 27 ++- src/h5core/h5_qsort.c | 13 +- src/h5core/h5_readwrite.c | 29 ---- src/h5core/h5_syscall.c | 2 + src/h5core/h5b_model.c | 92 +++++----- src/h5core/h5b_readwrite.c | 15 +- src/h5core/h5t_adjacencies.c | 118 +------------ src/h5core/h5t_adjacencies_private.h | 31 ++++ src/h5core/h5t_adjacencies_tetm.c | 232 ++++++++++++++++++-------- src/h5core/h5t_adjacencies_trim.c | 145 ++++++++++++---- src/h5core/h5t_core_private.h | 19 ++- src/h5core/h5t_errorhandling.c | 2 +- src/h5core/h5t_hsearch.c | 12 +- src/h5core/h5t_inquiry.c | 21 ++- src/h5core/h5t_map.c | 40 +++-- src/h5core/h5t_map_private.h | 2 +- src/h5core/h5t_openclose.c | 49 +++--- src/h5core/h5t_openclose_private.h | 4 +- src/h5core/h5t_readwrite.c | 34 ++-- src/h5core/h5t_readwrite_private.h | 7 + src/h5core/h5t_readwrite_tetm.c | 4 +- src/h5core/h5t_readwrite_trim.c | 4 +- src/h5core/h5t_ref_elements_private.h | 11 ++ src/h5core/h5t_retrieve.c | 7 +- src/h5core/h5t_retrieve_private.h | 9 + src/h5core/h5t_retrieve_trim.c | 2 +- src/h5core/h5t_store.c | 98 ++++++----- src/h5core/h5t_store_private.h | 28 ++++ src/h5core/h5t_store_tetm.c | 132 +++++++++++---- src/h5core/h5t_store_trim.c | 199 ++++++++++++---------- src/h5core/h5t_tags.c | 62 +++---- src/h5core/h5t_types_private.h | 30 +--- src/h5core/h5u_model.c | 7 +- src/h5core/h5u_readwrite.c | 21 +-- src/include/H5.h | 4 +- src/include/H5Block.h | 98 +++++------ src/include/H5Fed_adjacency.h | 86 +--------- src/include/H5Fed_retrieve.h | 4 +- src/include/h5core/h5_readwrite.h | 11 -- src/include/h5core/h5_types.h | 7 +- src/include/h5core/h5b_model.h | 76 +++++---- src/include/h5core/h5t_adjacencies.h | 82 +-------- src/include/h5core/h5t_map.h | 2 +- src/include/h5core/h5t_openclose.h | 2 + src/include/h5core/h5t_retrieve.h | 2 +- src/include/h5core/h5t_storemesh.h | 26 ++- src/include/h5core/h5t_tags.h | 34 +++- 54 files changed, 1077 insertions(+), 909 deletions(-) create mode 100644 src/h5core/h5t_ref_elements_private.h diff --git a/.gitattributes b/.gitattributes index 34dd871..9095633 100644 --- a/.gitattributes +++ b/.gitattributes @@ -448,6 +448,7 @@ src/h5core/h5t_readwrite_private.h -text src/h5core/h5t_readwrite_tetm.c -text src/h5core/h5t_readwrite_trim.c -text src/h5core/h5t_ref_elements.c -text +src/h5core/h5t_ref_elements_private.h -text src/h5core/h5t_retrieve.c -text src/h5core/h5t_retrieve_private.h -text src/h5core/h5t_retrieve_tetm.c -text diff --git a/src/h5core/Makefile.am b/src/h5core/Makefile.am index a425dbf..da8fff8 100644 --- a/src/h5core/Makefile.am +++ b/src/h5core/Makefile.am @@ -49,9 +49,11 @@ EXTRA_HEADERS = \ h5t_core_private.h \ h5t_errorhandling_private.h \ h5t_hsearch_private.h \ + h5t_inquiry_private.h \ h5t_map_private.h \ h5t_openclose_private.h \ h5t_readwrite_private.h \ + h5t_ref_elements_private.h \ h5t_retrieve_private.h \ h5t_store_private.h \ h5t_store_trim_private.h \ @@ -115,6 +117,11 @@ libH5hut_a_SOURCES = \ libH5hut_a_DEPENDENCIES = $(EXTRA_HEADERS) +all: all-am install-libs-local + +install-libs-local: + -cp ${lib_LIBRARIES} ../lib + install-exec-local: @$(INSTALL) -d $(DESTDIR)$(includedir)/h5core @$(INSTALL) -m644 ../include/h5core/*.h $(DESTDIR)$(includedir)/h5core/ diff --git a/src/h5core/h5_errorhandling.c b/src/h5core/h5_errorhandling.c index 43d828d..bab11aa 100644 --- a/src/h5core/h5_errorhandling.c +++ b/src/h5core/h5_errorhandling.c @@ -157,6 +157,7 @@ h5_abort_errorhandler ( #else exit (-(int)f->__errno); #endif + return -(int)f->__errno; // never executed, just to supress a warning } static void @@ -167,10 +168,11 @@ _vprintf ( const char* fmt, va_list ap ) { - char *fmt2 = (char*)malloc( - strlen (prefix) + - strlen (fmt) + - strlen (__funcname) + 16); + size_t size = strlen (prefix); // to avoid remark #981 with Intel CC + size += strlen (fmt); + size += strlen (__funcname) + 16; + + char *fmt2 = (char*)malloc (size); if (fmt2 == NULL) return; sprintf (fmt2, "%s: %s: %s\n", prefix, __funcname, fmt); vfprintf (f, fmt2, ap); diff --git a/src/h5core/h5_fcmp.c b/src/h5core/h5_fcmp.c index 28ede2a..49210f1 100644 --- a/src/h5core/h5_fcmp.c +++ b/src/h5core/h5_fcmp.c @@ -3,6 +3,7 @@ #include #include "h5core/h5_core.h" +#include "h5_core_private.h" /*! Compare two floating point numbers using integers. See diff --git a/src/h5core/h5_hdf5.c b/src/h5core/h5_hdf5.c index 0b9f6c9..5ae0059 100644 --- a/src/h5core/h5_hdf5.c +++ b/src/h5core/h5_hdf5.c @@ -602,6 +602,7 @@ h5priv_get_base_type_name ( if (base_type_id == H5_FLOAT64_T) return "H5_FLOAT64_T"; if (base_type_id == H5_STRING_T) return "H5_STRING_T"; + h5_warn (f, "Unknown base type id %lu", (unsigned long)base_type_id); return "[unknown]"; } @@ -610,6 +611,7 @@ get_class_type_name ( h5_file_t* const f, hid_t base_type_id ) { +#pragma unused f if (base_type_id == H5_COMPOUND_T) return "H5_COMPOUND_T"; return "[unknown]"; @@ -1227,7 +1229,7 @@ _iter_op_get_obj_type ( herr = H5Lget_val(g_id, name, buf, info->u.val_size, H5P_DEFAULT); if ( herr < 0 ) - return h5_error(f, + return (H5O_type_t)h5_error (f, H5_ERR_HDF5, "Can't get external link for object '%s'!", name); @@ -1237,7 +1239,7 @@ _iter_op_get_obj_type ( herr = H5Lunpack_elink_val(buf, info->u.val_size, 0, &filename, &objname); if ( herr < 0 ) - return h5_error(f, + return (H5O_type_t)h5_error(f, H5_ERR_HDF5, "Can't unpack external link for object '%s'!", name); @@ -1250,7 +1252,7 @@ _iter_op_get_obj_type ( hid_t obj_id = H5Oopen(g_id, name, H5P_DEFAULT); if ( obj_id < 0 ) - return h5_error(f, + return (H5O_type_t)h5_error(f, H5_ERR_HDF5, "Can't open external link for object '%s'!", name); @@ -1261,7 +1263,7 @@ _iter_op_get_obj_type ( } if ( herr < 0 ) - return h5_error(f, + return (H5O_type_t)h5_error(f, H5_ERR_HDF5, "Can't query object with name '%s'!", name); diff --git a/src/h5core/h5_hsearch.c b/src/h5core/h5_hsearch.c index 16e00bd..365af29 100644 --- a/src/h5core/h5_hsearch.c +++ b/src/h5core/h5_hsearch.c @@ -69,7 +69,7 @@ h5priv_hcreate ( ) { /* Test for correct arguments. */ if (htab == NULL || htab->table != NULL) { - h5_error_internal (f, __FILE__, __func__, __LINE__); + return h5_error_internal (f, __FILE__, __func__, __LINE__); } /* Change nel to the first prime number not smaller as nel. */ nel |= 1; /* make odd */ @@ -99,7 +99,7 @@ h5priv_hresize ( h5_hashtable_t* htab // hash table to resize ) { if (htab == NULL || htab->table == NULL) { - h5_error_internal (f, __FILE__, __func__, __LINE__); + return h5_error_internal (f, __FILE__, __func__, __LINE__); } // create new hash table h5_hashtable_t __htab; @@ -138,7 +138,7 @@ h5priv_hdestroy ( ) { /* Test for correct arguments. */ if (htab == NULL) { - h5_error_internal (f, __FILE__, __func__, __LINE__); + return h5_error_internal (f, __FILE__, __func__, __LINE__); } /* Free used memory. */ diff --git a/src/h5core/h5_maps.c b/src/h5core/h5_maps.c index 72bce53..97d8b0d 100644 --- a/src/h5core/h5_maps.c +++ b/src/h5core/h5_maps.c @@ -23,6 +23,7 @@ h5priv_free_idlist_items ( h5_file_t* const f, h5_idlist_t* list ) { +#pragma unused f if (list->items != NULL) free (list->items); list->items = NULL; list->size = 0; @@ -106,6 +107,7 @@ h5priv_sort_idlist_by_eid ( h5_file_t* const f, h5_idlist_t* list ) { +#pragma unused f qsort ( list->items, list->num_items, @@ -124,6 +126,7 @@ h5priv_find_idlist ( h5_idlist_t* list, h5_id_t item ) { +#pragma unused f register h5_id_t low = 0; register h5_id_t high = list->num_items - 1; while (low <= high) { @@ -256,8 +259,8 @@ h5priv_search_idmap ( return -(low+1); // not found } -int -_cmp_idmap_items ( +static int +cmp_idmap_items ( const void* _item1, const void* _item2 ) { @@ -275,6 +278,6 @@ h5priv_sort_idmap ( h5_idmap_t* map ) { qsort ( map->items, map->num_items, sizeof (map->items[0]), - _cmp_idmap_items); + cmp_idmap_items); return H5_SUCCESS; } diff --git a/src/h5core/h5_openclose.c b/src/h5core/h5_openclose.c index 2a08519..d48f0ae 100644 --- a/src/h5core/h5_openclose.c +++ b/src/h5core/h5_openclose.c @@ -45,6 +45,7 @@ h5priv_error_handler ( hid_t estack_id, void* __f ) { +#pragma unused __f if (h5_get_debuglevel() >= 5) { H5Eprint (estack_id, stderr); } @@ -58,6 +59,8 @@ h5priv_error_handler ( Initialize unstructured data internal data structure. + TODO: Move to file "h5u_openclose.c" + \return H5_SUCCESS or error code */ static h5_err_t @@ -86,6 +89,8 @@ h5upriv_open_file ( Initialize H5Block internal structure. + TODO: Move to file "h5b_openclose.c" + \return H5_SUCCESS or error code */ static h5_err_t @@ -101,10 +106,11 @@ h5bpriv_open_file ( b = f->b; memset (b, 0, sizeof (*b)); +#if defined(PARALLEL_IO) size_t n = sizeof (struct h5b_partition) / sizeof (h5_int64_t); TRY( h5priv_mpi_type_contiguous(f, n, MPI_LONG_LONG, &b->partition_mpi_t) ); - +#endif memset (b->user_layout, 0, sizeof(*b->user_layout)); memset (b->write_layout, 0, sizeof(*b->write_layout)); @@ -130,13 +136,18 @@ h5bpriv_open_file ( \return NULL on error. */ -h5_err_t -h5priv_open_file ( +static h5_err_t +open_file ( h5_file_t* const f, const char* filename, /*!< The name of the data file to open. */ - char flags, /*!< The access mode for the file. */ + h5_int32_t flags, /*!< The access mode for the file. */ MPI_Comm comm /*!< MPI communicator */ ) { + +#if !defined(PARALLEL_IO) +#pragma unused comm +#endif + h5_info (f, "Opening file %s.", filename); TRY( h5priv_set_hdf5_errorhandler (f, H5E_DEFAULT, h5priv_error_handler, NULL) ); @@ -255,7 +266,7 @@ h5_open_file ( } memset (f, 0, sizeof (h5_file_t)); f->__funcname = funcname; - if (h5priv_open_file (f, filename, flags, comm) < 0) { + if (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 @@ -318,7 +329,9 @@ h5bpriv_close_file ( TRY( h5priv_close_hdf5_dataspace (f, b->diskshape) ); TRY( h5priv_close_hdf5_dataspace (f, b->memshape) ); TRY( h5priv_close_hdf5_property (f, b->dcreate_prop) ); +#if defined(PARALLEL_IO) TRY( h5priv_mpi_type_free (f, &b->partition_mpi_t) ); +#endif free (f->b); f->b = NULL; @@ -401,6 +414,10 @@ h5_get_stepname_fmt ( int l_name, /*!< length of buffer name */ int* width /*!< OUT: Width of the number */ ) { +#pragma unused f +#pragma unused name +#pragma unused l_name +#pragma unused width return h5_error_not_implemented (f, __FILE__, __func__, __LINE__); } diff --git a/src/h5core/h5_qsort.c b/src/h5core/h5_qsort.c index e67cb39..ee34ded 100644 --- a/src/h5core/h5_qsort.c +++ b/src/h5core/h5_qsort.c @@ -38,6 +38,8 @@ static char sccsid[] = "@(#)qsort.c 8.1 (Berkeley) 6/4/93"; #include +#include "h5_qsort_private.h" + #ifdef I_AM_QSORT_R typedef int cmp_t(void *, const void *, const void *); #else @@ -53,10 +55,10 @@ static inline void swapfunc(char *, char *, int, int); */ #define swapcode(TYPE, parmi, parmj, n) { \ long i = (n) / sizeof (TYPE); \ - TYPE *pi = (TYPE *) (parmi); \ - TYPE *pj = (TYPE *) (parmj); \ + TYPE *pi = (TYPE *) (parmi); \ + TYPE *pj = (TYPE *) (parmj); \ do { \ - TYPE t = *pi; \ + TYPE t = *pi; \ *pi++ = *pj; \ *pj++ = t; \ } while (--i > 0); \ @@ -66,10 +68,7 @@ static inline void swapfunc(char *, char *, int, int); es % sizeof(long) ? 2 : es == sizeof(long)? 0 : 1; static inline void -swapfunc(a, b, n, swaptype) - char *a, *b; - int n, swaptype; -{ +swapfunc(char* a, char* b, int n, int swaptype) { if(swaptype <= 1) swapcode(long, a, b, n) else diff --git a/src/h5core/h5_readwrite.c b/src/h5core/h5_readwrite.c index f13f8b3..6944d2a 100644 --- a/src/h5core/h5_readwrite.c +++ b/src/h5core/h5_readwrite.c @@ -3,35 +3,6 @@ #include "h5core/h5_core.h" #include "h5_core_private.h" -/* - Obsolete function - still in old H5Part code ! -*/ - -h5_err_t -h5_write_data ( - h5_file_t* const f, /*!< IN: Handle to open file */ - const char* name, /*!< IN: Name to associate array with */ - const void* array, /*!< IN: Array to commit to disk */ - const hid_t type_id, /*!< IN: Type of data */ - const hid_t group_id, - const hid_t memspace_id, - const hid_t diskspace_id - ) { - hid_t dset_id; - - h5_info (f, "Writing dataset %s/%s.", h5_get_objname(group_id), name); - TRY( dset_id = h5priv_create_hdf5_dataset ( - f, - group_id, - name, - type_id, - diskspace_id, - H5P_DEFAULT) ); - - f->empty = 0; - - return H5_SUCCESS; -} /*! Write data to dataset. diff --git a/src/h5core/h5_syscall.c b/src/h5core/h5_syscall.c index 09a5be9..99e5561 100644 --- a/src/h5core/h5_syscall.c +++ b/src/h5core/h5_syscall.c @@ -39,6 +39,7 @@ h5priv_free ( h5_file_t* const f, void* ptr ) { +#pragma unused f if (ptr) free (ptr); return H5_SUCCESS; } @@ -65,6 +66,7 @@ h5priv_tfind ( void* const* rootp, int (*compar) (const void* key1, const void* key2) ) { +#pragma unused f void* ptr = tfind (key, rootp, compar); if (ptr == NULL) { return (void*)(H5_ERR); diff --git a/src/h5core/h5b_model.c b/src/h5core/h5b_model.c index ed8cc79..8bfa91d 100644 --- a/src/h5core/h5b_model.c +++ b/src/h5core/h5b_model.c @@ -45,6 +45,7 @@ _normalize_partition ( } } +#if defined(PARALLEL) /* MLH: this could be improved with an MPI_Reduce and MAX operator... * but the user_layout array-of-structs would need to be a struct-of-arrays */ static void @@ -72,6 +73,7 @@ _get_max_dimensions ( || (p->k_end < q->k_start) ) + /*! \ingroup h5block_private @@ -81,8 +83,8 @@ _get_max_dimensions ( \return value != \c 0 if yes otherwise \c 0 */ -static int -_have_ghostzone ( +static inline int +have_ghostzone ( const h5b_partition_t *const p, /*!< IN: partition \c p */ const h5b_partition_t *const q /*!< IN: partition \c q */ ) { @@ -98,8 +100,8 @@ _have_ghostzone ( \return volume */ -static h5_int64_t -_volume_of_partition ( +static inline h5_int64_t +volume_of_partition ( const h5b_partition_t *const p /*!< IN: partition */ ) { return (p->i_end - p->i_start) @@ -117,8 +119,8 @@ _volume_of_partition ( \return volume */ -static h5_int64_t -_volume_of_ghostzone ( +static inline h5_int64_t +volume_of_ghostzone ( const h5b_partition_t *const p, /*!< IN: ptr to first partition */ const h5b_partition_t *const q /*!< IN: ptr to second partition */ ) { @@ -248,8 +250,8 @@ _dissolve_ghostzone ( p_ = *p; q_ = *q; if ( _dissolve_X_ghostzone ( &p_, &q_ ) == 0 ) { - vol = _volume_of_partition ( &p_ ) - + _volume_of_partition ( &q_ ); + vol = volume_of_partition ( &p_ ) + + volume_of_partition ( &q_ ); if ( vol > max_vol ) { max_vol = vol; p_best = p_; @@ -260,8 +262,8 @@ _dissolve_ghostzone ( p_ = *p; q_ = *q; if ( _dissolve_Y_ghostzone ( &p_, &q_ ) == 0 ) { - vol = _volume_of_partition ( &p_ ) - + _volume_of_partition ( &q_ ); + vol = volume_of_partition ( &p_ ) + + volume_of_partition ( &q_ ); if ( vol > max_vol ) { max_vol = vol; p_best = p_; @@ -272,8 +274,8 @@ _dissolve_ghostzone ( q_ = *q; if ( _dissolve_Z_ghostzone ( &p_, &q_ ) == 0 ) { - vol = _volume_of_partition ( &p_ ) - + _volume_of_partition ( &q_ ); + vol = volume_of_partition ( &p_ ) + + volume_of_partition ( &q_ ); if ( vol > max_vol ) { max_vol = vol; p_best = p_; @@ -313,7 +315,7 @@ _dissolve_ghostzone ( \return H5_SUCCESS or error code. */ -static h5_err_t +static inline h5_err_t _dissolve_ghostzones ( h5_file_t *const f, const h5b_partition_t *const user_layout, @@ -346,12 +348,12 @@ _dissolve_ghostzones ( proc_q < f->nprocs; proc_q++, q++ ) { - if ( _have_ghostzone ( p, q ) ) { + if ( have_ghostzone ( p, q ) ) { TRY( p_el = (struct list*)h5priv_alloc(f, NULL, sizeof(*p_el)) ); p_el->p = p; p_el->q = q; - p_el->vol = _volume_of_ghostzone ( p, q ); + p_el->vol = volume_of_ghostzone ( p, q ); p_el->prev = p_end; p_el->next = NULL; @@ -373,8 +375,8 @@ _dissolve_ghostzones ( p_el = p_max = p_begin->next; while ( p_el ) { - if ( _have_ghostzone ( p_el->p, p_el->q ) ) { - p_el->vol = _volume_of_ghostzone ( p_el->p, p_el->q ); + if ( have_ghostzone ( p_el->p, p_el->q ) ) { + p_el->vol = volume_of_ghostzone ( p_el->p, p_el->q ); if ( p_el->vol > p_max->vol ) p_max = p_el; p_el = p_el->next; @@ -393,6 +395,7 @@ _dissolve_ghostzones ( return H5_SUCCESS; } +#endif h5_err_t h5bpriv_release_hyperslab ( @@ -523,12 +526,12 @@ h5b_3d_has_view ( h5_err_t h5b_3d_set_view ( h5_file_t *const f, /*!< IN: File handle */ - const h5_int64_t i_start, /*!< IN: start index of \c i */ - const h5_int64_t i_end, /*!< IN: end index of \c i */ - const h5_int64_t j_start, /*!< IN: start index of \c j */ - const h5_int64_t j_end, /*!< IN: end index of \c j */ - const h5_int64_t k_start, /*!< IN: start index of \c k */ - const h5_int64_t k_end /*!< IN: end index of \c k */ + const h5_size_t i_start, /*!< IN: start index of \c i */ + const h5_size_t i_end, /*!< IN: end index of \c i */ + const h5_size_t j_start, /*!< IN: start index of \c j */ + const h5_size_t j_end, /*!< IN: end index of \c j */ + const h5_size_t k_start, /*!< IN: start index of \c k */ + const h5_size_t k_end /*!< IN: end index of \c k */ ) { h5b_partition_t *p = f->b->user_layout; @@ -589,13 +592,13 @@ h5b_3d_set_view ( h5_err_t h5b_3d_get_view ( - h5_file_t *const f, /*!< IN: File handle */ - h5_int64_t *i_start, /*!< OUT: start index of \c i */ - h5_int64_t *i_end, /*!< OUT: end index of \c i */ - h5_int64_t *j_start, /*!< OUT: start index of \c j */ - h5_int64_t *j_end, /*!< OUT: end index of \c j */ - h5_int64_t *k_start, /*!< OUT: start index of \c k */ - h5_int64_t *k_end /*!< OUT: end index of \c k */ + h5_file_t *const f, /*!< IN: File handle */ + h5_size_t *const i_start, /*!< OUT: start index of \c i */ + h5_size_t *const i_end, /*!< OUT: end index of \c i */ + h5_size_t *const j_start, /*!< OUT: start index of \c j */ + h5_size_t *const j_end, /*!< OUT: end index of \c j */ + h5_size_t *const k_start, /*!< OUT: start index of \c k */ + h5_size_t *const k_end /*!< OUT: end index of \c k */ ) { h5b_partition_t *p = f->b->user_layout; @@ -612,13 +615,13 @@ h5b_3d_get_view ( h5_err_t h5b_3d_get_reduced_view ( - h5_file_t *const f, /*!< IN: File handle */ - h5_int64_t *i_start, /*!< OUT: start index of \c i */ - h5_int64_t *i_end, /*!< OUT: end index of \c i */ - h5_int64_t *j_start, /*!< OUT: start index of \c j */ - h5_int64_t *j_end, /*!< OUT: end index of \c j */ - h5_int64_t *k_start, /*!< OUT: start index of \c k */ - h5_int64_t *k_end /*!< OUT: end index of \c k */ + h5_file_t *const f, /*!< IN: File handle */ + h5_size_t *const i_start, /*!< OUT: start index of \c i */ + h5_size_t *const i_end, /*!< OUT: end index of \c i */ + h5_size_t *const j_start, /*!< OUT: start index of \c j */ + h5_size_t *const j_end, /*!< OUT: end index of \c j */ + h5_size_t *const k_start, /*!< OUT: start index of \c k */ + h5_size_t *const k_end /*!< OUT: end index of \c k */ ) { h5b_partition_t *p = f->b->write_layout; @@ -636,9 +639,9 @@ h5b_3d_get_reduced_view ( h5_err_t h5b_3d_set_chunk ( h5_file_t *const f, /*!< IN: File handle */ - const h5_int64_t i, /*!< IN: size of \c i */ - const h5_int64_t j, /*!< IN: size of \c j */ - const h5_int64_t k /*!< IN: size of \c k */ + const h5_size_t i, /*!< IN: size of \c i */ + const h5_size_t j, /*!< IN: size of \c j */ + const h5_size_t k /*!< IN: size of \c k */ ) { if ( i == 0 || j == 0 || k == 0 ) @@ -662,9 +665,9 @@ h5_err_t h5b_3d_get_chunk ( h5_file_t *const f, /*!< IN: File handle */ const char *field_name, /*!< IN: name of dataset */ - h5_int64_t *i, /*!< OUT: size of \c i */ - h5_int64_t *j, /*!< OUT: size of \c j */ - h5_int64_t *k /*!< OUT: size of \c k */ + h5_size_t *const i, /*!< OUT: size of \c i */ + h5_size_t *const j, /*!< OUT: size of \c j */ + h5_size_t *const k /*!< OUT: size of \c k */ ) { CHECK_TIMEGROUP ( f ); @@ -696,6 +699,7 @@ h5b_3d_get_chunk ( return H5_SUCCESS; } +#if defined(PARALLEL_IO) h5_err_t h5b_3d_set_grid ( h5_file_t *const f, /*!< IN: File handle */ @@ -778,7 +782,6 @@ h5b_3d_set_dims ( (long long)dims[0], (long long)dims[1], (long long)dims[2], (long long)check_dims[0], (long long)check_dims[1], (long long)check_dims[2]); } - h5_int64_t coords[3]; TRY( h5b_3d_get_grid_coords(f, f->myproc, coords+0, coords+1, coords+2) ); @@ -802,6 +805,7 @@ h5b_3d_set_dims ( return H5_SUCCESS; } +#endif h5_err_t h5b_3d_set_halo ( diff --git a/src/h5core/h5b_readwrite.c b/src/h5core/h5b_readwrite.c index 6bbd5c0..6151819 100644 --- a/src/h5core/h5b_readwrite.c +++ b/src/h5core/h5b_readwrite.c @@ -267,10 +267,9 @@ _select_hyperslab_for_reading ( } static h5_err_t -_read_data ( +read_data ( h5_file_t *const f, /*!< IN: file handle */ - const char *field_name, /*!< IN: name of field */ - const char *data_name, /*!< IN: name of dataset */ + const char *dataset_name, /*!< IN: name of dataset */ void *data, /*!< OUT: ptr to read buffer */ const hid_t type /*!< IN: data type */ ) { @@ -278,7 +277,7 @@ _read_data ( hid_t dataset; h5b_fdata_t *b = f->b; - TRY( dataset = h5priv_open_hdf5_dataset(f, b->field_gid, data_name) ); + TRY( dataset = h5priv_open_hdf5_dataset(f, b->field_gid, dataset_name) ); TRY( _select_hyperslab_for_reading(f, dataset) ); TRY( h5priv_read_hdf5_dataset(f, dataset, @@ -302,7 +301,7 @@ h5b_read_scalar_data ( CHECK_TIMEGROUP( f ); CHECK_LAYOUT( f ); TRY( h5bpriv_open_field_group(f, field_name) ); - TRY( _read_data(f, field_name, H5_BLOCKNAME_X, data, type) ); + TRY( read_data(f, H5_BLOCKNAME_X, data, type) ); return H5_SUCCESS; } @@ -318,9 +317,9 @@ h5b_read_vector3d_data ( CHECK_TIMEGROUP( f ); CHECK_LAYOUT( f ); TRY( h5bpriv_open_field_group(f, field_name) ); - TRY( _read_data(f, field_name, H5_BLOCKNAME_X, xdata, type) ); - TRY( _read_data(f, field_name, H5_BLOCKNAME_Y, ydata, type) ); - TRY( _read_data(f, field_name, H5_BLOCKNAME_Z, zdata, type) ); + TRY( read_data(f, H5_BLOCKNAME_X, xdata, type) ); + TRY( read_data(f, H5_BLOCKNAME_Y, ydata, type) ); + TRY( read_data(f, H5_BLOCKNAME_Z, zdata, type) ); return H5_SUCCESS; } diff --git a/src/h5core/h5t_adjacencies.c b/src/h5core/h5t_adjacencies.c index 74cbbb1..385fe96 100644 --- a/src/h5core/h5t_adjacencies.c +++ b/src/h5core/h5t_adjacencies.c @@ -17,123 +17,13 @@ #include "h5_core_private.h" h5_err_t -h5t_get_edges_upadjacent_to_vertex ( +h5t_get_adjacencies ( h5_file_t* const f, - const h5_id_t local_vid, + const h5_id_t entity_id, + const h5_int32_t dim, h5_idlist_t** list ) { - 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 local_id, - h5_idlist_t** list - ) { - 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 local_id, - h5_idlist_t** list - ) { - 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 local_id, - h5_idlist_t** list - ) { - 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 local_id, - h5_idlist_t** list - ) { - 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 local_id, - h5_idlist_t** list - ) { - 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 local_id, - h5_idlist_t** list - ) { - return (*f->t->methods.adjacency->get_vertices_downadjacent_to_edge)( - f, local_id, list); -} - -h5_err_t -h5t_get_vertices_downadjacent_to_triangle ( - h5_file_t* const f, - const h5_id_t local_id, - h5_idlist_t** list - ) { - return (*f->t->methods.adjacency->get_vertices_downadjacent_to_triangle)( - f, local_id, list); -} - -h5_err_t -h5t_get_vertices_downadjacent_to_tet ( - h5_file_t* const f, - const h5_id_t local_id, - h5_idlist_t** list - ) { - 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 local_id, - h5_idlist_t** list - ) { - 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 local_id, - h5_idlist_t** list - ) { - 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 local_id, - h5_idlist_t** list - ) { - return (*f->t->methods.adjacency->get_triangles_downadjacent_to_tet)( - f, local_id, list); + return h5tpriv_get_adjacencies (f, entity_id, dim, list); } h5_err_t diff --git a/src/h5core/h5t_adjacencies_private.h b/src/h5core/h5t_adjacencies_private.h index ea9f81c..f0f325e 100644 --- a/src/h5core/h5t_adjacencies_private.h +++ b/src/h5core/h5t_adjacencies_private.h @@ -4,4 +4,35 @@ extern struct h5t_adjacency_methods h5tpriv_trim_adjacency_methods; extern struct h5t_adjacency_methods h5tpriv_tetm_adjacency_methods; +static inline h5_err_t +h5tpriv_get_adjacencies ( + h5_file_t* const f, + const h5_id_t entity_id, + const h5_int32_t dim, + h5_idlist_t** list + ) { + if (f->t->methods.adjacency == NULL) { + h5_error_internal (f, __FILE__, __func__, __LINE__); + } + return (*f->t->methods.adjacency->get_adjacencies)(f, entity_id, dim, list); +} + +static inline h5_err_t +h5tpriv_release_adjacency_structs ( + h5_file_t* const f + ) { + if (f->t->methods.adjacency == NULL) { + return 0; + } + return (*f->t->methods.adjacency->release_internal_structs)(f); +} + +static inline h5_err_t +h5tpriv_update_adjacency_structs ( + h5_file_t* const f, + const h5_id_t level_id + ) { + return (*f->t->methods.adjacency->update_internal_structs)(f, level_id); +} + #endif diff --git a/src/h5core/h5t_adjacencies_tetm.c b/src/h5core/h5t_adjacencies_tetm.c index 8fd0b0e..9d4e31c 100644 --- a/src/h5core/h5t_adjacencies_tetm.c +++ b/src/h5core/h5t_adjacencies_tetm.c @@ -19,18 +19,18 @@ /* compute T(V) from current level up to highest levels. */ -static h5_err_t +static inline h5_err_t compute_elems_of_vertices ( h5_file_t* const f, - const h5_id_t from_lvl + const h5_id_t level_idx ) { h5t_fdata_t* t = f->t; - h5_id_t idx = (from_lvl <= 0) ? 0 : t->num_elems[from_lvl-1]; + h5_id_t idx = (level_idx <= 0) ? 0 : t->num_elems[level_idx-1]; h5_tet_t *el = &t->loc_elems.tets[idx]; h5_id_t num_elems = t->num_elems[t->num_levels-1]; for (;idx < num_elems; idx++, el++) { int face_idx; - int num_faces = t->ref_elem->num_faces[0]; + int num_faces = h5tpriv_ref_elem_get_num_vertices(t); for (face_idx = 0; face_idx < num_faces; face_idx++) { h5_id_t vidx = el->vertex_indices[face_idx]; TRY( h5priv_append_to_idlist ( @@ -45,7 +45,7 @@ compute_elems_of_vertices ( /* Compute T(E) from current level up to highest levels. */ -static h5_err_t +static inline h5_err_t compute_elems_of_edges ( h5_file_t* const f, const h5_id_t from_lvl @@ -57,7 +57,7 @@ compute_elems_of_edges ( TRY( h5tpriv_resize_te_htab (f, 4*(num_elems-elem_idx)) ); for (;elem_idx < num_elems; elem_idx++) { int face_idx; - int num_faces = t->ref_elem->num_faces[1]; + int num_faces = h5tpriv_ref_elem_get_num_edges(t); for (face_idx = 0; face_idx < num_faces; face_idx++) { TRY( h5tpriv_search_te2 ( f, face_idx, elem_idx, &retval) ); @@ -66,7 +66,7 @@ compute_elems_of_edges ( return H5_SUCCESS; } -static h5_err_t +static inline h5_err_t compute_elems_of_triangles ( h5_file_t* const f, const h5_id_t from_lvl @@ -75,10 +75,10 @@ compute_elems_of_triangles ( h5_id_t elem_idx = (from_lvl <= 0) ? 0 : t->num_elems[from_lvl-1]; h5_id_t num_elems = t->num_elems[t->num_levels-1]; h5_idlist_t *retval = NULL; - TRY( h5tpriv_resize_te_htab (f, 4*(num_elems-elem_idx)) ); + TRY( h5tpriv_resize_td_htab (f, 4*(num_elems-elem_idx)) ); for (;elem_idx < num_elems; elem_idx++) { int face_idx; - int num_faces = t->ref_elem->num_faces[1]; + int num_faces = h5tpriv_ref_elem_get_num_edges (t); for (face_idx = 0; face_idx < num_faces; face_idx++) { TRY( h5tpriv_search_td2 ( f, face_idx, elem_idx, &retval) ); @@ -87,7 +87,7 @@ compute_elems_of_triangles ( return H5_SUCCESS; } -static h5_err_t +static inline h5_err_t compute_children_of_edge ( h5_file_t* const f, h5_id_t kid, @@ -112,7 +112,7 @@ compute_children_of_edge ( TRY( h5priv_append_to_idlist (f, children, *edge) ); } else { h5_id_t kids[2]; - TRY( t->methods.store->get_direct_children_of_edge ( + TRY( h5tpriv_get_direct_children_of_edge ( f, face_idx, tet->child_idx, @@ -127,7 +127,7 @@ compute_children_of_edge ( /* Compute all sections of an edge. */ -static h5_err_t +static inline h5_err_t compute_sections_of_edge ( h5_file_t* const f, h5_id_t kid, @@ -151,7 +151,7 @@ compute_sections_of_edge ( if (! h5tpriv_elem_is_on_cur_level (f, tet) == H5_OK) { refined = 1; h5_id_t kids[2]; - TRY( t->methods.store->get_direct_children_of_edge ( + TRY( h5tpriv_get_direct_children_of_edge ( f, face_id, tet->child_idx, @@ -197,7 +197,7 @@ compute_sections_of_edge ( [4,5,7]: 0, 5 [4,6,8]: 2, 4 [5,6,9]: 1, 7 [7,8,9]: 3, 6 */ -static h5_err_t +static inline h5_err_t compute_direct_children_of_triangle ( h5_file_t* const f, h5_id_t face_idx, @@ -210,7 +210,7 @@ compute_direct_children_of_triangle ( {{2,0},{2,2},{2,3},{1,7}}, {{3,1},{3,2},{3,3},{3,6}} }; - int num_faces = f->t->ref_elem->num_faces[2]; + int num_faces = h5tpriv_ref_elem_get_num_triangles (f->t); if ((face_idx < 0) || (face_idx >= num_faces)) { return h5_error_internal (f, __FILE__, __func__, __LINE__); } @@ -225,7 +225,7 @@ compute_direct_children_of_triangle ( return H5_SUCCESS; } -static h5_err_t +static inline h5_err_t compute_children_of_triangle ( h5_file_t* const f, h5_id_t did, @@ -264,7 +264,7 @@ compute_children_of_triangle ( return H5_SUCCESS; } -static h5_err_t +static inline h5_err_t compute_sections_of_triangle ( h5_file_t* const f, h5_id_t did, @@ -307,8 +307,8 @@ compute_sections_of_triangle ( map edge ID to unique ID if unique ID not in list: add */ -static h5_err_t -_add_edge ( +static inline h5_err_t +add_edge ( h5_file_t* const f, h5_idlist_t* list, h5_id_t face_idx, @@ -321,8 +321,8 @@ _add_edge ( } -static h5_err_t -get_edges_upadjacent_to_vertex ( +static inline h5_err_t +get_edges_uadj_to_vertex ( h5_file_t* const f, const h5_id_t vid, h5_idlist_t** list @@ -343,15 +343,15 @@ get_edges_upadjacent_to_vertex ( 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) ); + 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 ( +static inline h5_err_t +add_triangle ( h5_file_t* const f, h5_idlist_t* list, h5_id_t face, @@ -364,8 +364,8 @@ _add_triangle ( return H5_SUCCESS; } -static h5_err_t -get_triangles_upadjacent_to_vertex ( +static inline h5_err_t +get_triangles_uadj_to_vertex ( h5_file_t * const f, const h5_id_t vid, h5_idlist_t **list @@ -385,15 +385,15 @@ get_triangles_upadjacent_to_vertex ( 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) ); + 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; } -static h5_err_t -get_tets_upadjacent_to_vertex ( +static inline h5_err_t +get_tets_uadj_to_vertex ( h5_file_t* const f, const h5_id_t vid, h5_idlist_t** list @@ -416,8 +416,8 @@ get_tets_upadjacent_to_vertex ( return H5_SUCCESS; } -static h5_err_t -get_triangles_upadjacent_to_edge ( +static inline h5_err_t +get_triangles_uadj_to_edge ( h5_file_t* const f, const h5_id_t kid, h5_idlist_t** list @@ -432,16 +432,16 @@ get_triangles_upadjacent_to_edge ( for (; edge < end; edge++) { h5_id_t eid = h5tpriv_get_elem_idx (*edge); h5_id_t face_idx = h5tpriv_get_face_idx (*edge); - TRY( _add_triangle (f, *list, map[face_idx][0], eid) ); - TRY( _add_triangle (f, *list, map[face_idx][1], eid) ); + TRY( add_triangle (f, *list, map[face_idx][0], eid) ); + TRY( add_triangle (f, *list, map[face_idx][1], eid) ); } TRY( h5priv_free_idlist ( f, &children) ); return H5_SUCCESS; } -static h5_err_t -get_tets_upadjacent_to_edge ( +static inline h5_err_t +get_tets_uadj_to_edge ( h5_file_t* const f, const h5_id_t kid, h5_idlist_t** list @@ -460,8 +460,8 @@ get_tets_upadjacent_to_edge ( return H5_SUCCESS; } -static h5_err_t -get_tets_upadjacent_to_triangle ( +static inline h5_err_t +get_tets_uadj_to_triangle ( h5_file_t* const f, const h5_id_t did, h5_idlist_t** list @@ -480,8 +480,8 @@ get_tets_upadjacent_to_triangle ( return H5_SUCCESS; } -static h5_err_t -get_vertices_downadjacent_to_edge ( +static inline h5_err_t +get_vertices_dadj_to_edge ( h5_file_t* const f, const h5_id_t kid, h5_idlist_t** list @@ -505,8 +505,8 @@ get_vertices_downadjacent_to_edge ( /* Compute downward adjacent vertices of all edges of triangle. */ -static h5_err_t -get_vertices_downadjacent_to_triangle ( +static inline h5_err_t +get_vertices_dadj_to_triangle ( h5_file_t* const f, const h5_id_t did, h5_idlist_t** list @@ -540,8 +540,8 @@ get_vertices_downadjacent_to_triangle ( /* Compute downward adjacent vertices of all edges of tetrahedron. */ -static h5_err_t -get_vertices_downadjacent_to_tet ( +static inline h5_err_t +get_vertices_dadj_to_tet ( h5_file_t* const f, const h5_id_t eid, h5_idlist_t** list @@ -568,8 +568,8 @@ get_vertices_downadjacent_to_tet ( return H5_SUCCESS; } -static h5_err_t -get_edges_downadjacent_to_triangle ( +static inline h5_err_t +get_edges_dadj_to_triangle ( h5_file_t* const f, const h5_id_t did, h5_idlist_t** list @@ -597,8 +597,8 @@ get_edges_downadjacent_to_triangle ( return H5_SUCCESS; } -static h5_err_t -get_edges_downadjacent_to_tet ( +static inline h5_err_t +get_edges_dadj_to_tet ( h5_file_t* const f, const h5_id_t eid, h5_idlist_t** list @@ -622,8 +622,8 @@ get_edges_downadjacent_to_tet ( return H5_SUCCESS; } -static h5_err_t -get_triangles_downadjacent_to_tet ( +static inline h5_err_t +get_triangles_dadj_to_tet ( h5_file_t* const f, const h5_id_t eid, h5_idlist_t** list @@ -647,6 +647,117 @@ get_triangles_downadjacent_to_tet ( return H5_SUCCESS; } +static inline h5_err_t +dim_error( + h5_file_t* const f, + const h5_int32_t dim + ) { + return h5_error ( + f, + H5_ERR_INVAL, + "Illegal dimension %ld", (long)dim); +} + +static inline h5_err_t +get_adjacencies_to_vertex ( + h5_file_t* const f, + const h5_id_t entity_id, + const h5_int32_t dim, + h5_idlist_t** list + ) { + switch (dim) { + case 1: + return get_edges_uadj_to_vertex(f, entity_id, list); + case 2: + return get_triangles_uadj_to_vertex(f, entity_id, list); + case 3: + return get_tets_uadj_to_vertex(f, entity_id, list); + default: + return dim_error (f, dim); + } +} + +static inline h5_err_t +get_adjacencies_to_edge ( + h5_file_t* const f, + const h5_id_t entity_id, + const h5_int32_t dim, + h5_idlist_t** list + ) { + switch (dim) { + case 0: + return get_vertices_dadj_to_edge(f, entity_id, list); + case 2: + return get_triangles_uadj_to_edge(f, entity_id, list); + case 3: + return get_tets_uadj_to_edge(f, entity_id, list); + default: + return dim_error (f, dim); + } +} + +static inline h5_err_t +get_adjacencies_to_triangle ( + h5_file_t* const f, + const h5_id_t entity_id, + const h5_int32_t dim, + h5_idlist_t** list + ) { + switch (dim) { + case 0: + return get_vertices_dadj_to_triangle(f, entity_id, list); + case 1: + return get_edges_dadj_to_triangle(f, entity_id, list); + case 3: + return get_tets_uadj_to_triangle(f, entity_id, list); + default: + return dim_error (f, dim); + } +} + +static inline h5_err_t +get_adjacencies_to_tet ( + h5_file_t* const f, + const h5_id_t entity_id, + const h5_int32_t dim, + h5_idlist_t** list + ) { + switch (dim) { + case 0: + return get_vertices_dadj_to_tet(f, entity_id, list); + case 1: + return get_edges_dadj_to_tet(f, entity_id, list); + case 2: + return get_triangles_dadj_to_tet(f, entity_id, list); + default: + return dim_error (f, dim); + } +} + +static h5_err_t +get_adjacencies ( + h5_file_t* const f, + const h5_id_t entity_id, + const h5_int32_t dim, + h5_idlist_t** list + ) { + h5_id_t entity_type = h5tpriv_get_entity_type (entity_id); + switch (entity_type) { + case H5T_ETYPE_VERTEX: + return get_adjacencies_to_vertex (f, entity_id, dim, list); + case H5T_ETYPE_EDGE: + return get_adjacencies_to_edge (f, entity_id, dim, list); + case H5T_ETYPE_TRIANGLE: + return get_adjacencies_to_triangle (f, entity_id, dim, list); + case H5T_ETYPE_TET: + return get_adjacencies_to_tet (f, entity_id, dim, list); + default: + break; + } + return h5_error_internal (f, __FILE__, __func__, __LINE__); +} + + static h5_err_t update_internal_structs ( h5_file_t* const f, @@ -671,11 +782,11 @@ update_internal_structs ( return H5_SUCCESS; } - static h5_err_t release_internal_structs ( h5_file_t * const f ) { +#pragma unused f /* TO BE WRITTEN @@@ */ return H5_SUCCESS; } @@ -683,17 +794,6 @@ release_internal_structs ( struct h5t_adjacency_methods h5tpriv_tetm_adjacency_methods = { update_internal_structs, release_internal_structs, - get_edges_upadjacent_to_vertex, - get_triangles_upadjacent_to_vertex, - get_tets_upadjacent_to_vertex, - get_triangles_upadjacent_to_edge, - get_tets_upadjacent_to_edge, - get_tets_upadjacent_to_triangle, - get_vertices_downadjacent_to_edge, - get_vertices_downadjacent_to_triangle, - get_vertices_downadjacent_to_tet, - get_edges_downadjacent_to_triangle, - get_edges_downadjacent_to_tet, - get_triangles_downadjacent_to_tet + get_adjacencies, }; diff --git a/src/h5core/h5t_adjacencies_trim.c b/src/h5core/h5t_adjacencies_trim.c index c258906..cff707b 100644 --- a/src/h5core/h5t_adjacencies_trim.c +++ b/src/h5core/h5t_adjacencies_trim.c @@ -19,7 +19,7 @@ /* compute T(V) from current level up to highest levels. */ -static h5_err_t +static inline h5_err_t compute_elems_of_vertices ( h5_file_t* const f, const h5_id_t from_lvl @@ -30,7 +30,7 @@ compute_elems_of_vertices ( h5_id_t num_elems = t->num_elems[t->num_levels-1]; for (;elem_idx < num_elems; elem_idx++, el++) { int face_idx; - int num_faces = t->ref_elem->num_faces[0]; + int num_faces = h5tpriv_ref_elem_get_num_vertices (t); for (face_idx = 0; face_idx < num_faces; face_idx++) { h5_id_t vidx = el->vertex_indices[face_idx]; TRY( h5priv_append_to_idlist ( @@ -46,7 +46,7 @@ compute_elems_of_vertices ( /* Compute T(E) from current level up to highest levels. */ -static h5_err_t +static inline h5_err_t compute_elems_of_edges ( h5_file_t* const f, const h5_id_t from_lvl @@ -58,7 +58,7 @@ compute_elems_of_edges ( TRY( h5tpriv_resize_te_htab (f, 4*(num_elems-elem_idx)) ); for (;elem_idx < num_elems; elem_idx++) { int face_idx; - int num_faces = t->ref_elem->num_faces[1]; + int num_faces = h5tpriv_ref_elem_get_num_edges (t); for (face_idx = 0; face_idx < num_faces; face_idx++) { TRY ( h5tpriv_search_te2 ( f, face_idx, elem_idx, &retval ) ); @@ -67,7 +67,7 @@ compute_elems_of_edges ( return H5_SUCCESS; } -static h5_err_t +static inline h5_err_t compute_children_of_edge ( h5_file_t * const f, h5_id_t kid, @@ -94,7 +94,7 @@ compute_children_of_edge ( ); } else { h5_id_t kids[2]; - TRY ( t->methods.store->get_direct_children_of_edge ( + TRY ( h5tpriv_get_direct_children_of_edge ( f, face_idx, el->child_idx, @@ -111,7 +111,7 @@ compute_children_of_edge ( /* Compute all sections of an edge. */ -static h5_err_t +static inline h5_err_t compute_sections_of_edge ( h5_file_t * const f, h5_id_t kid, @@ -136,7 +136,7 @@ compute_sections_of_edge ( if ( ! h5tpriv_elem_is_on_cur_level ( f, el ) == H5_OK ) { refined = 1; h5_id_t kids[2]; - TRY ( t->methods.store->get_direct_children_of_edge ( + TRY ( h5tpriv_get_direct_children_of_edge ( f, face_id, el->child_idx, @@ -158,7 +158,7 @@ compute_sections_of_edge ( map edge ID to unique ID if unique ID not in list: add */ -static h5_err_t +static inline h5_err_t add_edge ( h5_file_t * const f, h5_idlist_t *list, @@ -172,8 +172,8 @@ add_edge ( } -static h5_err_t -get_edges_upadjacent_to_vertex ( +static inline h5_err_t +get_edges_uadj_to_vertex ( h5_file_t * const f, const h5_id_t entity_id, h5_idlist_t **list @@ -206,8 +206,8 @@ get_edges_upadjacent_to_vertex ( return H5_SUCCESS; } -static h5_err_t -get_triangles_upadjacent_to_vertex ( +static inline h5_err_t +get_triangles_uadj_to_vertex ( h5_file_t * const f, const h5_id_t entity_id, h5_idlist_t **list @@ -230,8 +230,8 @@ get_triangles_upadjacent_to_vertex ( return H5_SUCCESS; } -static h5_err_t -get_triangles_upadjacent_to_edge ( +static inline h5_err_t +get_triangles_uadj_to_edge ( h5_file_t * const f, const h5_id_t entity_id, h5_idlist_t **list @@ -251,8 +251,8 @@ get_triangles_upadjacent_to_edge ( return H5_SUCCESS; } -static h5_err_t -get_vertices_downadjacent_to_edge ( +static inline h5_err_t +get_vertices_dadj_to_edge ( h5_file_t * const f, const h5_id_t entity_id, h5_idlist_t **list @@ -276,8 +276,8 @@ get_vertices_downadjacent_to_edge ( /* Compute downward adjacent vertices of all edges of triangle. */ -static h5_err_t -get_vertices_downadjacent_to_triangle ( +static inline h5_err_t +get_vertices_dadj_to_triangle ( h5_file_t* const f, const h5_id_t entity_id, h5_idlist_t** list @@ -288,7 +288,7 @@ get_vertices_downadjacent_to_triangle ( h5_id_t elem_idx = h5tpriv_get_elem_idx ( entity_id ); // loop over all edges of triangle h5_id_t face_idx; - h5_id_t num_faces = f->t->ref_elem->num_faces[1]; + h5_id_t num_faces = h5tpriv_ref_elem_get_num_edges (f->t); for (face_idx = 0; face_idx < num_faces; face_idx++) { TRY( compute_sections_of_edge ( f, @@ -308,8 +308,8 @@ get_vertices_downadjacent_to_triangle ( return H5_SUCCESS; } -static h5_err_t -get_edges_downadjacent_to_triangle ( +static inline h5_err_t +get_edges_dadj_to_triangle ( h5_file_t* const f, const h5_id_t entity_id, h5_idlist_t** list @@ -320,7 +320,7 @@ get_edges_downadjacent_to_triangle ( h5_id_t elem_idx = h5tpriv_get_elem_idx (entity_id); // loop over all edges of triangle h5_id_t face_idx; - h5_id_t num_faces = f->t->ref_elem->num_faces[1]; + h5_id_t num_faces = h5tpriv_ref_elem_get_num_edges (f->t); for ( face_idx = 0; face_idx < num_faces; face_idx++ ) { TRY( compute_sections_of_edge ( f, @@ -337,7 +337,90 @@ get_edges_downadjacent_to_triangle ( return H5_SUCCESS; } +static inline h5_err_t +dim_error( + h5_file_t* const f, + const h5_int32_t dim + ) { + return h5_error ( + f, + H5_ERR_INVAL, + "Illegal dimension %ld", (long)dim); +} + +static inline h5_err_t +get_adjacencies_to_vertex ( + h5_file_t* const f, + const h5_id_t entity_id, + const h5_int32_t dim, + h5_idlist_t** list + ) { + switch (dim) { + case 1: + return get_edges_uadj_to_vertex(f, entity_id, list); + case 2: + return get_triangles_uadj_to_vertex(f, entity_id, list); + default: + return dim_error (f, dim); + } +} + +static inline h5_err_t +get_adjacencies_to_edge ( + h5_file_t* const f, + const h5_id_t entity_id, + const h5_int32_t dim, + h5_idlist_t** list + ) { + switch (dim) { + case 0: + return get_vertices_dadj_to_edge(f, entity_id, list); + case 2: + return get_triangles_uadj_to_edge(f, entity_id, list); + default: + return dim_error (f, dim); + } +} + +static inline h5_err_t +get_adjacencies_to_triangle ( + h5_file_t* const f, + const h5_id_t entity_id, + const h5_int32_t dim, + h5_idlist_t** list + ) { + switch (dim) { + case 0: + return get_vertices_dadj_to_triangle(f, entity_id, list); + case 1: + return get_edges_dadj_to_triangle(f, entity_id, list); + default: + return dim_error (f, dim); + } +} + static h5_err_t +get_adjacencies ( + h5_file_t* const f, + const h5_id_t entity_id, + const h5_int32_t dim, + h5_idlist_t** list + ) { + h5_id_t entity_type = h5tpriv_get_entity_type (entity_id); + switch (entity_type) { + case H5T_ETYPE_VERTEX: + return get_adjacencies_to_vertex (f, entity_id, dim, list); + case H5T_ETYPE_EDGE: + return get_adjacencies_to_edge (f, entity_id, dim, list); + case H5T_ETYPE_TRIANGLE: + return get_adjacencies_to_triangle (f, entity_id, dim, list); + default: + break; + } + return h5_error_internal (f, __FILE__, __func__, __LINE__); +} + +static inline h5_err_t update_internal_structs ( h5_file_t* const f, const h5_id_t from_lvl @@ -356,10 +439,11 @@ update_internal_structs ( return H5_SUCCESS; } -static h5_err_t +static inline h5_err_t release_internal_structs ( h5_file_t* const f ) { +#pragma unused f /* TO BE WRITTEN @@@ */ return H5_SUCCESS; } @@ -367,17 +451,6 @@ release_internal_structs ( struct h5t_adjacency_methods h5tpriv_trim_adjacency_methods = { update_internal_structs, release_internal_structs, - get_edges_upadjacent_to_vertex, - get_triangles_upadjacent_to_vertex, - NULL, - get_triangles_upadjacent_to_edge, - NULL, - NULL, - get_vertices_downadjacent_to_edge, - get_vertices_downadjacent_to_triangle, - NULL, - get_edges_downadjacent_to_triangle, - NULL, - NULL + get_adjacencies }; diff --git a/src/h5core/h5t_core_private.h b/src/h5core/h5t_core_private.h index 6a93314..c70581a 100644 --- a/src/h5core/h5t_core_private.h +++ b/src/h5core/h5t_core_private.h @@ -3,20 +3,21 @@ #define H5T_CONTAINER_GRPNAME "Topo" - -#include "h5t_openclose_private.h" -#include "h5t_adjacencies_private.h" -#include "h5t_consts_private.h" -#include "h5t_errorhandling_private.h" -#include "h5t_hsearch_private.h" -#include "h5t_map_private.h" -#include "h5t_readwrite_private.h" -#include "h5t_store_private.h" #include "h5t_tags_private.h" #include "h5t_types_private.h" #include "h5t_access_private.h" +#include "h5t_adjacencies_private.h" +#include "h5t_consts_private.h" +#include "h5t_inquiry_private.h" +#include "h5t_errorhandling_private.h" +#include "h5t_hsearch_private.h" +#include "h5t_map_private.h" +#include "h5t_openclose_private.h" +#include "h5t_ref_elements_private.h" +#include "h5t_readwrite_private.h" #include "h5t_retrieve_private.h" +#include "h5t_store_private.h" #endif diff --git a/src/h5core/h5t_errorhandling.c b/src/h5core/h5t_errorhandling.c index a24f1f5..27983fb 100644 --- a/src/h5core/h5t_errorhandling.c +++ b/src/h5core/h5t_errorhandling.c @@ -18,7 +18,7 @@ h5tpriv_error_local_elem_nexist ( int num_chars_printed = snprintf (s, sizeof(s), "%lld,", (long long)local_vertex_indices[0]); int i; - int num_vertices = t->ref_elem->num_faces[0]; + int num_vertices = h5tpriv_ref_elem_get_num_vertices (t); for (i = 1; i < num_vertices; i++) { num_chars_printed += snprintf ( s + num_chars_printed, sizeof (s) - num_chars_printed, diff --git a/src/h5core/h5t_hsearch.c b/src/h5core/h5t_hsearch.c index fb35de3..976e5fc 100644 --- a/src/h5core/h5t_hsearch.c +++ b/src/h5core/h5t_hsearch.c @@ -244,21 +244,25 @@ h5tpriv_search_td2 ( 3*(num_elems-elem_idx), &a->td_hash)); } - + /* search in directory, add if entry doen't already exists */ TRY( h5priv_hsearch ( f, entry, H5_ENTER, &__retval, &a->td_hash) ); - h5t_td_entry_t *te_entry = (h5t_td_entry_t *)__retval; + + /* search ID in list of IDs for given triangle */ + h5t_td_entry_t *td_entry = (h5t_td_entry_t *)__retval; TRY( h5priv_search_idlist ( f, - &te_entry->value, + &td_entry->value, h5tpriv_build_triangle_id (face_idx, elem_idx)) ); - if (te_entry->value.num_items > 1) { + if (td_entry->value.num_items > 1) { TRY( h5priv_free (f, entry) ); } + *retval = &td_entry->value; + return H5_SUCCESS; } diff --git a/src/h5core/h5t_inquiry.c b/src/h5core/h5t_inquiry.c index 967fe81..0bb0cde 100644 --- a/src/h5core/h5t_inquiry.c +++ b/src/h5core/h5t_inquiry.c @@ -12,23 +12,20 @@ h5_size_t h5t_get_num_meshes ( h5_file_t* const f, - const enum h5_oid type_id + const h5_oid_t type_id ) { - h5t_fdata_t* t = f->t; + hid_t topo_gid; + hid_t meshes_gid; - if (t->num_meshes >= 0) { - return t->num_meshes; - } - if (t->topo_gid < 0) { - TRY( h5tpriv_open_topo_group (f) ); - } - TRY( t->num_meshes = h5_get_num_hdf5_groups (f, t->meshes_gid) ); + TRY( topo_gid = h5priv_open_group (f, f->root_gid, H5T_CONTAINER_GRPNAME) ); + TRY( meshes_gid = h5priv_open_group ( + f, topo_gid, h5tpriv_meshes_grpnames[type_id]) ); - return t->num_meshes; + return h5_get_num_hdf5_groups (f, meshes_gid); } /*! - Get the number of hierarchical mesh levels. + Get the number of hierarchical mesh levels for the current mesh. \param[in] f File handle @@ -78,6 +75,7 @@ h5t_get_num_elems ( h5_file_t* const f, const h5_id_t cnode ) { +#pragma unused cnode h5t_fdata_t* t = f->t; if (t->cur_mesh < 0) { @@ -107,6 +105,7 @@ h5t_get_num_vertices ( h5_file_t* const f, h5_id_t cnode ) { +#pragma unused cnode h5t_fdata_t* t = f->t; if (t->cur_mesh < 0) { diff --git a/src/h5core/h5t_map.c b/src/h5core/h5t_map.c index 0c9cd6c..e7cc2a5 100644 --- a/src/h5core/h5t_map.c +++ b/src/h5core/h5t_map.c @@ -112,7 +112,7 @@ cmp_elems ( const h5_id_t elem_idx2 ) { h5t_fdata_t* t = f->t; - int num_vertices = t->ref_elem->num_faces[0]; + int num_vertices = h5tpriv_ref_elem_get_num_vertices (t); h5_id_t* indices1 = h5tpriv_get_loc_elem_vertex_indices (f, elem_idx1); h5_id_t* indices2 = h5tpriv_get_loc_elem_vertex_indices (f, elem_idx2); @@ -136,7 +136,7 @@ cmp_elems1 ( h5_id_t elem_idx2 ) { h5t_fdata_t *t = f->t; - int num_vertices = t->ref_elem->num_faces[0]; + int num_vertices = h5tpriv_ref_elem_get_num_vertices (t); h5_id_t* indices1 = h5tpriv_get_loc_elem_vertex_indices (f, elem_idx1); h5_id_t* indices2 = h5tpriv_get_loc_elem_vertex_indices (f, elem_idx2); @@ -184,7 +184,7 @@ qsort_cmp_elems1 ( binary search. */ h5_err_t -h5tpriv_sort_elems ( +h5tpriv_sort_loc_elems ( h5_file_t* const f ) { h5t_fdata_t* t = f->t; @@ -281,9 +281,9 @@ h5t_map_global_vertex_indices2local ( Get local element idx of element given by its global idx. \param[in] f File handle - \param[in] global_idx Global element id + \param[in] glb_idx Global element index - \return Local element id or error code. + \return Local element index or error code. */ h5_id_t h5t_map_global_elem_idx2local ( @@ -316,18 +316,24 @@ h5t_map_global_elem_indices2local ( return H5_SUCCESS; } + +/* + + */ h5_err_t h5tpriv_rebuild_global_2_local_map_of_vertices ( h5_file_t* const f ) { h5t_fdata_t* t = f->t; if (t->num_levels <= 0) return H5_SUCCESS; - h5_id_t local_vid = t->cur_level > 0 ? - t->num_vertices[t->cur_level-1] : 0; - for (; local_vid < t->num_vertices[t->num_levels-1]; local_vid++) { - t->map_vertex_g2l.items[local_vid].global_id = - t->vertices[local_vid].global_idx; - t->map_vertex_g2l.items[local_vid].local_id = local_vid; + + h5_loc_idx_t loc_idx = t->cur_level > 0 ? t->num_vertices[t->cur_level-1] : 0; + h5_loc_idx_t num_loc_vertices = t->num_vertices[t->num_levels-1]; + h5_idmap_el_t *item = &t->map_vertex_g2l.items[loc_idx]; + + for (; loc_idx < num_loc_vertices; loc_idx++, item++) { + item->global_id = t->vertices[loc_idx].idx; + item->local_id = loc_idx; t->map_vertex_g2l.num_items++; } h5priv_sort_idmap (&t->map_vertex_g2l); @@ -342,13 +348,13 @@ h5tpriv_rebuild_global_2_local_map_of_elems ( h5t_fdata_t* t = f->t; if (t->num_levels <= 0) return H5_SUCCESS; - h5_id_t idx = 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[idx]; + h5_id_t loc_idx = t->cur_level > 0 ? t->num_elems[t->cur_level-1] : 0; + h5_id_t num_loc_elems = t->num_elems[t->num_levels-1]; + h5_idmap_el_t *item = &t->map_elem_g2l.items[loc_idx]; - for (; idx < num_elems; idx++, item++) { - item->global_id = h5tpriv_get_glb_elem_idx (f, idx); - item->local_id = idx; + for (; loc_idx < num_loc_elems; loc_idx++, item++) { + item->global_id = h5tpriv_get_glb_elem_idx (f, loc_idx); + item->local_id = loc_idx; t->map_elem_g2l.num_items++; } h5priv_sort_idmap (&t->map_elem_g2l); diff --git a/src/h5core/h5t_map_private.h b/src/h5core/h5t_map_private.h index 589c179..2c53a8e 100644 --- a/src/h5core/h5t_map_private.h +++ b/src/h5core/h5t_map_private.h @@ -14,7 +14,7 @@ h5tpriv_sort_vertices ( ); h5_err_t -h5tpriv_sort_elems ( +h5tpriv_sort_loc_elems ( h5_file_t * const f ); diff --git a/src/h5core/h5t_openclose.c b/src/h5core/h5t_openclose.c index d3585f9..b413450 100644 --- a/src/h5core/h5t_openclose.c +++ b/src/h5core/h5t_openclose.c @@ -71,8 +71,8 @@ create_vertex_type ( h5priv_insert_hdf5_type ( f, dtypes->h5_vertex_t, - "global_idx", - HOFFSET (struct h5_vertex, global_idx), + "idx", + HOFFSET (struct h5_vertex, idx), H5_ID_T) ); TRY( h5priv_insert_hdf5_type ( @@ -206,9 +206,9 @@ create_tet_type ( TRY( h5priv_insert_hdf5_type ( f, - dtypes->h5_triangle_t, + dtypes->h5_tet_t, "neighbor_indices", - HOFFSET(struct h5_triangle, neighbor_indices), + HOFFSET (struct h5_tetrahedron, neighbor_indices), dtypes->h5_4id_t) ); return H5_SUCCESS; @@ -384,6 +384,7 @@ h5_err_t h5tpriv_init_step ( h5_file_t* const f ) { +#pragma unused f return H5_SUCCESS; } @@ -396,7 +397,7 @@ h5_err_t h5tpriv_close_step ( h5_file_t* const f ) { - +#pragma unused f return H5_SUCCESS; } @@ -413,7 +414,8 @@ h5tpriv_open_topo_group ( h5_err_t h5tpriv_open_meshes_group ( - h5_file_t* const f + h5_file_t* const f, + const h5_oid_t type_id ) { h5t_fdata_t* t = f->t; @@ -423,24 +425,34 @@ h5tpriv_open_meshes_group ( TRY( (t->meshes_gid = h5priv_open_group ( f, t->topo_gid, - h5tpriv_meshes_grpnames[t->mesh_type])) ); + h5tpriv_meshes_grpnames[type_id])) ); + t->mesh_type = type_id; return H5_SUCCESS; } +/* + Open HDF5 group with specific mesh +*/ + h5_err_t h5tpriv_open_mesh_group ( - h5_file_t* const f + h5_file_t* const f, + const h5_oid_t type_id, + const h5_id_t id ) { h5t_fdata_t* t = f->t; if (t->meshes_gid < 0) { - TRY( h5tpriv_open_meshes_group (f) ); + TRY( h5tpriv_open_meshes_group (f, type_id) ); } + snprintf (t->mesh_name, sizeof (t->mesh_name), "%lld", (long long)id); + TRY( (t->mesh_gid = h5priv_open_group ( f, t->meshes_gid, t->mesh_name)) ); + t->cur_mesh = id; return H5_SUCCESS; } @@ -451,14 +463,14 @@ h5_err_t h5t_open_mesh ( h5_file_t* const f, h5_id_t id, - const h5_oid_t type + const h5_oid_t type_id ) { h5t_fdata_t* t = f->t; TRY( h5t_close_mesh (f) ); if (t->num_meshes < 0) { - h5_size_t result = h5t_get_num_meshes (f, type); + h5_size_t result = h5t_get_num_meshes (f, type_id); t->num_meshes = (result > 0 ? result : 0); } if ((id < -1) || (id >= t->num_meshes)) { @@ -467,10 +479,7 @@ h5t_open_mesh ( if (id == -1) { /* append new mesh */ id = t->num_meshes; } - t->mesh_type = type; - snprintf (t->mesh_name, sizeof (t->mesh_name), "%lld", (long long)id); - - switch (type) { + switch (type_id) { case H5_OID_TETRAHEDRON: t->dsinfo_elems.type_id = t->dtypes.h5_tet_t; t->methods = tet_funcs; @@ -485,9 +494,7 @@ h5t_open_mesh ( return h5_error_internal (f, __FILE__, __func__, __LINE__); } - TRY( h5tpriv_open_mesh_group (f) ); - - t->cur_mesh = id; + TRY( h5tpriv_open_mesh_group (f, type_id, id) ); if (id != t->num_meshes) { /* open existing */ TRY( h5tpriv_read_mesh (f) ); @@ -533,9 +540,7 @@ release_memory ( h5_file_t* const f ) { TRY( h5tpriv_release_tags (f) ); - if (f->t->methods.adjacency != NULL) { - TRY( (*f->t->methods.adjacency->release_internal_structs) (f) ); - } + TRY( h5tpriv_release_adjacency_structs (f) ); TRY( release_elems (f) ); TRY( release_vertices (f) ); @@ -569,7 +574,7 @@ h5t_set_level ( t->cur_level = level_id; if (level_id >= t->num_loaded_levels) { - TRY( (t->methods.adjacency->update_internal_structs)(f, prev_level+1) ); + TRY( (h5tpriv_update_adjacency_structs)(f, prev_level+1) ); } return H5_SUCCESS; } diff --git a/src/h5core/h5t_openclose_private.h b/src/h5core/h5t_openclose_private.h index 590e1c7..a7bee96 100644 --- a/src/h5core/h5t_openclose_private.h +++ b/src/h5core/h5t_openclose_private.h @@ -4,8 +4,8 @@ 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_open_meshes_group ( h5_file_t * const f, const h5_oid_t ); +h5_err_t h5tpriv_open_mesh_group ( h5_file_t * const f, const h5_oid_t, const h5_id_t ); h5_err_t h5tpriv_close_step ( h5_file_t * const f ); h5_err_t h5tpriv_init_fdata ( h5_file_t * const f ); diff --git a/src/h5core/h5t_readwrite.c b/src/h5core/h5t_readwrite.c index 392643a..14769d6 100644 --- a/src/h5core/h5t_readwrite.c +++ b/src/h5core/h5t_readwrite.c @@ -6,6 +6,8 @@ open_space_all ( h5_file_t* const f, const hid_t dataset_id ) { +#pragma unused f +#pragma unused dataset_id return H5S_ALL; } @@ -25,9 +27,6 @@ write_vertices ( if (t->num_vertices <= 0) return H5_SUCCESS; /* ???? */ - if (t->mesh_gid < 0) { - TRY( h5tpriv_open_mesh_group (f) ); - } t->dsinfo_vertices.dims[0] = t->num_vertices[t->cur_level]; TRY( h5priv_write_dataset_by_name ( f, @@ -55,10 +54,6 @@ write_elems ( if (t->num_elems <= 0) return H5_SUCCESS; - if (t->mesh_gid < 0) { - TRY( h5tpriv_open_mesh_group (f) ); - } - TRY( h5priv_write_dataset_by_name ( f, t->mesh_gid, @@ -129,6 +124,8 @@ open_mem_space_vertices ( h5_file_t* const f, hid_t dataset_id ) { +#pragma unused f +#pragma unused dataset_id return H5S_ALL; } @@ -137,6 +134,8 @@ open_file_space_vertices ( h5_file_t* const f, hid_t dataset_id ) { +#pragma unused f +#pragma unused dataset_id return H5S_ALL; } @@ -147,7 +146,7 @@ read_num_vertices ( h5t_fdata_t* t = f->t; if (t->mesh_gid < 0) { - TRY( h5tpriv_open_mesh_group (f) ); + return h5_error_internal (f, __FILE__, __func__, __LINE__); } ssize_t num_bytes = t->num_levels*sizeof (t->num_vertices[0]); TRY( t->num_vertices = h5priv_alloc (f, t->num_vertices, num_bytes) ); @@ -191,7 +190,7 @@ read_num_elems ( h5t_fdata_t* t = f->t; if (t->mesh_gid < 0) { - TRY( h5tpriv_open_mesh_group (f) ); + return h5_error_internal (f, __FILE__, __func__, __LINE__); } size_t size = t->num_levels * sizeof (t->num_elems[0]); TRY( t->num_elems = h5priv_alloc (f, NULL, size) ); @@ -220,6 +219,8 @@ open_mem_space_elems ( h5_file_t* const f, hid_t dataset_id ) { +#pragma unused f +#pragma unused dataset_id return H5S_ALL; } @@ -228,6 +229,8 @@ open_file_space_elems ( h5_file_t* const f, hid_t dataset_id ) { +#pragma unused f +#pragma unused dataset_id return H5S_ALL; } @@ -239,8 +242,7 @@ read_elems ( ) { h5t_fdata_t* t = f->t; - TRY( (*t->methods.store->alloc_elems)( - f, 0, t->num_elems[t->num_levels-1]) ); + TRY( h5tpriv_alloc_elems(f, 0, t->num_elems[t->num_levels-1]) ); TRY( h5priv_read_dataset_by_name ( f, t->mesh_gid, @@ -249,9 +251,9 @@ read_elems ( open_file_space_elems, t->glb_elems.data) ); - TRY( h5tpriv_sort_elems (f) ); + TRY( h5tpriv_sort_loc_elems (f) ); TRY( h5tpriv_rebuild_global_2_local_map_of_elems (f) ); - TRY( (*f->t->methods.read->init_loc_elems_struct) (f) ); + TRY( h5tpriv_init_loc_elems_struct (f) ); return H5_SUCCESS; } @@ -270,15 +272,15 @@ h5tpriv_read_mesh ( h5_file_t* const f ) { h5t_fdata_t* t = f->t; - if (f->t->mesh_gid < 0) { - TRY( h5tpriv_open_mesh_group (f) ); + if (t->mesh_gid < 0) { + return h5_error_internal (f, __FILE__, __func__, __LINE__); } TRY( read_num_levels (f) ); TRY( read_num_vertices (f) ); TRY( read_num_elems (f) ); TRY( read_vertices (f) ); TRY( read_elems (f) ); - TRY( (t->methods.adjacency->update_internal_structs)(f, 0) ); + TRY( h5tpriv_update_adjacency_structs (f, 0) ); TRY( read_mtags (f) ); t->num_loaded_levels = t->num_levels; return H5_SUCCESS; diff --git a/src/h5core/h5t_readwrite_private.h b/src/h5core/h5t_readwrite_private.h index 648eb50..d7d8d00 100644 --- a/src/h5core/h5t_readwrite_private.h +++ b/src/h5core/h5t_readwrite_private.h @@ -25,4 +25,11 @@ h5tpriv_write_mesh ( extern struct h5t_read_methods h5tpriv_read_trim_methods; extern struct h5t_read_methods h5tpriv_read_tetm_methods; +static inline h5_err_t +h5tpriv_init_loc_elems_struct ( + h5_file_t* const f + ) { + return (*f->t->methods.read->init_loc_elems_struct) (f); +} + #endif diff --git a/src/h5core/h5t_readwrite_tetm.c b/src/h5core/h5t_readwrite_tetm.c index af097c6..83dd9c5 100644 --- a/src/h5core/h5t_readwrite_tetm.c +++ b/src/h5core/h5t_readwrite_tetm.c @@ -12,8 +12,8 @@ init_loc_elems_struct ( h5_id_t idx = 0; const h5_id_t num_elems = t->num_elems[t->num_levels-1]; h5_id_t level_idx = 0; - int num_vertices = t->ref_elem->num_faces[0]; - int num_edges = t->ref_elem->num_faces[1]; + int num_vertices = h5tpriv_ref_elem_get_num_vertices (t); + int num_edges = h5tpriv_ref_elem_get_num_edges (t); h5_tet_t* loc_elem = t->loc_elems.tets; h5_tet_t* glb_elem = t->glb_elems.tets; diff --git a/src/h5core/h5t_readwrite_trim.c b/src/h5core/h5t_readwrite_trim.c index d0156c2..773643a 100644 --- a/src/h5core/h5t_readwrite_trim.c +++ b/src/h5core/h5t_readwrite_trim.c @@ -12,8 +12,8 @@ init_loc_elems_struct ( h5_id_t idx = 0; const h5_id_t num_elems = t->num_elems[t->num_levels-1]; h5_id_t level_idx = 0; - int num_vertices = t->ref_elem->num_faces[0]; - int num_edges = t->ref_elem->num_faces[1]; + int num_vertices = h5tpriv_ref_elem_get_num_vertices (t); + int num_edges = h5tpriv_ref_elem_get_num_edges (t); h5_triangle_t* loc_elem = t->loc_elems.tris; h5_triangle_t* glb_elem = t->glb_elems.tris; diff --git a/src/h5core/h5t_ref_elements_private.h b/src/h5core/h5t_ref_elements_private.h new file mode 100644 index 0000000..bc1e191 --- /dev/null +++ b/src/h5core/h5t_ref_elements_private.h @@ -0,0 +1,11 @@ +#ifndef __H5T_REF_ELEMENTS_PRIVATE_H +#define __H5T_REF_ELEMENTS_PRIVATE_H + +#define h5tpriv_ref_elem_get_num_vertices(this) (this->ref_elem->num_faces[0]) +#define h5tpriv_ref_elem_get_num_edges(this) (this->ref_elem->num_faces[1]) +#define h5tpriv_ref_elem_get_num_triangles(this) (this->ref_elem->num_faces[2]) +#define h5tpriv_ref_elem_get_num_faces(this, dim) (this->ref_elem->num_faces[dim]) + +#define h5tpriv_ref_elem_get_dim(this) (this->ref_elem->dim) + +#endif diff --git a/src/h5core/h5t_retrieve.c b/src/h5core/h5t_retrieve.c index 3a89712..3735505 100644 --- a/src/h5core/h5t_retrieve.c +++ b/src/h5core/h5t_retrieve.c @@ -68,7 +68,7 @@ h5t_begin_iterate_entities ( h5t_entity_iterator_t* iter, const int codim ) { - return (*f->t->methods.retrieve->init_iterator)(f, iter, codim); + return h5tpriv_init_iterator (f, iter, codim); } /*! @@ -81,8 +81,8 @@ iterate_faces ( ) { h5_idlist_t* entry; h5_size_t i; - int dim = iter->ref_elem->dim - iter->codim; - int num_faces = iter->ref_elem->num_faces[dim] - 1; + int dim = h5tpriv_ref_elem_get_dim (iter) - iter->codim; + int num_faces = h5tpriv_ref_elem_get_num_faces (iter, dim) - 1; do { if (iter->face_idx >= num_faces) { if (h5tpriv_skip_to_next_elem_on_level (f, iter) == H5_NOK) { @@ -143,6 +143,7 @@ h5t_end_iterate_entities ( h5_file_t* const f, h5t_entity_iterator_t* iter ) { +#pragma unused f iter->face_idx = -1; iter->elem_idx = -1; iter->codim = -1; diff --git a/src/h5core/h5t_retrieve_private.h b/src/h5core/h5t_retrieve_private.h index 6c35f77..5edb5b5 100644 --- a/src/h5core/h5t_retrieve_private.h +++ b/src/h5core/h5t_retrieve_private.h @@ -16,4 +16,13 @@ h5tpriv_elem_is_on_cur_level ( extern struct h5t_retrieve_methods h5tpriv_trim_retrieve_methods; extern struct h5t_retrieve_methods h5tpriv_tetm_retrieve_methods; +static inline h5_err_t +h5tpriv_init_iterator ( + h5_file_t* f, + h5t_entity_iterator_t* const iter, + const int codim + ) { + return (*f->t->methods.retrieve->init_iterator) (f, iter, codim); +} + #endif diff --git a/src/h5core/h5t_retrieve_trim.c b/src/h5core/h5t_retrieve_trim.c index a214ee7..7bda222 100644 --- a/src/h5core/h5t_retrieve_trim.c +++ b/src/h5core/h5t_retrieve_trim.c @@ -13,7 +13,7 @@ begin_iterate_entities ( iter->elem_idx = -1; iter->codim = codim; iter->ref_elem = f->t->ref_elem; - switch (iter->ref_elem->dim - codim) { + switch (h5tpriv_ref_elem_get_dim (iter) - codim) { case 0: // iterate vertices iter->find = h5tpriv_find_tv2; return h5tpriv_skip_to_next_elem_on_level (f, iter); diff --git a/src/h5core/h5t_store.c b/src/h5core/h5t_store.c index f5b799e..d8fe9ba 100644 --- a/src/h5core/h5t_store.c +++ b/src/h5core/h5t_store.c @@ -42,7 +42,7 @@ assign_global_vertex_indices ( for (local_idx = 0; local_idx < t->num_vertices[t->num_levels-1]; local_idx++) { - t->vertices[local_idx].global_idx = local_idx; + t->vertices[local_idx].idx = local_idx; } return H5_SUCCESS; @@ -52,7 +52,7 @@ assign_global_vertex_indices ( Assign unique global indices to new elements. */ static h5_err_t -assign_global_elem_indices ( +assign_glb_elem_indices ( h5_file_t* const f ) { h5t_fdata_t* const t = f->t; @@ -62,32 +62,55 @@ assign_global_elem_indices ( /* simple in serial runs: global index = local index */ - h5_id_t local_idx = (t->cur_level == 0) ? 0 : t->num_elems[t->cur_level-1]; - int num_vertices = t->ref_elem->num_faces[0]; + h5_loc_idx_t loc_idx = (t->cur_level == 0) ? 0 : t->num_elems[t->cur_level-1]; - for (; local_idx < t->num_elems[t->cur_level]; local_idx++) { - h5_generic_elem_t *loc_elem = h5tpriv_get_loc_elem (f, local_idx); - h5_generic_elem_t *glb_elem = h5tpriv_get_glb_elem (f, local_idx); + for (; loc_idx < t->num_elems[t->cur_level]; loc_idx++) { + h5_generic_elem_t *glb_elem = h5tpriv_get_glb_elem (f, loc_idx); + + glb_elem->idx = loc_idx; + } + + return H5_SUCCESS; +} + +static h5_err_t +assign_glb_elem_data ( + h5_file_t* const f + ) { + h5t_fdata_t* const t = f->t; + + if (t->cur_level < 0) return H5_SUCCESS; /* no level defined */ + + /* + simple in serial runs: global index = local index + */ + h5_loc_idx_t loc_idx = (t->cur_level == 0) ? 0 : t->num_elems[t->cur_level-1]; + int num_vertices = h5tpriv_ref_elem_get_num_vertices (t); + int dim = h5tpriv_ref_elem_get_dim (t) - 1; + int num_faces = h5tpriv_ref_elem_get_num_faces(t, dim); + for (; loc_idx < t->num_elems[t->cur_level]; loc_idx++) { + h5_generic_elem_t *loc_elem = h5tpriv_get_loc_elem (f, loc_idx); + h5_generic_elem_t *glb_elem = h5tpriv_get_glb_elem (f, loc_idx); - glb_elem->idx = local_idx; glb_elem->parent_idx = loc_elem->parent_idx; glb_elem->child_idx = loc_elem->child_idx; - h5_id_t* glb_indices = h5tpriv_get_glb_elem_vertex_indices (f, local_idx); - h5_id_t* loc_indices = h5tpriv_get_loc_elem_vertex_indices (f, local_idx); + h5_id_t* glb_indices = h5tpriv_get_glb_elem_vertex_indices (f, loc_idx); + h5_id_t* loc_indices = h5tpriv_get_loc_elem_vertex_indices (f, loc_idx); memcpy (glb_indices, loc_indices, num_vertices*sizeof(*glb_indices)); - glb_indices = h5tpriv_get_glb_elem_neighbor_indices (f, local_idx); - loc_indices = h5tpriv_get_loc_elem_neighbor_indices (f, local_idx); + glb_indices = h5tpriv_get_glb_elem_neighbor_indices (f, loc_idx); + loc_indices = h5tpriv_get_loc_elem_neighbor_indices (f, loc_idx); - memcpy (glb_indices, loc_indices, num_vertices*sizeof(*glb_indices)); + memcpy (glb_indices, loc_indices, num_faces*sizeof(*glb_indices)); } return H5_SUCCESS; } + h5_id_t h5t_add_level ( h5_file_t* const f @@ -150,7 +173,7 @@ h5t_begin_store_vertices ( h5_id_t h5t_store_vertex ( h5_file_t* const f, /*!< file handle */ - const h5_id_t global_idx, /*!< global vertex id or -1 */ + const h5_id_t glb_idx, /*!< global vertex id or -1 */ const h5_float64_t P[3] /*!< coordinates */ ) { h5t_fdata_t* const t = f->t; @@ -170,7 +193,7 @@ h5t_store_vertex ( h5_id_t local_idx = ++t->last_stored_vid; h5_vertex_t *vertex = &t->vertices[local_idx]; - vertex->global_idx = global_idx; /* ID from mesher, replaced later!*/ + vertex->idx = glb_idx; /* ID from mesher, replaced later!*/ memcpy (&vertex->P, P, sizeof (vertex->P)); return local_idx; } @@ -214,7 +237,7 @@ h5t_begin_store_elems ( */ size_t nel = 2097152 > 5*new ? 2097152 : 5*new; TRY( h5tpriv_resize_te_htab (f, nel) ); - return (*t->methods.store->alloc_elems) (f, cur, new); + return h5tpriv_alloc_elems (f, cur, new); } @@ -261,14 +284,14 @@ h5t_store_elem ( h5tpriv_set_loc_elem_child_idx (f, elem_idx, -1); h5tpriv_set_loc_elem_level_idx (f, elem_idx, t->cur_level); - h5_id_t* loc_elem_vertex_indices = h5tpriv_get_loc_elem_vertex_indices (f, elem_idx); - int num_vertices = t->ref_elem->num_faces[0]; - memcpy (loc_elem_vertex_indices, vertex_indices, sizeof (*vertex_indices) * num_vertices); - h5tpriv_sort_local_vertex_indices (f, loc_elem_vertex_indices, num_vertices); + h5_id_t* loc_vertex_indices = h5tpriv_get_loc_elem_vertex_indices (f, elem_idx); + int num_vertices = h5tpriv_ref_elem_get_num_vertices (t); + memcpy (loc_vertex_indices, vertex_indices, sizeof (*vertex_indices)*num_vertices); + h5tpriv_sort_local_vertex_indices (f, loc_vertex_indices, num_vertices); - /* add edges to directory which maps edges to elements */ + /* add edges to map edges -> elements */ h5_id_t face_idx; - int num_faces = t->ref_elem->num_faces[1]; + int num_faces = h5tpriv_ref_elem_get_num_edges (t); h5_idlist_t* retval; for (face_idx = 0; face_idx < num_faces; face_idx++) { // add edges to neighbour struct @@ -288,13 +311,21 @@ h5t_end_store_elems ( h5t_fdata_t* const t = f->t; t->num_elems[t->cur_level] = t->last_stored_eid+1; - TRY( assign_global_elem_indices (f) ); - TRY( h5tpriv_sort_elems (f) ); + TRY( h5tpriv_sort_loc_elems (f) ); + + /* assign global indices to new indices */ + TRY( assign_glb_elem_indices (f) ); + + /* rebuild map: global index -> local_index */ TRY( h5tpriv_rebuild_global_2_local_map_of_elems (f) ); + /* mesh specific finalize */ TRY( (t->methods.store->end_store_elems)(f) ); + /* setup global element data */ + TRY( assign_glb_elem_data (f) ); + return H5_SUCCESS; } @@ -362,13 +393,13 @@ h5t_pre_refine ( Refine previously marked elements. */ h5_err_t -h5t_refine ( +h5t_refine_marked_elems ( h5_file_t* const f ) { h5t_fdata_t* const t = f->t; int i; for (i = 0; i < t->marked_entities.num_items; i++) { - TRY( h5t_refine_elem (f, t->marked_entities.items[i]) ); + TRY( h5tpriv_refine_elem (f, t->marked_entities.items[i]) ); } return H5_SUCCESS; } @@ -399,25 +430,12 @@ h5t_begin_refine_elems ( } -/*! - Refine element \c elem_id. Actually we set a mark only ... - - \return local id of first new element or \c -1 -*/ -h5_id_t -h5t_refine_elem ( - h5_file_t* const f, - const h5_id_t elem_id - ) { - return h5t_mark_entity (f, elem_id); -} - h5_err_t h5t_end_refine_elems ( h5_file_t* const f ) { TRY( h5t_pre_refine (f) ); - TRY( h5t_refine (f) ); + TRY( h5t_refine_marked_elems (f) ); TRY( h5t_post_refine (f) ); return H5_SUCCESS; diff --git a/src/h5core/h5t_store_private.h b/src/h5core/h5t_store_private.h index c36aa78..2a7b842 100644 --- a/src/h5core/h5t_store_private.h +++ b/src/h5core/h5t_store_private.h @@ -4,4 +4,32 @@ extern struct h5t_store_methods h5tpriv_trim_store_methods; extern struct h5t_store_methods h5tpriv_tetm_store_methods; +static inline h5_err_t +h5tpriv_get_direct_children_of_edge ( + h5_file_t* const f, + h5_loc_idx_t face_idx, + h5_loc_idx_t elem_idx, + h5_loc_id_t children[2] + ) { + return (*f->t->methods.store->get_direct_children_of_edge) ( + f, face_idx, elem_idx, children); +} + +static inline h5_err_t +h5tpriv_alloc_elems ( + h5_file_t* const f, + const size_t cur, + const size_t new + ) { + return (*f->t->methods.store->alloc_elems) (f, cur, new); +} + +static inline h5_id_t +h5tpriv_refine_elem ( + h5_file_t * const f, + const h5_id_t local_eid + ) { + return (*f->t->methods.store->refine_elem)(f, local_eid); +} + #endif diff --git a/src/h5core/h5t_store_tetm.c b/src/h5core/h5t_store_tetm.c index 0004e60..2ab3d93 100644 --- a/src/h5core/h5t_store_tetm.c +++ b/src/h5core/h5t_store_tetm.c @@ -41,9 +41,9 @@ alloc_tets ( static h5_err_t get_direct_children_of_edge ( h5_file_t* const f, - h5_id_t face_idx, - h5_id_t elem_idx, - h5_id_t children[2] + h5_loc_idx_t face_idx, + h5_loc_idx_t elem_idx, + h5_loc_id_t children[2] ) { /* Please read the note about the offsets in the corresponding file @@ -56,8 +56,8 @@ get_direct_children_of_edge ( {1,3}, // edge 4 {2,3} // edge 5 }; - int num_faces = f->t->ref_elem->num_faces[1]; - if ((face_idx < 0) || ( face_idx >= num_faces)) { + h5_loc_idx_t num_faces = h5tpriv_ref_elem_get_num_edges (f->t); + if ((face_idx < 0) || (face_idx >= num_faces)) { return h5_error_internal (f, __FILE__, __func__, __LINE__); } children[0] = h5tpriv_build_edge_id (face_idx, elem_idx+offs[face_idx][0]); @@ -75,8 +75,8 @@ get_direct_children_of_edge ( static h5_id_t bisect_edge ( h5_file_t* const f, - const h5_id_t face_idx, - const h5_id_t elem_idx + const h5_loc_idx_t face_idx, + const h5_loc_idx_t elem_idx ) { h5t_fdata_t* t = f->t; h5_idlist_t* retval; @@ -88,17 +88,18 @@ bisect_edge ( check wether one of the found elements has been refined */ size_t i; - for ( i = 0; i < retval->num_items; i++ ) { - h5_id_t idx = h5tpriv_get_elem_idx ( retval->items[i] ); + for (i = 0; i < retval->num_items; i++) { + h5_id_t idx = h5tpriv_get_elem_idx (retval->items[i]); h5_id_t child_idx = h5tpriv_get_loc_elem_child_idx (f, idx); - if ( child_idx >= 0 ) { + if (child_idx >= 0) { /* this element has been refined! return bisecting point */ - h5_id_t face_id = h5tpriv_get_face_idx ( - retval->items[i] ); - h5_id_t kids[2], edge0[2], edge1[2]; + h5_loc_idx_t face_id = h5tpriv_get_face_idx ( + retval->items[i]); + h5_loc_id_t kids[2]; + h5_loc_idx_t edge0[2], edge1[2]; TRY( get_direct_children_of_edge ( f, face_id, @@ -115,17 +116,17 @@ bisect_edge ( /* None of the elements has been refined -> add new vertex. */ - h5_id_t indices[2]; + h5_loc_idx_t indices[2]; TRY( h5t_get_vertex_indices_of_edge2 (f, face_idx, elem_idx, indices) ); - h5_float64_t *P0 = t->vertices[indices[0]].P; - h5_float64_t *P1 = t->vertices[indices[1]].P; + h5_float64_t* P0 = t->vertices[indices[0]].P; + h5_float64_t* P1 = t->vertices[indices[1]].P; h5_float64_t P[3]; - P[0] = ( P0[0] + P1[0] ) / 2.0; - P[1] = ( P0[1] + P1[1] ) / 2.0; - P[2] = ( P0[2] + P1[2] ) / 2.0; + P[0] = (P0[0] + P1[0]) / 2.0; + P[1] = (P0[1] + P1[1]) / 2.0; + P[2] = (P0[2] + P1[2]) / 2.0; - return h5t_store_vertex ( f, -1, P ); + return h5t_store_vertex (f, -1, P); } /*! @@ -136,11 +137,11 @@ bisect_edge ( static h5_id_t refine_tet ( h5_file_t* const f, - const h5_id_t elem_idx + const h5_loc_idx_t elem_idx ) { h5t_fdata_t* t = f->t; - h5_id_t vertices[10]; - h5_id_t elem_idx_of_first_child; + h5_loc_idx_t vertices[10]; + h5_loc_idx_t elem_idx_of_first_child; h5_tet_t* el = &t->loc_elems.tets[elem_idx]; if ( el->child_idx >= 0 ) @@ -164,7 +165,7 @@ refine_tet ( /* add new tets */ - h5_id_t new_elem[4]; + h5_loc_idx_t new_elem[4]; new_elem[0] = vertices[0]; // child 0 new_elem[1] = vertices[4]; @@ -214,17 +215,92 @@ refine_tet ( new_elem[3] = vertices[9]; TRY( h5t_store_elem (f, elem_idx, new_elem) ); - t->glb_elems.tets[elem_idx].child_idx = elem_idx_of_first_child; + // t->glb_elems.tets[elem_idx].child_idx = elem_idx_of_first_child; t->loc_elems.tets[elem_idx].child_idx = elem_idx_of_first_child; t->num_elems_on_level[t->cur_level]--; return elem_idx_of_first_child; } -h5_err_t -end_store_elems ( - h5_file_t* f +static inline h5_loc_idx_t +compute_neighbor_of_face ( + h5_file_t* const f, + h5_loc_idx_t elem_idx, + const h5_loc_idx_t face_idx ) { + + h5t_fdata_t * const t = f->t; + h5_idlist_t* td; + h5_loc_idx_t neighbor_idx = -2; + + do { + TRY( h5tpriv_find_td2 ( + f, + face_idx, + elem_idx, + &td) ); + if (td == NULL) { + return h5_error_internal ( + f, __FILE__, __func__, __LINE__); + } + if (td->num_items == 1) { + // neighbor is coarser or face is on the border + elem_idx = t->loc_elems.tets[elem_idx].parent_idx; + if (elem_idx == -1) { + // we are on the level of the macro grid + neighbor_idx = -1; + } + } else if (td->num_items == 2) { + // neighbor has same level of coarsness + if (h5tpriv_get_elem_idx(td->items[0]) == elem_idx) { + neighbor_idx = h5tpriv_get_elem_idx (td->items[1]); + } else { + neighbor_idx = h5tpriv_get_elem_idx (td->items[0]); + } + + } else { + return h5_error_internal ( + f, __FILE__, __func__, __LINE__); + } + } while (neighbor_idx < -1); + return neighbor_idx; +} + +/* + New level has been added, compute neighbores for new elements. + */ +static inline h5_err_t +compute_neighbors_of_new_elems ( + h5_file_t* const f + ) { + h5t_fdata_t * const t = f->t; + if (t->cur_level < 0) { + // or should we consider this as an error? + return H5_SUCCESS; + } + h5_loc_idx_t elem_idx = t->cur_level == 0 ? 0 : t->num_elems[t->cur_level-1]; + const h5_loc_idx_t last_idx = t->num_elems[t->cur_level] - 1; + h5_tet_t *el = &t->loc_elems.tets[elem_idx]; + while (elem_idx <= last_idx) { + h5_loc_idx_t face_idx = 0; + for (; face_idx < 4; face_idx++) { + el->neighbor_indices[face_idx] = + compute_neighbor_of_face (f, elem_idx, face_idx); + } + elem_idx++; + el++; + } + + return H5_SUCCESS; +} + +static h5_err_t +end_store_elems ( + h5_file_t* const f + ) { + h5t_fdata_t* const t = f->t; + TRY( h5tpriv_update_adjacency_structs (f, t->cur_level) ); + TRY( compute_neighbors_of_new_elems (f) ); return H5_SUCCESS; } diff --git a/src/h5core/h5t_store_trim.c b/src/h5core/h5t_store_trim.c index ab88159..59763b6 100644 --- a/src/h5core/h5t_store_trim.c +++ b/src/h5core/h5t_store_trim.c @@ -40,11 +40,10 @@ alloc_triangles ( static h5_err_t get_direct_children_of_edge ( h5_file_t * const f, - const h5_id_t face_idx, - const h5_id_t elem_idx, // index of the first child! - h5_id_t children[2] + const h5_loc_idx_t face_idx, + const h5_loc_idx_t elem_idx, + h5_loc_id_t children[2] ) { - int num_faces = f->t->ref_elem->num_faces[1]; /* Please note: The face index of the children and the father is always the same. The only think we have to know, is the offset @@ -60,22 +59,25 @@ get_direct_children_of_edge ( {0,2}, // edge 1 {1,2} // edge 2 }; - - if ( ( face_idx < 0 ) || ( face_idx >= num_faces ) ) { - return h5_error_internal ( f, __FILE__, __func__, __LINE__ ); + h5_loc_idx_t num_faces = h5tpriv_ref_elem_get_num_edges (f->t); + if ((face_idx < 0) || (face_idx >= num_faces)) { + return h5_error_internal (f, __FILE__, __func__, __LINE__); } - children[0] = h5tpriv_build_edge_id ( face_idx, elem_idx+off[face_idx][0] ); - children[1] = h5tpriv_build_edge_id ( face_idx, elem_idx+off[face_idx][1] ); + children[0] = h5tpriv_build_edge_id (face_idx, elem_idx+off[face_idx][0]); + children[1] = h5tpriv_build_edge_id (face_idx, elem_idx+off[face_idx][1]); return H5_SUCCESS; } -static h5_id_t +/* + Bisect edge and return local vertex index of the bisecting point. +*/ +static h5_loc_idx_t bisect_edge ( h5_file_t* const f, - const h5_id_t face_idx, - const h5_id_t elem_idx + const h5_loc_idx_t face_idx, + const h5_loc_idx_t elem_idx ) { - h5t_fdata_t* t = f->t; + h5t_fdata_t* const t = f->t; h5_idlist_t* retval; /* get all elements sharing the given edge @@ -85,25 +87,25 @@ bisect_edge ( check wether one of the found elements has been refined */ size_t i; - for ( i = 0; i < retval->num_items; i++ ) { - h5_id_t idx = h5tpriv_get_elem_idx ( retval->items[i] ); - h5_id_t child_idx = h5tpriv_get_loc_elem_child_idx (f, idx); - if ( child_idx >= 0 ) { + for (i = 0; i < retval->num_items; i++) { + h5_loc_idx_t idx = h5tpriv_get_elem_idx (retval->items[i]); + h5_loc_idx_t child_idx = h5tpriv_get_loc_elem_child_idx (f, idx); + if (child_idx >= 0) { /* this element has been refined! return bisecting point */ - h5_id_t face_id = h5tpriv_get_face_idx ( - retval->items[i] ); - h5_id_t kids[2], edge0[2], edge1[2]; - TRY ( get_direct_children_of_edge ( + h5_loc_id_t kids[2]; + TRY( get_direct_children_of_edge ( f, - face_id, + h5tpriv_get_face_idx (retval->items[i]), child_idx, kids ) ); - TRY ( h5t_get_vertex_indices_of_edge ( f, kids[0], edge0 ) ); - TRY ( h5t_get_vertex_indices_of_edge ( f, kids[1], edge1 ) ); - if ( (edge0[0] == edge1[0]) || (edge0[0] == edge1[1]) ) + + h5_loc_idx_t edge0[2], edge1[2]; + TRY( h5t_get_vertex_indices_of_edge ( f, kids[0], edge0 ) ); + TRY( h5t_get_vertex_indices_of_edge ( f, kids[1], edge1 ) ); + if ((edge0[0] == edge1[0]) || (edge0[0] == edge1[1])) return edge0[0]; else return edge0[1]; @@ -112,50 +114,50 @@ bisect_edge ( /* None of the elements has been refined -> add new vertex. */ - h5_id_t indices[2]; + h5_loc_idx_t indices[2]; TRY( h5t_get_vertex_indices_of_edge2 (f, face_idx, elem_idx, indices) ); - h5_float64_t *P0 = t->vertices[indices[0]].P; - h5_float64_t *P1 = t->vertices[indices[1]].P; + h5_float64_t* P0 = t->vertices[indices[0]].P; + h5_float64_t* P1 = t->vertices[indices[1]].P; h5_float64_t P[3]; - P[0] = ( P0[0] + P1[0] ) / 2.0; - P[1] = ( P0[1] + P1[1] ) / 2.0; - P[2] = ( P0[2] + P1[2] ) / 2.0; + P[0] = (P0[0] + P1[0]) / 2.0; + P[1] = (P0[1] + P1[1]) / 2.0; + P[2] = (P0[2] + P1[2]) / 2.0; - return h5t_store_vertex ( f, -1, P ); + return h5t_store_vertex (f, -1, P); } /*! Refine triangle \c local_eid - \return Local id of first new triangle or \c -1 + \return Local index of first new triangle or \c H5_ERR */ -static h5_id_t +static h5_loc_idx_t refine_triangle ( h5_file_t* const f, - const h5_id_t elem_idx + const h5_loc_idx_t elem_idx ) { - h5t_fdata_t *t = f->t; - h5_id_t vertices[6]; // local vertex indices - h5_id_t elem_idx_of_first_child; - h5_triangle_t *el = &t->loc_elems.tris[elem_idx]; + h5t_fdata_t* const t = f->t; + h5_loc_idx_t vertices[6]; // local vertex indices + h5_loc_idx_t elem_idx_of_first_child; + h5_triangle_t* el = &t->loc_elems.tris[elem_idx]; - if ( el->child_idx >= 0 ) + if (el->child_idx >= 0) return h5_error ( f, H5_ERR_INVAL, "Element %lld already refined.", - (long long)elem_idx ); + (long long)elem_idx); vertices[0] = el->vertex_indices[0]; vertices[1] = el->vertex_indices[1]; vertices[2] = el->vertex_indices[2]; - vertices[3] = bisect_edge( f, 0, elem_idx ); - vertices[4] = bisect_edge( f, 1, elem_idx ); - vertices[5] = bisect_edge( f, 2, elem_idx ); + vertices[3] = bisect_edge (f, 0, elem_idx); + vertices[4] = bisect_edge (f, 1, elem_idx); + vertices[5] = bisect_edge (f, 2, elem_idx); - h5_id_t new_elem[3]; + h5_loc_idx_t new_elem[3]; new_elem[0] = vertices[0]; // V[0] < V[3] , V[4] new_elem[1] = vertices[3]; @@ -184,54 +186,75 @@ refine_triangle ( return elem_idx_of_first_child; } -/* - Compute the neighbors in the macro-grid. - */ -static h5_err_t -compute_neighbors_in_macrogrid ( - h5_file_t* const f +static inline h5_loc_idx_t +compute_neighbor_of_face ( + h5_file_t* const f, + h5_loc_idx_t elem_idx, + const h5_loc_idx_t face_idx ) { - h5t_fdata_t *t = f->t; - h5_id_t elem_idx = 0; - h5_triangle_t *el = &t->loc_elems.tris[0]; - h5_id_t num_elems = t->num_elems[0]; - for (;elem_idx < num_elems; elem_idx++, el++) { - int face_idx = 0; - for (; face_idx < 3; face_idx++) { - h5_idlist_t* te; - TRY( h5tpriv_find_te2 ( - f, - face_idx, - elem_idx, - &te) ); - if (te == NULL) { - } else { - } + h5t_fdata_t * const t = f->t; + h5_idlist_t* te; + h5_loc_idx_t neighbor_idx = -2; + + do { + TRY( h5tpriv_find_te2 ( + f, + face_idx, + elem_idx, + &te) ); + if (te == NULL) { + return h5_error_internal ( + f, __FILE__, __func__, __LINE__); } - } - return H5_SUCCESS; + if (te->num_items == 1) { + // neighbor is coarser or face is on the border + elem_idx = t->loc_elems.tris[elem_idx].parent_idx; + if (elem_idx == -1) { + // we are on the level of the macro grid + neighbor_idx = -1; + } + } else if (te->num_items == 2) { + // neighbor has same level of coarsness + if (h5tpriv_get_elem_idx(te->items[0]) == elem_idx) { + neighbor_idx = h5tpriv_get_elem_idx (te->items[1]); + } else { + neighbor_idx = h5tpriv_get_elem_idx (te->items[0]); + } + + } else { + return h5_error_internal ( + f, __FILE__, __func__, __LINE__); + } + } while (neighbor_idx < -1); + return neighbor_idx; } -static h5_err_t -compute_neighbors_for_refined_elems ( +/* + New level has been added, compute neighbores for new elements. + */ +static inline h5_err_t +compute_neighbors_of_new_elems ( h5_file_t* const f ) { - h5t_fdata_t *t = f->t; - return H5_SUCCESS; -} - -static h5_err_t -compute_neighbors ( - h5_file_t* const f - ) { - h5t_fdata_t *t = f->t; - - if (t->cur_level == 0) { - TRY( compute_neighbors_in_macrogrid (f) ); - } else { - TRY( compute_neighbors_for_refined_elems (f) ); + h5t_fdata_t * const t = f->t; + if (t->cur_level < 0) { + // or should we consider this as an error? + return H5_SUCCESS; } + h5_loc_idx_t elem_idx = t->cur_level == 0 ? 0 : t->num_elems[t->cur_level-1]; + const h5_loc_idx_t last_idx = t->num_elems[t->cur_level] - 1; + h5_triangle_t *el = &t->loc_elems.tris[elem_idx]; + while (elem_idx <= last_idx) { + h5_loc_idx_t face_idx = 0; + for (; face_idx < 3; face_idx++) { + el->neighbor_indices[face_idx] = + compute_neighbor_of_face (f, elem_idx, face_idx); + } + elem_idx++; + el++; + } + return H5_SUCCESS; } @@ -239,10 +262,10 @@ static h5_err_t end_store_elems ( h5_file_t* const f ) { - h5t_fdata_t *t = f->t; + h5t_fdata_t* t = f->t; - TRY( (t->methods.adjacency->update_internal_structs)(f, t->cur_level) ); - TRY( compute_neighbors (f) ); + TRY( h5tpriv_update_adjacency_structs (f, t->cur_level) ); + TRY( compute_neighbors_of_new_elems (f) ); return H5_SUCCESS; } diff --git a/src/h5core/h5t_tags.c b/src/h5core/h5t_tags.c index 59f0523..0331d75 100644 --- a/src/h5core/h5t_tags.c +++ b/src/h5core/h5t_tags.c @@ -25,8 +25,8 @@ init_container ( /* Initialize tag container for current mesh and level. */ -h5_err_t -h5tpriv_init_mtagsets ( +static h5_err_t +init_mtagsets ( h5_file_t * const f, size_t ntags ) { @@ -106,8 +106,8 @@ h5tpriv_release_tags ( \return H5_SUCCESS or error code */ -h5_err_t -h5tpriv_add_mtagset ( +static h5_err_t +add_mtagset ( h5_file_t * const f, char * name, h5_id_t type, @@ -119,7 +119,7 @@ h5tpriv_add_mtagset ( Initialize data structure for m-tagsets, if not already done. */ if ( t->mtags.names == NULL ) { - TRY ( h5tpriv_init_mtagsets ( f, 521 ) ); + TRY( init_mtagsets (f, 521) ); } /* ToDo: Resize! @@ -171,7 +171,7 @@ h5t_add_mtagset ( char * name, h5_id_t type ) { - return h5tpriv_add_mtagset ( f, name, type, 0 ); + return add_mtagset ( f, name, type, 0 ); } @@ -347,8 +347,8 @@ h5t_get_mtagset_info ( \return H5_SUCCESS or error code */ -h5_err_t -h5tpriv_set_mtag ( +static h5_err_t +set_mtag ( h5_file_t *const f, H5T_Tagset *tagset, const h5_id_t id, @@ -433,16 +433,17 @@ h5t_set_mtag_by_name ( ) { H5T_Tagset *tagset; TRY ( h5t_open_mtagset ( f, name, &tagset ) ); - return h5tpriv_set_mtag ( f, tagset, id, size, val ); + return set_mtag ( f, tagset, id, size, val ); } static h5_err_t -_get_tag_valp ( - h5_file_t *const f, - const H5T_Tagset *tagset, +get_tag_valp ( + h5_file_t* const f, + const H5T_Tagset* tagset, const h5_id_t entity_id, - h5t_tagval_t **valp + h5t_tagval_t** const valp ) { +#pragma unused f h5_id_t el_idx = h5tpriv_get_elem_idx ( entity_id ); h5_id_t subentity_id = h5tpriv_get_face_idx ( entity_id ); h5_id_t type_id = h5tpriv_get_entity_type ( entity_id ); @@ -458,7 +459,7 @@ _get_tag_valp ( return H5_NOK; /* no value set for this subentity */ } size_t k = tagselem->idx[i]; - valp = &tagselem->valp[k]; + *valp = tagselem->valp[k]; return H5_SUCCESS; } @@ -479,11 +480,11 @@ h5t_get_tag ( h5_file_t *const f, const H5T_Tagset *tagset, const h5_id_t entity_id, - size_t *dim, - void *vals + size_t* const dim, + void* const vals ) { h5t_tagval_t *tagval; - TRY ( _get_tag_valp ( f, tagset, entity_id, &tagval ) ); + TRY ( get_tag_valp ( f, tagset, entity_id, &tagval ) ); if ( (*dim > tagval->size) || (vals == NULL) ) { *dim = tagval->size; @@ -527,8 +528,8 @@ h5t_get_mtag_by_name ( */ h5_err_t h5t_remove_mtag ( - h5_file_t *const f, - H5T_Tagset *tagset, + h5_file_t* const f, + H5T_Tagset* tagset, const h5_id_t id ) { h5_id_t el_idx = h5tpriv_get_elem_idx ( id ); @@ -586,8 +587,10 @@ h5t_remove_mtag_by_name ( static hid_t open_space_all ( h5_file_t * const f, - hid_t dataset_id + const hid_t dataset_id ) { +#pragma unused f +#pragma unused dataset_id return H5S_ALL; } @@ -860,11 +863,11 @@ read_tagset ( add tagset and set values */ H5T_Tagset* tagset; - TRY( h5tpriv_add_mtagset (f, name, type, &tagset) ); + TRY( 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( h5tpriv_set_mtag ( + TRY( set_mtag ( f, tagset, entity->eid, @@ -909,8 +912,8 @@ h5tpriv_read_tag_container ( \return number of tagsets */ -h5_ssize_t -h5tpriv_get_tagset_names_of_entity ( +static h5_ssize_t +get_tagset_names_of_entity ( h5_file_t * const f, h5t_tagcontainer_t *ctn, h5_id_t entity_id, @@ -928,7 +931,7 @@ h5tpriv_get_tagset_names_of_entity ( &ctn->sets)); H5T_Tagset *tset = (H5T_Tagset*)__retval; h5t_tagval_t *tval; - if (_get_tag_valp (f, tset, entity_id, &tval) != H5_SUCCESS) { + if (get_tag_valp (f, tset, entity_id, &tval) != H5_SUCCESS) { continue; } if ( (names != NULL) && (_dim <= dim) ) { @@ -941,11 +944,10 @@ h5tpriv_get_tagset_names_of_entity ( h5_ssize_t h5t_get_mtagset_names_of_entity ( - h5_file_t * const f, - h5_id_t entity_id, + h5_file_t* const f, + const h5_id_t entity_id, char *names[], - h5_size_t dim + const h5_size_t dim ) { - return h5tpriv_get_tagset_names_of_entity ( - f, &f->t->mtags, entity_id, names, dim); + return get_tagset_names_of_entity (f, &f->t->mtags, entity_id, names, dim); } diff --git a/src/h5core/h5t_types_private.h b/src/h5core/h5t_types_private.h index 02dce73..a707e01 100644 --- a/src/h5core/h5t_types_private.h +++ b/src/h5core/h5t_types_private.h @@ -2,7 +2,7 @@ #define __H5T_TYPES_PRIVATE_H typedef struct h5_vertex { - h5_id_t global_idx; + h5_id_t idx; h5_coord3d_t P; } h5_vertex_t; @@ -71,7 +71,6 @@ struct h5t_retrieve_methods { h5_err_t (*init_iterator)(h5_file_t* const, h5t_entity_iterator_t*, const int); }; - struct h5t_access_methods { h5_generic_elem_t* (*get_loc_elem)( h5_file_t* const, const h5_id_t); @@ -126,7 +125,6 @@ struct h5t_access_methods { h5_file_t* const, const h5_id_t, const h5_id_t); h5_id_t (*set_glb_elem_neighbor_idx)( h5_file_t* const, const h5_id_t, const h5_id_t, const h5_id_t); - }; struct h5t_read_methods { @@ -136,30 +134,8 @@ struct h5t_read_methods { struct h5t_adjacency_methods { h5_err_t (*update_internal_structs)(h5_file_t* const, h5_id_t); 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**); + h5_err_t (*get_adjacencies)( + h5_file_t * const, const h5_id_t, const h5_int32_t, h5_idlist_t**); }; typedef struct h5t_methods { diff --git a/src/h5core/h5u_model.c b/src/h5core/h5u_model.c index 5f22fba..bcd9cdd 100644 --- a/src/h5core/h5u_model.c +++ b/src/h5core/h5u_model.c @@ -115,6 +115,7 @@ h5u_set_num_particles ( } #ifndef PARALLEL_IO +#pragma unused total count = u->nparticles; TRY( u->shape = h5priv_create_hdf5_dataspace(f, 1, &count, NULL) ); u->viewstart = 0; @@ -436,11 +437,13 @@ h5u_get_dataset_info ( dataset_name, len_dataset_name) ); if ( nelem ) { - TRY( *nelem = h5priv_get_npoints_of_hdf5_dataset_by_name ( + h5_ssize_t nelem_; + TRY( nelem_ = h5priv_get_npoints_of_hdf5_dataset_by_name ( f, f->step_gid, dataset_name) ); - if ( *nelem < 0 ) return *nelem; + if ( nelem_ < 0 ) return nelem_; + *nelem = nelem_; } if ( type ) { diff --git a/src/h5core/h5u_readwrite.c b/src/h5core/h5u_readwrite.c index aa605bb..6d001a3 100644 --- a/src/h5core/h5u_readwrite.c +++ b/src/h5core/h5u_readwrite.c @@ -28,20 +28,19 @@ h5u_read_data ( /* default spaces, if not using a view selection */ memspace_id = H5S_ALL; - TRY ( space_id = h5priv_get_hdf5_dataset_space(f, dataset_id) ); + TRY( space_id = h5priv_get_hdf5_dataset_space(f, dataset_id) ); /* get the number of elements on disk for the datset */ TRY ( ndisk = h5priv_get_npoints_of_hdf5_dataspace(f, space_id) ); - if ( u->diskshape != H5S_ALL ) - { - TRY ( nread = h5priv_get_npoints_of_hdf5_dataspace(f, u->diskshape) ); + if (u->diskshape != H5S_ALL) { + TRY( nread = h5priv_get_npoints_of_hdf5_dataspace(f, u->diskshape) ); /* make sure the disk space selected by the view doesn't * exceed the size of the dataset */ - if ( nread <= ndisk ) { + if (nread <= ndisk) { /* we no longer need the dataset space... */ - TRY ( h5priv_close_hdf5_dataspace(f, space_id) ); + TRY( h5priv_close_hdf5_dataspace(f, space_id) ); /* ...because it's safe to use the view selection */ space_id = f->u->diskshape; } else { @@ -55,20 +54,18 @@ h5u_read_data ( name2, (long long)ndisk, (long long)nread ); nread = ndisk; } - } - else { + } else { /* since the view selection is H5S_ALL, we will * read all available elements in the dataset space */ nread = ndisk; } - if ( u->memshape != H5S_ALL ) - { - TRY ( nread = h5priv_get_npoints_of_hdf5_dataspace(f, u->memshape) ); + if (u->memshape != H5S_ALL) { + TRY( nmem = h5priv_get_npoints_of_hdf5_dataspace(f, u->memshape) ); /* make sure the memory space selected by the view has * enough capacity for the read */ - if ( nmem >= nread ) { + if (nmem >= nread) { memspace_id = f->u->memshape; } else { /* the view selection is too small? diff --git a/src/include/H5.h b/src/include/H5.h index 0cfd5d4..f11ba6c 100644 --- a/src/include/H5.h +++ b/src/include/H5.h @@ -107,14 +107,14 @@ H5GetErrorHandler ( h5_err_t H5ReportErrorhandler ( - h5_file_t * const f, + const h5_file_t * const f, const char *fmt, va_list ap ); h5_err_t H5AbortErrorhandler ( - h5_file_t * const f, + const h5_file_t * const f, const char *fmt, va_list ap ); diff --git a/src/include/H5Block.h b/src/include/H5Block.h index fdace4f..19f8013 100644 --- a/src/include/H5Block.h +++ b/src/include/H5Block.h @@ -19,41 +19,44 @@ H5Block3dSetView ( h5_err_t H5Block3dGetView ( - h5_file_t *const f, /*!< IN: File handle */ - h5_size_t *i_start, /*!< OUT: start index of \c i */ - h5_size_t *i_end, /*!< OUT: end index of \c i */ - h5_size_t *j_start, /*!< OUT: start index of \c j */ - h5_size_t *j_end, /*!< OUT: end index of \c j */ - h5_size_t *k_start, /*!< OUT: start index of \c k */ - h5_size_t *k_end /*!< OUT: end index of \c k */ + h5_file_t *const f, /*!< IN: File handle */ + h5_size_t *const i_start, /*!< OUT: start index of \c i */ + h5_size_t *const i_end, /*!< OUT: end index of \c i */ + h5_size_t *const j_start, /*!< OUT: start index of \c j */ + h5_size_t *const j_end, /*!< OUT: end index of \c j */ + h5_size_t *const k_start, /*!< OUT: start index of \c k */ + h5_size_t *const k_end /*!< OUT: end index of \c k */ ); h5_err_t H5Block3dGetReducedView ( - h5_file_t *const f, /*!< IN: File handle */ - h5_size_t *i_start, /*!< OUT: start index of \c i */ - h5_size_t *i_end, /*!< OUT: end index of \c i */ - h5_size_t *j_start, /*!< OUT: start index of \c j */ - h5_size_t *j_end, /*!< OUT: end index of \c j */ - h5_size_t *k_start, /*!< OUT: start index of \c j */ - h5_size_t *k_end /*!< OUT: end index of \c j */ + h5_file_t *const f, /*!< IN: File handle */ + h5_size_t *const i_start, /*!< OUT: start index of \c i */ + h5_size_t *const i_end, /*!< OUT: end index of \c i */ + h5_size_t *const j_start, /*!< OUT: start index of \c j */ + h5_size_t *const j_end, /*!< OUT: end index of \c j */ + h5_size_t *const k_start, /*!< OUT: start index of \c j */ + h5_size_t *const k_end /*!< OUT: end index of \c j */ ); h5_err_t H5Block3dSetChunk ( h5_file_t *const f, /*!< IN: File handle */ - const h5_int64_t i, /*!< IN: size of \c i */ - const h5_int64_t j, /*!< IN: size of \c j */ - const h5_int64_t k /*!< IN: size of \c k */ + const h5_size_t i, /*!< IN: size of \c i */ + const h5_size_t j, /*!< IN: size of \c j */ + const h5_size_t k /*!< IN: size of \c k */ ); h5_err_t H5Block3dGetChunk ( h5_file_t *const f, /*!< IN: File handle */ const char *field_name, /*!< IN: name of dataset */ - h5_size_t *dims /*!< OUT: array containing the chunk dimensions */ + h5_size_t *const i, /*!< OUT: size of i */ + h5_size_t *const j, /*!< OUT: size of j */ + h5_size_t *const k /*!< OUT: size of k */ ); +#if defined(PARALLEL_IO) h5_err_t H5Block3dSetGrid ( h5_file_t *const f, /*!< IN: File handle */ @@ -66,9 +69,9 @@ h5_err_t H5Block3dGetGridCoords ( h5_file_t *const f, /*!< IN: File handle */ const int proc, /*!< IN: MPI processor */ - h5_int64_t *i, /*!< OUT: index in \c i */ - h5_int64_t *j, /*!< OUT: index in \c j */ - h5_int64_t *k /*!< OUT: index in \c k */ + h5_size_t *const i, /*!< OUT: index in \c i */ + h5_size_t *const j, /*!< OUT: index in \c j */ + h5_size_t *const k /*!< OUT: index in \c k */ ); h5_err_t @@ -78,6 +81,7 @@ H5Block3dSetDims ( const h5_size_t j, /*!< IN: dimension in \c j */ const h5_size_t k /*!< IN: dimension in \c k */ ); +#endif h5_err_t H5Block3dSetHalo ( @@ -94,59 +98,59 @@ H5BlockGetNumFields ( h5_err_t H5BlockGetFieldInfo ( - h5_file_t *const f, /*!< IN: file handle */ - const h5_size_t idx, /*!< IN: index of field */ - char *name, /*!< OUT: field name */ - const h5_size_t len_name, /*!< IN: buffer size */ - h5_size_t *field_rank, /*!< OUT: field rank */ - h5_size_t *field_dims, /*!< OUT: field dimensions */ - h5_size_t *elem_rank, /*!< OUT: element rank */ - h5_int64_t *type /*!< OUT: datatype */ + h5_file_t *const f, /*!< IN: file handle */ + const h5_size_t idx, /*!< IN: index of field */ + char *name, /*!< OUT: field name */ + const h5_size_t len_name, /*!< IN: buffer size */ + h5_size_t *const field_rank, /*!< OUT: field rank */ + h5_size_t *const field_dims, /*!< OUT: field dimensions */ + h5_size_t *const elem_rank, /*!< OUT: element rank */ + h5_int64_t *const type /*!< OUT: datatype */ ); h5_err_t H5BlockGetFieldInfoByName ( h5_file_t *const f, /*!< IN: file handle */ const char *name, /*!< IN: field name */ - h5_size_t *field_rank, /*!< OUT: field rank */ - h5_size_t *field_dims, /*!< OUT: field dimensions */ - h5_size_t *elem_rank, /*!< OUT: element rank */ - h5_int64_t *type /*!< OUT: datatype */ + h5_size_t *const field_rank, /*!< OUT: field rank */ + h5_size_t *const field_dims, /*!< OUT: field dimensions */ + h5_size_t *const elem_rank, /*!< OUT: element rank */ + h5_int64_t *const type /*!< OUT: datatype */ ); h5_err_t H5BlockWriteFieldAttribString ( - h5_file_t *const f, /*!< IN: file handle */ - const char *field_name, /*!< IN: field name */ - const char *attrib_name, /*!< IN: attribute name */ - const char *value /*!< IN: attribute value */ + h5_file_t *const f, /*!< IN: file handle */ + const char *const field_name, /*!< IN: field name */ + const char *const attrib_name, /*!< IN: attribute name */ + const char *const value /*!< IN: attribute value */ ); h5_err_t H5BlockReadFieldAttribString ( - h5_file_t *const f, /*!< IN: file handle */ - const char *field_name, /*!< IN: field name */ - const char *attrib_name, /*!< IN: attribute name */ - char *buffer /*!< OUT: attribute value */ + h5_file_t *const f, /*!< IN: file handle */ + const char *const field_name, /*!< IN: field name */ + const char *const attrib_name, /*!< IN: attribute name */ + char *const buffer /*!< OUT: attribute value */ ); h5_ssize_t H5BlockGetNumFieldAttribs ( - h5_file_t *const f, /*