mirror of
https://github.com/OPM/opm-simulators.git
synced 2025-01-14 04:21:56 -06:00
Make local solver in NLDD a runtime specified ISTLSolver
This commit is contained in:
parent
1615719993
commit
1f285ae0d5
@ -160,14 +160,11 @@ public:
|
||||
// only. This must be addressed before going parallel.
|
||||
const auto& eclState = model_.simulator().vanguard().eclState();
|
||||
FlowLinearSolverParameters loc_param;
|
||||
loc_param.is_nldd_local_solver_ = true;
|
||||
loc_param.init(eclState.getSimulationConfig().useCPR());
|
||||
// Override solver type with umfpack if small domain.
|
||||
// Otherwise hardcode to ILU0
|
||||
if (domains_[index].cells.size() < 200) {
|
||||
loc_param.linsolver_ = "umfpack";
|
||||
} else {
|
||||
loc_param.linsolver_ = "ilu0";
|
||||
loc_param.linear_solver_reduction_ = 1e-2;
|
||||
}
|
||||
loc_param.linear_solver_print_json_definition_ = false;
|
||||
const bool force_serial = true;
|
||||
|
@ -32,9 +32,7 @@ namespace Opm {
|
||||
void FlowLinearSolverParameters::init(bool cprRequestedInDataFile)
|
||||
{
|
||||
// TODO: these parameters have undocumented non-trivial dependencies
|
||||
linear_solver_reduction_ = Parameters::Get<Parameters::LinearSolverReduction>();
|
||||
relaxed_linear_solver_reduction_ = Parameters::Get<Parameters::RelaxedLinearSolverReduction>();
|
||||
linear_solver_maxiter_ = Parameters::Get<Parameters::LinearSolverMaxIter>();
|
||||
linear_solver_restart_ = Parameters::Get<Parameters::LinearSolverRestart>();
|
||||
linear_solver_verbosity_ = Parameters::Get<Parameters::LinearSolverVerbosity>();
|
||||
ilu_relaxation_ = Parameters::Get<Parameters::IluRelaxation>();
|
||||
@ -56,6 +54,18 @@ void FlowLinearSolverParameters::init(bool cprRequestedInDataFile)
|
||||
linsolver_ = Parameters::Get<Parameters::LinearSolver>();
|
||||
}
|
||||
|
||||
// if local solver from nldd, use nldd local linear solver parameters
|
||||
if (is_nldd_local_solver_) {
|
||||
linsolver_ = Parameters::Get<Parameters::NlddLocalLinearSolver>();
|
||||
linear_solver_reduction_ = Parameters::Get<Parameters::NlddLocalLinearSolverReduction>();
|
||||
linear_solver_maxiter_ = Parameters::Get<Parameters::NlddLocalLinearSolverMaxIter>();
|
||||
}
|
||||
else {
|
||||
linsolver_ = Parameters::Get<Parameters::LinearSolver>();
|
||||
linear_solver_reduction_ = Parameters::Get<Parameters::LinearSolverReduction>();
|
||||
linear_solver_maxiter_ = Parameters::Get<Parameters::LinearSolverMaxIter>();
|
||||
}
|
||||
|
||||
accelerator_mode_ = Parameters::Get<Parameters::AcceleratorMode>();
|
||||
bda_device_id_ = Parameters::Get<Parameters::BdaDeviceId>();
|
||||
opencl_platform_id_ = Parameters::Get<Parameters::OpenclPlatformId>();
|
||||
@ -66,11 +76,15 @@ void FlowLinearSolverParameters::registerParameters()
|
||||
{
|
||||
Parameters::Register<Parameters::LinearSolverReduction>
|
||||
("The minimum reduction of the residual which the linear solver must achieve");
|
||||
Parameters::Register<Parameters::NlddLocalLinearSolverReduction>
|
||||
("The minimum reduction of the residual which the NLDD local linear solver must achieve");
|
||||
Parameters::Register<Parameters::RelaxedLinearSolverReduction>
|
||||
("The minimum reduction of the residual which the linear solver need to "
|
||||
"achieve for the solution to be accepted");
|
||||
Parameters::Register<Parameters::LinearSolverMaxIter>
|
||||
("The maximum number of iterations of the linear solver");
|
||||
Parameters::Register<Parameters::NlddLocalLinearSolverMaxIter>
|
||||
("The maximum number of iterations of the NLDD local linear solver");
|
||||
Parameters::Register<Parameters::LinearSolverRestart>
|
||||
("The number of iterations after which GMRES is restarted");
|
||||
Parameters::Register<Parameters::LinearSolverVerbosity>
|
||||
@ -102,11 +116,16 @@ void FlowLinearSolverParameters::registerParameters()
|
||||
Parameters::Register<Parameters::ScaleLinearSystem>
|
||||
("Scale linear system according to equation scale and primary variable types");
|
||||
Parameters::Register<Parameters::LinearSolver>
|
||||
("Configuration of solver. Valid options are: ilu0 (default), "
|
||||
"dilu, cprw, cpr (an alias for cprw), cpr_quasiimpes, "
|
||||
("Configuration of solver. Valid options are: cprw (default), "
|
||||
"ilu0, dilu, cpr (an alias for cprw), cpr_quasiimpes, "
|
||||
"cpr_trueimpes, cpr_trueimpesanalytic, amg or hybrid (experimental). "
|
||||
"Alternatively, you can request a configuration to be read from a "
|
||||
"JSON file by giving the filename here, ending with '.json.'");
|
||||
Parameters::Register<Parameters::NlddLocalLinearSolver>
|
||||
("Configuration of NLDD local linear solver. Valid options are: ilu0 (default), "
|
||||
"dilu, cpr_quasiimpes and amg. "
|
||||
"Alternatively, you can request a configuration to be read from a "
|
||||
"JSON file by giving the filename here, ending with '.json.'");
|
||||
Parameters::Register<Parameters::LinearSolverPrintJsonDefinition>
|
||||
("Write the JSON definition of the linear solver setup to the DBG file.");
|
||||
Parameters::Register<Parameters::CprReuseSetup>
|
||||
@ -150,6 +169,7 @@ void FlowLinearSolverParameters::reset()
|
||||
newton_use_gmres_ = false;
|
||||
ignoreConvergenceFailure_ = false;
|
||||
scale_linear_system_ = false;
|
||||
is_nldd_local_solver_ = false;
|
||||
linsolver_ = "cprw";
|
||||
linear_solver_print_json_definition_ = true;
|
||||
cpr_reuse_setup_ = 4;
|
||||
|
@ -63,9 +63,11 @@ struct LinearSolverBackend<TypeTag, TTag::FlowIstlSolverParams>
|
||||
namespace Opm::Parameters {
|
||||
|
||||
struct LinearSolverReduction { static constexpr double value = 1e-2; };
|
||||
struct NlddLocalLinearSolverReduction { static constexpr double value = 1e-2; };
|
||||
struct RelaxedLinearSolverReduction { static constexpr double value = 1e-2; };
|
||||
struct IluRelaxation { static constexpr double value = 0.9; };
|
||||
struct LinearSolverMaxIter { static constexpr int value = 200; };
|
||||
struct NlddLocalLinearSolverMaxIter { static constexpr int value = 200; };
|
||||
struct LinearSolverRestart { static constexpr int value = 40; };
|
||||
struct IluFillinLevel { static constexpr int value = 0; };
|
||||
struct MiluVariant { static constexpr auto value = "ILU"; };
|
||||
@ -75,6 +77,7 @@ struct UseGmres { static constexpr bool value = false; };
|
||||
struct LinearSolverIgnoreConvergenceFailure { static constexpr bool value = false; };
|
||||
struct ScaleLinearSystem { static constexpr bool value = false; };
|
||||
struct LinearSolver { static constexpr auto value = "cprw"; };
|
||||
struct NlddLocalLinearSolver { static constexpr auto value = "ilu0"; };
|
||||
struct LinearSolverPrintJsonDefinition { static constexpr auto value = true; };
|
||||
struct CprReuseSetup { static constexpr int value = 4; };
|
||||
struct CprReuseInterval { static constexpr int value = 30; };
|
||||
@ -103,6 +106,7 @@ struct FlowLinearSolverParameters
|
||||
bool newton_use_gmres_;
|
||||
bool ignoreConvergenceFailure_;
|
||||
bool scale_linear_system_;
|
||||
bool is_nldd_local_solver_;
|
||||
std::string linsolver_;
|
||||
bool linear_solver_print_json_definition_;
|
||||
int cpr_reuse_setup_;
|
||||
|
@ -238,12 +238,20 @@ std::unique_ptr<Matrix> blockJacobiAdjacency(const Grid& grid,
|
||||
}
|
||||
// ------------
|
||||
} else {
|
||||
// Do a normal linear solver setup.
|
||||
assert(parameters_.size() == 1);
|
||||
assert(prm_.empty());
|
||||
prm_.push_back(setupPropertyTree(parameters_[0],
|
||||
Parameters::IsSet<Parameters::LinearSolverMaxIter>(),
|
||||
Parameters::IsSet<Parameters::LinearSolverReduction>()));
|
||||
|
||||
// Do a normal linear solver setup.
|
||||
if (parameters_[0].is_nldd_local_solver_) {
|
||||
prm_.push_back(setupPropertyTree(parameters_[0],
|
||||
Parameters::IsSet<Parameters::NlddLocalLinearSolverMaxIter>(),
|
||||
Parameters::IsSet<Parameters::NlddLocalLinearSolverReduction>()));
|
||||
}
|
||||
else {
|
||||
prm_.push_back(setupPropertyTree(parameters_[0],
|
||||
Parameters::IsSet<Parameters::LinearSolverMaxIter>(),
|
||||
Parameters::IsSet<Parameters::LinearSolverReduction>()));
|
||||
}
|
||||
}
|
||||
flexibleSolver_.resize(prm_.size());
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user