Tempus  Version of the Day
Time Integration
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
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  {
92  *out << "TimeEventBase name = " << getName() << std::endl;
93  }
95 
97 
98  virtual std::string getName() const { return name_; }
99  virtual void setName(std::string name) { name_ = name; }
100 
101  virtual Scalar getDefaultTime () const { return defaultTime_; }
102  virtual Scalar getDefaultTol () const { return defaultTol_; }
103  virtual int getDefaultIndex() const { return defaultIndex_; }
105 
106 
107 private:
108 
109  std::string name_;
110  const Scalar defaultTime_;
111  const Scalar defaultTol_;
112  const int defaultIndex_;
113 
114 };
115 
116 
117 } // namespace Tempus
118 
119 #endif // Tempus_TimeEventBase_decl_hpp
virtual Scalar getDefaultTime() const
virtual void describe() const
Describe member data.
virtual void setName(std::string name)
virtual int indexOfNextEvent(int index) const
Index of the next event. Negative indicating the last event is in the past.
virtual bool eventInRange(Scalar time1, Scalar time2) const
Test if an event occurs within the time range.
virtual Scalar timeToNextEvent(Scalar time) const
How much time until the next event. Negative indicating the last event is in the past.
virtual bool isTime(Scalar time) const
Test if time is near a TimeEvent (within tolerance).
virtual int getDefaultIndex() const
virtual Scalar getDefaultTol() const
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.
static RCP< FancyOStream > getDefaultOStream()
This class defines time events which can be used to &quot;trigger&quot; an action. Time events are points in ti...
virtual bool eventInRangeIndex(int index1, int index2) const
Test if an event occurs within the time range.
virtual std::string getName() const
virtual Scalar getAbsTol() const
virtual ~TimeEventBase()
Destructor.
virtual int indexToNextEvent(int index) const
How many indices until the next event. Negative indicating the last event is in the past...