47 #include "Teuchos_ParameterListExceptions.hpp" 53 , condPrefix_(
"Periodic Condition ")
57 const std::vector<Teuchos::RCP<const PeriodicBC_MatcherBase> > &
66 bool validEntry =
false;
69 "Error, the parameter {name=\"" <<
countStr_ <<
"\"," 71 "\nis required in parameter (sub)list \""<< pl->
name() <<
"\"." 72 "\n\nThe valid parameters and types are:\n" 82 for(
int i=1;i<=numBCs;i++) {
86 std::string cond = pl->
get<std::string>(ss.str());
110 if(pl==Teuchos::null) {
111 std::stringstream ss;
116 "Number of set periodic boundary conditions");
117 pl->
set<std::string>(ss.str(),
"MatchCondition bndry1;bndry2",
118 "Boundary condition fairs formatted: <MatchCondition> <bndry1>;<bndry2>");
127 "PeriodicBC requires a positive number (or none) of periodic boundary conditions.");
132 for(
int k=1;k<=count;k++) {
133 std::stringstream ss;
136 pl->
set<std::string>(ss.str(),
"MatchCondition bndry1;bndry2");
147 std::string::size_type beg = s.find_first_not_of(
' ');
149 return s.substr(beg,s.length()-beg);
154 std::string::size_type end = s.find_last_not_of(
' ');
156 return s.substr(0,end+1);
159 static std::string
trim(
const std::string & s)
167 std::string & matcher,
168 std::string & bndry1,
169 std::string & bndry2)
const 171 std::string::size_type endMatch = buildStr.find_first_of(
' ');
172 std::string::size_type begBndry = buildStr.find_first_of(
';');
174 matcher =
trim(buildStr.substr(0,endMatch));
175 bndry1 =
trim(buildStr.substr(endMatch,begBndry-endMatch));
176 bndry2 =
trim(buildStr.substr(begBndry+1,buildStr.length()));
180 std::string & matcher,
181 std::vector<std::string> & params,
182 std::string & bndry1,
183 std::string & bndry2)
const 185 std::string::size_type endMatchAndParams = buildStr.find_first_of(
':');
186 std::string::size_type begBndry = buildStr.find_first_of(
';');
189 if(endMatchAndParams==std::string::npos) {
194 bndry1 =
trim(buildStr.substr(endMatchAndParams+1,begBndry-(endMatchAndParams+1)));
195 bndry2 =
trim(buildStr.substr(begBndry+1,buildStr.length()));
197 std::string matchAndParams =
trim(buildStr.substr(0,endMatchAndParams));
198 std::string::size_type endMatch = matchAndParams.find_first_of(
' ');
201 if(endMatch==std::string::npos) {
202 matcher = matchAndParams;
210 matcher =
trim(matchAndParams.substr(0,endMatch));
211 matchAndParams = matchAndParams.substr(endMatch+1);
213 std::string::size_type comma = matchAndParams.find_first_of(
',');
214 while(comma!=std::string::npos) {
215 std::string p =
trim(matchAndParams.substr(0,comma));
218 "Error parsing periodic boundary condition \"" + buildStr +
"\"");
221 matchAndParams = matchAndParams.substr(comma+1);
222 comma = matchAndParams.find_first_of(
',');
225 std::string finalParam =
trim(matchAndParams);
226 if(finalParam.length()>0)
227 params.push_back(finalParam);
235 std::vector<std::string> params;
236 std::string matcher, bndry1, bndry2;
240 if(matcher==
"x-coord") {
245 if(matcher==
"y-coord") {
250 if(matcher==
"z-coord") {
255 if(matcher==
"x-edge") {
260 if(matcher==
"y-edge") {
265 if(matcher==
"z-edge") {
270 if(matcher==
"xy-coord" || matcher==
"yx-coord") {
275 if(matcher==
"xz-coord" || matcher==
"zx-coord") {
280 if(matcher==
"yz-coord" || matcher==
"zy-coord") {
285 if(matcher==
"xy-edge" || matcher==
"yx-edge") {
290 if(matcher==
"xz-edge" || matcher==
"zx-edge") {
295 if(matcher==
"yz-edge" || matcher==
"zy-edge") {
300 if(matcher==
"xy-face" || matcher==
"yx-face") {
305 if(matcher==
"xz-face" || matcher==
"zx-face") {
310 if(matcher==
"yz-face" || matcher==
"zy-face") {
315 if(matcher==
"(xy)z-quarter-coord") {
320 if(matcher==
"(yx)z-quarter-coord") {
325 if(matcher==
"(xz)y-quarter-coord") {
330 if(matcher==
"(zx)y-quarter-coord") {
335 if(matcher==
"(yz)x-quarter-coord") {
340 if(matcher==
"(zy)x-quarter-coord") {
346 "Failed parsing parameter list: could not find periodic boundary " 347 "condition matcher \"" << matcher <<
"\" " 348 "in string \"" << buildStr <<
"\"");
350 return Teuchos::null;
std::string currentParametersString() const
const std::string countStr_
T & get(const std::string &name, T def_value)
void buildMatcher_Tokenize(const std::string &buildStr, std::string &matcher, std::string &bndry1, std::string &bndry2) const
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
Teuchos::RCP< const PeriodicBC_MatcherBase > buildMatcher(const std::string &buildStr) const
Teuchos::RCP< const Teuchos::ParameterList > getValidParameters() const
static std::string trim_right(const std::string &s)
std::vector< Teuchos::RCP< const PeriodicBC_MatcherBase > > matchers_
matchers constructed by "setParameterList"
void validateParameters(ParameterList const &validParamList, int const depth=1000, EValidateUsed const validateUsed=VALIDATE_USED_ENABLED, EValidateDefaults const validateDefaults=VALIDATE_DEFAULTS_ENABLED) const
const std::string condPrefix_
TEUCHOS_DEPRECATED RCP< T > rcp(T *p, Dealloc_T dealloc, bool owns_mem)
Teuchos::RCP< Teuchos::ParameterList > unsetParameterList()
bool buildMatcher_Tokenize_withParams(const std::string &buildStr, std::string &matcher, std::vector< std::string > ¶ms, std::string &bndry1, std::string &bndry2) const
static std::string trim_left(const std::string &s)
const std::string & name() 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)
bool isParameter(const std::string &name) const
Teuchos::RCP< Teuchos::ParameterList > getNonconstParameterList()
RCP< const T > getConst() const
const std::vector< Teuchos::RCP< const PeriodicBC_MatcherBase > > & getMatchers() const
#define TEUCHOS_TEST_FOR_EXCEPTION_PURE_MSG(throw_exception_test, Exception, msg)