Tempus
Version of the Day
Time Integration
|
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>
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 () | |
Destructor. More... | |
Teuchos::RCP< const Teuchos::ParameterList > | getValidParameters () const |
Return a valid ParameterList with current settings. More... | |
Teuchos::RCP < Teuchos::ParameterList > | getNonconstParameterList () |
Return a valid non-const ParameterList with current settings. More... | |
void | printHistory (std::string verb="low") const |
Print information on States in the SolutionHistory. More... | |
void | initialize () const |
Initialize SolutionHistory. More... | |
bool | isInitialized () |
Return if SolutionHistory is initialized. More... | |
Public Member Functions inherited from Teuchos::Describable | |
void | describe (std::ostream &out, const EVerbosityLevel verbLevel=verbLevel_default) const |
virtual | ~Describable () |
LabeledObject () | |
virtual | ~LabeledObject () |
virtual void | setObjectLabel (const std::string &objectLabel) |
virtual std::string | getObjectLabel () const |
DescribableStreamManipulatorState | describe (const Describable &describable, const EVerbosityLevel verbLevel=Describable::verbLevel_default) |
std::ostream & | operator<< (std::ostream &os, const DescribableStreamManipulatorState &d) |
Public Member Functions inherited from Teuchos::VerboseObject< SolutionHistory< Scalar > > | |
VerboseObject (const EVerbosityLevel verbLevel=VERB_DEFAULT, const RCP< FancyOStream > &oStream=Teuchos::null) | |
virtual const VerboseObject & | setVerbLevel (const EVerbosityLevel verbLevel) const |
virtual const VerboseObject & | setOverridingVerbLevel (const EVerbosityLevel verbLevel) const |
virtual EVerbosityLevel | getVerbLevel () const |
TEUCHOSPARAMETERLIST_LIB_DLL_EXPORT RCP< const ParameterList > | getValidVerboseObjectSublist () |
TEUCHOSPARAMETERLIST_LIB_DLL_EXPORT void | setupVerboseObjectSublist (ParameterList *paramList) |
TEUCHOSPARAMETERLIST_LIB_DLL_EXPORT void | readVerboseObjectSublist (ParameterList *paramList, RCP< FancyOStream > *oStream, EVerbosityLevel *verbLevel) |
void | readVerboseObjectSublist (ParameterList *paramList, VerboseObject< ObjectType > *verboseObject) |
Public Member Functions inherited from Teuchos::VerboseObjectBase | |
virtual | ~VerboseObjectBase () |
VerboseObjectBase (const RCP< FancyOStream > &oStream=Teuchos::null) | |
virtual const VerboseObjectBase & | setOStream (const RCP< FancyOStream > &oStream) const |
virtual const VerboseObjectBase & | setOverridingOStream (const RCP< FancyOStream > &oStream) const |
virtual VerboseObjectBase & | setLinePrefix (const std::string &linePrefix) |
virtual RCP< FancyOStream > | getOStream () const |
virtual RCP< FancyOStream > | getOverridingOStream () const |
virtual std::string | getLinePrefix () const |
virtual OSTab | getOSTab (const int tabs=1, const std::string &linePrefix="") const |
Protected Attributes | |
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. More... | |
bool | isInitialized_ |
Bool if SolutionHistory is initialized. More... | |
Basic SolutionHistory Methods | |
void | addState (const Teuchos::RCP< SolutionState< Scalar > > &state, bool doChecks=true) |
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 () |
Clear the history. More... | |
void | copy (Teuchos::RCP< const SolutionHistory< Scalar > > sh) |
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... | |
void | setHistory (Teuchos::RCP< std::vector< Teuchos::RCP< SolutionState< Scalar > > > > h) |
Set 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) |
Set the storage type via enum. More... | |
StorageType | getStorageType () const |
Get the enum storage type. More... | |
void | setStorageTypeString (std::string st) |
Set the storage type via string. More... | |
std::string | getStorageTypeString () const |
Set the string storage type. More... | |
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 (bool warn=true) const |
Get the state with timestep index equal to n. More... | |
Teuchos::RCP< SolutionState < Scalar > > | getStateTimeIndexNM1 (bool warn=true) const |
Get the state with timestep index equal to n-1. More... | |
Teuchos::RCP< SolutionState < Scalar > > | getStateTimeIndexNM2 (bool warn=true) const |
Get the state with timestep index equal to n-2. More... | |
Teuchos::RCP< SolutionState < Scalar > > | getStateTimeIndex (int index, bool warn=true) const |
Get the state with timestep index equal to "index". More... | |
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... | |
Additional Inherited Members | |
Static Public Member Functions inherited from Teuchos::VerboseObject< SolutionHistory< Scalar > > | |
static void | setDefaultVerbLevel (const EVerbosityLevel defaultVerbLevel) |
static EVerbosityLevel | getDefaultVerbLevel () |
Static Public Member Functions inherited from Teuchos::VerboseObjectBase | |
static void | setDefaultOStream (const RCP< FancyOStream > &defaultOStream) |
static RCP< FancyOStream > | getDefaultOStream () |
Static Public Attributes inherited from Teuchos::Describable | |
static const EVerbosityLevel | verbLevel_default |
Protected Member Functions inherited from Teuchos::VerboseObject< SolutionHistory< Scalar > > | |
void | initializeVerboseObject (const EVerbosityLevel verbLevel=VERB_DEFAULT, const RCP< FancyOStream > &oStream=Teuchos::null) |
Protected Member Functions inherited from Teuchos::VerboseObjectBase | |
void | initializeVerboseObjectBase (const RCP< FancyOStream > &oStream=Teuchos::null) |
virtual void | informUpdatedVerbosityState () const |
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., , where is the timestep index. While developers can also be interested in the SolutionHistory index to access the correct SolutionState in the SolutionHistory, e.g., , where is the number of SolutionStates in the SolutionHistory (1 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 states for forward time integration, e.g., , 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., .
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 -> -1 FAIL -> -2 | PASS -> Invalid FAIL -> -1 |
After initializing working state During timestep Before accepting timestep | -2 | -1 |
After accepting timestep | PASS -> -1 FAIL -> -2 | PASS -> Invalid FAIL -> -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 28 of file Tempus_Integrator.hpp.
Tempus::SolutionHistory< Scalar >::SolutionHistory | ( | ) |
Default Contructor.
Definition at line 24 of file Tempus_SolutionHistory_impl.hpp.
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 35 of file Tempus_SolutionHistory_impl.hpp.
|
inline |
Destructor.
Definition at line 132 of file Tempus_SolutionHistory_decl.hpp.
void Tempus::SolutionHistory< Scalar >::addState | ( | const Teuchos::RCP< SolutionState< Scalar > > & | state, |
bool | doChecks = true |
||
) |
Add solution state to history.
Definition at line 52 of file Tempus_SolutionHistory_impl.hpp.
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 132 of file Tempus_SolutionHistory_impl.hpp.
void Tempus::SolutionHistory< Scalar >::removeState | ( | const Teuchos::RCP< SolutionState< Scalar > > & | state | ) |
Remove solution state.
Definition at line 150 of file Tempus_SolutionHistory_impl.hpp.
void Tempus::SolutionHistory< Scalar >::removeState | ( | const Scalar | time | ) |
Remove solution state based on time.
Definition at line 170 of file Tempus_SolutionHistory_impl.hpp.
Teuchos::RCP< SolutionState< Scalar > > Tempus::SolutionHistory< Scalar >::findState | ( | const Scalar | time | ) | const |
Find solution state at requested time (no interpolation)
Definition at line 177 of file Tempus_SolutionHistory_impl.hpp.
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 211 of file Tempus_SolutionHistory_impl.hpp.
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 220 of file Tempus_SolutionHistory_impl.hpp.
void Tempus::SolutionHistory< Scalar >::initWorkingState | ( | ) |
Initialize the working state.
Initialize the working state
Definition at line 228 of file Tempus_SolutionHistory_impl.hpp.
void Tempus::SolutionHistory< Scalar >::promoteWorkingState | ( | ) |
Promote the working state to current state.
Definition at line 269 of file Tempus_SolutionHistory_impl.hpp.
|
inline |
Clear the history.
Definition at line 168 of file Tempus_SolutionHistory_decl.hpp.
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 290 of file Tempus_SolutionHistory_impl.hpp.
|
inline |
Get this SolutionHistory's name.
Definition at line 182 of file Tempus_SolutionHistory_decl.hpp.
|
inline |
Set this SolutionHistory's name.
Definition at line 185 of file Tempus_SolutionHistory_decl.hpp.
|
inline |
Get underlining history.
Definition at line 188 of file Tempus_SolutionHistory_decl.hpp.
|
inline |
Set underlining history.
Definition at line 195 of file Tempus_SolutionHistory_decl.hpp.
|
inline |
Subscript operator.
Definition at line 203 of file Tempus_SolutionHistory_decl.hpp.
|
inline |
Subscript operator (const version)
Definition at line 214 of file Tempus_SolutionHistory_decl.hpp.
|
inline |
Return the current state, i.e., the last accepted state.
Definition at line 225 of file Tempus_SolutionHistory_decl.hpp.
|
inline |
Return the working state.
Definition at line 239 of file Tempus_SolutionHistory_decl.hpp.
|
inline |
Get the number of states.
Definition at line 252 of file Tempus_SolutionHistory_decl.hpp.
|
inline |
Get the current time.
Definition at line 255 of file Tempus_SolutionHistory_decl.hpp.
|
inline |
Get the current timestep index.
Definition at line 258 of file Tempus_SolutionHistory_decl.hpp.
void Tempus::SolutionHistory< Scalar >::setStorageLimit | ( | int | storage_limit | ) |
Set the maximum storage of this history.
Definition at line 310 of file Tempus_SolutionHistory_impl.hpp.
|
inline |
Get the maximum storage of this history.
Definition at line 264 of file Tempus_SolutionHistory_decl.hpp.
void Tempus::SolutionHistory< Scalar >::setStorageType | ( | StorageType | st | ) |
Set the storage type via enum.
Definition at line 353 of file Tempus_SolutionHistory_impl.hpp.
|
inline |
Get the enum storage type.
Definition at line 270 of file Tempus_SolutionHistory_decl.hpp.
void Tempus::SolutionHistory< Scalar >::setStorageTypeString | ( | std::string | st | ) |
Set the storage type via string.
Definition at line 366 of file Tempus_SolutionHistory_impl.hpp.
std::string Tempus::SolutionHistory< Scalar >::getStorageTypeString | ( | ) | const |
Set the string storage type.
Definition at line 391 of file Tempus_SolutionHistory_impl.hpp.
|
inline |
Return the current minimum time of the SolutionStates.
Definition at line 279 of file Tempus_SolutionHistory_decl.hpp.
|
inline |
Return the current maximum time of the SolutionStates.
Definition at line 282 of file Tempus_SolutionHistory_decl.hpp.
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 407 of file Tempus_SolutionHistory_impl.hpp.
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 427 of file Tempus_SolutionHistory_impl.hpp.
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 466 of file Tempus_SolutionHistory_impl.hpp.
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 508 of file Tempus_SolutionHistory_impl.hpp.
Teuchos::RCP< const Teuchos::ParameterList > Tempus::SolutionHistory< Scalar >::getValidParameters | ( | ) | const |
Return a valid ParameterList with current settings.
Definition at line 572 of file Tempus_SolutionHistory_impl.hpp.
Teuchos::RCP< Teuchos::ParameterList > Tempus::SolutionHistory< Scalar >::getNonconstParameterList | ( | ) |
Return a valid non-const ParameterList with current settings.
Definition at line 598 of file Tempus_SolutionHistory_impl.hpp.
|
virtual |
Reimplemented from Teuchos::Describable.
Definition at line 534 of file Tempus_SolutionHistory_impl.hpp.
|
virtual |
Reimplemented from Teuchos::Describable.
Definition at line 540 of file Tempus_SolutionHistory_impl.hpp.
void Tempus::SolutionHistory< Scalar >::setInterpolator | ( | const Teuchos::RCP< Interpolator< Scalar > > & | interpolator | ) |
Set the interpolator for this history.
Definition at line 604 of file Tempus_SolutionHistory_impl.hpp.
Teuchos::RCP< Interpolator< Scalar > > Tempus::SolutionHistory< Scalar >::getNonconstInterpolator | ( | ) |
Definition at line 618 of file Tempus_SolutionHistory_impl.hpp.
Teuchos::RCP< const Interpolator< Scalar > > Tempus::SolutionHistory< Scalar >::getInterpolator | ( | ) | const |
Definition at line 625 of file Tempus_SolutionHistory_impl.hpp.
Teuchos::RCP< Interpolator< Scalar > > Tempus::SolutionHistory< Scalar >::unSetInterpolator | ( | ) |
Unset the interpolator for this history.
Definition at line 631 of file Tempus_SolutionHistory_impl.hpp.
void Tempus::SolutionHistory< Scalar >::printHistory | ( | std::string | verb = "low" | ) | const |
Print information on States in the SolutionHistory.
Definition at line 639 of file Tempus_SolutionHistory_impl.hpp.
void Tempus::SolutionHistory< Scalar >::initialize | ( | ) | const |
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 671 of file Tempus_SolutionHistory_impl.hpp.
|
inline |
Return if SolutionHistory is initialized.
Definition at line 348 of file Tempus_SolutionHistory_decl.hpp.
|
protected |
Definition at line 351 of file Tempus_SolutionHistory_decl.hpp.
|
protected |
Definition at line 352 of file Tempus_SolutionHistory_decl.hpp.
|
protected |
Definition at line 353 of file Tempus_SolutionHistory_decl.hpp.
|
protected |
Definition at line 354 of file Tempus_SolutionHistory_decl.hpp.
|
protected |
Definition at line 355 of file Tempus_SolutionHistory_decl.hpp.
|
protected |
The state being worked on.
Definition at line 358 of file Tempus_SolutionHistory_decl.hpp.
|
mutableprotected |
Bool if SolutionHistory is initialized.
Definition at line 360 of file Tempus_SolutionHistory_decl.hpp.