IBAMR
An adaptive and distributed-memory parallel implementation of the immersed boundary (IB) method
|
Class SnapshotCache provides a method of storing snapshots of patch data on a snapshot of the patch hierarchy. More...
#include </home/runner/work/IBAMR/IBAMR/ibtk/include/ibtk/SnapshotCache.h>
Public Types | |
using | value_type = std::pair< double, SAMRAI::tbox::Pointer< SAMRAI::hier::PatchHierarchy< NDIM > > > |
using | iterator = std::vector< value_type >::iterator |
using | const_iterator = std::vector< value_type >::const_iterator |
Public Member Functions | |
SnapshotCache (std::string object_name, SAMRAI::tbox::Pointer< SAMRAI::hier::Variable< NDIM > > var, SAMRAI::tbox::Pointer< SAMRAI::tbox::Database > input_db, SAMRAI::tbox::Pointer< SAMRAI::hier::GridGeometry< NDIM > > grid_geom, bool register_for_restart=true) | |
~SnapshotCache () | |
The destructor for class SnapshotCache deallocates patch data as needed. | |
void | clearSnapshots () |
void | storeSnapshot (int u_idx, double time, SAMRAI::tbox::Pointer< SAMRAI::hier::PatchHierarchy< NDIM > > hierarchy) |
value_type | getSnapshot (double time, double tol=1.0e-8) |
iterator | begin () |
iterator | end () |
size_t | getNumSnapshots () |
void | putToDatabase (SAMRAI::tbox::Pointer< SAMRAI::tbox::Database > db) override |
int | getPatchIndex () |
SAMRAI::tbox::Pointer< SAMRAI::hier::Variable< NDIM > > | getVariable () |
Class SnapshotCache provides a method of storing snapshots of patch data on a snapshot of the patch hierarchy.
This class can be used to store one type of variable, which is specified in the constructor. When retrieving or storing data with this class, the same patch data layout must be used, e.g. you must consistently store/retrieve CellData<NDIM, double> with depth of 2.
This class stores snapshots in a list ordered by increasing time values. Iterators to the stored snapshots are provided via the begin(), end(), and getSnapshot() methods.
IBTK::SnapshotCache::SnapshotCache | ( | std::string | object_name, |
SAMRAI::tbox::Pointer< SAMRAI::hier::Variable< NDIM > > | var, | ||
SAMRAI::tbox::Pointer< SAMRAI::tbox::Database > | input_db, | ||
SAMRAI::tbox::Pointer< SAMRAI::hier::GridGeometry< NDIM > > | grid_geom, | ||
bool | register_for_restart = true |
||
) |
The constructor for class SnapshotCache sets some default values, reads in configuration information from input databases, and registers a variable/context pair with the VariableDatabase. Can optionally set up this class for restarts.
The optional input database is searched for the following key:
If the input database is an invalid pointer, the ghost cell width is 1. Note that this value should be set as the maximum ghost cell width needed to perform any needed refinement operation upon snapshot retrieval.
|
inline |
Get a const iterator to the first element of the snapshots. Dereferencing the iterator returns a pair of the snapshot time and patch hierarchy.
void IBTK::SnapshotCache::clearSnapshots | ( | ) |
Clear the snapshots stored in this object. This deallocates all patch indices stored by this object.
|
inline |
Get an iterator to element following the last element of the snapshots. Dereferencing this element results in undefined behavior.
|
inline |
Get the number of stored snapshots.
|
inline |
Get the patch index owned by this class.
SnapshotCache::value_type IBTK::SnapshotCache::getSnapshot | ( | double | time, |
double | tol = 1.0e-8 |
||
) |
Get a copy of the snapshot time and patch hierarchy pair. If a snapshot is not present within the provided tolerance, a pair of NaN and nullptr is returned.
|
inline |
Get the variable owned by this class.
|
overridevirtual |
Write the snapshot cache to a database. This writes both the time points and the snapshotted patch hierarchies.
Implements SAMRAI::tbox::Serializable.
void IBTK::SnapshotCache::storeSnapshot | ( | int | u_idx, |
double | time, | ||
SAMRAI::tbox::Pointer< SAMRAI::hier::PatchHierarchy< NDIM > > | hierarchy | ||
) |
Create a snapshot. This creates a snapshot of the current hierarchy, and copies that data from this patch index into a patch index maintained by this object. If you want to overwrite a snapshot, you should call getSnapshot() instead and copy the data manually. Data is not allocated in this class until this function is called.