2016-06-06 08:40:06 -05:00
|
|
|
/*
|
2020-05-07 09:13:39 -05:00
|
|
|
Copyright 2013, 2015, 2020 SINTEF Digital, Mathematics and Cybernetics.
|
2016-06-06 08:40:06 -05:00
|
|
|
Copyright 2015 Andreas Lauser
|
2017-11-21 04:12:16 -06:00
|
|
|
Copyright 2017 IRIS
|
2016-06-06 08:40:06 -05:00
|
|
|
|
|
|
|
This file is part of the Open Porous Media project (OPM).
|
|
|
|
|
|
|
|
OPM is free software: you can redistribute it and/or modify
|
|
|
|
it under the terms of the GNU General Public License as published by
|
|
|
|
the Free Software Foundation, either version 3 of the License, or
|
|
|
|
(at your option) any later version.
|
|
|
|
|
|
|
|
OPM is distributed in the hope that it will be useful,
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
GNU General Public License for more details.
|
|
|
|
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
|
|
along with OPM. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
*/
|
|
|
|
|
2024-01-31 07:14:50 -06:00
|
|
|
#ifndef OPM_SIMULATOR_FULLY_IMPLICIT_BLACKOIL_HEADER_INCLUDED
|
|
|
|
#define OPM_SIMULATOR_FULLY_IMPLICIT_BLACKOIL_HEADER_INCLUDED
|
2016-06-06 08:40:06 -05:00
|
|
|
|
2024-02-02 02:17:08 -06:00
|
|
|
#include <opm/common/ErrorMacros.hpp>
|
|
|
|
|
|
|
|
#include <opm/input/eclipse/Units/UnitSystem.hpp>
|
|
|
|
|
|
|
|
#include <opm/grid/utility/StopWatch.hpp>
|
2023-02-10 06:29:58 -06:00
|
|
|
|
2023-08-23 02:25:09 -05:00
|
|
|
#include <opm/simulators/aquifers/BlackoilAquiferModel.hpp>
|
2024-01-31 07:14:50 -06:00
|
|
|
#include <opm/simulators/flow/BlackoilModel.hpp>
|
2024-01-31 07:14:50 -06:00
|
|
|
#include <opm/simulators/flow/BlackoilModelParameters.hpp>
|
Output Non-Linear Convergence to Separate File if Requested
This commit enables outputting non-linear convergence metrics, i.e.,
the MB and CNV values, per phase, for each non-linear iteration in
each timestep. If the user passes the option value "iterations" to
the --extra-convergence-output command line option, this commit will
create a new output file, CASE.INFOITER, that holds
* report step
* time step within that report step
* elapsed time
* MB and CNV values per phase
* well convergence status
for each non-linear iteration.
We use an asynchronous file writing procedure and confer ownership
of the report step's unprocessed convergence reports to this
procedure just before the end of
SimulatorFullyImplicitBlackoilEbos::runStep()
At that point, the convergence reports are about to go out of scope.
The asynchronous protocol uses a dedicated queue of output requests,
class ConvergenceReportQueue, into which the producer-i.e., member
function runStep()-inserts new convergence reports and from which
the output thread, ConvergenceOutputThread::writeASynchronous(),
retrieves those requests before writing the file data.
2022-12-13 08:14:05 -06:00
|
|
|
#include <opm/simulators/flow/ConvergenceOutputConfiguration.hpp>
|
|
|
|
#include <opm/simulators/flow/ExtraConvergenceOutputThread.hpp>
|
2024-01-31 07:14:50 -06:00
|
|
|
#include <opm/simulators/flow/NonlinearSolver.hpp>
|
2024-02-02 01:41:35 -06:00
|
|
|
#include <opm/simulators/flow/SimulatorReportBanners.hpp>
|
2023-08-23 02:25:09 -05:00
|
|
|
#include <opm/simulators/flow/SimulatorSerializer.hpp>
|
2024-01-31 07:14:50 -06:00
|
|
|
#include <opm/simulators/timestepping/AdaptiveTimeStepping.hpp>
|
2023-03-01 06:40:54 -06:00
|
|
|
#include <opm/simulators/timestepping/ConvergenceReport.hpp>
|
Output Non-Linear Convergence to Separate File if Requested
This commit enables outputting non-linear convergence metrics, i.e.,
the MB and CNV values, per phase, for each non-linear iteration in
each timestep. If the user passes the option value "iterations" to
the --extra-convergence-output command line option, this commit will
create a new output file, CASE.INFOITER, that holds
* report step
* time step within that report step
* elapsed time
* MB and CNV values per phase
* well convergence status
for each non-linear iteration.
We use an asynchronous file writing procedure and confer ownership
of the report step's unprocessed convergence reports to this
procedure just before the end of
SimulatorFullyImplicitBlackoilEbos::runStep()
At that point, the convergence reports are about to go out of scope.
The asynchronous protocol uses a dedicated queue of output requests,
class ConvergenceReportQueue, into which the producer-i.e., member
function runStep()-inserts new convergence reports and from which
the output thread, ConvergenceOutputThread::writeASynchronous(),
retrieves those requests before writing the file data.
2022-12-13 08:14:05 -06:00
|
|
|
#include <opm/simulators/utils/moduleVersion.hpp>
|
|
|
|
#include <opm/simulators/wells/WellState.hpp>
|
|
|
|
|
2024-02-02 02:17:08 -06:00
|
|
|
#if HAVE_HDF5
|
|
|
|
#include <opm/simulators/utils/HDF5Serializer.hpp>
|
|
|
|
#endif
|
2016-06-06 08:40:06 -05:00
|
|
|
|
2024-02-02 02:17:08 -06:00
|
|
|
#include <fmt/format.h>
|
2023-02-09 05:50:46 -06:00
|
|
|
|
2024-02-02 02:17:08 -06:00
|
|
|
#include <cstddef>
|
2023-10-23 08:55:51 -05:00
|
|
|
#include <filesystem>
|
Output Non-Linear Convergence to Separate File if Requested
This commit enables outputting non-linear convergence metrics, i.e.,
the MB and CNV values, per phase, for each non-linear iteration in
each timestep. If the user passes the option value "iterations" to
the --extra-convergence-output command line option, this commit will
create a new output file, CASE.INFOITER, that holds
* report step
* time step within that report step
* elapsed time
* MB and CNV values per phase
* well convergence status
for each non-linear iteration.
We use an asynchronous file writing procedure and confer ownership
of the report step's unprocessed convergence reports to this
procedure just before the end of
SimulatorFullyImplicitBlackoilEbos::runStep()
At that point, the convergence reports are about to go out of scope.
The asynchronous protocol uses a dedicated queue of output requests,
class ConvergenceReportQueue, into which the producer-i.e., member
function runStep()-inserts new convergence reports and from which
the output thread, ConvergenceOutputThread::writeASynchronous(),
retrieves those requests before writing the file data.
2022-12-13 08:14:05 -06:00
|
|
|
#include <memory>
|
|
|
|
#include <optional>
|
|
|
|
#include <string>
|
|
|
|
#include <string_view>
|
|
|
|
#include <thread>
|
|
|
|
#include <utility>
|
|
|
|
#include <vector>
|
|
|
|
|
2024-06-28 05:17:13 -05:00
|
|
|
namespace Opm::Parameters {
|
2018-06-21 05:14:17 -05:00
|
|
|
|
2024-07-06 03:22:47 -05:00
|
|
|
struct EnableAdaptiveTimeStepping { static constexpr bool value = true; };
|
|
|
|
struct OutputExtraConvergenceInfo { static constexpr auto* value = "none"; };
|
|
|
|
struct SaveStep { static constexpr auto* value = ""; };
|
|
|
|
struct SaveFile { static constexpr auto* value = ""; };
|
|
|
|
struct LoadFile { static constexpr auto* value = ""; };
|
|
|
|
struct LoadStep { static constexpr int value = -1; };
|
2023-02-09 05:50:46 -06:00
|
|
|
|
2024-06-28 05:17:13 -05:00
|
|
|
} // namespace Opm::Parameters
|
2016-11-21 05:01:20 -06:00
|
|
|
|
2016-06-06 08:40:06 -05:00
|
|
|
namespace Opm {
|
|
|
|
|
2016-07-12 11:47:52 -05:00
|
|
|
/// a simulator for the blackoil model
|
2017-06-07 02:29:31 -05:00
|
|
|
template<class TypeTag>
|
2024-01-31 07:14:50 -06:00
|
|
|
class SimulatorFullyImplicitBlackoil : private SerializableSim
|
2016-06-06 08:40:06 -05:00
|
|
|
{
|
2016-07-12 11:47:52 -05:00
|
|
|
public:
|
2020-08-26 03:49:52 -05:00
|
|
|
using Simulator = GetPropType<TypeTag, Properties::Simulator>;
|
|
|
|
using Grid = GetPropType<TypeTag, Properties::Grid>;
|
|
|
|
using FluidSystem = GetPropType<TypeTag, Properties::FluidSystem>;
|
|
|
|
using ElementContext = GetPropType<TypeTag, Properties::ElementContext>;
|
|
|
|
using BlackoilIndices = GetPropType<TypeTag, Properties::Indices>;
|
|
|
|
using PrimaryVariables = GetPropType<TypeTag, Properties::PrimaryVariables>;
|
|
|
|
using MaterialLaw = GetPropType<TypeTag, Properties::MaterialLaw>;
|
|
|
|
using SolutionVector = GetPropType<TypeTag, Properties::SolutionVector>;
|
|
|
|
using MaterialLawParams = GetPropType<TypeTag, Properties::MaterialLawParams>;
|
2024-02-06 01:18:32 -06:00
|
|
|
using AquiferModel = GetPropType<TypeTag, Properties::AquiferModel>;
|
2017-04-06 07:21:59 -05:00
|
|
|
|
2024-01-31 07:14:50 -06:00
|
|
|
using TimeStepper = AdaptiveTimeStepping<TypeTag>;
|
2024-02-02 02:20:38 -06:00
|
|
|
using PolymerModule = BlackOilPolymerModule<TypeTag>;
|
|
|
|
using MICPModule = BlackOilMICPModule<TypeTag>;
|
2016-08-23 02:45:37 -05:00
|
|
|
|
2024-01-31 07:14:50 -06:00
|
|
|
using Model = BlackoilModel<TypeTag>;
|
2024-01-31 07:14:50 -06:00
|
|
|
using Solver = NonlinearSolver<TypeTag, Model>;
|
2024-02-02 02:20:38 -06:00
|
|
|
using ModelParameters = typename Model::ModelParameters;
|
|
|
|
using SolverParameters = typename Solver::SolverParameters;
|
|
|
|
using WellModel = BlackoilWellModel<TypeTag>;
|
2016-07-12 11:47:52 -05:00
|
|
|
|
|
|
|
/// Initialise from parameters and objects to observe.
|
|
|
|
/// \param[in] param parameters, this class accepts the following:
|
|
|
|
/// parameter (default) effect
|
|
|
|
/// -----------------------------------------------------------
|
|
|
|
/// output (true) write output to files?
|
|
|
|
/// output_dir ("output") output directoty
|
|
|
|
/// output_interval (1) output every nth step
|
|
|
|
/// nl_pressure_residual_tolerance (0.0) pressure solver residual tolerance (in Pascal)
|
|
|
|
/// nl_pressure_change_tolerance (1.0) pressure solver change tolerance (in Pascal)
|
|
|
|
/// nl_pressure_maxiter (10) max nonlinear iterations in pressure
|
|
|
|
/// nl_maxiter (30) max nonlinear iterations in transport
|
|
|
|
/// nl_tolerance (1e-9) transport solver absolute residual tolerance
|
|
|
|
/// num_transport_substeps (1) number of transport steps per pressure step
|
|
|
|
/// use_segregation_split (false) solve for gravity segregation (if false,
|
|
|
|
/// segregation is ignored).
|
|
|
|
///
|
|
|
|
/// \param[in] props fluid and rock properties
|
|
|
|
/// \param[in] linsolver linear solver
|
|
|
|
/// \param[in] eclipse_state the object which represents an internalized ECL deck
|
|
|
|
/// \param[in] output_writer
|
|
|
|
/// \param[in] threshold_pressures_by_face if nonempty, threshold pressures that inhibit flow
|
2024-02-06 04:55:07 -06:00
|
|
|
SimulatorFullyImplicitBlackoil(Simulator& simulator)
|
|
|
|
: simulator_(simulator)
|
2023-08-23 02:25:09 -05:00
|
|
|
, serializer_(*this,
|
2024-02-02 03:46:44 -06:00
|
|
|
FlowGenericVanguard::comm(),
|
2024-02-06 04:55:07 -06:00
|
|
|
simulator_.vanguard().eclState().getIOConfig(),
|
2024-07-06 03:22:47 -05:00
|
|
|
Parameters::Get<Parameters::SaveStep>(),
|
|
|
|
Parameters::Get<Parameters::LoadStep>(),
|
|
|
|
Parameters::Get<Parameters::SaveFile>(),
|
|
|
|
Parameters::Get<Parameters::LoadFile>())
|
2016-07-12 11:47:52 -05:00
|
|
|
{
|
2018-06-21 05:14:17 -05:00
|
|
|
phaseUsage_ = phaseUsageFromDeck(eclState());
|
|
|
|
|
Output Non-Linear Convergence to Separate File if Requested
This commit enables outputting non-linear convergence metrics, i.e.,
the MB and CNV values, per phase, for each non-linear iteration in
each timestep. If the user passes the option value "iterations" to
the --extra-convergence-output command line option, this commit will
create a new output file, CASE.INFOITER, that holds
* report step
* time step within that report step
* elapsed time
* MB and CNV values per phase
* well convergence status
for each non-linear iteration.
We use an asynchronous file writing procedure and confer ownership
of the report step's unprocessed convergence reports to this
procedure just before the end of
SimulatorFullyImplicitBlackoilEbos::runStep()
At that point, the convergence reports are about to go out of scope.
The asynchronous protocol uses a dedicated queue of output requests,
class ConvergenceReportQueue, into which the producer-i.e., member
function runStep()-inserts new convergence reports and from which
the output thread, ConvergenceOutputThread::writeASynchronous(),
retrieves those requests before writing the file data.
2022-12-13 08:14:05 -06:00
|
|
|
// Only rank 0 does print to std::cout, and only if specifically requested.
|
|
|
|
this->terminalOutput_ = false;
|
|
|
|
if (this->grid().comm().rank() == 0) {
|
2024-07-06 03:22:47 -05:00
|
|
|
this->terminalOutput_ = Parameters::Get<Parameters::EnableTerminalOutput>();
|
Output Non-Linear Convergence to Separate File if Requested
This commit enables outputting non-linear convergence metrics, i.e.,
the MB and CNV values, per phase, for each non-linear iteration in
each timestep. If the user passes the option value "iterations" to
the --extra-convergence-output command line option, this commit will
create a new output file, CASE.INFOITER, that holds
* report step
* time step within that report step
* elapsed time
* MB and CNV values per phase
* well convergence status
for each non-linear iteration.
We use an asynchronous file writing procedure and confer ownership
of the report step's unprocessed convergence reports to this
procedure just before the end of
SimulatorFullyImplicitBlackoilEbos::runStep()
At that point, the convergence reports are about to go out of scope.
The asynchronous protocol uses a dedicated queue of output requests,
class ConvergenceReportQueue, into which the producer-i.e., member
function runStep()-inserts new convergence reports and from which
the output thread, ConvergenceOutputThread::writeASynchronous(),
retrieves those requests before writing the file data.
2022-12-13 08:14:05 -06:00
|
|
|
|
2024-07-06 03:22:47 -05:00
|
|
|
this->startConvergenceOutputThread(Parameters::Get<Parameters::OutputExtraConvergenceInfo>(),
|
2022-12-16 07:49:28 -06:00
|
|
|
R"(OutputExtraConvergenceInfo (--output-extra-convergence-info))");
|
Output Non-Linear Convergence to Separate File if Requested
This commit enables outputting non-linear convergence metrics, i.e.,
the MB and CNV values, per phase, for each non-linear iteration in
each timestep. If the user passes the option value "iterations" to
the --extra-convergence-output command line option, this commit will
create a new output file, CASE.INFOITER, that holds
* report step
* time step within that report step
* elapsed time
* MB and CNV values per phase
* well convergence status
for each non-linear iteration.
We use an asynchronous file writing procedure and confer ownership
of the report step's unprocessed convergence reports to this
procedure just before the end of
SimulatorFullyImplicitBlackoilEbos::runStep()
At that point, the convergence reports are about to go out of scope.
The asynchronous protocol uses a dedicated queue of output requests,
class ConvergenceReportQueue, into which the producer-i.e., member
function runStep()-inserts new convergence reports and from which
the output thread, ConvergenceOutputThread::writeASynchronous(),
retrieves those requests before writing the file data.
2022-12-13 08:14:05 -06:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2024-01-31 07:14:50 -06:00
|
|
|
~SimulatorFullyImplicitBlackoil()
|
Output Non-Linear Convergence to Separate File if Requested
This commit enables outputting non-linear convergence metrics, i.e.,
the MB and CNV values, per phase, for each non-linear iteration in
each timestep. If the user passes the option value "iterations" to
the --extra-convergence-output command line option, this commit will
create a new output file, CASE.INFOITER, that holds
* report step
* time step within that report step
* elapsed time
* MB and CNV values per phase
* well convergence status
for each non-linear iteration.
We use an asynchronous file writing procedure and confer ownership
of the report step's unprocessed convergence reports to this
procedure just before the end of
SimulatorFullyImplicitBlackoilEbos::runStep()
At that point, the convergence reports are about to go out of scope.
The asynchronous protocol uses a dedicated queue of output requests,
class ConvergenceReportQueue, into which the producer-i.e., member
function runStep()-inserts new convergence reports and from which
the output thread, ConvergenceOutputThread::writeASynchronous(),
retrieves those requests before writing the file data.
2022-12-13 08:14:05 -06:00
|
|
|
{
|
|
|
|
// Safe to call on all ranks, not just the I/O rank.
|
|
|
|
this->endConvergenceOutputThread();
|
2018-06-21 05:14:17 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
static void registerParameters()
|
|
|
|
{
|
|
|
|
ModelParameters::registerParameters();
|
|
|
|
SolverParameters::registerParameters();
|
|
|
|
TimeStepper::registerParameters();
|
|
|
|
|
2024-07-06 03:22:47 -05:00
|
|
|
Parameters::Register<Parameters::EnableTerminalOutput>
|
2024-04-04 02:51:37 -05:00
|
|
|
("Print high-level information about the simulation's progress to the terminal");
|
2024-07-06 03:22:47 -05:00
|
|
|
Parameters::Register<Parameters::EnableAdaptiveTimeStepping>
|
2024-04-04 02:51:37 -05:00
|
|
|
("Use adaptive time stepping between report steps");
|
2024-07-06 03:22:47 -05:00
|
|
|
Parameters::Register<Parameters::OutputExtraConvergenceInfo>
|
2024-04-04 02:51:37 -05:00
|
|
|
("Provide additional convergence output "
|
|
|
|
"files for diagnostic purposes. "
|
|
|
|
"\"none\" gives no extra output and "
|
|
|
|
"overrides all other options, "
|
|
|
|
"\"steps\" generates an INFOSTEP file, "
|
|
|
|
"\"iterations\" generates an INFOITER file. "
|
|
|
|
"Combine options with commas, e.g., "
|
|
|
|
"\"steps,iterations\" for multiple outputs.");
|
2024-07-06 03:22:47 -05:00
|
|
|
Parameters::Register<Parameters::SaveStep>
|
2024-04-04 02:51:37 -05:00
|
|
|
("Save serialized state to .OPMRST file. "
|
|
|
|
"Either a specific report step, \"all\" to save "
|
|
|
|
"all report steps or \":x\" to save every x'th step."
|
|
|
|
"Use negative values of \"x\" to keep only the last "
|
|
|
|
"written step, or \"last\" to save every step, keeping "
|
|
|
|
"only the last.");
|
2024-07-06 03:22:47 -05:00
|
|
|
Parameters::Register<Parameters::LoadStep>
|
2024-04-04 02:51:37 -05:00
|
|
|
("Load serialized state from .OPMRST file. "
|
|
|
|
"Either a specific report step, or 0 to load last "
|
|
|
|
"stored report step.");
|
2024-07-06 03:22:47 -05:00
|
|
|
Parameters::Register<Parameters::SaveFile>
|
2024-04-04 02:51:37 -05:00
|
|
|
("FileName for .OPMRST file used for saving serialized state. "
|
|
|
|
"If empty, CASENAME.OPMRST is used.");
|
2024-07-06 03:22:47 -05:00
|
|
|
Parameters::Hide<Parameters::SaveFile>();
|
|
|
|
Parameters::Register<Parameters::LoadFile>
|
2024-04-04 02:51:37 -05:00
|
|
|
("FileName for .OPMRST file used to load serialized state. "
|
|
|
|
"If empty, CASENAME.OPMRST is used.");
|
2024-07-06 03:22:47 -05:00
|
|
|
Parameters::Hide<Parameters::LoadFile>();
|
2016-07-12 11:47:52 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
/// Run the simulation.
|
|
|
|
/// This will run succesive timesteps until timer.done() is true. It will
|
|
|
|
/// modify the reservoir and well states.
|
|
|
|
/// \param[in,out] timer governs the requested reporting timesteps
|
|
|
|
/// \param[in,out] state state of reservoir: pressure, fluxes
|
|
|
|
/// \return simulation report, with timing data
|
2017-12-04 03:35:13 -06:00
|
|
|
SimulatorReport run(SimulatorTimer& timer)
|
Refactor SimulatorFullyImplicitBlackoilEbos.hpp
A resubmission of commit bb20804 in PR #2403 and PR #2442 to work with the
current master.
Continues the work in #2619 and #2631 to refactor main simulation loop in
flow to work with the Python bindings.
The run() method in SimulatorFullyImplicitBlackoilEbos.hpp is refactored
in preparation for the implementation of a Python step() function in a
later commit. Currently run() is called from runSimulatorInitOrRun() in
FlowMainEbos.hpp using the runSimulatorRunCallback_(). Later, there
will be other callbacks like runSimulatorStepInitCallback_(), and
runSimulatorStepCallback_(), that will need to call different parts of
the code in run(). The run() function is thus refactored into run(),
runInit(), runStep(), and runLastStep(). Also, some of the local
variables in run() have to be made persistent between calls to
runStep(), this applies to variables report, solverTimer, totalTimer,
and adaptiveTimeStepping, which are made private class variables.
2020-05-29 08:42:13 -05:00
|
|
|
{
|
2020-06-23 05:14:07 -05:00
|
|
|
init(timer);
|
2022-08-25 03:32:35 -05:00
|
|
|
// Make cache up to date. No need for updating it in elementCtx.
|
2024-08-27 08:51:56 -05:00
|
|
|
// NB! Need to be at the correct step in case of restart
|
|
|
|
simulator_.setEpisodeIndex(timer.currentStepNum());
|
2024-02-06 04:55:07 -06:00
|
|
|
simulator_.model().invalidateAndUpdateIntensiveQuantities(/*timeIdx=*/0);
|
Refactor SimulatorFullyImplicitBlackoilEbos.hpp
A resubmission of commit bb20804 in PR #2403 and PR #2442 to work with the
current master.
Continues the work in #2619 and #2631 to refactor main simulation loop in
flow to work with the Python bindings.
The run() method in SimulatorFullyImplicitBlackoilEbos.hpp is refactored
in preparation for the implementation of a Python step() function in a
later commit. Currently run() is called from runSimulatorInitOrRun() in
FlowMainEbos.hpp using the runSimulatorRunCallback_(). Later, there
will be other callbacks like runSimulatorStepInitCallback_(), and
runSimulatorStepCallback_(), that will need to call different parts of
the code in run(). The run() function is thus refactored into run(),
runInit(), runStep(), and runLastStep(). Also, some of the local
variables in run() have to be made persistent between calls to
runStep(), this applies to variables report, solverTimer, totalTimer,
and adaptiveTimeStepping, which are made private class variables.
2020-05-29 08:42:13 -05:00
|
|
|
// Main simulation loop.
|
|
|
|
while (!timer.done()) {
|
2024-09-23 07:03:53 -05:00
|
|
|
simulator_.problem().writeReports(timer);
|
2020-06-23 05:14:07 -05:00
|
|
|
bool continue_looping = runStep(timer);
|
|
|
|
if (!continue_looping) break;
|
Refactor SimulatorFullyImplicitBlackoilEbos.hpp
A resubmission of commit bb20804 in PR #2403 and PR #2442 to work with the
current master.
Continues the work in #2619 and #2631 to refactor main simulation loop in
flow to work with the Python bindings.
The run() method in SimulatorFullyImplicitBlackoilEbos.hpp is refactored
in preparation for the implementation of a Python step() function in a
later commit. Currently run() is called from runSimulatorInitOrRun() in
FlowMainEbos.hpp using the runSimulatorRunCallback_(). Later, there
will be other callbacks like runSimulatorStepInitCallback_(), and
runSimulatorStepCallback_(), that will need to call different parts of
the code in run(). The run() function is thus refactored into run(),
runInit(), runStep(), and runLastStep(). Also, some of the local
variables in run() have to be made persistent between calls to
runStep(), this applies to variables report, solverTimer, totalTimer,
and adaptiveTimeStepping, which are made private class variables.
2020-05-29 08:42:13 -05:00
|
|
|
}
|
2024-09-23 07:03:53 -05:00
|
|
|
simulator_.problem().writeReports(timer);
|
2020-06-23 05:14:07 -05:00
|
|
|
return finalize();
|
Refactor SimulatorFullyImplicitBlackoilEbos.hpp
A resubmission of commit bb20804 in PR #2403 and PR #2442 to work with the
current master.
Continues the work in #2619 and #2631 to refactor main simulation loop in
flow to work with the Python bindings.
The run() method in SimulatorFullyImplicitBlackoilEbos.hpp is refactored
in preparation for the implementation of a Python step() function in a
later commit. Currently run() is called from runSimulatorInitOrRun() in
FlowMainEbos.hpp using the runSimulatorRunCallback_(). Later, there
will be other callbacks like runSimulatorStepInitCallback_(), and
runSimulatorStepCallback_(), that will need to call different parts of
the code in run(). The run() function is thus refactored into run(),
runInit(), runStep(), and runLastStep(). Also, some of the local
variables in run() have to be made persistent between calls to
runStep(), this applies to variables report, solverTimer, totalTimer,
and adaptiveTimeStepping, which are made private class variables.
2020-05-29 08:42:13 -05:00
|
|
|
}
|
|
|
|
|
2020-06-23 05:14:07 -05:00
|
|
|
void init(SimulatorTimer &timer)
|
2016-07-12 11:47:52 -05:00
|
|
|
{
|
2024-02-06 04:55:07 -06:00
|
|
|
simulator_.setEpisodeIndex(-1);
|
2019-04-03 10:26:57 -05:00
|
|
|
|
2016-07-12 11:47:52 -05:00
|
|
|
// Create timers and file for writing timing info.
|
2021-05-05 04:22:44 -05:00
|
|
|
solverTimer_ = std::make_unique<time::StopWatch>();
|
|
|
|
totalTimer_ = std::make_unique<time::StopWatch>();
|
Refactor SimulatorFullyImplicitBlackoilEbos.hpp
A resubmission of commit bb20804 in PR #2403 and PR #2442 to work with the
current master.
Continues the work in #2619 and #2631 to refactor main simulation loop in
flow to work with the Python bindings.
The run() method in SimulatorFullyImplicitBlackoilEbos.hpp is refactored
in preparation for the implementation of a Python step() function in a
later commit. Currently run() is called from runSimulatorInitOrRun() in
FlowMainEbos.hpp using the runSimulatorRunCallback_(). Later, there
will be other callbacks like runSimulatorStepInitCallback_(), and
runSimulatorStepCallback_(), that will need to call different parts of
the code in run(). The run() function is thus refactored into run(),
runInit(), runStep(), and runLastStep(). Also, some of the local
variables in run() have to be made persistent between calls to
runStep(), this applies to variables report, solverTimer, totalTimer,
and adaptiveTimeStepping, which are made private class variables.
2020-05-29 08:42:13 -05:00
|
|
|
totalTimer_->start();
|
2016-07-12 11:47:52 -05:00
|
|
|
|
|
|
|
// adaptive time stepping
|
2024-07-06 03:22:47 -05:00
|
|
|
bool enableAdaptive = Parameters::Get<Parameters::EnableAdaptiveTimeStepping>();
|
2024-07-06 03:22:47 -05:00
|
|
|
bool enableTUNING = Parameters::Get<Parameters::EnableTuning>();
|
2018-06-21 05:14:17 -05:00
|
|
|
if (enableAdaptive) {
|
2024-02-06 04:55:07 -06:00
|
|
|
const UnitSystem& unitSystem = this->simulator_.vanguard().eclState().getUnits();
|
2024-02-19 12:14:13 -06:00
|
|
|
const auto& sched_state = schedule()[timer.currentStepNum()];
|
|
|
|
auto max_next_tstep = sched_state.max_next_tstep(enableTUNING);
|
2018-06-21 05:14:17 -05:00
|
|
|
if (enableTUNING) {
|
2021-10-18 04:52:33 -05:00
|
|
|
adaptiveTimeStepping_ = std::make_unique<TimeStepper>(max_next_tstep,
|
|
|
|
sched_state.tuning(),
|
2021-02-17 04:30:57 -06:00
|
|
|
unitSystem, terminalOutput_);
|
2017-01-13 11:58:05 -06:00
|
|
|
}
|
2018-06-06 03:59:41 -05:00
|
|
|
else {
|
2024-02-19 12:14:13 -06:00
|
|
|
adaptiveTimeStepping_ = std::make_unique<TimeStepper>(unitSystem, max_next_tstep, terminalOutput_);
|
2018-06-06 03:59:41 -05:00
|
|
|
}
|
|
|
|
|
2018-06-06 03:59:41 -05:00
|
|
|
if (isRestart()) {
|
2024-02-06 04:55:07 -06:00
|
|
|
// For restarts the simulator may have gotten some information
|
2019-10-01 07:30:11 -05:00
|
|
|
// about the next timestep size from the OPMEXTRA field
|
2024-02-06 04:55:07 -06:00
|
|
|
adaptiveTimeStepping_->setSuggestedNextStep(simulator_.timeStepSize());
|
2017-02-24 07:52:12 -06:00
|
|
|
}
|
2016-07-12 11:47:52 -05:00
|
|
|
}
|
Refactor SimulatorFullyImplicitBlackoilEbos.hpp
A resubmission of commit bb20804 in PR #2403 and PR #2442 to work with the
current master.
Continues the work in #2619 and #2631 to refactor main simulation loop in
flow to work with the Python bindings.
The run() method in SimulatorFullyImplicitBlackoilEbos.hpp is refactored
in preparation for the implementation of a Python step() function in a
later commit. Currently run() is called from runSimulatorInitOrRun() in
FlowMainEbos.hpp using the runSimulatorRunCallback_(). Later, there
will be other callbacks like runSimulatorStepInitCallback_(), and
runSimulatorStepCallback_(), that will need to call different parts of
the code in run(). The run() function is thus refactored into run(),
runInit(), runStep(), and runLastStep(). Also, some of the local
variables in run() have to be made persistent between calls to
runStep(), this applies to variables report, solverTimer, totalTimer,
and adaptiveTimeStepping, which are made private class variables.
2020-05-29 08:42:13 -05:00
|
|
|
}
|
2016-07-12 11:47:52 -05:00
|
|
|
|
2024-01-31 07:14:50 -06:00
|
|
|
void updateTUNING(const Tuning& tuning)
|
|
|
|
{
|
2023-05-12 06:09:32 -05:00
|
|
|
modelParam_.tolerance_mb_ = tuning.XXXMBE;
|
|
|
|
if (terminalOutput_) {
|
2024-01-31 07:14:50 -06:00
|
|
|
OpmLog::debug(fmt::format("Setting SimulatorFullyImplicitBlackoil mass balance limit (XXXMBE) to {:.2e}", tuning.XXXMBE));
|
2023-05-03 06:17:20 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
Refactor SimulatorFullyImplicitBlackoilEbos.hpp
A resubmission of commit bb20804 in PR #2403 and PR #2442 to work with the
current master.
Continues the work in #2619 and #2631 to refactor main simulation loop in
flow to work with the Python bindings.
The run() method in SimulatorFullyImplicitBlackoilEbos.hpp is refactored
in preparation for the implementation of a Python step() function in a
later commit. Currently run() is called from runSimulatorInitOrRun() in
FlowMainEbos.hpp using the runSimulatorRunCallback_(). Later, there
will be other callbacks like runSimulatorStepInitCallback_(), and
runSimulatorStepCallback_(), that will need to call different parts of
the code in run(). The run() function is thus refactored into run(),
runInit(), runStep(), and runLastStep(). Also, some of the local
variables in run() have to be made persistent between calls to
runStep(), this applies to variables report, solverTimer, totalTimer,
and adaptiveTimeStepping, which are made private class variables.
2020-05-29 08:42:13 -05:00
|
|
|
bool runStep(SimulatorTimer& timer)
|
|
|
|
{
|
|
|
|
if (schedule().exitStatus().has_value()) {
|
2018-06-06 03:59:41 -05:00
|
|
|
if (terminalOutput_) {
|
Refactor SimulatorFullyImplicitBlackoilEbos.hpp
A resubmission of commit bb20804 in PR #2403 and PR #2442 to work with the
current master.
Continues the work in #2619 and #2631 to refactor main simulation loop in
flow to work with the Python bindings.
The run() method in SimulatorFullyImplicitBlackoilEbos.hpp is refactored
in preparation for the implementation of a Python step() function in a
later commit. Currently run() is called from runSimulatorInitOrRun() in
FlowMainEbos.hpp using the runSimulatorRunCallback_(). Later, there
will be other callbacks like runSimulatorStepInitCallback_(), and
runSimulatorStepCallback_(), that will need to call different parts of
the code in run(). The run() function is thus refactored into run(),
runInit(), runStep(), and runLastStep(). Also, some of the local
variables in run() have to be made persistent between calls to
runStep(), this applies to variables report, solverTimer, totalTimer,
and adaptiveTimeStepping, which are made private class variables.
2020-05-29 08:42:13 -05:00
|
|
|
OpmLog::info("Stopping simulation since EXIT was triggered by an action keyword.");
|
2016-07-12 11:47:52 -05:00
|
|
|
}
|
Refactor SimulatorFullyImplicitBlackoilEbos.hpp
A resubmission of commit bb20804 in PR #2403 and PR #2442 to work with the
current master.
Continues the work in #2619 and #2631 to refactor main simulation loop in
flow to work with the Python bindings.
The run() method in SimulatorFullyImplicitBlackoilEbos.hpp is refactored
in preparation for the implementation of a Python step() function in a
later commit. Currently run() is called from runSimulatorInitOrRun() in
FlowMainEbos.hpp using the runSimulatorRunCallback_(). Later, there
will be other callbacks like runSimulatorStepInitCallback_(), and
runSimulatorStepCallback_(), that will need to call different parts of
the code in run(). The run() function is thus refactored into run(),
runInit(), runStep(), and runLastStep(). Also, some of the local
variables in run() have to be made persistent between calls to
runStep(), this applies to variables report, solverTimer, totalTimer,
and adaptiveTimeStepping, which are made private class variables.
2020-05-29 08:42:13 -05:00
|
|
|
report_.success.exit_status = schedule().exitStatus().value();
|
|
|
|
return false;
|
|
|
|
}
|
2016-07-12 11:47:52 -05:00
|
|
|
|
2023-08-23 02:25:09 -05:00
|
|
|
if (serializer_.shouldLoad()) {
|
|
|
|
serializer_.loadTimerInfo(timer);
|
2023-02-09 05:50:46 -06:00
|
|
|
}
|
|
|
|
|
Refactor SimulatorFullyImplicitBlackoilEbos.hpp
A resubmission of commit bb20804 in PR #2403 and PR #2442 to work with the
current master.
Continues the work in #2619 and #2631 to refactor main simulation loop in
flow to work with the Python bindings.
The run() method in SimulatorFullyImplicitBlackoilEbos.hpp is refactored
in preparation for the implementation of a Python step() function in a
later commit. Currently run() is called from runSimulatorInitOrRun() in
FlowMainEbos.hpp using the runSimulatorRunCallback_(). Later, there
will be other callbacks like runSimulatorStepInitCallback_(), and
runSimulatorStepCallback_(), that will need to call different parts of
the code in run(). The run() function is thus refactored into run(),
runInit(), runStep(), and runLastStep(). Also, some of the local
variables in run() have to be made persistent between calls to
runStep(), this applies to variables report, solverTimer, totalTimer,
and adaptiveTimeStepping, which are made private class variables.
2020-05-29 08:42:13 -05:00
|
|
|
// Report timestep.
|
|
|
|
if (terminalOutput_) {
|
|
|
|
std::ostringstream ss;
|
|
|
|
timer.report(ss);
|
|
|
|
OpmLog::debug(ss.str());
|
|
|
|
}
|
2019-05-11 07:13:26 -05:00
|
|
|
|
Refactor SimulatorFullyImplicitBlackoilEbos.hpp
A resubmission of commit bb20804 in PR #2403 and PR #2442 to work with the
current master.
Continues the work in #2619 and #2631 to refactor main simulation loop in
flow to work with the Python bindings.
The run() method in SimulatorFullyImplicitBlackoilEbos.hpp is refactored
in preparation for the implementation of a Python step() function in a
later commit. Currently run() is called from runSimulatorInitOrRun() in
FlowMainEbos.hpp using the runSimulatorRunCallback_(). Later, there
will be other callbacks like runSimulatorStepInitCallback_(), and
runSimulatorStepCallback_(), that will need to call different parts of
the code in run(). The run() function is thus refactored into run(),
runInit(), runStep(), and runLastStep(). Also, some of the local
variables in run() have to be made persistent between calls to
runStep(), this applies to variables report, solverTimer, totalTimer,
and adaptiveTimeStepping, which are made private class variables.
2020-05-29 08:42:13 -05:00
|
|
|
if (terminalOutput_) {
|
2024-02-02 01:41:35 -06:00
|
|
|
details::outputReportStep(timer);
|
Refactor SimulatorFullyImplicitBlackoilEbos.hpp
A resubmission of commit bb20804 in PR #2403 and PR #2442 to work with the
current master.
Continues the work in #2619 and #2631 to refactor main simulation loop in
flow to work with the Python bindings.
The run() method in SimulatorFullyImplicitBlackoilEbos.hpp is refactored
in preparation for the implementation of a Python step() function in a
later commit. Currently run() is called from runSimulatorInitOrRun() in
FlowMainEbos.hpp using the runSimulatorRunCallback_(). Later, there
will be other callbacks like runSimulatorStepInitCallback_(), and
runSimulatorStepCallback_(), that will need to call different parts of
the code in run(). The run() function is thus refactored into run(),
runInit(), runStep(), and runLastStep(). Also, some of the local
variables in run() have to be made persistent between calls to
runStep(), this applies to variables report, solverTimer, totalTimer,
and adaptiveTimeStepping, which are made private class variables.
2020-05-29 08:42:13 -05:00
|
|
|
}
|
2016-11-14 03:16:57 -06:00
|
|
|
|
Refactor SimulatorFullyImplicitBlackoilEbos.hpp
A resubmission of commit bb20804 in PR #2403 and PR #2442 to work with the
current master.
Continues the work in #2619 and #2631 to refactor main simulation loop in
flow to work with the Python bindings.
The run() method in SimulatorFullyImplicitBlackoilEbos.hpp is refactored
in preparation for the implementation of a Python step() function in a
later commit. Currently run() is called from runSimulatorInitOrRun() in
FlowMainEbos.hpp using the runSimulatorRunCallback_(). Later, there
will be other callbacks like runSimulatorStepInitCallback_(), and
runSimulatorStepCallback_(), that will need to call different parts of
the code in run(). The run() function is thus refactored into run(),
runInit(), runStep(), and runLastStep(). Also, some of the local
variables in run() have to be made persistent between calls to
runStep(), this applies to variables report, solverTimer, totalTimer,
and adaptiveTimeStepping, which are made private class variables.
2020-05-29 08:42:13 -05:00
|
|
|
// write the inital state at the report stage
|
|
|
|
if (timer.initialStep()) {
|
|
|
|
Dune::Timer perfTimer;
|
|
|
|
perfTimer.start();
|
2019-04-03 10:26:57 -05:00
|
|
|
|
2024-02-06 04:55:07 -06:00
|
|
|
simulator_.setEpisodeIndex(-1);
|
|
|
|
simulator_.setEpisodeLength(0.0);
|
|
|
|
simulator_.setTimeStepSize(0.0);
|
Refactor SimulatorFullyImplicitBlackoilEbos.hpp
A resubmission of commit bb20804 in PR #2403 and PR #2442 to work with the
current master.
Continues the work in #2619 and #2631 to refactor main simulation loop in
flow to work with the Python bindings.
The run() method in SimulatorFullyImplicitBlackoilEbos.hpp is refactored
in preparation for the implementation of a Python step() function in a
later commit. Currently run() is called from runSimulatorInitOrRun() in
FlowMainEbos.hpp using the runSimulatorRunCallback_(). Later, there
will be other callbacks like runSimulatorStepInitCallback_(), and
runSimulatorStepCallback_(), that will need to call different parts of
the code in run(). The run() function is thus refactored into run(),
runInit(), runStep(), and runLastStep(). Also, some of the local
variables in run() have to be made persistent between calls to
runStep(), this applies to variables report, solverTimer, totalTimer,
and adaptiveTimeStepping, which are made private class variables.
2020-05-29 08:42:13 -05:00
|
|
|
wellModel_().beginReportStep(timer.currentStepNum());
|
2024-10-01 16:31:24 -05:00
|
|
|
simulator_.problem().writeOutput(true);
|
2016-11-14 03:16:57 -06:00
|
|
|
|
Refactor SimulatorFullyImplicitBlackoilEbos.hpp
A resubmission of commit bb20804 in PR #2403 and PR #2442 to work with the
current master.
Continues the work in #2619 and #2631 to refactor main simulation loop in
flow to work with the Python bindings.
The run() method in SimulatorFullyImplicitBlackoilEbos.hpp is refactored
in preparation for the implementation of a Python step() function in a
later commit. Currently run() is called from runSimulatorInitOrRun() in
FlowMainEbos.hpp using the runSimulatorRunCallback_(). Later, there
will be other callbacks like runSimulatorStepInitCallback_(), and
runSimulatorStepCallback_(), that will need to call different parts of
the code in run(). The run() function is thus refactored into run(),
runInit(), runStep(), and runLastStep(). Also, some of the local
variables in run() have to be made persistent between calls to
runStep(), this applies to variables report, solverTimer, totalTimer,
and adaptiveTimeStepping, which are made private class variables.
2020-05-29 08:42:13 -05:00
|
|
|
report_.success.output_write_time += perfTimer.stop();
|
|
|
|
}
|
|
|
|
|
|
|
|
// Run a multiple steps of the solver depending on the time step control.
|
|
|
|
solverTimer_->start();
|
|
|
|
|
2023-06-14 02:20:25 -05:00
|
|
|
if (!solver_) {
|
|
|
|
solver_ = createSolver(wellModel_());
|
|
|
|
}
|
Refactor SimulatorFullyImplicitBlackoilEbos.hpp
A resubmission of commit bb20804 in PR #2403 and PR #2442 to work with the
current master.
Continues the work in #2619 and #2631 to refactor main simulation loop in
flow to work with the Python bindings.
The run() method in SimulatorFullyImplicitBlackoilEbos.hpp is refactored
in preparation for the implementation of a Python step() function in a
later commit. Currently run() is called from runSimulatorInitOrRun() in
FlowMainEbos.hpp using the runSimulatorRunCallback_(). Later, there
will be other callbacks like runSimulatorStepInitCallback_(), and
runSimulatorStepCallback_(), that will need to call different parts of
the code in run(). The run() function is thus refactored into run(),
runInit(), runStep(), and runLastStep(). Also, some of the local
variables in run() have to be made persistent between calls to
runStep(), this applies to variables report, solverTimer, totalTimer,
and adaptiveTimeStepping, which are made private class variables.
2020-05-29 08:42:13 -05:00
|
|
|
|
2024-02-06 04:55:07 -06:00
|
|
|
simulator_.startNextEpisode(
|
|
|
|
simulator_.startTime()
|
2021-02-22 11:43:56 -06:00
|
|
|
+ schedule().seconds(timer.currentStepNum()),
|
Refactor SimulatorFullyImplicitBlackoilEbos.hpp
A resubmission of commit bb20804 in PR #2403 and PR #2442 to work with the
current master.
Continues the work in #2619 and #2631 to refactor main simulation loop in
flow to work with the Python bindings.
The run() method in SimulatorFullyImplicitBlackoilEbos.hpp is refactored
in preparation for the implementation of a Python step() function in a
later commit. Currently run() is called from runSimulatorInitOrRun() in
FlowMainEbos.hpp using the runSimulatorRunCallback_(). Later, there
will be other callbacks like runSimulatorStepInitCallback_(), and
runSimulatorStepCallback_(), that will need to call different parts of
the code in run(). The run() function is thus refactored into run(),
runInit(), runStep(), and runLastStep(). Also, some of the local
variables in run() have to be made persistent between calls to
runStep(), this applies to variables report, solverTimer, totalTimer,
and adaptiveTimeStepping, which are made private class variables.
2020-05-29 08:42:13 -05:00
|
|
|
timer.currentStepLength());
|
2024-02-06 04:55:07 -06:00
|
|
|
simulator_.setEpisodeIndex(timer.currentStepNum());
|
2024-04-22 09:48:11 -05:00
|
|
|
|
2023-08-23 02:25:09 -05:00
|
|
|
if (serializer_.shouldLoad()) {
|
|
|
|
wellModel_().prepareDeserialize(serializer_.loadStep() - 1);
|
|
|
|
serializer_.loadState();
|
2024-02-06 04:55:07 -06:00
|
|
|
simulator_.model().invalidateAndUpdateIntensiveQuantities(/*timeIdx=*/0);
|
2023-02-09 05:50:46 -06:00
|
|
|
}
|
2024-04-22 09:48:11 -05:00
|
|
|
|
|
|
|
this->solver_->model().beginReportStep();
|
|
|
|
|
2024-07-06 03:22:47 -05:00
|
|
|
const bool enableTUNING = Parameters::Get<Parameters::EnableTuning>();
|
2017-11-21 04:12:16 -06:00
|
|
|
|
Refactor SimulatorFullyImplicitBlackoilEbos.hpp
A resubmission of commit bb20804 in PR #2403 and PR #2442 to work with the
current master.
Continues the work in #2619 and #2631 to refactor main simulation loop in
flow to work with the Python bindings.
The run() method in SimulatorFullyImplicitBlackoilEbos.hpp is refactored
in preparation for the implementation of a Python step() function in a
later commit. Currently run() is called from runSimulatorInitOrRun() in
FlowMainEbos.hpp using the runSimulatorRunCallback_(). Later, there
will be other callbacks like runSimulatorStepInitCallback_(), and
runSimulatorStepCallback_(), that will need to call different parts of
the code in run(). The run() function is thus refactored into run(),
runInit(), runStep(), and runLastStep(). Also, some of the local
variables in run() have to be made persistent between calls to
runStep(), this applies to variables report, solverTimer, totalTimer,
and adaptiveTimeStepping, which are made private class variables.
2020-05-29 08:42:13 -05:00
|
|
|
// If sub stepping is enabled allow the solver to sub cycle
|
|
|
|
// in case the report steps are too large for the solver to converge
|
|
|
|
//
|
|
|
|
// \Note: The report steps are met in any case
|
|
|
|
// \Note: The sub stepping will require a copy of the state variables
|
|
|
|
if (adaptiveTimeStepping_) {
|
2024-02-22 10:02:48 -06:00
|
|
|
auto tuningUpdater = [enableTUNING, this, reportStep = timer.currentStepNum()]()
|
|
|
|
{
|
2024-02-06 04:55:07 -06:00
|
|
|
auto& schedule = this->simulator_.vanguard().schedule();
|
2024-02-22 10:02:48 -06:00
|
|
|
auto& events = this->schedule()[reportStep].events();
|
|
|
|
|
|
|
|
if (events.hasEvent(ScheduleEvents::TUNING_CHANGE)) {
|
|
|
|
// Unset the event to not trigger it again on the next sub step
|
|
|
|
schedule.clear_event(ScheduleEvents::TUNING_CHANGE, reportStep);
|
|
|
|
const auto& sched_state = schedule[reportStep];
|
|
|
|
const auto& max_next_tstep = sched_state.max_next_tstep(enableTUNING);
|
2021-10-18 04:52:33 -05:00
|
|
|
const auto& tuning = sched_state.tuning();
|
2024-02-19 12:14:13 -06:00
|
|
|
|
2024-02-22 10:02:48 -06:00
|
|
|
if (enableTUNING) {
|
|
|
|
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);
|
|
|
|
} else {
|
|
|
|
this->adaptiveTimeStepping_->updateNEXTSTEP(max_next_tstep);
|
|
|
|
}
|
|
|
|
return max_next_tstep >0;
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
};
|
|
|
|
tuningUpdater();
|
|
|
|
const auto& events = schedule()[timer.currentStepNum()].events();
|
2021-01-10 14:46:45 -06:00
|
|
|
bool event = events.hasEvent(ScheduleEvents::NEW_WELL) ||
|
2021-04-16 06:38:56 -05:00
|
|
|
events.hasEvent(ScheduleEvents::INJECTION_TYPE_CHANGED) ||
|
|
|
|
events.hasEvent(ScheduleEvents::WELL_SWITCHED_INJECTOR_PRODUCER) ||
|
2023-08-08 05:19:36 -05:00
|
|
|
events.hasEvent(ScheduleEvents::PRODUCTION_UPDATE) ||
|
|
|
|
events.hasEvent(ScheduleEvents::INJECTION_UPDATE) ||
|
2021-01-10 14:46:45 -06:00
|
|
|
events.hasEvent(ScheduleEvents::WELL_STATUS_CHANGE);
|
2024-02-22 10:02:48 -06:00
|
|
|
auto stepReport = adaptiveTimeStepping_->step(timer, *solver_, event, nullptr, tuningUpdater);
|
Refactor SimulatorFullyImplicitBlackoilEbos.hpp
A resubmission of commit bb20804 in PR #2403 and PR #2442 to work with the
current master.
Continues the work in #2619 and #2631 to refactor main simulation loop in
flow to work with the Python bindings.
The run() method in SimulatorFullyImplicitBlackoilEbos.hpp is refactored
in preparation for the implementation of a Python step() function in a
later commit. Currently run() is called from runSimulatorInitOrRun() in
FlowMainEbos.hpp using the runSimulatorRunCallback_(). Later, there
will be other callbacks like runSimulatorStepInitCallback_(), and
runSimulatorStepCallback_(), that will need to call different parts of
the code in run(). The run() function is thus refactored into run(),
runInit(), runStep(), and runLastStep(). Also, some of the local
variables in run() have to be made persistent between calls to
runStep(), this applies to variables report, solverTimer, totalTimer,
and adaptiveTimeStepping, which are made private class variables.
2020-05-29 08:42:13 -05:00
|
|
|
report_ += stepReport;
|
2022-02-03 04:58:09 -06:00
|
|
|
//Pass simulation report to eclwriter for summary output
|
2024-02-06 04:55:07 -06:00
|
|
|
simulator_.problem().setSimulationReport(report_);
|
Refactor SimulatorFullyImplicitBlackoilEbos.hpp
A resubmission of commit bb20804 in PR #2403 and PR #2442 to work with the
current master.
Continues the work in #2619 and #2631 to refactor main simulation loop in
flow to work with the Python bindings.
The run() method in SimulatorFullyImplicitBlackoilEbos.hpp is refactored
in preparation for the implementation of a Python step() function in a
later commit. Currently run() is called from runSimulatorInitOrRun() in
FlowMainEbos.hpp using the runSimulatorRunCallback_(). Later, there
will be other callbacks like runSimulatorStepInitCallback_(), and
runSimulatorStepCallback_(), that will need to call different parts of
the code in run(). The run() function is thus refactored into run(),
runInit(), runStep(), and runLastStep(). Also, some of the local
variables in run() have to be made persistent between calls to
runStep(), this applies to variables report, solverTimer, totalTimer,
and adaptiveTimeStepping, which are made private class variables.
2020-05-29 08:42:13 -05:00
|
|
|
} else {
|
|
|
|
// solve for complete report step
|
2023-06-14 02:20:25 -05:00
|
|
|
auto stepReport = solver_->step(timer);
|
Refactor SimulatorFullyImplicitBlackoilEbos.hpp
A resubmission of commit bb20804 in PR #2403 and PR #2442 to work with the
current master.
Continues the work in #2619 and #2631 to refactor main simulation loop in
flow to work with the Python bindings.
The run() method in SimulatorFullyImplicitBlackoilEbos.hpp is refactored
in preparation for the implementation of a Python step() function in a
later commit. Currently run() is called from runSimulatorInitOrRun() in
FlowMainEbos.hpp using the runSimulatorRunCallback_(). Later, there
will be other callbacks like runSimulatorStepInitCallback_(), and
runSimulatorStepCallback_(), that will need to call different parts of
the code in run(). The run() function is thus refactored into run(),
runInit(), runStep(), and runLastStep(). Also, some of the local
variables in run() have to be made persistent between calls to
runStep(), this applies to variables report, solverTimer, totalTimer,
and adaptiveTimeStepping, which are made private class variables.
2020-05-29 08:42:13 -05:00
|
|
|
report_ += stepReport;
|
|
|
|
if (terminalOutput_) {
|
|
|
|
std::ostringstream ss;
|
|
|
|
stepReport.reportStep(ss);
|
|
|
|
OpmLog::info(ss.str());
|
|
|
|
}
|
|
|
|
}
|
2016-08-08 07:58:25 -05:00
|
|
|
|
Refactor SimulatorFullyImplicitBlackoilEbos.hpp
A resubmission of commit bb20804 in PR #2403 and PR #2442 to work with the
current master.
Continues the work in #2619 and #2631 to refactor main simulation loop in
flow to work with the Python bindings.
The run() method in SimulatorFullyImplicitBlackoilEbos.hpp is refactored
in preparation for the implementation of a Python step() function in a
later commit. Currently run() is called from runSimulatorInitOrRun() in
FlowMainEbos.hpp using the runSimulatorRunCallback_(). Later, there
will be other callbacks like runSimulatorStepInitCallback_(), and
runSimulatorStepCallback_(), that will need to call different parts of
the code in run(). The run() function is thus refactored into run(),
runInit(), runStep(), and runLastStep(). Also, some of the local
variables in run() have to be made persistent between calls to
runStep(), this applies to variables report, solverTimer, totalTimer,
and adaptiveTimeStepping, which are made private class variables.
2020-05-29 08:42:13 -05:00
|
|
|
// write simulation state at the report stage
|
|
|
|
Dune::Timer perfTimer;
|
|
|
|
perfTimer.start();
|
|
|
|
const double nextstep = adaptiveTimeStepping_ ? adaptiveTimeStepping_->suggestedNextStep() : -1.0;
|
2024-02-06 04:55:07 -06:00
|
|
|
simulator_.problem().setNextTimeStepSize(nextstep);
|
2024-10-01 16:31:24 -05:00
|
|
|
simulator_.problem().writeOutput(true);
|
Refactor SimulatorFullyImplicitBlackoilEbos.hpp
A resubmission of commit bb20804 in PR #2403 and PR #2442 to work with the
current master.
Continues the work in #2619 and #2631 to refactor main simulation loop in
flow to work with the Python bindings.
The run() method in SimulatorFullyImplicitBlackoilEbos.hpp is refactored
in preparation for the implementation of a Python step() function in a
later commit. Currently run() is called from runSimulatorInitOrRun() in
FlowMainEbos.hpp using the runSimulatorRunCallback_(). Later, there
will be other callbacks like runSimulatorStepInitCallback_(), and
runSimulatorStepCallback_(), that will need to call different parts of
the code in run(). The run() function is thus refactored into run(),
runInit(), runStep(), and runLastStep(). Also, some of the local
variables in run() have to be made persistent between calls to
runStep(), this applies to variables report, solverTimer, totalTimer,
and adaptiveTimeStepping, which are made private class variables.
2020-05-29 08:42:13 -05:00
|
|
|
report_.success.output_write_time += perfTimer.stop();
|
2016-07-12 11:47:52 -05:00
|
|
|
|
2023-06-14 02:20:25 -05:00
|
|
|
solver_->model().endReportStep();
|
2016-07-12 11:47:52 -05:00
|
|
|
|
Refactor SimulatorFullyImplicitBlackoilEbos.hpp
A resubmission of commit bb20804 in PR #2403 and PR #2442 to work with the
current master.
Continues the work in #2619 and #2631 to refactor main simulation loop in
flow to work with the Python bindings.
The run() method in SimulatorFullyImplicitBlackoilEbos.hpp is refactored
in preparation for the implementation of a Python step() function in a
later commit. Currently run() is called from runSimulatorInitOrRun() in
FlowMainEbos.hpp using the runSimulatorRunCallback_(). Later, there
will be other callbacks like runSimulatorStepInitCallback_(), and
runSimulatorStepCallback_(), that will need to call different parts of
the code in run(). The run() function is thus refactored into run(),
runInit(), runStep(), and runLastStep(). Also, some of the local
variables in run() have to be made persistent between calls to
runStep(), this applies to variables report, solverTimer, totalTimer,
and adaptiveTimeStepping, which are made private class variables.
2020-05-29 08:42:13 -05:00
|
|
|
// take time that was used to solve system for this reportStep
|
|
|
|
solverTimer_->stop();
|
2017-03-13 11:48:19 -05:00
|
|
|
|
Refactor SimulatorFullyImplicitBlackoilEbos.hpp
A resubmission of commit bb20804 in PR #2403 and PR #2442 to work with the
current master.
Continues the work in #2619 and #2631 to refactor main simulation loop in
flow to work with the Python bindings.
The run() method in SimulatorFullyImplicitBlackoilEbos.hpp is refactored
in preparation for the implementation of a Python step() function in a
later commit. Currently run() is called from runSimulatorInitOrRun() in
FlowMainEbos.hpp using the runSimulatorRunCallback_(). Later, there
will be other callbacks like runSimulatorStepInitCallback_(), and
runSimulatorStepCallback_(), that will need to call different parts of
the code in run(). The run() function is thus refactored into run(),
runInit(), runStep(), and runLastStep(). Also, some of the local
variables in run() have to be made persistent between calls to
runStep(), this applies to variables report, solverTimer, totalTimer,
and adaptiveTimeStepping, which are made private class variables.
2020-05-29 08:42:13 -05:00
|
|
|
// update timing.
|
|
|
|
report_.success.solver_time += solverTimer_->secsSinceStart();
|
2016-12-22 06:45:31 -06:00
|
|
|
|
Output Non-Linear Convergence to Separate File if Requested
This commit enables outputting non-linear convergence metrics, i.e.,
the MB and CNV values, per phase, for each non-linear iteration in
each timestep. If the user passes the option value "iterations" to
the --extra-convergence-output command line option, this commit will
create a new output file, CASE.INFOITER, that holds
* report step
* time step within that report step
* elapsed time
* MB and CNV values per phase
* well convergence status
for each non-linear iteration.
We use an asynchronous file writing procedure and confer ownership
of the report step's unprocessed convergence reports to this
procedure just before the end of
SimulatorFullyImplicitBlackoilEbos::runStep()
At that point, the convergence reports are about to go out of scope.
The asynchronous protocol uses a dedicated queue of output requests,
class ConvergenceReportQueue, into which the producer-i.e., member
function runStep()-inserts new convergence reports and from which
the output thread, ConvergenceOutputThread::writeASynchronous(),
retrieves those requests before writing the file data.
2022-12-13 08:14:05 -06:00
|
|
|
if (this->grid().comm().rank() == 0) {
|
2024-04-22 09:48:11 -05:00
|
|
|
// Grab the step convergence reports that are new since last we
|
|
|
|
// were here.
|
|
|
|
const auto& reps = this->solver_->model().stepReports();
|
|
|
|
|
|
|
|
auto reports = std::vector<StepReport> {
|
|
|
|
reps.begin() + this->already_reported_steps_, reps.end()
|
|
|
|
};
|
|
|
|
|
|
|
|
this->writeConvergenceOutput(std::move(reports));
|
|
|
|
|
|
|
|
this->already_reported_steps_ = reps.size();
|
Output Non-Linear Convergence to Separate File if Requested
This commit enables outputting non-linear convergence metrics, i.e.,
the MB and CNV values, per phase, for each non-linear iteration in
each timestep. If the user passes the option value "iterations" to
the --extra-convergence-output command line option, this commit will
create a new output file, CASE.INFOITER, that holds
* report step
* time step within that report step
* elapsed time
* MB and CNV values per phase
* well convergence status
for each non-linear iteration.
We use an asynchronous file writing procedure and confer ownership
of the report step's unprocessed convergence reports to this
procedure just before the end of
SimulatorFullyImplicitBlackoilEbos::runStep()
At that point, the convergence reports are about to go out of scope.
The asynchronous protocol uses a dedicated queue of output requests,
class ConvergenceReportQueue, into which the producer-i.e., member
function runStep()-inserts new convergence reports and from which
the output thread, ConvergenceOutputThread::writeASynchronous(),
retrieves those requests before writing the file data.
2022-12-13 08:14:05 -06:00
|
|
|
}
|
|
|
|
|
Refactor SimulatorFullyImplicitBlackoilEbos.hpp
A resubmission of commit bb20804 in PR #2403 and PR #2442 to work with the
current master.
Continues the work in #2619 and #2631 to refactor main simulation loop in
flow to work with the Python bindings.
The run() method in SimulatorFullyImplicitBlackoilEbos.hpp is refactored
in preparation for the implementation of a Python step() function in a
later commit. Currently run() is called from runSimulatorInitOrRun() in
FlowMainEbos.hpp using the runSimulatorRunCallback_(). Later, there
will be other callbacks like runSimulatorStepInitCallback_(), and
runSimulatorStepCallback_(), that will need to call different parts of
the code in run(). The run() function is thus refactored into run(),
runInit(), runStep(), and runLastStep(). Also, some of the local
variables in run() have to be made persistent between calls to
runStep(), this applies to variables report, solverTimer, totalTimer,
and adaptiveTimeStepping, which are made private class variables.
2020-05-29 08:42:13 -05:00
|
|
|
// Increment timer, remember well state.
|
|
|
|
++timer;
|
2023-12-15 05:18:34 -06:00
|
|
|
|
Refactor SimulatorFullyImplicitBlackoilEbos.hpp
A resubmission of commit bb20804 in PR #2403 and PR #2442 to work with the
current master.
Continues the work in #2619 and #2631 to refactor main simulation loop in
flow to work with the Python bindings.
The run() method in SimulatorFullyImplicitBlackoilEbos.hpp is refactored
in preparation for the implementation of a Python step() function in a
later commit. Currently run() is called from runSimulatorInitOrRun() in
FlowMainEbos.hpp using the runSimulatorRunCallback_(). Later, there
will be other callbacks like runSimulatorStepInitCallback_(), and
runSimulatorStepCallback_(), that will need to call different parts of
the code in run(). The run() function is thus refactored into run(),
runInit(), runStep(), and runLastStep(). Also, some of the local
variables in run() have to be made persistent between calls to
runStep(), this applies to variables report, solverTimer, totalTimer,
and adaptiveTimeStepping, which are made private class variables.
2020-05-29 08:42:13 -05:00
|
|
|
if (terminalOutput_) {
|
|
|
|
std::string msg =
|
|
|
|
"Time step took " + std::to_string(solverTimer_->secsSinceStart()) + " seconds; "
|
|
|
|
"total solver time " + std::to_string(report_.success.solver_time) + " seconds.";
|
|
|
|
OpmLog::debug(msg);
|
2016-07-12 11:47:52 -05:00
|
|
|
}
|
Output Non-Linear Convergence to Separate File if Requested
This commit enables outputting non-linear convergence metrics, i.e.,
the MB and CNV values, per phase, for each non-linear iteration in
each timestep. If the user passes the option value "iterations" to
the --extra-convergence-output command line option, this commit will
create a new output file, CASE.INFOITER, that holds
* report step
* time step within that report step
* elapsed time
* MB and CNV values per phase
* well convergence status
for each non-linear iteration.
We use an asynchronous file writing procedure and confer ownership
of the report step's unprocessed convergence reports to this
procedure just before the end of
SimulatorFullyImplicitBlackoilEbos::runStep()
At that point, the convergence reports are about to go out of scope.
The asynchronous protocol uses a dedicated queue of output requests,
class ConvergenceReportQueue, into which the producer-i.e., member
function runStep()-inserts new convergence reports and from which
the output thread, ConvergenceOutputThread::writeASynchronous(),
retrieves those requests before writing the file data.
2022-12-13 08:14:05 -06:00
|
|
|
|
2023-08-23 02:25:09 -05:00
|
|
|
serializer_.save(timer);
|
2023-02-09 05:50:46 -06:00
|
|
|
|
Refactor SimulatorFullyImplicitBlackoilEbos.hpp
A resubmission of commit bb20804 in PR #2403 and PR #2442 to work with the
current master.
Continues the work in #2619 and #2631 to refactor main simulation loop in
flow to work with the Python bindings.
The run() method in SimulatorFullyImplicitBlackoilEbos.hpp is refactored
in preparation for the implementation of a Python step() function in a
later commit. Currently run() is called from runSimulatorInitOrRun() in
FlowMainEbos.hpp using the runSimulatorRunCallback_(). Later, there
will be other callbacks like runSimulatorStepInitCallback_(), and
runSimulatorStepCallback_(), that will need to call different parts of
the code in run(). The run() function is thus refactored into run(),
runInit(), runStep(), and runLastStep(). Also, some of the local
variables in run() have to be made persistent between calls to
runStep(), this applies to variables report, solverTimer, totalTimer,
and adaptiveTimeStepping, which are made private class variables.
2020-05-29 08:42:13 -05:00
|
|
|
return true;
|
|
|
|
}
|
2016-07-12 11:47:52 -05:00
|
|
|
|
2020-06-23 05:14:07 -05:00
|
|
|
SimulatorReport finalize()
|
Refactor SimulatorFullyImplicitBlackoilEbos.hpp
A resubmission of commit bb20804 in PR #2403 and PR #2442 to work with the
current master.
Continues the work in #2619 and #2631 to refactor main simulation loop in
flow to work with the Python bindings.
The run() method in SimulatorFullyImplicitBlackoilEbos.hpp is refactored
in preparation for the implementation of a Python step() function in a
later commit. Currently run() is called from runSimulatorInitOrRun() in
FlowMainEbos.hpp using the runSimulatorRunCallback_(). Later, there
will be other callbacks like runSimulatorStepInitCallback_(), and
runSimulatorStepCallback_(), that will need to call different parts of
the code in run(). The run() function is thus refactored into run(),
runInit(), runStep(), and runLastStep(). Also, some of the local
variables in run() have to be made persistent between calls to
runStep(), this applies to variables report, solverTimer, totalTimer,
and adaptiveTimeStepping, which are made private class variables.
2020-05-29 08:42:13 -05:00
|
|
|
{
|
2020-02-07 07:37:02 -06:00
|
|
|
// make sure all output is written to disk before run is finished
|
|
|
|
{
|
|
|
|
Dune::Timer finalOutputTimer;
|
|
|
|
finalOutputTimer.start();
|
|
|
|
|
2024-02-06 04:55:07 -06:00
|
|
|
simulator_.problem().finalizeOutput();
|
Refactor SimulatorFullyImplicitBlackoilEbos.hpp
A resubmission of commit bb20804 in PR #2403 and PR #2442 to work with the
current master.
Continues the work in #2619 and #2631 to refactor main simulation loop in
flow to work with the Python bindings.
The run() method in SimulatorFullyImplicitBlackoilEbos.hpp is refactored
in preparation for the implementation of a Python step() function in a
later commit. Currently run() is called from runSimulatorInitOrRun() in
FlowMainEbos.hpp using the runSimulatorRunCallback_(). Later, there
will be other callbacks like runSimulatorStepInitCallback_(), and
runSimulatorStepCallback_(), that will need to call different parts of
the code in run(). The run() function is thus refactored into run(),
runInit(), runStep(), and runLastStep(). Also, some of the local
variables in run() have to be made persistent between calls to
runStep(), this applies to variables report, solverTimer, totalTimer,
and adaptiveTimeStepping, which are made private class variables.
2020-05-29 08:42:13 -05:00
|
|
|
report_.success.output_write_time += finalOutputTimer.stop();
|
2020-02-07 07:37:02 -06:00
|
|
|
}
|
|
|
|
|
2016-07-12 11:47:52 -05:00
|
|
|
// Stop timer and create timing report
|
Refactor SimulatorFullyImplicitBlackoilEbos.hpp
A resubmission of commit bb20804 in PR #2403 and PR #2442 to work with the
current master.
Continues the work in #2619 and #2631 to refactor main simulation loop in
flow to work with the Python bindings.
The run() method in SimulatorFullyImplicitBlackoilEbos.hpp is refactored
in preparation for the implementation of a Python step() function in a
later commit. Currently run() is called from runSimulatorInitOrRun() in
FlowMainEbos.hpp using the runSimulatorRunCallback_(). Later, there
will be other callbacks like runSimulatorStepInitCallback_(), and
runSimulatorStepCallback_(), that will need to call different parts of
the code in run(). The run() function is thus refactored into run(),
runInit(), runStep(), and runLastStep(). Also, some of the local
variables in run() have to be made persistent between calls to
runStep(), this applies to variables report, solverTimer, totalTimer,
and adaptiveTimeStepping, which are made private class variables.
2020-05-29 08:42:13 -05:00
|
|
|
totalTimer_->stop();
|
|
|
|
report_.success.total_time = totalTimer_->secsSinceStart();
|
|
|
|
report_.success.converged = true;
|
2017-12-04 15:26:53 -06:00
|
|
|
|
Refactor SimulatorFullyImplicitBlackoilEbos.hpp
A resubmission of commit bb20804 in PR #2403 and PR #2442 to work with the
current master.
Continues the work in #2619 and #2631 to refactor main simulation loop in
flow to work with the Python bindings.
The run() method in SimulatorFullyImplicitBlackoilEbos.hpp is refactored
in preparation for the implementation of a Python step() function in a
later commit. Currently run() is called from runSimulatorInitOrRun() in
FlowMainEbos.hpp using the runSimulatorRunCallback_(). Later, there
will be other callbacks like runSimulatorStepInitCallback_(), and
runSimulatorStepCallback_(), that will need to call different parts of
the code in run(). The run() function is thus refactored into run(),
runInit(), runStep(), and runLastStep(). Also, some of the local
variables in run() have to be made persistent between calls to
runStep(), this applies to variables report, solverTimer, totalTimer,
and adaptiveTimeStepping, which are made private class variables.
2020-05-29 08:42:13 -05:00
|
|
|
return report_;
|
2016-07-12 11:47:52 -05:00
|
|
|
}
|
|
|
|
|
2016-08-08 08:12:51 -05:00
|
|
|
const Grid& grid() const
|
2024-02-06 04:55:07 -06:00
|
|
|
{ return simulator_.vanguard().grid(); }
|
2016-08-08 08:12:51 -05:00
|
|
|
|
2023-02-09 04:17:28 -06:00
|
|
|
template<class Serializer>
|
|
|
|
void serializeOp(Serializer& serializer)
|
|
|
|
{
|
2024-02-06 04:55:07 -06:00
|
|
|
serializer(simulator_);
|
2023-02-09 04:17:28 -06:00
|
|
|
serializer(report_);
|
|
|
|
serializer(adaptiveTimeStepping_);
|
|
|
|
}
|
|
|
|
|
2023-06-14 02:20:25 -05:00
|
|
|
const Model& model() const
|
|
|
|
{ return solver_->model(); }
|
|
|
|
|
2016-07-12 11:47:52 -05:00
|
|
|
protected:
|
2023-08-23 02:25:09 -05:00
|
|
|
//! \brief Load simulator state from hdf5 serializer.
|
|
|
|
void loadState([[maybe_unused]] HDF5Serializer& serializer,
|
|
|
|
[[maybe_unused]] const std::string& groupName) override
|
|
|
|
{
|
|
|
|
#if HAVE_HDF5
|
|
|
|
serializer.read(*this, groupName, "simulator_data");
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
//! \brief Save simulator state using hdf5 serializer.
|
|
|
|
void saveState([[maybe_unused]] HDF5Serializer& serializer,
|
|
|
|
[[maybe_unused]] const std::string& groupName) const override
|
|
|
|
{
|
|
|
|
#if HAVE_HDF5
|
|
|
|
serializer.write(*this, groupName, "simulator_data");
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
//! \brief Returns header data
|
|
|
|
std::array<std::string,5> getHeader() const override
|
|
|
|
{
|
|
|
|
std::ostringstream str;
|
2024-07-05 07:43:19 -05:00
|
|
|
Parameters::printValues(str);
|
2023-08-23 02:25:09 -05:00
|
|
|
return {"OPM Flow",
|
|
|
|
moduleVersion(),
|
|
|
|
compileTimestamp(),
|
2024-02-06 04:55:07 -06:00
|
|
|
simulator_.vanguard().caseName(),
|
2023-08-23 02:25:09 -05:00
|
|
|
str.str()};
|
|
|
|
}
|
|
|
|
|
|
|
|
//! \brief Returns local-to-global cell mapping.
|
|
|
|
const std::vector<int>& getCellMapping() const override
|
|
|
|
{
|
2024-02-06 04:55:07 -06:00
|
|
|
return simulator_.vanguard().globalCell();
|
2023-08-23 02:25:09 -05:00
|
|
|
}
|
|
|
|
|
2016-07-12 11:47:52 -05:00
|
|
|
|
2018-10-25 09:47:00 -05:00
|
|
|
std::unique_ptr<Solver> createSolver(WellModel& wellModel)
|
2016-07-12 11:47:52 -05:00
|
|
|
{
|
2024-02-06 04:55:07 -06:00
|
|
|
auto model = std::make_unique<Model>(simulator_,
|
2020-09-02 08:35:39 -05:00
|
|
|
modelParam_,
|
|
|
|
wellModel,
|
|
|
|
terminalOutput_);
|
2016-07-12 11:47:52 -05:00
|
|
|
|
2023-10-23 08:55:51 -05:00
|
|
|
if (this->modelParam_.write_partitions_) {
|
|
|
|
const auto& iocfg = this->eclState().cfg().io();
|
|
|
|
|
|
|
|
const auto odir = iocfg.getOutputDir()
|
|
|
|
/ std::filesystem::path { "partition" }
|
|
|
|
/ iocfg.getBaseName();
|
|
|
|
|
|
|
|
if (this->grid().comm().rank() == 0) {
|
|
|
|
create_directories(odir);
|
|
|
|
}
|
|
|
|
|
|
|
|
this->grid().comm().barrier();
|
|
|
|
|
|
|
|
model->writePartitions(odir);
|
|
|
|
|
|
|
|
this->modelParam_.write_partitions_ = false;
|
|
|
|
}
|
|
|
|
|
2020-09-02 08:35:39 -05:00
|
|
|
return std::make_unique<Solver>(solverParam_, std::move(model));
|
2016-07-12 11:47:52 -05:00
|
|
|
}
|
|
|
|
|
2016-10-20 13:16:42 -05:00
|
|
|
const EclipseState& eclState() const
|
2024-02-06 04:55:07 -06:00
|
|
|
{ return simulator_.vanguard().eclState(); }
|
2016-07-12 11:47:52 -05:00
|
|
|
|
2017-10-29 15:06:19 -05:00
|
|
|
|
|
|
|
const Schedule& schedule() const
|
2024-02-06 04:55:07 -06:00
|
|
|
{ return simulator_.vanguard().schedule(); }
|
2017-10-29 15:06:19 -05:00
|
|
|
|
2018-06-06 03:59:41 -05:00
|
|
|
bool isRestart() const
|
|
|
|
{
|
|
|
|
const auto& initconfig = eclState().getInitConfig();
|
|
|
|
return initconfig.restartRequested();
|
|
|
|
}
|
2017-06-07 02:29:31 -05:00
|
|
|
|
2018-08-16 04:51:36 -05:00
|
|
|
WellModel& wellModel_()
|
2024-02-06 04:55:07 -06:00
|
|
|
{ return simulator_.problem().wellModel(); }
|
2018-08-16 04:51:36 -05:00
|
|
|
|
|
|
|
const WellModel& wellModel_() const
|
2024-02-06 04:55:07 -06:00
|
|
|
{ return simulator_.problem().wellModel(); }
|
2018-08-16 04:51:36 -05:00
|
|
|
|
Output Non-Linear Convergence to Separate File if Requested
This commit enables outputting non-linear convergence metrics, i.e.,
the MB and CNV values, per phase, for each non-linear iteration in
each timestep. If the user passes the option value "iterations" to
the --extra-convergence-output command line option, this commit will
create a new output file, CASE.INFOITER, that holds
* report step
* time step within that report step
* elapsed time
* MB and CNV values per phase
* well convergence status
for each non-linear iteration.
We use an asynchronous file writing procedure and confer ownership
of the report step's unprocessed convergence reports to this
procedure just before the end of
SimulatorFullyImplicitBlackoilEbos::runStep()
At that point, the convergence reports are about to go out of scope.
The asynchronous protocol uses a dedicated queue of output requests,
class ConvergenceReportQueue, into which the producer-i.e., member
function runStep()-inserts new convergence reports and from which
the output thread, ConvergenceOutputThread::writeASynchronous(),
retrieves those requests before writing the file data.
2022-12-13 08:14:05 -06:00
|
|
|
void startConvergenceOutputThread(std::string_view convOutputOptions,
|
|
|
|
std::string_view optionName)
|
|
|
|
{
|
|
|
|
const auto config = ConvergenceOutputConfiguration {
|
|
|
|
convOutputOptions, optionName
|
|
|
|
};
|
|
|
|
if (! config.want(ConvergenceOutputConfiguration::Option::Iterations)) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
auto getPhaseName = ConvergenceOutputThread::ComponentToPhaseName {
|
|
|
|
[compNames = typename Model::ComponentName{}](const int compIdx)
|
|
|
|
{ return std::string_view { compNames.name(compIdx) }; }
|
|
|
|
};
|
|
|
|
|
|
|
|
auto convertTime = ConvergenceOutputThread::ConvertToTimeUnits {
|
|
|
|
[usys = this->eclState().getUnits()](const double time)
|
|
|
|
{ return usys.from_si(UnitSystem::measure::time, time); }
|
|
|
|
};
|
|
|
|
|
|
|
|
this->convergenceOutputQueue_.emplace();
|
|
|
|
this->convergenceOutputObject_.emplace
|
|
|
|
(this->eclState().getIOConfig().getOutputDir(),
|
|
|
|
this->eclState().getIOConfig().getBaseName(),
|
|
|
|
std::move(getPhaseName),
|
|
|
|
std::move(convertTime),
|
|
|
|
config, *this->convergenceOutputQueue_);
|
|
|
|
|
|
|
|
this->convergenceOutputThread_
|
|
|
|
.emplace(&ConvergenceOutputThread::writeASynchronous,
|
|
|
|
&this->convergenceOutputObject_.value());
|
|
|
|
}
|
|
|
|
|
2023-03-01 06:40:54 -06:00
|
|
|
void writeConvergenceOutput(std::vector<StepReport>&& reports)
|
Output Non-Linear Convergence to Separate File if Requested
This commit enables outputting non-linear convergence metrics, i.e.,
the MB and CNV values, per phase, for each non-linear iteration in
each timestep. If the user passes the option value "iterations" to
the --extra-convergence-output command line option, this commit will
create a new output file, CASE.INFOITER, that holds
* report step
* time step within that report step
* elapsed time
* MB and CNV values per phase
* well convergence status
for each non-linear iteration.
We use an asynchronous file writing procedure and confer ownership
of the report step's unprocessed convergence reports to this
procedure just before the end of
SimulatorFullyImplicitBlackoilEbos::runStep()
At that point, the convergence reports are about to go out of scope.
The asynchronous protocol uses a dedicated queue of output requests,
class ConvergenceReportQueue, into which the producer-i.e., member
function runStep()-inserts new convergence reports and from which
the output thread, ConvergenceOutputThread::writeASynchronous(),
retrieves those requests before writing the file data.
2022-12-13 08:14:05 -06:00
|
|
|
{
|
|
|
|
if (! this->convergenceOutputThread_.has_value()) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
auto requests = std::vector<ConvergenceReportQueue::OutputRequest>{};
|
|
|
|
requests.reserve(reports.size());
|
|
|
|
|
|
|
|
for (auto&& report : reports) {
|
|
|
|
requests.push_back({ report.report_step, report.current_step, std::move(report.report) });
|
|
|
|
}
|
|
|
|
|
|
|
|
this->convergenceOutputQueue_->enqueue(std::move(requests));
|
|
|
|
}
|
|
|
|
|
|
|
|
void endConvergenceOutputThread()
|
|
|
|
{
|
|
|
|
if (! this->convergenceOutputThread_.has_value()) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
this->convergenceOutputQueue_->signalLastOutputRequest();
|
|
|
|
this->convergenceOutputThread_->join();
|
|
|
|
}
|
|
|
|
|
2016-07-12 11:47:52 -05:00
|
|
|
// Data.
|
2024-02-06 04:55:07 -06:00
|
|
|
Simulator& simulator_;
|
2017-04-10 08:55:30 -05:00
|
|
|
|
2018-06-06 03:59:41 -05:00
|
|
|
ModelParameters modelParam_;
|
2018-06-21 05:14:17 -05:00
|
|
|
SolverParameters solverParam_;
|
2016-07-12 11:47:52 -05:00
|
|
|
|
2023-06-14 02:20:25 -05:00
|
|
|
std::unique_ptr<Solver> solver_;
|
|
|
|
|
2016-07-12 11:47:52 -05:00
|
|
|
// Observed objects.
|
2017-06-16 06:52:51 -05:00
|
|
|
PhaseUsage phaseUsage_;
|
2016-07-12 11:47:52 -05:00
|
|
|
// Misc. data
|
2018-06-21 05:14:17 -05:00
|
|
|
bool terminalOutput_;
|
Refactor SimulatorFullyImplicitBlackoilEbos.hpp
A resubmission of commit bb20804 in PR #2403 and PR #2442 to work with the
current master.
Continues the work in #2619 and #2631 to refactor main simulation loop in
flow to work with the Python bindings.
The run() method in SimulatorFullyImplicitBlackoilEbos.hpp is refactored
in preparation for the implementation of a Python step() function in a
later commit. Currently run() is called from runSimulatorInitOrRun() in
FlowMainEbos.hpp using the runSimulatorRunCallback_(). Later, there
will be other callbacks like runSimulatorStepInitCallback_(), and
runSimulatorStepCallback_(), that will need to call different parts of
the code in run(). The run() function is thus refactored into run(),
runInit(), runStep(), and runLastStep(). Also, some of the local
variables in run() have to be made persistent between calls to
runStep(), this applies to variables report, solverTimer, totalTimer,
and adaptiveTimeStepping, which are made private class variables.
2020-05-29 08:42:13 -05:00
|
|
|
|
|
|
|
SimulatorReport report_;
|
2023-06-14 02:20:25 -05:00
|
|
|
std::size_t already_reported_steps_ = 0;
|
2021-05-05 04:22:44 -05:00
|
|
|
std::unique_ptr<time::StopWatch> solverTimer_;
|
|
|
|
std::unique_ptr<time::StopWatch> totalTimer_;
|
Refactor SimulatorFullyImplicitBlackoilEbos.hpp
A resubmission of commit bb20804 in PR #2403 and PR #2442 to work with the
current master.
Continues the work in #2619 and #2631 to refactor main simulation loop in
flow to work with the Python bindings.
The run() method in SimulatorFullyImplicitBlackoilEbos.hpp is refactored
in preparation for the implementation of a Python step() function in a
later commit. Currently run() is called from runSimulatorInitOrRun() in
FlowMainEbos.hpp using the runSimulatorRunCallback_(). Later, there
will be other callbacks like runSimulatorStepInitCallback_(), and
runSimulatorStepCallback_(), that will need to call different parts of
the code in run(). The run() function is thus refactored into run(),
runInit(), runStep(), and runLastStep(). Also, some of the local
variables in run() have to be made persistent between calls to
runStep(), this applies to variables report, solverTimer, totalTimer,
and adaptiveTimeStepping, which are made private class variables.
2020-05-29 08:42:13 -05:00
|
|
|
std::unique_ptr<TimeStepper> adaptiveTimeStepping_;
|
Output Non-Linear Convergence to Separate File if Requested
This commit enables outputting non-linear convergence metrics, i.e.,
the MB and CNV values, per phase, for each non-linear iteration in
each timestep. If the user passes the option value "iterations" to
the --extra-convergence-output command line option, this commit will
create a new output file, CASE.INFOITER, that holds
* report step
* time step within that report step
* elapsed time
* MB and CNV values per phase
* well convergence status
for each non-linear iteration.
We use an asynchronous file writing procedure and confer ownership
of the report step's unprocessed convergence reports to this
procedure just before the end of
SimulatorFullyImplicitBlackoilEbos::runStep()
At that point, the convergence reports are about to go out of scope.
The asynchronous protocol uses a dedicated queue of output requests,
class ConvergenceReportQueue, into which the producer-i.e., member
function runStep()-inserts new convergence reports and from which
the output thread, ConvergenceOutputThread::writeASynchronous(),
retrieves those requests before writing the file data.
2022-12-13 08:14:05 -06:00
|
|
|
|
|
|
|
std::optional<ConvergenceReportQueue> convergenceOutputQueue_{};
|
|
|
|
std::optional<ConvergenceOutputThread> convergenceOutputObject_{};
|
|
|
|
std::optional<std::thread> convergenceOutputThread_{};
|
2023-02-09 05:50:46 -06:00
|
|
|
|
2023-08-23 02:25:09 -05:00
|
|
|
SimulatorSerializer serializer_;
|
2016-06-06 08:40:06 -05:00
|
|
|
};
|
|
|
|
|
|
|
|
} // namespace Opm
|
|
|
|
|
2024-01-31 07:14:50 -06:00
|
|
|
#endif // OPM_SIMULATOR_FULLY_IMPLICIT_BLACKOIL_HEADER_INCLUDED
|