Tempus  Version of the Day
Time Integration
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
Tempus::TimeEventRange< Scalar > Class Template Reference

TimeEventRange specifies a start, stop and stride time. More...

#include <Tempus_TimeEventRange_decl.hpp>

Inheritance diagram for Tempus::TimeEventRange< Scalar >:
Tempus::TimeEventBase< Scalar >

Public Member Functions

 TimeEventRange ()
 Default constructor. More...
 
 TimeEventRange (Scalar start, Scalar stop, Scalar stride, std::string name="", bool landOnExactly=true, Scalar relTol=std::numeric_limits< Scalar >::epsilon()*Scalar(100.0))
 Construct from start, stop and stride. More...
 
 TimeEventRange (Scalar start, Scalar stop, int numEvents, std::string name="", bool landOnExactly=true, Scalar relTol=std::numeric_limits< Scalar >::epsilon()*Scalar(100.0))
 Construct from start, stop and number of events. More...
 
virtual ~TimeEventRange ()
 Destructor. More...
 
virtual void describe (Teuchos::FancyOStream &out, const Teuchos::EVerbosityLevel verbLevel) const
 Describe member data. More...
 
Teuchos::RCP< const
Teuchos::ParameterList
getValidParameters () const
 Return a valid ParameterList with current settings. More...
 
- Public Member Functions inherited from Tempus::TimeEventBase< Scalar >
 TimeEventBase ()
 Constructor. More...
 
virtual ~TimeEventBase ()
 Destructor. More...
 
virtual bool isIndex (int index) const
 Test if index is an event. More...
 
virtual int indexToNextEvent (int index) const
 How many indices until the next event. More...
 
virtual int indexOfNextEvent (int index) const
 Return the index of the next event following the input index. More...
 
virtual bool eventInRangeIndex (int index1, int index2) const
 Test if an event occurs within the index range. More...
 
virtual std::string getName () const
 Return the name of the TimeEvent. More...
 
virtual void setName (std::string name)
 Set the name of the TimeEvent. More...
 
virtual std::string getType () const
 Return the type of TimeEvent. More...
 
virtual Scalar getDefaultTime () const
 Return the default time used for TimeEvents. More...
 
virtual Scalar getDefaultTol () const
 Return the default tolerance used by TimeEvents. More...
 
virtual int getDefaultIndex () const
 Return the default index used by TimeEvents. More...
 

Protected Member Functions

virtual void setTimeScale ()
 Set the time scale for the time events. More...
 
- Protected Member Functions inherited from Tempus::TimeEventBase< Scalar >
virtual void setType (std::string s)
 

Protected Attributes

Scalar start_
 Start of time range. More...
 
Scalar stop_
 Stop of time range. More...
 
Scalar stride_
 Stride of time range. More...
 
unsigned numEvents_
 Number of events in time range. More...
 
Scalar timeScale_
 A reference time scale, max(abs(start_,stop_)). More...
 
Scalar relTol_
 Relative time tolerance for matching time events. More...
 
Scalar absTol_
 Absolute time tolerance, relTol_*timeScale_. More...
 
bool landOnExactly_
 

Basic methods

virtual bool isTime (Scalar time) const
 Test if time is near an event (within tolerance). More...
 
virtual Scalar timeToNextEvent (Scalar time) const
 How much time until the next event. More...
 
virtual Scalar timeOfNextEvent (Scalar time) const
 Return the time of the next event following the input time. More...
 
virtual bool eventInRange (Scalar time1, Scalar time2) const
 Test if an event occurs within the time range. More...
 

Accessor methods

virtual void setTimeRange (Scalar start, Scalar stop, Scalar stride)
 Set the range of time events from start, stop and stride. More...
 
virtual void setTimeRange (Scalar start, Scalar stop, int numEvents)
 Set the range of time events from start, stop and number of events. More...
 
virtual Scalar getTimeStart () const
 Return the start of the time range. More...
 
virtual void setTimeStart (Scalar start)
 Set the start of the time range. More...
 
virtual Scalar getTimeStop () const
 Return the stop of the time range. More...
 
virtual void setTimeStop (Scalar stop)
 Set the stop of the time range. More...
 
virtual Scalar getTimeStride () const
 Return the stride of the time range. More...
 
virtual void setTimeStride (Scalar stride)
 Set the stride of the time range. More...
 
virtual int getNumEvents () const
 Return the number of time events in the time range. More...
 
