Tempus Version of the Day
Time Integration
Loading...
Searching...
No Matches
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"
15#include "Teuchos_ParameterList.hpp"
16
17#include "Tempus_config.hpp"
19
20
21namespace Tempus {
22
23
28template<class Scalar>
29class TimeEventRange : virtual public TimeEventBase<Scalar>
30{
31public:
32
35
38 Scalar start, Scalar stop, Scalar stride,
39 std::string name = "", bool landOnExactly = true,
40 Scalar relTol = std::numeric_limits<Scalar>::epsilon()*Scalar(100.0));
41
44 Scalar start, Scalar stop, int numEvents,
45 std::string name = "", bool landOnExactly = true,
46 Scalar relTol = std::numeric_limits<Scalar>::epsilon()*Scalar(100.0));
47
49 virtual ~TimeEventRange() {}
50
52
53
63 virtual bool isTime(Scalar time) const;
64
76 virtual Scalar timeToNextEvent(Scalar time) const;
77
89 virtual Scalar timeOfNextEvent(Scalar time) const;
90
102 virtual bool eventInRange(Scalar time1, Scalar time2) const;
104
106
107
115 virtual void setTimeRange(Scalar start, Scalar stop, Scalar stride);
116
125 virtual void setTimeRange(Scalar start, Scalar stop, int numEvents);
126
128 virtual Scalar getTimeStart() const { return start_; }
130 virtual void setTimeStart(Scalar start);
131
133 virtual Scalar getTimeStop() const { return stop_; }
135 virtual void setTimeStop(Scalar stop);
136
138 virtual Scalar getTimeStride() const { return stride_; }
139
149 virtual void setTimeStride(Scalar stride);
150
152 virtual int getNumEvents() const { return numEvents_; }
153
166 virtual void setNumEvents(int numEvents);
167
169 virtual Scalar getRelTol() const { return relTol_; }
170
180 virtual void setRelTol(Scalar relTol);
181
190 virtual Scalar getAbsTol() const { return absTol_; }
191
203 virtual bool getLandOnExactly() const { return landOnExactly_; }
204
206 virtual void setLandOnExactly(bool LOE) { landOnExactly_ = LOE; }
207
209
211 virtual void describe(Teuchos::FancyOStream &out,
212 const Teuchos::EVerbosityLevel verbLevel) const;
213
224 Teuchos::RCP<const Teuchos::ParameterList> getValidParameters() const;
225
226
227protected:
228
237 virtual void setTimeScale();
238
239 Scalar start_;
240 Scalar stop_;
241 Scalar stride_;
242 unsigned numEvents_;
243
244 Scalar timeScale_;
245 Scalar relTol_;
246 Scalar absTol_;
248
249};
250
251
252// Nonmember Contructors
253// ------------------------------------------------------------------------
254
264template<class Scalar>
265Teuchos::RCP<TimeEventRange<Scalar> >
266createTimeEventRange(Teuchos::RCP<Teuchos::ParameterList> pList);
267
268
269} // namespace Tempus
270
271#endif // Tempus_TimeEventRange_decl_hpp
This class defines time events which can be used to "trigger" an action.
TimeEventRange specifies a start, stop and stride time.
virtual Scalar getTimeStride() const
Return the stride of the time range.
virtual Scalar getTimeStart() const
Return the start of the time range.
Teuchos::RCP< const Teuchos::ParameterList > getValidParameters() const
Return a valid ParameterList with current settings.
virtual void setRelTol(Scalar relTol)
Set the relative tolerance.
virtual void describe(Teuchos::FancyOStream &out, const Teuchos::EVerbosityLevel verbLevel) const
Describe member data.
virtual void setNumEvents(int numEvents)
Set the number of time events.
virtual void setTimeScale()
Set the time scale for the time events.
virtual void setLandOnExactly(bool LOE)
Set if the time event should be landed on exactly.
bool landOnExactly_
Should these time events be landed on exactly, i.e, adjust the timestep to hit time event,...
virtual void setTimeStop(Scalar stop)
Set the stop of the time range.
virtual void setTimeStride(Scalar stride)
Set the stride of the time range.
virtual bool getLandOnExactly() const
Set if the time events need to be landed on exactly.
Scalar stride_
Stride of time range.
virtual Scalar timeOfNextEvent(Scalar time) const
Return the time of the next event following the input time.
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
Return the absolute tolerance.
virtual int getNumEvents() const
Return the number of time events in the time range.
Scalar start_
Start of time range.
unsigned numEvents_
Number of events in time range.
Scalar absTol_
Absolute time tolerance, relTol_*timeScale_.
TimeEventRange()
Default constructor.
virtual void setTimeStart(Scalar start)
Set the start of the time range.
virtual void setTimeRange(Scalar start, Scalar stop, Scalar stride)
Set the range of time events from start, stop and stride.
Scalar relTol_
Relative time tolerance for matching time events.
virtual Scalar getRelTol() const
Return the relative tolerance.
virtual bool isTime(Scalar time) const
Test if time is near an event (within tolerance).
Scalar stop_
Stop of time range.
virtual ~TimeEventRange()
Destructor.
virtual Scalar timeToNextEvent(Scalar time) const
How much time until the next event.
virtual Scalar getTimeStop() const
Return the stop of the time range.
Teuchos::RCP< TimeEventRange< Scalar > > createTimeEventRange(Teuchos::RCP< Teuchos::ParameterList > pList)
Nonmember Constructor via ParameterList.