12 #include "Tempus_StepperFactory.hpp"
13 #include "Tempus_TimeStepControl.hpp"
16 #include "../TestModels/DahlquistTestModel.hpp"
18 namespace Tempus_Unit_Test {
23 using Teuchos::rcp_const_cast;
24 using Teuchos::rcp_dynamic_cast;
25 using Teuchos::sublist;
38 TEUCHOS_TEST_FOR_EXCEPT(tscs->getReductFactor() != 0.5);
39 TEUCHOS_TEST_FOR_EXCEPT(tscs->getMinEta() != 0.0);
40 TEUCHOS_TEST_FOR_EXCEPT(tscs->getMaxEta() != 1.0e+16);
43 tscs->setAmplFactor(1.33);
45 TEUCHOS_TEST_FOR_EXCEPT(!tscs->isInitialized());
46 tscs->setReductFactor(0.75);
48 TEUCHOS_TEST_FOR_EXCEPT(!tscs->isInitialized());
49 tscs->setMinEta(0.01);
51 TEUCHOS_TEST_FOR_EXCEPT(!tscs->isInitialized());
52 tscs->setMaxEta(0.05);
54 TEUCHOS_TEST_FOR_EXCEPT(!tscs->isInitialized());
56 TEUCHOS_TEST_FOR_EXCEPT(tscs->getAmplFactor() != 1.33);
57 TEUCHOS_TEST_FOR_EXCEPT(tscs->getReductFactor() != 0.75);
58 TEUCHOS_TEST_FOR_EXCEPT(tscs->getMinEta() != 0.01);
59 TEUCHOS_TEST_FOR_EXCEPT(tscs->getMaxEta() != 0.05);
67 1.33, 0.75, 0.01, 0.05));
73 TEUCHOS_TEST_FOR_EXCEPT(tscs->getReductFactor() != 0.75);
74 TEUCHOS_TEST_FOR_EXCEPT(tscs->getMinEta() != 0.01);
75 TEUCHOS_TEST_FOR_EXCEPT(tscs->getMaxEta() != 0.05);
82 auto pl = Tempus::getTimeStepControlStrategyBasicVS_PL<double>();
84 pl->set<
double>(
"Amplification Factor", 1.33);
85 pl->set<
double>(
"Reduction Factor", 0.75);
86 pl->set<
double>(
"Minimum Value Monitoring Function", 0.01);
87 pl->set<
double>(
"Maximum Value Monitoring Function", 0.05);
89 auto tscs = Tempus::createTimeStepControlStrategyBasicVS<double>(pl);
94 TEUCHOS_TEST_FOR_EXCEPT(tscs->getReductFactor() != 0.75);
95 TEUCHOS_TEST_FOR_EXCEPT(tscs->getMinEta() != 0.01);
96 TEUCHOS_TEST_FOR_EXCEPT(tscs->getMaxEta() != 0.05);
104 tscs->setAmplFactor(1.1);
105 tscs->setReductFactor(0.5);
106 tscs->setMinEta(0.01);
107 tscs->setMaxEta(0.05);
113 tsc->setTimeStepControlStrategy(tscs);
114 tsc->setInitTime(0.0);
115 tsc->setFinalTime(10.0);
116 tsc->setMinTimeStep(0.01);
117 tsc->setInitTimeStep(0.1);
118 tsc->setMaxTimeStep(1.0);
119 tsc->setFinalIndex(100);
126 auto inArgsIC = model->getNominalValues();
129 auto icState = Tempus::createSolutionStateX<double>(icSolution);
134 solutionHistory->addState(icState);
135 solutionHistory->getCurrentState()->setTimeStep(0.5);
136 solutionHistory->getCurrentState()->setTime(0.0);
137 solutionHistory->getCurrentState()->setIndex(0);
140 for (
int i = 0; i < 2; i++) {
141 solutionHistory->initWorkingState();
143 tsc->setNextTimeStep(solutionHistory, status);
146 auto currentState = solutionHistory->getCurrentState();
147 auto workingState = solutionHistory->getWorkingState();
148 auto xN = workingState->getX();
149 Thyra::Vp_S(xN.ptr(), 1.0);
151 workingState->computeNorms(currentState);
154 solutionHistory->promoteWorkingState();
158 auto currentState = solutionHistory->getCurrentState();
165 solutionHistory->clear();
166 solutionHistory->addState(icState);
167 solutionHistory->getCurrentState()->setTimeStep(0.5);
168 solutionHistory->getCurrentState()->setTime(0.0);
169 solutionHistory->getCurrentState()->setIndex(0);
172 for (
int i = 0; i < 2; i++) {
173 solutionHistory->initWorkingState();
175 tsc->setNextTimeStep(solutionHistory, status);
178 auto currentState = solutionHistory->getCurrentState();
179 auto workingState = solutionHistory->getWorkingState();
180 auto xN = workingState->getX();
181 Thyra::Vp_S(xN.ptr(), 0.0);
183 workingState->computeNorms(currentState);
186 solutionHistory->promoteWorkingState();
191 auto currentState = solutionHistory->getCurrentState();
203 auto pl = tscs->getValidParameters();
205 TEST_COMPARE(pl->get<std::string>(
"Strategy Type"), ==,
"Basic VS");
215 std::ostringstream unusedParameters;
216 pl->unused(unusedParameters);
StepControlStrategy class for TimeStepControl.
The classic Dahlquist Test Problem.
#define TEST_COMPARE(v1, comp, v2)
#define TEST_FLOATING_EQUALITY(v1, v2, tol)
TEUCHOS_DEPRECATED RCP< T > rcp(T *p, Dealloc_T dealloc, bool owns_mem)
Status
Status for the Integrator, the Stepper and the SolutionState.
TEUCHOS_UNIT_TEST(BackwardEuler, Default_Construction)
TimeStepControl manages the time step size. There several mechanisms that effect the time step size a...
SolutionHistory is basically a container of SolutionStates. SolutionHistory maintains a collection of...
#define TEUCHOS_TEST_FOR_EXCEPT(throw_exception_test)