11#ifndef __Panzer_STK_PeriodicBC_MatchConditions_hpp__
12#define __Panzer_STK_PeriodicBC_MatchConditions_hpp__
14#include "Teuchos_Tuple.hpp"
34 std::string errStr =
"CoordMatcher \"" + std::string(1,
labels_[
index_]) +
"-coord\" takes at most two parameters <tol, relative>";
35 TEUCHOS_TEST_FOR_EXCEPTION(params.size()>2,std::logic_error,errStr);
43 std::string errStr2 = params[1] +
" is not a valid periodic option (try \"relative\")";
44 TEUCHOS_TEST_FOR_EXCEPTION(params[1]!=
"relative",std::logic_error,errStr2);
65 const Teuchos::Tuple<double,3> & b)
const
89 TEUCHOS_ASSERT(
index_ != 2);
99 void transform(
double * ptB,
const std::vector<double> & centroidA)
const
107 ptB[periodicIndex] = centroidA[periodicIndex];
127 +
"-coord\" takes at most two parameter <tol, relative>";
128 TEUCHOS_TEST_FOR_EXCEPTION(params.size()>2,std::logic_error,errStr);
131 if(params.size()>0) {
132 std::stringstream ss;
135 if(params.size()==2){
136 if (params[1] ==
"3D") {
138 std::cout <<
"WARNING : Keyword " << params[1] <<
" not needed for PlaneMatcher" << std::endl;
141 std::string errStr2 = params[1] +
" is not a valid periodic option (try \"relative\")";
142 TEUCHOS_TEST_FOR_EXCEPTION(params[1]!=
"relative",std::logic_error,errStr2);
160 PlaneMatcher(
int index0,
int index1,
const std::vector<std::string> & params)
170 const Teuchos::Tuple<double,3> & b)
const
182 std::stringstream ss;
218 void transform(
double * ptB,
const std::vector<double> & centroidA)
const
227 ptB[periodicIndex] = centroidA[periodicIndex];
246 +
"-quarter-coord\" takes only one parameter <tol>";
247 TEUCHOS_TEST_FOR_EXCEPTION(params.size()>1,std::logic_error,errStr);
250 if(params.size()==1) {
251 std::stringstream ss;
262 { TEUCHOS_ASSERT(index0a!=index1); TEUCHOS_ASSERT(index0b!=index1);
buildLabels(); }
267 { TEUCHOS_ASSERT(index0a!=index1); TEUCHOS_ASSERT(index0b!=index1);
buildLabels(); }
281 const Teuchos::Tuple<double,3> & b)
const
288 std::stringstream ss;
297 void transform(
double * ptB,
const std::vector<double> & centroidA)
const
346 TEUCHOS_TEST_FOR_EXCEPTION(params.size() > 2,std::logic_error,
"WedgeMatcher can only have one or two option parameters (tolerance and dimension)!");
349 if (params.size() > 0)
350 error_ = std::stod(params[0]);
352 if (params.size() > 1) {
353 if (params[1] ==
"2D")
355 else if (params[1] ==
"3D")
358 TEUCHOS_TEST_FOR_EXCEPTION(
true,std::runtime_error,
"ERROR: WedgeMatcher::parsParams() - the second params must be iether \"2D\" or \"3D\", param=" << params[1] <<
"\n");
367 const Teuchos::Tuple<double,3> & b)
const
372 (std::fabs(a[2]-b[2])<
error_) );
383 std::stringstream ss;
385 ss <<
"wy-coord <tol=" <<
error_ <<
">";
387 ss <<
"wx-coord <tol=" <<
error_ <<
">";
409 void transform(
double * ptB,
const std::vector<double> & centroidA)
const
void parseParams(const std::vector< std::string > ¶ms)
bool operator()(const Teuchos::Tuple< double, 3 > &a, const Teuchos::Tuple< double, 3 > &b) const
Returns true if points a and b match, i.e. their coordinates in the compared direction are within tol...
CoordMatcher(int index, const std::vector< std::string > ¶ms)
Construct with tolerance and "relative" option parsed from strings, as accepted by parseParams().
std::string getString() const
Returns a human-readable description of this matcher's compared coordinate and tolerance.
void transform(double *ptB, const std::vector< double > ¢roidA) const
Shifts ptB's periodic-direction coordinate to match centroidA's, in place.
CoordMatcher(int index)
Constructor where the index is the coordinate axis that will be compared to find matching nodes.
int getIndex() const
Returns the coordinate axis/direction being compared.
CoordMatcher(int index, double error)
Construct with an explicit absolute tolerance.
CoordMatcher(const CoordMatcher &cm)
Copy constructor.
double getAbsoluteTolerance() const
Returns the absolute matching tolerance.
int getPeriodicDirection() const
Returns the direction (0=x, 1=y) in which the boundary condition is periodic; the direction orthogona...
bool operator()(const Teuchos::Tuple< double, 3 > &a, const Teuchos::Tuple< double, 3 > &b) const
Returns true if points a and b match, i.e. their coordinates in both compared directions are within t...
PlaneMatcher(int index0, int index1)
index0 and index1 are the two coordinate directions defining the plane compared to find matching node...
PlaneMatcher(int index0, int index1, double error)
Construct with an explicit absolute tolerance.
int getIndex0() const
Returns the first coordinate direction being compared.
double getAbsoluteTolerance() const
Returns the absolute matching tolerance.
PlaneMatcher(int index0, int index1, const std::vector< std::string > ¶ms)
Construct with tolerance and "relative" option parsed from strings, as accepted by parseParams().
void transform(double *ptB, const std::vector< double > ¢roidA) const
Shifts ptB's periodic-direction coordinate to match centroidA's, in place.
PlaneMatcher(const PlaneMatcher &cm)
Copy constructor.
std::string getString() const
Returns a human-readable description of this matcher's compared coordinates and tolerance.
int getPeriodicDirection() const
Returns the direction orthogonal to the compared plane, in which the boundary condition is periodic.
void parseParams(const std::vector< std::string > ¶ms)
int getIndex1() const
Returns the second coordinate direction being compared.
QuarterPlaneMatcher(int index0a, int index0b, int index1)
index0a/index0b are the coordinate directions compared across the two quarter-symmetry planes; index1...
std::string getString() const
Returns a human-readable description of this matcher's compared coordinates and tolerance.
double getAbsoluteTolerance() const
Returns the absolute matching tolerance.
void transform(double *ptB, const std::vector< double > ¢roidA) const
Shifts ptB in place to reflect it into plane A's quarter-symmetry orientation, given plane A's centro...
QuarterPlaneMatcher(int index0a, int index0b, int index1, const std::vector< std::string > ¶ms)
Construct with tolerance parsed from strings, as accepted by parseParams().
QuarterPlaneMatcher(int index0a, int index0b, int index1, double error)
Construct with an explicit absolute tolerance.
QuarterPlaneMatcher(const QuarterPlaneMatcher &cm)
Copy constructor.
void parseParams(const std::vector< std::string > ¶ms)
bool operator()(const Teuchos::Tuple< double, 3 > &a, const Teuchos::Tuple< double, 3 > &b) const
Returns true if points a and b match across the quarter-symmetry planes, within tolerance.
int index0_
index to compare - 0 for wy (mirrored over yz), 1 for wx (mirrored over xz)
bool operator()(const Teuchos::Tuple< double, 3 > &a, const Teuchos::Tuple< double, 3 > &b) const
Returns true if points a and b match across the mirror plane, within tolerance.
WedgeMatcher::MirrorPlane getMirrorPlane() const
Returns which plane the wedge is mirrored over.
bool is_three_d_
Set to true if a 3D problem, set to false if 2D.
WedgeMatcher(const WedgeMatcher &cm)=default
Copy constructor.
std::string getString() const
Returns a human-readable description of this matcher's mirror plane and tolerance.
void transform(double *ptB, const std::vector< double > ¢roidA) const
Mirrors ptB's compared coordinate over the mirror plane, in place.
int getIndex() const
Returns the coordinate direction being compared.
WedgeMatcher(MirrorPlane mp, const std::vector< std::string > ¶ms)
Construct for the given mirror plane, with tolerance and dimensionality ("2D"/"3D") options parsed fr...
bool isThreeD() const
Returns true if this matcher was constructed for a 3D problem.
double getAbsoluteTolerance() const
Returns the absolute matching tolerance.