opm-simulators
Opm::SimulatorFullyImplicit< TypeTag > Class Template Reference

Top-level driver for a fully implicit flow simulation. More...

#include <SimulatorFullyImplicit.hpp>

Inheritance diagram for Opm::SimulatorFullyImplicit< TypeTag >:
Opm::SerializableSim

Public Types

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 >
 
using AquiferModel = GetPropType< TypeTag, Properties::AquiferModel >
 
using Model = GetPropType< TypeTag, Properties::NonlinearSystem >
 
using Scalar = GetPropType< TypeTag, Properties::Scalar >
 
using TimeStepper = AdaptiveTimeStepping< TypeTag >
 
using PolymerModule = BlackOilPolymerModule< TypeTag, enablePolymer >
 
using BioeffectsModule = BlackOilBioeffectsModule< TypeTag, enableBioeffects >
 
using Solver = NonlinearSolver< TypeTag, Model >
 
using ModelParameters = typename Model::ModelParameters
 
using SolverParameters = typename Solver::SolverParameters
 
using WellModel = GetPropType< TypeTag, Properties::WellModel >
 

Public Member Functions

 SimulatorFullyImplicit (Simulator &simulator)
 Construct from the surrounding eWoms Simulator. More...
 
 ~SimulatorFullyImplicit () override
 Ends the convergence-output thread cleanly on all ranks.
 
SimulatorReport run (SimulatorTimer &timer)
 Run the entire simulation to completion. More...
 
void init (const SimulatorTimer &timer)
 One-shot setup performed before the first runStep. More...
 
void updateTUNING (const Tuning &tuning)
 Apply a TUNING keyword to the cached model parameters. More...
 
void updateTUNINGDP (const TuningDp &tuning_dp)
 Apply a TUNINGDP keyword to the cached model parameters. More...
 
bool runStep (SimulatorTimer &timer)
 Advance the simulation by one report step. More...
 
SimulatorReport finalize ()
 Stop the timers and emit the final OPMRST output. More...
 
const Grid & grid () const
 
template<class Serializer >
void serializeOp (Serializer &serializer)
 Serialize the parts of this class needed for OPMRST round-tripping (the surrounding simulator state, the report, and the adaptive time stepper). More...
 
const Model & model () const
 

Static Public Member Functions

static void registerParameters ()
 Register all parameters consumed by this class and its major collaborators. More...
 

Static Public Attributes

static constexpr bool enablePolymer = getPropValue<TypeTag, Properties::EnablePolymer>()
 
static constexpr bool enableBioeffects = getPropValue<TypeTag, Properties::EnableBioeffects>()
 

Protected Member Functions

void loadState (HDF5Serializer &serializer, const std::string &groupName) override
 Load this simulator's data block from an OPMRST file via HDF5.
 
void saveState (HDF5Serializer &serializer, const std::string &groupName) const override
 Save this simulator's data block to an OPMRST file via HDF5.
 
std::array< std::string, 5 > getHeader () const override
 Return the OPMRST header tuple: product name, module version, compile timestamp, deck case name, and parameter dump. More...
 
const std::vector< int > & getCellMapping () const override
 Local-to-global cell index mapping.
 
std::unique_ptr< SolvercreateSolver (WellModel &wellModel)
 Build the Solver used during the current report step. More...
 
const EclipseState & eclState () const
 
const Schedule & schedule () const
 
bool isRestart () const
 
WellModel & wellModel_ ()
 
const WellModel & wellModel_ () const
 

Protected Attributes

Simulator & simulator_
 Surrounding eWoms simulator; observed, not owned.
 
ModelParameters modelParam_
 Cached model parameters; mutated by TUNING / TUNINGDP application.
 
SolverParameters solverParam_
 Cached nonlinear-solver parameters.
 
std::unique_ptr< Solversolver_
 Built lazily on the first runStep call; reused thereafter.
 
bool terminalOutput_
 Emit high-level progress to std::cout (rank 0 only).
 
SimulatorReport report_
 Aggregated report across the entire simulation.
 
std::unique_ptr< time::StopWatch > solverTimer_
 Wall-clock for the current report step's solve.
 
std::unique_ptr< time::StopWatch > totalTimer_
 Wall-clock for the entire simulation.
 
std::unique_ptr< TimeStepperadaptiveTimeStepping_
 Set iff adaptive time stepping is enabled.
 
SimulatorConvergenceOutput convergence_output_ {}
 Background thread for INFOSTEP / INFOITER files.
 
SimulatorSerializer serializer_
 OPMRST save / load.
 

Detailed Description

template<class TypeTag>
class Opm::SimulatorFullyImplicit< TypeTag >

Top-level driver for a fully implicit flow simulation.

Owns the per-report-step loop: run repeatedly invokes runStep until timer.done() is reached. Each runStep covers one report step (the interval between dates in the deck SCHEDULE), either as a single Solver::step call or, when adaptive time stepping is enabled (the default), by delegating the substep loop to AdaptiveTimeStepping::step.

Beyond the report-step loop, this class owns:

  • the NonlinearSolver, constructed lazily on the first runStep call;
  • per-report-step TUNING / TUNINGDP application via updateTUNING and updateTUNINGDP;
  • the WCYCLE-aware tuning-update callback handed to AdaptiveTimeStepping;
  • simulation report aggregation and wall-clock timing;
  • the convergence-output thread lifecycle (INFOSTEP / INFOITER);
  • OPMRST save/load via SimulatorSerializer;
  • reservoir-coupling master/slave bring-up and shutdown when RESERVOIR_COUPLING_ENABLED is set.

