Commit fa24f5f8 authored by Praetorius, Simon's avatar Praetorius, Simon

FileWriter cleaned up

parent ce0fece2
......@@ -29,7 +29,7 @@ The corresponding weak form of the equation reads:
with \f$ u\in V_g \f$.
Thus, we need to define a grid (discretization of \f$ \Omega \f$) and a finite
element space (discretization of \f$ V_0 \f$ and \f$ V_g \f$). This needs to be
element space (discretization of \f$ V_0 \f$ and \f$ V_g \f$). This cab be
provided as `Traits` parameter in the ProblemStat class:
~~~~~~~~~~~~~~~{.cpp}
......@@ -37,7 +37,7 @@ using Grid = Dune::AlbertaGrid<AMDIS_DIM, AMDIS_DOW>;
using Traits = LagrangeBasis<Grid::LeafGridView, 1>;
~~~~~~~~~~~~~~~
This defines and `AlbertaGrid` as grid and a Lagrange Finite-Element space with
where `AlbertaGrid` defines a grid and `Traits` a Lagrange Finite-Element space with
local polynomial degree 1 on the elements.
All AMDiS programs start with initialization of the library, using `AMDiS::init`
......@@ -62,7 +62,7 @@ prob.initialize(INIT_ALL);
Operators specify the (bi-)linear-form and the coefficient function in the term,
see \ref operators for a list of possible types. The bilinear-form in the Poisson
equation consists of second-order term with coefficitn = 1 and the linear-form
equation consists of a second-order term with coefficient = 1 and the linear-form
includes the function \f$ f(x)=-1 \f$:
~~~~~~~~~~~~~~~{.cpp}
......@@ -74,8 +74,8 @@ prob.addVectorOperator(opF, 0);
~~~~~~~~~~~~~~~
Boundary conditions, in the example above a Dirichlet condition, is specified by
defining a predicate for the boundary \f$ \partial\Omega \f$ and the values on the
boundary \f$ g(x) = 0 \f$:
defining a predicate for the boundary \f$ \Gamma\subset\partial\Omega \f$ and the
values on the boundary \f$ g(x) = 0 \f$:
~~~~~~~~~~~~~~~{.cpp}
auto predicate = [](auto const& x){ return x[0] < 1.e-8 || x[1] < 1.e-8; };
......@@ -93,7 +93,7 @@ adapt.adapt(); // assemble and solve
Finally, finish the AMDiS program with `AMDiS::finish()`.
In complete program then reads:
The complete program then reads:
~~~~~~~~~~~~~~~{.cpp}
#include <dune/amdis/AMDiS.hpp>
#include <dune/amdis/AdaptInfo.hpp>
......
......@@ -10,20 +10,48 @@
#include <dune/typetree/childextraction.hh>
#include <dune/amdis/Initfile.hpp>
#include <dune/amdis/common/Size.hpp>
#include <dune/amdis/common/ValueCategory.hpp>
#include <dune/amdis/gridfunctions/DOFVectorView.hpp>
#include <dune/amdis/io/FileWriterInterface.hpp>
#include <dune/amdis/utility/Filesystem.hpp>
namespace AMDiS
{
namespace Impl
{
template <class Tag> struct VTKFieldTypeImpl;
template <>
struct VTKFieldTypeImpl<tag::scalar> {
static const Dune::VTK::FieldInfo::Type value = Dune::VTK::FieldInfo::Type::scalar;
};
template <>
struct VTKFieldTypeImpl<tag::vector> {
static const Dune::VTK::FieldInfo::Type value = Dune::VTK::FieldInfo::Type::vector;
};
template <>
struct VTKFieldTypeImpl<tag::matrix> {
static const Dune::VTK::FieldInfo::Type value = Dune::VTK::FieldInfo::Type::tensor;
};
} // end namespace Impl
template <class Range>
constexpr Dune::VTK::FieldInfo::Type VTKFieldType = Impl::VTKFieldTypeImpl<ValueCategory_t<Range>>::value;
template <class Range>
constexpr std::size_t VTKFieldSize = Size<Range>;
template <class Traits, class TreePath>
class FileWriter
: public FileWriterInterface
{
private: // typedefs and static constants
using GlobalBasis = typename Traits::GlobalBasis;
using GridView = typename GlobalBasis::GridView;
using Vector = DOFVectorConstView<GlobalBasis,TreePath>;
using Range = typename Vector::Range;
/// Dimension of the mesh
static constexpr int dim = GridView::dimension;
......@@ -31,117 +59,57 @@ namespace AMDiS
/// Dimension of the world
static constexpr int dow = GridView::dimensionworld;
using Vector = DOFVector<GlobalBasis>;
public:
/// Constructor.
FileWriter(std::string baseName,
std::shared_ptr<GlobalBasis> const& basis,
TreePath const& tp,
std::shared_ptr<Vector> const& vector)
Vector const& dofvector)
: FileWriterInterface(baseName)
, basis_(basis)
, treePath_(tp)
, vector_(vector)
, dofvector_(dofvector)
{
//int subSampling = Parameters::get<int>(baseName + "->subsampling").value_or(0);
int m = Parameters::get<int>(baseName + "->ParaView mode").value_or(0);
mode_ = (m == 0 ? Dune::VTK::ascii : Dune::VTK::appendedraw);
//if (subSampling > 0)
// vtkWriter_ = std::make_shared<Dune::SubsamplingVTKWriter<GridView>>(basis_->gridView(), subSampling);
//else
vtkWriter_ = std::make_shared<Dune::VTKWriter<GridView>>(basis_->gridView());
int subSampling = Parameters::get<int>(baseName + "->subsampling").value_or(0);
vtkSeqWriter_ = std::make_shared<Dune::VTKSequenceWriter<GridView>>(vtkWriter_, filename_, dir_, "");
if (subSampling > 0)
vtkWriter_ = std::make_shared<Dune::SubsamplingVTKWriter<GridView>>(gridView(), subSampling);
else
vtkWriter_ = std::make_shared<Dune::VTKWriter<GridView>>(gridView());
mode_ = Parameters::get<int>(baseName + "->ParaView mode").value_or(0);
vtkSeqWriter_ = std::make_shared<Dune::VTKSequenceWriter<GridView>>(vtkWriter_, filename_, dir_, "");
vtkWriter_->addVertexData(dofvector_, Dune::VTK::FieldInfo(name_, VTKFieldType<Range>, VTKFieldSize<Range>));
}
/// Implements \ref FileWriterInterface::writeFiles
virtual void writeFiles(AdaptInfo& adaptInfo, bool force) override
{
using Tree = typename GlobalBasis::LocalView::Tree;
using Node = typename Dune::TypeTree::ChildForTreePath<Tree, TreePath>;
writeVertexData(typename Node::NodeTag{}, index_<Node::CHILDREN>, [&,this]()
{
if (mode_ == 0)
vtkSeqWriter_->write(adaptInfo.getTime(), Dune::VTK::ascii);
else if (mode_ == 1)
vtkSeqWriter_->write(adaptInfo.getTime(), Dune::VTK::appendedraw);
});
vtkSeqWriter_->write(adaptInfo.getTime(), mode_);
}
protected:
template <class W>
void writeVertexData(Dune::TypeTree::LeafNodeTag, index_t<0>, W write)
GridView const& gridView() const
{
using Dune::Functions::BasisBuilder::makeBasis;
using Dune::Functions::BasisBuilder::lagrange;
auto fct = makeDiscreteFunctionPtr(basis_,treePath_,vector_);
auto p1basis = makeBasis(basis_->gridView(), lagrange<1>());
auto data = makeDOFVector(p1basis, name_);
interpolate(p1basis, data, *fct);
auto dataFct = Dune::Functions::makeDiscreteGlobalBasisFunction<double>(p1basis,data);
vtkWriter_->addVertexData(dataFct, Dune::VTK::FieldInfo(name_, Dune::VTK::FieldInfo::Type::scalar, 1));
write();
vtkWriter_->clear();
}
template <std::size_t C, class W>
void writeVertexData(Dune::TypeTree::PowerNodeTag, index_t<C>, W write)
{
using Dune::Functions::BasisBuilder::makeBasis;
using Dune::Functions::BasisBuilder::lagrange;
using Dune::Functions::BasisBuilder::power;
using Dune::Functions::BasisBuilder::flatLexicographic;
assert( C == dow );
auto fct = makeDiscreteFunctionPtr(basis_,treePath_,vector_);
auto p1basis = makeBasis(basis_->gridView(), power<C>(lagrange<1>(), flatLexicographic()));
auto data = makeDOFVector(p1basis, name_);
interpolate(p1basis, data, *fct);
using Range = Dune::FieldVector<double,C>;
auto dataFct = Dune::Functions::makeDiscreteGlobalBasisFunction<Range>(p1basis,data);
vtkWriter_->addVertexData(dataFct, Dune::VTK::FieldInfo(name_, Dune::VTK::FieldInfo::Type::vector, C));
write();
vtkWriter_->clear();
return dofvector_.basis().gridView();
}
template <class NodeTag, std::size_t C, class W>
void writeVertexData(NodeTag, index_t<C>, W) {}
private:
std::shared_ptr<GlobalBasis> basis_;
TreePath treePath_;
std::shared_ptr<Vector> vector_;
Vector dofvector_;
std::shared_ptr<Dune::VTKWriter<GridView>> vtkWriter_;
std::shared_ptr<Dune::VTKSequenceWriter<GridView>> vtkSeqWriter_;
// std::vector<double> data_vector;
// represents VTK::OutputType: 0...ascii, 1...appendedraw
int mode_;
// represents VTK::OutputType: ascii, appendedraw
Dune::VTK::OutputType mode_;
};
template <class Traits, class GlobalBasis, class TreePath, class Vector>
template <class Traits, class GlobalBasis, class TreePath>
std::shared_ptr<FileWriter<Traits,TreePath>> makeFileWriterPtr(
std::string baseName,
std::shared_ptr<GlobalBasis> const& basis,
TreePath const& tp,
std::shared_ptr<Vector> const& vector)
DOFVectorConstView<GlobalBasis,TreePath> const& dofvector)
{
return std::make_shared<FileWriter<Traits,TreePath>>(baseName, basis, tp, vector);
return std::make_shared<FileWriter<Traits,TreePath>>(baseName, dofvector);
}
} // end namespace AMDiS
......@@ -173,29 +173,42 @@ namespace AMDiS
: GridFunctionOperatorBase<GridFct, QuadratureCreator>(gridFct, 0, quadCreator)
{}
/// Assemble a local element vector on the element that is bound.
/// \brief Assemble a local element vector on the element that is bound.
/**
* \param contextGeometry Container for context related data
* \param quad A quadrature formula
* \param elementVector The output element vector
* \param node The node of the test-basis
**/
template <class Context, class QuadratureRule,
class ElementVector, class Node>
void calculateElementVector(Context const&, //< container for context related data
QuadratureRule const&, //< a quadrature formula
ElementVector&, //< the output element vector
Node const& //< the node of the test-basis
)
void calculateElementVector(Context const& contextGeometry,
QuadratureRule const& quad,
ElementVector& elementVector,
Node const& node)
{
error_exit("Needs to be implemented!");
}
/// Assemble a local element matrix on the element that is bound.
/// \brief Assemble a local element matrix on the element that is bound.
/**
* \param contextGeometry Container for context related data
* \param quad A quadrature formula
* \param elementMatrix The output element matrix
* \param rowNode The node of the test-basis
* \param colNode The node of the trial-basis
* \param flag1 finiteelement is the same for test and trial
* \param flag2 nodes are the same in the basis-tree
**/
template <class Context, class QuadratureRule,
class ElementMatrix, class RowNode, class ColNode, bool sameFE, bool sameNode>
void calculateElementMatrix(Context const&, //< container for context related data
QuadratureRule const&, //< a quadrature formula
ElementMatrix&, //< the output element matrix
RowNode const&, //< the node of the test-basis
ColNode const&, //< the node of the trial-basis
std::integral_constant<bool, sameFE>, //< finiteelement is the same for test and trial
std::integral_constant<bool, sameNode> //< nodes are the same in the basis-tree
)
void calculateElementMatrix(Context const& contextGeometry,
QuadratureRule const& quad,
ElementMatrix& elementMatrix,
RowNode const& rowNode,
ColNode const& colNode,
std::integral_constant<bool, sameFE> flag1,
std::integral_constant<bool, sameNode> flag2)
{
error_exit("Needs to be implemented!");
}
......@@ -261,28 +274,28 @@ namespace AMDiS
/// Store tag and expression to create a \ref GridFunctionOperator
template <class Tag, class Expr>
auto makeOperator(Tag t, Expr const& expr)
auto makeOperator(Tag tag, Expr const& expr)
{
using RawExpr = Underlying_t<Expr>;
static_assert(Concepts::HasGridFunctionOrder<RawExpr>,
"Polynomial degree of expression can not be deduced. You need to provide an explicit value for polynomial order or a quadrature rule in `makeOperator()`.");
return ExpressionPreOperator<Tag, Expr, tag::deduce>{t, expr};
return ExpressionPreOperator<Tag, Expr, tag::deduce>{tag, expr};
}
/// Store tag and expression and polynomial order of expression to create a \ref GridFunctionOperator
template <class Tag, class Expr>
auto makeOperator(Tag t, Expr const& expr, int order,
auto makeOperator(Tag tag, Expr const& expr, int order,
Dune::QuadratureType::Enum qt = Dune::QuadratureType::GaussLegendre)
{
return ExpressionPreOperator<Tag, Expr, tag::order>{t, expr, order, qt};
return ExpressionPreOperator<Tag, Expr, tag::order>{tag, expr, order, qt};
}
/// Store tag and expression and a quadrature rule to create a \ref GridFunctionOperator
template <class Tag, class Expr, class ctype, int dim>
auto makeOperator(Tag t, Expr const& expr, Dune::QuadratureRule<ctype,dim> const& rule)
auto makeOperator(Tag tag, Expr const& expr, Dune::QuadratureRule<ctype,dim> const& rule)
{
return ExpressionPreOperator<Tag, Expr, tag::rule, Dune::QuadratureRule<ctype,dim>>{t, expr, rule};
return ExpressionPreOperator<Tag, Expr, tag::rule, Dune::QuadratureRule<ctype,dim>>{tag, expr, rule};
}
/** @} **/
......
......@@ -20,17 +20,17 @@
* \brief Defines operators to be assembled in the matrix/vector
*
* An `Operator` is a class providing methods necessary for assembling:
* - `void bind(Element, Geometry)` and `void unbind()` for binding an unbinding the
* - `bind(Element, Geometry)` and `unbind()` for binding an unbinding the
* element to (from) an GridView entity of codim 0. Additionally the Geometry
* object of the element is provided.
* - `Dune::QuadratureRule<ctype,dim> getQuadratureRule(Nodes...)` factory for the
* - `getQuadratureRule(Nodes...)` factory for the
* quadrature rules used in assembling the operator on the element. `Nodes...`
* is either `{RowNode, ColNode}` for Matrix-Operators or `{Node}` for a
* Vector-Operator.
* - `void calculateElementVector(ContextGeometry, QuadratureRule, ElementVector, Node)`
* - `calculateElementVector(ContextGeometry, QuadratureRule, ElementVector, Node)`
* where the `ContextGeometry` provides a reference to the ElementGeometry and
* geometry of the LocalContext (that can be different), *or*
* - `void calculateElementMatrix(ContextGeometry, QuadratureRule, ElementMatrix, RowNode, ColNode, Flags...)`
* - `calculateElementMatrix(ContextGeometry, QuadratureRule, ElementMatrix, RowNode, ColNode, Flags...)`
* Same as for `calculateElementVector` but additionally two optimization flags
* are provided as `bool_t<...>` type:
* + `sameFE`: the FiniteElementSpace of `RowNode` and `ColNode` are the same.
......
......@@ -122,8 +122,8 @@ void ProblemStat<Traits>::createFileWriter()
if (!Parameters::get<std::string>(componentName + "->filename"))
return;
auto writer = makeFileWriterPtr<Traits>(componentName, globalBasis, treePath, solution);
filewriter.push_back(writer);
auto writer = makeFileWriterPtr<Traits>(componentName, this->getSolution(treePath));
filewriter.push_back(std::move(writer));
});
}
......
This diff is collapsed.
#pragma once
#include <typet_traits>
namespace AMDiS
{
#ifdef AMDIS_HAS_CXX_VARIADIC_USING
template <class... Fs>
struct overloaded : Fs...
{
template <class... Fs_>
overloaded(Fs_&&... fs)
: Fs(std::forward<Fs_>(fs))...
{}
using Fs::operator()...;
};
#ifdef DUNE_HAVE_CXX_CLASS_TEMPLATE_ARGUMENT_DEDUCTION
template <class... Fs_>
overloaded(Fs_&&... fs) -> overloaded<std::decay_t<Fs_>...>
#endif
template <class... Fs>
overloaded<std::decay_t<Fs>...> overload(Fs&&... fs)
{
return {std::forward<Fs>(fs)...};
}
#endif
} // end namespace AMDiS
#pragma once
#include <array>
#include <tuple>
#include <type_traits>
#include <dune/amdis/common/ConceptsBase.hpp>
#include <dune/amdis/common/Mpl.hpp>
#include <dune/amdis/common/Utility.hpp>
namespace Dune
{
template <class T, int N>
class FieldVector;
template <class T, int N, int M>
class FieldMatrix;
}
namespace AMDiS
{
// Get the number of elements in a tuple / pair / array / ...
//@{
namespace Impl
{
template <class Tuple, class = Void_t<>>
struct SizeImpl : index_t<0> {};
template <class... Args>
struct SizeImpl<std::tuple<Args...>>
: index_t< sizeof...(Args) > {};
template <class Arg0, class Arg1>
struct SizeImpl<std::pair<Arg0, Arg1>>
: index_t<2> {};
template <class T, std::size_t N>
struct SizeImpl<std::array<T,N>>
: index_t<N> {};
template <class T, int N>
struct SizeImpl<Dune::FieldVector<T,N>, std::enable_if_t<(N!=1)>>
: index_t<N> {};
template <class T, int N, int M>
struct SizeImpl<Dune::FieldMatrix<T,N,M>, std::enable_if_t<(N!=1 || M!=1)>>
: index_t<N*M> {};
// Specialization for arithmetic types
template <class T>
struct SizeImpl<T, std::enable_if_t<std::is_arithmetic<T>::value> >
: index_t<1> {};
} // end namespace Impl
//@}
template <class T>
constexpr std::size_t Size = Impl::SizeImpl<std::decay_t<T>>::value;
} // end namespace AMDiS
......@@ -10,37 +10,6 @@
namespace AMDiS
{
namespace Impl
{
// workaround for MSVC (problems with alias templates in pack expansion)
template <class, class T>
struct InvokeType { using type = T; };
template <class, class, class T>
struct InvokeType2 { using type = T; };
template <class T>
struct ValueType
{
using type = typename InvokeType<T, typename T::value_type>::type;
};
}
template <class T>
using Value_t = typename Impl::ValueType<T>::type;
template <class T>
using Size_t = typename Impl::InvokeType<T, typename T::size_type>::type;
template <class T>
using Result_t = typename Impl::InvokeType<T, typename T::result_type>::type;
template <class T>
using Decay_t = typename Impl::InvokeType<T, typename std::decay<T>::type>::type;
template <class T1, class T2>
using Common_t = typename Impl::InvokeType2<T1, T2, typename std::common_type<T1,T2>::type>::type;
namespace Impl
{
template <class T>
......@@ -68,53 +37,13 @@ namespace AMDiS
struct Types {};
template <class... Ts>
using Types_t = Types<Decay_t<Ts>...>;
/// An identity type wrapper, represents the type itself
template <class T>
struct Id
{
using type = T;
};
template <class T>
using Id_t = typename Id<T>::type;
using Types_t = Types<std::decay_t<Ts>...>;
/// Alias that indicates ownership of resources
template <class T>
using owner = T;
/// Dummy type for unknown return type
struct no_valid_type {};
template <class F1, class F2>
struct overloaded : F1, F2
{
overloaded(F1 x1, F2 x2)
: F1(x1), F2(x2)
{}
using F1::operator();
using F2::operator();
};
template <class F>
F overload(F f) { return f; }
template <class F1, class F2>
overloaded<F1, F2> overload(F1 f1, F2 f2)
{
return {f1, f2};
}
template <class F1, class... Fs>
auto overload(F1 f1, Fs... fs)
{
return overload(f1, overload(fs...));
}
// ---------------------------------------------------------------------------
......
......@@ -19,6 +19,7 @@ namespace AMDiS
} // end namespace tag
/// Category of type T, e.g. scalar, vector matrix, specified by a tag
template <class T, class = void>
struct ValueCategory
......@@ -60,11 +61,12 @@ namespace AMDiS
};
template <class T>
struct ValueCategory<std::reference_wrapper<T>>
struct ValueCategory< std::reference_wrapper<T> >
{
using type = typename ValueCategory<T>::type;
};
namespace Category
{
template <class T>
......
......@@ -20,13 +20,8 @@ namespace AMDiS
* @{
**/
#ifndef DOXYGEN
template <class GlobalBasisType, class TreePathType, bool isConst = true>
class DOFVectorView;
#endif
template <class GlobalBasisType, class TreePathType>
class DOFVectorView<GlobalBasisType, TreePathType, true>
class DOFVectorConstView
{
public:
using GlobalBasis = GlobalBasisType;
......@@ -41,7 +36,7 @@ namespace AMDiS
using EntitySet = Dune::Functions::GridViewEntitySet<GridView, 0>;
using Domain = typename EntitySet::GlobalCoordinate;
using Range = typename Vector::value_type;
using Range = RangeType<SubTree>;
using DerivativeTraits = Dune::Functions::DefaultDerivativeTraits<Range(Domain)>;
using DerivativeRange = typename DerivativeTraits::Range;
......@@ -76,7 +71,7 @@ namespace AMDiS
using ReferenceGradientContainer = Dune::Functions::TreeData<SubTree, NodeData, true>;
public:
GradientLocalFunction(DOFVectorView const& globalFunction)
GradientLocalFunction(DOFVectorConstView const& globalFunction)
: globalFunction_(&globalFunction)
, localBasisView_(globalFunction_->basis().localView())
, localIndexSet_(globalFunction_->basis().localIndexSet())
......@@ -118,7 +113,7 @@ namespace AMDiS
}
private:
DOFVectorView const* globalFunction_;
DOFVectorConstView const* globalFunction_;
LocalBasisView localBasisView_;
LocalIndexSet localIndexSet_;
......@@ -136,8 +131,8 @@ namespace AMDiS
class LocalFunction
{
public:
using Domain = typename DOFVectorView::LocalDomain;
using Range = typename DOFVectorView::Range;
using Domain = typename DOFVectorConstView::LocalDomain;
using Range = typename DOFVectorConstView::Range;
private:
using LocalBasisView = typename GlobalBasis::LocalView;
......@@ -152,7 +147,7 @@ namespace AMDiS
using ShapeFunctionValueContainer = Dune::Functions::TreeData<SubTree, NodeData, true>;
public:
LocalFunction(DOFVectorView const& globalFunction)
LocalFunction(DOFVectorConstView const& globalFunction)
: globalFunction_(&globalFunction)
, localBasisView_(globalFunction_->basis().localView())
, localIndexSet_(globalFunction_->basis().localIndexSet())
......@@ -198,7 +193,7 @@ namespace AMDiS
}
private:
DOFVectorView const* globalFunction_;
DOFVectorConstView const* globalFunction_;
LocalBasisView localBasisView_;
LocalIndexSet localIndexSet_;
SubTree const* subTree_;
......@@ -211,7 +206,7 @@ namespace AMDiS
public:
/// Constructor. Stores a pointer to the dofVector and a copy of the treePath.
DOFVectorView(DOFVector<GlobalBasis> const& dofVector, TreePath const& treePath)
DOFVectorConstView(DOFVector<GlobalBasis> const& dofVector, TreePath const& treePath)
: dofVector_(&dofVector)
, treePath_(treePath)
, entitySet_(dofVector.getFeSpace().gridView())
......@@ -226,7 +221,7 @@ namespace AMDiS
}
/// \brief Create a local function for this view on the DOFVector. \relates LocalFunction
friend LocalFunction localFunction(DOFVectorView const& self)
friend LocalFunction localFunction(DOFVectorConstView const& self)
{
return LocalFunction{self};
}
......@@ -266,28 +261,28 @@ namespace AMDiS
// A mutable version of DOFVectorView
template <class GlobalBasisType, class TreePathType>
class DOFVectorView<GlobalBasisType, TreePathType, false>
: public DOFVectorView<GlobalBasisType, TreePathType, true>
class DOFVectorMutableView
: public DOFVectorConstView<GlobalBasisType, TreePathType>
{
using DOFVectorConstView = DOFVectorView<GlobalBasisType, TreePathType, true>;
using Super = DOFVectorConstView<GlobalBasisType, TreePathType>;
using GlobalBasis = GlobalBasisType;
using TreePath = TreePathType;
public:
/// Constructor. Stores a pointer to the mutable `dofvector`.
DOFVectorView(DOFVector<GlobalBasis>& dofVector, TreePath const& treePath)
: DOFVectorConstView(dofVector, treePath)
DOFVectorMutableView(DOFVector<GlobalBasis>& dofVector, TreePath const& treePath)
: Super(dofVector, treePath)
, mutableDofVector_(&dofVector)
{}
public:
/// Interpolation of GridFunction to DOFVector
template <class Expr>
DOFVectorView& interpolate(Expr&& expr)
DOFVectorMutableView& interpolate(Expr&& expr)
{
auto const& basis = DOFVectorConstView::basis();
auto const& treePath = DOFVectorConstView::treePath();
auto const& basis = Super::basis();
auto const& treePath = Super::treePath();
auto&& gridFct = makeGridFunction(std::forward<Expr>(expr), basis.gridView());
......@@ -303,7 +298,7 @@ namespace AMDiS
DOFVector<GlobalBasis>& coefficients() { return *mutableDofVector_; }
/// Return the const DOFVector
using DOFVectorConstView::coefficients;
using Super::coefficients;
protected:
DOFVector<GlobalBasis>* mutableDofVector_;
......@@ -317,14 +312,14 @@ namespace AMDiS
template <class GlobalBasis, class TreePath>
auto makeDOFVectorView(DOFVector<GlobalBasis> const& dofVector, TreePath const& treePath)
{
return DOFVectorView<GlobalBasis, TreePath, true>{dofVector, treePath};
return DOFVectorConstView<GlobalBasis, TreePath>{dofVector, treePath};
}
// A Generator for a mutable \ref DOFVectorView.
template <class GlobalBasis, class TreePath>
auto makeDOFVectorView(DOFVector<GlobalBasis>& dofVector, TreePath const& treePath)
{
return DOFVectorView<GlobalBasis, TreePath, false>{dofVector, treePath};
return DOFVectorMutableView<GlobalBasis, TreePath>