Tempus Version of the Day
Time Integration
Loading...
Searching...
No Matches
Tempus_UnitTest_TimeStepControl.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
12#include "Tempus_TimeStepControl.hpp"
13#include "Tempus_TimeEventList.hpp"
18
19namespace Tempus_Unit_Test {
20
21using Teuchos::ParameterList;
22using Teuchos::RCP;
23using Teuchos::rcp;
24using Teuchos::rcp_const_cast;
25using Teuchos::rcp_dynamic_cast;
26using Teuchos::sublist;
27
28// ************************************************************
29// ************************************************************
30TEUCHOS_UNIT_TEST(TimeStepControl, Default_Construction)
31{
32 auto tsc = rcp(new Tempus::TimeStepControl<double>());
33 TEUCHOS_TEST_FOR_EXCEPT(!tsc->isInitialized());
34
35 // Test the get functions (i.e., defaults).
36 TEST_COMPARE(tsc->getStepType(), ==, "Constant");
37 TEST_FLOATING_EQUALITY(tsc->getInitTime(), 0.0, 1.0e-14);
38 TEST_FLOATING_EQUALITY(tsc->getFinalTime(), 1.0e+99, 1.0e-14);
39 TEST_FLOATING_EQUALITY(tsc->getMinTimeStep(), 0.0, 1.0e-14);
40 TEST_FLOATING_EQUALITY(tsc->getInitTimeStep(), 1.0e+99, 1.0e-14);
41 TEST_FLOATING_EQUALITY(tsc->getMaxTimeStep(), 1.0e+99, 1.0e-14);
42 TEST_COMPARE(tsc->getInitIndex(), ==, 0);
43 TEST_COMPARE(tsc->getFinalIndex(), ==, 1000000);
44 TEST_FLOATING_EQUALITY(tsc->getMaxAbsError(), 1.0e-08, 1.0e-14);
45 TEST_FLOATING_EQUALITY(tsc->getMaxRelError(), 1.0e-08, 1.0e-14);
46 TEST_COMPARE(tsc->getMaxFailures(), ==, 10);
47 TEST_COMPARE(tsc->getMaxConsecFailures(), ==, 5);
48 TEST_COMPARE(tsc->getNumTimeSteps(), ==, -1);
49 TEST_COMPARE(tsc->getPrintDtChanges(), ==, true);
50 TEST_COMPARE(tsc->getOutputExactly(), ==, true);
51 TEST_COMPARE(tsc->getOutputIndexInterval(), ==, 1000000);
52 TEST_FLOATING_EQUALITY(tsc->getOutputTimeInterval(), 1.0e+99, 1.0e-14);
53 auto tec = tsc->getTimeEvents();
54 TEST_COMPARE(tec->getSize(), ==, 2);
55 TEST_COMPARE(tec->getTimeEventNames(), ==,
56 "Output Index Interval, Output Time Interval");
57
58 // Test the set functions.
59 tsc->setInitTime(1.0);
60 tsc->initialize();
61 TEUCHOS_TEST_FOR_EXCEPT(!tsc->isInitialized());
62 tsc->setFinalTime(100.0);
63 tsc->initialize();
64 TEUCHOS_TEST_FOR_EXCEPT(!tsc->isInitialized());
65 tsc->setMinTimeStep(0.01);
66 tsc->initialize();
67 TEUCHOS_TEST_FOR_EXCEPT(!tsc->isInitialized());
68 tsc->setInitTimeStep(0.02);
69 tsc->initialize();
70 TEUCHOS_TEST_FOR_EXCEPT(!tsc->isInitialized());
71 tsc->setMaxTimeStep(0.05);
72 tsc->initialize();
73 TEUCHOS_TEST_FOR_EXCEPT(!tsc->isInitialized());
74 tsc->setInitIndex(-100);
75 tsc->initialize();
76 TEUCHOS_TEST_FOR_EXCEPT(!tsc->isInitialized());
77 tsc->setFinalIndex(100);
78 tsc->initialize();
79 TEUCHOS_TEST_FOR_EXCEPT(!tsc->isInitialized());
80 tsc->setMaxAbsError(1.0e-06);
81 tsc->initialize();
82 TEUCHOS_TEST_FOR_EXCEPT(!tsc->isInitialized());
83 tsc->setMaxRelError(1.0e-06);
84 tsc->initialize();
85 TEUCHOS_TEST_FOR_EXCEPT(!tsc->isInitialized());
86 tsc->setMaxFailures(8);
87 tsc->initialize();
88 TEUCHOS_TEST_FOR_EXCEPT(!tsc->isInitialized());
89 tsc->setMaxConsecFailures(4);
90 tsc->initialize();
91 TEUCHOS_TEST_FOR_EXCEPT(!tsc->isInitialized());
92 tsc->setNumTimeSteps(-1);
93 tsc->initialize();
94 TEUCHOS_TEST_FOR_EXCEPT(!tsc->isInitialized());
95 tsc->setPrintDtChanges(false);
96 tsc->initialize();
97 TEUCHOS_TEST_FOR_EXCEPT(!tsc->isInitialized());
98 tsc->setOutputExactly(false);
99 tsc->initialize();
100 TEUCHOS_TEST_FOR_EXCEPT(!tsc->isInitialized());
101 tsc->setOutputIndexInterval(9);
102 tsc->initialize();
103 TEUCHOS_TEST_FOR_EXCEPT(!tsc->isInitialized());
104 tsc->setOutputTimeInterval(0.1);
105 tsc->initialize();
106 TEUCHOS_TEST_FOR_EXCEPT(!tsc->isInitialized());
107
108 TEST_COMPARE(tsc->getStepType(), ==, "Constant");
109 TEST_FLOATING_EQUALITY(tsc->getInitTime(), 1.0, 1.0e-14);
110 TEST_FLOATING_EQUALITY(tsc->getFinalTime(), 100.0, 1.0e-14);
111 TEST_FLOATING_EQUALITY(tsc->getMinTimeStep(), 0.01, 1.0e-14);
112 TEST_FLOATING_EQUALITY(tsc->getInitTimeStep(), 0.02, 1.0e-14);
113 TEST_FLOATING_EQUALITY(tsc->getMaxTimeStep(), 0.05, 1.0e-14);
114 TEST_COMPARE(tsc->getInitIndex(), ==, -100);
115 TEST_COMPARE(tsc->getFinalIndex(), ==, 100);
116 TEST_FLOATING_EQUALITY(tsc->getMaxAbsError(), 1.0e-06, 1.0e-14);
117 TEST_FLOATING_EQUALITY(tsc->getMaxRelError(), 1.0e-06, 1.0e-14);
118 TEST_COMPARE(tsc->getMaxFailures(), ==, 8);
119 TEST_COMPARE(tsc->getMaxConsecFailures(), ==, 4);
120 TEST_COMPARE(tsc->getNumTimeSteps(), ==, -1);
121 TEST_COMPARE(tsc->getPrintDtChanges(), ==, false);
122 TEST_COMPARE(tsc->getOutputExactly(), ==, false);
123 TEST_COMPARE(tsc->getOutputIndexInterval(), ==, 9);
124 TEST_FLOATING_EQUALITY(tsc->getOutputTimeInterval(), 0.1, 1.0e-14);
125
126 auto tecTmp = rcp(new Tempus::TimeEventComposite<double>());
127 auto ter = rcp(new Tempus::TimeEventRange<double>());
128 auto tel = rcp(new Tempus::TimeEventList<double>());
129 ter->setName("Test Range");
130 tel->setName("Test List");
131 tecTmp->add(ter);
132 tecTmp->add(tel);
133 tsc->setTimeEvents(tecTmp);
134 tec = tsc->getTimeEvents();
135 TEST_COMPARE(tec->getSize(), ==, 2);
136 TEST_COMPARE(tec->getTimeEventNames(), ==, "Test Range, Test List");
137}
138
139// ************************************************************
140// ************************************************************
141TEUCHOS_UNIT_TEST(TimeStepControl, Full_Construction)
142{
143 std::vector<int> outputIndices;
144 outputIndices.push_back(7);
145 outputIndices.push_back(11);
146 outputIndices.push_back(13);
147
148 std::vector<double> outputTimes;
149 outputTimes.push_back(0.3);
150 outputTimes.push_back(0.7);
151 outputTimes.push_back(1.3);
152 outputTimes.push_back(1.7);
153
154 auto tecTmp = rcp(new Tempus::TimeEventComposite<double>());
155 auto ter = rcp(new Tempus::TimeEventRange<double>());
156 auto teri = rcp(new Tempus::TimeEventRangeIndex<double>());
157 auto tel = rcp(new Tempus::TimeEventList<double>());
158 auto teli = rcp(new Tempus::TimeEventListIndex<double>());
159 ter->setName("Test Range");
160 teri->setName("Test Range Index");
161 tel->setName("Test List");
162 teli->setName("Test List Index");
163 tecTmp->add(ter);
164 tecTmp->add(teri);
165 tecTmp->add(tel);
166 tecTmp->add(teli);
167
169
170 auto tsc = rcp(new Tempus::TimeStepControl<double>(
171 1.0, /* initTime_ */
172 100.0, /* finalTime_ */
173 0.01, /* minTimeStep_ */
174 0.02, /* initTimeStep_ */
175 0.05, /* maxTimeStep_ */
176 -100, /* initIndex_ */
177 100, /* finalIndex_ */
178 1.0e-06, /* maxAbsError_ */
179 1.0e-06, /* maxRelError_ */
180 8, /* maxFailures_ */
181 4, /* maxConsecFailures_ */
182 -1, /* numTimeSteps_ */
183 false, /* printDtChanges_ */
184 false, /* outputExactly_ */
185 outputIndices, /* outputIndices_ */
186 outputTimes, /* outputTimes_ */
187 9, /* outputIndexInterval_ */
188 0.011, /* outputTimeInterval_ */
189 tecTmp, /* timeEvent_ */
190 tscsc /* stepControlStrategy_ */
191 ));
192
193 TEUCHOS_TEST_FOR_EXCEPT(!tsc->isInitialized());
194
195 TEST_COMPARE(tsc->getStepType(), ==, "Constant");
196 TEST_FLOATING_EQUALITY(tsc->getInitTime(), 1.0, 1.0e-14);
197 TEST_FLOATING_EQUALITY(tsc->getFinalTime(), 100.0, 1.0e-14);
198 TEST_FLOATING_EQUALITY(tsc->getMinTimeStep(), 0.01, 1.0e-14);
199 TEST_FLOATING_EQUALITY(tsc->getInitTimeStep(), 0.02, 1.0e-14);
200 TEST_FLOATING_EQUALITY(tsc->getMaxTimeStep(), 0.05, 1.0e-14);
201 TEST_COMPARE(tsc->getInitIndex(), ==, -100);
202 TEST_COMPARE(tsc->getFinalIndex(), ==, 100);
203 TEST_FLOATING_EQUALITY(tsc->getMaxAbsError(), 1.0e-06, 1.0e-14);
204 TEST_FLOATING_EQUALITY(tsc->getMaxRelError(), 1.0e-06, 1.0e-14);
205 TEST_COMPARE(tsc->getMaxFailures(), ==, 8);
206 TEST_COMPARE(tsc->getMaxConsecFailures(), ==, 4);
207 TEST_COMPARE(tsc->getNumTimeSteps(), ==, -1);
208 TEST_COMPARE(tsc->getPrintDtChanges(), ==, false);
209 TEST_COMPARE(tsc->getOutputExactly(), ==, false);
210 TEST_COMPARE(tsc->getOutputIndexInterval(), ==, 9);
211 TEST_FLOATING_EQUALITY(tsc->getOutputTimeInterval(), 0.011, 1.0e-14);
212 auto tec = tsc->getTimeEvents();
213 TEST_COMPARE(tec->getSize(), ==, 8);
214 TEST_COMPARE(
215 tec->getTimeEventNames(), ==,
216 "Test Range, Test Range Index, Test List, Test List Index, Output Time "
217 "Interval, Output Time List, Output Index Interval, Output Index List");
218}
219
220// ************************************************************
221// ************************************************************
222TEUCHOS_UNIT_TEST(TimeStepControl, createTimeStepControl)
223{
224 Teuchos::RCP<Teuchos::ParameterList> pl =
226
227 pl->set<double>("Initial Time", 1.0);
228 pl->set<double>("Final Time", 100.0);
229 pl->set<double>("Minimum Time Step", 0.01);
230 pl->set<double>("Initial Time Step", 0.02);
231 pl->set<double>("Maximum Time Step", 0.05);
232 pl->set<int>("Initial Time Index", -100);
233 pl->set<int>("Final Time Index", 100);
234 pl->set<double>("Maximum Absolute Error", 1.0e-06);
235 pl->set<double>("Maximum Relative Error", 1.0e-06);
236 pl->set<int>("Maximum Number of Stepper Failures", 8);
237 pl->set<int>("Maximum Number of Consecutive Stepper Failures", 4);
238 pl->set<int>("Number of Time Steps", -1);
239 pl->set<bool>("Print Time Step Changes", false);
240 pl->set<bool>("Output Exactly On Output Times", false);
241 pl->set<std::string>("Output Index List", "7, 11, 13");
242 pl->set<std::string>("Output Time List", "0.3, 0.7, 1.3, 1.7");
243 pl->set<int>("Output Index Interval", 9);
244 pl->set<double>("Output Time Interval", 0.011);
245
247 auto tscsPL = tscs->getValidParameters();
248 pl->set("Time Step Control Strategy", *tscsPL);
249
250 auto tec = rcp(new Tempus::TimeEventComposite<double>());
251 auto ter = rcp(new Tempus::TimeEventRange<double>());
252 auto teri = rcp(new Tempus::TimeEventRangeIndex<double>());
253 auto tel = rcp(new Tempus::TimeEventList<double>());
254 auto teli = rcp(new Tempus::TimeEventListIndex<double>());
255 ter->setName("Test Range");
256 teri->setName("Test Range Index");
257 tel->setName("Test List");
258 teli->setName("Test List Index");
259 tec->add(ter);
260 tec->add(teri);
261 tec->add(tel);
262 tec->add(teli);
263 auto tecPL = rcp_const_cast<ParameterList>(tec->getValidParameters());
264 pl->set("Time Step Control Events", *tecPL);
265
267 TEUCHOS_TEST_FOR_EXCEPT(!tsc->isInitialized());
268
269 tsc->describe(out, Teuchos::VERB_EXTREME);
270
271 TEST_COMPARE(tsc->getStepType(), ==, "Constant");
272 TEST_FLOATING_EQUALITY(tsc->getInitTime(), 1.0, 1.0e-14);
273 TEST_FLOATING_EQUALITY(tsc->getFinalTime(), 100.0, 1.0e-14);
274 TEST_FLOATING_EQUALITY(tsc->getMinTimeStep(), 0.01, 1.0e-14);
275 TEST_FLOATING_EQUALITY(tsc->getInitTimeStep(), 0.02, 1.0e-14);
276 TEST_FLOATING_EQUALITY(tsc->getMaxTimeStep(), 0.05, 1.0e-14);
277 TEST_COMPARE(tsc->getInitIndex(), ==, -100);
278 TEST_COMPARE(tsc->getFinalIndex(), ==, 100);
279 TEST_FLOATING_EQUALITY(tsc->getMaxAbsError(), 1.0e-06, 1.0e-14);
280 TEST_FLOATING_EQUALITY(tsc->getMaxRelError(), 1.0e-06, 1.0e-14);
281 TEST_COMPARE(tsc->getMaxFailures(), ==, 8);
282 TEST_COMPARE(tsc->getMaxConsecFailures(), ==, 4);
283 TEST_COMPARE(tsc->getNumTimeSteps(), ==, -1);
284 TEST_COMPARE(tsc->getPrintDtChanges(), ==, false);
285 TEST_COMPARE(tsc->getOutputExactly(), ==, false);
286 TEST_COMPARE(tsc->getOutputIndices()[0], ==, 7);
287 TEST_COMPARE(tsc->getOutputIndices()[1], ==, 11);
288 TEST_COMPARE(tsc->getOutputIndices()[2], ==, 13);
289 TEST_FLOATING_EQUALITY(tsc->getOutputTimes()[0], 0.3, 1.0e-14);
290 TEST_FLOATING_EQUALITY(tsc->getOutputTimes()[1], 0.7, 1.0e-14);
291 TEST_FLOATING_EQUALITY(tsc->getOutputTimes()[2], 1.3, 1.0e-14);
292 TEST_FLOATING_EQUALITY(tsc->getOutputTimes()[3], 1.7, 1.0e-14);
293 TEST_COMPARE(tsc->getOutputIndexInterval(), ==, 9);
294 TEST_FLOATING_EQUALITY(tsc->getOutputTimeInterval(), 0.011, 1.0e-14);
295
296 tec = tsc->getTimeEvents();
297 TEST_COMPARE(tec->getSize(), ==, 8);
298 TEST_COMPARE(
299 tec->getTimeEventNames(), ==,
300 "Output Index List, Output Index Interval, Output Time List, Output Time "
301 "Interval, Test Range, Test Range Index, Test List, Test List Index");
302}
303
304// ************************************************************
305// ************************************************************
306TEUCHOS_UNIT_TEST(TimeStepControl, Accessors)
307{
308 auto tsc = rcp(new Tempus::TimeStepControl<double>());
309 int iFirst = 0;
310 int iLast = 101;
311 int iStep = 17;
312 double dFirst = 0.0;
313 double dLast = 0.989;
314 double dStep = 0.01;
315
316 tsc->setInitTime(dFirst);
317 TEST_COMPARE(tsc->getInitTime(), ==, dFirst);
318 tsc->setFinalTime(dLast);
319 TEST_COMPARE(tsc->getFinalTime(), ==, dLast);
320 tsc->setMinTimeStep(dStep);
321 TEST_COMPARE(tsc->getMinTimeStep(), ==, dStep);
322 tsc->setInitTimeStep(dStep);
323 TEST_COMPARE(tsc->getInitTimeStep(), ==, dStep);
324 tsc->setMaxTimeStep(dLast);
325 TEST_COMPARE(tsc->getMaxTimeStep(), ==, dLast);
326 tsc->setInitIndex(iFirst);
327 TEST_COMPARE(tsc->getInitIndex(), ==, iFirst);
328 tsc->setFinalIndex(iLast);
329 TEST_COMPARE(tsc->getFinalIndex(), ==, iLast);
330 tsc->setMaxAbsError(dStep);
331 TEST_COMPARE(tsc->getMaxAbsError(), ==, dStep);
332 tsc->setMaxRelError(dStep);
333 TEST_COMPARE(tsc->getMaxRelError(), ==, dStep);
334 tsc->setOutputExactly(false);
335 TEST_COMPARE(tsc->getOutputExactly(), ==, false);
336 tsc->setOutputExactly(true);
337 TEST_COMPARE(tsc->getOutputExactly(), ==, true);
338
339 std::vector<int> iVSet{0, 1, 2, 3, 5, 8, 13, 21, 34};
340 tsc->setOutputIndices(iVSet);
341 TEUCHOS_TEST_FOR_EXCEPT(tsc->getOutputIndices() != iVSet);
342
343 tsc->setOutputIndexInterval(iStep);
344 TEST_COMPARE(tsc->getOutputIndexInterval(), ==, iStep);
345 tsc->setOutputTimeInterval(dStep);
346 TEST_COMPARE(tsc->getOutputTimeInterval(), ==, dStep);
347}
348
349// ************************************************************
350// ************************************************************
351TEUCHOS_UNIT_TEST(TimeStepControl, setOutputTimes)
352{
353 auto tsc = rcp(new Tempus::TimeStepControl<double>());
354
355 std::vector<double> times_in;
356 times_in.push_back(0.0000000000000000e-11);
357 times_in.push_back(0.1001384570000000e-11);
358 times_in.push_back(0.2002769140000000e-11);
359 times_in.push_back(0.3004153710000000e-11);
360 times_in.push_back(0.4005538280000000e-11);
361 times_in.push_back(0.5006922850000000e-11);
362 times_in.push_back(0.6008307420000000e-11);
363 times_in.push_back(0.7009691990000000e-11);
364 times_in.push_back(0.8011076560000000e-11);
365 times_in.push_back(0.9012461130000000e-11);
366 times_in.push_back(1.0013845700000000e-11);
367
368 tsc->setOutputTimes(times_in);
369 tsc->initialize();
370 auto times_out = tsc->getOutputTimes();
371 double maxDiff = 0.0;
372
373 // out << "\n times_in, times_out = " << std::endl;
374 for (size_t i = 0; i < times_in.size(); ++i) {
375 // out << std::setw(25) << std::setprecision(16) << times_in[i] << ","
376 // << std::setw(25) << std::setprecision(16) << times_out[i]
377 // << std::endl;
378 maxDiff = std::max(std::fabs(times_in[i] - times_out[i]), maxDiff);
379 }
380 // out << " maxDiff = " << maxDiff << std::endl;
381
382 TEST_COMPARE(maxDiff, <, 1.0e-25);
383
384 times_in.clear();
385 times_in.push_back(0.00000000000000000000000000000000);
386 times_in.push_back(0.00000000000100138457000000009381);
387 times_in.push_back(0.00000000000200276914000000018762);
388 times_in.push_back(0.00000000000300415371000000007949);
389 times_in.push_back(0.00000000000400553828000000037525);
390 times_in.push_back(0.00000000000500692284999999986321);
391 times_in.push_back(0.00000000000600830742000000015898);
392 times_in.push_back(0.00000000000700969198999999964694);
393 times_in.push_back(0.00000000000801107656000000075050);
394 times_in.push_back(0.00000000000901246112999999943067);
395 times_in.push_back(0.00000000001001384569999999972643);
396
397 tsc->setOutputTimes(times_in);
398 tsc->initialize();
399 times_out = tsc->getOutputTimes();
400 maxDiff = 0.0;
401
402 // out << "\n times_in, times_out = " << std::endl;
403 for (size_t i = 0; i < times_in.size(); ++i) {
404 // out << std::setw(30) << std::setprecision(20) << times_in[i] << ","
405 // << std::setw(30) << std::setprecision(20) << times_out[i]
406 // << std::endl;
407 maxDiff = std::max(std::fabs(times_in[i] - times_out[i]), maxDiff);
408 }
409 // out << " maxDiff = " << maxDiff << std::endl;
410
411 TEST_COMPARE(maxDiff, <, 1.0e-25);
412}
413
414// ************************************************************
415// ************************************************************
416TEUCHOS_UNIT_TEST(TimeStepControl, getOutputIndicesandIntervals)
417{
418 auto tsc = rcp(new Tempus::TimeStepControl<double>());
419 int setOutputTimeIndex = 17;
420 double setOutputTimeInterval = 1.101001000100001e-7;
421
422 tsc->setFinalTime(1.0);
423 tsc->setOutputIndexInterval(setOutputTimeIndex);
424 tsc->setOutputTimeInterval(setOutputTimeInterval);
425
426 int getOutputTimeIndex = tsc->getOutputIndexInterval();
427 double getOutputTimeInterval = tsc->getOutputTimeInterval();
428 TEST_COMPARE(getOutputTimeInterval, ==, setOutputTimeInterval);
429 TEST_COMPARE(getOutputTimeIndex, ==, setOutputTimeIndex);
430}
431
432// ************************************************************
433// ************************************************************
434TEUCHOS_UNIT_TEST(TimeStepControl, timeInRange)
435{
436 auto tsc = rcp(new Tempus::TimeStepControl<double>());
437 TEUCHOS_TEST_FOR_EXCEPT(!tsc->isInitialized());
438
439 // Testing lambda function
440 auto testTimeInRange = [=](double initTime, double finalTime) {
441 tsc->setInitTime(initTime);
442 tsc->setFinalTime(finalTime);
443 tsc->initialize();
444 TEUCHOS_TEST_FOR_EXCEPT(!tsc->isInitialized());
445
446 const int i = (initTime == 0)
447 ? 0
448 : 1 + (int)std::floor(std::log10(std::fabs(initTime)));
449 const double absTolInit10 = std::pow(10, i - 10);
450 const double absTolInit15 = std::pow(10, i - 15);
451 const int j = (finalTime == 0)
452 ? 0
453 : 1 + (int)std::floor(std::log10(std::fabs(finalTime)));
454 const double absTolFinal10 = std::pow(10, j - 10);
455 const double absTolFinal15 = std::pow(10, j - 15);
456
457 // Classic unit testing of critical values.
458 if (initTime == 0.0) {
459 TEUCHOS_TEST_FOR_EXCEPT(tsc->timeInRange(initTime - 0.1));
460 }
461 else {
462 TEUCHOS_TEST_FOR_EXCEPT(
463 tsc->timeInRange(initTime - 0.1 * std::fabs(initTime)));
464 }
465 TEUCHOS_TEST_FOR_EXCEPT(tsc->timeInRange(initTime - absTolInit10));
466 TEUCHOS_TEST_FOR_EXCEPT(!tsc->timeInRange(initTime - absTolInit15));
467 TEUCHOS_TEST_FOR_EXCEPT(!tsc->timeInRange(initTime));
468 TEUCHOS_TEST_FOR_EXCEPT(!tsc->timeInRange(initTime + absTolInit15));
469 TEUCHOS_TEST_FOR_EXCEPT(!tsc->timeInRange(initTime + absTolInit10));
470 TEUCHOS_TEST_FOR_EXCEPT(
471 !tsc->timeInRange(initTime + 0.3 * (std::fabs(finalTime - initTime))));
472 TEUCHOS_TEST_FOR_EXCEPT(!tsc->timeInRange(finalTime - absTolFinal10));
473 TEUCHOS_TEST_FOR_EXCEPT(tsc->timeInRange(finalTime - absTolFinal15));
474 TEUCHOS_TEST_FOR_EXCEPT(tsc->timeInRange(finalTime));
475 TEUCHOS_TEST_FOR_EXCEPT(tsc->timeInRange(finalTime + absTolFinal15));
476 TEUCHOS_TEST_FOR_EXCEPT(tsc->timeInRange(finalTime + absTolFinal10));
477 if (finalTime == 0.0) {
478 TEUCHOS_TEST_FOR_EXCEPT(tsc->timeInRange(finalTime + 0.1));
479 }
480 else {
481 TEUCHOS_TEST_FOR_EXCEPT(
482 tsc->timeInRange(finalTime + 0.1 * std::fabs(finalTime)));
483 }
484 };
485
486 // Test with initTime = 0.0
487 testTimeInRange(0.0, 1.0);
488
489 // Test with finalTime = 0.0
490 testTimeInRange(-1.0, 0.0);
491
492 // Test large and small times
493 testTimeInRange(9.9e-20, 3.3e+20);
494 testTimeInRange(-1.9e+20, 2.3e-20);
495}
496
497// ************************************************************
498// ************************************************************
499TEUCHOS_UNIT_TEST(TimeStepControl, indexInRange)
500{
501 auto tsc = rcp(new Tempus::TimeStepControl<double>());
502 TEUCHOS_TEST_FOR_EXCEPT(!tsc->isInitialized());
503
504 // Testing lambda function
505 auto testIndexInRange = [=](double initIndex, double finalIndex) {
506 tsc->setInitIndex(initIndex);
507 tsc->setFinalIndex(finalIndex);
508 tsc->initialize();
509 TEUCHOS_TEST_FOR_EXCEPT(!tsc->isInitialized());
510
511 // Classic unit testing of critical values.
512 TEUCHOS_TEST_FOR_EXCEPT(tsc->indexInRange(initIndex - 7));
513 TEUCHOS_TEST_FOR_EXCEPT(tsc->indexInRange(initIndex - 1));
514 TEUCHOS_TEST_FOR_EXCEPT(!tsc->indexInRange(initIndex));
515 TEUCHOS_TEST_FOR_EXCEPT(!tsc->indexInRange(initIndex + 1));
516 TEUCHOS_TEST_FOR_EXCEPT(!tsc->indexInRange(
517 initIndex + (int)0.3 * (std::fabs(finalIndex - initIndex))));
518 TEUCHOS_TEST_FOR_EXCEPT(!tsc->indexInRange(finalIndex - 1));
519 TEUCHOS_TEST_FOR_EXCEPT(tsc->indexInRange(finalIndex));
520 TEUCHOS_TEST_FOR_EXCEPT(tsc->indexInRange(finalIndex + 1));
521 TEUCHOS_TEST_FOR_EXCEPT(tsc->indexInRange(finalIndex + 7));
522 };
523
524 // Test with initIndex = 0.0
525 testIndexInRange(0, 10);
526
527 // Test with finalIndex = 0.0
528 testIndexInRange(-10, 0);
529
530 // Test large and small indices
531 testIndexInRange(-190000, 20);
532 testIndexInRange(-19, 200000);
533}
534
535// ************************************************************
536// ************************************************************
537TEUCHOS_UNIT_TEST(TimeStepControl, getValidParameters)
538{
539 std::vector<int> outputIndices;
540 outputIndices.push_back(7);
541 outputIndices.push_back(11);
542 outputIndices.push_back(13);
543
544 std::vector<double> outputTimes;
545 outputTimes.push_back(0.3);
546 outputTimes.push_back(0.7);
547 outputTimes.push_back(1.3);
548 outputTimes.push_back(1.7);
549
550 auto tec = rcp(new Tempus::TimeEventComposite<double>());
551
553
554 auto tsc = rcp(new Tempus::TimeStepControl<double>(
555 1.0, 100.0, 0.01, 0.02, 0.05, -100, 100, 1.0e-06, 1.0e-06, 8, 4, -1,
556 false, false, outputIndices, outputTimes, 9, 0.011, tec, tscsc));
557 TEUCHOS_TEST_FOR_EXCEPT(!tsc->isInitialized());
558
559 auto pl = tsc->getValidParameters();
560
561 TEST_FLOATING_EQUALITY(pl->get<double>("Initial Time"), 1.0, 1.0e-14);
562 TEST_FLOATING_EQUALITY(pl->get<double>("Final Time"), 100.0, 1.0e-14);
563 TEST_FLOATING_EQUALITY(pl->get<double>("Minimum Time Step"), 0.01, 1.0e-14);
564 TEST_FLOATING_EQUALITY(pl->get<double>("Initial Time Step"), 0.02, 1.0e-14);
565 TEST_FLOATING_EQUALITY(pl->get<double>("Maximum Time Step"), 0.05, 1.0e-14);
566 TEST_COMPARE(pl->get<int>("Initial Time Index"), ==, -100);
567 TEST_COMPARE(pl->get<int>("Final Time Index"), ==, 100);
568 TEST_FLOATING_EQUALITY(pl->get<double>("Maximum Absolute Error"), 1.0e-06,
569 1.0e-14);
570 TEST_FLOATING_EQUALITY(pl->get<double>("Maximum Relative Error"), 1.0e-06,
571 1.0e-14);
572 TEST_COMPARE(pl->get<int>("Maximum Number of Stepper Failures"), ==, 8);
573 TEST_COMPARE(pl->get<int>("Maximum Number of Consecutive Stepper Failures"),
574 ==, 4);
575 TEST_COMPARE(pl->get<int>("Number of Time Steps"), ==, -1);
576 TEST_COMPARE(pl->get<bool>("Print Time Step Changes"), ==, false);
577 TEST_COMPARE(pl->get<bool>("Output Exactly On Output Times"), ==, false);
578 TEST_COMPARE(pl->get<std::string>("Output Index List"), ==, "7, 11, 13");
579 TEST_COMPARE(pl->get<std::string>("Output Time List"), ==,
580 "0.3, 0.7, 1.3, 1.7");
581 TEST_COMPARE(pl->get<int>("Output Index Interval"), ==, 9);
582 TEST_FLOATING_EQUALITY(pl->get<double>("Output Time Interval"), 0.011,
583 1.0e-14);
584
585 { // Ensure that parameters are "used", excluding sublists.
586 std::ostringstream unusedParameters;
587 pl->unused(unusedParameters);
588 TEST_COMPARE(unusedParameters.str(), ==,
589 "WARNING: Parameter \"Time Step Control Strategy\" "
590 "[unused] is unused\n");
591 }
592
593 auto tscs_PL = pl->sublist("Time Step Control Strategy");
594 TEST_COMPARE(tscs_PL.get<std::string>("Strategy Type"), ==, "Constant");
595 TEST_FLOATING_EQUALITY(tscs_PL.get<double>("Time Step"), 0.0, 1.0e-14);
596
597 { // Ensure that parameters are "used", excluding sublists.
598 std::ostringstream unusedParameters;
599 tscs_PL.unused(unusedParameters);
600 TEST_COMPARE(unusedParameters.str(), ==, "");
601 }
602}
603
604// ************************************************************
605// ************************************************************
606TEUCHOS_UNIT_TEST(TimeStepControl, setNumTimeSteps)
607{
608 auto tsc = rcp(new Tempus::TimeStepControl<double>());
609 TEUCHOS_TEST_FOR_EXCEPT(!tsc->isInitialized());
610
611 tsc->setInitTime(0.0);
612 tsc->setFinalTime(100.0);
613 tsc->setMinTimeStep(0.01);
614 tsc->setInitTimeStep(0.02);
615 tsc->setMaxTimeStep(0.05);
616 tsc->setNumTimeSteps(-1);
617 tsc->initialize();
618 TEUCHOS_TEST_FOR_EXCEPT(!tsc->isInitialized());
619
620 TEST_FLOATING_EQUALITY(tsc->getInitTime(), 0.0, 1.0e-14);
621 TEST_FLOATING_EQUALITY(tsc->getFinalTime(), 100.0, 1.0e-14);
622 TEST_FLOATING_EQUALITY(tsc->getMinTimeStep(), 0.01, 1.0e-14);
623 TEST_FLOATING_EQUALITY(tsc->getInitTimeStep(), 0.02, 1.0e-14);
624 TEST_FLOATING_EQUALITY(tsc->getMaxTimeStep(), 0.05, 1.0e-14);
625 TEST_COMPARE(tsc->getNumTimeSteps(), ==, -1);
626
627 tsc->setNumTimeSteps(100);
628 tsc->initialize();
629
630 TEST_FLOATING_EQUALITY(tsc->getInitTime(), 0.0, 1.0e-14);
631 TEST_FLOATING_EQUALITY(tsc->getFinalTime(), 100.0, 1.0e-14);
632 TEST_FLOATING_EQUALITY(tsc->getMinTimeStep(), 1.0, 1.0e-14);
633 TEST_FLOATING_EQUALITY(tsc->getInitTimeStep(), 1.0, 1.0e-14);
634 TEST_FLOATING_EQUALITY(tsc->getMaxTimeStep(), 1.0, 1.0e-14);
635 TEST_COMPARE(tsc->getNumTimeSteps(), ==, 100);
636}
637
638// ************************************************************
639// ************************************************************
640TEUCHOS_UNIT_TEST(TimeStepControl, SetDtAfterOutput_Variable)
641{
642 // Setup the SolutionHistory --------------------------------
643 auto model = rcp(new Tempus_Test::SinCosModel<double>());
644 auto inArgsIC = model->getNominalValues();
645 auto icSolution = rcp_const_cast<Thyra::VectorBase<double>>(inArgsIC.get_x());
646 auto icState = Tempus::createSolutionStateX<double>(icSolution);
647 auto solutionHistory = rcp(new Tempus::SolutionHistory<double>());
648 solutionHistory->addState(icState);
649 double dt = 0.9;
650 solutionHistory->getCurrentState()->setTimeStep(dt);
651
652 // Setup the TimeStepControl --------------------------------
653 auto tsc = rcp(new Tempus::TimeStepControl<double>());
654 std::vector<double> outputTimes;
655 double outputTime = 0.8;
656 outputTimes.push_back(outputTime);
657 tsc->setOutputTimes(outputTimes);
658 tsc->setOutputExactly(true);
660 tsc->setTimeStepControlStrategy(tscs);
661 tsc->setMinTimeStep(dt / 2.0);
662 tsc->setInitTimeStep(dt);
663 tsc->setMaxTimeStep(2.0 * dt);
664 tsc->setPrintDtChanges(true);
665 tsc->initialize();
666 TEST_COMPARE(tsc->getOutputExactly(), ==, true);
668
669 // ** First Timestep ** //
670 // Set dt to hit outputTime.
671 solutionHistory->initWorkingState();
672 auto currentState = solutionHistory->getCurrentState();
673 auto workingState = solutionHistory->getWorkingState();
674
675 tsc->setNextTimeStep(solutionHistory, status);
676
677 TEST_FLOATING_EQUALITY(workingState->getTimeStep(), outputTime, 1.0e-14);
678 TEST_FLOATING_EQUALITY(workingState->getTime(), outputTime, 1.0e-14);
679 TEST_COMPARE(workingState->getOutput(), ==, true);
680
681 // ** Successful timestep !! ** //
682 workingState->setSolutionStatus(Tempus::Status::PASSED);
683
684 solutionHistory->promoteWorkingState();
685
686 // ** Second Timestep ** //
687 // Set dt to timestep before output.
688 solutionHistory->initWorkingState();
689 currentState = solutionHistory->getCurrentState();
690 workingState = solutionHistory->getWorkingState();
691
692 tsc->setNextTimeStep(solutionHistory, status);
693
694 TEST_FLOATING_EQUALITY(workingState->getTimeStep(), dt, 1.0e-14);
695 TEST_FLOATING_EQUALITY(currentState->getTime() + workingState->getTimeStep(),
696 workingState->getTime(), 1.0e-14);
697
698 TEST_COMPARE(workingState->getOutput(), ==, false);
699}
700
701// ************************************************************
702// ************************************************************
703// With two time events in the same time step, the time step must land on the
704// earliest one, and is an output step only if that is an output time.
705TEUCHOS_UNIT_TEST(TimeStepControl, LandOnEarliestTimeEvent_Variable)
706{
707 // Setup the SolutionHistory --------------------------------
708 auto model = rcp(new Tempus_Test::SinCosModel<double>());
709 auto inArgsIC = model->getNominalValues();
710 auto icSolution = rcp_const_cast<Thyra::VectorBase<double>>(inArgsIC.get_x());
711 auto icState = Tempus::createSolutionStateX<double>(icSolution);
712 auto solutionHistory = rcp(new Tempus::SolutionHistory<double>());
713 solutionHistory->addState(icState);
714 double dt = 0.9;
715 solutionHistory->getCurrentState()->setTimeStep(dt);
716
717 // Setup the TimeStepControl --------------------------------
718 // The output time (0.8) is in the TimeEventComposite before the other time
719 // event (0.5), but the time step must land on 0.5 first.
720 auto tsc = rcp(new Tempus::TimeStepControl<double>());
721 std::vector<double> outputTimes(1, 0.8);
722 tsc->setOutputTimes(outputTimes);
723 tsc->setOutputExactly(true);
724 tsc->getTimeEvents()->add(rcp(new Tempus::TimeEventList<double>(
725 std::vector<double>(1, 0.5), "Other Time List", true)));
727 tsc->setTimeStepControlStrategy(tscs);
728 tsc->setMinTimeStep(0.1);
729 tsc->setInitTimeStep(dt);
730 tsc->setMaxTimeStep(2.0 * dt);
731 tsc->initialize();
733
734 // ** First Timestep ** //
735 // Set dt to hit the other time event, not an output.
736 solutionHistory->initWorkingState();
737 auto workingState = solutionHistory->getWorkingState();
738 tsc->setNextTimeStep(solutionHistory, status);
739 TEST_FLOATING_EQUALITY(workingState->getTime(), 0.5, 1.0e-14);
740 TEST_COMPARE(workingState->getOutput(), ==, false);
741 workingState->setSolutionStatus(Tempus::Status::PASSED);
742 solutionHistory->promoteWorkingState();
743
744 // ** Second Timestep ** //
745 // Set dt to hit the output time.
746 solutionHistory->initWorkingState();
747 workingState = solutionHistory->getWorkingState();
748 tsc->setNextTimeStep(solutionHistory, status);
749 TEST_FLOATING_EQUALITY(workingState->getTime(), 0.8, 1.0e-14);
750 TEST_COMPARE(workingState->getOutput(), ==, true);
751}
752
753// ************************************************************
754// ************************************************************
755TEUCHOS_UNIT_TEST(TimeStepControl, SetDtAfterOutput_Constant)
756{
757 // Setup the SolutionHistory --------------------------------
758 auto model = rcp(new Tempus_Test::SinCosModel<double>());
759 auto inArgsIC = model->getNominalValues();
760 auto icSolution = rcp_const_cast<Thyra::VectorBase<double>>(inArgsIC.get_x());
761 auto icState = Tempus::createSolutionStateX<double>(icSolution);
762 auto solutionHistory = rcp(new Tempus::SolutionHistory<double>());
763 solutionHistory->addState(icState);
764 double dt = 0.9;
765 solutionHistory->getCurrentState()->setTimeStep(dt);
766
767 // Setup the TimeStepControl --------------------------------
768 auto tsc = rcp(new Tempus::TimeStepControl<double>());
769 std::vector<double> outputTimes;
770 double outputTime = 0.8;
771 outputTimes.push_back(outputTime);
772 tsc->setOutputTimes(outputTimes);
773 tsc->setMinTimeStep(dt / 2.0);
774 tsc->setInitTimeStep(dt);
775 tsc->setMaxTimeStep(2.0 * dt);
776 tsc->setOutputExactly(false);
777 tsc->initialize();
778 TEST_COMPARE(tsc->getOutputExactly(), ==, false);
780
781 // Set dt to hit outputTime for first timestep.
782 solutionHistory->initWorkingState();
783 auto currentState = solutionHistory->getCurrentState();
784 auto workingState = solutionHistory->getWorkingState();
785
786 tsc->setNextTimeStep(solutionHistory, status);
787 double timeN = workingState->getTime();
788 TEST_COMPARE(timeN, ==, dt);
789 // TEST_COMPARE( std::fabs(timeN-dt)/dt, <, 1.0e-15);
790 TEST_COMPARE(workingState->getOutput(), ==, true);
791
792 // ** Successful timestep !! ** //
793 workingState->setSolutionStatus(Tempus::Status::PASSED);
794
795 solutionHistory->promoteWorkingState();
796
797 // Set dt to timestep before output for second timestep.
798 solutionHistory->initWorkingState();
799 // Set local RCPs for WS and CS after initialize.
800 currentState = solutionHistory->getCurrentState();
801 workingState = solutionHistory->getWorkingState();
802
803 tsc->setNextTimeStep(solutionHistory, status);
804 timeN = workingState->getTime();
805 TEST_COMPARE((timeN), ==, 2 * dt);
806
807 double dtN = workingState->getTimeStep();
808 TEST_COMPARE(dt, ==, dtN);
809
810 TEST_COMPARE(workingState->getOutput(), ==, false);
811}
812
813// ************************************************************
814// ************************************************************
815TEUCHOS_UNIT_TEST(TimeStepControl, ConstantTimeStep_Roundoff)
816{
817 // Setup the SolutionHistory --------------------------------
818 auto model = rcp(new Tempus_Test::SinCosModel<double>());
819 auto inArgsIC = model->getNominalValues();
820 auto icSolution = rcp_const_cast<Thyra::VectorBase<double>>(inArgsIC.get_x());
821 auto icState = Tempus::createSolutionStateX<double>(icSolution);
822 auto solutionHistory = rcp(new Tempus::SolutionHistory<double>());
823 solutionHistory->addState(icState);
824 double dt = 1.0e-04;
825 solutionHistory->getCurrentState()->setTimeStep(dt);
826
827 // Setup the TimeStepControl --------------------------------
828 auto tsc = rcp(new Tempus::TimeStepControl<double>());
829 std::vector<double> outputTimes;
830 double outputTime = 0.8;
831 outputTimes.push_back(outputTime);
832 tsc->setOutputTimes(outputTimes);
833 tsc->setOutputExactly(true);
834 tsc->setTimeStepControlStrategy();
835 tsc->setInitTimeStep(dt);
836 tsc->initialize();
838
839 // Take 10000 timesteps.
840 for (int i = 0; i < 10000; ++i) {
841 solutionHistory->initWorkingState();
842 tsc->setNextTimeStep(solutionHistory, status);
843
844 // ** Successful timestep !! ** //
845 solutionHistory->getWorkingState()->setSolutionStatus(
847
848 solutionHistory->promoteWorkingState();
849 }
850
851 auto currentState = solutionHistory->getCurrentState();
852 double time = currentState->getTime();
853 TEST_COMPARE(std::fabs(time - 1.0), <, 1.0e-15);
854}
855
856// ************************************************************
857// ************************************************************
858TEUCHOS_UNIT_TEST(TimeStepControl, Setting_Strategies_PLs)
859{
860 { // Test without "Time Step Control Strategy"
862 pl->remove("Time Step Control Strategy");
863
864 auto tsc = Tempus::createTimeStepControl<double>(pl, false);
865 TEUCHOS_TEST_FOR_EXCEPT(tsc->isInitialized());
866 tsc->initialize();
867 TEUCHOS_TEST_FOR_EXCEPT(!tsc->isInitialized());
868
869 // Default strategy is "Constant"
870 TEUCHOS_TEST_FOR_EXCEPT(!(tsc->getStepType() == "Constant"));
871 TEUCHOS_TEST_FOR_EXCEPT(
872 !(tsc->getTimeStepControlStrategy()->getStrategyType() == "Constant"));
873 }
874
875 { // Test with "Basic VS" strategy
877 pl->remove("Time Step Control Strategy");
878 pl->set("Time Step Control Strategy",
880
882 TEUCHOS_TEST_FOR_EXCEPT(!tsc->isInitialized());
883
884 // Strategy should be "Basic VS"
885 TEUCHOS_TEST_FOR_EXCEPT(!(tsc->getStepType() == "Variable"));
886 TEUCHOS_TEST_FOR_EXCEPT(
887 !(tsc->getTimeStepControlStrategy()->getStrategyType() == "Basic VS"));
888 }
889
890 { // Test with "Integral Controller" strategy
892 pl->remove("Time Step Control Strategy");
893 pl->set(
894 "Time Step Control Strategy",
896
898 TEUCHOS_TEST_FOR_EXCEPT(!tsc->isInitialized());
899
900 // Strategy should be "Integral Controller"
901 TEUCHOS_TEST_FOR_EXCEPT(!(tsc->getStepType() == "Variable"));
902 TEUCHOS_TEST_FOR_EXCEPT(
903 !(tsc->getTimeStepControlStrategy()->getStrategyType() ==
904 "Integral Controller"));
905 }
906
907 { // Test with "Composite" strategy
909 pl->remove("Time Step Control Strategy");
910 pl->set("Time Step Control Strategy",
912
914 TEUCHOS_TEST_FOR_EXCEPT(!tsc->isInitialized());
915
916 // Strategy should be "Composite"
917 TEUCHOS_TEST_FOR_EXCEPT(!(tsc->getStepType() == "Constant"));
918 TEUCHOS_TEST_FOR_EXCEPT(
919 !(tsc->getTimeStepControlStrategy()->getStrategyType() == "Composite"));
920 }
921
922 { // Test with a non-Tempus strategy
924 pl->remove("Time Step Control Strategy");
925
926 auto nonTempusStrategyPL =
927 Teuchos::parameterList("Time Step Control Strategy");
928 nonTempusStrategyPL->set<std::string>("Strategy Type",
929 "Application Strategy");
930 nonTempusStrategyPL->set<double>("Secret Sauce", 1.2345);
931
932 pl->set("Time Step Control Strategy", *nonTempusStrategyPL);
933
935 TEUCHOS_TEST_FOR_EXCEPT(!tsc->isInitialized());
936
937 // Without finding a Tempus Strategy, the strategy should be the default
938 // strategy "Constant"
939 TEUCHOS_TEST_FOR_EXCEPT(!(tsc->getStepType() == "Constant"));
940 TEUCHOS_TEST_FOR_EXCEPT(
941 !(tsc->getTimeStepControlStrategy()->getStrategyType() == "Constant"));
942 }
943}
944
945// ************************************************************
946// ************************************************************
947TEUCHOS_UNIT_TEST(TimeStepControl, Cast_Composite)
948{
949 // Setup Composite for this test.
951 auto tscsBasicVS = rcp(new Tempus::TimeStepControlStrategyBasicVS<double>());
952 temp->addStrategy(tscsBasicVS);
953 auto tscsIntCtrl =
955 temp->addStrategy(tscsIntCtrl);
956 temp->initialize();
957 TEUCHOS_TEST_FOR_EXCEPT(!temp->isInitialized());
958
959 auto tsc = rcp(new Tempus::TimeStepControl<double>());
960 tsc->setTimeStepControlStrategy(temp);
961 tsc->initialize();
962 TEUCHOS_TEST_FOR_EXCEPT(!tsc->isInitialized());
963
964 Teuchos::RCP<Tempus::TimeStepControlStrategy<double>> strategy =
965 tsc->getTimeStepControlStrategy();
966
967 // Test that we can cast this to a TimeStepControlStrategyComposite.
968 auto tscsc =
969 rcp_dynamic_cast<Tempus::TimeStepControlStrategyComposite<double>>(
970 strategy);
971
972 TEST_COMPARE(tscsc->size(), ==, 2);
973
974 std::vector<Teuchos::RCP<Tempus::TimeStepControlStrategy<double>>>
975 strategies = tscsc->getStrategies();
976
977 auto strategyBasicVS =
978 Teuchos::rcp_dynamic_cast<Tempus::TimeStepControlStrategyBasicVS<double>>(
979 strategies[0]);
980
981 TEUCHOS_TEST_FOR_EXCEPT(strategyBasicVS->getStepType() != "Variable");
982 TEUCHOS_TEST_FOR_EXCEPT(strategyBasicVS->getAmplFactor() != 1.75);
983 TEUCHOS_TEST_FOR_EXCEPT(strategyBasicVS->getReductFactor() != 0.5);
984 TEUCHOS_TEST_FOR_EXCEPT(strategyBasicVS->getMinEta() != 0.0);
985 TEUCHOS_TEST_FOR_EXCEPT(strategyBasicVS->getMaxEta() != 1.0e+16);
986
987 auto strategyIC = Teuchos::rcp_dynamic_cast<
989
990 TEUCHOS_TEST_FOR_EXCEPT(strategyIC->getStepType() != "Variable");
991 TEUCHOS_TEST_FOR_EXCEPT(strategyIC->getController() != "PID");
992 TEUCHOS_TEST_FOR_EXCEPT(strategyIC->getKI() != 0.58);
993 TEUCHOS_TEST_FOR_EXCEPT(strategyIC->getKP() != 0.21);
994 TEUCHOS_TEST_FOR_EXCEPT(strategyIC->getKD() != 0.10);
995 TEUCHOS_TEST_FOR_EXCEPT(strategyIC->getSafetyFactor() != 0.90);
996 TEUCHOS_TEST_FOR_EXCEPT(strategyIC->getSafetyFactorAfterReject() != 0.90);
997 TEUCHOS_TEST_FOR_EXCEPT(strategyIC->getFacMax() != 5.0);
998 TEUCHOS_TEST_FOR_EXCEPT(strategyIC->getFacMin() != 0.5);
999}
1000
1001} // namespace Tempus_Unit_Test
SolutionHistory is basically a container of SolutionStates. SolutionHistory maintains a collection of...
This composite TimeEvent loops over added TimeEvents.
TimeEventList specifies a list of time events.
TimeEventListIndex specifies a list of index events.
TimeEventRange specifies a start, stop and stride time.
TimeEventRangeIndex specifies a start, stop and stride index.
TimeStepControl manages the time step size. There several mechanisms that effect the time step size a...
StepControlStrategy class for TimeStepControl.
TimeStepControlStrategyComposite loops over a vector of TimeStepControlStrategies.
StepControlStrategy class for TimeStepControl.
Sine-Cosine model problem from Rythmos. This is a canonical Sine-Cosine differential equation.
TEUCHOS_UNIT_TEST(BackwardEuler, Default_Construction)
Status
Status for the Integrator, the Stepper and the SolutionState.
Teuchos::RCP< SolutionState< Scalar > > createSolutionStateX(const Teuchos::RCP< Thyra::VectorBase< Scalar > > &x, const Teuchos::RCP< Thyra::VectorBase< Scalar > > &xdot=Teuchos::null, const Teuchos::RCP< Thyra::VectorBase< Scalar > > &xdotdot=Teuchos::null)
Nonmember constructor from non-const solution vectors, x.
Teuchos::RCP< TimeStepControl< Scalar > > createTimeStepControl(Teuchos::RCP< Teuchos::ParameterList > const &pList, bool runInitialize=true)
Nonmember constructor from ParameterList.
Teuchos::RCP< Teuchos::ParameterList > getTimeStepControlStrategyIntegralControllerPL()
Nonmember function to return ParameterList with default values.
Teuchos::RCP< Teuchos::ParameterList > getTimeStepControlPL()
Nonmember function to return ParameterList with default values.
Teuchos::RCP< Teuchos::ParameterList > getTimeStepControlStrategyCompositePL()
Nonmember function to return ParameterList with default values.
Teuchos::RCP< Teuchos::ParameterList > getTimeStepControlStrategyBasicVS_PL()
Nonmember function to return ParameterList with default values.