// -*- tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- // vi: set et ts=4 sw=2 sts=2: #ifndef DUNE_ISTL_TWOLEVELMETHODCPR_HH #define DUNE_ISTL_TWOLEVELMETHODCPR_HH // NOTE: This file is a modified version of dune/istl/paamg/twolevelmethod.hh from // dune-istl release 2.6.0. Modifications have been kept as minimal as possible. #include #include //#include "amg.hh" //#include"galerkin.hh" #include #include #include #include #include /** * @addtogroup ISTL_PAAMG * @{ * @file * @author Markus Blatt * @brief Algebraic twolevel methods. */ namespace Dune { namespace Amg { /** * @brief Abstract base class for transfer between levels and creation * of the coarse level system. * * @tparam FO The type of the linear operator of the finel level system. Has to be * derived from AssembledLinearOperator. * @tparam CO The type of the linear operator of the coarse level system. Has to be * derived from AssembledLinearOperator. */ template class LevelTransferPolicyCpr { public: /** * @brief The linear operator of the finel level system. Has to be * derived from AssembledLinearOperator. */ typedef FO FineOperatorType; /** * @brief The type of the range of the fine level operator. */ typedef typename FineOperatorType::range_type FineRangeType; /** * @brief The type of the domain of the fine level operator. */ typedef typename FineOperatorType::domain_type FineDomainType; /** * @brief The linear operator of the finel level system. Has to be * derived from AssembledLinearOperator. */ typedef CO CoarseOperatorType; /** * @brief The type of the range of the coarse level operator. */ typedef typename CoarseOperatorType::range_type CoarseRangeType; /** * @brief The type of the domain of the coarse level operator. */ typedef typename CoarseOperatorType::domain_type CoarseDomainType; /** * @brief Get the coarse level operator. * @return A shared pointer to the coarse level system. */ std::shared_ptr& getCoarseLevelOperator() { return operator_; } /** * @brief Get the coarse level right hand side. * @return The coarse level right hand side. */ CoarseRangeType& getCoarseLevelRhs() { return rhs_; } /** * @brief Get the coarse level left hand side. * @return The coarse level leftt hand side. */ CoarseDomainType& getCoarseLevelLhs() { return lhs_; } /** * @brief Transfers the data to the coarse level. * * Restricts the residual to the right hand side of the * coarse level system and initialies the left hand side * of the coarse level system. These can afterwards be accessed * usinf getCoarseLevelRhs() and getCoarseLevelLhs(). * @param fineDefect The current residual of the fine level system. */ virtual void moveToCoarseLevel(const FineRangeType& fineRhs)=0; /** * @brief Updates the fine level linear system after the correction * of the coarse levels system. * * After returning from this function the coarse level correction * will have been added to fine level system. * @param[inout] fineLhs The left hand side of the fine level to update * with the coarse level correction. */ virtual void moveToFineLevel(FineDomainType& fineLhs)=0; /** * @brief Algebraically creates the coarse level system. * * After returning from this function the coarse level operator * can be accessed using getCoarseLevelOperator(). * @param fineOperator The operator of the fine level system. */ virtual void createCoarseLevelSystem(const FineOperatorType& fineOperator)=0; /** * @brief ???. */ virtual void calculateCoarseEntries(const FineOperatorType& fineOperator) = 0; /** @brief Clone the current object. */ virtual LevelTransferPolicyCpr* clone() const =0; /** @brief Destructor. */ virtual ~LevelTransferPolicyCpr(){} protected: /** @brief The coarse level rhs. */ CoarseRangeType rhs_; /** @brief The coarse level lhs. */ CoarseDomainType lhs_; /** @brief the coarse level linear operator. */ std::shared_ptr operator_; }; /** * @brief A LeveTransferPolicy that used aggregation to construct the coarse level system. * @tparam O The type of the fine and coarse level operator. * @tparam C The criterion that describes the aggregation procedure. */ template class AggregationLevelTransferPolicyCpr : public LevelTransferPolicyCpr { typedef Dune::Amg::AggregatesMap AggregatesMap; public: typedef LevelTransferPolicyCpr FatherType; typedef C Criterion; typedef SequentialInformation ParallelInformation; AggregationLevelTransferPolicyCpr(const Criterion& crit) : criterion_(crit) {} void createCoarseLevelSystem(const O& fineOperator) { prolongDamp_ = criterion_.getProlongationDampingFactor(); GalerkinProduct productBuilder; typedef typename Dune::Amg::MatrixGraph MatrixGraph; typedef typename Dune::Amg::PropertiesGraph PropertiesGraph; MatrixGraph mg(fineOperator.getmat()); PropertiesGraph pg(mg,Dune::IdentityMap(),Dune::IdentityMap()); typedef NegateSet OverlapFlags; aggregatesMap_.reset(new AggregatesMap(pg.maxVertex()+1)); int noAggregates, isoAggregates, oneAggregates, skippedAggregates; std::tie(noAggregates, isoAggregates, oneAggregates, skippedAggregates) = aggregatesMap_->buildAggregates(fineOperator.getmat(), pg, criterion_, true); std::cout<<"no aggregates="<