virtual void setNumEvents (int numEvents)
 Set the number of time events. More...
 
virtual Scalar getRelTol () const
 Return the relative tolerance. More...
 
virtual void setRelTol (Scalar relTol)
 Set the relative tolerance. More...
 
virtual Scalar getAbsTol () const
 Return the absolute tolerance. More...
 
virtual bool getLandOnExactly () const
 Set if the time events need to be landed on exactly. More...
 
virtual void setLandOnExactly (bool LOE)
 Set if the time event should be landed on exactly. More...
 

Detailed Description

template<class Scalar>
class Tempus::TimeEventRange< Scalar >

TimeEventRange specifies a start, stop and stride time.

Definition at line 28 of file Tempus_TimeEventRange_decl.hpp.

Constructor & Destructor Documentation

template<class Scalar >
Tempus::TimeEventRange< Scalar >::TimeEventRange ( )

Default constructor.

Definition at line 18 of file Tempus_TimeEventRange_impl.hpp.

template<class Scalar >
Tempus::TimeEventRange< Scalar >::TimeEventRange ( Scalar  start,
Scalar  stop,
Scalar  stride,
std::string  name = "",
bool  landOnExactly = true,
Scalar  relTol = std::numeric_limits<Scalar>::epsilon() * Scalar(100.0) 
)

Construct from start, stop and stride.

Definition at line 38 of file Tempus_TimeEventRange_impl.hpp.

template<class Scalar >
Tempus::TimeEventRange< Scalar >::TimeEventRange ( Scalar  start,
Scalar  stop,
int  numEvents,
std::string  name = "",
bool  landOnExactly = true,
Scalar  relTol = std::numeric_limits<Scalar>::epsilon() * Scalar(100.0) 
)

Construct from start, stop and number of events.

Definition at line 65 of file Tempus_TimeEventRange_impl.hpp.

template<class Scalar >
virtual Tempus::TimeEventRange< Scalar >::~TimeEventRange ( )
inlinevirtual

Destructor.

Definition at line 46 of file Tempus_TimeEventRange_decl.hpp.

Member Function Documentation

template<class Scalar >
bool Tempus::TimeEventRange< Scalar >::isTime ( Scalar  time) const
virtual

Test if time is near an event (within tolerance).

Test if any of the events in the range is near the input time.

Parameters
[in]timeThe input time to check if it is near an event.
Returns
Return true if time is near a TimeEvent ( timeEvent-absTol < time < timeEvent+absTol ), otherwise return false.

Reimplemented from Tempus::TimeEventBase< Scalar >.

Definition at line 202 of file Tempus_TimeEventRange_impl.hpp.

template<class Scalar >
Scalar Tempus::TimeEventRange< Scalar >::timeToNextEvent ( Scalar  time) const
virtual

How much time until the next event.

Determine the amount of time until the next timeEvent in the range (i.e., time of next event minus the input time). If the input time is after all events, the default time (a time in the distant future) minus the input time is returned.

Parameters
[in]timeThe input time to measure to the next TimeEvent.
Returns
The amount of time to next TimeEvent ( nextTimeEvent-time ).

Reimplemented from Tempus::TimeEventBase< Scalar >.

Definition at line 228 of file Tempus_TimeEventRange_impl.hpp.

template<class Scalar >
Scalar Tempus::TimeEventRange< Scalar >::timeOfNextEvent ( Scalar  time) const
virtual

Return the time of the next event following the input time.

Returns the time of the next event that follows the input time. If the input time is before all events, the time of the first event is returned. If the input time is after all events, the default time (a time in the distant future) is returned. If the input time is an event time, the time of the next event is returned.

Parameters
time[in] Input time.
Returns
Time of the next event.

Reimplemented from Tempus::TimeEventBase< Scalar >.

Definition at line 234 of file Tempus_TimeEventRange_impl.hpp.

template<class Scalar >
bool Tempus::TimeEventRange< Scalar >::eventInRange ( Scalar  time1,
Scalar  time2 
) const
virtual

Test if an event occurs within the time range.

Find if an event is within the input range, (time1 < timeEvent-absTol and timeEvent-absTol <= time2), including the event's absolute tolerance. Note, this does not include time1, but does include time2.

Parameters
time1[in] Input time of one end of the range.
time2[in] Input time of the other end of the range.
Returns
True if an time event is within the range.

Reimplemented from Tempus::TimeEventBase< Scalar >.

