Tempus  Version of the Day
Time Integration
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros 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 
17 namespace Tempus {
18 
19 
20 /** \brief This class defines time events which can be used to "trigger" an action.
21  * Time events are points in time and/or timestep index where an
22  * an action should occur, such as, solution output (mesh and solution)
23  * diagnostic output, restart, screen dump, in-situ visualization,
24  * user-specified, or any other action.
25  *
26  * This class will store a collection time events, so that an object
27  * may quiry it and take appropriate action. Time events (time and
28  * timestep index) can be specified via
29  * - start, stop and stride
30  * - list of events
31  *
32  */
33 template<class Scalar>
35 {
36 public:
37 
38  /// Constructor
40  : name_("TimeEventBase"),
41  defaultTime_ (-std::numeric_limits<Scalar>::max()*1.0e-16),
42  defaultTol_ ( std::numeric_limits<Scalar>::min()),
43  defaultIndex_( std::numeric_limits<int>::min())
44  {}
45 
46  /// Destructor
47  virtual ~TimeEventBase() {}
48 
49  /// \name Basic methods
50  //@{
51  /// Test if time is near a TimeEvent (within tolerance).
52  virtual bool isTime(Scalar time) const
53  { return false; }
54 
55  virtual Scalar getAbsTol() const
56  { return defaultTol_; }
57 
58  /// How much time until the next event. Negative indicating the last event is in the past.
59  virtual Scalar timeToNextEvent(Scalar time) const
60  { return defaultTime_; }
61 
62  /// Time of the next event. Negative indicating the last event is in the past.
63  virtual Scalar timeOfNextEvent(Scalar time) const
64  { return defaultTime_; }
65 
66  /// Test if an event occurs within the time range.
67  virtual bool eventInRange(Scalar time1, Scalar time2) const
68  { return false; }
69 
70  /// Test if index is a time event.
71  virtual bool isIndex(int index) const
72  { return false; }
73 
74  /// How many indices until the next event. Negative indicating the last event is in the past.
75  virtual int indexToNextEvent(int index) const
76  { return defaultIndex_; }
77 
78  /// Index of the next event. Negative indicating the last event is in the past.
79  virtual int indexOfNextEvent(int index) const
80  { return defaultIndex_; }
81 
82  /// Test if an event occurs within the time range.
83  virtual bool eventInRangeIndex(int index1, int index2) const
84  { return false; }
85 
86  /// Describe member data.
87  virtual void describe() const
88  {
89  Teuchos::RCP<Teuchos::FancyOStream> out =
90  Teuchos::VerboseObjectBase::getDefaultOStream();
91  *out << "TimeEventBase name = " << getName() << std::endl;
92  }
93  //@}
94 
95  /// \name Accessor methods
96  //@{
97  virtual std::string getName() const { return name_; }
98  virtual void setName(std::string name) { name_ = name; }
99 
100  virtual Scalar getDefaultTime () const { return defaultTime_; }
101  virtual Scalar getDefaultTol () const { return defaultTol_; }
102  virtual int getDefaultIndex() const { return defaultIndex_; }
103  //@}
104 
105 
106 private:
107 
108  std::string name_;
109  const Scalar defaultTime_;
110  const Scalar defaultTol_;
111  const int defaultIndex_;
112 
113 };
114 
115 
116 } // namespace Tempus
117 
118 #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.
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...