3 #ifndef DUNE_AMG_KAMG_HH
4 #define DUNE_AMG_KAMG_HH
58 DUNE_UNUSED_PARAMETER(x); DUNE_UNUSED_PARAMETER(b);
64 DUNE_UNUSED_PARAMETER(x);
71 *levelContext_->update=0;
72 *levelContext_->rhs = d;
73 *levelContext_->lhs = v;
75 presmooth(*levelContext_, amg_.preSteps_);
76 bool processFineLevel =
77 amg_.moveToCoarseLevel(*levelContext_);
79 if(processFineLevel) {
83 coarseSolver_->apply(x, b, res);
84 *levelContext_->update=x;
87 amg_.moveToFineLevel(*levelContext_, processFineLevel);
90 v=*levelContext_->update;
119 std::shared_ptr<InverseOperator<Domain,Range> > coarseSolver_;
121 std::shared_ptr<typename AMG::LevelContext> levelContext_;
139 template<
class M,
class X,
class S,
class PI=SequentialInformation,
186 std::size_t maxLevelKrylovSteps=3,
double minDefectReduction=1e-1);
204 std::size_t maxLevelKrylovSteps=3,
double minDefectReduction=1e-1,
221 std::size_t maxLevelKrylovSteps;
224 double levelDefectReduction;
227 std::vector<std::shared_ptr<typename Amg::ScalarProduct> > scalarproducts;
230 std::vector<std::shared_ptr<KAmgTwoGrid<Amg> > > ksolvers;
234 template<
class M,
class X,
class S,
class P,
class K,
class A>
237 std::size_t ksteps,
double reduction)
238 : amg(matrices, coarseSolver, smootherArgs, params),
239 maxLevelKrylovSteps(ksteps), levelDefectReduction(reduction)
243 template<
class M,
class X,
class S,
class P,
class K,
class A>
247 std::size_t ksteps,
double reduction,
249 : amg(fineOperator, criterion, smootherArgs, pinfo),
250 maxLevelKrylovSteps(ksteps), levelDefectReduction(reduction)
254 template<
class M,
class X,
class S,
class P,
class K,
class A>
258 scalarproducts.reserve(amg.levels());
259 ksolvers.reserve(amg.levels());
261 typename OperatorHierarchy::ParallelMatrixHierarchy::Iterator
262 matrix = amg.matrices_->matrices().coarsest();
264 pinfo = amg.matrices_->parallelInformation().coarsest();
265 bool hasCoarsest=(amg.levels()==amg.maxlevels());
268 if(matrix==amg.matrices_->matrices().finest())
276 std::ostringstream s;
278 if(matrix!=amg.matrices_->matrices().finest())
280 scalarproducts.push_back(createScalarProduct<X>(*pinfo,category()));
281 std::shared_ptr<InverseOperator<Domain,Range> > ks =
282 std::shared_ptr<InverseOperator<Domain,Range> >(
new KrylovSolver(*matrix, *(scalarproducts.back()),
283 *(ksolvers.back()), levelDefectReduction,
284 maxLevelKrylovSteps, 0));
288 if(matrix==amg.matrices_->matrices().finest())
294 template<
class M,
class X,
class S,
class P,
class K,
class A>
301 template<
class M,
class X,
class S,
class P,
class K,
class A>
304 if(ksolvers.size()==0)
308 amg.solver_->apply(v,td,res);
311 typedef typename Amg::LevelContext LevelContext;
312 std::shared_ptr<LevelContext> levelContext(
new LevelContext);
313 amg.initIteratorsWithFineLevel(*levelContext);
314 typedef typename std::vector<std::shared_ptr<KAmgTwoGrid<Amg> > >::iterator Iter;
315 for(Iter solver=ksolvers.begin(); solver!=ksolvers.end(); ++solver)
316 (*solver)->setLevelContext(levelContext);
317 ksolvers.back()->apply(v,d);
321 template<
class M,
class X,
class S,
class P,
class K,
class A>
324 return amg.maxlevels();
Define general preconditioner interface.
void apply(Domain &v, const Range &d)
Apply one step of the preconditioner to the system A(v)=d.
Definition: kamg.hh:302
X Domain
The domain type.
Definition: amg.hh:84
KAMG(OperatorHierarchy &matrices, CoarseSolver &coarseSolver, const SmootherArgs &smootherArgs, const Parameters &parms, std::size_t maxLevelKrylovSteps=3, double minDefectReduction=1e-1)
Construct a new amg with a specific coarse solver.
Definition: kamg.hh:235
std::size_t maxlevels()
Definition: kamg.hh:322
SmootherTraits< Smoother >::Arguments SmootherArgs
The argument type for the construction of the smoother.
Definition: amg.hh:97
M Operator
The matrix operator type.
Definition: amg.hh:70
void post(Domain &x)
Clean up.
Definition: kamg.hh:295
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 postsmooth(LevelContext &levelContext, size_t steps)
Apply post smoothing on the current level.
Definition: smoother.hh:490
void pre(Domain &x, Range &b)
Prepare the preconditioner.
Definition: kamg.hh:255
virtual SolverCategory::Category category() const
Category of the preconditioner (see SolverCategory::Category)
Definition: amg.hh:165
PI ParallelInformation
The type of the parallel information. Either OwnerOverlapCommunication or another type describing the...
Definition: amg.hh:77
Definition: allocator.hh:7
an algebraic multigrid method using a Krylov-cycle.
Definition: kamg.hh:142
Amg::Domain Domain
the type of the domain.
Definition: kamg.hh:159
Amg::SmootherArgs SmootherArgs
The type of the arguments for construction of the smoothers.
Definition: kamg.hh:155
Amg::ParallelInformation ParallelInformation
the type of the parallelinformation to use.
Definition: kamg.hh:153
Amg::CoarseSolver CoarseSolver
The type of the coarse solver.
Definition: kamg.hh:151
Amg::OperatorHierarchy OperatorHierarchy
The type of the hierarchy of operators.
Definition: kamg.hh:149
Amg::Range Range
The type of the range.
Definition: kamg.hh:161
Amg::ScalarProduct ScalarProduct
The type of the scalar product.
Definition: kamg.hh:165
AMG< M, X, S, PI, A > Amg
The type of the underlying AMG.
Definition: kamg.hh:145
Amg::Operator Operator
the type of the lineatr operator.
Definition: kamg.hh:157
Amg::ParallelInformationHierarchy ParallelInformationHierarchy
The type of the hierarchy of parallel information.
Definition: kamg.hh:163
virtual SolverCategory::Category category() const
Category of the preconditioner (see SolverCategory::Category)
Definition: kamg.hh:168
K KrylovSolver
The type of the Krylov solver for the cycle.
Definition: kamg.hh:147
Two grid operator for AMG with Krylov cycle.
Definition: kamg.hh:31
void pre(typename AMG::Domain &x, typename AMG::Range &b)
Prepare the preconditioner.
Definition: kamg.hh:56
InverseOperator< Domain, Range > * coarseSolver()
Get a pointer to the coarse grid solver.
Definition: kamg.hh:97
KAmgTwoGrid(AMG &amg, std::shared_ptr< InverseOperator< Domain, Range > > coarseSolver)
Constructor.
Definition: kamg.hh:51
~KAmgTwoGrid()
Destructor.
Definition: kamg.hh:112
void post(typename AMG::Domain &x)
Clean up.
Definition: kamg.hh:62
virtual SolverCategory::Category category() const
Category of the preconditioner (see SolverCategory::Category)
Definition: kamg.hh:39
void setLevelContext(std::shared_ptr< typename AMG::LevelContext > p)
Set the level context pointer.
Definition: kamg.hh:106
void apply(typename AMG::Domain &v, const typename AMG::Range &d)
Apply one step of the preconditioner to the system A(v)=d.
Definition: kamg.hh:68
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
The hierarchies build by the coarsening process.
Definition: matrixhierarchy.hh:59
All parameters for AMG.
Definition: parameters.hh:391
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
Category
Definition: solvercategory.hh:21
Generalized preconditioned conjugate gradient solver.
Definition: solvers.hh:1285