43 #ifndef __Panzer_UniqueGlobalIndexer_hpp__
44 #define __Panzer_UniqueGlobalIndexer_hpp__
49 #include <unordered_map>
52 #include "Teuchos_Comm.hpp"
54 #include "Phalanx_KokkosDeviceTypes.hpp"
59 template <
typename LocalOrdinalT>
class ConnManagerBase;
88 virtual int getFieldNum(
const std::string & str)
const = 0;
92 virtual void getFieldOrder(std::vector<std::string> & fieldOrder)
const = 0;
107 virtual void getElementBlockIds(std::vector<std::string> & elementBlockIds)
const = 0;
111 virtual bool fieldInBlock(
const std::string &
field,
const std::string & block)
const = 0;
120 virtual const std::vector<int> &
getGIDFieldOffsets(
const std::string & blockId,
int fieldNum)
const = 0;
134 virtual const std::pair<std::vector<int>,std::vector<int> > &
136 int subcellDim,
int subcellId)
const = 0;
153 template <
typename LocalOrdinalT,
typename GlobalOrdinalT>
181 virtual int getFieldNum(
const std::string & str)
const = 0;
185 virtual void getFieldOrder(std::vector<std::string> & fieldOrder)
const = 0;
189 virtual void getElementBlockIds(std::vector<std::string> & elementBlockIds)
const = 0;
193 virtual bool fieldInBlock(
const std::string &
field,
const std::string & block)
const = 0;
202 virtual const std::vector<int> &
getGIDFieldOffsets(
const std::string & blockId,
int fieldNum)
const = 0;
216 virtual const std::pair<std::vector<int>,std::vector<int> > &
218 int subcellDim,
int subcellId)
const = 0;
225 virtual void getElementOrientation(LocalOrdinalT localElmtId,std::vector<double> & gidsOrientation)
const = 0;
234 virtual const std::vector<LocalOrdinalT> &
getElementBlock(
const std::string & blockId)
const = 0;
239 virtual void getElementGIDs(LocalOrdinalT localElmtId,std::vector<GlobalOrdinalT> & gids,
const std::string & blockIdHint=
"")
const = 0;
249 std::vector<GlobalOrdinalT>& indices)
const = 0;
259 std::vector<GlobalOrdinalT>& indices)
const = 0;
269 std::vector<GlobalOrdinalT>& indices)
const = 0;
297 virtual void ownedIndices(
const std::vector<GlobalOrdinalT> & indices,std::vector<bool> & isOwned)
const = 0;
302 const Kokkos::View<const LocalOrdinalT*,Kokkos::LayoutRight,PHX::Device>
getElementLIDs(LocalOrdinalT localElmtId)
const
303 {
return Kokkos::subview(
localIDs_k_, localElmtId, Kokkos::ALL() ); }
307 const Kokkos::View<const LocalOrdinalT**,Kokkos::LayoutRight,PHX::Device>
getLIDs()
const
314 Kokkos::View<LocalOrdinalT**,PHX::Device>
lids)
const
316 CopyCellLIDsFunctor functor;
317 functor.cellIds = cellIds;
319 functor.local_lids =
lids;
321 Kokkos::parallel_for(cellIds.extent(0),functor);
347 Kokkos::View<const LocalOrdinalT**,Kokkos::LayoutRight,PHX::Device>
global_lids;
350 KOKKOS_INLINE_FUNCTION
353 for(
int i=0;i<static_cast<int>(
local_lids.extent(1));i++)
371 std::vector<std::vector<LocalOrdinalT> > localIDs;
385 void setLocalIds(
const std::vector<std::vector<LocalOrdinalT> > & localIDs)
389 for(std::size_t i=0;i<localIDs.size();i++)
390 max = localIDs[i].size() > max ? localIDs[i].size() : max;
393 Kokkos::View<LocalOrdinalT**,Kokkos::LayoutRight,PHX::Device> localIDs_k
394 = Kokkos::View<LocalOrdinalT**,Kokkos::LayoutRight,PHX::Device>(
"ugi:localIDs_",localIDs.size(),max);
395 for(std::size_t i=0;i<localIDs.size();i++) {
396 for(std::size_t j=0;j<localIDs[i].size();j++)
397 localIDs_k(i,j) = localIDs[i][j];
415 Kokkos::View<const LocalOrdinalT**,Kokkos::LayoutRight,PHX::Device>
localIDs_k_;
422 template <
typename LocalOrdinalT,
typename GlobalOrdinalT>
425 template <
typename LocalOrdinalT,
typename GlobalOrdinalT>
429 std::vector<GlobalOrdinalT> ownedAndGhosted;
430 this->getOwnedAndGhostedIndices(ownedAndGhosted);
433 std::unordered_map<GlobalOrdinalT,LocalOrdinalT> hashMap;
434 for(std::size_t i=0;i<ownedAndGhosted.size();i++)
435 hashMap[ownedAndGhosted[i]] = i;
437 std::vector<std::string> elementBlocks;
438 this->getElementBlockIds(elementBlocks);
441 std::size_t numElmts = 0;
442 for(std::size_t eb=0;eb<elementBlocks.size();eb++)
443 numElmts += this->getElementBlock(elementBlocks[eb]).size();
444 localIDs.resize(numElmts);
447 for(std::size_t eb=0;eb<elementBlocks.size();eb++) {
448 std::vector<GlobalOrdinalT> gids;
449 const std::vector<LocalOrdinalT> & elmts = this->getElementBlock(elementBlocks[eb]);
451 for(std::size_t e=0;e<elmts.size();e++) {
452 this->getElementGIDs(elmts[e],gids,elementBlocks[eb]);
453 std::vector<LocalOrdinalT> &
lids = localIDs[elmts[e]];
454 lids.resize(gids.size());
456 for(std::size_t g=0;g<gids.size();g++)
457 lids[g] = hashMap[gids[g]];
const Kokkos::View< const LocalOrdinalT **, Kokkos::LayoutRight, PHX::Device > getLIDs() const
virtual int getNumFields() const =0
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.
KOKKOS_INLINE_FUNCTION void operator()(const int cell) const
virtual bool fieldInBlock(const std::string &field, const std::string &block) const =0
const Kokkos::View< const LocalOrdinalT *, Kokkos::LayoutRight, PHX::Device > getElementLIDs(LocalOrdinalT localElmtId) const
virtual void getElementGIDs(LocalOrdinalT localElmtId, std::vector< GlobalOrdinalT > &gids, const std::string &blockIdHint="") const =0
Get the global IDs for a particular element. This function overwrites the gids variable.
PHX::Device execution_space
virtual int getElementBlockGIDCount(const std::string &blockId) const =0
How any GIDs are associate with a particular element block.
virtual int getNumFields() const =0
virtual void getOwnedAndGhostedIndices(std::vector< GlobalOrdinalT > &indices) const =0
Get the set of owned and ghosted indices for this processor.
virtual void getElementBlockIds(std::vector< std::string > &elementBlockIds) const =0
virtual ~UniqueGlobalIndexer()=0
Pure virtual destructor: prevents warnings with inline empty implementation.
virtual int getNumOwned() const =0
Get the number of indices owned by this processor.
Kokkos::View< LocalOrdinalT **, PHX::Device > local_lids
void setLocalIds(const std::vector< std::vector< LocalOrdinalT > > &localIDs)
virtual ~UniqueGlobalIndexerBase()=0
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 Teuchos::RCP< Teuchos::Comm< int > > getComm() const =0
virtual void getElementOrientation(LocalOrdinalT localElmtId, std::vector< double > &gidsOrientation) const =0
Get a vector containg the orientation of the GIDs relative to the neighbors.
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 getFieldOrder(std::vector< std::string > &fieldOrder) const =0
virtual Teuchos::RCP< Teuchos::Comm< int > > getComm() const =0
Kokkos::View< const LO **, PHX::Device > lids
virtual bool fieldInBlock(const std::string &field, const std::string &block) const =0
Kokkos::View< const int *, PHX::Device > cellIds
virtual Teuchos::RCP< const ConnManagerBase< LocalOrdinalT > > getConnManagerBase() const =0
Returns the connection manager currently being used.
void getElementLIDs(Kokkos::View< const int *, PHX::Device > cellIds, Kokkos::View< LocalOrdinalT **, PHX::Device > lids) const
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 getElementBlockIds(std::vector< std::string > &elementBlockIds) const =0
virtual const std::vector< int > & getBlockFieldNumbers(const std::string &blockId) const =0
virtual int getNumOwnedAndGhosted() const =0
Get the number of owned and ghosted indices for this processor.
virtual void getGhostedIndices(std::vector< GlobalOrdinalT > &indices) const =0
Get the set of indices ghosted for this processor.
virtual int getElementBlockGIDCount(const std::string &blockId) const =0
How many GIDs are associate with a particular element block.
virtual int getNumGhosted() const =0
Get the number of indices ghosted for this processor.
void shareLocalIDs(const UniqueGlobalIndexer< LocalOrdinalT, GlobalOrdinalT > &src)
virtual const std::string & getFieldString(int num) const =0
Reverse lookup of the field string from a field number.
Kokkos::View< const LocalOrdinalT **, 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 LocalOrdinalT **, Kokkos::LayoutRight, PHX::Device > global_lids
virtual int getFieldNum(const std::string &str) const =0
Get the number used for access to this field.
virtual void ownedIndices(const std::vector< GlobalOrdinalT > &indices, std::vector< bool > &isOwned) const =0
void buildLocalIdsFromOwnedElements(std::vector< std::vector< LocalOrdinalT > > &localIDs) const
virtual const std::vector< int > & getBlockFieldNumbers(const std::string &blockId) const =0
virtual void getFieldOrder(std::vector< std::string > &fieldOrder) const =0
virtual const std::vector< LocalOrdinalT > & getElementBlock(const std::string &blockId) const =0
virtual int getFieldNum(const std::string &str) const =0
Get the number used for access to this field.
virtual void getOwnedIndices(std::vector< GlobalOrdinalT > &indices) const =0
Get the set of indices owned by this processor.