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