IBAMR  IBAMR version 0.19.
Public Types | Public Member Functions | Private Member Functions | Private Attributes | 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 <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. 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...
 
SnapshotCacheoperator= (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::VariableContextd_ctx
 
int d_snapshot_idx = IBTK::invalid_index
 
SAMRAI::hier::IntVector< NDIM > d_gcw = 1
 
std::vector< value_typed_snapshots
 
bool d_registered_for_restart = false
 

Detailed Description

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.

Member Typedef Documentation

◆ value_type

◆ iterator

◆ const_iterator

Constructor & Destructor Documentation

◆ SnapshotCache() [1/2]

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.

◆ ~SnapshotCache()

IBTK::SnapshotCache::~SnapshotCache ( )

◆ SnapshotCache() [2/2]

IBTK::SnapshotCache::SnapshotCache ( const SnapshotCache from)
privatedelete
Note
This constructor is not implemented and should not be used.
Parameters
fromThe value to copy to this object.

Member Function Documentation

◆ clearSnapshots()

void IBTK::SnapshotCache::clearSnapshots ( )

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

◆ 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.

◆ getSnapshot()

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.

◆ 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.

◆ 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.

◆ 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.

◆ getPatchIndex()

int IBTK::SnapshotCache::getPatchIndex ( )
inline

Get the patch index owned by this class.

◆ getVariable()

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

Get the variable owned by this class.

◆ getFromRestart()

void IBTK::SnapshotCache::getFromRestart ( SAMRAI::tbox::Pointer< SAMRAI::hier::GridGeometry< NDIM > >  grid_geom)
private

Read stored information from the restart files. Note the GridGeometry object is required in order to construct the snapshotted patch hierarchies.

◆ operator=()

SnapshotCache& IBTK::SnapshotCache::operator= ( const SnapshotCache that)
privatedelete
Note
This operator is not implemented and should not be used.
Parameters
thatThe value to assign to this object.
Returns
A reference to this object.

Member Data Documentation

◆ d_object_name

std::string IBTK::SnapshotCache::d_object_name
private

◆ d_snapshot_var

SAMRAI::tbox::Pointer<SAMRAI::hier::Variable<NDIM> > IBTK::SnapshotCache::d_snapshot_var
private

◆ d_ctx

SAMRAI::tbox::Pointer<SAMRAI::hier::VariableContext> IBTK::SnapshotCache::d_ctx
private

◆ d_snapshot_idx

int IBTK::SnapshotCache::d_snapshot_idx = IBTK::invalid_index
private

◆ d_gcw

SAMRAI::hier::IntVector<NDIM> IBTK::SnapshotCache::d_gcw = 1
private

◆ d_snapshots

std::vector<value_type> IBTK::SnapshotCache::d_snapshots
private

Vector of snapshots consisting of time points and hierarchies. Each hierarchy allocates data only with the patch data index stored by this class.

◆ d_registered_for_restart

bool IBTK::SnapshotCache::d_registered_for_restart = false
private

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