BlackoilModelEbos: enumerate solver approach for NLDD

adds command line validation and allows us to remove an assert on
user provided data
This commit is contained in:
Arne Morten Kvarving 2023-07-03 13:05:21 +02:00
parent 8eb5e173c3
commit c6cd74270b
3 changed files with 31 additions and 8 deletions

View File

@ -541,12 +541,16 @@ namespace Opm {
for (const int domain_index : domain_order) {
const auto& domain = domains_[domain_index];
SimulatorReportSingle local_report;
if (param_.local_solve_approach_ == "jacobi") {
switch (param_.local_solve_approach_) {
case DomainSolveApproach::Jacobi:
solveDomainJacobi(solution, locally_solved, local_report,
iteration, timer, domain);
} else {
break;
default:
case DomainSolveApproach::GaussSeidel:
solveDomainGaussSeidel(solution, locally_solved, local_report,
iteration, timer, domain);
break;
}
// This should have updated the global matrix to be
// dR_i/du_j evaluated at new local solutions for
@ -576,7 +580,7 @@ namespace Opm {
local_reports_accumulated_ += rep;
}
if (param_.local_solve_approach_ == "jacobi") {
if (param_.local_solve_approach_ == DomainSolveApproach::Jacobi) {
solution = locally_solved;
ebosSimulator_.model().invalidateAndUpdateIntensiveQuantities(/*timeIdx=*/0);
}
@ -1746,7 +1750,8 @@ namespace Opm {
const auto& solution = ebosSimulator().model().solution(0);
std::vector<int> domain_order(domains_.size());
if (param_.local_solve_approach_ == "gauss-seidel") {
switch (param_.local_solve_approach_) {
case DomainSolveApproach::GaussSeidel: {
switch (param_.local_domain_ordering_) {
case DomainOrderingMeasure::AveragePressure: {
// Use average pressures to order domains.
@ -1790,9 +1795,15 @@ namespace Opm {
domain_order[ii] = maxres_per_domain[ii].second;
}
}
break;
}
} else {
break;
}
case DomainSolveApproach::Jacobi:
default:
std::iota(domain_order.begin(), domain_order.end(), 0);
break;
}
return domain_order;
@ -1830,7 +1841,6 @@ namespace Opm {
const SimulatorTimerInterface& timer,
const Domain& domain)
{
assert(param_.local_solve_approach_ == "gauss-seidel");
auto initial_local_well_primary_vars = wellModel().getPrimaryVarsDomain(domain);
auto initial_local_solution = Details::extractVector(solution, domain.cells);
auto res = solveDomain(domain, timer, iteration);

View File

@ -539,7 +539,7 @@ namespace Opm
/// Nonlinear solver type: newton or nldd.
std::string nonlinear_solver_;
/// 'jacobi' and 'gauss-seidel' supported.
std::string local_solve_approach_;
DomainSolveApproach local_solve_approach_{DomainSolveApproach::Jacobi};
int max_local_solve_iterations_;
@ -587,7 +587,15 @@ namespace Opm
max_number_of_well_switches_ = EWOMS_GET_PARAM(TypeTag, int, MaximumNumberOfWellSwitches);
use_average_density_ms_wells_ = EWOMS_GET_PARAM(TypeTag, bool, UseAverageDensityMsWells);
nonlinear_solver_ = EWOMS_GET_PARAM(TypeTag, std::string, NonlinearSolver);
local_solve_approach_ = EWOMS_GET_PARAM(TypeTag, std::string, LocalSolveApproach);
std::string approach = EWOMS_GET_PARAM(TypeTag, std::string, LocalSolveApproach);
if (approach == "jacobi") {
local_solve_approach_ = DomainSolveApproach::Jacobi;
} else if (approach == "gauss-seidel") {
local_solve_approach_ = DomainSolveApproach::GaussSeidel;
} else {
throw std::runtime_error("Invalid domain solver approach '" + approach + "' specified.");
}
max_local_solve_iterations_ = EWOMS_GET_PARAM(TypeTag, int, MaxLocalSolveIterations);
local_tolerance_scaling_mb_ = EWOMS_GET_PARAM(TypeTag, double, LocalToleranceScalingMb);
local_tolerance_scaling_cnv_ = EWOMS_GET_PARAM(TypeTag, double, LocalToleranceScalingCnv);

View File

@ -27,6 +27,11 @@
namespace Opm
{
//! \brief Solver approach for NLDD.
enum class DomainSolveApproach {
Jacobi,
GaussSeidel
};
//! \brief Measure to use for domain ordering.
enum class DomainOrderingMeasure {