Tempus Version of the Day
Time Integration
Loading...
Searching...
No Matches
Public Member Functions | List of all members
Tempus::SolutionHistory< Scalar > Class Template Reference

SolutionHistory is basically a container of SolutionStates. SolutionHistory maintains a collection of SolutionStates for later retrival and reuse, such as checkpointing, restart, and undo operations. More...

#include <Tempus_SolutionHistory_decl.hpp>

Inheritance diagram for Tempus::SolutionHistory< Scalar >:

Public Member Functions

 SolutionHistory ()
 Default Contructor.
 
 SolutionHistory (std::string name, Teuchos::RCP< std::vector< Teuchos::RCP< SolutionState< Scalar > > > > history, Teuchos::RCP< Interpolator< Scalar > > interpolator, StorageType storageType, int storageLimit)
 Contructor.
 
 ~SolutionHistory ()
 Destructor.
 

Interpolation Methods

std::string name_
 
Teuchos::RCP< std::vector< Teuchos::RCP< SolutionState< Scalar > > > > history_
 
Teuchos::RCP< Interpolator< Scalar > > interpolator_
 
StorageType storageType_
 
int storageLimit_
 
Teuchos::RCP< SolutionState< Scalar > > workingState_
 The state being worked on.
 
bool isInitialized_
 Bool if SolutionHistory is initialized.
 
void setInterpolator (const Teuchos::RCP< Interpolator< Scalar > > &interpolator)
 Set the interpolator for this history.
 
Teuchos::RCP< Interpolator< Scalar > > getNonconstInterpolator ()
 
Teuchos::RCP< const Interpolator< Scalar > > getInterpolator () const
 
Teuchos::RCP< Interpolator< Scalar > > unSetInterpolator ()
 Unset the interpolator for this history.
 
void printHistory (std::string verb="low") const
 Print information on States in the SolutionHistory.
 
void initialize () const
 Initialize SolutionHistory.
 
bool isInitialized ()
 Return if SolutionHistory is initialized.
 

Basic SolutionHistory Methods

void addState (const Teuchos::RCP< SolutionState< Scalar > > &state, bool doChecks=true)
 Add solution state to history.
 
void addWorkingState (const Teuchos::RCP< SolutionState< Scalar > > &state, const bool updateTime=true)
 Add a working solution state to history.
 
void removeState (const Teuchos::RCP< SolutionState< Scalar > > &state)
 Remove solution state.
 
void removeState (const Scalar time)
 Remove solution state based on time.
 
Teuchos::RCP< SolutionState< Scalar > > findState (const Scalar time) const
 Find solution state at requested time (no interpolation)
 
Teuchos::RCP< SolutionState< Scalar > > interpolateState (const Scalar time) const
 Generate and interpolate a new solution state at requested time.
 
void interpolateState (const Scalar time, SolutionState< Scalar > *state_out) const
 Interpolate solution state at requested time and store in supplied state.
 
void initWorkingState ()
 Initialize the working state.
 
void promoteWorkingState ()
 Promote the working state to current state.
 
void clear ()
 Clear the history.
 
void copy (Teuchos::RCP< const SolutionHistory< Scalar > > sh)
 Make a shallow copy of SolutionHistory (i.e., only RCPs to states and interpolator).
 

Accessor methods

std::string getName () const
 Get this SolutionHistory's name.
 
void setName (std::string name)
 Set this SolutionHistory's name.
 
Teuchos::RCP< std::vector< Teuchos::RCP< SolutionState< Scalar > > > > getHistory () const
 Get underlining history.
 
void setHistory (Teuchos::RCP< std::vector< Teuchos::RCP< SolutionState< Scalar > > > > h)
 Set underlining history.
 
Teuchos::RCP< SolutionState< Scalar > > operator[] (const int i)
 Subscript operator.
 
Teuchos::RCP< const SolutionState< Scalar > > operator[] (const int i) const
 Subscript operator (const version)
 
Teuchos::RCP< SolutionState< Scalar > > getCurrentState () const
 Return the current state, i.e., the last accepted state.
 
