15 #include "Teuchos_ParameterListExceptions.hpp"
17 namespace panzer_stk {
21 , condPrefix_(
"Periodic Condition ")
22 , searchStr_(
"Use BBox Search")
23 , useBBoxSearch_(false)
27 const std::vector<Teuchos::RCP<const PeriodicBC_MatcherBase> > &
41 bool validEntry =
false;
44 "Error, the parameter {name=\"" <<
countStr_ <<
"\","
46 "\nis required in parameter (sub)list \""<< pl->
name() <<
"\"."
47 "\n\nThe valid parameters and types are:\n"
58 for(
int i=1;i<=numBCs;i++) {
62 std::string cond = pl->
get<std::string>(ss.str());
65 std::string matcherType = matcherPair.first;
66 unsigned int matcherDim = matcherPair.second;
67 if(matcherType ==
"coord"){
69 }
else if(matcherType ==
"edge")
71 else if(matcherType ==
"face")
73 else if(matcherType ==
"all"){
105 if(pl==Teuchos::null) {
106 std::stringstream ss;
111 "Number of set periodic boundary conditions");
112 pl->
set<std::string>(ss.str(),
"MatchCondition bndry1;bndry2",
113 "Boundary condition pairs formatted: <MatchCondition> <bndry1>;<bndry2>");
115 pl->
set<
bool>(
searchStr_,
false,
"Use bounding box search for GID match (requires STKSearch) or not");
124 "PeriodicBC requires a positive number (or none) of periodic boundary conditions.");
129 pl->
set<
bool>(
searchStr_,
false,
"Use bounding box search for GID match (requires STKSearch) or not");
131 for(
int k=1;k<=count;k++) {
132 std::stringstream ss;
135 pl->
set<std::string>(ss.str(),
"MatchCondition bndry1;bndry2");
146 std::string::size_type beg = s.find_first_not_of(
' ');
148 return s.substr(beg,s.length()-beg);
153 std::string::size_type
end = s.find_last_not_of(
' ');
155 return s.substr(0,end+1);
158 static std::string
trim(
const std::string & s)
167 std::string::size_type endMatch = buildStr.find_first_of(
' ');
169 std::string matcher =
trim(buildStr.substr(0,endMatch));
171 std::string::size_type hyphenMatch = matcher.find_last_of(
'-');
174 "Failed parsing parameter list: could not find periodic boundary "
175 "condition matcher \"" << matcher <<
"\" "
176 "in string \"" << buildStr <<
"\n"
177 "Matcher " << matcher <<
" requires a hyphen, e.g. x-coord, yz-edge\"");
179 std::string matcherType =
trim(matcher.substr(hyphenMatch+1,matcher.length()));
181 TEUCHOS_TEST_FOR_EXCEPTION((matcherType !=
"coord") && (matcherType !=
"edge") && (matcherType !=
"face") && (matcherType !=
"all"),std::logic_error,
182 "Failed parsing parameter list: could not find periodic boundary "
183 "condition matcher \"" << matcher <<
"\" "
184 "in string \"" << buildStr <<
"\n"
185 "Type " << matcherType <<
" is not a valid boundary condition type. Must be coord, edge, face, or all\"");
187 std::string matcherCoord =
trim(matcher.substr(0,hyphenMatch));
188 unsigned int matcherDim = 3;
189 if((matcherCoord ==
"x") || (matcherCoord ==
"y") || (matcherCoord ==
"z"))
192 return std::make_pair(matcherType,matcherDim);
197 std::string::size_type allPosition = buildStr.find(
"all");
199 std::string beforeType =
trim(buildStr.substr(0,allPosition));
200 std::string afterType =
trim(buildStr.substr(allPosition+3,buildStr.length()));
202 return beforeType + matcherType +
" " + afterType;
206 std::string & matcher,
207 std::string & bndry1,
208 std::string & bndry2)
const
210 std::string::size_type endMatch = buildStr.find_first_of(
' ');
211 std::string::size_type begBndry = buildStr.find_first_of(
';');
213 matcher =
trim(buildStr.substr(0,endMatch));
214 bndry1 =
trim(buildStr.substr(endMatch,begBndry-endMatch));
215 bndry2 =
trim(buildStr.substr(begBndry+1,buildStr.length()));
219 std::string & matcher,
220 std::vector<std::string> & params,
221 std::string & bndry1,
222 std::string & bndry2)
const
224 std::string::size_type endMatchAndParams = buildStr.find_first_of(
':');
225 std::string::size_type begBndry = buildStr.find_first_of(
';');
228 if(endMatchAndParams==std::string::npos) {
233 bndry1 =
trim(buildStr.substr(endMatchAndParams+1,begBndry-(endMatchAndParams+1)));
234 bndry2 =
trim(buildStr.substr(begBndry+1,buildStr.length()));
236 std::string matchAndParams =
trim(buildStr.substr(0,endMatchAndParams));
237 std::string::size_type endMatch = matchAndParams.find_first_of(
' ');
240 if(endMatch==std::string::npos) {
241 matcher = matchAndParams;
249 matcher =
trim(matchAndParams.substr(0,endMatch));
250 matchAndParams = matchAndParams.substr(endMatch+1);
252 std::string::size_type comma = matchAndParams.find_first_of(
',');
253 while(comma!=std::string::npos) {
254 std::string p =
trim(matchAndParams.substr(0,comma));
257 "Error parsing periodic boundary condition \"" + buildStr +
"\"");
260 matchAndParams = matchAndParams.substr(comma+1);
261 comma = matchAndParams.find_first_of(
',');
264 std::string finalParam =
trim(matchAndParams);
265 if(finalParam.length()>0)
266 params.push_back(finalParam);
274 std::vector<std::string> params;
275 std::string s_matcher, bndry1, bndry2;
279 if(s_matcher==
"x-coord") {
284 if(s_matcher==
"y-coord") {
289 if(s_matcher==
"z-coord") {
294 if(s_matcher==
"x-edge") {
299 if(s_matcher==
"y-edge") {
304 if(s_matcher==
"z-edge") {
309 if(s_matcher==
"xy-coord" || s_matcher==
"yx-coord") {
314 if(s_matcher==
"xz-coord" || s_matcher==
"zx-coord") {
319 if(s_matcher==
"yz-coord" || s_matcher==
"zy-coord") {
324 if(s_matcher==
"xy-edge" || s_matcher==
"yx-edge") {
329 if(s_matcher==
"xz-edge" || s_matcher==
"zx-edge") {
334 if(s_matcher==
"yz-edge" || s_matcher==
"zy-edge") {
339 if(s_matcher==
"xy-face" || s_matcher==
"yx-face") {
344 if(s_matcher==
"xz-face" || s_matcher==
"zx-face") {
349 if(s_matcher==
"yz-face" || s_matcher==
"zy-face") {
354 if(s_matcher==
"wx-coord") {
359 if(s_matcher==
"wy-coord") {
364 if(s_matcher==
"wx-edge") {
369 if(s_matcher==
"wy-edge") {
374 if(s_matcher==
"wx-face") {
379 if(s_matcher==
"wy-face") {
384 if(s_matcher==
"(xy)z-quarter-coord") {
389 if(s_matcher==
"(yx)z-quarter-coord") {
394 if(s_matcher==
"(xz)y-quarter-coord") {
399 if(s_matcher==
"(zx)y-quarter-coord") {
404 if(s_matcher==
"(yz)x-quarter-coord") {
409 if(s_matcher==
"(zy)x-quarter-coord") {
415 "Failed parsing parameter list: could not find periodic boundary "
416 "condition matcher \"" << s_matcher <<
"\" "
417 "in string \"" << buildStr <<
"\"");
419 return Teuchos::null;
bool buildMatcher_Tokenize_withParams(const std::string &buildStr, std::string &matcher, std::vector< std::string > ¶ms, std::string &bndry1, std::string &bndry2) const
RCP< const T > getConst() const
const std::string & name() const
const std::string countStr_
std::string currentParametersString() const
T & get(const std::string &name, T def_value)
void setParameterList(const Teuchos::RCP< Teuchos::ParameterList > &pl)
#define TEUCHOS_TEST_FOR_EXCEPTION(throw_exception_test, Exception, msg)
Teuchos::RCP< Teuchos::ParameterList > storedPL_
stored parameter list
ParameterList & set(std::string const &name, T &&value, std::string const &docString="", RCP< const ParameterEntryValidator > const &validator=null)
static std::string trim_right(const std::string &s)
std::vector< Teuchos::RCP< const PeriodicBC_MatcherBase > > faceMatchers_
std::vector< Teuchos::RCP< const PeriodicBC_MatcherBase > > matchers_
matchers constructed by "setParameterList"
bool isParameter(const std::string &name) const
const std::vector< Teuchos::RCP< const PeriodicBC_MatcherBase > > & getMatchers() const
Teuchos::RCP< const Teuchos::ParameterList > getValidParameters() const
const std::string condPrefix_
TEUCHOS_DEPRECATED RCP< T > rcp(T *p, Dealloc_T dealloc, bool owns_mem)
Teuchos::RCP< Teuchos::ParameterList > unsetParameterList()
std::vector< Teuchos::RCP< const PeriodicBC_MatcherBase > > edgeMatchers_
void buildMatcher_Tokenize(const std::string &buildStr, std::string &matcher, std::string &bndry1, std::string &bndry2) const
std::string replaceMatcherType(const std::string &buildStr, const std::string &matcherType) const
static std::string trim_left(const std::string &s)
const std::string searchStr_
void validateParameters(ParameterList const &validParamList, int const depth=1000, EValidateUsed const validateUsed=VALIDATE_USED_ENABLED, EValidateDefaults const validateDefaults=VALIDATE_DEFAULTS_ENABLED) const
const bool & useBoundingBoxSearch() const
Teuchos::RCP< PeriodicBC_MatcherBase > buildPeriodicBC_Matcher(const std::string &left, const std::string &right, const Matcher &matcher, const std::string type="coord")
static std::string trim(const std::string &s)
std::pair< std::string, unsigned int > getMatcherTypeAndDim(const std::string &buildStr) const
Teuchos::RCP< Teuchos::ParameterList > getNonconstParameterList()
Teuchos::RCP< const PeriodicBC_MatcherBase > buildMatcher(const std::string &buildStr) const
#define TEUCHOS_TEST_FOR_EXCEPTION_PURE_MSG(throw_exception_test, Exception, msg)