#pragma once #include #include #include namespace AMDiS { template struct BlockVectorType { using type = Dune::FieldVector; }; template struct BlockVectorType { using type = T; }; template class IstlVector { public: /// The type of the elements of the DOFVector using block_type = typename BlockVectorType::type; /// The type of the elements of the DOFVector using value_type = block_type; /// The underlying field type using field_type = typename block_type::field_type; /// The vector type of the underlying base vector using BaseVector = Dune::BlockVector; /// The index/size - type using size_type = typename BaseVector::size_type; public: /// Constructor. Constructs new BaseVector. IstlVector() = default; /// Return the data-vector \ref vector BaseVector const& vector() const { return vector_; } /// Return the data-vector \ref vector BaseVector& vector() { return vector_; } /// Return the current size of the \ref vector_ size_type size() const { return vector_.size(); } /// Resize the \ref vector_ to the size \p s void resize(size_type s) { vector_.resize(s); } /// Access the entry \p i of the \ref vector with read-access. block_type const& operator[](size_type i) const { test_exit_dbg(i < vector_.size(), "Index {} out of range [0,{})", i, vector_.size()); return vector_[i]; } /// Access the entry \p i of the \ref vector with write-access. block_type& operator[](size_type i) { test_exit_dbg(i < vector_.size(), "Index {} out of range [0,{})", i, vector_.size()); return vector_[i]; } void set(field_type value) { vector_ = value; } private: BaseVector vector_; }; template class DOFVector : public DOFVectorBase> { using Super = DOFVectorBase>; public: DOFVector(BasisType const& basis, DataTransferOperation op = DataTransferOperation::NO_OPERATION) : Super(basis, op) {} using Super::operator=; }; /// Constructor a dofvector from given basis and name template DOFVector makeDOFVector(Basis const& basis, DataTransferOperation op = DataTransferOperation::NO_OPERATION) { return {basis, op}; } } // end namespace AMDiS