Tempus  Version of the Day
Time Integration
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
Tempus_PhysicsStateCounter.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_PhysicsStateCounter_hpp
10 #define Tempus_PhysicsStateCounter_hpp
11 
12 #include "Teuchos_VerboseObject.hpp"
13 #include "Teuchos_Describable.hpp"
14 #include <string>
15 #include "Tempus_PhysicsState.hpp"
16 
17 
18 namespace Tempus_Test {
19 
20 template<class Scalar>
21 /** \brief PhysicsStateCounter is a simple PhysicsState that counts steps.
22  *
23  */
25  : virtual public Tempus::PhysicsState<Scalar>
26 {
27 public:
28 
29  /// Constructor
31  std::string pN = "Tempus::PhysicsStateCounter", int pI = 0)
32  : Tempus::PhysicsState<Scalar>(pN), physicsCounter_(pI)
33  {}
34 
35  /// Destructor
36  virtual ~PhysicsStateCounter() {}
37 
38  /// Clone constructor
39  virtual Teuchos::RCP<Tempus::PhysicsState<Scalar> > clone() const
40  {
41  Teuchos::RCP<PhysicsStateCounter<Scalar> > pSC = Teuchos::rcp(
43  this->physicsCounter_));
44  return pSC;
45  }
46 
47  //using Tempus::PhysicsState<Scalar>::copy;
48  /// This is a deep copy
49  virtual void copy(const Teuchos::RCP<const Tempus::PhysicsState<Scalar> >& pS)
50  {
51  Teuchos::RCP<const PhysicsStateCounter<Scalar> > pSC =
52  Teuchos::rcp_dynamic_cast<const PhysicsStateCounter<Scalar> >(pS);
53 
54  this->physicsName_ = pSC->getName();
55  this->physicsCounter_ = pSC->getCounter();
56  }
57 
58  /// Return counter of PhysicsStateCounter
59  virtual int getCounter() const { return physicsCounter_; }
60 
61  /// Set counter of PhysicsStateCounter
62  virtual void setCounter(int counter) { physicsCounter_ = counter; }
63 
64  /// \name Overridden from Teuchos::Describable
65  //@{
66  virtual void describe(Teuchos::FancyOStream & out,
67  const Teuchos::EVerbosityLevel verbLevel) const
68  {
69  out << this->description() << "::describe" << std::endl
70  << " physicsName = " << this->physicsName_ << std::endl
71  << " physicsCounter = " << physicsCounter_ << std::endl;
72  }
73  //@}
74 
75 protected:
76 
77  int physicsCounter_; ///< Counter for steps
78 
79 };
80 } // namespace Tempus_Test
81 #endif // Tempus_PhysicsStateCounter_hpp
PhysicsState is a simple class to hold information about the physics.
virtual int getCounter() const
Return counter of PhysicsStateCounter.
PhysicsStateCounter(std::string pN="Tempus::PhysicsStateCounter", int pI=0)
Constructor.
PhysicsState(std::string pN="Tempus::PhysicsState")
Constructor.
virtual void copy(const Teuchos::RCP< const Tempus::PhysicsState< Scalar > > &pS)
This is a deep copy.
virtual void describe(Teuchos::FancyOStream &out, const Teuchos::EVerbosityLevel verbLevel) const
PhysicsStateCounter is a simple PhysicsState that counts steps.
virtual std::string description() const
std::string physicsName_
Name of the creating Physics.
virtual Teuchos::RCP< Tempus::PhysicsState< Scalar > > clone() const
Clone constructor.
virtual void setCounter(int counter)
Set counter of PhysicsStateCounter.