Teuchos::RCP< SolutionState< Scalar > > getWorkingState (bool warn=true) const
 Return the working state.
 
int getNumStates () const
 Get the number of states.
 
Scalar getCurrentTime () const
 Get the current time.
 
int getCurrentIndex () const
 Get the current timestep index.
 
void setStorageLimit (int storage_limit)
 Set the maximum storage of this history.
 
int getStorageLimit () const
 Get the maximum storage of this history.
 
void setStorageType (StorageType st)
 Set the storage type via enum.
 
StorageType getStorageType () const
 Get the enum storage type.
 
void setStorageTypeString (std::string st)
 Set the storage type via string.
 
std::string getStorageTypeString () const
 Set the string storage type.
 
Scalar minTime () const
 Return the current minimum time of the SolutionStates.
 
Scalar maxTime () const
 Return the current maximum time of the SolutionStates.
 
Teuchos::RCP< SolutionState< Scalar > > getStateTimeIndexN (bool warn=true) const
 Get the state with timestep index equal to n.
 
Teuchos::RCP< SolutionState< Scalar > > getStateTimeIndexNM1 (bool warn=true) const
 Get the state with timestep index equal to n-1.
 
Teuchos::RCP< SolutionState< Scalar > > getStateTimeIndexNM2 (bool warn=true) const
 Get the state with timestep index equal to n-2.
 
Teuchos::RCP< SolutionState< Scalar > > getStateTimeIndex (int index, bool warn=true) const
 Get the state with timestep index equal to "index".
 
Teuchos::RCP< const Teuchos::ParameterList > getValidParameters () const
 Return a valid ParameterList with current settings.
 
Teuchos::RCP< Teuchos::ParameterList > getNonconstParameterList ()
 Return a valid non-const ParameterList with current settings.
 

Overridden from Teuchos::Describable

virtual std::string description () const
 
virtual void describe (Teuchos::FancyOStream &out, const Teuchos::EVerbosityLevel verbLevel) const
 

Detailed Description

template<class Scalar>
class Tempus::SolutionHistory< Scalar >

SolutionHistory is basically a container of SolutionStates. SolutionHistory maintains a collection of SolutionStates for later retrival and reuse, such as checkpointing, restart, and undo operations.

The actual storage of the SolutionStates may take several forms:

SolutionHistory can fill in SolutionStates between other SolutionStates by either

There are two sets of indices associated with SolutionHistory: timestep index and the SolutionHistory index. Users are interested in the timestep index as it indicates the solution increment, e.g., $[x^0, ... , x^{n-2}, x^{n-1}, x^{n}]$, where $n$ is the timestep index. While developers can also be interested in the SolutionHistory index to access the correct SolutionState in the SolutionHistory, e.g., $[S^0, ... , S^{M-1}]$, where $M$ is the number of SolutionStates in the SolutionHistory (1 $\le M \le$ StorageLimit_).

SolutionHistory will hold upto the StorageLimit_ number of states. Rules of thumb for the minimum storage limit:

The states contained in the SolutionHistory will often be the last $M$ states for forward time integration, e.g., $[S^0(x^{n-M+1}), ... , S^{M-3}(x^{n-2}), S^{M-2}(x^{n-1}),
    S^{M-1}(x^{n})]$, but this is not guaranteed. For example, during transient adjoint sensitivity calculations, not all the forward states can be stored and therefore will be recalculated. Thus intermediate states are kept to reduce recomputation costs, i.e., so one does not recalculate from the initial conditions to the desired time. This means the states in the SolutionHistory may not have consecutive timestep indices, e.g., $[..., S^{M-4}(x^{n-200}), S^{M-3}(x^{n-100}),
S^{M-2}(x^{n-1}), S^{M-1}(x^{n})]$.

The SolutionHistory is kept in chronological order, starting with the oldest state and ending with the latest.

The "current" state is the latest solution that has been successfully solved. The solution from the last successful time step or the initial conditions.

