9#ifndef Tempus_SolutionHistory_decl_hpp
10#define Tempus_SolutionHistory_decl_hpp
12#include "Tempus_config.hpp"
13#include "Tempus_SolutionState.hpp"
117template<
class Scalar>
119 :
virtual public Teuchos::Describable,
120 virtual public Teuchos::VerboseObject<SolutionHistory<Scalar> >
142 bool doChecks =
true);
146 const bool updateTime =
true);
155 Teuchos::RCP<SolutionState<Scalar> >
findState(
const Scalar time)
const;
158 Teuchos::RCP<SolutionState<Scalar> >
interpolateState(
const Scalar time)
const;
186 Teuchos::RCP<std::vector<Teuchos::RCP<SolutionState<Scalar> > > >
195 Teuchos::RCP<SolutionState<Scalar> >
operator[](
const int i) {
196 TEUCHOS_TEST_FOR_EXCEPTION(
197 !((0 <= i) && (i < (
int)
history_->size())), std::out_of_range,
198 "Error - SolutionHistory index is out of range.\n"
199 <<
" [Min, Max] = [ 0, " <<
history_->size()<<
"]\n"
200 <<
" index = " << i <<
"\n");
205 Teuchos::RCP<const SolutionState<Scalar> >
operator[](
const int i)
const {
206 TEUCHOS_TEST_FOR_EXCEPTION(
207 !((0 <= i) && (i < (
int)
history_->size())), std::out_of_range,
208 "Error - SolutionHistory index is out of range.\n"
209 <<
" [Min, Max] = [ 0, " <<
history_->size()<<
"]\n"
210 <<
" index = " << i <<
"\n");
218 Teuchos::RCP<SolutionState<Scalar> > state;
219 if (m == 0) state=Teuchos::null;
220 else if (m == 1 ||
workingState_ == Teuchos::null) state=(*history_)[m-1];
221 else if (m > 1) state=(*history_)[m-2];
229 Teuchos::RCP<Teuchos::FancyOStream> out = this->getOStream();
230 Teuchos::OSTab ostab(out,1,
"SolutionHistory::getWorkingState()");
231 *out <<
"Warning - WorkingState is null and likely has been promoted. "
232 <<
"You might want to call getCurrentState() instead.\n"
293 Teuchos::RCP<SolutionState<Scalar> >
getStateTimeIndex(
int index,
bool warn =
true)
const;
305 virtual void describe(Teuchos::FancyOStream & out,
306 const Teuchos::EVerbosityLevel verbLevel)
const;
338 Teuchos::RCP<std::vector<Teuchos::RCP<SolutionState<Scalar> > > >
history_;
351template<
class Scalar>
352Teuchos::RCP<SolutionHistory<Scalar> >
356template<
class Scalar>
357Teuchos::RCP<SolutionHistory<Scalar> >
361template<
class Scalar>
362Teuchos::RCP<SolutionHistory<Scalar> >
366template<
class Scalar>
367Teuchos::RCP<SolutionHistory<Scalar> >
Base strategy class for interpolation functionality.
SolutionHistory is basically a container of SolutionStates. SolutionHistory maintains a collection of...
std::string getName() const
Get this SolutionHistory's name.
Teuchos::RCP< SolutionState< Scalar > > getStateTimeIndex(int index, bool warn=true) const
Get the state with timestep index equal to "index".
Teuchos::RCP< std::vector< Teuchos::RCP< SolutionState< Scalar > > > > getHistory() const
Get underlining history.
void setName(std::string name)
Set this SolutionHistory's name.
Teuchos::RCP< SolutionState< Scalar > > getStateTimeIndexNM1(bool warn=true) const
Get the state with timestep index equal to n-1.
void initWorkingState()
Initialize the working state.
Teuchos::RCP< SolutionState< Scalar > > workingState_
The state being worked on.
Teuchos::RCP< const Teuchos::ParameterList > getValidParameters() const
Return a valid ParameterList with current settings.
Scalar minTime() const
Return the current minimum time of the SolutionStates.
Teuchos::RCP< const Interpolator< Scalar > > getInterpolator() const
bool isInitialized()
Return if SolutionHistory is initialized.
virtual std::string description() const
void addState(const Teuchos::RCP< SolutionState< Scalar > > &state, bool doChecks=true)
Add solution state to history.
Teuchos::RCP< SolutionState< Scalar > > getStateTimeIndexNM2(bool warn=true) const
Get the state with timestep index equal to n-2.
Teuchos::RCP< SolutionState< Scalar > > operator[](const int i)
Subscript operator.
void setStorageType(StorageType st)
Set the storage type via enum.
bool isInitialized_
Bool if SolutionHistory is initialized.
void setHistory(Teuchos::RCP< std::vector< Teuchos::RCP< SolutionState< Scalar > > > > h)
Set underlining history.
Scalar getCurrentTime() const
Get the current time.
Teuchos::RCP< Teuchos::ParameterList > getNonconstParameterList()
Return a valid non-const ParameterList with current settings.
std::string getStorageTypeString() const
Set the string storage type.
virtual void describe(Teuchos::FancyOStream &out, const Teuchos::EVerbosityLevel verbLevel) const
void copy(Teuchos::RCP< const SolutionHistory< Scalar > > sh)
Make a shallow copy of SolutionHistory (i.e., only RCPs to states and interpolator).
StorageType getStorageType() const
Get the enum storage type.
Teuchos::RCP< Interpolator< Scalar > > unSetInterpolator()
Unset the interpolator for this history.
int getNumStates() const
Get the number of states.
void initialize() const
Initialize SolutionHistory.
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.
Teuchos::RCP< SolutionState< Scalar > > getWorkingState(bool warn=true) const
Return the working state.
Teuchos::RCP< Interpolator< Scalar > > getNonconstInterpolator()
void setStorageTypeString(std::string st)
Set the storage type via string.
Teuchos::RCP< SolutionState< Scalar > > findState(const Scalar time) const
Find solution state at requested time (no interpolation)
void printHistory(std::string verb="low") const
Print information on States in the SolutionHistory.
Teuchos::RCP< SolutionState< Scalar > > getCurrentState() const
Return the current state, i.e., the last accepted state.
Teuchos::RCP< SolutionState< Scalar > > interpolateState(const Scalar time) const
Generate and interpolate a new solution state at requested time.
void removeState(const Teuchos::RCP< SolutionState< Scalar > > &state)
Remove solution state.
void addWorkingState(const Teuchos::RCP< SolutionState< Scalar > > &state, const bool updateTime=true)
Add a working solution state to history.
Teuchos::RCP< SolutionState< Scalar > > getStateTimeIndexN(bool warn=true) const
Get the state with timestep index equal to n.
Teuchos::RCP< std::vector< Teuchos::RCP< SolutionState< Scalar > > > > history_
void setInterpolator(const Teuchos::RCP< Interpolator< Scalar > > &interpolator)
Set the interpolator for this history.
~SolutionHistory()
Destructor.
Teuchos::RCP< const SolutionState< Scalar > > operator[](const int i) const
Subscript operator (const version)
Teuchos::RCP< Interpolator< Scalar > > interpolator_
SolutionHistory()
Default Contructor.
void clear()
Clear the history.
Scalar maxTime() const
Return the current maximum time of the SolutionStates.
void promoteWorkingState()
Promote the working state to current state.
Solution state for integrators and steppers. SolutionState contains the metadata for solutions and th...
@ STORAGE_TYPE_STATIC
Keep a fix number of states.
@ STORAGE_TYPE_UNLIMITED
Grow the history as needed.
@ STORAGE_TYPE_INVALID
Invalid storage type.
@ STORAGE_TYPE_UNDO
Keep the 2 newest states for undo.
@ STORAGE_TYPE_KEEP_NEWEST
Keep the single newest state.
Teuchos::RCP< SolutionHistory< Scalar > > createSolutionHistoryPL(Teuchos::RCP< Teuchos::ParameterList > pList)
Nonmember constructor from a ParameterList.
Teuchos::RCP< SolutionHistory< Scalar > > createSolutionHistoryState(const Teuchos::RCP< SolutionState< Scalar > > &state)
Nonmember contructor from a SolutionState.
Teuchos::RCP< SolutionHistory< Scalar > > createSolutionHistory()
Nonmember constructor.
Teuchos::RCP< SolutionHistory< Scalar > > createSolutionHistoryME(const Teuchos::RCP< const Thyra::ModelEvaluator< Scalar > > &model)
Nonmember contructor from a Thyra ModelEvaluator.