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 
62 template <typename GO>
63 class STKConnManager : public panzer::ConnManager<int,GO> {
64 public:
67 
69 
70  virtual ~STKConnManager() {}
71 
77  virtual void buildConnectivity(const panzer::FieldPattern & fp);
78 
84 
92  virtual const GlobalOrdinal * getConnectivity(LocalOrdinal localElmtId) const
93  { return &connectivity_[elmtLidToConn_[localElmtId]]; }
94 
103  { return &connectivity_[elmtLidToConn_[localElmtId]]; }
104 
111  virtual LocalOrdinal getConnectivitySize(LocalOrdinal localElmtId) const
112  { return connSize_[localElmtId]; }
113 
118  virtual std::string getBlockId(LocalOrdinal localElmtId) const;
119 
122  virtual std::size_t numElementBlocks() const
123  { return stkMeshDB_->getNumElementBlocks(); }
124 
127  virtual void getElementBlockIds(std::vector<std::string> & elementBlockIds) const
128  { return stkMeshDB_->getElementBlockNames(elementBlockIds); }
131  virtual void getElementBlockTopologies(std::vector<shards::CellTopology> & elementBlockTopologies) const{
132  std::vector<std::string> elementBlockIds;
133  getElementBlockIds(elementBlockIds);
134  elementBlockTopologies.reserve(elementBlockIds.size());
135  for (unsigned i=0; i<elementBlockIds.size(); ++i) {
136  elementBlockTopologies.push_back(*(stkMeshDB_->getCellTopology(elementBlockIds[i])));
137  }
138  }
146  virtual const std::vector<LocalOrdinal> & getElementBlock(const std::string & blockId) const
147  { return *(elementBlocks_.find(blockId)->second); }
148 
157  virtual const std::vector<LocalOrdinal> & getNeighborElementBlock(const std::string & blockId) const
158  { return *(neighborElementBlocks_.find(blockId)->second); }
159 
168  virtual void getDofCoords(const std::string & blockId,
169  const panzer::Intrepid2FieldPattern & coordProvider,
170  std::vector<std::size_t> & localCellIds,
171  Kokkos::DynRankView<double,PHX::Device> & points) const;
172 
176  { return stkMeshDB_; }
177 
185  std::size_t getOwnedElementCount() const
186  { return ownedElementCount_; }
187 
191  void associateElementsInSideset(const std::string sideset_id);
192 
198  std::vector<std::string> checkAssociateElementsInSidesets(const Teuchos::Comm<int>& comm) const;
199 
203  virtual const std::vector<LocalOrdinal>& getAssociatedNeighbors(const LocalOrdinal& el) const;
204 
208  virtual bool hasAssociatedNeighbors() const;
209 
210 protected:
216  void applyPeriodicBCs( const panzer::FieldPattern & fp, GlobalOrdinal nodeOffset, GlobalOrdinal edgeOffset,
217  GlobalOrdinal faceOffset, GlobalOrdinal cellOffset);
219 
223  LocalOrdinal & nodeIdCnt, LocalOrdinal & edgeIdCnt,
224  LocalOrdinal & faceIdCnt, LocalOrdinal & cellIdCnt,
225  GlobalOrdinal & nodeOffset, GlobalOrdinal & edgeOffset,
226  GlobalOrdinal & faceOffset, GlobalOrdinal & cellOffset) const;
227 
228  LocalOrdinal addSubcellConnectivities(stk::mesh::Entity element,unsigned subcellRank,
229  LocalOrdinal idCnt,GlobalOrdinal offset);
230 
231  void modifySubcellConnectivities(const panzer::FieldPattern & fp, stk::mesh::Entity element,
232  unsigned subcellRank,unsigned subcellId,GlobalOrdinal newId,GlobalOrdinal offset);
233 
235 
237 
238  // element block information
239  std::map<std::string,Teuchos::RCP<std::vector<LocalOrdinal> > > elementBlocks_;
240  std::map<std::string,Teuchos::RCP<std::vector<LocalOrdinal> > > neighborElementBlocks_;
241  std::map<std::string,GlobalOrdinal> blockIdToIndex_;
242 
243  std::vector<LocalOrdinal> elmtLidToConn_; // element LID to Connectivity map
244  std::vector<LocalOrdinal> connSize_; // element LID to Connectivity map
245  std::vector<GlobalOrdinal> connectivity_; // Connectivity
246 
247  std::size_t ownedElementCount_;
248 
249  std::vector<std::string> sidesetsToAssociate_;
250  std::vector<bool> sidesetYieldedAssociations_;
251  std::vector<std::vector<LocalOrdinal> > elmtToAssociatedElmts_;
252 };
253 
254 }
255 
256 #endif
std::vector< bool > sidesetYieldedAssociations_
panzer::ConnManager< int, GO >::GlobalOrdinal GlobalOrdinal
void associateElementsInSideset(const std::string sideset_id)
virtual Teuchos::RCP< panzer::ConnManagerBase< int > > noConnectivityClone() const
GlobalOrdinalT GlobalOrdinal
std::vector< GlobalOrdinal > connectivity_
std::vector< std::vector< LocalOrdinal > > elmtToAssociatedElmts_
virtual void buildConnectivity(const panzer::FieldPattern &fp)
std::map< std::string, GlobalOrdinal > blockIdToIndex_
virtual const std::vector< LocalOrdinal > & getElementBlock(const std::string &blockId) const
STKConnManager(const Teuchos::RCP< const STK_Interface > &stkMeshDB)
virtual bool hasAssociatedNeighbors() const
virtual const std::vector< LocalOrdinal > & getNeighborElementBlock(const std::string &blockId) const
virtual std::size_t numElementBlocks() const
virtual const std::vector< LocalOrdinal > & getAssociatedNeighbors(const LocalOrdinal &el) const
std::size_t getOwnedElementCount() 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
std::map< std::string, Teuchos::RCP< std::vector< LocalOrdinal > > > neighborElementBlocks_
panzer::ConnManager< int, GO >::LocalOrdinal LocalOrdinal
LocalOrdinal addSubcellConnectivities(stk::mesh::Entity element, unsigned subcellRank, LocalOrdinal idCnt, GlobalOrdinal offset)
std::vector< LocalOrdinal > connSize_
void modifySubcellConnectivities(const panzer::FieldPattern &fp, stk::mesh::Entity element, unsigned subcellRank, unsigned subcellId, GlobalOrdinal newId, GlobalOrdinal offset)
virtual void getElementBlockTopologies(std::vector< shards::CellTopology > &elementBlockTopologies) const
virtual LocalOrdinal getConnectivitySize(LocalOrdinal localElmtId) const
std::vector< std::string > checkAssociateElementsInSidesets(const Teuchos::Comm< int > &comm) const
virtual void getElementBlockIds(std::vector< std::string > &elementBlockIds) const
virtual GlobalOrdinal * getConnectivity(LocalOrdinal localElmtId)
Teuchos::RCP< std::vector< stk::mesh::Entity > > elements_
std::vector< std::string > sidesetsToAssociate_
void applyPeriodicBCs(const panzer::FieldPattern &fp, GlobalOrdinal nodeOffset, GlobalOrdinal edgeOffset, GlobalOrdinal faceOffset, GlobalOrdinal cellOffset)
virtual std::string getBlockId(LocalOrdinal localElmtId) const
std::vector< LocalOrdinal > elmtLidToConn_
void buildOffsetsAndIdCounts(const panzer::FieldPattern &fp, LocalOrdinal &nodeIdCnt, LocalOrdinal &edgeIdCnt, LocalOrdinal &faceIdCnt, LocalOrdinal &cellIdCnt, GlobalOrdinal &nodeOffset, GlobalOrdinal &edgeOffset, GlobalOrdinal &faceOffset, GlobalOrdinal &cellOffset) const
Teuchos::RCP< const STK_Interface > getSTKInterface() const
virtual const GlobalOrdinal * getConnectivity(LocalOrdinal localElmtId) const
std::map< std::string, Teuchos::RCP< std::vector< LocalOrdinal > > > elementBlocks_
Teuchos::RCP< const STK_Interface > stkMeshDB_