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;
92 template<
typename Graph,
typename VM>
93 static typename Graph::VertexDescriptor
99 typename Graph::VertexDescriptor noAggregates,
100 bool useFixedOrder =
false);
103 template<
typename G,
typename I>
104 class ParallelAggregateRenumberer :
public AggregateRenumberer<G>
106 typedef typename G::VertexDescriptor Vertex;
116 : AggregateRenumberer<G>(aggregates), isPublic_(false), lookup_(lookup),
121 void operator()(
const typename G::ConstEdgeIterator& edge)
123 AggregateRenumberer<G>::operator()(edge);
124 const IndexPair* pair= lookup_.pair(edge.target());
126 globalIndex(pair->
global());
127 attribute(pair->
local().attribute());
128 isPublic(pair->
local().isPublic());
132 Vertex operator()([[maybe_unused]]
const GlobalIndex& global)
134 Vertex current = this->number_;
144 void isPublic(
bool b)
146 isPublic_ = isPublic_ || b;
155 void attribute(
const Attribute& attribute)
157 attribute_=attribute;
160 Attribute attribute()
165 const GlobalIndex& globalIndex()
const
170 void globalIndex(
const GlobalIndex& global)
172 globalIndex_ = global;
177 Attribute attribute_;
178 const GlobalLookupIndexSet& lookup_;
179 GlobalIndex globalIndex_;
182 template<
typename Graph,
typename VM,
typename I>
183 static void buildCoarseIndexSet(
const ParallelInformation& pinfo,
186 AggregatesMap<typename Graph::VertexDescriptor>& aggregates,
187 ParallelIndexSet& coarseIndices,
188 ParallelAggregateRenumberer<Graph,I>& renumberer);
190 template<
typename Graph,
typename I>
191 static void buildCoarseRemoteIndices(
const RemoteIndices& fineRemote,
192 const AggregatesMap<typename Graph::VertexDescriptor>& aggregates,
193 ParallelIndexSet& coarseIndices,
194 RemoteIndices& coarseRemote,
195 ParallelAggregateRenumberer<Graph,I>& renumberer,
203 template<
typename G,
typename L,
typename E>
205 :
public ParallelIndicesCoarsener<OwnerOverlapCopyCommunication<G,L>,E>
218 class IndicesCoarsener<SequentialInformation,E>
221 template<
typename Graph,
typename VM>
222 static typename Graph::VertexDescriptor
223 coarsen(
const SequentialInformation & fineInfo,
227 SequentialInformation& coarseInfo,
228 typename Graph::VertexDescriptor noAggregates,
229 bool useFixedOrder =
false);
233 template<
typename T,
typename E>
234 template<
typename Graph,
typename VM>
235 inline typename Graph::VertexDescriptor
241 [[maybe_unused]]
typename Graph::VertexDescriptor noAggregates,
244 ParallelAggregateRenumberer<Graph,typename ParallelInformation::GlobalLookupIndexSet> renumberer(aggregates, fineInfo.globalLookup());
245 buildCoarseIndexSet(fineInfo, fineGraph, visitedMap, aggregates,
246 coarseInfo.indexSet(), renumberer);
247 buildCoarseRemoteIndices(fineInfo.remoteIndices(), aggregates, coarseInfo.indexSet(),
248 coarseInfo.remoteIndices(), renumberer, useFixedOrder);
253 template<
typename T,
typename E>
254 template<
typename Graph,
typename VM,
typename I>
255 void ParallelIndicesCoarsener<T,E>::buildCoarseIndexSet(
const ParallelInformation& pinfo,
260 ParallelAggregateRenumberer<Graph,I>& renumberer)
264 typedef typename Graph::ConstVertexIterator Iterator;
267 Iterator end = fineGraph.
end();
275 for(Iterator index = fineGraph.begin(); index != end; ++index) {
281 if(!
get(visitedMap, *index)) {
291 assert(!ExcludedAttributes::contains(pair->
local().attribute()));
292 renumberer.attribute(pair->
local().attribute());
293 renumberer.isPublic(pair->
local().isPublic());
294 renumberer.globalIndex(pair->
global());
298 aggregates.template breadthFirstSearch<false>(*index, aggregates[*index],
299 fineGraph, renumberer, visitedMap);
304 coarseIndices.
add(renumberer.globalIndex(),
305 LocalIndex(renumberer, renumberer.attribute(),
306 renumberer.isPublic()));
309 aggregates[*index] = renumberer;
316 assert(
static_cast<std::size_t
>(renumberer) >= coarseIndices.
size());
320 put(visitedMap, *
vertex,
false);
323 template<
typename T,
typename E>
324 template<
typename Graph,
typename I>
325 void ParallelIndicesCoarsener<T,E>::buildCoarseRemoteIndices(
const RemoteIndices& fineRemote,
326 const AggregatesMap<typename Graph::VertexDescriptor>& aggregates,
327 ParallelIndexSet& coarseIndices,
328 RemoteIndices& coarseRemote,
329 ParallelAggregateRenumberer<Graph,I>& renumberer,
332 std::vector<char> attributes(
static_cast<std::size_t
>(renumberer));
334 GlobalLookupIndexSet<ParallelIndexSet> coarseLookup(coarseIndices,
static_cast<std::size_t
>(renumberer));
336 typedef typename RemoteIndices::const_iterator Iterator;
337 Iterator end = fineRemote.end();
339 for(Iterator neighbour = fineRemote.begin();
340 neighbour != end; ++neighbour) {
341 int process = neighbour->first;
343 assert(neighbour->second.first==neighbour->second.second);
346 typedef typename std::vector<char>::iterator CIterator;
348 for(CIterator iter=attributes.begin(); iter!= attributes.end(); ++iter)
351 auto riEnd = neighbour->second.second->end();
353 for(
auto index = neighbour->second.second->begin();
354 index != riEnd; ++index) {
355 if(!E::contains(index->localIndexPair().local().attribute()) &&
356 aggregates[index->localIndexPair().local()] !=
359 assert(aggregates[index->localIndexPair().local()]<attributes.size());
360 if (attributes[aggregates[index->localIndexPair().local()]] != 3)
361 attributes[aggregates[index->localIndexPair().local()]] = index->attribute();
366 typedef RemoteIndexListModifier<ParallelIndexSet,typename RemoteIndices::Allocator,false> Modifier;
370 Modifier coarseList = coarseRemote.template getModifier<false,true>(process);
372 IndexIterator iend = coarseIndices.end();
373 for(IndexIterator index = coarseIndices.begin(); index != iend; ++index)
376 coarseList.insert(RemoteIndex(Attribute(attributes[index->local()]), &(*index)));
382 assert(coarseRemote.neighbours()==fineRemote.neighbours());
386 IndicesSyncer<ParallelIndexSet> syncer(coarseIndices, coarseRemote);
387 syncer.sync(renumberer, useFixedOrder);
394 template<
typename Graph,
typename VM>
395 typename Graph::VertexDescriptor
396 IndicesCoarsener<SequentialInformation,E>::coarsen(
397 [[maybe_unused]]
const SequentialInformation& fineInfo,
398 [[maybe_unused]] Graph& fineGraph,
399 [[maybe_unused]] VM& visitedMap,
400 [[maybe_unused]] AggregatesMap<typename Graph::VertexDescriptor>& aggregates,
401 [[maybe_unused]] SequentialInformation& coarseInfo,
402 [[maybe_unused]]
typename Graph::VertexDescriptor noAggregates,
403 [[maybe_unused]]
bool useFixedOrder)
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:190
Dune::RemoteIndex< GlobalIndex, Attribute > RemoteIndex
Type of the remote indices we manage.
Definition: remoteindices.hh:232
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:492
constexpr auto max
Function object that returns the greater of the given values.
Definition: hybridutilities.hh:484
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
Class for adding missing indices of a distributed index set in a local communication.
Dune namespace.
Definition: alignedallocator.hh:13
constexpr auto get(std::integer_sequence< T, II... >, std::integral_constant< std::size_t, pos >={})
Return the entry at position pos of the given sequence.
Definition: integersequence.hh:22
Classes providing communication interfaces for overlapping Schwarz methods.