Panzer  Version of the Day
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Panzer_STK_PeriodicBC_Matcher.hpp
Go to the documentation of this file.
1 // @HEADER
2 // ***********************************************************************
3 //
4 // Panzer: A partial differential equation assembly
5 // engine for strongly coupled complex multiphysics systems
6 // Copyright (2011) Sandia Corporation
7 //
8 // Under the terms of Contract DE-AC04-94AL85000 with Sandia Corporation,
9 // the U.S. Government retains certain rights in this software.
10 //
11 // Redistribution and use in source and binary forms, with or without
12 // modification, are permitted provided that the following conditions are
13 // met:
14 //
15 // 1. Redistributions of source code must retain the above copyright
16 // notice, this list of conditions and the following disclaimer.
17 //
18 // 2. Redistributions in binary form must reproduce the above copyright
19 // notice, this list of conditions and the following disclaimer in the
20 // documentation and/or other materials provided with the distribution.
21 //
22 // 3. Neither the name of the Corporation nor the names of the
23 // contributors may be used to endorse or promote products derived from
24 // this software without specific prior written permission.
25 //
26 // THIS SOFTWARE IS PROVIDED BY SANDIA CORPORATION "AS IS" AND ANY
27 // EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
28 // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
29 // PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL SANDIA CORPORATION OR THE
30 // CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
31 // EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
32 // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
33 // PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
34 // LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
35 // NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
36 // SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
37 //
38 // Questions? Contact Roger P. Pawlowski (rppawlo@sandia.gov) and
39 // Eric C. Cyr (eccyr@sandia.gov)
40 // ***********************************************************************
41 // @HEADER
42 
43 #ifndef __Panzer_STK_PeriodicBC_Matcher_hpp__
44 #define __Panzer_STK_PeriodicBC_Matcher_hpp__
45 
46 #include "Teuchos_Tuple.hpp"
47 #include "Teuchos_RCP.hpp"
48 
49 #include "Panzer_STK_Version.hpp"
50 #include "PanzerAdaptersSTK_config.hpp"
51 #include "Panzer_STK_Interface.hpp"
52 
53 namespace panzer_stk {
54 
59 namespace periodic_helpers {
60 
65  template <typename Matcher>
67  matchPeriodicSides(const std::string & left,const std::string & right,
68  const STK_Interface & mesh,
69  const Matcher & matcher, const std::string type_ = "coord");
70 
71  template <typename Matcher>
73  matchPeriodicSides(const std::string & left,const std::string & right,
74  const STK_Interface & mesh,
75  const Matcher & matcher,
76  const std::vector<std::pair<std::size_t,std::size_t> > & current, const std::string type_ = "coord");
77 
81  std::pair<Teuchos::RCP<std::vector<std::size_t> >,
83  getSideIdsAndCoords(const STK_Interface & mesh,
84  const std::string & sideName, const std::string type_ = "coord");
85 
89  std::pair<Teuchos::RCP<std::vector<std::size_t> >,
91  getLocalSideIdsAndCoords(const STK_Interface & mesh,
92  const std::string & sideName, const std::string type_ = "coord");
93 
98  getLocalSideIds(const STK_Interface & mesh,
99  const std::string & sideName, const std::string type_ = "coord");
100 
105  template <typename Matcher>
107  getLocallyMatchedSideIds(const std::vector<std::size_t> & side_ids,
108  const std::vector<Teuchos::Tuple<double,3> > & side_coords,
109  const STK_Interface & mesh,
110  const std::string & sideName,const Matcher & matcher, const std::string type_ = "coord");
111 
122  getGlobalPairing(const std::vector<std::size_t> & locallyRequiredIds,
123  const std::vector<std::pair<std::size_t,std::size_t> > & locallyMatchedIds,
124  const STK_Interface & mesh,bool failure);
125 
126 } // end periodic_helpers
127 
137 public:
139 
150  virtual
152  getMatchedPair(const STK_Interface & mesh,
153  const Teuchos::RCP<const std::vector<std::pair<std::size_t,std::size_t> > > & currentState = Teuchos::null
154  ) const = 0;
155 
159  virtual std::string getString() const = 0;
160 
164  virtual std::string getType() const = 0;
165 
167  virtual std::string getLeftSidesetName() const = 0;
168 
170  virtual std::string getRightSidesetName() const = 0;
171 
173  template<typename T>
174  const T* getAs() const {return dynamic_cast<const T*>(this);}
175 };
176 
182 template <typename Matcher>
184 public:
185  PeriodicBC_Matcher(const std::string & left, const std::string & right,const Matcher & matcher, const std::string type = "coord")
186  : left_(left), right_(right), matcher_(matcher), type_(type) {}
188  : left_(src.left_), right_(src.right_), matcher_(src.matcher_), type_(src.type_) {}
189 
202  const Teuchos::RCP<const std::vector<std::pair<std::size_t,std::size_t> > > & currentState = Teuchos::null
203  ) const
204  {
205  if(currentState==Teuchos::null)
207  else
208  return periodic_helpers::matchPeriodicSides(left_,right_,mesh,matcher_,*currentState,type_);
209  }
210 
211  std::string getString() const
212  {
213  std::stringstream ss;
214  ss << "condition: " << matcher_.getString() << ", sides = [ "
215  << "\"" << left_ << "\", "
216  << "\"" << right_ << "\" ]";
217  return ss.str();
218  }
219 
220  std::string getType() const
221  {return type_;}
222 
223  std::string getLeftSidesetName() const
224  {return left_;}
225 
226  std::string getRightSidesetName() const
227  {return right_;}
228 
229  const Matcher& getMatcher() const
230  {return matcher_;}
231 
232 private:
233  PeriodicBC_Matcher(); // hidden!
234 
235  std::string left_; // here left & right are stand in names just so
236  std::string right_; // that we realize that these boundaries are
237  // opposite of each other.
238  Matcher matcher_;
239 
240  std::string type_; // type of periodic BC: coord, edge, face
241 
242 };
243 
248 template <typename Matcher>
250 buildPeriodicBC_Matcher(const std::string & left, const std::string & right, const Matcher & matcher, const std::string type = "coord")
251 { return Teuchos::rcp(new PeriodicBC_Matcher<Matcher>(left,right,matcher,type)); }
252 
253 } // end panzer_stk
254 
256 
257 #endif
PeriodicBC_Matcher(const std::string &left, const std::string &right, const Matcher &matcher, const std::string type="coord")
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")
virtual std::string getString() const =0
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.
Teuchos::RCP< PeriodicBC_MatcherBase > buildPeriodicBC_Matcher(const std::string &left, const std::string &right, const Matcher &matcher, const std::string type="coord")
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 > > > &currentState=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 > > > &currentState=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. ...