14 #include "Tempus_config.hpp"
15 #include "Tempus_IntegratorBasic.hpp"
17 #include "Tempus_StepperFactory.hpp"
18 #include "Tempus_StepperNewmarkImplicitAForm.hpp"
19 #include "Tempus_StepperNewmarkImplicitDForm.hpp"
21 #include "../TestModels/HarmonicOscillatorModel.hpp"
22 #include "../TestUtils/Tempus_ConvergenceTestUtils.hpp"
29 namespace Tempus_Test {
31 using Teuchos::getParametersFromXmlFile;
34 using Teuchos::rcp_const_cast;
35 using Teuchos::rcp_dynamic_cast;
36 using Teuchos::sublist;
46 double tolerance = 1.0e-14;
47 std::vector<std::string> options;
48 options.push_back(
"useFSAL=true");
49 options.push_back(
"useFSAL=false");
50 options.push_back(
"ICConsistency and Check");
52 for (
const auto& option : options) {
55 "Tempus_Test_NewmarkExplicitAForm_BallParabolic.xml");
65 stepperPL->
remove(
"Zero Initial Guess");
66 if (option ==
"useFSAL=true")
67 stepperPL->
set(
"Use FSAL",
true);
68 else if (option ==
"useFSAL=false")
69 stepperPL->
set(
"Use FSAL",
false);
70 else if (option ==
"ICConsistency and Check") {
71 stepperPL->
set(
"Initial Condition Consistency",
"Consistent");
72 stepperPL->
set(
"Initial Condition Consistency Check",
true);
76 Tempus::createIntegratorBasic<double>(pl, model);
79 bool integratorStatus = integrator->advanceTime();
83 double time = integrator->getTime();
84 double timeFinal = pl->sublist(
"Default Integrator")
85 .sublist(
"Time Step Control")
86 .
get<
double>(
"Final Time");
92 model->getExactSolution(time).get_x();
95 std::ofstream ftmp(
"Tempus_Test_NewmarkExplicitAForm_BallParabolic.dat");
98 integrator->getSolutionHistory();
102 for (
int i = 0; i < solutionHistory->getNumStates(); i++) {
104 double time_i = solutionState->getTime();
106 x_exact_plot = model->getExactSolution(time_i).get_x();
107 ftmp << time_i <<
" " << get_ele(*(x_plot), 0) <<
" "
108 << get_ele(*(x_exact_plot), 0) << std::endl;
109 if (abs(get_ele(*(x_plot), 0) - get_ele(*(x_exact_plot), 0)) > err)
110 err = abs(get_ele(*(x_plot), 0) - get_ele(*(x_exact_plot), 0));
113 out <<
"Max error = " << err <<
"\n \n";
114 if (err > tolerance) passed =
false;
117 !passed, std::logic_error,
118 "\n Test failed! Max error = " << err <<
" > tolerance = " << tolerance
123 out <<
" Stepper = " << stepper->description() <<
"\n with "
124 << option << std::endl;
125 out <<
" =========================" << std::endl;
126 out <<
" Exact solution : " << get_ele(*(x_exact), 0) << std::endl;
127 out <<
" Computed solution: " << get_ele(*(x), 0) << std::endl;
128 out <<
" =========================" << std::endl;
#define TEUCHOS_TEST_FOR_EXCEPTION(throw_exception_test, Exception, msg)
#define TEST_FLOATING_EQUALITY(v1, v2, tol)
ParameterList & set(std::string const &name, T &&value, std::string const &docString="", RCP< const ParameterEntryValidator > const &validator=null)
Consider the ODE: where is a constant, is a constant damping parameter, is a constant forcing par...
bool remove(std::string const &name, bool throwIfNotExists=true)
TEUCHOS_UNIT_TEST(BackwardEuler, SinCos_ASA)
TEUCHOS_DEPRECATED RCP< T > rcp(T *p, Dealloc_T dealloc, bool owns_mem)
SolutionHistory is basically a container of SolutionStates. SolutionHistory maintains a collection of...
Solution state for integrators and steppers.