Tempus  Version of the Day
Time Integration
Tempus_TimeEventBase.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_TimeEventBase_decl_hpp
10 #define Tempus_TimeEventBase_decl_hpp
11 
12 // Teuchos
13 #include "Teuchos_Time.hpp"
14 #include "Teuchos_VerboseObject.hpp"
15 
16 #include "Tempus_config.hpp"
17 
18 namespace Tempus {
19 
20 
34 template<class Scalar>
36 {
37 public:
38 
41  : name_("TimeEventBase"),
42  defaultTime_ (-std::numeric_limits<Scalar>::max()*1.0e-16),
43  defaultTol_ ( std::numeric_limits<Scalar>::min()),
44  defaultIndex_( std::numeric_limits<int>::min())
45  {}
46 
48  virtual ~TimeEventBase() {}
49 
51 
52  virtual bool isTime(Scalar time) const
54  { return false; }
55 
56  virtual Scalar getAbsTol() const
57  { return defaultTol_; }
58 
60  virtual Scalar timeToNextEvent(Scalar time) const
61  { return defaultTime_; }
62 
64  virtual Scalar timeOfNextEvent(Scalar time) const
65  { return defaultTime_; }
66 
68  virtual bool eventInRange(Scalar time1, Scalar time2) const
69  { return false; }
70 
72  virtual bool isIndex(int index) const
73  { return false; }
74 
76  virtual int indexToNextEvent(int index) const
77  { return defaultIndex_; }
78 
80  virtual int indexOfNextEvent(int index) const
81  { return defaultIndex_; }
82 
84  virtual bool eventInRangeIndex(int index1, int index2) const
85  { return false; }
86 
88  virtual void describe() const
89  {
90  Teuchos::RCP<Teuchos::FancyOStream> out =
91  Teuchos::VerboseObjectBase::getDefaultOStream();
92  out->setOutputToRootOnly(0);
93  *out << "TimeEventBase name = " << getName() << std::endl;
94  }
96 
98 
99  virtual std::string getName() const { return name_; }
100  virtual void setName(std::string name) { name_ = name; }
101 
102  virtual Scalar getDefaultTime () const { return defaultTime_; }
103  virtual Scalar getDefaultTol () const { return defaultTol_; }
104  virtual int getDefaultIndex() const { return defaultIndex_; }
106 
107 
108 private:
109 
110  std::string name_;
111  const Scalar defaultTime_;
112  const Scalar defaultTol_;
113  const int defaultIndex_;
114 
115 };
116 
117 
118 } // namespace Tempus
119 
120 #endif // Tempus_TimeEventBase_decl_hpp
virtual Scalar getDefaultTime() const
virtual int indexOfNextEvent(int index) const
Index of the next event. Negative indicating the last event is in the past.
virtual std::string getName() const
virtual Scalar getDefaultTol() const
virtual void setName(std::string name)
virtual bool isIndex(int index) const
Test if index is a time event.
virtual Scalar timeOfNextEvent(Scalar time) const
Time of the next event. Negative indicating the last event is in the past.
virtual Scalar timeToNextEvent(Scalar time) const
How much time until the next event. Negative indicating the last event is in the past.
virtual Scalar getAbsTol() const
virtual bool eventInRange(Scalar time1, Scalar time2) const
Test if an event occurs within the time range.
virtual int indexToNextEvent(int index) const
How many indices until the next event. Negative indicating the last event is in the past...
virtual int getDefaultIndex() const
virtual void describe() const
Describe member data.
virtual bool eventInRangeIndex(int index1, int index2) const
Test if an event occurs within the time range.
virtual bool isTime(Scalar time) const
Test if time is near a TimeEvent (within tolerance).
This class defines time events which can be used to "trigger" an action. Time events are points in ti...
virtual ~TimeEventBase()
Destructor.