reorganize language bindings
This commit is contained in:
+268
@@ -0,0 +1,268 @@
|
||||
/*
|
||||
Copyright 2007-2008
|
||||
Paul Scherrer Institut, Villigen, Switzerland;
|
||||
Benedikt Oswald;
|
||||
Achim Gsell
|
||||
All rights reserved.
|
||||
|
||||
Authors
|
||||
Achim Gsell
|
||||
|
||||
Warning
|
||||
This code is under development.
|
||||
|
||||
*/
|
||||
|
||||
/*!
|
||||
Some conventions:
|
||||
Functions:
|
||||
Name:
|
||||
thisIsAFunction()
|
||||
Return values:
|
||||
negative value or NULL signals an error
|
||||
|
||||
|
||||
Macros:
|
||||
UPPERCASE_WITH_UNDERSCORE
|
||||
\note
|
||||
In function names we use the words \b get and \b store insteed of
|
||||
\b read and \b write, because no I/O is actually done in these
|
||||
functions.
|
||||
*/
|
||||
|
||||
|
||||
/*!
|
||||
\ingroup h5_c_api
|
||||
\defgroup h5_c_api_general
|
||||
*/
|
||||
|
||||
#include <stdarg.h>
|
||||
#include <hdf5.h>
|
||||
#include "h5_core/h5_core.h"
|
||||
#include "h5_core/h5_core_private.h"
|
||||
#include "H5.h"
|
||||
|
||||
/****** General routines *****************************************************/
|
||||
|
||||
/*!
|
||||
\ingroup h5_c_api_general
|
||||
|
||||
Open file with name \c filename. This function is available in the paralell
|
||||
and serial version. In the serial case \c comm may have any value.
|
||||
|
||||
\return File handle.
|
||||
\return NULL on error.
|
||||
*/
|
||||
h5_file_t *
|
||||
H5OpenFile (
|
||||
const char * filename, /*!< file name */
|
||||
const h5_int32_t oflag, /*!< file open flags */
|
||||
const MPI_Comm comm /*!< MPI communicator */
|
||||
) {
|
||||
return h5_open_file( filename, H5_O_RDWR, comm, __func__ );
|
||||
}
|
||||
|
||||
/*!
|
||||
\ingroup h5_c_api_general
|
||||
|
||||
Close file.
|
||||
|
||||
\return \c H5_SUCCESS or error code
|
||||
*/
|
||||
h5_err_t
|
||||
H5CloseFile (
|
||||
h5_file_t * const f /*!< file handle */
|
||||
) {
|
||||
SET_FNAME ( f, __func__ );
|
||||
return h5_close_file ( f );
|
||||
}
|
||||
|
||||
/*!
|
||||
\ingroup h5_c_api_general
|
||||
|
||||
Define format of the step names.
|
||||
|
||||
Example: ==H5FedDefineStepNameFormat( f, "Step", 6 )== defines step names
|
||||
like ==Step#000042==.
|
||||
|
||||
\return \c H5_SUCCESS or error code
|
||||
*/
|
||||
h5_err_t
|
||||
H5DefineStepNameFormat (
|
||||
h5_file_t *f, /*!< Handle to file */
|
||||
const char *name, /*!< Prefix */
|
||||
const h5_int64_t width /*!< Width of the number */
|
||||
) {
|
||||
SET_FNAME ( f, __func__ );
|
||||
|
||||
return h5_set_stepname_fmt( f, name, width );
|
||||
}
|
||||
|
||||
/*!
|
||||
\ingroup h5_c_api_general
|
||||
|
||||
Get format of the step names.
|
||||
|
||||
\return value \c >=0 on success
|
||||
\return -1 on error
|
||||
*/
|
||||
h5_err_t
|
||||
H5GetStepNameFormat (
|
||||
h5_file_t *f, /*!< Handle to file */
|
||||
char *name, /*!< OUT: Prefix */
|
||||
const h5_size_t l_name, /*!< length of buffer name */
|
||||
h5_size_t *width /*!< OUT: Width of the number */
|
||||
) {
|
||||
SET_FNAME ( f, __func__ );
|
||||
|
||||
return h5_get_stepname_fmt( f, name, l_name, width );
|
||||
}
|
||||
|
||||
/*!
|
||||
\ingroup h5_c_api_general
|
||||
|
||||
Set the current step.
|
||||
|
||||
\return \c H5_SUCCESS or error code
|
||||
*/
|
||||
h5_err_t
|
||||
H5SetStep (
|
||||
h5_file_t *f, /*!< [in] Handle to open file */
|
||||
const h5_int64_t step /*!< [in] Step to set. */
|
||||
) {
|
||||
|
||||
SET_FNAME ( f, __func__ );
|
||||
return h5_set_step ( f, step );
|
||||
}
|
||||
|
||||
/*!
|
||||
\ingroup h5_c_api_general
|
||||
|
||||
Get current step.
|
||||
|
||||
\return \c H5_SUCCESS or error code
|
||||
*/
|
||||
h5_id_t
|
||||
H5GetStep (
|
||||
h5_file_t *f /*!< Handle to open file */
|
||||
) {
|
||||
|
||||
SET_FNAME ( f, __func__ );
|
||||
return h5_get_step ( f );
|
||||
}
|
||||
|
||||
/*!
|
||||
\ingroup h5_c_api_general
|
||||
|
||||
Start traversing steps.
|
||||
|
||||
\return \c H5_SUCCESS or error code
|
||||
*/
|
||||
h5_err_t
|
||||
H5StartTraverseSteps (
|
||||
h5_file_t *f /*!< Handle to open file */
|
||||
) {
|
||||
|
||||
SET_FNAME ( f, __func__ );
|
||||
|
||||
return h5_start_traverse_steps( f );
|
||||
}
|
||||
|
||||
/*!
|
||||
\ingroup h5_c_api_general
|
||||
|
||||
Traverse steps.
|
||||
|
||||
\return \c H5_SUCCESS or error code
|
||||
*/
|
||||
h5_err_t
|
||||
H5TraverseSteps (
|
||||
h5_file_t * f /*!< Handle to open file */
|
||||
) {
|
||||
|
||||
SET_FNAME ( f, __func__ );
|
||||
|
||||
return h5_traverse_steps( f );
|
||||
}
|
||||
|
||||
/*!
|
||||
\ingroup h5part_c_api
|
||||
\defgroup h5part_c_api_errhandling Error Handling
|
||||
*/
|
||||
|
||||
/*!
|
||||
\ingroup h5part_c_api_errhandling
|
||||
|
||||
Set verbosity level to \c level.
|
||||
|
||||
\return \c H5_SUCCESS
|
||||
*/
|
||||
h5_err_t
|
||||
H5SetVerbosityLevel (
|
||||
const h5_id_t level
|
||||
) {
|
||||
|
||||
return h5_set_debuglevel ( level );
|
||||
}
|
||||
|
||||
/*!
|
||||
\ingroup h5part_c_api_errhandling
|
||||
|
||||
Set error handler to \c handler.
|
||||
|
||||
\return \c H5_SUCCESS
|
||||
*/
|
||||
h5_err_t
|
||||
H5SetErrorHandler (
|
||||
h5_errorhandler_t handler
|
||||
) {
|
||||
|
||||
return h5_set_errorhandler( handler );
|
||||
}
|
||||
|
||||
/*!
|
||||
\ingroup h5part_c_api_errhandling
|
||||
|
||||
Get current error handler.
|
||||
|
||||
\return Pointer to error handler.
|
||||
*/
|
||||
h5_errorhandler_t
|
||||
H5GetErrorHandler (
|
||||
void
|
||||
) {
|
||||
return h5_get_errorhandler();
|
||||
}
|
||||
|
||||
h5_err_t
|
||||
H5ReportErrorhandler (
|
||||
h5_file_t * const f,
|
||||
const char *fmt,
|
||||
va_list ap
|
||||
) {
|
||||
return h5_report_errorhandler ( f, fmt, ap );
|
||||
}
|
||||
|
||||
h5_err_t
|
||||
H5AbortErrorhandler (
|
||||
h5_file_t * const f,
|
||||
const char *fmt,
|
||||
va_list ap
|
||||
) {
|
||||
return h5_abort_errorhandler ( f, fmt, ap );
|
||||
}
|
||||
|
||||
/*!
|
||||
\ingroup h5part_c_api_errhandling
|
||||
|
||||
Get last error code.
|
||||
|
||||
\return error code
|
||||
*/
|
||||
h5_err_t
|
||||
H5GetErrno (
|
||||
h5_file_t * const f
|
||||
) {
|
||||
return h5_get_errno( f );
|
||||
}
|
||||
/*! @} */
|
||||
+108
@@ -0,0 +1,108 @@
|
||||
/*
|
||||
Copyright 2007-2008
|
||||
Paul Scherrer Institut, Villigen, Switzerland;
|
||||
Benedikt Oswald;
|
||||
Achim Gsell
|
||||
All rights reserved.
|
||||
|
||||
Authors
|
||||
Achim Gsell
|
||||
|
||||
Warning
|
||||
This code is under development.
|
||||
|
||||
*/
|
||||
|
||||
#ifndef __H5_H
|
||||
#define __H5_H
|
||||
|
||||
#include "H5_inquiry.h"
|
||||
|
||||
h5_file_t *
|
||||
H5OpenFile (
|
||||
const char * filename,
|
||||
const h5_int32_t oflag,
|
||||
const MPI_Comm comm
|
||||
);
|
||||
|
||||
h5_err_t
|
||||
H5CloseFile (
|
||||
h5_file_t * f
|
||||
);
|
||||
|
||||
h5_err_t
|
||||
H5SetStepNameFormat (
|
||||
h5_file_t *f,
|
||||
const char *name,
|
||||
const h5_int64_t width
|
||||
);
|
||||
|
||||
h5_err_t
|
||||
H5GetStepNameFormat (
|
||||
h5_file_t *f,
|
||||
char *name,
|
||||
const h5_size_t l_name,
|
||||
h5_size_t *width
|
||||
);
|
||||
|
||||
h5_err_t
|
||||
H5SetStep (
|
||||
h5_file_t *f,
|
||||
const h5_int64_t step
|
||||
);
|
||||
|
||||
h5_int64_t
|
||||
H5GetStep (
|
||||
h5_file_t *f
|
||||
);
|
||||
|
||||
h5_err_t
|
||||
H5StartTraverseSteps (
|
||||
h5_file_t *f
|
||||
);
|
||||
|
||||
h5_id_t
|
||||
H5TraverseSteps (
|
||||
h5_file_t *f
|
||||
);
|
||||
|
||||
h5_err_t
|
||||
H5EndTraverseSteps (
|
||||
h5_file_t *f
|
||||
);
|
||||
|
||||
h5_err_t
|
||||
H5SetVerbosityLevel (
|
||||
const h5_id_t level
|
||||
);
|
||||
|
||||
h5_err_t
|
||||
H5SetErrorHandler (
|
||||
h5_errorhandler_t handler
|
||||
);
|
||||
|
||||
h5_errorhandler_t
|
||||
H5GetErrorHandler (
|
||||
void
|
||||
);
|
||||
|
||||
h5_err_t
|
||||
H5ReportErrorhandler (
|
||||
h5_file_t * const f,
|
||||
const char *fmt,
|
||||
va_list ap
|
||||
);
|
||||
|
||||
h5_err_t
|
||||
H5AbortErrorhandler (
|
||||
h5_file_t * const f,
|
||||
const char *fmt,
|
||||
va_list ap
|
||||
);
|
||||
|
||||
h5_err_t
|
||||
H5GetErrno (
|
||||
h5_file_t * const f
|
||||
);
|
||||
|
||||
#endif
|
||||
+1852
File diff suppressed because it is too large
Load Diff
+204
@@ -0,0 +1,204 @@
|
||||
#ifndef __H5BLOCK_H
|
||||
#define __H5BLOCK_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/*!
|
||||
Interface for block structured field data
|
||||
|
||||
*/
|
||||
|
||||
h5_int64_t
|
||||
H5BlockDefine3DFieldLayout (
|
||||
h5_file_t *f,
|
||||
const h5_int64_t i_start,
|
||||
const h5_int64_t i_end,
|
||||
const h5_int64_t j_start,
|
||||
const h5_int64_t j_end,
|
||||
const h5_int64_t k_start,
|
||||
const h5_int64_t k_end
|
||||
);
|
||||
|
||||
h5_int64_t
|
||||
H5Block3dGetPartitionOfProc (
|
||||
h5_file_t *f,
|
||||
const h5_int64_t proc,
|
||||
h5_int64_t *i_start,
|
||||
h5_int64_t *i_end,
|
||||
h5_int64_t *j_start,
|
||||
h5_int64_t *j_end,
|
||||
h5_int64_t *k_start,
|
||||
h5_int64_t *k_end
|
||||
);
|
||||
|
||||
h5_int64_t
|
||||
H5Block3dGetReducedPartitionOfProc (
|
||||
h5_file_t *f,
|
||||
h5_int64_t proc,
|
||||
h5_int64_t *i_start,
|
||||
h5_int64_t *i_end,
|
||||
h5_int64_t *j_start,
|
||||
h5_int64_t *j_end,
|
||||
h5_int64_t *k_start,
|
||||
h5_int64_t *k_end
|
||||
);
|
||||
|
||||
h5_int64_t
|
||||
H5Block3dGetProcOf (
|
||||
h5_file_t *f,
|
||||
h5_int64_t i,
|
||||
h5_int64_t j,
|
||||
h5_int64_t k
|
||||
);
|
||||
|
||||
h5_int64_t
|
||||
H5Block3dWriteScalarField (
|
||||
h5_file_t *f,
|
||||
const char *name,
|
||||
const h5_float64_t *data
|
||||
);
|
||||
|
||||
h5_int64_t
|
||||
H5Block3dReadScalarField (
|
||||
h5_file_t *f,
|
||||
const char *name,
|
||||
h5_float64_t *data
|
||||
);
|
||||
|
||||
h5_int64_t
|
||||
H5BlockGetNumFields (
|
||||
h5_file_t *f
|
||||
);
|
||||
|
||||
h5_int64_t
|
||||
H5BlockGetFieldInfo (
|
||||
h5_file_t *f,
|
||||
const h5_int64_t idx,
|
||||
char *name,
|
||||
const h5_int64_t len_name,
|
||||
h5_int64_t *grid_rank,
|
||||
h5_int64_t *grid_dims,
|
||||
h5_int64_t *field_dims
|
||||
);
|
||||
|
||||
h5_int64_t
|
||||
H5BlockGetFieldInfoByName (
|
||||
h5_file_t *f,
|
||||
const char *field_name,
|
||||
h5_int64_t *grid_rank,
|
||||
h5_int64_t *grid_dims,
|
||||
h5_int64_t *field_dims
|
||||
);
|
||||
|
||||
h5_int64_t
|
||||
H5Block3dGetFieldOrigin (
|
||||
h5_file_t *f,
|
||||
const char *field_name,
|
||||
h5_float64_t *x_origin,
|
||||
h5_float64_t *y_origin,
|
||||
h5_float64_t *z_origin
|
||||
);
|
||||
|
||||
h5_int64_t
|
||||
H5Block3dSetFieldOrigin (
|
||||
h5_file_t *f,
|
||||
const char *field_name,
|
||||
const h5_float64_t x_origin,
|
||||
const h5_float64_t y_origin,
|
||||
const h5_float64_t z_origin
|
||||
);
|
||||
|
||||
h5_int64_t
|
||||
H5Block3dGetFieldSpacing (
|
||||
h5_file_t *f,
|
||||
const char *field_name,
|
||||
h5_float64_t *x_spacing,
|
||||
h5_float64_t *y_spacing,
|
||||
h5_float64_t *z_spacing
|
||||
);
|
||||
|
||||
h5_int64_t
|
||||
H5Block3dSetFieldSpacing (
|
||||
h5_file_t *f,
|
||||
const char *field_name,
|
||||
const h5_float64_t x_spacing,
|
||||
const h5_float64_t y_spacing,
|
||||
const h5_float64_t z_spacing
|
||||
);
|
||||
|
||||
|
||||
|
||||
h5_int64_t
|
||||
H5Block3dWrite3dVectorField (
|
||||
h5_file_t *f,
|
||||
const char *name,
|
||||
const h5_float64_t *xval,
|
||||
const h5_float64_t *yval,
|
||||
const h5_float64_t *zval
|
||||
);
|
||||
|
||||
h5_int64_t
|
||||
H5Block3dRead3dVectorField (
|
||||
h5_file_t *f,
|
||||
const char *name,
|
||||
h5_float64_t *xval,
|
||||
h5_float64_t *yval,
|
||||
h5_float64_t *zval
|
||||
);
|
||||
|
||||
h5_int64_t
|
||||
H5BlockWriteFieldAttrib (
|
||||
h5_file_t *f,
|
||||
const char *field_name,
|
||||
const char *attrib_name,
|
||||
const h5_int64_t attrib_type,
|
||||
const void *attrib_value,
|
||||
const h5_int64_t attrib_nelem
|
||||
);
|
||||
|
||||
h5_int64_t
|
||||
H5BlockWriteFieldAttribString (
|
||||
h5_file_t *f,
|
||||
const char *field_name,
|
||||
const char *attrib_name,
|
||||
const char *attrib_value
|
||||
);
|
||||
|
||||
h5_int64_t
|
||||
H5BlockGetNumFieldAttribs (
|
||||
h5_file_t *f,
|
||||
const char *field_name
|
||||
);
|
||||
|
||||
h5_int64_t
|
||||
H5BlockGetFieldAttribInfo (
|
||||
h5_file_t *f,
|
||||
const char *field_name,
|
||||
const h5_int64_t attrib_idx,
|
||||
char *attrib_name,
|
||||
const h5_int64_t len_of_attrib_name,
|
||||
h5_int64_t *attrib_type,
|
||||
h5_int64_t *attrib_nelem
|
||||
);
|
||||
|
||||
h5_int64_t
|
||||
H5BlockReadFieldAttrib (
|
||||
h5_file_t *f,
|
||||
const char *field_name,
|
||||
const char *attrib_name,
|
||||
void *attrib_value
|
||||
);
|
||||
|
||||
h5_int64_t
|
||||
H5BlockHasFieldData (
|
||||
h5_file_t *f
|
||||
);
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,54 @@
|
||||
/*
|
||||
Copyright 2007-2009
|
||||
Paul Scherrer Institut, Villigen, Switzerland;
|
||||
Benedikt Oswald;
|
||||
Achim Gsell
|
||||
All rights reserved.
|
||||
|
||||
Authors
|
||||
Achim Gsell
|
||||
|
||||
Warning
|
||||
This code is under development.
|
||||
|
||||
*/
|
||||
|
||||
#include <stdarg.h>
|
||||
#include <hdf5.h>
|
||||
#include "h5_core/h5_core.h"
|
||||
#include "h5_core/h5_core_private.h"
|
||||
#include "H5Fed.h"
|
||||
|
||||
h5_err_t
|
||||
H5FedOpenMesh (
|
||||
h5_file_t * const f,
|
||||
const h5_id_t mesh_id,
|
||||
const h5_oid_t mesh_type_id
|
||||
) {
|
||||
SET_FNAME ( f, __func__ );
|
||||
return h5t_open_mesh ( f, mesh_id, mesh_type_id );
|
||||
}
|
||||
|
||||
h5_err_t
|
||||
H5FedCloseMesh (
|
||||
h5_file_t * const f
|
||||
) {
|
||||
return h5_error_not_implemented ( f, __FILE__, __func__, __LINE__ );
|
||||
}
|
||||
|
||||
h5_err_t
|
||||
H5FedSetLevel (
|
||||
h5_file_t * const f,
|
||||
const h5_id_t level_id
|
||||
) {
|
||||
SET_FNAME ( f, __func__ );
|
||||
return h5t_open_level ( f, level_id );
|
||||
}
|
||||
|
||||
h5_err_t
|
||||
H5FedLinkMeshToStep (
|
||||
h5_file_t * f,
|
||||
const h5_id_t mesh_id
|
||||
) {
|
||||
return h5_error_not_implemented ( f, __FILE__, __func__, __LINE__ );
|
||||
}
|
||||
@@ -0,0 +1,70 @@
|
||||
/*
|
||||
Header file for declaring the H5Fed application programming
|
||||
interface (API) in the C language.
|
||||
|
||||
Copyright 2006-2007
|
||||
Paul Scherrer Institut, Villigen, Switzerland;
|
||||
Benedikt Oswald;
|
||||
Achim Gsell
|
||||
All rights reserved.
|
||||
|
||||
Authors
|
||||
Achim Gsell
|
||||
|
||||
Warning
|
||||
This code is under development.
|
||||
|
||||
*/
|
||||
|
||||
#ifndef __H5FED_H
|
||||
#define __H5FED_H
|
||||
|
||||
#include "H5.h"
|
||||
#include "H5Fed_adjacency.h"
|
||||
#include "H5Fed_inquiry.h"
|
||||
#include "H5Fed_map.h"
|
||||
#include "H5Fed_retrieve.h"
|
||||
#include "H5Fed_store.h"
|
||||
#include "H5Fed_tags.h"
|
||||
|
||||
/****** General routines *****************************************************/
|
||||
|
||||
h5_err_t
|
||||
H5FedOpenMesh (
|
||||
h5_file_t * const f,
|
||||
const h5_id_t mesh_id,
|
||||
const h5_oid_t mesh_type_id
|
||||
);
|
||||
|
||||
h5_err_t
|
||||
H5FedCloseMesh (
|
||||
h5_file_t * const f
|
||||
);
|
||||
|
||||
h5_err_t
|
||||
H5FedSetLevel (
|
||||
h5_file_t * f,
|
||||
const h5_id_t level_id
|
||||
);
|
||||
|
||||
h5_err_t
|
||||
H5FedLinkMeshToStep (
|
||||
h5_file_t * f,
|
||||
const h5_id_t mesh_id
|
||||
);
|
||||
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1,153 @@
|
||||
/*
|
||||
Copyright 2006-2007
|
||||
Paul Scherrer Institut, Villigen, Switzerland;
|
||||
Benedikt Oswald;
|
||||
Achim Gsell
|
||||
All rights reserved.
|
||||
|
||||
Authors
|
||||
Achim Gsell
|
||||
|
||||
Warning
|
||||
This code is under development.
|
||||
|
||||
*/
|
||||
|
||||
#include <hdf5.h>
|
||||
#include "h5_core/h5_types.h"
|
||||
#include "h5_core/h5_core.h"
|
||||
#include "H5Fed.h"
|
||||
|
||||
/****** UPWARD ADJACENCY routines *********************************************/
|
||||
|
||||
/*!
|
||||
\return number of upward adjacent edges
|
||||
*/
|
||||
h5_err_t
|
||||
H5FedGetEdgesUpAdjacentToVertex (
|
||||
h5_file_t * const f,
|
||||
const h5_id_t local_vid,
|
||||
h5_idlist_t **list
|
||||
) {
|
||||
SET_FNAME ( f, __func__ );
|
||||
return h5t_get_edges_upadjacent_to_vertex ( f, local_vid, list );
|
||||
}
|
||||
|
||||
h5_err_t
|
||||
H5FedGetTrianglesUpAdjacentToVertex (
|
||||
h5_file_t * const f,
|
||||
const h5_id_t local_vid,
|
||||
h5_idlist_t **list
|
||||
) {
|
||||
SET_FNAME ( f, __func__ );
|
||||
return h5t_get_triangles_upadjacent_to_vertex ( f, local_vid, list );
|
||||
}
|
||||
|
||||
h5_err_t
|
||||
H5FedGetTetsUpAdjacentToVertex (
|
||||
h5_file_t * const f,
|
||||
const h5_id_t local_vid,
|
||||
h5_idlist_t **list
|
||||
) {
|
||||
SET_FNAME ( f, __func__ );
|
||||
return h5t_get_tets_upadjacent_to_vertex ( f, local_vid, list );
|
||||
}
|
||||
|
||||
h5_err_t
|
||||
H5FedGetTrianglesUpAdjacentToEdge (
|
||||
h5_file_t * const f,
|
||||
const h5_id_t local_kid,
|
||||
h5_idlist_t **list
|
||||
) {
|
||||
SET_FNAME ( f, __func__ );
|
||||
return h5t_get_triangles_upadjacent_to_edge ( f, local_kid, list );
|
||||
}
|
||||
|
||||
h5_err_t
|
||||
H5FedGetTetsUpAdjacentToEdge (
|
||||
h5_file_t * const f,
|
||||
const h5_id_t local_kid,
|
||||
h5_idlist_t **list
|
||||
) {
|
||||
SET_FNAME ( f, __func__ );
|
||||
return h5t_get_tets_upadjacent_to_edge ( f, local_kid, list );
|
||||
}
|
||||
|
||||
h5_err_t
|
||||
H5FedGetTetsUpAdjacentToTriangle (
|
||||
h5_file_t * const f,
|
||||
const h5_id_t local_did,
|
||||
h5_idlist_t **list
|
||||
) {
|
||||
SET_FNAME ( f, __func__ );
|
||||
return h5t_get_tets_upadjacent_to_triangle ( f, local_did, list );
|
||||
}
|
||||
|
||||
h5_err_t
|
||||
H5FedGetVerticesDownAdjacentToEdge (
|
||||
h5_file_t * const f,
|
||||
const h5_id_t local_kid,
|
||||
h5_idlist_t **list
|
||||
) {
|
||||
SET_FNAME ( f, __func__ );
|
||||
return h5t_get_vertices_downadjacent_to_edge ( f, local_kid, list );
|
||||
}
|
||||
|
||||
h5_err_t
|
||||
H5FedGetVerticesDownAdjacentToTriangle (
|
||||
h5_file_t * const f,
|
||||
const h5_id_t local_did,
|
||||
h5_idlist_t **list
|
||||
) {
|
||||
SET_FNAME ( f, __func__ );
|
||||
return h5t_get_vertices_downadjacent_to_triangle ( f, local_did, list );
|
||||
}
|
||||
|
||||
h5_err_t
|
||||
H5FedGetVerticesDownAdjacentToTet (
|
||||
h5_file_t * const f,
|
||||
const h5_id_t local_tid,
|
||||
h5_idlist_t **list
|
||||
) {
|
||||
SET_FNAME ( f, __func__ );
|
||||
return h5t_get_vertices_downadjacent_to_tet ( f, local_tid, list );
|
||||
}
|
||||
|
||||
h5_err_t
|
||||
H5FedGetEdgesDownAdjacentToTriangle (
|
||||
h5_file_t * const f,
|
||||
const h5_id_t local_did,
|
||||
h5_idlist_t **list
|
||||
) {
|
||||
SET_FNAME ( f, __func__ );
|
||||
return h5t_get_edges_downadjacent_to_triangle ( f, local_did, list );
|
||||
}
|
||||
|
||||
h5_err_t
|
||||
H5FedGetEdgesDownAdjacentToTet (
|
||||
h5_file_t * const f,
|
||||
const h5_id_t local_tid,
|
||||
h5_idlist_t **list
|
||||
) {
|
||||
SET_FNAME ( f, __func__ );
|
||||
return h5t_get_edges_downadjacent_to_tet ( f, local_tid, list );
|
||||
}
|
||||
|
||||
h5_err_t
|
||||
H5FedGetTrianglesDownAdjacentToTet (
|
||||
h5_file_t * const f,
|
||||
const h5_id_t local_tid,
|
||||
h5_idlist_t **list
|
||||
) {
|
||||
SET_FNAME ( f, __func__ );
|
||||
return h5t_get_triangles_downadjacent_to_tet ( f, local_tid, list );
|
||||
}
|
||||
|
||||
h5_err_t
|
||||
H5FedReleaseListOfAdjacencies (
|
||||
h5_file_t * const f,
|
||||
h5_idlist_t **list
|
||||
) {
|
||||
SET_FNAME ( f, __func__ );
|
||||
return h5priv_free_idlist ( f, list );
|
||||
}
|
||||
@@ -0,0 +1,94 @@
|
||||
#ifndef __H5FED_ADJACENCY_H
|
||||
#define __H5FED_ADJACENCY_H
|
||||
|
||||
h5_err_t
|
||||
H5FedGetEdgesUpAdjacentToVertex (
|
||||
h5_file_t * const f,
|
||||
const h5_id_t local_vid,
|
||||
h5_idlist_t **list
|
||||
);
|
||||
|
||||
h5_err_t
|
||||
H5FedGetTrianglesUpAdjacentToVertex (
|
||||
h5_file_t * const f,
|
||||
const h5_id_t local_vid,
|
||||
h5_idlist_t **list
|
||||
);
|
||||
|
||||
h5_err_t
|
||||
H5FedGetTetsUpAdjacentToVertex (
|
||||
h5_file_t * const f,
|
||||
const h5_id_t local_vid,
|
||||
h5_idlist_t **list
|
||||
);
|
||||
|
||||
h5_err_t
|
||||
H5FedGetTrianglesUpAdjacentToEdge (
|
||||
h5_file_t * const f,
|
||||
const h5_id_t local_kid,
|
||||
h5_idlist_t **list
|
||||
);
|
||||
|
||||
h5_err_t
|
||||
H5FedGetTetsUpAdjacentToEdge (
|
||||
h5_file_t * const f,
|
||||
const h5_id_t local_kid,
|
||||
h5_idlist_t **list
|
||||
);
|
||||
|
||||
h5_err_t
|
||||
H5FedGetTetsUpAdjacentToTriangle (
|
||||
h5_file_t * const f,
|
||||
const h5_id_t local_did,
|
||||
h5_idlist_t **list
|
||||
);
|
||||
|
||||
h5_err_t
|
||||
H5FedGetVerticesDownAdjacentToEdge (
|
||||
h5_file_t * const f,
|
||||
const h5_id_t local_kid,
|
||||
h5_idlist_t **list
|
||||
);
|
||||
|
||||
h5_err_t
|
||||
H5FedGetVerticesDownAdjacentToTriangle (
|
||||
h5_file_t * const f,
|
||||
const h5_id_t local_did,
|
||||
h5_idlist_t **list
|
||||
);
|
||||
|
||||
h5_err_t
|
||||
H5FedGetVerticesDownAdjacentToTet (
|
||||
h5_file_t * const f,
|
||||
const h5_id_t local_tid,
|
||||
h5_idlist_t **list
|
||||
);
|
||||
|
||||
h5_err_t
|
||||
H5FedGetEdgesDownAdjacentToTriangle (
|
||||
h5_file_t * const f,
|
||||
const h5_id_t local_did,
|
||||
h5_idlist_t **list
|
||||
);
|
||||
|
||||
h5_err_t
|
||||
H5FedGetEdgesDownAdjacentToTet (
|
||||
h5_file_t * const f,
|
||||
const h5_id_t local_tid,
|
||||
h5_idlist_t **list
|
||||
);
|
||||
|
||||
h5_err_t
|
||||
H5FedGetTrianglesDownAdjacentToTet (
|
||||
h5_file_t * const f,
|
||||
const h5_id_t local_tid,
|
||||
h5_idlist_t **list
|
||||
);
|
||||
|
||||
h5_err_t
|
||||
H5FedReleaseListOfAdjacencies (
|
||||
h5_file_t * const f,
|
||||
h5_idlist_t **list
|
||||
);
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,169 @@
|
||||
/*
|
||||
Copyright 2007-2008
|
||||
Paul Scherrer Institut, Villigen, Switzerland;
|
||||
Benedikt Oswald;
|
||||
Achim Gsell
|
||||
All rights reserved.
|
||||
|
||||
Authors
|
||||
Achim Gsell
|
||||
|
||||
Warning
|
||||
This code is under development.
|
||||
|
||||
*/
|
||||
/*!
|
||||
\ingroup h5fed_c_api
|
||||
\defgroup h5fed_mesh_inquiry
|
||||
*/
|
||||
|
||||
#include <stdarg.h>
|
||||
#include <hdf5.h>
|
||||
#include "h5_core/h5_core.h"
|
||||
#include "H5Fed.h"
|
||||
|
||||
/*!
|
||||
Get number of meshes of given type.
|
||||
|
||||
\param[in] f File handle
|
||||
\param[in] type_id Type of mesh we want the number of.
|
||||
|
||||
\return Number of meshes of type \c type_id or error code.
|
||||
*/
|
||||
h5_size_t
|
||||
H5FedGetNumMeshes (
|
||||
h5_file_t * const f,
|
||||
const h5_oid_t type_id
|
||||
) {
|
||||
SET_FNAME ( f, __func__ );
|
||||
return h5t_get_num_meshes ( f, type_id );
|
||||
}
|
||||
|
||||
/*!
|
||||
Get the number of hierarchical mesh levels.
|
||||
|
||||
\param[in] f File handle
|
||||
|
||||
\return Number of hierarchical mesh levels or error code.
|
||||
*/
|
||||
h5_size_t
|
||||
H5FedGetNumLevels (
|
||||
h5_file_t * const f
|
||||
) {
|
||||
SET_FNAME ( f, __func__ );
|
||||
return h5t_get_num_levels ( f );
|
||||
}
|
||||
|
||||
/*!
|
||||
Get current mesh levels.
|
||||
|
||||
\param[in] f File handle
|
||||
|
||||
\return ID of current mesh levels or error code.
|
||||
*/
|
||||
h5_id_t
|
||||
H5FedGetLevel (
|
||||
h5_file_t * const f
|
||||
) {
|
||||
SET_FNAME ( f, __func__ );
|
||||
return h5t_get_level ( f );
|
||||
}
|
||||
|
||||
/*!
|
||||
Returns the number of vertices used for defining the (sub-)mesh
|
||||
at current level on this compute node.
|
||||
|
||||
\param[in] f file handle
|
||||
|
||||
\return Number of vertices or error code.
|
||||
*/
|
||||
h5_size_t
|
||||
H5FedGetNumVertices (
|
||||
h5_file_t * const f /*!< file handle */
|
||||
) {
|
||||
SET_FNAME ( f, __func__ );
|
||||
return h5t_get_num_vertices ( f, f->myproc );
|
||||
}
|
||||
|
||||
/*!
|
||||
Returns the number of vertices used for defining the (sub-)mesh
|
||||
at current level on compute node \c cnode.
|
||||
|
||||
\param[in] f file handle
|
||||
\param[in] cnode compute node
|
||||
|
||||
\return Number of vertices or error code.
|
||||
*/
|
||||
h5_size_t
|
||||
H5FedGetNumVerticesCnode (
|
||||
h5_file_t * const f,
|
||||
const h5_id_t cnode
|
||||
) {
|
||||
SET_FNAME ( f, __func__ );
|
||||
return h5t_get_num_vertices ( f, cnode );
|
||||
}
|
||||
|
||||
/*!
|
||||
Returns the number of vertices used for defining the (sub-)mesh
|
||||
at current level overl all compute nodes.
|
||||
|
||||
\param[in] f file handle
|
||||
|
||||
\return Total number of vertices or error code.
|
||||
*/
|
||||
h5_size_t
|
||||
H5FedGetNumVerticesTotal (
|
||||
h5_file_t * const f
|
||||
) {
|
||||
SET_FNAME ( f, __func__ );
|
||||
return h5t_get_num_vertices ( f, -1 );
|
||||
}
|
||||
|
||||
/*!
|
||||
Returns the number of elements present in the (sub-)mesh
|
||||
at current level on this compute node.
|
||||
|
||||
\param[in] f file handle
|
||||
|
||||
\return Number of elements or error code.
|
||||
*/
|
||||
h5_size_t
|
||||
H5FedGetNumElements (
|
||||
h5_file_t * const f
|
||||
) {
|
||||
SET_FNAME ( f, __func__ );
|
||||
return h5t_get_num_elems ( f, f->myproc );
|
||||
}
|
||||
|
||||
/*!
|
||||
Returns the number of elements present in the (sub-)mesh
|
||||
at current level on compute node \c cnode.
|
||||
|
||||
\param[in] f file handle
|
||||
\param[in] cnode Compute node
|
||||
|
||||
\return Number of elements or error code.
|
||||
*/
|
||||
h5_size_t
|
||||
H5FedGetNumElementsCnode (
|
||||
h5_file_t * const f,
|
||||
const h5_id_t cnode
|
||||
) {
|
||||
SET_FNAME ( f, __func__ );
|
||||
return h5t_get_num_elems ( f, cnode );
|
||||
}
|
||||
/*!
|
||||
Returns the number of elements present in the mesh
|
||||
at current level over all compute nodes.
|
||||
|
||||
\param[in] f File handle.
|
||||
|
||||
\return Number of elements or error code.
|
||||
*/
|
||||
h5_size_t
|
||||
H5FedGetNumElementsTotal (
|
||||
h5_file_t * const f
|
||||
) {
|
||||
SET_FNAME ( f, __func__ );
|
||||
return h5t_get_num_elems ( f, -1 );
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
/*
|
||||
Header file for declaring the H5Fed application programming
|
||||
interface (API) in the C language.
|
||||
|
||||
Copyright 2006-2007
|
||||
Paul Scherrer Institut, Villigen, Switzerland;
|
||||
Benedikt Oswald;
|
||||
Achim Gsell
|
||||
All rights reserved.
|
||||
|
||||
Authors
|
||||
Achim Gsell
|
||||
|
||||
Warning
|
||||
This code is under development.
|
||||
|
||||
*/
|
||||
#ifndef __H5FED_INQUIRY_H
|
||||
#define __H5FED_INQUIRY_H
|
||||
|
||||
h5_size_t H5FedGetNumMeshes ( h5_file_t * const f, const h5_oid_t type_id );
|
||||
h5_size_t H5FedGetNumLevels ( h5_file_t * const f );
|
||||
h5_id_t H5FedGetLevel ( h5_file_t * const f );
|
||||
h5_size_t H5FedGetNumVertices ( h5_file_t * const f );
|
||||
h5_size_t H5FedGetNumVerticesCnode ( h5_file_t * const f, const h5_id_t cnode );
|
||||
h5_size_t H5FedGetNumVerticesTotal ( h5_file_t * const f );
|
||||
h5_size_t H5FedGetNumElements ( h5_file_t * const f );
|
||||
h5_size_t H5FedGetNumElementsCnode ( h5_file_t * const f, const h5_id_t cnode );
|
||||
h5_size_t H5FedGetNumElementsTotal ( h5_file_t * const f );
|
||||
#endif
|
||||
@@ -0,0 +1,53 @@
|
||||
/*
|
||||
Copyright 2007-2009
|
||||
Paul Scherrer Institut, Villigen, Switzerland;
|
||||
Benedikt Oswald;
|
||||
Achim Gsell
|
||||
All rights reserved.
|
||||
|
||||
Authors
|
||||
Achim Gsell
|
||||
|
||||
Warning
|
||||
This code is under development.
|
||||
|
||||
*/
|
||||
/*!
|
||||
\ingroup h5fed_c_api
|
||||
\defgroup h5fed_map
|
||||
*/
|
||||
|
||||
#include <stdarg.h>
|
||||
#include <hdf5.h>
|
||||
#include "h5_core/h5_core.h"
|
||||
#include "H5Fed.h"
|
||||
|
||||
h5_err_t
|
||||
H5FedLMapEdgeID2VertexIDs (
|
||||
h5_file_t * const f,
|
||||
h5_id_t local_id,
|
||||
h5_id_t *local_vids
|
||||
) {
|
||||
SET_FNAME ( f, __func__ );
|
||||
return h5t_get_local_vids_of_edge ( f, local_id, local_vids );
|
||||
}
|
||||
|
||||
h5_err_t
|
||||
H5FedLMapTriangleID2VertexIDs (
|
||||
h5_file_t * const f,
|
||||
h5_id_t local_id,
|
||||
h5_id_t *local_vids
|
||||
) {
|
||||
SET_FNAME ( f, __func__ );
|
||||
return h5t_get_local_vids_of_triangle ( f, local_id, local_vids );
|
||||
}
|
||||
|
||||
h5_err_t
|
||||
H5FedLMapTetID2VertexIDs (
|
||||
h5_file_t * const f,
|
||||
h5_id_t local_id,
|
||||
h5_id_t *local_vids
|
||||
) {
|
||||
SET_FNAME ( f, __func__ );
|
||||
return h5t_get_local_vids_of_tet ( f, local_id, local_vids );
|
||||
}
|
||||
@@ -0,0 +1,44 @@
|
||||
/*
|
||||
Header file for declaring the H5Fed application programming
|
||||
interface (API) in the C language.
|
||||
|
||||
Copyright 2006-2007
|
||||
Paul Scherrer Institut, Villigen, Switzerland;
|
||||
Benedikt Oswald;
|
||||
Achim Gsell
|
||||
All rights reserved.
|
||||
|
||||
Authors
|
||||
Achim Gsell
|
||||
|
||||
Warning
|
||||
This code is under development.
|
||||
|
||||
*/
|
||||
|
||||
#ifndef __H5FED_MAP_H
|
||||
#define __H5FED_MAP_H
|
||||
|
||||
h5_err_t
|
||||
H5FedLMapEdgeID2VertexIDs (
|
||||
h5_file_t * const f,
|
||||
h5_id_t local_id,
|
||||
h5_id_t *localvids
|
||||
);
|
||||
|
||||
h5_err_t
|
||||
H5FedLMapTriangleID2VertexIDs (
|
||||
h5_file_t * const f,
|
||||
h5_id_t local_id,
|
||||
h5_id_t *localvids
|
||||
);
|
||||
|
||||
h5_err_t
|
||||
H5FedLMapTetID2VertexIDs (
|
||||
h5_file_t * const f,
|
||||
h5_id_t local_id,
|
||||
h5_id_t *localvids
|
||||
);
|
||||
|
||||
#endif
|
||||
|
||||
@@ -0,0 +1,238 @@
|
||||
/****** RETRIEVAL routines **************************************************/
|
||||
/*
|
||||
Copyright 2007-2008
|
||||
Paul Scherrer Institut, Villigen, Switzerland;
|
||||
Benedikt Oswald;
|
||||
Achim Gsell
|
||||
All rights reserved.
|
||||
|
||||
Authors
|
||||
Achim Gsell
|
||||
|
||||
Warning
|
||||
This code is under development.
|
||||
|
||||
*/
|
||||
|
||||
#include <stdarg.h>
|
||||
#include <hdf5.h>
|
||||
#include "h5_core/h5_core.h"
|
||||
#include "H5Fed.h"
|
||||
|
||||
|
||||
/*!
|
||||
Begin traverse over all vertices on this compute node.
|
||||
Initialize internal data structures.
|
||||
|
||||
\remark
|
||||
Vertices can be on processor boundaries! Therefore the same vertex can be
|
||||
processed on several compute nodes.
|
||||
|
||||
\param[in] f file handle
|
||||
|
||||
\return H5_SUCCESS or error code
|
||||
*/
|
||||
h5_err_t
|
||||
H5FedBeginTraverseVertices (
|
||||
h5_file_t * const f
|
||||
) {
|
||||
SET_FNAME ( f, __func__ );
|
||||
return h5t_begin_traverse_vertices ( f );
|
||||
}
|
||||
|
||||
/*!
|
||||
Get coordinates of next vertex.
|
||||
|
||||
\param[in] f file handle
|
||||
\param[out] P 3-dimensional coordinates
|
||||
|
||||
\return Local vertex ID
|
||||
\return -1, if done
|
||||
\return error code on error
|
||||
*/
|
||||
h5_id_t
|
||||
H5FedTraverseVertices (
|
||||
h5_file_t * const f,
|
||||
h5_float64_t P[3]
|
||||
) {
|
||||
SET_FNAME ( f, __func__ );
|
||||
return h5t_traverse_vertices ( f, P );
|
||||
}
|
||||
|
||||
/*!
|
||||
End of traversing. Release internal data structures.
|
||||
|
||||
\param[in] f File handle
|
||||
|
||||
\return H5_SUCCESS or error code
|
||||
|
||||
*/
|
||||
h5_err_t
|
||||
H5FedEndTraverseVertices (
|
||||
h5_file_t * const f
|
||||
) {
|
||||
SET_FNAME ( f, __func__ );
|
||||
return h5t_end_traverse_vertices ( f );
|
||||
}
|
||||
|
||||
/*!
|
||||
Begin traverse over all edges on this compute node.
|
||||
Initialize internal data structures.
|
||||
|
||||
\remark
|
||||
Edges can be on processor boundaries! Therefore the same edge can be
|
||||
processed on several compute nodes.
|
||||
|
||||
\param[in] f file handle
|
||||
|
||||
\return H5_SUCCESS or error code
|
||||
*/
|
||||
h5_err_t
|
||||
H5FedBeginTraverseEdges (
|
||||
h5_file_t * const f /*!< file handle */
|
||||
) {
|
||||
SET_FNAME ( f, __func__ );
|
||||
return h5t_begin_traverse_edges ( f );
|
||||
}
|
||||
|
||||
/*!
|
||||
Get local edge id and vertices of next edge.
|
||||
|
||||
\param[in] f file handle
|
||||
\param[out] vids local vertex IDs
|
||||
|
||||
\return Local edge ID
|
||||
\return -1, if done
|
||||
\return error code on error
|
||||
*/
|
||||
h5_id_t
|
||||
H5FedTraverseEdges (
|
||||
h5_file_t * const f,
|
||||
h5_id_t * const vids
|
||||
) {
|
||||
SET_FNAME ( f, __func__ );
|
||||
return h5t_traverse_edges ( f, vids );
|
||||
}
|
||||
|
||||
/*!
|
||||
End of traversing. Release internal data structures.
|
||||
|
||||
\param[in] f File handle
|
||||
|
||||
\return H5_SUCCESS or error code
|
||||
*/
|
||||
h5_err_t
|
||||
H5FedEndTraverseEdges (
|
||||
h5_file_t * const f /*!< file handle */
|
||||
) {
|
||||
SET_FNAME ( f, __func__ );
|
||||
return h5t_end_traverse_edges ( f );
|
||||
}
|
||||
|
||||
/*!
|
||||
Begin traverse over all triangles on this compute node.
|
||||
Initialize internal data structures.
|
||||
|
||||
\remark
|
||||
Triangles can be on processor boundaries! Therefore the same vertex can be
|
||||
processed on several compute nodes.
|
||||
|
||||
\param[in] f file handle
|
||||
|
||||
\return H5_SUCCESS or error code
|
||||
*/
|
||||
h5_err_t
|
||||
H5FedBeginTraverseTriangles (
|
||||
h5_file_t * const f
|
||||
) {
|
||||
SET_FNAME ( f, __func__ );
|
||||
return h5t_begin_traverse_triangles ( f );
|
||||
}
|
||||
|
||||
/*!
|
||||
Get local triangle ID and vertices of next triangle.
|
||||
|
||||
\param[in] f file handle
|
||||
\param[out] vids local vertex IDs
|
||||
|
||||
\return Local triangle ID
|
||||
\return -1, if done
|
||||
\return error code on error
|
||||
*/
|
||||
h5_id_t
|
||||
H5FedTraverseTriangles (
|
||||
h5_file_t * const f,
|
||||
h5_id_t * const vids
|
||||
) {
|
||||
SET_FNAME ( f, __func__ );
|
||||
return h5t_traverse_triangles ( f, vids );
|
||||
}
|
||||
|
||||
/*!
|
||||
End of traversing. Release internal data structures.
|
||||
|
||||
\param[in] f File handle
|
||||
|
||||
\return H5_SUCCESS or error code
|
||||
*/
|
||||
h5_err_t
|
||||
H5FedEndTraverseTriangles (
|
||||
h5_file_t * const f
|
||||
) {
|
||||
SET_FNAME ( f, __func__ );
|
||||
return h5t_end_traverse_triangles ( f );
|
||||
}
|
||||
|
||||
/*!
|
||||
Begin traverse over all elements on this compute node.
|
||||
Initialize internal data structures.
|
||||
|
||||
\remark
|
||||
Elements are unique per compute node. Ghost elements are *not* return
|
||||
while traversing.
|
||||
|
||||
\param[in] f file handle
|
||||
|
||||
\return H5_SUCCESS or error code
|
||||
*/
|
||||
h5_err_t
|
||||
H5FedBeginTraverseElements (
|
||||
h5_file_t * const f
|
||||
) {
|
||||
SET_FNAME ( f, __func__ );
|
||||
return h5t_begin_traverse_elems ( f );
|
||||
}
|
||||
|
||||
/*!
|
||||
Get local element ID and vertices of next element.
|
||||
|
||||
\param[in] f file handle
|
||||
\param[out] vids local vertex IDs
|
||||
|
||||
\return Local element ID
|
||||
\return -1, if done
|
||||
\return error code on error
|
||||
*/
|
||||
h5_id_t
|
||||
H5FedTraverseElements (
|
||||
h5_file_t * const f,
|
||||
h5_id_t * const vids
|
||||
) {
|
||||
SET_FNAME ( f, __func__ );
|
||||
return h5t_traverse_elems ( f, vids );
|
||||
}
|
||||
|
||||
/*!
|
||||
End of traversing. Release internal data structures.
|
||||
|
||||
\param[in] f File handle
|
||||
|
||||
\return H5_SUCCESS or error code
|
||||
*/
|
||||
h5_id_t
|
||||
H5FedEndTraverseElements (
|
||||
h5_file_t * const f
|
||||
) {
|
||||
return h5t_end_traverse_elems ( f );
|
||||
}
|
||||
|
||||
@@ -0,0 +1,33 @@
|
||||
/*
|
||||
Copyright 2007-2009
|
||||
Paul Scherrer Institut, Villigen, Switzerland;
|
||||
Benedikt Oswald;
|
||||
Achim Gsell
|
||||
All rights reserved.
|
||||
|
||||
Authors
|
||||
Achim Gsell
|
||||
|
||||
Warning
|
||||
This code is under development.
|
||||
|
||||
*/
|
||||
#ifndef __H5FED_RETRIEVE_H
|
||||
#define __H5FED_RETRIEVE_H
|
||||
|
||||
h5_err_t H5FedBeginTraverseVertices ( h5_file_t * const f );
|
||||
h5_id_t H5FedTraverseVertices ( h5_file_t * const f, h5_float64_t P[3] );
|
||||
h5_err_t H5FedEndTraverseVertices ( h5_file_t * const f );
|
||||
|
||||
h5_err_t H5FedBeginTraverseEdges ( h5_file_t * const f );
|
||||
h5_id_t H5FedTraverseEdges ( h5_file_t * const f, h5_id_t * const vids );
|
||||
h5_err_t H5FedEndTraverseEdges ( h5_file_t * const f );
|
||||
|
||||
h5_err_t H5FedBeginTraverseTriangles ( h5_file_t * const f );
|
||||
h5_id_t H5FedTraverseTriangles ( h5_file_t * const f, h5_id_t * const vids );
|
||||
h5_err_t H5FedEndTraverseTriangles ( h5_file_t * const f );
|
||||
|
||||
h5_err_t H5FedBeginTraverseElements ( h5_file_t * const f );
|
||||
h5_id_t H5FedTraverseElements ( h5_file_t * const f, h5_id_t * const vids );
|
||||
h5_err_t H5FedEndTraverseElements ( h5_file_t * const f );
|
||||
#endif
|
||||
@@ -0,0 +1,171 @@
|
||||
/*
|
||||
Copyright 2007-2008
|
||||
Paul Scherrer Institut, Villigen, Switzerland;
|
||||
Benedikt Oswald;
|
||||
Achim Gsell
|
||||
All rights reserved.
|
||||
|
||||
Authors
|
||||
Achim Gsell
|
||||
|
||||
Warning
|
||||
This code is under development.
|
||||
|
||||
*/
|
||||
|
||||
#include <stdarg.h>
|
||||
#include <hdf5.h>
|
||||
#include "h5_core/h5_core.h"
|
||||
#include "H5Fed.h"
|
||||
|
||||
|
||||
h5_id_t
|
||||
H5FedAddMesh (
|
||||
h5_file_t * const f,
|
||||
const h5_oid_t mesh_type_id
|
||||
) {
|
||||
SET_FNAME ( f, __func__ );
|
||||
return h5t_add_mesh ( f, mesh_type_id );
|
||||
}
|
||||
|
||||
/*!
|
||||
\ingroup h5fed_c_api
|
||||
|
||||
Add a new level with \c num_elems elements. The number of elements must be the
|
||||
real number of elements to add the level. If you want to refine \c n tetrahedra
|
||||
\c n*8 elements must be added.
|
||||
|
||||
\param[in] f File handle.
|
||||
\param[in] num_elems_to_refine Number of elements which will be refined.
|
||||
|
||||
\return ID of new level.
|
||||
|
||||
\note
|
||||
values for f->t.num_levels:
|
||||
\c -1 unknown: after opening the file. This is equivalent to
|
||||
"topological data has not been initialized".
|
||||
\c 0 no levels: HDF5 group for meshes may already exist but must not!
|
||||
\c > 0 number of mesh levels
|
||||
|
||||
*/
|
||||
h5_id_t
|
||||
H5FedAddLevel (
|
||||
h5_file_t * const f
|
||||
) {
|
||||
SET_FNAME ( f, __func__ );
|
||||
return h5t_add_level ( f );
|
||||
}
|
||||
|
||||
h5_err_t
|
||||
H5FedBeginStoreVertices (
|
||||
h5_file_t * const f,
|
||||
const h5_size_t num
|
||||
) {
|
||||
SET_FNAME ( f, __func__ );
|
||||
return h5t_begin_store_vertices ( f, num );
|
||||
}
|
||||
|
||||
/*!
|
||||
\ingroup h5fed_c_api
|
||||
|
||||
Stores the the coordinates of a specific vertex at level \c level
|
||||
with id \c vertex_id of the tetrahedral mesh.
|
||||
|
||||
\return local vertex id on success
|
||||
\return errno on error
|
||||
*/
|
||||
h5_id_t
|
||||
H5FedStoreVertex (
|
||||
h5_file_t * const f, /*!< file handle */
|
||||
const h5_id_t vertex_id, /*!< id from mesher or -1 */
|
||||
const h5_float64_t P[3] /*!< coordinates */
|
||||
) {
|
||||
|
||||
SET_FNAME ( f, __func__ );
|
||||
if ( h5t_get_level ( f ) != 0 ) {
|
||||
return h5_error (
|
||||
f,
|
||||
H5_ERR_INVAL,
|
||||
"Vertices can be added to level 0 only!" );
|
||||
}
|
||||
return h5t_store_vertex ( f, vertex_id, P );
|
||||
}
|
||||
|
||||
h5_err_t
|
||||
H5FedEndStoreVertices (
|
||||
h5_file_t * const f
|
||||
) {
|
||||
return h5t_end_store_vertices ( f );
|
||||
}
|
||||
|
||||
h5_err_t
|
||||
H5FedBeginStoreElements (
|
||||
h5_file_t * f,
|
||||
const h5_size_t num
|
||||
) {
|
||||
SET_FNAME ( f, __func__ );
|
||||
return h5t_begin_store_elems ( f, num );
|
||||
}
|
||||
|
||||
/*!
|
||||
\ingroup h5fed_c_api
|
||||
|
||||
Stores the 4-tuple, that contains the specific indices describing
|
||||
a tetrahedron with id \c tet_id at level \c level of the tetrahedral
|
||||
mesh.
|
||||
|
||||
Errors:
|
||||
* current level not yet defined
|
||||
* to many tets stored on level
|
||||
|
||||
\return local tetrahedron id
|
||||
\return \c errno on error
|
||||
*/
|
||||
h5_id_t
|
||||
H5FedStoreElement (
|
||||
h5_file_t * const f, /*!< file handle */
|
||||
const h5_id_t local_vids[] /*!< tuple with vertex id's */
|
||||
) {
|
||||
SET_FNAME ( f, __func__ );
|
||||
if ( h5t_get_level ( f ) != 0 ) {
|
||||
return h5_error (
|
||||
f,
|
||||
H5_ERR_INVAL,
|
||||
"Elements can be added to level 0 only!" );
|
||||
}
|
||||
return h5t_store_elem ( f, -1, local_vids );
|
||||
}
|
||||
|
||||
h5_err_t
|
||||
H5FedEndStoreElements (
|
||||
h5_file_t * const f
|
||||
) {
|
||||
SET_FNAME ( f, __func__ );
|
||||
return h5t_end_store_elems ( f );
|
||||
}
|
||||
|
||||
h5_err_t
|
||||
H5FedBeginRefineElements (
|
||||
h5_file_t * const f,
|
||||
const h5_size_t num
|
||||
) {
|
||||
SET_FNAME ( f, __func__ );
|
||||
return h5t_begin_refine_elems ( f, num );
|
||||
}
|
||||
|
||||
h5_id_t
|
||||
H5FedRefineElement (
|
||||
h5_file_t * const f, /*!< file handle */
|
||||
const h5_id_t local_eid /*!< local element id */
|
||||
) {
|
||||
SET_FNAME ( f, __func__ );
|
||||
return h5t_refine_elem ( f, local_eid );
|
||||
}
|
||||
|
||||
h5_err_t
|
||||
H5FedEndRefineElements (
|
||||
h5_file_t * const f
|
||||
) {
|
||||
SET_FNAME ( f, __func__ );
|
||||
return h5t_end_refine_elems ( f );
|
||||
}
|
||||
@@ -0,0 +1,93 @@
|
||||
/*
|
||||
Header file for declaring the H5Fed application programming
|
||||
interface (API) in the C language.
|
||||
|
||||
Copyright 2006-2009
|
||||
Paul Scherrer Institut, Villigen, Switzerland;
|
||||
Benedikt Oswald;
|
||||
Achim Gsell
|
||||
All rights reserved.
|
||||
|
||||
Authors
|
||||
Achim Gsell
|
||||
|
||||
Warning
|
||||
This code is under development.
|
||||
|
||||
*/
|
||||
|
||||
#ifndef __H5FED_STORE_H
|
||||
#define __H5FED_STORE_H
|
||||
|
||||
h5_id_t
|
||||
H5FedAddMesh (
|
||||
h5_file_t * const f,
|
||||
const h5_oid_t mesh_type_id
|
||||
);
|
||||
|
||||
h5_id_t
|
||||
H5FedAddLevel (
|
||||
h5_file_t * const f
|
||||
);
|
||||
|
||||
h5_err_t
|
||||
H5FedBeginStoreVertices (
|
||||
h5_file_t * const f,
|
||||
const h5_size_t num
|
||||
);
|
||||
|
||||
h5_id_t
|
||||
H5FedStoreVertex (
|
||||
h5_file_t * const f,
|
||||
const h5_id_t id,
|
||||
const h5_float64_t P[3]
|
||||
);
|
||||
|
||||
h5_err_t
|
||||
H5FedEndStoreVertices (
|
||||
h5_file_t * const f
|
||||
);
|
||||
|
||||
h5_err_t
|
||||
H5FedBeginStoreElements (
|
||||
h5_file_t * const f,
|
||||
const h5_size_t num
|
||||
);
|
||||
|
||||
|
||||
h5_id_t
|
||||
H5FedStoreElement (
|
||||
h5_file_t * const f,
|
||||
const h5_id_t local_vids[]
|
||||
);
|
||||
|
||||
h5_err_t
|
||||
H5FedEndStoreElements (
|
||||
h5_file_t * const f
|
||||
);
|
||||
|
||||
h5_err_t
|
||||
H5FedBeginRefineElements (
|
||||
h5_file_t * const f,
|
||||
const h5_size_t num
|
||||
);
|
||||
|
||||
h5_id_t
|
||||
H5FedRefineElement (
|
||||
h5_file_t * const f,
|
||||
const h5_id_t eid
|
||||
);
|
||||
|
||||
h5_err_t
|
||||
H5FedEndRefineElements (
|
||||
h5_file_t * const f
|
||||
);
|
||||
|
||||
h5_err_t
|
||||
H5FedMarkRefineElement (
|
||||
h5_file_t * const f,
|
||||
const h5_id_t eid
|
||||
);
|
||||
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,201 @@
|
||||
/*
|
||||
Copyright 2007-2009
|
||||
Paul Scherrer Institut, Villigen, Switzerland;
|
||||
Achim Gsell
|
||||
All rights reserved.
|
||||
|
||||
Authors
|
||||
Achim Gsell
|
||||
|
||||
Warning
|
||||
This code is under development.
|
||||
|
||||
*/
|
||||
#include <hdf5.h>
|
||||
#include "h5_core/h5_core.h"
|
||||
#include "H5Fed.h"
|
||||
|
||||
/*!
|
||||
Add a tagset to the current mesh.
|
||||
|
||||
\param[in] f file handle
|
||||
\param[in] name name of tagset
|
||||
\param[in] type data type of tagset
|
||||
|
||||
\return H5_SUCCESS or error code
|
||||
*/
|
||||
h5_err_t
|
||||
H5FedAddMTagset (
|
||||
h5_file_t * const f,
|
||||
char * name,
|
||||
h5_id_t type
|
||||
) {
|
||||
SET_FNAME ( f, __func__ );
|
||||
return h5t_add_mtagset ( f, name, type );
|
||||
}
|
||||
|
||||
/*!
|
||||
Remove a tagset from the current mesh.
|
||||
|
||||
\param[in] f file handle
|
||||
\param[in] name name of tagset to remove
|
||||
|
||||
\return H5_SUCCESS or error code
|
||||
*/
|
||||
h5_err_t
|
||||
H5FedRemoveMTagset (
|
||||
h5_file_t *const f,
|
||||
char name[]
|
||||
) {
|
||||
SET_FNAME ( f, __func__ );
|
||||
return h5t_remove_mtagset (f, name );
|
||||
}
|
||||
|
||||
/*!
|
||||
Get available tagsets in current mesh.
|
||||
|
||||
\param[in] f file handle
|
||||
\param[out] names names of available tagsets
|
||||
|
||||
\return Number of tagsets or error code
|
||||
*/
|
||||
h5_size_t
|
||||
H5FedGetMTagsets (
|
||||
h5_file_t *const f,
|
||||
char **names[]
|
||||
) {
|
||||
SET_FNAME ( f, __func__ );
|
||||
return h5t_get_mtagsets ( f, names );
|
||||
}
|
||||
|
||||
/*!
|
||||
Get type of tagset in current mesh.
|
||||
|
||||
\param[in] f file handle
|
||||
\param[in] name name of tagset
|
||||
|
||||
\return H5_SUCCESS or error code
|
||||
*/
|
||||
h5_id_t
|
||||
H5FedGetTypeOfMTagset (
|
||||
h5_file_t *const f,
|
||||
char name[]
|
||||
) {
|
||||
SET_FNAME ( f, __func__ );
|
||||
return h5t_get_mtagset_type_by_name ( f, name );
|
||||
}
|
||||
|
||||
/*!
|
||||
Set tag for entity in current mesh.
|
||||
|
||||
\param[in] f file handle
|
||||
\param[in] name names of tagset
|
||||
\param[in] id id of entity
|
||||
\param[in] dim dimension of value
|
||||
\param[in] val tag value
|
||||
|
||||
\return H5_SUCCESS or error code
|
||||
*/
|
||||
h5_err_t
|
||||
H5FedSetMTag (
|
||||
h5_file_t *const f,
|
||||
char name[],
|
||||
h5_id_t id,
|
||||
const size_t dims,
|
||||
void *val
|
||||
) {
|
||||
SET_FNAME ( f, __func__ );
|
||||
return h5t_set_mtag_by_name ( f, name, id, dims, val );
|
||||
}
|
||||
|
||||
h5_err_t
|
||||
H5FedSetMTagToVertex (
|
||||
h5_file_t *const f,
|
||||
char name[],
|
||||
h5_id_t id,
|
||||
const size_t dims,
|
||||
void *val
|
||||
) {
|
||||
SET_FNAME ( f, __func__ );
|
||||
id = h5tpriv_set_entity_type ( H5T_ETYPE_VERTEX, id );
|
||||
return h5t_set_mtag_by_name ( f, name, id, dims, val );
|
||||
}
|
||||
|
||||
h5_err_t
|
||||
H5FedSetMTagToEdge (
|
||||
h5_file_t *const f,
|
||||
char name[],
|
||||
h5_id_t id,
|
||||
const size_t dims,
|
||||
void *val
|
||||
) {
|
||||
SET_FNAME ( f, __func__ );
|
||||
id = h5tpriv_set_entity_type ( H5T_ETYPE_EDGE, id );
|
||||
return h5t_set_mtag_by_name ( f, name, id, dims, val );
|
||||
}
|
||||
|
||||
h5_err_t
|
||||
H5FedSetMTagToTriangle (
|
||||
h5_file_t *const f,
|
||||
char name[],
|
||||
h5_id_t id,
|
||||
const size_t dims,
|
||||
void *val
|
||||
) {
|
||||
SET_FNAME ( f, __func__ );
|
||||
id = h5tpriv_set_entity_type ( H5T_ETYPE_TRIANGLE, id );
|
||||
return h5t_set_mtag_by_name ( f, name, id, dims, val );
|
||||
}
|
||||
|
||||
h5_err_t
|
||||
H5FedSetMTagToTet (
|
||||
h5_file_t *const f,
|
||||
char name[],
|
||||
h5_id_t id,
|
||||
const size_t dims,
|
||||
void *val
|
||||
) {
|
||||
SET_FNAME ( f, __func__ );
|
||||
id = h5tpriv_set_entity_type ( H5T_ETYPE_TET, id );
|
||||
return h5t_set_mtag_by_name ( f, name, id, dims, val );
|
||||
}
|
||||
|
||||
/*!
|
||||
Set tag for entity in current mesh.
|
||||
|
||||
\param[in] f file handle
|
||||
\param[in] name names of tagset
|
||||
\param[in] id id of entity
|
||||
\param[out] dim dimension of value
|
||||
\param[out] val tag value
|
||||
|
||||
\return H5_SUCCESS or error code
|
||||
*/
|
||||
h5_err_t
|
||||
H5FedGetMTag (
|
||||
h5_file_t* const f,
|
||||
const char name[],
|
||||
const h5_id_t id,
|
||||
size_t* dim,
|
||||
void* vals
|
||||
) {
|
||||
SET_FNAME ( f, __func__ );
|
||||
return h5t_get_mtag_by_name ( f, name, id, dim, vals );
|
||||
}
|
||||
|
||||
/*!
|
||||
Remove tag for entity in current mesh.
|
||||
|
||||
\param[in] f file handle
|
||||
\param[in] name names of tagset
|
||||
\param[in] id id of entity
|
||||
*/
|
||||
h5_err_t
|
||||
H5FedRemoveMTag (
|
||||
h5_file_t *const f,
|
||||
const char name[],
|
||||
const h5_id_t id
|
||||
) {
|
||||
SET_FNAME ( f, __func__ );
|
||||
return h5t_remove_mtag_by_name ( f, name, id );
|
||||
}
|
||||
@@ -0,0 +1,40 @@
|
||||
#ifndef __H5FED_TAGS_H
|
||||
#define __H5FED_TAGS_H
|
||||
h5_err_t H5FedAddMTagset ( h5_file_t * const f,
|
||||
char * name,
|
||||
h5_id_t type );
|
||||
h5_err_t H5FedRemoveMTagset ( h5_file_t *const f,
|
||||
char name[] );
|
||||
h5_size_t H5FedGetMTagsets ( h5_file_t *const f,
|
||||
char **names[] );
|
||||
h5_id_t H5FedGetTypeOfMTagset ( h5_file_t *const f,
|
||||
char name[] );
|
||||
h5_err_t H5FedSetMTag ( h5_file_t *const f,
|
||||
char name[], h5_id_t id,
|
||||
const size_t dims, void *val );
|
||||
h5_err_t H5FedSetMTagToVertex ( h5_file_t *const f,
|
||||
char name[], h5_id_t id,
|
||||
const size_t dims, void *val );
|
||||
h5_err_t H5FedSetMTagToEdge ( h5_file_t *const f,
|
||||
char name[], h5_id_t id,
|
||||
const size_t dims, void *val );
|
||||
h5_err_t H5FedSetMTagToTriangle ( h5_file_t *const f,
|
||||
char name[], h5_id_t id,
|
||||
const size_t dims, void *val );
|
||||
h5_err_t H5FedSetMTagToTet ( h5_file_t *const f,
|
||||
char name[], h5_id_t id,
|
||||
const size_t dims, void *val );
|
||||
|
||||
h5_err_t H5FedGetMTag ( h5_file_t *const f,
|
||||
const char name[], const h5_id_t id,
|
||||
size_t *dims, void *val );
|
||||
h5_err_t H5FedRemoveMTag ( h5_file_t *const f,
|
||||
const char name[], const h5_id_t id );
|
||||
|
||||
/*
|
||||
Get descriptor for a tagset
|
||||
Get tag value by descriptor
|
||||
get size of value
|
||||
Get tagset names for specific entity
|
||||
*/
|
||||
#endif
|
||||
+974
@@ -0,0 +1,974 @@
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdarg.h> /* va_arg - System dependent ?! */
|
||||
#include <string.h>
|
||||
#include <errno.h>
|
||||
#include <fcntl.h>
|
||||
#include <hdf5.h>
|
||||
|
||||
#ifndef WIN32
|
||||
#include <unistd.h>
|
||||
#else /* WIN32 */
|
||||
#include <io.h>
|
||||
#define open _open
|
||||
#define close _close
|
||||
#endif /* WIN32 */
|
||||
|
||||
#include "h5_core/h5_core.h"
|
||||
#include "h5_core/h5_errorhandling_private.h"
|
||||
#include "H5Part.h"
|
||||
|
||||
/********* Private Variable Declarations *************/
|
||||
|
||||
|
||||
/********** Declaration of private functions ******/
|
||||
|
||||
|
||||
/*========== File Opening/Closing ===============*/
|
||||
|
||||
/*!
|
||||
\ingroup h5part_c_api
|
||||
\defgroup h5part_c_api_openclose File Opening and Closing
|
||||
*/
|
||||
|
||||
/*!
|
||||
\ingroup h5part_c_api_openclose
|
||||
|
||||
Opens file with specified filename.
|
||||
|
||||
If you open with flag \c H5PART_WRITE, it will truncate any
|
||||
file with the specified filename and start writing to it. If
|
||||
you open with \c H5PART_APPEND, then you can append new steps.
|
||||
If you open with \c H5PART_READ, then it will open the file
|
||||
readonly.
|
||||
|
||||
The typical extension for these files is \c .h5.
|
||||
|
||||
h5_file should be treated as an essentially opaque
|
||||
datastructure. It acts as the file handle, but internally
|
||||
it maintains several key state variables associated with
|
||||
the file.
|
||||
|
||||
\return File handle or \c NULL
|
||||
*/
|
||||
h5_file_t *
|
||||
H5PartOpenFileParallel (
|
||||
const char *filename, /*!< [in] The name of the data file to open. */
|
||||
unsigned flags, /*!< [in] The access mode for the file. */
|
||||
MPI_Comm comm /*!< [in] MPI communicator */
|
||||
) {
|
||||
return h5_open_file ( filename, flags, comm, __func__ );
|
||||
}
|
||||
|
||||
/*!
|
||||
\ingroup h5part_c_api_openclose
|
||||
|
||||
Opens file with specified filename.
|
||||
|
||||
If you open with flag \c H5PART_WRITE, it will truncate any
|
||||
file with the specified filename and start writing to it. If
|
||||
you open with \c H5PART_APPEND, then you can append new steps.
|
||||
If you open with \c H5PART_READ, then it will open the file
|
||||
readonly.
|
||||
|
||||
The typical extension for these files is \c .h5.
|
||||
|
||||
h5_file should be treated as an essentially opaque
|
||||
datastructure. It acts as the file handle, but internally
|
||||
it maintains several key state variables associated with
|
||||
the file.
|
||||
|
||||
\return File handle or \c NULL
|
||||
*/
|
||||
|
||||
h5_file_t *
|
||||
H5PartOpenFile (
|
||||
const char *filename, /*!< [in] The name of the data file to open. */
|
||||
unsigned flags /*!< [in] The access mode for the file. */
|
||||
) {
|
||||
|
||||
MPI_Comm comm = 0; /* dummy */
|
||||
|
||||
return h5_open_file ( filename, flags, comm, __func__ );
|
||||
}
|
||||
|
||||
/*!
|
||||
\ingroup h5part_c_api_openclose
|
||||
|
||||
Closes an open file.
|
||||
|
||||
\return \c H5_SUCCESS or error code
|
||||
*/
|
||||
h5_int64_t
|
||||
H5PartCloseFile (
|
||||
h5_file_t *f /*!< [in] filehandle of the file to close */
|
||||
) {
|
||||
|
||||
SET_FNAME ( f, __func__ );
|
||||
|
||||
return h5_close_file( f );
|
||||
}
|
||||
|
||||
/*============== File Writing Functions ==================== */
|
||||
|
||||
/*!
|
||||
\ingroup h5part_c_api
|
||||
\defgroup h5part_c_api_write File Writing
|
||||
*/
|
||||
|
||||
h5_int64_t
|
||||
H5PartDefineStepName (
|
||||
h5_file_t *f,
|
||||
const char *name,
|
||||
const h5_int64_t width
|
||||
) {
|
||||
SET_FNAME ( f, __func__ );
|
||||
|
||||
return h5_set_stepname_fmt( f, name, width );
|
||||
}
|
||||
|
||||
/*!
|
||||
\ingroup h5part_c_api_write
|
||||
|
||||
Set number of particles for current time-step.
|
||||
|
||||
This function's sole purpose is to prevent
|
||||
needless creation of new HDF5 DataSpace handles if the number of
|
||||
particles is invariant throughout the simulation. That's its only reason
|
||||
for existence. After you call this subroutine, all subsequent
|
||||
operations will assume this number of particles will be written.
|
||||
|
||||
|
||||
\return \c H5_SUCCESS or error code
|
||||
*/
|
||||
h5_int64_t
|
||||
H5PartSetNumParticles (
|
||||
h5_file_t *f, /*!< [in] Handle to open file */
|
||||
h5_int64_t nparticles /*!< [in] Number of particles */
|
||||
) {
|
||||
|
||||
SET_FNAME ( f, __func__ );
|
||||
|
||||
return h5u_set_num_elements( f, nparticles );
|
||||
}
|
||||
|
||||
/*!
|
||||
\ingroup h5part_c_api_write
|
||||
|
||||
Write array of 64 bit floating point data to file.
|
||||
|
||||
After setting the number of particles with \c H5PartSetNumParticles() and
|
||||
the current step using \c H5PartSetStep(), you can start writing datasets
|
||||
into the file. Each dataset has a name associated with it (chosen by the
|
||||
user) in order to facilitate later retrieval. The name of the dataset is
|
||||
specified in the parameter \c name, which must be a null-terminated string.
|
||||
|
||||
There are no restrictions on naming of datasets, but it is useful to arrive
|
||||
at some common naming convention when sharing data with other groups.
|
||||
|
||||
The writing routines also implicitly store the datatype of the array so that
|
||||
the array can be reconstructed properly on other systems with incompatible
|
||||
type representations.
|
||||
|
||||
All data that is written after setting the step is associated with that
|
||||
step. While the number of particles can change for each step, you
|
||||
cannot change the number of particles in the middle of a given step.
|
||||
|
||||
The data is committed to disk before the routine returns.
|
||||
|
||||
\return \c H5_SUCCESS or error code
|
||||
*/
|
||||
h5_int64_t
|
||||
H5PartWriteDataFloat64 (
|
||||
h5_file_t *f, /*!< [in] Handle to open file */
|
||||
const char *name, /*!< [in] Name to associate array with */
|
||||
const h5_float64_t *array /*!< [in] Array to commit to disk */
|
||||
) {
|
||||
|
||||
SET_FNAME ( f, __func__ );
|
||||
|
||||
return h5u_write_data ( f, name, (void*)array, H5T_NATIVE_DOUBLE );
|
||||
}
|
||||
|
||||
/*!
|
||||
\ingroup h5part_c_api_write
|
||||
|
||||
Write array of 64 bit integer data to file.
|
||||
|
||||
After setting the number of particles with \c H5PartSetNumParticles() and
|
||||
the current step using \c H5PartSetStep(), you can start writing datasets
|
||||
into the file. Each dataset has a name associated with it (chosen by the
|
||||
user) in order to facilitate later retrieval. The name of the dataset is
|
||||
specified in the parameter \c name, which must be a null-terminated string.
|
||||
|
||||
There are no restrictions on naming of datasets, but it is useful to arrive
|
||||
at some common naming convention when sharing data with other groups.
|
||||
|
||||
The writing routines also implicitly store the datatype of the array so that
|
||||
the array can be reconstructed properly on other systems with incompatible
|
||||
type representations.
|
||||
|
||||
All data that is written after setting the step is associated with that
|
||||
step. While the number of particles can change for each step, you
|
||||
cannot change the number of particles in the middle of a given step.
|
||||
|
||||
The data is committed to disk before the routine returns.
|
||||
|
||||
\return \c H5_SUCCESS or error code
|
||||
*/
|
||||
h5_int64_t
|
||||
H5PartWriteDataInt64 (
|
||||
h5_file_t *f, /*!< [in] Handle to open file */
|
||||
const char *name, /*!< [in] Name to associate array with */
|
||||
const h5_int64_t *array /*!< [in] Array to commit to disk */
|
||||
) {
|
||||
|
||||
SET_FNAME ( f, __func__ );
|
||||
|
||||
return h5u_write_data ( f, name, (void*)array, H5T_NATIVE_INT64 );
|
||||
}
|
||||
|
||||
/********************** reading and writing attribute ************************/
|
||||
|
||||
/********************** private functions to handle attributes ***************/
|
||||
|
||||
|
||||
/********************** attribute API ****************************************/
|
||||
|
||||
/*!
|
||||
\ingroup h5part_c_api
|
||||
\defgroup h5part_c_api_attrib Reading and Writing Attributes
|
||||
*/
|
||||
|
||||
/*!
|
||||
\ingroup h5part_c_api_attrib
|
||||
|
||||
Writes a string attribute bound to a file.
|
||||
|
||||
This function creates a new attribute \c name with the string \c value as
|
||||
content. The attribute is bound to the file associated with the file handle
|
||||
\c f.
|
||||
|
||||
If the attribute already exists an error will be returned. There
|
||||
is currently no way to change the content of an existing attribute.
|
||||
|
||||
\return \c H5_SUCCESS or error code
|
||||
*/
|
||||
h5_int64_t
|
||||
H5PartWriteFileAttribString (
|
||||
h5_file_t *f, /*!< [in] Handle to open file */
|
||||
const char *attrib_name,/*!< [in] Name of attribute to create */
|
||||
const char *attrib_value/*!< [in] Value of attribute */
|
||||
) {
|
||||
|
||||
SET_FNAME ( f, __func__ );
|
||||
|
||||
if ( h5_check_filehandle ( f ) != H5_SUCCESS )
|
||||
return h5_get_errno( f );
|
||||
|
||||
return h5_write_attrib (
|
||||
f,
|
||||
f->root_gid,
|
||||
attrib_name,
|
||||
H5T_NATIVE_CHAR,
|
||||
attrib_value,
|
||||
strlen ( attrib_value ) + 1 );
|
||||
}
|
||||
|
||||
/*!
|
||||
\ingroup h5part_c_api_attrib
|
||||
|
||||
Writes a string attribute bound to the current time-step.
|
||||
|
||||
This function creates a new attribute \c name with the string \c value as
|
||||
content. The attribute is bound to the current time step in the file given
|
||||
by the file handle \c f.
|
||||
|
||||
If the attribute already exists an error will be returned. There
|
||||
is currently no way to change the content of an existing attribute.
|
||||
|
||||
\return \c H5_SUCCESS or error code
|
||||
*/
|
||||
|
||||
h5_int64_t
|
||||
H5PartWriteStepAttribString (
|
||||
h5_file_t *f, /*!< [in] Handle to open file */
|
||||
const char *attrib_name,/*!< [in] Name of attribute to create */
|
||||
const char *attrib_value/*!< [in] Value of attribute */
|
||||
) {
|
||||
|
||||
SET_FNAME ( f, __func__ );
|
||||
|
||||
if ( h5_check_filehandle ( f ) != H5_SUCCESS )
|
||||
return h5_get_errno( f );
|
||||
|
||||
return h5_write_attrib (
|
||||
f,
|
||||
f->step_gid,
|
||||
attrib_name,
|
||||
H5T_NATIVE_CHAR,
|
||||
attrib_value,
|
||||
strlen ( attrib_value ) + 1 );
|
||||
}
|
||||
|
||||
/*!
|
||||
\ingroup h5part_c_api_attrib
|
||||
|
||||
Writes a attribute bound to the current time-step.
|
||||
|
||||
This function creates a new attribute \c name with the string \c value as
|
||||
content. The attribute is bound to the current time step in the file given
|
||||
by the file handle \c f.
|
||||
|
||||
The value of the attribute is given the parameter \c type, which must be one
|
||||
of \c H5T_NATIVE_DOUBLE, \c H5T_NATIVE_INT64 of \c H5T_NATIVE_CHAR, the array
|
||||
\c value and the number of elements \c nelem in the array.
|
||||
|
||||
If the attribute already exists an error will be returned. There
|
||||
is currently no way to change the content of an existing attribute.
|
||||
|
||||
\return \c H5_SUCCESS or error code
|
||||
*/
|
||||
|
||||
h5_int64_t
|
||||
H5PartWriteStepAttrib (
|
||||
h5_file_t *f, /*!< [in] Handle to open file */
|
||||
const char *attrib_name, /*!< [in] Name of attribute */
|
||||
const h5_int64_t attrib_type,/*!< [in] Type of value. */
|
||||
const void *attrib_value, /*!< [in] Value of attribute */
|
||||
const h5_int64_t attrib_nelem/*!< [in] Number of elements */
|
||||
){
|
||||
|
||||
SET_FNAME ( f, __func__ );
|
||||
|
||||
if ( h5_check_filehandle ( f ) != H5_SUCCESS )
|
||||
return h5_get_errno( f );
|
||||
|
||||
return h5_write_attrib (
|
||||
f,
|
||||
f->step_gid,
|
||||
attrib_name,
|
||||
(hid_t)attrib_type,
|
||||
attrib_value,
|
||||
attrib_nelem );
|
||||
}
|
||||
|
||||
/*!
|
||||
\ingroup h5part_c_api_attrib
|
||||
|
||||
Writes a attribute bound to a file.
|
||||
|
||||
This function creates a new attribute \c name with the string \c value as
|
||||
content. The attribute is bound to the file file given by the file handle
|
||||
\c f.
|
||||
|
||||
The value of the attribute is given the parameter \c type, which must be one
|
||||
of H5T_NATIVE_DOUBLE, H5T_NATIVE_INT64 of H5T_NATIVE_CHAR, the array \c value
|
||||
and the number of elements \c nelem in the array.
|
||||
|
||||
If the attribute already exists an error will be returned. There
|
||||
is currently no way to change the content of an existing attribute.
|
||||
|
||||
\return \c H5_SUCCESS or error code
|
||||
*/
|
||||
|
||||
h5_int64_t
|
||||
H5PartWriteFileAttrib (
|
||||
h5_file_t *f, /*!< [in] Handle to open file */
|
||||
const char *attrib_name, /*!< [in] Name of attribute */
|
||||
const h5_int64_t attrib_type,/*!< [in] Type of value. */
|
||||
const void *attrib_value, /*!< [in] Value of attribute */
|
||||
const h5_int64_t attrib_nelem/*!< [in] Number of elements */
|
||||
) {
|
||||
|
||||
SET_FNAME ( f, __func__ );
|
||||
|
||||
if ( h5_check_filehandle ( f ) != H5_SUCCESS )
|
||||
return h5_get_errno( f );
|
||||
|
||||
return h5_write_attrib (
|
||||
f,
|
||||
f->root_gid,
|
||||
attrib_name,
|
||||
(hid_t)attrib_type,
|
||||
attrib_value,
|
||||
attrib_nelem );
|
||||
}
|
||||
|
||||
/*!
|
||||
\ingroup h5part_c_api_attrib
|
||||
|
||||
Gets the number of attributes bound to the current step.
|
||||
|
||||
\return Number of attributes bound to current time step or error code.
|
||||
*/
|
||||
h5_int64_t
|
||||
H5PartGetNumStepAttribs (
|
||||
h5_file_t *f /*!< [in] Handle to open file */
|
||||
) {
|
||||
|
||||
SET_FNAME ( f, __func__ );
|
||||
|
||||
if ( h5_check_filehandle ( f ) != H5_SUCCESS )
|
||||
return h5_get_errno( f );
|
||||
|
||||
return h5_get_num_attribs ( f, f->step_gid );
|
||||
}
|
||||
|
||||
/*!
|
||||
\ingroup h5part_c_api_attrib
|
||||
|
||||
Gets the number of attributes bound to the file.
|
||||
|
||||
\return Number of attributes bound to file \c f or error code.
|
||||
*/
|
||||
h5_int64_t
|
||||
H5PartGetNumFileAttribs (
|
||||
h5_file_t *f /*!< [in] Handle to open file */
|
||||
) {
|
||||
|
||||
SET_FNAME ( f, __func__ );
|
||||
|
||||
if ( h5_check_filehandle ( f ) != H5_SUCCESS )
|
||||
return h5_get_errno( f );
|
||||
|
||||
return h5_get_num_attribs ( f, f->root_gid );
|
||||
}
|
||||
|
||||
/*!
|
||||
\ingroup h5part_c_api_attrib
|
||||
|
||||
Gets the name, type and number of elements of the step attribute
|
||||
specified by its index.
|
||||
|
||||
This function can be used to retrieve all attributes bound to the
|
||||
current time-step by looping from \c 0 to the number of attribute
|
||||
minus one. The number of attributes bound to the current
|
||||
time-step can be queried by calling the function
|
||||
\c H5PartGetNumStepAttribs().
|
||||
|
||||
\return \c H5_SUCCESS or error code
|
||||
*/
|
||||
h5_int64_t
|
||||
H5PartGetStepAttribInfo (
|
||||
h5_file_t *f, /*!< [in] Handle to open file */
|
||||
const h5_int64_t attrib_idx,/*!< [in] Index of attribute to
|
||||
get infos about */
|
||||
char *attrib_name, /*!< [out] Name of attribute */
|
||||
const h5_int64_t len_of_attrib_name,
|
||||
/*!< [in] length of buffer \c name */
|
||||
h5_int64_t *attrib_type, /*!< [out] Type of value. */
|
||||
h5_int64_t *attrib_nelem /*!< [out] Number of elements */
|
||||
) {
|
||||
|
||||
SET_FNAME ( f, __func__ );
|
||||
|
||||
if ( h5_check_filehandle ( f ) != H5_SUCCESS )
|
||||
return h5_get_errno( f );
|
||||
|
||||
return h5_get_attrib_info (
|
||||
f,
|
||||
f->step_gid,
|
||||
attrib_idx,
|
||||
attrib_name,
|
||||
len_of_attrib_name,
|
||||
attrib_type,
|
||||
attrib_nelem );
|
||||
}
|
||||
|
||||
/*!
|
||||
\ingroup h5part_c_api_attrib
|
||||
|
||||
Gets the name, type and number of elements of the file attribute
|
||||
specified by its index.
|
||||
|
||||
This function can be used to retrieve all attributes bound to the
|
||||
file \c f by looping from \c 0 to the number of attribute minus
|
||||
one. The number of attributes bound to file \c f can be queried
|
||||
by calling the function \c H5PartGetNumFileAttribs().
|
||||
|
||||
\return \c H5_SUCCESS or error code
|
||||
*/
|
||||
|
||||
h5_int64_t
|
||||
H5PartGetFileAttribInfo (
|
||||
h5_file_t *f, /*!< [in] Handle to open file */
|
||||
const h5_int64_t attrib_idx,/*!< [in] Index of attribute to get
|
||||
infos about */
|
||||
char *attrib_name, /*!< [out] Name of attribute */
|
||||
const h5_int64_t len_of_attrib_name,
|
||||
/*!< [in] length of buffer \c name */
|
||||
h5_int64_t *attrib_type, /*!< [out] Type of value. */
|
||||
h5_int64_t *attrib_nelem /*!< [out] Number of elements */
|
||||
) {
|
||||
|
||||
SET_FNAME ( f, __func__ );
|
||||
|
||||
if ( h5_check_filehandle ( f ) != H5_SUCCESS )
|
||||
return h5_get_errno ( f );
|
||||
|
||||
return h5_get_attrib_info (
|
||||
f,
|
||||
f->root_gid,
|
||||
attrib_idx,
|
||||
attrib_name,
|
||||
len_of_attrib_name,
|
||||
attrib_type,
|
||||
attrib_nelem );
|
||||
}
|
||||
|
||||
/*!
|
||||
\ingroup h5part_c_api_attrib
|
||||
|
||||
Reads an attribute bound to current time-step.
|
||||
|
||||
\return \c H5_SUCCESS or error code
|
||||
*/
|
||||
h5_int64_t
|
||||
H5PartReadStepAttrib (
|
||||
h5_file_t *f, /*!< [in] Handle to open file */
|
||||
const char *attrib_name, /*!< [in] Name of attribute to read */
|
||||
void *attrib_value /*!< [out] Value of attribute */
|
||||
) {
|
||||
|
||||
SET_FNAME ( f, __func__ );
|
||||
|
||||
if ( h5_check_filehandle ( f ) != H5_SUCCESS )
|
||||
return h5_get_errno ( f );
|
||||
|
||||
return h5_read_attrib ( f, f->step_gid, attrib_name, attrib_value );
|
||||
}
|
||||
|
||||
/*!
|
||||
\ingroup h5part_c_api_attrib
|
||||
|
||||
Reads an attribute bound to file \c f.
|
||||
|
||||
\return \c H5_SUCCESS or error code
|
||||
*/
|
||||
h5_int64_t
|
||||
H5PartReadFileAttrib (
|
||||
h5_file_t *f,
|
||||
const char *attrib_name,
|
||||
void *attrib_value
|
||||
) {
|
||||
|
||||
SET_FNAME ( f, __func__ );
|
||||
|
||||
if ( h5_check_filehandle ( f ) != H5_SUCCESS )
|
||||
return h5_get_errno ( f );
|
||||
|
||||
return h5_read_attrib ( f, f->root_gid, attrib_name, attrib_value );
|
||||
}
|
||||
|
||||
|
||||
/*================== File Reading Routines =================*/
|
||||
|
||||
/*!
|
||||
\ingroup h5part_c_api
|
||||
\defgroup h5part_c_api_read File Reading
|
||||
*/
|
||||
|
||||
/*
|
||||
H5PartSetStep:
|
||||
|
||||
|
||||
So you use this to random-access the file for a particular step.
|
||||
Failure to explicitly set the step on each read will leave you
|
||||
stuck on the same step for *all* of your reads. That is to say
|
||||
the writes auto-advance the file pointer, but the reads do not
|
||||
(they require explicit advancing by selecting a particular step).
|
||||
*/
|
||||
|
||||
/*!
|
||||
\ingroup h5part_c_api_read
|
||||
|
||||
Set the current time-step.
|
||||
|
||||
When writing data to a file the current time step must be set first
|
||||
(even if there is only one). In write-mode this function creates a new
|
||||
time-step! You are not allowed to step to an already existing time-step.
|
||||
This prevents you from overwriting existing data. Another consequence is,
|
||||
that you \b must write all data before going to the next time-step.
|
||||
|
||||
In read-mode you can use this function to random-access the file for a
|
||||
particular step.
|
||||
|
||||
\return \c H5_SUCCESS or error code
|
||||
*/
|
||||
h5_int64_t
|
||||
H5PartSetStep (
|
||||
h5_file_t *f, /*!< [in] Handle to open file */
|
||||
const h5_int64_t step /*!< [in] Time-step to set. */
|
||||
) {
|
||||
|
||||
SET_FNAME ( f, __func__ );
|
||||
|
||||
if ( h5_check_filehandle ( f ) != H5_SUCCESS )
|
||||
return h5_get_errno ( f );
|
||||
|
||||
return h5_set_step ( f, step );
|
||||
}
|
||||
|
||||
/********************** query file structure *********************************/
|
||||
|
||||
/*!
|
||||
\ingroup h5part_c_api_read
|
||||
|
||||
Get the number of datasets that are stored at the current time-step.
|
||||
|
||||
\return number of datasets in current step or error code
|
||||
*/
|
||||
|
||||
h5_int64_t
|
||||
H5PartGetNumDatasets (
|
||||
h5_file_t *f /*!< [in] Handle to open file */
|
||||
) {
|
||||
|
||||
SET_FNAME ( f, __func__ );
|
||||
CHECK_FILEHANDLE ( f );
|
||||
|
||||
return hdf5_get_num_objects ( f->file, f->step_name, H5G_DATASET );
|
||||
}
|
||||
|
||||
/*!
|
||||
\ingroup h5part_c_api_read
|
||||
|
||||
This reads the name of a dataset specified by it's index in the current
|
||||
time-step.
|
||||
|
||||
If the number of datasets is \c n, the range of \c _index is \c 0 to \c n-1.
|
||||
|
||||
\result \c H5_SUCCESS
|
||||
*/
|
||||
h5_int64_t
|
||||
H5PartGetDatasetName (
|
||||
h5_file_t *f, /*!< [in] Handle to open file */
|
||||
const h5_int64_t idx, /*!< [in] Index of the dataset */
|
||||
char *name, /*!< [out] Name of dataset */
|
||||
const h5_int64_t len_of_name/*!< [in] Size of buffer \c name */
|
||||
) {
|
||||
|
||||
SET_FNAME ( f, __func__ );
|
||||
|
||||
if ( h5_check_filehandle ( f ) != H5_SUCCESS )
|
||||
return h5_get_errno ( f );
|
||||
|
||||
return hdf5_get_object_name (
|
||||
f->file,
|
||||
f->step_name,
|
||||
H5G_DATASET,
|
||||
idx,
|
||||
name,
|
||||
len_of_name );
|
||||
}
|
||||
|
||||
/*!
|
||||
\ingroup h5part_c_api_read
|
||||
|
||||
Gets the name, type and number of elements of a dataset specified by it's
|
||||
index in the current time-step.
|
||||
|
||||
Type is one of \c H5T_NATIVE_DOUBLE or \c H5T_NATIVE_INT64.
|
||||
|
||||
\return \c H5_SUCCESS
|
||||
*/
|
||||
h5_int64_t
|
||||
H5PartGetDatasetInfo (
|
||||
h5_file_t *f, /*!< [in] Handle to open file */
|
||||
const h5_int64_t idx,/*!< [in] Index of the dataset */
|
||||
char *dataset_name, /*!< [out] Name of dataset */
|
||||
const h5_int64_t len_dataset_name,
|
||||
/*!< [in] Size of buffer \c dataset_name */
|
||||
h5_int64_t *type, /*!< [out] Type of data in dataset */
|
||||
h5_int64_t *nelem /*!< [out] Number of elements. */
|
||||
) {
|
||||
|
||||
SET_FNAME ( f, __func__ );
|
||||
|
||||
if ( h5_check_filehandle ( f ) != H5_SUCCESS )
|
||||
return h5_get_errno ( f );
|
||||
|
||||
return h5u_get_dataset_info (
|
||||
f, idx, dataset_name, len_dataset_name, type, nelem );
|
||||
}
|
||||
|
||||
/*!
|
||||
\ingroup h5part_c_api_read
|
||||
|
||||
This gets the number of particles stored in the current step.
|
||||
It will arbitrarily select a time-step if you haven't already set
|
||||
the step with \c H5PartSetStep().
|
||||
|
||||
\return number of particles in current step or an error
|
||||
code.
|
||||
*/
|
||||
h5_int64_t
|
||||
H5PartGetNumParticles (
|
||||
h5_file_t *f /*!< [in] Handle to open file */
|
||||
) {
|
||||
|
||||
SET_FNAME ( f, __func__ );
|
||||
|
||||
if ( h5_check_filehandle ( f ) != H5_SUCCESS )
|
||||
return h5_get_errno ( f );
|
||||
|
||||
if ( f->step_gid < 0 ) {
|
||||
h5_int64_t herr = h5_set_step ( f, 0 );
|
||||
if ( herr < 0 ) return herr;
|
||||
}
|
||||
|
||||
return h5u_get_num_elems ( f );
|
||||
}
|
||||
|
||||
/*!
|
||||
\ingroup h5part_c_api_read
|
||||
*/
|
||||
h5_int64_t
|
||||
H5PartResetView (
|
||||
h5_file_t *f /*!< [in] Handle to open file */
|
||||
) {
|
||||
SET_FNAME ( f, __func__ );
|
||||
|
||||
if ( h5_check_filehandle ( f ) != H5_SUCCESS )
|
||||
return h5_get_errno ( f );
|
||||
|
||||
CHECK_READONLY_MODE ( f );
|
||||
|
||||
return h5u_reset_view ( f );
|
||||
}
|
||||
|
||||
/*!
|
||||
\ingroup h5part_c_api_read
|
||||
*/
|
||||
h5_int64_t
|
||||
H5PartHasView (
|
||||
h5_file_t *f /*!< [in] Handle to open file */
|
||||
) {
|
||||
SET_FNAME ( f, __func__ );
|
||||
|
||||
CHECK_FILEHANDLE( f );
|
||||
CHECK_READONLY_MODE ( f );
|
||||
|
||||
return h5u_has_view ( f );
|
||||
}
|
||||
|
||||
|
||||
/*!
|
||||
\ingroup h5part_c_api_read
|
||||
|
||||
For parallel I/O or for subsetting operations on the datafile, the
|
||||
\c H5PartSetView() function allows you to define a subset of the total
|
||||
particle dataset to read. The concept of "view" works for both serial
|
||||
and for parallel I/O. The "view" will remain in effect until a new view
|
||||
is set, or the number of particles in a dataset changes, or the view is
|
||||
"unset" by calling \c H5PartSetView(file,-1,-1);
|
||||
|
||||
Before you set a view, the \c H5PartGetNumParticles() will return the
|
||||
total number of particles in the current time-step (even for the parallel
|
||||
reads). However, after you set a view, it will return the number of
|
||||
particles contained in the view.
|
||||
|
||||
The range is inclusive (the start and the end index).
|
||||
|
||||
\return \c H5_SUCCESS or error code
|
||||
*/
|
||||
h5_int64_t
|
||||
H5PartSetView (
|
||||
h5_file_t *f, /*!< [in] Handle to open file */
|
||||
const h5_int64_t start, /*!< [in] Start particle */
|
||||
const h5_int64_t end /*!< [in] End particle */
|
||||
) {
|
||||
|
||||
SET_FNAME ( f, __func__ );
|
||||
|
||||
CHECK_FILEHANDLE( f );
|
||||
CHECK_READONLY_MODE ( f );
|
||||
|
||||
if ( f->step_gid < 0 ) {
|
||||
h5_int64_t herr = h5_set_step ( f, 0 );
|
||||
if ( herr < 0 ) return herr;
|
||||
}
|
||||
|
||||
return h5u_set_view ( f, start, end );
|
||||
}
|
||||
|
||||
/*!
|
||||
\ingroup h5part_c_api_read
|
||||
|
||||
Allows you to query the current view. Start and End
|
||||
will be \c -1 if there is no current view established.
|
||||
Use \c H5PartHasView() to see if the view is smaller than the
|
||||
total dataset.
|
||||
|
||||
\return the number of elements in the view
|
||||
*/
|
||||
h5_int64_t
|
||||
H5PartGetView (
|
||||
h5_file_t *f, /*!< [in] Handle to open file */
|
||||
h5_int64_t *start, /*!< [out] Start particle */
|
||||
h5_int64_t *end /*!< [out] End particle */
|
||||
) {
|
||||
|
||||
SET_FNAME ( f, __func__ );
|
||||
|
||||
CHECK_FILEHANDLE( f );
|
||||
|
||||
if ( f->step_gid < 0 ) {
|
||||
h5_int64_t herr = h5_set_step ( f, 0 );
|
||||
if ( herr < 0 ) return herr;
|
||||
}
|
||||
return h5u_get_view( f, start, end );
|
||||
}
|
||||
|
||||
/*!
|
||||
\ingroup h5part_c_api_read
|
||||
|
||||
If it is too tedious to manually set the start and end coordinates
|
||||
for a view, the \c H5SetCanonicalView() will automatically select an
|
||||
appropriate domain decomposition of the data arrays for the degree
|
||||
of parallelism and set the "view" accordingly.
|
||||
|
||||
\return H5_SUCCESS or error code
|
||||
*/
|
||||
/*
|
||||
\note
|
||||
There is a bug in this function:
|
||||
If (NumParticles % f->nprocs) != 0 then
|
||||
the last (NumParticles % f->nprocs) particles are not handled!
|
||||
*/
|
||||
|
||||
h5_int64_t
|
||||
H5PartSetCanonicalView (
|
||||
h5_file_t *f /*!< [in] Handle to open file */
|
||||
) {
|
||||
|
||||
SET_FNAME ( f, __func__ );
|
||||
|
||||
h5_int64_t herr;
|
||||
|
||||
CHECK_FILEHANDLE( f );
|
||||
CHECK_READONLY_MODE ( f )
|
||||
|
||||
if ( f->step_gid < 0 ) {
|
||||
herr = h5_set_step ( f, 0 );
|
||||
if ( herr < 0 ) return herr;
|
||||
}
|
||||
|
||||
return h5u_set_canonical_view ( f );
|
||||
}
|
||||
|
||||
/*!
|
||||
\ingroup h5part_c_api_read
|
||||
|
||||
Read array of 64 bit floating point data from file.
|
||||
|
||||
When retrieving datasets from disk, you ask for them
|
||||
by name. There are no restrictions on naming of arrays,
|
||||
but it is useful to arrive at some common naming
|
||||
convention when sharing data with other groups.
|
||||
|
||||
\return \c H5_SUCCESS or error code
|
||||
*/
|
||||
h5_int64_t
|
||||
H5PartReadDataFloat64 (
|
||||
h5_file_t *f, /*!< [in] Handle to open file */
|
||||
const char *name, /*!< [in] Name to associate dataset with */
|
||||
h5_float64_t *array /*!< [out] Array of data */
|
||||
) {
|
||||
|
||||
SET_FNAME ( f, __func__ );
|
||||
|
||||
CHECK_FILEHANDLE( f );
|
||||
|
||||
return h5u_read_elems ( f, name, array, H5T_NATIVE_DOUBLE );
|
||||
}
|
||||
|
||||
/*!
|
||||
\ingroup h5part_c_api_read
|
||||
|
||||
Read array of 64 bit floating point data from file.
|
||||
|
||||
When retrieving datasets from disk, you ask for them
|
||||
by name. There are no restrictions on naming of arrays,
|
||||
but it is useful to arrive at some common naming
|
||||
convention when sharing data with other groups.
|
||||
|
||||
\return \c H5_SUCCESS or error code
|
||||
*/
|
||||
h5_int64_t
|
||||
H5PartReadDataInt64 (
|
||||
h5_file_t *f, /*!< [in] Handle to open file */
|
||||
const char *name, /*!< [in] Name to associate dataset with */
|
||||
h5_int64_t *array /*!< [out] Array of data */
|
||||
) {
|
||||
|
||||
SET_FNAME ( f, __func__ );
|
||||
CHECK_FILEHANDLE( f );
|
||||
|
||||
return h5u_read_elems ( f, name, array, H5T_NATIVE_INT64 );
|
||||
}
|
||||
|
||||
/*!
|
||||
\ingroup h5part_c_api_read
|
||||
|
||||
This is the mongo read function that pulls in all of the data for a
|
||||
given step in one shot. It also takes the step as an argument
|
||||
and will call \c H5PartSetStep() internally so that you don't have to
|
||||
make that call separately.
|
||||
|
||||
\note
|
||||
See also \c H5PartReadDataInt64() and \c H5PartReadDataFloat64() if you want
|
||||
to just read in one of the many datasets.
|
||||
|
||||
\return \c H5_SUCCESS or error code
|
||||
*/
|
||||
h5_int64_t
|
||||
H5PartReadParticleStep (
|
||||
h5_file_t *f, /*!< [in] Handle to open file */
|
||||
h5_int64_t step, /*!< [in] Step to read */
|
||||
h5_float64_t *x, /*!< [out] Buffer for dataset named "x" */
|
||||
h5_float64_t *y, /*!< [out] Buffer for dataset named "y" */
|
||||
h5_float64_t *z, /*!< [out] Buffer for dataset named "z" */
|
||||
h5_float64_t *px, /*!< [out] Buffer for dataset named "px" */
|
||||
h5_float64_t *py, /*!< [out] Buffer for dataset named "py" */
|
||||
h5_float64_t *pz, /*!< [out] Buffer for dataset named "pz" */
|
||||
h5_int64_t *id /*!< [out] Buffer for dataset named "id" */
|
||||
) {
|
||||
|
||||
SET_FNAME ( f, __func__ );
|
||||
h5_int64_t herr;
|
||||
|
||||
CHECK_FILEHANDLE( f );
|
||||
|
||||
herr = h5_set_step ( f, step );
|
||||
if ( herr < 0 ) return herr;
|
||||
|
||||
herr = h5u_read_elems ( f, "x", (void*)x, H5T_NATIVE_DOUBLE );
|
||||
if ( herr < 0 ) return herr;
|
||||
|
||||
herr = h5u_read_elems ( f, "y", (void*)y, H5T_NATIVE_DOUBLE );
|
||||
if ( herr < 0 ) return herr;
|
||||
|
||||
herr = h5u_read_elems ( f, "z", (void*)z, H5T_NATIVE_DOUBLE );
|
||||
if ( herr < 0 ) return herr;
|
||||
|
||||
herr = h5u_read_elems ( f, "px", (void*)px, H5T_NATIVE_DOUBLE );
|
||||
if ( herr < 0 ) return herr;
|
||||
|
||||
herr = h5u_read_elems ( f, "py", (void*)py, H5T_NATIVE_DOUBLE );
|
||||
if ( herr < 0 ) return herr;
|
||||
|
||||
herr = h5u_read_elems ( f, "pz", (void*)pz, H5T_NATIVE_DOUBLE );
|
||||
if ( herr < 0 ) return herr;
|
||||
|
||||
herr = h5u_read_elems ( f, "id", (void*)id, H5T_NATIVE_INT64 );
|
||||
if ( herr < 0 ) return herr;
|
||||
|
||||
return H5_SUCCESS;
|
||||
}
|
||||
|
||||
/****************** error handling ******************/
|
||||
|
||||
|
||||
+285
@@ -0,0 +1,285 @@
|
||||
/*
|
||||
Header file for declaring the H5Fed application programming
|
||||
interface (API) in the C language.
|
||||
|
||||
Copyright 2006-2007
|
||||
Paul Scherrer Institut, Villigen, Switzerland;
|
||||
Benedikt Oswald;
|
||||
Achim Gsell
|
||||
All rights reserved.
|
||||
|
||||
Authors
|
||||
Achim Gsell
|
||||
|
||||
Warning
|
||||
This code is under development.
|
||||
|
||||
*/
|
||||
#ifndef __H5Part_H
|
||||
#define __H5Part_H
|
||||
|
||||
#include <hdf5.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#include "h5_core/h5_core.h"
|
||||
#include "H5.h"
|
||||
#ifdef PARALLEL_IO
|
||||
#include <mpi.h>
|
||||
#endif
|
||||
|
||||
// #define H5PART_SUCCESS H5_SUCCESS
|
||||
#define H5PART_ERR_NOMEM H5_ERR_NOMEM
|
||||
#define H5PART_ERR_INVAL H5_ERR_INVAL
|
||||
#define H5PART_ERR_BADFD H5_ERR_BADFD
|
||||
#define H5PART_ERR_LAYOUT H5_ERR_LAYOUT
|
||||
#define H5PART_ERR_NOENT H5_ERR_NOENT
|
||||
#define H5PART_ERR_NOENTRY H5_ERR_NOENTRY
|
||||
|
||||
#define H5PART_ERR_MPI H5_ERR_MPI
|
||||
#define H5PART_ERR_HDF5 H5_ERR_HDF5
|
||||
|
||||
#define H5PART_READ H5_O_RDONLY
|
||||
#define H5PART_WRITE H5_O_WRONLY
|
||||
#define H5PART_APPEND H5_O_APPEND
|
||||
|
||||
#define H5PART_INT64 ((h5_int64_t)H5T_NATIVE_INT64)
|
||||
#define H5PART_FLOAT64 ((h5_int64_t)H5T_NATIVE_DOUBLE)
|
||||
#define H5PART_CHAR ((h5_int64_t)H5T_NATIVE_CHAR)
|
||||
|
||||
/*========== File Opening/Closing ===============*/
|
||||
h5_file_t *
|
||||
H5PartOpenFile(
|
||||
const char *filename,
|
||||
const unsigned flags
|
||||
);
|
||||
|
||||
#define H5PartOpenFileSerial(x,y) H5PartOpenFile(x,y)
|
||||
|
||||
#ifdef PARALLEL_IO
|
||||
h5_file_t *
|
||||
H5PartOpenFileParallel (
|
||||
const char *filename,
|
||||
const unsigned flags,
|
||||
MPI_Comm communicator
|
||||
);
|
||||
#endif
|
||||
|
||||
|
||||
h5_int64_t
|
||||
H5PartCloseFile (
|
||||
h5_file_t *f
|
||||
);
|
||||
|
||||
|
||||
/*============== File Writing Functions ==================== */
|
||||
h5_int64_t
|
||||
H5PartDefineStepName (
|
||||
h5_file_t *f,
|
||||
const char *name,
|
||||
const h5_int64_t width
|
||||
);
|
||||
|
||||
h5_int64_t
|
||||
H5PartSetNumParticles (
|
||||
h5_file_t *f,
|
||||
const h5_int64_t nparticles
|
||||
);
|
||||
|
||||
h5_int64_t
|
||||
H5PartWriteDataFloat64 (
|
||||
h5_file_t *f,
|
||||
const char *name,
|
||||
const h5_float64_t *array
|
||||
);
|
||||
|
||||
h5_int64_t
|
||||
H5PartWriteDataInt64 (
|
||||
h5_file_t *f,
|
||||
const char *name,
|
||||
const h5_int64_t *array
|
||||
);
|
||||
|
||||
/*================== File Reading Routines =================*/
|
||||
h5_int64_t
|
||||
H5PartSetStep (
|
||||
h5_file_t *f,
|
||||
const h5_int64_t step
|
||||
);
|
||||
|
||||
h5_int64_t
|
||||
H5PartGetNumDatasets (
|
||||
h5_file_t *f
|
||||
);
|
||||
|
||||
h5_int64_t
|
||||
H5PartGetDatasetName (
|
||||
h5_file_t *f,
|
||||
const h5_int64_t idx,
|
||||
char *name,
|
||||
const h5_int64_t maxlen
|
||||
);
|
||||
|
||||
h5_int64_t
|
||||
H5PartGetDatasetInfo (
|
||||
h5_file_t *f,
|
||||
const h5_int64_t idx,
|
||||
char *name,
|
||||
const h5_int64_t maxlen,
|
||||
h5_int64_t *type,
|
||||
h5_int64_t *nelem);
|
||||
|
||||
|
||||
h5_int64_t
|
||||
H5PartGetNumParticles (
|
||||
h5_file_t *f
|
||||
);
|
||||
|
||||
h5_int64_t
|
||||
H5PartSetView (
|
||||
h5_file_t *f,
|
||||
const h5_int64_t start,
|
||||
const h5_int64_t end
|
||||
);
|
||||
|
||||
|
||||
h5_int64_t
|
||||
H5PartGetView (
|
||||
h5_file_t *f,
|
||||
h5_int64_t *start,
|
||||
h5_int64_t *end
|
||||
);
|
||||
|
||||
h5_int64_t
|
||||
H5PartHasView (
|
||||
h5_file_t *f
|
||||
);
|
||||
|
||||
h5_int64_t
|
||||
H5PartResetView (
|
||||
h5_file_t *f
|
||||
);
|
||||
|
||||
h5_int64_t
|
||||
H5PartSetCanonicalView (
|
||||
h5_file_t *f
|
||||
);
|
||||
|
||||
h5_int64_t
|
||||
H5PartReadDataFloat64(
|
||||
h5_file_t *f,
|
||||
const char *name,
|
||||
h5_float64_t *array
|
||||
);
|
||||
|
||||
h5_int64_t
|
||||
H5PartReadDataInt64 (
|
||||
h5_file_t *f,
|
||||
const char *name,
|
||||
h5_int64_t *array
|
||||
);
|
||||
|
||||
h5_int64_t
|
||||
H5PartReadParticleStep (
|
||||
h5_file_t *f,
|
||||
const h5_int64_t step,
|
||||
h5_float64_t *x, /* particle positions */
|
||||
h5_float64_t *y,
|
||||
h5_float64_t *z,
|
||||
h5_float64_t *px, /* particle momenta */
|
||||
h5_float64_t *py,
|
||||
h5_float64_t *pz,
|
||||
h5_int64_t *id /* and phase */
|
||||
);
|
||||
|
||||
/**********==============Attributes Interface============***************/
|
||||
/* currently there is file attributes: Attributes bound to the file
|
||||
and step attributes which are bound to the current step. You
|
||||
must set the step explicitly before writing the attributes (just
|
||||
as you must do when you write a new dataset. Currently there are no
|
||||
attributes that are bound to a particular data array, but this could
|
||||
easily be done if required.
|
||||
*/
|
||||
h5_int64_t
|
||||
H5PartWriteStepAttrib (
|
||||
h5_file_t *f,
|
||||
const char *attrib_name,
|
||||
const h5_int64_t attrib_type,
|
||||
const void *attrib_value,
|
||||
const h5_int64_t attrib_nelem
|
||||
);
|
||||
|
||||
h5_int64_t
|
||||
H5PartWriteFileAttrib (
|
||||
h5_file_t *f,
|
||||
const char *attrib_name,
|
||||
const h5_int64_t attrib_type,
|
||||
const void *attrib_value,
|
||||
const h5_int64_t attrib_nelem
|
||||
);
|
||||
|
||||
h5_int64_t
|
||||
H5PartWriteFileAttribString (
|
||||
h5_file_t *f,
|
||||
const char *name,
|
||||
const char *attrib
|
||||
);
|
||||
|
||||
h5_int64_t
|
||||
H5PartWriteStepAttribString (
|
||||
h5_file_t *f,
|
||||
const char *name,
|
||||
const char *attrib
|
||||
);
|
||||
|
||||
h5_int64_t
|
||||
H5PartGetNumStepAttribs ( /* for current filestep */
|
||||
h5_file_t *f
|
||||
);
|
||||
|
||||
h5_int64_t
|
||||
H5PartGetNumFileAttribs (
|
||||
h5_file_t *f
|
||||
);
|
||||
|
||||
h5_int64_t
|
||||
H5PartGetStepAttribInfo (
|
||||
h5_file_t *f,
|
||||
const h5_int64_t attrib_idx,
|
||||
char *attrib_name,
|
||||
const h5_int64_t len_of_attrib_name,
|
||||
h5_int64_t *attrib_type,
|
||||
h5_int64_t *attrib_nelem
|
||||
);
|
||||
|
||||
h5_int64_t
|
||||
H5PartGetFileAttribInfo (
|
||||
h5_file_t *f,
|
||||
const h5_int64_t idx,
|
||||
char *name,
|
||||
const h5_int64_t maxnamelen,
|
||||
h5_int64_t *type,
|
||||
h5_int64_t *nelem
|
||||
);
|
||||
|
||||
h5_int64_t
|
||||
H5PartReadStepAttrib (
|
||||
h5_file_t *f,
|
||||
const char *name,
|
||||
void *data
|
||||
);
|
||||
|
||||
h5_int64_t
|
||||
H5PartReadFileAttrib (
|
||||
h5_file_t *f,
|
||||
const char *name,
|
||||
void *data
|
||||
);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,96 @@
|
||||
/*
|
||||
Copyright 2007-2008
|
||||
Paul Scherrer Institut, Villigen, Switzerland;
|
||||
Benedikt Oswald;
|
||||
Achim Gsell
|
||||
All rights reserved.
|
||||
|
||||
Authors
|
||||
Achim Gsell
|
||||
|
||||
Warning
|
||||
This code is under development.
|
||||
|
||||
*/
|
||||
/*!
|
||||
\ingroup h5f_c_api
|
||||
\defgroup h5_inquiry
|
||||
*/
|
||||
|
||||
#include <stdarg.h>
|
||||
#include <hdf5.h>
|
||||
#include "h5_core/h5_core.h"
|
||||
#include "h5_core/h5_core_private.h"
|
||||
#include "H5.h"
|
||||
|
||||
/*!
|
||||
\ingroup h5_inquiry
|
||||
|
||||
Get the number of compute nodes.
|
||||
|
||||
\param[in] f File handle.
|
||||
|
||||
\return Number of compute notes.
|
||||
\return \c -1 on error.
|
||||
*/
|
||||
h5_size_t
|
||||
H5GetNumNodes (
|
||||
h5_file_t * const f
|
||||
) {
|
||||
SET_FNAME ( f, __func__ );
|
||||
CHECK_FILEHANDLE ( f );
|
||||
return (h5_size_t)f->nprocs;
|
||||
}
|
||||
|
||||
/*!
|
||||
\ingroup h5part_c_api_read
|
||||
|
||||
Get the number of time-steps that are currently stored in the file
|
||||
\c f.
|
||||
|
||||
It works for both reading and writing of files, but is probably
|
||||
only typically used when you are reading.
|
||||
|
||||
\param[in] f File handle.
|
||||
|
||||
\return number of time-steps or error code
|
||||
*/
|
||||
h5_size_t
|
||||
H5GetNumSteps (
|
||||
h5_file_t * const f
|
||||
) {
|
||||
|
||||
SET_FNAME ( f, __func__ );
|
||||
CHECK_FILEHANDLE ( f );
|
||||
|
||||
return hdf5_get_num_objects_matching_pattern (
|
||||
f->file,
|
||||
"/",
|
||||
H5G_UNKNOWN,
|
||||
f->prefix_step_name );
|
||||
}
|
||||
|
||||
/*!
|
||||
\ingroup h5_inquiry
|
||||
|
||||
Query whether a particular step already exists in the file.
|
||||
|
||||
\param[in] f File handle.
|
||||
\param[in] stepno Step number to query for existence
|
||||
|
||||
\return true or false
|
||||
*/
|
||||
h5_err_t
|
||||
H5HasStep (
|
||||
h5_file_t *f,
|
||||
h5_id_t stepno
|
||||
) {
|
||||
|
||||
SET_FNAME ( f, __func__ );
|
||||
CHECK_FILEHANDLE ( f );
|
||||
|
||||
return h5_has_step( f, stepno );
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1,19 @@
|
||||
#ifndef __H5_INQUIRY_H
|
||||
#define __H5_INQUIRY_H
|
||||
|
||||
h5_size_t
|
||||
H5GetNumNodes (
|
||||
h5_file_t * const f
|
||||
);
|
||||
|
||||
h5_size_t
|
||||
H5GetNumSteps (
|
||||
h5_file_t * const f
|
||||
);
|
||||
|
||||
h5_err_t
|
||||
H5HasStep (
|
||||
h5_file_t * const f,
|
||||
h5_id_t step
|
||||
);
|
||||
#endif
|
||||
Reference in New Issue
Block a user