Tempus  Version of the Day
Time Integration
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
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 
18 namespace Tempus {
19 
34 template <class Scalar>
36  public:
39  : timeEventType_("Base"),
40  name_("TimeEventBase"),
41  defaultTime_(std::numeric_limits<Scalar>::max()),
42  defaultTol_(std::numeric_limits<Scalar>::epsilon() * Scalar(100.0)),
43  defaultIndex_(std::numeric_limits<int>::max())
44  {
45  }
46 
48  virtual ~TimeEventBase() {}
49 
51 
52 
62  virtual bool isTime(Scalar time) const { return false; }
63 
74  virtual Scalar timeToNextEvent(Scalar time) const { return defaultTime_; }
75 
92  virtual Scalar timeOfNextEvent(Scalar time) const { return defaultTime_; }
93 
111  virtual bool eventInRange(Scalar time1, Scalar time2) const { return false; }
112 
123  virtual bool isIndex(int index) const { return false; }
124 
134  virtual int indexToNextEvent(int index) const { return defaultIndex_; }
135 
152  virtual int indexOfNextEvent(int index) const { return defaultIndex_; }
153 
169  virtual bool eventInRangeIndex(int index1, int index2) const { return false; }
170 
172  virtual void describe(Teuchos::FancyOStream &out,
173  const Teuchos::EVerbosityLevel verbLevel) const
174  {
175  auto l_out = Teuchos::fancyOStream(out.getOStream());
176  Teuchos::OSTab ostab(*l_out, 2, "TimeEventBase");
177  l_out->setOutputToRootOnly(0);
178 
179  *l_out << "TimeEventBase name = " << getName() << std::endl;
180  }
181 
194  virtual Scalar getAbsTol() const { return defaultTol_; }
195 
213  virtual bool getLandOnExactly() const { return false; }
214 
216 
218 
219 
228  virtual std::string getName() const { return name_; }
230  virtual void setName(std::string name) { name_ = name; }
236  virtual std::string getType() const { return timeEventType_; }
238  virtual Scalar getDefaultTime() const { return defaultTime_; }
240  virtual Scalar getDefaultTol() const { return defaultTol_; }
242  virtual int getDefaultIndex() const { return defaultIndex_; }
244 
247  {
249  Teuchos::parameterList("Time Event Base");
250 
251  pl->setName(this->getName());
252  pl->set("Name", this->getName());
253  pl->set("Type", this->getType());
254 
255  return pl;
256  }
257 
258  protected:
259  virtual void setType(std::string s) { timeEventType_ = s; }
260 
261  private:
262  std::string timeEventType_;
263  std::string name_;
264  const Scalar defaultTime_;
265  const Scalar defaultTol_;
266  const int defaultIndex_;
267 };
268 
269 } // namespace Tempus
270 
271 #endif // Tempus_TimeEventBase_decl_hpp
virtual bool getLandOnExactly() const
Return if the time events need to be landed on exactly.
virtual std::string getType() const
Return the type of TimeEvent.
virtual void describe(Teuchos::FancyOStream &out, const Teuchos::EVerbosityLevel verbLevel) const
Describe member data.
virtual Scalar getDefaultTime() const
Return the default time used for TimeEvents.
const Scalar defaultTol_
Default tolerance.
virtual void setType(std::string s)
const int defaultIndex_
Default index.
virtual void setName(std::string name)
Set the name of the TimeEvent.
ParameterList & set(std::string const &name, T const &value, std::string const &docString="", RCP< const ParameterEntryValidator > const &validator=null)
virtual int indexOfNextEvent(int index) const
Return the index of the next event following the input index.
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.
std::string name_
Name to identify the TimeEvent.
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.
const Scalar defaultTime_
Default time.
virtual Scalar getDefaultTol() const
Return the default tolerance used by TimeEvents.
virtual bool isIndex(int index) const
Test if index is an event.
std::string timeEventType_
Time Event type.
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.
This class defines time events which can be used to &quot;trigger&quot; an action.
virtual bool eventInRangeIndex(int index1, int index2) const
Test if an event occurs within the index range.
virtual std::string getName() const
Return the name of the TimeEvent.
RCP< std::basic_ostream< char_type, traits_type > > getOStream()
virtual Scalar getAbsTol() const
Return the absolute tolerance.
virtual ~TimeEventBase()
Destructor.
virtual int indexToNextEvent(int index) const
How many indices until the next event.
ParameterList & setName(const std::string &name)