Panzer Version of the Day
Loading...
Searching...
No Matches
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
24
27
28namespace panzer_stk {
29
31public:
34 typedef typename Kokkos::DynRankView<GlobalOrdinal,PHX::Device>::host_mirror_type GlobalOrdinalView;
35 typedef typename Kokkos::DynRankView<LocalOrdinal, PHX::Device>::host_mirror_type LocalOrdinalView;
36
37 STKConnManager(const Teuchos::RCP<const STK_Interface> & stkMeshDB);
38
40
41 virtual ~STKConnManager() {}
42
48 virtual void buildConnectivity(const panzer::FieldPattern & fp);
49
54 virtual Teuchos::RCP<panzer::ConnManager> noConnectivityClone() const;
55
63 virtual const panzer::GlobalOrdinal * getConnectivity(LocalOrdinal localElmtId) const
64 { return &connectivity_[elmtLidToConn_[localElmtId]]; }
65
73 virtual panzer::GlobalOrdinal * getConnectivity(LocalOrdinal localElmtId)
74 { return &connectivity_[elmtLidToConn_[localElmtId]]; }
75
83 { return connSize_[localElmtId]; }
84
87
90
93
98 virtual std::string getBlockId(LocalOrdinal localElmtId) const;
99
102 virtual std::size_t numElementBlocks() const
103 { return stkMeshDB_->getNumElementBlocks(); }
104
107 virtual void getElementBlockIds(std::vector<std::string> & elementBlockIds) const
108 { return stkMeshDB_->getElementBlockNames(elementBlockIds); }
109
112 virtual void getElementBlockTopologies(std::vector<shards::CellTopology> & elementBlockTopologies) const{
113 std::vector<std::string> elementBlockIds;
114 getElementBlockIds(elementBlockIds);
115 elementBlockTopologies.reserve(elementBlockIds.size());
116
117 for (unsigned i=0; i<elementBlockIds.size(); ++i) {
118 elementBlockTopologies.push_back(*(stkMeshDB_->getCellTopology(elementBlockIds[i])));
119 }
120 }
128 virtual const std::vector<LocalOrdinal> & getElementBlock(const std::string & blockId) const
129 { return *(elementBlocks_.find(blockId)->second); }
130
139 virtual const std::vector<LocalOrdinal> & getNeighborElementBlock(const std::string & blockId) const
140 { return *(neighborElementBlocks_.find(blockId)->second); }
141
150 virtual void getDofCoords(const std::string & blockId,
151 const panzer::Intrepid2FieldPattern & coordProvider,
152 std::vector<std::size_t> & localCellIds,
153 Kokkos::DynRankView<double,PHX::Device> & points) const;
154
157 Teuchos::RCP<const STK_Interface> getSTKInterface() const
158 { return stkMeshDB_; }
159
167 std::size_t getOwnedElementCount() const
168 { return ownedElementCount_; }
169
173 void associateElementsInSideset(const std::string sideset_id);
174
180 std::vector<std::string> checkAssociateElementsInSidesets(const Teuchos::Comm<int>& comm) const;
181
185 virtual const std::vector<LocalOrdinal>& getAssociatedNeighbors(const LocalOrdinal& el) const;
186
190 virtual bool hasAssociatedNeighbors() const;
191
193 static void cacheConnectivity()
194 { cache_connectivity_ = true; }
195
199
202 { return cached_reuse_count_; }
203
204protected:
210 void applyPeriodicBCs( const panzer::FieldPattern & fp, GlobalOrdinal nodeOffset, GlobalOrdinal edgeOffset,
211 GlobalOrdinal faceOffset, GlobalOrdinal cellOffset);
213
217 LocalOrdinal & nodeIdCnt, LocalOrdinal & edgeIdCnt,
218 LocalOrdinal & faceIdCnt, LocalOrdinal & cellIdCnt,
219 GlobalOrdinal & nodeOffset, GlobalOrdinal & edgeOffset,
220 GlobalOrdinal & faceOffset, GlobalOrdinal & cellOffset) const;
221
235 LocalOrdinal addSubcellConnectivities(stk::mesh::Entity element,unsigned subcellRank,
236 LocalOrdinal idCnt,GlobalOrdinal offset,const unsigned maxIds=0);
237
238 void modifySubcellConnectivities(const panzer::FieldPattern & fp, stk::mesh::Entity element,
239 unsigned subcellRank,unsigned subcellId,GlobalOrdinal newId,GlobalOrdinal offset);
240
241 Teuchos::RCP<const STK_Interface> stkMeshDB_;
242
243 Teuchos::RCP<std::vector<stk::mesh::Entity> > elements_;
244
245 // element block information
246 std::map<std::string,Teuchos::RCP<std::vector<LocalOrdinal> > > elementBlocks_;
247 std::map<std::string,Teuchos::RCP<std::vector<LocalOrdinal> > > neighborElementBlocks_;
248 std::map<std::string,GlobalOrdinal> blockIdToIndex_;
249
250 std::vector<LocalOrdinal> elmtLidToConn_; // element LID to Connectivity map
251 std::vector<LocalOrdinal> connSize_; // element LID to Connectivity map
252 std::vector<GlobalOrdinal> connectivity_; // Connectivity
253
255
256 std::vector<std::string> sidesetsToAssociate_;
258 std::vector<std::vector<LocalOrdinal> > elmtToAssociatedElmts_;
259
260 using CachedEntry = std::pair<Teuchos::RCP<const panzer::FieldPattern>,Teuchos::RCP<panzer_stk::STKConnManager>>;
262 Teuchos::RCP<const panzer::FieldPattern> fp_;
263 FieldPatternCompare(const Teuchos::RCP<const panzer::FieldPattern>& fp):fp_(fp){}
264 bool inline operator()(CachedEntry& entry_to_compare) const
265 { return fp_->equals(*entry_to_compare.first); }
266 };
267
269 static std::vector<CachedEntry> cached_conn_managers_;
271};
272
273}
274
275#endif
Pure virtual base class for supplying mesh connectivity information to the DOF Manager.
panzer::GlobalOrdinal GlobalOrdinal
std::vector< std::string > checkAssociateElementsInSidesets(const Teuchos::Comm< int > &comm) const
void applyPeriodicBCs(const panzer::FieldPattern &fp, GlobalOrdinal nodeOffset, GlobalOrdinal edgeOffset, GlobalOrdinal faceOffset, GlobalOrdinal cellOffset)
Teuchos::RCP< std::vector< stk::mesh::Entity > > elements_
const LocalOrdinalView getElementLidToConnView()
virtual Teuchos::RCP< panzer::ConnManager > noConnectivityClone() const
Kokkos::DynRankView< GlobalOrdinal, PHX::Device >::host_mirror_type GlobalOrdinalView
virtual const panzer::GlobalOrdinal * getConnectivity(LocalOrdinal localElmtId) const
std::map< std::string, Teuchos::RCP< std::vector< LocalOrdinal > > > neighborElementBlocks_
panzer::ConnManager::LocalOrdinal LocalOrdinal
virtual void getDofCoords(const std::string &blockId, const panzer::Intrepid2FieldPattern &coordProvider, std::vector< std::size_t > &localCellIds, Kokkos::DynRankView< double, PHX::Device > &points) const
static int getCachedReuseCount()
This is purely for unit testing. Returns the number of times that buildConnectivity() was called,...
std::vector< std::vector< LocalOrdinal > > elmtToAssociatedElmts_
std::vector< LocalOrdinal > connSize_
static void cacheConnectivity()
Enables the caching of connectivity data. Be sure to call clearCachedConnectivityData() before exitin...
void buildOffsetsAndIdCounts(const panzer::FieldPattern &fp, LocalOrdinal &nodeIdCnt, LocalOrdinal &edgeIdCnt, LocalOrdinal &faceIdCnt, LocalOrdinal &cellIdCnt, GlobalOrdinal &nodeOffset, GlobalOrdinal &edgeOffset, GlobalOrdinal &faceOffset, GlobalOrdinal &cellOffset) const
panzer::ConnManager::GlobalOrdinal GlobalOrdinal
virtual panzer::GlobalOrdinal * getConnectivity(LocalOrdinal localElmtId)
virtual void buildConnectivity(const panzer::FieldPattern &fp)
std::vector< bool > sidesetYieldedAssociations_
const LocalOrdinalView getConnectivitySizeView()
static std::vector< CachedEntry > cached_conn_managers_
virtual bool hasAssociatedNeighbors() 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 getElementBlockIds(std::vector< std::string > &elementBlockIds) const
virtual LocalOrdinal getConnectivitySize(LocalOrdinal localElmtId) const
Kokkos::DynRankView< LocalOrdinal, PHX::Device >::host_mirror_type LocalOrdinalView
std::vector< std::string > sidesetsToAssociate_
virtual void getElementBlockTopologies(std::vector< shards::CellTopology > &elementBlockTopologies) const
virtual const std::vector< LocalOrdinal > & getAssociatedNeighbors(const LocalOrdinal &el) const
std::map< std::string, Teuchos::RCP< std::vector< LocalOrdinal > > > elementBlocks_
virtual const std::vector< LocalOrdinal > & getNeighborElementBlock(const std::string &blockId) const
Teuchos::RCP< const STK_Interface > getSTKInterface() const
std::map< std::string, GlobalOrdinal > blockIdToIndex_
virtual const std::vector< LocalOrdinal > & getElementBlock(const std::string &blockId) const
Teuchos::RCP< const STK_Interface > stkMeshDB_
virtual std::string getBlockId(LocalOrdinal localElmtId) const
std::vector< LocalOrdinal > elmtLidToConn_
void associateElementsInSideset(const std::string sideset_id)
std::pair< Teuchos::RCP< const panzer::FieldPattern >, Teuchos::RCP< panzer_stk::STKConnManager > > CachedEntry
static void clearCachedConnectivityData()
If you enable caching with cacheConnectivity(), this must be called prior to exiting the code.
void modifySubcellConnectivities(const panzer::FieldPattern &fp, stk::mesh::Entity element, unsigned subcellRank, unsigned subcellId, GlobalOrdinal newId, GlobalOrdinal offset)
std::vector< GlobalOrdinal > connectivity_
virtual std::size_t numElementBlocks() const
const GlobalOrdinalView getConnectivityView()
Teuchos::RCP< const panzer::FieldPattern > fp_
FieldPatternCompare(const Teuchos::RCP< const panzer::FieldPattern > &fp)
bool operator()(CachedEntry &entry_to_compare) const