diff --git a/dune/solvers/norms/energynorm.hh b/dune/solvers/norms/energynorm.hh index 49099cd6aa4484bf4d781df68201090208446605..86aef356fa5f6494b2752e570ff0d604024f3d06 100644 --- a/dune/solvers/norms/energynorm.hh +++ b/dune/solvers/norms/energynorm.hh @@ -4,6 +4,12 @@ #include "norm.hh" #include <dune/solvers/iterationsteps/lineariterationstep.hh> + /** \brief Vector norm induced by linear operator + * + * \f$\Vert u \Vert_A = (u, Au)^{1/2}\f$ + * + * \todo Elaborate documentation, esp. why does a norm have a member LinearIterationStep a.s.o. + */ template<class OperatorType, class DiscFuncType> class EnergyNorm : public Norm<DiscFuncType> { @@ -33,7 +39,7 @@ //! Compute the norm of the difference of two vectors double diff(const DiscFuncType& f1, const DiscFuncType& f2) const { if (iterationStep_ == NULL && matrix_ == NULL) - DUNE_THROW(Dune::Exception, "You have not supplied neither a matrix nor an IterationStep to the EnergyNorm routine!"); + DUNE_THROW(Dune::Exception, "You have supplied neither a matrix nor an IterationStep to the EnergyNorm!"); DiscFuncType tmp_f = f1; tmp_f -= f2; @@ -42,9 +48,15 @@ //! Compute the norm of the given vector double operator()(const DiscFuncType& f) const + { + return sqrt(this->EnergyNorm<OperatorType,DiscFuncType>::normSquared(f)); + } + + //! Compute the square of the norm of the given vector + virtual double normSquared(const DiscFuncType& f) const { if (iterationStep_ == NULL && matrix_ == NULL) - DUNE_THROW(Dune::Exception, "You have not supplied neither a matrix nor an IterationStep to the EnergyNorm routine!"); + DUNE_THROW(Dune::Exception, "You have supplied neither a matrix nor an IterationStep to the EnergyNorm!"); const OperatorType& A = (iterationStep_) ? *(iterationStep_->getMatrix()) @@ -54,7 +66,7 @@ tmp = 0; A.umv(f, tmp); - return sqrt(f * tmp); + return f*tmp; } /** \brief Compute the squared norm for a given vector and matrix @@ -66,7 +78,7 @@ tmp = 0; A.umv(u, tmp); return u*tmp; - } + } DUNE_DEPRECATED; protected: