Skip to content
Snippets Groups Projects
Commit e8d56d05 authored by Simon Praetorius's avatar Simon Praetorius
Browse files

Add FastAMG constructor with shared_ptr arguments

parent 1623ad6e
No related branches found
No related tags found
No related merge requests found
...@@ -50,7 +50,7 @@ namespace Dune ...@@ -50,7 +50,7 @@ namespace Dune
* *
* It combines one Gauss-Seidel smoothing sweep with * It combines one Gauss-Seidel smoothing sweep with
* the defect calculation to reduce memory transfers. * the defect calculation to reduce memory transfers.
* \tparam M The matrix type * \tparam M The matrix-operator type, e.g. MatrixAdapter or AssembledLinearOperator
* \tparam X The vector type * \tparam X The vector type
* \tparam PI Currently ignored. * \tparam PI Currently ignored.
* \tparam A An allocator for X * \tparam A An allocator for X
...@@ -103,10 +103,44 @@ namespace Dune ...@@ -103,10 +103,44 @@ namespace Dune
* @param pinfo The information about the parallel distribution of the data. * @param pinfo The information about the parallel distribution of the data.
*/ */
template<class C> template<class C>
FastAMG(const Operator& fineOperator, const C& criterion, FastAMG(std::shared_ptr<Operator> fineOperator,
const C& criterion,
const Parameters& parms=Parameters(), const Parameters& parms=Parameters(),
bool symmetric=true, bool symmetric=true,
const ParallelInformation& pinfo=ParallelInformation()); std::shared_ptr<ParallelInformation> pinfo=std::make_shared<ParallelInformation>());
/**
* @brief Construct an AMG with an inexact coarse solver based on the smoother.
*
* As coarse solver a preconditioned CG method with the smoother as preconditioner
* will be used. The matrix hierarchy is built automatically.
* @param fineOperator The operator on the fine level.
* @param criterion The criterion describing the coarsening strategy. E. g. SymmetricCriterion
* or UnsymmetricCriterion, and providing the parameters.
* @param parms The parameters for the AMG.
*
* NOTE: This constructor uses the default constructed `ParallelInformation`.
*/
template<class C>
FastAMG(const Operator& fineOperator,
const C& criterion,
const Parameters& parms=Parameters(),
bool symmetric=true)
: FastAMG(stackobject_to_shared_ptr(const_cast<Operator&>(fineOperator)),
criterion, parms, symmetric)
{}
//! \copydoc FastAMG(const std::shared_ptr<Operator>&,const C&,const Parameters&,bool,std::shared_ptr<ParallelInformation>)
template<class C>
FastAMG(const Operator& fineOperator,
const C& criterion,
const Parameters& parms,
bool symmetric,
const ParallelInformation& pinfo)
: FastAMG(stackobject_to_shared_ptr(const_cast<Operator&>(fineOperator)),
criterion, parms, symmetric,
stackobject_to_shared_ptr(const_cast<ParallelInformation&>(pinfo)))
{}
/** /**
* @brief Copy constructor. * @brief Copy constructor.
...@@ -167,8 +201,8 @@ namespace Dune ...@@ -167,8 +201,8 @@ namespace Dune
*/ */
template<class C> template<class C>
void createHierarchies(C& criterion, void createHierarchies(C& criterion,
const std::shared_ptr<const Operator>& matrixptr, std::shared_ptr<Operator> fineOperator,
const PI& pinfo); std::shared_ptr<PI> pinfo);
/** /**
* @brief A struct that holds the context of the current level. * @brief A struct that holds the context of the current level.
...@@ -314,11 +348,11 @@ namespace Dune ...@@ -314,11 +348,11 @@ namespace Dune
} }
template<class M, class X, class PI, class A> template<class M, class X, class PI, class A>
template<class C> template<class C>
FastAMG<M,X,PI,A>::FastAMG(const Operator& matrix, FastAMG<M,X,PI,A>::FastAMG(std::shared_ptr<Operator> fineOperator,
const C& criterion, const C& criterion,
const Parameters& parms, const Parameters& parms,
bool symmetric_, bool symmetric_,
const PI& pinfo) std::shared_ptr<PI> pinfo)
: solver_(), rhs_(), lhs_(), residual_(), scalarProduct_(), gamma_(parms.getGamma()), : solver_(), rhs_(), lhs_(), residual_(), scalarProduct_(), gamma_(parms.getGamma()),
preSteps_(parms.getNoPreSmoothSteps()), postSteps_(parms.getNoPostSmoothSteps()), preSteps_(parms.getNoPreSmoothSteps()), postSteps_(parms.getNoPostSmoothSteps()),
buildHierarchy_(true), buildHierarchy_(true),
...@@ -335,20 +369,17 @@ namespace Dune ...@@ -335,20 +369,17 @@ namespace Dune
// TODO: reestablish compile time checks. // TODO: reestablish compile time checks.
//static_assert(static_cast<int>(PI::category)==static_cast<int>(S::category), //static_assert(static_cast<int>(PI::category)==static_cast<int>(S::category),
// "Matrix and Solver must match in terms of category!"); // "Matrix and Solver must match in terms of category!");
auto matrixptr = stackobject_to_shared_ptr(matrix); createHierarchies(criterion, std::move(fineOperator), std::move(pinfo));
createHierarchies(criterion, matrixptr, pinfo);
} }
template<class M, class X, class PI, class A> template<class M, class X, class PI, class A>
template<class C> template<class C>
void FastAMG<M,X,PI,A>::createHierarchies(C& criterion, void FastAMG<M,X,PI,A>::createHierarchies(C& criterion,
const std::shared_ptr<const Operator>& matrixptr, std::shared_ptr<Operator> fineOperator,
const PI& pinfo) std::shared_ptr<PI> pinfo)
{ {
Timer watch; Timer watch;
matrices_ = std::make_shared<OperatorHierarchy>( matrices_ = std::make_shared<OperatorHierarchy>(std::move(fineOperator), std::move(pinfo));
std::const_pointer_cast<Operator>(matrixptr),
stackobject_to_shared_ptr(const_cast<PI&>(pinfo)));
matrices_->template build<NegateSet<typename PI::OwnerSet> >(criterion); matrices_->template build<NegateSet<typename PI::OwnerSet> >(criterion);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment