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
53 template <typename Matcher>
54 Teuchos::RCP<std::vector<std::pair<std::size_t,std::size_t> > >
55 matchPeriodicSides(const std::string & left,const std::string & right,
56 const STK_Interface & mesh,
57 const Matcher & matcher,
58 const std::vector<std::pair<std::size_t,std::size_t> > & current, const std::string type_ = "coord");
59
63 std::pair<Teuchos::RCP<std::vector<std::size_t> >,
64 Teuchos::RCP<std::vector<Teuchos::Tuple<double,3> > > >
65 getSideIdsAndCoords(const STK_Interface & mesh,
66 const std::string & sideName, const std::string type_ = "coord");
67
71 std::pair<Teuchos::RCP<std::vector<std::size_t> >,
72 Teuchos::RCP<std::vector<Teuchos::Tuple<double,3> > > >
73 getLocalSideIdsAndCoords(const STK_Interface & mesh,
74 const std::string & sideName, const std::string type_ = "coord");
75
79 Teuchos::RCP<std::vector<std::size_t> >
80 getLocalSideIds(const STK_Interface & mesh,
81 const std::string & sideName, const std::string type_ = "coord");
82
87 template <typename Matcher>
88 Teuchos::RCP<std::vector<std::pair<std::size_t,std::size_t> > >
89 getLocallyMatchedSideIds(const std::vector<std::size_t> & side_ids,
90 const std::vector<Teuchos::Tuple<double,3> > & side_coords,
91 const STK_Interface & mesh,
92 const std::string & sideName,const Matcher & matcher, const std::string type_ = "coord");
93
103 Teuchos::RCP<std::vector<std::pair<std::size_t,std::size_t> > >
104 getGlobalPairing(const std::vector<std::size_t> & locallyRequiredIds,
105 const std::vector<std::pair<std::size_t,std::size_t> > & locallyMatchedIds,
106 const STK_Interface & mesh,bool failure);
107
108#ifdef PANZER_HAVE_STKSEARCH
123 void fillLocalSearchVector(const STK_Interface & mesh, SphereIdVector & searchVector, const double & error,
124 const std::string & sideName, const std::string & type_, const bool & getGhostedIDs,
125 const std::vector<std::string> & matchedSides, std::vector<SearchId> & potentialIDsToRemap);
126
127 void fillLocalSearchVector(const STK_Interface & mesh, SphereIdVector & searchVector, const double & error,
128 const std::string & sideName, const std::string & type_, const bool & getGhostedIDs = false);
129
136 const std::vector<double> computeGlobalCentroid(const STK_Interface & mesh, const std::string & sideName);
137
144 template<typename Matcher> void
145 transformLocalSearchVector(SphereIdVector & searchVectorSideA, const Matcher & matcher, const std::vector<double> & centroidSideB );
146
161 template <typename Matcher>
162 Teuchos::RCP<std::vector<std::pair<size_t,size_t> > >
163 matchPeriodicSidesSearch(const std::string & sideA,const std::string & sideB,
164 const STK_Interface & mesh,
165 const Matcher & matcher, const std::vector<std::string> & matchedSides,
166 const std::vector<std::pair<size_t,size_t> > & previousMatches,
167 const std::string type_ = "coord");
168
169 template <typename Matcher>
170 Teuchos::RCP<std::vector<std::pair<size_t,size_t> > >
171 matchPeriodicSidesSearch(const std::string & sideA, const std::string & sideB,
172 const STK_Interface & mesh,
173 const Matcher & matcher, const std::string type_ = "coord");
174
184 void updateMapping(Teuchos::RCP<std::vector<std::pair<size_t,size_t> > > & currentMatches,
185 const std::vector<std::pair<size_t,size_t> > & previousMatches,
186 const std::vector<SearchId> & IDsToRemap, const STK_Interface & mesh);
187
195 void appendMapping(Teuchos::RCP<std::vector<std::pair<size_t,size_t> > > & currentMatches,
196 const std::vector<std::pair<size_t,size_t> > & previousMatches);
197#endif
198} // end periodic_helpers
199
209public:
211
222 virtual
223 Teuchos::RCP<std::vector<std::pair<std::size_t,std::size_t> > >
225 const Teuchos::RCP<const std::vector<std::pair<std::size_t,std::size_t> > > & currentState = Teuchos::null
226 ) const = 0;
227
228#ifdef PANZER_HAVE_STKSEARCH
245 virtual
246 Teuchos::RCP<std::vector<std::pair<std::size_t,std::size_t> > >
247 getMatchedPair(const STK_Interface & mesh, const std::vector<std::string> & matchedSides,
248 const Teuchos::RCP<const std::vector<std::pair<std::size_t,std::size_t> > > & currentState = Teuchos::null
249 ) const = 0;
250#endif
251
255 virtual std::string getString() const = 0;
256
260 virtual std::string getType() const = 0;
261
263 virtual std::string getLeftSidesetName() const = 0;
264
266 virtual std::string getRightSidesetName() const = 0;
267
269 template<typename T>
270 const T* getAs() const {return dynamic_cast<const T*>(this);}
271};
272
278template <typename Matcher>
280public:
282 PeriodicBC_Matcher(const std::string & left, const std::string & right,const Matcher & matcher, const std::string type = "coord")
283 : left_(left), right_(right), matcher_(matcher), type_(type) {}
287
298 Teuchos::RCP<std::vector<std::pair<std::size_t,std::size_t> > >
300 const Teuchos::RCP<const std::vector<std::pair<std::size_t,std::size_t> > > & currentState = Teuchos::null
301 ) const
302 {
303 if(currentState==Teuchos::null)
305 else
307 }
308
309#ifdef PANZER_HAVE_STKSEARCH
326 Teuchos::RCP<std::vector<std::pair<std::size_t,std::size_t> > >
327 getMatchedPair(const STK_Interface & mesh, const std::vector<std::string> & matchedSides,
328 const Teuchos::RCP<const std::vector<std::pair<std::size_t,std::size_t> > > & currentState = Teuchos::null
329 ) const
330 {
331 if(currentState==Teuchos::null)
333 else
334 return periodic_helpers::matchPeriodicSidesSearch(left_,right_,mesh,matcher_,matchedSides,*currentState,type_);
335 }
336#endif
337
338 std::string getString() const
339 {
340 std::stringstream ss;
341 ss << "condition: " << matcher_.getString() << ", sides = [ "
342 << "\"" << left_ << "\", "
343 << "\"" << right_ << "\" ]";
344 return ss.str();
345 }
346
347 std::string getType() const
348 {return type_;}
349
350 std::string getLeftSidesetName() const
351 {return left_;}
352
353 std::string getRightSidesetName() const
354 {return right_;}
355
357 const Matcher& getMatcher() const
358 {return matcher_;}
359
360private:
361 PeriodicBC_Matcher(); // hidden!
362
363 std::string left_; // here left & right are stand in names just so
364 std::string right_; // that we realize that these boundaries are
365 // opposite of each other.
366 Matcher matcher_;
367
368 std::string type_; // type of periodic BC: coord, edge, face
369
370};
371
376template <typename Matcher>
377Teuchos::RCP<PeriodicBC_MatcherBase>
378buildPeriodicBC_Matcher(const std::string & left, const std::string & right, const Matcher & matcher, const std::string type = "coord")
379{ return Teuchos::rcp(new PeriodicBC_Matcher<Matcher>(left,right,matcher,type)); }
380
381} // end panzer_stk
382
384
385#ifdef PANZER_HAVE_STKSEARCH
387#endif
388
389#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)
Copy constructor.
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")
Construct from the two sideset names to match and the matcher object defining how coordinates on them...
const Matcher & getMatcher() const
Returns the underlying matcher object.
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")