The "working" state is the state which is being worked on. It is valid from initialization (e.g., copied from the "current" state), during the the timestep, and until it is accepted and promoted to the new "current" state. Between the promotion and the initialization, the workingState_ is invalid (i.e., Teuchos::null). If the timestep fails, the workingState_ is maintained, and the timestep is retried until the Integrator declares a successful timestep or the time integration is a failure. The SolutionHistory indices associated with the currentState_ and the workingState_ vary during the time step loop, and are

Loop Portion currentState_ workingState_
Before initializing working state PASS -> $M$-1
FAIL -> $M$-2
PASS -> Invalid
FAIL -> $M$-1
After initializing working state
During timestep
Before accepting timestep
$M$-2 $M$-1
After accepting timestep PASS -> $M$-1
FAIL -> $M$-2
PASS -> Invalid
FAIL -> $M$-1

Initial conditions are considered PASSing, which sets up the loop. The difference between the currentState_ timestep index and the workingState_ timestep index is guaranteed to be one (except for when StorageLimit_ = 1, i.e., explicit one-step methods that can update the solution in-place).

Definition at line 118 of file Tempus_SolutionHistory_decl.hpp.

Constructor & Destructor Documentation

◆ SolutionHistory() [1/2]

template<class Scalar >
Tempus::SolutionHistory< Scalar >::SolutionHistory

Default Contructor.

Definition at line 24 of file Tempus_SolutionHistory_impl.hpp.

◆ SolutionHistory() [2/2]

template<class Scalar >
Tempus::SolutionHistory< Scalar >::SolutionHistory ( std::string  name,
Teuchos::RCP< std::vector< Teuchos::RCP< SolutionState< Scalar > > > >  history,
Teuchos::RCP< Interpolator< Scalar > >  interpolator,
StorageType  storageType,
int  storageLimit 
)

Contructor.

Definition at line 38 of file Tempus_SolutionHistory_impl.hpp.

◆ ~SolutionHistory()

template<class Scalar >
Tempus::SolutionHistory< Scalar >::~SolutionHistory ( )
inline

Destructor.

Definition at line 136 of file Tempus_SolutionHistory_decl.hpp.

Member Function Documentation

◆ addState()

template<class Scalar >
void Tempus::SolutionHistory< Scalar >::addState ( const Teuchos::RCP< SolutionState< Scalar > > &  state,
bool  doChecks = true 
)

Add solution state to history.

Definition at line 57 of file Tempus_SolutionHistory_impl.hpp.

◆ addWorkingState()

template<class Scalar >
void Tempus::SolutionHistory< Scalar >::addWorkingState ( const Teuchos::RCP< SolutionState< Scalar > > &  state,
const bool  updateTime = true 
)

Add a working solution state to history.

Definition at line 135 of file Tempus_SolutionHistory_impl.hpp.

◆ removeState() [1/2]

template<class Scalar >
void Tempus::SolutionHistory< Scalar >::removeState ( const Teuchos::RCP< SolutionState< Scalar > > &  state)

Remove solution state.

Definition at line 153 of file Tempus_SolutionHistory_impl.hpp.

◆ removeState() [2/2]

template<class Scalar >
void Tempus::SolutionHistory< Scalar >::removeState ( const Scalar  time)

Remove solution state based on time.

Definition at line 175 of file Tempus_SolutionHistory_impl.hpp.

◆ findState()

template<class Scalar >
Teuchos::RCP< SolutionState< Scalar > > Tempus::SolutionHistory< Scalar >::findState ( const Scalar  time) const

Find solution state at requested time (no interpolation)

Definition at line 184 of file Tempus_SolutionHistory_impl.hpp.

◆ interpolateState() [1/2]

template<class Scalar >
Teuchos::RCP< SolutionState< Scalar > > Tempus::SolutionHistory< Scalar >::interpolateState ( const Scalar  time) const

Generate and interpolate a new solution state at requested time.

Definition at line 215 of file Tempus_SolutionHistory_impl.hpp.

◆ interpolateState() [2/2]

template<class Scalar >
void Tempus::SolutionHistory< Scalar >::interpolateState ( const Scalar  time,
SolutionState< Scalar > *  state_out 
) const

Interpolate solution state at requested time and store in supplied state.

Definition at line 225 of file Tempus_SolutionHistory_impl.hpp.

◆ initWorkingState()

