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