Tempus  Version of the Day
Time Integration
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Tempus_TimeEventRange_decl.hpp
Go to the documentation of this file.
1 //@HEADER
2 // *****************************************************************************
3 // Tempus: Time Integration and Sensitivity Analysis Package
4 //
5 // Copyright 2017 NTESS and the Tempus contributors.
6 // SPDX-License-Identifier: BSD-3-Clause
7 // *****************************************************************************
8 //@HEADER
9 
10 #ifndef Tempus_TimeEventRange_decl_hpp
11 #define Tempus_TimeEventRange_decl_hpp
12 
13 #include <tuple>
14 
15 #include "Teuchos_Time.hpp"
17 
18 #include "Tempus_config.hpp"
19 #include "Tempus_TimeEventBase.hpp"
20 
21 namespace Tempus {
22 
27 template <class Scalar>
28 class TimeEventRange : virtual public TimeEventBase<Scalar> {
29  public:
32 
34  TimeEventRange(Scalar start, Scalar stop, Scalar stride,
35  std::string name = "", bool landOnExactly = true,
36  Scalar relTol = std::numeric_limits<Scalar>::epsilon() *
37  Scalar(100.0));
38 
40  TimeEventRange(Scalar start, Scalar stop, int numEvents,
41  std::string name = "", bool landOnExactly = true,
42  Scalar relTol = std::numeric_limits<Scalar>::epsilon() *
43  Scalar(100.0));
44 
46  virtual ~TimeEventRange() {}
47 
49 
50 
60  virtual bool isTime(Scalar time) const;
61 
73  virtual Scalar timeToNextEvent(Scalar time) const;
74 
86  virtual Scalar timeOfNextEvent(Scalar time) const;
87 
99  virtual bool eventInRange(Scalar time1, Scalar time2) const;
101 
103 
104 
112  virtual void setTimeRange(Scalar start, Scalar stop, Scalar stride);
113 
122  virtual void setTimeRange(Scalar start, Scalar stop, int numEvents);
123 
125  virtual Scalar getTimeStart() const { return start_; }
127  virtual void setTimeStart(Scalar start);
128 
130  virtual Scalar getTimeStop() const { return stop_; }
132  virtual void setTimeStop(Scalar stop);
133 
135  virtual Scalar getTimeStride() const { return stride_; }
136 
147  virtual void setTimeStride(Scalar stride);
148 
150  virtual int getNumEvents() const { return numEvents_; }
151 
164  virtual void setNumEvents(int numEvents);
165 
167  virtual Scalar getRelTol() const { return relTol_; }
168 
178  virtual void setRelTol(Scalar relTol);
179 
188  virtual Scalar getAbsTol() const { return absTol_; }
189 
202  virtual bool getLandOnExactly() const { return landOnExactly_; }
203 
205  virtual void setLandOnExactly(bool LOE) { landOnExactly_ = LOE; }
206 
208 
210  virtual void describe(Teuchos::FancyOStream &out,
211  const Teuchos::EVerbosityLevel verbLevel) const;
212 
224 
225  protected:
234  virtual void setTimeScale();
235 
236  Scalar start_;
237  Scalar stop_;
238  Scalar stride_;
239  unsigned numEvents_;
240 
241  Scalar timeScale_;
242  Scalar relTol_;
243  Scalar absTol_;
245 };
248 
249 // Nonmember Contructors
250 // ------------------------------------------------------------------------
251 
261 template <class Scalar>
264 
265 } // namespace Tempus
266 
267 #endif // Tempus_TimeEventRange_decl_hpp
Scalar relTol_
Relative time tolerance for matching time events.
Teuchos::RCP< const Teuchos::ParameterList > getValidParameters() const
Return a valid ParameterList with current settings.
unsigned numEvents_
Number of events in time range.
virtual void describe(Teuchos::FancyOStream &out, const Teuchos::EVerbosityLevel verbLevel) const
Describe member data.
virtual void setRelTol(Scalar relTol)
Set the relative tolerance.
Scalar stride_
Stride of time range.
virtual void setNumEvents(int numEvents)
Set the number of time events.
Scalar absTol_
Absolute time tolerance, relTol_*timeScale_.
virtual void setLandOnExactly(bool LOE)
Set if the time event should be landed on exactly.
virtual bool getLandOnExactly() const
Set if the time events need to be landed on exactly.
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.
Teuchos::RCP< TimeEventRange< Scalar > > createTimeEventRange(Teuchos::RCP< Teuchos::ParameterList > pList)
Nonmember Constructor via ParameterList.
virtual int getNumEvents() const
Return the number of time events in the time range.
virtual Scalar getTimeStride() const
Return the stride of the time range.
virtual void setTimeStop(Scalar stop)
Set the stop of the time range.
virtual void setTimeScale()
Set the time scale for the time events.
This class defines time events which can be used to &quot;trigger&quot; an action.
virtual Scalar getTimeStop() const
Return the stop of the time range.
virtual Scalar getTimeStart() const
Return the start of the time range.
virtual void setTimeStart(Scalar start)
Set the start of the time range.
Scalar stop_
Stop of time range.
virtual ~TimeEventRange()
Destructor.
virtual void setTimeStride(Scalar stride)
Set the stride of the time range.
virtual bool isTime(Scalar time) const
Test if time is near an event (within tolerance).
TimeEventRange()
Default constructor.
virtual Scalar timeOfNextEvent(Scalar time) const
Return the time of the next event following the input time.
virtual Scalar getRelTol() const
Return the relative tolerance.
virtual void setTimeRange(Scalar start, Scalar stop, Scalar stride)
Set the range of time events from start, stop and stride.
virtual Scalar getAbsTol() const
Return the absolute tolerance.