13 #include "Tempus_StepperNewmarkExplicitAForm.hpp"
19 #include "../TestModels/HarmonicOscillatorModel.hpp"
21 namespace Tempus_Unit_Test {
26 using Teuchos::rcp_const_cast;
27 using Teuchos::rcp_dynamic_cast;
28 using Teuchos::sublist;
32 class StepperNewmarkExplicitAFormModifierTest
36 StepperNewmarkExplicitAFormModifierTest()
37 : testBEGIN_STEP(false),
38 testBEFORE_EXPLICIT_EVAL(false),
39 testAFTER_EXPLICIT_EVAL(false),
41 testCurrentValue(-0.99),
48 virtual ~StepperNewmarkExplicitAFormModifierTest() {}
55 double>::ACTION_LOCATION actLoc)
59 testBEGIN_STEP =
true;
63 testBEFORE_EXPLICIT_EVAL =
true;
64 testName =
"Newmark Explicit A Form - Modifier";
65 stepper->setStepperName(testName);
69 testAFTER_EXPLICIT_EVAL =
true;
70 testDt = sh->getWorkingState()->getTimeStep();
76 auto x = sh->getWorkingState()->getX();
77 testCurrentValue = get_ele(*(x), 0);
82 "Error - unknown action location.\n");
87 bool testBEFORE_EXPLICIT_EVAL;
88 bool testAFTER_EXPLICIT_EVAL;
90 double testCurrentValue;
97 class StepperNewmarkExplicitAFormModifierXTest
101 StepperNewmarkExplicitAFormModifierXTest()
102 : testX_BEGIN_STEP(false),
103 testX_BEFORE_EXPLICIT_EVAL(false),
104 testX_AFTER_EXPLICIT_EVAL(false),
105 testX_END_STEP(false),
114 virtual ~StepperNewmarkExplicitAFormModifierXTest() {}
121 double>::MODIFIER_TYPE modType)
125 testX_BEGIN_STEP =
true;
127 testX = get_ele(*(x), 0);
130 case StepperNewmarkExplicitAFormModifierXBase<
131 double>::X_BEFORE_EXPLICIT_EVAL: {
132 testX_BEFORE_EXPLICIT_EVAL =
true;
134 testX = get_ele(*(x), 0);
137 case StepperNewmarkExplicitAFormModifierXBase<
138 double>::X_AFTER_EXPLICIT_EVAL: {
139 testX_AFTER_EXPLICIT_EVAL =
true;
140 testX = get_ele(*(x), 0);
144 testX_END_STEP =
true;
146 testX = get_ele(*(x), 0);
151 "Error - unknown action location.\n");
155 bool testX_BEGIN_STEP;
156 bool testX_BEFORE_EXPLICIT_EVAL;
157 bool testX_AFTER_EXPLICIT_EVAL;
169 using Teuchos::sublist;
172 std::vector<RCP<Thyra::VectorBase<double>>> solutions;
173 std::vector<RCP<Thyra::VectorBase<double>>> solutionsDot;
177 "Tempus_NewmarkExplicitAForm_HarmonicOscillator_Damped.xml");
187 stepperPL->
remove(
"Zero Initial Guess");
189 double dt = pl->
sublist(
"Default Integrator")
191 .
get<
double>(
"Initial Time Step");
194 pl->
sublist(
"Default Integrator")
196 .
set(
"Initial Time Step", dt);
197 integrator = Tempus::createIntegratorBasic<double>(pl, model);
201 integrator->getStepper(),
true);
203 auto modifier =
rcp(
new StepperNewmarkExplicitAFormModifierTest());
204 stepper->setAppAction(modifier);
205 stepper->initialize();
206 integrator->initialize();
209 bool integratorStatus = integrator->advanceTime();
214 TEST_COMPARE(modifier->testBEFORE_EXPLICIT_EVAL, ==,
true);
215 TEST_COMPARE(modifier->testAFTER_EXPLICIT_EVAL, ==,
true);
219 auto x = integrator->getX();
220 auto Dt = integrator->getTime();
223 TEST_COMPARE(modifier->testName, ==, stepper->getStepperName());
230 using Teuchos::sublist;
233 std::vector<RCP<Thyra::VectorBase<double>>> solutions;
234 std::vector<RCP<Thyra::VectorBase<double>>> solutionsDot;
238 "Tempus_NewmarkExplicitAForm_HarmonicOscillator_Damped.xml");
248 stepperPL->
remove(
"Zero Initial Guess");
250 double dt = pl->
sublist(
"Default Integrator")
252 .
get<
double>(
"Initial Time Step");
255 pl->
sublist(
"Default Integrator")
257 .
set(
"Initial Time Step", dt);
258 integrator = Tempus::createIntegratorBasic<double>(pl, model);
262 integrator->getStepper(),
true);
264 auto modifierX =
rcp(
new StepperNewmarkExplicitAFormModifierXTest());
265 stepper->setAppAction(modifierX);
266 stepper->initialize();
267 integrator->initialize();
270 bool integratorStatus = integrator->advanceTime();
275 TEST_COMPARE(modifierX->testX_BEFORE_EXPLICIT_EVAL, ==,
true);
276 TEST_COMPARE(modifierX->testX_AFTER_EXPLICIT_EVAL, ==,
true);
280 auto Dt = integrator->getTime();
283 const auto x = integrator->getX();
T & get(const std::string &name, T def_value)
ParameterList & set(std::string const &name, T const &value, std::string const &docString="", RCP< const ParameterEntryValidator > const &validator=null)
#define TEUCHOS_TEST_FOR_EXCEPTION(throw_exception_test, Exception, msg)
#define TEST_COMPARE(v1, comp, v2)
#define TEST_FLOATING_EQUALITY(v1, v2, tol)
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="")