Go to the documentation of this file.
3 #ifndef DUNE_ISTL_TWOLEVELMETHOD_HH
4 #define DUNE_ISTL_TWOLEVELMETHOD_HH
13 #include<dune/common/unused.hh>
36 template<
class FO,
class CO>
140 template<
class O,
class C>
156 prolongDamp_ = criterion_.getProlongationDampingFactor();
163 typedef NegateSet<typename ParallelInformation::OwnerSet> OverlapFlags;
167 int noAggregates, isoAggregates, oneAggregates, skippedAggregates;
169 std::tie(noAggregates, isoAggregates, oneAggregates, skippedAggregates) =
170 aggregatesMap_->buildAggregates(fineOperator.getmat(), pg, criterion_,
true);
171 std::cout<<
"no aggregates="<<noAggregates<<
" iso="<<isoAggregates<<
" one="<<oneAggregates<<
" skipped="<<skippedAggregates<<std::endl;
174 typedef std::vector<bool>::iterator Iterator;
175 typedef Dune::IteratorPropertyMap<Iterator, Dune::IdentityMap> VisitedMap;
176 std::vector<bool> excluded(fineOperator.getmat().N(),
false);
177 VisitedMap vm(excluded.begin(), Dune::IdentityMap());
179 std::size_t aggregates = renumberer.coarsen(pinfo, pg, vm,
180 *aggregatesMap_, pinfo,
182 std::vector<bool>& visited=excluded;
184 typedef std::vector<bool>::iterator Iterator;
186 for(Iterator iter= visited.begin(), end=visited.end();
189 matrix_.reset(productBuilder.
build(mg, vm,
194 productBuilder.
calculate(fineOperator.getmat(), *aggregatesMap_, *matrix_, pinfo, OverlapFlags());
195 this->
lhs_.resize(this->matrix_->M());
196 this->
rhs_.resize(this->matrix_->N());
220 typename O::matrix_type::field_type prolongDamp_;
221 std::shared_ptr<AggregatesMap> aggregatesMap_;
223 std::shared_ptr<typename O::matrix_type> matrix_;
232 template<
class O,
class S,
class C>
239 typedef typename O::range_type
X;
254 : smootherArgs_(args), criterion_(c)
258 : coarseOperator_(other.coarseOperator_), smootherArgs_(other.smootherArgs_),
259 criterion_(other.criterion_)
273 : amg_(op, crit,args), first_(true)
278 DUNE_UNUSED_PARAMETER(reduction);
279 DUNE_UNUSED_PARAMETER(res);
289 void apply(
X& x,
X& b, InverseOperatorResult& res)
291 return apply(x,b,1e-8,res);
297 return amg_.category();
300 ~AMGInverseOperator()
305 AMGInverseOperator(
const AMGInverseOperator& other)
306 : x_(other.x_), amg_(other.amg_), first_(other.first_)
329 coarseOperator_=transferPolicy.getCoarseLevelOperator();
330 AMGInverseOperator* inv =
new AMGInverseOperator(*coarseOperator_,
340 std::shared_ptr<Operator> coarseOperator_;
352 template<
class FO,
class CSP,
class S>
354 public Preconditioner<typename FO::domain_type, typename FO::range_type>
407 std::shared_ptr<SmootherType> smoother,
411 std::size_t preSteps=1, std::size_t postSteps=1)
412 : operator_(&op), smoother_(smoother),
413 preSteps_(preSteps), postSteps_(postSteps)
415 policy_ = policy.
clone();
417 coarseSolver_=coarsePolicy.createCoarseLevelSolver(*policy_);
421 : operator_(other.operator_), coarseSolver_(new
CoarseLevelSolver(*other.coarseSolver_)),
422 smoother_(other.smoother_), policy_(other.policy_->clone()),
423 preSteps_(other.preSteps_), postSteps_(other.postSteps_)
430 delete coarseSolver_;
440 DUNE_UNUSED_PARAMETER(x);
447 LevelContext context;
452 context.smoother=smoother_;
454 context.matrix=operator_;
463 *context.update += *context.lhs;
484 std::shared_ptr<SmootherType> smoother;
512 std::shared_ptr<S> smoother_;
514 LevelTransferPolicy<FO,typename CSP::Operator>* policy_;
516 std::size_t preSteps_;
518 std::size_t postSteps_;
CoarseOperatorType::range_type CoarseRangeType
The type of the range of the coarse level operator.
Definition: twolevelmethod.hh:61
AggregationLevelTransferPolicy(const Criterion &crit)
Definition: twolevelmethod.hh:150
Category
Definition: solvercategory.hh:21
TwoLevelMethod(const TwoLevelMethod &other)
Definition: twolevelmethod.hh:420
LevelTransferPolicy< O, O > FatherType
Definition: twolevelmethod.hh:146
FineOperatorType::range_type FineRangeType
The type of the range of the fine level operator.
Definition: twolevelmethod.hh:369
Operator Operator
The matrix operator type.
Definition: amg.hh:67
AMG< Operator, X, Smoother > AMGType
The type of the AMG construct on the coarse level.
Definition: twolevelmethod.hh:247
O::range_type X
The type of the range and domain of the operator.
Definition: twolevelmethod.hh:239
OneStepAMGCoarseSolverPolicy(const SmootherArgs &args, const Criterion &c)
Constructs the coarse solver policy.
Definition: twolevelmethod.hh:253
@ sequential
Category for sequential solvers.
Definition: solvercategory.hh:23
Class providing information about the mapping of the vertices onto aggregates.
Definition: aggregates.hh:542
A policy class for solving the coarse level system using one step of AMG.
Definition: twolevelmethod.hh:233
CO CoarseOperatorType
The linear operator of the finel level system. Has to be derived from AssembledLinearOperator.
Definition: twolevelmethod.hh:57
std::shared_ptr< CoarseOperatorType > operator_
the coarse level linear operator.
Definition: twolevelmethod.hh:132
S SmootherType
The type of the fine level smoother.
Definition: twolevelmethod.hh:390
void createCoarseLevelSystem(const O &fineOperator)
Algebraically creates the coarse level system.
Definition: twolevelmethod.hh:154
void moveToFineLevel(typename FatherType::FineDomainType &fineLhs)
Updates the fine level linear system after the correction of the coarse levels system.
Definition: twolevelmethod.hh:207
CSP CoarseLevelSolverPolicy
The type of the policy for constructing the coarse level solver.
Definition: twolevelmethod.hh:358
std::shared_ptr< CoarseOperatorType > & getCoarseLevelOperator()
Get the coarse level operator.
Definition: twolevelmethod.hh:70
virtual SolverCategory::Category category() const=0
Category of the solver (see SolverCategory::Category)
static void prolongateVector(const AggregatesMap< Vertex > &aggregates, Vector &coarse, Vector &fine, Vector &fineRedist, T1 damp, R &redistributor=R())
Abstract base class for all solvers.
Definition: solver.hh:91
virtual ~LevelTransferPolicy()
Destructor.
Definition: twolevelmethod.hh:124
A LeveTransferPolicy that used aggregation to construct the coarse level system.
Definition: twolevelmethod.hh:141
CoarseOperatorType::range_type CoarseRangeType
The type of the range of the coarse level operator.
Definition: twolevelmethod.hh:382
AMGInverseOperator CoarseLevelSolver
The type of solver constructed for the coarse level.
Definition: twolevelmethod.hh:317
~TwoLevelMethod()
Definition: twolevelmethod.hh:426
virtual void apply(X &x, X &b, InverseOperatorResult &res)=0
Apply inverse operator,.
CoarseOperatorType::domain_type CoarseDomainType
The type of the domain of the coarse level operator.
Definition: twolevelmethod.hh:386
OneStepAMGCoarseSolverPolicy(const OneStepAMGCoarseSolverPolicy &other)
Copy constructor.
Definition: twolevelmethod.hh:257
Provides a class for building the galerkin product based on a aggregation scheme.
CoarseRangeType rhs_
The coarse level rhs.
Definition: twolevelmethod.hh:128
The default class for the smoother arguments.
Definition: smoother.hh:35
Attaches properties to the edges and vertices of a graph.
Definition: graph.hh:975
Define general, extensible interface for operators. The available implementation wraps a matrix.
Statistics about the application of an inverse operator.
Definition: solver.hh:40
Abstract base class for transfer between levels and creation of the coarse level system.
Definition: twolevelmethod.hh:37
virtual LevelTransferPolicy * clone() const =0
Clone the current object.
AggregationLevelTransferPolicy * clone() const
Definition: twolevelmethod.hh:214
void pre(FineDomainType &x, FineRangeType &b)
Definition: twolevelmethod.hh:433
void calculate(const M &fine, const AggregatesMap< V > &aggregates, M &coarse, const I &pinfo, const O ©)
Calculate the galerkin product.
C Criterion
Definition: twolevelmethod.hh:147
virtual void moveToFineLevel(FineDomainType &fineLhs)=0
Updates the fine level linear system after the correction of the coarse levels system.
FO FineOperatorType
The linear operator of the finel level system. Has to be derived from AssembledLinearOperator.
Definition: twolevelmethod.hh:365
FO FineOperatorType
The linear operator of the finel level system. Has to be derived from AssembledLinearOperator.
Definition: twolevelmethod.hh:44
Definition: galerkin.hh:115
void presmooth(LevelContext &levelContext, size_t steps)
Apply pre smoothing on the current level.
Definition: smoother.hh:454
Define general, extensible interface for inverse operators.
CoarseOperatorType::domain_type CoarseDomainType
The type of the domain of the coarse level operator.
Definition: twolevelmethod.hh:65
CoarseDomainType & getCoarseLevelLhs()
Get the coarse level left hand side.
Definition: twolevelmethod.hh:87
O Operator
The type of the linear operator used.
Definition: twolevelmethod.hh:237
Class representing the properties of an ede in the matrix graph.
Definition: dependency.hh:37
The (undirected) graph of a matrix.
Definition: graph.hh:48
void moveToCoarseLevel(const typename FatherType::FineRangeType &fineRhs)
Definition: twolevelmethod.hh:200
void apply(FineDomainType &v, const FineRangeType &d)
Definition: twolevelmethod.hh:443
virtual SolverCategory::Category category() const
Category of the preconditioner (see SolverCategory::Category)
Definition: twolevelmethod.hh:470
CoarseLevelSolver * createCoarseLevelSolver(P &transferPolicy)
Constructs a coarse level solver.
Definition: twolevelmethod.hh:327
SmootherTraits< Smoother >::Arguments SmootherArgs
The argument type for the construction of the smoother.
Definition: amg.hh:94
Definition: twolevelmethod.hh:353
VertexDescriptor maxVertex() const
Get the maximal vertex descriptor.
SequentialInformation ParallelInformation
Definition: twolevelmethod.hh:148
FineOperatorType::range_type FineRangeType
The type of the range of the fine level operator.
Definition: twolevelmethod.hh:48
CoarseDomainType lhs_
The coarse level lhs.
Definition: twolevelmethod.hh:130
Definition: allocator.hh:7
void postsmooth(LevelContext &levelContext, size_t steps)
Apply post smoothing on the current level.
Definition: smoother.hh:476
static void restrictVector(const AggregatesMap< Vertex > &aggregates, Vector &coarse, const Vector &fine, T &comm)
void post(FineDomainType &x)
Definition: twolevelmethod.hh:438
Definition: indicescoarsener.hh:34
virtual void createCoarseLevelSystem(const FineOperatorType &fineOperator)=0
Algebraically creates the coarse level system.
FineOperatorType::domain_type FineDomainType
The type of the domain of the fine level operator.
Definition: twolevelmethod.hh:52
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:564
virtual void moveToCoarseLevel(const FineRangeType &fineRhs)=0
Transfers the data to the coarse level.
Dune::Amg::SmootherTraits< S >::Arguments SmootherArgs
The type of the arguments used for constructing the smoother.
Definition: twolevelmethod.hh:245
TwoLevelMethod(const FineOperatorType &op, std::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:406
CSP::Operator CoarseOperatorType
The linear operator of the finel level system. Has to be derived from AssembledLinearOperator.
Definition: twolevelmethod.hh:378
C Criterion
The type of the crition used for the aggregation within AMG.
Definition: twolevelmethod.hh:241
Base class for matrix free definition of preconditioners.
Definition: preconditioner.hh:30
CoarseLevelSolverPolicy::CoarseLevelSolver CoarseLevelSolver
The type of the coarse level solver.
Definition: twolevelmethod.hh:360
Class representing a node in the matrix graph.
Definition: dependency.hh:125
CoarseRangeType & getCoarseLevelRhs()
Get the coarse level right hand side.
Definition: twolevelmethod.hh:78
FineOperatorType::domain_type FineDomainType
The type of the domain of the fine level operator.
Definition: twolevelmethod.hh:373
S Smoother
The type of the smoother used in AMG.
Definition: twolevelmethod.hh:243