Panzer  Version of the Day
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 
69  STKConnManager(const Teuchos::RCP<const STK_Interface> & stkMeshDB);
70 
71  virtual ~STKConnManager() {}
72 
78  virtual void buildConnectivity(const panzer::FieldPattern & fp);
79 
84  virtual Teuchos::RCP<panzer::ConnManager> noConnectivityClone() const;
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 
185  Teuchos::RCP<const STK_Interface> getSTKInterface() const
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 
238  LocalOrdinal addSubcellConnectivities(stk::mesh::Entity element,unsigned subcellRank,
239  LocalOrdinal idCnt,GlobalOrdinal offset);
240 
241  void modifySubcellConnectivities(const panzer::FieldPattern & fp, stk::mesh::Entity element,
242  unsigned subcellRank,unsigned subcellId,GlobalOrdinal newId,GlobalOrdinal offset);
243 
244  Teuchos::RCP<const STK_Interface> stkMeshDB_;
245 
246  Teuchos::RCP<std::vector<stk::mesh::Entity> > elements_;
247 
248  // element block information
249  std::map<std::string,Teuchos::RCP<std::vector<LocalOrdinal> > > elementBlocks_;
250  std::map<std::string,Teuchos::RCP<std::vector<LocalOrdinal> > > neighborElementBlocks_;
251  std::map<std::string,GlobalOrdinal> blockIdToIndex_;
252 
253  std::vector<LocalOrdinal> elmtLidToConn_; // element LID to Connectivity map
254  std::vector<LocalOrdinal> connSize_; // element LID to Connectivity map
255  std::vector<GlobalOrdinal> connectivity_; // Connectivity
256 
257  std::size_t ownedElementCount_;
258 
259  std::vector<std::string> sidesetsToAssociate_;
260  std::vector<bool> sidesetYieldedAssociations_;
261  std::vector<std::vector<LocalOrdinal> > elmtToAssociatedElmts_;
262 };
263 
264 }
265 
266 #endif
virtual void getDofCoords(const std::string &blockId, const panzer::Intrepid2FieldPattern &coordProvider, std::vector< std::size_t > &localCellIds, Kokkos::DynRankView< double, PHX::Device > &points) const
void buildOffsetsAndIdCounts(const panzer::FieldPattern &fp, LocalOrdinal &nodeIdCnt, LocalOrdinal &edgeIdCnt, LocalOrdinal &faceIdCnt, LocalOrdinal &cellIdCnt, GlobalOrdinal &nodeOffset, GlobalOrdinal &edgeOffset, GlobalOrdinal &faceOffset, GlobalOrdinal &cellOffset) const
std::vector< std::string > checkAssociateElementsInSidesets(const Teuchos::Comm< int > &comm) const
virtual std::size_t numElementBlocks() const
virtual bool hasAssociatedNeighbors() const
std::map< std::string, Teuchos::RCP< std::vector< LocalOrdinal > > > elementBlocks_
const GlobalOrdinalView getConnectivityView()
virtual void getElementBlockTopologies(std::vector< shards::CellTopology > &elementBlockTopologies) const
const LocalOrdinalView getConnectivitySizeView()
panzer::ConnManager::GlobalOrdinal GlobalOrdinal
std::vector< bool > sidesetYieldedAssociations_
std::map< std::string, Teuchos::RCP< std::vector< LocalOrdinal > > > neighborElementBlocks_
virtual const std::vector< LocalOrdinal > & getElementBlock(const std::string &blockId) const
Teuchos::RCP< const STK_Interface > stkMeshDB_
std::map< std::string, GlobalOrdinal > blockIdToIndex_
Kokkos::DynRankView< LocalOrdinal, PHX::Device >::HostMirror LocalOrdinalView
std::vector< GlobalOrdinal > connectivity_
virtual LocalOrdinal getConnectivitySize(LocalOrdinal localElmtId) const
virtual const std::vector< LocalOrdinal > & getNeighborElementBlock(const std::string &blockId) const
const LocalOrdinalView getElementLidToConnView()
std::vector< std::vector< LocalOrdinal > > elmtToAssociatedElmts_
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
virtual const panzer::GlobalOrdinal * getConnectivity(LocalOrdinal localElmtId) const
panzer::GlobalOrdinal GlobalOrdinal
Pure virtual base class for supplying mesh connectivity information to the DOF Manager.
virtual void getElementBlockIds(std::vector< std::string > &elementBlockIds) const
virtual panzer::GlobalOrdinal * getConnectivity(LocalOrdinal localElmtId)
std::vector< LocalOrdinal > elmtLidToConn_
std::vector< std::string > sidesetsToAssociate_
std::size_t getOwnedElementCount() const
virtual const std::vector< LocalOrdinal > & getAssociatedNeighbors(const LocalOrdinal &el) const
Kokkos::DynRankView< GlobalOrdinal, PHX::Device >::HostMirror GlobalOrdinalView
Teuchos::RCP< const STK_Interface > getSTKInterface() const
LocalOrdinal addSubcellConnectivities(stk::mesh::Entity element, unsigned subcellRank, LocalOrdinal idCnt, GlobalOrdinal offset)
virtual std::string getBlockId(LocalOrdinal localElmtId) const
Teuchos::RCP< std::vector< stk::mesh::Entity > > elements_
virtual void buildConnectivity(const panzer::FieldPattern &fp)
virtual Teuchos::RCP< panzer::ConnManager > noConnectivityClone() const
STKConnManager(const Teuchos::RCP< const STK_Interface > &stkMeshDB)
void associateElementsInSideset(const std::string sideset_id)
std::vector< LocalOrdinal > connSize_