3#ifndef DUNE_AMG_INDICESCOARSENER_HH
4#define DUNE_AMG_INDICESCOARSENER_HH
9#include "renumberer.hh"
33 template<
typename T,
typename E>
34 class IndicesCoarsener
40 template<
typename T,
typename E>
41 class ParallelIndicesCoarsener
54 typedef typename ParallelInformation::ParallelIndexSet ParallelIndexSet;
87 template<
typename Graph,
typename VM>
88 static typename Graph::VertexDescriptor
94 typename Graph::VertexDescriptor noAggregates);
97 template<
typename G,
typename I>
98 class ParallelAggregateRenumberer :
public AggregateRenumberer<G>
100 typedef typename G::VertexDescriptor Vertex;
110 : AggregateRenumberer<G>(aggregates), isPublic_(false), lookup_(lookup),
115 void operator()(
const typename G::ConstEdgeIterator& edge)
117 AggregateRenumberer<G>::operator()(edge);
118 const IndexPair* pair= lookup_.pair(edge.target());
120 globalIndex(pair->
global());
121 attribute(pair->
local().attribute());
122 isPublic(pair->
local().isPublic());
126 Vertex operator()(
const GlobalIndex& global)
129 Vertex current = this->number_;
139 void isPublic(
bool b)
141 isPublic_ = isPublic_ || b;
146 globalIndex_ = std::numeric_limits<GlobalIndex>::max();
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 typename Graph::VertexDescriptor noAggregates)
237 ParallelAggregateRenumberer<Graph,typename ParallelInformation::GlobalLookupIndexSet> renumberer(aggregates, fineInfo.globalLookup());
238 buildCoarseIndexSet(fineInfo, fineGraph, visitedMap, aggregates,
239 coarseInfo.indexSet(), renumberer);
240 buildCoarseRemoteIndices(fineInfo.remoteIndices(), aggregates, coarseInfo.indexSet(),
241 coarseInfo.remoteIndices(), renumberer);
246 template<
typename T,
typename E>
247 template<
typename Graph,
typename VM,
typename I>
248 void ParallelIndicesCoarsener<T,E>::buildCoarseIndexSet(
const ParallelInformation& pinfo,
253 ParallelAggregateRenumberer<Graph,I>& renumberer)
257 typedef typename Graph::ConstVertexIterator Iterator;
260 Iterator end = fineGraph.
end();
268 for(Iterator index = fineGraph.begin(); index != end; ++index) {
274 if(!get(visitedMap, *index)) {
284 assert(!ExcludedAttributes::contains(pair->
local().attribute()));
285 renumberer.attribute(pair->
local().attribute());
286 renumberer.isPublic(pair->
local().isPublic());
287 renumberer.globalIndex(pair->
global());
291 aggregates.template breadthFirstSearch<false>(*index, aggregates[*index],
292 fineGraph, renumberer, visitedMap);
296 if(renumberer.globalIndex()!=std::numeric_limits<GlobalIndex>::max()) {
299 coarseIndices.
add(renumberer.globalIndex(),
300 LocalIndex(renumberer, renumberer.attribute(),
301 renumberer.isPublic()));
304 aggregates[*index] = renumberer;
311 assert(
static_cast<std::size_t
>(renumberer) >= coarseIndices.
size());
314 for(Iterator vertex=fineGraph.begin(); vertex != end; ++vertex)
315 put(visitedMap, *vertex,
false);
318 template<
typename T,
typename E>
319 template<
typename Graph,
typename I>
320 void ParallelIndicesCoarsener<T,E>::buildCoarseRemoteIndices(
const RemoteIndices& fineRemote,
321 const AggregatesMap<typename Graph::VertexDescriptor>& aggregates,
322 ParallelIndexSet& coarseIndices,
323 RemoteIndices& coarseRemote,
324 ParallelAggregateRenumberer<Graph,I>& renumberer)
326 std::vector<char> attributes(
static_cast<std::size_t
>(renumberer));
328 GlobalLookupIndexSet<ParallelIndexSet> coarseLookup(coarseIndices,
static_cast<std::size_t
>(renumberer));
330 typedef typename RemoteIndices::const_iterator Iterator;
331 Iterator end = fineRemote.end();
333 for(Iterator neighbour = fineRemote.begin();
334 neighbour != end; ++neighbour) {
335 int process = neighbour->first;
337 assert(neighbour->second.first==neighbour->second.second);
340 typedef typename std::vector<char>::iterator CIterator;
342 for(CIterator iter=attributes.begin(); iter!= attributes.end(); ++iter)
343 *iter = std::numeric_limits<char>::max();
346 Iterator riEnd = neighbour->second.second->end();
348 for(Iterator index = neighbour->second.second->begin();
349 index != riEnd; ++index) {
350 if(!E::contains(index->localIndexPair().local().attribute()) &&
351 aggregates[index->localIndexPair().local()] !=
354 assert(aggregates[index->localIndexPair().local()]<attributes.size());
355 if (attributes[aggregates[index->localIndexPair().local()]] != 3)
356 attributes[aggregates[index->localIndexPair().local()]] = index->attribute();
361 typedef RemoteIndexListModifier<ParallelIndexSet,typename RemoteIndices::Allocator,false> Modifier;
365 Modifier coarseList = coarseRemote.template getModifier<false,true>(process);
367 IndexIterator iend = coarseIndices.end();
368 for(IndexIterator index = coarseIndices.begin(); index != iend; ++index)
369 if(attributes[index->local()] != std::numeric_limits<char>::max()) {
371 coarseList.insert(RemoteIndex(Attribute(attributes[index->local()]), &(*index)));
377 assert(coarseRemote.neighbours()==fineRemote.neighbours());
381 IndicesSyncer<ParallelIndexSet> syncer(coarseIndices, coarseRemote);
382 syncer.sync(renumberer);
389 template<
typename Graph,
typename VM>
390 typename Graph::VertexDescriptor
391 IndicesCoarsener<SequentialInformation,E>::coarsen(
const SequentialInformation& fineInfo,
394 AggregatesMap<typename Graph::VertexDescriptor>& aggregates,
395 SequentialInformation& coarseInfo,
396 typename Graph::VertexDescriptor noAggregates)
Class providing information about the mapping of the vertices onto aggregates.
Definition: aggregates.hh:543
Decorates an index set with the possibility to find a global index that is mapped to a specific local...
Definition: indexset.hh:506
A pair consisting of a global and local index.
Definition: indexset.hh:84
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:217
The indices present on remote processes.
Definition: remoteindices.hh:181
Dune::RemoteIndex< GlobalIndex, Attribute > RemoteIndex
Type of the remote indices we manage.
Definition: remoteindices.hh:223
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:305
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:238
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:225
TG GlobalIndex
the type of the global index.
Definition: indexset.hh:106
SLListConstIterator< RemoteIndex, Allocator > const_iterator
The constant iterator of the list.
Definition: sllist.hh:72
LocalIndex::Attribute Attribute
The type of the attribute.
Definition: indicescoarsener.hh:69
ParallelIndexSet::LocalIndex LocalIndex
The type of the local index.
Definition: indicescoarsener.hh:64
T ParallelInformation
The type of the parallel information.
Definition: indicescoarsener.hh:52
static const V ISOLATED
Identifier of isolated vertices.
Definition: aggregates.hh:554
ParallelIndexSet::GlobalIndex GlobalIndex
The type of the global index.
Definition: indicescoarsener.hh:59
E ExcludedAttributes
The set of excluded attributes.
Definition: indicescoarsener.hh:47
Dune::RemoteIndices< ParallelIndexSet > RemoteIndices
The type of the remote indices.
Definition: indicescoarsener.hh:74
Class for adding missing indices of a distributed index set in a local communication.
Dune namespace.
Definition: alignment.hh:11
Classes providing communication interfaces for overlapping Schwarz methods.
Definition of the DUNE_UNUSED macro for the case that config.h is not available.
#define DUNE_UNUSED_PARAMETER(parm)
A macro to mark intentionally unused function parameters with.
Definition: unused.hh:18