9 #include "Teuchos_UnitTestHarness.hpp" 10 #include "Teuchos_XMLParameterListHelpers.hpp" 11 #include "Teuchos_TimeMonitor.hpp" 12 #include "Teuchos_DefaultComm.hpp" 14 #include "Thyra_VectorStdOps.hpp" 16 #include "Tempus_StepperFactory.hpp" 17 #include "Tempus_TimeStepControl.hpp" 21 #include "../TestModels/SinCosModel.hpp" 22 #include "../TestModels/DahlquistTestModel.hpp" 23 #include "../TestUtils/Tempus_ConvergenceTestUtils.hpp" 32 using Teuchos::rcp_const_cast;
33 using Teuchos::rcp_dynamic_cast;
34 using Teuchos::ParameterList;
35 using Teuchos::sublist;
36 using Teuchos::getParametersFromXmlFile;
44 TEUCHOS_TEST_FOR_EXCEPT(!tscs->isInitialized());
47 TEUCHOS_TEST_FOR_EXCEPT(tscs->getStrategyType() !=
"Constant");
48 TEUCHOS_TEST_FOR_EXCEPT(tscs->getStepType() !=
"Constant");
49 TEUCHOS_TEST_FOR_EXCEPT(tscs->getName() !=
"Constant");
50 TEST_FLOATING_EQUALITY (tscs->getConstantTimeStep(), 0.0, 1.0e-14);
53 tscs->setConstantTimeStep(0.989); tscs->initialize(); TEUCHOS_TEST_FOR_EXCEPT(!tscs->isInitialized());
55 TEST_FLOATING_EQUALITY (tscs->getConstantTimeStep(), 0.989, 1.0e-14);
65 0.123,
"Full_Construction_Test"));
66 TEUCHOS_TEST_FOR_EXCEPT(!tscs->isInitialized());
68 TEUCHOS_TEST_FOR_EXCEPT(tscs->getStrategyType() !=
"Constant");
69 TEUCHOS_TEST_FOR_EXCEPT(tscs->getStepType() !=
"Constant");
70 TEUCHOS_TEST_FOR_EXCEPT(tscs->getName() !=
"Full_Construction_Test");
71 TEST_FLOATING_EQUALITY (tscs->getConstantTimeStep(), 0.123, 1.0e-14);
79 auto pl = Tempus::getTimeStepControlStrategyConstantPL<double>();
82 pl->set<
double>(
"Time Step", 0.02);
84 auto tscsc = Tempus::createTimeStepControlStrategyConstant<double>(pl);
85 TEUCHOS_TEST_FOR_EXCEPT(!tscsc->isInitialized());
87 TEST_FLOATING_EQUALITY (tscsc->getConstantTimeStep(), 0.02, 1.0e-14);
96 TEUCHOS_TEST_FOR_EXCEPT(!tscs->isInitialized());
98 double initTime = 1.0;
103 auto inArgsIC = model->getNominalValues();
105 auto icState = Tempus::createSolutionStateX<double>(icSolution);
107 solutionHistory->addState(icState);
108 solutionHistory->getCurrentState()->setTimeStep(0.9);
109 solutionHistory->getCurrentState()->setTime(initTime);
110 solutionHistory->getCurrentState()->setIndex(initIndex);
114 tsc->setTimeStepControlStrategy(tscs);
115 tsc->setInitTime(initTime);
116 tsc->setFinalTime(100.0);
117 tsc->setMinTimeStep(0.01);
118 tsc->setInitTimeStep(0.02);
119 tsc->setMaxTimeStep(0.05);
120 tsc->setInitIndex(initIndex);
121 tsc->setFinalIndex(100);
123 TEUCHOS_TEST_FOR_EXCEPT(!tsc->isInitialized());
127 solutionHistory->initWorkingState();
129 tsc->setNextTimeStep(solutionHistory, status);
132 auto workingState = solutionHistory->getWorkingState();
133 TEST_FLOATING_EQUALITY( workingState->getTimeStep(), 0.02, 1.0e-14);
134 TEST_FLOATING_EQUALITY( workingState->getTime(), 1.02, 1.0e-14);
144 auto pl = tscsc->getValidParameters();
146 TEST_COMPARE ( pl->get<std::string>(
"Strategy Type"), ==,
"Constant");
147 TEST_FLOATING_EQUALITY( pl->get<
double>(
"Time Step"), 0.0, 1.0e-14);
150 std::ostringstream unusedParameters;
151 pl->unused(unusedParameters);
152 TEST_COMPARE ( unusedParameters.str(), ==,
"");
Sine-Cosine model problem from Rythmos. This is a canonical Sine-Cosine differential equation with a...
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...
StepControlStrategy class for TimeStepControl.