3#ifndef DUNE_GALERKIN_HH
4#define DUNE_GALERKIN_HH
8#include <dune/common/poolallocator.hh>
9#include <dune/common/enumset.hh>
10#include <dune/common/unused.hh>
86 typename M::CreateIterator row_;
88 std::size_t minRowSize_;
90 std::size_t maxRowSize_;
91 std::size_t sumRowSize_;
92#ifdef DUNE_ISTL_WITH_CHECKING
108 template<
class M,
class V,
class I,
class O>
110 const I& pinfo,
const O& copy);
130 template<
class G,
class V,
class Set>
134 const typename G::Matrix::size_type& size,
144 template<
class G,
class I,
class Set>
146 buildOverlapVertices(
const G& graph,
const I& pinfo,
156 return *
o1.aggregate < *
o2.aggregate;
175 template<
class G,
class V,
class Set>
179 const typename G::Matrix::size_type& size,
185 template<
class R,
class G,
class V>
194 template<
class R,
class G,
class V>
197 const typename G::VertexDescriptor& seed);
203 template<
class G,
class S,
class V>
229 typedef typename Graph::VertexDescriptor
Vertex;
268 template<
class G,
class T>
271 typedef typename G::VertexDescriptor
Vertex;
273 template<
class V,
class O,
class R>
287 typedef typename G::VertexDescriptor
Vertex;
289 template<
class V,
class R>
300 template<
class M,
class O>
301 static void set(M&
coarse,
const T& pinfo,
const O& copy);
307 template<
class M,
class O>
311 template<
class R,
class G,
class V>
314 const typename G::VertexDescriptor& seed)
316 assert(row.index()==aggregates[seed]);
317 row.insert(aggregates[seed]);
319 typedef typename G::VertexDescriptor Vertex;
320 typedef std::allocator<Vertex> Allocator;
329 template<
class R,
class G,
class V>
336 const typename G::VertexDescriptor aggregate=*seed->aggregate;
338 if (row.index()==*seed->aggregate) {
339 while(seed !=
overlapEnd && aggregate == *seed->aggregate) {
340 row.insert(*seed->aggregate);
344 put(visitedMap, seed->vertex,
true);
350 template<
class G,
class S,
class V>
354 : aggregates_(aggregates), graph_(graph), visitedMap_(visitedMap), connected_(connected)
357 template<
class G,
class S,
class V>
360 typedef typename G::VertexDescriptor
Vertex;
361 const Vertex& vertex = aggregates_[
edge.target()];
364 connected_.insert(vertex);
368 template<
class G,
class I,
class Set>
376 typedef typename G::ConstVertexIterator ConstIterator;
378 typedef typename GlobalLookup::IndexPair IndexPair;
380 const ConstIterator end = graph.end();
385 for(ConstIterator vertex=graph.begin(); vertex != end; ++vertex) {
388 if(
pair!=0 && overlap.contains(
pair->local().attribute()))
392 typedef typename G::VertexDescriptor Vertex;
400 for(ConstIterator vertex=graph.begin(); vertex != end; ++vertex) {
403 if(
pair!=0 && overlap.contains(
pair->local().attribute())) {
410 dverb << overlapCount<<
" overlap vertices"<<std::endl;
412 std::sort(overlapVertices, overlapVertices+overlapCount, OVLess<Vertex>());
415 return overlapVertices;
418 template<
class G,
class T>
419 template<
class V,
class O,
class R>
432 typedef typename G::VertexIterator VertexIterator;
434 VertexIterator
vend=graph.end();
436#ifdef DUNE_ISTL_WITH_CHECKING
443 for(VertexIterator vertex = graph.begin(); vertex !=
vend; ++vertex)
444 if(!
get(visitedMap, *vertex)) {
446 typedef typename GlobalLookup::IndexPair IndexPair;
448 if(
pair==0 || !overlap.contains(
pair->local().attribute())) {
449#ifdef DUNE_ISTL_WITH_CHECKING
451 examined.insert(aggregates[*vertex]);
471 dvverb<<
"constructed "<<row.index()<<
" non-overlapping rows"<<std::endl;
478#ifdef DUNE_ISTL_WITH_CHECKING
479 typedef typename GlobalLookup::IndexPair IndexPair;
493 template<
class V,
class R>
501 typedef typename G::VertexIterator VertexIterator;
503 VertexIterator
vend=graph.end();
504 for(VertexIterator vertex = graph.begin(); vertex !=
vend; ++vertex) {
505 if(!
get(visitedMap, *vertex)) {
515 : row_(matrix.createbegin()),
517 maxRowSize_(0), sumRowSize_(0)
519#ifdef DUNE_ISTL_WITH_CHECKING
542 sumRowSize_ += row_.size();
543 minRowSize_=std::min(minRowSize_, row_.size());
544 maxRowSize_=std::max(maxRowSize_, row_.size());
546#ifdef DUNE_ISTL_WITH_CHECKING
556#ifdef DUNE_ISTL_WITH_CHECKING
562 template<
class G,
class V,
class Set>
563 typename G::MutableMatrix*
567 const typename G::Matrix::size_type& size,
579 typedef typename G::MutableMatrix M;
585 typedef typename G::VertexIterator Vertex;
587 for(Vertex vertex =
fineGraph.begin(); vertex !=
vend; ++vertex) {
592 typedef typename G::MutableMatrix M;
611 template<
class G,
class V,
class Set>
612 typename G::MutableMatrix*
616 const typename G::Matrix::size_type& size,
620 typedef typename G::MutableMatrix M;
626 typedef typename G::VertexIterator Vertex;
628 for(Vertex vertex =
fineGraph.begin(); vertex !=
vend; ++vertex) {
643 template<
class M,
class V,
class P,
class O>
645 const P& pinfo,
const O& copy)
650 typedef typename M::ConstIterator RowIterator;
653 for(RowIterator row =
fine.begin(); row !=
endRow; ++row)
656 typedef typename M::ConstColIterator ColIterator;
657 ColIterator
endCol = row->end();
662 coarse[aggregates[row.index()]][aggregates[
col.index()]]+=*
col;
667 typedef typename M::block_type
BlockType;
669 for (RowIterator row =
coarse.begin(); row !=
coarse.end(); ++row)
670 rowsize[row.index()]=
coarse[row.index()][row.index()];
671 pinfo.copyOwnerToAll(rowsize,rowsize);
672 for (RowIterator row =
coarse.begin(); row !=
coarse.end(); ++row)
673 coarse[row.index()][row.index()] = rowsize[row.index()];
684 template<
class M,
class O>
687 typedef typename T::ParallelIndexSet::const_iterator ConstIterator;
688 ConstIterator end = pinfo.indexSet().end();
689 typedef typename M::block_type
Block;
691 for(
typename Block::RowIterator b=
identity.begin(); b !=
identity.end(); ++b)
692 b->operator[](b.index())=1.0;
694 for(ConstIterator index = pinfo.indexSet().begin();
695 index != end; ++index) {
696 if(copy.contains(index->local().attribute())) {
697 typedef typename M::ColIterator ColIterator;
698 typedef typename M::row_type Row;
699 Row row =
coarse[index->local()];
700 ColIterator cend = row.find(index->local());
701 ColIterator
col = row.begin();
716 template<
class M,
class O>
Provides classes for the Coloring process of AMG.
Col col
Definition matrixmatrix.hh:347
bool operator()(const OverlapVertex< A > &o1, const OverlapVertex< A > &o2)
Definition galerkin.hh:154
static void constructNonOverlapConnectivity(R &row, G &graph, V &visitedMap, const AggregatesMap< typename G::VertexDescriptor > &aggregates, const typename G::VertexDescriptor &seed)
Construct the connectivity of an aggregate in the overlap.
Definition galerkin.hh:312
G Graph
The type of the graph.
Definition galerkin.hh:210
void operator++()
Definition galerkin.hh:540
void operator()(const ConstEdgeIterator &edge)
Process an edge pointing to another aggregate.
Definition galerkin.hh:358
void insert(const typename M::size_type &index)
Definition galerkin.hh:553
static void constructOverlapConnectivity(R &row, G &graph, V &visitedMap, const AggregatesMap< typename G::VertexDescriptor > &aggregates, const OverlapVertex< typename G::VertexDescriptor > *&seed, const OverlapVertex< typename G::VertexDescriptor > *overlapEnd)
Definition galerkin.hh:330
G::MutableMatrix * build(G &fineGraph, V &visitedMap, const ParallelInformation &pinfo, AggregatesMap< typename G::VertexDescriptor > &aggregates, const typename G::Matrix::size_type &size, const Set ©)
Calculates the coarse matrix via a Galerkin product.
Definition galerkin.hh:564
std::size_t index()
Definition galerkin.hh:80
T ParallelInformation
Definition galerkin.hh:119
G::VertexDescriptor Vertex
Definition galerkin.hh:271
T Aggregate
The aggregate descriptor.
Definition galerkin.hh:36
SparsityBuilder(M &matrix)
Constructor.
Definition galerkin.hh:514
ConnectedBuilder(const AggregatesMap< Vertex > &aggregates, Graph &graph, VisitedMap &visitedMap, Set &connected)
Constructor.
Definition galerkin.hh:351
Graph::ConstEdgeIterator ConstEdgeIterator
The constant edge iterator.
Definition galerkin.hh:214
T Vertex
The vertex descriptor.
Definition galerkin.hh:41
G::VertexDescriptor Vertex
Definition galerkin.hh:287
static void examine(G &graph, V &visitedMap, const T &pinfo, const AggregatesMap< Vertex > &aggregates, const O &overlap, const OverlapVertex< Vertex > *overlapVertices, const OverlapVertex< Vertex > *overlapEnd, R &row)
Definition galerkin.hh:420
V VisitedMap
The type of the map for marking vertices as visited.
Definition galerkin.hh:224
int visitNeighbours(const G &graph, const typename G::VertexDescriptor &vertex, V &visitor)
Visit all neighbour vertices of a vertex in a graph.
S Set
The type of the connected set.
Definition galerkin.hh:219
Aggregate * aggregate
The aggregate the vertex belongs to.
Definition galerkin.hh:46
std::size_t sumRowSize()
Definition galerkin.hh:535
Vertex vertex
The vertex descriptor.
Definition galerkin.hh:51
std::size_t minRowSize()
Definition galerkin.hh:529
static void set(M &coarse, const T &pinfo, const O ©)
Definition galerkin.hh:685
Graph::VertexDescriptor Vertex
The vertex descriptor of the graph.
Definition galerkin.hh:229
void calculate(const M &fine, const AggregatesMap< V > &aggregates, M &coarse, const I &pinfo, const O ©)
Calculate the galerkin product.
std::size_t maxRowSize()
Definition galerkin.hh:524
Definition basearray.hh:19
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:292
Statistics about compression achieved in implicit mode.
Definition bcrsmatrix.hh:81
Class providing information about the mapping of the vertices onto aggregates.
Definition aggregates.hh:543
A Dummy visitor that does nothing for each visited edge.
Definition aggregates.hh:581
Definition galerkin.hh:32
Functor for building the sparsity pattern of the matrix using examineConnectivity.
Definition galerkin.hh:62
Definition galerkin.hh:98
Definition galerkin.hh:117
Definition galerkin.hh:184
Visitor for identifying connected aggregates during a breadthFirstSearch.
Definition galerkin.hh:205
Definition galerkin.hh:270
Definition galerkin.hh:299
@ nonoverlapping
Category for non-overlapping solvers.
Definition solvercategory.hh:23