diff --git a/opm/autodiff/BlackoilModelEbos.hpp b/opm/autodiff/BlackoilModelEbos.hpp index 84a294ca7..d3b3d7a4c 100644 --- a/opm/autodiff/BlackoilModelEbos.hpp +++ b/opm/autodiff/BlackoilModelEbos.hpp @@ -42,6 +42,7 @@ #include #include #include +#include #include #include @@ -138,6 +139,10 @@ namespace Opm { typedef ISTLSolver< MatrixBlockType, VectorBlockType > ISTLSolverType; //typedef typename SolutionVector :: value_type PrimaryVariables ; + // For the conversion between the surface volume rate and resrevoir voidage rate + using RateConverterType = RateConverter:: + SurfaceToReservoirVoidage >; + struct FIPData { enum FipId { FIP_AQUA = Opm::Water, @@ -187,6 +192,7 @@ namespace Opm { , param_( param ) , well_model_ (well_model) , terminal_output_ (terminal_output) + , rate_converter_(fluid_.phaseUsage(), fluid_.cellPvtRegionIndex(), AutoDiffGrid::numCells(grid_), std::vector(AutoDiffGrid::numCells(grid_),0)) , current_relaxation_(1.0) , dx_old_(AutoDiffGrid::numCells(grid_)) , isBeginReportStep_(false) @@ -1229,6 +1235,9 @@ namespace Opm { /// \brief The number of cells of the global grid. long int global_nc_; + // rate converter between the surface volume rates and reservoir voidage rates + RateConverterType rate_converter_; + std::vector> residual_norms_history_; double current_relaxation_; BVector dx_old_; @@ -1429,6 +1438,33 @@ namespace Opm { } + void updateRateConverter(const ReservoirState& reservoir_state) + { + const int nw = numWells(); + int global_number_wells = nw; + +#if HAVE_MPI + if ( istlSolver_->parallelInformation().type() == typeid(ParallelISTLInformation) ) + { + const auto& info = + boost::any_cast(istlSolver_->parallelInformation()); + global_number_wells = info.communicator().sum(global_number_wells); + if ( global_number_wells ) + { + rate_converter_.defineState(reservoir_state, boost::any_cast(istlSolver_->parallelInformation())); + } + } + else +#endif + { + if ( global_number_wells ) + { + rate_converter_.defineState(reservoir_state); + } + } + } + + public: void beginReportStep() {