12 #include "Tempus_TimeEventListIndex.hpp"
14 namespace Tempus_Unit_Test {
18 using Teuchos::rcp_const_cast;
19 using Teuchos::rcp_dynamic_cast;
35 TEST_COMPARE(te->indexToNextEvent(0), ==, te->getDefaultIndex());
36 TEST_COMPARE(te->indexOfNextEvent(0), ==, te->getDefaultIndex());
42 TEST_COMPARE(te->timeToNextEvent(1.0), ==, te->getDefaultTime());
43 TEST_COMPARE(te->timeOfNextEvent(1.0), ==, te->getDefaultTime());
51 std::vector<int> testVector;
52 testVector.push_back(-2);
53 testVector.push_back(0);
54 testVector.push_back(7);
55 testVector.push_back(3);
56 testVector.push_back(-5);
62 auto testList = te->getIndexList();
65 TEST_COMPARE(testList[1], ==, -2);
66 TEST_COMPARE(testList[2], ==, 0);
67 TEST_COMPARE(testList[3], ==, 3);
68 TEST_COMPARE(testList[4], ==, 7);
72 TEST_COMPARE(te->getIndexList().size(), ==, 5);
74 TEST_COMPARE(te->getIndexList().size(), ==, 6);
83 te->setName(
"TestName");
102 auto testList = te->getIndexList();
105 TEST_COMPARE(testList[1], ==, -5);
106 TEST_COMPARE(testList[2], ==, -2);
107 TEST_COMPARE(testList[3], ==, 1);
108 TEST_COMPARE(testList[4], ==, 4);
115 std::vector<int> testListIndex;
116 testListIndex.push_back(-5);
117 testListIndex.push_back(1);
118 testListIndex.push_back(-2);
119 testListIndex.push_back(4);
120 testListIndex.push_back(-9);
138 TEST_COMPARE(te->indexToNextEvent(4), ==, te->getDefaultIndex() - 4);
139 TEST_COMPARE(te->indexToNextEvent(9), ==, te->getDefaultIndex() - 9);
146 std::vector<int> testListIndex;
147 testListIndex.push_back(-5);
148 testListIndex.push_back(1);
149 testListIndex.push_back(-2);
150 testListIndex.push_back(4);
151 testListIndex.push_back(-9);
169 TEST_COMPARE(te->indexOfNextEvent(4), ==, te->getDefaultIndex());
170 TEST_COMPARE(te->indexOfNextEvent(9), ==, te->getDefaultIndex());
177 std::vector<int> testListIndex;
178 testListIndex.push_back(-5);
179 testListIndex.push_back(1);
180 testListIndex.push_back(-2);
181 testListIndex.push_back(4);
182 testListIndex.push_back(-9);
191 TEST_COMPARE(te->eventInRangeIndex(-12.0, -9), ==,
true);
192 TEST_COMPARE(te->eventInRangeIndex(-12.0, -8), ==,
true);
223 auto pl = teli->getValidParameters();
225 TEST_COMPARE(pl->get<std::string>(
"Type"), ==,
"List Index");
226 TEST_COMPARE(pl->get<std::string>(
"Name"), ==,
"TimeEventListIndex");
227 TEST_COMPARE(pl->get<std::string>(
"Index List"), ==,
"");
230 std::ostringstream unusedParameters;
231 pl->unused(unusedParameters);
242 Teuchos::parameterList(
"Time Event List Index");
244 pl->
set(
"Name",
"Unit Test Time Event List Index");
245 pl->
set(
"Type",
"List Index");
247 std::vector<int> indices;
248 indices.push_back(-99);
249 indices.push_back(13);
250 indices.push_back(97);
251 indices.push_back(101);
252 std::ostringstream list;
253 for (std::size_t i = 0; i < indices.size() - 1; ++i)
254 list << indices[i] <<
", ";
255 list << indices[indices.size() - 1];
256 pl->
set<std::string>(
"Index List", list.str());
259 auto teli = Tempus::createTimeEventListIndex<double>(pl);
263 TEST_COMPARE(teli->getName(), ==,
"Unit Test Time Event List Index");
265 auto teList = teli->getIndexList();
TimeEventListIndex specifies a list of index events.
#define TEST_COMPARE(v1, comp, v2)
ParameterList & set(std::string const &name, T &&value, std::string const &docString="", RCP< const ParameterEntryValidator > const &validator=null)
TEUCHOS_DEPRECATED RCP< T > rcp(T *p, Dealloc_T dealloc, bool owns_mem)
TEUCHOS_UNIT_TEST(BackwardEuler, Default_Construction)
Teuchos::RCP< TimeEventListIndex< Scalar > > createTimeEventListIndex(Teuchos::RCP< Teuchos::ParameterList > pList)
Nonmember Constructor via ParameterList.