Merge pull request #1678 from atgeirr/fix-throw-before-storing-report

Move throw-if-nan to after storing convergence report.
This commit is contained in:
Atgeirr Flø Rasmussen 2018-12-13 11:15:03 +01:00 committed by GitHub
commit 51d85d25d1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -266,7 +266,15 @@ namespace Opm {
{
auto convrep = getConvergence(timer, iteration,residual_norms);
report.converged = convrep.converged() && iteration > nonlinear_solver.minIter();;
ConvergenceReport::Severity severity = convrep.severityOfWorstFailure();
convergence_reports_.back().report.push_back(std::move(convrep));
// Throw if any NaN or too large residual found.
if (severity == ConvergenceReport::Severity::NotANumber) {
OPM_THROW(Opm::NumericalIssue, "NaN residual found!");
} else if (severity == ConvergenceReport::Severity::TooLarge) {
OPM_THROW(Opm::NumericalIssue, "Too large residual found!");
}
}
// checking whether the group targets are converged
@ -917,15 +925,6 @@ namespace Opm {
std::vector<Scalar> B_avg(numEq, 0.0);
auto report = getReservoirConvergence(timer.currentStepLength(), iteration, B_avg, residual_norms);
report += wellModel().getWellConvergence(B_avg);
// Throw if any NaN or too large residual found.
ConvergenceReport::Severity severity = report.severityOfWorstFailure();
if (severity == ConvergenceReport::Severity::NotANumber) {
OPM_THROW(Opm::NumericalIssue, "NaN residual found!");
} else if (severity == ConvergenceReport::Severity::TooLarge) {
OPM_THROW(Opm::NumericalIssue, "Too large residual found!");
}
return report;
}