9 #include "Teuchos_UnitTestHarness.hpp"
10 #include "Teuchos_XMLParameterListHelpers.hpp"
11 #include "Teuchos_TimeMonitor.hpp"
13 #include "Tempus_config.hpp"
14 #include "Tempus_IntegratorBasic.hpp"
17 #include "../TestModels/HarmonicOscillatorModel.hpp"
18 #include "../TestUtils/Tempus_ConvergenceTestUtils.hpp"
20 #include "Stratimikos_DefaultLinearSolverBuilder.hpp"
21 #include "Thyra_LinearOpWithSolveFactoryHelpers.hpp"
22 #include "Thyra_DetachedVectorView.hpp"
23 #include "Thyra_DetachedMultiVectorView.hpp"
26 #ifdef Tempus_ENABLE_MPI
27 #include "Epetra_MpiComm.h"
29 #include "Epetra_SerialComm.h"
37 namespace Tempus_Test {
40 using Teuchos::ParameterList;
41 using Teuchos::sublist;
42 using Teuchos::getParametersFromXmlFile;
50 #define TEST_BALL_PARABOLIC
51 #define TEST_SINCOS_EXPLICIT
52 #define TEST_HARMONIC_OSCILLATOR_DAMPED_EXPLICIT
53 #define TEST_HARMONIC_OSCILLATOR_DAMPED_CTOR
54 #define TEST_HARMONIC_OSCILLATOR_DAMPED_SECOND_ORDER
55 #define TEST_HARMONIC_OSCILLATOR_DAMPED_FIRST_ORDER
58 #ifdef TEST_BALL_PARABOLIC
63 double tolerance = 1.0e-14;
65 RCP<ParameterList> pList =
66 getParametersFromXmlFile(
"Tempus_NewmarkExplicitAForm_BallParabolic.xml");
69 RCP<ParameterList> hom_pl = sublist(pList,
"HarmonicOscillatorModel",
true);
70 RCP<HarmonicOscillatorModel<double> > model =
74 RCP<ParameterList> pl = sublist(pList,
"Tempus",
true);
75 RCP<ParameterList> stepperPL = sublist(pl,
"Default Stepper",
true);
76 stepperPL->remove(
"Zero Initial Guess");
78 RCP<Tempus::IntegratorBasic<double> > integrator =
79 Tempus::integratorBasic<double>(pl, model);
82 bool integratorStatus = integrator->advanceTime();
83 TEST_ASSERT(integratorStatus)
86 double time = integrator->getTime();
87 double timeFinal =pl->sublist(
"Default Integrator")
88 .sublist(
"Time Step Control").get<
double>(
"Final Time");
89 TEST_FLOATING_EQUALITY(time, timeFinal, 1.0e-14);
92 RCP<Thyra::VectorBase<double> > x = integrator->getX();
93 RCP<const Thyra::VectorBase<double> > x_exact =
94 model->getExactSolution(time).get_x();
97 std::ofstream ftmp(
"Tempus_NewmarkExplicitAForm_BallParabolic.dat");
100 integrator->getSolutionHistory();
103 RCP<const Thyra::VectorBase<double> > x_exact_plot;
104 for (
int i=0; i<solutionHistory->getNumStates(); i++) {
105 RCP<const SolutionState<double> > solutionState = (*solutionHistory)[i];
106 double time_i = solutionState->getTime();
107 RCP<const Thyra::VectorBase<double> > x_plot = solutionState->getX();
108 x_exact_plot = model->getExactSolution(time_i).get_x();
109 ftmp << time_i <<
" "
110 << get_ele(*(x_plot), 0) <<
" "
111 << get_ele(*(x_exact_plot), 0) << std::endl;
112 if (abs(get_ele(*(x_plot),0) - get_ele(*(x_exact_plot), 0)) > err)
113 err = abs(get_ele(*(x_plot),0) - get_ele(*(x_exact_plot), 0));
116 std::cout <<
"Max error = " << err <<
"\n \n";
120 TEUCHOS_TEST_FOR_EXCEPTION(!passed, std::logic_error,
121 "\n Test failed! Max error = " << err <<
" > tolerance = " << tolerance <<
"\n!");
126 #ifdef TEST_SINCOS_EXPLICIT
130 RCP<Tempus::IntegratorBasic<double> > integrator;
131 std::vector<RCP<Thyra::VectorBase<double>>> solutions;
132 std::vector<RCP<Thyra::VectorBase<double>>> solutionsDot;
133 std::vector<double> StepSize;
134 std::vector<double> xErrorNorm;
135 std::vector<double> xDotErrorNorm;
136 const int nTimeStepSizes = 9;
140 RCP<ParameterList> pList =
141 getParametersFromXmlFile(
"Tempus_NewmarkExplicitAForm_SinCos.xml");
144 RCP<ParameterList> hom_pl = sublist(pList,
"HarmonicOscillatorModel",
true);
145 RCP<HarmonicOscillatorModel<double> > model =
150 RCP<ParameterList> pl = sublist(pList,
"Tempus",
true);
151 RCP<ParameterList> stepperPL = sublist(pl,
"Default Stepper",
true);
152 stepperPL->remove(
"Zero Initial Guess");
156 double dt =pl->sublist(
"Default Integrator")
157 .sublist(
"Time Step Control").get<
double>(
"Initial Time Step");
160 for (
int n=0; n<nTimeStepSizes; n++) {
164 std::cout <<
"\n \n time step #" << n <<
" (out of "
165 << nTimeStepSizes-1 <<
"), dt = " << dt <<
"\n";
166 pl->sublist(
"Default Integrator")
167 .sublist(
"Time Step Control").set(
"Initial Time Step", dt);
168 integrator = Tempus::integratorBasic<double>(pl, model);
171 bool integratorStatus = integrator->advanceTime();
172 TEST_ASSERT(integratorStatus)
175 time = integrator->getTime();
176 double timeFinal =pl->sublist(
"Default Integrator")
177 .sublist(
"Time Step Control").get<
double>(
"Final Time");
178 TEST_FLOATING_EQUALITY(time, timeFinal, 1.0e-14);
183 integrator->getSolutionHistory();
184 writeSolution(
"Tempus_NewmarkExplicitAForm_SinCos.dat", solutionHistory);
186 RCP<Tempus::SolutionHistory<double> > solnHistExact =
188 for (
int i=0; i<solutionHistory->getNumStates(); i++) {
189 double time_i = (*solutionHistory)[i]->getTime();
190 RCP<Tempus::SolutionState<double> > state =
192 model->getExactSolution(time_i).get_x(),
193 model->getExactSolution(time_i).get_x_dot()));
194 state->setTime((*solutionHistory)[i]->getTime());
195 solnHistExact->addState(state);
197 writeSolution(
"Tempus_NewmarkExplicitAForm_SinCos-Ref.dat",solnHistExact);
201 StepSize.push_back(dt);
202 auto solution = Thyra::createMember(model->get_x_space());
203 Thyra::copy(*(integrator->getX()),solution.ptr());
204 solutions.push_back(solution);
205 auto solutionDot = Thyra::createMember(model->get_x_space());
206 Thyra::copy(*(integrator->getXdot()),solutionDot.ptr());
207 solutionsDot.push_back(solutionDot);
208 if (n == nTimeStepSizes-1) {
209 StepSize.push_back(0.0);
210 auto solutionExact = Thyra::createMember(model->get_x_space());
211 Thyra::copy(*(model->getExactSolution(time).get_x()),solutionExact.ptr());
212 solutions.push_back(solutionExact);
213 auto solutionDotExact = Thyra::createMember(model->get_x_space());
214 Thyra::copy(*(model->getExactSolution(time).get_x_dot()),
215 solutionDotExact.ptr());
216 solutionsDot.push_back(solutionDotExact);
222 double xDotSlope = 0.0;
223 RCP<Tempus::Stepper<double> > stepper = integrator->getStepper();
224 double order = stepper->getOrder();
227 solutions, xErrorNorm, xSlope,
228 solutionsDot, xDotErrorNorm, xDotSlope);
230 TEST_FLOATING_EQUALITY( xSlope, order, 0.02 );
231 TEST_FLOATING_EQUALITY( xErrorNorm[0], 0.0157928, 1.0e-4 );
232 TEST_FLOATING_EQUALITY( xDotSlope, order, 0.02 );
233 TEST_FLOATING_EQUALITY( xDotErrorNorm[0], 0.233045, 1.0e-4 );
235 Teuchos::TimeMonitor::summarize();
239 #ifdef TEST_HARMONIC_OSCILLATOR_DAMPED_EXPLICIT
243 RCP<Tempus::IntegratorBasic<double> > integrator;
244 std::vector<RCP<Thyra::VectorBase<double>>> solutions;
245 std::vector<RCP<Thyra::VectorBase<double>>> solutionsDot;
246 std::vector<double> StepSize;
247 std::vector<double> xErrorNorm;
248 std::vector<double> xDotErrorNorm;
249 const int nTimeStepSizes = 9;
253 RCP<ParameterList> pList =
254 getParametersFromXmlFile(
"Tempus_NewmarkExplicitAForm_HarmonicOscillator_Damped.xml");
257 RCP<ParameterList> hom_pl = sublist(pList,
"HarmonicOscillatorModel",
true);
258 RCP<HarmonicOscillatorModel<double> > model =
263 RCP<ParameterList> pl = sublist(pList,
"Tempus",
true);
264 RCP<ParameterList> stepperPL = sublist(pl,
"Default Stepper",
true);
265 stepperPL->remove(
"Zero Initial Guess");
269 double dt =pl->sublist(
"Default Integrator")
270 .sublist(
"Time Step Control").get<
double>(
"Initial Time Step");
273 for (
int n=0; n<nTimeStepSizes; n++) {
277 std::cout <<
"\n \n time step #" << n <<
" (out of "
278 << nTimeStepSizes-1 <<
"), dt = " << dt <<
"\n";
279 pl->sublist(
"Default Integrator")
280 .sublist(
"Time Step Control").set(
"Initial Time Step", dt);
281 integrator = Tempus::integratorBasic<double>(pl, model);
284 bool integratorStatus = integrator->advanceTime();
285 TEST_ASSERT(integratorStatus)
288 time = integrator->getTime();
289 double timeFinal =pl->sublist(
"Default Integrator")
290 .sublist(
"Time Step Control").get<
double>(
"Final Time");
291 TEST_FLOATING_EQUALITY(time, timeFinal, 1.0e-14);
296 integrator->getSolutionHistory();
297 writeSolution(
"Tempus_NewmarkExplicitAForm_HarmonicOscillator_Damped.dat", solutionHistory);
299 RCP<Tempus::SolutionHistory<double> > solnHistExact =
301 for (
int i=0; i<solutionHistory->getNumStates(); i++) {
302 double time_i = (*solutionHistory)[i]->getTime();
303 RCP<Tempus::SolutionState<double> > state =
305 model->getExactSolution(time_i).get_x(),
306 model->getExactSolution(time_i).get_x_dot()));
307 state->setTime((*solutionHistory)[i]->getTime());
308 solnHistExact->addState(state);
310 writeSolution(
"Tempus_NewmarkExplicitAForm_HarmonicOscillator_Damped-Ref.dat", solnHistExact);
314 StepSize.push_back(dt);
315 auto solution = Thyra::createMember(model->get_x_space());
316 Thyra::copy(*(integrator->getX()),solution.ptr());
317 solutions.push_back(solution);
318 auto solutionDot = Thyra::createMember(model->get_x_space());
319 Thyra::copy(*(integrator->getXdot()),solutionDot.ptr());
320 solutionsDot.push_back(solutionDot);
321 if (n == nTimeStepSizes-1) {
322 StepSize.push_back(0.0);
323 auto solutionExact = Thyra::createMember(model->get_x_space());
324 Thyra::copy(*(model->getExactSolution(time).get_x()),solutionExact.ptr());
325 solutions.push_back(solutionExact);
326 auto solutionDotExact = Thyra::createMember(model->get_x_space());
327 Thyra::copy(*(model->getExactSolution(time).get_x_dot()),
328 solutionDotExact.ptr());
329 solutionsDot.push_back(solutionDotExact);
335 double xDotSlope = 0.0;
336 RCP<Tempus::Stepper<double> > stepper = integrator->getStepper();
338 writeOrderError(
"Tempus_NewmarkExplicitAForm_HarmonicOscillator_Damped-Error.dat",
340 solutions, xErrorNorm, xSlope,
341 solutionsDot, xDotErrorNorm, xDotSlope);
343 TEST_FLOATING_EQUALITY( xSlope, 1.060930, 0.01 );
344 TEST_FLOATING_EQUALITY( xErrorNorm[0], 0.508229, 1.0e-4 );
345 TEST_FLOATING_EQUALITY( xDotSlope, 1.019300, 0.01 );
346 TEST_FLOATING_EQUALITY( xDotErrorNorm[0], 0.172900, 1.0e-4 );
348 Teuchos::TimeMonitor::summarize();
353 #ifdef TEST_HARMONIC_OSCILLATOR_DAMPED_CTOR
361 RCP<ParameterList> pList = getParametersFromXmlFile(
362 "Tempus_NewmarkImplicitAForm_HarmonicOscillator_Damped_SecondOrder.xml");
363 RCP<ParameterList> pl = sublist(pList,
"Tempus",
true);
366 RCP<ParameterList> hom_pl = sublist(pList,
"HarmonicOscillatorModel",
true);
367 RCP<HarmonicOscillatorModel<double> > model =
372 RCP<Tempus::StepperNewmarkImplicitAForm<double> > stepper =
373 sf->createStepperNewmarkImplicitAForm(model, Teuchos::null);
376 RCP<Tempus::TimeStepControl<double> > timeStepControl =
378 ParameterList tscPL = pl->sublist(
"Default Integrator")
379 .sublist(
"Time Step Control");
380 timeStepControl->setStepType (tscPL.get<std::string>(
"Integrator Step Type"));
381 timeStepControl->setInitIndex(tscPL.get<
int> (
"Initial Time Index"));
382 timeStepControl->setInitTime (tscPL.get<
double>(
"Initial Time"));
383 timeStepControl->setFinalTime(tscPL.get<
double>(
"Final Time"));
384 timeStepControl->setInitTimeStep(dt);
385 timeStepControl->initialize();
388 using Teuchos::rcp_const_cast;
389 Thyra::ModelEvaluatorBase::InArgs<double> inArgsIC =
390 stepper->getModel()->getNominalValues();
391 RCP<Thyra::VectorBase<double> > icX =
392 rcp_const_cast<Thyra::VectorBase<double> > (inArgsIC.get_x());
393 RCP<Thyra::VectorBase<double> > icXDot =
394 rcp_const_cast<Thyra::VectorBase<double> > (inArgsIC.get_x_dot());
395 RCP<Thyra::VectorBase<double> > icXDotDot =
396 rcp_const_cast<Thyra::VectorBase<double> > (inArgsIC.get_x_dot_dot());
397 RCP<Tempus::SolutionState<double> > icState =
399 icState->setTime (timeStepControl->getInitTime());
400 icState->setIndex (timeStepControl->getInitIndex());
401 icState->setTimeStep(0.0);
402 icState->setOrder (stepper->getOrder());
408 solutionHistory->setName(
"Forward States");
410 solutionHistory->setStorageLimit(2);
411 solutionHistory->addState(icState);
414 RCP<Tempus::IntegratorBasic<double> > integrator =
415 Tempus::integratorBasic<double>();
416 integrator->setStepperWStepper(stepper);
417 integrator->setTimeStepControl(timeStepControl);
418 integrator->setSolutionHistory(solutionHistory);
420 integrator->initialize();
424 bool integratorStatus = integrator->advanceTime();
425 TEST_ASSERT(integratorStatus)
429 double time = integrator->getTime();
430 double timeFinal =pl->sublist(
"Default Integrator")
431 .sublist(
"Time Step Control").get<
double>(
"Final Time");
432 TEST_FLOATING_EQUALITY(time, timeFinal, 1.0e-14);
435 RCP<Thyra::VectorBase<double> > x = integrator->getX();
436 RCP<const Thyra::VectorBase<double> > x_exact =
437 model->getExactSolution(time).get_x();
440 RCP<Thyra::VectorBase<double> > xdiff = x->clone_v();
441 Thyra::V_StVpStV(xdiff.ptr(), 1.0, *x_exact, -1.0, *(x));
444 std::cout <<
" Stepper = " << stepper->description() << std::endl;
445 std::cout <<
" =========================" << std::endl;
446 std::cout <<
" Exact solution : " << get_ele(*(x_exact), 0) << std::endl;
447 std::cout <<
" Computed solution: " << get_ele(*(x ), 0) << std::endl;
448 std::cout <<
" Difference : " << get_ele(*(xdiff ), 0) << std::endl;
449 std::cout <<
" =========================" << std::endl;
450 TEST_FLOATING_EQUALITY(get_ele(*(x), 0), -0.222222, 1.0e-4 );
455 #ifdef TEST_HARMONIC_OSCILLATOR_DAMPED_SECOND_ORDER
459 RCP<Tempus::IntegratorBasic<double> > integrator;
460 std::vector<RCP<Thyra::VectorBase<double>>> solutions;
461 std::vector<RCP<Thyra::VectorBase<double>>> solutionsDot;
462 std::vector<double> StepSize;
463 std::vector<double> xErrorNorm;
464 std::vector<double> xDotErrorNorm;
465 const int nTimeStepSizes = 10;
469 RCP<ParameterList> pList =
470 getParametersFromXmlFile(
"Tempus_NewmarkImplicitAForm_HarmonicOscillator_Damped_SecondOrder.xml");
473 RCP<ParameterList> hom_pl = sublist(pList,
"HarmonicOscillatorModel",
true);
474 RCP<HarmonicOscillatorModel<double> > model =
479 RCP<ParameterList> pl = sublist(pList,
"Tempus",
true);
483 double dt =pl->sublist(
"Default Integrator")
484 .sublist(
"Time Step Control").get<
double>(
"Initial Time Step");
487 for (
int n=0; n<nTimeStepSizes; n++) {
491 std::cout <<
"\n \n time step #" << n <<
" (out of "
492 << nTimeStepSizes-1 <<
"), dt = " << dt <<
"\n";
493 pl->sublist(
"Default Integrator")
494 .sublist(
"Time Step Control").set(
"Initial Time Step", dt);
495 integrator = Tempus::integratorBasic<double>(pl, model);
498 bool integratorStatus = integrator->advanceTime();
499 TEST_ASSERT(integratorStatus)
502 time = integrator->getTime();
503 double timeFinal =pl->sublist(
"Default Integrator")
504 .sublist(
"Time Step Control").get<
double>(
"Final Time");
505 TEST_FLOATING_EQUALITY(time, timeFinal, 1.0e-14);
510 integrator->getSolutionHistory();
511 writeSolution(
"Tempus_NewmarkImplicitAForm_HarmonicOscillator_Damped_SecondOrder.dat", solutionHistory);
513 RCP<Tempus::SolutionHistory<double> > solnHistExact =
515 for (
int i=0; i<solutionHistory->getNumStates(); i++) {
516 double time_i = (*solutionHistory)[i]->getTime();
517 RCP<Tempus::SolutionState<double> > state =
519 model->getExactSolution(time_i).get_x(),
520 model->getExactSolution(time_i).get_x_dot()));
521 state->setTime((*solutionHistory)[i]->getTime());
522 solnHistExact->addState(state);
524 writeSolution(
"Tempus_NewmarkImplicitAForm_HarmonicOscillator_Damped_SecondOrder-Ref.dat", solnHistExact);
528 StepSize.push_back(dt);
529 auto solution = Thyra::createMember(model->get_x_space());
530 Thyra::copy(*(integrator->getX()),solution.ptr());
531 solutions.push_back(solution);
532 auto solutionDot = Thyra::createMember(model->get_x_space());
533 Thyra::copy(*(integrator->getXdot()),solutionDot.ptr());
534 solutionsDot.push_back(solutionDot);
535 if (n == nTimeStepSizes-1) {
536 StepSize.push_back(0.0);
537 auto solutionExact = Thyra::createMember(model->get_x_space());
538 Thyra::copy(*(model->getExactSolution(time).get_x()),solutionExact.ptr());
539 solutions.push_back(solutionExact);
540 auto solutionDotExact = Thyra::createMember(model->get_x_space());
541 Thyra::copy(*(model->getExactSolution(time).get_x_dot()),
542 solutionDotExact.ptr());
543 solutionsDot.push_back(solutionDotExact);
549 double xDotSlope = 0.0;
550 RCP<Tempus::Stepper<double> > stepper = integrator->getStepper();
551 double order = stepper->getOrder();
552 writeOrderError(
"Tempus_NewmarkImplicitAForm_HarmonicOscillator_Damped_SecondOrder_SinCos-Error.dat",
554 solutions, xErrorNorm, xSlope,
555 solutionsDot, xDotErrorNorm, xDotSlope);
557 TEST_FLOATING_EQUALITY( xSlope, order, 0.01 );
558 TEST_FLOATING_EQUALITY( xErrorNorm[0], 0.0484483, 1.0e-4 );
559 TEST_FLOATING_EQUALITY( xDotSlope, order, 0.01 );
560 TEST_FLOATING_EQUALITY( xDotErrorNorm[0], 0.0484483, 1.0e-4 );
562 Teuchos::TimeMonitor::summarize();
566 #ifdef TEST_HARMONIC_OSCILLATOR_DAMPED_FIRST_ORDER
570 RCP<Tempus::IntegratorBasic<double> > integrator;
571 std::vector<RCP<Thyra::VectorBase<double>>> solutions;
572 std::vector<RCP<Thyra::VectorBase<double>>> solutionsDot;
573 std::vector<double> StepSize;
574 std::vector<double> xErrorNorm;
575 std::vector<double> xDotErrorNorm;
576 const int nTimeStepSizes = 10;
580 RCP<ParameterList> pList =
581 getParametersFromXmlFile(
"Tempus_NewmarkImplicitAForm_HarmonicOscillator_Damped_FirstOrder.xml");
584 RCP<ParameterList> hom_pl = sublist(pList,
"HarmonicOscillatorModel",
true);
585 RCP<HarmonicOscillatorModel<double> > model =
590 RCP<ParameterList> pl = sublist(pList,
"Tempus",
true);
594 double dt =pl->sublist(
"Default Integrator")
595 .sublist(
"Time Step Control").get<
double>(
"Initial Time Step");
598 for (
int n=0; n<nTimeStepSizes; n++) {
602 std::cout <<
"\n \n time step #" << n <<
" (out of "
603 << nTimeStepSizes-1 <<
"), dt = " << dt <<
"\n";
604 pl->sublist(
"Default Integrator")
605 .sublist(
"Time Step Control").set(
"Initial Time Step", dt);
606 integrator = Tempus::integratorBasic<double>(pl, model);
609 bool integratorStatus = integrator->advanceTime();
610 TEST_ASSERT(integratorStatus)
613 time = integrator->getTime();
614 double timeFinal =pl->sublist(
"Default Integrator")
615 .sublist(
"Time Step Control").get<
double>(
"Final Time");
616 TEST_FLOATING_EQUALITY(time, timeFinal, 1.0e-14);
621 integrator->getSolutionHistory();
622 writeSolution(
"Tempus_NewmarkImplicitAForm_HarmonicOscillator_Damped_FirstOrder.dat", solutionHistory);
624 RCP<Tempus::SolutionHistory<double> > solnHistExact =
626 for (
int i=0; i<solutionHistory->getNumStates(); i++) {
627 double time_i = (*solutionHistory)[i]->getTime();
628 RCP<Tempus::SolutionState<double> > state =
630 model->getExactSolution(time_i).get_x(),
631 model->getExactSolution(time_i).get_x_dot()));
632 state->setTime((*solutionHistory)[i]->getTime());
633 solnHistExact->addState(state);
635 writeSolution(
"Tempus_NewmarkImplicitAForm_HarmonicOscillator_Damped_FirstOrder-Ref.dat", solnHistExact);
639 StepSize.push_back(dt);
640 auto solution = Thyra::createMember(model->get_x_space());
641 Thyra::copy(*(integrator->getX()),solution.ptr());
642 solutions.push_back(solution);
643 auto solutionDot = Thyra::createMember(model->get_x_space());
644 Thyra::copy(*(integrator->getXdot()),solutionDot.ptr());
645 solutionsDot.push_back(solutionDot);
646 if (n == nTimeStepSizes-1) {
647 StepSize.push_back(0.0);
648 auto solutionExact = Thyra::createMember(model->get_x_space());
649 Thyra::copy(*(model->getExactSolution(time).get_x()),solutionExact.ptr());
650 solutions.push_back(solutionExact);
651 auto solutionDotExact = Thyra::createMember(model->get_x_space());
652 Thyra::copy(*(model->getExactSolution(time).get_x_dot()),
653 solutionDotExact.ptr());
654 solutionsDot.push_back(solutionDotExact);
660 double xDotSlope = 0.0;
661 RCP<Tempus::Stepper<double> > stepper = integrator->getStepper();
662 double order = stepper->getOrder();
663 writeOrderError(
"Tempus_NewmarkImplicitAForm_HarmonicOscillator_Damped_FirstOrder-Error.dat",
665 solutions, xErrorNorm, xSlope,
666 solutionsDot, xDotErrorNorm, xDotSlope);
668 TEST_FLOATING_EQUALITY( xSlope, order, 0.02 );
669 TEST_FLOATING_EQUALITY( xErrorNorm[0], 0.0224726, 1.0e-4 );
670 TEST_FLOATING_EQUALITY( xDotSlope, order, 0.02 );
671 TEST_FLOATING_EQUALITY( xDotErrorNorm[0], 0.0122223, 1.0e-4 );
673 Teuchos::TimeMonitor::summarize();
void writeSolution(const std::string filename, Teuchos::RCP< const Tempus::SolutionHistory< Scalar > > solutionHistory)
Consider the ODE: where is a constant, is a constant damping parameter, is a constant forcing par...
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.
Solution state for integrators and steppers. SolutionState contains the metadata for solutions and th...