diff --git a/dune/istl/paamg/kamg.hh b/dune/istl/paamg/kamg.hh index efdfd8e6f3d84724170e71575b6a085d115765b9..a44ad07461a389626431aa054dc4e4af88f1daf3 100644 --- a/dune/istl/paamg/kamg.hh +++ b/dune/istl/paamg/kamg.hh @@ -179,8 +179,23 @@ namespace Dune */ KAMG(const OperatorHierarchy& matrices, CoarseSolver& coarseSolver, const SmootherArgs& smootherArgs, std::size_t gamma, - std::size_t preSmoothingSteps =1, std::size_t postSmoothingSteps = 1, - std::size_t maxLevelKrylovSteps = 3 , double minDefectReduction =1e-1); + std::size_t preSmoothingSteps=1, std::size_t postSmoothingSteps=1, + std::size_t maxLevelKrylovSteps=3, double minDefectReduction=1e-1) DUNE_DEPRECATED; + + /** + * @brief Construct a new amg with a specific coarse solver. + * @param matrices The already set up matix hierarchy. + * @param coarseSolver The set up solver to use on the coarse + * grid, must match the coarse matrix in the matrix hierachy. + * @param smootherArgs The arguments needed for thesmoother to use + * for pre and post smoothing. + * @param parms The parameters for the AMG. + * @param maxLevelKrylovSteps maximum of krylov iterations on a particular level (default=3) + * @param minDefectReduction minimal defect reduction during the krylov iterations on a particular level (default=1e-1) + */ + KAMG(const OperatorHierarchy& matrices, CoarseSolver& coarseSolver, + const SmootherArgs& smootherArgs, const Parameters& parms, + std::size_t maxLevelKrylovSteps=3, double minDefectReduction=1e-1); /** * @brief Construct an AMG with an inexact coarse solver based on the smoother. @@ -197,12 +212,35 @@ namespace Dune * @param maxLevelKrylovSteps The maximum number of Krylov steps allowed at each level. * @param minDefectReduction The defect reduction to achieve on each krylov level. * @param pinfo The information about the parallel distribution of the data. + * @deprecated Use + * KAMG(const Operator&, const C&, const SmootherArgs, const ParallelInformation) + * instead. + * All parameters can be set in the criterion! */ template<class C> KAMG(const Operator& fineOperator, const C& criterion, - const SmootherArgs& smootherArgs, std::size_t gamma=1, + const SmootherArgs& smootherArgs, std::size_t gamma, std::size_t preSmoothingSteps=1, std::size_t postSmoothingSteps=1, std::size_t maxLevelKrylovSteps=3, double minDefectReduction=1e-1, + const ParallelInformation& pinfo=ParallelInformation()) DUNE_DEPRECATED; + + /** + * @brief Construct an AMG with an inexact coarse solver based on the smoother. + * + * As coarse solver a preconditioned CG method with the smoother as preconditioner + * will be used. The matrix hierarchy is built automatically. + * @param fineOperator The operator on the fine level. + * @param criterion The criterion describing the coarsening strategy. E. g. SymmetricCriterion + * or UnsymmetricCriterion, and providing the parameters. + * @param smootherArgs The arguments for constructing the smoothers. + * @param maxLevelKrylovSteps maximum of krylov iterations on a particular level (default=3) + * @param minDefectReduction minimal defect reduction during the krylov iterations on a particular level (default=1e-1) + * @param pinfo The information about the parallel distribution of the data. + */ + template<class C> + KAMG(const Operator& fineOperator, const C& criterion, + const SmootherArgs& smootherArgs=SmootherArgs(), + std::size_t maxLevelKrylovSteps=3, double minDefectReduction=1e-1, const ParallelInformation& pinfo=ParallelInformation()); /** \copydoc Preconditioner::pre(X&,Y&) */ @@ -241,6 +279,14 @@ namespace Dune postSmoothingSteps), maxLevelKrylovSteps(ksteps), levelDefectReduction(reduction) {} + template<class M, class X, class S, class P, class K, class A> + KAMG<M,X,S,P,K,A>::KAMG(const OperatorHierarchy& matrices, CoarseSolver& coarseSolver, + const SmootherArgs& smootherArgs, const Parameters& params, + std::size_t ksteps, double reduction) + : amg(matrices, coarseSolver, smootherArgs, params), + maxLevelKrylovSteps(ksteps), levelDefectReduction(reduction) + {} + template<class M, class X, class S, class P, class K, class A> template<class C> KAMG<M,X,S,P,K,A>::KAMG(const Operator& fineOperator, const C& criterion, @@ -252,6 +298,16 @@ namespace Dune postSmoothingSteps, false, pinfo), maxLevelKrylovSteps(ksteps), levelDefectReduction(reduction) {} + template<class M, class X, class S, class P, class K, class A> + template<class C> + KAMG<M,X,S,P,K,A>::KAMG(const Operator& fineOperator, const C& criterion, + const SmootherArgs& smootherArgs, + std::size_t ksteps, double reduction, + const ParallelInformation& pinfo) + : amg(fineOperator, criterion, smootherArgs, pinfo), + maxLevelKrylovSteps(ksteps), levelDefectReduction(reduction) + {} + template<class M, class X, class S, class P, class K, class A> void KAMG<M,X,S,P,K,A>::pre(Domain& x, Range& b) diff --git a/dune/istl/paamg/test/kamgtest.cc b/dune/istl/paamg/test/kamgtest.cc index 08fd6c0f9ea69e4a256b89f2a2e3401e6384e82c..440d5f3f6894ae71c4d74e04259cddc5bf84a80c 100644 --- a/dune/istl/paamg/test/kamgtest.cc +++ b/dune/istl/paamg/test/kamgtest.cc @@ -96,7 +96,7 @@ void testAMG(int N, int coarsenTarget, int ml) Dune::SeqScalarProduct<Vector> sp; typedef Dune::Amg::KAMG<Operator,Vector,Smoother,Dune::Amg::SequentialInformation> AMG; - AMG amg(fop, criterion, smootherArgs, 1, 1, 1); + AMG amg(fop, criterion, smootherArgs); double buildtime = watch.elapsed();