14 #include "Tempus_StepperNewmarkExplicitAForm.hpp"
20 #include "../TestModels/HarmonicOscillatorModel.hpp"
22 namespace Tempus_Unit_Test {
27 using Teuchos::rcp_const_cast;
28 using Teuchos::rcp_dynamic_cast;
29 using Teuchos::sublist;
33 class StepperNewmarkExplicitAFormModifierTest
37 StepperNewmarkExplicitAFormModifierTest()
38 : testBEGIN_STEP(false),
39 testBEFORE_EXPLICIT_EVAL(false),
40 testAFTER_EXPLICIT_EVAL(false),
42 testCurrentValue(-0.99),
49 virtual ~StepperNewmarkExplicitAFormModifierTest() {}
56 double>::ACTION_LOCATION actLoc)
60 testBEGIN_STEP =
true;
64 testBEFORE_EXPLICIT_EVAL =
true;
65 testName =
"Newmark Explicit A Form - Modifier";
66 stepper->setStepperName(testName);
70 testAFTER_EXPLICIT_EVAL =
true;
71 testDt = sh->getWorkingState()->getTimeStep();
77 auto x = sh->getWorkingState()->getX();
78 testCurrentValue = get_ele(*(x), 0);
83 "Error - unknown action location.\n");
88 bool testBEFORE_EXPLICIT_EVAL;
89 bool testAFTER_EXPLICIT_EVAL;
91 double testCurrentValue;
98 class StepperNewmarkExplicitAFormModifierXTest
102 StepperNewmarkExplicitAFormModifierXTest()
103 : testX_BEGIN_STEP(false),
104 testX_BEFORE_EXPLICIT_EVAL(false),
105 testX_AFTER_EXPLICIT_EVAL(false),
106 testX_END_STEP(false),
115 virtual ~StepperNewmarkExplicitAFormModifierXTest() {}
122 double>::MODIFIER_TYPE modType)
126 testX_BEGIN_STEP =
true;
128 testX = get_ele(*(x), 0);
131 case StepperNewmarkExplicitAFormModifierXBase<
132 double>::X_BEFORE_EXPLICIT_EVAL: {
133 testX_BEFORE_EXPLICIT_EVAL =
true;
135 testX = get_ele(*(x), 0);
138 case StepperNewmarkExplicitAFormModifierXBase<
139 double>::X_AFTER_EXPLICIT_EVAL: {
140 testX_AFTER_EXPLICIT_EVAL =
true;
141 testX = get_ele(*(x), 0);
145 testX_END_STEP =
true;
147 testX = get_ele(*(x), 0);
152 "Error - unknown action location.\n");
156 bool testX_BEGIN_STEP;
157 bool testX_BEFORE_EXPLICIT_EVAL;
158 bool testX_AFTER_EXPLICIT_EVAL;
170 using Teuchos::sublist;
173 std::vector<RCP<Thyra::VectorBase<double>>> solutions;
174 std::vector<RCP<Thyra::VectorBase<double>>> solutionsDot;
178 "Tempus_NewmarkExplicitAForm_HarmonicOscillator_Damped.xml");
188 stepperPL->
remove(
"Zero Initial Guess");
190 double dt = pl->
sublist(
"Default Integrator")
192 .
get<
double>(
"Initial Time Step");
195 pl->
sublist(
"Default Integrator")
197 .
set(
"Initial Time Step", dt);
198 integrator = Tempus::createIntegratorBasic<double>(pl, model);
202 integrator->getStepper(),
true);
204 auto modifier =
rcp(
new StepperNewmarkExplicitAFormModifierTest());
205 stepper->setAppAction(modifier);
206 stepper->initialize();
207 integrator->initialize();
210 bool integratorStatus = integrator->advanceTime();
215 TEST_COMPARE(modifier->testBEFORE_EXPLICIT_EVAL, ==,
true);
216 TEST_COMPARE(modifier->testAFTER_EXPLICIT_EVAL, ==,
true);
220 auto x = integrator->getX();
221 auto Dt = integrator->getTime();
224 TEST_COMPARE(modifier->testName, ==, stepper->getStepperName());
231 using Teuchos::sublist;
234 std::vector<RCP<Thyra::VectorBase<double>>> solutions;
235 std::vector<RCP<Thyra::VectorBase<double>>> solutionsDot;
239 "Tempus_NewmarkExplicitAForm_HarmonicOscillator_Damped.xml");
249 stepperPL->
remove(
"Zero Initial Guess");
251 double dt = pl->
sublist(
"Default Integrator")
253 .
get<
double>(
"Initial Time Step");
256 pl->
sublist(
"Default Integrator")
258 .
set(
"Initial Time Step", dt);
259 integrator = Tempus::createIntegratorBasic<double>(pl, model);
263 integrator->getStepper(),
true);
265 auto modifierX =
rcp(
new StepperNewmarkExplicitAFormModifierXTest());
266 stepper->setAppAction(modifierX);
267 stepper->initialize();
268 integrator->initialize();
271 bool integratorStatus = integrator->advanceTime();
276 TEST_COMPARE(modifierX->testX_BEFORE_EXPLICIT_EVAL, ==,
true);
277 TEST_COMPARE(modifierX->testX_AFTER_EXPLICIT_EVAL, ==,
true);
281 auto Dt = integrator->getTime();
284 const auto x = integrator->getX();
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)
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_DEPRECATED RCP< T > rcp(T *p, Dealloc_T dealloc, bool owns_mem)
TEUCHOS_UNIT_TEST(BackwardEuler, Default_Construction)
SolutionHistory is basically a container of SolutionStates. SolutionHistory maintains a collection of...
ParameterList & sublist(const std::string &name, bool mustAlreadyExist=false, const std::string &docString="")