187 Teuchos::RCP<Teuchos::ParameterList>
const& pList,
188 std::string name =
"Composite")
191 using Teuchos::ParameterList;
193 std::vector<std::string> tscsList;
195 TEUCHOS_TEST_FOR_EXCEPTION(
196 pList->get<std::string>(
"Strategy Type") !=
"Composite", std::logic_error,
197 "Error - Strategy Type != 'Composite'. (='"
198 +pList->get<std::string>(
"Strategy Type")+
"')\n");
202 std::string str = pList->get<std::string>(
"Strategy List");
203 std::string delimiters(
",");
204 const char* WhiteSpace =
" \t\v\r\n";
206 std::string::size_type lastPos = str.find_first_not_of(delimiters, 0);
208 std::string::size_type pos = str.find_first_of(delimiters, lastPos);
209 while ((pos != std::string::npos) || (lastPos != std::string::npos)) {
211 std::string token = str.substr(lastPos,pos-lastPos);
213 std::size_t start = token.find_first_not_of(WhiteSpace);
214 std::size_t end = token.find_last_not_of(WhiteSpace);
215 token = (start == end ? std::string() : token.substr(start, end-start+1));
217 tscsList.push_back(token);
218 if(pos==std::string::npos)
break;
220 lastPos = str.find_first_not_of(delimiters, pos);
221 pos = str.find_first_of(delimiters, lastPos);
224 auto tscsc = Teuchos::rcp(
new TimeStepControlStrategyComposite<Scalar>());
227 for (
auto tscsName: tscsList) {
228 RCP<ParameterList> pl =
229 Teuchos::rcp(
new ParameterList(pList->sublist(tscsName,
true)));
231 auto strategyType = pl->get<std::string>(
"Strategy Type",
"Unknown");
232 if (strategyType ==
"Constant") {
234 createTimeStepControlStrategyConstant<Scalar>(pl, tscsName));
235 }
else if (strategyType ==
"Basic VS") {
237 createTimeStepControlStrategyBasicVS<Scalar>(pl, tscsName));
238 }
else if (strategyType ==
"Integral Controller") {
240 createTimeStepControlStrategyIntegralController<Scalar>(pl, tscsName));
241 }
else if (strategyType ==
"Composite") {
243 createTimeStepControlStrategyComposite<Scalar>(pl, tscsName));
245 RCP<Teuchos::FancyOStream> out =
246 Teuchos::fancyOStream(Teuchos::rcpFromRef(std::cout));
247 out->setOutputToRootOnly(0);
248 Teuchos::OSTab ostab(out,1,
"createTimeStepControlStrategyComposite()");
249 *out <<
"Warning -- Unknown strategy type!\n"
250 <<
"'Strategy Type' = '" << strategyType <<
"'\n"
251 <<
"Should call addStrategy() with this\n"
252 <<
"(app-specific?) strategy, and initialize().\n" << std::endl;
257 tscsc->setName(name);
259 if (tscsc->size() == 0) {
260 RCP<Teuchos::FancyOStream> out =
261 Teuchos::fancyOStream(Teuchos::rcpFromRef(std::cout));
262 out->setOutputToRootOnly(0);
263 Teuchos::OSTab ostab(out,1,
"createTimeStepControlStrategyComposite()");
264 *out <<
"Warning -- Did not find a Tempus strategy to create!\n"
265 <<
"Should call addStrategy() with (app-specific?) strategy(ies),\n"
266 <<
"and initialize().\n" << std::endl;