Skip to content
Snippets Groups Projects
Commit b4354e26 authored by Oliver Sander's avatar Oliver Sander Committed by sander@PCPOOL.MI.FU-BERLIN.DE
Browse files

Do print or use a convergence rate estimate for the first iteration.

The estimate we use can only work starting from the second one.
I hope this patch definitely fixes the problems with spurious NaN, inf,
and astronomical maxTotalConvRates.

[[Imported from SVN: r3040]]
parent 718ab7e7
No related branches found
No related tags found
No related merge requests found
......@@ -95,6 +95,7 @@ void ::LoopSolver<VectorType, BitVectorType>::solve()
error = normOfCorrection;
normOfOldCorrection = normOfCorrection;
// If a reference solution has been provided compute the error with respect to it
if (referenceSolution_)
{
normOfError = this->errorNorm_->diff(iterationStep_->getSol(), *referenceSolution_);
......@@ -103,12 +104,11 @@ void ::LoopSolver<VectorType, BitVectorType>::solve()
normOfOldError = normOfError;
}
// Turn the error into the relative error, if requested
if (this->useRelativeError_)
error = error / oldNorm;
else
error = error;
if (!isinf(convRate) && !isnan(convRate)) {
if (!isinf(convRate) && !isnan(convRate) && i>0) {
totalConvRate *= convRate;
this->maxTotalConvRate_ = std::max(this->maxTotalConvRate_, std::pow(totalConvRate, 1/((double)convRateCounter+1)));
convRateCounter++;
......@@ -137,7 +137,10 @@ void ::LoopSolver<VectorType, BitVectorType>::solve()
std::cout << std::resetiosflags(std::ios::scientific);
std::cout << std::setiosflags(std::ios::fixed);
std::cout << std::setw(9) << std::setprecision(5) << convRate;
if (i==0) // We can't estimate the convergence rate at the first iteration
std::cout << " ";
else
std::cout << std::setw(9) << std::setprecision(5) << convRate;
std::cout << std::resetiosflags(std::ios::fixed);
std::cout << this->iterationStep_->getOutput();
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment