Tempus  Version of the Day
Time Integration
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros 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 // Teuchos
15 #include "Teuchos_Time.hpp"
16 
17 // Tempus
18 #include "Tempus_TimeEventBase.hpp"
19 
20 
21 namespace Tempus {
22 
23 
24 /** \brief TimeEventList specifies a list of time events.
25  *
26  *
27  */
28 template<class Scalar>
29 class TimeEventList : virtual public TimeEventBase<Scalar>
30 {
31 public:
32 
33  /// Default constructor.
34  TimeEventList();
35 
36  /// Construct with full argument list of data members.
37  TimeEventList(std::string name, std::vector<Scalar> timeList,
38  Scalar relTol, bool landOnExactly);
39 
40  /// Destructor
41  virtual ~TimeEventList() {}
42 
43  /// \name Basic methods
44  //@{
45  /// Test if time is near a TimeEvent (within tolerance).
46  virtual bool isTime(Scalar time) const;
47 
48  /// How much time until the next event. Negative indicating the last event is in the past.
49  virtual Scalar timeToNextEvent(Scalar time) const;
50 
51  /// Time of the next event. Negative indicating the last event is in the past.
52  virtual Scalar timeOfNextEvent(Scalar time) const;
53 
54  /// Test if an event occurs within the time range.
55  virtual bool eventInRange(Scalar time1, Scalar time2) const;
56 
57  /// Describe member data.
58  virtual void describe() const;
59  //@}
60 
61  /// \name Accessor methods
62  //@{
63  virtual std::vector<Scalar> getTimeList() const { return timeList_; }
64  virtual void setTimeList(std::vector<Scalar> timeList);
65  virtual void addTime(Scalar time);
66  virtual void clearTimeList() { timeList_.clear(); }
67 
68  virtual Scalar getRelTol() const { return relTol_; }
69  virtual void setRelTol(Scalar relTol);
70 
71  virtual Scalar getAbsTol() const { return absTol_; }
72 
73  virtual bool getLandOnExactly() const { return landOnExactly_; }
74  virtual void setLandOnExactly(bool LOE) { landOnExactly_ = LOE; }
75  //@}
76 
77 
78 protected:
79 
80  virtual void setTimeScale();
81 
82  std::vector<Scalar> timeList_; ///< Sorted and unique list of time events.
83 
84  Scalar timeScale_; ///< A reference time scale, max(abs(start_,stop_)).
85  Scalar relTol_; ///< Relative time tolerance for matching time events.
86  Scalar absTol_; ///< Absolute time tolerance, relTol_*timeScale_.
87  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.
88 };
89 
90 
91 } // namespace Tempus
92 
93 #endif // Tempus_TimeEventList_decl_hpp
virtual void setTimeList(std::vector< Scalar > timeList)
virtual bool isTime(Scalar time) const
Test if time is near a TimeEvent (within tolerance).
Scalar relTol_
Relative time tolerance for matching time events.
virtual ~TimeEventList()
Destructor.
Scalar absTol_
Absolute time tolerance, relTol_*timeScale_.
virtual void addTime(Scalar time)
virtual Scalar timeOfNextEvent(Scalar time) const
Time of the next event. Negative indicating the last event is in the past.
virtual bool eventInRange(Scalar time1, Scalar time2) const
Test if an event occurs within the time range.
virtual void describe() const
Describe member data.
std::vector< Scalar > timeList_
Sorted and unique list of time events.
virtual void setRelTol(Scalar relTol)
This class defines time events which can be used to &quot;trigger&quot; an action. Time events are points in ti...
virtual bool getLandOnExactly() const
Scalar timeScale_
A reference time scale, max(abs(start_,stop_)).
virtual Scalar getAbsTol() const
TimeEventList()
Default constructor.
virtual Scalar timeToNextEvent(Scalar time) const
How much time until the next event. Negative indicating the last event is in the past.
virtual Scalar getRelTol() const
virtual void setLandOnExactly(bool LOE)
TimeEventList specifies a list of time events.
bool landOnExactly_
Should these time events be landed on exactly, i.e, adjust the timestep to hit time event...
virtual std::vector< Scalar > getTimeList() const