47 #include "Teuchos_ParameterListExceptions.hpp"
49 namespace panzer_stk {
53 , condPrefix_(
"Periodic Condition ")
54 , searchStr_(
"Use BBox Search")
55 , useBBoxSearch_(false)
59 const std::vector<Teuchos::RCP<const PeriodicBC_MatcherBase> > &
73 bool validEntry =
false;
76 "Error, the parameter {name=\"" <<
countStr_ <<
"\","
78 "\nis required in parameter (sub)list \""<< pl->
name() <<
"\"."
79 "\n\nThe valid parameters and types are:\n"
90 for(
int i=1;i<=numBCs;i++) {
94 std::string cond = pl->
get<std::string>(ss.str());
97 std::string matcherType = matcherPair.first;
98 unsigned int matcherDim = matcherPair.second;
99 if(matcherType ==
"coord"){
101 }
else if(matcherType ==
"edge")
103 else if(matcherType ==
"face")
105 else if(matcherType ==
"all"){
137 if(pl==Teuchos::null) {
138 std::stringstream ss;
143 "Number of set periodic boundary conditions");
144 pl->
set<std::string>(ss.str(),
"MatchCondition bndry1;bndry2",
145 "Boundary condition pairs formatted: <MatchCondition> <bndry1>;<bndry2>");
147 pl->
set<
bool>(
searchStr_,
false,
"Use bounding box search for GID match (requires STKSearch) or not");
156 "PeriodicBC requires a positive number (or none) of periodic boundary conditions.");
161 pl->
set<
bool>(
searchStr_,
false,
"Use bounding box search for GID match (requires STKSearch) or not");
163 for(
int k=1;k<=count;k++) {
164 std::stringstream ss;
167 pl->
set<std::string>(ss.str(),
"MatchCondition bndry1;bndry2");
178 std::string::size_type beg = s.find_first_not_of(
' ');
180 return s.substr(beg,s.length()-beg);
185 std::string::size_type
end = s.find_last_not_of(
' ');
187 return s.substr(0,end+1);
190 static std::string
trim(
const std::string & s)
199 std::string::size_type endMatch = buildStr.find_first_of(
' ');
201 std::string matcher =
trim(buildStr.substr(0,endMatch));
203 std::string::size_type hyphenMatch = matcher.find_last_of(
'-');
206 "Failed parsing parameter list: could not find periodic boundary "
207 "condition matcher \"" << matcher <<
"\" "
208 "in string \"" << buildStr <<
"\n"
209 "Matcher " << matcher <<
" requires a hyphen, e.g. x-coord, yz-edge\"");
211 std::string matcherType =
trim(matcher.substr(hyphenMatch+1,matcher.length()));
213 TEUCHOS_TEST_FOR_EXCEPTION((matcherType !=
"coord") && (matcherType !=
"edge") && (matcherType !=
"face") && (matcherType !=
"all"),std::logic_error,
214 "Failed parsing parameter list: could not find periodic boundary "
215 "condition matcher \"" << matcher <<
"\" "
216 "in string \"" << buildStr <<
"\n"
217 "Type " << matcherType <<
" is not a valid boundary condition type. Must be coord, edge, face, or all\"");
219 std::string matcherCoord =
trim(matcher.substr(0,hyphenMatch));
220 unsigned int matcherDim = 3;
221 if((matcherCoord ==
"x") || (matcherCoord ==
"y") || (matcherCoord ==
"z"))
224 return std::make_pair(matcherType,matcherDim);
229 std::string::size_type allPosition = buildStr.find(
"all");
231 std::string beforeType =
trim(buildStr.substr(0,allPosition));
232 std::string afterType =
trim(buildStr.substr(allPosition+3,buildStr.length()));
234 return beforeType + matcherType +
" " + afterType;
238 std::string & matcher,
239 std::string & bndry1,
240 std::string & bndry2)
const
242 std::string::size_type endMatch = buildStr.find_first_of(
' ');
243 std::string::size_type begBndry = buildStr.find_first_of(
';');
245 matcher =
trim(buildStr.substr(0,endMatch));
246 bndry1 =
trim(buildStr.substr(endMatch,begBndry-endMatch));
247 bndry2 =
trim(buildStr.substr(begBndry+1,buildStr.length()));
251 std::string & matcher,
252 std::vector<std::string> & params,
253 std::string & bndry1,
254 std::string & bndry2)
const
256 std::string::size_type endMatchAndParams = buildStr.find_first_of(
':');
257 std::string::size_type begBndry = buildStr.find_first_of(
';');
260 if(endMatchAndParams==std::string::npos) {
265 bndry1 =
trim(buildStr.substr(endMatchAndParams+1,begBndry-(endMatchAndParams+1)));
266 bndry2 =
trim(buildStr.substr(begBndry+1,buildStr.length()));
268 std::string matchAndParams =
trim(buildStr.substr(0,endMatchAndParams));
269 std::string::size_type endMatch = matchAndParams.find_first_of(
' ');
272 if(endMatch==std::string::npos) {
273 matcher = matchAndParams;
281 matcher =
trim(matchAndParams.substr(0,endMatch));
282 matchAndParams = matchAndParams.substr(endMatch+1);
284 std::string::size_type comma = matchAndParams.find_first_of(
',');
285 while(comma!=std::string::npos) {
286 std::string p =
trim(matchAndParams.substr(0,comma));
289 "Error parsing periodic boundary condition \"" + buildStr +
"\"");
292 matchAndParams = matchAndParams.substr(comma+1);
293 comma = matchAndParams.find_first_of(
',');
296 std::string finalParam =
trim(matchAndParams);
297 if(finalParam.length()>0)
298 params.push_back(finalParam);
306 std::vector<std::string> params;
307 std::string s_matcher, bndry1, bndry2;
311 if(s_matcher==
"x-coord") {
316 if(s_matcher==
"y-coord") {
321 if(s_matcher==
"z-coord") {
326 if(s_matcher==
"x-edge") {
331 if(s_matcher==
"y-edge") {
336 if(s_matcher==
"z-edge") {
341 if(s_matcher==
"xy-coord" || s_matcher==
"yx-coord") {
346 if(s_matcher==
"xz-coord" || s_matcher==
"zx-coord") {
351 if(s_matcher==
"yz-coord" || s_matcher==
"zy-coord") {
356 if(s_matcher==
"xy-edge" || s_matcher==
"yx-edge") {
361 if(s_matcher==
"xz-edge" || s_matcher==
"zx-edge") {
366 if(s_matcher==
"yz-edge" || s_matcher==
"zy-edge") {
371 if(s_matcher==
"xy-face" || s_matcher==
"yx-face") {
376 if(s_matcher==
"xz-face" || s_matcher==
"zx-face") {
381 if(s_matcher==
"yz-face" || s_matcher==
"zy-face") {
386 if(s_matcher==
"wx-coord") {
391 if(s_matcher==
"wy-coord") {
396 if(s_matcher==
"wx-edge") {
401 if(s_matcher==
"wy-edge") {
406 if(s_matcher==
"wx-face") {
411 if(s_matcher==
"wy-face") {
416 if(s_matcher==
"(xy)z-quarter-coord") {
421 if(s_matcher==
"(yx)z-quarter-coord") {
426 if(s_matcher==
"(xz)y-quarter-coord") {
431 if(s_matcher==
"(zx)y-quarter-coord") {
436 if(s_matcher==
"(yz)x-quarter-coord") {
441 if(s_matcher==
"(zy)x-quarter-coord") {
447 "Failed parsing parameter list: could not find periodic boundary "
448 "condition matcher \"" << s_matcher <<
"\" "
449 "in string \"" << buildStr <<
"\"");
451 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)
ParameterList & set(std::string const &name, T const &value, std::string const &docString="", RCP< const ParameterEntryValidator > const &validator=null)
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
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)