Tempus  Version of the Day
Time Integration
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Tempus_UnitTest_TimeEventRange.cpp
Go to the documentation of this file.
1 //@HEADER
2 // *****************************************************************************
3 // Tempus: Time Integration and Sensitivity Analysis Package
4 //
5 // Copyright 2017 NTESS and the Tempus contributors.
6 // SPDX-License-Identifier: BSD-3-Clause
7 // *****************************************************************************
8 //@HEADER
9 
11 #include "Tempus_TimeEventRange.hpp"
12 
13 static double PI = M_PI;
14 
15 namespace Tempus_Unit_Test {
16 
17 using Teuchos::RCP;
18 using Teuchos::rcp;
19 using Teuchos::rcp_const_cast;
20 using Teuchos::rcp_dynamic_cast;
21 
22 // ************************************************************
23 // ************************************************************
24 TEUCHOS_UNIT_TEST(TimeEventRange, Default_Construction)
25 {
26  auto te = rcp(new Tempus::TimeEventRange<double>());
27 
28  TEST_COMPARE(te->getName(), ==, "TimeEventRange (0; 0; 0)");
29  te->setName("TestName");
30  TEST_COMPARE(te->getName(), ==, "TestName");
31 
32  TEST_FLOATING_EQUALITY(te->getTimeStart(), 0.0, 1.0e-14);
33  TEST_FLOATING_EQUALITY(te->getTimeStop(), 0.0, 1.0e-14);
34  TEST_FLOATING_EQUALITY(te->getTimeStride(), 0.0, 1.0e-14);
35  TEST_COMPARE(te->getNumEvents(), ==, 1);
36 
38  te->getRelTol(), std::numeric_limits<double>::epsilon() * 100.0, 1.0e-14);
40  te->getAbsTol(), std::numeric_limits<double>::epsilon() * 100.0, 1.0e-14);
41 
42  TEST_COMPARE(te->getLandOnExactly(), ==, true);
43 }
44 
45 // ************************************************************
46 // ************************************************************
47 TEUCHOS_UNIT_TEST(TimeEventRange, Full_Construction_Stride)
48 {
49  auto te = rcp(new Tempus::TimeEventRange<double>(0.0, PI, 1.0, "TestName",
50  true, 1.0e-14));
51 
52  // te->describe(out, Teuchos::VERB_EXTREME);
53 
54  TEST_COMPARE(te->getName(), ==, "TestName");
55 
56  // Test when everything is zero.
57  TEST_FLOATING_EQUALITY(te->getTimeStart(), 0.0, 1.0e-14);
58  TEST_FLOATING_EQUALITY(te->getTimeStop(), PI, 1.0e-14);
59  TEST_FLOATING_EQUALITY(te->getTimeStride(), 1.0, 1.0e-14);
60  TEST_COMPARE(te->getNumEvents(), ==, 4);
61 
62  auto teRange2 = rcp(new Tempus::TimeEventRange<double>(
63  -PI / 2.0, PI / 2.0, PI / 4.0, "teRange2", true, 1.0e-14));
64 
65  TEST_FLOATING_EQUALITY(teRange2->timeToNextEvent(0.1), PI / 4.0 - 0.1,
66  1.0e-14);
67 }
68 
69 // ************************************************************
70 // ************************************************************
71 TEUCHOS_UNIT_TEST(TimeEventRange, Full_Construction_NumEvents)
72 {
73  auto te = rcp(new Tempus::TimeEventRange<double>(0.0, PI, 5, "TestName", true,
74  1.0e-14));
75 
76  TEST_COMPARE(te->getName(), ==, "TestName");
77 
78  // Test when everything is zero.
79  TEST_FLOATING_EQUALITY(te->getTimeStart(), 0.0, 1.0e-14);
80  TEST_FLOATING_EQUALITY(te->getTimeStop(), PI, 1.0e-14);
81  TEST_FLOATING_EQUALITY(te->getTimeStride(), PI / 4.0, 1.0e-14);
82  TEST_COMPARE(te->getNumEvents(), ==, 5);
83 }
84 
85 // ************************************************************
86 // ************************************************************
87 TEUCHOS_UNIT_TEST(TimeEventRange, Basic_Accessors)
88 {
89  auto te = rcp(new Tempus::TimeEventRange<double>());
90 
91  te->setRelTol(0.1);
92  TEST_FLOATING_EQUALITY(te->getRelTol(), 0.1, 1.0e-14);
93  te->setRelTol(1.0e-14);
94  te->setLandOnExactly(false);
95  TEST_COMPARE(te->getLandOnExactly(), ==, false);
96  te->setLandOnExactly(true);
97 
98  // Reset start after stop.
99  te->setTimeStart(1.0);
100  TEST_FLOATING_EQUALITY(te->getTimeStart(), 1.0, 1.0e-14);
101  TEST_FLOATING_EQUALITY(te->getTimeStop(), 1.0, 1.0e-14);
102  TEST_FLOATING_EQUALITY(te->getTimeStride(), 0.0, 1.0e-14);
103  TEST_COMPARE(te->getNumEvents(), ==, 1);
104 
105  // Reset stop.
106  te->setTimeStop(4.0);
107  TEST_FLOATING_EQUALITY(te->getTimeStart(), 1.0, 1.0e-14);
108  TEST_FLOATING_EQUALITY(te->getTimeStop(), 4.0, 1.0e-14);
109  TEST_FLOATING_EQUALITY(te->getTimeStride(), 3.0, 1.0e-14);
110  TEST_COMPARE(te->getNumEvents(), ==, 2);
111 
112  // Reset stride.
113  te->setTimeStride(0.5);
114  TEST_FLOATING_EQUALITY(te->getTimeStart(), 1.0, 1.0e-14);
115  TEST_FLOATING_EQUALITY(te->getTimeStop(), 4.0, 1.0e-14);
116  TEST_FLOATING_EQUALITY(te->getTimeStride(), 0.5, 1.0e-14);
117  TEST_COMPARE(te->getNumEvents(), ==, 7);
118 }
119 
120 // ************************************************************
121 // ************************************************************
122 TEUCHOS_UNIT_TEST(TimeEventRange, Stride)
123 {
124  auto te = rcp(new Tempus::TimeEventRange<double>());
125  te->setTimeStart(1.0);
126  te->setTimeStop(4.0);
127  te->setTimeStride(0.5);
128 
129  // Negative stride should be reset to stop_-start_.
130  te->setTimeStride(-0.5);
131  TEST_FLOATING_EQUALITY(te->getTimeStart(), 1.0, 1.0e-14);
132  TEST_FLOATING_EQUALITY(te->getTimeStop(), 4.0, 1.0e-14);
133  TEST_FLOATING_EQUALITY(te->getTimeStride(), 0.5, 1.0e-14);
134  TEST_COMPARE(te->getNumEvents(), ==, 7);
135 
136  // Large stride should be reset to stop_-start_.
137  te->setTimeStride(5.0);
138  TEST_FLOATING_EQUALITY(te->getTimeStart(), 1.0, 1.0e-14);
139  TEST_FLOATING_EQUALITY(te->getTimeStop(), 4.0, 1.0e-14);
140  TEST_FLOATING_EQUALITY(te->getTimeStride(), 3.0, 1.0e-14);
141  TEST_COMPARE(te->getNumEvents(), ==, 2);
142 
143  // Stride smaller than relative tolerance should be reset to stop_-start_.
144  te->setTimeStride(1.0e-14);
145  TEST_FLOATING_EQUALITY(te->getTimeStart(), 1.0, 1.0e-14);
146  TEST_FLOATING_EQUALITY(te->getTimeStop(), 4.0, 1.0e-14);
147  TEST_FLOATING_EQUALITY(te->getTimeStride(), 3.0, 1.0e-14);
148  TEST_COMPARE(te->getNumEvents(), ==, 2);
149 }
150 
151 // ************************************************************
152 // ************************************************************
153 TEUCHOS_UNIT_TEST(TimeEventRange, setTimeRange)
154 {
155  auto te = rcp(new Tempus::TimeEventRange<double>());
156 
157  // Set with time range.
158  te->setTimeRange(0.0, PI, 1.0);
159  TEST_FLOATING_EQUALITY(te->getTimeStart(), 0.0, 1.0e-14);
160  TEST_FLOATING_EQUALITY(te->getTimeStop(), PI, 1.0e-14);
161  TEST_FLOATING_EQUALITY(te->getTimeStride(), 1.0, 1.0e-14);
162  TEST_COMPARE(te->getNumEvents(), ==, 4);
163 }
164 
165 // ************************************************************
166 // ************************************************************
167 TEUCHOS_UNIT_TEST(TimeEventRange, isTime)
168 {
169  auto te = rcp(new Tempus::TimeEventRange<double>());
170  te->setTimeRange(0.0, PI, 1.0);
171  te->setRelTol(1.0e-14);
172 
173  // Before first event. (This is exactly one stride before range.)
174  TEST_COMPARE(te->isTime(-1.0 + -10.0e-14), ==,
175  false); // Just outside tolerance.
176  TEST_COMPARE(te->isTime(-1.0 + -0.1e-14), ==,
177  false); // Just inside tolerance.
178  TEST_COMPARE(te->isTime(-1.0 + 0.0), ==, false); // Right on timeEvent.
179  TEST_COMPARE(te->isTime(-1.0 + 0.1e-14), ==,
180  false); // Just inside tolerance.
181  TEST_COMPARE(te->isTime(-1.0 + 10.0e-14), ==,
182  false); // Just outside tolerance.
183 
184  // Around first event.
185  TEST_COMPARE(te->isTime(-10.0e-14), ==, false); // Just outside tolerance.
186  TEST_COMPARE(te->isTime(-0.1e-14), ==, true); // Just inside tolerance.
187  TEST_COMPARE(te->isTime(0.0), ==, true); // Right on timeEvent.
188  TEST_COMPARE(te->isTime(0.1e-14), ==, true); // Just inside tolerance.
189  TEST_COMPARE(te->isTime(10.0e-14), ==, false); // Just outside tolerance.
190 
191  // Around mid event.
192  TEST_COMPARE(te->isTime(1.0 + -10.0e-14), ==,
193  false); // Just outside tolerance.
194  TEST_COMPARE(te->isTime(1.0 + -0.1e-14), ==, true); // Just inside tolerance.
195  TEST_COMPARE(te->isTime(1.0 + 0.0), ==, true); // Right on timeEvent.
196  TEST_COMPARE(te->isTime(1.0 + 0.1e-14), ==, true); // Just inside tolerance.
197  TEST_COMPARE(te->isTime(1.0 + 10.0e-14), ==,
198  false); // Just outside tolerance.
199 
200  // Around last event.
201  TEST_COMPARE(te->isTime(3.0 + -10.0e-14), ==,
202  false); // Just outside tolerance.
203  TEST_COMPARE(te->isTime(3.0 + -0.1e-14), ==, true); // Just inside tolerance.
204  TEST_COMPARE(te->isTime(3.0 + 0.0), ==, true); // Right on timeEvent.
205  TEST_COMPARE(te->isTime(3.0 + 0.1e-14), ==, true); // Just inside tolerance.
206  TEST_COMPARE(te->isTime(3.0 + 10.0e-14), ==,
207  false); // Just outside tolerance.
208 
209  // After last event. (This is exactly one stride after range.)
210  TEST_COMPARE(te->isTime(4.0 + -10.0e-14), ==,
211  false); // Just outside tolerance.
212  TEST_COMPARE(te->isTime(4.0 + -0.1e-14), ==,
213  false); // Just inside tolerance.
214  TEST_COMPARE(te->isTime(4.0 + 0.0), ==, false); // Right on timeEvent.
215  TEST_COMPARE(te->isTime(4.0 + 0.1e-14), ==, false); // Just inside tolerance.
216  TEST_COMPARE(te->isTime(4.0 + 10.0e-14), ==,
217  false); // Just outside tolerance.
218 }
219 
220 // ************************************************************
221 // ************************************************************
222 TEUCHOS_UNIT_TEST(TimeEventRange, timeToNextEvent)
223 {
224  auto te = rcp(new Tempus::TimeEventRange<double>());
225  te->setTimeRange(0.0, PI, 1.0);
226  te->setRelTol(1.0e-14);
227 
228  // Test timeToNextEvent.
229  // Around first event.
230  TEST_FLOATING_EQUALITY(te->timeToNextEvent(-10.0e-14), 10.0e-14,
231  1.0e-14); // Just outside tolerance.
232  TEST_FLOATING_EQUALITY(te->timeToNextEvent(-0.1e-14), 1.0 + 0.1e-14,
233  1.0e-14); // Just inside tolerance.
234  TEST_FLOATING_EQUALITY(te->timeToNextEvent(0.0), 1.0 + 0.0,
235  1.0e-14); // Right on timeEvent.
236  TEST_FLOATING_EQUALITY(te->timeToNextEvent(0.1e-14), 1.0 - 0.1e-14,
237  1.0e-14); // Just inside tolerance.
238  TEST_FLOATING_EQUALITY(te->timeToNextEvent(10.0e-14), 1.0 - 10.0e-14,
239  1.0e-14); // Just outside tolerance.
240 
241  // Around mid event.
242  TEST_FLOATING_EQUALITY(te->timeToNextEvent(1.0 + -10.0e-14), 10.0e-14,
243  1.0e-02); // Just outside tolerance.
244  TEST_FLOATING_EQUALITY(te->timeToNextEvent(1.0 + -0.1e-14), 1.0 + 0.1e-14,
245  1.0e-01); // Just inside tolerance.
246  TEST_FLOATING_EQUALITY(te->timeToNextEvent(1.0 + 0.0), 1.0 + 0.0,
247  1.0e-02); // Right on timeEvent.
248  TEST_FLOATING_EQUALITY(te->timeToNextEvent(1.0 + 0.1e-14), 1.0 - 0.1e-14,
249  1.0e-01); // Just inside tolerance.
250  TEST_FLOATING_EQUALITY(te->timeToNextEvent(1.0 + 10.0e-14), 1.0 - 10.0e-14,
251  1.0e-14); // Just outside tolerance.
252 
253  // Around last event.
254  TEST_FLOATING_EQUALITY(te->timeToNextEvent(3.0 + -10.0e-14), 10.0e-14,
255  1.0e-02); // Just outside tolerance.
256  TEST_FLOATING_EQUALITY(te->timeToNextEvent(3.0 + -0.1e-14),
257  te->getDefaultTime(),
258  1.0e-01); // Just inside tolerance.
259  TEST_FLOATING_EQUALITY(te->timeToNextEvent(3.0 + 0.0), te->getDefaultTime(),
260  1.0e-02); // Right on timeEvent.
261  TEST_FLOATING_EQUALITY(te->timeToNextEvent(3.0 + 0.1e-14),
262  te->getDefaultTime(),
263  1.0e-01); // Just inside tolerance.
264  TEST_FLOATING_EQUALITY(te->timeToNextEvent(3.0 + 10.0e-14),
265  te->getDefaultTime(),
266  1.0e-02); // Just outside tolerance.
267 }
268 
269 // ************************************************************
270 // ************************************************************
271 TEUCHOS_UNIT_TEST(TimeEventRange, timeOfNextEvent)
272 {
273  auto te = rcp(new Tempus::TimeEventRange<double>());
274  te->setTimeRange(0.0, PI, 1.0);
275  te->setRelTol(1.0e-14);
276 
277  // Test timeOfNextEvent.
278  // Around first event.
279  TEST_FLOATING_EQUALITY(te->timeOfNextEvent(-10.0e-14), 0.0,
280  1.0e-14); // Just outside tolerance.
281  TEST_FLOATING_EQUALITY(te->timeOfNextEvent(-0.1e-14), 1.0,
282  1.0e-14); // Just inside tolerance.
283  TEST_FLOATING_EQUALITY(te->timeOfNextEvent(0.0), 1.0,
284  1.0e-14); // Right on timeEvent.
285  TEST_FLOATING_EQUALITY(te->timeOfNextEvent(0.1e-14), 1.0,
286  1.0e-14); // Just inside tolerance.
287  TEST_FLOATING_EQUALITY(te->timeOfNextEvent(10.0e-14), 1.0,
288  1.0e-14); // Just outside tolerance.
289 
290  // Around mid event.
291  TEST_FLOATING_EQUALITY(te->timeOfNextEvent(1.0 + -10.0e-14), 1.0,
292  1.0e-14); // Just outside tolerance.
293  TEST_FLOATING_EQUALITY(te->timeOfNextEvent(1.0 + -0.1e-14), 2.0,
294  1.0e-14); // Just inside tolerance.
295  TEST_FLOATING_EQUALITY(te->timeOfNextEvent(1.0 + 0.0), 2.0,
296  1.0e-14); // Right on timeEvent.
297  TEST_FLOATING_EQUALITY(te->timeOfNextEvent(1.0 + 0.1e-14), 2.0,
298  1.0e-14); // Just inside tolerance.
299  TEST_FLOATING_EQUALITY(te->timeOfNextEvent(1.0 + 10.0e-14), 2.0,
300  1.0e-14); // Just outside tolerance.
301 
302  // Around last event.
303  TEST_FLOATING_EQUALITY(te->timeOfNextEvent(3.0 + -10.0e-14), 3.0,
304  1.0e-14); // Just outside tolerance.
305  TEST_FLOATING_EQUALITY(te->timeOfNextEvent(3.0 + -0.1e-14),
306  te->getDefaultTime(),
307  1.0e-14); // Just inside tolerance.
308  TEST_FLOATING_EQUALITY(te->timeOfNextEvent(3.0 + 0.0), te->getDefaultTime(),
309  1.0e-14); // Right on timeEvent.
310  TEST_FLOATING_EQUALITY(te->timeOfNextEvent(3.0 + 0.1e-14),
311  te->getDefaultTime(),
312  1.0e-14); // Just inside tolerance.
313  TEST_FLOATING_EQUALITY(te->timeOfNextEvent(3.0 + 10.0e-14),
314  te->getDefaultTime(),
315  1.0e-14); // Just outside tolerance.
316 }
317 
318 // ************************************************************
319 // ************************************************************
320 TEUCHOS_UNIT_TEST(TimeEventRange, eventInRange)
321 {
322  auto te = rcp(new Tempus::TimeEventRange<double>());
323  te->setTimeRange(0.0, PI, 1.0);
324  te->setRelTol(1.0e-14);
325 
326  // Test eventInRange.
327  // Right end of input range.
328  // Around first event.
329  TEST_COMPARE(te->eventInRange(-1.0, -10.0e-14), ==,
330  false); // Just outside tolerance.
331  TEST_COMPARE(te->eventInRange(-1.0, -0.1e-14), ==,
332  true); // Just inside tolerance.
333  TEST_COMPARE(te->eventInRange(-1.0, 0.0), ==, true); // Right on timeEvent.
334  TEST_COMPARE(te->eventInRange(-1.0, 0.1e-14), ==,
335  true); // Just inside tolerance.
336  TEST_COMPARE(te->eventInRange(-1.0, 10.0e-14), ==,
337  true); // Just outside tolerance.
338 
339  // Around mid event.
340  TEST_COMPARE(te->eventInRange(0.5, 1.0 + -10.0e-14), ==,
341  false); // Just outside tolerance.
342  TEST_COMPARE(te->eventInRange(0.5, 1.0 + -0.1e-14), ==,
343  true); // Just inside tolerance.
344  TEST_COMPARE(te->eventInRange(0.5, 1.0 + 0.0), ==,
345  true); // Right on timeEvent.
346  TEST_COMPARE(te->eventInRange(0.5, 1.0 + 0.1e-14), ==,
347  true); // Just inside tolerance.
348  TEST_COMPARE(te->eventInRange(0.5, 1.0 + 10.0e-14), ==,
349  true); // Just outside tolerance.
350 
351  // Around last event.
352  TEST_COMPARE(te->eventInRange(2.5, 3.0 + -10.0e-14), ==,
353  false); // Just outside tolerance.
354  TEST_COMPARE(te->eventInRange(2.5, 3.0 + -0.1e-14), ==,
355  true); // Just inside tolerance.
356  TEST_COMPARE(te->eventInRange(2.5, 3.0 + 0.0), ==,
357  true); // Right on timeEvent.
358  TEST_COMPARE(te->eventInRange(2.5, 3.0 + 0.1e-14), ==,
359  true); // Just inside tolerance.
360  TEST_COMPARE(te->eventInRange(2.5, 3.0 + 10.0e-14), ==,
361  true); // Just outside tolerance.
362 
363  // Left end of input range.
364  // Around first event.
365  TEST_COMPARE(te->eventInRange(-10.0e-14, 0.5), ==,
366  true); // Just outside tolerance.
367  TEST_COMPARE(te->eventInRange(-0.1e-14, 0.5), ==,
368  false); // Just inside tolerance.
369  TEST_COMPARE(te->eventInRange(0.0, 0.5), ==, false); // Right on timeEvent.
370  TEST_COMPARE(te->eventInRange(0.1e-14, 0.5), ==,
371  false); // Just inside tolerance.
372  TEST_COMPARE(te->eventInRange(10.0e-14, 0.5), ==,
373  false); // Just outside tolerance.
374 
375  // Around mid event.
376  TEST_COMPARE(te->eventInRange(1.0 + -10.0e-14, 1.5), ==,
377  true); // Just outside tolerance.
378  TEST_COMPARE(te->eventInRange(1.0 + -0.1e-14, 1.5), ==,
379  false); // Just inside tolerance.
380  TEST_COMPARE(te->eventInRange(1.0 + 0.0, 1.5), ==,
381  false); // Right on timeEvent.
382  TEST_COMPARE(te->eventInRange(1.0 + 0.1e-14, 1.5), ==,
383  false); // Just inside tolerance.
384  TEST_COMPARE(te->eventInRange(1.0 + 10.0e-14, 1.5), ==,
385  false); // Just outside tolerance.
386 
387  // Around last event.
388  TEST_COMPARE(te->eventInRange(3.0 + -10.0e-14, 4.0), ==,
389  true); // Just outside tolerance.
390  TEST_COMPARE(te->eventInRange(3.0 + -0.1e-14, 4.0), ==,
391  false); // Just inside tolerance.
392  TEST_COMPARE(te->eventInRange(3.0 + 0.0, 4.0), ==,
393  false); // Right on timeEvent.
394  TEST_COMPARE(te->eventInRange(3.0 + 0.1e-14, 4.0), ==,
395  false); // Just inside tolerance.
396  TEST_COMPARE(te->eventInRange(3.0 + 10.0e-14, 4.0), ==,
397  false); // Just outside tolerance.
398 }
399 
400 // ************************************************************
401 // ************************************************************
402 TEUCHOS_UNIT_TEST(TimeEventRange, getValidParameters)
403 {
404  auto ter = rcp(new Tempus::TimeEventRange<double>());
405 
406  auto pl = ter->getValidParameters();
407 
408  TEST_COMPARE(pl->get<std::string>("Type"), ==, "Range");
409  TEST_COMPARE(pl->get<std::string>("Name"), ==, "TimeEventRange (0; 0; 0)");
410  TEST_FLOATING_EQUALITY(pl->get<double>("Start Time"), 0.0, 1.0e-14);
411  TEST_FLOATING_EQUALITY(pl->get<double>("Stop Time"), 0.0, 1.0e-14);
412  TEST_FLOATING_EQUALITY(pl->get<double>("Stride Time"), 0.0, 1.0e-14);
413  TEST_COMPARE(pl->get<int>("Number of Events"), ==, 1);
414  TEST_FLOATING_EQUALITY(pl->get<double>("Relative Tolerance"),
415  std::numeric_limits<double>::epsilon() * 100.0,
416  1.0e-14);
417  TEST_COMPARE(pl->get<bool>("Land On Exactly"), ==, true);
418 
419  { // Ensure that parameters are "used", excluding sublists.
420  std::ostringstream unusedParameters;
421  pl->unused(unusedParameters);
422  TEST_COMPARE(unusedParameters.str(), ==, "");
423  }
424 }
425 
426 // ************************************************************
427 // ************************************************************
429 {
430  // Construct parameterList similar to getValidParameters().
432  Teuchos::parameterList("Time Event Range");
433 
434  pl->set("Name", "Unit Test Time Event Range");
435  pl->set("Type", "Range");
436  pl->set("Start Time", -0.1);
437  pl->set("Stop Time", 1.1);
438  pl->set("Stride Time", 0.1);
439  pl->set("Relative Tolerance", 1.0e-10);
440  pl->set("Land On Exactly", false);
441 
442  // Construct TimeEventRange from ParameterList.
443  auto ter = Tempus::createTimeEventRange<double>(pl);
444 
445  // ter->describe(out, Teuchos::VERB_EXTREME);
446 
447  TEST_COMPARE(ter->getName(), ==, "Unit Test Time Event Range");
448  TEST_COMPARE(ter->getType(), ==, "Range");
449  TEST_FLOATING_EQUALITY(ter->getTimeStart(), -0.1, 1.0e-14);
450  TEST_FLOATING_EQUALITY(ter->getTimeStop(), 1.1, 1.0e-14);
451  TEST_FLOATING_EQUALITY(ter->getTimeStride(), 0.1, 1.0e-14);
452  TEST_COMPARE(ter->getNumEvents(), ==, 13);
453  TEST_FLOATING_EQUALITY(ter->getRelTol(), 1.0e-10, 1.0e-14);
454  TEST_COMPARE(ter->getLandOnExactly(), ==, false);
455 }
456 
457 // ************************************************************
458 // ************************************************************
459 TEUCHOS_UNIT_TEST(TimeEventRange, SingleEventAtZero)
460 {
461  auto ter = rcp(new Tempus::TimeEventRange<double>(0.0, 0.0, 0.0,
462  "SingleEventAtZero", true));
463  ter->describe(out, Teuchos::VERB_EXTREME);
464 
465  TEST_COMPARE(ter->getNumEvents(), ==, 1);
466 
467  TEST_COMPARE(ter->isTime(0.0), ==, true);
468  TEST_FLOATING_EQUALITY(ter->timeToNextEvent(-1.0), 1.0, 1.0e-14);
469  TEST_FLOATING_EQUALITY(ter->timeOfNextEvent(-1.0), 0.0, 1.0e-14);
470  TEST_FLOATING_EQUALITY(ter->timeToNextEvent(0.0), ter->getDefaultTime(),
471  1.0e-14);
472  TEST_FLOATING_EQUALITY(ter->timeOfNextEvent(0.0), ter->getDefaultTime(),
473  1.0e-14);
474  TEST_COMPARE(ter->eventInRange(-1.0, 1.0), ==, true);
475  TEST_COMPARE(ter->eventInRange(0.0, 1.0), ==, false);
476  TEST_COMPARE(ter->eventInRange(0.0, 0.0), ==, false);
477 }
478 
479 } // namespace Tempus_Unit_Test
#define TEST_COMPARE(v1, comp, v2)
#define TEST_FLOATING_EQUALITY(v1, v2, tol)
ParameterList & set(std::string const &name, T &&value, std::string const &docString="", RCP< const ParameterEntryValidator > const &validator=null)
TimeEventRange specifies a start, stop and stride time.
TEUCHOS_DEPRECATED RCP< T > rcp(T *p, Dealloc_T dealloc, bool owns_mem)
Teuchos::RCP< TimeEventRange< Scalar > > createTimeEventRange(Teuchos::RCP< Teuchos::ParameterList > pList)
Nonmember Constructor via ParameterList.
TEUCHOS_UNIT_TEST(BackwardEuler, Default_Construction)
static double PI