|
IBAMR
IBAMR version 0.19.
|
Class SnapshotCache provides a method of storing snapshots of patch data on a snapshot of the patch hierarchy. More...
#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. More... | |
| 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 () |
Private Member Functions | |
| void | getFromRestart (SAMRAI::tbox::Pointer< SAMRAI::hier::GridGeometry< NDIM > > grid_geom) |
| SnapshotCache (const SnapshotCache &from)=delete | |
| Copy constructor. More... | |
| SnapshotCache & | operator= (const SnapshotCache &that)=delete |
| Assignment operator. More... | |
Private Attributes | |
| std::string | d_object_name |
| SAMRAI::tbox::Pointer< SAMRAI::hier::Variable< NDIM > > | d_snapshot_var |
| SAMRAI::tbox::Pointer< SAMRAI::hier::VariableContext > | d_ctx |
| int | d_snapshot_idx = IBTK::invalid_index |
| SAMRAI::hier::IntVector< NDIM > | d_gcw = 1 |
| std::vector< value_type > | d_snapshots |
| bool | d_registered_for_restart = false |
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.
| using IBTK::SnapshotCache::value_type = std::pair<double, SAMRAI::tbox::Pointer<SAMRAI::hier::PatchHierarchy<NDIM> > > |
| using IBTK::SnapshotCache::iterator = std::vector<value_type>::iterator |
| using IBTK::SnapshotCache::const_iterator = std::vector<value_type>::const_iterator |
| 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.
| IBTK::SnapshotCache::~SnapshotCache | ( | ) |
|
privatedelete |
| from | The value to copy to this object. |
| void IBTK::SnapshotCache::clearSnapshots | ( | ) |
Clear the snapshots stored in this object. This deallocates all patch indices stored by this object.
| 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.
| 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 a const iterator to the first element of the snapshots. Dereferencing the iterator returns a pair of the snapshot time and patch hierarchy.
|
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.
|
overridevirtual |
Write the snapshot cache to a database. This writes both the time points and the snapshotted patch hierarchies.
Implements SAMRAI::tbox::Serializable.
|
inline |
Get the patch index owned by this class.
|
inline |
Get the variable owned by this class.
|
private |
Read stored information from the restart files. Note the GridGeometry object is required in order to construct the snapshotted patch hierarchies.
|
privatedelete |
| that | The value to assign to this object. |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
Vector of snapshots consisting of time points and hierarchies. Each hierarchy allocates data only with the patch data index stored by this class.
|
private |
1.8.17