2012-02-20 06:23:01 -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_INCOMPTPFA_HEADER_INCLUDED
|
|
|
|
#define OPM_INCOMPTPFA_HEADER_INCLUDED
|
|
|
|
|
|
|
|
|
|
|
|
#include <vector>
|
|
|
|
|
|
|
|
struct UnstructuredGrid;
|
|
|
|
struct ifs_tpfa_data;
|
2012-04-10 07:47:29 -05:00
|
|
|
struct Wells;
|
2012-03-07 02:32:56 -06:00
|
|
|
struct FlowBoundaryConditions;
|
2012-02-20 06:23:01 -06:00
|
|
|
|
|
|
|
namespace Opm
|
|
|
|
{
|
|
|
|
|
2012-02-21 14:45:04 -06:00
|
|
|
class LinearSolverInterface;
|
|
|
|
|
2012-05-11 06:02:48 -05:00
|
|
|
/// Encapsulating a tpfa pressure solver for the incompressible-fluid case.
|
|
|
|
/// Supports gravity, wells controlled by bhp or reservoir rates,
|
2012-05-11 08:10:02 -05:00
|
|
|
/// boundary conditions and simple sources as driving forces.
|
2012-05-11 06:02:48 -05:00
|
|
|
/// Rock compressibility can be included, but any nonlinear iterations
|
2012-05-11 08:10:02 -05:00
|
|
|
/// are not handled in this class.
|
2012-02-20 06:23:01 -06:00
|
|
|
/// Below we use the shortcuts D for the number of dimensions, N
|
|
|
|
/// for the number of cells and F for the number of faces.
|
|
|
|
class IncompTpfa
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
/// Construct solver.
|
|
|
|
/// \param[in] g A 2d or 3d grid.
|
|
|
|
/// \param[in] permeability Array of permeability tensors, the array
|
|
|
|
/// should have size N*D^2, if D == g.dimensions
|
|
|
|
/// and N == g.number_of_cells.
|
|
|
|
/// \param[in] gravity Gravity vector. If nonzero, the array should
|
|
|
|
/// have D elements.
|
2012-05-30 08:09:57 -05:00
|
|
|
/// \param[in] linsolver A linear solver.
|
2012-04-10 07:47:29 -05:00
|
|
|
/// \param[in] wells The wells argument. Will be used in solution,
|
|
|
|
/// is ignored if NULL
|
2012-02-20 06:23:01 -06:00
|
|
|
IncompTpfa(const UnstructuredGrid& g,
|
|
|
|
const double* permeability,
|
2012-02-21 14:45:04 -06:00
|
|
|
const double* gravity,
|
2012-06-06 08:14:46 -05:00
|
|
|
LinearSolverInterface& linsolver,
|
2012-06-07 06:34:05 -05:00
|
|
|
const Wells* wells);
|
2012-02-20 06:23:01 -06:00
|
|
|
|
|
|
|
/// Destructor.
|
|
|
|
~IncompTpfa();
|
|
|
|
|
2012-03-19 05:52:03 -05:00
|
|
|
/// Assemble and solve incompressible pressure system.
|
2012-02-20 06:23:01 -06:00
|
|
|
/// \param[in] totmob Must contain N total mobility values (one per cell).
|
2012-04-12 11:13:57 -05:00
|
|
|
/// \f$totmob = \sum_{p} kr_p/mu_p\f$.
|
2012-02-20 06:39:40 -06:00
|
|
|
/// \param[in] omega Must be empty if constructor gravity argument was null.
|
|
|
|
/// Otherwise must contain N mobility-weighted density values (one per cell).
|
2012-04-12 11:13:57 -05:00
|
|
|
/// \f$omega = \frac{\sum_{p} mob_p rho_p}{\sum_p rho_p}\f$.
|
2012-02-20 06:39:40 -06:00
|
|
|
/// \param[in] src Must contain N source rates (one per cell).
|
2012-02-20 06:23:01 -06:00
|
|
|
/// Positive values represent total inflow rates,
|
|
|
|
/// negative values represent total outflow rates.
|
2012-05-30 08:09:57 -05:00
|
|
|
/// \param[in] wdp Should contain the differences between
|
|
|
|
/// well BHP and perforation pressures.
|
|
|
|
/// May be empty if there are no wells.
|
2012-03-07 02:32:56 -06:00
|
|
|
/// \param[in] bcs If non-null, specifies boundary conditions.
|
|
|
|
/// If null, noflow conditions are assumed.
|
2012-02-20 06:23:01 -06:00
|
|
|
/// \param[out] pressure Will contain N cell-pressure values.
|
|
|
|
/// \param[out] faceflux Will contain F signed face flux values.
|
2012-04-12 09:36:08 -05:00
|
|
|
/// \param[out] well_bhp Will contain bhp values for each well passed
|
|
|
|
/// in the constructor
|
|
|
|
/// \param[out] well_rate Will contain rate values for each well passed
|
|
|
|
/// in the constructor
|
2012-02-20 06:23:01 -06:00
|
|
|
void solve(const std::vector<double>& totmob,
|
|
|
|
const std::vector<double>& omega,
|
|
|
|
const std::vector<double>& src,
|
2012-04-12 11:47:06 -05:00
|
|
|
const std::vector<double>& wdp,
|
2012-03-07 02:32:56 -06:00
|
|
|
const FlowBoundaryConditions* bcs,
|
2012-02-20 06:23:01 -06:00
|
|
|
std::vector<double>& pressure,
|
2012-04-12 09:36:08 -05:00
|
|
|
std::vector<double>& faceflux,
|
|
|
|
std::vector<double>& well_bhp,
|
|
|
|
std::vector<double>& well_rate);
|
2012-02-20 06:23:01 -06:00
|
|
|
|
2012-03-19 05:52:03 -05:00
|
|
|
/// Assemble and solve pressure system with rock compressibility (assumed constant per cell).
|
|
|
|
/// \param[in] totmob Must contain N total mobility values (one per cell).
|
|
|
|
/// totmob = \sum_{p} kr_p/mu_p.
|
|
|
|
/// \param[in] omega Must be empty if constructor gravity argument was null.
|
2012-03-20 08:21:22 -05:00
|
|
|
/// Otherwise must contain N fractional-flow-weighted density
|
|
|
|
/// values (one per cell).
|
|
|
|
/// omega = \frac{\sum_{p} mob_p rho_p}{\sum_p mob_p}.
|
2012-03-19 05:52:03 -05:00
|
|
|
/// \param[in] src Must contain N source rates (one per cell).
|
|
|
|
/// Positive values represent total inflow rates,
|
|
|
|
/// negative values represent total outflow rates.
|
2012-05-30 08:09:57 -05:00
|
|
|
/// \param[in] wdp Should contain the differences between
|
|
|
|
/// well BHP and perforation pressures.
|
|
|
|
/// May be empty if there are no wells.
|
2012-03-19 05:52:03 -05:00
|
|
|
/// \param[in] bcs If non-null, specifies boundary conditions.
|
|
|
|
/// If null, noflow conditions are assumed.
|
|
|
|
/// \param[in] porevol Must contain N pore volumes.
|
|
|
|
/// \param[in] rock_comp Must contain N rock compressibilities.
|
|
|
|
/// rock_comp = (d poro / d p)*(1/poro).
|
|
|
|
/// \param[in] dt Timestep.
|
|
|
|
/// \param[out] pressure Will contain N cell-pressure values.
|
|
|
|
/// \param[out] faceflux Will contain F signed face flux values.
|
2012-04-12 09:36:08 -05:00
|
|
|
/// \param[out] well_bhp Will contain bhp values for each well passed
|
|
|
|
/// in the constructor
|
|
|
|
/// \param[out] well_rate Will contain rate values for each well passed
|
|
|
|
/// in the constructor
|
2012-03-19 05:52:03 -05:00
|
|
|
void solve(const std::vector<double>& totmob,
|
|
|
|
const std::vector<double>& omega,
|
|
|
|
const std::vector<double>& src,
|
2012-04-12 11:47:06 -05:00
|
|
|
const std::vector<double>& wdp,
|
2012-03-19 05:52:03 -05:00
|
|
|
const FlowBoundaryConditions* bcs,
|
|
|
|
const std::vector<double>& porevol,
|
|
|
|
const std::vector<double>& rock_comp,
|
|
|
|
const double dt,
|
|
|
|
std::vector<double>& pressure,
|
2012-04-12 09:36:08 -05:00
|
|
|
std::vector<double>& faceflux,
|
|
|
|
std::vector<double>& well_bhp,
|
|
|
|
std::vector<double>& well_rate);
|
2012-03-19 05:52:03 -05:00
|
|
|
|
2012-05-09 08:06:13 -05:00
|
|
|
void solveIncrement(const std::vector<double>& totmob,
|
|
|
|
const std::vector<double>& omega,
|
|
|
|
const std::vector<double>& src,
|
|
|
|
const std::vector<double>& wdp,
|
|
|
|
const FlowBoundaryConditions* bcs,
|
|
|
|
const std::vector<double>& porevol,
|
|
|
|
const std::vector<double>& rock_comp,
|
|
|
|
const std::vector<double>& prev_pressure,
|
|
|
|
const std::vector<double>& initial_porevol,
|
|
|
|
const double dt,
|
|
|
|
std::vector<double>& pressure_increment);
|
|
|
|
|
|
|
|
void computeFaceFlux(const std::vector<double>& totmob,
|
|
|
|
const std::vector<double>& omega,
|
|
|
|
const std::vector<double>& src,
|
|
|
|
const std::vector<double>& wdp,
|
|
|
|
const FlowBoundaryConditions* bcs,
|
|
|
|
std::vector<double>& pressure,
|
|
|
|
std::vector<double>& faceflux,
|
|
|
|
std::vector<double>& well_bhp,
|
|
|
|
std::vector<double>& well_rate);
|
|
|
|
|
2012-02-27 10:29:09 -06:00
|
|
|
/// Expose read-only reference to internal half-transmissibility.
|
|
|
|
const ::std::vector<double>& getHalfTrans() const { return htrans_; }
|
|
|
|
|
2012-06-06 08:14:46 -05:00
|
|
|
/// Set tolerance for the linear solver.
|
|
|
|
/// \param[in] tol tolerance value
|
|
|
|
void setTolerance(const double tol);
|
|
|
|
|
|
|
|
/// Get tolerance of the linear solver.
|
|
|
|
/// \param[out] tolerance value
|
|
|
|
double getTolerance() const;
|
|
|
|
|
|
|
|
|
2012-02-20 06:23:01 -06:00
|
|
|
private:
|
|
|
|
const UnstructuredGrid& grid_;
|
2012-06-06 08:14:46 -05:00
|
|
|
LinearSolverInterface& linsolver_;
|
2012-02-20 06:23:01 -06:00
|
|
|
::std::vector<double> htrans_;
|
|
|
|
::std::vector<double> trans_ ;
|
|
|
|
::std::vector<double> gpress_;
|
|
|
|
::std::vector<double> gpress_omegaweighted_;
|
2012-04-10 07:47:29 -05:00
|
|
|
|
|
|
|
const struct Wells* wells_;
|
2012-02-20 06:23:01 -06:00
|
|
|
struct ifs_tpfa_data* h_;
|
|
|
|
};
|
|
|
|
|
|
|
|
} // namespace Opm
|
|
|
|
|
|
|
|
#endif // OPM_INCOMPTPFA_HEADER_INCLUDED
|