14 #include "../TestModels/DahlquistTestModel.hpp"
15 #include "../TestModels/VanDerPol_IMEX_ExplicitModel.hpp"
16 #include "../TestModels/VanDerPol_IMEX_ImplicitModel.hpp"
18 namespace Tempus_Unit_Test {
23 using Teuchos::rcp_const_cast;
24 using Teuchos::rcp_dynamic_cast;
25 using Teuchos::sublist;
40 explicitModel, implicitModel));
44 stepper->setModel(model);
45 stepper->initialize();
55 bool useFSAL = stepper->getUseFSAL();
56 std::string ICConsistency = stepper->getICConsistency();
57 bool ICConsistencyCheck = stepper->getICConsistencyCheck();
58 bool zeroInitialGuess = stepper->getZeroInitialGuess();
59 std::string stepperType =
"IMEX RK SSP2";
61 auto explicitTableau = stepperERK->getTableau();
64 auto implicitTableau = stepperSDIRK->getTableau();
68 stepper->setAppAction(modifier);
69 stepper->initialize();
71 stepper->setAppAction(modifierX);
72 stepper->initialize();
74 stepper->setAppAction(observer);
75 stepper->initialize();
77 stepper->setSolver(solver);
78 stepper->initialize();
80 stepper->setUseFSAL(useFSAL);
81 stepper->initialize();
83 stepper->setICConsistency(ICConsistency);
84 stepper->initialize();
86 stepper->setICConsistencyCheck(ICConsistencyCheck);
87 stepper->initialize();
89 stepper->setZeroInitialGuess(zeroInitialGuess);
90 stepper->initialize();
93 stepper->setStepperName(stepperType);
94 stepper->initialize();
96 stepper->setExplicitTableau(explicitTableau);
97 stepper->initialize();
99 stepper->setImplicitTableau(implicitTableau);
100 stepper->initialize();
102 stepper->setOrder(order);
103 stepper->initialize();
112 model, solver, useFSAL, ICConsistency, ICConsistencyCheck,
113 zeroInitialGuess, modifier, stepperType, explicitTableau, implicitTableau,
131 explicitModel, implicitModel));
146 explicitModel, implicitModel));
150 auto stepper = sf->createStepper(
"General IMEX RK", model);
157 StepperFactory_Construction_General_wo_Parameterlist_Model)
165 explicitModel, implicitModel));
169 auto stepper = sf->createStepper(
"General IMEX RK");
170 stepper->setModel(model);
171 stepper->initialize();
186 explicitModel, implicitModel));
191 class StepperRKModifierIMEX_TrapezoidaTest
197 : out(Out), success(Success)
203 virtual ~StepperRKModifierIMEX_TrapezoidaTest() {}
211 const double relTol = 1.0e-14;
218 stepper_imex->getImplicitTableau()->c();
220 auto currentState = sh->getCurrentState();
221 auto workingState = sh->getWorkingState();
222 const double dt = workingState->getTimeStep();
223 double time = currentState->getTime();
224 double imp_time = time;
225 if (stageNumber >= 0) {
226 time += c(stageNumber) * dt;
227 imp_time += chat(stageNumber) * dt;
230 auto x = workingState->getX();
231 auto xDot = workingState->getXDot();
232 if (xDot == Teuchos::null) xDot = stepper->getStepperXDot();
237 auto imex_me = Teuchos::rcp_dynamic_cast<
239 stepper->getModel(),
true);
240 auto explicitModel = Teuchos::rcp_dynamic_cast<
242 imex_me->getExplicitModel(),
true);
243 auto implicitModel = Teuchos::rcp_dynamic_cast<
245 imex_me->getImplicitModel(),
true);
252 const double x_0 = get_ele(*(x), 0);
262 const double X_i = get_ele(*(x), 0);
263 const double f_i = get_ele(*(xDot), 0);
265 if (stageNumber == 0) {
271 else if (stageNumber == 1) {
286 const double X_i = get_ele(*(x), 0);
287 const double f_i = get_ele(*(xDot), 0);
289 if (stageNumber == 0) {
296 else if (stageNumber == 1) {
310 const double x_1 = get_ele(*(x), 0);
311 time = workingState->getTime();
336 explicitModel, implicitModel));
338 auto modifier =
rcp(
new StepperRKModifierIMEX_TrapezoidaTest(out, success));
342 stepper->setModel(model);
348 bool useFSAL = stepper->getUseFSAL();
349 std::string ICConsistency = stepper->getICConsistency();
350 bool ICConsistencyCheck = stepper->getICConsistencyCheck();
351 bool zeroInitialGuess = stepper->getZeroInitialGuess();
352 std::string stepperType =
"IMEX RK SSP2";
354 auto explicitTableau = stepperERK->getTableau();
357 auto implicitTableau = stepperSDIRK->getTableau();
360 stepper->setStepperName(stepperType);
361 stepper->setExplicitTableau(explicitTableau);
362 stepper->setImplicitTableau(implicitTableau);
363 stepper->setOrder(order);
364 stepper->setSolver(solver);
365 stepper->setUseFSAL(useFSAL);
366 stepper->setICConsistency(ICConsistency);
367 stepper->setICConsistencyCheck(ICConsistencyCheck);
368 stepper->setZeroInitialGuess(zeroInitialGuess);
370 stepper->setModel(model);
371 stepper->setAppAction(modifier);
372 stepper->setUseFSAL(
false);
373 stepper->initialize();
379 stepper->setInitialConditions(solutionHistory);
380 solutionHistory->initWorkingState();
382 solutionHistory->getWorkingState()->setTimeStep(dt);
383 solutionHistory->getWorkingState()->setTime(dt);
384 stepper->takeStep(solutionHistory);
At the beginning of the stage.
At the beginning of the step.
van der Pol model formulated for IMEX-RK.
Default observer for StepperRK.
Explicit Runge-Kutta time stepper.
void testFactoryConstruction(std::string stepperType, const Teuchos::RCP< const Thyra::ModelEvaluator< double > > &model)
Unit test utility for Stepper construction through StepperFactory.
The classic Dahlquist Test Problem.
ModelEvaluator pair for implicit and explicit (IMEX) evaulations.
Implicit-Explicit Runge-Kutta (IMEX-RK) time stepper.
#define TEST_COMPARE(v1, comp, v2)
#define TEST_FLOATING_EQUALITY(v1, v2, tol)
Before the implicit solve.
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.
Base class for Runge-Kutta methods, ExplicitRK, DIRK and IMEX.
void testRKAppAction(const Teuchos::RCP< Tempus::StepperRKBase< double >> &stepper, const Teuchos::RCP< const Thyra::ModelEvaluator< double >> &model, Teuchos::FancyOStream &out, bool &success)
Unit test utility for Stepper RK AppAction.
TEUCHOS_DEPRECATED RCP< T > rcp(T *p, Dealloc_T dealloc, bool owns_mem)
TEUCHOS_UNIT_TEST(BackwardEuler, Default_Construction)
virtual void modify(Teuchos::RCP< SolutionHistory< double > >, Teuchos::RCP< StepperRKBase< double > >, const typename StepperRKAppAction< double >::ACTION_LOCATION actLoc)=0
Modify RK Stepper.
virtual int getStageNumber() const
SolutionHistory is basically a container of SolutionStates. SolutionHistory maintains a collection of...
ACTION_LOCATION
Indicates the location of application action (see algorithm).
Default ModifierX for StepperRK.
After the implicit solve.
Before the explicit evaluation.
Default modifier for StepperRK.
van der Pol model formulated for IMEX.
#define TEUCHOS_ASSERT(assertion_test)
Base modifier for StepperRK.
#define TEUCHOS_TEST_FOR_EXCEPT(throw_exception_test)