Skip to content
Snippets Groups Projects
Commit 660ccf1f authored by Dominic Kempf's avatar Dominic Kempf Committed by Steffen Müthing
Browse files

Add wrapper object for new build mode

This wrapper allows code to use the BCRSMode in implicit
build mode with the default operator[][] API during the
initial build stage.
parent f7782421
No related branches found
No related tags found
No related merge requests found
......@@ -92,6 +92,57 @@ namespace Dune {
double mem_ratio;
};
/** @brief A wrapper to treat with the BCRSMatrix build mode during mymode build mode
* @tparam M the matrix type
* The mymode build mode of Dune::BCRSMatrix handles matrices different during
* assembly and afterwards. Using this class, one can wrap a BCRSMatrix to allow
* use with code that is not written for BCRSMatrix specifically. The wrapper
* forwards any calls to operator[][] to the entry() method.The assembly code
* does not even necessarily need to know that the underlying matrix is sparse.
* Dune::AMG uses this to reassemble an existing matrix without code duplication.
*/
template<class M>
class BuildModeWrapper
{
public:
typedef typename M::block_type block_type;
typedef typename M::size_type size_type;
class row_object
{
public:
row_object(M& m, size_type i) : _m(m), _i(i) {}
block_type& operator[](size_type j) const
{
return _m.entry(_i,j);
}
private:
M& _m;
size_type _i;
};
BuildModeWrapper(M& m) : _m(m) {}
row_object operator[](size_type i) const
{
return row_object(_m,i);
}
size_type N() const
{
return _m.N();
}
size_type M() const
{
return _m.M();
}
private:
M& _m;
};
/**
\brief A sparse block matrix with compressed row storage
......
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