Skip to content
Snippets Groups Projects
Commit dd7391f0 authored by maxka's avatar maxka
Browse files

Use custom multi types to enable block nesting and scalar operations.

parent b281c07e
Branches
No related tags found
1 merge request!18Feature/energynorm matrix provider
Pipeline #
......@@ -136,14 +136,14 @@ bool testWith(const M& m, const V& v, Field normValue, const char* s) {
}
template<class... Args>
struct NestableMultiTypeBlockVector : public Dune::MultiTypeBlockVector<Args...> {
struct CustomMultiTypeBlockVector : public Dune::MultiTypeBlockVector<Args...> {
constexpr static size_t blocklevel = 1; // fake value need for BlockVector nesting
template<class K, typename = std::enable_if_t<Dune::IsNumber<K>::value>>
void operator=(K v) { Dune::Hybrid::forEach(*this, [v](auto& m) { m = v; }); } // allow init by scalar
};
template<class... Args>
struct NestableMultiTypeBlockMatrix : public Dune::MultiTypeBlockMatrix<Args...> {
struct CustomMultiTypeBlockMatrix : public Dune::MultiTypeBlockMatrix<Args...> {
constexpr static size_t blocklevel = 1; // fake value needed for BCRSMatrix nesting
template<class K, typename = std::enable_if_t<Dune::IsNumber<K>::value>>
void operator*=(K v) { Dune::Hybrid::forEach(*this, [v](auto& b) { b *= v; }); } // allow multiplication by scalar
......@@ -152,7 +152,7 @@ struct NestableMultiTypeBlockMatrix : public Dune::MultiTypeBlockMatrix<Args...>
// inject field traits for custom multi type block vector to be used by the norms
namespace Dune {
template<class T, class... TT>
struct FieldTraits<NestableMultiTypeBlockVector<T, TT...>> {
struct FieldTraits<CustomMultiTypeBlockVector<T, TT...>> {
using field_type = typename FieldTraits<T>::field_type;
using real_type = typename FieldTraits<T>::real_type;
};
......@@ -161,7 +161,7 @@ struct FieldTraits<NestableMultiTypeBlockVector<T, TT...>> {
// inject fake(!) default bit vector for custom multi type block vector
namespace Dune { namespace Solvers { namespace Imp {
template<class T, class... TT>
struct DefaultBitVector<NestableMultiTypeBlockVector<T, TT...>> {
struct DefaultBitVector<CustomMultiTypeBlockVector<T, TT...>> {
using type = T;
};
}}}
......@@ -227,10 +227,10 @@ int main() try
/// test with multi blocked vectors
// types
using MVector = MultiTypeBlockVector<BVector, BVector>;
using MMatrix0 = MultiTypeBlockMatrix<BMatrix, BMatrix>;
using MMatrix1 = MultiTypeBlockMatrix<BMatrix, BMatrix>;
using MMatrix = MultiTypeBlockMatrix<MMatrix0, MMatrix1>;
using MVector = CustomMultiTypeBlockVector<BVector, BVector>;
using MMatrix0 = CustomMultiTypeBlockMatrix<BMatrix, BMatrix>;
using MMatrix1 = CustomMultiTypeBlockMatrix<BMatrix, BMatrix>;
using MMatrix = CustomMultiTypeBlockMatrix<MMatrix0, MMatrix1>;
// instance setup
using namespace Dune::Hybrid;
MVector mVector;
......@@ -242,10 +242,10 @@ int main() try
/// test with blocked multitype vectors
// types
using NVector = NestableMultiTypeBlockVector<FVector, FVector>;
using NMatrix0 = NestableMultiTypeBlockMatrix<FMatrix, FMatrix>;
using NMatrix1 = NestableMultiTypeBlockMatrix<FMatrix, FMatrix>;
using NMatrix = NestableMultiTypeBlockMatrix<NMatrix0, NMatrix1>;
using NVector = CustomMultiTypeBlockVector<FVector, FVector>;
using NMatrix0 = CustomMultiTypeBlockMatrix<FMatrix, FMatrix>;
using NMatrix1 = CustomMultiTypeBlockMatrix<FMatrix, FMatrix>;
using NMatrix = CustomMultiTypeBlockMatrix<NMatrix0, NMatrix1>;
constexpr size_t bnSize = 4;
using BNVector = BlockVector<NVector>;
using BNMatrix = BCRSMatrix<NMatrix>;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment