Chombo + EB  3.2
Classes | Namespaces | Macros | Typedefs | Enumerations | Functions
CH_HDF5.H File Reference
#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 "EdgeDataBox.H"
#include "NodeFArrayBox.H"
#include "NamespaceHeader.H"
#include "NamespaceFooter.H"
#include "BaseNamespaceHeader.H"
#include "NamespaceVar.H"
#include "BaseNamespaceFooter.H"
Include dependency graph for CH_HDF5.H:
This graph shows which files directly or indirectly include this file:

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...
 
class  WriteMultiData< T >
 Methods for writing multiple LevelData to an HDF5 file. More...
 
struct  OffsetBuffer
 

Namespaces

 CH_HDF5
 

Macros

#define _CH_HDF5_H_
 
#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 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)
 
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. 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, 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 dataTypes (Vector< hid_t > &a_types, const EdgeDataBox &dummy)
 
template<>
void dataTypes (Vector< hid_t > &a_types, const NodeFArrayBox &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<>
void dataSize (const EdgeDataBox &item, Vector< int > &a_sizes, const Box &box, const Interval &comps)
 
template<>
void dataSize (const NodeFArrayBox &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)
 

Macro Definition Documentation

◆ _CH_HDF5_H_

#define _CH_HDF5_H_

◆ CHOFFSET

#define CHOFFSET (   object,
  member 
)    (int)((char*)&(object.member) - (char*)&object)

Typedef Documentation

◆ ch_offset_t

typedef hssize_t ch_offset_t

Function Documentation

◆ read() [1/5]

template<class T >
void read ( T &  item,
Vector< Vector< char > > &  a_allocatedBuffers,
const Box box,
const Interval comps 
)

◆ writeLevel() [1/2]

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

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().

◆ readLevel() [1/2]

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 
)

◆ readLevel() [2/2]

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 
)

◆ write() [1/4]

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().

◆ write() [2/4]

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 
)

◆ write() [3/4]

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.

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().

◆ read() [2/5]

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 } } }

◆ readBoxes()

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)

◆ readFArrayBox()

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.

◆ read() [3/5]

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.

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(), Vector< T >::size(), BoxLayout::size(), MayDay::Warning(), and IntVect::Zero.

◆ read() [4/5]

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.

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().

◆ HDF5HeaderDataattributeScan()

herr_t HDF5HeaderDataattributeScan ( hid_t  loc_id,
const char *  name,
const H5A_info_t *  info,
void *  opdata 
)

◆ operator<<() [1/2]

std::ostream& operator<< ( std::ostream &  os,
const HDF5HeaderData data 
)

◆ H5Type() [1/8]

template<class T >
hid_t H5Type ( const T *  dummy)

References createData(), MayDay::Error(), and name().

Referenced by createDataset().

◆ H5Type() [2/8]

template<>
hid_t H5Type ( const int *  dummy)

◆ H5Type() [3/8]

template<>
hid_t H5Type ( const long long *  dummy)

◆ H5Type() [4/8]

template<>
hid_t H5Type ( const float *  dummy)

◆ H5Type() [5/8]

template<>
hid_t H5Type ( const double *  dummy)

◆ H5Type() [6/8]

template<>
hid_t H5Type ( const Box dummy)

◆ H5Type() [7/8]

template<>
hid_t H5Type ( const RealVect dummy)

◆ H5Type() [8/8]

template<>
hid_t H5Type ( const IntVect dummy)

◆ createData()

void createData ( hid_t &  a_dataset,
hid_t &  a_dataspace,
HDF5Handle handle,
const std::string &  name,
hid_t  type,
hsize_t  size 
)

◆ createDataset()

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 
)

◆ writeDataset()

void writeDataset ( hid_t  a_dataset,
hid_t  a_dataspace,
const void *  start,
ch_offset_t  off,
hsize_t  count 
)

Referenced by createDataset().

◆ readDataset()

void readDataset ( hid_t  a_dataset,
hid_t  a_dataspace,
void *  start,
ch_offset_t  off,
hsize_t  count 
)

Referenced by createDataset().

◆ operator<<() [2/2]

ostream& operator<< ( ostream &  os,
const OffsetBuffer ob 
)

◆ linearSize() [1/2]

template<>
int linearSize ( const CH_XDIR::OffsetBuffer &  a_input)

◆ linearIn() [1/2]

