mirror of
https://github.com/OPM/opm-simulators.git
synced 2025-02-25 18:55:30 -06:00
Merge pull request #3519 from totto82/continueOnConvergenceFailure
Option for continue on solver convergence failure
This commit is contained in:
@@ -45,6 +45,10 @@ struct SolverMinTimeStep {
|
|||||||
using type = UndefinedProperty;
|
using type = UndefinedProperty;
|
||||||
};
|
};
|
||||||
template<class TypeTag, class MyTypeTag>
|
template<class TypeTag, class MyTypeTag>
|
||||||
|
struct SolverContinueOnConvergenceFailure {
|
||||||
|
using type = UndefinedProperty;
|
||||||
|
};
|
||||||
|
template<class TypeTag, class MyTypeTag>
|
||||||
struct SolverMaxRestarts {
|
struct SolverMaxRestarts {
|
||||||
using type = UndefinedProperty;
|
using type = UndefinedProperty;
|
||||||
};
|
};
|
||||||
@@ -139,6 +143,10 @@ struct SolverMinTimeStep<TypeTag, TTag::FlowTimeSteppingParameters> {
|
|||||||
static constexpr type value = 1.0e-12;
|
static constexpr type value = 1.0e-12;
|
||||||
};
|
};
|
||||||
template<class TypeTag>
|
template<class TypeTag>
|
||||||
|
struct SolverContinueOnConvergenceFailure<TypeTag, TTag::FlowTimeSteppingParameters> {
|
||||||
|
static constexpr bool value = false;
|
||||||
|
};
|
||||||
|
template<class TypeTag>
|
||||||
struct SolverMaxRestarts<TypeTag, TTag::FlowTimeSteppingParameters> {
|
struct SolverMaxRestarts<TypeTag, TTag::FlowTimeSteppingParameters> {
|
||||||
static constexpr int value = 10;
|
static constexpr int value = 10;
|
||||||
};
|
};
|
||||||
@@ -262,6 +270,7 @@ namespace Opm {
|
|||||||
, maxGrowth_(EWOMS_GET_PARAM(TypeTag, double, SolverMaxGrowth)) // 3.0
|
, maxGrowth_(EWOMS_GET_PARAM(TypeTag, double, SolverMaxGrowth)) // 3.0
|
||||||
, maxTimeStep_(EWOMS_GET_PARAM(TypeTag, double, SolverMaxTimeStepInDays)*24*60*60) // 365.25
|
, maxTimeStep_(EWOMS_GET_PARAM(TypeTag, double, SolverMaxTimeStepInDays)*24*60*60) // 365.25
|
||||||
, minTimeStep_(unitSystem.to_si(UnitSystem::measure::time, EWOMS_GET_PARAM(TypeTag, double, SolverMinTimeStep))) // 1e-12;
|
, minTimeStep_(unitSystem.to_si(UnitSystem::measure::time, EWOMS_GET_PARAM(TypeTag, double, SolverMinTimeStep))) // 1e-12;
|
||||||
|
, ignoreConvergenceFailure_(EWOMS_GET_PARAM(TypeTag, bool, SolverContinueOnConvergenceFailure)) // false;
|
||||||
, solverRestartMax_(EWOMS_GET_PARAM(TypeTag, int, SolverMaxRestarts)) // 10
|
, solverRestartMax_(EWOMS_GET_PARAM(TypeTag, int, SolverMaxRestarts)) // 10
|
||||||
, solverVerbose_(EWOMS_GET_PARAM(TypeTag, int, SolverVerbosity) > 0 && terminalOutput) // 2
|
, solverVerbose_(EWOMS_GET_PARAM(TypeTag, int, SolverVerbosity) > 0 && terminalOutput) // 2
|
||||||
, timestepVerbose_(EWOMS_GET_PARAM(TypeTag, int, TimeStepVerbosity) > 0 && terminalOutput) // 2
|
, timestepVerbose_(EWOMS_GET_PARAM(TypeTag, int, TimeStepVerbosity) > 0 && terminalOutput) // 2
|
||||||
@@ -288,7 +297,8 @@ namespace Opm {
|
|||||||
, growthFactor_(tuning.TFDIFF)
|
, growthFactor_(tuning.TFDIFF)
|
||||||
, maxGrowth_(tuning.TSFMAX)
|
, maxGrowth_(tuning.TSFMAX)
|
||||||
, maxTimeStep_(tuning.TSMAXZ) // 365.25
|
, maxTimeStep_(tuning.TSMAXZ) // 365.25
|
||||||
, minTimeStep_(unitSystem.to_si(UnitSystem::measure::time, EWOMS_GET_PARAM(TypeTag, double, SolverMinTimeStep))) // 1e-12;
|
, minTimeStep_(tuning.TSFMIN) // 0.1;
|
||||||
|
, ignoreConvergenceFailure_(true)
|
||||||
, solverRestartMax_(EWOMS_GET_PARAM(TypeTag, int, SolverMaxRestarts)) // 10
|
, solverRestartMax_(EWOMS_GET_PARAM(TypeTag, int, SolverMaxRestarts)) // 10
|
||||||
, solverVerbose_(EWOMS_GET_PARAM(TypeTag, int, SolverVerbosity) > 0 && terminalOutput) // 2
|
, solverVerbose_(EWOMS_GET_PARAM(TypeTag, int, SolverVerbosity) > 0 && terminalOutput) // 2
|
||||||
, timestepVerbose_(EWOMS_GET_PARAM(TypeTag, int, TimeStepVerbosity) > 0 && terminalOutput) // 2
|
, timestepVerbose_(EWOMS_GET_PARAM(TypeTag, int, TimeStepVerbosity) > 0 && terminalOutput) // 2
|
||||||
@@ -314,6 +324,8 @@ namespace Opm {
|
|||||||
"The maximum size of a time step in days");
|
"The maximum size of a time step in days");
|
||||||
EWOMS_REGISTER_PARAM(TypeTag, double, SolverMinTimeStep,
|
EWOMS_REGISTER_PARAM(TypeTag, double, SolverMinTimeStep,
|
||||||
"The minimum size of a time step in days for field and metric and hours for lab. If a step cannot converge without getting cut below this step size the simulator will stop");
|
"The minimum size of a time step in days for field and metric and hours for lab. If a step cannot converge without getting cut below this step size the simulator will stop");
|
||||||
|
EWOMS_REGISTER_PARAM(TypeTag, bool, SolverContinueOnConvergenceFailure,
|
||||||
|
"Continue instead of stop when minimum solver time step is reached");
|
||||||
EWOMS_REGISTER_PARAM(TypeTag, int, SolverMaxRestarts,
|
EWOMS_REGISTER_PARAM(TypeTag, int, SolverMaxRestarts,
|
||||||
"The maximum number of breakdowns before a substep is given up and the simulator is terminated");
|
"The maximum number of breakdowns before a substep is given up and the simulator is terminated");
|
||||||
EWOMS_REGISTER_PARAM(TypeTag, int, SolverVerbosity,
|
EWOMS_REGISTER_PARAM(TypeTag, int, SolverVerbosity,
|
||||||
@@ -444,7 +456,20 @@ namespace Opm {
|
|||||||
|
|
||||||
report += substepReport;
|
report += substepReport;
|
||||||
|
|
||||||
if (substepReport.converged) {
|
bool continue_on_uncoverged_solution = ignoreConvergenceFailure_ && !substepReport.converged && dt <= minTimeStep_;
|
||||||
|
|
||||||
|
if (continue_on_uncoverged_solution) {
|
||||||
|
const auto msg = std::string("Solver failed to converge but timestep ")
|
||||||
|
+ std::to_string(dt) + " is smaller or equal to "
|
||||||
|
+ std::to_string(minTimeStep_) + "\n which is the minimum threshold given"
|
||||||
|
+ "by option --solver-min-time-step= \n";
|
||||||
|
if (solverVerbose_) {
|
||||||
|
OpmLog::error(msg);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (substepReport.converged || continue_on_uncoverged_solution) {
|
||||||
|
|
||||||
// advance by current dt
|
// advance by current dt
|
||||||
++substepTimer;
|
++substepTimer;
|
||||||
|
|
||||||
@@ -735,6 +760,7 @@ namespace Opm {
|
|||||||
double maxGrowth_; //!< factor that limits the maximum growth of a time step
|
double maxGrowth_; //!< factor that limits the maximum growth of a time step
|
||||||
double maxTimeStep_; //!< maximal allowed time step size in days
|
double maxTimeStep_; //!< maximal allowed time step size in days
|
||||||
double minTimeStep_; //!< minimal allowed time step size before throwing
|
double minTimeStep_; //!< minimal allowed time step size before throwing
|
||||||
|
bool ignoreConvergenceFailure_; //!< continue instead of stop when minimum time step is reached
|
||||||
int solverRestartMax_; //!< how many restart of solver are allowed
|
int solverRestartMax_; //!< how many restart of solver are allowed
|
||||||
bool solverVerbose_; //!< solver verbosity
|
bool solverVerbose_; //!< solver verbosity
|
||||||
bool timestepVerbose_; //!< timestep verbosity
|
bool timestepVerbose_; //!< timestep verbosity
|
||||||
|
|||||||
Reference in New Issue
Block a user