14 #include "../TestModels/DahlquistTestModel.hpp"
16 namespace Tempus_Unit_Test {
21 using Teuchos::rcp_const_cast;
22 using Teuchos::rcp_dynamic_cast;
23 using Teuchos::sublist;
56 class StepperRKModifierEDIRK_TrapezoidaTest
62 : out(Out), success(Success)
68 virtual ~StepperRKModifierEDIRK_TrapezoidaTest() {}
76 const double relTol = 1.0e-14;
77 auto stageNumber = stepper->getStageNumber();
80 auto currentState = sh->getCurrentState();
81 auto workingState = sh->getWorkingState();
82 const double dt = workingState->getTimeStep();
83 double time = currentState->getTime();
84 if (stageNumber >= 0) time += c(stageNumber) * dt;
86 auto x = workingState->getX();
87 auto xDot = workingState->getXDot();
88 if (xDot == Teuchos::null) xDot = stepper->getStepperXDot();
93 auto DME = Teuchos::rcp_dynamic_cast<
100 const double x_0 = get_ele(*(x), 0);
101 const double xDot_0 = get_ele(*(xDot), 0);
111 const double X_i = get_ele(*(x), 0);
112 const double f_i = get_ele(*(xDot), 0);
114 if (stageNumber == 0) {
119 else if (stageNumber == 1) {
133 const double X_i = get_ele(*(x), 0);
134 const double f_i = get_ele(*(xDot), 0);
136 if (stageNumber == 0) {
142 else if (stageNumber == 1) {
155 const double x_1 = get_ele(*(x), 0);
156 time = workingState->getTime();
162 if (stepper->getUseEmbedded() ==
true) {
164 TEST_ASSERT(std::abs(workingState->getTolAbs()) < relTol);
166 TEST_ASSERT(std::abs(workingState->getErrorRel()) < relTol);
185 auto modifier =
rcp(
new StepperRKModifierEDIRK_TrapezoidaTest(out, success));
187 stepper->setModel(model);
188 stepper->setAppAction(modifier);
189 stepper->setICConsistency(
"Consistent");
190 stepper->setUseFSAL(
false);
191 stepper->initialize();
197 stepper->setInitialConditions(solutionHistory);
198 solutionHistory->initWorkingState();
200 solutionHistory->getWorkingState()->setTimeStep(dt);
201 solutionHistory->getWorkingState()->setTime(dt);
202 stepper->takeStep(solutionHistory);
At the beginning of the stage.
At the beginning of the step.
void testDIRKAccessorsFullConstruction(const RCP< Tempus::StepperDIRK< double >> &stepper)
Unit test utility for ExplicitRK Stepper construction and accessors.
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.
#define TEST_COMPARE(v1, comp, v2)
#define TEST_FLOATING_EQUALITY(v1, v2, tol)
Before the implicit solve.
Sine-Cosine model problem from Rythmos. This is a canonical Sine-Cosine differential equation with a...
RK Trapezoidal Rule (A.K.A. RK Crank-Nicolson)
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)
SolutionHistory is basically a container of SolutionStates. SolutionHistory maintains a collection of...
ACTION_LOCATION
Indicates the location of application action (see algorithm).
After the implicit solve.
Before the explicit evaluation.
#define TEUCHOS_ASSERT(assertion_test)
Base modifier for StepperRK.
#define TEUCHOS_TEST_FOR_EXCEPT(throw_exception_test)