Skip to content
Snippets Groups Projects
Commit 01b18870 authored by Christian Engwer's avatar Christian Engwer
Browse files

[prec] change internal memory management of parallel preconditioners

like all other preconditioners we now use shared_ptr to be able to go
via the base class.
parent bd05ab5a
No related branches found
No related tags found
1 merge request!274Feature/amg memory management
This commit is part of merge request !274. Comments created here will be created in the context of that merge request.
......@@ -266,6 +266,7 @@ namespace Dune {
: public Dune::Preconditioner<typename P::domain_type,typename P::range_type> {
friend struct Amg::ConstructionTraits<NonoverlappingBlockPreconditioner<C,P> >;
public:
typedef Preconditioner<typename P::domain_type,typename P::range_type> Prec;
//! \brief The domain type of the preconditioner.
typedef typename P::domain_type domain_type;
//! \brief The range type of the preconditioner.
......@@ -280,9 +281,27 @@ namespace Dune {
\param c The communication object for syncing owner and copy
data points. (E.~g. OwnerOverlapCommunication )
*/
NonoverlappingBlockPreconditioner (P& prec, const communication_type& c)
: preconditioner(prec), communication(c)
{}
/*! \brief Constructor.
constructor gets all parameters to operate the prec.
\param p The sequential preconditioner.
\param c The communication object for syncing overlap and copy
data points. (E.~g. OwnerOverlapCopyCommunication )
*/
NonoverlappingBlockPreconditioner (Prec& p, const communication_type& c)
: _preconditioner(stackobject_to_shared_ptr(p)), _communication(c)
{ }
/*! \brief Constructor.
constructor gets all parameters to operate the prec.
\param p The sequential preconditioner.
\param c The communication object for syncing overlap and copy
data points. (E.~g. OwnerOverlapCopyCommunication )
*/
NonoverlappingBlockPreconditioner (const std::shared_ptr<Prec>& p, const communication_type& c)
: _preconditioner(p), _communication(c)
{ }
/*!
\brief Prepare the preconditioner.
......@@ -291,7 +310,7 @@ namespace Dune {
*/
virtual void pre (domain_type& x, range_type& b)
{
preconditioner.pre(x,b);
_preconditioner->pre(x,b);
}
/*!
......@@ -304,8 +323,8 @@ namespace Dune {
// block preconditioner equivalent to WrappedPreconditioner from
// pdelab/backend/ovlpistsolverbackend.hh,
// but not to BlockPreconditioner from schwarz.hh
preconditioner.apply(v,d);
communication.addOwnerCopyToOwnerCopy(v,v);
_preconditioner->apply(v,d);
_communication.addOwnerCopyToOwnerCopy(v,v);
}
/*!
......@@ -315,7 +334,7 @@ namespace Dune {
*/
virtual void post (domain_type& x)
{
preconditioner.post(x);
_preconditioner->post(x);
}
//! Category of the preconditioner (see SolverCategory::Category)
......@@ -326,10 +345,10 @@ namespace Dune {
private:
//! \brief a sequential preconditioner
P& preconditioner;
std::shared_ptr<Prec>& _preconditioner;
//! \brief the communication object
const communication_type& communication;
const communication_type& _communication;
};
/** @} end documentation */
......
......@@ -294,8 +294,19 @@ namespace Dune {
\param c The communication object for syncing overlap and copy
data points. (E.~g. OwnerOverlapCopyCommunication )
*/
BlockPreconditioner (T& p, const communication_type& c)
: preconditioner(p), communication(c)
BlockPreconditioner (Preconditioner<X,Y>& p, const communication_type& c)
: _preconditioner(stackobject_to_shared_ptr(p)), _communication(c)
{ }
/*! \brief Constructor.
constructor gets all parameters to operate the prec.
\param p The sequential preconditioner.
\param c The communication object for syncing overlap and copy
data points. (E.~g. OwnerOverlapCopyCommunication )
*/
BlockPreconditioner (const std::shared_ptr<Preconditioner<X,Y>>& p, const communication_type& c)
: _preconditioner(p), _communication(c)
{ }
/*!
......@@ -305,8 +316,8 @@ namespace Dune {
*/
virtual void pre (X& x, Y& b)
{
communication.copyOwnerToAll(x,x); // make dirichlet values consistent
preconditioner.pre(x,b);
_communication.copyOwnerToAll(x,x); // make dirichlet values consistent
_preconditioner->pre(x,b);
}
/*!
......@@ -316,15 +327,15 @@ namespace Dune {
*/
virtual void apply (X& v, const Y& d)
{
preconditioner.apply(v,d);
communication.copyOwnerToAll(v,v);
_preconditioner->apply(v,d);
_communication.copyOwnerToAll(v,v);
}
template<bool forward>
void apply (X& v, const Y& d)
{
preconditioner.template apply<forward>(v,d);
communication.copyOwnerToAll(v,v);
_preconditioner->template apply<forward>(v,d);
_communication.copyOwnerToAll(v,v);
}
/*!
......@@ -334,7 +345,7 @@ namespace Dune {
*/
virtual void post (X& x)
{
preconditioner.post(x);
_preconditioner->post(x);
}
//! Category of the preconditioner (see SolverCategory::Category)
......@@ -345,10 +356,10 @@ namespace Dune {
private:
//! \brief a sequential preconditioner
T& preconditioner;
std::shared_ptr<Preconditioner<X,Y>> _preconditioner;
//! \brief the communication object
const communication_type& communication;
const communication_type& _communication;
};
/** @} end documentation */
......
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