Tempus  Version of the Day
Time Integration
Tempus_TimeEventRange_decl.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_TimeEventRange_decl_hpp
10 #define Tempus_TimeEventRange_decl_hpp
11 
12 #include <tuple>
13 
14 // Teuchos
15 #include "Teuchos_Time.hpp"
16 
17 // Tempus
18 #include "Tempus_TimeEventBase.hpp"
19 
20 
21 namespace Tempus {
22 
23 
24 /** \brief TimeEventRange specifies a start, stop and stride time.
25  *
26  *
27  */
28 template<class Scalar>
29 class TimeEventRange : virtual public TimeEventBase<Scalar>
30 {
31 public:
32 
33  /// Default constructor.
35 
36  /// Construct with full argument list of data members.
37  TimeEventRange(std::string name, Scalar start, Scalar stop, Scalar stride,
38  Scalar relTol, bool landOnExactly);
39 
40  /// Construct with full argument list of data members.
41  TimeEventRange(std::string name, Scalar start, Scalar stop, int numEvents,
42  Scalar relTol, bool landOnExactly);
43 
44  /// Destructor
45  virtual ~TimeEventRange() {}
46 
47  /// \name Basic methods
48  //@{
49  /// Test if time is near a TimeEvent (within tolerance).
50  virtual bool isTime(Scalar time) const;
51 
52  /// How much time until the next event. Negative indicating the last event is in the past.
53  virtual Scalar timeToNextEvent(Scalar time) const;
54 
55  /// Time of the next event. Negative indicating the last event is in the past.
56  virtual Scalar timeOfNextEvent(Scalar time) const;
57 
58  /// Test if an event occurs within the time range.
59  virtual bool eventInRange(Scalar time1, Scalar time2) const;
60  //@}
61 
62  /// \name Accessor methods
63  //@{
64  virtual void setTimeRange(Scalar start, Scalar stop, Scalar stride)
65  { setTimeStart(start); setTimeStop(stop); setTimeStride(stride); }
66  virtual void setTimeRange(Scalar start, Scalar stop, int numEvents)
67  { setTimeStart(start); setTimeStop(stop); setNumEvents(numEvents); }
68 
69  virtual Scalar getTimeStart() const { return start_; }
70  virtual void setTimeStart(Scalar start);
71 
72  virtual Scalar getTimeStop() const { return stop_; }
73  virtual void setTimeStop(Scalar stop);
74 
75  virtual Scalar getTimeStride() const { return stride_; }
76  virtual void setTimeStride(Scalar stride);
77 
78  virtual int getNumEvents() const { return numEvents_; }
79  virtual void setNumEvents(int numEvents);
80 
81  virtual Scalar getRelTol() const { return relTol_; }
82  virtual void setRelTol(Scalar relTol);
83 
84  virtual Scalar getAbsTol() const { return absTol_; }
85 
86  virtual bool getLandOnExactly() const { return landOnExactly_; }
87  virtual void setLandOnExactly(bool LOE) { landOnExactly_ = LOE; }
88 
89  /// Describe member data.
90  virtual void describe() const;
91  //@}
92 
93 
94 protected:
95 
96  virtual void setTimeScale();
97 
98  Scalar start_; ///< Start of time range.
99  Scalar stop_; ///< Stop of time range.
100  Scalar stride_; ///< Stride of time range.
101  unsigned numEvents_; ///< Number of events in time range.
102 
103  Scalar timeScale_; ///< A reference time scale, max(abs(start_,stop_)).
104  Scalar relTol_; ///< Relative time tolerance for matching time events.
105  Scalar absTol_; ///< Absolute time tolerance, relTol_*timeScale_.
106  bool landOnExactly_; ///< Should these time events be landed on exactly, i.e, adjust the timestep to hit time event, versus stepping over and keeping the time step unchanged.
107 
108 };
109 
110 
111 } // namespace Tempus
112 
113 #endif // Tempus_TimeEventRange_decl_hpp
This class defines time events which can be used to "trigger" an action. Time events are points in ti...
TimeEventRange specifies a start, stop and stride time.
virtual Scalar getTimeStride() const
virtual Scalar getTimeStart() const
virtual void setTimeRange(Scalar start, Scalar stop, int numEvents)
virtual void setRelTol(Scalar relTol)
virtual void setNumEvents(int numEvents)
virtual void setLandOnExactly(bool LOE)
virtual void describe() const
Describe member data.
bool landOnExactly_
Should these time events be landed on exactly, i.e, adjust the timestep to hit time event,...
virtual void setTimeStop(Scalar stop)
virtual void setTimeStride(Scalar stride)
virtual bool getLandOnExactly() const
Scalar stride_
Stride of time range.
virtual Scalar timeOfNextEvent(Scalar time) const
Time 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.
Scalar timeScale_
A reference time scale, max(abs(start_,stop_)).
virtual Scalar getAbsTol() const
Scalar start_
Start of time range.
unsigned numEvents_
Number of events in time range.
Scalar absTol_
Absolute time tolerance, relTol_*timeScale_.
virtual void setTimeRange(Scalar start, Scalar stop, Scalar stride)
TimeEventRange()
Default constructor.
virtual void setTimeStart(Scalar start)
Scalar relTol_
Relative time tolerance for matching time events.
virtual Scalar getRelTol() const
virtual bool isTime(Scalar time) const
Test if time is near a TimeEvent (within tolerance).
Scalar stop_
Stop of time range.
virtual ~TimeEventRange()
Destructor.
virtual Scalar timeToNextEvent(Scalar time) const
How much time until the next event. Negative indicating the last event is in the past.
virtual Scalar getTimeStop() const