Tempus Version of the Day
Time Integration
Loading...
Searching...
No Matches
Tempus_TimeEventBase.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_TimeEventBase_decl_hpp
10#define Tempus_TimeEventBase_decl_hpp
11
12// Teuchos
13#include "Teuchos_Time.hpp"
14#include "Teuchos_VerboseObject.hpp"
15
16#include "Tempus_config.hpp"
17
18namespace Tempus {
19
20
34template<class Scalar>
36{
37public:
38
41 : timeEventType_("Base"),
42 name_("TimeEventBase"),
43 defaultTime_ (std::numeric_limits<Scalar>::max()),
44 defaultTol_ (std::numeric_limits<Scalar>::epsilon()*Scalar(100.0)),
45 defaultIndex_(std::numeric_limits<int>::max())
46 {}
47
49 virtual ~TimeEventBase() {}
50
52
53
63 virtual bool isTime(Scalar time) const
64 { return false; }
65
76 virtual Scalar timeToNextEvent(Scalar time) const
77 { return defaultTime_; }
78
95 virtual Scalar timeOfNextEvent(Scalar time) const
96 { return defaultTime_; }
97
115 virtual bool eventInRange(Scalar time1, Scalar time2) const
116 { return false; }
117
128 virtual bool isIndex(int index) const
129 { return false; }
130
140 virtual int indexToNextEvent(int index) const
141 { return defaultIndex_; }
142
159 virtual int indexOfNextEvent(int index) const
160 { return defaultIndex_; }
161
177 virtual bool eventInRangeIndex(int index1, int index2) const
178 { return false; }
179
181 virtual void describe(Teuchos::FancyOStream &out,
182 const Teuchos::EVerbosityLevel verbLevel) const
183 {
184 auto l_out = Teuchos::fancyOStream( out.getOStream() );
185 Teuchos::OSTab ostab(*l_out, 2, "TimeEventBase");
186 l_out->setOutputToRootOnly(0);
187
188 *l_out << "TimeEventBase name = " << getName() << std::endl;
189 }
190
203 virtual Scalar getAbsTol() const
204 { return defaultTol_; }
205
222 virtual bool getLandOnExactly() const { return false; }
223
225
227
228
237 virtual std::string getName() const { return name_; }
239 virtual void setName(std::string name) { name_ = name; }
245 virtual std::string getType() const { return timeEventType_; }
247 virtual Scalar getDefaultTime () const { return defaultTime_; }
249 virtual Scalar getDefaultTol () const { return defaultTol_; }
251 virtual int getDefaultIndex() const { return defaultIndex_; }
253
254
256 virtual Teuchos::RCP<const Teuchos::ParameterList> getValidParameters() const
257 {
258 Teuchos::RCP<Teuchos::ParameterList> pl =
259 Teuchos::parameterList("Time Event Base");
260
261 pl->setName(this->getName());
262 pl->set("Name", this->getName());
263 pl->set("Type", this->getType());
264
265 return pl;
266 }
267
268protected:
269
270 virtual void setType(std::string s) { timeEventType_ = s; }
271
272private:
273
274 std::string timeEventType_;
275 std::string name_;
276 const Scalar defaultTime_;
277 const Scalar defaultTol_;
278 const int defaultIndex_;
279
280};
281
282
283} // namespace Tempus
284
285#endif // Tempus_TimeEventBase_decl_hpp
This class defines time events which can be used to "trigger" an action.
std::string name_
Name to identify the TimeEvent.
virtual bool eventInRange(Scalar time1, Scalar time2) const
Test if an event occurs within the time range.
virtual Scalar timeToNextEvent(Scalar time) const
How much time until the next event.
const Scalar defaultTime_
Default time.
const Scalar defaultTol_
Default tolerance.
virtual Scalar timeOfNextEvent(Scalar time) const
Return the time of the next event following the input time.
virtual Teuchos::RCP< const Teuchos::ParameterList > getValidParameters() const
Return ParameterList with current values.
virtual void setType(std::string s)
virtual int indexOfNextEvent(int index) const
Return the index of the next event following the input index.
virtual int indexToNextEvent(int index) const
How many indices until the next event.
virtual ~TimeEventBase()
Destructor.
virtual std::string getName() const
Return the name of the TimeEvent.
virtual std::string getType() const
Return the type of TimeEvent.
virtual bool isIndex(int index) const
Test if index is an event.
virtual bool eventInRangeIndex(int index1, int index2) const
Test if an event occurs within the index range.
virtual void setName(std::string name)
Set the name of the TimeEvent.
virtual void describe(Teuchos::FancyOStream &out, const Teuchos::EVerbosityLevel verbLevel) const
Describe member data.
virtual bool isTime(Scalar time) const
Test if time is near an event (within tolerance).
virtual int getDefaultIndex() const
Return the default index used by TimeEvents.
virtual Scalar getAbsTol() const
Return the absolute tolerance.
virtual Scalar getDefaultTime() const
Return the default time used for TimeEvents.
const int defaultIndex_
Default index.
std::string timeEventType_
Time Event type.
virtual Scalar getDefaultTol() const
Return the default tolerance used by TimeEvents.
virtual bool getLandOnExactly() const
Return if the time events need to be landed on exactly.