Definition at line 255 of file Tempus_TimeEventRange_impl.hpp.

template<class Scalar >
void Tempus::TimeEventRange< Scalar >::setTimeRange ( Scalar  start,
Scalar  stop,
Scalar  stride 
)
virtual

Set the range of time events from start, stop and stride.

This will completely replace the time range.

Parameters
start[in] The start of the time range.
stop[in] The stop of the time range.
stride[in] The stride of the time range.

Definition at line 92 of file Tempus_TimeEventRange_impl.hpp.

template<class Scalar >
void Tempus::TimeEventRange< Scalar >::setTimeRange ( Scalar  start,
Scalar  stop,
int  numEvents 
)
virtual

Set the range of time events from start, stop and number of events.

This will completely replace the time range

Parameters
start[in] The start of the time range.
stop[in] The stop of the time range.
numEvents[in] The number of events in time range.

Definition at line 107 of file Tempus_TimeEventRange_impl.hpp.

template<class Scalar >
virtual Scalar Tempus::TimeEventRange< Scalar >::getTimeStart ( ) const
inlinevirtual

Return the start of the time range.

Definition at line 125 of file Tempus_TimeEventRange_decl.hpp.

template<class Scalar >
void Tempus::TimeEventRange< Scalar >::setTimeStart ( Scalar  start)
virtual

Set the start of the time range.

Definition at line 122 of file Tempus_TimeEventRange_impl.hpp.

template<class Scalar >
virtual Scalar Tempus::TimeEventRange< Scalar >::getTimeStop ( ) const
inlinevirtual

Return the stop of the time range.

Definition at line 130 of file Tempus_TimeEventRange_decl.hpp.

template<class Scalar >
void Tempus::TimeEventRange< Scalar >::setTimeStop ( Scalar  stop)
virtual

Set the stop of the time range.

Definition at line 131 of file Tempus_TimeEventRange_impl.hpp.

template<class Scalar >
virtual Scalar Tempus::TimeEventRange< Scalar >::getTimeStride ( ) const
inlinevirtual

Return the stride of the time range.

Definition at line 135 of file Tempus_TimeEventRange_decl.hpp.

template<class Scalar >
void Tempus::TimeEventRange< Scalar >::setTimeStride ( Scalar  stride)
virtual

Set the stride of the time range.

If start_ = stop_, then stride_ = 0.0, set numEvents_ = 1, and return. If stride_ > stop_-start_ or stride_ < 2*absTol_, then stride = stop_-start_.

Reset numEvents_ = (stop_-start_)/stride_ + 1.

Parameters
stride[in] The time stride for the time range.

Definition at line 153 of file Tempus_TimeEventRange_impl.hpp.

template<class Scalar >
virtual int Tempus::TimeEventRange< Scalar >::getNumEvents ( ) const
inlinevirtual

Return the number of time events in the time range.

Definition at line 150 of file Tempus_TimeEventRange_decl.hpp.

template<class Scalar >
void Tempus::TimeEventRange< Scalar >::setNumEvents ( int  numEvents)
virtual

Set the number of time events.

  • If numEvents_ < 0, then reset numEvents from start_, stop_ and stride_.
  • ElseIf start_ = stop_, numEvents = 1, and reset stride = 0.
  • ElseIf numEvents_ < 2, numEvents = 2, and stride = stop_ - start_.
  • Else stride = (stop_ - start_)/(numEvents_-1).

If the resulting stride is less than twice the absolute tolerance, the stride is set to 2*absTol_.

Parameters
numEvents[in] The number of events in time range.

Definition at line 170 of file Tempus_TimeEventRange_impl.hpp.

template<class Scalar >
virtual Scalar Tempus::TimeEventRange< Scalar >::getRelTol ( ) const
inlinevirtual

Return the relative tolerance.

Definition at line 167 of file Tempus_TimeEventRange_decl.hpp.

template<class Scalar >
void Tempus::TimeEventRange< Scalar >::setRelTol ( Scalar  relTol)
virtual

Set the relative tolerance.

The relative tolerance is used to set the absolute tolerance along with the TimeEvent time scale, i.e., absTol_ = timeScale_ * relTol_. Also see getAbsTol() and setTimeScale().

Parameters
relTol[in] The input relative tolerance.

Definition at line 195 of file Tempus_TimeEventRange_impl.hpp.

template<class Scalar >
virtual Scalar Tempus::TimeEventRange< Scalar >::getAbsTol ( ) const
inlinevirtual

