11 #ifndef __Panzer_GlobalIndexer_hpp__
12 #define __Panzer_GlobalIndexer_hpp__
16 #include <unordered_map>
18 #include "Teuchos_Comm.hpp"
19 #include "Phalanx_KokkosDeviceTypes.hpp"
20 #include "PanzerDofMgr_config.hpp"
54 virtual int getFieldNum(
const std::string & str)
const = 0;
58 virtual void getFieldOrder(std::vector<std::string> & fieldOrder)
const = 0;
77 virtual bool fieldInBlock(
const std::string &
field,
const std::string & block)
const = 0;
86 virtual const std::vector<int> &
getGIDFieldOffsets(
const std::string & blockId,
int fieldNum)
const = 0;
100 virtual const std::pair<std::vector<int>,std::vector<int> > &
102 int subcellDim,
int subcellId)
const = 0;
113 virtual void getElementOrientation(panzer::LocalOrdinal localElmtId,std::vector<double> & gidsOrientation)
const = 0;
122 virtual const std::vector<panzer::LocalOrdinal> &
getElementBlock(
const std::string & blockId)
const = 0;
127 virtual void getElementGIDs(panzer::LocalOrdinal localElmtId,std::vector<panzer::GlobalOrdinal> & gids,
const std::string & blockIdHint=
"")
const = 0;
136 getOwnedIndices(std::vector<panzer::GlobalOrdinal>& indices)
const = 0;
162 virtual void getElementGIDsAsInt(panzer::LocalOrdinal localElmtId,std::vector<int> & gids,
const std::string & blockIdHint=
"")
const = 0;
216 virtual void ownedIndices(
const std::vector<panzer::GlobalOrdinal> & indices,std::vector<bool> & isOwned)
const = 0;
222 {
return Kokkos::subview(
localIDs_k_, localElmtId, Kokkos::ALL() ); }
245 template <
typename ArrayT>
262 Kokkos::parallel_for(cellIds.extent(0),functor);
276 template <
typename ArrayT>
286 KOKKOS_INLINE_FUNCTION
307 std::vector<std::vector<panzer::LocalOrdinal> > localIDs;
321 void setLocalIds(
const std::vector<std::vector<panzer::LocalOrdinal> > & localIDs)
325 for(std::size_t i=0;i<localIDs.size();i++)
326 max = localIDs[i].size() > max ? localIDs[i].size() : max;
331 auto localIDs_h = Kokkos::create_mirror_view(localIDs_k);
332 for(std::size_t i=0;i<localIDs.size();i++) {
333 for(std::size_t j=0;j<localIDs[i].size();j++)
334 localIDs_h(i,j) = localIDs[i][j];
336 Kokkos::deep_copy(localIDs_k, localIDs_h);
359 std::vector<panzer::GlobalOrdinal> ownedAndGhosted;
363 std::unordered_map<panzer::GlobalOrdinal,panzer::LocalOrdinal> hashMap;
364 for(std::size_t i=0;i<ownedAndGhosted.size();i++)
365 hashMap[ownedAndGhosted[i]] = i;
367 std::vector<std::string> elementBlocks;
371 std::size_t numElmts = 0;
372 for(std::size_t eb=0;eb<elementBlocks.size();eb++)
374 localIDs.resize(numElmts);
377 for(std::size_t eb=0;eb<elementBlocks.size();eb++) {
378 std::vector<panzer::GlobalOrdinal> gids;
379 const std::vector<panzer::LocalOrdinal> & elmts = this->
getElementBlock(elementBlocks[eb]);
381 for(std::size_t e=0;e<elmts.size();e++) {
383 std::vector<panzer::LocalOrdinal> &
lids = localIDs[elmts[e]];
384 lids.resize(gids.size());
386 for(std::size_t g=0;g<gids.size();g++)
387 lids[g] = hashMap[gids[g]];
virtual const std::string & getFieldString(int num) const =0
Reverse lookup of the field string from a field number.
virtual Teuchos::RCP< Teuchos::Comm< int > > getComm() const =0
void shareLocalIDs(const GlobalIndexer &src)
virtual void getGhostedIndices(std::vector< panzer::GlobalOrdinal > &indices) const =0
Get the set of indices ghosted for this processor.
PHX::Device execution_space
const Kokkos::View< const panzer::LocalOrdinal *, Kokkos::LayoutRight, PHX::Device > getElementLIDs(panzer::LocalOrdinal localElmtId) const
virtual void getGhostedIndicesAsInt(std::vector< int > &indices) const =0
Get the set of indices ghosted for this processor.
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 const std::vector< panzer::LocalOrdinal > & getElementBlock(const std::string &blockId) const =0
virtual void getOwnedAndGhostedIndicesAsInt(std::vector< int > &indices) const =0
Get the set of owned and ghosted indices for this processor.
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
void getElementLIDs(PHX::View< const int * > cellIds, ArrayT lids, const int num_dofs=0) const
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.
PHX::View< const int * > cellIds
virtual void getOwnedIndices(std::vector< panzer::GlobalOrdinal > &indices) const =0
Get the set of indices owned by this processor.
Kokkos::View< const LO **, Kokkos::LayoutRight, PHX::Device > lids
virtual bool fieldInBlock(const std::string &field, const std::string &block) const =0
virtual int getNumGhosted() const =0
Get the number of indices ghosted for this processor.
virtual int getNumFields() const =0
Kokkos::View< const panzer::LocalOrdinal **, Kokkos::LayoutRight, PHX::Device > global_lids
virtual void ownedIndices(const std::vector< panzer::GlobalOrdinal > &indices, std::vector< bool > &isOwned) const =0
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 void getOwnedAndGhostedIndices(std::vector< panzer::GlobalOrdinal > &indices) const =0
Get the set of owned and ghosted indices for this processor.
virtual int getNumOwnedAndGhosted() const =0
Get the number of owned and ghosted indices for this processor.
void setLocalIds(const std::vector< std::vector< panzer::LocalOrdinal > > &localIDs)
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 int getNumOwned() const =0
Get the number of indices owned by this processor.
Kokkos::View< const panzer::LocalOrdinal **, Kokkos::LayoutRight, PHX::Device > localIDs_k_
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...
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 const std::vector< int > & getBlockFieldNumbers(const std::string &blockId) const =0
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 getFieldOrder(std::vector< std::string > &fieldOrder) const =0
#define TEUCHOS_ASSERT(assertion_test)
KOKKOS_INLINE_FUNCTION void operator()(const int cell) const
void buildLocalIdsFromOwnedElements(std::vector< std::vector< panzer::LocalOrdinal > > &localIDs) const