Merge pull request #4400 from blattms/use-cpr-from-datafile

Use CPR if specified in RUNSPEC / Make cprw the default
This commit is contained in:
Bård Skaflestad
2023-01-19 16:59:48 +01:00
committed by GitHub
6 changed files with 18 additions and 16 deletions
@@ -238,7 +238,7 @@ namespace Opm
bool opencl_ilu_parallel_;
template <class TypeTag>
void init()
void init(bool cprRequestedInDataFile)
{
// TODO: these parameters have undocumented non-trivial dependencies
linear_solver_reduction_ = EWOMS_GET_PARAM(TypeTag, double, LinearSolverReduction);
@@ -255,7 +255,13 @@ namespace Opm
scale_linear_system_ = EWOMS_GET_PARAM(TypeTag, bool, ScaleLinearSystem);
cpr_reuse_setup_ = EWOMS_GET_PARAM(TypeTag, int, CprReuseSetup);
cpr_reuse_interval_ = EWOMS_GET_PARAM(TypeTag, int, CprReuseInterval);
linsolver_ = EWOMS_GET_PARAM(TypeTag, std::string, LinearSolver);
if (!EWOMS_PARAM_IS_SET(TypeTag, int, LinearSolverMaxIter) && cprRequestedInDataFile) {
linsolver_ = "cpr";
} else {
linsolver_ = EWOMS_GET_PARAM(TypeTag, std::string, LinearSolver);
}
accelerator_mode_ = EWOMS_GET_PARAM(TypeTag, std::string, AcceleratorMode);
bda_device_id_ = EWOMS_GET_PARAM(TypeTag, int, BdaDeviceId);
opencl_platform_id_ = EWOMS_GET_PARAM(TypeTag, int, OpenclPlatformId);
@@ -279,7 +285,7 @@ namespace Opm
EWOMS_REGISTER_PARAM(TypeTag, bool, ScaleLinearSystem, "Scale linear system according to equation scale and primary variable types");
EWOMS_REGISTER_PARAM(TypeTag, int, 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");
EWOMS_REGISTER_PARAM(TypeTag, int, 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.");
EWOMS_REGISTER_PARAM(TypeTag, std::string, LinearSolver, "Configuration of solver. Valid options are: ilu0 (default), cpr (an alias for cpr_trueimpes), cpr_quasiimpes, cpr_trueimpes or amg. Alternatively, you can request a configuration to be read from a JSON file by giving the filename here, ending with '.json.'");
EWOMS_REGISTER_PARAM(TypeTag, std::string, LinearSolver, "Configuration of solver. Valid options are: ilu0 (default), cprw, cpr (an alias for cprw), cpr_quasiimpes, cpr_trueimpes or amg. Alternatively, you can request a configuration to be read from a JSON file by giving the filename here, ending with '.json.'");
EWOMS_REGISTER_PARAM(TypeTag, std::string, AcceleratorMode, "Choose a linear solver, usage: '--accelerator-mode=[none|cusparse|opencl|amgcl|rocalution]'");
EWOMS_REGISTER_PARAM(TypeTag, int, BdaDeviceId, "Choose device ID for cusparseSolver or openclSolver, use 'nvidia-smi' or 'clinfo' to determine valid IDs");
EWOMS_REGISTER_PARAM(TypeTag, int, OpenclPlatformId, "Choose platform ID for openclSolver, use 'clinfo' to determine valid platform IDs");
+1 -1
View File
@@ -241,7 +241,7 @@ std::unique_ptr<Matrix> blockJacobiAdjacency(const Grid& grid,
#if HAVE_MPI
comm_.reset( new CommunicationType( simulator_.vanguard().grid().comm() ) );
#endif
parameters_.template init<TypeTag>();
parameters_.template init<TypeTag>(simulator_.vanguard().eclState().getSimulationConfig().useCPR());
prm_ = setupPropertyTree(parameters_,
EWOMS_PARAM_IS_SET(TypeTag, int, LinearSolverMaxIter),
EWOMS_PARAM_IS_SET(TypeTag, double, LinearSolverReduction));
+2 -6
View File
@@ -63,11 +63,7 @@ setupPropertyTree(FlowLinearSolverParameters p, // Note: copying the parameters
}
// Use CPR configuration.
if ((conf == "cpr") || (conf == "cpr_trueimpes") || (conf == "cpr_quasiimpes")) {
if (conf == "cpr") {
// Treat "cpr" as short cut for the true IMPES variant.
conf = "cpr_trueimpes";
}
if ((conf == "cpr_trueimpes") || (conf == "cpr_quasiimpes")) {
if (!linearSolverMaxIterSet) {
// Use our own default unless it was explicitly overridden by user.
p.linear_solver_maxiter_ = 20;
@@ -79,7 +75,7 @@ setupPropertyTree(FlowLinearSolverParameters p, // Note: copying the parameters
return setupCPR(conf, p);
}
if ((conf == "cprw")) {
if ((conf == "cpr") || (conf == "cprw")) {
if (!linearSolverMaxIterSet) {
// Use our own default unless it was explicitly overridden by user.
p.linear_solver_maxiter_ = 20;