Merge pull request #5495 from akva2/move_linsol_params_to_params

Move linear solver parameters to Opm::Parameters namespace
This commit is contained in:
Arne Morten Kvarving 2024-08-02 21:24:20 +02:00 committed by GitHub
commit 5ec2a499bc
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 275 additions and 292 deletions

View File

@ -128,7 +128,7 @@ namespace Opm {
registerAllParameters_<TypeTag>(/*finalizeRegistration=*/false); registerAllParameters_<TypeTag>(/*finalizeRegistration=*/false);
// hide the parameters unused by flow. TODO: this is a pain to maintain // hide the parameters unused by flow. TODO: this is a pain to maintain
Parameters::hideParam<TypeTag, Properties::EnableGravity>(); Parameters::hideParam<TypeTag, Parameters::EnableGravity>();
Parameters::hideParam<TypeTag, Parameters::EnableGridAdaptation>(); Parameters::hideParam<TypeTag, Parameters::EnableGridAdaptation>();
// this parameter is actually used in eWoms, but the flow well model // this parameter is actually used in eWoms, but the flow well model

View File

@ -392,7 +392,7 @@ public:
// disables gravity, else the standard value of the gravity constant at sea level // disables gravity, else the standard value of the gravity constant at sea level
// on earth is used // on earth is used
this->gravity_ = 0.0; this->gravity_ = 0.0;
if (Parameters::get<TypeTag, Properties::EnableGravity>()) if (Parameters::get<TypeTag, Parameters::EnableGravity>())
this->gravity_[dim - 1] = 9.80665; this->gravity_[dim - 1] = 9.80665;
if (!eclState.getInitConfig().hasGravity()) if (!eclState.getInitConfig().hasGravity())
this->gravity_[dim - 1] = 0.0; this->gravity_[dim - 1] = 0.0;

View File

@ -238,12 +238,6 @@ struct AquiferModel<TypeTag, TTag::FlowBaseProblem> {
using type = BaseAquiferModel<TypeTag>; using type = BaseAquiferModel<TypeTag>;
}; };
// Enable gravity
template<class TypeTag>
struct EnableGravity<TypeTag, TTag::FlowBaseProblem> {
static constexpr bool value = true;
};
// Enable diffusion // Enable diffusion
template<class TypeTag> template<class TypeTag>
struct EnableDiffusion<TypeTag, TTag::FlowBaseProblem> { struct EnableDiffusion<TypeTag, TTag::FlowBaseProblem> {
@ -471,10 +465,10 @@ struct ExplicitRockCompaction<TypeTag, TTag::FlowBaseProblem> {
namespace Opm::Parameters { namespace Opm::Parameters {
// Disable the VTK output by default for this problem ... // Enable gravity
template<class TypeTag> template<class TypeTag>
struct EnableVtkOutput<TypeTag, Properties::TTag::FlowBaseProblem> struct EnableGravity<TypeTag, Properties::TTag::FlowBaseProblem>
{ static constexpr bool value = false; }; { static constexpr bool value = true; };
// the cache for intensive quantities can be used for ECL problems and also yields a // the cache for intensive quantities can be used for ECL problems and also yields a
// decent speedup... // decent speedup...
@ -487,6 +481,11 @@ template<class TypeTag>
struct EnableStorageCache<TypeTag, Properties::TTag::FlowBaseProblem> struct EnableStorageCache<TypeTag, Properties::TTag::FlowBaseProblem>
{ static constexpr bool value = true; }; { static constexpr bool value = true; };
// Disable the VTK output by default for this problem ...
template<class TypeTag>
struct EnableVtkOutput<TypeTag, Properties::TTag::FlowBaseProblem>
{ static constexpr bool value = false; };
// The default for the end time of the simulation [s] // The default for the end time of the simulation [s]
// //
// By default, stop it after the universe will probably have stopped // By default, stop it after the universe will probably have stopped

View File

@ -26,376 +26,360 @@
#include <opm/simulators/linalg/MILU.hpp> #include <opm/simulators/linalg/MILU.hpp>
#include <opm/simulators/linalg/linalgparameters.hh>
#include <opm/simulators/linalg/linalgproperties.hh> #include <opm/simulators/linalg/linalgproperties.hh>
#include <opm/models/utils/parametersystem.hh> #include <opm/models/utils/parametersystem.hh>
namespace Opm { namespace Opm {
template <class TypeTag> template <class TypeTag>
class ISTLSolverBda; class ISTLSolverBda;
template <class TypeTag> template <class TypeTag>
class ISTLSolver; class ISTLSolver;
} }
namespace Opm::Properties { namespace Opm::Properties {
namespace TTag { namespace TTag {
struct FlowIstlSolverParams {}; struct FlowIstlSolverParams {};
} }
template<class TypeTag, class MyTypeTag> template<class TypeTag, class MyTypeTag>
struct LinearSolverReduction { struct LinearSolverReduction { using type = UndefinedProperty; };
using type = UndefinedProperty;
};
template<class TypeTag, class MyTypeTag> template<class TypeTag, class MyTypeTag>
struct RelaxedLinearSolverReduction { struct RelaxedLinearSolverReduction { using type = UndefinedProperty; };
using type = UndefinedProperty;
};
template<class TypeTag, class MyTypeTag> template<class TypeTag, class MyTypeTag>
struct LinearSolverMaxIter { struct LinearSolverMaxIter { using type = UndefinedProperty; };
using type = UndefinedProperty;
};
template<class TypeTag, class MyTypeTag> template<class TypeTag, class MyTypeTag>
struct LinearSolverRestart { struct LinearSolverRestart { using type = UndefinedProperty; };
using type = UndefinedProperty;
};
//
// LinearSolverVerbosity defined in opm-models
//
template<class TypeTag, class MyTypeTag> template<class TypeTag, class MyTypeTag>
struct IluRelaxation { struct IluRelaxation { using type = UndefinedProperty; };
using type = UndefinedProperty;
};
template<class TypeTag, class MyTypeTag> template<class TypeTag, class MyTypeTag>
struct IluFillinLevel { struct IluFillinLevel { using type = UndefinedProperty; };
using type = UndefinedProperty;
};
template<class TypeTag, class MyTypeTag> template<class TypeTag, class MyTypeTag>
struct MiluVariant { struct MiluVariant { using type = UndefinedProperty; };
using type = UndefinedProperty;
};
template<class TypeTag, class MyTypeTag> template<class TypeTag, class MyTypeTag>
struct IluRedblack { struct IluRedblack { using type = UndefinedProperty; };
using type = UndefinedProperty;
};
template<class TypeTag, class MyTypeTag> template<class TypeTag, class MyTypeTag>
struct IluReorderSpheres { struct IluReorderSpheres { using type = UndefinedProperty; };
using type = UndefinedProperty;
};
template<class TypeTag, class MyTypeTag> template<class TypeTag, class MyTypeTag>
struct UseGmres { struct UseGmres { using type = UndefinedProperty; };
using type = UndefinedProperty;
};
template<class TypeTag, class MyTypeTag> template<class TypeTag, class MyTypeTag>
struct LinearSolverIgnoreConvergenceFailure{ struct LinearSolverIgnoreConvergenceFailure { using type = UndefinedProperty; };
using type = UndefinedProperty;
};
template<class TypeTag, class MyTypeTag> template<class TypeTag, class MyTypeTag>
struct ScaleLinearSystem { struct ScaleLinearSystem { using type = UndefinedProperty; };
using type = UndefinedProperty;
};
template<class TypeTag, class MyTypeTag> template<class TypeTag, class MyTypeTag>
struct LinearSolver { struct LinearSolver { using type = UndefinedProperty; };
using type = UndefinedProperty;
};
template<class TypeTag, class MyTypeTag> template<class TypeTag, class MyTypeTag>
struct LinearSolverPrintJsonDefinition { struct LinearSolverPrintJsonDefinition { using type = UndefinedProperty; };
using type = UndefinedProperty;
};
template<class TypeTag, class MyTypeTag> template<class TypeTag, class MyTypeTag>
struct CprReuseSetup { struct CprReuseSetup { using type = UndefinedProperty; };
using type = UndefinedProperty;
};
template<class TypeTag, class MyTypeTag> template<class TypeTag, class MyTypeTag>
struct CprReuseInterval { struct CprReuseInterval { using type = UndefinedProperty; };
using type = UndefinedProperty;
};
template<class TypeTag, class MyTypeTag> template<class TypeTag, class MyTypeTag>
struct AcceleratorMode { struct AcceleratorMode { using type = UndefinedProperty; };
using type = UndefinedProperty;
};
template<class TypeTag, class MyTypeTag> template<class TypeTag, class MyTypeTag>
struct BdaDeviceId { struct BdaDeviceId { using type = UndefinedProperty; };
using type = UndefinedProperty;
};
template<class TypeTag, class MyTypeTag> template<class TypeTag, class MyTypeTag>
struct OpenclPlatformId { struct OpenclPlatformId { using type = UndefinedProperty; };
using type = UndefinedProperty;
};
template<class TypeTag, class MyTypeTag> template<class TypeTag, class MyTypeTag>
struct OpenclIluParallel { struct OpenclIluParallel { using type = UndefinedProperty; };
using type = UndefinedProperty;
};
template<class TypeTag> template<class TypeTag>
struct LinearSolverReduction<TypeTag, TTag::FlowIstlSolverParams> { struct LinearSolverReduction<TypeTag, TTag::FlowIstlSolverParams>
{
using type = GetPropType<TypeTag, Scalar>; using type = GetPropType<TypeTag, Scalar>;
static constexpr type value = 1e-2; static constexpr type value = 1e-2;
}; };
template<class TypeTag> template<class TypeTag>
struct RelaxedLinearSolverReduction<TypeTag, TTag::FlowIstlSolverParams> { struct RelaxedLinearSolverReduction<TypeTag, TTag::FlowIstlSolverParams>
{
using type = GetPropType<TypeTag, Scalar>; using type = GetPropType<TypeTag, Scalar>;
static constexpr type value = 1e-2; static constexpr type value = 1e-2;
}; };
template<class TypeTag> template<class TypeTag>
struct LinearSolverMaxIter<TypeTag, TTag::FlowIstlSolverParams> { struct LinearSolverMaxIter<TypeTag, TTag::FlowIstlSolverParams>
static constexpr int value = 200; { static constexpr int value = 200; };
};
template<class TypeTag> template<class TypeTag>
struct LinearSolverRestart<TypeTag, TTag::FlowIstlSolverParams> { struct LinearSolverRestart<TypeTag, TTag::FlowIstlSolverParams>
static constexpr int value = 40; { static constexpr int value = 40; };
};
template<class TypeTag> template<class TypeTag>
struct LinearSolverVerbosity<TypeTag, TTag::FlowIstlSolverParams> { struct IluRelaxation<TypeTag, TTag::FlowIstlSolverParams>
static constexpr int value = 0; {
};
template<class TypeTag>
struct IluRelaxation<TypeTag, TTag::FlowIstlSolverParams> {
using type = GetPropType<TypeTag, Scalar>; using type = GetPropType<TypeTag, Scalar>;
static constexpr type value = 0.9; static constexpr type value = 0.9;
}; };
template<class TypeTag> template<class TypeTag>
struct IluFillinLevel<TypeTag, TTag::FlowIstlSolverParams> { struct IluFillinLevel<TypeTag, TTag::FlowIstlSolverParams>
static constexpr int value = 0; { static constexpr int value = 0; };
};
template<class TypeTag> template<class TypeTag>
struct MiluVariant<TypeTag, TTag::FlowIstlSolverParams> { struct MiluVariant<TypeTag, TTag::FlowIstlSolverParams>
static constexpr auto value = "ILU"; { static constexpr auto value = "ILU"; };
};
template<class TypeTag> template<class TypeTag>
struct IluRedblack<TypeTag, TTag::FlowIstlSolverParams> { struct IluRedblack<TypeTag, TTag::FlowIstlSolverParams>
static constexpr bool value = false; { static constexpr bool value = false; };
};
template<class TypeTag> template<class TypeTag>
struct IluReorderSpheres<TypeTag, TTag::FlowIstlSolverParams> { struct IluReorderSpheres<TypeTag, TTag::FlowIstlSolverParams>
static constexpr bool value = false; { static constexpr bool value = false; };
};
template<class TypeTag> template<class TypeTag>
struct UseGmres<TypeTag, TTag::FlowIstlSolverParams> { struct UseGmres<TypeTag, TTag::FlowIstlSolverParams>
static constexpr bool value = false; { static constexpr bool value = false; };
};
template<class TypeTag> template<class TypeTag>
struct LinearSolverIgnoreConvergenceFailure<TypeTag, TTag::FlowIstlSolverParams> { struct LinearSolverIgnoreConvergenceFailure<TypeTag, TTag::FlowIstlSolverParams>
static constexpr bool value = false; { static constexpr bool value = false; };
};
template<class TypeTag> template<class TypeTag>
struct ScaleLinearSystem<TypeTag, TTag::FlowIstlSolverParams> { struct ScaleLinearSystem<TypeTag, TTag::FlowIstlSolverParams>
static constexpr bool value = false; { static constexpr bool value = false; };
};
template<class TypeTag> template<class TypeTag>
struct LinearSolver<TypeTag, TTag::FlowIstlSolverParams> { struct LinearSolver<TypeTag, TTag::FlowIstlSolverParams>
static constexpr auto value = "ilu0"; { static constexpr auto value = "ilu0"; };
};
template<class TypeTag> template<class TypeTag>
struct LinearSolverPrintJsonDefinition<TypeTag, TTag::FlowIstlSolverParams> { struct LinearSolverPrintJsonDefinition<TypeTag, TTag::FlowIstlSolverParams>
static constexpr auto value = true; { static constexpr auto value = true; };
};
template<class TypeTag> template<class TypeTag>
struct CprReuseSetup<TypeTag, TTag::FlowIstlSolverParams> { struct CprReuseSetup<TypeTag, TTag::FlowIstlSolverParams>
static constexpr int value = 4; { static constexpr int value = 4; };
};
template<class TypeTag> template<class TypeTag>
struct CprReuseInterval<TypeTag, TTag::FlowIstlSolverParams> { struct CprReuseInterval<TypeTag, TTag::FlowIstlSolverParams>
static constexpr int value = 30; { static constexpr int value = 30; };
};
template<class TypeTag> template<class TypeTag>
struct AcceleratorMode<TypeTag, TTag::FlowIstlSolverParams> { struct AcceleratorMode<TypeTag, TTag::FlowIstlSolverParams>
static constexpr auto value = "none"; { static constexpr auto value = "none"; };
};
template<class TypeTag> template<class TypeTag>
struct BdaDeviceId<TypeTag, TTag::FlowIstlSolverParams> { struct BdaDeviceId<TypeTag, TTag::FlowIstlSolverParams>
static constexpr int value = 0; { static constexpr int value = 0; };
};
template<class TypeTag> template<class TypeTag>
struct OpenclPlatformId<TypeTag, TTag::FlowIstlSolverParams> { struct OpenclPlatformId<TypeTag, TTag::FlowIstlSolverParams>
static constexpr int value = 0; { static constexpr int value = 0; };
};
template<class TypeTag> template<class TypeTag>
struct OpenclIluParallel<TypeTag, TTag::FlowIstlSolverParams> { struct OpenclIluParallel<TypeTag, TTag::FlowIstlSolverParams>
static constexpr bool value = true; // note: false should only be used in debug { static constexpr bool value = true; }; // note: false should only be used in debug
};
// Set the backend to be used. // Set the backend to be used.
template<class TypeTag> template<class TypeTag>
struct LinearSolverBackend<TypeTag, TTag::FlowIstlSolverParams> { struct LinearSolverBackend<TypeTag, TTag::FlowIstlSolverParams>
{
#if COMPILE_BDA_BRIDGE #if COMPILE_BDA_BRIDGE
using type = ISTLSolverBda<TypeTag>; using type = ISTLSolverBda<TypeTag>;
#else #else
using type = ISTLSolver<TypeTag>; using type = ISTLSolver<TypeTag>;
#endif #endif
}; };
} // namespace Opm::Properties } // namespace Opm::Properties
namespace Opm namespace Opm::Parameters {
template<class TypeTag>
struct LinearSolverVerbosity<TypeTag, Properties::TTag::FlowIstlSolverParams>
{ static constexpr int value = 0; };
} // namespace Opm::Properties
namespace Opm {
/// This class carries all parameters for the NewtonIterationBlackoilInterleaved class.
struct FlowLinearSolverParameters
{ {
double linear_solver_reduction_;
double relaxed_linear_solver_reduction_;
int linear_solver_maxiter_;
int linear_solver_restart_;
int linear_solver_verbosity_;
double ilu_relaxation_;
int ilu_fillin_level_;
MILU_VARIANT ilu_milu_;
bool ilu_redblack_;
bool ilu_reorder_sphere_;
bool newton_use_gmres_;
bool ignoreConvergenceFailure_;
bool scale_linear_system_;
std::string linsolver_;
bool linear_solver_print_json_definition_;
int cpr_reuse_setup_;
int cpr_reuse_interval_;
std::string accelerator_mode_;
int bda_device_id_;
int opencl_platform_id_;
bool opencl_ilu_parallel_;
template <class TypeTag>
/// This class carries all parameters for the NewtonIterationBlackoilInterleaved class. void init(bool cprRequestedInDataFile)
struct FlowLinearSolverParameters
{ {
double linear_solver_reduction_; // TODO: these parameters have undocumented non-trivial dependencies
double relaxed_linear_solver_reduction_; linear_solver_reduction_ = Parameters::get<TypeTag, Properties::LinearSolverReduction>();
int linear_solver_maxiter_; relaxed_linear_solver_reduction_ = Parameters::get<TypeTag, Properties::RelaxedLinearSolverReduction>();
int linear_solver_restart_; linear_solver_maxiter_ = Parameters::get<TypeTag, Properties::LinearSolverMaxIter>();
int linear_solver_verbosity_; linear_solver_restart_ = Parameters::get<TypeTag, Properties::LinearSolverRestart>();
double ilu_relaxation_; linear_solver_verbosity_ = Parameters::get<TypeTag, Parameters::LinearSolverVerbosity>();
int ilu_fillin_level_; ilu_relaxation_ = Parameters::get<TypeTag, Properties::IluRelaxation>();
MILU_VARIANT ilu_milu_; ilu_fillin_level_ = Parameters::get<TypeTag, Properties::IluFillinLevel>();
bool ilu_redblack_; ilu_milu_ = convertString2Milu(Parameters::get<TypeTag, Properties::MiluVariant>());
bool ilu_reorder_sphere_; ilu_redblack_ = Parameters::get<TypeTag, Properties::IluRedblack>();
bool newton_use_gmres_; ilu_reorder_sphere_ = Parameters::get<TypeTag, Properties::IluReorderSpheres>();
bool ignoreConvergenceFailure_; newton_use_gmres_ = Parameters::get<TypeTag, Properties::UseGmres>();
bool scale_linear_system_; ignoreConvergenceFailure_ = Parameters::get<TypeTag, Properties::LinearSolverIgnoreConvergenceFailure>();
std::string linsolver_; scale_linear_system_ = Parameters::get<TypeTag, Properties::ScaleLinearSystem>();
bool linear_solver_print_json_definition_; linsolver_ = Parameters::get<TypeTag, Properties::LinearSolver>();
int cpr_reuse_setup_; linear_solver_print_json_definition_ = Parameters::get<TypeTag, Properties::LinearSolverPrintJsonDefinition>();
int cpr_reuse_interval_; cpr_reuse_setup_ = Parameters::get<TypeTag, Properties::CprReuseSetup>();
std::string accelerator_mode_; cpr_reuse_interval_ = Parameters::get<TypeTag, Properties::CprReuseInterval>();
int bda_device_id_;
int opencl_platform_id_;
bool opencl_ilu_parallel_;
template <class TypeTag> if (!Parameters::isSet<TypeTag, Properties::LinearSolver>() && cprRequestedInDataFile) {
void init(bool cprRequestedInDataFile) linsolver_ = "cpr";
{ } else {
// TODO: these parameters have undocumented non-trivial dependencies
linear_solver_reduction_ = Parameters::get<TypeTag, Properties::LinearSolverReduction>();
relaxed_linear_solver_reduction_ = Parameters::get<TypeTag, Properties::RelaxedLinearSolverReduction>();
linear_solver_maxiter_ = Parameters::get<TypeTag, Properties::LinearSolverMaxIter>();
linear_solver_restart_ = Parameters::get<TypeTag, Properties::LinearSolverRestart>();
linear_solver_verbosity_ = Parameters::get<TypeTag, Properties::LinearSolverVerbosity>();
ilu_relaxation_ = Parameters::get<TypeTag, Properties::IluRelaxation>();
ilu_fillin_level_ = Parameters::get<TypeTag, Properties::IluFillinLevel>();
ilu_milu_ = convertString2Milu(Parameters::get<TypeTag, Properties::MiluVariant>());
ilu_redblack_ = Parameters::get<TypeTag, Properties::IluRedblack>();
ilu_reorder_sphere_ = Parameters::get<TypeTag, Properties::IluReorderSpheres>();
newton_use_gmres_ = Parameters::get<TypeTag, Properties::UseGmres>();
ignoreConvergenceFailure_ = Parameters::get<TypeTag, Properties::LinearSolverIgnoreConvergenceFailure>();
scale_linear_system_ = Parameters::get<TypeTag, Properties::ScaleLinearSystem>();
linsolver_ = Parameters::get<TypeTag, Properties::LinearSolver>(); linsolver_ = Parameters::get<TypeTag, Properties::LinearSolver>();
linear_solver_print_json_definition_ = Parameters::get<TypeTag, Properties::LinearSolverPrintJsonDefinition>();
cpr_reuse_setup_ = Parameters::get<TypeTag, Properties::CprReuseSetup>();
cpr_reuse_interval_ = Parameters::get<TypeTag, Properties::CprReuseInterval>();
if (!Parameters::isSet<TypeTag, Properties::LinearSolver>() && cprRequestedInDataFile) {
linsolver_ = "cpr";
} else {
linsolver_ = Parameters::get<TypeTag, Properties::LinearSolver>();
}
accelerator_mode_ = Parameters::get<TypeTag, Properties::AcceleratorMode>();
bda_device_id_ = Parameters::get<TypeTag, Properties::BdaDeviceId>();
opencl_platform_id_ = Parameters::get<TypeTag, Properties::OpenclPlatformId>();
opencl_ilu_parallel_ = Parameters::get<TypeTag, Properties::OpenclIluParallel>();
} }
template <class TypeTag> accelerator_mode_ = Parameters::get<TypeTag, Properties::AcceleratorMode>();
static void registerParameters() bda_device_id_ = Parameters::get<TypeTag, Properties::BdaDeviceId>();
{ opencl_platform_id_ = Parameters::get<TypeTag, Properties::OpenclPlatformId>();
Parameters::registerParam<TypeTag, Properties::LinearSolverReduction> opencl_ilu_parallel_ = Parameters::get<TypeTag, Properties::OpenclIluParallel>();
("The minimum reduction of the residual which the linear solver must achieve"); }
Parameters::registerParam<TypeTag, Properties::RelaxedLinearSolverReduction>
("The minimum reduction of the residual which the linear solver need to "
"achieve for the solution to be accepted");
Parameters::registerParam<TypeTag, Properties::LinearSolverMaxIter>
("The maximum number of iterations of the linear solver");
Parameters::registerParam<TypeTag, Properties::LinearSolverRestart>
("The number of iterations after which GMRES is restarted");
Parameters::registerParam<TypeTag, Properties::LinearSolverVerbosity>
("The verbosity level of the linear solver (0: off, 2: all)");
Parameters::registerParam<TypeTag, Properties::IluRelaxation>
("The relaxation factor of the linear solver's ILU preconditioner");
Parameters::registerParam<TypeTag, Properties::IluFillinLevel>
("The fill-in level of the linear solver's ILU preconditioner");
Parameters::registerParam<TypeTag, Properties::MiluVariant>
("Specify which variant of the modified-ILU preconditioner ought to be used. "
"Possible variants are: ILU (default, plain ILU), "
"MILU_1 (lump diagonal with dropped row entries), "
"MILU_2 (lump diagonal with the sum of the absolute values of the dropped row entries), "
"MILU_3 (if diagonal is positive add sum of dropped row entries, otherwise subtract them), "
"MILU_4 (if diagonal is positive add sum of dropped row entries, otherwise do nothing");
Parameters::registerParam<TypeTag, Properties::IluRedblack>
("Use red-black partitioning for the ILU preconditioner");
Parameters::registerParam<TypeTag, Properties::IluReorderSpheres>
("Whether to reorder the entries of the matrix in the red-black "
"ILU preconditioner in spheres starting at an edge. "
"If false the original ordering is preserved in each color. "
"Otherwise why try to ensure D4 ordering (in a 2D structured grid, "
"the diagonal elements are consecutive).");
Parameters::registerParam<TypeTag, Properties::UseGmres>
("Use GMRES as the linear solver");
Parameters::registerParam<TypeTag, Properties::LinearSolverIgnoreConvergenceFailure>
("Continue with the simulation like nothing happened "
"after the linear solver did not converge");
Parameters::registerParam<TypeTag, Properties::ScaleLinearSystem>
("Scale linear system according to equation scale and primary variable types");
Parameters::registerParam<TypeTag, Properties::LinearSolver>
("Configuration of solver. Valid options are: ilu0 (default), "
"dilu, cprw, 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::registerParam<TypeTag, Properties::LinearSolverPrintJsonDefinition>
("Write the JSON definition of the linear solver setup to the DBG file.");
Parameters::registerParam<TypeTag, Properties::CprReuseSetup>
("Reuse preconditioner setup. Valid options are "
"0: recreate the preconditioner for every linear solve, "
"1: recreate once every timestep, "
"2: recreate if last linear solve took more than 10 iterations, "
"3: never recreate, "
"4: recreated every CprReuseInterval");
Parameters::registerParam<TypeTag, Properties::CprReuseInterval>
("Reuse preconditioner interval. Used when CprReuseSetup is set to 4, "
"then the preconditioner will be fully recreated instead of reused "
"every N linear solve, where N is this parameter.");
Parameters::registerParam<TypeTag, Properties::AcceleratorMode>
("Choose a linear solver, usage: "
"'--accelerator-mode=[none|cusparse|opencl|amgcl|rocalution|rocsparse]'");
Parameters::registerParam<TypeTag, Properties::BdaDeviceId>
("Choose device ID for cusparseSolver or openclSolver, "
"use 'nvidia-smi' or 'clinfo' to determine valid IDs");
Parameters::registerParam<TypeTag, Properties::OpenclPlatformId>
("Choose platform ID for openclSolver, use 'clinfo' "
"to determine valid platform IDs");
Parameters::registerParam<TypeTag, Properties::OpenclIluParallel>
("Parallelize ILU decomposition and application on GPU");
}
FlowLinearSolverParameters() { reset(); } template <class TypeTag>
static void registerParameters()
{
Parameters::registerParam<TypeTag, Properties::LinearSolverReduction>
("The minimum reduction of the residual which the linear solver must achieve");
Parameters::registerParam<TypeTag, Properties::RelaxedLinearSolverReduction>
("The minimum reduction of the residual which the linear solver need to "
"achieve for the solution to be accepted");
Parameters::registerParam<TypeTag, Properties::LinearSolverMaxIter>
("The maximum number of iterations of the linear solver");
Parameters::registerParam<TypeTag, Properties::LinearSolverRestart>
("The number of iterations after which GMRES is restarted");
Parameters::registerParam<TypeTag, Parameters::LinearSolverVerbosity>
("The verbosity level of the linear solver (0: off, 2: all)");
Parameters::registerParam<TypeTag, Properties::IluRelaxation>
("The relaxation factor of the linear solver's ILU preconditioner");
Parameters::registerParam<TypeTag, Properties::IluFillinLevel>
("The fill-in level of the linear solver's ILU preconditioner");
Parameters::registerParam<TypeTag, Properties::MiluVariant>
("Specify which variant of the modified-ILU preconditioner ought to be used. "
"Possible variants are: ILU (default, plain ILU), "
"MILU_1 (lump diagonal with dropped row entries), "
"MILU_2 (lump diagonal with the sum of the absolute values of the dropped row entries), "
"MILU_3 (if diagonal is positive add sum of dropped row entries, otherwise subtract them), "
"MILU_4 (if diagonal is positive add sum of dropped row entries, otherwise do nothing");
Parameters::registerParam<TypeTag, Properties::IluRedblack>
("Use red-black partitioning for the ILU preconditioner");
Parameters::registerParam<TypeTag, Properties::IluReorderSpheres>
("Whether to reorder the entries of the matrix in the red-black "
"ILU preconditioner in spheres starting at an edge. "
"If false the original ordering is preserved in each color. "
"Otherwise why try to ensure D4 ordering (in a 2D structured grid, "
"the diagonal elements are consecutive).");
Parameters::registerParam<TypeTag, Properties::UseGmres>
("Use GMRES as the linear solver");
Parameters::registerParam<TypeTag, Properties::LinearSolverIgnoreConvergenceFailure>
("Continue with the simulation like nothing happened "
"after the linear solver did not converge");
Parameters::registerParam<TypeTag, Properties::ScaleLinearSystem>
("Scale linear system according to equation scale and primary variable types");
Parameters::registerParam<TypeTag, Properties::LinearSolver>
("Configuration of solver. Valid options are: ilu0 (default), "
"dilu, cprw, 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::registerParam<TypeTag, Properties::LinearSolverPrintJsonDefinition>
("Write the JSON definition of the linear solver setup to the DBG file.");
Parameters::registerParam<TypeTag, Properties::CprReuseSetup>
("Reuse preconditioner setup. Valid options are "
"0: recreate the preconditioner for every linear solve, "
"1: recreate once every timestep, "
"2: recreate if last linear solve took more than 10 iterations, "
"3: never recreate, "
"4: recreated every CprReuseInterval");
Parameters::registerParam<TypeTag, Properties::CprReuseInterval>
("Reuse preconditioner interval. Used when CprReuseSetup is set to 4, "
"then the preconditioner will be fully recreated instead of reused "
"every N linear solve, where N is this parameter.");
Parameters::registerParam<TypeTag, Properties::AcceleratorMode>
("Choose a linear solver, usage: "
"'--accelerator-mode=[none|cusparse|opencl|amgcl|rocalution|rocsparse]'");
Parameters::registerParam<TypeTag, Properties::BdaDeviceId>
("Choose device ID for cusparseSolver or openclSolver, "
"use 'nvidia-smi' or 'clinfo' to determine valid IDs");
Parameters::registerParam<TypeTag, Properties::OpenclPlatformId>
("Choose platform ID for openclSolver, use 'clinfo' "
"to determine valid platform IDs");
Parameters::registerParam<TypeTag, Properties::OpenclIluParallel>
("Parallelize ILU decomposition and application on GPU");
}
// set default values FlowLinearSolverParameters() { reset(); }
void reset()
{
relaxed_linear_solver_reduction_ = 1e-2;
linear_solver_reduction_ = 1e-2;
linear_solver_maxiter_ = 200;
linear_solver_restart_ = 40;
linear_solver_verbosity_ = 0;
ilu_relaxation_ = 0.9;
ilu_fillin_level_ = 0;
ilu_milu_ = MILU_VARIANT::ILU;
ilu_redblack_ = false;
ilu_reorder_sphere_ = false;
newton_use_gmres_ = false;
ignoreConvergenceFailure_ = false;
scale_linear_system_ = false;
linsolver_ = "ilu0";
linear_solver_print_json_definition_ = true;
cpr_reuse_setup_ = 4;
cpr_reuse_interval_ = 30;
accelerator_mode_ = "none";
bda_device_id_ = 0;
opencl_platform_id_ = 0;
opencl_ilu_parallel_ = true;
}
};
// set default values
void reset()
{
relaxed_linear_solver_reduction_ = 1e-2;
linear_solver_reduction_ = 1e-2;
linear_solver_maxiter_ = 200;
linear_solver_restart_ = 40;
linear_solver_verbosity_ = 0;
ilu_relaxation_ = 0.9;
ilu_fillin_level_ = 0;
ilu_milu_ = MILU_VARIANT::ILU;
ilu_redblack_ = false;
ilu_reorder_sphere_ = false;
newton_use_gmres_ = false;
ignoreConvergenceFailure_ = false;
scale_linear_system_ = false;
linsolver_ = "ilu0";
linear_solver_print_json_definition_ = true;
cpr_reuse_setup_ = 4;
cpr_reuse_interval_ = 30;
accelerator_mode_ = "none";
bda_device_id_ = 0;
opencl_platform_id_ = 0;
opencl_ilu_parallel_ = true;
}
};
} // namespace Opm } // namespace Opm
#endif // OPM_FLOWLINEARSOLVERPARAMETERS_HEADER_INCLUDED #endif // OPM_FLOWLINEARSOLVERPARAMETERS_HEADER_INCLUDED