The class is instantiated once per simulation process. Static configuration is registered via registerParameters during program startup.

Constructor & Destructor Documentation

◆ SimulatorFullyImplicit()

template<class TypeTag >
Opm::SimulatorFullyImplicit< TypeTag >::SimulatorFullyImplicit ( Simulator &  simulator)
explicit

Construct from the surrounding eWoms Simulator.

Initialises the OPMRST serializer from the SaveStep / LoadStep / SaveFile / LoadFile parameters and, on rank 0 with terminal output enabled, starts the background convergence-output thread that writes INFOSTEP / INFOITER files.

Parameters
simulatorThe surrounding eWoms simulator; observed, not owned.

Member Function Documentation

◆ createSolver()

template<class TypeTag >
std::unique_ptr< typename SimulatorFullyImplicit< TypeTag >::Solver > Opm::SimulatorFullyImplicit< TypeTag >::createSolver ( WellModel &  wellModel)
protected

Build the Solver used during the current report step.

Wraps a freshly constructed Model in a Solver. Side effect: if write_partitions is set in the model parameters, the partition layout is written under <output_dir>/partition/<case> on the first call only — the flag is cleared after, so subsequent calls skip the dump.

◆ finalize()

template<class TypeTag >
SimulatorReport Opm::SimulatorFullyImplicit< TypeTag >::finalize ( )

Stop the timers and emit the final OPMRST output.

Called by run after the report-step loop finishes. Stops the total wall-clock timer and marks the report as converged.

Returns
The final aggregated simulation report.

◆ getHeader()

template<class TypeTag >
std::array< std::string, 5 > Opm::SimulatorFullyImplicit< TypeTag >::getHeader ( ) const
overrideprotectedvirtual

Return the OPMRST header tuple: product name, module version, compile timestamp, deck case name, and parameter dump.

Implements Opm::SerializableSim.

◆ init()

template<class TypeTag >
void Opm::SimulatorFullyImplicit< TypeTag >::init ( const SimulatorTimer timer)

One-shot setup performed before the first runStep.

Constructs the wall-clock timers and the AdaptiveTimeStepping instance (if adaptive stepping is enabled). For restart runs, the suggested next step is seeded from Simulator::timeStepSize().

Parameters
timerReport-step timer; only its current step is read here.

◆ registerParameters()

template<class TypeTag >
void Opm::SimulatorFullyImplicit< TypeTag >::registerParameters ( )
static

Register all parameters consumed by this class and its major collaborators.

Forwards to ModelParameters::registerParameters, SolverParameters::registerParameters, AdaptiveTimeStepping::registerParameters, Opm::detail::registerSimulatorParameters, and the TPSA Newton-method / linear-solver parameter sets. Called once during program startup.

◆ run()

template<class TypeTag >
SimulatorReport Opm::SimulatorFullyImplicit< TypeTag >::run ( SimulatorTimer timer)

Run the entire simulation to completion.

Loops over report steps, calling runStep on each one. Stops early if the schedule triggers an EXIT keyword.

Parameters
timerOuter report-step timer; advanced once per report step.
Returns
Aggregated simulation report (timing + per-step data).

◆ runStep()

template<class TypeTag >
bool Opm::SimulatorFullyImplicit< TypeTag >::runStep ( SimulatorTimer timer)

Advance the simulation by one report step.

Called by run once per report step. Performs:

  • early exit if the schedule requested EXIT;
  • OPMRST state load on the chosen restart step;
  • first-step init-state output;
  • lazy construction of the Solver;
  • construction and dispatch of the WCYCLE / TUNING / TUNINGDP tuning-update callback consumed by AdaptiveTimeStepping;
  • the actual solve, either via AdaptiveTimeStepping::step (substep loop) or a single Solver::step call;
  • end-of-step report output and OPMRST save.
Parameters
timerReport-step timer; advanced by one report step on success.
Returns
false to terminate the outer run loop (e.g. EXIT keyword); true to continue with the next report step.

◆ serializeOp()

template<class TypeTag >
template<class Serializer >
void Opm::SimulatorFullyImplicit< TypeTag >::serializeOp ( Serializer &  serializer)

Serialize the parts of this class needed for OPMRST round-tripping (the surrounding simulator state, the report, and the adaptive time stepper).

◆ updateTUNING()

template<class TypeTag >
void Opm::SimulatorFullyImplicit< TypeTag >::updateTUNING ( const Tuning &  tuning)

Apply a TUNING keyword to the cached model parameters.

Overwrites convergence tolerances (TRGCNV / XXXCNV / TRGMBE / XXXMBE) and Newton iteration limits (NEWTMX / NEWTMN) on the ModelParameters copy held by this class. Items that are recognised by the parser but not honoured by this simulator are logged at warning level on rank 0.

Note
This method only updates the copy held here. The same TUNING data is forwarded separately to the model held by the solver and to AdaptiveTimeStepping by the tuning-update callback in runStep.

◆ updateTUNINGDP()

template<class TypeTag >
void Opm::SimulatorFullyImplicit< TypeTag >::updateTUNINGDP ( const TuningDp &  tuning_dp)

Apply a TUNINGDP keyword to the cached model parameters.

Overwrites the maximum allowed pressure (TRGDDP), saturation (TRGDDS), and dissolved-gas / vaporised-oil ratio (TRGDDRS, TRGDDRV) changes per Newton iteration. TRGLCV / XXXLCV are accepted by the parser but logged as unsupported on rank 0.


The documentation for this class was generated from the following files: