3 #ifndef DUNE_ISTL_TWOLEVELMETHOD_HH
4 #define DUNE_ISTL_TWOLEVELMETHOD_HH
10 #include<dune/common/shared_ptr.hh>
11 #include<dune/common/unused.hh>
34 template<
class FO,
class CO>
138 template<
class O,
class C>
154 prolongDamp_ = criterion_.getProlongationDampingFactor();
159 MatrixGraph mg(fineOperator.getmat());
160 PropertiesGraph pg(mg,Dune::IdentityMap(),Dune::IdentityMap());
161 typedef NegateSet<typename ParallelInformation::OwnerSet> OverlapFlags;
165 int noAggregates, isoAggregates, oneAggregates, skippedAggregates;
167 tie(noAggregates, isoAggregates, oneAggregates, skippedAggregates) =
168 aggregatesMap_->buildAggregates(fineOperator.getmat(), pg, criterion_,
true);
169 std::cout<<
"no aggregates="<<noAggregates<<
" iso="<<isoAggregates<<
" one="<<oneAggregates<<
" skipped="<<skippedAggregates<<std::endl;
172 typedef std::vector<bool>::iterator Iterator;
173 typedef Dune::IteratorPropertyMap<Iterator, Dune::IdentityMap> VisitedMap;
174 std::vector<bool> excluded(fineOperator.getmat().N(),
false);
175 VisitedMap vm(excluded.begin(), Dune::IdentityMap());
177 std::size_t aggregates = renumberer.coarsen(pinfo, pg, vm,
178 *aggregatesMap_, pinfo,
180 std::vector<bool>& visited=excluded;
182 typedef std::vector<bool>::iterator Iterator;
184 for(Iterator iter= visited.begin(), end=visited.end();
187 matrix_.reset(productBuilder.
build(mg, vm,
192 productBuilder.
calculate(fineOperator.getmat(), *aggregatesMap_, *matrix_, pinfo, OverlapFlags());
193 this->
lhs_.resize(this->matrix_->M());
194 this->
rhs_.resize(this->matrix_->N());
218 typename O::matrix_type::field_type prolongDamp_;
219 shared_ptr<AggregatesMap> aggregatesMap_;
221 shared_ptr<typename O::matrix_type> matrix_;
230 template<
class O,
class S,
class C>
237 typedef typename O::range_type
X;
252 : smootherArgs_(args), criterion_(c)
256 : coarseOperator_(other.coarseOperator_), smootherArgs_(other.smootherArgs_),
257 criterion_(other.criterion_)
271 : amg_(op, crit,args), first_(true)
276 DUNE_UNUSED_PARAMETER(reduction);
277 DUNE_UNUSED_PARAMETER(res);
287 void apply(
X& x,
X& b, InverseOperatorResult& res)
289 return apply(x,b,1e-8,res);
292 ~AMGInverseOperator()
297 AMGInverseOperator(
const AMGInverseOperator& other)
298 : x_(other.x_), amg_(other.amg_), first_(other.first_)
321 coarseOperator_=transferPolicy.getCoarseLevelOperator();
322 AMGInverseOperator* inv =
new AMGInverseOperator(*coarseOperator_,
332 shared_ptr<Operator> coarseOperator_;
344 template<
class FO,
class CSP,
class S>
346 public Preconditioner<typename FO::domain_type, typename FO::range_type>
404 shared_ptr<SmootherType> smoother,
408 std::size_t preSteps=1, std::size_t postSteps=1)
409 : operator_(&op), smoother_(smoother),
410 preSteps_(preSteps), postSteps_(postSteps)
412 policy_ = policy.
clone();
414 coarseSolver_=coarsePolicy.createCoarseLevelSolver(*policy_);
418 : operator_(other.operator_), coarseSolver_(new
CoarseLevelSolver(*other.coarseSolver_)),
419 smoother_(other.smoother_), policy_(other.policy_->clone()),
420 preSteps_(other.preSteps_), postSteps_(other.postSteps_)
427 delete coarseSolver_;
437 DUNE_UNUSED_PARAMETER(x);
444 LevelContext context;
449 context.smoother=smoother_;
451 context.matrix=operator_;
460 *context.update += *context.lhs;
475 shared_ptr<SmootherType> smoother;
503 shared_ptr<S> smoother_;
505 LevelTransferPolicy<FO,typename CSP::Operator>* policy_;
507 std::size_t preSteps_;
509 std::size_t postSteps_;
AMGInverseOperator CoarseLevelSolver
The type of solver constructed for the coarse level.
Definition: twolevelmethod.hh:309
static void restrictVector(const AggregatesMap< Vertex > &aggregates, Vector &coarse, const Vector &fine, T &comm)
virtual void moveToCoarseLevel(const FineRangeType &fineRhs)=0
Transfers the data to the coarse level.
FO FineOperatorType
The linear operator of the finel level system. Has to be derived from AssembledLinearOperator.
Definition: twolevelmethod.hh:42
SmootherTraits< Smoother >::Arguments SmootherArgs
The argument type for the construction of the smoother.
Definition: amg.hh:92
CoarseOperatorType::range_type CoarseRangeType
The type of the range of the coarse level operator.
Definition: twolevelmethod.hh:59
Base class for matrix free definition of preconditioners.
Definition: preconditioner.hh:26
CO CoarseOperatorType
The linear operator of the finel level system. Has to be derived from AssembledLinearOperator.
Definition: twolevelmethod.hh:55
CoarseRangeType & getCoarseLevelRhs()
Get the coarse level right hand side.
Definition: twolevelmethod.hh:76
shared_ptr< CoarseOperatorType > operator_
the coarse level linear operator.
Definition: twolevelmethod.hh:130
void calculate(const M &fine, const AggregatesMap< V > &aggregates, M &coarse, const I &pinfo, const O ©)
Calculate the galerkin product.
S SmootherType
The type of the fine level smoother.
Definition: twolevelmethod.hh:382
Provides a class for building the galerkin product based on a aggregation scheme. ...
Definition: indicescoarsener.hh:35
OneStepAMGCoarseSolverPolicy(const OneStepAMGCoarseSolverPolicy &other)
Copy constructor.
Definition: twolevelmethod.hh:255
O::range_type X
The type of the range and domain of the operator.
Definition: twolevelmethod.hh:237
Abstract base class for all solvers.
Definition: solver.hh:79
virtual void createCoarseLevelSystem(const FineOperatorType &fineOperator)=0
Algebraically creates the coarse level system.
Abstract base class for transfer between levels and creation of the coarse level system.
Definition: twolevelmethod.hh:35
C Criterion
The type of the crition used for the aggregation within AMG.
Definition: twolevelmethod.hh:239
FineOperatorType::range_type FineRangeType
The type of the range of the fine level operator.
Definition: twolevelmethod.hh:361
static void prolongateVector(const AggregatesMap< Vertex > &aggregates, Vector &coarse, Vector &fine, Vector &fineRedist, T1 damp, R &redistributor=R())
Attaches properties to the edges and vertices of a graph.
Definition: graph.hh:976
Definition: galerkin.hh:116
O Operator
The type of the linear operator used.
Definition: twolevelmethod.hh:235
TwoLevelMethod(const FineOperatorType &op, shared_ptr< SmootherType > smoother, const LevelTransferPolicy< FineOperatorType, CoarseOperatorType > &policy, CoarseLevelSolverPolicy &coarsePolicy, std::size_t preSteps=1, std::size_t postSteps=1)
Constructs a two level method.
Definition: twolevelmethod.hh:403
virtual ~LevelTransferPolicy()
Destructor.
Definition: twolevelmethod.hh:122
AggregationLevelTransferPolicy(const Criterion &crit)
Definition: twolevelmethod.hh:148
The (undirected) graph of a matrix.
Definition: graph.hh:49
G::MutableMatrix * build(G &fineGraph, V &visitedMap, const ParallelInformation &pinfo, AggregatesMap< typename G::VertexDescriptor > &aggregates, const typename G::Matrix::size_type &size, const Set ©)
Calculates the coarse matrix via a Galerkin product.
Definition: galerkin.hh:565
~TwoLevelMethod()
Definition: twolevelmethod.hh:423
virtual void apply(X &x, X &b, InverseOperatorResult &res)=0
Apply inverse operator,.
shared_ptr< CoarseOperatorType > & getCoarseLevelOperator()
Get the coarse level operator.
Definition: twolevelmethod.hh:68
virtual void moveToFineLevel(FineDomainType &fineLhs)=0
Updates the fine level linear system after the correction of the coarse levels system.
Dune::Amg::SmootherTraits< S >::Arguments SmootherArgs
The type of the arguments used for constructing the smoother.
Definition: twolevelmethod.hh:243
Class representing a node in the matrix graph.
Definition: dependency.hh:126
CoarseOperatorType::range_type CoarseRangeType
The type of the range of the coarse level operator.
Definition: twolevelmethod.hh:374
void apply(FineDomainType &v, const FineRangeType &d)
Definition: twolevelmethod.hh:440
Class providing information about the mapping of the vertices onto aggregates.
Definition: aggregates.hh:497
Definition: twolevelmethod.hh:345
CoarseOperatorType::domain_type CoarseDomainType
The type of the domain of the coarse level operator.
Definition: twolevelmethod.hh:63
FineOperatorType::range_type FineRangeType
The type of the range of the fine level operator.
Definition: twolevelmethod.hh:46
void moveToCoarseLevel(const typename FatherType::FineRangeType &fineRhs)
Definition: twolevelmethod.hh:198
Operator Operator
The matrix operator type.
Definition: amg.hh:65
The category the preconditioner is part of.
Definition: twolevelmethod.hh:386
Define general, extensible interface for inverse operators.
Category for sequential solvers.
Definition: solvercategory.hh:22
Class representing the properties of an ede in the matrix graph.
Definition: dependency.hh:38
virtual LevelTransferPolicy * clone() const =0
Clone the current object.
FineOperatorType::domain_type FineDomainType
The type of the domain of the fine level operator.
Definition: twolevelmethod.hh:365
FineOperatorType::domain_type FineDomainType
The type of the domain of the fine level operator.
Definition: twolevelmethod.hh:50
OneStepAMGCoarseSolverPolicy(const SmootherArgs &args, const Criterion &c)
Constructs the coarse solver policy.
Definition: twolevelmethod.hh:251
Statistics about the application of an inverse operator.
Definition: solver.hh:31
CSP CoarseLevelSolverPolicy
The type of the policy for constructing the coarse level solver.
Definition: twolevelmethod.hh:350
S Smoother
The type of the smoother used in AMG.
Definition: twolevelmethod.hh:241
FO FineOperatorType
The linear operator of the finel level system. Has to be derived from AssembledLinearOperator.
Definition: twolevelmethod.hh:357
Define general, extensible interface for operators. The available implementation wraps a matrix...
TwoLevelMethod(const TwoLevelMethod &other)
Definition: twolevelmethod.hh:417
LevelTransferPolicy< O, O > FatherType
Definition: twolevelmethod.hh:144
void post(FineDomainType &x)
Definition: twolevelmethod.hh:435
C Criterion
Definition: twolevelmethod.hh:145
AMG< Operator, X, Smoother > AMGType
The type of the AMG construct on the coarse level.
Definition: twolevelmethod.hh:245
void moveToFineLevel(typename FatherType::FineDomainType &fineLhs)
Updates the fine level linear system after the correction of the coarse levels system.
Definition: twolevelmethod.hh:205
void pre(FineDomainType &x, FineRangeType &b)
Definition: twolevelmethod.hh:430
SequentialInformation ParallelInformation
Definition: twolevelmethod.hh:146
void presmooth(LevelContext &levelContext, size_t steps)
Apply pre smoothing on the current level.
Definition: smoother.hh:408
CoarseDomainType & getCoarseLevelLhs()
Get the coarse level left hand side.
Definition: twolevelmethod.hh:85
CoarseRangeType rhs_
The coarse level rhs.
Definition: twolevelmethod.hh:126
void postsmooth(LevelContext &levelContext, size_t steps)
Apply post smoothing on the current level.
Definition: smoother.hh:430
CoarseDomainType lhs_
The coarse level lhs.
Definition: twolevelmethod.hh:128
CoarseLevelSolverPolicy::CoarseLevelSolver CoarseLevelSolver
The type of the coarse level solver.
Definition: twolevelmethod.hh:352
The default class for the smoother arguments.
Definition: smoother.hh:35
CSP::Operator CoarseOperatorType
The linear operator of the finel level system. Has to be derived from AssembledLinearOperator.
Definition: twolevelmethod.hh:370
A policy class for solving the coarse level system using one step of AMG.
Definition: twolevelmethod.hh:231
CoarseLevelSolver * createCoarseLevelSolver(P &transferPolicy)
Constructs a coarse level solver.
Definition: twolevelmethod.hh:319
A LeveTransferPolicy that used aggregation to construct the coarse level system.
Definition: twolevelmethod.hh:139
CoarseOperatorType::domain_type CoarseDomainType
The type of the domain of the coarse level operator.
Definition: twolevelmethod.hh:378
AggregationLevelTransferPolicy * clone() const
Clone the current object.
Definition: twolevelmethod.hh:212
void createCoarseLevelSystem(const O &fineOperator)
Algebraically creates the coarse level system.
Definition: twolevelmethod.hh:152