template<>
void linearIn ( CH_XDIR::OffsetBuffer &  a_outputT,
const void *const  a_inBuf 
)

◆ linearOut() [1/2]

template<>
void linearOut ( void *const  a_outBuf,
const CH_XDIR::OffsetBuffer &  a_inputT 
)

◆ linearSize() [2/2]

template<>
int linearSize ( const Vector< CH_XDIR::OffsetBuffer > &  a_input)

◆ linearIn() [2/2]

template<>
void linearIn ( Vector< CH_XDIR::OffsetBuffer > &  a_outputT,
const void *const  inBuf 
)

◆ linearOut() [2/2]

template<>
void linearOut ( void *const  a_outBuf,
const Vector< CH_XDIR::OffsetBuffer > &  a_inputT 
)

◆ dataTypes() [1/7]

template<>
void dataTypes ( Vector< hid_t > &  a_types,
const BaseFab< int > &  dummy 
)
inline

References Vector< T >::resize().

Referenced by blockWrite(), read(), and write().

◆ dataTypes() [2/7]

template<>
void dataTypes ( Vector< hid_t > &  a_types,
const BaseFab< char > &  dummy 
)
inline

References Vector< T >::resize().

◆ dataTypes() [3/7]

template<>
void dataTypes ( Vector< hid_t > &  a_types,
const FArrayBox dummy 
)
inline

◆ dataTypes() [4/7]

template<>
void dataTypes ( Vector< hid_t > &  a_types,
const FluxBox dummy 
)
inline

◆ dataTypes() [5/7]

template<>
void dataTypes ( Vector< hid_t > &  a_types,
const EdgeDataBox dummy 
)
inline

◆ dataTypes() [6/7]

template<>
void dataTypes ( Vector< hid_t > &  a_types,
const NodeFArrayBox dummy 
)
inline

◆ dataSize() [1/7]

template<>
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().

◆ dataSize() [2/7]

template<>
void dataSize ( const BaseFab< char > &  item,
Vector< int > &  a_sizes,
const Box box,
const Interval comps 
)
inline

References Box::numPts(), and Interval::size().

◆ dataSize() [3/7]

template<>
void dataSize ( const FArrayBox item,
Vector< int > &  a_sizes,
const Box box,
const Interval comps 
)
inline

References Box::numPts(), and Interval::size().

◆ dataSize() [4/7]

template<>
void dataSize ( const FluxBox item,
Vector< int > &  a_sizes,
const Box box,
const Interval comps 
)
inline

◆ dataSize() [5/7]

template<>
void dataSize ( const EdgeDataBox item,
Vector< int > &  a_sizes,
const Box box,
const Interval comps 
)
inline

◆ dataSize() [6/7]

template<>
void dataSize ( const NodeFArrayBox item,
Vector< int > &  a_sizes,
const Box box,
const Interval comps 
)
inline

◆ name() [1/4]

template<>
const char* name ( const FArrayBox a_dummySpecializationArg)
inline

◆ name() [2/4]

template<>
const char* name ( const BaseFab< int > &  a_dummySpecializationArg)
inline

References name().

◆ name() [3/4]

template<>
const char* name ( const BaseFab< char > &  a_dummySpecializationArg)
inline

References name().

◆ dataTypes() [7/7]

template<class T >
void dataTypes ( Vector< hid_t > &  a_types,
const T &  dummy 
)
inline

References Vector< T >::resize().

◆ dataSize() [7/7]

template<class T >
void dataSize ( const T &  item,
Vector< int > &  a_sizes,
const Box box,
const Interval comps 
)
inline

References Vector< T >::size().

◆ write() [4/4]

template<class T >
void write ( const T &  item,
Vector< void *> &  a_allocatedBuffers,
const Box box,
const Interval comps 
)
inline

◆ read() [5/5]

template<class T >
void read ( T &  item,
Vector< void *> &  a_allocatedBuffers,
const Box box,
const Interval comps 
)
inline

◆ name() [4/4]

template<class T >
const char* name ( const T &  a_dummySpecializationArg)
inline

References name().

◆ getOffsets() [1/2]

template<class T >
void getOffsets ( Vector< Vector< long long > > &  offsets,
const BoxLayoutData< T > &  a_data,
int  types,
const Interval comps,
const IntVect outputGhost 
)

◆ getOffsets() [2/2]

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 
)

◆ writeLevel() [2/2]

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 
)