Tempus  Version of the Day
Time Integration
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
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
Scalar relTol_
Relative time tolerance for matching time events.
virtual void describe() const
Describe member data.
unsigned numEvents_
Number of events in time range.
virtual void setRelTol(Scalar relTol)
Scalar stride_
Stride of time range.
virtual void setNumEvents(int numEvents)
Scalar absTol_
Absolute time tolerance, relTol_*timeScale_.
virtual void setLandOnExactly(bool LOE)
virtual bool getLandOnExactly() const
virtual void setTimeRange(Scalar start, Scalar stop, int numEvents)
Scalar timeScale_
A reference time scale, max(abs(start_,stop_)).
Scalar start_
Start of time range.
virtual bool eventInRange(Scalar time1, Scalar time2) const
Test if an event occurs within the time range.
TimeEventRange specifies a start, stop and stride time.
virtual Scalar timeToNextEvent(Scalar time) const
How much time until the next event. Negative indicating the last event is in the past.
bool landOnExactly_
Should these time events be landed on exactly, i.e, adjust the timestep to hit time event...
virtual Scalar getTimeStride() const
virtual void setTimeStop(Scalar stop)
virtual void setTimeRange(Scalar start, Scalar stop, Scalar stride)
This class defines time events which can be used to &quot;trigger&quot; an action. Time events are points in ti...
virtual Scalar getTimeStop() const
virtual Scalar getTimeStart() const
virtual void setTimeStart(Scalar start)
Scalar stop_
Stop of time range.
virtual ~TimeEventRange()
Destructor.
virtual void setTimeStride(Scalar stride)
virtual bool isTime(Scalar time) const
Test if time is near a TimeEvent (within tolerance).
TimeEventRange()
Default constructor.
virtual Scalar timeOfNextEvent(Scalar time) const
Time of the next event. Negative indicating the last event is in the past.
virtual Scalar getRelTol() const
virtual Scalar getAbsTol() const