Skip to content
Snippets Groups Projects
Commit 4fbe09e6 authored by Oliver Sander's avatar Oliver Sander
Browse files

Start implementing general unit test for the dune-istl matrix interface

... and use it to test the BCRSMatrix class.

Currently, the new test only tests the vector space operations
required of a dune-istl matrix.  More is to come in subsequent
patches.
parent 8cd7d792
Branches
Tags
1 merge request!282Improve matrix testing
# install the test tools as we want to support testing 3rd-party vectors with an installed dune-istl
# install the test tools as we want to support testing 3rd-party vectors and matrices with an installed dune-istl
install(FILES
matrixtest.hh
vectortest.hh
laplacian.hh
multirhstest.hh
......@@ -7,6 +8,8 @@ install(FILES
dune_add_test(SOURCES bcrsassigntest.cc)
dune_add_test(SOURCES bcrsmatrixtest.cc)
dune_add_test(SOURCES bcrsnormtest.cc)
dune_add_test(SOURCES cgconditiontest.cc)
......
// -*- tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
// vi: set et ts=4 sw=2 sts=2:
#include "config.h"
#include <dune/common/fmatrix.hh>
#include <dune/common/fvector.hh>
#include <dune/common/float_cmp.hh>
#include <dune/istl/bvector.hh>
#include <dune/istl/test/laplacian.hh>
#include <dune/istl/test/matrixtest.hh>
using namespace Dune;
template <class Matrix, class Vector>
int testBCRSMatrix(int size)
{
// Set up a test matrix
Matrix mat;
setupLaplacian(mat, size);
// Test vector space operations
testVectorSpaceOperations(mat);
return 0;
}
int main(int argc, char** argv)
{
// Test block matrices and vectors with trivial blocks
int ret = testBCRSMatrix<BCRSMatrix<FieldMatrix<double,1,1> >, BlockVector<FieldVector<double,1> > >(10);
return ret;
}
// -*- tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
// vi: set et ts=4 sw=2 sts=2:
#ifndef DUNE_ISTL_TEST_MATRIXTEST_HH
#define DUNE_ISTL_TEST_MATRIXTEST_HH
/** \file
* \brief Infrastructure for testing the dune-istl matrix interface
*
* This file contains various methods that test parts of the dune-istl matrix interface.
* They only test very general features, i.e., features that every dune-istl matrix should
* have.
*
* At the same time, these tests should help to define what the dune-istl matrix interface
* actually is. They may not currently define the entire interface, but they are a lower
* bound: any feature that is tested here is part of the dune-istl matrix interface.
*/
#include <dune/common/exceptions.hh>
#include <dune/common/test/iteratortest.hh>
namespace Dune
{
template <typename Matrix>
void testVectorSpaceOperations(const Matrix& m)
{
// Make a mutable copy of the argument
Matrix mMutable = m;
// operator+=
mMutable += m;
// operator-=
mMutable -= m;
// operator*=
mMutable *= 0.5;
// operator/=
mMutable /= 0.5;
// axpy -- not sure whether that really is an interface method
//mMutable.axpy(0.5,m);
}
} // namespace Dune
#endif
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment