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: 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 #include "Teuchos_Time.hpp"
16 
17 #include "Tempus_config.hpp"
18 #include "Tempus_TimeEventBase.hpp"
19 
20 namespace Tempus {
21 
26 template <class Scalar>
27 class TimeEventRange : virtual public TimeEventBase<Scalar> {
28  public:
31 
33  TimeEventRange(Scalar start, Scalar stop, Scalar stride,
34  std::string name = "", bool landOnExactly = true,
35  Scalar relTol = std::numeric_limits<Scalar>::epsilon() *
36  Scalar(100.0));
37 
39  TimeEventRange(Scalar start, Scalar stop, int numEvents,
40  std::string name = "", bool landOnExactly = true,
41  Scalar relTol = std::numeric_limits<Scalar>::epsilon() *
42  Scalar(100.0));
43 
45  virtual ~TimeEventRange() {}
46 
48 
49 
59  virtual bool isTime(Scalar time) const;
60 
72  virtual Scalar timeToNextEvent(Scalar time) const;
73 
85  virtual Scalar timeOfNextEvent(Scalar time) const;
86 
98  virtual bool eventInRange(Scalar time1, Scalar time2) const;
100 
102 
103 
111  virtual void setTimeRange(Scalar start, Scalar stop, Scalar stride);
112 
121  virtual void setTimeRange(Scalar start, Scalar stop, int numEvents);
122 
124  virtual Scalar getTimeStart() const { return start_; }
126  virtual void setTimeStart(Scalar start);
127 
129  virtual Scalar getTimeStop() const { return stop_; }
131  virtual void setTimeStop(Scalar stop);
132 
134  virtual Scalar getTimeStride() const { return stride_; }
135 
146  virtual void setTimeStride(Scalar stride);
147 
149  virtual int getNumEvents() const { return numEvents_; }
150 
163  virtual void setNumEvents(int numEvents);
164 
166  virtual Scalar getRelTol() const { return relTol_; }
167 
177  virtual void setRelTol(Scalar relTol);
178 
187  virtual Scalar getAbsTol() const { return absTol_; }
188 
201  virtual bool getLandOnExactly() const { return landOnExactly_; }
202 
204  virtual void setLandOnExactly(bool LOE) { landOnExactly_ = LOE; }
205 
207 
209  virtual void describe(Teuchos::FancyOStream &out,
210  const Teuchos::EVerbosityLevel verbLevel) const;
211 
223 
224  protected:
233  virtual void setTimeScale();
234 
235  Scalar start_;
236  Scalar stop_;
237  Scalar stride_;
238  unsigned numEvents_;
239 
240  Scalar timeScale_;
241  Scalar relTol_;
242  Scalar absTol_;
244 };
247 
248 // Nonmember Contructors
249 // ------------------------------------------------------------------------
250 
260 template <class Scalar>
263 
264 } // namespace Tempus
265 
266 #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.