Tempus  Version of the Day
Time Integration
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Tempus_TimeEventList_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_TimeEventList_decl_hpp
10 #define Tempus_TimeEventList_decl_hpp
11 
12 #include <vector>
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 TimeEventList : virtual public TimeEventBase<Scalar> {
28  public:
30  TimeEventList();
31 
33  TimeEventList(std::vector<Scalar> timeList,
34  std::string name = "TimeEventList", bool landOnExactly = true,
35  Scalar relTol = std::numeric_limits<Scalar>::epsilon() *
36  Scalar(100.0));
37 
39  virtual ~TimeEventList() {}
40 
42 
43 
53  virtual bool isTime(Scalar time) const;
54 
65  virtual Scalar timeToNextEvent(Scalar time) const;
66 
78  virtual Scalar timeOfNextEvent(Scalar time) const;
79 
92  virtual bool eventInRange(Scalar time1, Scalar time2) const;
93 
95  virtual void describe(Teuchos::FancyOStream &out,
96  const Teuchos::EVerbosityLevel verbLevel) const;
98 
100 
101  virtual std::vector<Scalar> getTimeList() const { return timeList_; }
103 
113  virtual void setTimeList(std::vector<Scalar> timeList, bool sort = true);
114 
124  virtual void addTime(Scalar time);
125 
127  virtual void clearTimeList() { timeList_.clear(); }
128 
130  virtual Scalar getRelTol() const { return relTol_; }
131 
141  virtual void setRelTol(Scalar relTol);
142 
153  virtual Scalar getAbsTol() const { return absTol_; }
154 
167  virtual bool getLandOnExactly() const { return landOnExactly_; }
168 
170  virtual void setLandOnExactly(bool LOE) { landOnExactly_ = LOE; }
172 
184 
185  protected:
194  virtual void setTimeScale();
195 
196  std::vector<Scalar> timeList_;
197 
198  Scalar timeScale_;
199  Scalar relTol_;
200  Scalar absTol_;
202 };
205 
206 // Nonmember Contructors
207 // ------------------------------------------------------------------------
208 
218 template <class Scalar>
221 
222 } // namespace Tempus
223 
224 #endif // Tempus_TimeEventList_decl_hpp
virtual bool isTime(Scalar time) const
Test if time is near an event (within tolerance).
Teuchos::RCP< const Teuchos::ParameterList > getValidParameters() const
Return a valid ParameterList with current settings.
Scalar relTol_
Relative time tolerance for matching time events.
virtual ~TimeEventList()
Destructor.
Scalar absTol_
Absolute time tolerance, relTol_*timeScale_.
virtual void addTime(Scalar time)
Add the time to event vector.
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.
virtual void setTimeScale()
Set the time scale for the time events.
std::vector< Scalar > timeList_
Sorted and unique list of time events.
virtual void clearTimeList()
Clear the vector of all events.
virtual void setRelTol(Scalar relTol)
Set the relative tolerance.
virtual void setTimeList(std::vector< Scalar > timeList, bool sort=true)
Set the list of time events.
This class defines time events which can be used to &quot;trigger&quot; an action.
virtual bool getLandOnExactly() const
Return if the time events need to be landed on exactly.
Scalar timeScale_
A reference time scale.
virtual Scalar getAbsTol() const
Return the absolute tolerance.
TimeEventList()
Default constructor.
virtual void describe(Teuchos::FancyOStream &out, const Teuchos::EVerbosityLevel verbLevel) const
Describe member data.
virtual Scalar timeToNextEvent(Scalar time) const
How much time until the next event.
virtual Scalar getRelTol() const
Return the relative tolerance.
virtual void setLandOnExactly(bool LOE)
Set if the time event should be landed on exactly.
TimeEventList specifies a list of time events.
Teuchos::RCP< TimeEventList< Scalar > > createTimeEventList(Teuchos::RCP< Teuchos::ParameterList > pList)
Nonmember Constructor via ParameterList.
virtual std::vector< Scalar > getTimeList() const
Return the list of time events.