43 #ifndef __Panzer_Filtered_UniqueGlobalIndexer_impl_hpp__ 44 #define __Panzer_Filtered_UniqueGlobalIndexer_impl_hpp__ 46 #include <unordered_set> 48 #include "PanzerDofMgr_config.hpp" 51 #include "Tpetra_Map.hpp" 52 #include "Tpetra_Import.hpp" 53 #include "Tpetra_Vector.hpp" 57 template <
typename LocalOrdinalT,
typename GlobalOrdinalT>
62 template <
typename LocalOrdinalT,
typename GlobalOrdinalT>
66 const std::vector<GlobalOrdinalT> & filtered)
68 typedef std::unordered_set<GlobalOrdinalT> HashTable;
74 this->shareLocalIDs(*base_);
77 std::vector<GlobalOrdinalT> baseOwned;
78 base_->getOwnedIndices(baseOwned);
81 HashTable filteredHash;
82 for(std::size_t i=0;i<filtered.size();i++)
83 filteredHash.insert(filtered[i]);
86 for(std::size_t i=0;i<baseOwned.size();i++) {
87 typename HashTable::const_iterator itr = filteredHash.find(baseOwned[i]);
89 if(itr==filteredHash.end())
90 owned_.push_back(baseOwned[i]);
94 template <
typename LocalOrdinalT,
typename GlobalOrdinalT>
101 typedef GlobalOrdinalT GO;
102 typedef LocalOrdinalT LO;
104 typedef Tpetra::Map<LO, GO, Node> Map;
105 typedef Tpetra::Vector<GO,LO,GO,Node> Vector;
106 typedef Tpetra::Import<LO,GO,Node> Import;
108 std::vector<GlobalOrdinalT> ownedIndices;
109 std::vector<GlobalOrdinalT> ghostedIndices;
112 getOwnedIndices(ownedIndices);
113 getOwnedAndGhostedIndices(ghostedIndices);
116 = Tpetra::createNonContigMap<LO,GO>(ownedIndices,getComm());
118 = Tpetra::createNonContigMap<LO,GO>(ghostedIndices,getComm());
122 Vector ownedActive(ownedMap);
123 ownedActive.putScalar(1);
126 Vector ghostedActive(ghostedMap);
127 ghostedActive.putScalar(0);
131 Import importer(ownedMap,ghostedMap);
132 ghostedActive.doImport(ownedActive,importer,Tpetra::INSERT);
138 indicator.insert(indicator.end(),data.
begin(),data.
end());
141 template <
typename LocalOrdinalT,
typename GlobalOrdinalT>
149 std::vector<int> indicators;
150 getOwnedAndGhostedNotFilteredIndicator(indicators);
153 std::vector<GlobalOrdinalT> ghostedIndices;
154 getOwnedAndGhostedIndices(ghostedIndices);
157 for(std::size_t i=0;i<indicators.size();i++) {
159 indices.push_back(ghostedIndices[i]);
163 template <
typename LocalOrdinalT,
typename GlobalOrdinalT>
168 indices.resize(owned_.size());
169 for (
size_t i = 0; i < owned_.size(); ++i) {
170 indices[i]=owned_[i];
174 template <
typename LocalOrdinalT,
typename GlobalOrdinalT>
177 ownedIndices(
const std::vector<GlobalOrdinalT> & indices,std::vector<bool> & isOwned)
const 180 if(indices.size()!=isOwned.size())
181 isOwned.resize(indices.size(),
false);
182 typename std::vector<GlobalOrdinalT>::const_iterator endOf = owned_.end();
183 for (std::size_t i = 0; i < indices.size(); ++i) {
184 isOwned[i] = ( std::find(owned_.begin(), owned_.end(), indices[i])!=endOf );
void initialize(const Teuchos::RCP< const UniqueGlobalIndexer< LocalOrdinalT, GlobalOrdinalT > > &ugi, const std::vector< GlobalOrdinalT > &filteredIndices)
Filtered_UniqueGlobalIndexer()
void getOwnedAndGhostedNotFilteredIndicator(std::vector< int > &indicator) const
Kokkos::Compat::KokkosDeviceWrapperNode< PHX::Device > TpetraNodeType
virtual void getOwnedIndices(std::vector< GlobalOrdinalT > &indices) const
virtual void ownedIndices(const std::vector< GlobalOrdinalT > &indices, std::vector< bool > &isOwned) const
void getFilteredOwnedAndGhostedIndices(std::vector< GlobalOrdinalT > &indices) const