template<class Scalar >
void Tempus::SolutionHistory< Scalar >::initWorkingState

Initialize the working state.

Initialize the working state

Definition at line 234 of file Tempus_SolutionHistory_impl.hpp.

◆ promoteWorkingState()

template<class Scalar >
void Tempus::SolutionHistory< Scalar >::promoteWorkingState

Promote the working state to current state.

Definition at line 268 of file Tempus_SolutionHistory_impl.hpp.

◆ clear()

template<class Scalar >
void Tempus::SolutionHistory< Scalar >::clear ( )
inline

Clear the history.

Definition at line 171 of file Tempus_SolutionHistory_decl.hpp.

◆ copy()

template<class Scalar >
void Tempus::SolutionHistory< Scalar >::copy ( Teuchos::RCP< const SolutionHistory< Scalar > >  sh)

Make a shallow copy of SolutionHistory (i.e., only RCPs to states and interpolator).

Definition at line 289 of file Tempus_SolutionHistory_impl.hpp.

◆ getName()

template<class Scalar >
std::string Tempus::SolutionHistory< Scalar >::getName ( ) const
inline

Get this SolutionHistory's name.

Definition at line 180 of file Tempus_SolutionHistory_decl.hpp.

◆ setName()

template<class Scalar >
void Tempus::SolutionHistory< Scalar >::setName ( std::string  name)
inline

Set this SolutionHistory's name.

Definition at line 183 of file Tempus_SolutionHistory_decl.hpp.

◆ getHistory()

template<class Scalar >
Teuchos::RCP< std::vector< Teuchos::RCP< SolutionState< Scalar > > > > Tempus::SolutionHistory< Scalar >::getHistory ( ) const
inline

Get underlining history.

Definition at line 187 of file Tempus_SolutionHistory_decl.hpp.

◆ setHistory()

template<class Scalar >
void Tempus::SolutionHistory< Scalar >::setHistory ( Teuchos::RCP< std::vector< Teuchos::RCP< SolutionState< Scalar > > > >  h)
inline

Set underlining history.

Definition at line 190 of file Tempus_SolutionHistory_decl.hpp.

◆ operator[]() [1/2]

template<class Scalar >
Teuchos::RCP< SolutionState< Scalar > > Tempus::SolutionHistory< Scalar >::operator[] ( const int  i)
inline

Subscript operator.

Definition at line 195 of file Tempus_SolutionHistory_decl.hpp.

◆ operator[]() [2/2]

template<class Scalar >
Teuchos::RCP< const SolutionState< Scalar > > Tempus::SolutionHistory< Scalar >::operator[] ( const int  i) const
inline

Subscript operator (const version)

Definition at line 205 of file Tempus_SolutionHistory_decl.hpp.

◆ getCurrentState()

template<class Scalar >
Teuchos::RCP< SolutionState< Scalar > > Tempus::SolutionHistory< Scalar >::getCurrentState ( ) const
inline

Return the current state, i.e., the last accepted state.

Definition at line 215 of file Tempus_SolutionHistory_decl.hpp.

◆ getWorkingState()

template<class Scalar >
Teuchos::RCP< SolutionState< Scalar > > Tempus::SolutionHistory< Scalar >::getWorkingState ( bool  warn = true) const
inline

Return the working state.

Definition at line 226 of file Tempus_SolutionHistory_decl.hpp.

◆ getNumStates()

template<class Scalar >
int Tempus::SolutionHistory< Scalar >::getNumStates ( ) const
inline

Get the number of states.

Definition at line 239 of file Tempus_SolutionHistory_decl.hpp.

◆ getCurrentTime()

template<class Scalar >
Scalar Tempus::SolutionHistory< Scalar >::getCurrentTime ( ) const
inline

Get the current time.

Definition at line 242 of file Tempus_SolutionHistory_decl.hpp.

◆ getCurrentIndex()

template<class Scalar >
int Tempus::SolutionHistory< Scalar >::getCurrentIndex ( ) const
inline

Get the current timestep index.

Definition at line 245 of file Tempus_SolutionHistory_decl.hpp.

◆ setStorageLimit()

