#include <iostream>
#include "LevelData.H"
#include "HDF5Portable.H"
#include <string>
#include <map>
#include "RealVect.H"
#include "CH_Timer.H"
#include "LoadBalance.H"
#include "LayoutIterator.H"
#include "Vector.H"
#include "memtrack.H"
#include "FluxBox.H"
#include "NamespaceHeader.H"
#include "NamespaceFooter.H"
#include "BaseNamespaceHeader.H"
#include "NamespaceVar.H"
#include "BaseNamespaceFooter.H"
Go to the source code of this file.
Namespaces | |
namespace | CH_HDF5 |
Classes | |
class | HDF5Handle |
Handle to a particular group in an HDF file. More... | |
class | HDF5HeaderData |
data to be added to HDF5 files. More... | |
class | WriteMultiData< T > |
Methods for writing multiple LevelData to an HDF5 file. More... | |
struct | OffsetBuffer |
Defines | |
#define | CHOFFSET(object, member) (int)((char*)&(object.member) - (char*)&object) |
Typedefs | |
typedef hssize_t | ch_offset_t |
Enumerations | |
enum | CH_HDF5::IOPolicy { CH_HDF5::IOPolicyDefault = 0, CH_HDF5::IOPolicyMultiDimHyperslab = (1<<0), CH_HDF5::IOPolicyCollectiveWrite = (1<<1) } |
Functions | |
template<class T> | |
void | read (T &item, Vector< Vector< char > > &a_allocatedBuffers, const Box &box, const Interval &comps) |
template<class T> | |
int | writeLevel (HDF5Handle &a_handle, const int &a_level, const T &a_data, const Real &a_dx, const Real &a_dt, const Real &a_time, const Box &a_domain, const int &a_refRatio, const IntVect &outputGhost=IntVect::Zero, const Interval &comps=Interval()) |
user-friendly function to write out data on a AMR level | |
template<class T> | |
int | readLevel (HDF5Handle &a_handle, const int &a_level, LevelData< T > &a_data, Real &a_dx, Real &a_dt, Real &a_time, Box &a_domain, int &a_refRatio, const Interval &a_comps=Interval(), bool setGhost=false) |
template<class T> | |
int | readLevel (HDF5Handle &a_handle, const int &a_level, LevelData< T > &a_data, RealVect &a_dx, Real &a_dt, Real &a_time, Box &a_domain, IntVect &a_refRatio, const Interval &a_comps=Interval(), bool setGhost=false) |
int | write (HDF5Handle &a_handle, const BoxLayout &a_layout, const std::string &name="boxes") |
writes BoxLayout to HDF5 file. | |
template<class T> | |
int | write (HDF5Handle &a_handle, const BoxLayoutData< T > &a_data, const std::string &a_name, IntVect outputGhost=IntVect::Zero, const Interval &comps=Interval(), bool newForm=false) |
writes a BoxLayoutData<T> to an HDF5 file. | |
template<class T> | |
int | write (HDF5Handle &a_handle, const LevelData< T > &a_data, const std::string &a_name, const IntVect &outputGhost=IntVect::Zero, const Interval &comps=Interval()) |
writes a LevelData<T> to an HDF5 file. | |
int | read (HDF5Handle &a_handle, Vector< Box > &boxes, const std::string &name="boxes") |
reads Vector<Box> from location specified by a_handle. | |
int | readBoxes (HDF5Handle &a_handle, Vector< Vector< Box > > &boxes) |
reads the set of Boxes out from the level_* groups of a Chombo HDF5 AMR file | |
int | readFArrayBox (HDF5Handle &a_handle, FArrayBox &a_fab, int a_level, int a_boxNumber, const Interval &a_components, const std::string &a_dataName="data") |
FArrayBox-at-a-time read function. FArrayBox gets redefined in the function. Reads data field named by a_dataName. | |
template<class T> | |
int | read (HDF5Handle &a_handle, BoxLayoutData< T > &a_data, const std::string &a_name, const BoxLayout &a_layout, const Interval &a_comps=Interval(), bool redefineData=true) |
read BoxLayoutData named a_name from location specified by a_handle. | |
template<class T> | |
int | read (HDF5Handle &a_handle, LevelData< T > &a_data, const std::string &a_name, const DisjointBoxLayout &a_layout, const Interval &a_comps=Interval(), bool redefineData=true) |
read LevelData named a_name from location specified by a_handle. | |
herr_t | HDF5HeaderDataattributeScan (hid_t loc_id, const char *name, const H5A_info_t *info, void *opdata) |
std::ostream & | operator<< (std::ostream &os, const HDF5HeaderData &data) |
template<class T> | |
hid_t | H5Type (const T *dummy) |
template<> | |
hid_t | H5Type (const int *dummy) |
template<> | |
hid_t | H5Type (const long long *dummy) |
template<> | |
hid_t | H5Type (const float *dummy) |
template<> | |
hid_t | H5Type (const double *dummy) |
template<> | |
hid_t | H5Type (const Box *dummy) |
template<> | |
hid_t | H5Type (const RealVect *dummy) |
template<> | |
hid_t | H5Type (const IntVect *dummy) |
void | createData (hid_t &a_dataset, hid_t &a_dataspace, HDF5Handle &handle, const std::string &name, hid_t type, hsize_t size) |
template<class T> | |
void | createDataset (hid_t &a_dataset, hid_t &a_dataspace, HDF5Handle &handle, const std::string &name, const T *dummy, hsize_t size) |
void | writeDataset (hid_t a_dataset, hid_t a_dataspace, const void *start, ch_offset_t off, hsize_t count) |
void | readDataset (hid_t a_dataset, hid_t a_dataspace, void *start, ch_offset_t off, hsize_t count) |
ostream & | operator<< (ostream &os, const OffsetBuffer &ob) |
template<> | |
int | linearSize (const CH_XDIR::OffsetBuffer &a_input) |
template<> | |
void | linearIn (CH_XDIR::OffsetBuffer &a_outputT, const void *const a_inBuf) |
template<> | |
void | linearOut (void *const a_outBuf, const CH_XDIR::OffsetBuffer &a_inputT) |
template<> | |
int | linearSize (const Vector< CH_XDIR::OffsetBuffer > &a_input) |
template<> | |
void | linearIn (Vector< CH_XDIR::OffsetBuffer > &a_outputT, const void *const inBuf) |
template<> | |
void | linearOut (void *const a_outBuf, const Vector< CH_XDIR::OffsetBuffer > &a_inputT) |
template<> | |
void | dataTypes (Vector< hid_t > &a_types, const BaseFab< int > &dummy) |
template<> | |
void | dataTypes (Vector< hid_t > &a_types, const BaseFab< char > &dummy) |
template<> | |
void | dataTypes (Vector< hid_t > &a_types, const FArrayBox &dummy) |
template<> | |
void | dataTypes (Vector< hid_t > &a_types, const FluxBox &dummy) |
template<> | |
void | dataSize (const BaseFab< int > &item, Vector< int > &a_sizes, const Box &box, const Interval &comps) |
template<> | |
void | dataSize (const BaseFab< char > &item, Vector< int > &a_sizes, const Box &box, const Interval &comps) |
template<> | |
void | dataSize (const FArrayBox &item, Vector< int > &a_sizes, const Box &box, const Interval &comps) |
template<> | |
void | dataSize (const FluxBox &item, Vector< int > &a_sizes, const Box &box, const Interval &comps) |
template<> | |
const char * | name (const FArrayBox &a_dummySpecializationArg) |
template<> | |
const char * | name (const BaseFab< int > &a_dummySpecializationArg) |
template<> | |
const char * | name (const BaseFab< char > &a_dummySpecializationArg) |
template<class T> | |
void | dataTypes (Vector< hid_t > &a_types, const T &dummy) |
template<class T> | |
void | dataSize (const T &item, Vector< int > &a_sizes, const Box &box, const Interval &comps) |
template<class T> | |
void | write (const T &item, Vector< void * > &a_allocatedBuffers, const Box &box, const Interval &comps) |
template<class T> | |
void | read (T &item, Vector< void * > &a_allocatedBuffers, const Box &box, const Interval &comps) |
template<class T> | |
const char * | name (const T &a_dummySpecializationArg) |
template<class T> | |
void | getOffsets (Vector< Vector< long long > > &offsets, const BoxLayoutData< T > &a_data, int types, const Interval &comps, const IntVect &outputGhost) |
template<class T> | |
void | getOffsets (Vector< Vector< long long > > &a_offsets, const BoxLayout a_layout, int a_numTypes, const Interval &a_comps, const IntVect &a_outputGhost) |
template<class T> | |
int | writeLevel (HDF5Handle &a_handle, const int &a_level, const T &a_data, const RealVect &a_dx, const Real &a_dt, const Real &a_time, const Box &a_domain, const IntVect &a_refRatios, const IntVect &outputGhost, const Interval &comps) |
#define CHOFFSET | ( | object, | |||
member | ) | (int)((char*)&(object.member) - (char*)&object) |
typedef hssize_t ch_offset_t |
void read | ( | T & | item, | |
Vector< Vector< char > > & | a_allocatedBuffers, | |||
const Box & | box, | |||
const Interval & | comps | |||
) | [inline] |
Referenced by blockRead(), blockReadLevel(), read(), and readLevel().
int writeLevel | ( | HDF5Handle & | a_handle, | |
const int & | a_level, | |||
const T & | a_data, | |||
const Real & | a_dx, | |||
const Real & | a_dt, | |||
const Real & | a_time, | |||
const Box & | a_domain, | |||
const int & | a_refRatio, | |||
const IntVect & | outputGhost = IntVect::Zero , |
|||
const Interval & | comps = Interval() | |||
) | [inline] |
user-friendly function to write out data on a AMR level
all data is IN data. a_handle: handle open and ready. a_data: data, what else do you want to know ? a_dx: the grid spacing at this level a_dt: the timestep size that was last completed a_time: the time of this level (might not be the same as other levels) a_domain: the problem domain, represented at this level of refinement a_refRatio:the refinement of a_level+1 wrt a_level. for vis systems it would probably help if you use 1 for a_level==max_level.
References HDF5Handle::getGroup(), HDF5HeaderData::m_box, HDF5HeaderData::m_int, HDF5HeaderData::m_real, HDF5Handle::setGroup(), write(), and HDF5HeaderData::writeToFile().
int readLevel | ( | HDF5Handle & | a_handle, | |
const int & | a_level, | |||
LevelData< T > & | a_data, | |||
RealVect & | a_dx, | |||
Real & | a_dt, | |||
Real & | a_time, | |||
Box & | a_domain, | |||
IntVect & | a_refRatio, | |||
const Interval & | a_comps = Interval() , |
|||
bool | setGhost = false | |||
) | [inline] |
References DisjointBoxLayout::close(), HDF5Handle::getGroup(), LoadBalance(), HDF5HeaderData::m_box, HDF5HeaderData::m_int, HDF5HeaderData::m_intvect, HDF5HeaderData::m_real, HDF5HeaderData::m_realvect, read(), HDF5HeaderData::readFromFile(), HDF5Handle::setGroup(), IntVect::Unit, and RealVect::Unit.
int write | ( | HDF5Handle & | a_handle, | |
const BoxLayout & | a_layout, | |||
const std::string & | name = "boxes" | |||
) |
writes BoxLayout to HDF5 file.
Writes BoxLayout to HDF5 file. Only one BoxLayout per group is permitted, this operation overwrites previous entries. This operation assumes boxes are cell-centered.\ returns: success: 0\ HDF5 error: negative error code.\
Referenced by blockWriteLevel(), blockWriteToBuffer(), write(), writeLevel(), and WriteMultiData< T >::WriteMultiData().
int write | ( | HDF5Handle & | a_handle, | |
const BoxLayoutData< T > & | a_data, | |||
const std::string & | a_name, | |||
IntVect | outputGhost = IntVect::Zero , |
|||
const Interval & | comps = Interval() , |
|||
bool | newForm = false | |||
) | [inline] |
writes a BoxLayoutData<T> to an HDF5 file.
writes a BoxLayoutData<T> to an HDF5 file.\ returns: success: 0\ HDF5 error: negative error code.\
References LayoutData< T >::box(), LayoutData< T >::boxLayout(), CH_assert, CH_TIME, CH_TIMELEAF, HDF5Handle::CREATE_SERIAL, LayoutData< T >::dataIterator(), dataTypes(), MayDay::Error(), freeMT, HDF5Handle::getGroup(), getOffsets(), HDF5Handle::groupID(), Box::grow(), BoxLayout::index(), BoxLayoutData< T >::interval(), HDF5HeaderData::m_int, HDF5HeaderData::m_intvect, HDF5HeaderData::m_string, mallocMT, name(), LayoutIterator::ok(), HDF5Handle::openMode(), pout(), procID(), HDF5Handle::setGroup(), DataIterator::size(), Vector< T >::size(), Interval::size(), write(), and HDF5HeaderData::writeToFile().
int write | ( | HDF5Handle & | a_handle, | |
const LevelData< T > & | a_data, | |||
const std::string & | a_name, | |||
const IntVect & | outputGhost = IntVect::Zero , |
|||
const Interval & | comps = Interval() | |||
) | [inline] |
writes a LevelData<T> to an HDF5 file.
Writes a LevelData<T> to an HDF5 file. the DisjointBoxLayout is not written out with the data, the user is required to handle that object seperately. (see the "read" interface below).\ returns: success: 0\ HDF5 error: negative error code.\
References CH_START, CH_STOP, CH_TIMER, CH_TIMERS, HDF5Handle::getGroup(), LevelData< T >::ghostVect(), HDF5HeaderData::m_intvect, IntVect::min(), HDF5Handle::setGroup(), write(), and HDF5HeaderData::writeToFile().
int read | ( | HDF5Handle & | a_handle, | |
Vector< Box > & | boxes, | |||
const std::string & | name = "boxes" | |||
) |
reads Vector<Box> from location specified by a_handle.
Reads BoxLayout from the group specified by a_handle. Only one BoxLayout per group is permitted, this operation overwrites. This operation assumes boxes are cell-centered.\ returns: success: 0\ HDF5 error: negative error code.\
Arg name refers to the name of an HDF5 dataset in which the boxes you want are stored in a particular format, which is the one used to output DataLayouts to HDF5. Here is an example of that format (as shown by h5dump):
DATASET "datalayout" { DATATYPE H5T_COMPOUND { H5T_STD_I32LE "lo_i"; H5T_STD_I32LE "lo_j"; H5T_STD_I32LE "hi_i"; H5T_STD_I32LE "hi_j"; } DATASPACE SIMPLE { ( 2 ) / ( 2 ) } DATA { (0): { 0, 0, 1, 0 }, (1): { 2, 0, 2, 1 } } }
int readBoxes | ( | HDF5Handle & | a_handle, | |
Vector< Vector< Box > > & | boxes | |||
) |
reads the set of Boxes out from the level_* groups of a Chombo HDF5 AMR file
goes to all groups named level_n for level n = 0 to numLevel and fills the vector of boxes. CH_HDF5.Handle must be set to the root group (the default location when the file is just opened.
A handy *get everything* version of int read(HDF5Handle& a_handle, Vector<Box>& boxes)
int readFArrayBox | ( | HDF5Handle & | a_handle, | |
FArrayBox & | a_fab, | |||
int | a_level, | |||
int | a_boxNumber, | |||
const Interval & | a_components, | |||
const std::string & | a_dataName = "data" | |||
) |
FArrayBox-at-a-time read function. FArrayBox gets redefined in the function. Reads data field named by a_dataName.
FArrayBox gets redefined in the function. it will be sized to the box at the [level,boxNumber] position and have components the go from [0,a_components.size()-1]
some meta-data has to be read again and again internally to do this function, but it should make some out-of-core tools possible.
int read | ( | HDF5Handle & | a_handle, | |
BoxLayoutData< T > & | a_data, | |||
const std::string & | a_name, | |||
const BoxLayout & | a_layout, | |||
const Interval & | a_comps = Interval() , |
|||
bool | redefineData = true | |||
) | [inline] |
read BoxLayoutData named a_name from location specified by a_handle.
Read BoxLayoutData named a_name from location specified by a_handle. User must supply the correct BoxLayout for this function if redefineData == true. \ returns: success: 0\ bad location: 1\ HDF5 error: negative error code.\
References LayoutData< T >::box(), LayoutData< T >::boxLayout(), CH_assert, CH_TIME, CH_TIMELEAF, LayoutData< T >::dataIterator(), dataTypes(), BoxLayoutData< T >::define(), HDF5Handle::getGroup(), HDF5Handle::groupID(), Box::grow(), BoxLayout::index(), HDF5HeaderData::m_int, HDF5HeaderData::m_intvect, read(), HDF5HeaderData::readFromFile(), Vector< T >::resize(), HDF5Handle::setGroup(), Interval::size(), BoxLayout::size(), Vector< T >::size(), MayDay::Warning(), and IntVect::Zero.
int read | ( | HDF5Handle & | a_handle, | |
LevelData< T > & | a_data, | |||
const std::string & | a_name, | |||
const DisjointBoxLayout & | a_layout, | |||
const Interval & | a_comps = Interval() , |
|||
bool | redefineData = true | |||
) | [inline] |
read LevelData named a_name from location specified by a_handle.
Read LevelData named a_name from location specified by a_handle. User must supply the correct BoxLayout for this function.
Arg a_name is significant: the HDF5 group to which a_handle is set is is assumed to contain a dataset called <a_name>:datatype=<some integer>="">, a dataset called <a_name>:offsets=<some integer>="">, and a subgroup named <a_name>_attributes. You will have all these items if you dumped your LevelData out using the corresponding write() function defined here.
If arg redefineData==false, then the user must pass in a valid LevelData. Otherwise, this function figures out how many components and ghost cells there are, and allocates the correct amount of space. The actual FArray data held by the LevelData gets filled in here, regardless of redefineData; "redefine" alludes to the family of define() functions.
returns: success: 0\ bad location: 1\ HDF5 error: negative error code.\
References LevelData< T >::define(), Interval::end(), MayDay::Error(), HDF5Handle::getGroup(), HDF5HeaderData::m_int, HDF5HeaderData::m_intvect, read(), HDF5HeaderData::readFromFile(), HDF5Handle::setGroup(), Interval::size(), and MayDay::Warning().
herr_t HDF5HeaderDataattributeScan | ( | hid_t | loc_id, | |
const char * | name, | |||
const H5A_info_t * | info, | |||
void * | opdata | |||
) |
std::ostream& operator<< | ( | std::ostream & | os, | |
const HDF5HeaderData & | data | |||
) |
hid_t H5Type | ( | const T * | dummy | ) | [inline] |
hid_t H5Type | ( | const int * | dummy | ) | [inline] |
hid_t H5Type | ( | const long long * | dummy | ) | [inline] |
hid_t H5Type | ( | const float * | dummy | ) | [inline] |
hid_t H5Type | ( | const double * | dummy | ) | [inline] |
hid_t H5Type | ( | const Box * | dummy | ) | [inline] |
hid_t H5Type | ( | const RealVect * | dummy | ) | [inline] |
hid_t H5Type | ( | const IntVect * | dummy | ) | [inline] |
void createData | ( | hid_t & | a_dataset, | |
hid_t & | a_dataspace, | |||
HDF5Handle & | handle, | |||
const std::string & | name, | |||
hid_t | type, | |||
hsize_t | size | |||
) |
Referenced by createDataset().
void createDataset | ( | hid_t & | a_dataset, | |
hid_t & | a_dataspace, | |||
HDF5Handle & | handle, | |||
const std::string & | name, | |||
const T * | dummy, | |||
hsize_t | size | |||
) | [inline] |
References createData(), and H5Type().
void writeDataset | ( | hid_t | a_dataset, | |
hid_t | a_dataspace, | |||
const void * | start, | |||
ch_offset_t | off, | |||
hsize_t | count | |||
) |
void readDataset | ( | hid_t | a_dataset, | |
hid_t | a_dataspace, | |||
void * | start, | |||
ch_offset_t | off, | |||
hsize_t | count | |||
) |
ostream& operator<< | ( | ostream & | os, | |
const OffsetBuffer & | ob | |||
) |
int linearSize | ( | const CH_XDIR::OffsetBuffer & | a_input | ) | [inline] |
void linearIn | ( | CH_XDIR::OffsetBuffer & | a_outputT, | |
const void *const | a_inBuf | |||
) | [inline] |
void linearOut | ( | void *const | a_outBuf, | |
const CH_XDIR::OffsetBuffer & | a_inputT | |||
) | [inline] |
int linearSize | ( | const Vector< CH_XDIR::OffsetBuffer > & | a_input | ) | [inline] |
void linearIn | ( | Vector< CH_XDIR::OffsetBuffer > & | a_outputT, | |
const void *const | inBuf | |||
) | [inline] |
void linearOut | ( | void *const | a_outBuf, | |
const Vector< CH_XDIR::OffsetBuffer > & | a_inputT | |||
) | [inline] |
References Vector< T >::resize().
References H5T_NATIVE_REAL, and Vector< T >::resize().
References H5T_NATIVE_REAL, and Vector< T >::resize().
void dataSize | ( | const BaseFab< int > & | item, | |
Vector< int > & | a_sizes, | |||
const Box & | box, | |||
const Interval & | comps | |||
) | [inline] |
References Box::numPts(), and Interval::size().
Referenced by blockLocalOffsets(), and getOffsets().
void dataSize | ( | const BaseFab< char > & | item, | |
Vector< int > & | a_sizes, | |||
const Box & | box, | |||
const Interval & | comps | |||
) | [inline] |
References Box::numPts(), and Interval::size().
void dataSize | ( | const FArrayBox & | item, | |
Vector< int > & | a_sizes, | |||
const Box & | box, | |||
const Interval & | comps | |||
) | [inline] |
References Box::numPts(), and Interval::size().
void dataSize | ( | const FluxBox & | item, | |
Vector< int > & | a_sizes, | |||
const Box & | box, | |||
const Interval & | comps | |||
) | [inline] |
References CH_SPACEDIM, Box::numPts(), Interval::size(), and surroundingNodes().
const char* name | ( | const FArrayBox & | a_dummySpecializationArg | ) | [inline] |
const char* name | ( | const BaseFab< int > & | a_dummySpecializationArg | ) | [inline] |
References name().
const char* name | ( | const BaseFab< char > & | a_dummySpecializationArg | ) | [inline] |
References name().
void dataTypes | ( | Vector< hid_t > & | a_types, | |
const T & | dummy | |||
) | [inline] |
References Vector< T >::resize().
void dataSize | ( | const T & | item, | |
Vector< int > & | a_sizes, | |||
const Box & | box, | |||
const Interval & | comps | |||
) | [inline] |
References Vector< T >::size().
void write | ( | const T & | item, | |
Vector< void * > & | a_allocatedBuffers, | |||
const Box & | box, | |||
const Interval & | comps | |||
) | [inline] |
void read | ( | T & | item, | |
Vector< void * > & | a_allocatedBuffers, | |||
const Box & | box, | |||
const Interval & | comps | |||
) | [inline] |
const char* name | ( | const T & | a_dummySpecializationArg | ) | [inline] |
References name().
void getOffsets | ( | Vector< Vector< long long > > & | offsets, | |
const BoxLayoutData< T > & | a_data, | |||
int | types, | |||
const Interval & | comps, | |||
const IntVect & | outputGhost | |||
) | [inline] |
References LayoutData< T >::boxLayout(), broadcast(), CH_TIME, CH_TIMELEAF, SerialTask::compute, LayoutData< T >::dataIterator(), dataSize(), gather(), Box::grow(), OffsetBuffer::index, BoxLayout::index(), BoxLayout::layoutIterator(), numProc(), OffsetBuffer::offsets, Vector< T >::push_back(), Vector< T >::size(), BoxLayout::size(), and uniqueProc().
Referenced by write().
void getOffsets | ( | Vector< Vector< long long > > & | a_offsets, | |
const BoxLayout | a_layout, | |||
int | a_numTypes, | |||
const Interval & | a_comps, | |||
const IntVect & | a_outputGhost | |||
) | [inline] |
References CH_assert, CH_TIME, dataSize(), Box::grow(), BoxLayout::layoutIterator(), Vector< T >::size(), and BoxLayout::size().