|
Tempus
Version of the Day
Time Integration
|
Go to the documentation of this file.
9 #ifndef Tempus_SolutionHistory_decl_hpp
10 #define Tempus_SolutionHistory_decl_hpp
13 #include "Teuchos_VerboseObject.hpp"
14 #include "Teuchos_Describable.hpp"
15 #include "Teuchos_ParameterListAcceptorDefaultBase.hpp"
17 #include "Thyra_VectorStdOps.hpp"
19 #include "Tempus_config.hpp"
20 #include "Tempus_SolutionState.hpp"
124 template<
class Scalar>
125 class SolutionHistory
126 :
virtual public Teuchos::Describable,
127 virtual public Teuchos::VerboseObject<SolutionHistory<Scalar> >,
128 virtual public Teuchos::ParameterListAcceptor
134 SolutionHistory(Teuchos::RCP<Teuchos::ParameterList> shPL = Teuchos::null);
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;
182 Teuchos::RCP<std::vector<Teuchos::RCP<SolutionState<Scalar> > > >
186 Teuchos::RCP<SolutionState<Scalar> >
operator[](
const int i) {
187 TEUCHOS_TEST_FOR_EXCEPTION(
188 !((0 <= i) and (i < (
int)
history_->size())), std::out_of_range,
189 "Error - SolutionHistory index is out of range.\n"
190 <<
" [Min, Max] = [ 0, " <<
history_->size()<<
"]\n"
191 <<
" index = " << i <<
"\n");
196 Teuchos::RCP<const SolutionState<Scalar> >
operator[](
const int i)
const {
197 TEUCHOS_TEST_FOR_EXCEPTION(
198 !((0 <= i) and (i < (
int)
history_->size())), std::out_of_range,
199 "Error - SolutionHistory index is out of range.\n"
200 <<
" [Min, Max] = [ 0, " <<
history_->size()<<
"]\n"
201 <<
" index = " << i <<
"\n");
209 Teuchos::RCP<SolutionState<Scalar> > state;
210 if (m == 0) state=Teuchos::null;
211 else if (m == 1 or
workingState_ == Teuchos::null) state=(*history_)[m-1];
212 else if (m > 1) state=(*history_)[m-2];
268 virtual void describe(Teuchos::FancyOStream & out,
269 const Teuchos::EVerbosityLevel verbLevel)
const;
284 Teuchos::RCP<Teuchos::FancyOStream> out = this->getOStream();
285 Teuchos::OSTab ostab(out,1,
"SolutionHistory::printHistory");
287 <<
" (w - working; c - current; i - interpolated)" << std::endl;
288 for (
int i=0; i<(int)
history_->size() ; ++i) {
289 auto state = (*history_)[i];
293 else if (state->getMetaData()->getIsInterpolated() ==
true) *out<<
"i - ";
295 *out <<
"[" << i <<
"] = " << state << std::endl;
296 if (verb ==
"medium" or verb ==
"high") {
297 if (state != Teuchos::null) {
298 auto x = state->getX();
299 *out <<
" x = " << x << std::endl
300 <<
" norm(x) = " << Thyra::norm(*x) << std::endl;
303 if (verb ==
"high") {
304 (*history_)[i]->describe(*out,this->getVerbLevel());
312 Teuchos::RCP<Teuchos::ParameterList>
shPL_;
313 Teuchos::RCP<std::vector<Teuchos::RCP<SolutionState<Scalar> > > >
history_;
322 template<
class Scalar>
323 Teuchos::RCP<SolutionHistory<Scalar> >
324 solutionHistory(Teuchos::RCP<Teuchos::ParameterList> pList = Teuchos::null);
329 #endif // Tempus_SolutionHistory_decl_hpp
Teuchos::RCP< SolutionState< Scalar > > getStateTimeIndex(int index) const
Get the state with timestep index equal to "index".
Teuchos::RCP< Interpolator< Scalar > > unSetInterpolator()
Unset the interpolator for this history.
void addWorkingState(const Teuchos::RCP< SolutionState< Scalar > > &state, const bool updateTime=true)
Add a working solution state to history.
Teuchos::RCP< SolutionState< Scalar > > workingState_
The state being worked on.
Teuchos::RCP< SolutionHistory< Scalar > > solutionHistory(Teuchos::RCP< Teuchos::ParameterList > pList=Teuchos::null)
Nonmember constructor.
Keep a fix number of states.
SolutionHistory(Teuchos::RCP< Teuchos::ParameterList > shPL=Teuchos::null)
Contructor.
void setParameterList(const Teuchos::RCP< Teuchos::ParameterList > &pl)
int getCurrentIndex() const
Get the current timestep index.
Scalar minTime() const
Return the current minimum time of the SolutionStates.
void setName(std::string name)
Set this SolutionHistory's name.
Teuchos::RCP< Interpolator< Scalar > > getNonconstInterpolator()
Teuchos::RCP< SolutionState< Scalar > > interpolateState(const Scalar time) const
Generate and interpolate a new solution state at requested time.
Teuchos::RCP< SolutionState< Scalar > > getWorkingState() const
Return the working state.
int getNumStates() const
Get the number of states.
Grow the history as needed.
virtual std::string description() const
Keep the 2 newest states for undo.
Teuchos::RCP< const Interpolator< Scalar > > getInterpolator() const
Scalar maxTime() const
Return the current maximum time of the SolutionStates.
Solution state for integrators and steppers. SolutionState contains the metadata for solutions and th...
void initWorkingState()
Initialize the working state.
Teuchos::RCP< Interpolator< Scalar > > interpolator_
Teuchos::RCP< Teuchos::ParameterList > getNonconstParameterList()
Keep the single newest state.
Teuchos::RCP< SolutionState< Scalar > > findState(const Scalar time) const
Find solution state at requested time (no interpolation)
void addState(const Teuchos::RCP< SolutionState< Scalar > > &state)
Add solution state to history.
Teuchos::RCP< const SolutionState< Scalar > > operator[](const int i) const
Subscript operator (const version)
Teuchos::RCP< std::vector< Teuchos::RCP< SolutionState< Scalar > > > > history_
void printHistory(std::string verb="low") const
virtual void describe(Teuchos::FancyOStream &out, const Teuchos::EVerbosityLevel verbLevel) const
Teuchos::RCP< SolutionState< Scalar > > getStateTimeIndexN() const
Get the state with timestep index equal to n.
Teuchos::RCP< SolutionState< Scalar > > getStateTimeIndexNM2() const
Get the state with timestep index equal to n-2.
void setStorageLimit(int storage_limit)
Set the maximum storage of this history.
Teuchos::RCP< SolutionState< Scalar > > getStateTimeIndexNM1() const
Get the state with timestep index equal to n-1.
void setInterpolator(const Teuchos::RCP< Interpolator< Scalar > > &interpolator)
Set the interpolator for this history.
void setStorageType(StorageType st)
Teuchos::RCP< const Teuchos::ParameterList > getValidParameters() const
Teuchos::RCP< std::vector< Teuchos::RCP< SolutionState< Scalar > > > > getHistory() const
Get underlining history.
int getStorageLimit() const
Get the maximum storage of this history.
~SolutionHistory()
Destructor.
Teuchos::RCP< SolutionState< Scalar > > getCurrentState() const
Return the current state, i.e., the last accepted state.
Scalar getCurrentTime() const
Get the current time.
Teuchos::RCP< Teuchos::ParameterList > unsetParameterList()
Teuchos::RCP< SolutionState< Scalar > > operator[](const int i)
Subscript operator.
void removeState(const Teuchos::RCP< SolutionState< Scalar > > &state)
Remove solution state.
void promoteWorkingState()
Promote the working state to current state.
std::string getName() const
Get this SolutionHistory's name.
Teuchos::RCP< Teuchos::ParameterList > shPL_
Base strategy class for interpolation functionality.
StorageType getStorageType()