3#ifndef DUNE_AMGSMOOTHER_HH
4#define DUNE_AMGSMOOTHER_HH
11#include <dune/common/propertymap.hh>
12#include <dune/common/unused.hh>
69 template<
class X,
class Y,
class C,
class T>
76 template<
class C,
class T>
89 typedef typename T::matrix_type Matrix;
148 template<
class T,
class C=SequentialInformation>
171 class ConstructionTraits;
176 template<
class M,
class X,
class Y,
int l>
184 args.getArgs().relaxationFactor);
198 template<
class M,
class X,
class Y,
int l>
206 args.getArgs().relaxationFactor);
218 template<
class M,
class X,
class Y,
int l>
226 args.getArgs().relaxationFactor);
240 template<
class M,
class X,
class Y>
248 args.getArgs().relaxationFactor);
258 template<
class M,
class X,
class Y>
284 template<
class M,
class X,
class Y>
292 args.getArgs().relaxationFactor);
305 template<
class M,
class X,
class Y,
class C>
313 args.getArgs().relaxationFactor,
322 template<
class X,
class Y,
class C,
class T>
335 SeqConstructionTraits::deconstruct(
static_cast<T*
>(&
bp->preconditioner));
341 template<
class C,
class T>
354 SeqConstructionTraits::deconstruct(
static_cast<T*
>(&
bp->preconditioner));
374 typedef typename Smoother::range_type
Range;
375 typedef typename Smoother::domain_type
Domain;
407 template<
typename LevelContext>
410 for(std::size_t i=0; i <
steps; ++i) {
429 template<
typename LevelContext>
432 for(std::size_t i=0; i <
steps; ++i) {
445 template<
class M,
class X,
class Y,
int l>
449 typedef typename Smoother::range_type
Range;
450 typedef typename Smoother::domain_type
Domain;
464 template<
class M,
class X,
class Y,
class C,
int l>
468 typedef typename Smoother::range_type
Range;
469 typedef typename Smoother::domain_type
Domain;
483 template<
class M,
class X,
class Y,
class C,
int l>
487 typedef typename Smoother::range_type
Range;
488 typedef typename Smoother::domain_type
Domain;
505 template<
class M,
class X,
class MO,
class MS,
class A>
506 class SeqOverlappingSchwarz;
508 struct MultiplicativeSchwarzMode;
512 template<
class M,
class X,
class MS,
class TA>
517 typedef typename Smoother::range_type
Range;
518 typedef typename Smoother::domain_type
Domain;
551 template<
class M,
class X,
class TM,
class TS,
class TA>
557 template<
class M,
class X,
class TM,
class TS,
class TA>
572 Father::setMatrix(matrix);
574 std::vector<bool> visited(
amap.noVertices(),
false);
582 switch(Father::getArgs().overlap) {
583 case SmootherArgs::vertex :
586 createSubdomains(matrix, graph,
amap,
visitor, visitedMap);
589 case SmootherArgs::pairwise :
591 createPairDomains(graph);
594 case SmootherArgs::aggregate :
597 createSubdomains(matrix, graph,
amap,
visitor, visitedMap);
600 case SmootherArgs::none :
602 createSubdomains(matrix, graph,
amap,
visitor, visitedMap);
610 Father::setMatrix(matrix);
619 std::vector<bool> visited(
amap.noVertices(),
false);
627 switch(Father::getArgs().overlap) {
628 case SmootherArgs::vertex :
631 createSubdomains(matrix, graph,
amap,
visitor, visitedMap);
634 case SmootherArgs::aggregate :
643 case SmootherArgs::pairwise :
645 createPairDomains(graph);
648 case SmootherArgs::none :
650 createSubdomains(matrix, graph,
amap,
visitor, visitedMap);
664 : subdomains(
subdomains_), max(-1), subdomain(-1), aggregates(aggregates_)
669 if(aggregates[
edge.target()]!=AggregatesMap::ISOLATED)
670 subdomains[subdomain].insert(
edge.target());
674 subdomain=aggregate_;
675 max = std::max(subdomain, aggregate_);
704 struct AggregateAdder
708 : subdomains(
subdomains_), subdomain(-1), aggregates(aggregates_),
709 adder(
subdomains_, aggregates_), graph(graph_), visitedMap(visitedMap_)
714 subdomains[subdomain].insert(
edge.target());
718 if(aggregates[
edge.target()]!=AggregatesMap::ISOLATED) {
722 graph,
vlist, adder, adder,
729 adder.setAggregate(aggregate_);
730 aggregate=aggregate_;
752 typedef typename M::size_type size_type;
754 std::set<std::pair<size_type,size_type> >
pairs;
756 for(
VIter v=graph.begin(),
ve=graph.end();
ve != v; ++v)
760 if(
e.source()<
e.target())
761 pairs.insert(std::make_pair(
e.source(),
e.target()));
763 pairs.insert(std::make_pair(
e.target(),
e.source()));
767 subdomains.resize(
pairs.size());
768 Dune::dinfo <<std::endl<<
"Created "<<
pairs.size()<<
" ("<<
total<<
") pair domains"<<std::endl<<std::endl;
769 typedef typename std::set<std::pair<size_type,size_type> >::const_iterator
SIter;
770 typename Vector::iterator subdomain=subdomains.begin();
774 subdomain->insert(
s->first);
775 subdomain->insert(
s->second);
778 std::size_t minsize=10000;
779 std::size_t maxsize=0;
781 for(
typename Vector::size_type i=0; i < subdomains.size(); ++i) {
782 sum+=subdomains[i].size();
783 minsize=std::min(minsize, subdomains[i].size());
784 maxsize=std::max(maxsize, subdomains[i].size());
786 Dune::dinfo<<
"Subdomain size: min="<<minsize<<
" max="<<maxsize<<
" avg="<<(sum/subdomains.size())
787 <<
" no="<<subdomains.size()<<std::endl;
790 template<
class Visitor>
791 void createSubdomains(
const M& matrix,
const MatrixGraph<const M>& graph,
792 const AggregatesMap& amap, Visitor& overlapVisitor,
793 IteratorPropertyMap<std::vector<bool>::iterator,IdentityMap>& visitedMap )
800 AggregateDescriptor maxAggregate=0;
802 for(std::size_t i=0; i < amap.noVertices(); ++i)
806 maxAggregate = std::max(maxAggregate, amap[i]);
808 subdomains.resize(maxAggregate+1+isolated);
811 for(
typename Vector::size_type i=0; i < subdomains.size(); ++i)
812 subdomains[i].clear();
817 VertexAdder aggregateVisitor(subdomains, amap);
819 for(VertexDescriptor i=0; i < amap.noVertices(); ++i)
820 if(!
get(visitedMap, i)) {
821 AggregateDescriptor aggregate=amap[i];
825 subdomains.push_back(Subdomain());
826 aggregate=subdomains.size()-1;
828 overlapVisitor.setAggregate(aggregate);
829 aggregateVisitor.setAggregate(aggregate);
830 subdomains[aggregate].insert(i);
832 amap.template breadthFirstSearch<false,false>(i, aggregate, graph, vlist, aggregateVisitor,
833 overlapVisitor, visitedMap);
836 std::size_t minsize=10000;
837 std::size_t maxsize=0;
839 for(
typename Vector::size_type i=0; i < subdomains.size(); ++i) {
840 sum+=subdomains[i].size();
841 minsize=std::min(minsize, subdomains[i].size());
842 maxsize=std::max(maxsize, subdomains[i].size());
844 Dune::dinfo<<
"Subdomain size: min="<<minsize<<
" max="<<maxsize<<
" avg="<<(sum/subdomains.size())
845 <<
" no="<<subdomains.size()<<
" isolated="<<isolated<<std::endl;
854 template<
class M,
class X,
class TM,
class TS,
class TA>
862 args.getSubDomains(),
863 args.getArgs().relaxationFactor,
864 args.getArgs().onthefly);
Define general preconditioner interface.
Helper classes for the construction of classes without empty constructor.
Provides classes for the Coloring process of AMG.
static void postSmooth(Smoother &smoother, Domain &v, Range &d)
Definition smoother.hh:496
void operator()(const T &edge)
Definition smoother.hh:691
static void deconstruct(NonoverlappingBlockPreconditioner< C, T > *bp)
Definition smoother.hh:352
static void preSmooth(Smoother &smoother, Domain &v, const Range &d)
Definition smoother.hh:520
const Matrix & getMatrix() const
Definition smoother.hh:110
Smoother::range_type Range
Definition smoother.hh:517
int setAggregate(const AggregateDescriptor &aggregate_)
Definition smoother.hh:693
DefaultSmootherArgs< typename T::matrix_type::field_type > Arguments
Definition smoother.hh:65
int setAggregate(const AggregateDescriptor &aggregate_)
Definition smoother.hh:672
ConstructionTraits< T > SeqConstructionTraits
Definition smoother.hh:345
static SeqSSOR< M, X, Y, l > * construct(Arguments &args)
Definition smoother.hh:181
void setArgs(const SmootherArgs &args)
Definition smoother.hh:115
ConstructionArgs< SeqOverlappingSchwarz< M, X, TM, TS, TA > > Arguments
Definition smoother.hh:857
NonoverlappingBlockPreconditioner< C, SeqSOR< M, X, Y, l > > Smoother
Definition smoother.hh:486
static void postSmooth(Smoother &smoother, Domain &v, Range &d)
Definition smoother.hh:458
ConstructionArgs< SeqILUn< M, X, Y > > Arguments
Definition smoother.hh:287
static void deconstruct(SeqSOR< M, X, Y, l > *sor)
Definition smoother.hh:209
DefaultConstructionArgs< SeqILU0< M, X, Y > > Arguments
Definition smoother.hh:243
AggregateAdder(Vector &subdomains_, const AggregatesMap &aggregates_, const MatrixGraph< const M > &graph_, VM &visitedMap_)
Definition smoother.hh:706
Overlap
Definition smoother.hh:540
void setComm(const C &comm)
Definition smoother.hh:156
SeqOverlappingSchwarzSmootherArgs< typename M::field_type > Arguments
Definition smoother.hh:554
static void deconstruct(SeqILU0< M, X, Y > *ilu)
Definition smoother.hh:251
Vector::value_type Subdomain
Definition smoother.hh:568
static void preSmooth(Smoother &smoother, Domain &v, Range &d)
Definition smoother.hh:490
Smoother::range_type Range
Definition smoother.hh:487
DefaultSmootherArgs< typename T::matrix_type::field_type > Arguments
Definition smoother.hh:79
SeqSOR< M, X, Y, l > Smoother
Definition smoother.hh:448
void operator()(const T &edge)
Definition smoother.hh:712
AggregatesMap::AggregateDescriptor AggregateDescriptor
Definition smoother.hh:566
bool onthefly
Definition smoother.hh:543
DefaultConstructionArgs< SeqSOR< M, X, Y, l > > Arguments
Definition smoother.hh:201
virtual void setMatrix(const M &matrix, const AggregatesMap &amap)
Definition smoother.hh:570
static SeqSOR< M, X, Y, l > * construct(Arguments &args)
Definition smoother.hh:203
DefaultConstructionArgs< SeqJac< M, X, Y, l > > Arguments
Definition smoother.hh:221
DefaultConstructionArgs< SeqSSOR< M, X, Y, l > > Arguments
Definition smoother.hh:179
const SmootherArgs getArgs() const
Definition smoother.hh:131
VertexAdder(Vector &subdomains_, const AggregatesMap &aggregates_)
Definition smoother.hh:663
const Vector & getSubDomains()
Definition smoother.hh:655
SeqOverlappingSchwarz< M, X, TM, TS, TA >::subdomain_vector Vector
Definition smoother.hh:567
static void preSmooth(Smoother &smoother, Domain &v, Range &d)
Definition smoother.hh:471
void setMatrix(const Matrix &matrix)
Definition smoother.hh:99
static SeqOverlappingSchwarz< M, X, TM, TS, TA > * construct(Arguments &args)
Definition smoother.hh:859
T Smoother
Definition smoother.hh:373
static void preSmooth(Smoother &smoother, Domain &v, Range &d)
Definition smoother.hh:452
BlockPreconditioner< X, Y, C, SeqSOR< M, X, Y, l > > Smoother
Definition smoother.hh:467
static BlockPreconditioner< X, Y, C, T > * construct(Arguments &args)
Definition smoother.hh:327
int noSubdomains() const
Definition smoother.hh:678
AggregateDescriptor * iterator
Definition aggregates.hh:722
static SeqILUn< M, X, Y > * construct(Arguments &args)
Definition smoother.hh:289
void presmooth(LevelContext &levelContext, size_t steps)
Apply pre smoothing on the current level.
Definition smoother.hh:408
Smoother::domain_type Domain
Definition smoother.hh:518
SeqOverlappingSchwarzSmootherArgs(Overlap overlap_=vertex, bool onthefly_=false)
Definition smoother.hh:545
DefaultParallelConstructionArgs< T, C > Arguments
Definition smoother.hh:325
DefaultParallelConstructionArgs< T, C > Arguments
Definition smoother.hh:344
static void deconstruct(SeqILUn< M, X, Y > *ilu)
Definition smoother.hh:295
const Matrix * matrix_
Definition smoother.hh:137
const SequentialInformation & getComm()
Definition smoother.hh:126
V AggregateDescriptor
The aggregate descriptor type.
Definition aggregates.hh:563
static const V ISOLATED
Identifier of isolated vertices.
Definition aggregates.hh:554
static void deconstruct(SeqOverlappingSchwarz< M, X, TM, TS, TA > *schwarz)
Definition smoother.hh:867
DefaultSmootherArgs()
Default constructor.
Definition smoother.hh:54
int getN()
Definition smoother.hh:271
void setMatrix(const M &matrix)
Definition smoother.hh:608
static SeqJac< M, X, Y, l > * construct(Arguments &args)
Definition smoother.hh:223
void operator()(const T &edge)
Definition smoother.hh:667
static void postSmooth(Smoother &smoother, Domain &v, const Range &d)
apply post smoothing in forward direction
Definition smoother.hh:396
void setN(int n)
Definition smoother.hh:267
Smoother::domain_type Domain
Definition smoother.hh:488
Smoother::domain_type Domain
Definition smoother.hh:375
static void deconstruct(ParSSOR< M, X, Y, C > *ssor)
Definition smoother.hh:316
ConstructionArgs(int n=1)
Definition smoother.hh:263
SLList< VertexDescriptor, Allocator > VertexList
The type of a single linked list of vertex descriptors.
Definition aggregates.hh:575
static void deconstruct(SeqSSOR< M, X, Y, l > *ssor)
Definition smoother.hh:187
SeqOverlappingSchwarz< M, X, MultiplicativeSchwarzMode, MS, TA > Smoother
Definition smoother.hh:516
MatrixGraph< M >::VertexDescriptor VertexDescriptor
Definition smoother.hh:564
int noSubdomains() const
Definition smoother.hh:733
static void deconstruct(SeqJac< M, X, Y, l > *jac)
Definition smoother.hh:229
DefaultSmootherArgs< typename T::matrix_type::field_type > Arguments
Definition smoother.hh:72
static ParSSOR< M, X, Y, C > * construct(Arguments &args)
Definition smoother.hh:310
virtual void setMatrix(const Matrix &matrix, const AggregatesMap &amap)
Definition smoother.hh:103
int noSubdomains() const
Definition smoother.hh:697
void postsmooth(LevelContext &levelContext, size_t steps)
Apply post smoothing on the current level.
Definition smoother.hh:430
Dune::Amg::AggregatesMap< VertexDescriptor > AggregatesMap
Definition smoother.hh:565
void setComm(T1 &comm)
Definition smoother.hh:121
static void postSmooth(Smoother &smoother, Domain &v, const Range &d)
Definition smoother.hh:526
static SeqILU0< M, X, Y > * construct(Arguments &args)
Definition smoother.hh:245
DefaultParallelConstructionArgs< M, C > Arguments
Definition smoother.hh:308
RelaxationFactor relaxationFactor
The relaxation factor to use.
Definition smoother.hh:49
virtual ~DefaultParallelConstructionArgs()
Definition smoother.hh:153
Smoother::domain_type Domain
Definition smoother.hh:450
int setAggregate(const AggregateDescriptor &aggregate_)
Definition smoother.hh:727
Smoother::range_type Range
Definition smoother.hh:449
const C & getComm() const
Definition smoother.hh:161
virtual ~DefaultConstructionArgs()
Definition smoother.hh:96
static void preSmooth(Smoother &smoother, Domain &v, const Range &d)
apply pre smoothing in forward direction
Definition smoother.hh:384
static void postSmooth(Smoother &smoother, Domain &v, Range &d)
Definition smoother.hh:477
ConstructionTraits< T > SeqConstructionTraits
Definition smoother.hh:326
static NonoverlappingBlockPreconditioner< C, T > * construct(Arguments &args)
Definition smoother.hh:346
Smoother::range_type Range
Definition smoother.hh:468
static void deconstruct(BlockPreconditioner< X, Y, C, T > *bp)
Definition smoother.hh:333
int iterations
The numbe of iterations to perform.
Definition smoother.hh:45
T RelaxationFactor
The type of the relaxation factor.
Definition smoother.hh:40
Smoother::range_type Range
Definition smoother.hh:374
Overlap overlap
Definition smoother.hh:542
Smoother::domain_type Domain
Definition smoother.hh:469
@ aggregate
Definition smoother.hh:540
@ none
Definition smoother.hh:540
@ pairwise
Definition smoother.hh:540
@ vertex
Definition smoother.hh:540
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
Sequential overlapping Schwarz preconditioner.
Definition overlappingschwarz.hh:742
std::vector< subdomain_type, typename TA::template rebind< subdomain_type >::other > subdomain_vector
The vector type containing the subdomain to row index mapping.
Definition overlappingschwarz.hh:784
Traits class for generically constructing non default constructable types.
Definition construction.hh:38
Nonoverlapping parallel preconditioner.
Definition novlpschwarz.hh:342
Tag that tells the Schwarz method to be multiplicative.
Definition overlappingschwarz.hh:122
Class providing information about the mapping of the vertices onto aggregates.
Definition aggregates.hh:543
M::size_type VertexDescriptor
The vertex descriptor.
Definition graph.hh:71
The default class for the smoother arguments.
Definition smoother.hh:36
Traits class for getting the attribute class of a smoother.
Definition smoother.hh:64
Construction Arguments for the default smoothers.
Definition smoother.hh:88
Definition smoother.hh:146
Definition smoother.hh:151
Definition smoother.hh:261
Helper class for applying the smoothers.
Definition smoother.hh:372
Definition smoother.hh:539
Definition smoother.hh:560
Sequential SSOR preconditioner.
Definition preconditioners.hh:127
Sequential SOR preconditioner.
Definition preconditioners.hh:215
The sequential jacobian preconditioner.
Definition preconditioners.hh:402
Sequential ILU0 preconditioner.
Definition preconditioners.hh:488
Sequential ILU(n) preconditioner.
Definition preconditioners.hh:572
A parallel SSOR preconditioner.
Definition schwarz.hh:253
Block parallel preconditioner.
Definition schwarz.hh:356