Return the absolute tolerance.

The absolute tolerance is primarily used to determine if two times are equal (i.e., t1 is equal to t2, if t2-absTol_ < t1 < t2+absTol_).

Returns
The absolute tolerance.

Reimplemented from Tempus::TimeEventBase< Scalar >.

Definition at line 188 of file Tempus_TimeEventRange_decl.hpp.

template<class Scalar >
virtual bool Tempus::TimeEventRange< Scalar >::getLandOnExactly ( ) const
inlinevirtual

Set if the time events need to be landed on exactly.

If true, this sets whether the time events need to be landed on exactly, e.g., the time step needs to be adjusted so the solution is determined at the time event.

If false, this indicates that time event will still occur but can be stepped over without changing the time step.

Returns
LOE Flag indicating if TimeEvent should land on the time event exactly.

Reimplemented from Tempus::TimeEventBase< Scalar >.

Definition at line 202 of file Tempus_TimeEventRange_decl.hpp.

template<class Scalar >
virtual void Tempus::TimeEventRange< Scalar >::setLandOnExactly ( bool  LOE)
inlinevirtual

Set if the time event should be landed on exactly.

Definition at line 205 of file Tempus_TimeEventRange_decl.hpp.

template<class Scalar >
void Tempus::TimeEventRange< Scalar >::describe ( Teuchos::FancyOStream out,
const Teuchos::EVerbosityLevel  verbLevel 
) const
virtual

Describe member data.

Reimplemented from Tempus::TimeEventBase< Scalar >.

Definition at line 288 of file Tempus_TimeEventRange_impl.hpp.

template<class Scalar >
Teuchos::RCP< const Teuchos::ParameterList > Tempus::TimeEventRange< Scalar >::getValidParameters ( ) const
virtual

Return a valid ParameterList with current settings.

The returned ParameterList will contain the current parameters and can be used to reconstruct the TimeEventRange using createTimeEventRange(...). The ParameterList will have the TimeEventRange parameters along with all the parameters for the TimeEvents contained in the composite.

Returns
Teuchos::ParameterList of TimeEventRange.

Reimplemented from Tempus::TimeEventBase< Scalar >.

Definition at line 311 of file Tempus_TimeEventRange_impl.hpp.

template<class Scalar >
void Tempus::TimeEventRange< Scalar >::setTimeScale ( )
protectedvirtual

Set the time scale for the time events.

This sets the reference time scale, which is solely determined from the time events in the range (this is why it is a protected function). It tries to find an appropriate scale for the time events, e.g., max(t0, ... , tn).

Definition at line 140 of file Tempus_TimeEventRange_impl.hpp.

Member Data Documentation

template<class Scalar >
Scalar Tempus::TimeEventRange< Scalar >::start_
protected

Start of time range.

Definition at line 236 of file Tempus_TimeEventRange_decl.hpp.

template<class Scalar >
Scalar Tempus::TimeEventRange< Scalar >::stop_
protected

Stop of time range.

Definition at line 237 of file Tempus_TimeEventRange_decl.hpp.

template<class Scalar >
Scalar Tempus::TimeEventRange< Scalar >::stride_
protected

Stride of time range.

Definition at line 238 of file Tempus_TimeEventRange_decl.hpp.

template<class Scalar >
unsigned Tempus::TimeEventRange< Scalar >::numEvents_
protected

Number of events in time range.

Definition at line 239 of file Tempus_TimeEventRange_decl.hpp.

template<class Scalar >
Scalar Tempus::TimeEventRange< Scalar >::timeScale_
protected

A reference time scale, max(abs(start_,stop_)).

Definition at line 241 of file Tempus_TimeEventRange_decl.hpp.

template<class Scalar >
Scalar Tempus::TimeEventRange< Scalar >::relTol_
protected

Relative time tolerance for matching time events.

Definition at line 242 of file Tempus_TimeEventRange_decl.hpp.

template<class Scalar >
Scalar Tempus::TimeEventRange< Scalar >::absTol_
protected

Absolute time tolerance, relTol_*timeScale_.

Definition at line 243 of file Tempus_TimeEventRange_decl.hpp.

template<class Scalar >
bool Tempus::TimeEventRange< Scalar >::landOnExactly_
protected

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.

Definition at line 244 of file Tempus_TimeEventRange_decl.hpp.


The documentation for this class was generated from the following files: