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