Tempus  Version of the Day
Time Integration
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
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_Integrator.hpp>

Inheritance diagram for Tempus::SolutionHistory< Scalar >:

Public Member Functions

 SolutionHistory ()
 Default Contructor. More...
 
 SolutionHistory (std::string name, Teuchos::RCP< std::vector< Teuchos::RCP< SolutionState< Scalar > > > > history, Teuchos::RCP< Interpolator< Scalar > > interpolator, StorageType storageType, int storageLimit)
 Contructor. More...
 
 SolutionHistory (Teuchos::RCP< Teuchos::ParameterList > shPL)
 Contructor (Slated for deprecation. Use createSolutionHistory(shPL);) More...
 
 ~SolutionHistory ()
 Destructor. More...
 
void printHistory (std::string verb="low") const
 
Basic SolutionHistory Methods
void addState (const Teuchos::RCP< SolutionState< Scalar > > &state)
 Add solution state to history. More...
 
void addWorkingState (const Teuchos::RCP< SolutionState< Scalar > > &state, const bool updateTime=true)
 Add a working solution state to history. More...
 
void removeState (const Teuchos::RCP< SolutionState< Scalar > > &state)
 Remove solution state. More...
 
void removeState (const Scalar time)
 Remove solution state based on time. More...
 
Teuchos::RCP< SolutionState
< Scalar > > 
findState (const Scalar time) const
 Find solution state at requested time (no interpolation) More...
 
Teuchos::RCP< SolutionState
< Scalar > > 
interpolateState (const Scalar time) const
 Generate and interpolate a new solution state at requested time. More...
 
void interpolateState (const Scalar time, SolutionState< Scalar > *state_out) const
 Interpolate solution state at requested time and store in supplied state. More...
 
void initWorkingState ()
 Initialize the working state. More...
 
void promoteWorkingState ()
 Promote the working state to current state. More...
 
void clear ()
 
Accessor methods
std::string getName () const
 Get this SolutionHistory's name. More...
 
void setName (std::string name)
 Set this SolutionHistory's name. More...
 
Teuchos::RCP< std::vector
< Teuchos::RCP< SolutionState
< Scalar > > > > 
getHistory () const
 Get underlining history. More...
 
Teuchos::RCP< SolutionState
< Scalar > > 
operator[] (const int i)
 Subscript operator. More...
 
Teuchos::RCP< const
SolutionState< Scalar > > 
operator[] (const int i) const
 Subscript operator (const version) More...
 
Teuchos::RCP< SolutionState
< Scalar > > 
getCurrentState () const
 Return the current state, i.e., the last accepted state. More...
 
Teuchos::RCP< SolutionState
< Scalar > > 
getWorkingState (bool warn=true) const
 Return the working state. More...
 
int getNumStates () const
 Get the number of states. More...
 
Scalar getCurrentTime () const
 Get the current time. More...
 
int getCurrentIndex () const
 Get the current timestep index. More...
 
void setStorageLimit (int storage_limit)
 Set the maximum storage of this history. More...
 
int getStorageLimit () const
 Get the maximum storage of this history. More...
 
void setStorageType (StorageType st)
 
StorageType getStorageType ()
 
Scalar minTime () const
 Return the current minimum time of the SolutionStates. More...
 
Scalar maxTime () const
 Return the current maximum time of the SolutionStates. More...
 
Teuchos::RCP< SolutionState
< Scalar > > 
getStateTimeIndexN () const
 Get the state with timestep index equal to n. More...
 
Teuchos::RCP< SolutionState
< Scalar > > 
getStateTimeIndexNM1 () const
 Get the state with timestep index equal to n-1. More...
 
Teuchos::RCP< SolutionState
< Scalar > > 
getStateTimeIndexNM2 () const
 Get the state with timestep index equal to n-2. More...
 
Teuchos::RCP< SolutionState
< Scalar > > 
getStateTimeIndex (int index) const
 Get the state with timestep index equal to "index". More...
 
