Skip to content
Snippets Groups Projects
Commit e305bfbe authored by Max Kahnt's avatar Max Kahnt
Browse files

Add addProduct test for MultiTypeBlockMatrix arithmetic.

parent 64fdd4e7
No related branches found
No related tags found
No related merge requests found
......@@ -9,7 +9,10 @@
#include <dune/common/diagonalmatrix.hh>
#include <dune/common/fmatrix.hh>
#include <dune/common/fvector.hh>
#include <dune/common/indices.hh>
#include <dune/istl/bcrsmatrix.hh>
#include <dune/istl/multitypeblockmatrix.hh>
#include <dune/istl/multitypeblockvector.hh>
#include <dune/istl/scaledidmatrix.hh>
#include "common.hh"
......@@ -636,6 +639,37 @@ public:
passed =
passed and isCloseDune(scaledIdentityMatrix_check, ResultType(0));
}
// case MM += scalar*MM
{
using ResultType = Dune::MultiTypeBlockMatrix<
Dune::MultiTypeBlockVector<
Dune::FieldMatrix<FT, 1, 1>, Dune::FieldMatrix<FT, 1, 2> >,
Dune::MultiTypeBlockVector<
Dune::FieldMatrix<FT, 2, 1>, Dune::FieldMatrix<FT, 2, 2> > >;
ResultType multiTypeBlockMatrix_a, multiTypeBlockMatrix_b;
using namespace Dune::Indices;
multiTypeBlockMatrix_a[_0][_0] = {{1}};
multiTypeBlockMatrix_a[_0][_1] = {{2, 3}};
multiTypeBlockMatrix_a[_1][_0] = {{4}, {5}};
multiTypeBlockMatrix_a[_1][_1] = {{6, 7}, {8, 9}};
multiTypeBlockMatrix_b[_0][_0] = {{9}};
multiTypeBlockMatrix_b[_0][_1] = {{8, 7}};
multiTypeBlockMatrix_b[_1][_0] = {{6}, {5}};
multiTypeBlockMatrix_b[_1][_1] = {{4, 3}, {2, 1}};
addProduct(multiTypeBlockMatrix_a, scalar_b, multiTypeBlockMatrix_b);
ResultType multiTypeBlockMatrix_check;
multiTypeBlockMatrix_check[_0][_0] = {{19}};
multiTypeBlockMatrix_check[_0][_1] = {{18, 17}};
multiTypeBlockMatrix_check[_1][_0] = {{16}, {15}};
multiTypeBlockMatrix_check[_1][_1] = {{14, 13}, {12, 11}};
using namespace Dune::Hybrid;
forEach(integralRange(size(multiTypeBlockMatrix_a)), [&](auto&& i) {
forEach(integralRange(size(multiTypeBlockMatrix_a[i])), [&](auto && j) {
passed = passed and isCloseDune(multiTypeBlockMatrix_a[i][j],
multiTypeBlockMatrix_check[i][j]);
});
});
}
// RECTANGULAR MATRICES
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment