50 #include "Kokkos_DynRankView.hpp"
57 #include "Teuchos_FancyOStream.hpp"
59 namespace panzer_stk {
66 class LocalIdCompare {
68 LocalIdCompare(
const RCP<const STK_Interface> & mesh) : mesh_(mesh) {}
71 bool operator() (stk::mesh::Entity a,stk::mesh::Entity b)
72 {
return mesh_->elementLocalId(a) < mesh_->elementLocalId(b);}
75 RCP<const STK_Interface> mesh_;
79 : stkMeshDB_(stkMeshDB), ownedElementCount_(0)
108 std::vector<std::string> blockIds;
111 std::size_t blockIndex=0;
112 for(std::vector<std::string>::const_iterator idItr=blockIds.begin();
113 idItr!=blockIds.end();++idItr,++blockIndex) {
114 std::string blockId = *idItr;
117 std::vector<stk::mesh::Entity> blockElmts;
118 stkMeshDB_->getMyElements(blockId,blockElmts);
125 for(std::size_t i=0;i<blockElmts.size();i++)
132 for(std::vector<std::string>::const_iterator idItr=blockIds.begin();
133 idItr!=blockIds.end();++idItr,++blockIndex) {
134 std::string blockId = *idItr;
137 std::vector<stk::mesh::Entity> blockElmts;
138 stkMeshDB_->getNeighborElements(blockId,blockElmts);
145 for(std::size_t i=0;i<blockElmts.size();i++)
193 edgeOffset = nodeOffset+(maxNodeId+1)*nodeIdCnt;
194 faceOffset = edgeOffset+(maxEdgeId+1)*edgeIdCnt;
195 cellOffset = faceOffset+(maxFaceId+1)*faceIdCnt;
199 && edgeOffset <= faceOffset
200 && faceOffset <= cellOffset);
205 unsigned subcellRank,
214 stk::mesh::BulkData& bulkData = *
stkMeshDB_->getBulkData();
215 const stk::mesh::EntityRank rank =
static_cast<stk::mesh::EntityRank
>(subcellRank);
216 const size_t num_rels = bulkData.num_connectivity(element, rank);
217 stk::mesh::Entity
const* relations = bulkData.begin(element, rank);
218 for(std::size_t sc=0; sc<num_rels; ++sc) {
219 stk::mesh::Entity subcell = relations[sc];
223 connectivity_.push_back(offset+idCnt*(bulkData.identifier(subcell)-1)+i);
237 const std::vector<int> & subCellIndices = fp.
getSubcellIndices(subcellRank,subcellId);
240 for(std::size_t i=0;i<subCellIndices.size();i++) {
241 conn[subCellIndices[i]] = offset+subCellIndices.size()*(newId-1)+i;
247 #ifdef HAVE_EXTRA_TIMERS
249 RCP<Teuchos::TimeMonitor> tM =
rcp(
new TimeMonitor(*TimeMonitor::getNewTimer(std::string(
"panzer_stk::STKConnManager::buildConnectivity"))));
252 stk::mesh::BulkData& bulkData = *
stkMeshDB_->getBulkData();
262 LocalOrdinal nodeIdCnt=0, edgeIdCnt=0, faceIdCnt=0, cellIdCnt=0;
263 GlobalOrdinal nodeOffset=0, edgeOffset=0, faceOffset=0, cellOffset=0;
265 nodeOffset, edgeOffset, faceOffset, cellOffset);
273 for(std::size_t elmtLid=0;elmtLid!=
elements_->size();++elmtLid) {
275 stk::mesh::Entity element = (*elements_)[elmtLid];
289 connectivity_.push_back(cellOffset+cellIdCnt*(bulkData.identifier(element)-1));
309 stk::mesh::Entity element = (*elements_)[localElmtId];
311 return stkMeshDB_->containingBlockId(element);
320 #ifdef HAVE_EXTRA_TIMERS
322 RCP<Teuchos::TimeMonitor> tM =
rcp(
new TimeMonitor(*TimeMonitor::getNewTimer(std::string(
"panzer_stk::STKConnManager::applyPeriodicBCs"))));
329 = matchedValues.first;
331 = matchedValues.second;
334 if(matchedNodes==Teuchos::null)
return;
336 for(std::size_t m=0;m<matchedNodes->size();m++) {
337 stk::mesh::EntityId oldNodeId = (*matchedNodes)[m].first;
338 std::size_t newNodeId = (*matchedNodes)[m].second;
340 std::vector<stk::mesh::Entity> elements;
341 std::vector<int> localIds;
345 if((*matchTypes)[m] == 0)
346 offset1 = nodeOffset-offset0;
347 else if((*matchTypes)[m] == 1){
349 offset1 = edgeOffset-offset0;
350 }
else if((*matchTypes)[m] == 2){
352 offset1 = faceOffset-offset0;
357 stkMeshDB_->getOwnedElementsSharingNode(oldNodeId-offset0,elements,localIds,(*matchTypes)[m]);
360 for(std::size_t e=0;e<elements.size();e++){
371 std::vector<std::size_t> & localCellIds,
372 Kokkos::DynRankView<double,PHX::Device> & points)
const
378 Kokkos::DynRankView<double,PHX::Device> vertices;
382 points = Kokkos::DynRankView<double,PHX::Device>(
"points",localCellIds.size(),numIds,dim);
399 stk::mesh::Entity
const e)
401 return static_cast<std::size_t
>(
402 std::distance(elements.begin(), std::find(elements.begin(), elements.end(), e)));
407 stk::mesh::BulkData& bulkData = *
stkMeshDB_->getBulkData();
410 std::vector<stk::mesh::Entity> sides;
413 for (std::vector<stk::mesh::Entity>::const_iterator si = sides.begin();
414 si != sides.end(); ++si) {
415 stk::mesh::Entity side = *si;
416 const size_t num_elements = bulkData.num_elements(side);
417 stk::mesh::Entity
const* elements = bulkData.begin_elements(side);
418 if (num_elements != 2) {
436 std::vector<std::string> sidesets;
446 const std::vector<STKConnManager::LocalOrdinal>&
void clearLocalElementMapping()
virtual int getDimension() const =0
void getIdsAndVertices(const panzer_stk::STK_Interface &mesh, std::string blockId, std::vector< std::size_t > &localIds, ArrayT &vertices)
std::map< std::string, Teuchos::RCP< std::vector< LocalOrdinal > > > elementBlocks_
virtual const std::vector< LocalOrdinal > & getAssociatedNeighbors(const LocalOrdinal &el) const
virtual int getDimension() const
virtual std::string getBlockId(LocalOrdinal localElmtId) const
panzer::ConnManager::GlobalOrdinal GlobalOrdinal
std::vector< bool > sidesetYieldedAssociations_
std::map< std::string, Teuchos::RCP< std::vector< LocalOrdinal > > > neighborElementBlocks_
Teuchos::RCP< const STK_Interface > stkMeshDB_
std::vector< GlobalOrdinal > connectivity_
std::size_t ownedElementCount_
virtual bool hasAssociatedNeighbors() const
std::vector< std::string > checkAssociateElementsInSidesets(const Teuchos::Comm< int > &comm) const
std::vector< std::vector< LocalOrdinal > > elmtToAssociatedElmts_
virtual int numberIds() const
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
TEUCHOS_DEPRECATED RCP< T > rcp(T *p, Dealloc_T dealloc, bool owns_mem)
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
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 buildLocalElementMapping()
std::vector< LocalOrdinal > elmtLidToConn_
std::vector< std::string > sidesetsToAssociate_
void getInterpolatoryCoordinates(Kokkos::DynRankView< double, PHX::Device > &coords) const
LocalOrdinal addSubcellConnectivities(stk::mesh::Entity element, unsigned subcellRank, LocalOrdinal idCnt, GlobalOrdinal offset)
virtual const std::vector< int > & getSubcellIndices(int dim, int cellIndex) const =0
void applyInterfaceConditions()
#define TEUCHOS_ASSERT(assertion_test)
Teuchos::RCP< std::vector< stk::mesh::Entity > > elements_
std::size_t getElementIdx(const std::vector< stk::mesh::Entity > &elements, stk::mesh::Entity const e)
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_