43#ifndef __Panzer_GlobalIndexer_hpp__
44#define __Panzer_GlobalIndexer_hpp__
48#include <unordered_map>
49#include "Teuchos_RCP.hpp"
50#include "Teuchos_Comm.hpp"
51#include "Phalanx_KokkosDeviceTypes.hpp"
52#include "PanzerDofMgr_config.hpp"
66 virtual Teuchos::RCP<Teuchos::Comm<int> >
getComm()
const = 0;
90 virtual void getFieldOrder(std::vector<std::string> & fieldOrder)
const = 0;
118 virtual const std::vector<int> &
getGIDFieldOffsets(
const std::string & blockId,
int fieldNum)
const = 0;
132 virtual const std::pair<std::vector<int>,std::vector<int> > &
134 int subcellDim,
int subcellId)
const = 0;
145 virtual void getElementOrientation(panzer::LocalOrdinal localElmtId,std::vector<double> & gidsOrientation)
const = 0;
154 virtual const std::vector<panzer::LocalOrdinal> &
getElementBlock(
const std::string & blockId)
const = 0;
159 virtual void getElementGIDs(panzer::LocalOrdinal localElmtId,std::vector<panzer::GlobalOrdinal> & gids,
const std::string & blockIdHint=
"")
const = 0;
194 virtual void getElementGIDsAsInt(panzer::LocalOrdinal localElmtId,std::vector<int> & gids,
const std::string & blockIdHint=
"")
const = 0;
248 virtual void ownedIndices(
const std::vector<panzer::GlobalOrdinal> & indices,std::vector<bool> & isOwned)
const = 0;
253 const Kokkos::View<const panzer::LocalOrdinal*,Kokkos::LayoutRight,PHX::Device>
getElementLIDs(panzer::LocalOrdinal localElmtId)
const
254 {
return Kokkos::subview(
localIDs_k_, localElmtId, Kokkos::ALL() ); }
258 const Kokkos::View<const panzer::LocalOrdinal**,Kokkos::LayoutRight,PHX::Device>
getLIDs()
const
277 template <
typename ArrayT>
290 TEUCHOS_ASSERT(functor.
local_lids.extent(1) >= num_dofs);
291 TEUCHOS_ASSERT(functor.
global_lids.extent(1) >= num_dofs);
294 Kokkos::parallel_for(cellIds.extent(0),functor);
308 template <
typename ArrayT>
314 Kokkos::View<const panzer::LocalOrdinal**,Kokkos::LayoutRight,PHX::Device>
global_lids;
318 KOKKOS_INLINE_FUNCTION
339 std::vector<std::vector<panzer::LocalOrdinal> > localIDs;
353 void setLocalIds(
const std::vector<std::vector<panzer::LocalOrdinal> > & localIDs)
357 for(std::size_t i=0;i<localIDs.size();i++)
358 max = localIDs[i].size() > max ? localIDs[i].size() : max;
361 Kokkos::View<panzer::LocalOrdinal**,Kokkos::LayoutRight,PHX::Device> localIDs_k
362 = Kokkos::View<panzer::LocalOrdinal**,Kokkos::LayoutRight,PHX::Device>(
"ugi:localIDs_",localIDs.size(),max);
363 auto localIDs_h = Kokkos::create_mirror_view(localIDs_k);
364 for(std::size_t i=0;i<localIDs.size();i++) {
365 for(std::size_t j=0;j<localIDs[i].size();j++)
366 localIDs_h(i,j) = localIDs[i][j];
368 Kokkos::deep_copy(localIDs_k, localIDs_h);
385 Kokkos::View<const panzer::LocalOrdinal**,Kokkos::LayoutRight,PHX::Device>
localIDs_k_;
391 std::vector<panzer::GlobalOrdinal> ownedAndGhosted;
395 std::unordered_map<panzer::GlobalOrdinal,panzer::LocalOrdinal> hashMap;
396 for(std::size_t i=0;i<ownedAndGhosted.size();i++)
397 hashMap[ownedAndGhosted[i]] = i;
399 std::vector<std::string> elementBlocks;
403 std::size_t numElmts = 0;
404 for(std::size_t eb=0;eb<elementBlocks.size();eb++)
406 localIDs.resize(numElmts);
409 for(std::size_t eb=0;eb<elementBlocks.size();eb++) {
410 std::vector<panzer::GlobalOrdinal> gids;
411 const std::vector<panzer::LocalOrdinal> & elmts = this->
getElementBlock(elementBlocks[eb]);
413 for(std::size_t e=0;e<elmts.size();e++) {
415 std::vector<panzer::LocalOrdinal> &
lids = localIDs[elmts[e]];
416 lids.resize(gids.size());
418 for(std::size_t g=0;g<gids.size();g++)
419 lids[g] = hashMap[gids[g]];
PHX::MDField< ScalarT, panzer::Cell, panzer::BASIS > field
A field to which we'll contribute, or in which we'll store, the result of computing this integral.
Kokkos::View< const LO **, Kokkos::LayoutRight, PHX::Device > lids
PHX::View< const int * > cellIds
KOKKOS_INLINE_FUNCTION void operator()(const int cell) const
PHX::Device execution_space
Kokkos::View< const panzer::LocalOrdinal **, Kokkos::LayoutRight, PHX::Device > global_lids
virtual const std::string & getFieldString(int num) const =0
Reverse lookup of the field string from a field number.
virtual void getGhostedIndices(std::vector< panzer::GlobalOrdinal > &indices) const =0
Get the set of indices ghosted for this processor.
virtual const std::vector< panzer::LocalOrdinal > & getElementBlock(const std::string &blockId) const =0
virtual void ownedIndices(const std::vector< panzer::GlobalOrdinal > &indices, std::vector< bool > &isOwned) const =0
void setLocalIds(const std::vector< std::vector< panzer::LocalOrdinal > > &localIDs)
virtual const std::vector< int > & getBlockFieldNumbers(const std::string &blockId) const =0
virtual ~GlobalIndexer()
Pure virtual destructor: prevents warnings with inline empty implementation.
virtual const std::pair< std::vector< int >, std::vector< int > > & getGIDFieldOffsets_closure(const std::string &blockId, int fieldNum, int subcellDim, int subcellId) const =0
Use the field pattern so that you can find a particular field in the GIDs array. This version lets yo...
virtual void getGhostedIndicesAsInt(std::vector< int > &indices) const =0
Get the set of indices ghosted for this processor.
void getElementLIDs(PHX::View< const int * > cellIds, ArrayT lids, const int num_dofs=0) const
virtual const std::vector< int > & getGIDFieldOffsets(const std::string &blockId, int fieldNum) const =0
Use the field pattern so that you can find a particular field in the GIDs array.
virtual void getElementGIDs(panzer::LocalOrdinal localElmtId, std::vector< panzer::GlobalOrdinal > &gids, const std::string &blockIdHint="") const =0
Get the global IDs for a particular element. This function overwrites the gids variable.
virtual void getOwnedAndGhostedIndicesAsInt(std::vector< int > &indices) const =0
Get the set of owned and ghosted indices for this processor.
void shareLocalIDs(const GlobalIndexer &src)
virtual void getElementGIDsAsInt(panzer::LocalOrdinal localElmtId, std::vector< int > &gids, const std::string &blockIdHint="") const =0
Get the global IDs for a particular element. This function overwrites the gids variable.
virtual int getNumGhosted() const =0
Get the number of indices ghosted for this processor.
virtual int getNumOwned() const =0
Get the number of indices owned by this processor.
virtual int getNumFields() const =0
virtual void getOwnedAndGhostedIndices(std::vector< panzer::GlobalOrdinal > &indices) const =0
Get the set of owned and ghosted indices for this processor.
virtual Teuchos::RCP< Teuchos::Comm< int > > getComm() const =0
virtual int getElementBlockGIDCount(const std::size_t &blockIndex) const =0
How any GIDs are associate with each element in a particular element block.
const Kokkos::View< const panzer::LocalOrdinal **, Kokkos::LayoutRight, PHX::Device > getLIDs() const
virtual int getNumOwnedAndGhosted() const =0
Get the number of owned and ghosted indices for this processor.
virtual void getOwnedIndices(std::vector< panzer::GlobalOrdinal > &indices) const =0
Get the set of indices owned by this processor.
virtual void getFieldOrder(std::vector< std::string > &fieldOrder) const =0
const Kokkos::View< const panzer::LocalOrdinal *, Kokkos::LayoutRight, PHX::Device > getElementLIDs(panzer::LocalOrdinal localElmtId) const
Kokkos::View< const panzer::LocalOrdinal **, Kokkos::LayoutRight, PHX::Device > localIDs_k_
virtual Teuchos::RCP< const ConnManager > getConnManager() const =0
Returns the connection manager currently being used.
virtual int getFieldNum(const std::string &str) const =0
Get the number used for access to this field.
virtual void getOwnedIndicesAsInt(std::vector< int > &indices) const =0
Get the set of indices owned by this processor.
virtual int getElementBlockGIDCount(const std::string &blockId) const =0
How many GIDs are associated with each element in a particular element block.
virtual void getElementOrientation(panzer::LocalOrdinal localElmtId, std::vector< double > &gidsOrientation) const =0
Get a vector containg the orientation of the GIDs relative to the neighbors.
virtual void getElementBlockIds(std::vector< std::string > &elementBlockIds) const =0
virtual bool fieldInBlock(const std::string &field, const std::string &block) const =0
void buildLocalIdsFromOwnedElements(std::vector< std::vector< panzer::LocalOrdinal > > &localIDs) const