5#ifndef DUNE_AMG_INDICESCOARSENER_HH
6#define DUNE_AMG_INDICESCOARSENER_HH
10#include "renumberer.hh"
34 template<
typename T,
typename E>
35 class IndicesCoarsener
41 template<
typename T,
typename E>
42 class ParallelIndicesCoarsener
55 typedef typename ParallelInformation::ParallelIndexSet ParallelIndexSet;
88 template<
typename Graph,
typename VM>
89 static typename Graph::VertexDescriptor
95 typename Graph::VertexDescriptor noAggregates);
98 template<
typename G,
typename I>
99 class ParallelAggregateRenumberer :
public AggregateRenumberer<G>
101 typedef typename G::VertexDescriptor Vertex;
111 : AggregateRenumberer<G>(aggregates), isPublic_(false), lookup_(lookup),
116 void operator()(
const typename G::ConstEdgeIterator& edge)
118 AggregateRenumberer<G>::operator()(edge);
119 const IndexPair* pair= lookup_.pair(edge.target());
121 globalIndex(pair->
global());
122 attribute(pair->
local().attribute());
123 isPublic(pair->
local().isPublic());
127 Vertex operator()([[maybe_unused]]
const GlobalIndex& global)
129 Vertex current = this->number_;
139 void isPublic(
bool b)
141 isPublic_ = isPublic_ || b;
150 void attribute(
const Attribute& attribute)
152 attribute_=attribute;
155 Attribute attribute()
160 const GlobalIndex& globalIndex()
const
165 void globalIndex(
const GlobalIndex& global)
167 globalIndex_ = global;
172 Attribute attribute_;
173 const GlobalLookupIndexSet& lookup_;
174 GlobalIndex globalIndex_;
177 template<
typename Graph,
typename VM,
typename I>
178 static void buildCoarseIndexSet(
const ParallelInformation& pinfo,
181 AggregatesMap<typename Graph::VertexDescriptor>& aggregates,
182 ParallelIndexSet& coarseIndices,
183 ParallelAggregateRenumberer<Graph,I>& renumberer);
185 template<
typename Graph,
typename I>
186 static void buildCoarseRemoteIndices(
const RemoteIndices& fineRemote,
187 const AggregatesMap<typename Graph::VertexDescriptor>& aggregates,
188 ParallelIndexSet& coarseIndices,
189 RemoteIndices& coarseRemote,
190 ParallelAggregateRenumberer<Graph,I>& renumberer);
197 template<
typename G,
typename L,
typename E>
199 :
public ParallelIndicesCoarsener<OwnerOverlapCopyCommunication<G,L>,E>
212 class IndicesCoarsener<SequentialInformation,E>
215 template<
typename Graph,
typename VM>
216 static typename Graph::VertexDescriptor
217 coarsen(
const SequentialInformation & fineInfo,
221 SequentialInformation& coarseInfo,
222 typename Graph::VertexDescriptor noAggregates);
226 template<
typename T,
typename E>
227 template<
typename Graph,
typename VM>
228 inline typename Graph::VertexDescriptor
234 [[maybe_unused]]
typename Graph::VertexDescriptor noAggregates)
236 ParallelAggregateRenumberer<Graph,typename ParallelInformation::GlobalLookupIndexSet> renumberer(aggregates, fineInfo.globalLookup());
237 buildCoarseIndexSet(fineInfo, fineGraph, visitedMap, aggregates,
238 coarseInfo.indexSet(), renumberer);
239 buildCoarseRemoteIndices(fineInfo.remoteIndices(), aggregates, coarseInfo.indexSet(),
240 coarseInfo.remoteIndices(), renumberer);
245 template<
typename T,
typename E>
246 template<
typename Graph,
typename VM,
typename I>
247 void ParallelIndicesCoarsener<T,E>::buildCoarseIndexSet(
const ParallelInformation& pinfo,
252 ParallelAggregateRenumberer<Graph,I>& renumberer)
256 typedef typename Graph::ConstVertexIterator Iterator;
259 Iterator end = fineGraph.
end();
267 for(Iterator index = fineGraph.begin(); index != end; ++index) {
273 if(!get(visitedMap, *index)) {
283 assert(!ExcludedAttributes::contains(pair->
local().attribute()));
284 renumberer.attribute(pair->
local().attribute());
285 renumberer.isPublic(pair->
local().isPublic());
286 renumberer.globalIndex(pair->
global());
290 aggregates.template breadthFirstSearch<false>(*index, aggregates[*index],
291 fineGraph, renumberer, visitedMap);
296 coarseIndices.
add(renumberer.globalIndex(),
297 LocalIndex(renumberer, renumberer.attribute(),
298 renumberer.isPublic()));
301 aggregates[*index] = renumberer;
308 assert(
static_cast<std::size_t
>(renumberer) >= coarseIndices.
size());
312 put(visitedMap, *
vertex,
false);
315 template<
typename T,
typename E>
316 template<
typename Graph,
typename I>
317 void ParallelIndicesCoarsener<T,E>::buildCoarseRemoteIndices(
const RemoteIndices& fineRemote,
318 const AggregatesMap<typename Graph::VertexDescriptor>& aggregates,
319 ParallelIndexSet& coarseIndices,
320 RemoteIndices& coarseRemote,
321 ParallelAggregateRenumberer<Graph,I>& renumberer)
323 std::vector<char> attributes(
static_cast<std::size_t
>(renumberer));
325 GlobalLookupIndexSet<ParallelIndexSet> coarseLookup(coarseIndices,
static_cast<std::size_t
>(renumberer));
327 typedef typename RemoteIndices::const_iterator Iterator;
328 Iterator end = fineRemote.end();
330 for(Iterator neighbour = fineRemote.begin();
331 neighbour != end; ++neighbour) {
332 int process = neighbour->first;
334 assert(neighbour->second.first==neighbour->second.second);
337 typedef typename std::vector<char>::iterator CIterator;
339 for(CIterator iter=attributes.begin(); iter!= attributes.end(); ++iter)
342 auto riEnd = neighbour->second.second->end();
344 for(
auto index = neighbour->second.second->begin();
345 index != riEnd; ++index) {
346 if(!E::contains(index->localIndexPair().local().attribute()) &&
347 aggregates[index->localIndexPair().local()] !=
350 assert(aggregates[index->localIndexPair().local()]<attributes.size());
351 if (attributes[aggregates[index->localIndexPair().local()]] != 3)
352 attributes[aggregates[index->localIndexPair().local()]] = index->attribute();
357 typedef RemoteIndexListModifier<ParallelIndexSet,typename RemoteIndices::Allocator,false> Modifier;
361 Modifier coarseList = coarseRemote.template getModifier<false,true>(process);
363 IndexIterator iend = coarseIndices.end();
364 for(IndexIterator index = coarseIndices.begin(); index != iend; ++index)
367 coarseList.insert(RemoteIndex(Attribute(attributes[index->local()]), &(*index)));
373 assert(coarseRemote.neighbours()==fineRemote.neighbours());
377 IndicesSyncer<ParallelIndexSet> syncer(coarseIndices, coarseRemote);
378 syncer.sync(renumberer);
385 template<
typename Graph,
typename VM>
386 typename Graph::VertexDescriptor
387 IndicesCoarsener<SequentialInformation,E>::coarsen(
388 [[maybe_unused]]
const SequentialInformation& fineInfo,
389 [[maybe_unused]] Graph& fineGraph,
390 [[maybe_unused]] VM& visitedMap,
391 [[maybe_unused]] AggregatesMap<typename Graph::VertexDescriptor>& aggregates,
392 [[maybe_unused]] SequentialInformation& coarseInfo,
393 [[maybe_unused]]
typename Graph::VertexDescriptor noAggregates)
Class providing information about the mapping of the vertices onto aggregates.
Definition: aggregates.hh:560
Decorates an index set with the possibility to find a global index that is mapped to a specific local...
Definition: indexset.hh:507
A pair consisting of a global and local index.
Definition: indexset.hh:85
An index present on the local process.
Definition: localindex.hh:35
A class setting up standard communication for a two-valued attribute set with owner/overlap/copy sema...
Definition: owneroverlapcopy.hh:174
Manager class for the mapping between local indices and globally unique indices.
Definition: indexset.hh:218
The indices present on remote processes.
Definition: remoteindices.hh:189
Dune::RemoteIndex< GlobalIndex, Attribute > RemoteIndex
Type of the remote indices we manage.
Definition: remoteindices.hh:231
void beginResize()
Indicate that the index set is to be resized.
size_t size() const
Get the total number (public and nonpublic) indices.
ArrayList< IndexPair, N >::const_iterator const_iterator
The constant iterator over the pairs.
Definition: indexset.hh:296
void add(const GlobalIndex &global)
Add an new index to the set.
const_iterator end() const
Get an iterator over the indices positioned after the last index.
TL LocalIndex
The type of the local index, e.g. ParallelLocalIndex.
Definition: indexset.hh:239
const GlobalIndex & global() const
Get the global index.
void endResize()
Indicate that the resizing finishes.
const IndexPair * pair(const std::size_t &local) const
Get the index pair corresponding to a local index.
LocalIndex & local()
Get the local index.
TG GlobalIndex
the type of the global index. This type has to provide at least a operator< for sorting.
Definition: indexset.hh:226
TG GlobalIndex
the type of the global index.
Definition: indexset.hh:107
constexpr GeometryType vertex
GeometryType representing a vertex.
Definition: type.hh:506
LocalIndex::Attribute Attribute
The type of the attribute.
Definition: indicescoarsener.hh:70
ParallelIndexSet::LocalIndex LocalIndex
The type of the local index.
Definition: indicescoarsener.hh:65
T ParallelInformation
The type of the parallel information.
Definition: indicescoarsener.hh:53
static const V ISOLATED
Identifier of isolated vertices.
Definition: aggregates.hh:571
ParallelIndexSet::GlobalIndex GlobalIndex
The type of the global index.
Definition: indicescoarsener.hh:60
E ExcludedAttributes
The set of excluded attributes.
Definition: indicescoarsener.hh:48
Dune::RemoteIndices< ParallelIndexSet > RemoteIndices
The type of the remote indices.
Definition: indicescoarsener.hh:75
auto max(ADLTag< 0 >, const V &v1, const V &v2)
implements binary Simd::max()
Definition: defaults.hh:81
Class for adding missing indices of a distributed index set in a local communication.
Dune namespace.
Definition: alignedallocator.hh:13
Classes providing communication interfaces for overlapping Schwarz methods.