12 #include "Teuchos_DefaultComm.hpp"
14 #include "Thyra_VectorStdOps.hpp"
16 #include "Tempus_SolutionHistory.hpp"
17 #include "Tempus_StepperFactory.hpp"
22 #include "../TestModels/DahlquistTestModel.hpp"
23 #include "../TestModels/VanDerPol_IMEX_ExplicitModel.hpp"
24 #include "../TestModels/VanDerPol_IMEX_ImplicitModel.hpp"
25 #include "../TestUtils/Tempus_ConvergenceTestUtils.hpp"
30 namespace Tempus_Unit_Test {
34 using Teuchos::rcp_const_cast;
35 using Teuchos::rcp_dynamic_cast;
37 using Teuchos::sublist;
38 using Teuchos::getParametersFromXmlFile;
52 explicitModel, implicitModel));
56 stepper->setModel(model);
57 stepper->initialize();
67 bool useFSAL = stepper->getUseFSAL();
68 std::string ICConsistency = stepper->getICConsistency();
69 bool ICConsistencyCheck = stepper->getICConsistencyCheck();
70 bool zeroInitialGuess = stepper->getZeroInitialGuess();
71 std::string stepperType =
"IMEX RK SSP2";
73 auto explicitTableau = stepperERK->getTableau();
75 auto implicitTableau = stepperSDIRK->getTableau();
85 stepper->setICConsistency(ICConsistency); stepper->initialize();
TEUCHOS_TEST_FOR_EXCEPT(!stepper->isInitialized());
86 stepper->setICConsistencyCheck(ICConsistencyCheck); stepper->initialize();
TEUCHOS_TEST_FOR_EXCEPT(!stepper->isInitialized());
87 stepper->setZeroInitialGuess(zeroInitialGuess); stepper->initialize();
TEUCHOS_TEST_FOR_EXCEPT(!stepper->isInitialized());
89 stepper->setStepperName(stepperType); stepper->initialize();
TEUCHOS_TEST_FOR_EXCEPT(!stepper->isInitialized());
90 stepper->setExplicitTableau(explicitTableau); stepper->initialize();
TEUCHOS_TEST_FOR_EXCEPT(!stepper->isInitialized());
91 stepper->setImplicitTableau(implicitTableau); stepper->initialize();
TEUCHOS_TEST_FOR_EXCEPT(!stepper->isInitialized());
100 model, solver, useFSAL, ICConsistency, ICConsistencyCheck,
101 zeroInitialGuess, modifier, stepperType, explicitTableau,
102 implicitTableau, order));
118 explicitModel, implicitModel));
132 explicitModel, implicitModel));
136 auto stepper = sf->createStepper(
"General IMEX RK", model);
149 explicitModel, implicitModel));
153 auto stepper = sf->createStepper(
"General IMEX RK");
154 stepper->setModel(model);
155 stepper->initialize();
169 explicitModel, implicitModel));
176 class StepperRKModifierIMEX_TrapezoidaTest
183 : out(Out), success(Success)
188 virtual ~StepperRKModifierIMEX_TrapezoidaTest(){}
196 const double relTol = 1.0e-14;
202 auto currentState = sh->getCurrentState();
203 auto workingState = sh->getWorkingState();
204 const double dt = workingState->getTimeStep();
205 double time = currentState->getTime();
206 double imp_time = time;
207 if (stageNumber >= 0) {
208 time += c(stageNumber)*dt;
209 imp_time += chat(stageNumber)*dt;
212 auto x = workingState->getX();
213 auto xDot = workingState->getXDot();
214 if (xDot == Teuchos::null) xDot = stepper->getStepperXDot();
230 const double x_0 = get_ele(*(x), 0);
241 const double X_i = get_ele(*(x), 0);
242 const double f_i = get_ele(*(xDot), 0);
244 if (stageNumber == 0) {
249 }
else if (stageNumber == 1) {
264 const double X_i = get_ele(*(x), 0);
265 const double f_i = get_ele(*(xDot), 0);
267 if (stageNumber == 0) {
273 }
else if (stageNumber == 1) {
286 const double x_1 = get_ele(*(x), 0);
287 time = workingState->getTime();
315 explicitModel, implicitModel));
317 auto modifier =
rcp(
new StepperRKModifierIMEX_TrapezoidaTest(out, success));
322 stepper->setModel(model);
328 bool useFSAL = stepper->getUseFSAL();
329 std::string ICConsistency = stepper->getICConsistency();
330 bool ICConsistencyCheck = stepper->getICConsistencyCheck();
331 bool zeroInitialGuess = stepper->getZeroInitialGuess();
332 std::string stepperType =
"IMEX RK SSP2";
334 auto explicitTableau = stepperERK->getTableau();
336 auto implicitTableau = stepperSDIRK->getTableau();
339 stepper->setStepperName(stepperType);
340 stepper->setExplicitTableau(explicitTableau);
341 stepper->setImplicitTableau(implicitTableau);
342 stepper->setOrder(order);
343 stepper->setSolver(solver);
344 stepper->setUseFSAL(useFSAL);
345 stepper->setICConsistency(ICConsistency);
346 stepper->setICConsistencyCheck(ICConsistencyCheck);
347 stepper->setZeroInitialGuess(zeroInitialGuess);
349 stepper->setModel(model);
350 stepper->setAppAction(modifier);
351 stepper->setUseFSAL(
false);
352 stepper->initialize();
358 stepper->setInitialConditions(solutionHistory);
359 solutionHistory->initWorkingState();
361 solutionHistory->getWorkingState()->setTimeStep(dt);
362 solutionHistory->getWorkingState()->setTime(dt);
363 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)