- bugfixes
- API adaptions
This commit is contained in:
@@ -47,9 +47,10 @@ include_HEADERS = \
|
||||
h5_core.h \
|
||||
h5_errorhandling.h \
|
||||
h5_errorhandling_private.h \
|
||||
h5_fcmp.h \
|
||||
h5_hdf5.h \
|
||||
h5_fcmp_private.h \
|
||||
h5_hdf5_private.h \
|
||||
h5_maps.h \
|
||||
h5_mpi_private.h \
|
||||
h5_openclose.h \
|
||||
h5_qsort_private.h \
|
||||
h5_readwrite.h \
|
||||
@@ -82,6 +83,7 @@ libH5_core_a_SOURCES = \
|
||||
h5_fcmp.c \
|
||||
h5_hdf5.c \
|
||||
h5_maps.c \
|
||||
h5_mpi.c \
|
||||
h5_openclose.c \
|
||||
h5_qsort.c \
|
||||
h5_qsort_r.c \
|
||||
|
||||
+11
-22
@@ -38,15 +38,11 @@ h5_read_attrib (
|
||||
hid_t mytype;
|
||||
hsize_t nelem;
|
||||
|
||||
TRY ( attrib_id = _h5_open_attribute_by_name ( f, id, attrib_name ) );
|
||||
TRY ( attrib_id = _h5_open_attribute ( f, id, attrib_name ) );
|
||||
TRY ( mytype = _h5_get_attribute_type ( f, attrib_id ) );
|
||||
TRY ( space_id = _h5_get_attribute_space ( f, attrib_id ) );
|
||||
|
||||
nelem = H5Sget_simple_extent_npoints ( space_id );
|
||||
if ( nelem < 0 ) return HANDLE_H5S_GET_SIMPLE_EXTENT_NPOINTS_ERR( f );
|
||||
|
||||
type_id = h5_normalize_h5_type ( f, mytype );
|
||||
|
||||
TRY ( nelem = _h5_get_npoints_of_space ( f, space_id ) );
|
||||
TRY ( type_id = h5_normalize_h5_type ( f, mytype ) );
|
||||
TRY ( _h5_read_attribute ( f, attrib_id, type_id, attrib_value ) );
|
||||
TRY ( _h5_close_dataspace( f, space_id ) );
|
||||
TRY ( _h5_close_type( f, mytype ) );
|
||||
@@ -74,7 +70,7 @@ h5_write_attrib (
|
||||
hid_t space_id;
|
||||
hid_t attrib_id;
|
||||
|
||||
TRY ( space_id = _h5_create_dataset_space ( f, 1, &attrib_nelem, NULL) );
|
||||
TRY ( space_id = _h5_create_space ( f, 1, &attrib_nelem, NULL) );
|
||||
TRY ( attrib_id = _h5_create_attribute (
|
||||
f,
|
||||
id,
|
||||
@@ -111,16 +107,14 @@ h5_get_attrib_info (
|
||||
hid_t mytype;
|
||||
hid_t space_id;
|
||||
|
||||
attrib_id = H5Aopen_idx ( id, (unsigned int)attrib_idx );
|
||||
if ( attrib_id < 0 ) return HANDLE_H5A_OPEN_IDX_ERR ( f, attrib_idx );
|
||||
TRY ( attrib_id = _h5_open_attribute_idx (
|
||||
f,
|
||||
id,
|
||||
(unsigned int)attrib_idx ) );
|
||||
|
||||
if ( attrib_nelem ) {
|
||||
TRY ( space_id = _h5_get_attribute_space ( f, attrib_id ) );
|
||||
|
||||
*attrib_nelem = H5Sget_simple_extent_npoints ( space_id );
|
||||
if ( *attrib_nelem < 0 )
|
||||
return HANDLE_H5S_GET_SIMPLE_EXTENT_NPOINTS_ERR( f );
|
||||
|
||||
TRY ( *attrib_nelem = _h5_get_npoints_of_space ( f, space_id ) );
|
||||
TRY( _h5_close_dataspace( f, space_id ) );
|
||||
}
|
||||
if ( attrib_name ) {
|
||||
@@ -132,7 +126,7 @@ h5_get_attrib_info (
|
||||
}
|
||||
if ( attrib_type ) {
|
||||
TRY ( mytype = _h5_get_attribute_type ( f, attrib_id ) );
|
||||
*attrib_type = h5_normalize_h5_type ( f, mytype );
|
||||
TRY ( *attrib_type = h5_normalize_h5_type ( f, mytype ) );
|
||||
TRY ( _h5_close_type( f, mytype ) );
|
||||
}
|
||||
TRY ( _h5_close_attribute ( f, attrib_id ) );
|
||||
@@ -152,11 +146,6 @@ h5_get_num_attribs (
|
||||
h5_file_t * const f, /*!< handle to open file */
|
||||
const hid_t id
|
||||
) {
|
||||
|
||||
CHECK_FILEHANDLE ( f );
|
||||
|
||||
int nattribs = H5Aget_num_attrs ( id );
|
||||
if ( nattribs < 0 ) HANDLE_H5A_GET_NUM_ATTRS_ERR( f );
|
||||
|
||||
return (h5_size_t) nattribs;
|
||||
return _h5_get_num_attributes ( f, id );
|
||||
}
|
||||
|
||||
@@ -6,8 +6,6 @@
|
||||
|
||||
#include "h5_attribs.h"
|
||||
#include "h5_errorhandling.h"
|
||||
#include "h5_fcmp.h"
|
||||
#include "h5_hdf5.h"
|
||||
#include "h5_maps.h"
|
||||
#include "h5_openclose.h"
|
||||
#include "h5_readwrite.h"
|
||||
|
||||
@@ -7,6 +7,9 @@
|
||||
#include "h5u_types_private.h"
|
||||
|
||||
#include "h5_errorhandling_private.h"
|
||||
#include "h5_fcmp_private.h"
|
||||
#include "h5_hdf5_private.h"
|
||||
#include "h5_mpi_private.h"
|
||||
#include "h5_qsort_private.h"
|
||||
#include "h5_readwrite_private.h"
|
||||
#include "h5_syscall_private.h"
|
||||
|
||||
@@ -42,19 +42,6 @@
|
||||
H5_ERR_BADFD, \
|
||||
"Called with bad filehandle." );
|
||||
|
||||
#define HANDLE_H5_NOMEM_ERR( f ) \
|
||||
h5_error( \
|
||||
f, \
|
||||
H5_ERR_NOMEM, \
|
||||
"Out of memory." );
|
||||
|
||||
#define HANDLE_H5_SETSTEP_ERR( f, rc, step ) \
|
||||
h5_error( \
|
||||
f, \
|
||||
h5_get_funcname(), \
|
||||
rc, \
|
||||
"Cannont set step to %lld.", (long long)step );
|
||||
|
||||
#define _h5_handle_file_mode_error( f, mode_id ) \
|
||||
h5_error( \
|
||||
f, \
|
||||
@@ -62,12 +49,6 @@
|
||||
"Operation not permitted in mode \"%s\"", \
|
||||
H5_O_MODES[mode_id] );
|
||||
|
||||
#define HANDLE_H5_FILE_ACCESS_TYPE_ERR( f, flags ) \
|
||||
h5_error( \
|
||||
f, \
|
||||
H5_ERR_INVAL, \
|
||||
"Invalid file access mode \"%d\".", flags);
|
||||
|
||||
#define HANDLE_H5_STEP_EXISTS_ERR( f, step ) \
|
||||
h5_error( \
|
||||
f, \
|
||||
@@ -104,95 +85,4 @@
|
||||
"%s id %lld out of range", \
|
||||
otype, oid );
|
||||
|
||||
/**************** HDF5 *********************/
|
||||
/* H5A: Attribute */
|
||||
#define HANDLE_H5A_GET_NUM_ATTRS_ERR( f ) \
|
||||
h5_error( \
|
||||
f, \
|
||||
H5_ERR_HDF5, \
|
||||
"Cannot get number of attributes." );
|
||||
|
||||
#define HANDLE_H5A_OPEN_IDX_ERR( f, n ) \
|
||||
h5_error( \
|
||||
f, \
|
||||
H5_ERR_HDF5, \
|
||||
"Cannot open attribute specified by index \"%lld\".", \
|
||||
(long long)n );
|
||||
|
||||
/* H5G: group */
|
||||
#define HANDLE_H5G_GET_OBJINFO_ERR( f, s ) \
|
||||
h5_error( \
|
||||
f, \
|
||||
H5_ERR_HDF5, \
|
||||
"Cannot get information about object \"%s\".", s );
|
||||
|
||||
/* H5P: property */
|
||||
#define HANDLE_H5P_SET_FAPL_MPIO_ERR( f ) \
|
||||
h5_error( \
|
||||
f, \
|
||||
H5_ERR_HDF5, \
|
||||
"Cannot store IO communicator information to the " \
|
||||
"file access property list.");
|
||||
|
||||
/* H5S: dataspace */
|
||||
#define HANDLE_H5S_CREATE_SIMPLE_3D_ERR( f, dims ) \
|
||||
h5_error( \
|
||||
f, \
|
||||
H5_ERR_HDF5, \
|
||||
"Cannot create 3d dataspace with dimension sizes " \
|
||||
"\"(%lld,%lld,%lld)\".", \
|
||||
(long long)dims[0], (long long)dims[1], (long long)dims[2] );
|
||||
|
||||
#define HANDLE_H5S_GET_SELECT_NPOINTS_ERR(f) \
|
||||
h5_error( \
|
||||
f, \
|
||||
H5_ERR_HDF5, \
|
||||
"Cannot determine the number of elements" \
|
||||
"in dataspace selection." );
|
||||
|
||||
#define HANDLE_H5S_GET_SIMPLE_EXTENT_NPOINTS_ERR( f ) \
|
||||
h5_error( \
|
||||
f, \
|
||||
H5_ERR_HDF5, \
|
||||
"Cannot determine number of elements in dataspace." );
|
||||
|
||||
#define HANDLE_H5S_SELECT_HYPERSLAB_ERR( f ) \
|
||||
h5_error( \
|
||||
f, \
|
||||
H5_ERR_HDF5, \
|
||||
"Cannot set select hyperslap region or add the " \
|
||||
"specified region" );
|
||||
|
||||
#define HANDLE_H5S_GET_SIMPLE_EXTENT_DIMS_ERR( f ) \
|
||||
h5_error( \
|
||||
f, \
|
||||
H5_ERR_HDF5, \
|
||||
"Cannot get dimension sizes of dataset" );
|
||||
|
||||
|
||||
/* MPI */
|
||||
#define HANDLE_MPI_ALLGATHER_ERR( f ) \
|
||||
h5_error( \
|
||||
f, \
|
||||
H5_ERR_MPI, \
|
||||
"Cannot gather data." );
|
||||
|
||||
#define HANDLE_MPI_COMM_SIZE_ERR( f ) \
|
||||
h5_error( \
|
||||
f, \
|
||||
H5_ERR_MPI, \
|
||||
"Cannot get number of processes in my group." );
|
||||
|
||||
#define HANDLE_MPI_COMM_RANK_ERR( f ) \
|
||||
h5_error( \
|
||||
f, \
|
||||
H5_ERR_MPI, \
|
||||
"Cannot get rank of the calling process in my group." );
|
||||
|
||||
#define HANDLE_MPI_UNAVAILABLE_ERR( f ) \
|
||||
h5_error( \
|
||||
f, \
|
||||
H5_ERR_MPI, \
|
||||
"MPI not available" );
|
||||
|
||||
#endif
|
||||
|
||||
@@ -1,18 +1,18 @@
|
||||
#include <assert.h>
|
||||
#include <stdlib.h>
|
||||
#include <hdf5.h>
|
||||
#include "h5_types.h"
|
||||
#include "h5_core.h"
|
||||
|
||||
/*!
|
||||
Compare to floating point numbers using integers. See
|
||||
Compare two floating point numbers using integers. See
|
||||
http://www.cygnus-software.com/papers/comparingfloats/comparingfloats.htm
|
||||
for a detailed explanation.
|
||||
*/
|
||||
int
|
||||
h5_int64_t
|
||||
_h5_fcmp (
|
||||
h5_float64_t A,
|
||||
h5_float64_t B,
|
||||
h5_int64_t maxUlps ) {
|
||||
h5_int32_t maxUlps ) {
|
||||
|
||||
// Make sure maxUlps is non-negative and small enough that the
|
||||
// default NAN won't compare as equal to anything.
|
||||
|
||||
+148
-4
@@ -69,7 +69,7 @@ _h5_close_group (
|
||||
h5_file_t * const f,
|
||||
const hid_t group_id
|
||||
) {
|
||||
if ( group_id == 0 || group_id == -1 ) return H5_SUCCESS;
|
||||
if ( group_id <= 0 ) return H5_SUCCESS;
|
||||
const char *group_name = h5_get_objname( group_id );
|
||||
if ( H5Gclose ( group_id ) < 0 ) {
|
||||
return h5_error (
|
||||
@@ -285,7 +285,7 @@ _h5_close_dataset (
|
||||
|
||||
*/
|
||||
hid_t
|
||||
_h5_create_dataset_space (
|
||||
_h5_create_space (
|
||||
h5_file_t * const f,
|
||||
const int rank,
|
||||
const hsize_t * dims,
|
||||
@@ -301,6 +301,77 @@ _h5_create_dataset_space (
|
||||
return dataspace_id;
|
||||
}
|
||||
|
||||
herr_t
|
||||
_h5_select_hyperslab_of_space (
|
||||
h5_file_t * const f,
|
||||
hid_t space_id,
|
||||
H5S_seloper_t op,
|
||||
const hsize_t *start,
|
||||
const hsize_t *stride,
|
||||
const hsize_t *count,
|
||||
const hsize_t *block
|
||||
) {
|
||||
herr_t herr = H5Sselect_hyperslab (
|
||||
space_id,
|
||||
op,
|
||||
start,
|
||||
stride,
|
||||
count,
|
||||
block );
|
||||
if ( herr < 0 )
|
||||
return h5_error (
|
||||
f,
|
||||
H5_ERR_HDF5,
|
||||
"Cannot set select hyperslap region or add the "
|
||||
"specified region" );
|
||||
return H5_SUCCESS;
|
||||
}
|
||||
|
||||
hssize_t
|
||||
_h5_get_selected_npoints_of_space (
|
||||
h5_file_t * const f,
|
||||
hid_t space_id
|
||||
) {
|
||||
hssize_t size = H5Sget_select_npoints ( space_id );
|
||||
if ( size < 0 )
|
||||
h5_error(
|
||||
f,
|
||||
H5_ERR_HDF5,
|
||||
"Cannot determine number of selected elements in dataspace." );
|
||||
return size;
|
||||
}
|
||||
|
||||
hssize_t
|
||||
_h5_get_npoints_of_space (
|
||||
h5_file_t * const f,
|
||||
hid_t space_id
|
||||
) {
|
||||
hssize_t size = H5Sget_simple_extent_npoints ( space_id );
|
||||
if ( size < 0 )
|
||||
h5_error(
|
||||
f,
|
||||
H5_ERR_HDF5,
|
||||
"Cannot determine number of elements in dataspace." );
|
||||
return size;
|
||||
}
|
||||
|
||||
int
|
||||
_h5_get_dims_of_space (
|
||||
h5_file_t * const f,
|
||||
hid_t space_id,
|
||||
hsize_t *dims,
|
||||
hsize_t *maxdims
|
||||
) {
|
||||
int rank = H5Sget_simple_extent_dims ( space_id, dims, maxdims );
|
||||
if ( rank < 0 )
|
||||
return h5_error (
|
||||
f,
|
||||
H5_ERR_HDF5,
|
||||
"Cannot determine rank of dataspace." );
|
||||
return rank;
|
||||
}
|
||||
|
||||
|
||||
/*!
|
||||
Close space.
|
||||
|
||||
@@ -462,6 +533,25 @@ _h5_set_chunk_property (
|
||||
return H5_SUCCESS;
|
||||
}
|
||||
|
||||
#ifdef PARALLEL_IO
|
||||
h5_err_t
|
||||
_h5_set_fapl_mpio_property (
|
||||
h5_file_t * const f,
|
||||
hid_t fapl_id,
|
||||
MPI_Comm comm,
|
||||
MPI_Info info
|
||||
) {
|
||||
herr_t herr = H5Pset_fapl_mpio ( fapl_id, comm, info );
|
||||
if ( herr < 0 )
|
||||
h5_error(
|
||||
f,
|
||||
H5_ERR_HDF5,
|
||||
"Cannot store IO communicator information to the "
|
||||
"file access property list.");
|
||||
return H5_SUCCESS;
|
||||
}
|
||||
#endif
|
||||
|
||||
h5_err_t
|
||||
_h5_close_property (
|
||||
h5_file_t * const f,
|
||||
@@ -512,12 +602,49 @@ _h5_set_errorhandler (
|
||||
|
||||
/****** A t t r i b u t e ****************************************************/
|
||||
hid_t
|
||||
_h5_open_attribute_by_name (
|
||||
_h5_open_attribute (
|
||||
h5_file_t * const f,
|
||||
hid_t loc_id,
|
||||
const char *attr_name
|
||||
) {
|
||||
hid_t attr_id = H5Aopen ( loc_id, attr_name, H5P_DEFAULT );
|
||||
if ( attr_id < 0 )
|
||||
return h5_error (
|
||||
f,
|
||||
H5_ERR_HDF5,
|
||||
"Cannot open attribute \"%s\" of \"%s\".",
|
||||
attr_name,
|
||||
h5_get_objname( loc_id ) );
|
||||
return attr_id;
|
||||
}
|
||||
|
||||
hid_t
|
||||
_h5_open_attribute_idx (
|
||||
h5_file_t * const f,
|
||||
hid_t loc_id,
|
||||
unsigned int idx
|
||||
) {
|
||||
hid_t attr_id = H5Aopen_idx ( loc_id, idx );
|
||||
if ( attr_id < 0 )
|
||||
return h5_error (
|
||||
f,
|
||||
H5_ERR_HDF5,
|
||||
"Cannot open attribute \"%u\" of \"%s\".",
|
||||
idx,
|
||||
h5_get_objname( loc_id ) );
|
||||
return attr_id;
|
||||
}
|
||||
|
||||
hid_t
|
||||
_h5_open_attribute_by_name (
|
||||
h5_file_t * const f,
|
||||
hid_t loc_id,
|
||||
const char *obj_name,
|
||||
const char *attr_name
|
||||
) {
|
||||
hid_t attr_id = H5Aopen_by_name (
|
||||
loc_id,
|
||||
obj_name,
|
||||
attr_name,
|
||||
H5P_DEFAULT,
|
||||
H5P_DEFAULT );
|
||||
@@ -527,8 +654,9 @@ _h5_open_attribute_by_name (
|
||||
H5_ERR_HDF5,
|
||||
"Cannot open attribute \"%s\" of \"%s\".",
|
||||
attr_name,
|
||||
h5_get_objname( loc_id ) );
|
||||
obj_name );
|
||||
return attr_id;
|
||||
}
|
||||
|
||||
hid_t
|
||||
_h5_create_attribute (
|
||||
@@ -639,6 +767,22 @@ _h5_get_attribute_space (
|
||||
return space_id;
|
||||
}
|
||||
|
||||
int
|
||||
_h5_get_num_attributes (
|
||||
h5_file_t * const f,
|
||||
hid_t loc_id
|
||||
) {
|
||||
int num = H5Aget_num_attrs ( loc_id );
|
||||
if ( num < 0 )
|
||||
return h5_error (
|
||||
f,
|
||||
H5_ERR_HDF5,
|
||||
"Cannot get number of attributes of \"%s\".",
|
||||
h5_get_objname( loc_id ) );
|
||||
return num;
|
||||
}
|
||||
|
||||
|
||||
herr_t
|
||||
_h5_close_attribute (
|
||||
h5_file_t * const f,
|
||||
|
||||
+27
-49
@@ -63,22 +63,17 @@ static h5_int64_t
|
||||
_h5u_open_file (
|
||||
h5_file_t *f /*!< IN: file handle */
|
||||
) {
|
||||
f->u = (struct h5u_fdata*) malloc( sizeof (*f->u) );
|
||||
if ( f->u == NULL ) {
|
||||
return HANDLE_H5_NOMEM_ERR( f );
|
||||
}
|
||||
struct h5u_fdata *u = f->u;
|
||||
TRY ( f->u = (struct h5u_fdata*) _h5_alloc( f, NULL, sizeof (*f->u) ) );
|
||||
h5u_fdata_t *u = f->u;
|
||||
|
||||
u->shape = 0;
|
||||
u->diskshape = H5S_ALL;
|
||||
u->memshape = H5S_ALL;
|
||||
u->viewstart = -1;
|
||||
u->viewend = -1;
|
||||
u->pnparticles =
|
||||
(h5_int64_t*) malloc (f->nprocs * sizeof (h5_int64_t));
|
||||
if (u->pnparticles == NULL) {
|
||||
return HANDLE_H5_NOMEM_ERR( f );
|
||||
}
|
||||
size_t size = f->nprocs * sizeof (h5_int64_t);
|
||||
TRY ( u->pnparticles = _h5_alloc ( f, NULL, size ) );
|
||||
|
||||
return H5_SUCCESS;
|
||||
}
|
||||
|
||||
@@ -95,27 +90,21 @@ static h5_int64_t
|
||||
_h5b_open_file (
|
||||
h5_file_t *f /*!< IN: file handle */
|
||||
) {
|
||||
struct h5b_fdata *b;
|
||||
h5b_fdata_t *b;
|
||||
|
||||
if ( (f == 0) || (f->file == 0) ) return HANDLE_H5_BADFD_ERR( f );
|
||||
if ( f->b ) return H5_SUCCESS;
|
||||
|
||||
f->b = (struct h5b_fdata*) malloc( sizeof (*f->b) );
|
||||
if ( f->b == NULL ) {
|
||||
return HANDLE_H5_NOMEM_ERR( f );
|
||||
}
|
||||
TRY ( f->b = (h5b_fdata_t*) _h5_alloc ( f, NULL, sizeof (*f->b) ) );
|
||||
|
||||
b = f->b;
|
||||
memset ( b, 0, sizeof (*b) );
|
||||
b->user_layout = (struct h5b_partition*) malloc (
|
||||
f->nprocs * sizeof (b->user_layout[0]) );
|
||||
if ( b->user_layout == NULL ) {
|
||||
return HANDLE_H5_NOMEM_ERR( f );
|
||||
}
|
||||
b->write_layout = (struct h5b_partition*) malloc (
|
||||
f->nprocs * sizeof (b->write_layout[0]) );
|
||||
if ( b->write_layout == NULL ) {
|
||||
return HANDLE_H5_NOMEM_ERR( f );
|
||||
}
|
||||
|
||||
size_t size = f->nprocs * sizeof (b->user_layout[0]);
|
||||
TRY ( b->user_layout = _h5_alloc ( f, NULL, size ) );
|
||||
size = f->nprocs * sizeof (b->write_layout[0]);
|
||||
TRY ( b->write_layout = _h5_alloc ( f, NULL, size ) );
|
||||
|
||||
b->step_idx = -1;
|
||||
b->blockgroup = -1;
|
||||
b->shape = -1;
|
||||
@@ -147,12 +136,7 @@ _h5_open_file (
|
||||
h5_info ( f, "Opening file %s.", filename );
|
||||
|
||||
TRY ( _h5_set_errorhandler ( f, H5E_DEFAULT, _h5_error_handler, NULL ) );
|
||||
|
||||
f->prefix_step_name = strdup ( H5PART_GROUPNAME_STEP );
|
||||
if( f->prefix_step_name == NULL )
|
||||
return HANDLE_H5_NOMEM_ERR( f );
|
||||
|
||||
f->width_step_idx = 0;
|
||||
TRY ( h5_set_stepname_fmt ( f, H5PART_GROUPNAME_STEP, 0 ) );
|
||||
|
||||
f->xfer_prop = f->create_prop = f->access_prop = H5P_DEFAULT;
|
||||
|
||||
@@ -162,9 +146,8 @@ _h5_open_file (
|
||||
|
||||
#ifdef PARALLEL_IO
|
||||
f->comm = comm;
|
||||
if (MPI_Comm_size (comm, &f->nprocs) != MPI_SUCCESS) {
|
||||
return HANDLE_MPI_COMM_SIZE_ERR;
|
||||
}
|
||||
TRY ( _h5_mpi_comm_size ( f, comm, &f->nprocs ) );
|
||||
|
||||
if (MPI_Comm_rank (comm, &f->myproc) != MPI_SUCCESS) {
|
||||
return HANDLE_MPI_COMM_RANK_ERR;
|
||||
}
|
||||
@@ -176,9 +159,7 @@ _h5_open_file (
|
||||
/* ks: IBM_large_block_io */
|
||||
MPI_Info_create(&info);
|
||||
MPI_Info_set(info, "IBM_largeblock_io", "true" );
|
||||
if (H5Pset_fapl_mpio (f->access_prop, comm, info) < 0) {
|
||||
return HANDLE_H5P_SET_FAPL_MPIO_ERR;
|
||||
}
|
||||
TRY ( _h5_set_fapl_mpio_property ( f->access_prop, comm, info ) );
|
||||
MPI_Info_free(&info);
|
||||
|
||||
TRY ( f->access_prop = _h5_create_property ( f, H5P_FILE_ACCESS ) );
|
||||
@@ -220,7 +201,10 @@ _h5_open_file (
|
||||
}
|
||||
}
|
||||
else {
|
||||
return HANDLE_H5_FILE_ACCESS_TYPE_ERR ( f, flags );
|
||||
return h5_error (
|
||||
f,
|
||||
H5_ERR_INVAL,
|
||||
"Invalid file access mode \"%d\".", flags);
|
||||
}
|
||||
|
||||
if (f->file < 0)
|
||||
@@ -268,9 +252,6 @@ h5_open_file (
|
||||
f->__funcname = funcname;
|
||||
if ( _h5_open_file( f, filename, flags, comm ) < 0 ) {
|
||||
if (f != NULL ) {
|
||||
if (f->prefix_step_name) {
|
||||
free (f->prefix_step_name);
|
||||
}
|
||||
if (f->u->pnparticles != NULL) {
|
||||
free (f->u->pnparticles);
|
||||
}
|
||||
@@ -370,9 +351,6 @@ h5_close_file (
|
||||
TRY( _h5_close_group ( f, f->root_gid ) );
|
||||
TRY( _h5_close_file ( f, f->file ) );
|
||||
|
||||
if (f->prefix_step_name) {
|
||||
free (f->prefix_step_name);
|
||||
}
|
||||
free( f );
|
||||
|
||||
return H5_SUCCESS;
|
||||
@@ -388,16 +366,16 @@ h5_close_file (
|
||||
|
||||
\return \c H5_SUCCESS or error code
|
||||
*/
|
||||
h5_int64_t
|
||||
h5_err_t
|
||||
h5_set_stepname_fmt (
|
||||
h5_file_t *f,
|
||||
const char *name,
|
||||
const h5_int64_t width
|
||||
) {
|
||||
f->prefix_step_name = strdup ( name );
|
||||
if( f->prefix_step_name == NULL ) {
|
||||
return HANDLE_H5_NOMEM_ERR( f );
|
||||
}
|
||||
strncpy (
|
||||
f->prefix_step_name,
|
||||
name,
|
||||
sizeof ( f->prefix_step_name ) - 1 );
|
||||
f->width_step_idx = (int)width;
|
||||
|
||||
return H5_SUCCESS;
|
||||
|
||||
+10
-10
@@ -102,23 +102,22 @@ _h5_write (
|
||||
extend dataset?
|
||||
*/
|
||||
} else {
|
||||
TRY( (dataspace_id = _h5_create_dataset_space (
|
||||
TRY ( dataspace_id = _h5_create_space (
|
||||
f,
|
||||
ds_info->rank,
|
||||
ds_info->dims,
|
||||
ds_info->maxdims ) ) );
|
||||
TRY( (dataset_id = _h5_create_dataset (
|
||||
ds_info->maxdims ) );
|
||||
TRY ( dataset_id = _h5_create_dataset (
|
||||
f,
|
||||
loc_id,
|
||||
ds_info->name,
|
||||
*ds_info->type_id,
|
||||
dataspace_id,
|
||||
ds_info->create_prop ) ) );
|
||||
ds_info->create_prop ) );
|
||||
}
|
||||
TRY( (memspace_id = (*set_memspace)( f, 0 ) ) );
|
||||
TRY( (diskspace_id = (*set_diskspace)( f, dataspace_id ) ) );
|
||||
|
||||
TRY( _h5_write_dataset (
|
||||
TRY ( memspace_id = (*set_memspace)( f, 0 ) );
|
||||
TRY ( diskspace_id = (*set_diskspace)( f, dataspace_id ) );
|
||||
TRY ( _h5_write_dataset (
|
||||
f,
|
||||
dataset_id,
|
||||
*ds_info->type_id,
|
||||
@@ -126,8 +125,9 @@ _h5_write (
|
||||
diskspace_id,
|
||||
f->xfer_prop,
|
||||
data ) );
|
||||
|
||||
TRY( _h5_close_dataset( f, dataset_id ) );
|
||||
TRY ( _h5_close_dataspace ( f, diskspace_id ) );
|
||||
TRY ( _h5_close_dataspace ( f, memspace_id ) );
|
||||
TRY ( _h5_close_dataset( f, dataset_id ) );
|
||||
|
||||
f->empty = 0;
|
||||
|
||||
|
||||
@@ -11,7 +11,10 @@ _h5_alloc (
|
||||
h5_debug ( f, "Allocating %ld bytes.", size );
|
||||
ptr = realloc ( ptr, size );
|
||||
if ( ptr == NULL ) {
|
||||
HANDLE_H5_NOMEM_ERR( f );
|
||||
h5_error (
|
||||
f,
|
||||
H5_ERR_NOMEM,
|
||||
"Out of memory." );
|
||||
return (void*)(-1);
|
||||
}
|
||||
return ptr;
|
||||
|
||||
@@ -85,13 +85,11 @@ struct h5_file {
|
||||
hid_t xfer_prop; /* file transfer properties */
|
||||
hid_t create_prop; /* file create properties */
|
||||
hid_t access_prop; /* file access properties */
|
||||
|
||||
|
||||
hid_t root_gid; /* id of root group */
|
||||
hid_t step_gid; /* id of current step */
|
||||
|
||||
/* step internal data */
|
||||
char *prefix_step_name; /* Prefix of step name */
|
||||
char prefix_step_name[256]; /* Prefix of step name */
|
||||
int width_step_idx; /* pad step index with 0 up to this */
|
||||
char step_name[128]; /* full step name */
|
||||
h5_int64_t step_idx; /* step index */
|
||||
@@ -114,4 +112,7 @@ typedef enum h5_oid h5_oid_t;
|
||||
|
||||
#define H5_MAX_VERTICES_PER_ELEM H5_OID_TETRAHEDRON
|
||||
|
||||
#define H5_TRIANGLE_MESH (H5_OID_TRIANGLE)
|
||||
#define H5_TETRAHEDRAL_MESH (H5_OID_TETRAHEDRON)
|
||||
|
||||
#endif
|
||||
|
||||
@@ -7,13 +7,16 @@ struct smap {
|
||||
h5_id_t *items;
|
||||
};
|
||||
|
||||
struct h5_idmap_el {
|
||||
h5_id_t global_id;
|
||||
h5_id_t local_id;
|
||||
};
|
||||
typedef struct h5_idmap_el h5_idmap_el_t;
|
||||
|
||||
struct idmap {
|
||||
h5_size_t size; /* allocated space in number of items */
|
||||
h5_size_t num_items; /* stored items */
|
||||
struct {
|
||||
h5_id_t global_id;
|
||||
h5_id_t local_id;
|
||||
} *items;
|
||||
h5_idmap_el_t *items;
|
||||
};
|
||||
|
||||
|
||||
|
||||
@@ -118,19 +118,15 @@ _h5t_read_boundaryfaces (
|
||||
|
||||
const char * const dataset_name = "Faces";
|
||||
hid_t dataset_id;
|
||||
TRY( dataset_id = _h5_open_dataset ( f, boundary->gid, dataset_name ) );
|
||||
TRY( diskspace_id = _h5_get_dataset_space ( f, dataset_id ) );
|
||||
h5_size_t num_faces;
|
||||
TRY ( dataset_id = _h5_open_dataset ( f, boundary->gid, dataset_name ) );
|
||||
TRY ( diskspace_id = _h5_get_dataset_space ( f, dataset_id ) );
|
||||
TRY ( num_faces = _h5_get_npoints_of_space ( f, diskspace_id ) );
|
||||
TRY ( _h5_close_dataspace( f, diskspace_id ) );
|
||||
TRY ( _h5_close_dataset( f, dataset_id ) );
|
||||
TRY ( h5t_add_num_boundaryfaces ( f, num_faces ) );
|
||||
|
||||
h5_id_t num_faces = H5Sget_simple_extent_npoints ( diskspace_id );
|
||||
if ( num_faces < 0 )
|
||||
return HANDLE_H5S_GET_SIMPLE_EXTENT_NPOINTS_ERR ( f );
|
||||
|
||||
TRY( _h5_close_dataspace( f, diskspace_id ) );
|
||||
TRY( _h5_close_dataset( f, dataset_id ) );
|
||||
|
||||
h5t_add_num_boundaryfaces ( f, num_faces );
|
||||
|
||||
TRY( _h5_read_dataset (
|
||||
TRY ( _h5_read_dataset (
|
||||
f,
|
||||
dataset_id,
|
||||
H5T_NATIVE_INT32,
|
||||
@@ -138,7 +134,7 @@ _h5t_read_boundaryfaces (
|
||||
H5S_ALL,
|
||||
f->xfer_prop,
|
||||
boundary->faces ) );
|
||||
TRY( _h5_close_dataset( f, dataset_id ) );
|
||||
TRY ( _h5_close_dataset( f, dataset_id ) );
|
||||
|
||||
return H5_SUCCESS;
|
||||
}
|
||||
@@ -201,37 +197,26 @@ h5t_add_num_boundaryfaces (
|
||||
const h5_id_t num_faces
|
||||
) {
|
||||
struct h5t_fdata *t = f->t;
|
||||
boundary_t *boundary = &t->boundary;
|
||||
|
||||
boundary->num_faces = realloc (
|
||||
boundary->num_faces,
|
||||
t->num_levels*sizeof(boundary->num_faces[0]) );
|
||||
boundary->num_faces_on_level = realloc (
|
||||
boundary->num_faces_on_level,
|
||||
t->num_levels*sizeof(boundary->num_faces_on_level[0]) );
|
||||
boundary->faces = realloc (
|
||||
boundary->faces,
|
||||
num_faces*sizeof(boundary->faces[0]) );
|
||||
boundary->lfaces = realloc (
|
||||
boundary->lfaces,
|
||||
num_faces*sizeof(boundary->lfaces[0]) );
|
||||
if ( boundary->num_faces == NULL ||
|
||||
boundary->num_faces_on_level == NULL ||
|
||||
boundary->faces == NULL ||
|
||||
boundary->lfaces == NULL ) {
|
||||
return HANDLE_H5_NOMEM_ERR ( f );
|
||||
}
|
||||
memset ( boundary->num_faces,
|
||||
0, t->num_levels*sizeof(boundary->num_faces[0]) );
|
||||
memset ( boundary->num_faces_on_level,
|
||||
0, t->num_levels*sizeof(boundary->num_faces_on_level[0]) );
|
||||
memset ( boundary->faces,
|
||||
-1, num_faces*sizeof(boundary->faces[0]) );
|
||||
memset (
|
||||
boundary->lfaces,
|
||||
0, num_faces*sizeof(boundary->lfaces[0]) );
|
||||
boundary->num_faces[0] = num_faces;
|
||||
boundary->last_accessed_face = -1;
|
||||
boundary_t *b = &t->boundary;
|
||||
|
||||
size_t size = t->num_levels * sizeof(b->num_faces[0]);
|
||||
TRY ( b->num_faces = _h5_alloc ( f, b->num_faces, size ) );
|
||||
memset ( b->num_faces, 0, size );
|
||||
|
||||
size = t->num_levels * sizeof(b->num_faces_on_level[0]);
|
||||
TRY ( b->num_faces_on_level = _h5_alloc ( f, b->num_faces_on_level, size ) );
|
||||
memset ( b->num_faces_on_level, 0, size );
|
||||
|
||||
size = num_faces * sizeof(b->faces[0]);
|
||||
TRY ( b->faces = _h5_alloc ( f, b->faces, size ) );
|
||||
memset ( b->faces, -1, size );
|
||||
|
||||
size = num_faces*sizeof(b->lfaces[0]);
|
||||
TRY ( b->lfaces = _h5_alloc ( f, b->lfaces, size ) );
|
||||
memset ( b->lfaces, 0, size );
|
||||
|
||||
b->num_faces[0] = num_faces;
|
||||
b->last_accessed_face = -1;
|
||||
|
||||
return H5_SUCCESS;
|
||||
}
|
||||
@@ -254,8 +239,7 @@ h5t_store_boundaryface (
|
||||
struct h5t_fdata *t = f->t;
|
||||
|
||||
if ( t->vertices == NULL ) {
|
||||
h5_err_t h5err = _h5t_read_mesh ( f );
|
||||
if ( h5err < 0 ) return h5err;
|
||||
TRY ( _h5t_read_mesh ( f ) );
|
||||
}
|
||||
|
||||
switch ( t->mesh_type ) {
|
||||
@@ -315,7 +299,7 @@ h5t_store_boundaryface_local_id (
|
||||
switch ( t->mesh_type ) {
|
||||
case H5_OID_TETRAHEDRON: {
|
||||
h5_id_t local_tet_id = local_fid & H5_TET_MASK;
|
||||
if ( t->elems.tets[local_tet_id].parent_eid != -1 ) {
|
||||
if ( t->elems.tets[local_tet_id].global_parent_eid != -1 ) {
|
||||
return _h5t_error_store_boundaryface_local_id (
|
||||
f,
|
||||
local_fid );
|
||||
|
||||
@@ -25,22 +25,6 @@ _h5t_handle_get_global_eid_err (
|
||||
}
|
||||
}
|
||||
|
||||
h5_err_t
|
||||
_h5t_handle_get_local_eid_err (
|
||||
h5_file_t *f,
|
||||
const h5_id_t * const local_vids
|
||||
) {
|
||||
struct h5t_fdata *t = f->t;
|
||||
switch ( t->mesh_type ) {
|
||||
case H5_OID_TETRAHEDRON:
|
||||
return _h5t_error_local_tet_id_nexist ( f, local_vids );
|
||||
case H5_OID_TRIANGLE:
|
||||
return _h5t_error_local_triangle_id_nexist ( f, local_vids );
|
||||
default:
|
||||
return h5_error_internal( f, __FILE__, __func__, __LINE__ );
|
||||
}
|
||||
}
|
||||
|
||||
h5_err_t
|
||||
_h5t_error_illegal_object_type (
|
||||
h5_file_t * const f,
|
||||
|
||||
@@ -8,12 +8,6 @@ _h5t_handle_get_global_eid_err (
|
||||
const h5_id_t * const global_vids
|
||||
);
|
||||
|
||||
h5_err_t
|
||||
_h5t_handle_get_local_eid_err (
|
||||
h5_file_t *f,
|
||||
const h5_id_t * const local_vids
|
||||
);
|
||||
|
||||
h5_err_t
|
||||
_h5t_error_illegal_object_type (
|
||||
h5_file_t * const f,
|
||||
|
||||
@@ -39,6 +39,7 @@ h5t_get_num_levels (
|
||||
struct h5t_fdata *t = f->t;
|
||||
hid_t dataset_id;
|
||||
hid_t diskspace_id;
|
||||
hssize_t size;
|
||||
|
||||
if ( t->num_levels >= 0 ) return t->num_levels;
|
||||
if ( t->cur_mesh < 0 ) {
|
||||
@@ -47,14 +48,10 @@ h5t_get_num_levels (
|
||||
if ( t->mesh_gid < 0 ) {
|
||||
TRY( _h5t_open_mesh_group ( f ) );
|
||||
}
|
||||
TRY( dataset_id = _h5_open_dataset ( f, t->mesh_gid, "NumVertices" ) );
|
||||
TRY( diskspace_id = _h5_get_dataset_space ( f, dataset_id ) );
|
||||
|
||||
hssize_t size = H5Sget_simple_extent_npoints ( diskspace_id );
|
||||
if ( size < 0 )
|
||||
return HANDLE_H5S_GET_SIMPLE_EXTENT_NPOINTS_ERR ( f );
|
||||
|
||||
TRY( _h5_close_dataspace( f, diskspace_id ) );
|
||||
TRY ( dataset_id = _h5_open_dataset ( f, t->mesh_gid, "NumVertices" ) );
|
||||
TRY ( diskspace_id = _h5_get_dataset_space ( f, dataset_id ) );
|
||||
TRY ( size = _h5_get_npoints_of_space ( f, diskspace_id ) );
|
||||
TRY ( _h5_close_dataspace( f, diskspace_id ) );
|
||||
|
||||
t->num_levels = size;
|
||||
return size;
|
||||
|
||||
+139
-48
@@ -3,6 +3,15 @@
|
||||
#include "h5_core/h5_core.h"
|
||||
#include "h5_core/h5_core_private.h"
|
||||
|
||||
/*
|
||||
Mapping of global to local id's:
|
||||
|
||||
Before adding a new level or closing the mesh, we must define global id's
|
||||
for the vertices and elements. This we have to do only for the last stored
|
||||
level.
|
||||
*/
|
||||
|
||||
|
||||
/*!
|
||||
Compare to vertices given by their 3-dimensional coordinates
|
||||
*/
|
||||
@@ -13,7 +22,7 @@ _cmp_vertices (
|
||||
) {
|
||||
int i;
|
||||
for ( i = 0; i < 3; i++ ) {
|
||||
int diff = _h5_fcmp ( P0[i], P1[i], 10 );
|
||||
h5_int64_t diff = _h5_fcmp ( P0[i], P1[i], 10 );
|
||||
if ( diff < 0 ) return -1;
|
||||
else if ( diff > 0 ) return 1;
|
||||
}
|
||||
@@ -37,19 +46,22 @@ _qsort_cmp_vertices (
|
||||
|
||||
|
||||
/*!
|
||||
We assume that the number of vertices is already known.
|
||||
Sort vertices. Store local id's in a sorted array so we can run a
|
||||
binary search.
|
||||
*/
|
||||
h5_err_t
|
||||
_h5t_sort_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;
|
||||
|
||||
struct h5t_fdata *t = f->t;
|
||||
h5_id_t num_vertices = t->num_vertices[t->num_levels-1];
|
||||
|
||||
h5_id_t i;
|
||||
for ( i = 0; i < num_vertices; i++ ) {
|
||||
t->sorted_lvertices.items[i] = i;
|
||||
for ( ; local_vid < num_vertices; local_vid++ ) {
|
||||
t->sorted_lvertices.items[local_vid] = local_vid;
|
||||
}
|
||||
t->sorted_lvertices.num_items = num_vertices;
|
||||
|
||||
@@ -63,7 +75,13 @@ _h5t_sort_vertices (
|
||||
return H5_SUCCESS;
|
||||
}
|
||||
|
||||
/*!
|
||||
Search vertex in the sorted array of vertices. The vertex is given by its
|
||||
coordinates.
|
||||
|
||||
\return index of vertex in the sorted array or the negative value
|
||||
of the index where it should be inserted.
|
||||
*/
|
||||
static h5_id_t
|
||||
_search_vertex (
|
||||
h5_file_t * const f,
|
||||
@@ -78,7 +96,7 @@ _search_vertex (
|
||||
|
||||
h5_id_t local_vid = t->sorted_lvertices.items[mid];
|
||||
h5_float64_t *P1 = t->vertices[local_vid].P;
|
||||
int diff = _cmp_vertices ( P0, P1 );
|
||||
int diff = _cmp_vertices ( P0, P1 );
|
||||
if ( diff < 0 )
|
||||
high = mid - 1;
|
||||
else if ( diff > 0 )
|
||||
@@ -89,6 +107,12 @@ _search_vertex (
|
||||
return -(low+1); // not found
|
||||
}
|
||||
|
||||
/*!
|
||||
Return local vertex id of a vertex given by its coordinates.
|
||||
|
||||
\return local vertex id if found
|
||||
\return negativ value
|
||||
*/
|
||||
h5_id_t
|
||||
_h5t_get_local_vid (
|
||||
h5_file_t * const f,
|
||||
@@ -96,18 +120,16 @@ _h5t_get_local_vid (
|
||||
) {
|
||||
struct h5t_fdata *t = f->t;
|
||||
|
||||
h5_id_t local_vid;
|
||||
TRY2( local_vid = _search_vertex ( f, P ), fail );
|
||||
return t->sorted_lvertices.items[local_vid];
|
||||
fail:
|
||||
return H5_ERR;
|
||||
h5_id_t idx;
|
||||
idx = _search_vertex ( f, P );
|
||||
if ( idx < 0 ) return idx;
|
||||
return t->sorted_lvertices.items[idx];
|
||||
}
|
||||
|
||||
/*!
|
||||
Returns the local vertex id of the i-th vertex of an element. For triangles
|
||||
i is in [0,1,2], for tetraheda i is in [0,1,2,3].
|
||||
*/
|
||||
|
||||
static h5_id_t
|
||||
_get_local_vid_of_elem (
|
||||
h5_file_t * f,
|
||||
@@ -121,25 +143,25 @@ _get_local_vid_of_elem (
|
||||
|
||||
switch ( t->mesh_type ) {
|
||||
case H5_OID_TETRAHEDRON: {
|
||||
local_vid = t->elems_data.tets[local_eid].vids[ith_vertex];
|
||||
local_vid = t->elems_data.tets[local_eid].local_vids[ith_vertex];
|
||||
if ( local_vid == -1 ) {
|
||||
global_vid =
|
||||
t->elems.tets[local_eid].vids[ith_vertex];
|
||||
t->elems.tets[local_eid].global_vids[ith_vertex];
|
||||
local_vid = _h5_search_idmap (
|
||||
&t->map_vertex_g2l, global_vid );
|
||||
t->elems_data.tets[local_eid].vids[ith_vertex] =
|
||||
t->elems_data.tets[local_eid].local_vids[ith_vertex] =
|
||||
local_vid;
|
||||
}
|
||||
break;
|
||||
}
|
||||
case H5_OID_TRIANGLE: {
|
||||
local_vid = t->elems_data.tris[local_eid].vids[ith_vertex];
|
||||
local_vid = t->elems_data.tris[local_eid].local_vids[ith_vertex];
|
||||
if ( local_vid == -1 ) {
|
||||
global_vid =
|
||||
t->elems.tris[local_eid].vids[ith_vertex];
|
||||
t->elems.tris[local_eid].global_vids[ith_vertex];
|
||||
local_vid = _h5_search_idmap (
|
||||
&t->map_vertex_g2l, global_vid );
|
||||
t->elems_data.tris[local_eid].vids[ith_vertex] =
|
||||
t->elems_data.tris[local_eid].local_vids[ith_vertex] =
|
||||
local_vid;
|
||||
}
|
||||
break;
|
||||
@@ -266,16 +288,16 @@ h5_err_t
|
||||
_h5t_sort_elems (
|
||||
h5_file_t *f
|
||||
) {
|
||||
|
||||
struct h5t_fdata *t = f->t;
|
||||
h5_size_t num_elems;
|
||||
TRY( num_elems = h5t_get_num_elems_total ( f, f->myproc, -1 ) );
|
||||
h5t_fdata_t *t = f->t;
|
||||
if ( t->num_levels <= 0 ) return H5_SUCCESS;
|
||||
h5_id_t local_eid = t->cur_level > 0 ? t->num_elems[t->cur_level-1] : 0;
|
||||
h5_size_t num_elems = t->num_elems[t->num_levels-1];
|
||||
|
||||
int k;
|
||||
h5_id_t i;
|
||||
for ( k = 0; k < 2; k++ ) {
|
||||
TRY( _h5_alloc_smap ( f, &t->sorted_elems[k], num_elems ) );
|
||||
for ( i = 0; i < num_elems; i++ ) {
|
||||
for ( i = local_eid; i < num_elems; i++ ) {
|
||||
t->sorted_elems[k].items[i] = i;
|
||||
}
|
||||
t->sorted_elems[k].num_items = num_elems;
|
||||
@@ -373,7 +395,7 @@ _search_elem (
|
||||
register int mid = (low + high) / 2;
|
||||
|
||||
h5_id_t local_eid = t->sorted_elems[0].items[mid];
|
||||
h5_id_t *elem2 = t->elems_data.tets[local_eid].vids;
|
||||
h5_id_t *elem2 = t->elems_data.tets[local_eid].local_vids;
|
||||
int diff = _vcmp_elems ( f, elem1, elem2 );
|
||||
if ( diff < 0 )
|
||||
high = mid - 1;
|
||||
@@ -382,11 +404,20 @@ _search_elem (
|
||||
else
|
||||
return mid; // found
|
||||
}
|
||||
switch ( t->mesh_type ) {
|
||||
case H5_OID_TETRAHEDRON:
|
||||
return _h5t_error_local_tet_id_nexist ( f, local_vids );
|
||||
case H5_OID_TRIANGLE:
|
||||
return _h5t_error_local_triangle_id_nexist ( f, local_vids );
|
||||
default:
|
||||
return h5_error_internal( f, __FILE__, __func__, __LINE__ );
|
||||
}
|
||||
return -(low+1); // not found
|
||||
}
|
||||
|
||||
/*!
|
||||
Get local id of elem given by local vertex id's
|
||||
Get local element id given by its local vertex id's.
|
||||
|
||||
*/
|
||||
h5_id_t
|
||||
h5t_get_local_eid (
|
||||
@@ -396,10 +427,8 @@ h5t_get_local_eid (
|
||||
struct h5t_fdata *t = f->t;
|
||||
|
||||
h5_id_t local_eid;
|
||||
TRY2( local_eid = _search_elem ( f, local_vids ), fail );
|
||||
TRY ( local_eid = _search_elem ( f, local_vids ) );
|
||||
return t->sorted_elems[0].items[local_eid];
|
||||
fail:
|
||||
return _h5t_handle_get_local_eid_err ( f, local_vids );
|
||||
}
|
||||
|
||||
/*!
|
||||
@@ -427,7 +456,7 @@ h5t_map_local_vid2global (
|
||||
|
||||
if ( local_vid < 0 || local_vid > t->num_vertices[t->num_levels-1] )
|
||||
return HANDLE_H5_OUT_OF_RANGE_ERR ( f, "vertex", local_vid );
|
||||
return t->vertices[local_vid].vid;
|
||||
return t->vertices[local_vid].global_vid;
|
||||
}
|
||||
|
||||
h5_err_t
|
||||
@@ -464,12 +493,12 @@ h5t_map_local_eid2global (
|
||||
case H5_OID_TETRAHEDRON:
|
||||
if ( local_eid < 0 || local_eid > t->num_elems[t->num_levels-1] )
|
||||
return HANDLE_H5_OUT_OF_RANGE_ERR ( f, "tet", local_eid );
|
||||
return t->elems.tets[local_eid].eid;
|
||||
return t->elems.tets[local_eid].global_eid;
|
||||
case H5_OID_TRIANGLE:
|
||||
if ( local_eid < 0 || local_eid > t->num_elems[t->num_levels-1] )
|
||||
return HANDLE_H5_OUT_OF_RANGE_ERR (
|
||||
f, "triangle", local_eid );
|
||||
return t->elems.tris[local_eid].eid;
|
||||
return t->elems.tris[local_eid].global_eid;
|
||||
default:
|
||||
return h5_error_internal ( f, __FILE__, __func__, __LINE__ );
|
||||
}
|
||||
@@ -487,15 +516,15 @@ h5t_get_global_eid (
|
||||
h5_id_t local_vids[H5_MAX_VERTICES_PER_ELEM];
|
||||
|
||||
if ( t->vertices == NULL ) {
|
||||
TRY( _h5t_read_mesh ( f ) );
|
||||
TRY ( _h5t_read_mesh ( f ) );
|
||||
}
|
||||
TRY2( h5t_map_global_vids2local (
|
||||
TRY2 ( h5t_map_global_vids2local (
|
||||
f,
|
||||
global_vids,
|
||||
t->mesh_type,
|
||||
local_vids ), fail );
|
||||
h5_id_t local_eid;
|
||||
TRY2( local_eid = h5t_get_local_eid ( f, local_vids ), fail );
|
||||
TRY2 ( local_eid = h5t_get_local_eid ( f, local_vids ), fail );
|
||||
return h5t_map_local_eid2global ( f, local_eid );
|
||||
fail:
|
||||
return _h5t_handle_get_global_eid_err ( f, global_vids );
|
||||
@@ -517,7 +546,7 @@ _search_ith_vertex_in_elem (
|
||||
register int mid = (low + high) / 2;
|
||||
|
||||
h5_id_t local_eid = t->sorted_elems[i].items[mid];
|
||||
h5_id_t local_vid2 = t->elems_data.tets[local_eid].vids[i];
|
||||
h5_id_t local_vid2 = t->elems_data.tets[local_eid].local_vids[i];
|
||||
h5_float64_t *vertex2 = t->vertices[local_vid2].P;
|
||||
int diff = _cmp_vertices ( vertex1, vertex2 );
|
||||
|
||||
@@ -540,7 +569,7 @@ _tetm_contain_triangle (
|
||||
) {
|
||||
struct h5t_fdata *t = f->t;
|
||||
|
||||
h5_id_t *local_vids_of_elem = t->elems_data.tets[local_eid].vids;
|
||||
h5_id_t *local_vids_of_elem = t->elems_data.tets[local_eid].local_vids;
|
||||
if ( i == 0 &&
|
||||
local_vids[1] == local_vids_of_elem[1] &&
|
||||
local_vids[2] == local_vids_of_elem[2]
|
||||
@@ -636,16 +665,14 @@ h5t_get_global_triangle_id (
|
||||
struct h5t_fdata *t = f->t;
|
||||
|
||||
if ( t->vertices == NULL ) {
|
||||
h5_err_t h5err = _h5t_read_mesh ( f );
|
||||
if ( h5err < 0 ) return h5err;
|
||||
TRY ( _h5t_read_mesh ( f ) );
|
||||
}
|
||||
|
||||
switch ( t->mesh_type ) {
|
||||
case H5_OID_TETRAHEDRON: {
|
||||
h5_id_t local_vids[3];
|
||||
h5_err_t h5err = h5t_map_global_vids2local (
|
||||
f, global_vids, 3, local_vids );
|
||||
if ( h5err < 0 ) return h5err;
|
||||
TRY ( h5t_map_global_vids2local (
|
||||
f, global_vids, 3, local_vids ) );
|
||||
h5_id_t local_tid = h5t_get_local_triangle_id ( f, local_vids );
|
||||
if ( local_tid < 0 )
|
||||
return _h5t_error_global_triangle_id_nexist (
|
||||
@@ -655,7 +682,7 @@ h5t_get_global_triangle_id (
|
||||
case H5_OID_TRIANGLE:
|
||||
return h5t_get_global_eid ( f, global_vids );
|
||||
default:
|
||||
return h5_error_internal ( f, __FILE__, __func__, __LINE__ );
|
||||
return h5_error_internal ( f, __FILE__, __func__, __LINE__ );
|
||||
}
|
||||
}
|
||||
|
||||
@@ -671,8 +698,7 @@ h5t_get_local_triangle_id (
|
||||
|
||||
switch ( t->mesh_type ) {
|
||||
case H5_OID_TETRAHEDRON: {
|
||||
h5_err_t h5err = _h5t_read_mesh ( f );
|
||||
if ( h5err < 0 ) return h5err;
|
||||
TRY ( _h5t_read_mesh ( f ) );
|
||||
h5_id_t local_tid = _tetm_search_triangle ( f, local_vids );
|
||||
if ( local_tid == -1 ) {
|
||||
return _h5t_error_local_triangle_id_nexist( f, local_vids );
|
||||
@@ -682,10 +708,18 @@ h5t_get_local_triangle_id (
|
||||
case H5_OID_TRIANGLE:
|
||||
return h5t_get_local_eid ( f, local_vids );
|
||||
default:
|
||||
return h5_error_internal ( f, __FILE__, __func__, __LINE__ );
|
||||
return h5_error_internal ( f, __FILE__, __func__, __LINE__ );
|
||||
}
|
||||
}
|
||||
|
||||
/*!
|
||||
Get local element id for an element given by its global id.
|
||||
|
||||
\param[in] f File handle
|
||||
\param[in] global_eid Global element id
|
||||
|
||||
\return Local element id or error code.
|
||||
*/
|
||||
h5_id_t
|
||||
h5t_map_global_eid2local (
|
||||
h5_file_t * const f,
|
||||
@@ -750,6 +784,63 @@ h5t_map_local_triangle_id2global (
|
||||
case H5_OID_TRIANGLE:
|
||||
return h5t_map_local_eid2global ( f, local_tri_id );
|
||||
default:
|
||||
return h5_error_internal ( f, __FILE__, __func__, __LINE__ );
|
||||
return h5_error_internal ( f, __FILE__, __func__, __LINE__ );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
h5_err_t
|
||||
_h5t_rebuild_global_2_local_map_of_vertices (
|
||||
h5_file_t * const f
|
||||
) {
|
||||
struct h5t_fdata *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_vid;
|
||||
t->map_vertex_g2l.items[local_vid].local_id = local_vid;
|
||||
t->map_vertex_g2l.num_items++;
|
||||
}
|
||||
_h5_sort_idmap ( &t->map_vertex_g2l );
|
||||
|
||||
return H5_SUCCESS;
|
||||
}
|
||||
|
||||
h5_err_t
|
||||
_h5t_rebuild_global_2_local_map_of_elems (
|
||||
h5_file_t * const f
|
||||
) {
|
||||
h5t_fdata_t *t = f->t;
|
||||
if ( t->num_levels <= 0 ) return H5_SUCCESS;
|
||||
h5_id_t local_eid = t->cur_level > 0 ? t->num_elems[t->cur_level-1] : 0;
|
||||
h5_id_t num_elems = t->num_elems[t->num_levels-1];
|
||||
h5_idmap_el_t *item = &t->map_elem_g2l.items[local_eid];
|
||||
|
||||
switch ( t->mesh_type ) {
|
||||
case H5_OID_TETRAHEDRON: {
|
||||
h5_tet_t *elem = &t->elems.tets[local_eid];
|
||||
for ( ; local_eid < num_elems; local_eid++, item++, elem++ ) {
|
||||
item->global_id = elem->global_eid;
|
||||
item->local_id = local_eid;
|
||||
t->map_elem_g2l.num_items++;
|
||||
}
|
||||
break;
|
||||
}
|
||||
case H5_OID_TRIANGLE: {
|
||||
h5_triangle_t *elem = &t->elems.tris[local_eid];
|
||||
for ( ; local_eid < num_elems; local_eid++, item++, elem++ ) {
|
||||
item->global_id = elem->global_eid;
|
||||
item->local_id = local_eid;
|
||||
t->map_elem_g2l.num_items++;
|
||||
}
|
||||
break;
|
||||
}
|
||||
default:
|
||||
return h5_error_internal( f, __FILE__, __func__, __LINE__ );
|
||||
}
|
||||
_h5_sort_idmap ( &t->map_elem_g2l );
|
||||
|
||||
return H5_SUCCESS;
|
||||
}
|
||||
|
||||
@@ -25,4 +25,13 @@ _h5t_sort_elems (
|
||||
h5_file_t * const f
|
||||
);
|
||||
|
||||
h5_err_t
|
||||
_h5t_rebuild_global_2_local_map_of_vertices (
|
||||
h5_file_t * const f
|
||||
);
|
||||
|
||||
h5_err_t
|
||||
_h5t_rebuild_global_2_local_map_of_elems (
|
||||
h5_file_t * const f
|
||||
);
|
||||
#endif
|
||||
|
||||
+15
-18
@@ -62,8 +62,8 @@ _create_vertex_type (
|
||||
_h5_insert_type (
|
||||
f,
|
||||
dtypes->h5_vertex_t,
|
||||
"vid",
|
||||
HOFFSET(struct h5_vertex, vid),
|
||||
"global_vid",
|
||||
HOFFSET(struct h5_vertex, global_vid),
|
||||
H5_ID_T ) );
|
||||
TRY(
|
||||
_h5_insert_type (
|
||||
@@ -91,15 +91,15 @@ _create_triangle_type (
|
||||
_h5_insert_type (
|
||||
f,
|
||||
dtypes->h5_triangle_t,
|
||||
"eid",
|
||||
HOFFSET(struct h5_triangle, eid),
|
||||
"global_eid",
|
||||
HOFFSET(struct h5_triangle, global_eid),
|
||||
H5_ID_T ) );
|
||||
TRY(
|
||||
_h5_insert_type (
|
||||
f,
|
||||
dtypes->h5_triangle_t,
|
||||
"parent_eid",
|
||||
HOFFSET(struct h5_triangle, parent_eid),
|
||||
"global_parent_eid",
|
||||
HOFFSET(struct h5_triangle, global_parent_eid),
|
||||
H5_ID_T ) );
|
||||
TRY(
|
||||
_h5_insert_type (
|
||||
@@ -112,8 +112,8 @@ _create_triangle_type (
|
||||
_h5_insert_type (
|
||||
f,
|
||||
dtypes->h5_triangle_t,
|
||||
"vids",
|
||||
HOFFSET(struct h5_triangle, vids),
|
||||
"global_vids",
|
||||
HOFFSET(struct h5_triangle, global_vids),
|
||||
dtypes->h5_3id_t ) );
|
||||
|
||||
return H5_SUCCESS;
|
||||
@@ -134,15 +134,15 @@ _create_tet_type (
|
||||
_h5_insert_type (
|
||||
f,
|
||||
dtypes->h5_tet_t,
|
||||
"eid",
|
||||
HOFFSET(struct h5_tetrahedron, eid),
|
||||
"global_eid",
|
||||
HOFFSET(struct h5_tetrahedron, global_eid),
|
||||
H5_ID_T ) );
|
||||
TRY(
|
||||
_h5_insert_type (
|
||||
f,
|
||||
dtypes->h5_tet_t,
|
||||
"parent_eid",
|
||||
HOFFSET(struct h5_tetrahedron, parent_eid),
|
||||
"global_parent_eid",
|
||||
HOFFSET(struct h5_tetrahedron, global_parent_eid),
|
||||
H5_ID_T ) );
|
||||
TRY(
|
||||
_h5_insert_type (
|
||||
@@ -155,8 +155,8 @@ _create_tet_type (
|
||||
_h5_insert_type (
|
||||
f,
|
||||
dtypes->h5_tet_t,
|
||||
"vids",
|
||||
HOFFSET(struct h5_tetrahedron, vids),
|
||||
"global_vids",
|
||||
HOFFSET(struct h5_tetrahedron, global_vids),
|
||||
dtypes->h5_4id_t ) );
|
||||
|
||||
return H5_SUCCESS;
|
||||
@@ -301,7 +301,7 @@ _h5t_open_file (
|
||||
) {
|
||||
|
||||
TRY( (f->t = _h5_alloc ( f, NULL, sizeof(*f->t) ) ) );
|
||||
struct h5t_fdata *t = f->t;
|
||||
h5t_fdata_t *t = f->t;
|
||||
|
||||
t->dtypes.h5_id_t = H5_INT64_T;
|
||||
t->dtypes.h5_float64_t = H5_FLOAT64_T;
|
||||
@@ -310,9 +310,6 @@ _h5t_open_file (
|
||||
TRY( _create_vertex_type ( f ) );
|
||||
TRY( _create_triangle_type ( f ) );
|
||||
TRY( _create_tet_type ( f ) );
|
||||
|
||||
|
||||
|
||||
TRY( _init_fdata ( f ) );
|
||||
|
||||
return H5_SUCCESS;
|
||||
|
||||
+134
-223
@@ -37,7 +37,7 @@ _write_vertices (
|
||||
if ( t->mesh_gid < 0 ) {
|
||||
TRY( _h5t_open_mesh_group ( f ) );
|
||||
}
|
||||
|
||||
t->dsinfo_vertices.dims[0] = t->num_vertices[t->cur_level];
|
||||
TRY( _h5_write (
|
||||
f,
|
||||
t->mesh_gid,
|
||||
@@ -68,7 +68,7 @@ _write_elems (
|
||||
TRY( _h5t_open_mesh_group ( f ) );
|
||||
}
|
||||
|
||||
TRY( _h5_write (
|
||||
TRY ( _h5_write (
|
||||
f,
|
||||
t->mesh_gid,
|
||||
&t->dsinfo_elems,
|
||||
@@ -76,7 +76,7 @@ _write_elems (
|
||||
_open_space_all,
|
||||
t->elems.data ) );
|
||||
|
||||
TRY( _h5_write (
|
||||
TRY ( _h5_write (
|
||||
f,
|
||||
t->mesh_gid,
|
||||
&t->dsinfo_num_elems,
|
||||
@@ -84,7 +84,7 @@ _write_elems (
|
||||
_open_space_all,
|
||||
t->num_elems ) );
|
||||
|
||||
TRY( _h5_write (
|
||||
TRY ( _h5_write (
|
||||
f,
|
||||
t->mesh_gid,
|
||||
&t->dsinfo_num_elems_on_level,
|
||||
@@ -99,7 +99,11 @@ h5_err_t
|
||||
_h5t_write_mesh (
|
||||
h5_file_t * f
|
||||
) {
|
||||
if ( ! f->t->mesh_changed ) return 0;
|
||||
h5t_fdata_t *t = f->t;
|
||||
if ( ! t->mesh_changed ) return 0;
|
||||
if ( t->level_changed ) {
|
||||
TRY ( _h5t_close_level ( f ) );
|
||||
}
|
||||
|
||||
TRY( _write_vertices( f ) );
|
||||
TRY( _write_elems( f ) );
|
||||
@@ -107,42 +111,6 @@ _h5t_write_mesh (
|
||||
return H5_SUCCESS;
|
||||
}
|
||||
|
||||
/*
|
||||
read everything with this function !?
|
||||
*/
|
||||
static h5_err_t
|
||||
_read_dataset (
|
||||
h5_file_t * f,
|
||||
hid_t group_id,
|
||||
const char dataset_name[],
|
||||
hid_t type_id,
|
||||
hid_t (*open_mem_space)(h5_file_t*,hid_t),
|
||||
hid_t (*open_file_space)(h5_file_t*,hid_t),
|
||||
void * const data ) {
|
||||
|
||||
hid_t dataset_id;
|
||||
hid_t mem_space_id;
|
||||
hid_t file_space_id;
|
||||
|
||||
TRY( dataset_id = _h5_open_dataset ( f, group_id, dataset_name ) );
|
||||
TRY( mem_space_id = (*open_mem_space)( f, dataset_id ) );
|
||||
TRY( file_space_id = (*open_file_space)( f, dataset_id ) );
|
||||
TRY( _h5_read_dataset (
|
||||
f,
|
||||
dataset_id,
|
||||
type_id,
|
||||
mem_space_id,
|
||||
file_space_id,
|
||||
f->xfer_prop,
|
||||
data ) );
|
||||
|
||||
TRY( _h5_close_dataspace( f, file_space_id ) );
|
||||
TRY( _h5_close_dataspace( f, mem_space_id ) );
|
||||
TRY( _h5_close_dataset( f, dataset_id ) );
|
||||
|
||||
return H5_SUCCESS;
|
||||
}
|
||||
|
||||
static hid_t
|
||||
_open_mem_space_vertices (
|
||||
h5_file_t * const f,
|
||||
@@ -163,27 +131,20 @@ h5_err_t
|
||||
_h5t_read_num_vertices (
|
||||
h5_file_t * const f
|
||||
) {
|
||||
h5_err_t h5err;
|
||||
struct h5t_fdata *t = f->t;
|
||||
|
||||
if ( t->mesh_gid < 0 ) {
|
||||
h5err = _h5t_open_mesh_group ( f );
|
||||
if ( h5err < 0 ) return h5err;
|
||||
TRY ( _h5t_open_mesh_group ( f ) );
|
||||
}
|
||||
ssize_t num_bytes = t->num_levels*sizeof ( t->num_vertices[0] );
|
||||
h5_debug ( f, "Allocating %ld bytes.", num_bytes );
|
||||
t->num_vertices = realloc ( t->num_vertices, num_bytes );
|
||||
if ( t->num_vertices == NULL )
|
||||
return HANDLE_H5_NOMEM_ERR ( f );
|
||||
h5err = _read_dataset (
|
||||
TRY ( t->num_vertices = _h5_alloc ( f, t->num_vertices, num_bytes ) );
|
||||
TRY ( _h5_read (
|
||||
f,
|
||||
t->mesh_gid,
|
||||
"NumVertices",
|
||||
H5T_NATIVE_INT32,
|
||||
&t->dsinfo_num_vertices,
|
||||
_open_space_all,
|
||||
_open_space_all,
|
||||
t->num_vertices );
|
||||
if ( h5err < 0 ) return h5err;
|
||||
t->num_vertices ) );
|
||||
|
||||
return H5_SUCCESS;
|
||||
}
|
||||
@@ -202,24 +163,15 @@ _h5t_read_vertices (
|
||||
}
|
||||
|
||||
TRY( _h5t_alloc_num_vertices ( f, t->num_vertices[t->num_levels-1] ) );
|
||||
TRY( _read_dataset (
|
||||
TRY( _h5_read (
|
||||
f,
|
||||
t->mesh_gid,
|
||||
"Vertices",
|
||||
t->dtypes.h5_vertex_t,
|
||||
&t->dsinfo_vertices,
|
||||
_open_mem_space_vertices,
|
||||
_open_file_space_vertices,
|
||||
t->vertices ) );
|
||||
|
||||
h5_id_t local_vid = 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].vid;
|
||||
t->map_vertex_g2l.items[local_vid].local_id = local_vid;
|
||||
t->map_vertex_g2l.num_items++;
|
||||
}
|
||||
_h5_sort_idmap ( &t->map_vertex_g2l );
|
||||
_h5t_sort_vertices ( f );
|
||||
TRY ( _h5t_sort_vertices ( f ) );
|
||||
TRY ( _h5t_rebuild_global_2_local_map_of_vertices ( f ) );
|
||||
|
||||
return H5_SUCCESS;
|
||||
}
|
||||
@@ -244,20 +196,29 @@ h5t_traverse_vertices (
|
||||
struct h5t_fdata *t = f->t;
|
||||
|
||||
if ( t->vertices == NULL ) {
|
||||
h5_err_t h5err = _h5t_read_vertices ( f );
|
||||
if ( h5err < 0 ) return h5err;
|
||||
TRY ( _h5t_read_mesh ( f ) );
|
||||
}
|
||||
if ( t->last_retrieved_vid+1 >= t->num_vertices[t->cur_level] ) {
|
||||
h5_debug ( f, "Traversing done!" );
|
||||
return 0;
|
||||
}
|
||||
h5_vertex_t *vertex = &t->vertices[++t->last_retrieved_vid];
|
||||
*id = vertex->vid;
|
||||
*id = vertex->global_vid;
|
||||
memcpy ( P, &vertex->P, sizeof ( vertex->P ) );
|
||||
|
||||
return t->last_retrieved_vid;
|
||||
}
|
||||
|
||||
h5_err_t
|
||||
h5t_end_traverse_vertices (
|
||||
h5_file_t * f
|
||||
) {
|
||||
struct h5t_fdata *t = f->t;
|
||||
|
||||
t->last_retrieved_vid = -1;
|
||||
return H5_SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
h5_err_t
|
||||
_h5t_read_num_elems (
|
||||
@@ -271,20 +232,18 @@ _h5t_read_num_elems (
|
||||
size_t size = t->num_levels * sizeof ( t->num_elems[0] );
|
||||
TRY( t->num_elems = _h5_alloc ( f, NULL, size ) );
|
||||
TRY( t->num_elems_on_level = _h5_alloc ( f, NULL, size ) );
|
||||
TRY( _read_dataset (
|
||||
TRY( _h5_read (
|
||||
f,
|
||||
t->mesh_gid,
|
||||
"NumElems",
|
||||
H5T_NATIVE_INT32,
|
||||
&t->dsinfo_num_elems,
|
||||
_open_space_all,
|
||||
_open_space_all,
|
||||
t->num_elems ) );
|
||||
|
||||
TRY( _read_dataset (
|
||||
TRY( _h5_read (
|
||||
f,
|
||||
t->mesh_gid,
|
||||
"NumElemsOnLevel",
|
||||
H5T_NATIVE_INT32,
|
||||
&t->dsinfo_num_elems_on_level,
|
||||
_open_space_all,
|
||||
_open_space_all,
|
||||
t->num_elems_on_level ) );
|
||||
@@ -312,12 +271,10 @@ h5_err_t
|
||||
_h5t_read_elems (
|
||||
h5_file_t * f
|
||||
) {
|
||||
h5_err_t h5err;
|
||||
struct h5t_fdata *t = f->t;
|
||||
|
||||
if ( t->mesh_gid < 0 ) {
|
||||
h5err = _h5t_open_mesh_group ( f );
|
||||
if ( h5err < 0 ) return h5err;
|
||||
TRY( _h5t_open_mesh_group ( f ) );
|
||||
}
|
||||
|
||||
if ( t->num_elems == NULL ) {
|
||||
@@ -325,41 +282,66 @@ _h5t_read_elems (
|
||||
}
|
||||
|
||||
TRY( _h5t_alloc_num_elems ( f, 0, t->num_elems[t->num_levels-1] ) );
|
||||
TRY( _read_dataset (
|
||||
TRY( _h5_read (
|
||||
f,
|
||||
t->mesh_gid,
|
||||
"Elems",
|
||||
t->elem_tid,
|
||||
&t->dsinfo_elems,
|
||||
_open_mem_space_elems,
|
||||
_open_file_space_elems,
|
||||
t->elems.data ) );
|
||||
|
||||
TRY ( _h5t_sort_elems ( f ) );
|
||||
TRY ( _h5t_rebuild_global_2_local_map_of_elems ( f ) );
|
||||
/*
|
||||
setup structure with local vertex ids
|
||||
*/
|
||||
h5_id_t local_eid = 0;
|
||||
h5_id_t num_elems = t->num_elems[t->num_levels-1];
|
||||
switch ( t->mesh_type ) {
|
||||
case H5_OID_TETRAHEDRON:
|
||||
for ( local_eid = 0; local_eid < num_elems; local_eid++ ) {
|
||||
case H5_OID_TETRAHEDRON: {
|
||||
h5_tet_t *el;
|
||||
h5_tet_data_t *el_data;
|
||||
|
||||
for ( local_eid = 0, el = t->elems.tets, el_data = t->elems_data.tets;
|
||||
local_eid < num_elems;
|
||||
local_eid++, el++, el_data++ ) {
|
||||
|
||||
TRY( h5t_map_global_vids2local (
|
||||
f,
|
||||
t->elems.tets[local_eid].vids,
|
||||
el->global_vids,
|
||||
t->mesh_type,
|
||||
t->elems_data.tets[local_eid].vids
|
||||
el_data->local_vids
|
||||
) );
|
||||
if ( el->global_parent_eid >= 0 )
|
||||
TRY ( el_data->local_parent_eid =
|
||||
h5t_map_global_eid2local (
|
||||
f,
|
||||
el->global_parent_eid ) );
|
||||
}
|
||||
break;
|
||||
case H5_OID_TRIANGLE:
|
||||
for ( local_eid = 0; local_eid < num_elems; local_eid++ ) {
|
||||
}
|
||||
case H5_OID_TRIANGLE: {
|
||||
h5_triangle_t *el;
|
||||
h5_triangle_data_t *el_data;
|
||||
|
||||
for ( local_eid = 0, el = t->elems.tris, el_data = t->elems_data.tris;
|
||||
local_eid < num_elems;
|
||||
local_eid++, el++, el_data++ ) {
|
||||
|
||||
TRY( h5t_map_global_vids2local (
|
||||
f,
|
||||
t->elems.tris[local_eid].vids,
|
||||
el->global_vids,
|
||||
t->mesh_type,
|
||||
t->elems_data.tris[local_eid].vids
|
||||
el_data->local_vids
|
||||
) );
|
||||
if ( el->global_parent_eid >= 0 )
|
||||
TRY ( el_data->local_parent_eid =
|
||||
h5t_map_global_eid2local (
|
||||
f,
|
||||
el->global_parent_eid ) );
|
||||
}
|
||||
break;
|
||||
}
|
||||
default:
|
||||
return -1;
|
||||
}
|
||||
@@ -369,160 +351,91 @@ _h5t_read_elems (
|
||||
|
||||
|
||||
h5_err_t
|
||||
h5t_start_traverse_tets (
|
||||
h5t_start_traverse_elems (
|
||||
h5_file_t * f
|
||||
) {
|
||||
struct h5t_fdata *t = f->t;
|
||||
|
||||
switch ( t->mesh_type ) {
|
||||
case H5_OID_TRIANGLE: {
|
||||
return H5_ERR_INVAL;
|
||||
}
|
||||
case H5_OID_TETRAHEDRON: {
|
||||
t->last_retrieved_eid = -1;
|
||||
return H5_SUCCESS;
|
||||
}
|
||||
default:
|
||||
return H5_ERR_INTERNAL;
|
||||
}
|
||||
h5t_fdata_t *t = f->t;
|
||||
t->last_retrieved_eid = -1;
|
||||
return H5_SUCCESS;
|
||||
}
|
||||
|
||||
/*!
|
||||
\param[in] f file handle
|
||||
\param[out] global_eid Global element id
|
||||
\param[out] local_parent_id Local parent id
|
||||
\param[out] vids Local vertex id
|
||||
*/
|
||||
h5_id_t
|
||||
_traverse_tets (
|
||||
h5_file_t * f,
|
||||
h5_id_t * const id, /*!< OUT: global tetrahedron id */
|
||||
h5_id_t * const parent_id, /*!< OUT: global parent id
|
||||
if level \c >0 else \c -1 */
|
||||
h5_id_t ids[4] /*!< OUT: tuple with vertex id's */
|
||||
h5t_traverse_elems (
|
||||
h5_file_t * const f,
|
||||
h5_id_t * const global_eid,
|
||||
h5_id_t * const local_parent_id,
|
||||
h5_id_t *local_vids
|
||||
) {
|
||||
struct h5t_fdata *t = f->t;
|
||||
h5t_fdata_t *t = f->t;
|
||||
h5_element_t *elem;
|
||||
h5_element_data_t *elem_data;
|
||||
|
||||
if ( t->elems.data == NULL ) {
|
||||
h5_err_t h5err = _h5t_read_elems ( f );
|
||||
if ( h5err < 0 ) return h5err;
|
||||
TRY ( _h5t_read_elems ( f ) );
|
||||
}
|
||||
if ( t->last_retrieved_eid+1 >= t->num_elems[t->cur_level] ) {
|
||||
h5_debug ( f, "Traversing done!" );
|
||||
return 0;
|
||||
}
|
||||
h5_tetrahedron_t *tet = &t->elems.tets[++t->last_retrieved_eid];
|
||||
|
||||
while ( (tet->refined_on_level != -1) &&
|
||||
(tet->refined_on_level <= t->cur_level) ){
|
||||
tet++;
|
||||
t->last_retrieved_eid++;
|
||||
do {
|
||||
switch ( t->mesh_type ) {
|
||||
case H5_OID_TETRAHEDRON:
|
||||
elem = (h5_element_t*)
|
||||
&t->elems.tets[++t->last_retrieved_eid];
|
||||
break;
|
||||
case H5_OID_TRIANGLE:
|
||||
elem = (h5_element_t*)
|
||||
&t->elems.tris[++t->last_retrieved_eid];
|
||||
break;
|
||||
default:
|
||||
return h5_error_internal (
|
||||
f, __FILE__, __func__, __LINE__ );
|
||||
}
|
||||
if ( t->last_retrieved_eid >= t->num_elems[t->cur_level] ) {
|
||||
return h5_error_internal( f, __FILE__, __func__, __LINE__ );
|
||||
return h5_error_internal (
|
||||
f, __FILE__, __func__, __LINE__ );
|
||||
}
|
||||
}
|
||||
while ( (elem->refined_on_level != -1) &&
|
||||
(elem->refined_on_level <= t->cur_level) );
|
||||
|
||||
*id = tet->eid;
|
||||
*parent_id = tet->parent_eid;
|
||||
memcpy ( ids, &tet->vids, sizeof ( tet->vids ) );
|
||||
switch ( t->mesh_type ) {
|
||||
case H5_OID_TETRAHEDRON:
|
||||
elem_data = (h5_element_data_t*)
|
||||
&t->elems_data.tets[t->last_retrieved_eid];
|
||||
break;
|
||||
case H5_OID_TRIANGLE:
|
||||
elem_data = (h5_element_data_t*)
|
||||
&t->elems_data.tris[t->last_retrieved_eid];
|
||||
break;
|
||||
default:
|
||||
return h5_error_internal (
|
||||
f, __FILE__, __func__, __LINE__ );
|
||||
}
|
||||
|
||||
*global_eid = elem->global_eid;
|
||||
*local_parent_id = elem_data->local_parent_eid;
|
||||
memcpy (
|
||||
local_vids,
|
||||
&elem_data->local_vids,
|
||||
sizeof ( elem_data->local_vids[0] ) * t->mesh_type );
|
||||
|
||||
return t->last_retrieved_eid;
|
||||
}
|
||||
|
||||
h5_id_t
|
||||
h5t_traverse_tets (
|
||||
h5_file_t * f,
|
||||
h5_id_t * const id, /*!< OUT: global tetrahedron id */
|
||||
h5_id_t * const parent_id, /*!< OUT: global parent id
|
||||
if level \c >0 else \c -1 */
|
||||
h5_id_t ids[4] /*!< OUT: tuple with vertex id's */
|
||||
) {
|
||||
struct h5t_fdata *t = f->t;
|
||||
|
||||
switch ( t->mesh_type ) {
|
||||
case H5_OID_TRIANGLE: {
|
||||
return H5_ERR_INVAL;
|
||||
}
|
||||
case H5_OID_TETRAHEDRON: {
|
||||
return _traverse_tets ( f, id, parent_id, ids );
|
||||
}
|
||||
default:
|
||||
return h5_error_internal( f, __FILE__, __func__, __LINE__ );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
h5_err_t
|
||||
h5t_start_traverse_triangles (
|
||||
h5t_end_traverse_elems (
|
||||
h5_file_t * f
|
||||
) {
|
||||
struct h5t_fdata *t = f->t;
|
||||
|
||||
switch ( t->mesh_type ) {
|
||||
case H5_OID_TRIANGLE: {
|
||||
t->last_retrieved_eid = -1;
|
||||
return H5_SUCCESS;
|
||||
}
|
||||
case H5_OID_TETRAHEDRON: {
|
||||
return h5_error_not_implemented( f, __FILE__, __func__, __LINE__ );
|
||||
}
|
||||
default:
|
||||
return h5_error_internal( f, __FILE__, __func__, __LINE__ );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
static h5_id_t
|
||||
_traverse_triangles (
|
||||
h5_file_t * f,
|
||||
h5_id_t * const id, /*!< OUT: global triangle id */
|
||||
h5_id_t * const parent_id, /*!< OUT: global parent id
|
||||
if level \c >0 else \c -1 */
|
||||
h5_id_t ids[3] /*!< OUT: tuple with vertex id's */
|
||||
) {
|
||||
struct h5t_fdata *t = f->t;
|
||||
|
||||
if ( t->elems.data == NULL ) {
|
||||
h5_err_t h5err = _h5t_read_elems ( f );
|
||||
if ( h5err < 0 ) return h5err;
|
||||
}
|
||||
if ( t->last_retrieved_eid+1 >= t->num_elems[t->cur_level] ) {
|
||||
h5_debug ( f, "Traversing done!" );
|
||||
return 0;
|
||||
}
|
||||
h5_triangle_t *tri = &t->elems.tris[++t->last_retrieved_eid];
|
||||
|
||||
while ( (tri->refined_on_level != -1) &&
|
||||
(tri->refined_on_level <= t->cur_level) ){
|
||||
tri++;
|
||||
t->last_retrieved_eid++;
|
||||
if ( t->last_retrieved_eid >= t->num_elems[t->cur_level] ) {
|
||||
return h5_error_internal( f, __FILE__, __func__, __LINE__ );
|
||||
}
|
||||
}
|
||||
|
||||
*id = tri->eid;
|
||||
*parent_id = tri->parent_eid;
|
||||
memcpy ( ids, &tri->vids, sizeof ( tri->vids ) );
|
||||
|
||||
return t->last_retrieved_eid;
|
||||
}
|
||||
|
||||
h5_id_t
|
||||
h5t_traverse_triangles (
|
||||
h5_file_t * f,
|
||||
h5_id_t * const id, /*!< OUT: global triangle id */
|
||||
h5_id_t * const parent_id, /*!< OUT: global parent id
|
||||
if level \c >0 else \c -1 */
|
||||
h5_id_t ids[3] /*!< OUT: tuple with vertex id's */
|
||||
) {
|
||||
|
||||
struct h5t_fdata *t = f->t;
|
||||
|
||||
switch ( t->mesh_type ) {
|
||||
case H5_OID_TRIANGLE: {
|
||||
return _traverse_triangles ( f, id, parent_id, ids );
|
||||
}
|
||||
case H5_OID_TETRAHEDRON: {
|
||||
return h5_error_not_implemented( f, __FILE__, __func__, __LINE__ );
|
||||
}
|
||||
default:
|
||||
return h5_error_internal( f, __FILE__, __func__, __LINE__ );
|
||||
}
|
||||
h5t_fdata_t *t = f->t;
|
||||
t->last_retrieved_eid = -1;
|
||||
return H5_SUCCESS;
|
||||
}
|
||||
|
||||
h5_err_t
|
||||
@@ -532,13 +445,11 @@ _h5t_read_mesh (
|
||||
struct h5t_fdata *t = f->t;
|
||||
|
||||
if ( t->vertices == NULL ) {
|
||||
h5_err_t h5err = _h5t_read_vertices ( f );
|
||||
if ( h5err < 0 ) return h5err;
|
||||
TRY ( _h5t_read_vertices ( f ) );
|
||||
}
|
||||
|
||||
if ( t->elems.data == NULL ) {
|
||||
h5_err_t h5err = _h5t_read_elems ( f );
|
||||
if ( h5err < 0 ) return h5err;
|
||||
TRY ( _h5t_read_elems ( f ) );
|
||||
}
|
||||
|
||||
if ( t->sorted_elems[0].items == NULL ) {
|
||||
|
||||
@@ -23,6 +23,16 @@ h5t_traverse_vertices (
|
||||
h5_float64_t P[3]
|
||||
);
|
||||
|
||||
h5_err_t
|
||||
h5t_end_traverse_vertices (
|
||||
h5_file_t * f
|
||||
);
|
||||
|
||||
h5_err_t
|
||||
h5t_end_traverse_elems (
|
||||
h5_file_t * const f
|
||||
);
|
||||
|
||||
h5_size_t
|
||||
h5t_add_num_tets (
|
||||
h5_file_t * f,
|
||||
@@ -46,6 +56,20 @@ _h5t_read_elems (
|
||||
h5_file_t * f
|
||||
);
|
||||
|
||||
h5_err_t
|
||||
h5t_start_traverse_elems (
|
||||
h5_file_t * f
|
||||
);
|
||||
|
||||
h5_id_t
|
||||
h5t_traverse_elems (
|
||||
h5_file_t * f,
|
||||
h5_id_t * const id,
|
||||
h5_id_t * const parent_id,
|
||||
h5_id_t * vids
|
||||
);
|
||||
|
||||
|
||||
h5_err_t
|
||||
h5t_start_traverse_tets (
|
||||
h5_file_t * f
|
||||
|
||||
+213
-119
@@ -21,26 +21,100 @@ h5t_add_mesh (
|
||||
h5_id_t mesh_id = 0;
|
||||
|
||||
TRY( (mesh_id = h5t_open_mesh ( f, -1, mesh_type )) );
|
||||
TRY( h5t_add_level ( f, num_elems+3, num_elems ) );
|
||||
TRY( _h5t_add_level ( f, num_elems+3, num_elems ) );
|
||||
|
||||
f->t->mesh_changed = 1;
|
||||
|
||||
return mesh_id;
|
||||
}
|
||||
|
||||
/*
|
||||
|
||||
* Assign unique global id's to vertices. Vertices already have
|
||||
unique id's assigned by the mesher but this id's may not be
|
||||
consecutive numbered starting from 0.
|
||||
* Set the global vertex id's in element definitions.
|
||||
* Assign unique global id's to elements. This is a NOOP if we are
|
||||
running serial.
|
||||
|
||||
Where are the global vertex id's stored?
|
||||
- Vertex definitions
|
||||
|
||||
*/
|
||||
herr_t
|
||||
_h5t_assign_global_ids (
|
||||
h5_file_t * const f
|
||||
) {
|
||||
h5t_fdata_t *t = f->t;
|
||||
h5_id_t local_id;
|
||||
|
||||
if ( t->cur_level < 0 ) return H5_SUCCESS; /* no level defined */
|
||||
|
||||
/*
|
||||
assign global id to vertices
|
||||
*/
|
||||
/*
|
||||
simple in serial runs: global_id = local_id
|
||||
*/
|
||||
for ( local_id = 0; local_id < t->num_vertices[t->num_levels-1]; local_id++ ) {
|
||||
t->vertices[local_id].global_vid = local_id;
|
||||
}
|
||||
|
||||
return H5_SUCCESS;
|
||||
}
|
||||
|
||||
h5_err_t
|
||||
_h5t_close_level (
|
||||
h5_file_t * const f
|
||||
) {
|
||||
h5t_fdata_t *t = f->t;
|
||||
|
||||
if ( t->num_levels <= 0 ) return H5_SUCCESS;
|
||||
|
||||
t->num_vertices[t->cur_level] = t->last_stored_vid+1;
|
||||
TRY ( _h5t_assign_global_ids ( f ) );
|
||||
|
||||
TRY ( _h5t_sort_vertices ( f ) );
|
||||
TRY ( _h5t_rebuild_global_2_local_map_of_vertices ( f ) );
|
||||
TRY ( _h5t_sort_elems ( f ) );
|
||||
TRY ( _h5t_rebuild_global_2_local_map_of_elems ( f ) );
|
||||
|
||||
return H5_SUCCESS;
|
||||
}
|
||||
|
||||
h5_id_t
|
||||
h5t_add_level (
|
||||
h5_file_t * const f,
|
||||
h5_size_t num_elems
|
||||
) {
|
||||
switch ( f->t->mesh_type ) {
|
||||
case H5_OID_TETRAHEDRON:
|
||||
num_elems += 8;
|
||||
break;
|
||||
case H5_OID_TRIANGLE:
|
||||
num_elems += 4;
|
||||
break;
|
||||
default:
|
||||
return h5_error_internal ( f, __FILE__, __func__, __LINE__ );
|
||||
}
|
||||
h5_id_t num_vertices = (num_elems>>2)*3; /* this is an upper limit */
|
||||
return _h5t_add_level ( f, num_vertices, num_elems );
|
||||
}
|
||||
|
||||
h5_id_t
|
||||
_h5t_add_level (
|
||||
h5_file_t * const f,
|
||||
const h5_size_t num_vertices,
|
||||
const h5_size_t num_elems
|
||||
) {
|
||||
struct h5t_fdata *t = f->t;
|
||||
h5t_fdata_t *t = f->t;
|
||||
|
||||
if ( f->mode == H5_O_RDONLY ) {
|
||||
return H5_ERR_INVAL;
|
||||
}
|
||||
|
||||
TRY ( _h5t_close_level ( f ) );
|
||||
|
||||
/* t->num_levels will be set to zero on file creation(!) */
|
||||
if ( t->num_levels == -1 ) { /* unknown number of levels */
|
||||
/* determine number of levels */
|
||||
@@ -55,9 +129,9 @@ h5t_add_level (
|
||||
t->num_vertices = realloc ( t->num_vertices, num_bytes );
|
||||
t->num_vertices[t->cur_level] = -1;
|
||||
|
||||
t->num_elems = realloc ( t->num_elems, num_bytes );
|
||||
TRY ( t->num_elems = _h5_alloc ( f, t->num_elems, num_bytes ) );
|
||||
t->num_elems[t->cur_level] = -1;
|
||||
t->num_elems_on_level = realloc ( t->num_elems_on_level, num_bytes );
|
||||
TRY ( t->num_elems_on_level = _h5_alloc ( f, t->num_elems_on_level, num_bytes ) );
|
||||
t->num_elems_on_level[t->cur_level] = -1;
|
||||
|
||||
t->new_level = t->cur_level;
|
||||
@@ -78,21 +152,19 @@ _h5t_alloc_num_vertices (
|
||||
h5_file_t * const f,
|
||||
const h5_size_t num_vertices
|
||||
) {
|
||||
struct h5t_fdata *t = f->t;
|
||||
|
||||
ssize_t num_bytes = num_vertices*sizeof ( t->vertices[0] );
|
||||
h5_debug ( f, "Allocating %ld bytes.", num_bytes );
|
||||
t->vertices = realloc ( t->vertices, num_bytes );
|
||||
if ( t->vertices == NULL ) {
|
||||
return HANDLE_H5_NOMEM_ERR ( f );
|
||||
}
|
||||
h5t_fdata_t *t = f->t;
|
||||
|
||||
ssize_t size = num_vertices * sizeof ( t->vertices[0] );
|
||||
TRY ( t->vertices = _h5_alloc ( f, t->vertices, size ) );
|
||||
TRY( _h5_alloc_idmap ( f, &t->map_vertex_g2l, num_vertices ) );
|
||||
TRY( _h5_alloc_smap ( f, &t->sorted_lvertices, num_vertices ) );
|
||||
|
||||
return H5_SUCCESS;
|
||||
}
|
||||
|
||||
/*!
|
||||
Allocate memory for (more) vertices.
|
||||
*/
|
||||
h5_err_t
|
||||
_h5t_add_num_vertices (
|
||||
h5_file_t * const f,
|
||||
@@ -103,11 +175,11 @@ _h5t_add_num_vertices (
|
||||
if ( t->cur_level < 0 ) {
|
||||
return _h5t_error_undef_level( f );
|
||||
}
|
||||
ssize_t num_vertices = (t->cur_level > 0 ?
|
||||
t->num_vertices[t->cur_level-1] + num : num);
|
||||
t->num_vertices[t->cur_level] = num_vertices;
|
||||
t->dsinfo_vertices.dims[0] = num_vertices;
|
||||
return _h5t_alloc_num_vertices ( f, num_vertices );
|
||||
h5_size_t cur_num_vertices = ( t->cur_level > 0 ?
|
||||
t->num_vertices[t->cur_level-1] : 0 );
|
||||
t->num_vertices[t->cur_level] = cur_num_vertices+num;
|
||||
t->dsinfo_vertices.dims[0] = cur_num_vertices+num;
|
||||
return _h5t_alloc_num_vertices ( f, cur_num_vertices+num );
|
||||
}
|
||||
|
||||
h5_id_t
|
||||
@@ -117,24 +189,24 @@ h5t_store_vertex (
|
||||
const h5_float64_t P[3] /*!< coordinates */
|
||||
) {
|
||||
struct h5t_fdata *t = f->t;
|
||||
|
||||
|
||||
/*
|
||||
more than allocated
|
||||
*/
|
||||
if ( t->last_stored_vid+1 >= t->num_vertices[t->cur_level] )
|
||||
return HANDLE_H5_OVERFLOW_ERR(
|
||||
f, "vertex", t->num_vertices[t->cur_level] );
|
||||
|
||||
|
||||
/*
|
||||
missing call to add the first level
|
||||
*/
|
||||
if ( t->cur_level < 0 )
|
||||
return _h5t_error_undef_level( f );
|
||||
|
||||
t->level_changed = 1;
|
||||
h5_id_t local_id = ++t->last_stored_vid;
|
||||
h5_vertex_t *vertex = &t->vertices[local_id];
|
||||
vertex->vid = global_vid; /* global id from mesher not yet handled! */
|
||||
vertex->vid = local_id; /* serial case: global id == local id */
|
||||
vertex->global_vid = global_vid; /* global id from mesher,replaced later!*/
|
||||
memcpy ( &vertex->P, P, sizeof ( vertex->P ) );
|
||||
|
||||
return local_id;
|
||||
@@ -163,17 +235,12 @@ _h5t_alloc_num_elems (
|
||||
return -1;
|
||||
}
|
||||
|
||||
t->elems.data = realloc (
|
||||
t->elems.data, new_num_elems * sizeof_elem );
|
||||
if ( t->elems.data == NULL ) {
|
||||
return H5_ERR_NOMEM;
|
||||
}
|
||||
size_t size = new_num_elems * sizeof_elem;
|
||||
TRY ( t->elems.data = _h5_alloc ( f, t->elems.data, size ) );
|
||||
|
||||
size = new_num_elems * sizeof_lelem;
|
||||
TRY ( t->elems_data.data = _h5_alloc ( f, t->elems_data.data, size ) );
|
||||
|
||||
t->elems_data.data = realloc (
|
||||
t->elems_data.data, new_num_elems*sizeof_lelem );
|
||||
if ( t->elems_data.data == NULL ) {
|
||||
return H5_ERR_NOMEM;
|
||||
}
|
||||
memset (
|
||||
t->elems_data.data+cur_num_elems*sizeof_lelem,
|
||||
-1,
|
||||
@@ -247,25 +314,32 @@ h5t_store_elem (
|
||||
}
|
||||
}
|
||||
|
||||
/*!
|
||||
Store tetrahedron. The vertices are given with there *local* id's!
|
||||
|
||||
\param[in] f File handle.
|
||||
\param[in] local_parent_id Local id of the parent element or \c -1.
|
||||
\param[in] local_vids Local vertex id's defining the tetrahedron.
|
||||
*/
|
||||
h5_id_t
|
||||
_h5t_store_tet (
|
||||
h5_file_t * const f,
|
||||
const h5_id_t local_parent_eid, /*!< local parent id
|
||||
if level \c >0 else \c -1 */
|
||||
const h5_id_t vids[4] /*!< tuple with local vertex id's */
|
||||
const h5_id_t local_parent_eid,
|
||||
const h5_id_t local_vids[4]
|
||||
) {
|
||||
|
||||
struct h5t_fdata *t = f->t;
|
||||
|
||||
t->level_changed = 1;
|
||||
h5_id_t local_eid = ++t->last_stored_eid;
|
||||
h5_tetrahedron_t *tet = &t->elems.tets[local_eid];
|
||||
tet->eid = local_eid;
|
||||
tet->parent_eid = local_parent_eid;
|
||||
h5_tet_data_t *tet_data = &t->elems_data.tets[local_eid];
|
||||
tet->global_eid = local_eid;
|
||||
tet->global_parent_eid = local_parent_eid;
|
||||
tet->refined_on_level = -1;
|
||||
|
||||
memcpy ( &tet->vids, vids, sizeof ( tet->vids ) );
|
||||
|
||||
_h5t_sort_local_vids ( f, tet->vids, 4 );
|
||||
memcpy ( &tet->global_vids, local_vids, sizeof ( tet->global_vids ) );
|
||||
_h5t_sort_local_vids ( f, tet->global_vids, 4 );
|
||||
memcpy ( &tet_data->local_vids, &tet->global_vids, sizeof ( tet->global_vids ) );
|
||||
|
||||
if ( local_parent_eid >= 0 ) {
|
||||
if ( t->elems.tets[local_parent_eid].refined_on_level < 0 ) {
|
||||
@@ -286,14 +360,17 @@ _h5t_store_triangle (
|
||||
) {
|
||||
|
||||
struct h5t_fdata *t = f->t;
|
||||
|
||||
t->level_changed = 1;
|
||||
h5_id_t local_eid = ++t->last_stored_eid;
|
||||
h5_triangle_t *tri = &t->elems.tris[local_eid];
|
||||
tri->eid = local_eid;
|
||||
tri->parent_eid = local_parent_eid;
|
||||
h5_triangle_data_t *tri_data = &t->elems_data.tris[local_eid];
|
||||
tri->global_eid = local_eid;
|
||||
tri->global_parent_eid = local_parent_eid;
|
||||
tri->refined_on_level = -1;
|
||||
|
||||
memcpy ( &tri->vids, vids, sizeof ( tri->vids ) );
|
||||
memcpy ( &tri->global_vids, vids, sizeof ( tri->global_vids ) );
|
||||
_h5t_sort_local_vids ( f, tri->global_vids, 3 );
|
||||
memcpy ( &tri_data->local_vids, &tri->global_vids, sizeof ( tri->global_vids ) );
|
||||
|
||||
if ( local_parent_eid >= 0 ) {
|
||||
if ( t->elems.tris[local_parent_eid].refined_on_level < 0 ) {
|
||||
@@ -319,22 +396,20 @@ _h5t_bisect_edge (
|
||||
h5_id_t local_vid1
|
||||
) {
|
||||
struct h5t_fdata *t = f->t;
|
||||
h5_id_t local_id = -1;
|
||||
h5_id_t local_vid = -1;
|
||||
h5_float64_t *P0 = t->vertices[local_vid0].P;
|
||||
h5_float64_t *P1 = t->vertices[local_vid1].P;
|
||||
h5_float64_t P[3];
|
||||
|
||||
local_id = ++t->last_stored_vid;
|
||||
h5_vertex_t *vertex = &t->vertices[local_id];
|
||||
vertex->vid = local_id;
|
||||
vertex->P[0] = ( P0[0] + P1[0] ) / 2.0;
|
||||
vertex->P[1] = ( P0[1] + P1[1] ) / 2.0;
|
||||
vertex->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;
|
||||
|
||||
if ( _h5t_get_local_vid( f, vertex->P ) < 0 ) {
|
||||
t->num_vertices[t->cur_level]++;
|
||||
/* add vertex if not already exist */
|
||||
if ( (local_vid = _h5t_get_local_vid( f, P )) < 0 ) {
|
||||
TRY ( local_vid = h5t_store_vertex ( f, -1, P ) );
|
||||
}
|
||||
|
||||
return local_id;
|
||||
return local_vid;
|
||||
}
|
||||
|
||||
/*!
|
||||
@@ -366,9 +441,61 @@ h5t_refine_elem (
|
||||
h5_id_t
|
||||
_h5t_refine_triangle (
|
||||
h5_file_t * const f,
|
||||
const h5_id_t local_eid
|
||||
const h5_id_t local_parent_eid
|
||||
) {
|
||||
return -1;
|
||||
h5t_fdata_t *t = f->t;
|
||||
h5_id_t local_vids[3];
|
||||
h5_id_t local_eid;
|
||||
|
||||
local_vids[0] = _h5t_bisect_edge(
|
||||
f,
|
||||
t->elems_data.tris[local_parent_eid].local_vids[0],
|
||||
t->elems_data.tris[local_parent_eid].local_vids[1] );
|
||||
local_vids[1] = _h5t_bisect_edge(
|
||||
f,
|
||||
t->elems_data.tris[local_parent_eid].local_vids[0],
|
||||
t->elems_data.tris[local_parent_eid].local_vids[2] );
|
||||
local_vids[2] = _h5t_bisect_edge(
|
||||
f,
|
||||
t->elems_data.tris[local_parent_eid].local_vids[1],
|
||||
t->elems_data.tris[local_parent_eid].local_vids[2] );
|
||||
|
||||
|
||||
h5_id_t elem_local_vids[4];
|
||||
|
||||
/* 0 */
|
||||
elem_local_vids[0] = t->elems_data.tets[local_parent_eid].local_vids[0];
|
||||
elem_local_vids[1] = local_vids[0];
|
||||
elem_local_vids[2] = local_vids[1];
|
||||
TRY ( local_eid = _h5t_store_triangle (
|
||||
f,
|
||||
local_parent_eid, elem_local_vids ) );
|
||||
|
||||
/* 1 */
|
||||
elem_local_vids[0] = t->elems_data.tets[local_parent_eid].local_vids[1];
|
||||
elem_local_vids[1] = local_vids[0];
|
||||
elem_local_vids[2] = local_vids[2];
|
||||
TRY ( _h5t_store_triangle (
|
||||
f,
|
||||
local_parent_eid, elem_local_vids ) );
|
||||
|
||||
/* 2 */
|
||||
elem_local_vids[0] = t->elems_data.tets[local_parent_eid].local_vids[2];
|
||||
elem_local_vids[1] = local_vids[1];
|
||||
elem_local_vids[2] = local_vids[2];
|
||||
TRY ( _h5t_store_triangle (
|
||||
f,
|
||||
local_parent_eid, elem_local_vids ) );
|
||||
|
||||
/* 3 */
|
||||
elem_local_vids[0] = local_vids[0];
|
||||
elem_local_vids[1] = local_vids[1];
|
||||
elem_local_vids[2] = local_vids[2];
|
||||
TRY ( _h5t_store_triangle (
|
||||
f,
|
||||
local_parent_eid, elem_local_vids ) );
|
||||
|
||||
return local_eid;
|
||||
}
|
||||
|
||||
/*!
|
||||
@@ -379,35 +506,36 @@ _h5t_refine_triangle (
|
||||
h5_id_t
|
||||
_h5t_refine_tet (
|
||||
h5_file_t * const f,
|
||||
const h5_id_t local_eid
|
||||
const h5_id_t local_parent_eid
|
||||
) {
|
||||
struct h5t_fdata *t = f->t;
|
||||
h5t_fdata_t *t = f->t;
|
||||
h5_id_t local_vids[6];
|
||||
h5_id_t local_eid;
|
||||
|
||||
local_vids[0] = _h5t_bisect_edge(
|
||||
f,
|
||||
t->elems_data.tets[local_eid].vids[0],
|
||||
t->elems_data.tets[local_eid].vids[1] );
|
||||
t->elems_data.tets[local_parent_eid].local_vids[0],
|
||||
t->elems_data.tets[local_parent_eid].local_vids[1] );
|
||||
local_vids[1] = _h5t_bisect_edge(
|
||||
f,
|
||||
t->elems_data.tets[local_eid].vids[0],
|
||||
t->elems_data.tets[local_eid].vids[2] );
|
||||
t->elems_data.tets[local_parent_eid].local_vids[0],
|
||||
t->elems_data.tets[local_parent_eid].local_vids[2] );
|
||||
local_vids[2] = _h5t_bisect_edge(
|
||||
f,
|
||||
t->elems_data.tets[local_eid].vids[0],
|
||||
t->elems_data.tets[local_eid].vids[3] );
|
||||
t->elems_data.tets[local_parent_eid].local_vids[0],
|
||||
t->elems_data.tets[local_parent_eid].local_vids[3] );
|
||||
local_vids[3] = _h5t_bisect_edge(
|
||||
f,
|
||||
t->elems_data.tets[local_eid].vids[1],
|
||||
t->elems_data.tets[local_eid].vids[2] );
|
||||
t->elems_data.tets[local_parent_eid].local_vids[1],
|
||||
t->elems_data.tets[local_parent_eid].local_vids[2] );
|
||||
local_vids[4] = _h5t_bisect_edge(
|
||||
f,
|
||||
t->elems_data.tets[local_eid].vids[1],
|
||||
t->elems_data.tets[local_eid].vids[3] );
|
||||
t->elems_data.tets[local_parent_eid].local_vids[1],
|
||||
t->elems_data.tets[local_parent_eid].local_vids[3] );
|
||||
local_vids[5] = _h5t_bisect_edge(
|
||||
f,
|
||||
t->elems_data.tets[local_eid].vids[2],
|
||||
t->elems_data.tets[local_eid].vids[3] );
|
||||
t->elems_data.tets[local_parent_eid].local_vids[2],
|
||||
t->elems_data.tets[local_parent_eid].local_vids[3] );
|
||||
|
||||
/*
|
||||
add new tets
|
||||
@@ -415,96 +543,62 @@ _h5t_refine_tet (
|
||||
h5_id_t new_tet_local_vids[4];
|
||||
|
||||
/* 0 */
|
||||
h5_id_t new_tet_local_id = h5t_get_num_elems( f, f->myproc, -1 );
|
||||
new_tet_local_vids[0] = t->elems_data.tets[local_eid].vids[0];
|
||||
new_tet_local_vids[0] = t->elems_data.tets[local_parent_eid].local_vids[0];
|
||||
new_tet_local_vids[1] = local_vids[0]; // (01)
|
||||
new_tet_local_vids[2] = local_vids[1]; // (02)
|
||||
new_tet_local_vids[3] = local_vids[2]; // (03)
|
||||
TRY2( _h5t_store_tet (
|
||||
f,
|
||||
new_tet_local_id,
|
||||
new_tet_local_vids ), fail );
|
||||
TRY ( local_eid = _h5t_store_tet (
|
||||
f, local_parent_eid, new_tet_local_vids ) );
|
||||
|
||||
/* 1 */
|
||||
new_tet_local_id = h5t_get_num_elems( f, f->myproc, -1 );
|
||||
new_tet_local_vids[0] = t->elems_data.tets[local_eid].vids[1];
|
||||
new_tet_local_vids[0] = t->elems_data.tets[local_parent_eid].local_vids[1];
|
||||
new_tet_local_vids[1] = local_vids[0]; // (01)
|
||||
new_tet_local_vids[2] = local_vids[3]; // (12)
|
||||
new_tet_local_vids[3] = local_vids[4]; // (13)
|
||||
TRY2( _h5t_store_tet (
|
||||
f,
|
||||
new_tet_local_id,
|
||||
new_tet_local_vids ), fail );
|
||||
TRY ( _h5t_store_tet ( f, local_parent_eid, new_tet_local_vids ) );
|
||||
|
||||
/* 2 */
|
||||
new_tet_local_id = h5t_get_num_elems( f, f->myproc, -1 );
|
||||
new_tet_local_vids[0] = t->elems_data.tets[local_eid].vids[2];
|
||||
new_tet_local_vids[0] = t->elems_data.tets[local_parent_eid].local_vids[2];
|
||||
new_tet_local_vids[1] = local_vids[1]; // (02)
|
||||
new_tet_local_vids[2] = local_vids[3]; // (12)
|
||||
new_tet_local_vids[3] = local_vids[5]; // (23)
|
||||
TRY2( _h5t_store_tet (
|
||||
f,
|
||||
new_tet_local_id,
|
||||
new_tet_local_vids ), fail );
|
||||
TRY ( _h5t_store_tet ( f, local_parent_eid, new_tet_local_vids ) );
|
||||
|
||||
/* 3 */
|
||||
new_tet_local_id = h5t_get_num_elems( f, f->myproc, -1 );
|
||||
new_tet_local_vids[0] = t->elems_data.tets[local_eid].vids[3];
|
||||
new_tet_local_vids[0] = t->elems_data.tets[local_parent_eid].local_vids[3];
|
||||
new_tet_local_vids[1] = local_vids[2]; // (03)
|
||||
new_tet_local_vids[2] = local_vids[4]; // (13)
|
||||
new_tet_local_vids[3] = local_vids[5]; // (23)
|
||||
TRY2( _h5t_store_tet (
|
||||
f,
|
||||
new_tet_local_id,
|
||||
new_tet_local_vids ), fail );
|
||||
TRY ( _h5t_store_tet ( f, local_parent_eid, new_tet_local_vids ) );
|
||||
|
||||
/* 4 */
|
||||
new_tet_local_id = h5t_get_num_elems( f, f->myproc, -1 );
|
||||
new_tet_local_vids[0] = local_vids[0]; // (01)
|
||||
new_tet_local_vids[1] = local_vids[1]; // (02)
|
||||
new_tet_local_vids[2] = local_vids[2]; // (03)
|
||||
new_tet_local_vids[3] = local_vids[4]; // (13)
|
||||
TRY2( _h5t_store_tet (
|
||||
f,
|
||||
new_tet_local_id,
|
||||
new_tet_local_vids ), fail );
|
||||
TRY ( _h5t_store_tet ( f, local_parent_eid, new_tet_local_vids ) );
|
||||
|
||||
/* 5 */
|
||||
new_tet_local_id = h5t_get_num_elems( f, f->myproc, -1 );
|
||||
new_tet_local_vids[0] = local_vids[0]; // (01)
|
||||
new_tet_local_vids[1] = local_vids[1]; // (02)
|
||||
new_tet_local_vids[2] = local_vids[3]; // (12)
|
||||
new_tet_local_vids[3] = local_vids[4]; // (13)
|
||||
TRY2( _h5t_store_tet (
|
||||
f,
|
||||
new_tet_local_id,
|
||||
new_tet_local_vids ), fail );
|
||||
TRY ( _h5t_store_tet ( f, local_parent_eid, new_tet_local_vids ) );
|
||||
|
||||
/* 6 */
|
||||
new_tet_local_id = h5t_get_num_elems( f, f->myproc, -1 );
|
||||
new_tet_local_vids[0] = local_vids[1]; // (02)
|
||||
new_tet_local_vids[1] = local_vids[2]; // (03)
|
||||
new_tet_local_vids[2] = local_vids[4]; // (13)
|
||||
new_tet_local_vids[3] = local_vids[5]; // (23)
|
||||
TRY2( _h5t_store_tet (
|
||||
f,
|
||||
new_tet_local_id,
|
||||
new_tet_local_vids ), fail );
|
||||
TRY ( _h5t_store_tet ( f, local_parent_eid, new_tet_local_vids ) );
|
||||
|
||||
/* 7 */
|
||||
new_tet_local_id = h5t_get_num_elems( f, f->myproc, -1 );
|
||||
new_tet_local_vids[0] = local_vids[1]; // (02)
|
||||
new_tet_local_vids[1] = local_vids[3]; // (12)
|
||||
new_tet_local_vids[2] = local_vids[4]; // (13)
|
||||
new_tet_local_vids[3] = local_vids[5]; // (23)
|
||||
TRY2( _h5t_store_tet (
|
||||
f,
|
||||
new_tet_local_id,
|
||||
new_tet_local_vids ), fail );
|
||||
TRY ( _h5t_store_tet ( f, local_parent_eid, new_tet_local_vids ) );
|
||||
|
||||
return H5_SUCCESS;
|
||||
|
||||
fail:
|
||||
return H5_ERR;
|
||||
return local_eid;
|
||||
}
|
||||
|
||||
|
||||
@@ -11,7 +11,6 @@ h5t_add_mesh (
|
||||
h5_id_t
|
||||
h5t_add_level (
|
||||
h5_file_t * const f,
|
||||
const h5_size_t num_vertices,
|
||||
const h5_size_t num_elems
|
||||
);
|
||||
|
||||
|
||||
@@ -1,6 +1,13 @@
|
||||
#ifndef __H5T_STOREMESH_PRIVATE_H
|
||||
#define __H5T_STOREMESH_PRIVATE_H
|
||||
|
||||
h5_id_t
|
||||
_h5t_add_level (
|
||||
h5_file_t * const f,
|
||||
const h5_size_t num_vertices,
|
||||
const h5_size_t num_elems
|
||||
);
|
||||
|
||||
h5_err_t
|
||||
_h5t_alloc_num_vertices (
|
||||
h5_file_t * const f,
|
||||
@@ -25,4 +32,9 @@ _h5t_alloc_num_elems (
|
||||
const size_t cur_num_elems,
|
||||
const size_t new_num_elems
|
||||
);
|
||||
|
||||
h5_err_t
|
||||
_h5t_close_level (
|
||||
h5_file_t * const f
|
||||
);
|
||||
#endif
|
||||
|
||||
@@ -6,40 +6,56 @@ typedef h5_int64_t h5_4id_t[4];
|
||||
typedef h5_float64_t h5_coord3d_t[3];
|
||||
|
||||
struct h5_vertex {
|
||||
h5_id_t vid;
|
||||
h5_id_t global_vid;
|
||||
h5_coord3d_t P;
|
||||
};
|
||||
typedef struct h5_vertex h5_vertex_t;
|
||||
|
||||
struct h5_triangle {
|
||||
h5_id_t eid;
|
||||
h5_id_t parent_eid;
|
||||
h5_id_t global_eid;
|
||||
h5_id_t global_parent_eid;
|
||||
h5_id_t refined_on_level;
|
||||
h5_3id_t vids;
|
||||
h5_3id_t global_vids;
|
||||
};
|
||||
typedef struct h5_triangle h5_triangle_t;
|
||||
|
||||
struct h5_tetrahedron {
|
||||
h5_id_t eid;
|
||||
h5_id_t parent_eid;
|
||||
h5_id_t global_eid;
|
||||
h5_id_t global_parent_eid;
|
||||
h5_id_t refined_on_level;
|
||||
h5_4id_t vids;
|
||||
h5_4id_t global_vids;
|
||||
};
|
||||
|
||||
struct h5_element {
|
||||
h5_id_t global_eid;
|
||||
h5_id_t global_parent_eid;
|
||||
h5_id_t refined_on_level;
|
||||
h5_id_t global_vids[1];
|
||||
};
|
||||
|
||||
|
||||
typedef struct h5_tetrahedron h5_tetrahedron_t;
|
||||
typedef struct h5_tetrahedron h5_tet_t;
|
||||
typedef struct h5_element h5_element_t;
|
||||
|
||||
struct h5_triangle_local {
|
||||
h5_id_t parent_eid;
|
||||
h5_3id_t vids; /* local(!) vertex ids */
|
||||
struct h5_triangle_data {
|
||||
h5_id_t local_parent_eid;
|
||||
h5_3id_t local_vids;
|
||||
};
|
||||
typedef struct h5_triangle_local h5_triangle_local_t;
|
||||
typedef struct h5_triangle_data h5_triangle_data_t;
|
||||
|
||||
struct h5_tet_local {
|
||||
h5_id_t parent_eid;
|
||||
h5_4id_t vids; /* local(!) vertex ids */
|
||||
struct h5_tet_data {
|
||||
h5_id_t local_parent_eid;
|
||||
h5_4id_t local_vids;
|
||||
};
|
||||
typedef struct h5_tet_local h5_tet_local_t;
|
||||
typedef struct h5_tet_data h5_tet_data_t;
|
||||
|
||||
struct h5_element_data {
|
||||
h5_id_t local_parent_eid;
|
||||
h5_id_t local_vids[1];
|
||||
};
|
||||
typedef struct h5_element_data h5_element_data_t;
|
||||
|
||||
|
||||
union h5_elems {
|
||||
h5_tet_t *tets;
|
||||
@@ -49,8 +65,8 @@ union h5_elems {
|
||||
typedef union h5_elems h5_elems_t;
|
||||
|
||||
union h5_elems_data {
|
||||
h5_tet_local_t *tets;
|
||||
h5_triangle_local_t *tris;
|
||||
h5_tet_data_t *tets;
|
||||
h5_triangle_data_t *tris;
|
||||
void *data;
|
||||
};
|
||||
typedef union h5_elems_data h5_elems_data_t;
|
||||
@@ -106,19 +122,20 @@ struct h5t_fdata {
|
||||
/*** book-keeping ***/
|
||||
char mesh_name[16];
|
||||
char mesh_label[256];
|
||||
h5_oid_t mesh_type; /* object id of element type */
|
||||
h5_id_t cur_mesh; /* id of current mesh */
|
||||
h5_id_t mesh_changed; /* true if new or has been changed */
|
||||
h5_id_t num_meshes; /* number of meshes */
|
||||
hid_t elem_tid; /* HDF5 type id: tet, triangle etc */
|
||||
h5_id_t cur_level; /* id of current level */
|
||||
h5_id_t new_level; /* idx of the first new level or -1 */
|
||||
h5_size_t num_levels; /* number of levels */
|
||||
h5_oid_t mesh_type; /* object id of element type */
|
||||
h5_id_t cur_mesh; /* id of current mesh */
|
||||
h5_id_t mesh_changed; /* true if new or has been changed */
|
||||
h5_id_t num_meshes; /* number of meshes */
|
||||
hid_t elem_tid; /* HDF5 type id: tet, triangle etc */
|
||||
h5_id_t cur_level; /* id of current level */
|
||||
h5_id_t new_level; /* idx of the first new level or -1 */
|
||||
h5_size_t num_levels; /* number of levels */
|
||||
h5_id_t level_changed;
|
||||
|
||||
/*** vertices ***/
|
||||
h5_vertex_t *vertices;
|
||||
h5_size_t *num_vertices;
|
||||
struct idmap map_vertex_g2l; /* map global id to local id */
|
||||
struct idmap map_vertex_g2l; /* map global id to local id */
|
||||
struct smap sorted_lvertices;
|
||||
h5_id_t last_retrieved_vid;
|
||||
h5_id_t last_stored_vid;
|
||||
@@ -128,10 +145,10 @@ struct h5t_fdata {
|
||||
|
||||
/*** Elements ***/
|
||||
h5_elems_t elems;
|
||||
h5_elems_data_t elems_data; /* local, per element data */
|
||||
h5_elems_data_t elems_data; /* local, per element data */
|
||||
h5_size_t *num_elems;
|
||||
h5_size_t *num_elems_on_level;
|
||||
struct idmap map_elem_g2l; /* map global id to local id */
|
||||
struct idmap map_elem_g2l; /* map global id to local id */
|
||||
|
||||
/*
|
||||
array with geometrically sorted local entitiy ids
|
||||
|
||||
+40
-48
@@ -21,11 +21,9 @@ _get_diskshape_for_reading (
|
||||
h5_file_t *f,
|
||||
hid_t dataset
|
||||
) {
|
||||
|
||||
herr_t r;
|
||||
struct h5u_fdata *u = f->u;
|
||||
|
||||
hid_t space;
|
||||
|
||||
TRY( space = _h5_get_dataset_space ( f, dataset ) );
|
||||
|
||||
if ( h5u_has_view ( f ) ) {
|
||||
@@ -44,17 +42,19 @@ _get_diskshape_for_reading (
|
||||
|
||||
/* now we select a subset */
|
||||
if ( u->diskshape > 0 ) {
|
||||
r = H5Sselect_hyperslab (
|
||||
u->diskshape, H5S_SELECT_SET,
|
||||
&start, &stride, &count, NULL);
|
||||
if ( r < 0 )
|
||||
return (hid_t)HANDLE_H5S_SELECT_HYPERSLAB_ERR ( f );
|
||||
TRY ( _h5_select_hyperslab_of_space (
|
||||
f,
|
||||
u->diskshape,
|
||||
H5S_SELECT_SET,
|
||||
&start, &stride, &count,
|
||||
NULL ) );
|
||||
}
|
||||
/* now we select a subset */
|
||||
r = H5Sselect_hyperslab (
|
||||
space,H5S_SELECT_SET,
|
||||
&start, &stride, &count, NULL );
|
||||
if ( r < 0 ) return (hid_t)HANDLE_H5S_SELECT_HYPERSLAB_ERR ( f );
|
||||
TRY ( _h5_select_hyperslab_of_space (
|
||||
f,
|
||||
space,
|
||||
H5S_SELECT_SET,
|
||||
&start, &stride, &count,
|
||||
NULL ) );
|
||||
|
||||
h5_debug (
|
||||
f,
|
||||
@@ -76,7 +76,7 @@ _get_memshape_for_reading (
|
||||
if ( h5u_has_view ( f ) ) {
|
||||
hsize_t dmax=H5S_UNLIMITED;
|
||||
hsize_t len = u->viewend - u->viewstart;
|
||||
return _h5_create_dataset_space ( f, 1, &len, &dmax );
|
||||
return _h5_create_space ( f, 1, &len, &dmax );
|
||||
} else {
|
||||
return H5S_ALL;
|
||||
}
|
||||
@@ -108,13 +108,10 @@ h5u_get_num_elems (
|
||||
TRY( space_id = _get_diskshape_for_reading ( f, dataset_id ) );
|
||||
|
||||
if ( h5u_has_view ( f ) ) {
|
||||
nparticles = H5Sget_select_npoints ( space_id );
|
||||
if ( nparticles < 0 ) return HANDLE_H5S_GET_SELECT_NPOINTS_ERR ( f );
|
||||
TRY ( nparticles = _h5_get_selected_npoints_of_space ( f, space_id ) );
|
||||
}
|
||||
else {
|
||||
nparticles = H5Sget_simple_extent_npoints ( space_id );
|
||||
if ( nparticles < 0 )
|
||||
return HANDLE_H5S_GET_SIMPLE_EXTENT_NPOINTS_ERR ( f );
|
||||
TRY ( nparticles = _h5_get_npoints_of_space ( f, space_id ) );
|
||||
}
|
||||
TRY( _h5_close_dataspace( f, space_id ) );
|
||||
TRY( _h5_close_dataset( f, dataset_id ) );
|
||||
@@ -175,14 +172,14 @@ h5u_set_num_elements (
|
||||
}
|
||||
#endif
|
||||
TRY( _h5_close_dataspace( f, u->diskshape ) );
|
||||
u->diskshape = H5S_ALL;
|
||||
TRY( _h5_close_dataspace( f, u->memshape ) );
|
||||
u->memshape = H5S_ALL;
|
||||
TRY( _h5_close_dataspace( f, u->shape ) );
|
||||
u->diskshape = H5S_ALL;
|
||||
u->memshape = H5S_ALL;
|
||||
u->shape = H5S_ALL;
|
||||
u->nparticles =(hsize_t) nparticles;
|
||||
#ifndef PARALLEL_IO
|
||||
TRY( u->shape = _h5_create_dataset_space (
|
||||
TRY( u->shape = _h5_create_space (
|
||||
f,
|
||||
1,
|
||||
&(u->nparticles),
|
||||
@@ -211,13 +208,11 @@ h5u_set_num_elements (
|
||||
acquire the number of particles to be written from each MPI process
|
||||
*/
|
||||
|
||||
r = MPI_Allgather (
|
||||
TRY ( _h5_mpi_allgather (
|
||||
&nparticles, 1, MPI_LONG_LONG,
|
||||
f->pnparticles, 1, MPI_LONG_LONG,
|
||||
f->comm);
|
||||
if ( r != MPI_SUCCESS) {
|
||||
return HANDLE_MPI_ALLGATHER_ERR;
|
||||
}
|
||||
f->comm ) );
|
||||
|
||||
if ( f->myproc == 0 ) {
|
||||
h5_debug ( "Particle offsets:" );
|
||||
for(i=0;i<f->nprocs;i++)
|
||||
@@ -240,23 +235,22 @@ h5u_set_num_elements (
|
||||
}
|
||||
|
||||
/* declare overall datasize */
|
||||
TRY ( f->shape = _h5_create_dataset_space ( f, 1, &total, &total ) );
|
||||
TRY ( f->shape = _h5_create_space ( f, 1, &total, &total ) );
|
||||
|
||||
/* declare overall data size but then will select a subset */
|
||||
TRY ( f->diskshape = _h5_create_dataset_space ( f, 1, &total, &total) );
|
||||
TRY ( f->diskshape = _h5_create_space ( f, 1, &total, &total) );
|
||||
|
||||
/* declare local memory datasize */
|
||||
TRY ( f->memshape = _h5_create_dataset_space (
|
||||
TRY ( f->memshape = _h5_create_space (
|
||||
f, 1, &(f->nparticles), &dmax ) );
|
||||
|
||||
count[0] = nparticles;
|
||||
r = H5Sselect_hyperslab (
|
||||
f->diskshape,
|
||||
H5S_SELECT_SET,
|
||||
start,
|
||||
stride,
|
||||
count, NULL );
|
||||
if ( r < 0 ) return HANDLE_H5S_SELECT_HYPERSLAB_ERR;
|
||||
TRY ( _h5_select_hyperslab_of_space (
|
||||
f,
|
||||
f->diskshape,
|
||||
H5S_SELECT_SET,
|
||||
start, stride, count,
|
||||
NULL ) );
|
||||
|
||||
if ( f->step_gid < 0 ) {
|
||||
TRY ( h5_set_step ( f, 0 ) );
|
||||
@@ -361,23 +355,21 @@ h5u_set_view (
|
||||
u->nparticles = end - start + 1;
|
||||
|
||||
/* declare overall datasize */
|
||||
TRY ( u->shape = _h5_create_dataset_space ( f, 1, &total, &total ) );
|
||||
TRY ( u->shape = _h5_create_space ( f, 1, &total, &total ) );
|
||||
|
||||
/* declare overall data size but then will select a subset */
|
||||
TRY ( u->diskshape= _h5_create_dataset_space ( f, 1, &total, &total ) );
|
||||
TRY ( u->diskshape= _h5_create_space ( f, 1, &total, &total ) );
|
||||
|
||||
/* declare local memory datasize */
|
||||
TRY ( u->memshape = _h5_create_dataset_space (
|
||||
TRY ( u->memshape = _h5_create_space (
|
||||
f, 1, &(u->nparticles), &dmax ) );
|
||||
|
||||
herr = H5Sselect_hyperslab (
|
||||
u->diskshape,
|
||||
H5S_SELECT_SET,
|
||||
(hsize_t*)&start,
|
||||
&stride,
|
||||
&total,
|
||||
NULL );
|
||||
if ( herr < 0 ) return HANDLE_H5S_SELECT_HYPERSLAB_ERR ( f );
|
||||
TRY ( _h5_select_hyperslab_of_space (
|
||||
f,
|
||||
u->diskshape,
|
||||
H5S_SELECT_SET,
|
||||
(hsize_t*)&start, &stride, &total,
|
||||
NULL ) );
|
||||
|
||||
return H5_SUCCESS;
|
||||
}
|
||||
|
||||
@@ -76,8 +76,13 @@ hdf5_get_num_objects_matching_pattern (
|
||||
data.type = type;
|
||||
data.pattern = pattern;
|
||||
|
||||
TRY( H5Giterate ( group_id, group_name, &idx,
|
||||
_iteration_operator, &data ) );
|
||||
/*
|
||||
H5Giterate return a negative value, if no matching object
|
||||
was found! How can we handle an error?
|
||||
Anyway: H5Giterate is depricated in hdf5 >= 1.8!
|
||||
*/
|
||||
H5Giterate ( group_id, group_name, &idx,
|
||||
_iteration_operator, &data );
|
||||
|
||||
return data.count;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user