9 #include "Teuchos_UnitTestHarness.hpp"
10 #include "Teuchos_XMLParameterListHelpers.hpp"
11 #include "Teuchos_TimeMonitor.hpp"
13 #include "Thyra_VectorStdOps.hpp"
15 #include "Tempus_IntegratorBasic.hpp"
18 #include "../TestModels/SinCosModel.hpp"
19 #include "../TestModels/VanDerPolModel.hpp"
20 #include "../TestUtils/Tempus_ConvergenceTestUtils.hpp"
25 namespace Tempus_Test {
29 using Teuchos::rcp_const_cast;
30 using Teuchos::rcp_dynamic_cast;
31 using Teuchos::ParameterList;
32 using Teuchos::parameterList;
33 using Teuchos::sublist;
34 using Teuchos::getParametersFromXmlFile;
41 #define TEST_PARAMETERLIST
42 #define TEST_CONSTRUCTING_FROM_DEFAULTS
44 #define TEST_VANDERPOL
45 #define TEST_EMBEDDED_DIRK
48 #ifdef TEST_PARAMETERLIST
53 std::vector<std::string> RKMethods;
54 RKMethods.push_back(
"General DIRK");
55 RKMethods.push_back(
"RK Backward Euler");
56 RKMethods.push_back(
"DIRK 1 Stage Theta Method");
57 RKMethods.push_back(
"RK Implicit 1 Stage 1st order Radau IA");
58 RKMethods.push_back(
"RK Implicit Midpoint");
59 RKMethods.push_back(
"SDIRK 2 Stage 2nd order");
60 RKMethods.push_back(
"RK Implicit 2 Stage 2nd order Lobatto IIIB");
61 RKMethods.push_back(
"SDIRK 2 Stage 3rd order");
62 RKMethods.push_back(
"EDIRK 2 Stage 3rd order");
63 RKMethods.push_back(
"EDIRK 2 Stage Theta Method");
64 RKMethods.push_back(
"SDIRK 3 Stage 4th order");
65 RKMethods.push_back(
"SDIRK 5 Stage 4th order");
66 RKMethods.push_back(
"SDIRK 5 Stage 5th order");
67 RKMethods.push_back(
"SDIRK 2(1) Pair");
68 RKMethods.push_back(
"RK Trapezoidal Rule");
69 RKMethods.push_back(
"RK Crank-Nicolson");
71 for(std::vector<std::string>::size_type m = 0; m != RKMethods.size(); m++) {
73 std::string RKMethod = RKMethods[m];
76 RCP<ParameterList> pList =
77 getParametersFromXmlFile(
"Tempus_DIRK_SinCos.xml");
80 RCP<ParameterList> scm_pl = sublist(pList,
"SinCosModel",
true);
83 RCP<ParameterList> tempusPL = sublist(pList,
"Tempus",
true);
84 tempusPL->sublist(
"Default Stepper").set(
"Stepper Type", RKMethods[m]);
86 if (RKMethods[m] ==
"DIRK 1 Stage Theta Method" ||
87 RKMethods[m] ==
"EDIRK 2 Stage Theta Method") {
89 RCP<ParameterList> stepperPL = sublist(tempusPL,
"Default Stepper",
true);
90 RCP<ParameterList> solverPL = parameterList();
91 *solverPL = *(sublist(stepperPL,
"Default Solver",
true));
92 tempusPL->sublist(
"Default Stepper").remove(
"Zero Initial Guess");
93 tempusPL->sublist(
"Default Stepper").remove(
"Default Solver");
94 tempusPL->sublist(
"Default Stepper").set<
bool>(
"Zero Initial Guess", 0);
95 tempusPL->sublist(
"Default Stepper").remove(
"Reset Initial Guess");
96 tempusPL->sublist(
"Default Stepper").set<
bool>(
"Reset Initial Guess", 1);
97 tempusPL->sublist(
"Default Stepper").set(
"Default Solver", *solverPL);
98 tempusPL->sublist(
"Default Stepper").set<
double>(
"theta", 0.5);
99 }
else if (RKMethods[m] ==
"SDIRK 2 Stage 2nd order") {
101 RCP<ParameterList> stepperPL = sublist(tempusPL,
"Default Stepper",
true);
102 RCP<ParameterList> solverPL = parameterList();
103 *solverPL = *(sublist(stepperPL,
"Default Solver",
true));
104 tempusPL->sublist(
"Default Stepper").remove(
"Default Solver");
105 tempusPL->sublist(
"Default Stepper").remove(
"Zero Initial Guess");
106 tempusPL->sublist(
"Default Stepper").set<
bool>(
"Zero Initial Guess", 0);
107 tempusPL->sublist(
"Default Stepper").remove(
"Reset Initial Guess");
108 tempusPL->sublist(
"Default Stepper").set<
bool>(
"Reset Initial Guess", 1);
109 tempusPL->sublist(
"Default Stepper").set(
"Default Solver", *solverPL);
110 tempusPL->sublist(
"Default Stepper")
111 .set<
double>(
"gamma", 0.2928932188134524);
112 }
else if (RKMethods[m] ==
"SDIRK 2 Stage 3rd order") {
114 RCP<ParameterList> stepperPL = sublist(tempusPL,
"Default Stepper",
true);
115 RCP<ParameterList> solverPL = parameterList();
116 *solverPL = *(sublist(stepperPL,
"Default Solver",
true));
117 tempusPL->sublist(
"Default Stepper").remove(
"Zero Initial Guess");
118 tempusPL->sublist(
"Default Stepper").set<
bool>(
"Zero Initial Guess", 0);
119 tempusPL->sublist(
"Default Stepper").remove(
"Default Solver");
120 tempusPL->sublist(
"Default Stepper").remove(
"Reset Initial Guess");
121 tempusPL->sublist(
"Default Stepper").set<
bool>(
"Reset Initial Guess", 1);
122 tempusPL->sublist(
"Default Stepper").set(
"Default Solver", *solverPL);
123 tempusPL->sublist(
"Default Stepper")
124 .set<std::string>(
"Gamma Type",
"3rd Order A-stable");
125 tempusPL->sublist(
"Default Stepper")
126 .set<
double>(
"gamma", 0.7886751345948128);
127 }
else if (RKMethods[m] ==
"RK Crank-Nicolson") {
129 tempusPL->sublist(
"Default Stepper")
130 .set(
"Stepper Type",
"RK Trapezoidal Rule");
131 }
else if (RKMethods[m] ==
"General DIRK") {
133 Teuchos::RCP<Teuchos::ParameterList> tableauPL = Teuchos::parameterList();
134 tableauPL->set<std::string>(
"A",
"0.2928932188134524 0.0; 0.7071067811865476 0.2928932188134524");
135 tableauPL->set<std::string>(
"b",
"0.7071067811865476 0.2928932188134524");
136 tableauPL->set<std::string>(
"c",
"0.2928932188134524 1.0");
137 tableauPL->set<
int>(
"order", 2);
138 tableauPL->set<std::string>(
"bstar",
"");
139 tempusPL->sublist(
"Default Stepper").set(
"Tableau", *tableauPL);
145 RCP<Tempus::IntegratorBasic<double> > integrator =
146 Tempus::integratorBasic<double>(tempusPL, model);
148 RCP<ParameterList> stepperPL = sublist(tempusPL,
"Default Stepper",
true);
149 RCP<ParameterList> defaultPL =
150 Teuchos::rcp_const_cast<Teuchos::ParameterList>(
151 integrator->getStepper()->getValidParameters());
152 defaultPL->remove(
"Description");
154 bool pass = haveSameValues(*stepperPL, *defaultPL,
true);
156 std::cout << std::endl;
157 std::cout <<
"stepperPL -------------- \n" << *stepperPL << std::endl;
158 std::cout <<
"defaultPL -------------- \n" << *defaultPL << std::endl;
165 RCP<Tempus::IntegratorBasic<double> > integrator =
166 Tempus::integratorBasic<double>(model, RKMethods[m]);
168 RCP<ParameterList> stepperPL = sublist(tempusPL,
"Default Stepper",
true);
169 RCP<ParameterList> defaultPL =
170 Teuchos::rcp_const_cast<Teuchos::ParameterList>(
171 integrator->getStepper()->getValidParameters());
172 defaultPL->remove(
"Description");
174 bool pass = haveSameValues(*stepperPL, *defaultPL,
true);
176 std::cout << std::endl;
177 std::cout <<
"stepperPL -------------- \n" << *stepperPL << std::endl;
178 std::cout <<
"defaultPL -------------- \n" << *defaultPL << std::endl;
184 #endif // TEST_PARAMETERLIST
187 #ifdef TEST_CONSTRUCTING_FROM_DEFAULTS
195 RCP<ParameterList> pList =
196 getParametersFromXmlFile(
"Tempus_DIRK_SinCos.xml");
197 RCP<ParameterList> pl = sublist(pList,
"Tempus",
true);
200 RCP<ParameterList> scm_pl = sublist(pList,
"SinCosModel",
true);
205 RCP<Tempus::StepperFactory<double> > sf =
207 RCP<Tempus::Stepper<double> > stepper =
208 sf->createStepper(
"SDIRK 2 Stage 2nd order");
209 stepper->setModel(model);
210 stepper->setSolver();
211 stepper->initialize();
215 ParameterList tscPL = pl->sublist(
"Default Integrator")
216 .sublist(
"Time Step Control");
217 timeStepControl->setStepType (tscPL.get<std::string>(
"Integrator Step Type"));
218 timeStepControl->setInitIndex(tscPL.get<
int> (
"Initial Time Index"));
219 timeStepControl->setInitTime (tscPL.get<
double>(
"Initial Time"));
220 timeStepControl->setFinalTime(tscPL.get<
double>(
"Final Time"));
221 timeStepControl->setInitTimeStep(dt);
222 timeStepControl->initialize();
225 Thyra::ModelEvaluatorBase::InArgs<double> inArgsIC =
226 stepper->getModel()->getNominalValues();
227 auto icSolution = rcp_const_cast<Thyra::VectorBase<double> > (inArgsIC.get_x());
229 icState->setTime (timeStepControl->getInitTime());
230 icState->setIndex (timeStepControl->getInitIndex());
231 icState->setTimeStep(0.0);
232 icState->setOrder (stepper->getOrder());
243 RCP<Tempus::IntegratorBasic<double> > integrator =
244 Tempus::integratorBasic<double>();
245 integrator->setStepperWStepper(stepper);
246 integrator->setTimeStepControl(timeStepControl);
249 integrator->initialize();
253 bool integratorStatus = integrator->advanceTime();
254 TEST_ASSERT(integratorStatus)
258 double time = integrator->getTime();
259 double timeFinal =pl->sublist(
"Default Integrator")
260 .sublist(
"Time Step Control").get<
double>(
"Final Time");
261 TEST_FLOATING_EQUALITY(time, timeFinal, 1.0e-14);
264 RCP<Thyra::VectorBase<double> > x = integrator->getX();
265 RCP<const Thyra::VectorBase<double> > x_exact =
266 model->getExactSolution(time).get_x();
269 RCP<Thyra::VectorBase<double> > xdiff = x->clone_v();
270 Thyra::V_StVpStV(xdiff.ptr(), 1.0, *x_exact, -1.0, *(x));
273 std::cout <<
" Stepper = SDIRK 2 Stage 2nd order" << std::endl;
274 std::cout <<
" =========================" << std::endl;
275 std::cout <<
" Exact solution : " << get_ele(*(x_exact), 0) <<
" "
276 << get_ele(*(x_exact), 1) << std::endl;
277 std::cout <<
" Computed solution: " << get_ele(*(x ), 0) <<
" "
278 << get_ele(*(x ), 1) << std::endl;
279 std::cout <<
" Difference : " << get_ele(*(xdiff ), 0) <<
" "
280 << get_ele(*(xdiff ), 1) << std::endl;
281 std::cout <<
" =========================" << std::endl;
282 TEST_FLOATING_EQUALITY(get_ele(*(x), 0), 0.841470, 1.0e-4 );
283 TEST_FLOATING_EQUALITY(get_ele(*(x), 1), 0.540304, 1.0e-4 );
285 #endif // TEST_CONSTRUCTING_FROM_DEFAULTS
293 std::vector<std::string> RKMethods;
294 RKMethods.push_back(
"General DIRK");
295 RKMethods.push_back(
"RK Backward Euler");
296 RKMethods.push_back(
"DIRK 1 Stage Theta Method");
297 RKMethods.push_back(
"RK Implicit 1 Stage 1st order Radau IA");
298 RKMethods.push_back(
"RK Implicit Midpoint");
299 RKMethods.push_back(
"SDIRK 2 Stage 2nd order");
300 RKMethods.push_back(
"RK Implicit 2 Stage 2nd order Lobatto IIIB");
301 RKMethods.push_back(
"SDIRK 2 Stage 3rd order");
302 RKMethods.push_back(
"EDIRK 2 Stage 3rd order");
303 RKMethods.push_back(
"EDIRK 2 Stage Theta Method");
304 RKMethods.push_back(
"SDIRK 3 Stage 4th order");
305 RKMethods.push_back(
"SDIRK 5 Stage 4th order");
306 RKMethods.push_back(
"SDIRK 5 Stage 5th order");
307 RKMethods.push_back(
"SDIRK 2(1) Pair");
308 RKMethods.push_back(
"RK Trapezoidal Rule");
309 RKMethods.push_back(
"RK Crank-Nicolson");
311 std::vector<double> RKMethodErrors;
312 RKMethodErrors.push_back(2.52738e-05);
313 RKMethodErrors.push_back(0.0124201);
314 RKMethodErrors.push_back(5.20785e-05);
315 RKMethodErrors.push_back(0.0124201);
316 RKMethodErrors.push_back(5.20785e-05);
317 RKMethodErrors.push_back(2.52738e-05);
318 RKMethodErrors.push_back(5.20785e-05);
319 RKMethodErrors.push_back(1.40223e-06);
320 RKMethodErrors.push_back(2.17004e-07);
321 RKMethodErrors.push_back(5.20785e-05);
322 RKMethodErrors.push_back(6.41463e-08);
323 RKMethodErrors.push_back(3.30631e-10);
324 RKMethodErrors.push_back(1.35728e-11);
325 RKMethodErrors.push_back(0.0001041);
326 RKMethodErrors.push_back(5.20785e-05);
327 RKMethodErrors.push_back(5.20785e-05);
329 for(std::vector<std::string>::size_type m = 0; m != RKMethods.size(); m++) {
331 std::string RKMethod = RKMethods[m];
332 std::replace(RKMethod.begin(), RKMethod.end(),
' ',
'_');
333 std::replace(RKMethod.begin(), RKMethod.end(),
'/',
'.');
335 RCP<Tempus::IntegratorBasic<double> > integrator;
336 std::vector<RCP<Thyra::VectorBase<double>>> solutions;
337 std::vector<RCP<Thyra::VectorBase<double>>> solutionsDot;
338 std::vector<double> StepSize;
339 std::vector<double> xErrorNorm;
340 std::vector<double> xDotErrorNorm;
342 const int nTimeStepSizes = 2;
345 for (
int n=0; n<nTimeStepSizes; n++) {
348 RCP<ParameterList> pList =
349 getParametersFromXmlFile(
"Tempus_DIRK_SinCos.xml");
352 RCP<ParameterList> scm_pl = sublist(pList,
"SinCosModel",
true);
356 RCP<ParameterList> pl = sublist(pList,
"Tempus",
true);
357 pl->sublist(
"Default Stepper").set(
"Stepper Type", RKMethods[m]);
358 if (RKMethods[m] ==
"DIRK 1 Stage Theta Method" ||
359 RKMethods[m] ==
"EDIRK 2 Stage Theta Method") {
360 pl->sublist(
"Default Stepper").set<
double>(
"theta", 0.5);
361 }
else if (RKMethods[m] ==
"SDIRK 2 Stage 2nd order") {
362 pl->sublist(
"Default Stepper").set(
"gamma", 0.2928932188134524);
363 }
else if (RKMethods[m] ==
"SDIRK 2 Stage 3rd order") {
364 pl->sublist(
"Default Stepper")
365 .set<std::string>(
"Gamma Type",
"3rd Order A-stable");
371 pl->sublist(
"Default Integrator")
372 .sublist(
"Time Step Control").set(
"Initial Time Step", dt);
373 integrator = Tempus::integratorBasic<double>(pl, model);
379 RCP<Thyra::VectorBase<double> > x0 =
380 model->getNominalValues().get_x()->clone_v();
381 integrator->initializeSolutionHistory(0.0, x0);
384 bool integratorStatus = integrator->advanceTime();
385 TEST_ASSERT(integratorStatus)
388 time = integrator->getTime();
389 double timeFinal = pl->sublist(
"Default Integrator")
390 .sublist(
"Time Step Control").get<
double>(
"Final Time");
391 double tol = 100.0 * std::numeric_limits<double>::epsilon();
392 TEST_FLOATING_EQUALITY(time, timeFinal, tol);
397 integrator->getSolutionHistory();
398 writeSolution(
"Tempus_"+RKMethod+
"_SinCos.dat", solutionHistory);
401 for (
int i=0; i<solutionHistory->getNumStates(); i++) {
402 double time_i = (*solutionHistory)[i]->getTime();
404 model->getExactSolution(time_i).get_x(),
405 model->getExactSolution(time_i).get_x_dot()));
406 state->setTime((*solutionHistory)[i]->getTime());
407 solnHistExact->addState(state);
409 writeSolution(
"Tempus_"+RKMethod+
"_SinCos-Ref.dat", solnHistExact);
413 StepSize.push_back(dt);
414 auto solution = Thyra::createMember(model->get_x_space());
415 Thyra::copy(*(integrator->getX()),solution.ptr());
416 solutions.push_back(solution);
417 auto solutionDot = Thyra::createMember(model->get_x_space());
418 Thyra::copy(*(integrator->getXdot()),solutionDot.ptr());
419 solutionsDot.push_back(solutionDot);
420 if (n == nTimeStepSizes-1) {
421 StepSize.push_back(0.0);
422 auto solutionExact = Thyra::createMember(model->get_x_space());
423 Thyra::copy(*(model->getExactSolution(time).get_x()),solutionExact.ptr());
424 solutions.push_back(solutionExact);
425 auto solutionDotExact = Thyra::createMember(model->get_x_space());
426 Thyra::copy(*(model->getExactSolution(time).get_x_dot()),
427 solutionDotExact.ptr());
428 solutionsDot.push_back(solutionDotExact);
434 double xDotSlope = 0.0;
435 RCP<Tempus::Stepper<double> > stepper = integrator->getStepper();
436 double order = stepper->getOrder();
439 solutions, xErrorNorm, xSlope,
440 solutionsDot, xDotErrorNorm, xDotSlope);
442 TEST_FLOATING_EQUALITY( xSlope, order, 0.01 );
443 TEST_FLOATING_EQUALITY( xErrorNorm[0], RKMethodErrors[m], 5.0e-4 );
450 #endif // TEST_SINCOS
453 #ifdef TEST_VANDERPOL
458 std::vector<std::string> RKMethods;
459 RKMethods.push_back(
"SDIRK 2 Stage 2nd order");
461 std::string RKMethod = RKMethods[0];
462 std::replace(RKMethod.begin(), RKMethod.end(),
' ',
'_');
463 std::replace(RKMethod.begin(), RKMethod.end(),
'/',
'.');
465 RCP<Tempus::IntegratorBasic<double> > integrator;
466 std::vector<RCP<Thyra::VectorBase<double>>> solutions;
467 std::vector<RCP<Thyra::VectorBase<double>>> solutionsDot;
468 std::vector<double> StepSize;
469 std::vector<double> xErrorNorm;
470 std::vector<double> xDotErrorNorm;
472 const int nTimeStepSizes = 3;
475 for (
int n=0; n<nTimeStepSizes; n++) {
478 RCP<ParameterList> pList =
479 getParametersFromXmlFile(
"Tempus_DIRK_VanDerPol.xml");
482 RCP<ParameterList> vdpm_pl = sublist(pList,
"VanDerPolModel",
true);
486 RCP<ParameterList> pl = sublist(pList,
"Tempus",
true);
487 pl->sublist(
"Default Stepper").set(
"Stepper Type", RKMethods[0]);
488 pl->sublist(
"Default Stepper").set(
"gamma", 0.2928932188134524);
492 if (n == nTimeStepSizes-1) dt /= 10.0;
495 pl->sublist(
"Default Integrator")
496 .sublist(
"Time Step Control").set(
"Initial Time Step", dt);
497 integrator = Tempus::integratorBasic<double>(pl, model);
500 bool integratorStatus = integrator->advanceTime();
501 TEST_ASSERT(integratorStatus)
504 time = integrator->getTime();
505 double timeFinal =pl->sublist(
"Default Integrator")
506 .sublist(
"Time Step Control").get<
double>(
"Final Time");
507 double tol = 100.0 * std::numeric_limits<double>::epsilon();
508 TEST_FLOATING_EQUALITY(time, timeFinal, tol);
511 StepSize.push_back(dt);
512 auto solution = Thyra::createMember(model->get_x_space());
513 Thyra::copy(*(integrator->getX()),solution.ptr());
514 solutions.push_back(solution);
515 auto solutionDot = Thyra::createMember(model->get_x_space());
516 Thyra::copy(*(integrator->getXdot()),solutionDot.ptr());
517 solutionsDot.push_back(solutionDot);
521 if ((n == 0) or (n == nTimeStepSizes-1)) {
522 std::string fname =
"Tempus_"+RKMethod+
"_VanDerPol-Ref.dat";
523 if (n == 0) fname =
"Tempus_"+RKMethod+
"_VanDerPol.dat";
525 integrator->getSolutionHistory();
532 double xDotSlope = 0.0;
533 RCP<Tempus::Stepper<double> > stepper = integrator->getStepper();
534 double order = stepper->getOrder();
537 solutions, xErrorNorm, xSlope,
538 solutionsDot, xDotErrorNorm, xDotSlope);
540 TEST_FLOATING_EQUALITY( xSlope, order, 0.06 );
541 TEST_FLOATING_EQUALITY( xErrorNorm[0], 1.07525e-05, 1.0e-4 );
546 Teuchos::TimeMonitor::summarize();
548 #endif // TEST_VANDERPOL
551 #ifdef TEST_EMBEDDED_DIRK
557 std::vector<std::string> IntegratorList;
558 IntegratorList.push_back(
"Embedded_Integrator_PID");
559 IntegratorList.push_back(
"Embedded_Integrator");
562 const int refIstep = 217;
564 for(
auto integratorChoice : IntegratorList){
566 std::cout <<
"Using Integrator: " << integratorChoice <<
" !!!" << std::endl;
569 RCP<ParameterList> pList =
570 getParametersFromXmlFile(
"Tempus_DIRK_VanDerPol.xml");
574 RCP<ParameterList> vdpm_pl = sublist(pList,
"VanDerPolModel",
true);
578 RCP<ParameterList> pl = sublist(pList,
"Tempus",
true);
579 pl->set(
"Integrator Name", integratorChoice);
582 RCP<Tempus::IntegratorBasic<double> > integrator =
583 Tempus::integratorBasic<double>(pl, model);
585 const std::string RKMethod_ =
586 pl->sublist(integratorChoice).get<std::string>(
"Stepper Name");
589 bool integratorStatus = integrator->advanceTime();
590 TEST_ASSERT(integratorStatus);
593 double time = integrator->getTime();
594 double timeFinal = pl->sublist(integratorChoice)
595 .sublist(
"Time Step Control").get<
double>(
"Final Time");
596 TEST_FLOATING_EQUALITY(time, timeFinal, 1.0e-14);
600 RCP<Thyra::VectorBase<double> > x = integrator->getX();
601 RCP<Thyra::VectorBase<double> > xref = x->clone_v();
602 Thyra::set_ele(0, -1.5484458614405929, xref.ptr());
603 Thyra::set_ele(1, 1.0181127316101317, xref.ptr());
606 RCP<Thyra::VectorBase<double> > xdiff = x->clone_v();
607 Thyra::V_StVpStV(xdiff.ptr(), 1.0, *xref, -1.0, *(x));
608 const double L2norm = Thyra::norm_2(*xdiff);
611 if (integratorChoice ==
"Embedded_Integrator_PID"){
612 const double absTol = pl->sublist(integratorChoice).
613 sublist(
"Time Step Control").get<
double>(
"Maximum Absolute Error");
614 const double relTol = pl->sublist(integratorChoice).
615 sublist(
"Time Step Control").get<
double>(
"Maximum Relative Error");
621 const int iStep = integrator->getSolutionHistory()->
622 getCurrentState()->getIndex();
627 TEST_FLOATING_EQUALITY(std::log10(L2norm),std::log10(absTol), 0.3 );
628 TEST_FLOATING_EQUALITY(std::log10(L2norm),std::log10(relTol), 0.3 );
630 TEST_COMPARE(iStep, <=, refIstep);
634 std::ofstream ftmp(
"Tempus_"+integratorChoice+RKMethod_+
"_VDP_Example.dat");
636 integrator->getSolutionHistory();
637 int nStates = solutionHistory->getNumStates();
639 for (
int i=0; i<nStates; i++) {
640 RCP<const SolutionState<double> > solutionState = (*solutionHistory)[i];
641 double time_i = solutionState->getTime();
642 RCP<const Thyra::VectorBase<double> > x_plot = solutionState->getX();
644 ftmp << time_i <<
" "
645 << Thyra::get_ele(*(x_plot), 0) <<
" "
646 << Thyra::get_ele(*(x_plot), 1) <<
" " << std::endl;
651 Teuchos::TimeMonitor::summarize();
Sine-Cosine model problem from Rythmos. This is a canonical Sine-Cosine differential equation with a...
void writeSolution(const std::string filename, Teuchos::RCP< const Tempus::SolutionHistory< Scalar > > solutionHistory)
void writeOrderError(const std::string filename, Teuchos::RCP< Tempus::Stepper< Scalar > > stepper, std::vector< Scalar > &StepSize, std::vector< Teuchos::RCP< Thyra::VectorBase< Scalar >>> &solutions, std::vector< Scalar > &xErrorNorm, Scalar &xSlope, std::vector< Teuchos::RCP< Thyra::VectorBase< Scalar >>> &solutionsDot, std::vector< Scalar > &xDotErrorNorm, Scalar &xDotSlope, std::vector< Teuchos::RCP< Thyra::VectorBase< Scalar >>> &solutionsDotDot, std::vector< Scalar > &xDotDotErrorNorm, Scalar &xDotDotSlope)
TEUCHOS_UNIT_TEST(BackwardEuler, SinCos_ASA)
TimeStepControl manages the time step size. There several mechanicisms that effect the time step size...
Teuchos::RCP< SolutionHistory< Scalar > > solutionHistory(Teuchos::RCP< Teuchos::ParameterList > pList=Teuchos::null)
Nonmember constructor.
SolutionHistory is basically a container of SolutionStates. SolutionHistory maintains a collection of...
Keep a fix number of states.
van der Pol model problem for nonlinear electrical circuit.
Solution state for integrators and steppers. SolutionState contains the metadata for solutions and th...