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: Time Integration and Sensitivity Analysis Package
4 //
5 // Copyright 2017 NTESS and the Tempus contributors.
6 // SPDX-License-Identifier: BSD-3-Clause
7 // *****************************************************************************
8 //@HEADER
9 
10 #ifndef Tempus_SolutionState_decl_hpp
11 #define Tempus_SolutionState_decl_hpp
12 
13 #include "Teuchos_VerboseObject.hpp"
14 #include "Teuchos_Describable.hpp"
15 
16 #include "Thyra_VectorBase.hpp"
17 #include "Thyra_ModelEvaluator.hpp"
18 
19 #include "Tempus_config.hpp"
20 #include "Tempus_SolutionStateMetaData.hpp"
21 #include "Tempus_StepperState.hpp"
22 #include "Tempus_PhysicsState.hpp"
23 
24 namespace Tempus {
25 
136 template <class Scalar>
138  : public Teuchos::Describable,
139  public Teuchos::VerboseObject<Tempus::SolutionState<Scalar> > {
140  public:
146  SolutionState();
147 
151  const Teuchos::RCP<Thyra::VectorBase<Scalar> >& xdotdot,
152  const Teuchos::RCP<StepperState<Scalar> >& stepperState,
153  const Teuchos::RCP<PhysicsState<Scalar> >& physicsState);
154 
156  const Teuchos::RCP<const Thyra::VectorBase<Scalar> >& x,
157  const Teuchos::RCP<const Thyra::VectorBase<Scalar> >& xdot,
158  const Teuchos::RCP<const Thyra::VectorBase<Scalar> >& xdotdot,
159  const Teuchos::RCP<const StepperState<Scalar> >& stepperState,
160  const Teuchos::RCP<const PhysicsState<Scalar> >& physicsState);
161 
164 
166  virtual Teuchos::RCP<SolutionState<Scalar> > clone() const;
167 
169  virtual void copy(const Teuchos::RCP<const SolutionState<Scalar> >& ss);
170 
172  virtual void copySolutionData(
173  const Teuchos::RCP<const SolutionState<Scalar> >& s);
174 
176  virtual ~SolutionState() {}
177 
179 
181  {
182  return metaData_;
183  }
185  {
186  TEUCHOS_ASSERT(metaData_nc_ != Teuchos::null);
187  return metaData_nc_;
188  }
189 
190  virtual Scalar getTime() const { return metaData_->getTime(); }
191  virtual int getIndex() const { return metaData_->getIStep(); }
192  virtual Scalar getTimeStep() const { return metaData_->getDt(); }
193  virtual Scalar getErrorAbs() const { return metaData_->getErrorAbs(); }
194  virtual Scalar getErrorRel() const { return metaData_->getErrorRel(); }
195  virtual Scalar getErrorRelNm1() const { return metaData_->getErrorRelNm1(); }
196  virtual Scalar getErrorRelNm2() const { return metaData_->getErrorRelNm2(); }
197  virtual int getOrder() const { return metaData_->getOrder(); }
198  virtual int getNFailures() const { return metaData_->getNFailures(); }
199  virtual int getNRunningFailures() const
200  {
201  return metaData_->getNRunningFailures();
202  }
203  virtual int getNConsecutiveFailures() const
204  {
205  return metaData_->getNConsecutiveFailures();
206  }
207  virtual Scalar getTolAbs() const { return metaData_->getTolAbs(); }
208  virtual Scalar getTolRel() const { return metaData_->getTolRel(); }
209  virtual Scalar getXNormL2() const { return metaData_->getXNormL2(); }
210  virtual Scalar getDxNormL2Abs() const { return metaData_->getDxNormL2Abs(); }
211  virtual Scalar getDxNormL2Rel() const { return metaData_->getDxNormL2Rel(); }
212  virtual bool getComputeNorms() const { return metaData_->getComputeNorms(); }
213  virtual Status getSolutionStatus() const
214  {
215  return metaData_->getSolutionStatus();
216  }
217  virtual bool getOutput() const { return metaData_->getOutput(); }
218  virtual bool getOutputScreen() const { return metaData_->getOutputScreen(); }
219  virtual bool getIsSynced() const { return metaData_->getIsSynced(); }
220  virtual bool getIsInterpolated() const
221  {
222  return metaData_->getIsInterpolated();
223  }
224  virtual bool getAccuracy() const { return metaData_->getAccuracy(); }
226 
228 
229  virtual void setMetaData(
231  {
232  metaData_ = md;
233  metaData_nc_ = Teuchos::null;
234  }
236  {
237  metaData_nc_ = md;
239  }
240 
241  virtual void setTime(Scalar time)
242  {
243  TEUCHOS_ASSERT(metaData_nc_ != Teuchos::null);
244  metaData_nc_->setTime(time);
245  }
246  virtual void setIndex(Scalar index)
247  {
248  TEUCHOS_ASSERT(metaData_nc_ != Teuchos::null);
249  metaData_nc_->setIStep(index);
250  }
251  virtual void setTimeStep(Scalar dt)
252  {
253  TEUCHOS_ASSERT(metaData_nc_ != Teuchos::null);
254  metaData_nc_->setDt(dt);
255  }
256  virtual void setErrorAbs(Scalar errorAbs)
257  {
258  TEUCHOS_ASSERT(metaData_nc_ != Teuchos::null);
259  metaData_nc_->setErrorAbs(errorAbs);
260  }
261  virtual void setErrorRel(Scalar errorRel)
262  {
263  TEUCHOS_ASSERT(metaData_nc_ != Teuchos::null);
264  metaData_nc_->setErrorRel(errorRel);
265  }
266  virtual void setOrder(int order)
267  {
268  TEUCHOS_ASSERT(metaData_nc_ != Teuchos::null);
269  metaData_nc_->setOrder(order);
270  }
271 
272  virtual void setNFailures(int nFailures)
273  {
274  TEUCHOS_ASSERT(metaData_nc_ != Teuchos::null);
275  metaData_nc_->setNFailures(nFailures);
276  }
277  virtual void setNRunningFailures(int nFailures)
278  {
279  TEUCHOS_ASSERT(metaData_nc_ != Teuchos::null);
280  metaData_nc_->setNRunningFailures(nFailures);
281  }
282  virtual void setNConsecutiveFailures(int nConsecutiveFailures)
283  {
284  TEUCHOS_ASSERT(metaData_nc_ != Teuchos::null);
285  metaData_nc_->setNConsecutiveFailures(nConsecutiveFailures);
286  }
287  virtual void setTolRel(Scalar tolRel)
288  {
289  TEUCHOS_ASSERT(metaData_nc_ != Teuchos::null);
290  metaData_nc_->setTolRel(tolRel);
291  }
292  virtual void setTolAbs(Scalar tolAbs)
293  {
294  TEUCHOS_ASSERT(metaData_nc_ != Teuchos::null);
295  metaData_nc_->setTolAbs(tolAbs);
296  }
297 
298  virtual void setXNormL2(Scalar xNormL2)
299  {
300  TEUCHOS_ASSERT(metaData_nc_ != Teuchos::null);
301  metaData_nc_->setXNormL2(xNormL2);
302  }
303  virtual void setDxNormL2Rel(Scalar dxNormL2Rel)
304  {
305  TEUCHOS_ASSERT(metaData_nc_ != Teuchos::null);
306  metaData_nc_->setDxNormL2Rel(dxNormL2Rel);
307  }
308  virtual void setDxNormL2Abs(Scalar dxNormL2Abs)
309  {
310  TEUCHOS_ASSERT(metaData_nc_ != Teuchos::null);
311  metaData_nc_->setDxNormL2Abs(dxNormL2Abs);
312  }
313  virtual void setComputeNorms(bool computeNorms)
314  {
315  TEUCHOS_ASSERT(metaData_nc_ != Teuchos::null);
316  metaData_nc_->setComputeNorms(computeNorms);
317  }
318 
319  virtual void setSolutionStatus(Status s)
320  {
321  TEUCHOS_ASSERT(metaData_nc_ != Teuchos::null);
322  metaData_nc_->setSolutionStatus(s);
323  }
324  virtual void setSolutionStatus(const Thyra::SolveStatus<Scalar> sStatus)
325  {
327  metaData_nc_->setSolutionStatus(Status::PASSED);
328  else
329  metaData_nc_->setSolutionStatus(Status::FAILED);
330  }
331 
332  virtual void setOutput(bool output)
333  {
334  TEUCHOS_ASSERT(metaData_nc_ != Teuchos::null);
335  metaData_nc_->setOutput(output);
336  }
337  virtual void setOutputScreen(bool output)
338  {
339  TEUCHOS_ASSERT(metaData_nc_ != Teuchos::null);
340  metaData_nc_->setOutputScreen(output);
341  }
342  virtual void setIsSynced(bool isSynced)
343  {
344  TEUCHOS_ASSERT(metaData_nc_ != Teuchos::null);
345  metaData_nc_->setIsSynced(isSynced);
346  }
347  virtual void setIsInterpolated(bool isInterpolated)
348  {
349  TEUCHOS_ASSERT(metaData_nc_ != Teuchos::null);
350  metaData_nc_->setIsInterpolated(isInterpolated);
351  }
352  virtual void setAccuracy(bool accuracy)
353  {
354  TEUCHOS_ASSERT(metaData_nc_ != Teuchos::null);
355  metaData_nc_->setAccuracy(accuracy);
356  }
358 
360 
362  {
363  TEUCHOS_ASSERT(x_nc_ != Teuchos::null);
364  return x_nc_;
365  }
367  {
368  return x_;
369  }
371  {
372  return xdot_nc_;
373  }
375  {
376  return xdot_;
377  }
379  {
380  return xdotdot_nc_;
381  }
383  {
384  return xdotdot_;
385  }
386 
388  {
389  TEUCHOS_ASSERT(stepperState_nc_ != Teuchos::null);
390  return stepperState_nc_;
391  }
393  {
394  return stepperState_;
395  }
396 
398  {
399  return physicsState_nc_;
400  }
402  {
403  return physicsState_;
404  }
406 
408 
410  {
411  x_nc_ = x;
412  x_ = x;
413  }
415  {
416  x_nc_ = Teuchos::null;
417  x_ = x;
418  }
420  {
421  xdot_nc_ = xdot;
422  xdot_ = xdot;
423  }
424  virtual void setXDot(Teuchos::RCP<const Thyra::VectorBase<Scalar> > xdot)
425  {
426  xdot_nc_ = Teuchos::null;
427  xdot_ = xdot;
428  }
430  {
431  xdotdot_nc_ = xdotdot;
432  xdotdot_ = xdotdot;
433  }
434  virtual void setXDotDot(
435  Teuchos::RCP<const Thyra::VectorBase<Scalar> > xdotdot)
436  {
437  xdotdot_nc_ = Teuchos::null;
438  xdotdot_ = xdotdot;
439  }
440 
442  {
443  stepperState_nc_ = ss;
444  stepperState_ = ss;
445  }
447  {
448  stepperState_nc_ = Teuchos::null;
449  stepperState_ = ss;
450  }
451 
453  {
454  physicsState_nc_ = ps;
455  physicsState_ = ps;
456  }
458  {
459  physicsState_nc_ = Teuchos::null;
460  physicsState_ = ps;
461  }
463 
465 
466  bool operator<(const SolutionState<Scalar>& ss) const;
468 
470  bool operator<=(const SolutionState<Scalar>& ss) const;
471 
473  bool operator<(const Scalar& t) const;
474 
476  bool operator<=(const Scalar& t) const;
477 
479  bool operator>(const SolutionState<Scalar>& ss) const;
480 
482  bool operator>=(const SolutionState<Scalar>& ss) const;
483 
485  bool operator>(const Scalar& t) const;
486 
488  bool operator>=(const Scalar& t) const;
489 
491  bool operator==(const SolutionState<Scalar>& ss) const;
492 
494  bool operator==(const Scalar& t) const;
496 
498 
499  virtual std::string description() const;
500  virtual void describe(Teuchos::FancyOStream& out,
501  const Teuchos::EVerbosityLevel verbLevel) const;
503 
505  virtual void computeNorms(
506  const Teuchos::RCP<const SolutionState<Scalar> >& ssIn = Teuchos::null);
507 
508  private:
509  // Member Data
510 
514 
518 
522 
526 
530 
534 };
535 
537 template <class Scalar>
540  const Teuchos::RCP<Thyra::VectorBase<Scalar> >& xdot = Teuchos::null,
541  const Teuchos::RCP<Thyra::VectorBase<Scalar> >& xdotdot = Teuchos::null);
542 
544 template <class Scalar>
546  const Teuchos::RCP<const Thyra::VectorBase<Scalar> >& x,
547  const Teuchos::RCP<const Thyra::VectorBase<Scalar> >& xdot = Teuchos::null,
548  const Teuchos::RCP<const Thyra::VectorBase<Scalar> >& xdotdot =
549  Teuchos::null);
550 
552 template <class Scalar>
554  const Teuchos::RCP<const Thyra::ModelEvaluator<Scalar> >& model,
555  const Teuchos::RCP<StepperState<Scalar> >& stepperState = Teuchos::null,
556  const Teuchos::RCP<PhysicsState<Scalar> >& physicsState = Teuchos::null);
557 
558 } // namespace Tempus
559 
560 #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 Scalar getErrorRelNm2() const
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 Scalar getErrorRelNm1() const
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
Greater 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
Greater than or equal to 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 or equal to 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.
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.