Overridden from Teuchos::ParameterListAcceptor
void setParameterList (const Teuchos::RCP< Teuchos::ParameterList > &pl)
 
Teuchos::RCP< const
Teuchos::ParameterList > 
getValidParameters () const
 
Teuchos::RCP
< Teuchos::ParameterList > 
getNonconstParameterList ()
 
Teuchos::RCP
< Teuchos::ParameterList > 
unsetParameterList ()
 
Overridden from Teuchos::Describable
virtual std::string description () const
 
virtual void describe (Teuchos::FancyOStream &out, const Teuchos::EVerbosityLevel verbLevel) const
 
Interpolation Methods
void setInterpolator (const Teuchos::RCP< Interpolator< Scalar > > &interpolator)
 Set the interpolator for this history. More...
 
Teuchos::RCP< Interpolator
< Scalar > > 
getNonconstInterpolator ()
 
Teuchos::RCP< const
Interpolator< Scalar > > 
getInterpolator () const
 
Teuchos::RCP< Interpolator
< Scalar > > 
unSetInterpolator ()
 Unset the interpolator for this history. More...
 

Protected Attributes

std::string name_
 
Teuchos::RCP
< Teuchos::ParameterList > 
shPL_
 
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. More...
 

Detailed Description

template<typename 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:

  • in memory
  • on disk
  • combination
  • use ATDM DataWareHouse but the interface should be unchanged and very similar to other containers.

SolutionHistory can fill in SolutionStates between other SolutionStates by either

  • Integrating from one SolutionState to the desired time
    • This might include methods like Griewank's algorithm.
  • Interpolating between SolutionStates
    • Interpolated SolutionStates may not be suitable for adjoint solutions, restart, or undo operations (see SolutionState).

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:

  • Explicit one-step methods can update the solution state in-place –> StorageLimit_ = 1.
  • Implicit one-step methods need two solution states –> StorageLimit_ = 2.
  • MultiStep methods require k past solution states –> StorageLimit_ = k+1.

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 25 of file Tempus_Integrator.hpp.

Constructor & Destructor Documentation

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

Default Contructor.

Definition at line 57 of file Tempus_SolutionHistory_impl.hpp.

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 75 of file Tempus_SolutionHistory_impl.hpp.

template<class Scalar >
Tempus::SolutionHistory< Scalar >::SolutionHistory ( Teuchos::RCP< Teuchos::ParameterList >  shPL)

Contructor (Slated for deprecation. Use createSolutionHistory(shPL);)

Definition at line 99 of file Tempus_SolutionHistory_impl.hpp.

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

Destructor.

Definition at line 148 of file Tempus_SolutionHistory_decl.hpp.

Member Function Documentation

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

Add solution state to history.

Definition at line 118 of file Tempus_SolutionHistory_impl.hpp.

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 173 of file Tempus_SolutionHistory_impl.hpp.

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

Definition at line 181 of file Tempus_SolutionHistory_decl.hpp.

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

Definition at line 418 of file Tempus_SolutionHistory_impl.hpp.

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

Definition at line 411 of file Tempus_SolutionHistory_impl.hpp.

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 222 of file Tempus_SolutionHistory_impl.hpp.

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

Get the current timestep index.

Definition at line 247 of file Tempus_SolutionHistory_decl.hpp.

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

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

Definition at line 217 of file Tempus_SolutionHistory_decl.hpp.

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

Get the current time.

Definition at line 244 of file Tempus_SolutionHistory_decl.hpp.

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

Get underlining history.

Definition at line 194 of file Tempus_SolutionHistory_decl.hpp.

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

Definition at line 576 of file Tempus_SolutionHistory_impl.hpp.

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

Get this SolutionHistory's name.

Definition at line 187 of file Tempus_SolutionHistory_decl.hpp.

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

Definition at line 569 of file Tempus_SolutionHistory_impl.hpp.

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

Definition at line 535 of file Tempus_SolutionHistory_impl.hpp.

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

