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
35public:
38 typedef typename Kokkos::DynRankView<GlobalOrdinal,PHX::Device>::host_mirror_type GlobalOrdinalView;
39 typedef typename Kokkos::DynRankView<LocalOrdinal, PHX::Device>::host_mirror_type LocalOrdinalView;
40
42 STKConnManager(const Teuchos::RCP<const STK_Interface> & stkMeshDB);
43
46
47 virtual ~STKConnManager() {}
48
54 virtual void buildConnectivity(const panzer::FieldPattern & fp);
55
60 virtual Teuchos::RCP<panzer::ConnManager> noConnectivityClone() const;
61
69 virtual const panzer::GlobalOrdinal * getConnectivity(LocalOrdinal localElmtId) const
70 { return &connectivity_[elmtLidToConn_[localElmtId]]; }
71
79 virtual panzer::GlobalOrdinal * getConnectivity(LocalOrdinal localElmtId)
80 { return &connectivity_[elmtLidToConn_[localElmtId]]; }
81
89 { return connSize_[localElmtId]; }
90
94
98
102
107 virtual std::string getBlockId(LocalOrdinal localElmtId) const;
108
111 virtual std::size_t numElementBlocks() const
112 { return stkMeshDB_->getNumElementBlocks(); }
113
116 virtual void getElementBlockIds(std::vector<std::string> & elementBlockIds) const
117 { return stkMeshDB_->getElementBlockNames(elementBlockIds); }
118
121 virtual void getElementBlockTopologies(std::vector<shards::CellTopology> & elementBlockTopologies) const{
122 std::vector<std::string> elementBlockIds;
123 getElementBlockIds(elementBlockIds);
124 elementBlockTopologies.reserve(elementBlockIds.size());
125
126 for (unsigned i=0; i<elementBlockIds.size(); ++i) {
127 elementBlockTopologies.push_back(*(stkMeshDB_->getCellTopology(elementBlockIds[i])));
128 }
129 }
137 virtual const std::vector<LocalOrdinal> & getElementBlock(const std::string & blockId) const
138 { return *(elementBlocks_.find(blockId)->second); }
139
148 virtual const std::vector<LocalOrdinal> & getNeighborElementBlock(const std::string & blockId) const
149 { return *(neighborElementBlocks_.find(blockId)->second); }
150
159 virtual void getDofCoords(const std::string & blockId,
160 const panzer::Intrepid2FieldPattern & coordProvider,
161 std::vector<std::size_t> & localCellIds,
162 Kokkos::DynRankView<double,PHX::Device> & points) const;
163
166 Teuchos::RCP<const STK_Interface> getSTKInterface() const
167 { return stkMeshDB_; }
168
176 std::size_t getOwnedElementCount() const
177 { return ownedElementCount_; }
178
182 void associateElementsInSideset(const std::string sideset_id);
183
189 std::vector<std::string> checkAssociateElementsInSidesets(const Teuchos::Comm<int>& comm) const;
190
194 virtual const std::vector<LocalOrdinal>& getAssociatedNeighbors(const LocalOrdinal& el) const;
195
199 virtual bool hasAssociatedNeighbors() const;
200
202 static void cacheConnectivity()
203 { cache_connectivity_ = true; }
204
207 {
208 PANZER_FUNC_TIME_MONITOR("panzer::ConnectivityManager::clearCachedConnectivityData()");
209 cached_conn_managers_.clear();
210 }
211
214 { return cached_reuse_count_; }
215
216protected:
222 void applyPeriodicBCs( const panzer::FieldPattern & fp, GlobalOrdinal nodeOffset, GlobalOrdinal edgeOffset,
223 GlobalOrdinal faceOffset, GlobalOrdinal cellOffset);
225
229 LocalOrdinal & nodeIdCnt, LocalOrdinal & edgeIdCnt,
230 LocalOrdinal & faceIdCnt, LocalOrdinal & cellIdCnt,
231 GlobalOrdinal & nodeOffset, GlobalOrdinal & edgeOffset,
232 GlobalOrdinal & faceOffset, GlobalOrdinal & cellOffset) const;
233
247 LocalOrdinal addSubcellConnectivities(stk::mesh::Entity element,unsigned subcellRank,
248 LocalOrdinal idCnt,GlobalOrdinal offset,const unsigned maxIds=0);
249
250 void modifySubcellConnectivities(const panzer::FieldPattern & fp, stk::mesh::Entity element,
251 unsigned subcellRank,unsigned subcellId,GlobalOrdinal newId,GlobalOrdinal offset);
252
253 Teuchos::RCP<const STK_Interface> stkMeshDB_;
254
255 Teuchos::RCP<std::vector<stk::mesh::Entity> > elements_;
256
257 // element block information
258 std::map<std::string,Teuchos::RCP<std::vector<LocalOrdinal> > > elementBlocks_;
259 std::map<std::string,Teuchos::RCP<std::vector<LocalOrdinal> > > neighborElementBlocks_;
260 std::map<std::string,GlobalOrdinal> blockIdToIndex_;
261
262 std::vector<LocalOrdinal> elmtLidToConn_; // element LID to Connectivity map
263 std::vector<LocalOrdinal> connSize_; // element LID to Connectivity map
264 std::vector<GlobalOrdinal> connectivity_; // Connectivity
265
267
268 std::vector<std::string> sidesetsToAssociate_;
270 std::vector<std::vector<LocalOrdinal> > elmtToAssociatedElmts_;
271
272 using CachedEntry = std::pair<Teuchos::RCP<const panzer::FieldPattern>,Teuchos::RCP<panzer_stk::STKConnManager>>;
274 Teuchos::RCP<const panzer::FieldPattern> fp_;
275 FieldPatternCompare(const Teuchos::RCP<const panzer::FieldPattern>& fp):fp_(fp){}
276 bool inline operator()(CachedEntry& entry_to_compare) const
277 { return fp_->equals(*entry_to_compare.first); }
278 };
279
281 static std::vector<CachedEntry> cached_conn_managers_;
283};
284
285}
286
287#endif
Pure virtual base class for supplying mesh connectivity information to the DOF Manager.
panzer::GlobalOrdinal GlobalOrdinal
A panzer::ConnManager implementation backed by an STK mesh, mapping local element IDs to global mesh-...
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()
Returns a view of the per-element offset into the flat connectivity array returned by getConnectivity...
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()
Returns a view of the per-element connectivity size array.
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()
Returns a view of the flat connectivity array (all elements' global IDs, concatenated).
Teuchos::RCP< const panzer::FieldPattern > fp_
FieldPatternCompare(const Teuchos::RCP< const panzer::FieldPattern > &fp)
bool operator()(CachedEntry &entry_to_compare) const