11 #ifndef __Panzer_STK_PeriodicBC_Matcher_hpp__
12 #define __Panzer_STK_PeriodicBC_Matcher_hpp__
14 #include "Teuchos_Tuple.hpp"
18 #include "PanzerAdaptersSTK_config.hpp"
21 #ifdef PANZER_HAVE_STKSEARCH
22 #include "stk_search/CoarseSearch.hpp"
25 namespace panzer_stk {
31 namespace periodic_helpers {
33 #ifdef PANZER_HAVE_STKSEARCH
35 typedef stk::search::IdentProc<stk::mesh::EntityKey> SearchId;
36 typedef stk::search::Sphere<double> Sphere;
37 typedef std::vector< std::pair<Sphere,SearchId> > SphereIdVector;
38 typedef std::vector<std::pair<SearchId,SearchId> > SearchPairVector;
39 typedef std::vector<std::pair<stk::mesh::EntityKey,stk::mesh::EntityKey> > SearchPairSet;
46 template <
typename Matcher>
49 const STK_Interface & mesh,
50 const Matcher & matcher,
const std::string type_ =
"coord");
52 template <
typename Matcher>
55 const STK_Interface & mesh,
56 const Matcher & matcher,
57 const std::vector<std::pair<std::size_t,std::size_t> > & current,
const std::string type_ =
"coord");
62 std::pair<Teuchos::RCP<std::vector<std::size_t> >,
65 const std::string & sideName,
const std::string type_ =
"coord");
70 std::pair<Teuchos::RCP<std::vector<std::size_t> >,
73 const std::string & sideName,
const std::string type_ =
"coord");
80 const std::string & sideName,
const std::string type_ =
"coord");
86 template <
typename Matcher>
90 const STK_Interface & mesh,
91 const std::string & sideName,
const Matcher & matcher,
const std::string type_ =
"coord");
104 const std::vector<std::pair<std::size_t,std::size_t> > & locallyMatchedIds,
105 const STK_Interface & mesh,
bool failure);
107 #ifdef PANZER_HAVE_STKSEARCH
122 void fillLocalSearchVector(
const STK_Interface & mesh, SphereIdVector & searchVector,
const double & error,
123 const std::string & sideName,
const std::string & type_,
const bool & getGhostedIDs,
124 const std::vector<std::string> & matchedSides, std::vector<SearchId> & potentialIDsToRemap);
126 void fillLocalSearchVector(
const STK_Interface & mesh, SphereIdVector & searchVector,
const double & error,
127 const std::string & sideName,
const std::string & type_,
const bool & getGhostedIDs =
false);
135 const std::vector<double> computeGlobalCentroid(
const STK_Interface & mesh,
const std::string & sideName);
143 template<
typename Matcher>
void
144 transformLocalSearchVector(SphereIdVector & searchVectorSideA,
const Matcher & matcher,
const std::vector<double> & centroidSideB );
160 template <
typename Matcher>
163 const STK_Interface & mesh,
164 const Matcher & matcher,
const std::vector<std::string> & matchedSides,
165 const std::vector<std::pair<size_t,size_t> > & previousMatches,
166 const std::string type_ =
"coord");
168 template <
typename Matcher>
171 const STK_Interface & mesh,
172 const Matcher & matcher,
const std::string type_ =
"coord");
183 void updateMapping(
Teuchos::RCP<std::vector<std::pair<size_t,size_t> > > & currentMatches,
184 const std::vector<std::pair<size_t,size_t> > & previousMatches,
185 const std::vector<SearchId> & IDsToRemap,
const STK_Interface & mesh);
194 void appendMapping(
Teuchos::RCP<std::vector<std::pair<size_t,size_t> > > & currentMatches,
195 const std::vector<std::pair<size_t,size_t> > & previousMatches);
224 const Teuchos::RCP<
const std::vector<std::pair<std::size_t,std::size_t> > > & currentState = Teuchos::null
227 #ifdef PANZER_HAVE_STKSEARCH
247 const Teuchos::RCP<
const std::vector<std::pair<std::size_t,std::size_t> > > & currentState = Teuchos::null
254 virtual std::string
getString()
const = 0;
259 virtual std::string
getType()
const = 0;
269 const T*
getAs()
const {
return dynamic_cast<const T*
>(
this);}
277 template <
typename Matcher>
280 PeriodicBC_Matcher(
const std::string & left,
const std::string & right,
const Matcher & matcher,
const std::string type =
"coord")
297 const Teuchos::RCP<
const std::vector<std::pair<std::size_t,std::size_t> > > & currentState = Teuchos::null
300 if(currentState==Teuchos::null)
306 #ifdef PANZER_HAVE_STKSEARCH
325 const Teuchos::RCP<
const std::vector<std::pair<std::size_t,std::size_t> > > & currentState = Teuchos::null
328 if(currentState==Teuchos::null)
337 std::stringstream ss;
338 ss <<
"condition: " <<
matcher_.getString() <<
", sides = [ "
339 <<
"\"" <<
left_ <<
"\", "
340 <<
"\"" <<
right_ <<
"\" ]";
372 template <
typename Matcher>
374 buildPeriodicBC_Matcher(
const std::string & left,
const std::string & right,
const Matcher & matcher,
const std::string type =
"coord")
381 #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. ...