| 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 |
#include <dune/istl/bvector.hh> |
| 6 |
#include <dune/istl/operators.hh> |
| 7 |
#include <dune/common/fmatrix.hh> |
| 8 |
#include <dune/common/fvector.hh> |
| 9 |
#include <dune/common/timer.hh> |
| 10 |
#include "laplacian.hh" |
| 11 |
|
| 12 |
int main(int argc, char** argv) |
| 13 |
{ |
| 14 |
|
| 15 |
const int BS=1; |
| 16 |
int N=100; |
| 17 |
|
| 18 |
if(argc>1) |
| 19 |
N = atoi(argv[1]); |
| 20 |
std::cout << "testing for N=" << N << " BS=" << BS << std::endl; |
| 21 |
|
| 22 |
|
| 23 |
typedef Dune::FieldMatrix<double,BS,BS> MatrixBlock; |
| 24 |
typedef Dune::BCRSMatrix<MatrixBlock> BCRSMat; |
| 25 |
typedef Dune::FieldVector<double,BS> VectorBlock; |
| 26 |
typedef Dune::BlockVector<VectorBlock> Vector; |
| 27 |
typedef Dune::MatrixAdapter<BCRSMat,Vector,Vector> Operator; |
| 28 |
|
| 29 |
BCRSMat mat; |
| 30 |
Operator fop(mat); |
| 31 |
Vector b(N*N), x(N*N); |
| 32 |
|
| 33 |
setupLaplacian(mat,N); |
| 34 |
b=1; |
| 35 |
x=0; |
| 36 |
|
| 37 |
Dune::Timer watch; |
| 38 |
|
| 39 |
watch.reset(); |
| 40 |
|
| 41 |
int iter=1000; |
| 42 |
|
| 43 |
for(int i=0; i< iter; ++i) |
| 44 |
fop.apply(x,b); |
| 45 |
|
| 46 |
std::cout<<iter<<" MV took "<<watch.elapsed()<<" seconds"<<std::endl; |
| 47 |
watch.reset(); |
| 48 |
|
| 49 |
for(int i=0; i< iter; ++i) { |
| 50 |
x=0; |
| 51 |
mat.umv(b,x); |
| 52 |
} |
| 53 |
|
| 54 |
std::cout<<iter<<" equivalent UMV took "<<watch.elapsed()<<" seconds"<<std::endl; |
| 55 |
} |