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