Panzer Version of the Day
Loading...
Searching...
No Matches
Panzer_STK_PeriodicBC_Matcher.hpp
Go to the documentation of this file.
1// @HEADER
2// *****************************************************************************
3// Panzer: A partial differential equation assembly
4// engine for strongly coupled complex multiphysics systems
5//
6// Copyright 2011 NTESS and the Panzer contributors.
7// SPDX-License-Identifier: BSD-3-Clause
8// *****************************************************************************
9// @HEADER
10
11#ifndef __Panzer_STK_PeriodicBC_Matcher_hpp__
12#define __Panzer_STK_PeriodicBC_Matcher_hpp__
13
14#include "Teuchos_Tuple.hpp"
15#include "Teuchos_RCP.hpp"
16
18#include "PanzerAdaptersSTK_config.hpp"
20
21#ifdef PANZER_HAVE_STKSEARCH
22#include "stk_search/CoarseSearch.hpp"
23#endif
24
25namespace panzer_stk {
26
31namespace periodic_helpers {
32
33#ifdef PANZER_HAVE_STKSEARCH
34 // Copied from PeriodicBoundarySearch
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;
40#endif
41
46 template <typename Matcher>
47 Teuchos::RCP<std::vector<std::pair<std::size_t,std::size_t> > >
48 matchPeriodicSides(const std::string & left,const std::string & right,
49 const STK_Interface & mesh,
50 const Matcher & matcher, const std::string type_ = "coord");
51
52 template <typename Matcher>
53 Teuchos::RCP<std::vector<std::pair<std::size_t,std::size_t> > >
54 matchPeriodicSides(const std::string & left,const std::string & right,
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");
58
62 std::pair<Teuchos::RCP<std::vector<std::size_t> >,
63 Teuchos::RCP<std::vector<Teuchos::Tuple<double,3> > > >
64 getSideIdsAndCoords(const STK_Interface & mesh,
65 const std::string & sideName, const std::string type_ = "coord");
66
70 std::pair<Teuchos::RCP<std::vector<std::size_t> >,
71 Teuchos::RCP<std::vector<Teuchos::Tuple<double,3> > > >
72 getLocalSideIdsAndCoords(const STK_Interface & mesh,
73 const std::string & sideName, const std::string type_ = "coord");
74
78 Teuchos::RCP<std::vector<std::size_t> >
79 getLocalSideIds(const STK_Interface & mesh,
80 const std::string & sideName, const std::string type_ = "coord");
81
86 template <typename Matcher>
87 Teuchos::RCP<std::vector<std::pair<std::size_t,std::size_t> > >
88 getLocallyMatchedSideIds(const std::vector<std::size_t> & side_ids,
89 const std::vector<Teuchos::Tuple<double,3> > & side_coords,
90 const STK_Interface & mesh,
91 const std::string & sideName,const Matcher & matcher, const std::string type_ = "coord");
92
102 Teuchos::RCP<std::vector<std::pair<std::size_t,std::size_t> > >
103 getGlobalPairing(const std::vector<std::size_t> & locallyRequiredIds,
104 const std::vector<std::pair<std::size_t,std::size_t> > & locallyMatchedIds,
105 const STK_Interface & mesh,bool failure);
106
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);
125
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);
128
135 const std::vector<double> computeGlobalCentroid(const STK_Interface & mesh, const std::string & sideName);
136
143 template<typename Matcher> void
144 transformLocalSearchVector(SphereIdVector & searchVectorSideA, const Matcher & matcher, const std::vector<double> & centroidSideB );
145
160 template <typename Matcher>
161 Teuchos::RCP<std::vector<std::pair<size_t,size_t> > >
162 matchPeriodicSidesSearch(const std::string & sideA,const std::string & sideB,
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");
167
168 template <typename Matcher>
169 Teuchos::RCP<std::vector<std::pair<size_t,size_t> > >
170 matchPeriodicSidesSearch(const std::string & sideA, const std::string & sideB,
171 const STK_Interface & mesh,
172 const Matcher & matcher, const std::string type_ = "coord");
173
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);
186
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);
196#endif
197} // end periodic_helpers
198
208public:
210
221 virtual
222 Teuchos::RCP<std::vector<std::pair<std::size_t,std::size_t> > >
224 const Teuchos::RCP<const std::vector<std::pair<std::size_t,std::size_t> > > & currentState = Teuchos::null
225 ) const = 0;
226
227#ifdef PANZER_HAVE_STKSEARCH
244 virtual
245 Teuchos::RCP<std::vector<std::pair<std::size_t,std::size_t> > >
246 getMatchedPair(const STK_Interface & mesh, const std::vector<std::string> & matchedSides,
247 const Teuchos::RCP<const std::vector<std::pair<std::size_t,std::size_t> > > & currentState = Teuchos::null
248 ) const = 0;
249#endif
250
254 virtual std::string getString() const = 0;
255
259 virtual std::string getType() const = 0;
260
262 virtual std::string getLeftSidesetName() const = 0;
263
265 virtual std::string getRightSidesetName() const = 0;
266
268 template<typename T>
269 const T* getAs() const {return dynamic_cast<const T*>(this);}
270};
271
277template <typename Matcher>
279public:
280 PeriodicBC_Matcher(const std::string & left, const std::string & right,const Matcher & matcher, const std::string type = "coord")
281 : left_(left), right_(right), matcher_(matcher), type_(type) {}
284
295 Teuchos::RCP<std::vector<std::pair<std::size_t,std::size_t> > >
297 const Teuchos::RCP<const std::vector<std::pair<std::size_t,std::size_t> > > & currentState = Teuchos::null
298 ) const
299 {
300 if(currentState==Teuchos::null)
302 else
304 }
305
306#ifdef PANZER_HAVE_STKSEARCH
323 Teuchos::RCP<std::vector<std::pair<std::size_t,std::size_t> > >
324 getMatchedPair(const STK_Interface & mesh, const std::vector<std::string> & matchedSides,
325 const Teuchos::RCP<const std::vector<std::pair<std::size_t,std::size_t> > > & currentState = Teuchos::null
326 ) const
327 {
328 if(currentState==Teuchos::null)
330 else
331 return periodic_helpers::matchPeriodicSidesSearch(left_,right_,mesh,matcher_,matchedSides,*currentState,type_);
332 }
333#endif
334
335 std::string getString() const
336 {
337 std::stringstream ss;
338 ss << "condition: " << matcher_.getString() << ", sides = [ "
339 << "\"" << left_ << "\", "
340 << "\"" << right_ << "\" ]";
341 return ss.str();
342 }
343
344 std::string getType() const
345 {return type_;}
346
347 std::string getLeftSidesetName() const
348 {return left_;}
349
350 std::string getRightSidesetName() const
351 {return right_;}
352
353 const Matcher& getMatcher() const
354 {return matcher_;}
355
356private:
357 PeriodicBC_Matcher(); // hidden!
358
359 std::string left_; // here left & right are stand in names just so
360 std::string right_; // that we realize that these boundaries are
361 // opposite of each other.
362 Matcher matcher_;
363
364 std::string type_; // type of periodic BC: coord, edge, face
365
366};
367
372template <typename Matcher>
373Teuchos::RCP<PeriodicBC_MatcherBase>
374buildPeriodicBC_Matcher(const std::string & left, const std::string & right, const Matcher & matcher, const std::string type = "coord")
375{ return Teuchos::rcp(new PeriodicBC_Matcher<Matcher>(left,right,matcher,type)); }
376
377} // end panzer_stk
378
380
381#ifdef PANZER_HAVE_STKSEARCH
383#endif
384
385#endif
virtual std::string getRightSidesetName() const =0
Returns the sideset name for the right side.
virtual std::string getString() const =0
virtual std::string getLeftSidesetName() const =0
Returns the sideset name for the left side.
const T * getAs() const
Attempts to cast the underlying matcher to type T. Returns nullptr if cast fails.
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 > > > &currentState=Teuchos::null) const =0
virtual std::string getType() const =0
std::string getRightSidesetName() const
Returns the sideset name for the right side.
PeriodicBC_Matcher(const PeriodicBC_Matcher &src)
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 > > > &currentState=Teuchos::null) const
PeriodicBC_Matcher(const std::string &left, const std::string &right, const Matcher &matcher, const std::string type="coord")
std::string getLeftSidesetName() const
Returns the sideset name for the left side.
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_)
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)
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_)
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_)
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")
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")
void transformLocalSearchVector(SphereIdVector &searchVectorSideA, const Matcher &matcher, const std::vector< double > &centroidSideB)
Teuchos::RCP< std::vector< std::size_t > > getLocalSideIds(const STK_Interface &mesh, const std::string &sideName, const std::string type_)
Teuchos::RCP< PeriodicBC_MatcherBase > buildPeriodicBC_Matcher(const std::string &left, const std::string &right, const Matcher &matcher, const std::string type="coord")