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 
68 
69  virtual ~STKConnManager() {}
70 
76  virtual void buildConnectivity(const panzer::FieldPattern & fp);
77 
83 
91  virtual const panzer::GlobalOrdinal * getConnectivity(LocalOrdinal localElmtId) const
92  { return &connectivity_[elmtLidToConn_[localElmtId]]; }
93 
101  virtual panzer::GlobalOrdinal * getConnectivity(LocalOrdinal localElmtId)
102  { return &connectivity_[elmtLidToConn_[localElmtId]]; }
103 
110  virtual LocalOrdinal getConnectivitySize(LocalOrdinal localElmtId) const
111  { return connSize_[localElmtId]; }
112 
117  virtual std::string getBlockId(LocalOrdinal localElmtId) const;
118 
121  virtual std::size_t numElementBlocks() const
122  { return stkMeshDB_->getNumElementBlocks(); }
123 
126  virtual void getElementBlockIds(std::vector<std::string> & elementBlockIds) const
127  { return stkMeshDB_->getElementBlockNames(elementBlockIds); }
130  virtual void getElementBlockTopologies(std::vector<shards::CellTopology> & elementBlockTopologies) const{
131  std::vector<std::string> elementBlockIds;
132  getElementBlockIds(elementBlockIds);
133  elementBlockTopologies.reserve(elementBlockIds.size());
134  for (unsigned i=0; i<elementBlockIds.size(); ++i) {
135  elementBlockTopologies.push_back(*(stkMeshDB_->getCellTopology(elementBlockIds[i])));
136  }
137  }
145  virtual const std::vector<LocalOrdinal> & getElementBlock(const std::string & blockId) const
146  { return *(elementBlocks_.find(blockId)->second); }
147 
156  virtual const std::vector<LocalOrdinal> & getNeighborElementBlock(const std::string & blockId) const
157  { return *(neighborElementBlocks_.find(blockId)->second); }
158 
167  virtual void getDofCoords(const std::string & blockId,
168  const panzer::Intrepid2FieldPattern & coordProvider,
169  std::vector<std::size_t> & localCellIds,
170  Kokkos::DynRankView<double,PHX::Device> & points) const;
171 
175  { return stkMeshDB_; }
176 
184  std::size_t getOwnedElementCount() const
185  { return ownedElementCount_; }
186 
190  void associateElementsInSideset(const std::string sideset_id);
191 
197  std::vector<std::string> checkAssociateElementsInSidesets(const Teuchos::Comm<int>& comm) const;
198 
202  virtual const std::vector<LocalOrdinal>& getAssociatedNeighbors(const LocalOrdinal& el) const;
203 
207  virtual bool hasAssociatedNeighbors() const;
208 
209 protected:
215  void applyPeriodicBCs( const panzer::FieldPattern & fp, GlobalOrdinal nodeOffset, GlobalOrdinal edgeOffset,
216  GlobalOrdinal faceOffset, GlobalOrdinal cellOffset);
218 
222  LocalOrdinal & nodeIdCnt, LocalOrdinal & edgeIdCnt,
223  LocalOrdinal & faceIdCnt, LocalOrdinal & cellIdCnt,
224  GlobalOrdinal & nodeOffset, GlobalOrdinal & edgeOffset,
225  GlobalOrdinal & faceOffset, GlobalOrdinal & cellOffset) const;
226 
227  LocalOrdinal addSubcellConnectivities(stk::mesh::Entity element,unsigned subcellRank,
228  LocalOrdinal idCnt,GlobalOrdinal offset);
229 
230  void modifySubcellConnectivities(const panzer::FieldPattern & fp, stk::mesh::Entity element,
231  unsigned subcellRank,unsigned subcellId,GlobalOrdinal newId,GlobalOrdinal offset);
232 
234 
236 
237  // element block information
238  std::map<std::string,Teuchos::RCP<std::vector<LocalOrdinal> > > elementBlocks_;
239  std::map<std::string,Teuchos::RCP<std::vector<LocalOrdinal> > > neighborElementBlocks_;
240  std::map<std::string,GlobalOrdinal> blockIdToIndex_;
241 
242  std::vector<LocalOrdinal> elmtLidToConn_; // element LID to Connectivity map
243  std::vector<LocalOrdinal> connSize_; // element LID to Connectivity map
244  std::vector<GlobalOrdinal> connectivity_; // Connectivity
245 
246  std::size_t ownedElementCount_;
247 
248  std::vector<std::string> sidesetsToAssociate_;
249  std::vector<bool> sidesetYieldedAssociations_;
250  std::vector<std::vector<LocalOrdinal> > elmtToAssociatedElmts_;
251 };
252 
253 }
254 
255 #endif
std::map< std::string, Teuchos::RCP< std::vector< LocalOrdinal > > > elementBlocks_
virtual const std::vector< LocalOrdinal > & getAssociatedNeighbors(const LocalOrdinal &el) const
virtual std::string getBlockId(LocalOrdinal localElmtId) const
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_
std::vector< GlobalOrdinal > connectivity_
virtual bool hasAssociatedNeighbors() const
std::vector< std::string > checkAssociateElementsInSidesets(const Teuchos::Comm< int > &comm) const
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
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_
LocalOrdinal addSubcellConnectivities(stk::mesh::Entity element, unsigned subcellRank, LocalOrdinal idCnt, GlobalOrdinal offset)
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_