Chombo + EB
3.0
|
#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.
Classes | |
class | HDF5Handle |
Handle to a particular group in an HDF file. More... | |
class | HDF5HeaderData |
data to be added to HDF5 files. More... | |
struct | OffsetBuffer |
Macros | |
#define | _CH_HDF5_H_ |
#define | CHOFFSET(object, member) (int)((char*)&(object.member) - (char*)&object) |
Typedefs | |
typedef hssize_t | ch_offset_t |
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 More... | |
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) |
int | write (HDF5Handle &a_handle, const BoxLayout &a_layout, const std::string &name="boxes") |
writes BoxLayout to HDF5 file. More... | |
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. More... | |
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. More... | |
int | read (HDF5Handle &a_handle, Vector< Box > &boxes, const std::string &name="boxes") |
reads Vector<Box> from location specified by a_handle. More... | |
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 More... | |
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. More... | |
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. More... | |
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. More... | |
herr_t | HDF5HeaderDataattributeScan (hid_t loc_id, const char *name, 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) |
#define _CH_HDF5_H_ |
#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 | ||
) |
References name(), readBoxes(), readFArrayBox(), readLevel(), write(), writeLevel(), and IntVect::Zero.
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() |
||
) |
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().
Referenced by read().
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 |
||
) |
References DisjointBoxLayout::close(), HDF5Handle::getGroup(), LoadBalance(), HDF5HeaderData::m_box, HDF5HeaderData::m_int, HDF5HeaderData::m_real, read(), HDF5HeaderData::readFromFile(), and HDF5Handle::setGroup().
Referenced by read().
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(), read(), write(), and writeLevel().
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.
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, LayoutData< T >::dataIterator(), dataTypes(), MayDay::Error(), freeMT, HDF5Handle::getGroup(), getOffsets(), HDF5Handle::groupID(), Box::grow(), BoxLayout::index(), BoxLayoutData< T >::interval(), HDF5HeaderData::m_int, HDF5HeaderData::m_string, mallocMT, name(), LayoutIterator::ok(), pout(), procID(), HDF5Handle::setGroup(), Interval::size(), Vector< T >::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() |
||
) |
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 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)
Referenced by read().
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.
Referenced by read().
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.
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, LayoutData< T >::dataIterator(), dataTypes(), BoxLayoutData< T >::define(), HDF5Handle::getGroup(), HDF5Handle::groupID(), Box::grow(), BoxLayout::index(), HDF5HeaderData::m_int, HDF5HeaderData::m_intvect, LayoutIterator::ok(), read(), HDF5HeaderData::readFromFile(), Vector< T >::resize(), HDF5Handle::setGroup(), Interval::size(), Vector< T >::size(), BoxLayout::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 |
||
) |
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, | ||
void * | opdata | ||
) |
std::ostream& operator<< | ( | std::ostream & | os, |
const HDF5HeaderData & | data | ||
) |
hid_t H5Type | ( | const T * | dummy | ) |
References createData(), MayDay::Error(), and name().
Referenced by createDataset().
hid_t H5Type | ( | const int * | dummy | ) |
hid_t H5Type | ( | const long long * | dummy | ) |
hid_t H5Type | ( | const float * | dummy | ) |
hid_t H5Type | ( | const double * | dummy | ) |
hid_t H5Type | ( | const Box * | dummy | ) |
hid_t H5Type | ( | const RealVect * | dummy | ) |
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 | ||
) |
Referenced by createDataset(), H5Type(), AMRTGA< T >::newOp(), and AMRTGA< T >::oneStep().
void createDataset | ( | hid_t & | a_dataset, |
hid_t & | a_dataspace, | ||
HDF5Handle & | handle, | ||
const std::string & | name, | ||
const T * | dummy, | ||
hsize_t | size | ||
) |
References createData(), H5Type(), readDataset(), and writeDataset().
void writeDataset | ( | hid_t | a_dataset, |
hid_t | a_dataspace, | ||
const void * | start, | ||
ch_offset_t | off, | ||
hsize_t | count | ||
) |
Referenced by createDataset().
void readDataset | ( | hid_t | a_dataset, |
hid_t | a_dataspace, | ||
void * | start, | ||
ch_offset_t | off, | ||
hsize_t | count | ||
) |
Referenced by createDataset().
ostream& operator<< | ( | ostream & | os, |
const OffsetBuffer & | ob | ||
) |
int linearSize | ( | const CH_XDIR::OffsetBuffer & | a_input | ) |
void linearIn | ( | CH_XDIR::OffsetBuffer & | a_outputT, |
const void *const | a_inBuf | ||
) |
void linearOut | ( | void *const | a_outBuf, |
const CH_XDIR::OffsetBuffer & | a_inputT | ||
) |
int linearSize | ( | const Vector< CH_XDIR::OffsetBuffer > & | a_input | ) |
void linearIn | ( | Vector< CH_XDIR::OffsetBuffer > & | a_outputT, |
const void *const | inBuf | ||
) |
void linearOut | ( | void *const | a_outBuf, |
const Vector< CH_XDIR::OffsetBuffer > & | a_inputT | ||
) |
References Vector< T >::resize().
Referenced by blockWrite(), read(), and write().
References Vector< T >::resize().
References H5T_NATIVE_REAL, and Vector< T >::resize().
References H5T_NATIVE_REAL, and Vector< T >::resize().
|
inline |
References Box::numPts(), and Interval::size().
Referenced by blockLocalOffsets(), and getOffsets().
|
inline |
References Box::numPts(), and Interval::size().
|
inline |
References Box::numPts(), and Interval::size().
|
inline |
References CH_SPACEDIM, Box::numPts(), Interval::size(), and surroundingNodes().
|
inline |
|
inline |
References name().
|
inline |
References name().
|
inline |
References Vector< T >::resize().
|
inline |
References Vector< T >::size().
|
inline |
|
inline |
|
inline |
References name().
void getOffsets | ( | Vector< Vector< long long > > & | offsets, |
const BoxLayoutData< T > & | a_data, | ||
int | types, | ||
const Interval & | comps, | ||
const IntVect & | outputGhost | ||
) |
References LayoutData< T >::boxLayout(), broadcast(), SerialTask::compute, LayoutData< T >::dataIterator(), dataSize(), gather(), Box::grow(), BoxLayout::index(), OffsetBuffer::index, BoxLayout::layoutIterator(), numProc(), OffsetBuffer::offsets, LayoutIterator::ok(), Vector< T >::push_back(), Vector< T >::size(), BoxLayout::size(), and uniqueProc().
Referenced by write().