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 // 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_STKConnManager_hpp__
12 #define __Panzer_STKConnManager_hpp__
13 
14 #include <vector>
15 
16 // Teuchos includes
17 #include "Teuchos_RCP.hpp"
18 
19 // Kokkos includes
20 #include "Kokkos_DynRankView.hpp"
21 
22 // Panzer includes
23 #include "Panzer_ConnManager.hpp"
24 
25 #include "Panzer_STK_Interface.hpp"
27 
28 namespace panzer_stk {
29 
31 public:
34  typedef typename Kokkos::DynRankView<GlobalOrdinal,PHX::Device>::HostMirror GlobalOrdinalView;
35  typedef typename Kokkos::DynRankView<LocalOrdinal, PHX::Device>::HostMirror LocalOrdinalView;
36 
38 
39  virtual ~STKConnManager() {}
40 
46  virtual void buildConnectivity(const panzer::FieldPattern & fp);
47 
53 
61  virtual const panzer::GlobalOrdinal * getConnectivity(LocalOrdinal localElmtId) const
62  { return &connectivity_[elmtLidToConn_[localElmtId]]; }
63 
71  virtual panzer::GlobalOrdinal * getConnectivity(LocalOrdinal localElmtId)
72  { return &connectivity_[elmtLidToConn_[localElmtId]]; }
73 
80  virtual LocalOrdinal getConnectivitySize(LocalOrdinal localElmtId) const
81  { return connSize_[localElmtId]; }
82 
84  { return GlobalOrdinalView(connectivity_.data(), connectivity_.size()); }
85 
87  { return LocalOrdinalView(connSize_.data(), connSize_.size()); }
88 
90  { return LocalOrdinalView(elmtLidToConn_.data(), elmtLidToConn_.size()); }
91 
96  virtual std::string getBlockId(LocalOrdinal localElmtId) const;
97 
100  virtual std::size_t numElementBlocks() const
101  { return stkMeshDB_->getNumElementBlocks(); }
102 
105  virtual void getElementBlockIds(std::vector<std::string> & elementBlockIds) const
106  { return stkMeshDB_->getElementBlockNames(elementBlockIds); }
109  virtual void getElementBlockTopologies(std::vector<shards::CellTopology> & elementBlockTopologies) const{
110  std::vector<std::string> elementBlockIds;
111  getElementBlockIds(elementBlockIds);
112  elementBlockTopologies.reserve(elementBlockIds.size());
113  for (unsigned i=0; i<elementBlockIds.size(); ++i) {
114  elementBlockTopologies.push_back(*(stkMeshDB_->getCellTopology(elementBlockIds[i])));
115  }
116  }
124  virtual const std::vector<LocalOrdinal> & getElementBlock(const std::string & blockId) const
125  { return *(elementBlocks_.find(blockId)->second); }
126 
135  virtual const std::vector<LocalOrdinal> & getNeighborElementBlock(const std::string & blockId) const
136  { return *(neighborElementBlocks_.find(blockId)->second); }
137 
146  virtual void getDofCoords(const std::string & blockId,
147  const panzer::Intrepid2FieldPattern & coordProvider,
148  std::vector<std::size_t> & localCellIds,
149  Kokkos::DynRankView<double,PHX::Device> & points) const;
150 
154  { return stkMeshDB_; }
155 
163  std::size_t getOwnedElementCount() const
164  { return ownedElementCount_; }
165 
169  void associateElementsInSideset(const std::string sideset_id);
170 
176  std::vector<std::string> checkAssociateElementsInSidesets(const Teuchos::Comm<int>& comm) const;
177 
181  virtual const std::vector<LocalOrdinal>& getAssociatedNeighbors(const LocalOrdinal& el) const;
182 
186  virtual bool hasAssociatedNeighbors() const;
187 
188 protected:
194  void applyPeriodicBCs( const panzer::FieldPattern & fp, GlobalOrdinal nodeOffset, GlobalOrdinal edgeOffset,
195  GlobalOrdinal faceOffset, GlobalOrdinal cellOffset);
197 
201  LocalOrdinal & nodeIdCnt, LocalOrdinal & edgeIdCnt,
202  LocalOrdinal & faceIdCnt, LocalOrdinal & cellIdCnt,
203  GlobalOrdinal & nodeOffset, GlobalOrdinal & edgeOffset,
204  GlobalOrdinal & faceOffset, GlobalOrdinal & cellOffset) const;
205 
219  LocalOrdinal addSubcellConnectivities(stk::mesh::Entity element,unsigned subcellRank,
220  LocalOrdinal idCnt,GlobalOrdinal offset,const unsigned maxIds=0);
221 
222  void modifySubcellConnectivities(const panzer::FieldPattern & fp, stk::mesh::Entity element,
223  unsigned subcellRank,unsigned subcellId,GlobalOrdinal newId,GlobalOrdinal offset);
224 
226 
228 
229  // element block information
230  std::map<std::string,Teuchos::RCP<std::vector<LocalOrdinal> > > elementBlocks_;
231  std::map<std::string,Teuchos::RCP<std::vector<LocalOrdinal> > > neighborElementBlocks_;
232  std::map<std::string,GlobalOrdinal> blockIdToIndex_;
233 
234  std::vector<LocalOrdinal> elmtLidToConn_; // element LID to Connectivity map
235  std::vector<LocalOrdinal> connSize_; // element LID to Connectivity map
236  std::vector<GlobalOrdinal> connectivity_; // Connectivity
237 
238  std::size_t ownedElementCount_;
239 
240  std::vector<std::string> sidesetsToAssociate_;
241  std::vector<bool> sidesetYieldedAssociations_;
242  std::vector<std::vector<LocalOrdinal> > elmtToAssociatedElmts_;
243 };
244 
245 }
246 
247 #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_