Commit aa77a167 authored by Praetorius, Simon's avatar Praetorius, Simon
Browse files

cleanup of DOFVector and DOFMatrix

parent 7857ffc2
......@@ -38,7 +38,10 @@ namespace AMDiS
/// The index/size - type
using size_type = typename RowBasis::size_type;
/// The type of the data matrix used in the backend
using BaseMatrix = typename Backend::BaseMatrix;
/// The type of the matrix filled on an element with local contributions
using ElementMatrix = Dune::DynamicMatrix<double>;
public:
......@@ -56,9 +59,6 @@ namespace AMDiS
: DOFMatrixBase(Dune::wrap_or_move(FWD(rowBasis)), Dune::wrap_or_move(FWD(colBasis)))
{}
DOFMatrixBase(DOFMatrixBase const&) = delete;
DOFMatrixBase(DOFMatrixBase&&) = delete;
/// Return the row-basis \ref rowBasis of the matrix
std::shared_ptr<RowBasis const> rowBasis() const
{
......@@ -103,6 +103,7 @@ namespace AMDiS
void finish(bool asmMatrix);
/// Insert a block of values into the matrix (add to existing values)
/// The global matrix indices are determined by the corresponding localviews.
void insert(RowLocalView const& rowLocalView,
ColLocalView const& colLocalView,
ElementMatrix const& elementMatrix);
......@@ -132,6 +133,7 @@ namespace AMDiS
* [[expects: row is valid tree-path in RowBasis]]
* [[expects: col is valid tree-path in ColBasis]]
**/
// TODO: add method without contextTag.
template <class ContextTag, class Expr,
class RowTreePath = RootTreePath, class ColTreePath = RootTreePath>
void addOperator(ContextTag contextTag, Expr const& expr,
......@@ -144,21 +146,17 @@ namespace AMDiS
/// Assemble all matrix operators, TODO: incooperate boundary conditions
void assemble();
/// \brief Deletes all rows with \p dirichletNodes != 0 and if \p apply is true, adds
/// a one on the diagonal of the matrix.
auto applyDirichletBC(std::vector<char> const& dirichletNodes)
{
return backend_.applyDirichletBC(dirichletNodes);
}
/// Number of nonzeros in the matrix
size_type nnz() const
{
return backend_.nnz();
}
protected:
/// The finite element space / basis associated with the rows/columns
/// The finite element space / basis associated with the rows
std::shared_ptr<RowBasis> rowBasis_;
/// The finite element space / basis associated with the columns
std::shared_ptr<ColBasis> colBasis_;
/// Data backend
......
......@@ -17,7 +17,8 @@
namespace AMDiS
{
/// The container that stores a data-vector and a corresponding basis
/// The container that stores a data-vector and a corresponding basis, should be
/// derived from \ref DOFVectorBase.
template <class GlobalBasis, class ValueType = double>
class DOFVector;
......@@ -70,6 +71,8 @@ namespace AMDiS
/// The type of the data vector used in the backend
using BaseVector = typename Backend::BaseVector;
/// The type of the vector filled on an element with local contributions
using ElementVector = Dune::DynamicVector<double>;
/// Defines an interface to transfer the data during grid adaption
......@@ -89,7 +92,8 @@ namespace AMDiS
operators_.init(*basis_);
}
/// Constructor. Wraps the reference into a non-destroying shared_ptr or moves the basis into a new shared_ptr.
/// Constructor. Wraps the reference into a non-destroying shared_ptr or moves
/// the basis into a new shared_ptr.
template <class GB_>
DOFVectorBase(GB_&& basis, DataTransferOperation op)
: DOFVectorBase(Dune::wrap_or_move(FWD(basis)), op)
......@@ -140,7 +144,7 @@ namespace AMDiS
/// Sets each DOFVector to the scalar \p value.
template <class Number,
std::enable_if_t<Dune::IsNumber<Number>::value, int> = 0>
REQUIRES(Dune::IsNumber<Number>::value)>
Self& operator=(Number value)
{
backend_.set(value);
......@@ -153,12 +157,6 @@ namespace AMDiS
return basis_;
}
/// Return the (mutable) basis \ref basis_ associated to the vector
// std::shared_ptr<GlobalBasis> basis()
// {
// return basis_;
// }
/// Return the data-vector
BaseVector const& vector() const
{
......@@ -177,6 +175,7 @@ namespace AMDiS
return basis_->dimension();
}
/// Resize the \ref vector to the size of the \ref basis
void resize(Dune::Functions::SizeInfo<GB> const& s)
{
backend_.resize(size_type(s));
......@@ -207,8 +206,11 @@ namespace AMDiS
return backend_[i];
}
/// Prepare the DOFVector for insertion of values, finish the insertion with
/// \ref finish().
void init(bool asmVector);
/// Finish the insertion of values, see \ref init()
void finish(bool asmVector);
/// Insert a block of values into the matrix (add to existing values)
......@@ -221,7 +223,7 @@ namespace AMDiS
/// Assemble the vector operators on the bound element.
void assemble(LocalView const& localView);
/// Assemble all vector operators
/// Assemble all vector operators added by \ref addOperator().
void assemble();
/// Return the associated DataTransfer object
......@@ -249,24 +251,28 @@ namespace AMDiS
}
/// Implementation of \ref DOFVectorInterface::preAdapt
/// Redirects to a \ref DataTransfer object.
void preAdapt(bool mightCoarsen) override
{
dataTransfer_->preAdapt(*this, mightCoarsen);
}
/// Implementation of \ref DOFVectorInterface::postAdapt
/// Redirects to a \ref DataTransfer object.
void postAdapt(bool refined) override
{
dataTransfer_->postAdapt(*this, refined);
}
private:
// register this DOFVector and its basis to the DataTransfer
void attachToGridTransfer()
{
GridTransferManager::attach(basis_->gridView().grid(), *this);
GridTransferManager::attach(basis_->gridView().grid(), *basis_);
}
// deregister this DOFVector and its basis from the DataTransfer
void detachFromGridTransfer()
{
GridTransferManager::detach(basis_->gridView().grid(), *basis_);
......@@ -283,10 +289,11 @@ namespace AMDiS
/// Dense vector to store coefficients during \ref assemble()
ElementVector elementVector_;
/// List of operators associated to nodes
/// List of operators associated to nodes, filled in \ref addOperator().
VectorOperators<GlobalBasis> operators_;
/// Data interpolation when the grid changes
/// Data interpolation when the grid changes, set by default
/// to \ref DataTransferOperation::INTERPOLATE.
std::shared_ptr<DataTransfer> dataTransfer_;
};
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment