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_;