11 #ifndef __Panzer_Filtered_GlobalIndexer_impl_hpp__
12 #define __Panzer_Filtered_GlobalIndexer_impl_hpp__
14 #include <unordered_set>
16 #include "PanzerDofMgr_config.hpp"
19 #include "Tpetra_Map.hpp"
20 #include "Tpetra_Import.hpp"
21 #include "Tpetra_Export.hpp"
22 #include "Tpetra_Vector.hpp"
32 const std::vector<panzer::GlobalOrdinal>& filtered)
34 using GO = panzer::GlobalOrdinal;
35 using LO = panzer::LocalOrdinal;
37 using Map = Tpetra::Map<LO, GO, Node>;
38 using Vector = Tpetra::Vector<GO,LO,GO,Node>;
39 using Export = Tpetra::Export<LO,GO,Node>;
43 using HashTable = std::unordered_set<panzer::GlobalOrdinal>;
51 vector<panzer::GlobalOrdinal> baseOwned, baseGhosted;
52 base_->getOwnedIndices(baseOwned);
53 base_->getGhostedIndices(baseGhosted);
56 = Tpetra::createNonContigMapWithNode<LO,GO,Node>(baseOwned,
getComm());
58 = Tpetra::createNonContigMapWithNode<LO,GO,Node>(baseGhosted,
getComm());
60 Vector ownedFiltered(ownedMap);
61 Vector ghostedFiltered(ghostedMap);
63 ownedFiltered.putScalar(0.0);
64 ghostedFiltered.putScalar(0.0);
67 auto ownedFiltered_host = ownedFiltered.getLocalViewHost(Tpetra::Access::ReadWrite);
68 auto ghostedFiltered_host = ghostedFiltered.getLocalViewHost(Tpetra::Access::ReadWrite);
70 for(panzer::GlobalOrdinal f : filtered) {
71 bool isOwned = std::find(baseOwned.begin(),baseOwned.end(),f)!=baseOwned.end();
72 bool isGhosted = std::find(baseGhosted.begin(),baseGhosted.end(),f)!=baseGhosted.end();
75 ownedFiltered_host(ownedMap->getLocalElement(f),0) = 1.0;
77 ghostedFiltered_host(ghostedMap->getLocalElement(f),0) = 1.0;
82 Export exporter(ghostedMap,ownedMap);
83 ownedFiltered.doExport(ghostedFiltered, exporter, Tpetra::ADD);
88 HashTable filteredHash;
89 for(
int i(0); i < data.
size(); ++i) {
91 filteredHash.insert(baseOwned[i]);
99 for (
size_t i(0); i < baseOwned.size(); ++i)
101 auto itr = filteredHash.find(baseOwned[i]);
102 if (itr == filteredHash.end())
103 owned_.push_back(baseOwned[i]);
121 using GO = panzer::GlobalOrdinal;
122 using LO = panzer::LocalOrdinal;
124 using Map = Tpetra::Map<LO, GO, Node>;
125 using Vector = Tpetra::Vector<GO,LO,GO,Node>;
126 using Import = Tpetra::Import<LO,GO,Node>;
129 std::vector<panzer::GlobalOrdinal> ghostedIndices;
138 = Tpetra::createNonContigMapWithNode<LO,GO,Node>(ghostedIndices,
getComm());
142 Vector ownedActive(ownedMap);
143 ownedActive.putScalar(1);
146 Vector ghostedActive(ghostedMap);
147 ghostedActive.putScalar(0);
151 Import importer(ownedMap,ghostedMap);
152 ghostedActive.doImport(ownedActive,importer,Tpetra::INSERT);
158 indicator.insert(indicator.end(),data.
begin(),data.
end());
169 std::vector<int> indicators;
173 std::vector<panzer::GlobalOrdinal> ghostedIndices;
177 for(std::size_t i=0;i<indicators.size();i++) {
179 indices.push_back(ghostedIndices[i]);
186 ownedIndices(
const std::vector<panzer::GlobalOrdinal> & indices,std::vector<bool> & isOwned)
const
189 if(indices.size()!=isOwned.size())
190 isOwned.resize(indices.size(),
false);
191 typename std::vector<panzer::GlobalOrdinal>::const_iterator endOf =
owned_.end();
192 for (std::size_t i = 0; i < indices.size(); ++i) {
193 isOwned[i] = ( std::find(
owned_.begin(),
owned_.end(), indices[i])!=endOf );
void getOwnedAndGhostedNotFilteredIndicator(std::vector< int > &indicator) const
virtual void getOwnedIndices(std::vector< panzer::GlobalOrdinal > &indices) const
Get the set of indices owned by this processor.
std::vector< panzer::GlobalOrdinal > ghosted_
The list of ghosted indices.
std::vector< panzer::GlobalOrdinal > owned_
The list of owned indices.
void getFilteredOwnedAndGhostedIndices(std::vector< panzer::GlobalOrdinal > &indices) const
virtual void ownedIndices(const std::vector< panzer::GlobalOrdinal > &indices, std::vector< bool > &isOwned) const
virtual Teuchos::RCP< Teuchos::Comm< int > > getComm() const
virtual void getOwnedAndGhostedIndices(std::vector< panzer::GlobalOrdinal > &indices) const
Get the set of owned and ghosted indices for this processor.
Teuchos::RCP< const GlobalIndexer > base_
Tpetra::KokkosCompat::KokkosDeviceWrapperNode< PHX::Device > TpetraNodeType
void initialize(const Teuchos::RCP< const GlobalIndexer > &ugi, const std::vector< panzer::GlobalOrdinal > &filteredIndices)