Skip to content
Snippets Groups Projects
Commit 3abefe26 authored by Markus Blatt's avatar Markus Blatt
Browse files

Check whether diagonals are present.

[[Imported from SVN: r695]]
parent 68895878
Branches
Tags
No related merge requests found
......@@ -5,6 +5,7 @@
#include <dune/common/typetraits.hh>
#include <dune/common/helpertemplates.hh>
#include "istlexception.hh"
namespace Dune
{
......@@ -54,6 +55,41 @@ namespace Dune
}
/**
* @brief Check whether the a matrix has diagonal values
* on blocklevel recursion levels.
*/
template<std::size_t blocklevel, std::size_t l=blocklevel>
struct CheckIfDiagonalPresent
{
/**
* @brief Check whether the a matrix has diagonal values
* on blocklevel recursion levels.
*/
template<class Matrix>
static void check(const Matrix& mat)
{
#ifdef DUNE_ISTL_WITH_CHECKING
CheckIfDiagonalPresent<blocklevel-1,l>::check(mat);
#endif
}
};
template<std::size_t l>
struct CheckIfDiagonalPresent<0,l>
{
template<class Matrix>
static void check(const Matrix& mat)
{
typedef typename Matrix::ConstRowIterator Row;
for(Row row = mat.begin(); row!=mat.end(); ++row) {
if(row->find(row.index())==row->end())
DUNE_THROW(ISTLException, "Missing diagonal value in row "<<row.index()
<<" at block recursion level "<<l);
}
}
};
/**
* @brief Get the number of nonzero fields in the matrix.
*
......
......@@ -11,6 +11,7 @@
#include "solvercategory.hh"
#include "istlexception.hh"
#include "matrixutils.hh"
#include "io.hh"
#include "gsetc.hh"
#include "ilu.hh"
......@@ -134,7 +135,9 @@ namespace Dune {
*/
SeqSSOR (const M& A, int n, field_type w)
: _A_(A), _n(n), _w(w)
{ }
{
CheckIfDiagonalPresent<l>::check(_A_);
}
/*!
\brief Prepare the preconditioner.
......@@ -207,7 +210,9 @@ namespace Dune {
*/
SeqSOR (const M& A, int n, field_type w)
: _A_(A), _n(n), _w(w)
{ }
{
CheckIfDiagonalPresent<l>::check(_A_);
}
/*!
\brief Prepare the preconditioner.
......@@ -277,7 +282,9 @@ namespace Dune {
*/
SeqGS (const M& A, int n, field_type w)
: _A_(A), _n(n), _w(w)
{ }
{
CheckIfDiagonalPresent<l>::check(_A_);
}
/*!
\brief Prepare the preconditioner.
......@@ -347,7 +354,9 @@ namespace Dune {
*/
SeqJac (const M& A, int n, field_type w)
: _A_(A), _n(n), _w(w)
{ }
{
CheckIfDiagonalPresent<l>::check(_A_);
}
/*!
\brief Prepare the preconditioner.
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment