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