Skip to content
Snippets Groups Projects
Commit 2b43402e authored by Oliver Sander's avatar Oliver Sander Committed by sander
Browse files

Do not require the user to set an error norm

If no norm is given, the error is measured in the l^2 norm

[[Imported from SVN: r12439]]
parent b4807eba
Branches
Tags
No related merge requests found
......@@ -11,9 +11,6 @@ void TruncatedCGSolver<MatrixType, VectorType>::check() const
if (preconditioner_)
preconditioner_->check();
if (!errorNorm_)
DUNE_THROW(SolverError, "You need to supply a norm to a CG solver!");
}
template <class MatrixType, class VectorType>
......@@ -221,10 +218,10 @@ void TruncatedCGSolver<MatrixType, VectorType>::solve()
// //////////////////////////////////////////////////
// Compute error
// //////////////////////////////////////////////////
field_type oldNorm = errorNorm_->operator()(oldSolution);
field_type oldNorm = (errorNorm_) ? errorNorm_->operator()(oldSolution) : oldSolution.two_norm();
oldSolution -= *x_;
field_type normOfCorrection = errorNorm_->operator()(oldSolution);
field_type normOfCorrection = (errorNorm_) ? errorNorm_->operator()(oldSolution) : oldSolution.two_norm();
if (this->useRelativeError_)
error = normOfCorrection / oldNorm;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment