Tempus  Version of the Day
Time Integration
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Tempus_UnitTest_BDF2.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 
13 
14 #include "Tempus_StepperBDF2.hpp"
19 
20 namespace Tempus_Unit_Test {
21 
23 using Teuchos::RCP;
24 using Teuchos::rcp;
25 using Teuchos::rcp_const_cast;
26 using Teuchos::rcp_dynamic_cast;
27 using Teuchos::sublist;
28 
29 // ************************************************************
30 // ************************************************************
31 TEUCHOS_UNIT_TEST(BDF2, Default_Construction)
32 {
33  auto model = rcp(new Tempus_Test::SinCosModel<double>());
34 
35  // Default construction.
36  auto stepper = rcp(new Tempus::StepperBDF2<double>());
37  stepper->setModel(model);
38  stepper->initialize();
39  TEUCHOS_TEST_FOR_EXCEPT(!stepper->isInitialized());
40 
41  // Default values for construction.
42  auto modifier = rcp(new Tempus::StepperBDF2ModifierDefault<double>());
43  auto solver = rcp(new Thyra::NOXNonlinearSolver());
44  solver->setParameterList(Tempus::defaultSolverParameters());
45 
46  auto startUpStepper = rcp(new Tempus::StepperDIRK_1StageTheta<double>());
47  startUpStepper->setModel(
48  model); // Can use the same model since both steppers are implicit ODEs.
49  startUpStepper->initialize();
50 
51  auto defaultStepper = rcp(new Tempus::StepperBDF2<double>());
52  bool useFSAL = defaultStepper->getUseFSAL();
53  std::string ICConsistency = defaultStepper->getICConsistency();
54  bool ICConsistencyCheck = defaultStepper->getICConsistencyCheck();
55  bool zeroInitialGuess = defaultStepper->getZeroInitialGuess();
56 
57  // Test the set functions.
58  stepper->setAppAction(modifier);
59  stepper->initialize();
60  TEUCHOS_TEST_FOR_EXCEPT(!stepper->isInitialized());
61  stepper->setSolver(solver);
62  stepper->initialize();
63  TEUCHOS_TEST_FOR_EXCEPT(!stepper->isInitialized());
64  stepper->setStartUpStepper(startUpStepper);
65  stepper->initialize();
66  TEUCHOS_TEST_FOR_EXCEPT(!stepper->isInitialized());
67  stepper->setUseFSAL(useFSAL);
68  stepper->initialize();
69  TEUCHOS_TEST_FOR_EXCEPT(!stepper->isInitialized());
70  stepper->setICConsistency(ICConsistency);
71  stepper->initialize();
72  TEUCHOS_TEST_FOR_EXCEPT(!stepper->isInitialized());
73  stepper->setICConsistencyCheck(ICConsistencyCheck);
74  stepper->initialize();
75  TEUCHOS_TEST_FOR_EXCEPT(!stepper->isInitialized());
76  stepper->setZeroInitialGuess(zeroInitialGuess);
77  stepper->initialize();
78  TEUCHOS_TEST_FOR_EXCEPT(!stepper->isInitialized());
79 
80  stepper = rcp(new Tempus::StepperBDF2<double>(
81  model, solver, startUpStepper, useFSAL, ICConsistency, ICConsistencyCheck,
82  zeroInitialGuess, modifier));
83  TEUCHOS_TEST_FOR_EXCEPT(!stepper->isInitialized());
84  // Test stepper properties.
85  TEUCHOS_ASSERT(stepper->getOrder() == 2);
86 }
87 
88 // ************************************************************
89 // ************************************************************
90 TEUCHOS_UNIT_TEST(BDF2, StepperFactory_Construction)
91 {
92  auto model = rcp(new Tempus_Test::SinCosModel<double>());
93  testFactoryConstruction("BDF2", model);
94 }
95 
96 // ************************************************************
97 // ************************************************************
99 {
100  // Read params from .xml file
101  RCP<ParameterList> pList =
102  Teuchos::getParametersFromXmlFile("Tempus_BDF2_SinCos.xml");
103 
104  // Setup the SinCosModel
105  RCP<ParameterList> scm_pl = sublist(pList, "SinCosModel", true);
106  auto model = rcp(new Tempus_Test::SinCosModel<double>(scm_pl));
107 
108  RCP<ParameterList> tempusPL = sublist(pList, "Tempus", true);
109 
110  // Test constructor IntegratorBasic(tempusPL, model)
111  {
113  Tempus::createIntegratorBasic<double>(tempusPL, model);
114 
115  RCP<ParameterList> stepperPL = sublist(tempusPL, "Default Stepper", true);
116  RCP<const ParameterList> defaultPL =
117  integrator->getStepper()->getValidParameters();
118  bool pass = haveSameValuesSorted(*stepperPL, *defaultPL, true);
119  if (!pass) {
120  out << std::endl;
121  out << "stepperPL -------------- \n"
122  << *stepperPL << std::endl;
123  out << "defaultPL -------------- \n"
124  << *defaultPL << std::endl;
125  }
126  TEST_ASSERT(pass)
127  }
128 
129  // Test constructor IntegratorBasic(model, stepperType)
130  {
132  Tempus::createIntegratorBasic<double>(model, std::string("BDF2"));
133 
134  RCP<ParameterList> stepperPL = sublist(tempusPL, "Default Stepper", true);
135  RCP<const ParameterList> defaultPL =
136  integrator->getStepper()->getValidParameters();
137 
138  bool pass = haveSameValuesSorted(*stepperPL, *defaultPL, true);
139  if (!pass) {
140  out << std::endl;
141  out << "stepperPL -------------- \n"
142  << *stepperPL << std::endl;
143  out << "defaultPL -------------- \n"
144  << *defaultPL << std::endl;
145  }
146  TEST_ASSERT(pass)
147  }
148 }
149 
150 // ************************************************************
151 // ************************************************************
152 TEUCHOS_UNIT_TEST(BDF2, ConstructingFromDefaults)
153 {
154  double dt = 0.1;
155  std::vector<std::string> options;
156  options.push_back("Default Parameters");
157  options.push_back("ICConsistency and Check");
158 
159  for (const auto& option : options) {
160  // Read params from .xml file
161  RCP<ParameterList> pList =
162  Teuchos::getParametersFromXmlFile("Tempus_BDF2_SinCos.xml");
163  RCP<ParameterList> pl = sublist(pList, "Tempus", true);
164 
165  // Setup the SinCosModel
166  RCP<ParameterList> scm_pl = sublist(pList, "SinCosModel", true);
167  // RCP<SinCosModel<double> > model = sineCosineModel(scm_pl);
168  auto model = rcp(new Tempus_Test::SinCosModel<double>(scm_pl));
169 
170  // Setup Stepper for field solve ----------------------------
171  auto stepper = rcp(new Tempus::StepperBDF2<double>());
172  stepper->setModel(model);
173  if (option == "ICConsistency and Check") {
174  stepper->setICConsistency("Consistent");
175  stepper->setICConsistencyCheck(true);
176  }
177  stepper->initialize();
178 
179  // Setup TimeStepControl ------------------------------------
180  auto timeStepControl = rcp(new Tempus::TimeStepControl<double>());
181  ParameterList tscPL =
182  pl->sublist("Default Integrator").sublist("Time Step Control");
183  timeStepControl->setInitIndex(tscPL.get<int>("Initial Time Index"));
184  timeStepControl->setInitTime(tscPL.get<double>("Initial Time"));
185  timeStepControl->setFinalTime(tscPL.get<double>("Final Time"));
186  timeStepControl->setInitTimeStep(dt);
187  timeStepControl->initialize();
188 
189  // Setup initial condition SolutionState --------------------
190  auto inArgsIC = model->getNominalValues();
191  auto icSolution =
192  rcp_const_cast<Thyra::VectorBase<double> >(inArgsIC.get_x());
193  auto icState = Tempus::createSolutionStateX(icSolution);
194  icState->setTime(timeStepControl->getInitTime());
195  icState->setIndex(timeStepControl->getInitIndex());
196  icState->setTimeStep(0.0);
197  icState->setOrder(stepper->getOrder());
198  icState->setSolutionStatus(Tempus::Status::PASSED); // ICs are passing.
199 
200  // Setup SolutionHistory ------------------------------------
201  auto solutionHistory = rcp(new Tempus::SolutionHistory<double>());
202  solutionHistory->setName("Forward States");
203  solutionHistory->setStorageType(Tempus::STORAGE_TYPE_STATIC);
204  solutionHistory->setStorageLimit(3);
205  solutionHistory->addState(icState);
206 
207  // Ensure ICs are consistent and stepper memory is set (e.g., xDot is set).
208  stepper->setInitialConditions(solutionHistory);
209 
210  // Setup Integrator -----------------------------------------
212  Tempus::createIntegratorBasic<double>();
213  integrator->setStepper(stepper);
214  integrator->setTimeStepControl(timeStepControl);
215  integrator->setSolutionHistory(solutionHistory);
216  // integrator->setObserver(...);
217  integrator->initialize();
218 
219  // Integrate to timeMax
220  bool integratorStatus = integrator->advanceTime();
221  TEST_ASSERT(integratorStatus)
222 
223  // Test if at 'Final Time'
224  double time = integrator->getTime();
225  double timeFinal = pl->sublist("Default Integrator")
226  .sublist("Time Step Control")
227  .get<double>("Final Time");
228  TEST_FLOATING_EQUALITY(time, timeFinal, 1.0e-14);
229 
230  // Time-integrated solution and the exact solution
231  RCP<Thyra::VectorBase<double> > x = integrator->getX();
233  model->getExactSolution(time).get_x();
234 
235  // Calculate the error
236  RCP<Thyra::VectorBase<double> > xdiff = x->clone_v();
237  Thyra::V_StVpStV(xdiff.ptr(), 1.0, *x_exact, -1.0, *(x));
238 
239  // Check the order and intercept
240  out << " Stepper = " << stepper->description() << "\n with "
241  << option << std::endl;
242  out << " =========================" << std::endl;
243  out << " Exact solution : " << get_ele(*(x_exact), 0) << " "
244  << get_ele(*(x_exact), 1) << std::endl;
245  out << " Computed solution: " << get_ele(*(x), 0) << " "
246  << get_ele(*(x), 1) << std::endl;
247  out << " Difference : " << get_ele(*(xdiff), 0) << " "
248  << get_ele(*(xdiff), 1) << std::endl;
249  out << " =========================" << std::endl;
250  TEST_FLOATING_EQUALITY(get_ele(*(x), 0), 0.839732, 1.0e-4);
251  TEST_FLOATING_EQUALITY(get_ele(*(x), 1), 0.542663, 1.0e-4);
252  }
253 }
254 
255 // ************************************************************
256 // ************************************************************
257 class StepperBDF2ModifierTest
258  : virtual public Tempus::StepperBDF2ModifierBase<double> {
259  public:
261  StepperBDF2ModifierTest()
262  : testBEGIN_STEP(false),
263  testBEFORE_SOLVE(false),
264  testAFTER_SOLVE(false),
265  testEND_STEP(false),
266  testCurrentValue(-0.99),
267  testWorkingValue(-0.99),
268  testDt(.99),
269  testType("")
270  {
271  }
272 
274  virtual ~StepperBDF2ModifierTest() {}
275 
277  virtual void modify(
281  actLoc)
282  {
283  switch (actLoc) {
285  testBEGIN_STEP = true;
286  auto x = sh->getWorkingState()->getX();
287  testCurrentValue = get_ele(*(x), 0);
288  break;
289  }
291  testBEFORE_SOLVE = true;
292  testType = "BDF2 - Modifier";
293  break;
294  }
296  testAFTER_SOLVE = true;
297  testDt = sh->getCurrentState()->getTimeStep() / 10.0;
298  sh->getCurrentState()->setTimeStep(testDt);
299  break;
300  }
302  testEND_STEP = true;
303  auto x = sh->getWorkingState()->getX();
304  testWorkingValue = get_ele(*(x), 0);
305  break;
306  }
307  default:
308  TEUCHOS_TEST_FOR_EXCEPTION(true, std::logic_error,
309  "Error - unknown action location.\n");
310  }
311  }
312  bool testBEGIN_STEP;
313  bool testBEFORE_SOLVE;
314  bool testAFTER_SOLVE;
315  bool testEND_STEP;
316  double testCurrentValue;
317  double testWorkingValue;
318  double testDt;
319  std::string testType;
320 };
321 
322 TEUCHOS_UNIT_TEST(BDF2, AppAction_Modifier)
323 {
324  auto model = rcp(new Tempus_Test::SinCosModel<double>());
325 
326  // Setup Stepper for field solve ----------------------------
327  auto stepper = rcp(new Tempus::StepperBDF2<double>());
328  stepper->setModel(model);
329  auto modifier = rcp(new StepperBDF2ModifierTest());
330  stepper->setAppAction(modifier);
331  stepper->initialize();
332 
333  // Setup initial condition SolutionState --------------------
334  auto inArgsIC = model->getNominalValues();
335  auto icSolution =
336  rcp_const_cast<Thyra::VectorBase<double> >(inArgsIC.get_x());
337  auto icState = Tempus::createSolutionStateX(icSolution);
338  icState->setTime(0.0);
339  icState->setIndex(0);
340  icState->setTimeStep(1.0);
341  icState->setOrder(stepper->getOrder());
342  icState->setSolutionStatus(Tempus::Status::PASSED); // ICs are passing.
343 
344  // Setup TimeStepControl ------------------------------------
345  auto timeStepControl = rcp(new Tempus::TimeStepControl<double>());
346  timeStepControl->setInitIndex(0);
347  timeStepControl->setInitTime(0.0);
348  timeStepControl->setFinalTime(2.0);
349  timeStepControl->setInitTimeStep(1.0);
350  timeStepControl->initialize();
351 
352  // Setup SolutionHistory ------------------------------------
353  auto solutionHistory = rcp(new Tempus::SolutionHistory<double>());
354  solutionHistory->setName("Forward States");
355  solutionHistory->setStorageType(Tempus::STORAGE_TYPE_STATIC);
356  solutionHistory->setStorageLimit(3);
357  solutionHistory->addState(icState);
358 
359  // Take two time steps (the first step will not test BDF2's modifier)
360  stepper->setInitialConditions(solutionHistory);
361  solutionHistory->initWorkingState();
362  double dt = 1.0;
363  solutionHistory->getWorkingState()->setTimeStep(dt);
364  stepper->takeStep(solutionHistory);
365  solutionHistory->promoteWorkingState();
366  solutionHistory->initWorkingState();
367  stepper->takeStep(solutionHistory);
368 
369  TEST_COMPARE(modifier->testBEGIN_STEP, ==, true);
370  TEST_COMPARE(modifier->testBEFORE_SOLVE, ==, true);
371  TEST_COMPARE(modifier->testAFTER_SOLVE, ==, true);
372  TEST_COMPARE(modifier->testEND_STEP, ==, true);
373 
374  auto Dt = solutionHistory->getCurrentState()->getTimeStep();
375  TEST_FLOATING_EQUALITY(modifier->testDt, Dt, 1.0e-15);
376  auto x = solutionHistory->getCurrentState()->getX();
377  TEST_FLOATING_EQUALITY(modifier->testCurrentValue, get_ele(*(x), 0), 1.0e-15);
378  x = solutionHistory->getWorkingState()->getX();
379  TEST_FLOATING_EQUALITY(modifier->testWorkingValue, get_ele(*(x), 0), 1.0e-15);
380  TEST_COMPARE(modifier->testType, ==, "BDF2 - Modifier");
381 }
382 
383 // ************************************************************
384 // ************************************************************
385 class StepperBDF2ObserverTest
386  : virtual public Tempus::StepperBDF2ObserverBase<double> {
387  public:
389  StepperBDF2ObserverTest()
390  : testBEGIN_STEP(false),
391  testBEFORE_SOLVE(false),
392  testAFTER_SOLVE(false),
393  testEND_STEP(false),
394  testCurrentValue(0.99),
395  testWorkingValue(0.99),
396  testDt(.99),
397  testType("")
398  {
399  }
400 
402  virtual ~StepperBDF2ObserverTest() {}
403 
405  virtual void modify(
409  actLoc)
410  {
411  switch (actLoc) {
413  testBEGIN_STEP = true;
414  auto x = sh->getCurrentState()->getX();
415  testCurrentValue = get_ele(*(x), 0);
416  break;
417  }
419  testBEFORE_SOLVE = true;
420  testType = stepper->getStepperType();
421  break;
422  }
424  testAFTER_SOLVE = true;
425  testDt = sh->getCurrentState()->getTimeStep();
426  break;
427  }
429  testEND_STEP = true;
430  auto x = sh->getWorkingState()->getX();
431  testWorkingValue = get_ele(*(x), 0);
432  break;
433  }
434 
435  default:
436  TEUCHOS_TEST_FOR_EXCEPTION(true, std::logic_error,
437  "Error - unknown action location.\n");
438  }
439  }
440  bool testBEGIN_STEP;
441  bool testBEFORE_SOLVE;
442  bool testAFTER_SOLVE;
443  bool testEND_STEP;
444  double testCurrentValue;
445  double testWorkingValue;
446  double testDt;
447  std::string testType;
448 };
449 
450 // ************************************************************
451 // ************************************************************
452 TEUCHOS_UNIT_TEST(BDF2, AppAction_Observer)
453 {
454  auto model = rcp(new Tempus_Test::SinCosModel<double>());
455 
456  // Setup Stepper for field solve ----------------------------
457  auto stepper = rcp(new Tempus::StepperBDF2<double>());
458  stepper->setModel(model);
459  auto observer = rcp(new StepperBDF2ModifierTest());
460  stepper->setAppAction(observer);
461  stepper->initialize();
462 
463  // Setup initial condition SolutionState --------------------
464  auto inArgsIC = model->getNominalValues();
465  auto icSolution =
466  rcp_const_cast<Thyra::VectorBase<double> >(inArgsIC.get_x());
467  auto icState = Tempus::createSolutionStateX(icSolution);
468  icState->setTime(0.0);
469  icState->setIndex(0);
470  icState->setTimeStep(1.0);
471  icState->setOrder(stepper->getOrder());
472  icState->setSolutionStatus(Tempus::Status::PASSED); // ICs are passing.
473 
474  // Setup TimeStepControl ------------------------------------
475  auto timeStepControl = rcp(new Tempus::TimeStepControl<double>());
476  timeStepControl->setInitIndex(0);
477  timeStepControl->setInitTime(0.0);
478  timeStepControl->setFinalTime(2.0);
479  timeStepControl->setInitTimeStep(1.0);
480  timeStepControl->initialize();
481 
482  // Setup SolutionHistory ------------------------------------
483  auto solutionHistory = rcp(new Tempus::SolutionHistory<double>());
484  solutionHistory->setName("Forward States");
485  solutionHistory->setStorageType(Tempus::STORAGE_TYPE_STATIC);
486  solutionHistory->setStorageLimit(3);
487  solutionHistory->addState(icState);
488 
489  // Take two time steps (the first step will not test BDF2's modifier)
490  stepper->setInitialConditions(solutionHistory);
491  solutionHistory->initWorkingState();
492  double dt = 1.0;
493  solutionHistory->getWorkingState()->setTimeStep(dt);
494  stepper->takeStep(solutionHistory);
495  solutionHistory->promoteWorkingState();
496  solutionHistory->initWorkingState();
497  stepper->takeStep(solutionHistory);
498 
499  TEST_COMPARE(observer->testBEGIN_STEP, ==, true);
500  TEST_COMPARE(observer->testBEFORE_SOLVE, ==, true);
501  TEST_COMPARE(observer->testAFTER_SOLVE, ==, true);
502  TEST_COMPARE(observer->testEND_STEP, ==, true);
503 
504  auto Dt = solutionHistory->getCurrentState()->getTimeStep();
505  TEST_FLOATING_EQUALITY(observer->testDt, Dt, 1.0e-15);
506 
507  auto x = solutionHistory->getCurrentState()->getX();
508  TEST_FLOATING_EQUALITY(observer->testCurrentValue, get_ele(*(x), 0), 1.0e-15);
509  x = solutionHistory->getWorkingState()->getX();
510  TEST_FLOATING_EQUALITY(observer->testWorkingValue, get_ele(*(x), 0), 1.0e-15);
511  TEST_COMPARE(observer->testType, ==, "BDF2 - Modifier");
512 }
513 
514 // ************************************************************
515 // ************************************************************
516 class StepperBDF2ModifierXTest
517  : virtual public Tempus::StepperBDF2ModifierXBase<double> {
518  public:
520  StepperBDF2ModifierXTest()
521  : testX_BEGIN_STEP(false),
522  testX_BEFORE_SOLVE(false),
523  testX_AFTER_SOLVE(false),
524  testX_END_STEP(false),
525  testXbegin(-.99),
526  testXend(-.99),
527  testTime(0.0),
528  testDt(0.0)
529  {
530  }
531 
533  virtual ~StepperBDF2ModifierXTest() {}
534 
536  virtual void modify(
537  Teuchos::RCP<Thyra::VectorBase<double> > x, const double time,
538  const double dt,
540  modType)
541  {
542  switch (modType) {
544  testX_BEGIN_STEP = true;
545  testXbegin = get_ele(*(x), 0);
546  break;
547  }
549  testX_BEFORE_SOLVE = true;
550  testDt = dt;
551  break;
552  }
554  testX_AFTER_SOLVE = true;
555  testTime = time;
556  break;
557  }
559  testX_END_STEP = true;
560  testXend = get_ele(*(x), 0);
561  break;
562  }
563  default:
564  TEUCHOS_TEST_FOR_EXCEPTION(true, std::logic_error,
565  "Error - unknown action location.\n");
566  }
567  }
568  bool testX_BEGIN_STEP;
569  bool testX_BEFORE_SOLVE;
570  bool testX_AFTER_SOLVE;
571  bool testX_END_STEP;
572  double testXbegin;
573  double testXend;
574  double testTime;
575  double testDt;
576 };
577 
578 // ************************************************************
579 // ************************************************************
580 TEUCHOS_UNIT_TEST(BDF2, AppAction_ModifierX)
581 {
582  auto model = rcp(new Tempus_Test::SinCosModel<double>());
583  // Setup Stepper for field solve ----------------------------
584  auto stepper = rcp(new Tempus::StepperBDF2<double>());
585  stepper->setModel(model);
586  auto modifierX = rcp(new StepperBDF2ModifierXTest());
587  stepper->setAppAction(modifierX);
588  stepper->initialize();
589 
590  // Setup initial condition SolutionState --------------------
591  auto inArgsIC = model->getNominalValues();
592  auto icSolution =
593  rcp_const_cast<Thyra::VectorBase<double> >(inArgsIC.get_x());
594  auto icState = Tempus::createSolutionStateX(icSolution);
595  icState->setTime(0.0);
596  icState->setIndex(0);
597  icState->setTimeStep(1.0);
598  icState->setOrder(stepper->getOrder());
599  icState->setSolutionStatus(Tempus::Status::PASSED); // ICs are passing.
600 
601  // Setup TimeStepControl ------------------------------------
602  auto timeStepControl = rcp(new Tempus::TimeStepControl<double>());
603  timeStepControl->setInitIndex(0);
604  timeStepControl->setInitTime(0.0);
605  timeStepControl->setFinalTime(2.0);
606  timeStepControl->setInitTimeStep(1.0);
607  timeStepControl->initialize();
608 
609  // Setup SolutionHistory ------------------------------------
610  auto solutionHistory = rcp(new Tempus::SolutionHistory<double>());
611  solutionHistory->setName("Forward States");
612  solutionHistory->setStorageType(Tempus::STORAGE_TYPE_STATIC);
613  solutionHistory->setStorageLimit(3);
614  solutionHistory->addState(icState);
615 
616  // Take two time steps (the first step will not test BDF2's modifier)
617  stepper->setInitialConditions(solutionHistory);
618  solutionHistory->initWorkingState();
619  double dt = 1.0;
620  solutionHistory->getWorkingState()->setTimeStep(dt);
621  stepper->takeStep(solutionHistory);
622  solutionHistory->promoteWorkingState();
623  solutionHistory->initWorkingState();
624  stepper->takeStep(solutionHistory);
625 
626  TEST_COMPARE(modifierX->testX_BEGIN_STEP, ==, true);
627  TEST_COMPARE(modifierX->testX_BEFORE_SOLVE, ==, true);
628  TEST_COMPARE(modifierX->testX_AFTER_SOLVE, ==, true);
629  TEST_COMPARE(modifierX->testX_END_STEP, ==, true);
630 
631  // Testing that values can be set through the Modifier.
632  auto x = solutionHistory->getCurrentState()->getX();
633  TEST_FLOATING_EQUALITY(modifierX->testXbegin, get_ele(*(x), 0), 1.0e-15);
634  auto Dt = solutionHistory->getWorkingState()->getTimeStep();
635  x = solutionHistory->getWorkingState()->getX();
636  TEST_FLOATING_EQUALITY(modifierX->testXend, get_ele(*(x), 0), 1.0e-15);
637  TEST_FLOATING_EQUALITY(modifierX->testDt, Dt, 1.0e-15);
638  auto time = solutionHistory->getWorkingState()->getTime();
639  TEST_FLOATING_EQUALITY(modifierX->testTime, time, 1.0e-15);
640 }
641 
642 } // namespace Tempus_Unit_Test
BDF2 (Backward-Difference-Formula-2) time stepper.
Teuchos::RCP< SolutionState< Scalar > > createSolutionStateX(const Teuchos::RCP< Thyra::VectorBase< Scalar > > &x, const Teuchos::RCP< Thyra::VectorBase< Scalar > > &xdot=Teuchos::null, const Teuchos::RCP< Thyra::VectorBase< Scalar > > &xdotdot=Teuchos::null)
Nonmember constructor from non-const solution vectors, x.
ACTION_LOCATION
Indicates the location of application action (see algorithm).
void testFactoryConstruction(std::string stepperType, const Teuchos::RCP< const Thyra::ModelEvaluator< double > > &model)
Unit test utility for Stepper construction through StepperFactory.
T & get(const std::string &name, T def_value)
#define TEUCHOS_TEST_FOR_EXCEPTION(throw_exception_test, Exception, msg)
#define TEST_COMPARE(v1, comp, v2)
#define TEST_FLOATING_EQUALITY(v1, v2, tol)
#define TEST_ASSERT(v1)
Sine-Cosine model problem from Rythmos. This is a canonical Sine-Cosine differential equation with a...
Teuchos::RCP< Teuchos::ParameterList > defaultSolverParameters()
Returns the default solver ParameterList for implicit Steppers.
TEUCHOS_DEPRECATED RCP< T > rcp(T *p, Dealloc_T dealloc, bool owns_mem)
virtual void modify(Teuchos::RCP< Thyra::VectorBase< double > >, const double, const double, const MODIFIER_TYPE modType)=0
Modify solution based on the MODIFIER_TYPE.
Ptr< T > ptr() const
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...
Keep a fix number of states.
ParameterList & sublist(const std::string &name, bool mustAlreadyExist=false, const std::string &docString="")
#define TEUCHOS_ASSERT(assertion_test)
MODIFIER_TYPE
Indicates the location of application action (see algorithm).
#define TEUCHOS_TEST_FOR_EXCEPT(throw_exception_test)