Panzer  Version of the Day
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Panzer_STKConnManager.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_STKConnManager_hpp__
44 #define __Panzer_STKConnManager_hpp__
45 
46 #include <vector>
47 
48 // Teuchos includes
49 #include "Teuchos_RCP.hpp"
50 
51 // Kokkos includes
52 #include "Kokkos_DynRankView.hpp"
53 
54 // Panzer includes
55 #include "Panzer_ConnManager.hpp"
56 
57 #include "Panzer_STK_Interface.hpp"
59 
60 namespace panzer_stk {
61 
63 public:
66  typedef typename Kokkos::DynRankView<GlobalOrdinal,PHX::Device>::HostMirror GlobalOrdinalView;
67  typedef typename Kokkos::DynRankView<LocalOrdinal, PHX::Device>::HostMirror LocalOrdinalView;
68 
70 
71  virtual ~STKConnManager() {}
72 
78  virtual void buildConnectivity(const panzer::FieldPattern & fp);
79 
85 
93  virtual const panzer::GlobalOrdinal * getConnectivity(LocalOrdinal localElmtId) const
94  { return &connectivity_[elmtLidToConn_[localElmtId]]; }
95 
103  virtual panzer::GlobalOrdinal * getConnectivity(LocalOrdinal localElmtId)
104  { return &connectivity_[elmtLidToConn_[localElmtId]]; }
105 
112  virtual LocalOrdinal getConnectivitySize(LocalOrdinal localElmtId) const
113  { return connSize_[localElmtId]; }
114 
116  { return GlobalOrdinalView(connectivity_.data(), connectivity_.size()); }
117 
119  { return LocalOrdinalView(connSize_.data(), connSize_.size()); }
120 
122  { return LocalOrdinalView(elmtLidToConn_.data(), elmtLidToConn_.size()); }
123 
128  virtual std::string getBlockId(LocalOrdinal localElmtId) const;
129 
132  virtual std::size_t numElementBlocks() const
133  { return stkMeshDB_->getNumElementBlocks(); }
134 
137  virtual void getElementBlockIds(std::vector<std::string> & elementBlockIds) const
138  { return stkMeshDB_->getElementBlockNames(elementBlockIds); }
141  virtual void getElementBlockTopologies(std::vector<shards::CellTopology> & elementBlockTopologies) const{
142  std::vector<std::string> elementBlockIds;
143  getElementBlockIds(elementBlockIds);
144  elementBlockTopologies.reserve(elementBlockIds.size());
145  for (unsigned i=0; i<elementBlockIds.size(); ++i) {
146  elementBlockTopologies.push_back(*(stkMeshDB_->getCellTopology(elementBlockIds[i])));
147  }
148  }
156  virtual const std::vector<LocalOrdinal> & getElementBlock(const std::string & blockId) const
157  { return *(elementBlocks_.find(blockId)->second); }
158 
167  virtual const std::vector<LocalOrdinal> & getNeighborElementBlock(const std::string & blockId) const
168  { return *(neighborElementBlocks_.find(blockId)->second); }
169 
178  virtual void getDofCoords(const std::string & blockId,
179  const panzer::Intrepid2FieldPattern & coordProvider,
180  std::vector<std::size_t> & localCellIds,
181  Kokkos::DynRankView<double,PHX::Device> & points) const;
182 
186  { return stkMeshDB_; }
187 
195  std::size_t getOwnedElementCount() const
196  { return ownedElementCount_; }
197 
201  void associateElementsInSideset(const std::string sideset_id);
202 
208  std::vector<std::string> checkAssociateElementsInSidesets(const Teuchos::Comm<int>& comm) const;
209 
213  virtual const std::vector<LocalOrdinal>& getAssociatedNeighbors(const LocalOrdinal& el) const;
214 
218  virtual bool hasAssociatedNeighbors() const;
219 
220 protected:
226  void applyPeriodicBCs( const panzer::FieldPattern & fp, GlobalOrdinal nodeOffset, GlobalOrdinal edgeOffset,
227  GlobalOrdinal faceOffset, GlobalOrdinal cellOffset);
229 
233  LocalOrdinal & nodeIdCnt, LocalOrdinal & edgeIdCnt,
234  LocalOrdinal & faceIdCnt, LocalOrdinal & cellIdCnt,
235  GlobalOrdinal & nodeOffset, GlobalOrdinal & edgeOffset,
236  GlobalOrdinal & faceOffset, GlobalOrdinal & cellOffset) const;
237 
251  LocalOrdinal addSubcellConnectivities(stk::mesh::Entity element,unsigned subcellRank,
252  LocalOrdinal idCnt,GlobalOrdinal offset,const unsigned maxIds=0);
253 
254  void modifySubcellConnectivities(const panzer::FieldPattern & fp, stk::mesh::Entity element,
255  unsigned subcellRank,unsigned subcellId,GlobalOrdinal newId,GlobalOrdinal offset);
256 
258 
260 
261  // element block information
262  std::map<std::string,Teuchos::RCP<std::vector<LocalOrdinal> > > elementBlocks_;
263  std::map<std::string,Teuchos::RCP<std::vector<LocalOrdinal> > > neighborElementBlocks_;
264  std::map<std::string,GlobalOrdinal> blockIdToIndex_;
265 
266  std::vector<LocalOrdinal> elmtLidToConn_; // element LID to Connectivity map
267  std::vector<LocalOrdinal> connSize_; // element LID to Connectivity map
268  std::vector<GlobalOrdinal> connectivity_; // Connectivity
269 
270  std::size_t ownedElementCount_;
271 
272  std::vector<std::string> sidesetsToAssociate_;
273  std::vector<bool> sidesetYieldedAssociations_;
274  std::vector<std::vector<LocalOrdinal> > elmtToAssociatedElmts_;
275 };
276 
277 }
278 
279 #endif
std::map< std::string, Teuchos::RCP< std::vector< LocalOrdinal > > > elementBlocks_
const GlobalOrdinalView getConnectivityView()
virtual const std::vector< LocalOrdinal > & getAssociatedNeighbors(const LocalOrdinal &el) const
virtual std::string getBlockId(LocalOrdinal localElmtId) const
const LocalOrdinalView getConnectivitySizeView()
panzer::ConnManager::GlobalOrdinal GlobalOrdinal
std::size_t getOwnedElementCount() const
virtual const std::vector< LocalOrdinal > & getNeighborElementBlock(const std::string &blockId) const
std::vector< bool > sidesetYieldedAssociations_
std::map< std::string, Teuchos::RCP< std::vector< LocalOrdinal > > > neighborElementBlocks_
Teuchos::RCP< const STK_Interface > stkMeshDB_
std::map< std::string, GlobalOrdinal > blockIdToIndex_
Kokkos::DynRankView< LocalOrdinal, PHX::Device >::HostMirror LocalOrdinalView
std::vector< GlobalOrdinal > connectivity_
virtual bool hasAssociatedNeighbors() const
std::vector< std::string > checkAssociateElementsInSidesets(const Teuchos::Comm< int > &comm) const
const LocalOrdinalView getElementLidToConnView()
virtual std::size_t numElementBlocks() const
std::vector< std::vector< LocalOrdinal > > elmtToAssociatedElmts_
virtual const panzer::GlobalOrdinal * getConnectivity(LocalOrdinal localElmtId) const
void buildOffsetsAndIdCounts(const panzer::FieldPattern &fp, LocalOrdinal &nodeIdCnt, LocalOrdinal &edgeIdCnt, LocalOrdinal &faceIdCnt, LocalOrdinal &cellIdCnt, GlobalOrdinal &nodeOffset, GlobalOrdinal &edgeOffset, GlobalOrdinal &faceOffset, GlobalOrdinal &cellOffset) const
virtual void getElementBlockIds(std::vector< std::string > &elementBlockIds) const
virtual Teuchos::RCP< panzer::ConnManager > noConnectivityClone() const
void modifySubcellConnectivities(const panzer::FieldPattern &fp, stk::mesh::Entity element, unsigned subcellRank, unsigned subcellId, GlobalOrdinal newId, GlobalOrdinal offset)
void applyPeriodicBCs(const panzer::FieldPattern &fp, GlobalOrdinal nodeOffset, GlobalOrdinal edgeOffset, GlobalOrdinal faceOffset, GlobalOrdinal cellOffset)
panzer::ConnManager::LocalOrdinal LocalOrdinal
panzer::GlobalOrdinal GlobalOrdinal
virtual const std::vector< LocalOrdinal > & getElementBlock(const std::string &blockId) const
Pure virtual base class for supplying mesh connectivity information to the DOF Manager.
virtual LocalOrdinal getConnectivitySize(LocalOrdinal localElmtId) const
LocalOrdinal addSubcellConnectivities(stk::mesh::Entity element, unsigned subcellRank, LocalOrdinal idCnt, GlobalOrdinal offset, const unsigned maxIds=0)
Loops over relations of a given rank for a specified element and adds a unique ID to the connectivity...
virtual void getDofCoords(const std::string &blockId, const panzer::Intrepid2FieldPattern &coordProvider, std::vector< std::size_t > &localCellIds, Kokkos::DynRankView< double, PHX::Device > &points) const
Teuchos::RCP< const STK_Interface > getSTKInterface() const
virtual panzer::GlobalOrdinal * getConnectivity(LocalOrdinal localElmtId)
std::vector< LocalOrdinal > elmtLidToConn_
virtual void getElementBlockTopologies(std::vector< shards::CellTopology > &elementBlockTopologies) const
std::vector< std::string > sidesetsToAssociate_
Kokkos::DynRankView< GlobalOrdinal, PHX::Device >::HostMirror GlobalOrdinalView
Teuchos::RCP< std::vector< stk::mesh::Entity > > elements_
virtual void buildConnectivity(const panzer::FieldPattern &fp)
STKConnManager(const Teuchos::RCP< const STK_Interface > &stkMeshDB)
void associateElementsInSideset(const std::string sideset_id)
std::vector< LocalOrdinal > connSize_