13 #include "../TestModels/DahlquistTestModel.hpp"
14 #include "../TestModels/VanDerPol_IMEX_ExplicitModel.hpp"
15 #include "../TestModels/VanDerPol_IMEX_ImplicitModel.hpp"
18 namespace Tempus_Unit_Test {
22 using Teuchos::rcp_const_cast;
23 using Teuchos::rcp_dynamic_cast;
25 using Teuchos::sublist;
39 explicitModel, implicitModel));
43 stepper->setModel(model);
44 stepper->initialize();
54 bool useFSAL = stepper->getUseFSAL();
55 std::string ICConsistency = stepper->getICConsistency();
56 bool ICConsistencyCheck = stepper->getICConsistencyCheck();
57 bool zeroInitialGuess = stepper->getZeroInitialGuess();
58 std::string stepperType =
"IMEX RK SSP2";
60 auto explicitTableau = stepperERK->getTableau();
62 auto implicitTableau = stepperSDIRK->getTableau();
72 stepper->setICConsistency(ICConsistency); stepper->initialize();
TEUCHOS_TEST_FOR_EXCEPT(!stepper->isInitialized());
73 stepper->setICConsistencyCheck(ICConsistencyCheck); stepper->initialize();
TEUCHOS_TEST_FOR_EXCEPT(!stepper->isInitialized());
74 stepper->setZeroInitialGuess(zeroInitialGuess); stepper->initialize();
TEUCHOS_TEST_FOR_EXCEPT(!stepper->isInitialized());
76 stepper->setStepperName(stepperType); stepper->initialize();
TEUCHOS_TEST_FOR_EXCEPT(!stepper->isInitialized());
77 stepper->setExplicitTableau(explicitTableau); stepper->initialize();
TEUCHOS_TEST_FOR_EXCEPT(!stepper->isInitialized());
78 stepper->setImplicitTableau(implicitTableau); stepper->initialize();
TEUCHOS_TEST_FOR_EXCEPT(!stepper->isInitialized());
87 model, solver, useFSAL, ICConsistency, ICConsistencyCheck,
88 zeroInitialGuess, modifier, stepperType, explicitTableau,
89 implicitTableau, order));
105 explicitModel, implicitModel));
119 explicitModel, implicitModel));
123 auto stepper = sf->createStepper(
"General IMEX RK", model);
136 explicitModel, implicitModel));
140 auto stepper = sf->createStepper(
"General IMEX RK");
141 stepper->setModel(model);
142 stepper->initialize();
156 explicitModel, implicitModel));
163 class StepperRKModifierIMEX_TrapezoidaTest
170 : out(Out), success(Success)
175 virtual ~StepperRKModifierIMEX_TrapezoidaTest(){}
183 const double relTol = 1.0e-14;
189 auto currentState = sh->getCurrentState();
190 auto workingState = sh->getWorkingState();
191 const double dt = workingState->getTimeStep();
192 double time = currentState->getTime();
193 double imp_time = time;
194 if (stageNumber >= 0) {
195 time += c(stageNumber)*dt;
196 imp_time += chat(stageNumber)*dt;
199 auto x = workingState->getX();
200 auto xDot = workingState->getXDot();
201 if (xDot == Teuchos::null) xDot = stepper->getStepperXDot();
217 const double x_0 = get_ele(*(x), 0);
228 const double X_i = get_ele(*(x), 0);
229 const double f_i = get_ele(*(xDot), 0);
231 if (stageNumber == 0) {
236 }
else if (stageNumber == 1) {
251 const double X_i = get_ele(*(x), 0);
252 const double f_i = get_ele(*(xDot), 0);
254 if (stageNumber == 0) {
260 }
else if (stageNumber == 1) {
273 const double x_1 = get_ele(*(x), 0);
274 time = workingState->getTime();
302 explicitModel, implicitModel));
304 auto modifier =
rcp(
new StepperRKModifierIMEX_TrapezoidaTest(out, success));
309 stepper->setModel(model);
315 bool useFSAL = stepper->getUseFSAL();
316 std::string ICConsistency = stepper->getICConsistency();
317 bool ICConsistencyCheck = stepper->getICConsistencyCheck();
318 bool zeroInitialGuess = stepper->getZeroInitialGuess();
319 std::string stepperType =
"IMEX RK SSP2";
321 auto explicitTableau = stepperERK->getTableau();
323 auto implicitTableau = stepperSDIRK->getTableau();
326 stepper->setStepperName(stepperType);
327 stepper->setExplicitTableau(explicitTableau);
328 stepper->setImplicitTableau(implicitTableau);
329 stepper->setOrder(order);
330 stepper->setSolver(solver);
331 stepper->setUseFSAL(useFSAL);
332 stepper->setICConsistency(ICConsistency);
333 stepper->setICConsistencyCheck(ICConsistencyCheck);
334 stepper->setZeroInitialGuess(zeroInitialGuess);
336 stepper->setModel(model);
337 stepper->setAppAction(modifier);
338 stepper->setUseFSAL(
false);
339 stepper->initialize();
345 stepper->setInitialConditions(solutionHistory);
346 solutionHistory->initWorkingState();
348 solutionHistory->getWorkingState()->setTimeStep(dt);
349 solutionHistory->getWorkingState()->setTime(dt);
350 stepper->takeStep(solutionHistory);
At the beginning of the stage.
At the beginning of the step.
van der Pol model formulated for IMEX-RK.
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.
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.
TEUCHOS_DEPRECATED RCP< T > rcp(T *p, Dealloc_T dealloc, bool owns_mem)
TEUCHOS_UNIT_TEST(BackwardEuler, Default_Construction)
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)