Catch exceptions from local solves.

This commit is contained in:
Atgeirr Flø Rasmussen 2023-12-22 09:15:00 +01:00
parent 38f39e2ac6
commit b9b42a01cc

View File

@ -212,6 +212,7 @@ public:
for (const int domain_index : domain_order) {
const auto& domain = domains_[domain_index];
SimulatorReportSingle local_report;
try {
switch (model_.param().local_solve_approach_) {
case DomainSolveApproach::Jacobi:
solveDomainJacobi(solution, locally_solved, local_report,
@ -223,6 +224,11 @@ public:
iteration, timer, domain);
break;
}
}
catch (...) {
// Something went wrong during local solves.
local_report.converged = false;
}
// This should have updated the global matrix to be
// dR_i/du_j evaluated at new local solutions for
// i == j, at old solution for i != j.
@ -233,9 +239,10 @@ public:
domain_reports[domain.index] = local_report;
}
// Log summary of local solve convergence to DBG file.
{
// Accumulate local solve data.
int num_converged = 0;
int num_domains = domain_reports.size();
{
SimulatorReportSingle rep;
for (const auto& dr : domain_reports) {
if (dr.converged) {
@ -243,13 +250,9 @@ public:
}
rep += dr;
}
std::ostringstream os;
os << fmt::format("Local solves finished. Converged for {}/{} domains.\n",
num_converged, domain_reports.size());
rep.reportFullyImplicit(os, nullptr);
OpmLog::debug(os.str());
local_reports_accumulated_ += rep;
}
bool is_iorank = true;
if (model_.param().local_solve_approach_ == DomainSolveApproach::Jacobi) {
solution = locally_solved;
@ -284,9 +287,19 @@ public:
// Update intensive quantities for our overlap values.
model_.ebosSimulator().model().invalidateAndUpdateIntensiveQuantitiesOverlap(/*timeIdx=*/0);
// Make total counts of domains converged.
num_converged = comm.sum(num_converged);
num_domains = comm.sum(num_domains);
is_iorank = comm.rank() == 0;
}
#endif // HAVE_MPI
if (is_iorank) {
OpmLog::debug(fmt::format("Local solves finished. Converged for {}/{} domains.\n",
num_converged, num_domains));
}
// Finish with a Newton step.
// Note that the "iteration + 100" is a simple way to avoid entering
// "if (iteration == 0)" and similar blocks, and also makes it a little