3 #ifndef DUNE_AMG_AMG_HH
4 #define DUNE_AMG_AMG_HH
7 #include <dune/common/exceptions.hh>
16 #include <dune/common/typetraits.hh>
17 #include <dune/common/exceptions.hh>
18 #include <dune/common/scalarvectorview.hh>
19 #include <dune/common/scalarmatrixview.hh>
20 #include <dune/common/parametertree.hh>
43 template<
class M,
class X,
class S,
class P,
class K,
class A>
59 template<
class M,
class X,
class S,
class PI=SequentialInformation,
60 class A=std::allocator<X> >
63 template<
class M1,
class X1,
class S1,
class P1,
class K1,
class A1>
194 matrices_->recalculateGalerkin(NegateSet<typename PI::OwnerSet>());
211 void createHierarchies(C& criterion,
212 const std::shared_ptr<const Operator>& matrixptr,
238 typename OperatorHierarchy::RedistributeInfoList::const_iterator
redist;
242 typename OperatorHierarchy::AggregatesMapList::const_iterator
aggregates;
266 void mgc(LevelContext& levelContext);
276 void moveToFineLevel(LevelContext& levelContext,
bool processedFineLevel);
282 bool moveToCoarseLevel(LevelContext& levelContext);
288 void initIteratorsWithFineLevel(LevelContext& levelContext);
291 std::shared_ptr<OperatorHierarchy> matrices_;
295 std::shared_ptr<Hierarchy<Smoother,A> > smoothers_;
297 std::shared_ptr<CoarseSolver> solver_;
299 std::shared_ptr<Hierarchy<Range,A>> rhs_;
301 std::shared_ptr<Hierarchy<Domain,A>> lhs_;
303 std::shared_ptr<Hierarchy<Domain,A>> update_;
307 std::shared_ptr<ScalarProduct> scalarProduct_;
311 std::size_t preSteps_;
313 std::size_t postSteps_;
314 bool buildHierarchy_;
316 bool coarsesolverconverged;
317 std::shared_ptr<Smoother> coarseSmoother_;
321 std::size_t verbosity_;
324 template<
class M,
class X,
class S,
class PI,
class A>
326 : matrices_(amg.matrices_), smootherArgs_(amg.smootherArgs_),
327 smoothers_(amg.smoothers_), solver_(amg.solver_),
328 rhs_(), lhs_(), update_(),
329 scalarProduct_(amg.scalarProduct_), gamma_(amg.gamma_),
330 preSteps_(amg.preSteps_), postSteps_(amg.postSteps_),
331 buildHierarchy_(amg.buildHierarchy_),
332 additive(amg.additive), coarsesolverconverged(amg.coarsesolverconverged),
333 coarseSmoother_(amg.coarseSmoother_),
334 category_(amg.category_),
335 verbosity_(amg.verbosity_)
338 template<
class M,
class X,
class S,
class PI,
class A>
342 : matrices_(stackobject_to_shared_ptr(matrices)), smootherArgs_(smootherArgs),
344 rhs_(), lhs_(), update_(), scalarProduct_(0),
345 gamma_(parms.getGamma()), preSteps_(parms.getNoPreSmoothSteps()),
346 postSteps_(parms.getNoPostSmoothSteps()), buildHierarchy_(false),
347 additive(parms.getAdditive()), coarsesolverconverged(true),
351 verbosity_(parms.debugLevel())
353 assert(matrices_->isBuilt());
356 matrices_->coarsenSmoother(*smoothers_, smootherArgs_);
359 template<
class M,
class X,
class S,
class PI,
class A>
365 : smootherArgs_(smootherArgs),
367 rhs_(), lhs_(), update_(), scalarProduct_(),
368 gamma_(criterion.getGamma()), preSteps_(criterion.getNoPreSmoothSteps()),
369 postSteps_(criterion.getNoPostSmoothSteps()), buildHierarchy_(true),
370 additive(criterion.getAdditive()), coarsesolverconverged(true),
373 verbosity_(criterion.debugLevel())
380 auto matrixptr = stackobject_to_shared_ptr(matrix);
381 createHierarchies(criterion, matrixptr, pinfo);
384 template<
class M,
class X,
class S,
class PI,
class A>
386 const ParameterTree& configuration,
389 solver_(), rhs_(), lhs_(), update_(), scalarProduct_(), buildHierarchy_(true),
390 coarsesolverconverged(true), coarseSmoother_(),
394 if (configuration.hasKey (
"smootherIterations"))
395 smootherArgs_.iterations = configuration.get<
int>(
"smootherIterations");
397 if (configuration.hasKey (
"smootherRelaxation"))
398 smootherArgs_.relaxationFactor = configuration.get<
typename SmootherArgs::RelaxationFactor>(
"smootherRelaxation");
403 Criterion criterion (configuration.get<
int>(
"maxLevel"));
405 if (configuration.hasKey (
"coarsenTarget"))
406 criterion.setCoarsenTarget (configuration.get<
int>(
"coarsenTarget"));
407 if (configuration.hasKey (
"prolongationDampingFactor"))
408 criterion.setProlongationDampingFactor (configuration.get<
double>(
"prolongationDampingFactor"));
410 if (configuration.hasKey (
"alpha"))
411 criterion.setAlpha (configuration.get<
double> (
"alpha"));
413 if (configuration.hasKey (
"beta"))
414 criterion.setBeta (configuration.get<
double> (
"beta"));
416 if (configuration.hasKey (
"gamma"))
417 criterion.setGamma (configuration.get<std::size_t> (
"gamma"));
418 gamma_ = criterion.getGamma();
420 if (configuration.hasKey (
"additive"))
421 criterion.setAdditive (configuration.get<
bool>(
"additive"));
422 additive = criterion.getAdditive();
424 if (configuration.hasKey (
"preSteps"))
425 criterion.setNoPreSmoothSteps (configuration.get<std::size_t> (
"preSteps"));
426 preSteps_ = criterion.getNoPreSmoothSteps ();
428 if (configuration.hasKey (
"postSteps"))
429 criterion.setNoPostSmoothSteps (configuration.get<std::size_t> (
"preSteps"));
430 postSteps_ = criterion.getNoPostSmoothSteps ();
432 verbosity_ = configuration.get(
"verbosity",2);
433 criterion.setDebugLevel (verbosity_);
435 createHierarchies(criterion, matrixptr, pinfo);
446 #if DISABLE_AMG_DIRECTSOLVER
448 #elif HAVE_SUITESPARSE_UMFPACK
456 template <
class M, SolverType>
462 DUNE_THROW(NotImplemented,
"DirectSolver not selected");
465 static std::string
name () {
return "None"; }
467 #if HAVE_SUITESPARSE_UMFPACK
472 static type*
create(
const M&
mat,
bool verbose,
bool reusevector )
474 return new type(
mat, verbose, reusevector );
476 static std::string
name () {
return "UMFPack"; }
486 return new type(
mat, verbose, reusevector );
488 static std::string
name () {
return "SuperLU"; }
503 template<
class M,
class X,
class S,
class PI,
class A>
505 void AMG<M,X,S,PI,A>::createHierarchies(C& criterion,
506 const std::shared_ptr<const Operator>& matrixptr,
510 matrices_ = std::make_shared<OperatorHierarchy>(
511 std::const_pointer_cast<Operator>(matrixptr),
512 stackobject_to_shared_ptr(
const_cast<PI&
>(pinfo)));
514 matrices_->template build<NegateSet<typename PI::OwnerSet> >(criterion);
517 matrices_->coarsenSmoother(*smoothers_, smootherArgs_);
523 if(buildHierarchy_ && matrices_->levels()==matrices_->maxlevels()
524 && ( ! matrices_->redistributeInformation().back().isSetup() ||
525 matrices_->parallelInformation().coarsest().getRedistributed().communicator().size() ) )
528 SmootherArgs sargs(smootherArgs_);
529 sargs.iterations = 1;
532 cargs.setArgs(sargs);
533 if(matrices_->redistributeInformation().back().isSetup()) {
535 cargs.setMatrix(matrices_->matrices().coarsest().getRedistributed().getmat());
536 cargs.setComm(matrices_->parallelInformation().coarsest().getRedistributed());
538 cargs.setMatrix(matrices_->matrices().coarsest()->getmat());
539 cargs.setComm(*matrices_->parallelInformation().coarsest());
543 scalarProduct_ = createScalarProduct<X>(cargs.getComm(),category());
545 typedef DirectSolverSelector< typename M::matrix_type, X > SolverSelector;
548 if( SolverSelector::isDirectSolver &&
549 (std::is_same<ParallelInformation,SequentialInformation>::value
550 || matrices_->parallelInformation().coarsest()->communicator().size()==1
551 || (matrices_->parallelInformation().coarsest().isRedistributed()
552 && matrices_->parallelInformation().coarsest().getRedistributed().communicator().size()==1
553 && matrices_->parallelInformation().coarsest().getRedistributed().communicator().size()>0) )
556 if(matrices_->parallelInformation().coarsest().isRedistributed())
558 if(matrices_->matrices().coarsest().getRedistributed().getmat().N()>0)
561 solver_.reset(SolverSelector::create(matrices_->matrices().coarsest().getRedistributed().getmat(),
false,
false));
568 solver_.reset(SolverSelector::create(matrices_->matrices().coarsest()->getmat(),
false,
false));
570 if(verbosity_>0 && matrices_->parallelInformation().coarsest()->communicator().rank()==0)
571 std::cout<<
"Using a direct coarse solver (" << SolverSelector::name() <<
")" << std::endl;
575 if(matrices_->parallelInformation().coarsest().isRedistributed())
577 if(matrices_->matrices().coarsest().getRedistributed().getmat().N()>0)
582 solver_.reset(
new BiCGSTABSolver<X>(
const_cast<M&
>(matrices_->matrices().coarsest().getRedistributed()),
584 *coarseSmoother_, 1E-2, 1000, 0));
589 solver_.reset(
new BiCGSTABSolver<X>(
const_cast<M&
>(*matrices_->matrices().coarsest()),
591 *coarseSmoother_, 1E-2, 1000, 0));
610 if(verbosity_>0 && matrices_->parallelInformation().finest()->communicator().rank()==0)
611 std::cout<<
"Building hierarchy of "<<matrices_->maxlevels()<<
" levels "
612 <<
"(including coarse solver) took "<<watch.elapsed()<<
" seconds."<<std::endl;
616 template<
class M,
class X,
class S,
class PI,
class A>
623 typedef typename M::matrix_type
Matrix;
630 const Matrix&
mat=matrices_->matrices().finest()->getmat();
631 for(RowIter row=
mat.begin(); row!=
mat.end(); ++row) {
632 bool isDirichlet =
true;
633 bool hasDiagonal =
false;
635 for(ColIter
col=row->begin();
col!=row->end(); ++
col) {
636 if(row.index()==
col.index()) {
644 if(isDirichlet && hasDiagonal)
646 auto&& xEntry = Impl::asVector(x[row.index()]);
647 auto&& bEntry = Impl::asVector(b[row.index()]);
648 Impl::asMatrix(diagonal).solve(xEntry, bEntry);
652 if(smoothers_->levels()>0)
653 smoothers_->finest()->pre(x,b);
656 matrices_->parallelInformation().coarsest()->copyOwnerToAll(x,x);
657 rhs_ = std::make_shared<Hierarchy<Range,A>>(std::make_shared<Range>(b));
658 lhs_ = std::make_shared<Hierarchy<Domain,A>>(std::make_shared<Domain>(x));
659 update_ = std::make_shared<Hierarchy<Domain,A>>(std::make_shared<Domain>(x));
660 matrices_->coarsenVector(*rhs_);
661 matrices_->coarsenVector(*lhs_);
662 matrices_->coarsenVector(*update_);
668 Iterator coarsest = smoothers_->
coarsest();
669 Iterator smoother = smoothers_->finest();
670 RIterator rhs = rhs_->finest();
671 DIterator lhs = lhs_->finest();
672 if(smoothers_->levels()>1) {
674 assert(lhs_->levels()==rhs_->levels());
675 assert(smoothers_->levels()==lhs_->levels() || matrices_->levels()==matrices_->maxlevels());
676 assert(smoothers_->levels()+1==lhs_->levels() || matrices_->levels()<matrices_->maxlevels());
678 if(smoother!=coarsest)
679 for(++smoother, ++lhs, ++rhs; smoother != coarsest; ++smoother, ++lhs, ++rhs)
680 smoother->pre(*lhs,*rhs);
681 smoother->pre(*lhs,*rhs);
691 template<
class M,
class X,
class S,
class PI,
class A>
694 return matrices_->levels();
696 template<
class M,
class X,
class S,
class PI,
class A>
699 return matrices_->maxlevels();
703 template<
class M,
class X,
class S,
class PI,
class A>
706 LevelContext levelContext;
714 initIteratorsWithFineLevel(levelContext);
717 *levelContext.lhs = v;
718 *levelContext.rhs = d;
719 *levelContext.update=0;
720 levelContext.level=0;
724 if(postSteps_==0||matrices_->maxlevels()==1)
725 levelContext.pinfo->copyOwnerToAll(*levelContext.update, *levelContext.update);
727 v=*levelContext.update;
732 template<
class M,
class X,
class S,
class PI,
class A>
735 levelContext.smoother = smoothers_->finest();
736 levelContext.matrix = matrices_->matrices().finest();
737 levelContext.pinfo = matrices_->parallelInformation().finest();
738 levelContext.redist =
739 matrices_->redistributeInformation().begin();
740 levelContext.aggregates = matrices_->aggregatesMaps().begin();
741 levelContext.lhs = lhs_->finest();
742 levelContext.update = update_->finest();
743 levelContext.rhs = rhs_->finest();
746 template<
class M,
class X,
class S,
class PI,
class A>
748 ::moveToCoarseLevel(LevelContext& levelContext)
751 bool processNextLevel=
true;
753 if(levelContext.redist->isSetup()) {
754 levelContext.redist->redistribute(
static_cast<const Range&
>(*levelContext.rhs),
755 levelContext.rhs.getRedistributed());
756 processNextLevel = levelContext.rhs.getRedistributed().size()>0;
757 if(processNextLevel) {
760 ++levelContext.pinfo;
763 static_cast<const Range&
>(fineRhs.getRedistributed()),
764 *levelContext.pinfo);
769 ++levelContext.pinfo;
772 *levelContext.rhs,
static_cast<const Range&
>(*fineRhs),
773 *levelContext.pinfo);
776 if(processNextLevel) {
779 ++levelContext.update;
780 ++levelContext.matrix;
781 ++levelContext.level;
782 ++levelContext.redist;
784 if(levelContext.matrix != matrices_->matrices().coarsest() || matrices_->levels()<matrices_->maxlevels()) {
786 ++levelContext.smoother;
787 ++levelContext.aggregates;
790 *levelContext.update=0;
792 return processNextLevel;
795 template<
class M,
class X,
class S,
class PI,
class A>
797 ::moveToFineLevel(LevelContext& levelContext,
bool processNextLevel)
799 if(processNextLevel) {
800 if(levelContext.matrix != matrices_->matrices().coarsest() || matrices_->levels()<matrices_->maxlevels()) {
802 --levelContext.smoother;
803 --levelContext.aggregates;
805 --levelContext.redist;
806 --levelContext.level;
808 --levelContext.matrix;
812 --levelContext.pinfo;
814 if(levelContext.redist->isSetup()) {
816 levelContext.lhs.getRedistributed()=0;
818 ::prolongateVector(*(*levelContext.aggregates), *levelContext.update, *levelContext.lhs,
819 levelContext.lhs.getRedistributed(),
820 matrices_->getProlongationDampingFactor(),
821 *levelContext.pinfo, *levelContext.redist);
825 ::prolongateVector(*(*levelContext.aggregates), *levelContext.update, *levelContext.lhs,
826 matrices_->getProlongationDampingFactor(),
827 *levelContext.pinfo);
831 if(processNextLevel) {
832 --levelContext.update;
836 *levelContext.update += *levelContext.lhs;
839 template<
class M,
class X,
class S,
class PI,
class A>
845 template<
class M,
class X,
class S,
class PI,
class A>
847 if(levelContext.matrix == matrices_->matrices().coarsest() && levels()==maxlevels()) {
851 if(levelContext.redist->isSetup()) {
852 levelContext.redist->redistribute(*levelContext.rhs, levelContext.rhs.getRedistributed());
853 if(levelContext.rhs.getRedistributed().size()>0) {
855 levelContext.pinfo.getRedistributed().copyOwnerToAll(levelContext.rhs.getRedistributed(),
856 levelContext.rhs.getRedistributed());
857 solver_->apply(levelContext.update.getRedistributed(),
858 levelContext.rhs.getRedistributed(), res);
860 levelContext.redist->redistributeBackward(*levelContext.update, levelContext.update.getRedistributed());
861 levelContext.pinfo->copyOwnerToAll(*levelContext.update, *levelContext.update);
863 levelContext.pinfo->copyOwnerToAll(*levelContext.rhs, *levelContext.rhs);
864 solver_->apply(*levelContext.update, *levelContext.rhs, res);
868 coarsesolverconverged =
false;
873 #ifndef DUNE_AMG_NO_COARSEGRIDCORRECTION
874 bool processNextLevel = moveToCoarseLevel(levelContext);
876 if(processNextLevel) {
878 for(std::size_t i=0; i<gamma_; i++)
882 moveToFineLevel(levelContext, processNextLevel);
887 if(levelContext.matrix == matrices_->matrices().finest()) {
888 coarsesolverconverged = matrices_->parallelInformation().finest()->communicator().prod(coarsesolverconverged);
889 if(!coarsesolverconverged)
890 DUNE_THROW(MathError,
"Coarse solver did not converge");
898 template<
class M,
class X,
class S,
class PI,
class A>
899 void AMG<M,X,S,PI,A>::additiveMgc(){
902 typename ParallelInformationHierarchy::Iterator pinfo=matrices_->parallelInformation().finest();
905 typename OperatorHierarchy::AggregatesMapList::const_iterator aggregates=matrices_->aggregatesMaps().begin();
910 ::restrictVector(*(*aggregates), *rhs,
static_cast<const Range&
>(*fineRhs), *pinfo);
916 lhs = lhs_->finest();
919 for(rhs=rhs_->finest(); rhs != rhs_->coarsest(); ++lhs, ++rhs, ++smoother) {
922 smoother->apply(*lhs, *rhs);
926 #ifndef DUNE_AMG_NO_COARSEGRIDCORRECTION
927 InverseOperatorResult res;
928 pinfo->copyOwnerToAll(*rhs, *rhs);
929 solver_->apply(*lhs, *rhs, res);
932 DUNE_THROW(MathError,
"Coarse solver did not converge");
948 template<
class M,
class X,
class S,
class PI,
class A>
951 DUNE_UNUSED_PARAMETER(x);
955 Iterator coarsest = smoothers_->
coarsest();
956 Iterator smoother = smoothers_->finest();
957 DIterator lhs = lhs_->finest();
958 if(smoothers_->levels()>0) {
959 if(smoother != coarsest || matrices_->levels()<matrices_->maxlevels())
960 smoother->post(*lhs);
961 if(smoother!=coarsest)
962 for(++smoother, ++lhs; smoother != coarsest; ++smoother, ++lhs)
963 smoother->post(*lhs);
964 smoother->post(*lhs);
971 template<
class M,
class X,
class S,
class PI,
class A>
975 matrices_->getCoarsestAggregatesOnFinest(cont);
984 template<
typename TL,
typename M>
985 std::shared_ptr<Dune::Preconditioner<typename Dune::TypeListElement<1, TL>::type,
986 typename Dune::TypeListElement<2, TL>::type>>
990 using D =
typename Dune::TypeListElement<1, decltype(tl)>::type;
991 using R =
typename Dune::TypeListElement<2, decltype(tl)>::type;
992 std::shared_ptr<Preconditioner<D,R>> amg;
993 std::string smoother = config.get(
"smoother",
"ssor");
995 std::shared_ptr<OP> op = std::make_shared<OP>(
mat);
996 if(smoother ==
"ssor")
997 return std::make_shared<Amg::AMG<OP, D, SeqSSOR<M,D,R>>>(op, config);
998 if(smoother ==
"sor")
999 return std::make_shared<Amg::AMG<OP, D, SeqSOR<M,D,R>>>(op, config);
1000 if(smoother ==
"jac")
1001 return std::make_shared<Amg::AMG<OP, D, SeqJac<M,D,R>>>(op, config);
1002 if(smoother ==
"gs")
1003 return std::make_shared<Amg::AMG<OP, D, SeqGS<M,D,R>>>(op, config);
1004 if(smoother ==
"ilu")
1005 return std::make_shared<Amg::AMG<OP, D, SeqILU<M,D,R>>>(op, config);
1007 DUNE_THROW(Dune::Exception,
"Unknown smoother for AMG");
1010 template<
typename TL,
typename M>
1011 std::shared_ptr<Dune::Preconditioner<typename Dune::TypeListElement<1, TL>::type,
1012 typename Dune::TypeListElement<2, TL>::type>>
1016 DUNE_THROW(
UnsupportedType,
"AMG needs a FieldMatrix as Matrix block_type");
Provides a classes representing the hierarchies in AMG.
Classes for the generic construction and application of the smoothers.
Prolongation and restriction for amg.
Define base class for scalar product and norm.
Implementations of the inverse operator interface.
Templates characterizing the type of a solver.
Classes for using SuperLU with ISTL matrices.
Classes for using UMFPack with ISTL matrices.
Col col
Definition: matrixmatrix.hh:349
Matrix & mat
Definition: matrixmatrix.hh:345
AMG(const AMG &amg)
Copy constructor.
Definition: amg.hh:325
void pre(Domain &x, Range &b)
Prepare the preconditioner.
Definition: amg.hh:617
static std::string name()
Definition: amg.hh:496
Hierarchy< Domain, A >::Iterator update
The iterator over the updates.
Definition: amg.hh:250
Hierarchy< Range, A >::Iterator rhs
The iterator over the right hand sided.
Definition: amg.hh:254
static std::string name()
Definition: amg.hh:488
Matrix ::field_type field_type
Definition: amg.hh:442
bool usesDirectCoarseLevelSolver() const
Check whether the coarse solver used is a direct solver.
Definition: amg.hh:840
X Domain
The domain type.
Definition: amg.hh:84
static DirectSolver * create(const Matrix &mat, bool verbose, bool reusevector)
Definition: amg.hh:497
AMG(OperatorHierarchy &matrices, CoarseSolver &coarseSolver, const SmootherArgs &smootherArgs, const Parameters &parms)
Construct a new amg with a specific coarse solver.
Definition: amg.hh:339
AMG(std::shared_ptr< const Operator > fineOperator, const ParameterTree &configuration, const ParallelInformation &pinfo=ParallelInformation())
Constructor an AMG via ParameterTree.
Definition: amg.hh:385
ParallelInformationHierarchy::Iterator pinfo
The iterator over the parallel information.
Definition: amg.hh:234
SolverType
Definition: amg.hh:443
OperatorHierarchy::AggregatesMapList::const_iterator aggregates
The iterator over the aggregates maps.
Definition: amg.hh:242
SmootherTraits< Smoother >::Arguments SmootherArgs
The argument type for the construction of the smoother.
Definition: amg.hh:97
Solver< Matrix, solver > SelectedSolver
Definition: amg.hh:493
S Smoother
The type of the smoother.
Definition: amg.hh:94
static std::string name()
Definition: amg.hh:465
Hierarchy< Smoother, A >::Iterator smoother
The iterator over the smoothers.
Definition: amg.hh:226
M Operator
The matrix operator type.
Definition: amg.hh:70
OperatorHierarchy::ParallelMatrixHierarchy::ConstIterator matrix
The iterator over the matrices.
Definition: amg.hh:230
SelectedSolver ::type DirectSolver
Definition: amg.hh:494
SuperLU< M > type
Definition: amg.hh:483
OperatorHierarchy::RedistributeInfoList::const_iterator redist
The iterator over the redistribution information.
Definition: amg.hh:238
X Range
The range type.
Definition: amg.hh:86
void presmooth(LevelContext &levelContext, size_t steps)
Apply pre smoothing on the current level.
Definition: smoother.hh:468
void getCoarsestAggregateNumbers(std::vector< std::size_t, A1 > &cont)
Get the aggregate number of each unknown on the coarsest level.
Definition: amg.hh:973
std::size_t levels()
Definition: amg.hh:692
InverseOperator< Vector, Vector > type
Definition: amg.hh:459
Hierarchy< Domain, A >::Iterator lhs
The iterator over the left hand side.
Definition: amg.hh:246
const void * Arguments
A type holding all the arguments needed to call the constructor.
Definition: construction.hh:44
static constexpr SolverType solver
Definition: amg.hh:445
static std::shared_ptr< T > construct(Arguments &args)
Construct an object with the specified arguments.
Definition: construction.hh:52
static constexpr bool isDirectSolver
Definition: amg.hh:495
void recalculateHierarchy()
Recalculate the matrix hierarchy.
Definition: amg.hh:192
Iterator coarsest()
Get an iterator positioned at the coarsest level.
Definition: hierarchy.hh:382
OperatorHierarchy::ParallelInformationHierarchy ParallelInformationHierarchy
The parallal data distribution hierarchy type.
Definition: amg.hh:81
InverseOperator< X, X > CoarseSolver
the type of the coarse solver.
Definition: amg.hh:88
void post(Domain &x)
Clean up.
Definition: amg.hh:949
std::size_t maxlevels()
Definition: amg.hh:697
void postsmooth(LevelContext &levelContext, size_t steps)
Apply post smoothing on the current level.
Definition: smoother.hh:490
std::shared_ptr< Dune::Preconditioner< typename Dune::TypeListElement< 1, TL >::type, typename Dune::TypeListElement< 2, TL >::type > > operator()(TL tl, const M &mat, const Dune::ParameterTree &config, std::enable_if_t< isValidBlockType< typename M::block_type >::value, int >=0) const
Definition: amg.hh:987
static type * create(const M &mat, bool verbose, bool reusevector)
Definition: amg.hh:460
std::size_t level
The level index.
Definition: amg.hh:258
AMG(const Operator &fineOperator, const C &criterion, const SmootherArgs &smootherArgs=SmootherArgs(), const ParallelInformation &pinfo=ParallelInformation())
Construct an AMG with an inexact coarse solver based on the smoother.
Definition: amg.hh:361
void apply(Domain &v, const Range &d)
Apply one step of the preconditioner to the system A(v)=d.
Definition: amg.hh:704
Smoother SmootherType
Definition: amg.hh:222
MatrixHierarchy< M, ParallelInformation, A > OperatorHierarchy
The operator hierarchy type.
Definition: amg.hh:79
virtual SolverCategory::Category category() const
Category of the preconditioner (see SolverCategory::Category)
Definition: amg.hh:165
static type * create(const M &mat, bool verbose, bool reusevector)
Definition: amg.hh:484
PI ParallelInformation
The type of the parallel information. Either OwnerOverlapCommunication or another type describing the...
Definition: amg.hh:77
@ none
Definition: amg.hh:443
@ umfpack
Definition: amg.hh:443
@ superlu
Definition: amg.hh:443
Definition: allocator.hh:7
DUNE_REGISTER_PRECONDITIONER("amg", AMGCreator())
ConstIterator class for sequential access.
Definition: matrix.hh:401
A generic dynamic dense matrix.
Definition: matrix.hh:558
typename Imp::BlockTraits< T >::field_type field_type
Export the type representing the underlying field.
Definition: matrix.hh:562
row_type::const_iterator ConstColIterator
Const iterator for the entries of each row.
Definition: matrix.hh:586
T block_type
Export the type representing the components.
Definition: matrix.hh:565
Definition: matrixutils.hh:26
Adapter to turn a matrix into a linear operator.
Definition: operators.hh:135
Functor using the row sum (infinity) norm to determine strong couplings.
Definition: aggregates.hh:459
an algebraic multigrid method using a Krylov-cycle.
Definition: kamg.hh:142
Two grid operator for AMG with Krylov cycle.
Definition: kamg.hh:31
Parallel algebraic multigrid based on agglomeration.
Definition: amg.hh:62
LevelIterator< Hierarchy< ParallelInformation, Allocator >, ParallelInformation > Iterator
Type of the mutable iterator.
Definition: hierarchy.hh:215
LevelIterator< const Hierarchy< MatrixOperator, Allocator >, const MatrixOperator > ConstIterator
Type of the const iterator.
Definition: hierarchy.hh:218
The hierarchies build by the coarsening process.
Definition: matrixhierarchy.hh:59
The criterion describing the stop criteria for the coarsening process.
Definition: matrixhierarchy.hh:283
All parameters for AMG.
Definition: parameters.hh:391
Traits class for getting the attribute class of a smoother.
Definition: smoother.hh:65
static void restrictVector(const AggregatesMap< Vertex > &aggregates, Vector &coarse, const Vector &fine, T &comm)
static void prolongateVector(const AggregatesMap< Vertex > &aggregates, Vector &coarse, Vector &fine, Vector &fineRedist, T1 damp, R &redistributor=R())
Base class for matrix free definition of preconditioners.
Definition: preconditioner.hh:30
Base class for scalar product and norm computation.
Definition: scalarproducts.hh:48
Statistics about the application of an inverse operator.
Definition: solver.hh:46
bool converged
True if convergence criterion has been met.
Definition: solver.hh:71
Categories for the solvers.
Definition: solvercategory.hh:20
Category
Definition: solvercategory.hh:21
static Category category(const OP &op, decltype(op.category()) *=nullptr)
Helperfunction to extract the solver category either from an enum, or from the newly introduced virtu...
Definition: solvercategory.hh:32
Definition: solvercategory.hh:52
Definition: solverfactory.hh:124
Definition: solvertype.hh:14
SuperLu Solver.
Definition: superlu.hh:293
Definition: umfpack.hh:48
The UMFPack direct sparse solver.
Definition: umfpack.hh:214