43 #ifndef __Panzer_GlobalIndexer_hpp__ 
   44 #define __Panzer_GlobalIndexer_hpp__ 
   48 #include <unordered_map>  
   50 #include "Teuchos_Comm.hpp" 
   51 #include "Phalanx_KokkosDeviceTypes.hpp" 
   52 #include "PanzerDofMgr_config.hpp" 
   86    virtual int getFieldNum(
const std::string & str) 
const = 0;
 
   90    virtual void getFieldOrder(std::vector<std::string> & fieldOrder) 
const = 0;
 
  105    virtual void getElementBlockIds(std::vector<std::string> & elementBlockIds) 
const = 0; 
 
  109    virtual bool fieldInBlock(
const std::string & 
field, 
const std::string & block) 
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;
 
  168    getOwnedIndices(std::vector<panzer::GlobalOrdinal>& indices) 
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 
  265                        Kokkos::View<panzer::LocalOrdinal**,PHX::Device> 
lids)
 const 
  272      Kokkos::parallel_for(cellIds.extent(0),functor);
 
  291      Kokkos::View<const panzer::LocalOrdinal**,Kokkos::LayoutRight,PHX::Device> 
global_lids;
 
  294      KOKKOS_INLINE_FUNCTION
 
  297        for(
int i=0;i<static_cast<int>(
local_lids.extent(1));i++) 
 
  315      std::vector<std::vector<panzer::LocalOrdinal> > localIDs; 
 
  329    void setLocalIds(
const std::vector<std::vector<panzer::LocalOrdinal> > & localIDs)
 
  333      for(std::size_t i=0;i<localIDs.size();i++)
 
  334        max = localIDs[i].size() > max ? localIDs[i].size() : max;
 
  337      Kokkos::View<panzer::LocalOrdinal**,Kokkos::LayoutRight,PHX::Device> localIDs_k 
 
  338        = Kokkos::View<panzer::LocalOrdinal**,Kokkos::LayoutRight,PHX::Device>(
"ugi:localIDs_",localIDs.size(),max);
 
  339      for(std::size_t i=0;i<localIDs.size();i++) {
 
  340        for(std::size_t j=0;j<localIDs[i].size();j++)
 
  341          localIDs_k(i,j) = localIDs[i][j];
 
  359   Kokkos::View<const panzer::LocalOrdinal**,Kokkos::LayoutRight,PHX::Device> 
localIDs_k_;
 
  365   std::vector<panzer::GlobalOrdinal> ownedAndGhosted;
 
  369   std::unordered_map<panzer::GlobalOrdinal,panzer::LocalOrdinal> hashMap;
 
  370   for(std::size_t i=0;i<ownedAndGhosted.size();i++)
 
  371     hashMap[ownedAndGhosted[i]] = i;
 
  373   std::vector<std::string> elementBlocks;
 
  377   std::size_t numElmts = 0;
 
  378   for(std::size_t eb=0;eb<elementBlocks.size();eb++)
 
  380   localIDs.resize(numElmts); 
 
  383   for(std::size_t eb=0;eb<elementBlocks.size();eb++) {
 
  384     std::vector<panzer::GlobalOrdinal> gids;
 
  385     const std::vector<panzer::LocalOrdinal> & elmts = this->
getElementBlock(elementBlocks[eb]);
 
  387     for(std::size_t e=0;e<elmts.size();e++) {
 
  389       std::vector<panzer::LocalOrdinal> & 
lids = localIDs[elmts[e]];
 
  390       lids.resize(gids.size());
 
  392       for(std::size_t g=0;g<gids.size();g++)
 
  393         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. 
 
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 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
 
Kokkos::View< const panzer::LocalOrdinal **, Kokkos::LayoutRight, PHX::Device > global_lids
 
void getElementLIDs(Kokkos::View< const int *, PHX::Device > cellIds, Kokkos::View< panzer::LocalOrdinal **, PHX::Device > lids) 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. 
 
Kokkos::View< const LO **, PHX::Device > lids
 
virtual void getOwnedIndices(std::vector< panzer::GlobalOrdinal > &indices) const =0
Get the set of indices owned by this processor. 
 
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
 
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...
 
Kokkos::View< const int *, PHX::Device > cellIds
 
KOKKOS_INLINE_FUNCTION void operator()(const int cell) 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 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. 
 
Kokkos::View< panzer::LocalOrdinal **, PHX::Device > local_lids
 
virtual void getFieldOrder(std::vector< std::string > &fieldOrder) const =0
 
PHX::Device execution_space
 
void buildLocalIdsFromOwnedElements(std::vector< std::vector< panzer::LocalOrdinal > > &localIDs) const