12 #include "Tempus_TimeStepControl.hpp"
18 namespace Tempus_Unit_Test {
23 using Teuchos::rcp_const_cast;
24 using Teuchos::rcp_dynamic_cast;
25 using Teuchos::sublist;
33 tscsc->isInitialized());
37 tscsc->addStrategy(tscsConstant);
43 std::vector<Teuchos::RCP<Tempus::TimeStepControlStrategy<double>>>
44 strategies = tscsc->getStrategies();
46 auto strategyConstant =
60 tscsc->isInitialized());
63 tscsc->addStrategy(tscsBasicVS);
66 tscsc->addStrategy(tscsIntCtrl);
72 std::vector<Teuchos::RCP<Tempus::TimeStepControlStrategy<double>>>
73 strategies = tscsc->getStrategies();
75 auto strategyBasicVS =
80 auto strategyIntCtrl = rcp_dynamic_cast<
83 "Integral Controller");
96 tscsc_temp->addStrategy(tscs_BasicVS);
97 tscsc_temp->addStrategy(tscs_IC);
98 tscsc_temp->initialize();
104 auto tscsc = Tempus::createTimeStepControlStrategyComposite<double>(pl);
108 std::vector<Teuchos::RCP<Tempus::TimeStepControlStrategy<double>>>
109 strategies = tscsc->getStrategies();
111 auto strategyBasicVS =
117 TEUCHOS_TEST_FOR_EXCEPT(strategyBasicVS->getReductFactor() != 0.5);
118 TEUCHOS_TEST_FOR_EXCEPT(strategyBasicVS->getMinEta() != 0.0);
119 TEUCHOS_TEST_FOR_EXCEPT(strategyBasicVS->getMaxEta() != 1.0e+16);
121 auto strategyIC = Teuchos::rcp_dynamic_cast<
124 TEUCHOS_TEST_FOR_EXCEPT(strategyIC->getStepType() !=
"Variable");
125 TEUCHOS_TEST_FOR_EXCEPT(strategyIC->getController() !=
"PID");
126 TEUCHOS_TEST_FOR_EXCEPT(strategyIC->getKI() != 0.58);
127 TEUCHOS_TEST_FOR_EXCEPT(strategyIC->getKP() != 0.21);
128 TEUCHOS_TEST_FOR_EXCEPT(strategyIC->getKD() != 0.10);
129 TEUCHOS_TEST_FOR_EXCEPT(strategyIC->getSafetyFactor() != 0.90);
130 TEUCHOS_TEST_FOR_EXCEPT(strategyIC->getSafetyFactorAfterReject() != 0.90);
131 TEUCHOS_TEST_FOR_EXCEPT(strategyIC->getFacMax() != 5.0);
132 TEUCHOS_TEST_FOR_EXCEPT(strategyIC->getFacMin() != 0.5);
145 tscsc_temp->addStrategy(tscs_BasicVS);
146 tscsc_temp->addStrategy(tscs_IC);
147 tscsc_temp->initialize();
150 auto pl = tscsc_temp->getValidParameters();
152 TEST_COMPARE(pl->get<std::string>(
"Strategy Type"), ==,
"Composite");
154 "Basic VS, Integral Controller");
156 TEST_COMPARE(pl->isSublist(
"Integral Controller"), ==,
true);
159 std::ostringstream unusedParameters;
160 pl->unused(unusedParameters);
162 unusedParameters.str(), ==,
163 "WARNING: Parameter \"Basic VS\" [unused] is unused\n"
164 "WARNING: Parameter \"Integral Controller\" [unused] is unused\n");
167 auto BasicVS_PL = pl->sublist(
"Basic VS");
168 TEST_COMPARE(BasicVS_PL.get<std::string>(
"Strategy Type"), ==,
"Basic VS");
174 BasicVS_PL.get<
double>(
"Minimum Value Monitoring Function"), 0.0,
177 BasicVS_PL.get<
double>(
"Maximum Value Monitoring Function"), 1.0e+16,
181 std::ostringstream unusedParameters;
182 BasicVS_PL.unused(unusedParameters);
186 auto IntCtrl_PL = pl->sublist(
"Integral Controller");
187 TEST_COMPARE(IntCtrl_PL.get<std::string>(
"Strategy Type"), ==,
188 "Integral Controller");
189 TEST_COMPARE(IntCtrl_PL.get<std::string>(
"Controller Type"), ==,
"PID");
195 IntCtrl_PL.get<
double>(
"Safety Factor After Step Rejection"), 0.9,
203 std::ostringstream unusedParameters;
204 IntCtrl_PL.unused(unusedParameters);
214 auto pl = Tempus::getTimeStepControlStrategyCompositePL<double>();
216 auto tscsc = Tempus::createTimeStepControlStrategyComposite<double>(pl);
219 std::vector<Teuchos::RCP<Tempus::TimeStepControlStrategy<double>>>
220 strategies = tscsc->getStrategies();
231 auto pl = Tempus::getTimeStepControlStrategyCompositePL<double>();
232 pl->set(
"Strategy List",
"");
233 pl->remove(
"Constant");
235 auto tscsc = Tempus::createTimeStepControlStrategyComposite<double>(pl);
237 tscsc->isInitialized());
241 TEUCHOS_TEST_FOR_EXCEPT(!(tscsc->getStrategyType() ==
"Composite"));
242 TEUCHOS_TEST_FOR_EXCEPT(!(tscsc->getStrategies().size() == 0));
246 auto pl = Tempus::getTimeStepControlStrategyCompositePL<double>();
247 pl->remove(
"Constant");
248 pl->set(
"Strategy List",
"Application Strategy");
250 auto nonTempusStrategyPL = Teuchos::parameterList(
"Application Strategy");
251 nonTempusStrategyPL->set<std::string>(
"Strategy Type",
252 "Application Strategy");
253 nonTempusStrategyPL->set<
double>(
"Secret Sauce", 1.2345);
254 pl->set(
"Application Strategy", *nonTempusStrategyPL);
256 auto tscsc = Tempus::createTimeStepControlStrategyComposite<double>(pl);
258 tscsc->isInitialized());
262 TEUCHOS_TEST_FOR_EXCEPT(!(tscsc->getStrategyType() ==
"Composite"));
263 TEUCHOS_TEST_FOR_EXCEPT(!(tscsc->getStrategies().size() == 0));
272 temp->addStrategy(tscsBasicVS);
275 temp->addStrategy(tscsIntCtrl);
280 auto sList = pl->
get<std::string>(
"Strategy List");
281 pl->set(
"Strategy List", sList +
", Application Strategy");
283 auto nonTempusStrategyPL = Teuchos::parameterList(
"Application Strategy");
284 nonTempusStrategyPL->set<std::string>(
"Strategy Type",
285 "Application Strategy");
286 nonTempusStrategyPL->set<
double>(
"Secret Sauce", 1.2345);
287 pl->set(
"Application Strategy", *nonTempusStrategyPL);
289 auto tscsc = Tempus::createTimeStepControlStrategyComposite<double>(pl);
294 TEUCHOS_TEST_FOR_EXCEPT(!(tscsc->getStrategyType() ==
"Composite"));
295 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)