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 };
166 
172 template <typename Matcher>
174 public:
175  PeriodicBC_Matcher(const std::string & left, const std::string & right,const Matcher & matcher, const std::string type = "coord")
176  : left_(left), right_(right), matcher_(matcher), type_(type) {}
178  : left_(src.left_), right_(src.right_), matcher_(src.matcher_), type_(src.type_) {}
179 
192  const Teuchos::RCP<const std::vector<std::pair<std::size_t,std::size_t> > > & currentState = Teuchos::null
193  ) const
194  {
195  if(currentState==Teuchos::null)
197  else
198  return periodic_helpers::matchPeriodicSides(left_,right_,mesh,matcher_,*currentState,type_);
199  }
200 
201  std::string getString() const
202  {
203  std::stringstream ss;
204  ss << "condition: " << matcher_.getString() << ", sides = [ "
205  << "\"" << left_ << "\", "
206  << "\"" << right_ << "\" ]";
207  return ss.str();
208  }
209 
210  std::string getType() const
211  {
212  return type_;
213  }
214 
215 private:
216  PeriodicBC_Matcher(); // hidden!
217 
218  std::string left_; // here left & right are stand in names just so
219  std::string right_; // that we realize that these boundaries are
220  // opposite of each other.
221  Matcher matcher_;
222 
223  std::string type_; // type of periodic BC: coord, edge, face
224 
225 };
226 
231 template <typename Matcher>
233 buildPeriodicBC_Matcher(const std::string & left, const std::string & right, const Matcher & matcher, const std::string type = "coord")
234 { return Teuchos::rcp(new PeriodicBC_Matcher<Matcher>(left,right,matcher,type)); }
235 
236 } // end panzer_stk
237 
239 
240 #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_)
TEUCHOS_DEPRECATED RCP< T > rcp(T *p, Dealloc_T dealloc, bool owns_mem)
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)
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::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")