12 #include "Teuchos_DefaultComm.hpp"
14 #include "Thyra_VectorStdOps.hpp"
18 #include "../TestModels/SinCosModel.hpp"
19 #include "../TestModels/DahlquistTestModel.hpp"
20 #include "../TestUtils/Tempus_ConvergenceTestUtils.hpp"
26 namespace Tempus_Unit_Test {
30 using Teuchos::rcp_const_cast;
31 using Teuchos::rcp_dynamic_cast;
33 using Teuchos::sublist;
34 using Teuchos::getParametersFromXmlFile;
71 class StepperRKModifierEDIRK_TrapezoidaTest
78 : out(Out), success(Success)
83 virtual ~StepperRKModifierEDIRK_TrapezoidaTest(){}
91 const double relTol = 1.0e-14;
92 auto stageNumber = stepper->getStageNumber();
95 auto currentState = sh->getCurrentState();
96 auto workingState = sh->getWorkingState();
97 const double dt = workingState->getTimeStep();
98 double time = currentState->getTime();
99 if (stageNumber >= 0) time += c(stageNumber)*dt;
101 auto x = workingState->getX();
102 auto xDot = workingState->getXDot();
103 if (xDot == Teuchos::null) xDot = stepper->getStepperXDot();
109 auto DME = Teuchos::rcp_dynamic_cast<
115 const double x_0 = get_ele(*(x), 0);
116 const double xDot_0 = get_ele(*(xDot), 0);
127 const double X_i = get_ele(*(x), 0);
128 const double f_i = get_ele(*(xDot), 0);
130 if (stageNumber == 0) {
134 }
else if (stageNumber == 1) {
148 const double X_i = get_ele(*(x), 0);
149 const double f_i = get_ele(*(xDot), 0);
151 if (stageNumber == 0) {
156 }
else if (stageNumber == 1) {
169 const double x_1 = get_ele(*(x), 0);
170 time = workingState->getTime();
176 if (stepper->getUseEmbedded() ==
true) {
178 TEST_ASSERT(std::abs(workingState->getTolAbs()) < relTol);
180 TEST_ASSERT(std::abs(workingState->getErrorRel()) < relTol);
205 auto modifier =
rcp(
new StepperRKModifierEDIRK_TrapezoidaTest(out, success));
207 stepper->setModel(model);
208 stepper->setAppAction(modifier);
209 stepper->setICConsistency(
"Consistent");
210 stepper->setUseFSAL(
false);
211 stepper->initialize();
217 stepper->setInitialConditions(solutionHistory);
218 solutionHistory->initWorkingState();
220 solutionHistory->getWorkingState()->setTimeStep(dt);
221 solutionHistory->getWorkingState()->setTime(dt);
222 stepper->takeStep(solutionHistory);
At the beginning of the stage.
At the beginning of the step.
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.
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.
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).
void testDIRKAccessorsFullConstruction(const RCP< Tempus::StepperDIRK< double > > &stepper)
Unit test utility for ExplicitRK Stepper construction and accessors.
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)