1 // -*- tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
2 // vi: set et ts=4 sw=2 sts=2:
3 /**
4  * \file
5  * \brief Test block level function
6  */
7 
8 #if HAVE_CONFIG_H
9 #include "config.h"
10 #endif
11 
12 #include <dune/common/fmatrix.hh>
13 #include <dune/common/fvector.hh>
14 
15 #include <dune/istl/matrix.hh>
16 #include <dune/istl/bvector.hh>
17 #include <dune/istl/bcrsmatrix.hh>
18 #include <dune/istl/multitypeblockvector.hh>
19 #include <dune/istl/multitypeblockmatrix.hh>
20 #include <dune/istl/blocklevel.hh>
21 
22 template<int i, int j>
23 using FMBlock = Dune::FieldMatrix<double,i,j>;
24 
25 template<int i>
26 using FVBlock = Dune::FieldVector<double,i>;
27 
main(int argc,char ** argv)28 int main(int argc, char** argv)
29 {
30   using namespace Dune;
31 
32   static_assert(blockLevel<double>() == 0, "Wrong block level!");
33 
34   // vector tests
35   static_assert(blockLevel<FVBlock<3>>() == 1, "Wrong block level!");
36   static_assert(blockLevel<BlockVector<FVBlock<3>>>() == 2, "Wrong block level!");
37 
38   using BlockType0 = BlockVector<FVBlock<3>>;
39   using BlockType1 = BlockVector<double>;
40   using MTBV0 = MultiTypeBlockVector<BlockType0, BlockType0>;
41   static_assert(blockLevel<MTBV0>() == 3, "Wrong block level!");
42 
43   using MTBV1 = MultiTypeBlockVector<BlockType0, BlockType1>;
44   static_assert(maxBlockLevel<MTBV1>() == 3, "Wrong block level!");
45   static_assert(minBlockLevel<MTBV1>() == 2, "Wrong block level!");
46   static_assert(!hasUniqueBlockLevel<MTBV1>(), "Block level shouldn't be unique!");
47 
48   // matrix tests
49   static_assert(blockLevel<FMBlock<3,1>>() == 1, "Wrong block level!");
50   static_assert(blockLevel<Matrix<FMBlock<3,1>>>() == 2, "Wrong block level!");
51   static_assert(blockLevel<BCRSMatrix<FMBlock<3,1>>>() == 2, "Wrong block level!");
52 
53   using RowType0 = MultiTypeBlockVector<Matrix<FMBlock<3,3>>, Matrix<FMBlock<3,1>>>;
54   using RowType1 = MultiTypeBlockVector<Matrix<FMBlock<1,3>>, Matrix<FMBlock<3,3>>>;
55   using RowType2 = MultiTypeBlockVector<Matrix<FMBlock<1,3>>, Matrix<double>>;
56   using MTBM0 = MultiTypeBlockMatrix<RowType0, RowType1, RowType1>;
57   static_assert(blockLevel<MTBM0>() == 3, "Wrong block level!");
58 
59   using MTBM1 = MultiTypeBlockMatrix<RowType0, RowType1, RowType2>;
60   static_assert(maxBlockLevel<MTBM1>() == 3, "Wrong block level!");
61   static_assert(minBlockLevel<MTBM1>() == 2, "Wrong block level!");
62   static_assert(!hasUniqueBlockLevel<MTBM1>(), "Block level shouldn't be unique!");
63 
64   return 0;
65 }
66