template<class Scalar >
void Tempus::SolutionHistory< Scalar >::setStorageLimit ( int  storage_limit)

Set the maximum storage of this history.

Definition at line 309 of file Tempus_SolutionHistory_impl.hpp.

◆ getStorageLimit()

template<class Scalar >
int Tempus::SolutionHistory< Scalar >::getStorageLimit ( ) const
inline

Get the maximum storage of this history.

Definition at line 251 of file Tempus_SolutionHistory_decl.hpp.

◆ setStorageType()

template<class Scalar >
void Tempus::SolutionHistory< Scalar >::setStorageType ( StorageType  st)

Set the storage type via enum.

Definition at line 349 of file Tempus_SolutionHistory_impl.hpp.

◆ getStorageType()

template<class Scalar >
StorageType Tempus::SolutionHistory< Scalar >::getStorageType ( ) const
inline

Get the enum storage type.

Definition at line 257 of file Tempus_SolutionHistory_decl.hpp.

◆ setStorageTypeString()

template<class Scalar >
void Tempus::SolutionHistory< Scalar >::setStorageTypeString ( std::string  st)

Set the storage type via string.

Definition at line 361 of file Tempus_SolutionHistory_impl.hpp.

◆ getStorageTypeString()

template<class Scalar >
std::string Tempus::SolutionHistory< Scalar >::getStorageTypeString

Set the string storage type.

Definition at line 382 of file Tempus_SolutionHistory_impl.hpp.

◆ minTime()

template<class Scalar >
Scalar Tempus::SolutionHistory< Scalar >::minTime ( ) const
inline

Return the current minimum time of the SolutionStates.

Definition at line 266 of file Tempus_SolutionHistory_decl.hpp.

◆ maxTime()

template<class Scalar >
Scalar Tempus::SolutionHistory< Scalar >::maxTime ( ) const
inline

Return the current maximum time of the SolutionStates.

Definition at line 269 of file Tempus_SolutionHistory_decl.hpp.

◆ getStateTimeIndexN()

template<class Scalar >
Teuchos::RCP< SolutionState< Scalar > > Tempus::SolutionHistory< Scalar >::getStateTimeIndexN ( bool  warn = true) const

Get the state with timestep index equal to n.

If not available return Teuchos::null;

Definition at line 395 of file Tempus_SolutionHistory_impl.hpp.

◆ getStateTimeIndexNM1()

template<class Scalar >
Teuchos::RCP< SolutionState< Scalar > > Tempus::SolutionHistory< Scalar >::getStateTimeIndexNM1 ( bool  warn = true) const

Get the state with timestep index equal to n-1.

If not available return Teuchos::null;

Definition at line 415 of file Tempus_SolutionHistory_impl.hpp.

◆ getStateTimeIndexNM2()

template<class Scalar >
Teuchos::RCP< SolutionState< Scalar > > Tempus::SolutionHistory< Scalar >::getStateTimeIndexNM2 ( bool  warn = true) const

Get the state with timestep index equal to n-2.

If not available return Teuchos::null;

Definition at line 453 of file Tempus_SolutionHistory_impl.hpp.

◆ getStateTimeIndex()

template<class Scalar >
Teuchos::RCP< SolutionState< Scalar > > Tempus::SolutionHistory< Scalar >::getStateTimeIndex ( int  index,
bool  warn = true 
) const

Get the state with timestep index equal to "index".

If not available return Teuchos::null;

Definition at line 494 of file Tempus_SolutionHistory_impl.hpp.

◆ getValidParameters()

template<class Scalar >
Teuchos::RCP< const Teuchos::ParameterList > Tempus::SolutionHistory< Scalar >::getValidParameters

Return a valid ParameterList with current settings.

Definition at line 559 of file Tempus_SolutionHistory_impl.hpp.

◆ getNonconstParameterList()

template<class Scalar >
Teuchos::RCP< Teuchos::ParameterList > Tempus::SolutionHistory< Scalar >::getNonconstParameterList

Return a valid non-const ParameterList with current settings.

Definition at line 584 of file Tempus_SolutionHistory_impl.hpp.