Get the number of states.

Definition at line 241 of file Tempus_SolutionHistory_decl.hpp.

template<class Scalar >
Teuchos::RCP< SolutionState< Scalar > > Tempus::SolutionHistory< Scalar >::getStateTimeIndex ( int  index) const

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

Definition at line 395 of file Tempus_SolutionHistory_impl.hpp.

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

Get the state with timestep index equal to n.

Definition at line 338 of file Tempus_SolutionHistory_impl.hpp.

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

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

Definition at line 349 of file Tempus_SolutionHistory_impl.hpp.

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

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

Definition at line 372 of file Tempus_SolutionHistory_impl.hpp.

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

Get the maximum storage of this history.

Definition at line 253 of file Tempus_SolutionHistory_decl.hpp.

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

Definition at line 256 of file Tempus_SolutionHistory_decl.hpp.

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

Definition at line 509 of file Tempus_SolutionHistory_impl.hpp.

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

Return the working state.

Definition at line 228 of file Tempus_SolutionHistory_decl.hpp.

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

Initialize the working state.

Initialize the working state

Definition at line 269 of file Tempus_SolutionHistory_impl.hpp.

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 250 of file Tempus_SolutionHistory_impl.hpp.

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 260 of file Tempus_SolutionHistory_impl.hpp.

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

Return the current maximum time of the SolutionStates.

Definition at line 262 of file Tempus_SolutionHistory_decl.hpp.

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

Return the current minimum time of the SolutionStates.

Definition at line 259 of file Tempus_SolutionHistory_decl.hpp.

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

Subscript operator.

Definition at line 197 of file Tempus_SolutionHistory_decl.hpp.

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

Subscript operator (const version)

Definition at line 207 of file Tempus_SolutionHistory_decl.hpp.

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

Definition at line 302 of file Tempus_SolutionHistory_decl.hpp.

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

Promote the working state to current state.

Definition at line 303 of file Tempus_SolutionHistory_impl.hpp.

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

Remove solution state.

Definition at line 191 of file Tempus_SolutionHistory_impl.hpp.

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

Remove solution state based on time.

Definition at line 213 of file Tempus_SolutionHistory_impl.hpp.

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

Set the interpolator for this history.

Definition at line 551 of file Tempus_SolutionHistory_impl.hpp.

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

Set this SolutionHistory's name.

Definition at line 190 of file Tempus_SolutionHistory_decl.hpp.

template<class Scalar >
void Tempus::SolutionHistory< Scalar >::setParameterList ( const Teuchos::RCP< Teuchos::ParameterList > &  pl)

Definition at line 444 of file Tempus_SolutionHistory_impl.hpp.

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

Set the maximum storage of this history.

Definition at line 324 of file Tempus_SolutionHistory_impl.hpp.

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

Definition at line 255 of file Tempus_SolutionHistory_decl.hpp.

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

Unset the interpolator for this history.

Definition at line 583 of file Tempus_SolutionHistory_impl.hpp.

template<class Scalar >
Teuchos::RCP< Teuchos::ParameterList > Tempus::SolutionHistory< Scalar >::unsetParameterList ( )

Definition at line 543 of file Tempus_SolutionHistory_impl.hpp.

Member Data Documentation

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

Definition at line 333 of file Tempus_SolutionHistory_decl.hpp.

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

Definition at line 334 of file Tempus_SolutionHistory_decl.hpp.

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

Definition at line 331 of file Tempus_SolutionHistory_decl.hpp.

template<typename Scalar >
Teuchos::RCP<Teuchos::ParameterList> Tempus::SolutionHistory< Scalar >::shPL_
protected

Definition at line 332 of file Tempus_SolutionHistory_decl.hpp.

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

Definition at line 336 of file Tempus_SolutionHistory_decl.hpp.

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

Definition at line 335 of file Tempus_SolutionHistory_decl.hpp.

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

The state being worked on.

Definition at line 338 of file Tempus_SolutionHistory_decl.hpp.


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