Skip to content
Snippets Groups Projects
Commit 1266505c authored by graeser's avatar graeser Committed by graeser
Browse files

Use shared_ptr

[[Imported from SVN: r12421]]
parent de753e85
No related branches found
No related tags found
No related merge requests found
......@@ -4,6 +4,7 @@
#include <dune/istl/bcrsmatrix.hh>
#include <dune/common/fmatrix.hh>
#include <dune/common/bitsetvector.hh>
#include <dune/common/shared_ptr.hh>
#include <dune/solvers/operators/sumoperator.hh>
#include <dune/solvers/common/staticmatrixtools.hh>
......@@ -43,15 +44,15 @@ public:
CompressedMultigridTransfer()
{
matrix_ = new TransferOperatorType;
matrixInternallyAllocated = true;
matrix_ = Dune::make_shared<TransferOperatorType>();
}
CompressedMultigridTransfer(typename Dune::shared_ptr<TransferOperatorType>& matrix) :
matrix_(matrix)
{}
virtual ~CompressedMultigridTransfer()
{
if (matrixInternallyAllocated)
delete matrix_;
}
{}
/** \brief Sets up the operator between two P1 spaces
......@@ -134,22 +135,23 @@ public:
return *matrix_;
}
/** \brief Set matrix! */
void setMatrix(typename Dune::shared_ptr<TransferOperatorType>& matrix)
{
matrix_ = matrix;
}
/** \brief Set matrix! */
void setMatrix(TransferOperatorType& matrix)
{
if (matrixInternallyAllocated)
delete matrix_;
matrixInternallyAllocated = false;
matrix_ = &matrix;
matrix_ = Dune::stackobject_to_shared_ptr<TransferOperatorType>(matrix);
}
protected:
TransferOperatorType* matrix_;
bool matrixInternallyAllocated;
typename Dune::shared_ptr<TransferOperatorType> matrix_;
};
template<
......@@ -173,15 +175,15 @@ public:
CompressedMultigridTransfer()
{
matrix_ = new TransferOperatorType;
matrixInternallyAllocated = true;
matrix_ = Dune::make_shared<TransferOperatorType>();
}
CompressedMultigridTransfer(typename Dune::shared_ptr<TransferOperatorType>& matrix) :
matrix_(matrix)
{}
virtual ~CompressedMultigridTransfer()
{
if (matrixInternallyAllocated)
delete matrix_;
}
{}
/** \brief Sets up the operator between two P1 spaces
......@@ -285,22 +287,23 @@ public:
return *matrix_;
}
/** \brief Set matrix! */
void setMatrix(typename Dune::shared_ptr<TransferOperatorType>& matrix)
{
matrix_ = matrix;
}
/** \brief Set matrix! */
void setMatrix(TransferOperatorType& matrix)
{
if (matrixInternallyAllocated)
delete matrix_;
matrixInternallyAllocated = false;
matrix_ = &matrix;
matrix_ = Dune::stackobject_to_shared_ptr<TransferOperatorType>(matrix);
}
protected:
TransferOperatorType* matrix_;
bool matrixInternallyAllocated;
typename Dune::shared_ptr<TransferOperatorType> matrix_;
};
#endif
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment