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"
15 #include "Tempus_StepperNewmarkImplicitAForm.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 =
371 RCP<Tempus::StepperNewmarkImplicitAForm<double> > stepper =
375 RCP<Tempus::TimeStepControl<double> > timeStepControl =
377 ParameterList tscPL = pl->sublist(
"Default Integrator")
378 .sublist(
"Time Step Control");
379 timeStepControl->setStepType (tscPL.get<std::string>(
"Integrator Step Type"));
380 timeStepControl->setInitIndex(tscPL.get<
int> (
"Initial Time Index"));
381 timeStepControl->setInitTime (tscPL.get<
double>(
"Initial Time"));
382 timeStepControl->setFinalTime(tscPL.get<
double>(
"Final Time"));
383 timeStepControl->setInitTimeStep(dt);
384 timeStepControl->initialize();
387 using Teuchos::rcp_const_cast;
388 Thyra::ModelEvaluatorBase::InArgs<double> inArgsIC =
389 stepper->getModel()->getNominalValues();
390 RCP<Thyra::VectorBase<double> > icX =
391 rcp_const_cast<Thyra::VectorBase<double> > (inArgsIC.get_x());
392 RCP<Thyra::VectorBase<double> > icXDot =
393 rcp_const_cast<Thyra::VectorBase<double> > (inArgsIC.get_x_dot());
394 RCP<Thyra::VectorBase<double> > icXDotDot =
395 rcp_const_cast<Thyra::VectorBase<double> > (inArgsIC.get_x_dot_dot());
396 RCP<Tempus::SolutionState<double> > icState =
398 icState->setTime (timeStepControl->getInitTime());
399 icState->setIndex (timeStepControl->getInitIndex());
400 icState->setTimeStep(0.0);
401 icState->setOrder (stepper->getOrder());
407 solutionHistory->setName(
"Forward States");
409 solutionHistory->setStorageLimit(2);
410 solutionHistory->addState(icState);
413 RCP<Tempus::IntegratorBasic<double> > integrator =
414 Tempus::integratorBasic<double>();
415 integrator->setStepperWStepper(stepper);
416 integrator->setTimeStepControl(timeStepControl);
417 integrator->setSolutionHistory(solutionHistory);
419 integrator->initialize();
423 bool integratorStatus = integrator->advanceTime();
424 TEST_ASSERT(integratorStatus)
428 double time = integrator->getTime();
429 double timeFinal =pl->sublist(
"Default Integrator")
430 .sublist(
"Time Step Control").get<
double>(
"Final Time");
431 TEST_FLOATING_EQUALITY(time, timeFinal, 1.0e-14);
434 RCP<Thyra::VectorBase<double> > x = integrator->getX();
435 RCP<const Thyra::VectorBase<double> > x_exact =
436 model->getExactSolution(time).get_x();
439 RCP<Thyra::VectorBase<double> > xdiff = x->clone_v();
440 Thyra::V_StVpStV(xdiff.ptr(), 1.0, *x_exact, -1.0, *(x));
443 std::cout <<
" Stepper = " << stepper->description() << std::endl;
444 std::cout <<
" =========================" << std::endl;
445 std::cout <<
" Exact solution : " << get_ele(*(x_exact), 0) << std::endl;
446 std::cout <<
" Computed solution: " << get_ele(*(x ), 0) << std::endl;
447 std::cout <<
" Difference : " << get_ele(*(xdiff ), 0) << std::endl;
448 std::cout <<
" =========================" << std::endl;
449 TEST_FLOATING_EQUALITY(get_ele(*(x), 0), -0.222222, 1.0e-4 );
454 #ifdef TEST_HARMONIC_OSCILLATOR_DAMPED_SECOND_ORDER
458 RCP<Tempus::IntegratorBasic<double> > integrator;
459 std::vector<RCP<Thyra::VectorBase<double>>> solutions;
460 std::vector<RCP<Thyra::VectorBase<double>>> solutionsDot;
461 std::vector<double> StepSize;
462 std::vector<double> xErrorNorm;
463 std::vector<double> xDotErrorNorm;
464 const int nTimeStepSizes = 10;
468 RCP<ParameterList> pList =
469 getParametersFromXmlFile(
"Tempus_NewmarkImplicitAForm_HarmonicOscillator_Damped_SecondOrder.xml");
472 RCP<ParameterList> hom_pl = sublist(pList,
"HarmonicOscillatorModel",
true);
473 RCP<HarmonicOscillatorModel<double> > model =
478 RCP<ParameterList> pl = sublist(pList,
"Tempus",
true);
482 double dt =pl->sublist(
"Default Integrator")
483 .sublist(
"Time Step Control").get<
double>(
"Initial Time Step");
486 for (
int n=0; n<nTimeStepSizes; n++) {
490 std::cout <<
"\n \n time step #" << n <<
" (out of "
491 << nTimeStepSizes-1 <<
"), dt = " << dt <<
"\n";
492 pl->sublist(
"Default Integrator")
493 .sublist(
"Time Step Control").set(
"Initial Time Step", dt);
494 integrator = Tempus::integratorBasic<double>(pl, model);
497 bool integratorStatus = integrator->advanceTime();
498 TEST_ASSERT(integratorStatus)
501 time = integrator->getTime();
502 double timeFinal =pl->sublist(
"Default Integrator")
503 .sublist(
"Time Step Control").get<
double>(
"Final Time");
504 TEST_FLOATING_EQUALITY(time, timeFinal, 1.0e-14);
509 integrator->getSolutionHistory();
510 writeSolution(
"Tempus_NewmarkImplicitAForm_HarmonicOscillator_Damped_SecondOrder.dat", solutionHistory);
512 RCP<Tempus::SolutionHistory<double> > solnHistExact =
514 for (
int i=0; i<solutionHistory->getNumStates(); i++) {
515 double time_i = (*solutionHistory)[i]->getTime();
516 RCP<Tempus::SolutionState<double> > state =
518 model->getExactSolution(time_i).get_x(),
519 model->getExactSolution(time_i).get_x_dot()));
520 state->setTime((*solutionHistory)[i]->getTime());
521 solnHistExact->addState(state);
523 writeSolution(
"Tempus_NewmarkImplicitAForm_HarmonicOscillator_Damped_SecondOrder-Ref.dat", solnHistExact);
527 StepSize.push_back(dt);
528 auto solution = Thyra::createMember(model->get_x_space());
529 Thyra::copy(*(integrator->getX()),solution.ptr());
530 solutions.push_back(solution);
531 auto solutionDot = Thyra::createMember(model->get_x_space());
532 Thyra::copy(*(integrator->getXdot()),solutionDot.ptr());
533 solutionsDot.push_back(solutionDot);
534 if (n == nTimeStepSizes-1) {
535 StepSize.push_back(0.0);
536 auto solutionExact = Thyra::createMember(model->get_x_space());
537 Thyra::copy(*(model->getExactSolution(time).get_x()),solutionExact.ptr());
538 solutions.push_back(solutionExact);
539 auto solutionDotExact = Thyra::createMember(model->get_x_space());
540 Thyra::copy(*(model->getExactSolution(time).get_x_dot()),
541 solutionDotExact.ptr());
542 solutionsDot.push_back(solutionDotExact);
548 double xDotSlope = 0.0;
549 RCP<Tempus::Stepper<double> > stepper = integrator->getStepper();
550 double order = stepper->getOrder();
551 writeOrderError(
"Tempus_NewmarkImplicitAForm_HarmonicOscillator_Damped_SecondOrder_SinCos-Error.dat",
553 solutions, xErrorNorm, xSlope,
554 solutionsDot, xDotErrorNorm, xDotSlope);
556 TEST_FLOATING_EQUALITY( xSlope, order, 0.01 );
557 TEST_FLOATING_EQUALITY( xErrorNorm[0], 0.0484483, 1.0e-4 );
558 TEST_FLOATING_EQUALITY( xDotSlope, order, 0.01 );
559 TEST_FLOATING_EQUALITY( xDotErrorNorm[0], 0.0484483, 1.0e-4 );
561 Teuchos::TimeMonitor::summarize();
565 #ifdef TEST_HARMONIC_OSCILLATOR_DAMPED_FIRST_ORDER
569 RCP<Tempus::IntegratorBasic<double> > integrator;
570 std::vector<RCP<Thyra::VectorBase<double>>> solutions;
571 std::vector<RCP<Thyra::VectorBase<double>>> solutionsDot;
572 std::vector<double> StepSize;
573 std::vector<double> xErrorNorm;
574 std::vector<double> xDotErrorNorm;
575 const int nTimeStepSizes = 10;
579 RCP<ParameterList> pList =
580 getParametersFromXmlFile(
"Tempus_NewmarkImplicitAForm_HarmonicOscillator_Damped_FirstOrder.xml");
583 RCP<ParameterList> hom_pl = sublist(pList,
"HarmonicOscillatorModel",
true);
584 RCP<HarmonicOscillatorModel<double> > model =
589 RCP<ParameterList> pl = sublist(pList,
"Tempus",
true);
593 double dt =pl->sublist(
"Default Integrator")
594 .sublist(
"Time Step Control").get<
double>(
"Initial Time Step");
597 for (
int n=0; n<nTimeStepSizes; n++) {
601 std::cout <<
"\n \n time step #" << n <<
" (out of "
602 << nTimeStepSizes-1 <<
"), dt = " << dt <<
"\n";
603 pl->sublist(
"Default Integrator")
604 .sublist(
"Time Step Control").set(
"Initial Time Step", dt);
605 integrator = Tempus::integratorBasic<double>(pl, model);
608 bool integratorStatus = integrator->advanceTime();
609 TEST_ASSERT(integratorStatus)
612 time = integrator->getTime();
613 double timeFinal =pl->sublist(
"Default Integrator")
614 .sublist(
"Time Step Control").get<
double>(
"Final Time");
615 TEST_FLOATING_EQUALITY(time, timeFinal, 1.0e-14);
620 integrator->getSolutionHistory();
621 writeSolution(
"Tempus_NewmarkImplicitAForm_HarmonicOscillator_Damped_FirstOrder.dat", solutionHistory);
623 RCP<Tempus::SolutionHistory<double> > solnHistExact =
625 for (
int i=0; i<solutionHistory->getNumStates(); i++) {
626 double time_i = (*solutionHistory)[i]->getTime();
627 RCP<Tempus::SolutionState<double> > state =
629 model->getExactSolution(time_i).get_x(),
630 model->getExactSolution(time_i).get_x_dot()));
631 state->setTime((*solutionHistory)[i]->getTime());
632 solnHistExact->addState(state);
634 writeSolution(
"Tempus_NewmarkImplicitAForm_HarmonicOscillator_Damped_FirstOrder-Ref.dat", solnHistExact);
638 StepSize.push_back(dt);
639 auto solution = Thyra::createMember(model->get_x_space());
640 Thyra::copy(*(integrator->getX()),solution.ptr());
641 solutions.push_back(solution);
642 auto solutionDot = Thyra::createMember(model->get_x_space());
643 Thyra::copy(*(integrator->getXdot()),solutionDot.ptr());
644 solutionsDot.push_back(solutionDot);
645 if (n == nTimeStepSizes-1) {
646 StepSize.push_back(0.0);
647 auto solutionExact = Thyra::createMember(model->get_x_space());
648 Thyra::copy(*(model->getExactSolution(time).get_x()),solutionExact.ptr());
649 solutions.push_back(solutionExact);
650 auto solutionDotExact = Thyra::createMember(model->get_x_space());
651 Thyra::copy(*(model->getExactSolution(time).get_x_dot()),
652 solutionDotExact.ptr());
653 solutionsDot.push_back(solutionDotExact);
659 double xDotSlope = 0.0;
660 RCP<Tempus::Stepper<double> > stepper = integrator->getStepper();
661 double order = stepper->getOrder();
662 writeOrderError(
"Tempus_NewmarkImplicitAForm_HarmonicOscillator_Damped_FirstOrder-Error.dat",
664 solutions, xErrorNorm, xSlope,
665 solutionsDot, xDotErrorNorm, xDotSlope);
667 TEST_FLOATING_EQUALITY( xSlope, order, 0.02 );
668 TEST_FLOATING_EQUALITY( xErrorNorm[0], 0.0224726, 1.0e-4 );
669 TEST_FLOATING_EQUALITY( xDotSlope, order, 0.02 );
670 TEST_FLOATING_EQUALITY( xDotErrorNorm[0], 0.0122223, 1.0e-4 );
672 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...