IBAMR
An adaptive and distributed-memory parallel implementation of the immersed boundary (IB) method
Public Types | Public Member Functions | List of all members
IBTK::SnapshotCache Class Reference

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>

Inheritance diagram for IBTK::SnapshotCache:
Inheritance graph
[legend]

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

Detailed Description

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.

Constructor & Destructor Documentation

◆ SnapshotCache()

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:

  • 'gcw' : Integer array that is the ghost cell width with which the internal variable is set up.

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.

Member Function Documentation

◆ begin()

iterator IBTK::SnapshotCache::begin ( )
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.

Note
This iterator is invalid if the number of snapshots changes.

◆ clearSnapshots()

void IBTK::SnapshotCache::clearSnapshots ( )

Clear the snapshots stored in this object. This deallocates all patch indices stored by this object.

◆ end()

iterator IBTK::SnapshotCache::end ( )
inline

Get an iterator to element following the last element of the snapshots. Dereferencing this element results in undefined behavior.

Note
This iterator is invalid if the number of snapshots changes.

◆ getNumSnapshots()

size_t IBTK::SnapshotCache::getNumSnapshots ( )
inline

Get the number of stored snapshots.

◆ getPatchIndex()

int IBTK::SnapshotCache::getPatchIndex ( )
inline

Get the patch index owned by this class.

◆ getSnapshot()

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.

◆ getVariable()

SAMRAI::tbox::Pointer<SAMRAI::hier::Variable<NDIM> > IBTK::SnapshotCache::getVariable ( )
inline

Get the variable owned by this class.

◆ putToDatabase()

void IBTK::SnapshotCache::putToDatabase ( SAMRAI::tbox::Pointer< SAMRAI::tbox::Database db)
overridevirtual

Write the snapshot cache to a database. This writes both the time points and the snapshotted patch hierarchies.

Implements SAMRAI::tbox::Serializable.

◆ storeSnapshot()

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.


The documentation for this class was generated from the following files: