diff --git a/opm/simulators/flow/BlackoilModelEbos.hpp b/opm/simulators/flow/BlackoilModelEbos.hpp index a53bb07d0..d8181dd8f 100644 --- a/opm/simulators/flow/BlackoilModelEbos.hpp +++ b/opm/simulators/flow/BlackoilModelEbos.hpp @@ -24,6 +24,8 @@ #ifndef OPM_BLACKOILMODELEBOS_HEADER_INCLUDED #define OPM_BLACKOILMODELEBOS_HEADER_INCLUDED +#include + #include #include @@ -1595,6 +1597,7 @@ namespace Opm { return grid_.comm().sum(errorPV); } + ConvergenceReport getDomainReservoirConvergence(const double reportTime, const double dt, const int iteration, @@ -1704,6 +1707,17 @@ namespace Opm { + void updateTUNING(const Tuning& tuning) { + if (tuning.XXXMBE_has_nondefault_value) { + param_.tolerance_mb_ = tuning.XXXMBE; + if ( terminal_output_ ) { + + OpmLog::debug(fmt::format("Setting BlackoilModelEbos mass balance limit (XXXMBE) to {:.2e}", tuning.XXXMBE)); + } + } + } + + ConvergenceReport getReservoirConvergence(const double reportTime, const double dt, const int iteration, @@ -1728,7 +1742,7 @@ namespace Opm { auto cnvErrorPvFraction = computeCnvErrorPv(B_avg, dt); cnvErrorPvFraction /= (pvSum - numAquiferPvSum); - const double tol_mb = param_.tolerance_mb_; + const double tol_mb = param_.tolerance_mb_; // Default value of relaxed_max_pv_fraction_ is 0.03 and min_strict_cnv_iter_ is 0. // For each iteration, we need to determine whether to use the relaxed CNV tolerance. // To disable the usage of relaxed CNV tolerance, you can set the relaxed_max_pv_fraction_ to be 0. diff --git a/opm/simulators/flow/SimulatorFullyImplicitBlackoilEbos.hpp b/opm/simulators/flow/SimulatorFullyImplicitBlackoilEbos.hpp index 8608fd515..15baf43dc 100644 --- a/opm/simulators/flow/SimulatorFullyImplicitBlackoilEbos.hpp +++ b/opm/simulators/flow/SimulatorFullyImplicitBlackoilEbos.hpp @@ -23,6 +23,7 @@ #define OPM_SIMULATORFULLYIMPLICITBLACKOILEBOS_HEADER_INCLUDED #include +#include #include #include @@ -320,6 +321,15 @@ public: } } + void updateTUNING(const Tuning& tuning) { + if (tuning.XXXMBE_has_nondefault_value) { + modelParam_.tolerance_mb_ = tuning.XXXMBE; + if (terminalOutput_) { + OpmLog::debug(fmt::format("Setting SimulatorFullyImplicitBlackoilEbos mass balance limit (XXXMBE) to {:.2e}", tuning.XXXMBE)); + } + } + } + bool runStep(SimulatorTimer& timer) { if (schedule().exitStatus().has_value()) { @@ -393,6 +403,10 @@ public: const auto& tuning = sched_state.tuning(); const auto& max_next_tstep = sched_state.max_next_tstep(); adaptiveTimeStepping_->updateTUNING(max_next_tstep, tuning); + // \Note: Assumes TUNING is only used with adaptive time-stepping + // \Note: Need to update both solver (model) and simulator since solver is re-created each report step. + solver->model().updateTUNING(tuning); + this->updateTUNING(tuning); } } bool event = events.hasEvent(ScheduleEvents::NEW_WELL) ||