3#ifndef DUNE_AMG_INDICESCOARSENER_HH
4#define DUNE_AMG_INDICESCOARSENER_HH
6#include <dune/common/parallel/indicessyncer.hh>
32 template<
typename T,
typename E>
39 template<
typename T,
typename E>
63 typedef typename ParallelIndexSet::LocalIndex
LocalIndex;
86 template<
typename Graph,
typename VM>
87 static typename Graph::VertexDescriptor
93 typename Graph::VertexDescriptor noAggregates);
96 template<
typename G,
typename I>
99 typedef typename G::VertexDescriptor Vertex;
101 typedef I GlobalLookupIndexSet;
103 typedef typename GlobalLookupIndexSet::IndexPair IndexPair;
105 typedef typename IndexPair::GlobalIndex
GlobalIndex;
110 globalIndex_(std::numeric_limits<GlobalIndex>::max())
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_;
139 isPublic_ = isPublic_ || b;
144 globalIndex_ = std::numeric_limits<GlobalIndex>::max();
150 attribute_=attribute;
165 globalIndex_ = global;
171 const GlobalLookupIndexSet& lookup_;
175 template<
typename Graph,
typename VM,
typename I>
181 ParallelAggregateRenumberer<Graph,I>& renumberer);
183 template<
typename Graph,
typename I>
184 static void buildCoarseRemoteIndices(
const RemoteIndices& fineRemote,
188 ParallelAggregateRenumberer<Graph,I>& renumberer);
195 template<
typename G,
typename L,
typename E>
213 template<
typename Graph,
typename VM>
214 static typename Graph::VertexDescriptor
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>
249 ParallelIndexSet& coarseIndices,
250 ParallelAggregateRenumberer<Graph,I>& renumberer)
254 typedef typename Graph::ConstVertexIterator Iterator;
255 typedef typename ParallelInformation::GlobalLookupIndexSet GlobalLookupIndexSet;
257 Iterator end = fineGraph.end();
258 const GlobalLookupIndexSet& lookup = pinfo.globalLookup();
260 coarseIndices.beginResize();
265 for(Iterator index = fineGraph.begin(); index != end; ++index) {
271 if(!
get(visitedMap, *index)) {
273 typedef typename GlobalLookupIndexSet::IndexPair IndexPair;
274 const IndexPair* pair= lookup.pair(*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);
291 if(renumberer.globalIndex()!=std::numeric_limits<GlobalIndex>::max()) {
294 coarseIndices.add(renumberer.globalIndex(),
295 LocalIndex(renumberer, renumberer.attribute(),
296 renumberer.isPublic()));
299 aggregates[*index] = renumberer;
304 coarseIndices.endResize();
306 assert(
static_cast<std::size_t
>(renumberer) >= coarseIndices.size());
309 for(Iterator vertex=fineGraph.begin(); vertex != end; ++vertex)
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)
338 *iter = std::numeric_limits<char>::max();
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;
356 typedef typename RemoteIndices::RemoteIndex RemoteIndex;
357 typedef typename ParallelIndexSet::const_iterator IndexIterator;
359 Modifier coarseList = coarseRemote.template getModifier<false,true>(process);
361 IndexIterator iend = coarseIndices.end();
362 for(IndexIterator index = coarseIndices.begin(); index != iend; ++index)
363 if(attributes[index->local()] != std::numeric_limits<char>::max()) {
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
387 [[maybe_unused]] Graph& fineGraph,
388 [[maybe_unused]] VM& visitedMap,
391 [[maybe_unused]]
typename Graph::VertexDescriptor noAggregates)
Classes providing communication interfaces for overlapping Schwarz methods.
void reset()
Definition: indicescoarsener.hh:142
LocalIndex::Attribute Attribute
The type of the attribute.
Definition: indicescoarsener.hh:68
void operator()(const typename G::ConstEdgeIterator &edge)
Definition: indicescoarsener.hh:114
void isPublic(bool b)
Definition: indicescoarsener.hh:137
ParallelInformation::ParallelIndexSet ParallelIndexSet
Definition: indicescoarsener.hh:53
bool isPublic()
Definition: indicescoarsener.hh:132
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
Attribute attribute()
Definition: indicescoarsener.hh:153
Vertex operator()(const GlobalIndex &global)
Definition: indicescoarsener.hh:125
static Graph::VertexDescriptor coarsen(ParallelInformation &fineInfo, Graph &fineGraph, VM &visitedMap, AggregatesMap< typename Graph::VertexDescriptor > &aggregates, ParallelInformation &coarseInfo, typename Graph::VertexDescriptor noAggregates)
Build the coarse index set after the aggregatio.
Definition: indicescoarsener.hh:227
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
void attribute(const Attribute &attribute)
Definition: indicescoarsener.hh:148
E ExcludedAttributes
The set of excluded attributes.
Definition: indicescoarsener.hh:46
void globalIndex(const GlobalIndex &global)
Definition: indicescoarsener.hh:163
Dune::RemoteIndices< ParallelIndexSet > RemoteIndices
The type of the remote indices.
Definition: indicescoarsener.hh:73
ParallelAggregateRenumberer(AggregatesMap< Vertex > &aggregates, const I &lookup)
Definition: indicescoarsener.hh:108
const GlobalIndex & globalIndex() const
Definition: indicescoarsener.hh:158
Definition: allocator.hh:9
PropertyMapTypeSelector< Amg::VertexVisitedTag, Amg::PropertiesGraph< G, Amg::VertexProperties, EP, VM, EM > >::Type get(const Amg::VertexVisitedTag &tag, Amg::PropertiesGraph< G, Amg::VertexProperties, EP, VM, EM > &graph)
Definition: dependency.hh:291
A class setting up standard communication for a two-valued attribute set with owner/overlap/copy sema...
Definition: owneroverlapcopy.hh:172
Class providing information about the mapping of the vertices onto aggregates.
Definition: aggregates.hh:558
Definition: indicescoarsener.hh:34
Definition: indicescoarsener.hh:41
Definition: renumberer.hh:14
void operator++()
Definition: renumberer.hh:55
void operator()(const typename G::ConstEdgeIterator &edge)
Definition: renumberer.hh:49
Vertex number_
Definition: renumberer.hh:33