Merge pull request #5116 from atgeirr/parallel-well-domain-output

Parallel well domain and error logging for NLDD
This commit is contained in:
Bård Skaflestad
2024-01-23 15:41:11 +01:00
committed by GitHub
6 changed files with 129 additions and 69 deletions

View File

@@ -76,6 +76,7 @@ list (APPEND MAIN_SOURCE_FILES
opm/simulators/linalg/setupPropertyTree.cpp
opm/simulators/timestepping/AdaptiveSimulatorTimer.cpp
opm/simulators/timestepping/AdaptiveTimeSteppingEbos.cpp
opm/simulators/timestepping/ConvergenceReport.cpp
opm/simulators/timestepping/TimeStepControl.cpp
opm/simulators/timestepping/SimulatorTimer.cpp
opm/simulators/timestepping/SimulatorTimerInterface.cpp

View File

@@ -840,6 +840,13 @@ private:
if (mb_sum < acceptable_local_mb_sum && cnv_sum < acceptable_local_cnv_sum) {
local_report.converged = true;
logger.debug(fmt::format("Accepting solution in unconverged domain {} on rank {}.", domain.index, rank_));
} else {
logger.debug("Unconverged local solution.");
}
} else {
logger.debug("Unconverged local solution with well convergence failures:");
for (const auto& wf : convrep.wellFailures()) {
logger.debug(to_string(wf));
}
}
}

View File

@@ -45,22 +45,6 @@
#include <vector>
namespace {
std::string to_string(const Opm::ConvergenceReport::ReservoirFailure::Type t)
{
using Type = Opm::ConvergenceReport::ReservoirFailure::Type;
const auto type_strings = std::unordered_map<Type, std::string> {
{ Type::Invalid , "Invalid" },
{ Type::MassBalance, "MB" },
{ Type::Cnv , "CNV" },
};
auto strPos = type_strings.find(t);
assert ((strPos != type_strings.end()) &&
"Unsupported convergence metric type");
return strPos->second;
}
std::string
formatMetricColumn(const Opm::ConvergenceOutputThread::ComponentToPhaseName& getPhaseName,
@@ -113,48 +97,6 @@ namespace {
}
std::string to_string(const Opm::ConvergenceReport::Severity s)
{
using S = Opm::ConvergenceReport::Severity;
switch (s) {
case S::None:
return "None";
case S::Normal:
return "Normal";
case S::TooLarge:
return "TooLarge";
case S::NotANumber:
return "NotANumber";
}
throw std::logic_error("Unknown ConvergenceReport::Severity");
}
std::string to_string(const Opm::ConvergenceReport::WellFailure::Type t)
{
using T = Opm::ConvergenceReport::WellFailure::Type;
switch (t) {
case T::Invalid:
return "Invalid";
case T::MassBalance:
return "MassBalance";
case T::Pressure:
return "Pressure";
case T::ControlBHP:
return "ControlBHP";
case T::ControlTHP:
return "ControlTHP";
case T::ControlRate:
return "ControlRate";
case T::Unsolvable:
return "Unsolvable";
case T::WrongFlowDirection:
return "WrongFlowDirection";
}
throw std::logic_error("Unknown ConvergenceReport::WellFailure::Type");
}
void writeConvergenceRequest(std::ostream& os,
const Opm::ConvergenceOutputThread::ConvertToTimeUnits& convertTime,
std::string::size_type colSize,
@@ -180,13 +122,7 @@ namespace {
<< (report.wellFailed() ? "FAIL" : "CONV");
if (report.wellFailed()) {
for (const auto& wf : report.wellFailures()) {
os << " { "
<< wf.wellName() << ' ' << to_string(wf.type());
if (wf.type() == Opm::ConvergenceReport::WellFailure::Type::MassBalance) {
os << " Severity=" << to_string(wf.severity())
<< " Phase=" << wf.phase();
}
os << " }";
os << " " << to_string(wf);
}
}
os << '\n';

View File

@@ -0,0 +1,100 @@
/*
Copyright 2024 SINTEF AS.
This file is part of the Open Porous Media project (OPM).
OPM is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
OPM is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with OPM. If not, see <http://www.gnu.org/licenses/>.
*/
#include <opm/simulators/timestepping/ConvergenceReport.hpp>
#include <cassert>
#include <stdexcept>
#include <string>
#include <unordered_map>
#include <fmt/format.h>
namespace Opm
{
std::string to_string(const ConvergenceReport::ReservoirFailure::Type t)
{
using Type = ConvergenceReport::ReservoirFailure::Type;
const auto type_strings = std::unordered_map<Type, std::string> {
{ Type::Invalid , "Invalid" },
{ Type::MassBalance, "MB" },
{ Type::Cnv , "CNV" },
};
auto strPos = type_strings.find(t);
assert ((strPos != type_strings.end()) &&
"Unsupported convergence metric type");
return strPos->second;
}
std::string to_string(const ConvergenceReport::Severity s)
{
using S = ConvergenceReport::Severity;
switch (s) {
case S::None:
return "None";
case S::Normal:
return "Normal";
case S::TooLarge:
return "TooLarge";
case S::NotANumber:
return "NotANumber";
}
throw std::logic_error("Unknown ConvergenceReport::Severity");
}
std::string to_string(const ConvergenceReport::WellFailure::Type t)
{
using T = ConvergenceReport::WellFailure::Type;
switch (t) {
case T::Invalid:
return "Invalid";
case T::MassBalance:
return "MassBalance";
case T::Pressure:
return "Pressure";
case T::ControlBHP:
return "ControlBHP";
case T::ControlTHP:
return "ControlTHP";
case T::ControlRate:
return "ControlRate";
case T::Unsolvable:
return "Unsolvable";
case T::WrongFlowDirection:
return "WrongFlowDirection";
}
throw std::logic_error("Unknown ConvergenceReport::WellFailure::Type");
}
std::string to_string(const ConvergenceReport::WellFailure& wf)
{
std::string mberror = (wf.type() == ConvergenceReport::WellFailure::Type::MassBalance)
? fmt::format(" Severity={} Phase={}", to_string(wf.severity()), wf.phase()) : "";
return fmt::format("{{ {} {}{} }}", wf.wellName(), to_string(wf.type()), mberror);
}
} // namespace Opm

View File

@@ -229,6 +229,15 @@ namespace Opm
};
std::string to_string(const ConvergenceReport::ReservoirFailure::Type t);
std::string to_string(const ConvergenceReport::Severity s);
std::string to_string(const ConvergenceReport::WellFailure::Type t);
std::string to_string(const ConvergenceReport::WellFailure& wf);
} // namespace Opm
#endif // OPM_CONVERGENCEREPORT_HEADER_INCLUDED

View File

@@ -2665,13 +2665,20 @@ namespace Opm {
ebosSimulator_.gridView().comm());
// Write well/domain info to the DBG file.
if (ebosSimulator_.gridView().comm().rank() == 0) {
const Opm::Parallel::Communication& comm = grid().comm();
const int rank = comm.rank();
DeferredLogger local_log;
{
std::ostringstream os;
os << "Well name Domain\n";
os << "Well name Rank Domain\n";
for (const auto& [wname, domain] : well_domain_) {
os << wname << std::setw(21 - wname.size()) << domain << '\n';
os << wname << std::setw(19 - wname.size()) << rank << std::setw(12) << domain << '\n';
}
OpmLog::debug(os.str());
local_log.debug(os.str());
}
auto global_log = gatherDeferredLogger(local_log, comm);
if (terminal_output_) {
global_log.logMessages();
}
}