9 #include "Teuchos_UnitTestHarness.hpp"
10 #include "Teuchos_XMLParameterListHelpers.hpp"
11 #include "Teuchos_TimeMonitor.hpp"
12 #include "Teuchos_DefaultComm.hpp"
14 #include "Tempus_TimeEventRangeIndex.hpp"
16 #include "../TestUtils/Tempus_ConvergenceTestUtils.hpp"
19 namespace Tempus_Unit_Test {
23 using Teuchos::rcp_const_cast;
24 using Teuchos::rcp_dynamic_cast;
33 TEST_COMPARE(te->getName(), ==,
"TimeEventRangeIndex");
36 TEST_COMPARE(te->getIndexStart (), ==, 0);
37 TEST_COMPARE(te->getIndexStop (), ==, 0);
38 TEST_COMPARE(te->getIndexStride(), ==, 1);
39 TEST_COMPARE(te->getNumEvents (), ==, 1);
42 TEST_COMPARE(te->isTime(1.0), ==,
false);
43 TEST_COMPARE(te->timeToNextEvent(1.0), ==, te->getDefaultTime());
44 TEST_COMPARE(te->timeOfNextEvent(1.0), ==, te->getDefaultTime());
45 TEST_COMPARE(te->eventInRange(1.0, 4.0), ==,
false);
54 "TestName", -1, 10, 2));
56 TEST_COMPARE(te->getName(), ==,
"TestName");
59 TEST_COMPARE(te->getIndexStart (), ==, -1);
60 TEST_COMPARE(te->getIndexStop (), ==, 10);
61 TEST_COMPARE(te->getIndexStride(), ==, 2);
62 TEST_COMPARE(te->getNumEvents (), ==, 6);
72 te->setName(
"TestName");
73 TEST_COMPARE(te->getName(), ==,
"TestName");
77 TEST_COMPARE(te->getIndexStart (), ==, 1);
78 TEST_COMPARE(te->getIndexStop (), ==, 1);
79 TEST_COMPARE(te->getIndexStride(), ==, 1);
80 TEST_COMPARE(te->getNumEvents (), ==, 1);
84 TEST_COMPARE(te->getIndexStart (), ==, 1);
85 TEST_COMPARE(te->getIndexStop (), ==, 5);
86 TEST_COMPARE(te->getIndexStride(), ==, 1);
87 TEST_COMPARE(te->getNumEvents (), ==, 5);
90 te->setIndexStride(2);
91 TEST_COMPARE(te->getIndexStart (), ==, 1);
92 TEST_COMPARE(te->getIndexStop (), ==, 5);
93 TEST_COMPARE(te->getIndexStride(), ==, 2);
94 TEST_COMPARE(te->getNumEvents (), ==, 3);
97 te->setIndexRange(-5, 5, 3);
98 TEST_COMPARE(te->getIndexStart (), ==, -5);
99 TEST_COMPARE(te->getIndexStop (), ==, 5);
100 TEST_COMPARE(te->getIndexStride(), ==, 3);
101 TEST_COMPARE(te->getNumEvents (), ==, 4);
110 te->setIndexStart(1);
111 te->setIndexStop (5);
112 TEST_COMPARE(te->getIndexStart (), ==, 1);
113 TEST_COMPARE(te->getIndexStop (), ==, 5);
116 te->setIndexStride(-1);
117 TEST_COMPARE(te->getIndexStride(), ==, 1);
118 TEST_COMPARE(te->getNumEvents (), ==, 5);
121 te->setIndexStride(5);
122 TEST_COMPARE(te->getIndexStride(), ==, 4);
123 TEST_COMPARE(te->getNumEvents (), ==, 2);
132 te->setIndexRange(-5, 5, 3);
135 TEST_COMPARE(te->isIndex(-6), ==,
false);
136 TEST_COMPARE(te->isIndex(-5), ==, true );
137 TEST_COMPARE(te->isIndex(-4), ==,
false);
139 TEST_COMPARE(te->isIndex(0), ==,
false);
140 TEST_COMPARE(te->isIndex(1), ==, true );
141 TEST_COMPARE(te->isIndex(2), ==,
false);
143 TEST_COMPARE(te->isIndex(3), ==,
false);
144 TEST_COMPARE(te->isIndex(4), ==, true );
145 TEST_COMPARE(te->isIndex(5), ==,
false);
154 te->setIndexRange(-5, 5, 3);
157 TEST_COMPARE(te->indexToNextEvent(-9), ==, 4);
158 TEST_COMPARE(te->indexToNextEvent(-5), ==, 0);
159 TEST_COMPARE(te->indexToNextEvent(-4), ==, 2);
161 TEST_COMPARE(te->indexToNextEvent(-1), ==, 2);
162 TEST_COMPARE(te->indexToNextEvent( 1), ==, 0);
163 TEST_COMPARE(te->indexToNextEvent( 3), ==, 1);
165 TEST_COMPARE(te->indexToNextEvent( 2), ==, 2);
166 TEST_COMPARE(te->indexToNextEvent( 4), ==, 0);
167 TEST_COMPARE(te->indexToNextEvent( 8), ==,-4);
176 te->setIndexRange(-5, 5, 3);
179 TEST_COMPARE(te->indexOfNextEvent(-9), ==, -5);
180 TEST_COMPARE(te->indexOfNextEvent(-5), ==, -5);
181 TEST_COMPARE(te->indexOfNextEvent(-4), ==, -2);
183 TEST_COMPARE(te->indexOfNextEvent(-1), ==, 1);
184 TEST_COMPARE(te->indexOfNextEvent( 1), ==, 1);
185 TEST_COMPARE(te->indexOfNextEvent( 3), ==, 4);
187 TEST_COMPARE(te->indexOfNextEvent( 2), ==, 4);
188 TEST_COMPARE(te->indexOfNextEvent( 4), ==, 4);
189 TEST_COMPARE(te->indexOfNextEvent( 8), ==, 4);
198 te->setIndexRange(-5, 5, 3);
202 TEST_COMPARE(te->eventInRangeIndex(-9, -6), ==,
false);
203 TEST_COMPARE(te->eventInRangeIndex(-9, -5), ==, true );
204 TEST_COMPARE(te->eventInRangeIndex(-9, -4), ==, true );
206 TEST_COMPARE(te->eventInRangeIndex(-1, 0), ==,
false);
207 TEST_COMPARE(te->eventInRangeIndex(-1, 1), ==, true );
208 TEST_COMPARE(te->eventInRangeIndex(-1, 2), ==, true );
210 TEST_COMPARE(te->eventInRangeIndex(2, 3), ==,
false);
211 TEST_COMPARE(te->eventInRangeIndex(2, 4), ==, true );
212 TEST_COMPARE(te->eventInRangeIndex(2, 5), ==, true );
215 TEST_COMPARE(te->eventInRangeIndex(-6.0, -3), ==, true );
216 TEST_COMPARE(te->eventInRangeIndex(-5.0, -3), ==, true );
217 TEST_COMPARE(te->eventInRangeIndex(-4.0, -3), ==,
false);
219 TEST_COMPARE(te->eventInRangeIndex(-3, 0), ==, true );
220 TEST_COMPARE(te->eventInRangeIndex(-2, 0), ==, true );
221 TEST_COMPARE(te->eventInRangeIndex(-1, 0), ==,
false);
223 TEST_COMPARE(te->eventInRangeIndex(3, 8), ==, true );
224 TEST_COMPARE(te->eventInRangeIndex(4, 8), ==, true );
225 TEST_COMPARE(te->eventInRangeIndex(5, 8), ==,
false);
TimeEventRangeIndex specifies a start, stop and stride index.
TEUCHOS_UNIT_TEST(BackwardEuler, Default_Construction)