MFEM
v3.3
Finite element discretization library
|
Data collection with Sidre routines following the Conduit mesh blueprint specification. More...
#include <sidredatacollection.hpp>
Public Member Functions | |
SidreDataCollection (const std::string &collection_name, Mesh *the_mesh=NULL, bool owns_mesh_data=false) | |
Constructor that allocates and initializes a Sidre DataStore. More... | |
SidreDataCollection (const std::string &collection_name, asctoolkit::sidre::DataGroup *global_grp, asctoolkit::sidre::DataGroup *domain_grp, bool owns_mesh_data=false) | |
Constructor that links to an external Sidre DataStore. More... | |
void | SetComm (MPI_Comm comm) |
Associate an MPI communicator with the collection. More... | |
virtual void | RegisterField (const std::string &field_name, GridFunction *gf) |
Register a GridFunction in the Sidre DataStore. More... | |
void | RegisterField (const std::string &field_name, GridFunction *gf, const std::string &buffer_name, asctoolkit::sidre::SidreLength offset) |
Register a GridFunction in the Sidre DataStore. More... | |
void | SetMeshNodesName (const std::string &nodes_name) |
Set the name of the mesh nodes field. More... | |
virtual void | DeregisterField (const std::string &field_name) |
De-register field_name from the SidreDataCollection. More... | |
virtual | ~SidreDataCollection () |
Delete all owned data. More... | |
virtual void | SetMesh (Mesh *new_mesh) |
Set/change the mesh associated with the collection. More... | |
void | SetGroupPointers (asctoolkit::sidre::DataGroup *global_grp, asctoolkit::sidre::DataGroup *domain_grp) |
Reset the domain and global datastore group pointers. More... | |
asctoolkit::sidre::DataGroup * | GetBPGroup () |
asctoolkit::sidre::DataGroup * | GetBPIndexGroup () |
virtual void | PrepareToSave () |
Prepare the DataStore for writing. More... | |
virtual void | Save () |
Save the collection to file. More... | |
void | Save (const std::string &filename, const std::string &protocol) |
Save the collection to filename. More... | |
void | Load (const std::string &path, const std::string &protocol) |
Load the Sidre DataStore from file. More... | |
virtual void | Load (int cycle_=0) |
Load SidreDataCollection from file. More... | |
void | LoadExternalData (const std::string &path) |
Load external data after registering externally owned fields. More... | |
void | UpdateStateFromDS () |
Updates the DataCollection's cycle, time, and time-step variables with the values from the data store. More... | |
void | UpdateStateToDS () |
Updates the data store's cycle, time, and time-step variables with the values from the SidreDataCollection. More... | |
Methods for named buffer access and manipulation. | |
asctoolkit::sidre::DataView * | GetNamedBuffer (const std::string &buffer_name) const |
Get a pointer to the sidre::DataView holding the named buffer for buffer_name. More... | |
asctoolkit::sidre::DataView * | AllocNamedBuffer (const std::string &buffer_name, asctoolkit::sidre::SidreLength sz, asctoolkit::sidre::TypeID type=asctoolkit::sidre::DOUBLE_ID) |
Return newly allocated or existing named buffer for buffer_name. More... | |
void | FreeNamedBuffer (const std::string &buffer_name) |
Deallocate the named buffer buffer_name. More... | |
Public Member Functions inherited from mfem::DataCollection | |
DataCollection (const std::string &collection_name, Mesh *mesh_=NULL) | |
Initialize the collection with its name and Mesh. More... | |
virtual void | RegisterQField (const std::string &q_field_name, QuadratureFunction *qf) |
Add a QuadratureFunction to the collection. More... | |
virtual void | DeregisterQField (const std::string &field_name) |
Remove a QuadratureFunction from the collection. More... | |
bool | HasField (const std::string &name) const |
Check if a grid function is part of the collection. More... | |
GridFunction * | GetField (const std::string &field_name) |
Get a pointer to a grid function in the collection. More... | |
ParGridFunction * | GetParField (const std::string &field_name) |
Get a pointer to a parallel grid function in the collection. More... | |
bool | HasQField (const std::string &q_field_name) const |
Check if a QuadratureFunction with the given name is in the collection. More... | |
QuadratureFunction * | GetQField (const std::string &q_field_name) |
Get a pointer to a QuadratureFunction in the collection. More... | |
const FieldMapType & | GetFieldMap () const |
Get a const reference to the internal field map. More... | |
const QFieldMapType & | GetQFieldMap () const |
Get a const reference to the internal q-field map. More... | |
Mesh * | GetMesh () |
Get a pointer to the mesh in the collection. More... | |
void | SetCycle (int c) |
Set time cycle (for time-dependent simulations) More... | |
void | SetTime (double t) |
Set physical time (for time-dependent simulations) More... | |
void | SetTimeStep (double ts) |
Set the simulation time step (for time-dependent simulations) More... | |
int | GetCycle () const |
Get time cycle (for time-dependent simulations) More... | |
double | GetTime () const |
Get physical time (for time-dependent simulations) More... | |
double | GetTimeStep () const |
Get the simulation time step (for time-dependent simulations) More... | |
const std::string & | GetCollectionName () const |
Get the name of the collection. More... | |
void | SetOwnData (bool o) |
Set the ownership of collection data. More... | |
void | SetPrecision (int prec) |
Set the precision (number of digits) used for the text output of doubles. More... | |
void | SetPadDigits (int digits) |
Set the number of digits used for the cycle and MPI rank in filenames. More... | |
void | SetFormat (int fmt) |
Set the desired output mesh format: 0 - serial format (default), 1 - parallel format. More... | |
void | SetPrefixPath (const std::string &prefix) |
Set the path where the DataCollection will be saved. More... | |
const std::string & | GetPrefixPath () const |
Get the path where the DataCollection will be saved. More... | |
virtual void | SaveMesh () |
Save the mesh, creating the collection directory. More... | |
virtual void | SaveField (const std::string &field_name) |
Save one field, assuming the collection directory already exists. More... | |
virtual void | SaveQField (const std::string &q_field_name) |
Save one q-field, assuming the collection directory already exists. More... | |
virtual | ~DataCollection () |
Delete the mesh and fields if owned by the collection. More... | |
int | Error () const |
Get the current error state. More... | |
void | ResetError (int err=NO_ERROR) |
Reset the error state. More... | |
Protected Member Functions | |
asctoolkit::sidre::DataGroup * | named_buffers_grp () const |
asctoolkit::sidre::DataView * | alloc_view (asctoolkit::sidre::DataGroup *grp, const std::string &view_name) |
asctoolkit::sidre::DataView * | alloc_view (asctoolkit::sidre::DataGroup *grp, const std::string &view_name, const asctoolkit::sidre::DataType &dtype) |
asctoolkit::sidre::DataGroup * | alloc_group (asctoolkit::sidre::DataGroup *grp, const std::string &group_name) |
std::string | get_file_path (const std::string &filename) const |
Protected Member Functions inherited from mfem::DataCollection | |
void | DeleteData () |
Delete data owned by the DataCollection keeping field information. More... | |
void | DeleteAll () |
Delete data owned by the DataCollection including field information. More... | |
std::string | GetFieldFileName (const std::string &field_name) |
void | SaveOneField (const FieldMapIterator &it) |
Save one field to disk, assuming the collection directory exists. More... | |
void | SaveOneQField (const QFieldMapIterator &it) |
Save one q-field to disk, assuming the collection directory exists. More... | |
Additional Inherited Members | |
Public Types inherited from mfem::DataCollection | |
enum | { NO_ERROR = 0, READ_ERROR = 1, WRITE_ERROR = 2 } |
Errors returned by Error() More... | |
typedef std::map< std::string, GridFunction * > | FieldMapType |
typedef std::map< std::string, QuadratureFunction * > | QFieldMapType |
Protected Types inherited from mfem::DataCollection | |
typedef FieldMapType::iterator | FieldMapIterator |
The fields and their names (used when saving) More... | |
typedef FieldMapType::const_iterator | FieldMapConstIterator |
typedef QFieldMapType::iterator | QFieldMapIterator |
typedef QFieldMapType::const_iterator | QFieldMapConstIterator |
Static Protected Member Functions inherited from mfem::DataCollection | |
static int | create_directory (const std::string &dir_name, const Mesh *mesh, int myid) |
Protected Attributes inherited from mfem::DataCollection | |
std::string | name |
Name of the collection, used as a directory name when saving. More... | |
std::string | prefix_path |
FieldMapType | field_map |
QFieldMapType | q_field_map |
Mesh * | mesh |
The (common) mesh for the collected fields. More... | |
int | cycle |
double | time |
Physical time (for time-dependent simulations) More... | |
double | time_step |
Time step i.e. delta_t (for time-dependent simulations) More... | |
bool | serial |
Serial or parallel run? More... | |
bool | appendRankToFileName |
Append rank to any output file names. More... | |
int | myid |
MPI rank (in parallel) More... | |
int | num_procs |
Number of MPI ranks (in parallel) More... | |
int | precision |
Precision (number of digits) used for the text output of doubles. More... | |
int | pad_digits |
Number of digits used for the cycle and MPI rank in filenames. More... | |
int | format |
Output mesh format: 0 - serial format (default), 1 - parallel format. More... | |
bool | own_data |
Should the collection delete its mesh and fields. More... | |
int | error |
Error state. More... | |
Static Protected Attributes inherited from mfem::DataCollection | |
static const int | precision_default = 6 |
Default value for precision. More... | |
static const int | pad_digits_default = 6 |
Default value for pad_digits. More... | |
Data collection with Sidre routines following the Conduit mesh blueprint specification.
SidreDataCollection provides an HDF5-based file format for visualization or restart capability. This functionality is aimed primarily at customers of LLNL's ASC Toolkit that run problems at extreme scales.
For more information, see:
The layout created in the Sidre DataStore is: ("──"
denote groups, "─•"
denote views, "─\>"
denote links, i.e. shallow-copy view)
<root> ├── <collection-name>_global (global group) │ └── blueprint_index │ └── <collection-name> (bp_index group) │ ├── state │ │ ├─• cycle │ │ ├─• time │ │ └─• number_of_domains = <mesh-mpi-comm-size> │ ├── coordsets │ │ └── coords │ │ ├─• path = "<bp-path>/coordsets/coords" │ │ ├─• type ─> <bp-grp>/coordsets/coords/type = "explicit" │ │ └─• coord_system = "x"|"xy"|"xyz" │ ├── topologies │ │ ├── mesh │ │ │ ├─• path = "<bp-path>/topologies/mesh" │ │ │ ├─• type ─> <bp-grp>/topologies/mesh/type = "unstructured" │ │ │ ├─• coordset ─> <bp-grp>/topologies/mesh/coordset = "coords" │ │ │ ├─• grid_function ─> <bp-grp>/topologies/mesh/grid_function = "<nodes-field-name>" │ │ │ └─• boundary_topology ─> <bp-grp>/topologies/mesh/boundary_topology = "boundary" │ │ └── boundary │ │ ├─• path = "<bp-path>/topologies/mesh" │ │ ├─• type ─> <bp-grp>/topologies/boundary/type = "unstructured" │ │ └─• coordset ─> <bp-grp>/topologies/boundary/coordset = "coords" │ └── fields │ ├── mesh_material_attribute │ │ ├─• path = "<bp-path>/fields/mesh_material_attribute" │ │ ├─• association ─> <bp-grp>/fields/mesh_material_attribute/association = "element" │ │ ├─• topology ─> <bp-grp>/fields/mesh_material_attribute/topology = "mesh" │ │ └─• number_of_components = 1 │ ├── boundary_material_attribute │ │ ├─• path = "<bp-path>/fields/boundary_material_attribute" │ │ ├─• association ─> <bp-grp>/fields/boundary_material_attribute/association = "element" │ │ ├─• topology ─> <bp-grp>/fields/boundary_material_attribute/topology = "boundary" │ │ └─• number_of_components = 1 │ ├── grid-function-1 │ │ ├─• path = "<bp-path>/fields/grid-function-1" │ │ ├─• basis ─> <bp-grp>/fields/grid-function-1/basis = "<fe-coll-name>" │ │ ├─• topology ─> <bp-grp>/fields/grid-function-1/topology = "mesh" │ │ └─• number_of_components = gf1->VectorDim() │ ├── grid-function-2 │ │ ├─• path = "<bp-path>/fields/grid-function-2" │ │ ├─• basis ─> <bp-grp>/fields/grid-function-2/basis = "<fe-coll-name>" │ │ ├─• topology ─> <bp-grp>/fields/grid-function-2/topology = "mesh" │ │ └─• number_of_components = gf2->VectorDim() │ ├── ... │ ... └── <collection-name> (domain group) ├── blueprint (blueprint group) │ ├── state │ │ ├─• cycle │ │ ├─• time │ │ ├─• domain = <mesh-mpi-rank> │ │ └─• time_step │ ├── coordsets │ │ └── coords │ │ ├─• type = "explicit" │ │ └── values │ │ ├─• x = view in <vertex-coords-buffer>/<ext-double-data> │ │ ├─• y = view in <vertex-coords-buffer>/<ext-double-data> │ │ └─• z = view in <vertex-coords-buffer>/<ext-double-data> │ ├── topologies │ │ ├── mesh │ │ │ ├─• type = "unstructured" │ │ │ ├── elements │ │ │ │ ├─• shape = "points"|"lines"|... │ │ │ │ └─• connectivity = <vert-idx-array> │ │ │ ├─• coordset = "coords" │ │ │ ├─• grid_function = "<nodes-field-name>" │ │ │ └─• boundary_topology = "boundary" │ │ └── boundary │ │ ├─• type = "unstructured" │ │ ├── elements │ │ │ ├─• shape = "points"|"lines"|... │ │ │ └─• connectivity = <vert-idx-array> │ │ └─• coordset = "coords" │ └── fields │ ├── mesh_material_attribute │ │ ├─• association = "element" │ │ ├─• topology = "mesh" │ │ └─• values = <attr-array> │ ├── boundary_material_attribute │ │ ├─• association = "element" │ │ ├─• topology = "boundary" │ │ └─• values = <attr-array> │ ├── grid-function-1 (name can include path) │ │ ├─• basis = "<fe-coll-name>" │ │ ├─• topology = "mesh" │ │ └─• values = <ext-double-array>/<named-buffer> (vdim == 1) │ ├── grid-function-2 (name can include path) │ │ ├─• basis = "<fe-coll-name>" │ │ ├─• topology = "mesh" │ │ └── values (vdim > 1) │ │ ├─• x0 = view into <ext-double-array>/<named-buffer> │ │ ├─• x1 = view into <ext-double-array>/<named-buffer> │ │ └─• x2 = view into <ext-double-array>/<named-buffer> │ ├── ... │ ... └── named_buffers (named_buffers group) ├─• vertex_coords = <double-array> ├─• grid-function-1 = <double-array> ├─• grid-function-2 = <double-array> ...
Definition at line 159 of file sidredatacollection.hpp.
mfem::SidreDataCollection::SidreDataCollection | ( | const std::string & | collection_name, |
Mesh * | the_mesh = NULL , |
||
bool | owns_mesh_data = false |
||
) |
Constructor that allocates and initializes a Sidre DataStore.
[in] | collection_name | Name of the collection used as a file name when saving |
[in] | the_mesh | Mesh shared by all grid functions in the collection (can be NULL) |
[in] | owns_mesh_data | Does the SidreDC own the mesh vertices? |
With this constructor, the SidreDataCollection owns the allocated Sidre DataStore.
Definition at line 34 of file sidredatacollection.cpp.
mfem::SidreDataCollection::SidreDataCollection | ( | const std::string & | collection_name, |
asctoolkit::sidre::DataGroup * | global_grp, | ||
asctoolkit::sidre::DataGroup * | domain_grp, | ||
bool | owns_mesh_data = false |
||
) |
Constructor that links to an external Sidre DataStore.
Specifically, the global and domain groups can be at arbitrary paths.
[in] | collection_name | Name of the collection used as a file name when saving |
[in] | global_grp | Pointer to the global group in the datastore, see the above schematic |
[in] | domain_grp | Pointer to the domain group in the datastore, see the above schematic |
[in] | owns_mesh_data | Does the SidreDC own the mesh vertices? |
With this constructor, the SidreDataCollection does not own the Sidre DataStore.
Definition at line 72 of file sidredatacollection.cpp.
|
virtual |
Delete all owned data.
Definition at line 94 of file sidredatacollection.cpp.
|
protected |
Definition at line 161 of file sidredatacollection.cpp.
|
protected |
Definition at line 124 of file sidredatacollection.cpp.
|
protected |
Definition at line 140 of file sidredatacollection.cpp.
asctoolkit::sidre::DataView * mfem::SidreDataCollection::AllocNamedBuffer | ( | const std::string & | buffer_name, |
asctoolkit::sidre::SidreLength | sz, | ||
asctoolkit::sidre::TypeID | type = asctoolkit::sidre::DOUBLE_ID |
||
) |
Return newly allocated or existing named buffer for buffer_name.
The buffer is stored in the named_buffers group. If the currently allocated buffer size is smaller than sz, then the buffer is reallocated with size sz, destroying its contents.
Definition at line 194 of file sidredatacollection.cpp.
|
virtual |
De-register field_name from the SidreDataCollection.
The field is removed from the field_map and the DataStore, including deleting it from the named_buffers group, if allocated.
Reimplemented from mfem::DataCollection.
Definition at line 983 of file sidredatacollection.cpp.
|
inline |
Deallocate the named buffer buffer_name.
Definition at line 346 of file sidredatacollection.hpp.
|
protected |
Definition at line 177 of file sidredatacollection.cpp.
|
inline |
Definition at line 269 of file sidredatacollection.hpp.
|
inline |
Definition at line 270 of file sidredatacollection.hpp.
|
inline |
Get a pointer to the sidre::DataView holding the named buffer for buffer_name.
If such named buffer is not allocated, the method returns NULL.
Definition at line 330 of file sidredatacollection.hpp.
void mfem::SidreDataCollection::Load | ( | const std::string & | path, |
const std::string & | protocol | ||
) |
Load the Sidre DataStore from file.
No mesh or fields are read from the loaded DataStore.
If the data collection created the datastore, it knows the layout of where the domain and global groups are, and can restore them after the Load().
If, however, the data collection does not own the datastore (e.g. it did not create the datastore), the host code must reset these pointers after the load operation, using SetGroupPointers(), and also reset the state variables, using UpdateStateFromDS().
Definition at line 600 of file sidredatacollection.cpp.
|
inlinevirtual |
Load SidreDataCollection from file.
The used file path is based on the current prefix path, collection name, and the given cycle_. The protocol is "sidre_hdf5".
Reimplemented from mfem::DataCollection.
Definition at line 303 of file sidredatacollection.hpp.
void mfem::SidreDataCollection::LoadExternalData | ( | const std::string & | path | ) |
Load external data after registering externally owned fields.
Definition at line 633 of file sidredatacollection.cpp.
|
protected |
Definition at line 114 of file sidredatacollection.cpp.
|
virtual |
Prepare the DataStore for writing.
Definition at line 668 of file sidredatacollection.cpp.
|
inlinevirtual |
Register a GridFunction in the Sidre DataStore.
This method is a shortcut for the call RegisterField(field_name, gf, field_name, 0)
.
Reimplemented from mfem::DataCollection.
Definition at line 210 of file sidredatacollection.hpp.
void mfem::SidreDataCollection::RegisterField | ( | const std::string & | field_name, |
GridFunction * | gf, | ||
const std::string & | buffer_name, | ||
asctoolkit::sidre::SidreLength | offset | ||
) |
Register a GridFunction in the Sidre DataStore.
The registration procedure is as follows:
Both the field_name and buffer_name can contain a path prefix.
Definition at line 913 of file sidredatacollection.cpp.
|
virtual |
Save the collection to file.
This method calls Save(collection_name, "sidre_hdf5")
.
Reimplemented from mfem::DataCollection.
Definition at line 674 of file sidredatacollection.cpp.
void mfem::SidreDataCollection::Save | ( | const std::string & | filename, |
const std::string & | protocol | ||
) |
Save the collection to filename.
The collection path prefix is prepended to the filename and the current cycle is appended, if cycle >= 0.
Definition at line 682 of file sidredatacollection.cpp.
void mfem::SidreDataCollection::SetComm | ( | MPI_Comm | comm | ) |
Associate an MPI communicator with the collection.
If no mesh was associated with the collection, this method should be called before using any of the Load() methods to read parallel data.
Definition at line 103 of file sidredatacollection.cpp.
void mfem::SidreDataCollection::SetGroupPointers | ( | asctoolkit::sidre::DataGroup * | global_grp, |
asctoolkit::sidre::DataGroup * | domain_grp | ||
) |
Reset the domain and global datastore group pointers.
These are set in the constructor, but if a host code changes the datastore contents ( such as wiping out the datastore and loading in new contents from a file, i.e. a restart ) these pointers will need to be reset to valid groups in the datastore.
Definition at line 587 of file sidredatacollection.cpp.
|
virtual |
Set/change the mesh associated with the collection.
Uses the field name "mesh_nodes" or the value set by SetMeshNodesName() to register the mesh nodes GridFunction, if the mesh uses nodes.
Reimplemented from mfem::DataCollection.
Definition at line 498 of file sidredatacollection.cpp.
|
inline |
Set the name of the mesh nodes field.
This name will be used by SetMesh() to register the mesh nodes, if not already registered. Also, this method should be called if the mesh nodes GridFunction was or will be registered directly by the user. The default value for the name is "mesh_nodes".
Definition at line 241 of file sidredatacollection.hpp.
void mfem::SidreDataCollection::UpdateStateFromDS | ( | ) |
Updates the DataCollection's cycle, time, and time-step variables with the values from the data store.
Definition at line 648 of file sidredatacollection.cpp.
void mfem::SidreDataCollection::UpdateStateToDS | ( | ) |
Updates the data store's cycle, time, and time-step variables with the values from the SidreDataCollection.
Definition at line 655 of file sidredatacollection.cpp.