3#ifndef DUNE_AMG_INDICESCOARSENER_HH
4#define DUNE_AMG_INDICESCOARSENER_HH
8#include "renumberer.hh"
32 template<
typename T,
typename E>
33 class IndicesCoarsener
39 template<
typename T,
typename E>
40 class ParallelIndicesCoarsener
53 typedef typename ParallelInformation::ParallelIndexSet ParallelIndexSet;
86 template<
typename Graph,
typename VM>
87 static typename Graph::VertexDescriptor
93 typename Graph::VertexDescriptor noAggregates);
96 template<
typename G,
typename I>
97 class ParallelAggregateRenumberer :
public AggregateRenumberer<G>
99 typedef typename G::VertexDescriptor Vertex;
109 : AggregateRenumberer<G>(aggregates), isPublic_(false), lookup_(lookup),
114 void operator()(
const typename G::ConstEdgeIterator& edge)
116 AggregateRenumberer<G>::operator()(edge);
117 const IndexPair* pair= lookup_.pair(edge.target());
119 globalIndex(pair->
global());
120 attribute(pair->
local().attribute());
121 isPublic(pair->
local().isPublic());
125 Vertex operator()([[maybe_unused]]
const GlobalIndex& global)
127 Vertex current = this->number_;
137 void isPublic(
bool b)
139 isPublic_ = isPublic_ || b;
148 void attribute(
const Attribute& attribute)
150 attribute_=attribute;
153 Attribute attribute()
158 const GlobalIndex& globalIndex()
const
163 void globalIndex(
const GlobalIndex& global)
165 globalIndex_ = global;
170 Attribute attribute_;
171 const GlobalLookupIndexSet& lookup_;
172 GlobalIndex globalIndex_;
175 template<
typename Graph,
typename VM,
typename I>
176 static void buildCoarseIndexSet(
const ParallelInformation& pinfo,
179 AggregatesMap<typename Graph::VertexDescriptor>& aggregates,
180 ParallelIndexSet& coarseIndices,
181 ParallelAggregateRenumberer<Graph,I>& renumberer);
183 template<
typename Graph,
typename I>
184 static void buildCoarseRemoteIndices(
const RemoteIndices& fineRemote,
185 const AggregatesMap<typename Graph::VertexDescriptor>& aggregates,
186 ParallelIndexSet& coarseIndices,
187 RemoteIndices& coarseRemote,
188 ParallelAggregateRenumberer<Graph,I>& renumberer);
195 template<
typename G,
typename L,
typename E>
197 :
public ParallelIndicesCoarsener<OwnerOverlapCopyCommunication<G,L>,E>
210 class IndicesCoarsener<SequentialInformation,E>
213 template<
typename Graph,
typename VM>
214 static typename Graph::VertexDescriptor
215 coarsen(
const SequentialInformation & fineInfo,
219 SequentialInformation& coarseInfo,
220 typename Graph::VertexDescriptor noAggregates);
224 template<
typename T,
typename E>
225 template<
typename Graph,
typename VM>
226 inline typename Graph::VertexDescriptor
232 [[maybe_unused]]
typename Graph::VertexDescriptor noAggregates)
234 ParallelAggregateRenumberer<Graph,typename ParallelInformation::GlobalLookupIndexSet> renumberer(aggregates, fineInfo.globalLookup());
235 buildCoarseIndexSet(fineInfo, fineGraph, visitedMap, aggregates,
236 coarseInfo.indexSet(), renumberer);
237 buildCoarseRemoteIndices(fineInfo.remoteIndices(), aggregates, coarseInfo.indexSet(),
238 coarseInfo.remoteIndices(), renumberer);
243 template<
typename T,
typename E>
244 template<
typename Graph,
typename VM,
typename I>
245 void ParallelIndicesCoarsener<T,E>::buildCoarseIndexSet(
const ParallelInformation& pinfo,
250 ParallelAggregateRenumberer<Graph,I>& renumberer)
254 typedef typename Graph::ConstVertexIterator Iterator;
257 Iterator end = fineGraph.
end();
265 for(Iterator index = fineGraph.begin(); index != end; ++index) {
271 if(!get(visitedMap, *index)) {
281 assert(!ExcludedAttributes::contains(pair->
local().attribute()));
282 renumberer.attribute(pair->
local().attribute());
283 renumberer.isPublic(pair->
local().isPublic());
284 renumberer.globalIndex(pair->
global());
288 aggregates.template breadthFirstSearch<false>(*index, aggregates[*index],
289 fineGraph, renumberer, visitedMap);
294 coarseIndices.
add(renumberer.globalIndex(),
295 LocalIndex(renumberer, renumberer.attribute(),
296 renumberer.isPublic()));
299 aggregates[*index] = renumberer;
306 assert(
static_cast<std::size_t
>(renumberer) >= coarseIndices.
size());
310 put(visitedMap, *
vertex,
false);
313 template<
typename T,
typename E>
314 template<
typename Graph,
typename I>
315 void ParallelIndicesCoarsener<T,E>::buildCoarseRemoteIndices(
const RemoteIndices& fineRemote,
316 const AggregatesMap<typename Graph::VertexDescriptor>& aggregates,
317 ParallelIndexSet& coarseIndices,
318 RemoteIndices& coarseRemote,
319 ParallelAggregateRenumberer<Graph,I>& renumberer)
321 std::vector<char> attributes(
static_cast<std::size_t
>(renumberer));
323 GlobalLookupIndexSet<ParallelIndexSet> coarseLookup(coarseIndices,
static_cast<std::size_t
>(renumberer));
325 typedef typename RemoteIndices::const_iterator Iterator;
326 Iterator end = fineRemote.end();
328 for(Iterator neighbour = fineRemote.begin();
329 neighbour != end; ++neighbour) {
330 int process = neighbour->first;
332 assert(neighbour->second.first==neighbour->second.second);
335 typedef typename std::vector<char>::iterator CIterator;
337 for(CIterator iter=attributes.begin(); iter!= attributes.end(); ++iter)
340 auto riEnd = neighbour->second.second->end();
342 for(
auto index = neighbour->second.second->begin();
343 index != riEnd; ++index) {
344 if(!E::contains(index->localIndexPair().local().attribute()) &&
345 aggregates[index->localIndexPair().local()] !=
348 assert(aggregates[index->localIndexPair().local()]<attributes.size());
349 if (attributes[aggregates[index->localIndexPair().local()]] != 3)
350 attributes[aggregates[index->localIndexPair().local()]] = index->attribute();
355 typedef RemoteIndexListModifier<ParallelIndexSet,typename RemoteIndices::Allocator,false> Modifier;
359 Modifier coarseList = coarseRemote.template getModifier<false,true>(process);
361 IndexIterator iend = coarseIndices.end();
362 for(IndexIterator index = coarseIndices.begin(); index != iend; ++index)
365 coarseList.insert(RemoteIndex(Attribute(attributes[index->local()]), &(*index)));
371 assert(coarseRemote.neighbours()==fineRemote.neighbours());
375 IndicesSyncer<ParallelIndexSet> syncer(coarseIndices, coarseRemote);
376 syncer.sync(renumberer);
383 template<
typename Graph,
typename VM>
384 typename Graph::VertexDescriptor
385 IndicesCoarsener<SequentialInformation,E>::coarsen(
386 [[maybe_unused]]
const SequentialInformation& fineInfo,
387 [[maybe_unused]] Graph& fineGraph,
388 [[maybe_unused]] VM& visitedMap,
389 [[maybe_unused]] AggregatesMap<typename Graph::VertexDescriptor>& aggregates,
390 [[maybe_unused]] SequentialInformation& coarseInfo,
391 [[maybe_unused]]
typename Graph::VertexDescriptor noAggregates)
Class providing information about the mapping of the vertices onto aggregates.
Definition: aggregates.hh:558
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:83
An index present on the local process.
Definition: localindex.hh:33
A class setting up standard communication for a two-valued attribute set with owner/overlap/copy sema...
Definition: owneroverlapcopy.hh:172
Manager class for the mapping between local indices and globally unique indices.
Definition: indexset.hh:216
The indices present on remote processes.
Definition: remoteindices.hh:187
Dune::RemoteIndex< GlobalIndex, Attribute > RemoteIndex
Type of the remote indices we manage.
Definition: remoteindices.hh:229
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:237
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:224
TG GlobalIndex
the type of the global index.
Definition: indexset.hh:105
constexpr GeometryType vertex
GeometryType representing a vertex.
Definition: type.hh:504
LocalIndex::Attribute Attribute
The type of the attribute.
Definition: indicescoarsener.hh:68
ParallelIndexSet::LocalIndex LocalIndex
The type of the local index.
Definition: indicescoarsener.hh:63
T ParallelInformation
The type of the parallel information.
Definition: indicescoarsener.hh:51
static const V ISOLATED
Identifier of isolated vertices.
Definition: aggregates.hh:569
ParallelIndexSet::GlobalIndex GlobalIndex
The type of the global index.
Definition: indicescoarsener.hh:58
E ExcludedAttributes
The set of excluded attributes.
Definition: indicescoarsener.hh:46
Dune::RemoteIndices< ParallelIndexSet > RemoteIndices
The type of the remote indices.
Definition: indicescoarsener.hh:73
auto max(ADLTag< 0 >, const V &v1, const V &v2)
implements binary Simd::max()
Definition: defaults.hh:79
Class for adding missing indices of a distributed index set in a local communication.
Dune namespace.
Definition: alignedallocator.hh:11
Classes providing communication interfaces for overlapping Schwarz methods.