FieldHDF.h¶
-
template<typename
FileDataType
, typenameField
, typenameMesh
, typenameDir
= size_t>
voidCubism::IO
::
FieldWriteHDF
(const std::string &fname, const std::string &aname, const Field &field, const Mesh &mesh, const double time, const Dir face_dir = 0, const bool create_xdmf = true)¶ Write field data to HDF file.
Write the data carried by
field
to an HDF5 container file. The data that is written to the file is specified by the index space described inmesh
.Note
The variables
field
andmesh
are only related by the index space they span. If there is no common intersection, no data will be written to the file. If the mesh spans a larger index space and full or partially contains the index space spanned byfield
then the index space spanned bymesh
is clipped to that spanned byfield
.Example:
#include "Cubism/Block/Field.h" #include "Cubism/Core/Index.h" #include "Cubism/Mesh/StructuredUniform.h" #include "Cubism/IO/FieldHDF.h" using Mesh = Cubism::Mesh::StructuredUniform<double, 3>; using MeshIntegrity = typename Mesh::MeshIntegrity; using PointType = typename Mesh::PointType; using IRange = typename Mesh::IndexRangeType; using MIndex = typename Mesh::MultiIndex; using CellField = Cubism::Block::CellField<double, Mesh::Dim>; int main(void) { // mesh in [0,1]^3 with 16^3 cells const PointType end(1); const MIndex cells(16); Mesh m(end, cells, MeshIntegrity::FullMesh); // cell field spans an index space [6,10)^3 const IRange cell_range(6, 10); CellField cf(cell_range); // write field to file (since the mesh fully contains cell_range, the // file contains 64 doubles at the coordinates defined in m using the // indices in cell_range Cubism::IO::FieldWriteHDF<double>( "filename", "attributename", cf, m, 0.0); return 0; }
- Template Parameters
FileDataType
: HDF file data typeField
: Field typeMesh
: Mesh typeDir
: Special type that defines a cast tosize_t
- Parameters
fname
: Output full filename without file extensionaname
: Name of quantity infield
field
: Input fieldmesh
: Input meshtime
: Current timeface_dir
: Face direction (relevant forCubism::EntityType::Face
)create_xdmf
: Flag for XDMF wrapper
-
template<typename
FileDataType
, typenameField
, typenameMesh
, typenameDir
= size_t>
voidCubism::IO
::
FieldReadHDF
(const std::string &fname, Field &field, const Mesh &mesh, const Dir face_dir = 0)¶ Read field data from HDF file.
Read the data of an HDF5 container file into
field
. The data that is read from the file is specified by the index space described inmesh
.- Template Parameters
FileDataType
: HDF file data typeField
: Field typeMesh
: Mesh typeDir
: Special type that defines a cast tosize_t
- Parameters
fname
: Input full filename without file extensionfield
: Field populated with file datamesh
: Field (sub)meshface_dir
: Face direction (relevant forCubism::EntityType::Face
)