Tempus  Version of the Day
Time Integration
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Tempus_SolutionState_decl.hpp
Go to the documentation of this file.
1 // @HEADER
2 // ****************************************************************************
3 // Tempus: Copyright (2017) Sandia Corporation
4 //
5 // Distributed under BSD 3-clause license (See accompanying file Copyright.txt)
6 // ****************************************************************************
7 // @HEADER
8 
9 #ifndef Tempus_SolutionState_decl_hpp
10 #define Tempus_SolutionState_decl_hpp
11 
12 #include "Teuchos_VerboseObject.hpp"
13 #include "Teuchos_Describable.hpp"
14 
15 #include "Thyra_VectorBase.hpp"
16 #include "Thyra_ModelEvaluator.hpp"
17 
18 #include "Tempus_config.hpp"
19 #include "Tempus_SolutionStateMetaData.hpp"
20 #include "Tempus_StepperState.hpp"
21 #include "Tempus_PhysicsState.hpp"
22 
23 
24 namespace Tempus {
25 
55 template<class Scalar>
57  public Teuchos::Describable,
58  public Teuchos::VerboseObject<Tempus::SolutionState<Scalar> >
59 {
60 public:
61 
67  SolutionState();
68 
69 #ifndef TEMPUS_HIDE_DEPRECATED_CODE
72  const Teuchos::RCP<Thyra::VectorBase<Scalar> >& xdot = Teuchos::null,
73  const Teuchos::RCP<Thyra::VectorBase<Scalar> >& xddot = Teuchos::null,
74  const Teuchos::RCP<StepperState<Scalar> >& stepperState = Teuchos::null,
75  const Teuchos::RCP<PhysicsState<Scalar> >& physicsState = Teuchos::null);
76 
78  const Teuchos::RCP<const Thyra::VectorBase<Scalar> >& x,
79  const Teuchos::RCP<const Thyra::VectorBase<Scalar> >& xdot = Teuchos::null,
80  const Teuchos::RCP<const Thyra::VectorBase<Scalar> >& xddot= Teuchos::null,
81  const Teuchos::RCP<const StepperState<Scalar> >& stepperSt = Teuchos::null,
82  const Teuchos::RCP<const PhysicsState<Scalar> >& physicsSt = Teuchos::null);
83 #endif
84 
89  const Teuchos::RCP<Thyra::VectorBase<Scalar> >& xdotdot,
90  const Teuchos::RCP<StepperState<Scalar> >& stepperState,
91  const Teuchos::RCP<PhysicsState<Scalar> >& physicsState);
92 
95  const Teuchos::RCP<const Thyra::VectorBase<Scalar> >& x,
96  const Teuchos::RCP<const Thyra::VectorBase<Scalar> >& xdot,
97  const Teuchos::RCP<const Thyra::VectorBase<Scalar> >& xdotdot,
98  const Teuchos::RCP<const StepperState<Scalar> >& stepperState,
99  const Teuchos::RCP<const PhysicsState<Scalar> >& physicsState);
100 
101 #ifndef TEMPUS_HIDE_DEPRECATED_CODE
103  const Teuchos::RCP<const Thyra::ModelEvaluator<Scalar> >& model,
104  const Teuchos::RCP<StepperState<Scalar> >& stepperState = Teuchos::null,
105  const Teuchos::RCP<PhysicsState<Scalar> >& physicsState = Teuchos::null);
106 #endif
107 
110 
112  virtual Teuchos::RCP<SolutionState<Scalar> > clone() const;
113 
115  virtual void copy(const Teuchos::RCP<const SolutionState<Scalar> >& ss);
116 
118  virtual void copySolutionData(
119  const Teuchos::RCP<const SolutionState<Scalar> >& s);
120 
122  virtual ~SolutionState() {}
123 
125 
127  getMetaData() const { return metaData_; }
129  { TEUCHOS_ASSERT(metaData_nc_ != Teuchos::null);
130  return metaData_nc_; }
131 
132  virtual Scalar getTime() const {return metaData_->getTime();}
133  virtual int getIndex() const {return metaData_->getIStep();}
134  virtual Scalar getTimeStep() const {return metaData_->getDt();}
135  virtual Scalar getErrorAbs() const {return metaData_->getErrorAbs();}
136  virtual Scalar getErrorRel() const {return metaData_->getErrorRel();}
137  virtual int getOrder() const {return metaData_->getOrder();}
138  virtual int getNFailures() const {return metaData_->getNFailures();}
139  virtual int getNRunningFailures() const {return metaData_->getNRunningFailures();}
140  virtual int getNConsecutiveFailures() const {return metaData_->getNConsecutiveFailures();}
141  virtual Scalar getTolAbs() const {return metaData_->getTolAbs();}
142  virtual Scalar getTolRel() const {return metaData_->getTolRel();}
143  virtual Scalar getXNormL2() const {return metaData_->getXNormL2();}
144  virtual Scalar getDxNormL2Abs() const {return metaData_->getDxNormL2Abs();}
145  virtual Scalar getDxNormL2Rel() const {return metaData_->getDxNormL2Rel();}
146  virtual bool getComputeNorms() const {return metaData_->getComputeNorms();}
147  virtual Status getSolutionStatus() const {return metaData_->getSolutionStatus();}
148  virtual bool getOutput() const {return metaData_->getOutput();}
149  virtual bool getOutputScreen() const {return metaData_->getOutputScreen();}
150  virtual bool getIsSynced() const {return metaData_->getIsSynced();}
151  virtual bool getIsInterpolated() const {return metaData_->getIsInterpolated();}
152  virtual bool getAccuracy() const {return metaData_->getAccuracy();}
154 
156 
157  virtual void setMetaData(
159  { metaData_ = md; metaData_nc_ = Teuchos::null; }
161  { metaData_nc_ = md; metaData_ = metaData_nc_; }
162 
163  virtual void setTime(Scalar time) { TEUCHOS_ASSERT(metaData_nc_ != Teuchos::null);
164  metaData_nc_->setTime(time);}
165  virtual void setIndex(Scalar index) { TEUCHOS_ASSERT(metaData_nc_ != Teuchos::null);
166  metaData_nc_->setIStep(index);}
167  virtual void setTimeStep(Scalar dt) { TEUCHOS_ASSERT(metaData_nc_ != Teuchos::null);
168  metaData_nc_->setDt(dt);}
169  virtual void setErrorAbs(Scalar errorAbs){ TEUCHOS_ASSERT(metaData_nc_ != Teuchos::null);
170  metaData_nc_->setErrorAbs(errorAbs);}
171  virtual void setErrorRel(Scalar errorRel){ TEUCHOS_ASSERT(metaData_nc_ != Teuchos::null);
172  metaData_nc_->setErrorRel(errorRel);}
173  virtual void setOrder(int order) { TEUCHOS_ASSERT(metaData_nc_ != Teuchos::null);
174  metaData_nc_->setOrder(order); }
175 
176  virtual void setNFailures(int nFailures) { TEUCHOS_ASSERT(metaData_nc_ != Teuchos::null);
177  metaData_nc_->setNFailures(nFailures); }
178  virtual void setNRunningFailures(int nFailures) { TEUCHOS_ASSERT(metaData_nc_ != Teuchos::null);
179  metaData_nc_->setNRunningFailures(nFailures); }
180  virtual void setNConsecutiveFailures(int nConsecutiveFailures)
181  { TEUCHOS_ASSERT(metaData_nc_ != Teuchos::null);
182  metaData_nc_->setNConsecutiveFailures(nConsecutiveFailures); }
183  virtual void setTolRel (Scalar tolRel){ TEUCHOS_ASSERT(metaData_nc_ != Teuchos::null);
184  metaData_nc_->setTolRel(tolRel); }
185  virtual void setTolAbs (Scalar tolAbs){ TEUCHOS_ASSERT(metaData_nc_ != Teuchos::null);
186  metaData_nc_->setTolAbs(tolAbs); }
187 
188  virtual void setXNormL2 (Scalar xNormL2){ TEUCHOS_ASSERT(metaData_nc_ != Teuchos::null);
189  metaData_nc_->setXNormL2(xNormL2); }
190  virtual void setDxNormL2Rel (Scalar dxNormL2Rel){ TEUCHOS_ASSERT(metaData_nc_ != Teuchos::null);
191  metaData_nc_->setDxNormL2Rel(dxNormL2Rel); }
192  virtual void setDxNormL2Abs (Scalar dxNormL2Abs){ TEUCHOS_ASSERT(metaData_nc_ != Teuchos::null);
193  metaData_nc_->setDxNormL2Abs(dxNormL2Abs); }
194  virtual void setComputeNorms(bool computeNorms) { TEUCHOS_ASSERT(metaData_nc_ != Teuchos::null);
195  metaData_nc_->setComputeNorms(computeNorms); }
196 
197  virtual void setSolutionStatus(Status s) { TEUCHOS_ASSERT(metaData_nc_ != Teuchos::null);
198  metaData_nc_->setSolutionStatus(s); }
199  virtual void setSolutionStatus(const Thyra::SolveStatus<Scalar> sStatus)
200  {
202  metaData_nc_->setSolutionStatus(Status::PASSED);
203  else
204  metaData_nc_->setSolutionStatus(Status::FAILED);
205  }
206 
207  virtual void setOutput(bool output) { TEUCHOS_ASSERT(metaData_nc_ != Teuchos::null);
208  metaData_nc_->setOutput(output); }
209  virtual void setOutputScreen(bool output) { TEUCHOS_ASSERT(metaData_nc_ != Teuchos::null);
210  metaData_nc_->setOutputScreen(output); }
211  virtual void setIsSynced(bool isSynced) { TEUCHOS_ASSERT(metaData_nc_ != Teuchos::null);
212  metaData_nc_->setIsSynced(isSynced); }
213  virtual void setIsInterpolated(bool isInterpolated) { TEUCHOS_ASSERT(metaData_nc_ != Teuchos::null);
214  metaData_nc_->setIsInterpolated(isInterpolated); }
215  virtual void setAccuracy(bool accuracy) { TEUCHOS_ASSERT(metaData_nc_ != Teuchos::null);
216  metaData_nc_->setAccuracy(accuracy); }
218 
220 
222  { TEUCHOS_ASSERT(x_nc_ != Teuchos::null);
223  return x_nc_; }
225  { return x_; }
227  { return xdot_nc_; }
229  { return xdot_; }
231  { return xdotdot_nc_; }
233  { return xdotdot_; }
234 
236  { TEUCHOS_ASSERT(stepperState_nc_ != Teuchos::null);
237  return stepperState_nc_; }
239  { return stepperState_; }
240 
242  { return physicsState_nc_; }
244  { return physicsState_; }
246 
248 
250  { x_nc_ = x; x_ = x; }
252  { x_nc_ = Teuchos::null; x_ = x; }
254  { xdot_nc_ = xdot; xdot_ = xdot; }
255  virtual void setXDot(Teuchos::RCP<const Thyra::VectorBase<Scalar> > xdot)
256  { xdot_nc_ = Teuchos::null; xdot_ = xdot; }
258  { xdotdot_nc_ = xdotdot; xdotdot_ = xdotdot; }
259  virtual void setXDotDot(Teuchos::RCP<const Thyra::VectorBase<Scalar> > xdotdot)
260  { xdotdot_nc_ = Teuchos::null; xdotdot_ = xdotdot; }
261 
263  { stepperState_nc_ = ss; stepperState_ = ss; }
265  { stepperState_nc_ = Teuchos::null; stepperState_ = ss; }
266 
268  { physicsState_nc_ = ps; physicsState_ = ps; }
270  { physicsState_nc_ = Teuchos::null; physicsState_ = ps; }
272 
273 
275 
276  bool operator< (const SolutionState<Scalar>& ss) const;
278 
280  bool operator<= (const SolutionState<Scalar>& ss) const;
281 
283  bool operator< (const Scalar& t) const;
284 
286  bool operator<= (const Scalar& t) const;
287 
289  bool operator> (const SolutionState<Scalar>& ss) const;
290 
292  bool operator>= (const SolutionState<Scalar>& ss) const;
293 
295  bool operator> (const Scalar& t) const;
296 
298  bool operator>= (const Scalar& t) const;
299 
301  bool operator== (const SolutionState<Scalar>& ss) const;
302 
304  bool operator== (const Scalar& t) const;
306 
308 
309  virtual std::string description() const;
310  virtual void describe(Teuchos::FancyOStream &out,
311  const Teuchos::EVerbosityLevel verbLevel) const;
313 
315  virtual void computeNorms(
316  const Teuchos::RCP<const SolutionState<Scalar> >& ssIn = Teuchos::null);
317 
318 private:
319  // Member Data
320 
324 
328 
332 
336 
340 
344 
345 };
346 
347 
349 template<class Scalar>
353  const Teuchos::RCP<Thyra::VectorBase<Scalar> >& xdot = Teuchos::null,
354  const Teuchos::RCP<Thyra::VectorBase<Scalar> >& xdotdot = Teuchos::null);
355 
357 template<class Scalar>
360  const Teuchos::RCP<const Thyra::VectorBase<Scalar> >& x,
361  const Teuchos::RCP<const Thyra::VectorBase<Scalar> >& xdot =Teuchos::null,
362  const Teuchos::RCP<const Thyra::VectorBase<Scalar> >& xdotdot =Teuchos::null);
363 
365 template<class Scalar>
368  const Teuchos::RCP<const Thyra::ModelEvaluator<Scalar> >& model,
369  const Teuchos::RCP<StepperState<Scalar> >& stepperState = Teuchos::null,
370  const Teuchos::RCP<PhysicsState<Scalar> >& physicsState = Teuchos::null);
371 
372 
373 
374 } // namespace Tempus
375 
376 #endif // Tempus_SolutionState_decl_hpp
Teuchos::RCP< SolutionState< Scalar > > createSolutionStateX(const Teuchos::RCP< Thyra::VectorBase< Scalar > > &x, const Teuchos::RCP< Thyra::VectorBase< Scalar > > &xdot=Teuchos::null, const Teuchos::RCP< Thyra::VectorBase< Scalar > > &xdotdot=Teuchos::null)
Nonmember constructor from non-const solution vectors, x.
PhysicsState is a simple class to hold information about the physics.
virtual Teuchos::RCP< const Thyra::VectorBase< Scalar > > getXDot() const
virtual void setXNormL2(Scalar xNormL2)
virtual Teuchos::RCP< StepperState< Scalar > > getStepperState()
virtual int getNRunningFailures() const
virtual void setNFailures(int nFailures)
virtual void setStepperState(const Teuchos::RCP< StepperState< Scalar > > &ss)
Teuchos::RCP< Thyra::VectorBase< Scalar > > xdot_nc_
virtual bool getOutputScreen() const
virtual Teuchos::RCP< Thyra::VectorBase< Scalar > > getXDot()
virtual void setDxNormL2Rel(Scalar dxNormL2Rel)
virtual void setXDot(Teuchos::RCP< const Thyra::VectorBase< Scalar > > xdot)
virtual void setErrorAbs(Scalar errorAbs)
virtual Scalar getTolRel() const
Teuchos::RCP< const SolutionStateMetaData< Scalar > > metaData_
Meta Data for the solution state.
virtual void setTolAbs(Scalar tolAbs)
virtual void setStepperState(Teuchos::RCP< StepperState< Scalar > > &ss)
virtual Scalar getTolAbs() const
virtual int getNConsecutiveFailures() const
virtual void setIsSynced(bool isSynced)
virtual void setIsInterpolated(bool isInterpolated)
virtual void setXDot(Teuchos::RCP< Thyra::VectorBase< Scalar > > xdot)
Teuchos::RCP< PhysicsState< Scalar > > physicsState_nc_
virtual Teuchos::RCP< const Thyra::VectorBase< Scalar > > getX() const
Teuchos::RCP< const PhysicsState< Scalar > > physicsState_
PhysicsState for this SolutionState.
virtual Scalar getXNormL2() const
virtual void setDxNormL2Abs(Scalar dxNormL2Abs)
Teuchos::RCP< const Thyra::VectorBase< Scalar > > xdotdot_
Second time derivative of the solution.
virtual Teuchos::RCP< PhysicsState< Scalar > > getPhysicsState()
Teuchos::RCP< Thyra::VectorBase< Scalar > > xdotdot_nc_
StepperState is a simple class to hold state information about the stepper.
virtual void setIndex(Scalar index)
virtual Scalar getTime() const
bool operator>(const SolutionState< Scalar > &ss) const
Less than comparison for sorting based on time.
Status
Status for the Integrator, the Stepper and the SolutionState.
Teuchos::RCP< const StepperState< Scalar > > stepperState_
StepperState for this SolutionState.
virtual void setSolutionStatus(const Thyra::SolveStatus< Scalar > sStatus)
virtual void setTimeStep(Scalar dt)
virtual void setErrorRel(Scalar errorRel)
virtual void setNRunningFailures(int nFailures)
virtual void copySolutionData(const Teuchos::RCP< const SolutionState< Scalar > > &s)
Deep copy solution data, but keep metaData untouched.
virtual void describe(Teuchos::FancyOStream &out, const Teuchos::EVerbosityLevel verbLevel) const
virtual Teuchos::RCP< Thyra::VectorBase< Scalar > > getXDotDot()
virtual void setSolutionStatus(Status s)
virtual Teuchos::RCP< const PhysicsState< Scalar > > getPhysicsState() const
SolutionState()
Default Constructor – Not meant for immediate adding to SolutionHistory. This constructor does not se...
virtual void setX(Teuchos::RCP< const Thyra::VectorBase< Scalar > > x)
virtual Teuchos::RCP< const StepperState< Scalar > > getStepperState() const
virtual void setNConsecutiveFailures(int nConsecutiveFailures)
virtual bool getIsSynced() const
virtual Scalar getDxNormL2Rel() const
bool operator>=(const SolutionState< Scalar > &ss) const
Less than comparison for sorting based on time.
virtual bool getComputeNorms() const
Teuchos::RCP< SolutionState< Scalar > > createSolutionStateME(const Teuchos::RCP< const Thyra::ModelEvaluator< Scalar > > &model, const Teuchos::RCP< StepperState< Scalar > > &stepperState=Teuchos::null, const Teuchos::RCP< PhysicsState< Scalar > > &physicsState=Teuchos::null)
Nonmember constructor from Thyra ModelEvaluator.
virtual void setXDotDot(Teuchos::RCP< Thyra::VectorBase< Scalar > > xdotdot)
Teuchos::RCP< const Thyra::VectorBase< Scalar > > x_
Solution.
ESolveStatus solveStatus
Teuchos::RCP< Thyra::VectorBase< Scalar > > x_nc_
bool operator==(const SolutionState< Scalar > &ss) const
Equality comparison for matching.
Teuchos::RCP< StepperState< Scalar > > stepperState_nc_
virtual Teuchos::RCP< SolutionStateMetaData< Scalar > > getMetaData()
virtual Scalar getErrorAbs() const
virtual void setAccuracy(bool accuracy)
virtual ~SolutionState()
Destructor.
virtual void setOutputScreen(bool output)
bool operator<=(const SolutionState< Scalar > &ss) const
Less than comparison for sorting based on time.
virtual Teuchos::RCP< SolutionState< Scalar > > clone() const
This is a deep copy constructor.
virtual void computeNorms(const Teuchos::RCP< const SolutionState< Scalar > > &ssIn=Teuchos::null)
Compute the solution norms, and solution change from ssIn, if provided.
virtual Teuchos::RCP< const SolutionStateMetaData< Scalar > > getMetaData() const
bool operator<(const SolutionState< Scalar > &ss) const
Less than comparison for sorting based on time.
virtual Scalar getDxNormL2Abs() const
virtual Scalar getErrorRel() const
virtual bool getIsInterpolated() const
virtual void setOrder(int order)
virtual bool getAccuracy() const
virtual void setX(Teuchos::RCP< Thyra::VectorBase< Scalar > > x)
virtual void setPhysicsState(const Teuchos::RCP< PhysicsState< Scalar > > &ps)
virtual void setXDotDot(Teuchos::RCP< const Thyra::VectorBase< Scalar > > xdotdot)
#define TEUCHOS_ASSERT(assertion_test)
virtual void setMetaData(Teuchos::RCP< SolutionStateMetaData< Scalar > > md)
virtual Status getSolutionStatus() const
virtual void setMetaData(Teuchos::RCP< const SolutionStateMetaData< Scalar > > md)
virtual Scalar getTimeStep() const
virtual Teuchos::RCP< Thyra::VectorBase< Scalar > > getX()
virtual void setTime(Scalar time)
virtual void setPhysicsState(Teuchos::RCP< PhysicsState< Scalar > > &ps)
virtual void setComputeNorms(bool computeNorms)
virtual Teuchos::RCP< const Thyra::VectorBase< Scalar > > getXDotDot() const
Teuchos::RCP< const Thyra::VectorBase< Scalar > > xdot_
Time derivative of the solution.
virtual void setOutput(bool output)
virtual std::string description() const
Solution state for integrators and steppers. SolutionState contains the metadata for solutions and th...
virtual void setTolRel(Scalar tolRel)
Teuchos::RCP< SolutionStateMetaData< Scalar > > metaData_nc_
virtual void copy(const Teuchos::RCP< const SolutionState< Scalar > > &ss)
This is a deep copy.