12 #include "Teuchos_DefaultComm.hpp"
14 #include "Thyra_VectorStdOps.hpp"
16 #include "Tempus_StepperFactory.hpp"
17 #include "Tempus_TimeStepControl.hpp"
23 #include "../TestModels/SinCosModel.hpp"
24 #include "../TestModels/DahlquistTestModel.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;
49 tscsc->addStrategy(tscsConstant);
55 std::vector<Teuchos::RCP<Tempus::TimeStepControlStrategy<double>>>
56 strategies = tscsc->getStrategies();
73 tscsc->addStrategy(tscsBasicVS);
75 tscsc->addStrategy(tscsIntCtrl);
81 std::vector<Teuchos::RCP<Tempus::TimeStepControlStrategy<double>>>
82 strategies = tscsc->getStrategies();
103 tscsc_temp->addStrategy(tscs_BasicVS);
104 tscsc_temp->addStrategy(tscs_IC);
105 tscsc_temp->initialize();
110 auto tscsc = Tempus::createTimeStepControlStrategyComposite<double>(pl);
114 std::vector<Teuchos::RCP<Tempus::TimeStepControlStrategy<double>>>
115 strategies = tscsc->getStrategies();
121 TEUCHOS_TEST_FOR_EXCEPT(strategyBasicVS->getReductFactor() != 0.5);
122 TEUCHOS_TEST_FOR_EXCEPT(strategyBasicVS->getMinEta() != 0.0);
123 TEUCHOS_TEST_FOR_EXCEPT(strategyBasicVS->getMaxEta() != 1.0e+16);
127 TEUCHOS_TEST_FOR_EXCEPT(strategyIC->getStepType() !=
"Variable");
128 TEUCHOS_TEST_FOR_EXCEPT(strategyIC->getController() !=
"PID");
129 TEUCHOS_TEST_FOR_EXCEPT(strategyIC->getKI() != 0.58);
130 TEUCHOS_TEST_FOR_EXCEPT(strategyIC->getKP() != 0.21);
131 TEUCHOS_TEST_FOR_EXCEPT(strategyIC->getKD() != 0.10);
132 TEUCHOS_TEST_FOR_EXCEPT(strategyIC->getSafetyFactor() != 0.90);
133 TEUCHOS_TEST_FOR_EXCEPT(strategyIC->getSafetyFactorAfterReject() != 0.90);
134 TEUCHOS_TEST_FOR_EXCEPT(strategyIC->getFacMax() != 5.0);
135 TEUCHOS_TEST_FOR_EXCEPT(strategyIC->getFacMin() != 0.5);
148 tscsc_temp->addStrategy(tscs_BasicVS);
149 tscsc_temp->addStrategy(tscs_IC);
150 tscsc_temp->initialize();
153 auto pl = tscsc_temp->getValidParameters();
155 TEST_COMPARE ( pl->get<std::string>(
"Strategy Type"), ==,
"Composite");
156 TEST_COMPARE ( pl->get<std::string>(
"Strategy List"), ==,
"Basic VS, Integral Controller");
158 TEST_COMPARE ( pl->isSublist(
"Integral Controller") , ==,
true);
161 std::ostringstream unusedParameters;
162 pl->unused(unusedParameters);
164 "WARNING: Parameter \"Basic VS\" [unused] is unused\n"
165 "WARNING: Parameter \"Integral Controller\" [unused] is unused\n");
168 auto BasicVS_PL = pl->sublist(
"Basic VS");
169 TEST_COMPARE ( BasicVS_PL.get<std::string>(
"Strategy Type") , ==,
"Basic VS");
176 std::ostringstream unusedParameters;
177 BasicVS_PL.unused(unusedParameters);
181 auto IntCtrl_PL = pl->sublist(
"Integral Controller");
182 TEST_COMPARE ( IntCtrl_PL.get<std::string>(
"Strategy Type") , ==,
"Integral Controller");
183 TEST_COMPARE ( IntCtrl_PL.get<std::string>(
"Controller Type") , ==,
"PID");
193 std::ostringstream unusedParameters;
194 IntCtrl_PL.unused(unusedParameters);
206 auto pl = Tempus::getTimeStepControlStrategyCompositePL<double>();
208 auto tscsc = Tempus::createTimeStepControlStrategyComposite<double>(pl);
211 std::vector<Teuchos::RCP<Tempus::TimeStepControlStrategy<double>>>
212 strategies = tscsc->getStrategies();
223 auto pl = Tempus::getTimeStepControlStrategyCompositePL<double>();
224 pl->set(
"Strategy List",
"");
225 pl->remove(
"Constant");
227 auto tscsc = Tempus::createTimeStepControlStrategyComposite<double>(pl);
232 TEUCHOS_TEST_FOR_EXCEPT(!(tscsc->getStrategyType() ==
"Composite"));
233 TEUCHOS_TEST_FOR_EXCEPT(!(tscsc->getStrategies().size() == 0));
237 auto pl = Tempus::getTimeStepControlStrategyCompositePL<double>();
238 pl->remove(
"Constant");
239 pl->set(
"Strategy List",
"Application Strategy");
241 auto nonTempusStrategyPL =
242 Teuchos::parameterList(
"Application Strategy");
243 nonTempusStrategyPL->set<std::string>(
"Strategy Type",
"Application Strategy");
244 nonTempusStrategyPL->set<
double>(
"Secret Sauce", 1.2345);
245 pl->set(
"Application Strategy", *nonTempusStrategyPL);
247 auto tscsc = Tempus::createTimeStepControlStrategyComposite<double>(pl);
252 TEUCHOS_TEST_FOR_EXCEPT(!(tscsc->getStrategyType() ==
"Composite"));
253 TEUCHOS_TEST_FOR_EXCEPT(!(tscsc->getStrategies().size() == 0));
261 temp->addStrategy(tscsBasicVS);
263 temp->addStrategy(tscsIntCtrl);
267 auto sList = pl->
get<std::string>(
"Strategy List");
268 pl->set(
"Strategy List", sList+
", Application Strategy");
270 auto nonTempusStrategyPL =
271 Teuchos::parameterList(
"Application Strategy");
272 nonTempusStrategyPL->set<std::string>(
"Strategy Type",
"Application Strategy");
273 nonTempusStrategyPL->set<
double>(
"Secret Sauce", 1.2345);
274 pl->set(
"Application Strategy", *nonTempusStrategyPL);
276 auto tscsc = Tempus::createTimeStepControlStrategyComposite<double>(pl);
281 TEUCHOS_TEST_FOR_EXCEPT(!(tscsc->getStrategyType() ==
"Composite"));
282 TEUCHOS_TEST_FOR_EXCEPT(!(tscsc->getStrategies().size() == 2));
T & get(const std::string &name, T def_value)
StepControlStrategy class for TimeStepControl.
#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)
TEUCHOS_UNIT_TEST(BackwardEuler, Default_Construction)
StepControlStrategy class for TimeStepControl.
TimeStepControlStrategyComposite loops over a vector of TimeStepControlStrategies.
StepControlStrategy class for TimeStepControl.
#define TEUCHOS_TEST_FOR_EXCEPT(throw_exception_test)