◆ description()

template<class Scalar >
std::string Tempus::SolutionHistory< Scalar >::description
virtual

Definition at line 519 of file Tempus_SolutionHistory_impl.hpp.

◆ describe()

template<class Scalar >
void Tempus::SolutionHistory< Scalar >::describe ( Teuchos::FancyOStream &  out,
const Teuchos::EVerbosityLevel  verbLevel 
) const
virtual

Definition at line 526 of file Tempus_SolutionHistory_impl.hpp.

◆ setInterpolator()

template<class Scalar >
void Tempus::SolutionHistory< Scalar >::setInterpolator ( const Teuchos::RCP< Interpolator< Scalar > > &  interpolator)

Set the interpolator for this history.

Definition at line 591 of file Tempus_SolutionHistory_impl.hpp.

◆ getNonconstInterpolator()

template<class Scalar >
Teuchos::RCP< Interpolator< Scalar > > Tempus::SolutionHistory< Scalar >::getNonconstInterpolator

Definition at line 604 of file Tempus_SolutionHistory_impl.hpp.

◆ getInterpolator()

template<class Scalar >
Teuchos::RCP< const Interpolator< Scalar > > Tempus::SolutionHistory< Scalar >::getInterpolator

Definition at line 611 of file Tempus_SolutionHistory_impl.hpp.

◆ unSetInterpolator()

template<class Scalar >
Teuchos::RCP< Interpolator< Scalar > > Tempus::SolutionHistory< Scalar >::unSetInterpolator

Unset the interpolator for this history.

Definition at line 618 of file Tempus_SolutionHistory_impl.hpp.

◆ printHistory()

template<class Scalar >
void Tempus::SolutionHistory< Scalar >::printHistory ( std::string  verb = "low") const

Print information on States in the SolutionHistory.

Definition at line 627 of file Tempus_SolutionHistory_impl.hpp.

◆ initialize()

template<class Scalar >
void Tempus::SolutionHistory< Scalar >::initialize

Initialize SolutionHistory.

This function will check if all member data is initialized and is consistent. This function does not make member data consistent, but just checks it. This ensures it is inexpensive.

Definition at line 656 of file Tempus_SolutionHistory_impl.hpp.

◆ isInitialized()

template<class Scalar >
bool Tempus::SolutionHistory< Scalar >::isInitialized ( )
inline

Return if SolutionHistory is initialized.

Definition at line 332 of file Tempus_SolutionHistory_decl.hpp.

Member Data Documentation

◆ name_

template<class Scalar >
std::string Tempus::SolutionHistory< Scalar >::name_
protected

Definition at line 337 of file Tempus_SolutionHistory_decl.hpp.

◆ history_

template<class Scalar >
Teuchos::RCP<std::vector<Teuchos::RCP<SolutionState<Scalar> > > > Tempus::SolutionHistory< Scalar >::history_
protected

Definition at line 338 of file Tempus_SolutionHistory_decl.hpp.

◆ interpolator_

template<class Scalar >
Teuchos::RCP<Interpolator<Scalar> > Tempus::SolutionHistory< Scalar >::interpolator_
protected

Definition at line 339 of file Tempus_SolutionHistory_decl.hpp.

◆ storageType_

template<class Scalar >
StorageType Tempus::SolutionHistory< Scalar >::storageType_
protected

Definition at line 340 of file Tempus_SolutionHistory_decl.hpp.

◆ storageLimit_

template<class Scalar >
int Tempus::SolutionHistory< Scalar >::storageLimit_
protected

Definition at line 341 of file Tempus_SolutionHistory_decl.hpp.

◆ workingState_

template<class Scalar >
Teuchos::RCP<SolutionState<Scalar> > Tempus::SolutionHistory< Scalar >::workingState_
protected

The state being worked on.

Definition at line 343 of file Tempus_SolutionHistory_decl.hpp.

◆ isInitialized_

template<class Scalar >
bool Tempus::SolutionHistory< Scalar >::isInitialized_
mutableprotected

Bool if SolutionHistory is initialized.

Definition at line 345 of file Tempus_SolutionHistory_decl.hpp.


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