3#ifndef DUNE_GLOBALAGGREGATES_HH
4#define DUNE_GLOBALAGGREGATES_HH
18#include <dune/common/parallel/indexset.hh>
25 template<
typename T,
typename TI>
26 struct GlobalAggregatesMap
29 typedef TI ParallelIndexSet;
31 typedef typename ParallelIndexSet::GlobalIndex GlobalIndex;
33 typedef typename ParallelIndexSet::GlobalIndex IndexedType;
35 typedef typename ParallelIndexSet::LocalIndex LocalIndex;
39 GlobalAggregatesMap(AggregatesMap<Vertex>& aggregates,
40 const GlobalLookupIndexSet<ParallelIndexSet>& indexset)
41 : aggregates_(aggregates), indexset_(indexset)
44 inline const GlobalIndex& operator[](std::size_t index)
const
46 const Vertex& aggregate = aggregates_[index];
49 return isolatedMarker;
51 const Dune::IndexPair<GlobalIndex,LocalIndex >* pair = indexset_.pair(aggregate);
53 return pair->global();
58 inline GlobalIndex& get(std::size_t index)
60 const Vertex& aggregate = aggregates_[index];
62 const Dune::IndexPair<GlobalIndex,LocalIndex >* pair = indexset_.pair(aggregate);
64 return const_cast<GlobalIndex&
>(pair->global());
70 Proxy(
const GlobalLookupIndexSet<ParallelIndexSet>& indexset, Vertex& aggregate)
71 : indexset_(&indexset), aggregate_(&aggregate)
74 Proxy& operator=(
const GlobalIndex& global)
76 if(global==isolatedMarker)
80 *aggregate_ = indexset_->operator[](global).local();
85 const GlobalLookupIndexSet<ParallelIndexSet>* indexset_;
89 inline Proxy operator[](std::size_t index)
91 return Proxy(indexset_, aggregates_[index]);
94 inline void put(
const GlobalIndex& global,
size_t i)
96 aggregates_[i]=indexset_[global].local();
101 AggregatesMap<Vertex>& aggregates_;
102 const GlobalLookupIndexSet<ParallelIndexSet>& indexset_;
103 static const GlobalIndex isolatedMarker;
106 template<
typename T,
typename TI>
107 const typename TI::GlobalIndex GlobalAggregatesMap<T,TI>::isolatedMarker =
108 std::numeric_limits<typename TI::GlobalIndex>::max();
110 template<
typename T,
typename TI>
111 struct AggregatesGatherScatter
113 typedef TI ParallelIndexSet;
114 typedef typename ParallelIndexSet::GlobalIndex GlobalIndex;
116 static const GlobalIndex& gather(
const GlobalAggregatesMap<T,TI>& ga,
size_t i)
121 static void scatter(GlobalAggregatesMap<T,TI>& ga, GlobalIndex global,
size_t i)
127 template<
typename T,
typename O,
typename I>
128 struct AggregatesPublisher
139 template<
class T1,
class T2>
140 class OwnerOverlapCopyCommunication;
156 template<
typename T,
typename O,
typename T1,
typename T2>
160 typedef O OverlapFlags;
167 const GlobalLookupIndexSet& globalLookup)
169 typedef Dune::Amg::GlobalAggregatesMap<Vertex,IndexSet> GlobalMap;
170 GlobalMap gmap(aggregates, globalLookup);
177 typedef typename ParallelInformation::RemoteIndices::const_iterator Lists;
178 Lists lists = pinfo.
remoteIndices().find(pinfo.communicator().rank());
184 Vertex maxAggregate =0;
186 for(Iter i=aggregates.begin(), end=aggregates.end(); i!=end; ++i)
187 maxAggregate = std::max(maxAggregate, *i);
190 std::map<Vertex,Vertex> newMapping;
193 typedef typename ParallelInformation::RemoteIndices::RemoteIndexList
194 ::const_iterator RIter;
195 for(RIter ri=lists->second.first->begin(), rend = lists->second.first->end();
197 if(O::contains(ri->localIndexPair().local().attribute()))
198 newMapping.insert(std::make_pair(aggregates[ri->localIndexPair().local()],
201 typedef typename std::map<Vertex,Vertex>::iterator MIter;
202 for(MIter mi=newMapping.begin(), mend=newMapping.end();
204 mi->second=++maxAggregate;
207 for(RIter ri=lists->second.first->begin(), rend = lists->second.first->end();
209 if(O::contains(ri->localIndexPair().local().attribute()))
210 aggregates[ri->localIndexPair().local()] =
211 newMapping[aggregates[ri->localIndexPair().local()]];
217 template<
typename T,
typename O>
218 struct AggregatesPublisher<T,O,SequentialInformation>
221 typedef SequentialInformation ParallelInformation;
222 typedef typename ParallelInformation::GlobalLookupIndexSet GlobalLookupIndexSet;
225 [[maybe_unused]] ParallelInformation& pinfo,
226 [[maybe_unused]]
const GlobalLookupIndexSet& globalLookup)
234 template<
typename T,
typename TI>
235 struct CommPolicy<Amg::GlobalAggregatesMap<T,TI> >
237 typedef Amg::AggregatesMap<T> Type;
238 typedef typename Amg::GlobalAggregatesMap<T,TI>::IndexedType IndexedType;
239 typedef SizeOne IndexedTypeFlag;
240 static int getSize(
const Type&,
int)
Provides classes for the Coloring process of AMG.
A class setting up standard communication for a two-valued attribute set with owner/overlap/copy sema...
Definition: owneroverlapcopy.hh:172
void copyCopyToAll(const T &source, T &dest) const
Communicate values from copy data points to all other data points.
Definition: owneroverlapcopy.hh:326
Dune::GlobalLookupIndexSet< ParallelIndexSet > GlobalLookupIndexSet
The type of the reverse lookup of indices.
Definition: owneroverlapcopy.hh:454
void copyOwnerToAll(const T &source, T &dest) const
Communicate values from owner data points to all other data points.
Definition: owneroverlapcopy.hh:309
const RemoteIndices & remoteIndices() const
Get the underlying remote indices.
Definition: owneroverlapcopy.hh:469
Dune::ParallelIndexSet< GlobalIdType, LI, 512 > ParallelIndexSet
The type of the parallel index set.
Definition: owneroverlapcopy.hh:447
static const Vertex ISOLATED
Identifier of isolated vertices.
Definition: aggregates.hh:569
static const Vertex UNAGGREGATED
Identifier of not yet aggregated vertices.
Definition: aggregates.hh:564
@ nonoverlapping
Category for non-overlapping solvers.
Definition: solvercategory.hh:25
static Category category(const OP &op, decltype(op.category()) *=nullptr)
Helperfunction to extract the solver category either from an enum, or from the newly introduced virtu...
Definition: solvercategory.hh:32