10#ifndef Tempus_TimeEventRangeIndex_impl_hpp
11#define Tempus_TimeEventRangeIndex_impl_hpp
15template <
class Scalar>
20 std::ostringstream oss;
27template <
class Scalar>
29 int stride, std::string name)
34 std::ostringstream oss;
35 oss <<
"TimeEventRangeIndex (" << start <<
"; " << stop <<
"; " << stride
46template <
class Scalar>
56template <
class Scalar>
67template <
class Scalar>
80template <
class Scalar>
89template <
class Scalar>
93 if (index < start_ || index > indexOfLast)
return false;
99template <
class Scalar>
105template <
class Scalar>
123template <
class Scalar>
127 if (index1 > index2) {
135 if (index2 <
start_ || indexOfLast < index1)
return false;
137 const int strideJustBeforeIndex1 = std::min(
140 const int strideJustAfterIndex2 = std::max(
143 for (
int i = strideJustBeforeIndex1; i <= strideJustAfterIndex2; i++) {
145 if (index1 < indexEvent && indexEvent <= index2)
return true;
151template <
class Scalar>
153 Teuchos::FancyOStream &out,
const Teuchos::EVerbosityLevel )
const
155 auto l_out = Teuchos::fancyOStream(out.getOStream());
156 Teuchos::OSTab ostab(*l_out, 2,
"TimeEventRangeIndex");
157 l_out->setOutputToRootOnly(0);
159 *l_out <<
"TimeEventRangeIndex:"
161 <<
" name = " << this->
getName() <<
"\n"
162 <<
" Type = " << this->
getType() <<
"\n"
163 <<
" start_ = " <<
start_ <<
"\n"
164 <<
" stop_ = " <<
stop_ <<
"\n"
165 <<
" stride_ = " <<
stride_ <<
"\n"
166 <<
" numEvents_ = " <<
numEvents_ << std::endl;
169template <
class Scalar>
170Teuchos::RCP<const Teuchos::ParameterList>
173 Teuchos::RCP<Teuchos::ParameterList> pl =
174 Teuchos::parameterList(
"Time Event Range Index");
177 pl->set(
"Name", this->
getName());
178 pl->set(
"Type",
"Range Index");
180 pl->set(
"Start Index",
getIndexStart(),
"Start of Index range");
181 pl->set(
"Stop Index",
getIndexStop(),
"Stop of Index range");
182 pl->set(
"Stride Index",
getIndexStride(),
"Stride of Index range");
190template <
class Scalar>
192 Teuchos::RCP<Teuchos::ParameterList> pl)
195 if (pl == Teuchos::null)
return teri;
197 TEUCHOS_TEST_FOR_EXCEPTION(
198 pl->get<std::string>(
"Type",
"Range Index") !=
"Range Index",
200 "Error - Time Event Type != 'Range Index'. (='" +
201 pl->get<std::string>(
"Type") +
"')\n");
203 pl->validateParametersAndSetDefaults(*teri->getValidParameters());
205 teri->setName(pl->get(
"Name",
"From createTimeEventRangeIndex"));
206 teri->setIndexStart(pl->get(
"Start Index", teri->getIndexStart()));
207 teri->setIndexStop(pl->get(
"Stop Index", teri->getIndexStop()));
208 teri->setIndexStride(pl->get(
"Stride Index", teri->getIndexStride()));
virtual void setType(std::string s)
virtual std::string getName() const
Return the name of the TimeEvent.
virtual std::string getType() const
Return the type of TimeEvent.
virtual void setName(std::string name)
Set the name of the TimeEvent.
virtual int getDefaultIndex() const
Return the default index used by TimeEvents.
TimeEventRangeIndex specifies a start, stop and stride index.
virtual int getIndexStop() const
Return the stop of the index range.
virtual bool isIndex(int index) const
Test if index is a time event.
virtual void describe(Teuchos::FancyOStream &out, const Teuchos::EVerbosityLevel verbLevel) const
Describe member data.
int stop_
Stop of index range.
virtual void setIndexStop(int stop)
Set the stop of the index range.
virtual int indexOfNextEvent(int index) const
Return the index of the next event following the input index.
TimeEventRangeIndex()
Default constructor.
int stride_
Stride of index range.
virtual void setIndexRange(int start, int stop, int stride)
Set the range of event indices.
virtual bool eventInRangeIndex(int index1, int index2) const
Test if an event occurs within the index range.
unsigned numEvents_
Number of events in index range.
virtual void setIndexStart(int start)
Set the start of the index range.
virtual void setNumEvents()
Set the number of events from start_, stop_ and stride_.
virtual int indexToNextEvent(int index) const
How many indices until the next event.
virtual int getIndexStride() const
Return the stride of the index range.
virtual int getIndexStart() const
Return the start of the index range.
int start_
Start of index range.
virtual void setIndexStride(int stride)
Set the stride of the index range.
Teuchos::RCP< const Teuchos::ParameterList > getValidParameters() const
Return a valid ParameterList with current settings.
Teuchos::RCP< TimeEventRangeIndex< Scalar > > createTimeEventRangeIndex(Teuchos::RCP< Teuchos::ParameterList > pList)
Nonmember Constructor via ParameterList.