2012-05-14 03:53:50 -05: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_COMPRESSIBLETPFA_HEADER_INCLUDED
|
|
|
|
#define OPM_COMPRESSIBLETPFA_HEADER_INCLUDED
|
|
|
|
|
|
|
|
|
|
|
|
#include <vector>
|
|
|
|
|
|
|
|
struct UnstructuredGrid;
|
|
|
|
struct cfs_tpfa_res_data;
|
|
|
|
struct Wells;
|
|
|
|
struct FlowBoundaryConditions;
|
|
|
|
|
|
|
|
namespace Opm
|
|
|
|
{
|
|
|
|
|
2012-05-16 07:38:55 -05:00
|
|
|
class BlackoilState;
|
2012-05-18 04:10:31 -05:00
|
|
|
class BlackoilPropertiesInterface;
|
2012-08-17 03:38:41 -05:00
|
|
|
class RockCompressibility;
|
2012-05-14 03:53:50 -05:00
|
|
|
class LinearSolverInterface;
|
2012-05-16 08:49:02 -05:00
|
|
|
class WellState;
|
2012-05-14 03:53:50 -05:00
|
|
|
|
|
|
|
/// Encapsulating a tpfa pressure solver for the compressible-fluid case.
|
|
|
|
/// Supports gravity, wells and simple sources as driving forces.
|
|
|
|
/// 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 CompressibleTpfa
|
|
|
|
{
|
|
|
|
public:
|
2012-05-18 04:10:31 -05:00
|
|
|
/// Construct solver.
|
2012-08-17 03:38:41 -05:00
|
|
|
/// \param[in] grid A 2d or 3d grid.
|
|
|
|
/// \param[in] props Rock and fluid properties.
|
|
|
|
/// \param[in] rock_comp_props Rock compressibility properties. May be null.
|
|
|
|
/// \param[in] linsolver Linear solver to use.
|
|
|
|
/// \param[in] residual_tol Solution accepted if inf-norm of residual is smaller.
|
|
|
|
/// \param[in] change_tol Solution accepted if inf-norm of change in pressure is smaller.
|
|
|
|
/// \param[in] maxiter Maximum acceptable number of iterations.
|
|
|
|
/// \param[in] gravity Gravity vector. If non-null, the array should
|
|
|
|
/// have D elements.
|
|
|
|
/// \param[in] wells The wells argument. Will be used in solution,
|
|
|
|
/// is ignored if NULL.
|
|
|
|
/// Note: this class observes the well object, and
|
|
|
|
/// makes the assumption that the well topology
|
|
|
|
/// and completions does not change during the
|
|
|
|
/// run. However, controls (only) are allowed
|
|
|
|
/// to change.
|
2012-08-27 02:48:06 -05:00
|
|
|
CompressibleTpfa(const UnstructuredGrid& grid,
|
2012-05-18 04:10:31 -05:00
|
|
|
const BlackoilPropertiesInterface& props,
|
2012-08-17 03:38:41 -05:00
|
|
|
const RockCompressibility* rock_comp_props,
|
2012-05-14 03:53:50 -05:00
|
|
|
const LinearSolverInterface& linsolver,
|
2012-05-21 04:24:12 -05:00
|
|
|
const double residual_tol,
|
|
|
|
const double change_tol,
|
|
|
|
const int maxiter,
|
2012-05-18 04:10:31 -05:00
|
|
|
const double* gravity,
|
|
|
|
const Wells* wells);
|
2012-05-14 03:53:50 -05:00
|
|
|
|
2012-08-27 02:48:06 -05:00
|
|
|
/// Destructor.
|
2013-03-07 08:14:01 -06:00
|
|
|
virtual ~CompressibleTpfa();
|
2012-05-14 03:53:50 -05:00
|
|
|
|
2012-05-21 04:24:12 -05:00
|
|
|
/// Solve the pressure equation by Newton-Raphson scheme.
|
|
|
|
/// May throw an exception if the number of iterations
|
|
|
|
/// exceed maxiter (set in constructor).
|
2012-05-16 07:38:55 -05:00
|
|
|
void solve(const double dt,
|
2012-05-16 08:49:02 -05:00
|
|
|
BlackoilState& state,
|
|
|
|
WellState& well_state);
|
2012-05-14 03:53:50 -05:00
|
|
|
|
2012-08-23 07:03:20 -05:00
|
|
|
/// @brief After solve(), was the resulting pressure singular.
|
|
|
|
/// Returns true if the pressure is singular in the following
|
|
|
|
/// sense: if everything is incompressible and there are no
|
|
|
|
/// pressure conditions, the absolute values of the pressure
|
|
|
|
/// solution are arbitrary. (But the differences in pressure
|
|
|
|
/// are significant.)
|
|
|
|
bool singularPressure() const;
|
|
|
|
|
2012-05-14 03:53:50 -05:00
|
|
|
private:
|
2012-08-27 06:19:04 -05:00
|
|
|
virtual void computePerSolveDynamicData(const double dt,
|
|
|
|
const BlackoilState& state,
|
|
|
|
const WellState& well_state);
|
2012-05-21 03:10:35 -05:00
|
|
|
void computePerIterationDynamicData(const double dt,
|
|
|
|
const BlackoilState& state,
|
|
|
|
const WellState& well_state);
|
2012-08-27 06:19:04 -05:00
|
|
|
virtual void computeCellDynamicData(const double dt,
|
|
|
|
const BlackoilState& state,
|
|
|
|
const WellState& well_state);
|
2012-05-21 03:10:35 -05:00
|
|
|
void computeFaceDynamicData(const double dt,
|
|
|
|
const BlackoilState& state,
|
|
|
|
const WellState& well_state);
|
|
|
|
void computeWellDynamicData(const double dt,
|
|
|
|
const BlackoilState& state,
|
|
|
|
const WellState& well_state);
|
2012-05-21 03:47:21 -05:00
|
|
|
void assemble(const double dt,
|
|
|
|
const BlackoilState& state,
|
|
|
|
const WellState& well_state);
|
2012-05-14 03:53:50 -05:00
|
|
|
void solveIncrement();
|
2012-05-21 05:48:54 -05:00
|
|
|
double residualNorm() const;
|
|
|
|
double incrementNorm() const;
|
2012-08-27 02:48:06 -05:00
|
|
|
void computeResults(BlackoilState& state,
|
2012-05-21 05:58:42 -05:00
|
|
|
WellState& well_state) const;
|
2012-08-27 06:19:04 -05:00
|
|
|
protected:
|
|
|
|
void computeWellPotentials(const BlackoilState& state);
|
2012-05-14 03:53:50 -05:00
|
|
|
|
|
|
|
// ------ Data that will remain unmodified after construction. ------
|
2012-08-27 02:48:06 -05:00
|
|
|
const UnstructuredGrid& grid_;
|
2012-05-18 04:10:31 -05:00
|
|
|
const BlackoilPropertiesInterface& props_;
|
2012-08-17 03:38:41 -05:00
|
|
|
const RockCompressibility* rock_comp_props_;
|
2012-05-14 03:53:50 -05:00
|
|
|
const LinearSolverInterface& linsolver_;
|
2012-05-21 04:24:12 -05:00
|
|
|
const double residual_tol_;
|
|
|
|
const double change_tol_;
|
|
|
|
const int maxiter_;
|
|
|
|
const double* gravity_; // May be NULL
|
|
|
|
const Wells* wells_; // May be NULL, outside may modify controls (only) between calls to solve().
|
2012-08-27 02:48:06 -05:00
|
|
|
std::vector<double> htrans_;
|
|
|
|
std::vector<double> trans_ ;
|
2012-05-21 03:10:35 -05:00
|
|
|
std::vector<int> allcells_;
|
2012-05-14 03:53:50 -05:00
|
|
|
|
|
|
|
// ------ Internal data for the cfs_tpfa_res solver. ------
|
2012-08-27 02:48:06 -05:00
|
|
|
struct cfs_tpfa_res_data* h_;
|
2012-05-14 03:53:50 -05:00
|
|
|
|
|
|
|
// ------ Data that will be modified for every solve. ------
|
2012-10-16 06:55:07 -05:00
|
|
|
std::vector<double> wellperf_wdp_;
|
2012-08-17 03:38:41 -05:00
|
|
|
std::vector<double> initial_porevol_;
|
2012-05-14 03:53:50 -05:00
|
|
|
|
|
|
|
// ------ Data that will be modified for every solver iteration. ------
|
2012-05-16 08:49:02 -05:00
|
|
|
std::vector<double> cell_A_;
|
|
|
|
std::vector<double> cell_dA_;
|
2012-05-21 03:10:35 -05:00
|
|
|
std::vector<double> cell_viscosity_;
|
|
|
|
std::vector<double> cell_phasemob_;
|
|
|
|
std::vector<double> cell_voldisc_;
|
2012-05-16 08:49:02 -05:00
|
|
|
std::vector<double> face_A_;
|
|
|
|
std::vector<double> face_phasemob_;
|
2012-05-21 03:10:35 -05:00
|
|
|
std::vector<double> face_gravcap_;
|
|
|
|
std::vector<double> wellperf_A_;
|
|
|
|
std::vector<double> wellperf_phasemob_;
|
2012-08-17 03:38:41 -05:00
|
|
|
std::vector<double> porevol_; // Only modified if rock_comp_props_ is non-null.
|
|
|
|
std::vector<double> rock_comp_; // Empty unless rock_comp_props_ is non-null.
|
2012-05-14 03:53:50 -05:00
|
|
|
// The update to be applied to the pressures (cell and bhp).
|
|
|
|
std::vector<double> pressure_increment_;
|
2012-08-23 07:03:20 -05:00
|
|
|
// True if the matrix assembled would be singular but for the
|
|
|
|
// adjustment made in the cfs_*_assemble() calls. This happens
|
|
|
|
// if everything is incompressible and there are no pressure
|
|
|
|
// conditions.
|
|
|
|
bool singular_;
|
2012-05-14 03:53:50 -05:00
|
|
|
};
|
|
|
|
|
|
|
|
} // namespace Opm
|
|
|
|
|
|
|
|
|
|
|
|
#endif // OPM_COMPRESSIBLETPFA_HEADER_INCLUDED
|