43 #ifndef __Panzer_Filtered_GlobalIndexer_impl_hpp__
44 #define __Panzer_Filtered_GlobalIndexer_impl_hpp__
46 #include <unordered_set>
48 #include "PanzerDofMgr_config.hpp"
51 #include "Tpetra_Map.hpp"
52 #include "Tpetra_Import.hpp"
53 #include "Tpetra_Export.hpp"
54 #include "Tpetra_Vector.hpp"
64 const std::vector<panzer::GlobalOrdinal>& filtered)
66 using GO = panzer::GlobalOrdinal;
67 using LO = panzer::LocalOrdinal;
69 using Map = Tpetra::Map<LO, GO, Node>;
70 using Vector = Tpetra::Vector<GO,LO,GO,Node>;
71 using Export = Tpetra::Export<LO,GO,Node>;
75 using HashTable = std::unordered_set<panzer::GlobalOrdinal>;
83 vector<panzer::GlobalOrdinal> baseOwned, baseGhosted;
84 base_->getOwnedIndices(baseOwned);
85 base_->getGhostedIndices(baseGhosted);
88 = Tpetra::createNonContigMapWithNode<LO,GO,Node>(baseOwned,
getComm());
90 = Tpetra::createNonContigMapWithNode<LO,GO,Node>(baseGhosted,
getComm());
92 Vector ownedFiltered(ownedMap);
93 Vector ghostedFiltered(ghostedMap);
95 ownedFiltered.putScalar(0.0);
96 ghostedFiltered.putScalar(0.0);
99 auto ownedFiltered_host = ownedFiltered.getLocalViewHost(Tpetra::Access::ReadWrite);
100 auto ghostedFiltered_host = ghostedFiltered.getLocalViewHost(Tpetra::Access::ReadWrite);
102 for(panzer::GlobalOrdinal f : filtered) {
103 bool isOwned = std::find(baseOwned.begin(),baseOwned.end(),f)!=baseOwned.end();
104 bool isGhosted = std::find(baseGhosted.begin(),baseGhosted.end(),f)!=baseGhosted.end();
107 ownedFiltered_host(ownedMap->getLocalElement(f),0) = 1.0;
109 ghostedFiltered_host(ghostedMap->getLocalElement(f),0) = 1.0;
114 Export exporter(ghostedMap,ownedMap);
115 ownedFiltered.doExport(ghostedFiltered, exporter, Tpetra::ADD);
120 HashTable filteredHash;
121 for(
int i(0); i < data.
size(); ++i) {
123 filteredHash.insert(baseOwned[i]);
131 for (
size_t i(0); i < baseOwned.size(); ++i)
133 auto itr = filteredHash.find(baseOwned[i]);
134 if (itr == filteredHash.end())
135 owned_.push_back(baseOwned[i]);
153 using GO = panzer::GlobalOrdinal;
154 using LO = panzer::LocalOrdinal;
156 using Map = Tpetra::Map<LO, GO, Node>;
157 using Vector = Tpetra::Vector<GO,LO,GO,Node>;
158 using Import = Tpetra::Import<LO,GO,Node>;
161 std::vector<panzer::GlobalOrdinal> ghostedIndices;
170 = Tpetra::createNonContigMapWithNode<LO,GO,Node>(ghostedIndices,
getComm());
174 Vector ownedActive(ownedMap);
175 ownedActive.putScalar(1);
178 Vector ghostedActive(ghostedMap);
179 ghostedActive.putScalar(0);
183 Import importer(ownedMap,ghostedMap);
184 ghostedActive.doImport(ownedActive,importer,Tpetra::INSERT);
190 indicator.insert(indicator.end(),data.
begin(),data.
end());
201 std::vector<int> indicators;
205 std::vector<panzer::GlobalOrdinal> ghostedIndices;
209 for(std::size_t i=0;i<indicators.size();i++) {
211 indices.push_back(ghostedIndices[i]);
218 ownedIndices(
const std::vector<panzer::GlobalOrdinal> & indices,std::vector<bool> & isOwned)
const
221 if(indices.size()!=isOwned.size())
222 isOwned.resize(indices.size(),
false);
223 typename std::vector<panzer::GlobalOrdinal>::const_iterator endOf =
owned_.end();
224 for (std::size_t i = 0; i < indices.size(); ++i) {
225 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)