12 #include "Tempus_StepperHHTAlpha.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;
39 stepper->setModel(model);
40 stepper->initialize();
47 bool useFSAL = stepper->getUseFSAL();
48 std::string ICConsistency = stepper->getICConsistency();
49 bool ICConsistencyCheck = stepper->getICConsistencyCheck();
50 bool zeroInitialGuess = stepper->getZeroInitialGuess();
51 std::string schemeName =
"Newmark Beta User Defined";
62 stepper->setSolver(solver);
63 stepper->initialize();
65 stepper->setUseFSAL(useFSAL);
66 stepper->initialize();
68 stepper->setICConsistency(ICConsistency);
69 stepper->initialize();
71 stepper->setICConsistencyCheck(ICConsistencyCheck);
72 stepper->initialize();
74 stepper->setZeroInitialGuess(zeroInitialGuess);
75 stepper->initialize();
78 stepper->setAppAction(modifier);
79 stepper->initialize();
81 stepper->setAppAction(modifierX);
82 stepper->initialize();
84 stepper->setAppAction(observer);
85 stepper->initialize();
88 stepper->setSchemeName(schemeName);
89 stepper->initialize();
91 stepper->setBeta(beta);
92 stepper->initialize();
94 stepper->setGamma(gamma);
95 stepper->initialize();
97 stepper->setAlphaF(alpha_f);
98 stepper->initialize();
100 stepper->setAlphaM(alpha_m);
101 stepper->initialize();
106 model, solver, useFSAL, ICConsistency, ICConsistencyCheck,
107 zeroInitialGuess, schemeName, beta, gamma, alpha_f, alpha_m, modifier));
124 class StepperHHTAlphaModifierTest
128 StepperHHTAlphaModifierTest()
129 : testBEGIN_STEP(false),
130 testBEFORE_SOLVE(false),
131 testAFTER_SOLVE(false),
133 testCurrentValue(-0.99),
134 testWorkingValue(-0.99),
141 virtual ~StepperHHTAlphaModifierTest() {}
152 testBEGIN_STEP =
true;
153 auto x = sh->getCurrentState()->getX();
154 testCurrentValue = get_ele(*(x), 0);
158 testBEFORE_SOLVE =
true;
159 testDt = sh->getWorkingState()->getTimeStep() / 10.0;
160 sh->getWorkingState()->setTimeStep(testDt);
164 testAFTER_SOLVE =
true;
165 testName =
"HHT Alpha - Modifier";
166 stepper->setStepperName(testName);
171 auto x = sh->getWorkingState()->getX();
172 testWorkingValue = get_ele(*(x), 0);
177 "Error - unknown action location.\n");
181 bool testBEFORE_SOLVE;
182 bool testAFTER_SOLVE;
184 double testCurrentValue;
185 double testWorkingValue;
187 std::string testName;
197 stepper->setModel(model);
198 auto modifier =
rcp(
new StepperHHTAlphaModifierTest());
199 stepper->setAppAction(modifier);
200 stepper->initialize();
206 stepper->setInitialConditions(solutionHistory);
207 solutionHistory->initWorkingState();
209 solutionHistory->getWorkingState()->setTimeStep(dt);
210 stepper->takeStep(solutionHistory);
219 auto x = solutionHistory->getCurrentState()->getX();
221 x = solutionHistory->getWorkingState()->getX();
223 auto Dt = solutionHistory->getWorkingState()->getTimeStep();
225 TEST_COMPARE(modifier->testName, ==,
"HHT Alpha - Modifier");
230 class StepperHHTAlphaObserverTest
234 StepperHHTAlphaObserverTest()
235 : testBEGIN_STEP(false),
236 testBEFORE_SOLVE(false),
237 testAFTER_SOLVE(false),
239 testCurrentValue(-0.99),
240 testWorkingValue(-0.99),
247 virtual ~StepperHHTAlphaObserverTest() {}
250 virtual void observe(
258 testBEGIN_STEP =
true;
259 auto x = sh->getCurrentState()->getX();
260 testCurrentValue = get_ele(*(x), 0);
264 testBEFORE_SOLVE =
true;
265 testDt = sh->getWorkingState()->getTimeStep();
269 testAFTER_SOLVE =
true;
270 testName = stepper->getStepperType();
275 auto x = sh->getWorkingState()->getX();
276 testWorkingValue = get_ele(*(x), 0);
281 "Error - unknown action location.\n");
286 bool testBEFORE_SOLVE;
287 bool testAFTER_SOLVE;
289 double testCurrentValue;
290 double testWorkingValue;
292 std::string testName;
302 stepper->setModel(model);
303 auto observer =
rcp(
new StepperHHTAlphaObserverTest());
304 stepper->setAppAction(observer);
305 stepper->initialize();
311 stepper->setInitialConditions(solutionHistory);
312 solutionHistory->initWorkingState();
314 solutionHistory->getWorkingState()->setTimeStep(dt);
315 stepper->takeStep(solutionHistory);
323 auto x = solutionHistory->getCurrentState()->getX();
325 x = solutionHistory->getWorkingState()->getX();
334 class StepperHHTAlphaModifierXTest
338 StepperHHTAlphaModifierXTest()
339 : testX_BEGIN_STEP(false),
340 testX_BEFORE_SOLVE(false),
341 testX_AFTER_SOLVE(false),
342 testX_END_STEP(false),
351 virtual ~StepperHHTAlphaModifierXTest() {}
362 testX_BEGIN_STEP =
true;
363 testXbegin = get_ele(*(x), 0);
367 testX_BEFORE_SOLVE =
true;
372 testX_AFTER_SOLVE =
true;
377 testX_END_STEP =
true;
378 testXend = get_ele(*(x), 0);
383 "Error - unknown action location.\n");
387 bool testX_BEGIN_STEP;
388 bool testX_BEFORE_SOLVE;
389 bool testX_AFTER_SOLVE;
404 stepper->setModel(model);
405 auto modifierX =
rcp(
new StepperHHTAlphaModifierXTest());
406 stepper->setAppAction(modifierX);
407 stepper->initialize();
412 stepper->setInitialConditions(solutionHistory);
413 solutionHistory->initWorkingState();
415 solutionHistory->getWorkingState()->setTimeStep(dt);
416 stepper->takeStep(solutionHistory);
425 auto xbegin = solutionHistory->getCurrentState()->getX();
427 auto xend = solutionHistory->getWorkingState()->getX();
429 auto Dt = solutionHistory->getWorkingState()->getTimeStep();
431 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)