2012-02-26 14:05:19 -06:00
|
|
|
/*
|
|
|
|
Copyright 2012 SINTEF ICT, Applied Mathematics.
|
|
|
|
|
|
|
|
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/>.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef OPM_MISCUTILITIES_HEADER_INCLUDED
|
|
|
|
#define OPM_MISCUTILITIES_HEADER_INCLUDED
|
|
|
|
|
|
|
|
#include <vector>
|
2012-03-14 06:47:01 -05:00
|
|
|
#include <iosfwd>
|
2012-02-26 14:05:19 -06:00
|
|
|
|
2012-03-14 03:51:08 -05:00
|
|
|
struct Wells;
|
|
|
|
struct UnstructuredGrid;
|
2012-02-26 14:05:19 -06:00
|
|
|
|
|
|
|
namespace Opm
|
|
|
|
{
|
|
|
|
|
2012-03-14 03:51:08 -05:00
|
|
|
class IncompPropertiesInterface;
|
2012-05-15 05:50:02 -05:00
|
|
|
class BlackoilPropertiesInterface;
|
2012-03-20 04:31:32 -05:00
|
|
|
class RockCompressibility;
|
2012-03-14 03:51:08 -05:00
|
|
|
|
2012-02-26 14:05:19 -06:00
|
|
|
/// @brief Computes pore volume of all cells in a grid.
|
|
|
|
/// @param[in] grid a grid
|
2012-05-14 14:47:10 -05:00
|
|
|
/// @param[in] porosity array of grid.number_of_cells porosity values
|
2012-02-26 14:05:19 -06:00
|
|
|
/// @param[out] porevol the pore volume by cell.
|
|
|
|
void computePorevolume(const UnstructuredGrid& grid,
|
2012-05-14 14:47:10 -05:00
|
|
|
const double* porosity,
|
2012-02-26 14:05:19 -06:00
|
|
|
std::vector<double>& porevol);
|
|
|
|
|
|
|
|
|
2012-03-20 04:31:32 -05:00
|
|
|
/// @brief Computes pore volume of all cells in a grid, with rock compressibility effects.
|
|
|
|
/// @param[in] grid a grid
|
2012-09-03 04:29:48 -05:00
|
|
|
/// @param[in] porosity array of grid.number_of_cells porosity values (at reference pressure)
|
2012-03-20 04:31:32 -05:00
|
|
|
/// @param[in] rock_comp rock compressibility properties
|
|
|
|
/// @param[in] pressure pressure by cell
|
|
|
|
/// @param[out] porevol the pore volume by cell.
|
|
|
|
void computePorevolume(const UnstructuredGrid& grid,
|
2012-05-14 14:47:10 -05:00
|
|
|
const double* porosity,
|
2012-03-20 04:31:32 -05:00
|
|
|
const RockCompressibility& rock_comp,
|
|
|
|
const std::vector<double>& pressure,
|
|
|
|
std::vector<double>& porevol);
|
|
|
|
|
2012-08-29 03:54:21 -05:00
|
|
|
/// @brief Computes porosity of all cells in a grid, with rock compressibility effects.
|
|
|
|
/// @param[in] grid a grid
|
2012-09-03 05:26:22 -05:00
|
|
|
/// @param[in] porosity_standard array of grid.number_of_cells porosity values (at reference presure)
|
2012-08-29 03:54:21 -05:00
|
|
|
/// @param[in] rock_comp rock compressibility properties
|
|
|
|
/// @param[in] pressure pressure by cell
|
|
|
|
/// @param[out] porosity porosity (at reservoir condition)
|
|
|
|
void computePorosity(const UnstructuredGrid& grid,
|
|
|
|
const double* porosity_standard,
|
|
|
|
const RockCompressibility& rock_comp,
|
|
|
|
const std::vector<double>& pressure,
|
|
|
|
std::vector<double>& porosity);
|
2012-03-20 04:31:32 -05:00
|
|
|
|
2012-03-13 09:56:52 -05:00
|
|
|
/// @brief Computes total saturated volumes over all grid cells.
|
2012-03-14 07:46:21 -05:00
|
|
|
/// @param[in] pv the pore volume by cell.
|
2012-03-13 09:56:52 -05:00
|
|
|
/// @param[in] s saturation values (for all P phases)
|
|
|
|
/// @param[out] sat_vol must point to a valid array with P elements,
|
|
|
|
/// where P = s.size()/pv.size().
|
|
|
|
/// For each phase p, we compute
|
|
|
|
/// sat_vol_p = sum_i s_p_i pv_i
|
|
|
|
void computeSaturatedVol(const std::vector<double>& pv,
|
|
|
|
const std::vector<double>& s,
|
|
|
|
double* sat_vol);
|
|
|
|
|
|
|
|
|
2012-03-09 04:44:21 -06:00
|
|
|
/// @brief Computes average saturations over all grid cells.
|
2012-03-14 07:46:21 -05:00
|
|
|
/// @param[in] pv the pore volume by cell.
|
2012-03-09 04:44:21 -06:00
|
|
|
/// @param[in] s saturation values (for all P phases)
|
|
|
|
/// @param[out] aver_sat must point to a valid array with P elements,
|
|
|
|
/// where P = s.size()/pv.size().
|
|
|
|
/// For each phase p, we compute
|
|
|
|
/// aver_sat_p = (sum_i s_p_i pv_i) / (sum_i pv_i).
|
|
|
|
void computeAverageSat(const std::vector<double>& pv,
|
|
|
|
const std::vector<double>& s,
|
|
|
|
double* aver_sat);
|
|
|
|
|
|
|
|
|
2012-03-13 09:56:52 -05:00
|
|
|
/// @brief Computes injected and produced volumes of all phases.
|
|
|
|
/// Note 1: assumes that only the first phase is injected.
|
|
|
|
/// Note 2: assumes that transport has been done with an
|
|
|
|
/// implicit method, i.e. that the current state
|
|
|
|
/// gives the mobilities used for the preceding timestep.
|
|
|
|
/// @param[in] props fluid and rock properties.
|
|
|
|
/// @param[in] s saturation values (for all P phases)
|
|
|
|
/// @param[in] src if < 0: total outflow, if > 0: first phase inflow.
|
|
|
|
/// @param[in] dt timestep used
|
|
|
|
/// @param[out] injected must point to a valid array with P elements,
|
|
|
|
/// where P = s.size()/src.size().
|
|
|
|
/// @param[out] produced must also point to a valid array with P elements.
|
|
|
|
void computeInjectedProduced(const IncompPropertiesInterface& props,
|
|
|
|
const std::vector<double>& s,
|
|
|
|
const std::vector<double>& src,
|
|
|
|
const double dt,
|
|
|
|
double* injected,
|
|
|
|
double* produced);
|
|
|
|
|
2012-02-26 14:05:19 -06:00
|
|
|
/// @brief Computes total mobility for a set of saturation values.
|
|
|
|
/// @param[in] props rock and fluid properties
|
2012-03-06 08:10:21 -06:00
|
|
|
/// @param[in] cells cells with which the saturation values are associated
|
2012-02-26 14:05:19 -06:00
|
|
|
/// @param[in] s saturation values (for all phases)
|
|
|
|
/// @param[out] totmob total mobilities.
|
|
|
|
void computeTotalMobility(const Opm::IncompPropertiesInterface& props,
|
|
|
|
const std::vector<int>& cells,
|
|
|
|
const std::vector<double>& s,
|
|
|
|
std::vector<double>& totmob);
|
|
|
|
|
|
|
|
/// @brief Computes total mobility and omega for a set of saturation values.
|
|
|
|
/// @param[in] props rock and fluid properties
|
2012-03-06 08:10:21 -06:00
|
|
|
/// @param[in] cells cells with which the saturation values are associated
|
2012-02-26 14:05:19 -06:00
|
|
|
/// @param[in] s saturation values (for all phases)
|
|
|
|
/// @param[out] totmob total mobility
|
2012-03-20 08:21:22 -05:00
|
|
|
/// @param[out] omega fractional-flow weighted fluid densities.
|
2012-02-26 14:05:19 -06:00
|
|
|
void computeTotalMobilityOmega(const Opm::IncompPropertiesInterface& props,
|
|
|
|
const std::vector<int>& cells,
|
|
|
|
const std::vector<double>& s,
|
|
|
|
std::vector<double>& totmob,
|
|
|
|
std::vector<double>& omega);
|
|
|
|
|
2012-03-13 18:00:15 -05:00
|
|
|
|
2012-03-20 04:13:27 -05:00
|
|
|
/// @brief Computes phase mobilities for a set of saturation values.
|
|
|
|
/// @param[in] props rock and fluid properties
|
|
|
|
/// @param[in] cells cells with which the saturation values are associated
|
|
|
|
/// @param[in] s saturation values (for all phases)
|
|
|
|
/// @param[out] pmobc phase mobilities (for all phases).
|
2012-03-12 10:03:29 -05:00
|
|
|
void computePhaseMobilities(const Opm::IncompPropertiesInterface& props,
|
|
|
|
const std::vector<int>& cells,
|
|
|
|
const std::vector<double>& s ,
|
|
|
|
std::vector<double>& pmobc);
|
2013-07-28 06:34:13 -05:00
|
|
|
|
2012-05-08 04:04:15 -05:00
|
|
|
|
|
|
|
/// Computes the fractional flow for each cell in the cells argument
|
|
|
|
/// @param[in] props rock and fluid properties
|
|
|
|
/// @param[in] cells cells with which the saturation values are associated
|
|
|
|
/// @param[in] saturations saturation values (for all phases)
|
|
|
|
/// @param[out] fractional_flow the fractional flow for each phase for each cell.
|
|
|
|
void computeFractionalFlow(const Opm::IncompPropertiesInterface& props,
|
|
|
|
const std::vector<int>& cells,
|
|
|
|
const std::vector<double>& saturations,
|
|
|
|
std::vector<double>& fractional_flows);
|
2012-03-12 10:03:29 -05:00
|
|
|
|
2012-03-13 18:00:15 -05:00
|
|
|
|
2012-03-12 07:00:48 -05:00
|
|
|
/// Compute two-phase transport source terms from face fluxes,
|
|
|
|
/// and pressure equation source terms. This puts boundary flows
|
|
|
|
/// into the source terms for the transport equation.
|
|
|
|
/// \param[in] grid The grid used.
|
|
|
|
/// \param[in] src Pressure eq. source terms. The sign convention is:
|
|
|
|
/// (+) positive total inflow (positive velocity divergence)
|
|
|
|
/// (-) negative total outflow
|
|
|
|
/// \param[in] faceflux Signed face fluxes, typically the result from a flow solver.
|
2012-04-24 08:15:36 -05:00
|
|
|
/// \param[in] inflow_frac Fraction of inflow (boundary and source terms) that consists of first phase.
|
2012-03-12 07:00:48 -05:00
|
|
|
/// Example: if only water is injected, inflow_frac == 1.0.
|
|
|
|
/// Note: it is not possible (with this method) to use different fractions
|
|
|
|
/// for different inflow sources, be they source terms of boundary flows.
|
2012-04-24 08:15:36 -05:00
|
|
|
/// \param[in] wells Wells data structure, or null if no wells.
|
|
|
|
/// \param[in] well_perfrates Volumetric flow rates per well perforation.
|
2012-03-12 07:00:48 -05:00
|
|
|
/// \param[out] transport_src The transport source terms. They are to be interpreted depending on sign:
|
|
|
|
/// (+) positive inflow of first phase (water)
|
|
|
|
/// (-) negative total outflow of both phases
|
|
|
|
void computeTransportSource(const UnstructuredGrid& grid,
|
|
|
|
const std::vector<double>& src,
|
|
|
|
const std::vector<double>& faceflux,
|
|
|
|
const double inflow_frac,
|
2012-04-24 08:15:36 -05:00
|
|
|
const Wells* wells,
|
|
|
|
const std::vector<double>& well_perfrates,
|
2012-03-12 07:00:48 -05:00
|
|
|
std::vector<double>& transport_src);
|
|
|
|
|
2012-03-13 18:00:15 -05:00
|
|
|
|
2012-02-26 14:05:19 -06:00
|
|
|
/// @brief Estimates a scalar cell velocity from face fluxes.
|
|
|
|
/// @param[in] grid a grid
|
|
|
|
/// @param[in] face_flux signed per-face fluxes
|
|
|
|
/// @param[out] cell_velocity the estimated velocities.
|
|
|
|
void estimateCellVelocity(const UnstructuredGrid& grid,
|
|
|
|
const std::vector<double>& face_flux,
|
|
|
|
std::vector<double>& cell_velocity);
|
|
|
|
|
|
|
|
/// Extract a vector of water saturations from a vector of
|
|
|
|
/// interleaved water and oil saturations.
|
|
|
|
void toWaterSat(const std::vector<double>& sboth,
|
|
|
|
std::vector<double>& sw);
|
|
|
|
|
2012-03-13 09:56:52 -05:00
|
|
|
/// Make a vector of interleaved water and oil saturations from
|
2012-02-26 14:05:19 -06:00
|
|
|
/// a vector of water saturations.
|
|
|
|
void toBothSat(const std::vector<double>& sw,
|
|
|
|
std::vector<double>& sboth);
|
|
|
|
|
2012-03-14 03:51:08 -05:00
|
|
|
/// Create a src vector equivalent to a wells structure.
|
|
|
|
/// For this to be valid, the wells must be all rate-controlled and
|
|
|
|
/// single-perforation.
|
|
|
|
void wellsToSrc(const Wells& wells, const int num_cells, std::vector<double>& src);
|
2013-07-28 06:34:13 -05:00
|
|
|
|
2012-04-16 04:39:16 -05:00
|
|
|
/// Computes the WDP for each well.
|
|
|
|
/// \param[in] wells Wells that need their wdp calculated.
|
|
|
|
/// \param[in] grid The associated grid to make cell lookups.
|
2013-07-28 06:34:13 -05:00
|
|
|
/// \param[in] saturations A vector of weights for each cell for each phase
|
|
|
|
/// in the grid (or well, see per_grid_cell parameter). So for cell i,
|
2012-04-16 04:39:16 -05:00
|
|
|
/// saturations[i*densities.size() + p] should give the weight
|
|
|
|
/// of phase p in cell i.
|
|
|
|
/// \param[in] densities Density for each phase.
|
|
|
|
/// \param[out] wdp Will contain, for each well, the wdp of the well.
|
2013-07-28 06:34:13 -05:00
|
|
|
/// \param[in] per_grid_cell Whether or not the saturations are per grid cell or per
|
2012-04-17 02:19:06 -05:00
|
|
|
/// well cell.
|
2012-04-12 10:50:51 -05:00
|
|
|
void computeWDP(const Wells& wells, const UnstructuredGrid& grid, const std::vector<double>& saturations,
|
2012-04-25 05:37:30 -05:00
|
|
|
const double* densities, const double gravity, const bool per_grid_cell,
|
|
|
|
std::vector<double>& wdp);
|
2013-07-28 06:34:13 -05:00
|
|
|
|
|
|
|
/// Computes (sums) the flow rate for each well.
|
2012-04-16 04:39:16 -05:00
|
|
|
/// \param[in] wells The wells for which the flow rate should be computed.
|
2013-07-28 06:34:13 -05:00
|
|
|
/// \param[in] flow_rates_per_cell Flow rates per well cells. Should ordered the same way as
|
2012-04-16 04:39:16 -05:00
|
|
|
/// wells.
|
|
|
|
/// \param[out] flow_rates_per_well Will contain the summed up flow_rates for each well.
|
2012-04-13 07:22:44 -05:00
|
|
|
void computeFlowRatePerWell(const Wells& wells, const std::vector<double>& flow_rates_per_cell,
|
|
|
|
std::vector<double>& flow_rates_per_well);
|
2013-07-28 06:34:13 -05:00
|
|
|
|
2012-05-08 04:04:15 -05:00
|
|
|
/// Computes the phase flow rate per well
|
|
|
|
/// \param[in] wells The wells for which the flow rate should be computed
|
2012-05-08 05:23:58 -05:00
|
|
|
/// \param[in] flow_rates_per_well_cell The total flow rate for each cell (ordered the same
|
2012-05-08 04:04:15 -05:00
|
|
|
/// way as the wells struct
|
|
|
|
/// \param[in] fractional_flows the fractional flow for each cell in each well
|
|
|
|
/// \param[out] phase_flow_per_well Will contain the phase flow per well
|
2013-07-28 06:34:13 -05:00
|
|
|
void computePhaseFlowRatesPerWell(const Wells& wells,
|
2012-05-08 05:23:58 -05:00
|
|
|
const std::vector<double>& flow_rates_per_well_cell,
|
2012-05-08 04:04:15 -05:00
|
|
|
const std::vector<double>& fractional_flows,
|
2012-05-08 05:23:58 -05:00
|
|
|
std::vector<double>& phase_flow_per_well);
|
2013-07-28 06:34:13 -05:00
|
|
|
|
|
|
|
|
2013-09-24 07:39:41 -05:00
|
|
|
|
|
|
|
|
2013-09-24 07:14:54 -05:00
|
|
|
/// A simple flow reporting utility, encapsulating the watercut curves.
|
|
|
|
///
|
|
|
|
/// Typically call push() after every timestep to build up report,
|
|
|
|
/// then call write() to write report as a matrix with times in the
|
|
|
|
/// first columns, water cut in the second column and cumulative
|
|
|
|
/// production in the last column. Units used will be the same as
|
|
|
|
/// is passed in, no conversion is done.
|
2012-03-14 06:47:01 -05:00
|
|
|
class Watercut
|
|
|
|
{
|
|
|
|
public:
|
2013-09-24 07:14:54 -05:00
|
|
|
/// Add a report point.
|
2013-09-24 07:39:41 -05:00
|
|
|
/// \param[in] time current time in the simulation
|
|
|
|
/// \param[in] fraction current water cut
|
|
|
|
/// \param[in] produced current total cumulative production
|
2012-03-14 06:47:01 -05:00
|
|
|
void push(double time, double fraction, double produced);
|
2013-09-24 07:14:54 -05:00
|
|
|
/// Write report to a stream.
|
2013-09-24 07:39:41 -05:00
|
|
|
/// \param[in, out] os output stream
|
2012-03-14 06:47:01 -05:00
|
|
|
void write(std::ostream& os) const;
|
|
|
|
private:
|
|
|
|
std::vector<double> data_;
|
|
|
|
};
|
2012-03-14 03:51:08 -05:00
|
|
|
|
2013-09-24 07:39:41 -05:00
|
|
|
|
|
|
|
|
|
|
|
|
2012-04-25 04:00:33 -05:00
|
|
|
/// Well reporting utility.
|
2013-09-24 07:14:54 -05:00
|
|
|
///
|
|
|
|
/// This class will store, for each call to push(), the following:
|
|
|
|
/// - the time parameter that was passed to push()
|
|
|
|
/// - for each well:
|
|
|
|
/// - bottom hole pressure in bars
|
|
|
|
/// - the well total rate in cubic meters per day
|
|
|
|
/// - the water cut (water rate / total rate)
|
|
|
|
///
|
|
|
|
/// The method write() will write these data to a stream, as a
|
|
|
|
/// matrix with time in the first column, bhp, rate and watercut
|
|
|
|
/// of the first well in the second through fourth columns and so
|
|
|
|
/// on.
|
2012-04-25 04:00:33 -05:00
|
|
|
class WellReport
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
/// Add a report point.
|
2013-09-24 07:39:41 -05:00
|
|
|
/// \param[in] props fluid and rock properties
|
|
|
|
/// \param[in] wells well configuration
|
|
|
|
/// \param[in] saturation saturations by cell and phase
|
|
|
|
/// \param[in] time current simulation time
|
|
|
|
/// \param[in] well_bhp bhp values of each well
|
|
|
|
/// \param[in] well_perfrates total flow at each well perforation
|
2012-04-25 04:00:33 -05:00
|
|
|
void push(const IncompPropertiesInterface& props,
|
|
|
|
const Wells& wells,
|
|
|
|
const std::vector<double>& saturation,
|
|
|
|
const double time,
|
|
|
|
const std::vector<double>& well_bhp,
|
|
|
|
const std::vector<double>& well_perfrates);
|
2012-05-15 05:50:02 -05:00
|
|
|
/// Add a report point (compressible fluids).
|
2013-09-24 07:39:41 -05:00
|
|
|
/// \param[in] props fluid and rock properties
|
|
|
|
/// \param[in] wells well configuration
|
|
|
|
/// \param[in] p pressure by cell
|
|
|
|
/// \param[in] z surface volumes by cell and component
|
|
|
|
/// \param[in] s saturations by cell and phase
|
|
|
|
/// \param[in] time current simulation time
|
|
|
|
/// \param[in] well_bhp bhp values of each well
|
|
|
|
/// \param[in] well_perfrates total flow at each well perforation
|
2012-05-15 05:50:02 -05:00
|
|
|
void push(const BlackoilPropertiesInterface& props,
|
|
|
|
const Wells& wells,
|
|
|
|
const std::vector<double>& p,
|
|
|
|
const std::vector<double>& z,
|
|
|
|
const std::vector<double>& s,
|
|
|
|
const double time,
|
|
|
|
const std::vector<double>& well_bhp,
|
|
|
|
const std::vector<double>& well_perfrates);
|
2012-04-25 04:00:33 -05:00
|
|
|
/// Write report to a stream.
|
2013-09-24 07:39:41 -05:00
|
|
|
/// \param[in, out] os output stream
|
2012-04-25 04:00:33 -05:00
|
|
|
void write(std::ostream& os) const;
|
|
|
|
private:
|
|
|
|
std::vector<std::vector<double> > data_;
|
|
|
|
};
|
|
|
|
|
2012-02-26 14:05:19 -06:00
|
|
|
} // namespace Opm
|
|
|
|
|
|
|
|
#endif // OPM_MISCUTILITIES_HEADER_INCLUDED
|