43 #ifndef __Panzer_STK_PeriodicBC_Matcher_hpp__
44 #define __Panzer_STK_PeriodicBC_Matcher_hpp__
46 #include "Teuchos_Tuple.hpp"
50 #include "PanzerAdaptersSTK_config.hpp"
53 #ifdef PANZER_HAVE_STKSEARCH
54 #include "stk_search/CoarseSearch.hpp"
57 namespace panzer_stk {
63 namespace periodic_helpers {
65 #ifdef PANZER_HAVE_STKSEARCH
67 typedef stk::search::IdentProc<stk::mesh::EntityKey> SearchId;
68 typedef stk::search::Sphere<double> Sphere;
69 typedef std::vector< std::pair<Sphere,SearchId> > SphereIdVector;
70 typedef std::vector<std::pair<SearchId,SearchId> > SearchPairVector;
71 typedef std::vector<std::pair<stk::mesh::EntityKey,stk::mesh::EntityKey> > SearchPairSet;
78 template <
typename Matcher>
81 const STK_Interface & mesh,
82 const Matcher & matcher,
const std::string type_ =
"coord");
84 template <
typename Matcher>
87 const STK_Interface & mesh,
88 const Matcher & matcher,
89 const std::vector<std::pair<std::size_t,std::size_t> > & current,
const std::string type_ =
"coord");
94 std::pair<Teuchos::RCP<std::vector<std::size_t> >,
97 const std::string & sideName,
const std::string type_ =
"coord");
102 std::pair<Teuchos::RCP<std::vector<std::size_t> >,
105 const std::string & sideName,
const std::string type_ =
"coord");
112 const std::string & sideName,
const std::string type_ =
"coord");
118 template <
typename Matcher>
122 const STK_Interface & mesh,
123 const std::string & sideName,
const Matcher & matcher,
const std::string type_ =
"coord");
136 const std::vector<std::pair<std::size_t,std::size_t> > & locallyMatchedIds,
137 const STK_Interface & mesh,
bool failure);
139 #ifdef PANZER_HAVE_STKSEARCH
154 void fillLocalSearchVector(
const STK_Interface & mesh, SphereIdVector & searchVector,
const double & error,
155 const std::string & sideName,
const std::string & type_,
const bool & getGhostedIDs,
156 const std::vector<std::string> & matchedSides, std::vector<SearchId> & potentialIDsToRemap);
158 void fillLocalSearchVector(
const STK_Interface & mesh, SphereIdVector & searchVector,
const double & error,
159 const std::string & sideName,
const std::string & type_,
const bool & getGhostedIDs =
false);
167 const std::vector<double> computeGlobalCentroid(
const STK_Interface & mesh,
const std::string & sideName);
175 template<
typename Matcher>
void
176 transformLocalSearchVector(SphereIdVector & searchVectorSideA,
const Matcher & matcher,
const std::vector<double> & centroidSideB );
192 template <
typename Matcher>
195 const STK_Interface & mesh,
196 const Matcher & matcher,
const std::vector<std::string> & matchedSides,
197 const std::vector<std::pair<size_t,size_t> > & previousMatches,
198 const std::string type_ =
"coord");
200 template <
typename Matcher>
203 const STK_Interface & mesh,
204 const Matcher & matcher,
const std::string type_ =
"coord");
215 void updateMapping(
Teuchos::RCP<std::vector<std::pair<size_t,size_t> > > & currentMatches,
216 const std::vector<std::pair<size_t,size_t> > & previousMatches,
217 const std::vector<SearchId> & IDsToRemap,
const STK_Interface & mesh);
226 void appendMapping(
Teuchos::RCP<std::vector<std::pair<size_t,size_t> > > & currentMatches,
227 const std::vector<std::pair<size_t,size_t> > & previousMatches);
256 const Teuchos::RCP<
const std::vector<std::pair<std::size_t,std::size_t> > > & currentState = Teuchos::null
259 #ifdef PANZER_HAVE_STKSEARCH
279 const Teuchos::RCP<
const std::vector<std::pair<std::size_t,std::size_t> > > & currentState = Teuchos::null
286 virtual std::string
getString()
const = 0;
291 virtual std::string
getType()
const = 0;
301 const T*
getAs()
const {
return dynamic_cast<const T*
>(
this);}
309 template <
typename Matcher>
312 PeriodicBC_Matcher(
const std::string & left,
const std::string & right,
const Matcher & matcher,
const std::string type =
"coord")
329 const Teuchos::RCP<
const std::vector<std::pair<std::size_t,std::size_t> > > & currentState = Teuchos::null
332 if(currentState==Teuchos::null)
338 #ifdef PANZER_HAVE_STKSEARCH
357 const Teuchos::RCP<
const std::vector<std::pair<std::size_t,std::size_t> > > & currentState = Teuchos::null
360 if(currentState==Teuchos::null)
369 std::stringstream ss;
370 ss <<
"condition: " <<
matcher_.getString() <<
", sides = [ "
371 <<
"\"" <<
left_ <<
"\", "
372 <<
"\"" <<
right_ <<
"\" ]";
404 template <
typename Matcher>
406 buildPeriodicBC_Matcher(
const std::string & left,
const std::string & right,
const Matcher & matcher,
const std::string type =
"coord")
413 #ifdef PANZER_HAVE_STKSEARCH
PeriodicBC_Matcher(const std::string &left, const std::string &right, const Matcher &matcher, const std::string type="coord")
virtual ~PeriodicBC_MatcherBase()
const Matcher & getMatcher() const
Teuchos::RCP< std::vector< std::size_t > > getLocalSideIds(const STK_Interface &mesh, const std::string &sideName, const std::string type_)
Teuchos::RCP< std::vector< std::pair< std::size_t, std::size_t > > > matchPeriodicSides(const std::string &left, const std::string &right, const STK_Interface &mesh, const Matcher &matcher, const std::string type_="coord")
Teuchos::RCP< std::vector< std::pair< size_t, size_t > > > matchPeriodicSidesSearch(const std::string &sideA, const std::string &sideB, const STK_Interface &mesh, const Matcher &matcher, const std::string type_)
virtual std::string getString() const =0
void transformLocalSearchVector(SphereIdVector &searchVectorSideA, const Matcher &matcher, const std::vector< double > ¢roidSideB)
PeriodicBC_Matcher(const PeriodicBC_Matcher &src)
std::pair< Teuchos::RCP< std::vector< std::size_t > >, Teuchos::RCP< std::vector< Teuchos::Tuple< double, 3 > > > > getLocalSideIdsAndCoords(const STK_Interface &mesh, const std::string &sideName, const std::string type_)
std::string getLeftSidesetName() const
Returns the sideset name for the left side.
TEUCHOS_DEPRECATED RCP< T > rcp(T *p, Dealloc_T dealloc, bool owns_mem)
virtual std::string getLeftSidesetName() const =0
Returns the sideset name for the left side.
std::string getString() const
Teuchos::RCP< PeriodicBC_MatcherBase > buildPeriodicBC_Matcher(const std::string &left, const std::string &right, const Matcher &matcher, const std::string type="coord")
std::string getType() const
Teuchos::RCP< std::vector< std::pair< std::size_t, std::size_t > > > getGlobalPairing(const std::vector< std::size_t > &locallyRequiredIds, const std::vector< std::pair< std::size_t, std::size_t > > &locallyMatchedIds, const STK_Interface &mesh, bool failure)
virtual std::string getRightSidesetName() const =0
Returns the sideset name for the right side.
Teuchos::RCP< std::vector< std::pair< std::size_t, std::size_t > > > getMatchedPair(const STK_Interface &mesh, const Teuchos::RCP< const std::vector< std::pair< std::size_t, std::size_t > > > ¤tState=Teuchos::null) const
virtual std::string getType() const =0
virtual Teuchos::RCP< std::vector< std::pair< std::size_t, std::size_t > > > getMatchedPair(const STK_Interface &mesh, const Teuchos::RCP< const std::vector< std::pair< std::size_t, std::size_t > > > ¤tState=Teuchos::null) const =0
std::string getRightSidesetName() const
Returns the sideset name for the right side.
std::pair< Teuchos::RCP< std::vector< std::size_t > >, Teuchos::RCP< std::vector< Teuchos::Tuple< double, 3 > > > > getSideIdsAndCoords(const STK_Interface &mesh, const std::string &sideName, const std::string type_)
Teuchos::RCP< std::vector< std::pair< std::size_t, std::size_t > > > getLocallyMatchedSideIds(const std::vector< std::size_t > &side_ids, const std::vector< Teuchos::Tuple< double, 3 > > &side_coords, const STK_Interface &mesh, const std::string &sideName, const Matcher &matcher, const std::string type_="coord")
const T * getAs() const
Attempts to cast the underlying matcher to type T. Returns nullptr if cast fails. ...