13 #include "Tempus_StepperNewmarkExplicitAForm.hpp"
19 #include "../TestModels/HarmonicOscillatorModel.hpp"
22 namespace Tempus_Unit_Test {
26 using Teuchos::rcp_const_cast;
27 using Teuchos::rcp_dynamic_cast;
29 using Teuchos::sublist;
34 class StepperNewmarkExplicitAFormModifierTest
40 StepperNewmarkExplicitAFormModifierTest()
41 : testBEGIN_STEP(false), testBEFORE_EXPLICIT_EVAL(false),
42 testAFTER_EXPLICIT_EVAL(false), testEND_STEP(false),
43 testCurrentValue(-0.99),
44 testDt(-1.5), testName(
"")
48 virtual ~StepperNewmarkExplicitAFormModifierTest(){}
59 testBEGIN_STEP =
true;
64 testBEFORE_EXPLICIT_EVAL =
true;
65 testName =
"Newmark Explicit A Form - Modifier";
66 stepper->setStepperName(testName);
71 testAFTER_EXPLICIT_EVAL =
true;
72 testDt = sh->getWorkingState()->getTimeStep();
79 auto x = sh->getWorkingState()->getX();
80 testCurrentValue = get_ele(*(x), 0);
85 "Error - unknown action location.\n");
90 bool testBEFORE_EXPLICIT_EVAL;
91 bool testAFTER_EXPLICIT_EVAL;
93 double testCurrentValue;
101 class StepperNewmarkExplicitAFormModifierXTest
107 StepperNewmarkExplicitAFormModifierXTest()
108 : testX_BEGIN_STEP(false), testX_BEFORE_EXPLICIT_EVAL(false),
109 testX_AFTER_EXPLICIT_EVAL(false), testX_END_STEP(false),
110 testX(-0.99), testXDot(-0.99),
111 testDt(-1.5), testTime(-1.5)
115 virtual ~StepperNewmarkExplicitAFormModifierXTest(){}
120 const double time,
const double dt,
126 testX_BEGIN_STEP =
true;
128 testX = get_ele(*(x), 0);
133 testX_BEFORE_EXPLICIT_EVAL =
true;
135 testX = get_ele(*(x), 0);
140 testX_AFTER_EXPLICIT_EVAL =
true;
141 testX = get_ele(*(x), 0);
146 testX_END_STEP =
true;
148 testX = get_ele(*(x), 0);
153 "Error - unknown action location.\n");
157 bool testX_BEGIN_STEP;
158 bool testX_BEFORE_EXPLICIT_EVAL;
159 bool testX_AFTER_EXPLICIT_EVAL;
171 using Teuchos::sublist;
175 std::vector<RCP<Thyra::VectorBase<double>>> solutions;
176 std::vector<RCP<Thyra::VectorBase<double>>> solutionsDot;
180 Teuchos::getParametersFromXmlFile(
"Tempus_NewmarkExplicitAForm_HarmonicOscillator_Damped.xml");
190 stepperPL->
remove(
"Zero Initial Guess");
192 double dt =pl->
sublist(
"Default Integrator")
193 .
sublist(
"Time Step Control").
get<
double>(
"Initial Time Step");
196 pl->
sublist(
"Default Integrator")
197 .
sublist(
"Time Step Control").
set(
"Initial Time Step", dt);
198 integrator = Tempus::createIntegratorBasic<double>(pl, model);
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;
234 std::vector<RCP<Thyra::VectorBase<double>>> solutions;
235 std::vector<RCP<Thyra::VectorBase<double>>> solutionsDot;
239 Teuchos::getParametersFromXmlFile(
"Tempus_NewmarkExplicitAForm_HarmonicOscillator_Damped.xml");
249 stepperPL->
remove(
"Zero Initial Guess");
251 double dt =pl->
sublist(
"Default Integrator")
252 .
sublist(
"Time Step Control").
get<
double>(
"Initial Time Step");
255 pl->
sublist(
"Default Integrator")
256 .
sublist(
"Time Step Control").
set(
"Initial Time Step", dt);
257 integrator = Tempus::createIntegratorBasic<double>(pl, model);
262 auto modifierX =
rcp(
new StepperNewmarkExplicitAFormModifierXTest());
263 stepper->setAppAction(modifierX);
264 stepper->initialize();
265 integrator->initialize();
268 bool integratorStatus = integrator->advanceTime();
273 TEST_COMPARE(modifierX->testX_BEFORE_EXPLICIT_EVAL, ==,
true);
274 TEST_COMPARE(modifierX->testX_AFTER_EXPLICIT_EVAL, ==,
true);
279 auto Dt = integrator->getTime();
282 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="")