11 #include "Tempus_StepperHHTAlpha.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;
38 stepper->setModel(model);
39 stepper->initialize();
46 bool useFSAL = stepper->getUseFSAL();
47 std::string ICConsistency = stepper->getICConsistency();
48 bool ICConsistencyCheck = stepper->getICConsistencyCheck();
49 bool zeroInitialGuess = stepper->getZeroInitialGuess();
50 std::string schemeName =
"Newmark Beta User Defined";
61 stepper->setSolver(solver);
62 stepper->initialize();
64 stepper->setUseFSAL(useFSAL);
65 stepper->initialize();
67 stepper->setICConsistency(ICConsistency);
68 stepper->initialize();
70 stepper->setICConsistencyCheck(ICConsistencyCheck);
71 stepper->initialize();
73 stepper->setZeroInitialGuess(zeroInitialGuess);
74 stepper->initialize();
77 stepper->setAppAction(modifier);
78 stepper->initialize();
80 stepper->setAppAction(modifierX);
81 stepper->initialize();
83 stepper->setAppAction(observer);
84 stepper->initialize();
87 stepper->setSchemeName(schemeName);
88 stepper->initialize();
90 stepper->setBeta(beta);
91 stepper->initialize();
93 stepper->setGamma(gamma);
94 stepper->initialize();
96 stepper->setAlphaF(alpha_f);
97 stepper->initialize();
99 stepper->setAlphaM(alpha_m);
100 stepper->initialize();
105 model, solver, useFSAL, ICConsistency, ICConsistencyCheck,
106 zeroInitialGuess, schemeName, beta, gamma, alpha_f, alpha_m, modifier));
123 class StepperHHTAlphaModifierTest
127 StepperHHTAlphaModifierTest()
128 : testBEGIN_STEP(false),
129 testBEFORE_SOLVE(false),
130 testAFTER_SOLVE(false),
132 testCurrentValue(-0.99),
133 testWorkingValue(-0.99),
140 virtual ~StepperHHTAlphaModifierTest() {}
151 testBEGIN_STEP =
true;
152 auto x = sh->getCurrentState()->getX();
153 testCurrentValue = get_ele(*(x), 0);
157 testBEFORE_SOLVE =
true;
158 testDt = sh->getWorkingState()->getTimeStep() / 10.0;
159 sh->getWorkingState()->setTimeStep(testDt);
163 testAFTER_SOLVE =
true;
164 testName =
"HHT Alpha - Modifier";
165 stepper->setStepperName(testName);
170 auto x = sh->getWorkingState()->getX();
171 testWorkingValue = get_ele(*(x), 0);
176 "Error - unknown action location.\n");
180 bool testBEFORE_SOLVE;
181 bool testAFTER_SOLVE;
183 double testCurrentValue;
184 double testWorkingValue;
186 std::string testName;
196 stepper->setModel(model);
197 auto modifier =
rcp(
new StepperHHTAlphaModifierTest());
198 stepper->setAppAction(modifier);
199 stepper->initialize();
205 stepper->setInitialConditions(solutionHistory);
206 solutionHistory->initWorkingState();
208 solutionHistory->getWorkingState()->setTimeStep(dt);
209 stepper->takeStep(solutionHistory);
218 auto x = solutionHistory->getCurrentState()->getX();
220 x = solutionHistory->getWorkingState()->getX();
222 auto Dt = solutionHistory->getWorkingState()->getTimeStep();
224 TEST_COMPARE(modifier->testName, ==,
"HHT Alpha - Modifier");
229 class StepperHHTAlphaObserverTest
233 StepperHHTAlphaObserverTest()
234 : testBEGIN_STEP(false),
235 testBEFORE_SOLVE(false),
236 testAFTER_SOLVE(false),
238 testCurrentValue(-0.99),
239 testWorkingValue(-0.99),
246 virtual ~StepperHHTAlphaObserverTest() {}
249 virtual void observe(
257 testBEGIN_STEP =
true;
258 auto x = sh->getCurrentState()->getX();
259 testCurrentValue = get_ele(*(x), 0);
263 testBEFORE_SOLVE =
true;
264 testDt = sh->getWorkingState()->getTimeStep();
268 testAFTER_SOLVE =
true;
269 testName = stepper->getStepperType();
274 auto x = sh->getWorkingState()->getX();
275 testWorkingValue = get_ele(*(x), 0);
280 "Error - unknown action location.\n");
285 bool testBEFORE_SOLVE;
286 bool testAFTER_SOLVE;
288 double testCurrentValue;
289 double testWorkingValue;
291 std::string testName;
301 stepper->setModel(model);
302 auto observer =
rcp(
new StepperHHTAlphaObserverTest());
303 stepper->setAppAction(observer);
304 stepper->initialize();
310 stepper->setInitialConditions(solutionHistory);
311 solutionHistory->initWorkingState();
313 solutionHistory->getWorkingState()->setTimeStep(dt);
314 stepper->takeStep(solutionHistory);
322 auto x = solutionHistory->getCurrentState()->getX();
324 x = solutionHistory->getWorkingState()->getX();
333 class StepperHHTAlphaModifierXTest
337 StepperHHTAlphaModifierXTest()
338 : testX_BEGIN_STEP(false),
339 testX_BEFORE_SOLVE(false),
340 testX_AFTER_SOLVE(false),
341 testX_END_STEP(false),
350 virtual ~StepperHHTAlphaModifierXTest() {}
361 testX_BEGIN_STEP =
true;
362 testXbegin = get_ele(*(x), 0);
366 testX_BEFORE_SOLVE =
true;
371 testX_AFTER_SOLVE =
true;
376 testX_END_STEP =
true;
377 testXend = get_ele(*(x), 0);
382 "Error - unknown action location.\n");
386 bool testX_BEGIN_STEP;
387 bool testX_BEFORE_SOLVE;
388 bool testX_AFTER_SOLVE;
403 stepper->setModel(model);
404 auto modifierX =
rcp(
new StepperHHTAlphaModifierXTest());
405 stepper->setAppAction(modifierX);
406 stepper->initialize();
411 stepper->setInitialConditions(solutionHistory);
412 solutionHistory->initWorkingState();
414 solutionHistory->getWorkingState()->setTimeStep(dt);
415 stepper->takeStep(solutionHistory);
424 auto xbegin = solutionHistory->getCurrentState()->getX();
426 auto xend = solutionHistory->getWorkingState()->getX();
428 auto Dt = solutionHistory->getWorkingState()->getTimeStep();
430 auto time = solutionHistory->getWorkingState()->getTime();
MODIFIER_TYPE
Indicates the location of application action (see algorithm).
Base observer for StepperHHTAlpha.
Base ModifierX for StepperHHTAlpha.
Modify at the beginning of the step.
void testFactoryConstruction(std::string stepperType, const Teuchos::RCP< const Thyra::ModelEvaluator< double > > &model)
Unit test utility for Stepper construction through StepperFactory.
After the implicit solve.
Modify after the implicit solve.
Modify at the end of the step.
#define TEUCHOS_TEST_FOR_EXCEPTION(throw_exception_test, Exception, msg)
#define TEST_COMPARE(v1, comp, v2)
#define TEST_FLOATING_EQUALITY(v1, v2, tol)
Teuchos::RCP< Teuchos::ParameterList > defaultSolverParameters()
Returns the default solver ParameterList for implicit Steppers.
Teuchos::RCP< SolutionHistory< Scalar > > createSolutionHistoryME(const Teuchos::RCP< const Thyra::ModelEvaluator< Scalar > > &model)
Nonmember contructor from a Thyra ModelEvaluator.
Consider the ODE: where is a constant, is a constant damping parameter, is a constant forcing par...
TEUCHOS_DEPRECATED RCP< T > rcp(T *p, Dealloc_T dealloc, bool owns_mem)
At the beginning of the step.
Base modifier for StepperHHTAlpha.
Default ModifierX for StepperHHTAlpha.
virtual void modify(Teuchos::RCP< Thyra::VectorBase< double > >, const double, const double, const MODIFIER_TYPE modType)=0
Modify solution based on the MODIFIER_TYPE.
Before the implicit solve.
TEUCHOS_UNIT_TEST(BackwardEuler, Default_Construction)
SolutionHistory is basically a container of SolutionStates. SolutionHistory maintains a collection of...
Default modifier for StepperHHTAlpha.
Default observer for StepperHHTAlpha.
Modify before the implicit solve.
ACTION_LOCATION
Indicates the location of application action (see algorithm).
#define TEUCHOS_ASSERT(assertion_test)
#define TEUCHOS_TEST_FOR_EXCEPT(throw_exception_test)