Skip to content
Snippets Groups Projects
Commit 3c7db109 authored by Christian Engwer's avatar Christian Engwer
Browse files

[kamg] add new constructors, compatible with the new constructors of the amg

parent cac6f96d
No related branches found
No related tags found
No related merge requests found
...@@ -179,8 +179,23 @@ namespace Dune ...@@ -179,8 +179,23 @@ namespace Dune
*/ */
KAMG(const OperatorHierarchy& matrices, CoarseSolver& coarseSolver, KAMG(const OperatorHierarchy& matrices, CoarseSolver& coarseSolver,
const SmootherArgs& smootherArgs, std::size_t gamma, const SmootherArgs& smootherArgs, std::size_t gamma,
std::size_t preSmoothingSteps =1, std::size_t postSmoothingSteps = 1, std::size_t preSmoothingSteps=1, std::size_t postSmoothingSteps=1,
std::size_t maxLevelKrylovSteps = 3 , double minDefectReduction =1e-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. * @brief Construct an AMG with an inexact coarse solver based on the smoother.
...@@ -197,12 +212,35 @@ namespace Dune ...@@ -197,12 +212,35 @@ namespace Dune
* @param maxLevelKrylovSteps The maximum number of Krylov steps allowed at each level. * @param maxLevelKrylovSteps The maximum number of Krylov steps allowed at each level.
* @param minDefectReduction The defect reduction to achieve on each krylov level. * @param minDefectReduction The defect reduction to achieve on each krylov level.
* @param pinfo The information about the parallel distribution of the data. * @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> template<class C>
KAMG(const Operator& fineOperator, const C& criterion, 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 preSmoothingSteps=1, std::size_t postSmoothingSteps=1,
std::size_t maxLevelKrylovSteps=3, double minDefectReduction=1e-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()); const ParallelInformation& pinfo=ParallelInformation());
/** \copydoc Preconditioner::pre(X&,Y&) */ /** \copydoc Preconditioner::pre(X&,Y&) */
...@@ -241,6 +279,14 @@ namespace Dune ...@@ -241,6 +279,14 @@ namespace Dune
postSmoothingSteps), maxLevelKrylovSteps(ksteps), levelDefectReduction(reduction) 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 M, class X, class S, class P, class K, class A>
template<class C> template<class C>
KAMG<M,X,S,P,K,A>::KAMG(const Operator& fineOperator, const C& criterion, KAMG<M,X,S,P,K,A>::KAMG(const Operator& fineOperator, const C& criterion,
...@@ -252,6 +298,16 @@ namespace Dune ...@@ -252,6 +298,16 @@ namespace Dune
postSmoothingSteps, false, pinfo), maxLevelKrylovSteps(ksteps), levelDefectReduction(reduction) 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> 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) void KAMG<M,X,S,P,K,A>::pre(Domain& x, Range& b)
......
...@@ -96,7 +96,7 @@ void testAMG(int N, int coarsenTarget, int ml) ...@@ -96,7 +96,7 @@ void testAMG(int N, int coarsenTarget, int ml)
Dune::SeqScalarProduct<Vector> sp; Dune::SeqScalarProduct<Vector> sp;
typedef Dune::Amg::KAMG<Operator,Vector,Smoother,Dune::Amg::SequentialInformation> AMG; 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(); double buildtime = watch.elapsed();
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment