11 #include "Tempus_StepperHHTAlpha.hpp"
19 #include "../TestModels/HarmonicOscillatorModel.hpp"
21 namespace Tempus_Unit_Test {
25 using Teuchos::rcp_const_cast;
26 using Teuchos::rcp_dynamic_cast;
28 using Teuchos::sublist;
39 stepper->setModel(model);
40 stepper->initialize();
48 bool useFSAL = stepper->getUseFSAL();
49 std::string ICConsistency = stepper->getICConsistency();
50 bool ICConsistencyCheck = stepper->getICConsistencyCheck();
51 bool zeroInitialGuess = stepper->getZeroInitialGuess();
52 std::string schemeName =
"Newmark Beta User Defined";
65 stepper->setICConsistency(ICConsistency); stepper->initialize();
TEUCHOS_TEST_FOR_EXCEPT(!stepper->isInitialized());
66 stepper->setICConsistencyCheck(ICConsistencyCheck); stepper->initialize();
TEUCHOS_TEST_FOR_EXCEPT(!stepper->isInitialized());
67 stepper->setZeroInitialGuess(zeroInitialGuess); stepper->initialize();
TEUCHOS_TEST_FOR_EXCEPT(!stepper->isInitialized());
81 model, solver, useFSAL,
82 ICConsistency, ICConsistencyCheck, zeroInitialGuess,
83 schemeName, beta, gamma, alpha_f, alpha_m,modifier));
101 class StepperHHTAlphaModifierTest
107 StepperHHTAlphaModifierTest()
108 : testBEGIN_STEP(false), testBEFORE_SOLVE(false),
109 testAFTER_SOLVE(false), testEND_STEP(false),
110 testCurrentValue(-0.99), testWorkingValue(-0.99),
111 testDt(-1.5), testName(
"")
115 virtual ~StepperHHTAlphaModifierTest(){}
126 testBEGIN_STEP =
true;
127 auto x = sh->getCurrentState()->getX();
128 testCurrentValue = get_ele(*(x), 0);
133 testBEFORE_SOLVE =
true;
134 testDt = sh->getWorkingState()->getTimeStep()/10.0;
135 sh->getWorkingState()->setTimeStep(testDt);
140 testAFTER_SOLVE =
true;
141 testName =
"HHT Alpha - Modifier";
142 stepper->setStepperName(testName);
148 auto x = sh->getWorkingState()->getX();
149 testWorkingValue = get_ele(*(x), 0);
154 "Error - unknown action location.\n");
158 bool testBEFORE_SOLVE;
159 bool testAFTER_SOLVE;
161 double testCurrentValue;
162 double testWorkingValue;
164 std::string testName;
174 stepper->setModel(model);
175 auto modifier =
rcp(
new StepperHHTAlphaModifierTest());
176 stepper->setAppAction(modifier);
177 stepper->initialize();
183 stepper->setInitialConditions(solutionHistory);
184 solutionHistory->initWorkingState();
186 solutionHistory->getWorkingState()->setTimeStep(dt);
187 stepper->takeStep(solutionHistory);
196 auto x = solutionHistory->getCurrentState()->getX();
198 x = solutionHistory->getWorkingState()->getX();
200 auto Dt = solutionHistory->getWorkingState()->getTimeStep();
202 TEST_COMPARE(modifier->testName, ==,
"HHT Alpha - Modifier");
207 class StepperHHTAlphaObserverTest
212 StepperHHTAlphaObserverTest()
213 : testBEGIN_STEP(false), testBEFORE_SOLVE(false),
214 testAFTER_SOLVE(false), testEND_STEP(false),
215 testCurrentValue(-0.99), testWorkingValue(-0.99),
216 testDt(-1.5), testName(
"")
220 virtual ~StepperHHTAlphaObserverTest(){}
223 virtual void observe(
231 testBEGIN_STEP =
true;
232 auto x = sh->getCurrentState()->getX();
233 testCurrentValue = get_ele(*(x), 0);
238 testBEFORE_SOLVE =
true;
239 testDt = sh->getWorkingState()->getTimeStep();
244 testAFTER_SOLVE =
true;
245 testName = stepper->getStepperType();
251 auto x = sh->getWorkingState()->getX();
252 testWorkingValue = get_ele(*(x), 0);
257 "Error - unknown action location.\n");
262 bool testBEFORE_SOLVE;
263 bool testAFTER_SOLVE;
265 double testCurrentValue;
266 double testWorkingValue;
268 std::string testName;
278 stepper->setModel(model);
279 auto observer =
rcp(
new StepperHHTAlphaObserverTest());
280 stepper->setAppAction(observer);
281 stepper->initialize();
287 stepper->setInitialConditions(solutionHistory);
288 solutionHistory->initWorkingState();
290 solutionHistory->getWorkingState()->setTimeStep(dt);
291 stepper->takeStep(solutionHistory);
299 auto x = solutionHistory->getCurrentState()->getX();
301 x = solutionHistory->getWorkingState()->getX();
310 class StepperHHTAlphaModifierXTest
316 StepperHHTAlphaModifierXTest()
317 : testX_BEGIN_STEP(false), testX_BEFORE_SOLVE(false),
318 testX_AFTER_SOLVE(false), testX_END_STEP(false),
319 testXbegin(-0.99), testXend(-0.99),
320 testDt(-1.5), testTime(-1.5)
324 virtual ~StepperHHTAlphaModifierXTest(){}
329 const double time,
const double dt,
335 testX_BEGIN_STEP =
true;
336 testXbegin = get_ele(*(x), 0);
341 testX_BEFORE_SOLVE =
true;
347 testX_AFTER_SOLVE =
true;
353 testX_END_STEP =
true;
354 testXend = get_ele(*(x), 0);
359 "Error - unknown action location.\n");
363 bool testX_BEGIN_STEP;
364 bool testX_BEFORE_SOLVE;
365 bool testX_AFTER_SOLVE;
380 stepper->setModel(model);
381 auto modifierX =
rcp(
new StepperHHTAlphaModifierXTest());
382 stepper->setAppAction(modifierX);
383 stepper->initialize();
388 stepper->setInitialConditions(solutionHistory);
389 solutionHistory->initWorkingState();
391 solutionHistory->getWorkingState()->setTimeStep(dt);
392 stepper->takeStep(solutionHistory);
401 auto xbegin = solutionHistory->getCurrentState()->getX();
403 auto xend = solutionHistory->getWorkingState()->getX();
405 auto Dt = solutionHistory->getWorkingState()->getTimeStep();
407 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)