diff --git a/dune/solvers/norms/h1seminorm.hh b/dune/solvers/norms/h1seminorm.hh index 449dd1f38fb5c2add402021d7ea2ed5b652449e9..b30bfacd7211d7db7cb4c793d58a4b6e701d5f25 100644 --- a/dune/solvers/norms/h1seminorm.hh +++ b/dune/solvers/norms/h1seminorm.hh @@ -17,11 +17,16 @@ public: H1SemiNorm(const Dune::BCRSMatrix<Dune::FieldMatrix<double,1,1> >& matrix) : matrix_(&matrix) - {} + { + assert(matrix.N() == matrix.M()); + } //! Compute the norm of the difference of two vectors double diff(const VectorType& u1, const VectorType& u2) const { + assert(u1.size()==u2.size()); + assert(u1.size()==matrix_->N()); + double sum = 0; for (size_t i=0; i<matrix_->N(); i++) @@ -42,6 +47,9 @@ public: { if (matrix_ == NULL) DUNE_THROW(Dune::Exception, "You have not supplied neither a matrix nor an IterationStep to the EnergyNorm routine!"); + + assert(u.size()==matrix_->N()); + // we compute sqrt{uAu^t}. We have implemented this by hand because the matrix is // always scalar but the vectors may not be double sum = 0;