mirror of
https://github.com/OPM/opm-simulators.git
synced 2025-02-25 18:55:30 -06:00
Merge branch 'master' into ert
Conflicts: Makefile.am configure.ac examples/Makefile.am opm/core/GridManager.cpp opm/core/eclipse/EclipseGridParser.cpp opm/core/grid/cpgpreprocess/preprocess.h tests/Makefile.am
This commit is contained in:
commit
9c77d12f8d
@ -151,7 +151,7 @@ namespace Opm
|
|||||||
double* dpcds) const;
|
double* dpcds) const;
|
||||||
|
|
||||||
|
|
||||||
/// Obtain the range of allowable saturation values.
|
/// Obtain the range of allowable saturation values.
|
||||||
/// In cell cells[i], saturation of phase p is allowed to be
|
/// In cell cells[i], saturation of phase p is allowed to be
|
||||||
/// in the interval [smin[i*P + p], smax[i*P + p]].
|
/// in the interval [smin[i*P + p], smax[i*P + p]].
|
||||||
/// \param[in] n Number of data points.
|
/// \param[in] n Number of data points.
|
||||||
|
@ -18,19 +18,68 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#include <opm/core/fluid/BlackoilPropertiesFromDeck.hpp>
|
#include <opm/core/fluid/BlackoilPropertiesFromDeck.hpp>
|
||||||
|
#include <opm/core/utility/parameters/ParameterGroup.hpp>
|
||||||
|
|
||||||
namespace Opm
|
namespace Opm
|
||||||
{
|
{
|
||||||
|
|
||||||
BlackoilPropertiesFromDeck::BlackoilPropertiesFromDeck(const EclipseGridParser& deck,
|
BlackoilPropertiesFromDeck::BlackoilPropertiesFromDeck(const EclipseGridParser& deck,
|
||||||
const std::vector<int>& global_cell)
|
const UnstructuredGrid& grid)
|
||||||
{
|
{
|
||||||
rock_.init(deck, global_cell);
|
rock_.init(deck, grid);
|
||||||
pvt_.init(deck);
|
pvt_.init(deck, 200);
|
||||||
satprops_.init(deck, global_cell);
|
SaturationPropsFromDeck<SatFuncStone2Uniform>* ptr
|
||||||
if (pvt_.numPhases() != satprops_.numPhases()) {
|
= new SaturationPropsFromDeck<SatFuncStone2Uniform>();
|
||||||
THROW("BlackoilPropertiesBasic::BlackoilPropertiesBasic() - Inconsistent number of phases in pvt data ("
|
satprops_.reset(ptr);
|
||||||
<< pvt_.numPhases() << ") and saturation-dependent function data (" << satprops_.numPhases() << ").");
|
ptr->init(deck, grid, 200);
|
||||||
|
|
||||||
|
if (pvt_.numPhases() != satprops_->numPhases()) {
|
||||||
|
THROW("BlackoilPropertiesFromDeck::BlackoilPropertiesFromDeck() - Inconsistent number of phases in pvt data ("
|
||||||
|
<< pvt_.numPhases() << ") and saturation-dependent function data (" << satprops_->numPhases() << ").");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
BlackoilPropertiesFromDeck::BlackoilPropertiesFromDeck(const EclipseGridParser& deck,
|
||||||
|
const UnstructuredGrid& grid,
|
||||||
|
const parameter::ParameterGroup& param)
|
||||||
|
{
|
||||||
|
rock_.init(deck, grid);
|
||||||
|
const int pvt_samples = param.getDefault("pvt_tab_size", 200);
|
||||||
|
pvt_.init(deck, pvt_samples);
|
||||||
|
|
||||||
|
// Unfortunate lack of pointer smartness here...
|
||||||
|
const int sat_samples = param.getDefault("sat_tab_size", 200);
|
||||||
|
std::string threephase_model = param.getDefault<std::string>("threephase_model", "simple");
|
||||||
|
bool use_stone2 = (threephase_model == "stone2");
|
||||||
|
if (sat_samples > 1) {
|
||||||
|
if (use_stone2) {
|
||||||
|
SaturationPropsFromDeck<SatFuncStone2Uniform>* ptr
|
||||||
|
= new SaturationPropsFromDeck<SatFuncStone2Uniform>();
|
||||||
|
satprops_.reset(ptr);
|
||||||
|
ptr->init(deck, grid, sat_samples);
|
||||||
|
} else {
|
||||||
|
SaturationPropsFromDeck<SatFuncSimpleUniform>* ptr
|
||||||
|
= new SaturationPropsFromDeck<SatFuncSimpleUniform>();
|
||||||
|
satprops_.reset(ptr);
|
||||||
|
ptr->init(deck, grid, sat_samples);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if (use_stone2) {
|
||||||
|
SaturationPropsFromDeck<SatFuncStone2Nonuniform>* ptr
|
||||||
|
= new SaturationPropsFromDeck<SatFuncStone2Nonuniform>();
|
||||||
|
satprops_.reset(ptr);
|
||||||
|
ptr->init(deck, grid, sat_samples);
|
||||||
|
} else {
|
||||||
|
SaturationPropsFromDeck<SatFuncSimpleNonuniform>* ptr
|
||||||
|
= new SaturationPropsFromDeck<SatFuncSimpleNonuniform>();
|
||||||
|
satprops_.reset(ptr);
|
||||||
|
ptr->init(deck, grid, sat_samples);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (pvt_.numPhases() != satprops_->numPhases()) {
|
||||||
|
THROW("BlackoilPropertiesFromDeck::BlackoilPropertiesFromDeck() - Inconsistent number of phases in pvt data ("
|
||||||
|
<< pvt_.numPhases() << ") and saturation-dependent function data (" << satprops_->numPhases() << ").");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -235,7 +284,7 @@ namespace Opm
|
|||||||
double* kr,
|
double* kr,
|
||||||
double* dkrds) const
|
double* dkrds) const
|
||||||
{
|
{
|
||||||
satprops_.relperm(n, s, cells, kr, dkrds);
|
satprops_->relperm(n, s, cells, kr, dkrds);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -254,7 +303,7 @@ namespace Opm
|
|||||||
double* pc,
|
double* pc,
|
||||||
double* dpcds) const
|
double* dpcds) const
|
||||||
{
|
{
|
||||||
satprops_.capPress(n, s, cells, pc, dpcds);
|
satprops_->capPress(n, s, cells, pc, dpcds);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -270,7 +319,7 @@ namespace Opm
|
|||||||
double* smin,
|
double* smin,
|
||||||
double* smax) const
|
double* smax) const
|
||||||
{
|
{
|
||||||
satprops_.satRange(n, cells, smin, smax);
|
satprops_->satRange(n, cells, smin, smax);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -26,6 +26,10 @@
|
|||||||
#include <opm/core/fluid/blackoil/BlackoilPvtProperties.hpp>
|
#include <opm/core/fluid/blackoil/BlackoilPvtProperties.hpp>
|
||||||
#include <opm/core/fluid/SaturationPropsFromDeck.hpp>
|
#include <opm/core/fluid/SaturationPropsFromDeck.hpp>
|
||||||
#include <opm/core/eclipse/EclipseGridParser.hpp>
|
#include <opm/core/eclipse/EclipseGridParser.hpp>
|
||||||
|
#include <opm/core/utility/parameters/ParameterGroup.hpp>
|
||||||
|
#include <boost/scoped_ptr.hpp>
|
||||||
|
|
||||||
|
struct UnstructuredGrid;
|
||||||
|
|
||||||
namespace Opm
|
namespace Opm
|
||||||
{
|
{
|
||||||
@ -35,12 +39,28 @@ namespace Opm
|
|||||||
class BlackoilPropertiesFromDeck : public BlackoilPropertiesInterface
|
class BlackoilPropertiesFromDeck : public BlackoilPropertiesInterface
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
/// Construct from deck and cell mapping.
|
/// Initialize from deck and grid.
|
||||||
/// \param deck eclipse input parser
|
/// \param[in] deck Deck input parser
|
||||||
/// \param global_cell mapping from cell indices (typically from a processed grid)
|
/// \param[in] grid Grid to which property object applies, needed for the
|
||||||
|
/// mapping from cell indices (typically from a processed grid)
|
||||||
/// to logical cartesian indices consistent with the deck.
|
/// to logical cartesian indices consistent with the deck.
|
||||||
BlackoilPropertiesFromDeck(const EclipseGridParser& deck,
|
BlackoilPropertiesFromDeck(const EclipseGridParser& deck,
|
||||||
const std::vector<int>& global_cell);
|
const UnstructuredGrid& grid);
|
||||||
|
|
||||||
|
/// Initialize from deck, grid and parameters.
|
||||||
|
/// \param[in] deck Deck input parser
|
||||||
|
/// \param[in] grid Grid to which property object applies, needed for the
|
||||||
|
/// mapping from cell indices (typically from a processed grid)
|
||||||
|
/// to logical cartesian indices consistent with the deck.
|
||||||
|
/// \param[in] param Parameters. Accepted parameters include:
|
||||||
|
/// pvt_tab_size (200) number of uniform sample points for dead-oil pvt tables.
|
||||||
|
/// sat_tab_size (200) number of uniform sample points for saturation tables.
|
||||||
|
/// threephase_model("simple") three-phase relperm model (accepts "simple" and "stone2").
|
||||||
|
/// For both size parameters, a 0 or negative value indicates that no spline fitting is to
|
||||||
|
/// be done, and the input fluid data used directly for linear interpolation.
|
||||||
|
BlackoilPropertiesFromDeck(const EclipseGridParser& deck,
|
||||||
|
const UnstructuredGrid& grid,
|
||||||
|
const parameter::ParameterGroup& param);
|
||||||
|
|
||||||
/// Destructor.
|
/// Destructor.
|
||||||
virtual ~BlackoilPropertiesFromDeck();
|
virtual ~BlackoilPropertiesFromDeck();
|
||||||
@ -162,7 +182,7 @@ namespace Opm
|
|||||||
private:
|
private:
|
||||||
RockFromDeck rock_;
|
RockFromDeck rock_;
|
||||||
BlackoilPvtProperties pvt_;
|
BlackoilPvtProperties pvt_;
|
||||||
SaturationPropsFromDeck satprops_;
|
boost::scoped_ptr<SaturationPropsInterface> satprops_;
|
||||||
mutable std::vector<double> B_;
|
mutable std::vector<double> B_;
|
||||||
mutable std::vector<double> dB_;
|
mutable std::vector<double> dB_;
|
||||||
mutable std::vector<double> R_;
|
mutable std::vector<double> R_;
|
||||||
|
@ -27,11 +27,11 @@ namespace Opm
|
|||||||
{
|
{
|
||||||
|
|
||||||
IncompPropertiesFromDeck::IncompPropertiesFromDeck(const EclipseGridParser& deck,
|
IncompPropertiesFromDeck::IncompPropertiesFromDeck(const EclipseGridParser& deck,
|
||||||
const std::vector<int>& global_cell)
|
const UnstructuredGrid& grid)
|
||||||
{
|
{
|
||||||
rock_.init(deck, global_cell);
|
rock_.init(deck, grid);
|
||||||
pvt_.init(deck);
|
pvt_.init(deck);
|
||||||
satprops_.init(deck, global_cell);
|
satprops_.init(deck, grid, 200);
|
||||||
if (pvt_.numPhases() != satprops_.numPhases()) {
|
if (pvt_.numPhases() != satprops_.numPhases()) {
|
||||||
THROW("IncompPropertiesFromDeck::IncompPropertiesFromDeck() - Inconsistent number of phases in pvt data ("
|
THROW("IncompPropertiesFromDeck::IncompPropertiesFromDeck() - Inconsistent number of phases in pvt data ("
|
||||||
<< pvt_.numPhases() << ") and saturation-dependent function data (" << satprops_.numPhases() << ").");
|
<< pvt_.numPhases() << ") and saturation-dependent function data (" << satprops_.numPhases() << ").");
|
||||||
|
@ -26,6 +26,8 @@
|
|||||||
#include <opm/core/fluid/SaturationPropsFromDeck.hpp>
|
#include <opm/core/fluid/SaturationPropsFromDeck.hpp>
|
||||||
#include <opm/core/eclipse/EclipseGridParser.hpp>
|
#include <opm/core/eclipse/EclipseGridParser.hpp>
|
||||||
|
|
||||||
|
struct UnstructuredGrid;
|
||||||
|
|
||||||
namespace Opm
|
namespace Opm
|
||||||
{
|
{
|
||||||
|
|
||||||
@ -43,12 +45,13 @@ namespace Opm
|
|||||||
class IncompPropertiesFromDeck : public IncompPropertiesInterface
|
class IncompPropertiesFromDeck : public IncompPropertiesInterface
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
/// Construct from deck and cell mapping.
|
/// Initialize from deck and grid.
|
||||||
/// \param deck eclipse input parser
|
/// \param deck Deck input parser
|
||||||
/// \param global_cell mapping from cell indices (typically from a processed grid)
|
/// \param grid Grid to which property object applies, needed for the
|
||||||
|
/// mapping from cell indices (typically from a processed grid)
|
||||||
/// to logical cartesian indices consistent with the deck.
|
/// to logical cartesian indices consistent with the deck.
|
||||||
IncompPropertiesFromDeck(const EclipseGridParser& deck,
|
IncompPropertiesFromDeck(const EclipseGridParser& deck,
|
||||||
const std::vector<int>& global_cell);
|
const UnstructuredGrid& grid);
|
||||||
|
|
||||||
/// Destructor.
|
/// Destructor.
|
||||||
virtual ~IncompPropertiesFromDeck();
|
virtual ~IncompPropertiesFromDeck();
|
||||||
@ -132,7 +135,7 @@ namespace Opm
|
|||||||
private:
|
private:
|
||||||
RockFromDeck rock_;
|
RockFromDeck rock_;
|
||||||
PvtPropertiesIncompFromDeck pvt_;
|
PvtPropertiesIncompFromDeck pvt_;
|
||||||
SaturationPropsFromDeck satprops_;
|
SaturationPropsFromDeck<SatFuncStone2Uniform> satprops_;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
@ -69,7 +69,8 @@ namespace Opm
|
|||||||
const double cpnorm = rock_comp_*(pressure - pref_);
|
const double cpnorm = rock_comp_*(pressure - pref_);
|
||||||
return (1.0 + cpnorm + 0.5*cpnorm*cpnorm);
|
return (1.0 + cpnorm + 0.5*cpnorm*cpnorm);
|
||||||
} else {
|
} else {
|
||||||
return Opm::linearInterpolation(p_, poromult_, pressure);
|
// return Opm::linearInterpolation(p_, poromult_, pressure);
|
||||||
|
return Opm::linearInterpolationExtrap(p_, poromult_, pressure);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -78,8 +79,11 @@ namespace Opm
|
|||||||
if (p_.empty()) {
|
if (p_.empty()) {
|
||||||
return rock_comp_;
|
return rock_comp_;
|
||||||
} else {
|
} else {
|
||||||
const double poromult = Opm::linearInterpolation(p_, poromult_, pressure);
|
//const double poromult = Opm::linearInterpolation(p_, poromult_, pressure);
|
||||||
const double dporomultdp = Opm::linearInterpolationDerivative(p_, poromult_, pressure);
|
//const double dporomultdp = Opm::linearInterpolationDerivative(p_, poromult_, pressure);
|
||||||
|
const double poromult = Opm::linearInterpolationExtrap(p_, poromult_, pressure);
|
||||||
|
const double dporomultdp = Opm::linearInterpolationDerivativeExtrap(p_, poromult_, pressure);
|
||||||
|
|
||||||
return dporomultdp/poromult;
|
return dporomultdp/poromult;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -19,7 +19,7 @@
|
|||||||
|
|
||||||
|
|
||||||
#include <opm/core/fluid/RockFromDeck.hpp>
|
#include <opm/core/fluid/RockFromDeck.hpp>
|
||||||
|
#include <opm/core/grid.h>
|
||||||
#include <tr1/array>
|
#include <tr1/array>
|
||||||
|
|
||||||
namespace Opm
|
namespace Opm
|
||||||
@ -36,8 +36,6 @@ namespace Opm
|
|||||||
PermeabilityKind fillTensor(const EclipseGridParser& parser,
|
PermeabilityKind fillTensor(const EclipseGridParser& parser,
|
||||||
std::vector<const std::vector<double>*>& tensor,
|
std::vector<const std::vector<double>*>& tensor,
|
||||||
std::tr1::array<int,9>& kmap);
|
std::tr1::array<int,9>& kmap);
|
||||||
|
|
||||||
int numGlobalCells(const EclipseGridParser& parser);
|
|
||||||
} // anonymous namespace
|
} // anonymous namespace
|
||||||
|
|
||||||
|
|
||||||
@ -53,28 +51,29 @@ namespace Opm
|
|||||||
|
|
||||||
/// Initialize from deck and cell mapping.
|
/// Initialize from deck and cell mapping.
|
||||||
/// \param deck Deck input parser
|
/// \param deck Deck input parser
|
||||||
/// \param global_cell mapping from cell indices (typically from a processed grid)
|
/// \param grid grid to which property object applies, needed for the
|
||||||
|
/// mapping from cell indices (typically from a processed grid)
|
||||||
/// to logical cartesian indices consistent with the deck.
|
/// to logical cartesian indices consistent with the deck.
|
||||||
void RockFromDeck::init(const EclipseGridParser& deck,
|
void RockFromDeck::init(const EclipseGridParser& deck,
|
||||||
const std::vector<int>& global_cell)
|
const UnstructuredGrid& grid)
|
||||||
{
|
{
|
||||||
assignPorosity(deck, global_cell);
|
assignPorosity(deck, grid);
|
||||||
permfield_valid_.assign(global_cell.size(), false);
|
permfield_valid_.assign(grid.number_of_cells, false);
|
||||||
const double perm_threshold = 0.0; // Maybe turn into parameter?
|
const double perm_threshold = 0.0; // Maybe turn into parameter?
|
||||||
assignPermeability(deck, global_cell, perm_threshold);
|
assignPermeability(deck, grid, perm_threshold);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void RockFromDeck::assignPorosity(const EclipseGridParser& parser,
|
void RockFromDeck::assignPorosity(const EclipseGridParser& parser,
|
||||||
const std::vector<int>& global_cell)
|
const UnstructuredGrid& grid)
|
||||||
{
|
{
|
||||||
porosity_.assign(global_cell.size(), 1.0);
|
porosity_.assign(grid.number_of_cells, 1.0);
|
||||||
|
const int* gc = grid.global_cell;
|
||||||
if (parser.hasField("PORO")) {
|
if (parser.hasField("PORO")) {
|
||||||
const std::vector<double>& poro = parser.getFloatingPointValue("PORO");
|
const std::vector<double>& poro = parser.getFloatingPointValue("PORO");
|
||||||
|
|
||||||
for (int c = 0; c < int(porosity_.size()); ++c) {
|
for (int c = 0; c < int(porosity_.size()); ++c) {
|
||||||
porosity_[c] = poro[global_cell[c]];
|
const int deck_pos = (gc == NULL) ? c : gc[c];
|
||||||
|
porosity_[c] = poro[deck_pos];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -82,14 +81,16 @@ namespace Opm
|
|||||||
|
|
||||||
|
|
||||||
void RockFromDeck::assignPermeability(const EclipseGridParser& parser,
|
void RockFromDeck::assignPermeability(const EclipseGridParser& parser,
|
||||||
const std::vector<int>& global_cell,
|
const UnstructuredGrid& grid,
|
||||||
double perm_threshold)
|
double perm_threshold)
|
||||||
{
|
{
|
||||||
const int dim = 3;
|
const int dim = 3;
|
||||||
const int num_global_cells = numGlobalCells(parser);
|
const int num_global_cells = grid.cartdims[0]*grid.cartdims[1]*grid.cartdims[2];
|
||||||
|
const int nc = grid.number_of_cells;
|
||||||
|
|
||||||
ASSERT (num_global_cells > 0);
|
ASSERT (num_global_cells > 0);
|
||||||
|
|
||||||
permeability_.assign(dim * dim * global_cell.size(), 0.0);
|
permeability_.assign(dim * dim * nc, 0.0);
|
||||||
|
|
||||||
std::vector<const std::vector<double>*> tensor;
|
std::vector<const std::vector<double>*> tensor;
|
||||||
tensor.reserve(10);
|
tensor.reserve(10);
|
||||||
@ -111,13 +112,13 @@ namespace Opm
|
|||||||
// chosen) default value...
|
// chosen) default value...
|
||||||
//
|
//
|
||||||
if (tensor.size() > 1) {
|
if (tensor.size() > 1) {
|
||||||
const int nc = global_cell.size();
|
const int* gc = grid.global_cell;
|
||||||
int off = 0;
|
int off = 0;
|
||||||
|
|
||||||
for (int c = 0; c < nc; ++c, off += dim*dim) {
|
for (int c = 0; c < nc; ++c, off += dim*dim) {
|
||||||
// SharedPermTensor K(dim, dim, &permeability_[off]);
|
// SharedPermTensor K(dim, dim, &permeability_[off]);
|
||||||
int kix = 0;
|
int kix = 0;
|
||||||
const int glob = global_cell[c];
|
const int glob = (gc == NULL) ? c : gc[c];
|
||||||
|
|
||||||
for (int i = 0; i < dim; ++i) {
|
for (int i = 0; i < dim; ++i) {
|
||||||
for (int j = 0; j < dim; ++j, ++kix) {
|
for (int j = 0; j < dim; ++j, ++kix) {
|
||||||
@ -331,26 +332,6 @@ namespace Opm
|
|||||||
return kind;
|
return kind;
|
||||||
}
|
}
|
||||||
|
|
||||||
int numGlobalCells(const EclipseGridParser& parser)
|
|
||||||
{
|
|
||||||
int ngc = -1;
|
|
||||||
|
|
||||||
if (parser.hasField("DIMENS")) {
|
|
||||||
const std::vector<int>&
|
|
||||||
dims = parser.getIntegerValue("DIMENS");
|
|
||||||
|
|
||||||
ngc = dims[0] * dims[1] * dims[2];
|
|
||||||
}
|
|
||||||
else if (parser.hasField("SPECGRID")) {
|
|
||||||
const SPECGRID& sgr = parser.getSPECGRID();
|
|
||||||
|
|
||||||
ngc = sgr.dimensions[ 0 ];
|
|
||||||
ngc *= sgr.dimensions[ 1 ];
|
|
||||||
ngc *= sgr.dimensions[ 2 ];
|
|
||||||
}
|
|
||||||
|
|
||||||
return ngc;
|
|
||||||
}
|
|
||||||
} // anonymous namespace
|
} // anonymous namespace
|
||||||
|
|
||||||
} // namespace Opm
|
} // namespace Opm
|
||||||
|
@ -24,6 +24,7 @@
|
|||||||
#include <opm/core/eclipse/EclipseGridParser.hpp>
|
#include <opm/core/eclipse/EclipseGridParser.hpp>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
|
struct UnstructuredGrid;
|
||||||
|
|
||||||
namespace Opm
|
namespace Opm
|
||||||
{
|
{
|
||||||
@ -34,12 +35,13 @@ namespace Opm
|
|||||||
/// Default constructor.
|
/// Default constructor.
|
||||||
RockFromDeck();
|
RockFromDeck();
|
||||||
|
|
||||||
/// Initialize from deck and cell mapping.
|
/// Initialize from deck and grid.
|
||||||
/// \param deck Deck input parser
|
/// \param deck Deck input parser
|
||||||
/// \param global_cell mapping from cell indices (typically from a processed grid)
|
/// \param grid Grid to which property object applies, needed for the
|
||||||
|
/// mapping from cell indices (typically from a processed grid)
|
||||||
/// to logical cartesian indices consistent with the deck.
|
/// to logical cartesian indices consistent with the deck.
|
||||||
void init(const EclipseGridParser& deck,
|
void init(const EclipseGridParser& deck,
|
||||||
const std::vector<int>& global_cell);
|
const UnstructuredGrid& grid);
|
||||||
|
|
||||||
/// \return D, the number of spatial dimensions. Always 3 for deck input.
|
/// \return D, the number of spatial dimensions. Always 3 for deck input.
|
||||||
int numDimensions() const
|
int numDimensions() const
|
||||||
@ -69,9 +71,9 @@ namespace Opm
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
void assignPorosity(const EclipseGridParser& parser,
|
void assignPorosity(const EclipseGridParser& parser,
|
||||||
const std::vector<int>& global_cell);
|
const UnstructuredGrid& grid);
|
||||||
void assignPermeability(const EclipseGridParser& parser,
|
void assignPermeability(const EclipseGridParser& parser,
|
||||||
const std::vector<int>& global_cell,
|
const UnstructuredGrid& grid,
|
||||||
const double perm_threshold);
|
const double perm_threshold);
|
||||||
|
|
||||||
std::vector<double> porosity_;
|
std::vector<double> porosity_;
|
||||||
|
@ -99,6 +99,7 @@ namespace Opm
|
|||||||
|
|
||||||
/// Default constructor.
|
/// Default constructor.
|
||||||
SaturationPropsBasic::SaturationPropsBasic()
|
SaturationPropsBasic::SaturationPropsBasic()
|
||||||
|
: num_phases_(0), relperm_func_(Constant)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -113,7 +114,8 @@ namespace Opm
|
|||||||
THROW("SaturationPropsBasic::init() illegal num_phases: " << num_phases);
|
THROW("SaturationPropsBasic::init() illegal num_phases: " << num_phases);
|
||||||
}
|
}
|
||||||
num_phases_ = num_phases;
|
num_phases_ = num_phases;
|
||||||
std::string rpf = param.getDefault("relperm_func", std::string("Unset"));
|
//std::string rpf = param.getDefault("relperm_func", std::string("Unset"));
|
||||||
|
std::string rpf = param.getDefault("relperm_func", std::string("Linear"));
|
||||||
if (rpf == "Constant") {
|
if (rpf == "Constant") {
|
||||||
relperm_func_ = Constant;
|
relperm_func_ = Constant;
|
||||||
if(num_phases!=1){
|
if(num_phases!=1){
|
||||||
|
@ -20,24 +20,44 @@
|
|||||||
#ifndef OPM_SATURATIONPROPSFROMDECK_HEADER_INCLUDED
|
#ifndef OPM_SATURATIONPROPSFROMDECK_HEADER_INCLUDED
|
||||||
#define OPM_SATURATIONPROPSFROMDECK_HEADER_INCLUDED
|
#define OPM_SATURATIONPROPSFROMDECK_HEADER_INCLUDED
|
||||||
|
|
||||||
|
#include <opm/core/fluid/SaturationPropsInterface.hpp>
|
||||||
|
#include <opm/core/utility/parameters/ParameterGroup.hpp>
|
||||||
#include <opm/core/eclipse/EclipseGridParser.hpp>
|
#include <opm/core/eclipse/EclipseGridParser.hpp>
|
||||||
#include <opm/core/utility/UniformTableLinear.hpp>
|
|
||||||
#include <opm/core/fluid/blackoil/BlackoilPhases.hpp>
|
#include <opm/core/fluid/blackoil/BlackoilPhases.hpp>
|
||||||
|
#include <opm/core/fluid/SatFuncStone2.hpp>
|
||||||
|
#include <opm/core/fluid/SatFuncSimple.hpp>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
|
struct UnstructuredGrid;
|
||||||
|
|
||||||
namespace Opm
|
namespace Opm
|
||||||
{
|
{
|
||||||
|
|
||||||
class SaturationPropsFromDeck : public BlackoilPhases
|
|
||||||
|
|
||||||
|
/// Interface to saturation functions from deck.
|
||||||
|
/// Possible values for template argument (for now):
|
||||||
|
/// SatFuncSetStone2Nonuniform,
|
||||||
|
/// SatFuncSetStone2Uniform.
|
||||||
|
/// SatFuncSetSimpleNonuniform,
|
||||||
|
/// SatFuncSetSimpleUniform.
|
||||||
|
template <class SatFuncSet>
|
||||||
|
class SaturationPropsFromDeck : public SaturationPropsInterface
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
/// Default constructor.
|
/// Default constructor.
|
||||||
SaturationPropsFromDeck();
|
SaturationPropsFromDeck();
|
||||||
|
|
||||||
/// Initialize from deck.
|
/// Initialize from deck and grid.
|
||||||
/// global_cell maps from grid cells to their original logical Cartesian indices.
|
/// \param[in] deck Deck input parser
|
||||||
|
/// \param[in] grid Grid to which property object applies, needed for the
|
||||||
|
/// mapping from cell indices (typically from a processed grid)
|
||||||
|
/// to logical cartesian indices consistent with the deck.
|
||||||
|
/// \param[in] samples Number of uniform sample points for saturation tables.
|
||||||
|
/// NOTE: samples will only be used with the SatFuncSetUniform template argument.
|
||||||
void init(const EclipseGridParser& deck,
|
void init(const EclipseGridParser& deck,
|
||||||
const std::vector<int>& global_cell);
|
const UnstructuredGrid& grid,
|
||||||
|
const int samples);
|
||||||
|
|
||||||
/// \return P, the number of phases.
|
/// \return P, the number of phases.
|
||||||
int numPhases() const;
|
int numPhases() const;
|
||||||
@ -83,30 +103,12 @@ namespace Opm
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
PhaseUsage phase_usage_;
|
PhaseUsage phase_usage_;
|
||||||
class SatFuncSet
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
void init(const EclipseGridParser& deck, const int table_num, PhaseUsage phase_usg);
|
|
||||||
void evalKr(const double* s, double* kr) const;
|
|
||||||
void evalKrDeriv(const double* s, double* kr, double* dkrds) const;
|
|
||||||
void evalPc(const double* s, double* pc) const;
|
|
||||||
void evalPcDeriv(const double* s, double* pc, double* dpcds) const;
|
|
||||||
double smin_[PhaseUsage::MaxNumPhases];
|
|
||||||
double smax_[PhaseUsage::MaxNumPhases];
|
|
||||||
private:
|
|
||||||
PhaseUsage phase_usage; // A copy of the outer class' phase_usage_.
|
|
||||||
UniformTableLinear<double> krw_;
|
|
||||||
UniformTableLinear<double> krow_;
|
|
||||||
UniformTableLinear<double> pcow_;
|
|
||||||
UniformTableLinear<double> krg_;
|
|
||||||
UniformTableLinear<double> krog_;
|
|
||||||
UniformTableLinear<double> pcog_;
|
|
||||||
double krocw_; // = krow_(s_wc)
|
|
||||||
};
|
|
||||||
std::vector<SatFuncSet> satfuncset_;
|
std::vector<SatFuncSet> satfuncset_;
|
||||||
std::vector<int> cell_to_func_; // = SATNUM - 1
|
std::vector<int> cell_to_func_; // = SATNUM - 1
|
||||||
|
|
||||||
const SatFuncSet& funcForCell(const int cell) const;
|
typedef SatFuncSet Funcs;
|
||||||
|
|
||||||
|
const Funcs& funcForCell(const int cell) const;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
@ -114,6 +116,7 @@ namespace Opm
|
|||||||
} // namespace Opm
|
} // namespace Opm
|
||||||
|
|
||||||
|
|
||||||
|
#include <opm/core/fluid/SaturationPropsFromDeck_impl.hpp>
|
||||||
|
|
||||||
|
|
||||||
#endif // OPM_SATURATIONPROPSFROMDECK_HEADER_INCLUDED
|
#endif // OPM_SATURATIONPROPSFROMDECK_HEADER_INCLUDED
|
||||||
|
221
opm/core/fluid/SaturationPropsFromDeck_impl.hpp
Normal file
221
opm/core/fluid/SaturationPropsFromDeck_impl.hpp
Normal file
@ -0,0 +1,221 @@
|
|||||||
|
/*
|
||||||
|
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_SATURATIONPROPSFROMDECK_IMPL_HEADER_INCLUDED
|
||||||
|
#define OPM_SATURATIONPROPSFROMDECK_IMPL_HEADER_INCLUDED
|
||||||
|
|
||||||
|
|
||||||
|
#include <opm/core/utility/UniformTableLinear.hpp>
|
||||||
|
#include <opm/core/utility/NonuniformTableLinear.hpp>
|
||||||
|
#include <opm/core/fluid/blackoil/phaseUsageFromDeck.hpp>
|
||||||
|
#include <opm/core/grid.h>
|
||||||
|
|
||||||
|
namespace Opm
|
||||||
|
{
|
||||||
|
|
||||||
|
|
||||||
|
// ----------- Methods of SaturationPropsFromDeck ---------
|
||||||
|
|
||||||
|
|
||||||
|
/// Default constructor.
|
||||||
|
template <class SatFuncSet>
|
||||||
|
SaturationPropsFromDeck<SatFuncSet>::SaturationPropsFromDeck()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Initialize from deck.
|
||||||
|
template <class SatFuncSet>
|
||||||
|
void SaturationPropsFromDeck<SatFuncSet>::init(const EclipseGridParser& deck,
|
||||||
|
const UnstructuredGrid& grid,
|
||||||
|
const int samples)
|
||||||
|
{
|
||||||
|
phase_usage_ = phaseUsageFromDeck(deck);
|
||||||
|
|
||||||
|
// Extract input data.
|
||||||
|
// Oil phase should be active.
|
||||||
|
if (!phase_usage_.phase_used[Liquid]) {
|
||||||
|
THROW("SaturationPropsFromDeck::init() -- oil phase must be active.");
|
||||||
|
}
|
||||||
|
|
||||||
|
// Obtain SATNUM, if it exists, and create cell_to_func_.
|
||||||
|
// Otherwise, let the cell_to_func_ mapping be just empty.
|
||||||
|
int satfuncs_expected = 1;
|
||||||
|
if (deck.hasField("SATNUM")) {
|
||||||
|
const std::vector<int>& satnum = deck.getIntegerValue("SATNUM");
|
||||||
|
satfuncs_expected = *std::max_element(satnum.begin(), satnum.end());
|
||||||
|
const int num_cells = grid.number_of_cells;
|
||||||
|
cell_to_func_.resize(num_cells);
|
||||||
|
const int* gc = grid.global_cell;
|
||||||
|
for (int cell = 0; cell < num_cells; ++cell) {
|
||||||
|
const int deck_pos = (gc == NULL) ? cell : gc[cell];
|
||||||
|
cell_to_func_[cell] = satnum[deck_pos] - 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Find number of tables, check for consistency.
|
||||||
|
enum { Uninitialized = -1 };
|
||||||
|
int num_tables = Uninitialized;
|
||||||
|
if (phase_usage_.phase_used[Aqua]) {
|
||||||
|
const SWOF::table_t& swof_table = deck.getSWOF().swof_;
|
||||||
|
num_tables = swof_table.size();
|
||||||
|
if (num_tables < satfuncs_expected) {
|
||||||
|
THROW("Found " << num_tables << " SWOF tables, SATNUM specifies at least " << satfuncs_expected);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (phase_usage_.phase_used[Vapour]) {
|
||||||
|
const SGOF::table_t& sgof_table = deck.getSGOF().sgof_;
|
||||||
|
int num_sgof_tables = sgof_table.size();
|
||||||
|
if (num_sgof_tables < satfuncs_expected) {
|
||||||
|
THROW("Found " << num_tables << " SGOF tables, SATNUM specifies at least " << satfuncs_expected);
|
||||||
|
}
|
||||||
|
if (num_tables == Uninitialized) {
|
||||||
|
num_tables = num_sgof_tables;
|
||||||
|
} else if (num_tables != num_sgof_tables) {
|
||||||
|
THROW("Inconsistent number of tables in SWOF and SGOF.");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Initialize tables.
|
||||||
|
satfuncset_.resize(num_tables);
|
||||||
|
for (int table = 0; table < num_tables; ++table) {
|
||||||
|
satfuncset_[table].init(deck, table, phase_usage_, samples);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/// \return P, the number of phases.
|
||||||
|
template <class SatFuncSet>
|
||||||
|
int SaturationPropsFromDeck<SatFuncSet>::numPhases() const
|
||||||
|
{
|
||||||
|
return phase_usage_.num_phases;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/// Relative permeability.
|
||||||
|
/// \param[in] n Number of data points.
|
||||||
|
/// \param[in] s Array of nP saturation values.
|
||||||
|
/// \param[in] cells Array of n cell indices to be associated with the s values.
|
||||||
|
/// \param[out] kr Array of nP relperm values, array must be valid before calling.
|
||||||
|
/// \param[out] dkrds If non-null: array of nP^2 relperm derivative values,
|
||||||
|
/// array must be valid before calling.
|
||||||
|
/// The P^2 derivative matrix is
|
||||||
|
/// m_{ij} = \frac{dkr_i}{ds^j},
|
||||||
|
/// and is output in Fortran order (m_00 m_10 m_20 m01 ...)
|
||||||
|
template <class SatFuncSet>
|
||||||
|
void SaturationPropsFromDeck<SatFuncSet>::relperm(const int n,
|
||||||
|
const double* s,
|
||||||
|
const int* cells,
|
||||||
|
double* kr,
|
||||||
|
double* dkrds) const
|
||||||
|
{
|
||||||
|
ASSERT (cells != 0);
|
||||||
|
|
||||||
|
const int np = phase_usage_.num_phases;
|
||||||
|
if (dkrds) {
|
||||||
|
// #pragma omp parallel for
|
||||||
|
for (int i = 0; i < n; ++i) {
|
||||||
|
funcForCell(cells[i]).evalKrDeriv(s + np*i, kr + np*i, dkrds + np*np*i);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
// #pragma omp parallel for
|
||||||
|
for (int i = 0; i < n; ++i) {
|
||||||
|
funcForCell(cells[i]).evalKr(s + np*i, kr + np*i);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/// Capillary pressure.
|
||||||
|
/// \param[in] n Number of data points.
|
||||||
|
/// \param[in] s Array of nP saturation values.
|
||||||
|
/// \param[in] cells Array of n cell indices to be associated with the s values.
|
||||||
|
/// \param[out] pc Array of nP capillary pressure values, array must be valid before calling.
|
||||||
|
/// \param[out] dpcds If non-null: array of nP^2 derivative values,
|
||||||
|
/// array must be valid before calling.
|
||||||
|
/// The P^2 derivative matrix is
|
||||||
|
/// m_{ij} = \frac{dpc_i}{ds^j},
|
||||||
|
/// and is output in Fortran order (m_00 m_10 m_20 m01 ...)
|
||||||
|
template <class SatFuncSet>
|
||||||
|
void SaturationPropsFromDeck<SatFuncSet>::capPress(const int n,
|
||||||
|
const double* s,
|
||||||
|
const int* cells,
|
||||||
|
double* pc,
|
||||||
|
double* dpcds) const
|
||||||
|
{
|
||||||
|
ASSERT (cells != 0);
|
||||||
|
|
||||||
|
const int np = phase_usage_.num_phases;
|
||||||
|
if (dpcds) {
|
||||||
|
// #pragma omp parallel for
|
||||||
|
for (int i = 0; i < n; ++i) {
|
||||||
|
funcForCell(cells[i]).evalPcDeriv(s + np*i, pc + np*i, dpcds + np*np*i);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
// #pragma omp parallel for
|
||||||
|
for (int i = 0; i < n; ++i) {
|
||||||
|
funcForCell(cells[i]).evalPc(s + np*i, pc + np*i);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/// Obtain the range of allowable saturation values.
|
||||||
|
/// \param[in] n Number of data points.
|
||||||
|
/// \param[in] cells Array of n cell indices.
|
||||||
|
/// \param[out] smin Array of nP minimum s values, array must be valid before calling.
|
||||||
|
/// \param[out] smax Array of nP maximum s values, array must be valid before calling.
|
||||||
|
template <class SatFuncSet>
|
||||||
|
void SaturationPropsFromDeck<SatFuncSet>::satRange(const int n,
|
||||||
|
const int* cells,
|
||||||
|
double* smin,
|
||||||
|
double* smax) const
|
||||||
|
{
|
||||||
|
ASSERT (cells != 0);
|
||||||
|
|
||||||
|
const int np = phase_usage_.num_phases;
|
||||||
|
for (int i = 0; i < n; ++i) {
|
||||||
|
for (int p = 0; p < np; ++p) {
|
||||||
|
smin[np*i + p] = funcForCell(cells[i]).smin_[p];
|
||||||
|
smax[np*i + p] = funcForCell(cells[i]).smax_[p];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// Map the cell number to the correct function set.
|
||||||
|
template <class SatFuncSet>
|
||||||
|
const typename SaturationPropsFromDeck<SatFuncSet>::Funcs&
|
||||||
|
SaturationPropsFromDeck<SatFuncSet>::funcForCell(const int cell) const
|
||||||
|
{
|
||||||
|
return cell_to_func_.empty() ? satfuncset_[0] : satfuncset_[cell_to_func_[cell]];
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
} // namespace Opm
|
||||||
|
|
||||||
|
#endif // OPM_SATURATIONPROPSFROMDECK_IMPL_HEADER_INCLUDED
|
85
opm/core/fluid/SaturationPropsInterface.hpp
Normal file
85
opm/core/fluid/SaturationPropsInterface.hpp
Normal file
@ -0,0 +1,85 @@
|
|||||||
|
/*
|
||||||
|
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_SATURATIONPROPSINTERFACE_HEADER_INCLUDED
|
||||||
|
#define OPM_SATURATIONPROPSINTERFACE_HEADER_INCLUDED
|
||||||
|
|
||||||
|
#include <opm/core/fluid/blackoil/BlackoilPhases.hpp>
|
||||||
|
|
||||||
|
|
||||||
|
namespace Opm
|
||||||
|
{
|
||||||
|
|
||||||
|
class SaturationPropsInterface : public BlackoilPhases
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
/// Virtual destructor.
|
||||||
|
virtual ~SaturationPropsInterface() {};
|
||||||
|
|
||||||
|
/// \return P, the number of phases.
|
||||||
|
virtual int numPhases() const = 0;
|
||||||
|
|
||||||
|
/// Relative permeability.
|
||||||
|
/// \param[in] n Number of data points.
|
||||||
|
/// \param[in] s Array of nP saturation values.
|
||||||
|
/// \param[out] kr Array of nP relperm values, array must be valid before calling.
|
||||||
|
/// \param[out] dkrds If non-null: array of nP^2 relperm derivative values,
|
||||||
|
/// array must be valid before calling.
|
||||||
|
/// The P^2 derivative matrix is
|
||||||
|
/// m_{ij} = \frac{dkr_i}{ds^j},
|
||||||
|
/// and is output in Fortran order (m_00 m_10 m_20 m01 ...)
|
||||||
|
virtual void relperm(const int n,
|
||||||
|
const double* s,
|
||||||
|
const int* cells,
|
||||||
|
double* kr,
|
||||||
|
double* dkrds) const = 0;
|
||||||
|
|
||||||
|
/// Capillary pressure.
|
||||||
|
/// \param[in] n Number of data points.
|
||||||
|
/// \param[in] s Array of nP saturation values.
|
||||||
|
/// \param[out] pc Array of nP capillary pressure values, array must be valid before calling.
|
||||||
|
/// \param[out] dpcds If non-null: array of nP^2 derivative values,
|
||||||
|
/// array must be valid before calling.
|
||||||
|
/// The P^2 derivative matrix is
|
||||||
|
/// m_{ij} = \frac{dpc_i}{ds^j},
|
||||||
|
/// and is output in Fortran order (m_00 m_10 m_20 m01 ...)
|
||||||
|
virtual void capPress(const int n,
|
||||||
|
const double* s,
|
||||||
|
const int* cells,
|
||||||
|
double* pc,
|
||||||
|
double* dpcds) const = 0;
|
||||||
|
|
||||||
|
/// Obtain the range of allowable saturation values.
|
||||||
|
/// \param[in] n Number of data points.
|
||||||
|
/// \param[out] smin Array of nP minimum s values, array must be valid before calling.
|
||||||
|
/// \param[out] smax Array of nP maximum s values, array must be valid before calling.
|
||||||
|
virtual void satRange(const int n,
|
||||||
|
const int* cells,
|
||||||
|
double* smin,
|
||||||
|
double* smax) const = 0;
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
} // namespace Opm
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
#endif // OPM_SATURATIONPROPSINTERFACE_HEADER_INCLUDED
|
@ -47,7 +47,13 @@ namespace Opm
|
|||||||
BlackoilPvtProperties();
|
BlackoilPvtProperties();
|
||||||
|
|
||||||
/// Initialize from deck.
|
/// Initialize from deck.
|
||||||
void init(const EclipseGridParser& deck);
|
/// \param deck An input deck.
|
||||||
|
/// \param samples If greater than zero, indicates the number of
|
||||||
|
/// uniform samples to be taken from monotone spline
|
||||||
|
/// curves interpolating the fluid data.
|
||||||
|
/// Otherwise, interpolate linearly in the original
|
||||||
|
/// data without fitting a spline.
|
||||||
|
void init(const EclipseGridParser& deck, const int samples);
|
||||||
|
|
||||||
/// Number of active phases.
|
/// Number of active phases.
|
||||||
int numPhases() const;
|
int numPhases() const;
|
||||||
|
@ -31,6 +31,11 @@
|
|||||||
#include <opm/core/linalg/LinearSolverIstl.hpp>
|
#include <opm/core/linalg/LinearSolverIstl.hpp>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#if HAVE_AGMG
|
||||||
|
#include <opm/core/linalg/LinearSolverAGMG.hpp>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
#include <opm/core/utility/parameters/ParameterGroup.hpp>
|
#include <opm/core/utility/parameters/ParameterGroup.hpp>
|
||||||
#include <opm/core/utility/ErrorMacros.hpp>
|
#include <opm/core/utility/ErrorMacros.hpp>
|
||||||
#include <string>
|
#include <string>
|
||||||
@ -70,6 +75,12 @@ namespace Opm
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
else if (ls == "agmg") {
|
||||||
|
#if HAVE_AGMG
|
||||||
|
solver_.reset(new LinearSolverAGMG(param));
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
else {
|
else {
|
||||||
THROW("Linear solver " << ls << " is unknown.");
|
THROW("Linear solver " << ls << " is unknown.");
|
||||||
}
|
}
|
||||||
|
@ -24,10 +24,7 @@
|
|||||||
|
|
||||||
#include <opm/core/linalg/LinearSolverIstl.hpp>
|
#include <opm/core/linalg/LinearSolverIstl.hpp>
|
||||||
|
|
||||||
// Work around the fact that istl headers expect
|
#include <opm/core/utility/have_boost_redef.hpp>
|
||||||
// HAVE_BOOST to be 1, and not just defined.
|
|
||||||
#undef HAVE_BOOST
|
|
||||||
#define HAVE_BOOST 1
|
|
||||||
|
|
||||||
// TODO: clean up includes.
|
// TODO: clean up includes.
|
||||||
#include <dune/common/deprecated.hh>
|
#include <dune/common/deprecated.hh>
|
||||||
|
@ -30,6 +30,7 @@
|
|||||||
#include <opm/core/newwells.h>
|
#include <opm/core/newwells.h>
|
||||||
#include <opm/core/simulator/BlackoilState.hpp>
|
#include <opm/core/simulator/BlackoilState.hpp>
|
||||||
#include <opm/core/simulator/WellState.hpp>
|
#include <opm/core/simulator/WellState.hpp>
|
||||||
|
#include <opm/core/fluid/RockCompressibility.hpp>
|
||||||
|
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
#include <cmath>
|
#include <cmath>
|
||||||
@ -58,6 +59,7 @@ namespace Opm
|
|||||||
/// to change.
|
/// to change.
|
||||||
CompressibleTpfa::CompressibleTpfa(const UnstructuredGrid& grid,
|
CompressibleTpfa::CompressibleTpfa(const UnstructuredGrid& grid,
|
||||||
const BlackoilPropertiesInterface& props,
|
const BlackoilPropertiesInterface& props,
|
||||||
|
const RockCompressibility* rock_comp_props,
|
||||||
const LinearSolverInterface& linsolver,
|
const LinearSolverInterface& linsolver,
|
||||||
const double residual_tol,
|
const double residual_tol,
|
||||||
const double change_tol,
|
const double change_tol,
|
||||||
@ -66,6 +68,7 @@ namespace Opm
|
|||||||
const struct Wells* wells)
|
const struct Wells* wells)
|
||||||
: grid_(grid),
|
: grid_(grid),
|
||||||
props_(props),
|
props_(props),
|
||||||
|
rock_comp_props_(rock_comp_props),
|
||||||
linsolver_(linsolver),
|
linsolver_(linsolver),
|
||||||
residual_tol_(residual_tol),
|
residual_tol_(residual_tol),
|
||||||
change_tol_(change_tol),
|
change_tol_(change_tol),
|
||||||
@ -74,8 +77,8 @@ namespace Opm
|
|||||||
wells_(wells),
|
wells_(wells),
|
||||||
htrans_(grid.cell_facepos[ grid.number_of_cells ]),
|
htrans_(grid.cell_facepos[ grid.number_of_cells ]),
|
||||||
trans_ (grid.number_of_faces),
|
trans_ (grid.number_of_faces),
|
||||||
porevol_(grid.number_of_cells),
|
allcells_(grid.number_of_cells),
|
||||||
allcells_(grid.number_of_cells)
|
singular_(false)
|
||||||
{
|
{
|
||||||
if (wells_ && (wells_->number_of_phases != props.numPhases())) {
|
if (wells_ && (wells_->number_of_phases != props.numPhases())) {
|
||||||
THROW("Inconsistent number of phases specified (wells vs. props): "
|
THROW("Inconsistent number of phases specified (wells vs. props): "
|
||||||
@ -86,7 +89,12 @@ namespace Opm
|
|||||||
UnstructuredGrid* gg = const_cast<UnstructuredGrid*>(&grid_);
|
UnstructuredGrid* gg = const_cast<UnstructuredGrid*>(&grid_);
|
||||||
tpfa_htrans_compute(gg, props.permeability(), &htrans_[0]);
|
tpfa_htrans_compute(gg, props.permeability(), &htrans_[0]);
|
||||||
tpfa_trans_compute(gg, &htrans_[0], &trans_[0]);
|
tpfa_trans_compute(gg, &htrans_[0], &trans_[0]);
|
||||||
|
// If we have rock compressibility, pore volumes are updated
|
||||||
|
// in the compute*() methods, otherwise they are constant and
|
||||||
|
// hence may be computed here.
|
||||||
|
if (rock_comp_props_ == NULL || !rock_comp_props_->isActive()) {
|
||||||
computePorevolume(grid_, props.porosity(), porevol_);
|
computePorevolume(grid_, props.porosity(), porevol_);
|
||||||
|
}
|
||||||
for (int c = 0; c < grid.number_of_cells; ++c) {
|
for (int c = 0; c < grid.number_of_cells; ++c) {
|
||||||
allcells_[c] = c;
|
allcells_[c] = c;
|
||||||
}
|
}
|
||||||
@ -182,6 +190,21 @@ namespace Opm
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/// @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 CompressibleTpfa::singularPressure() const
|
||||||
|
{
|
||||||
|
return singular_;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/// Compute well potentials.
|
/// Compute well potentials.
|
||||||
void CompressibleTpfa::computeWellPotentials(const BlackoilState& state)
|
void CompressibleTpfa::computeWellPotentials(const BlackoilState& state)
|
||||||
{
|
{
|
||||||
@ -230,6 +253,9 @@ namespace Opm
|
|||||||
const WellState& /*well_state*/)
|
const WellState& /*well_state*/)
|
||||||
{
|
{
|
||||||
computeWellPotentials(state);
|
computeWellPotentials(state);
|
||||||
|
if (rock_comp_props_ && rock_comp_props_->isActive()) {
|
||||||
|
computePorevolume(grid_, props_.porosity(), *rock_comp_props_, state.pressure(), initial_porevol_);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -252,6 +278,8 @@ namespace Opm
|
|||||||
// std::vector<double> face_gravcap_;
|
// std::vector<double> face_gravcap_;
|
||||||
// std::vector<double> wellperf_A_;
|
// std::vector<double> wellperf_A_;
|
||||||
// std::vector<double> wellperf_phasemob_;
|
// std::vector<double> wellperf_phasemob_;
|
||||||
|
// 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.
|
||||||
computeCellDynamicData(dt, state, well_state);
|
computeCellDynamicData(dt, state, well_state);
|
||||||
computeFaceDynamicData(dt, state, well_state);
|
computeFaceDynamicData(dt, state, well_state);
|
||||||
computeWellDynamicData(dt, state, well_state);
|
computeWellDynamicData(dt, state, well_state);
|
||||||
@ -273,6 +301,8 @@ namespace Opm
|
|||||||
// std::vector<double> cell_viscosity_;
|
// std::vector<double> cell_viscosity_;
|
||||||
// std::vector<double> cell_phasemob_;
|
// std::vector<double> cell_phasemob_;
|
||||||
// std::vector<double> cell_voldisc_;
|
// std::vector<double> cell_voldisc_;
|
||||||
|
// 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.
|
||||||
const int nc = grid_.number_of_cells;
|
const int nc = grid_.number_of_cells;
|
||||||
const int np = props_.numPhases();
|
const int np = props_.numPhases();
|
||||||
const double* cell_p = &state.pressure()[0];
|
const double* cell_p = &state.pressure()[0];
|
||||||
@ -296,6 +326,14 @@ namespace Opm
|
|||||||
// TODO: Check this!
|
// TODO: Check this!
|
||||||
cell_voldisc_.clear();
|
cell_voldisc_.clear();
|
||||||
cell_voldisc_.resize(nc, 0.0);
|
cell_voldisc_.resize(nc, 0.0);
|
||||||
|
|
||||||
|
if (rock_comp_props_ && rock_comp_props_->isActive()) {
|
||||||
|
computePorevolume(grid_, props_.porosity(), *rock_comp_props_, state.pressure(), porevol_);
|
||||||
|
rock_comp_.resize(nc);
|
||||||
|
for (int cell = 0; cell < nc; ++cell) {
|
||||||
|
rock_comp_[cell] = rock_comp_props_->rockComp(state.pressure()[cell]);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -341,7 +379,7 @@ namespace Opm
|
|||||||
const double depth_diff = face_depth - grid_.cell_centroids[c[j]*dim + dim - 1];
|
const double depth_diff = face_depth - grid_.cell_centroids[c[j]*dim + dim - 1];
|
||||||
props_.density(1, &cell_A_[np*np*c[j]], &gravcontrib[j][0]);
|
props_.density(1, &cell_A_[np*np*c[j]], &gravcontrib[j][0]);
|
||||||
for (int p = 0; p < np; ++p) {
|
for (int p = 0; p < np; ++p) {
|
||||||
gravcontrib[j][p] *= depth_diff;
|
gravcontrib[j][p] *= depth_diff*grav;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
std::fill(gravcontrib[j].begin(), gravcontrib[j].end(), 0.0);
|
std::fill(gravcontrib[j].begin(), gravcontrib[j].end(), 0.0);
|
||||||
@ -465,9 +503,20 @@ namespace Opm
|
|||||||
cq.Af = &face_A_[0];
|
cq.Af = &face_A_[0];
|
||||||
cq.phasemobf = &face_phasemob_[0];
|
cq.phasemobf = &face_phasemob_[0];
|
||||||
cq.voldiscr = &cell_voldisc_[0];
|
cq.voldiscr = &cell_voldisc_[0];
|
||||||
|
int was_adjusted = 0;
|
||||||
|
if (! (rock_comp_props_ && rock_comp_props_->isActive())) {
|
||||||
|
was_adjusted =
|
||||||
cfs_tpfa_res_assemble(gg, dt, &forces, z, &cq, &trans_[0],
|
cfs_tpfa_res_assemble(gg, dt, &forces, z, &cq, &trans_[0],
|
||||||
&face_gravcap_[0], cell_press, well_bhp,
|
&face_gravcap_[0], cell_press, well_bhp,
|
||||||
&porevol_[0], h_);
|
&porevol_[0], h_);
|
||||||
|
} else {
|
||||||
|
was_adjusted =
|
||||||
|
cfs_tpfa_res_comprock_assemble(gg, dt, &forces, z, &cq, &trans_[0],
|
||||||
|
&face_gravcap_[0], cell_press, well_bhp,
|
||||||
|
&porevol_[0], &initial_porevol_[0],
|
||||||
|
&rock_comp_[0], h_);
|
||||||
|
}
|
||||||
|
singular_ = (was_adjusted == 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -33,6 +33,7 @@ namespace Opm
|
|||||||
|
|
||||||
class BlackoilState;
|
class BlackoilState;
|
||||||
class BlackoilPropertiesInterface;
|
class BlackoilPropertiesInterface;
|
||||||
|
class RockCompressibility;
|
||||||
class LinearSolverInterface;
|
class LinearSolverInterface;
|
||||||
class WellState;
|
class WellState;
|
||||||
|
|
||||||
@ -46,6 +47,7 @@ namespace Opm
|
|||||||
/// Construct solver.
|
/// Construct solver.
|
||||||
/// \param[in] grid A 2d or 3d grid.
|
/// \param[in] grid A 2d or 3d grid.
|
||||||
/// \param[in] props Rock and fluid properties.
|
/// \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] linsolver Linear solver to use.
|
||||||
/// \param[in] residual_tol Solution accepted if inf-norm of residual is smaller.
|
/// \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] change_tol Solution accepted if inf-norm of change in pressure is smaller.
|
||||||
@ -61,6 +63,7 @@ namespace Opm
|
|||||||
/// to change.
|
/// to change.
|
||||||
CompressibleTpfa(const UnstructuredGrid& grid,
|
CompressibleTpfa(const UnstructuredGrid& grid,
|
||||||
const BlackoilPropertiesInterface& props,
|
const BlackoilPropertiesInterface& props,
|
||||||
|
const RockCompressibility* rock_comp_props,
|
||||||
const LinearSolverInterface& linsolver,
|
const LinearSolverInterface& linsolver,
|
||||||
const double residual_tol,
|
const double residual_tol,
|
||||||
const double change_tol,
|
const double change_tol,
|
||||||
@ -78,15 +81,22 @@ namespace Opm
|
|||||||
BlackoilState& state,
|
BlackoilState& state,
|
||||||
WellState& well_state);
|
WellState& well_state);
|
||||||
|
|
||||||
|
/// @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;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void computePerSolveDynamicData(const double dt,
|
virtual void computePerSolveDynamicData(const double dt,
|
||||||
const BlackoilState& state,
|
const BlackoilState& state,
|
||||||
const WellState& well_state);
|
const WellState& well_state);
|
||||||
void computeWellPotentials(const BlackoilState& state);
|
|
||||||
void computePerIterationDynamicData(const double dt,
|
void computePerIterationDynamicData(const double dt,
|
||||||
const BlackoilState& state,
|
const BlackoilState& state,
|
||||||
const WellState& well_state);
|
const WellState& well_state);
|
||||||
void computeCellDynamicData(const double dt,
|
virtual void computeCellDynamicData(const double dt,
|
||||||
const BlackoilState& state,
|
const BlackoilState& state,
|
||||||
const WellState& well_state);
|
const WellState& well_state);
|
||||||
void computeFaceDynamicData(const double dt,
|
void computeFaceDynamicData(const double dt,
|
||||||
@ -103,10 +113,13 @@ namespace Opm
|
|||||||
double incrementNorm() const;
|
double incrementNorm() const;
|
||||||
void computeResults(BlackoilState& state,
|
void computeResults(BlackoilState& state,
|
||||||
WellState& well_state) const;
|
WellState& well_state) const;
|
||||||
|
protected:
|
||||||
|
void computeWellPotentials(const BlackoilState& state);
|
||||||
|
|
||||||
// ------ Data that will remain unmodified after construction. ------
|
// ------ Data that will remain unmodified after construction. ------
|
||||||
const UnstructuredGrid& grid_;
|
const UnstructuredGrid& grid_;
|
||||||
const BlackoilPropertiesInterface& props_;
|
const BlackoilPropertiesInterface& props_;
|
||||||
|
const RockCompressibility* rock_comp_props_;
|
||||||
const LinearSolverInterface& linsolver_;
|
const LinearSolverInterface& linsolver_;
|
||||||
const double residual_tol_;
|
const double residual_tol_;
|
||||||
const double change_tol_;
|
const double change_tol_;
|
||||||
@ -115,7 +128,6 @@ namespace Opm
|
|||||||
const Wells* wells_; // May be NULL, outside may modify controls (only) between calls to solve().
|
const Wells* wells_; // May be NULL, outside may modify controls (only) between calls to solve().
|
||||||
std::vector<double> htrans_;
|
std::vector<double> htrans_;
|
||||||
std::vector<double> trans_ ;
|
std::vector<double> trans_ ;
|
||||||
std::vector<double> porevol_;
|
|
||||||
std::vector<int> allcells_;
|
std::vector<int> allcells_;
|
||||||
|
|
||||||
// ------ Internal data for the cfs_tpfa_res solver. ------
|
// ------ Internal data for the cfs_tpfa_res solver. ------
|
||||||
@ -123,6 +135,7 @@ namespace Opm
|
|||||||
|
|
||||||
// ------ Data that will be modified for every solve. ------
|
// ------ Data that will be modified for every solve. ------
|
||||||
std::vector<double> wellperf_gpot_;
|
std::vector<double> wellperf_gpot_;
|
||||||
|
std::vector<double> initial_porevol_;
|
||||||
|
|
||||||
// ------ Data that will be modified for every solver iteration. ------
|
// ------ Data that will be modified for every solver iteration. ------
|
||||||
std::vector<double> cell_A_;
|
std::vector<double> cell_A_;
|
||||||
@ -135,13 +148,15 @@ namespace Opm
|
|||||||
std::vector<double> face_gravcap_;
|
std::vector<double> face_gravcap_;
|
||||||
std::vector<double> wellperf_A_;
|
std::vector<double> wellperf_A_;
|
||||||
std::vector<double> wellperf_phasemob_;
|
std::vector<double> wellperf_phasemob_;
|
||||||
|
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.
|
||||||
// The update to be applied to the pressures (cell and bhp).
|
// The update to be applied to the pressures (cell and bhp).
|
||||||
std::vector<double> pressure_increment_;
|
std::vector<double> pressure_increment_;
|
||||||
|
// 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_;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace Opm
|
} // namespace Opm
|
||||||
|
@ -1156,7 +1156,7 @@ cfs_tpfa_res_construct(struct UnstructuredGrid *G ,
|
|||||||
|
|
||||||
|
|
||||||
/* ---------------------------------------------------------------------- */
|
/* ---------------------------------------------------------------------- */
|
||||||
void
|
int
|
||||||
cfs_tpfa_res_assemble(struct UnstructuredGrid *G ,
|
cfs_tpfa_res_assemble(struct UnstructuredGrid *G ,
|
||||||
double dt ,
|
double dt ,
|
||||||
struct cfs_tpfa_res_forces *forces ,
|
struct cfs_tpfa_res_forces *forces ,
|
||||||
@ -1170,7 +1170,7 @@ cfs_tpfa_res_assemble(struct UnstructuredGrid *G ,
|
|||||||
struct cfs_tpfa_res_data *h )
|
struct cfs_tpfa_res_data *h )
|
||||||
/* ---------------------------------------------------------------------- */
|
/* ---------------------------------------------------------------------- */
|
||||||
{
|
{
|
||||||
int res_is_neumann, well_is_neumann, c, np2;
|
int res_is_neumann, well_is_neumann, c, np2, singular;
|
||||||
|
|
||||||
csrmatrix_zero( h->J);
|
csrmatrix_zero( h->J);
|
||||||
vector_zero (h->J->m, h->F);
|
vector_zero (h->J->m, h->F);
|
||||||
@ -1207,9 +1207,76 @@ cfs_tpfa_res_assemble(struct UnstructuredGrid *G ,
|
|||||||
assemble_sources(dt, forces->src, h);
|
assemble_sources(dt, forces->src, h);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (res_is_neumann && well_is_neumann && h->pimpl->is_incomp) {
|
singular = res_is_neumann && well_is_neumann && h->pimpl->is_incomp;
|
||||||
h->J->sa[0] *= 2;
|
if (singular) {
|
||||||
|
h->J->sa[0] *= 2.0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return singular;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/* ---------------------------------------------------------------------- */
|
||||||
|
int
|
||||||
|
cfs_tpfa_res_comprock_assemble(
|
||||||
|
struct UnstructuredGrid *G ,
|
||||||
|
double dt ,
|
||||||
|
struct cfs_tpfa_res_forces *forces ,
|
||||||
|
const double *zc ,
|
||||||
|
struct compr_quantities_gen *cq ,
|
||||||
|
const double *trans ,
|
||||||
|
const double *gravcap_f,
|
||||||
|
const double *cpress ,
|
||||||
|
const double *wpress ,
|
||||||
|
const double *porevol ,
|
||||||
|
const double *porevol0 ,
|
||||||
|
const double *rock_comp,
|
||||||
|
struct cfs_tpfa_res_data *h )
|
||||||
|
/* ---------------------------------------------------------------------- */
|
||||||
|
{
|
||||||
|
/* We want to add this term to the usual residual:
|
||||||
|
*
|
||||||
|
* (porevol(pressure)-porevol(initial_pressure))/dt.
|
||||||
|
*
|
||||||
|
* Its derivative (for the diagonal term of the Jacobian) is:
|
||||||
|
*
|
||||||
|
* porevol(pressure)*rock_comp(pressure)/dt
|
||||||
|
*/
|
||||||
|
|
||||||
|
int c, rock_is_incomp, singular;
|
||||||
|
size_t j;
|
||||||
|
double dpv;
|
||||||
|
|
||||||
|
/* Assemble usual system (without rock compressibility). */
|
||||||
|
singular = cfs_tpfa_res_assemble(G, dt, forces, zc, cq, trans, gravcap_f,
|
||||||
|
cpress, wpress, porevol0, h);
|
||||||
|
|
||||||
|
/* If we made a singularity-removing adjustment in the
|
||||||
|
regular assembly, we undo it here. */
|
||||||
|
if (singular) {
|
||||||
|
h->J->sa[0] /= 2.0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Add new terms to residual and Jacobian. */
|
||||||
|
rock_is_incomp = 1;
|
||||||
|
for (c = 0; c < G->number_of_cells; c++) {
|
||||||
|
j = csrmatrix_elm_index(c, c, h->J);
|
||||||
|
|
||||||
|
dpv = (porevol[c] - porevol0[c]);
|
||||||
|
if (dpv != 0.0 || rock_comp[c] != 0.0) {
|
||||||
|
rock_is_incomp = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
h->J->sa[j] += porevol[c] * rock_comp[c];
|
||||||
|
h->F[c] += dpv;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Re-do the singularity-removing adjustment if necessary */
|
||||||
|
if (rock_is_incomp && singular) {
|
||||||
|
h->J->sa[0] *= 2.0;
|
||||||
|
}
|
||||||
|
|
||||||
|
return rock_is_incomp && singular;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -59,7 +59,11 @@ cfs_tpfa_res_construct(struct UnstructuredGrid *G ,
|
|||||||
void
|
void
|
||||||
cfs_tpfa_res_destroy(struct cfs_tpfa_res_data *h);
|
cfs_tpfa_res_destroy(struct cfs_tpfa_res_data *h);
|
||||||
|
|
||||||
void
|
/* Return value is 1 if the assembled matrix was adjusted to remove a
|
||||||
|
singularity. This happens if all fluids are incompressible and
|
||||||
|
there are no pressure conditions on wells or boundaries.
|
||||||
|
Otherwise return 0. */
|
||||||
|
int
|
||||||
cfs_tpfa_res_assemble(struct UnstructuredGrid *G,
|
cfs_tpfa_res_assemble(struct UnstructuredGrid *G,
|
||||||
double dt,
|
double dt,
|
||||||
struct cfs_tpfa_res_forces *forces,
|
struct cfs_tpfa_res_forces *forces,
|
||||||
@ -72,6 +76,27 @@ cfs_tpfa_res_assemble(struct UnstructuredGrid *G,
|
|||||||
const double *porevol,
|
const double *porevol,
|
||||||
struct cfs_tpfa_res_data *h);
|
struct cfs_tpfa_res_data *h);
|
||||||
|
|
||||||
|
/* Return value is 1 if the assembled matrix was adjusted to remove a
|
||||||
|
singularity. This happens if all fluids are incompressible, the
|
||||||
|
rock is incompressible, and there are no pressure conditions on
|
||||||
|
wells or boundaries.
|
||||||
|
Otherwise return 0. */
|
||||||
|
int
|
||||||
|
cfs_tpfa_res_comprock_assemble(
|
||||||
|
struct UnstructuredGrid *G,
|
||||||
|
double dt,
|
||||||
|
struct cfs_tpfa_res_forces *forces,
|
||||||
|
const double *zc,
|
||||||
|
struct compr_quantities_gen *cq,
|
||||||
|
const double *trans,
|
||||||
|
const double *gravcap_f,
|
||||||
|
const double *cpress,
|
||||||
|
const double *wpress,
|
||||||
|
const double *porevol,
|
||||||
|
const double *porevol0,
|
||||||
|
const double *rock_comp,
|
||||||
|
struct cfs_tpfa_res_data *h);
|
||||||
|
|
||||||
void
|
void
|
||||||
cfs_tpfa_res_flux(struct UnstructuredGrid *G ,
|
cfs_tpfa_res_flux(struct UnstructuredGrid *G ,
|
||||||
struct cfs_tpfa_res_forces *forces ,
|
struct cfs_tpfa_res_forces *forces ,
|
||||||
|
@ -771,7 +771,7 @@ ifs_tpfa_assemble_comprock_increment(struct UnstructuredGrid *G ,
|
|||||||
assemble_incompressible(G, F, trans, gpress, h, &system_singular, &ok);
|
assemble_incompressible(G, F, trans, gpress, h, &system_singular, &ok);
|
||||||
|
|
||||||
/* We want to solve a Newton step for the residual
|
/* We want to solve a Newton step for the residual
|
||||||
* (porevol(pressure)-porevol(initial_pressure))/dt + residual_for_imcompressible
|
* (porevol(pressure)-porevol(initial_pressure))/dt + residual_for_incompressible
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
@ -20,6 +20,16 @@
|
|||||||
#ifndef OPM_IFS_TPFA_HEADER_INCLUDED
|
#ifndef OPM_IFS_TPFA_HEADER_INCLUDED
|
||||||
#define OPM_IFS_TPFA_HEADER_INCLUDED
|
#define OPM_IFS_TPFA_HEADER_INCLUDED
|
||||||
|
|
||||||
|
/**
|
||||||
|
* \file
|
||||||
|
* Interfaces and data structures to assemble a system of simultaneous linear
|
||||||
|
* equations discretising a flow problem that is either incompressible or
|
||||||
|
* features rock compressibility using the two-point flux approximation method.
|
||||||
|
*
|
||||||
|
* Includes support for reconstructing the Darcy flux field as well as well
|
||||||
|
* connection fluxes.
|
||||||
|
*/
|
||||||
|
|
||||||
#include <opm/core/grid.h>
|
#include <opm/core/grid.h>
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
@ -31,37 +41,66 @@ struct CSRMatrix;
|
|||||||
struct FlowBoundaryConditions;
|
struct FlowBoundaryConditions;
|
||||||
struct Wells;
|
struct Wells;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Main data structure presenting a view of an assembled system of simultaneous
|
||||||
|
* linear equations which may be solved using external software.
|
||||||
|
*/
|
||||||
struct ifs_tpfa_data {
|
struct ifs_tpfa_data {
|
||||||
struct CSRMatrix *A;
|
struct CSRMatrix *A; /**< Coefficient matrix */
|
||||||
double *b;
|
double *b; /**< Right-hand side */
|
||||||
double *x;
|
double *x; /**< Solution */
|
||||||
|
|
||||||
struct ifs_tpfa_impl *pimpl;
|
struct ifs_tpfa_impl *pimpl; /**< Internal management structure */
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Solution variables.
|
||||||
|
*/
|
||||||
struct ifs_tpfa_solution {
|
struct ifs_tpfa_solution {
|
||||||
double *cell_press;
|
double *cell_press; /**< Cell pressures */
|
||||||
double *face_flux ;
|
double *face_flux ; /**< Interface fluxes */
|
||||||
|
|
||||||
double *well_press; /* BHP */
|
double *well_press; /**< Bottom-hole pressures for each well */
|
||||||
double *well_flux ; /* Perforation (total) fluxes */
|
double *well_flux ; /**< Well connection total fluxes */
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Driving forces pertaining to a particular model setup.
|
||||||
|
*/
|
||||||
struct ifs_tpfa_forces {
|
struct ifs_tpfa_forces {
|
||||||
const double *src;
|
const double *src; /**< Explicit source terms */
|
||||||
const struct FlowBoundaryConditions *bc ;
|
const struct FlowBoundaryConditions *bc ; /**< Boundary conditions */
|
||||||
|
|
||||||
const struct Wells *W ;
|
const struct Wells *W ; /**< Well topology */
|
||||||
const double *totmob;
|
const double *totmob; /**< Total mobility in each cell */
|
||||||
const double *wdp ;
|
const double *wdp ; /**< Gravity adjustment at each perforation */
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Allocate TPFA management structure capable of assembling a system of
|
||||||
|
* simultaneous linear equations corresponding to a particular grid and well
|
||||||
|
* configuration.
|
||||||
|
*
|
||||||
|
* @param[in] G Grid.
|
||||||
|
* @param[in] W Well topology.
|
||||||
|
* @return Fully formed TPFA management structure if successful, @c NULL in case
|
||||||
|
* of allocation failure.
|
||||||
|
*/
|
||||||
struct ifs_tpfa_data *
|
struct ifs_tpfa_data *
|
||||||
ifs_tpfa_construct(struct UnstructuredGrid *G,
|
ifs_tpfa_construct(struct UnstructuredGrid *G,
|
||||||
struct Wells *W);
|
struct Wells *W);
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @param[in] G
|
||||||
|
* @param[in] F
|
||||||
|
* @param[in] trans
|
||||||
|
* @param[in] gpress
|
||||||
|
* @param[in,out] h
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
int
|
int
|
||||||
ifs_tpfa_assemble(struct UnstructuredGrid *G ,
|
ifs_tpfa_assemble(struct UnstructuredGrid *G ,
|
||||||
const struct ifs_tpfa_forces *F ,
|
const struct ifs_tpfa_forces *F ,
|
||||||
|
@ -42,6 +42,12 @@ namespace Opm
|
|||||||
<< "\n Pressure time: " << pressure_time
|
<< "\n Pressure time: " << pressure_time
|
||||||
<< "\n Transport time: " << transport_time << std::endl;
|
<< "\n Transport time: " << transport_time << std::endl;
|
||||||
}
|
}
|
||||||
|
void SimulatorReport::reportParam(std::ostream& os)
|
||||||
|
{
|
||||||
|
os << "/timing/total_time=" << total_time
|
||||||
|
<< "\n/timing/pressure/total_time=" << pressure_time
|
||||||
|
<< "\n/timing/transport/total_time=" << transport_time << std::endl;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
} // namespace Opm
|
} // namespace Opm
|
||||||
|
@ -38,6 +38,7 @@ namespace Opm
|
|||||||
void operator+=(const SimulatorReport& sr);
|
void operator+=(const SimulatorReport& sr);
|
||||||
/// Print a report to the given stream.
|
/// Print a report to the given stream.
|
||||||
void report(std::ostream& os);
|
void report(std::ostream& os);
|
||||||
|
void reportParam(std::ostream& os);
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace Opm
|
} // namespace Opm
|
||||||
|
@ -24,6 +24,7 @@
|
|||||||
#include <opm/core/transport/reorder/reordersequence.h>
|
#include <opm/core/transport/reorder/reordersequence.h>
|
||||||
#include <opm/core/utility/RootFinders.hpp>
|
#include <opm/core/utility/RootFinders.hpp>
|
||||||
#include <opm/core/utility/miscUtilities.hpp>
|
#include <opm/core/utility/miscUtilities.hpp>
|
||||||
|
#include <opm/core/utility/miscUtilitiesBlackoil.hpp>
|
||||||
#include <opm/core/pressure/tpfa/trans_tpfa.h>
|
#include <opm/core/pressure/tpfa/trans_tpfa.h>
|
||||||
|
|
||||||
#include <fstream>
|
#include <fstream>
|
||||||
@ -38,7 +39,8 @@ namespace Opm
|
|||||||
typedef RegulaFalsi<WarnAndContinueOnError> RootFinder;
|
typedef RegulaFalsi<WarnAndContinueOnError> RootFinder;
|
||||||
|
|
||||||
|
|
||||||
TransportModelCompressibleTwophase::TransportModelCompressibleTwophase(const UnstructuredGrid& grid,
|
TransportModelCompressibleTwophase::TransportModelCompressibleTwophase(
|
||||||
|
const UnstructuredGrid& grid,
|
||||||
const Opm::BlackoilPropertiesInterface& props,
|
const Opm::BlackoilPropertiesInterface& props,
|
||||||
const double tol,
|
const double tol,
|
||||||
const int maxit)
|
const int maxit)
|
||||||
@ -51,6 +53,7 @@ namespace Opm
|
|||||||
dt_(0.0),
|
dt_(0.0),
|
||||||
saturation_(grid.number_of_cells, -1.0),
|
saturation_(grid.number_of_cells, -1.0),
|
||||||
fractionalflow_(grid.number_of_cells, -1.0),
|
fractionalflow_(grid.number_of_cells, -1.0),
|
||||||
|
gravity_(0),
|
||||||
mob_(2*grid.number_of_cells, -1.0),
|
mob_(2*grid.number_of_cells, -1.0),
|
||||||
ia_upw_(grid.number_of_cells + 1, -1),
|
ia_upw_(grid.number_of_cells + 1, -1),
|
||||||
ja_upw_(grid.number_of_faces, -1),
|
ja_upw_(grid.number_of_faces, -1),
|
||||||
@ -75,14 +78,16 @@ namespace Opm
|
|||||||
|
|
||||||
void TransportModelCompressibleTwophase::solve(const double* darcyflux,
|
void TransportModelCompressibleTwophase::solve(const double* darcyflux,
|
||||||
const double* pressure,
|
const double* pressure,
|
||||||
const double* surfacevol0,
|
const double* porevolume0,
|
||||||
const double* porevolume,
|
const double* porevolume,
|
||||||
const double* source,
|
const double* source,
|
||||||
const double dt,
|
const double dt,
|
||||||
std::vector<double>& saturation)
|
std::vector<double>& saturation,
|
||||||
|
std::vector<double>& surfacevol)
|
||||||
{
|
{
|
||||||
darcyflux_ = darcyflux;
|
darcyflux_ = darcyflux;
|
||||||
surfacevol0_ = surfacevol0;
|
surfacevol0_ = &surfacevol[0];
|
||||||
|
porevolume0_ = porevolume0;
|
||||||
porevolume_ = porevolume;
|
porevolume_ = porevolume;
|
||||||
source_ = source;
|
source_ = source;
|
||||||
dt_ = dt;
|
dt_ = dt;
|
||||||
@ -91,6 +96,11 @@ namespace Opm
|
|||||||
props_.viscosity(props_.numCells(), pressure, NULL, &allcells_[0], &visc_[0], NULL);
|
props_.viscosity(props_.numCells(), pressure, NULL, &allcells_[0], &visc_[0], NULL);
|
||||||
props_.matrix(props_.numCells(), pressure, NULL, &allcells_[0], &A_[0], NULL);
|
props_.matrix(props_.numCells(), pressure, NULL, &allcells_[0], &A_[0], NULL);
|
||||||
|
|
||||||
|
// Check immiscibility requirement (only done for first cell).
|
||||||
|
if (A_[1] != 0.0 || A_[2] != 0.0) {
|
||||||
|
THROW("TransportModelCompressibleTwophase requires a property object without miscibility.");
|
||||||
|
}
|
||||||
|
|
||||||
std::vector<int> seq(grid_.number_of_cells);
|
std::vector<int> seq(grid_.number_of_cells);
|
||||||
std::vector<int> comp(grid_.number_of_cells + 1);
|
std::vector<int> comp(grid_.number_of_cells + 1);
|
||||||
int ncomp;
|
int ncomp;
|
||||||
@ -105,43 +115,47 @@ namespace Opm
|
|||||||
&ia_downw_[0], &ja_downw_[0]);
|
&ia_downw_[0], &ja_downw_[0]);
|
||||||
reorderAndTransport(grid_, darcyflux);
|
reorderAndTransport(grid_, darcyflux);
|
||||||
toBothSat(saturation_, saturation);
|
toBothSat(saturation_, saturation);
|
||||||
|
|
||||||
|
// Compute surface volume as a postprocessing step from saturation and A_
|
||||||
|
computeSurfacevol(grid_.number_of_cells, props_.numPhases(), &A_[0], &saturation[0], &surfacevol[0]);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Residual function r(s) for a single-cell implicit Euler transport
|
// Residual function r(s) for a single-cell implicit Euler transport
|
||||||
//
|
//
|
||||||
// [[ incompressible was: r(s) = s - s0 + dt/pv*( influx + outflux*f(s) ) ]]
|
// [[ incompressible was: r(s) = s - s0 + dt/pv*( influx + outflux*f(s) ) ]]
|
||||||
//
|
//
|
||||||
// r(s) = s - B*z0 + dt/pv*( influx + outflux*f(s))
|
// r(s) = s - B*z0 + s*(poro - poro0)/poro0 + dt/pv*( influx + outflux*f(s) )
|
||||||
//
|
//
|
||||||
// @@@ What about the source term
|
// @@@ What about the source term
|
||||||
//
|
//
|
||||||
// where influx is water influx, outflux is total outflux.
|
// where influx is water influx, outflux is total outflux.
|
||||||
// We need the formula influx = B_i sum_{j->i} b_j v_{ij} + q_w.
|
// We need the formula influx = B_i sum_{j->i} b_j v_{ij} - B_i q_w.
|
||||||
// outflux = B_i sum_{i->j} b_i v_{ij} - q = sum_{i->j} v_{ij} - q (as before)
|
// outflux = B_i sum_{i->j} b_i v_{ij} - B_i q = sum_{i->j} v_{ij} - B_i q
|
||||||
// Influxes are negative, outfluxes positive.
|
// Influxes are negative, outfluxes positive.
|
||||||
struct TransportModelCompressibleTwophase::Residual
|
struct TransportModelCompressibleTwophase::Residual
|
||||||
{
|
{
|
||||||
int cell;
|
int cell;
|
||||||
double s0;
|
double B_cell;
|
||||||
double influx; // sum_j min(v_ij, 0)*f(s_j) + q_w // TODO: fix comment.
|
double z0;
|
||||||
double outflux; // sum_j max(v_ij, 0) - q
|
double influx; // B_i sum_j b_j min(v_ij, 0)*f(s_j) - B_i q_w
|
||||||
|
double outflux; // sum_j max(v_ij, 0) - B_i q
|
||||||
// @@@ TODO: figure out change to rock-comp. terms with fluid compr.
|
// @@@ TODO: figure out change to rock-comp. terms with fluid compr.
|
||||||
// double comp_term; // q - sum_j v_ij
|
double comp_term; // Now: used to be: q - sum_j v_ij
|
||||||
double dtpv; // dt/pv(i)
|
double dtpv; // dt/pv(i)
|
||||||
const TransportModelCompressibleTwophase& tm;
|
const TransportModelCompressibleTwophase& tm;
|
||||||
explicit Residual(const TransportModelCompressibleTwophase& tmodel, int cell_index)
|
explicit Residual(const TransportModelCompressibleTwophase& tmodel, int cell_index)
|
||||||
: tm(tmodel)
|
: tm(tmodel)
|
||||||
{
|
{
|
||||||
cell = cell_index;
|
cell = cell_index;
|
||||||
s0 = tm.saturation_[cell];
|
|
||||||
const int np = tm.props_.numPhases();
|
const int np = tm.props_.numPhases();
|
||||||
const double B_cell = 1.0/tm.A_[np*np*cell + 0];
|
z0 = tm.surfacevol0_[np*cell + 0]; // I.e. water surface volume
|
||||||
|
B_cell = 1.0/tm.A_[np*np*cell + 0];
|
||||||
double src_flux = -tm.source_[cell];
|
double src_flux = -tm.source_[cell];
|
||||||
bool src_is_inflow = src_flux < 0.0;
|
bool src_is_inflow = src_flux < 0.0;
|
||||||
influx = src_is_inflow ? src_flux : 0.0;
|
influx = src_is_inflow ? B_cell*src_flux : 0.0;
|
||||||
outflux = !src_is_inflow ? src_flux : 0.0;
|
outflux = !src_is_inflow ? B_cell*src_flux : 0.0;
|
||||||
// comp_term = tm.source_[cell]; // Note: this assumes that all source flux is water.
|
comp_term = (tm.porevolume_[cell] - tm.porevolume0_[cell])/tm.porevolume0_[cell];
|
||||||
dtpv = tm.dt_/tm.porevolume_[cell];
|
dtpv = tm.dt_/tm.porevolume0_[cell];
|
||||||
for (int i = tm.grid_.cell_facepos[cell]; i < tm.grid_.cell_facepos[cell+1]; ++i) {
|
for (int i = tm.grid_.cell_facepos[cell]; i < tm.grid_.cell_facepos[cell+1]; ++i) {
|
||||||
const int f = tm.grid_.cell_faces[i];
|
const int f = tm.grid_.cell_faces[i];
|
||||||
double flux;
|
double flux;
|
||||||
@ -160,16 +174,15 @@ namespace Opm
|
|||||||
const double b_face = tm.A_[np*np*other + 0];
|
const double b_face = tm.A_[np*np*other + 0];
|
||||||
influx += B_cell*b_face*flux*tm.fractionalflow_[other];
|
influx += B_cell*b_face*flux*tm.fractionalflow_[other];
|
||||||
} else {
|
} else {
|
||||||
outflux += flux;
|
outflux += flux; // Because B_cell*b_face = 1 for outflow faces
|
||||||
}
|
}
|
||||||
// comp_term -= flux;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
double operator()(double s) const
|
double operator()(double s) const
|
||||||
{
|
{
|
||||||
// return s - s0 + dtpv*(outflux*tm.fracFlow(s, cell) + influx + s*comp_term);
|
// return s - s0 + dtpv*(outflux*tm.fracFlow(s, cell) + influx + s*comp_term);
|
||||||
return s - s0 + dtpv*(outflux*tm.fracFlow(s, cell) + influx);
|
return s - B_cell*z0 + dtpv*(outflux*tm.fracFlow(s, cell) + influx) + s*comp_term;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -252,6 +265,8 @@ namespace Opm
|
|||||||
++update_count;
|
++update_count;
|
||||||
const int cell = cells[i];
|
const int cell = cells[i];
|
||||||
const double old_s = saturation_[cell];
|
const double old_s = saturation_[cell];
|
||||||
|
// solveSingleCell() requires saturation_[cell]
|
||||||
|
// to be s0.
|
||||||
saturation_[cell] = s0[i];
|
saturation_[cell] = s0[i];
|
||||||
solveSingleCell(cell);
|
solveSingleCell(cell);
|
||||||
const double s_change = std::fabs(saturation_[cell] - old_s);
|
const double s_change = std::fabs(saturation_[cell] - old_s);
|
||||||
@ -303,8 +318,9 @@ namespace Opm
|
|||||||
|
|
||||||
// Residual function r(s) for a single-cell implicit Euler gravity segregation
|
// Residual function r(s) for a single-cell implicit Euler gravity segregation
|
||||||
//
|
//
|
||||||
// r(s) = s - s0 + dt/pv*sum_{j adj i}( gravmod_ij * gf_ij ).
|
// [[ incompressible was: r(s) = s - s0 + dt/pv*sum_{j adj i}( gravmod_ij * gf_ij ) ]]
|
||||||
//
|
//
|
||||||
|
// r(s) = s - B*z0 + dt/pv*( influx + outflux*f(s) )
|
||||||
struct TransportModelCompressibleTwophase::GravityResidual
|
struct TransportModelCompressibleTwophase::GravityResidual
|
||||||
{
|
{
|
||||||
int cell;
|
int cell;
|
||||||
@ -333,7 +349,7 @@ namespace Opm
|
|||||||
gf[1] = gravflux[pos];
|
gf[1] = gravflux[pos];
|
||||||
}
|
}
|
||||||
s0 = tm.saturation_[cell];
|
s0 = tm.saturation_[cell];
|
||||||
dtpv = tm.dt_/tm.porevolume_[cell];
|
dtpv = tm.dt_/tm.porevolume0_[cell];
|
||||||
|
|
||||||
}
|
}
|
||||||
double operator()(double s) const
|
double operator()(double s) const
|
||||||
@ -372,30 +388,54 @@ namespace Opm
|
|||||||
|
|
||||||
void TransportModelCompressibleTwophase::initGravity(const double* grav)
|
void TransportModelCompressibleTwophase::initGravity(const double* grav)
|
||||||
{
|
{
|
||||||
// Set up gravflux_ = T_ij g (rho_w - rho_o) (z_i - z_j)
|
// Set up transmissibilities.
|
||||||
std::vector<double> htrans(grid_.cell_facepos[grid_.number_of_cells]);
|
std::vector<double> htrans(grid_.cell_facepos[grid_.number_of_cells]);
|
||||||
const int nf = grid_.number_of_faces;
|
const int nf = grid_.number_of_faces;
|
||||||
const int dim = grid_.dimensions;
|
trans_.resize(nf);
|
||||||
gravflux_.resize(nf);
|
gravflux_.resize(nf);
|
||||||
tpfa_htrans_compute(const_cast<UnstructuredGrid*>(&grid_), props_.permeability(), &htrans[0]);
|
tpfa_htrans_compute(const_cast<UnstructuredGrid*>(&grid_), props_.permeability(), &htrans[0]);
|
||||||
tpfa_trans_compute(const_cast<UnstructuredGrid*>(&grid_), &htrans[0], &gravflux_[0]);
|
tpfa_trans_compute(const_cast<UnstructuredGrid*>(&grid_), &htrans[0], &trans_[0]);
|
||||||
|
|
||||||
const double delta_rho = 0.0;// props_.density()[0] - props_.density()[1];
|
// Remember gravity vector.
|
||||||
THROW("TransportModelCompressibleTwophase gravity solver not done yet."); // See line above...
|
gravity_ = grav;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
void TransportModelCompressibleTwophase::initGravityDynamic()
|
||||||
|
{
|
||||||
|
// Set up gravflux_ = T_ij g [ (b_w,i rho_w,S - b_o,i rho_o,S) (z_i - z_f)
|
||||||
|
// + (b_w,j rho_w,S - b_o,j rho_o,S) (z_f - z_j) ]
|
||||||
|
// But b_w,i * rho_w,S = rho_w,i, which we conmpute with a call to props_.density().
|
||||||
|
// We assume that we already have stored T_ij in trans_.
|
||||||
|
// We also assume that the A_ matrices are updated from an earlier call to solve().
|
||||||
|
const int nc = grid_.number_of_cells;
|
||||||
|
const int nf = grid_.number_of_faces;
|
||||||
|
const int np = props_.numPhases();
|
||||||
|
ASSERT(np == 2);
|
||||||
|
const int dim = grid_.dimensions;
|
||||||
|
density_.resize(nc*np);
|
||||||
|
props_.density(grid_.number_of_cells, &A_[0], &density_[0]);
|
||||||
|
std::fill(gravflux_.begin(), gravflux_.end(), 0.0);
|
||||||
for (int f = 0; f < nf; ++f) {
|
for (int f = 0; f < nf; ++f) {
|
||||||
const int* c = &grid_.face_cells[2*f];
|
const int* c = &grid_.face_cells[2*f];
|
||||||
double gdz = 0.0;
|
const double signs[2] = { 1.0, -1.0 };
|
||||||
if (c[0] != -1 && c[1] != -1) {
|
if (c[0] != -1 && c[1] != -1) {
|
||||||
|
for (int ci = 0; ci < 2; ++ci) {
|
||||||
|
double gdz = 0.0;
|
||||||
for (int d = 0; d < dim; ++d) {
|
for (int d = 0; d < dim; ++d) {
|
||||||
gdz += grav[d]*(grid_.cell_centroids[dim*c[0] + d] - grid_.cell_centroids[dim*c[1] + d]);
|
gdz += gravity_[d]*(grid_.cell_centroids[dim*c[ci] + d] - grid_.face_centroids[dim*f + d]);
|
||||||
|
}
|
||||||
|
gravflux_[f] += signs[ci]*trans_[f]*gdz*(density_[2*c[ci]] - density_[2*c[ci] + 1]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
gravflux_[f] *= delta_rho*gdz;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void TransportModelCompressibleTwophase::solveSingleCellGravity(const std::vector<int>& cells,
|
void TransportModelCompressibleTwophase::solveSingleCellGravity(const std::vector<int>& cells,
|
||||||
const int pos,
|
const int pos,
|
||||||
const double* gravflux)
|
const double* gravflux)
|
||||||
@ -467,10 +507,14 @@ namespace Opm
|
|||||||
|
|
||||||
void TransportModelCompressibleTwophase::solveGravity(const std::vector<std::vector<int> >& columns,
|
void TransportModelCompressibleTwophase::solveGravity(const std::vector<std::vector<int> >& columns,
|
||||||
const double* pressure,
|
const double* pressure,
|
||||||
const double* porevolume,
|
const double* porevolume0,
|
||||||
const double dt,
|
const double dt,
|
||||||
std::vector<double>& saturation)
|
std::vector<double>& saturation,
|
||||||
|
std::vector<double>& surfacevol)
|
||||||
{
|
{
|
||||||
|
// Assume that solve() has already been called, so that A_ is current.
|
||||||
|
initGravityDynamic();
|
||||||
|
|
||||||
// Initialize mobilities.
|
// Initialize mobilities.
|
||||||
const int nc = grid_.number_of_cells;
|
const int nc = grid_.number_of_cells;
|
||||||
std::vector<int> cells(nc);
|
std::vector<int> cells(nc);
|
||||||
@ -489,7 +533,7 @@ namespace Opm
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Set up other variables.
|
// Set up other variables.
|
||||||
porevolume_ = porevolume;
|
porevolume0_ = porevolume0;
|
||||||
dt_ = dt;
|
dt_ = dt;
|
||||||
toWaterSat(saturation, saturation_);
|
toWaterSat(saturation, saturation_);
|
||||||
|
|
||||||
@ -502,6 +546,9 @@ namespace Opm
|
|||||||
std::cout << "Gauss-Seidel column solver average iterations: "
|
std::cout << "Gauss-Seidel column solver average iterations: "
|
||||||
<< double(num_iters)/double(columns.size()) << std::endl;
|
<< double(num_iters)/double(columns.size()) << std::endl;
|
||||||
toBothSat(saturation_, saturation);
|
toBothSat(saturation_, saturation);
|
||||||
|
|
||||||
|
// Compute surface volume as a postprocessing step from saturation and A_
|
||||||
|
computeSurfacevol(grid_.number_of_cells, props_.numPhases(), &A_[0], &saturation[0], &surfacevol[0]);
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace Opm
|
} // namespace Opm
|
||||||
|
@ -30,6 +30,8 @@ namespace Opm
|
|||||||
|
|
||||||
class BlackoilPropertiesInterface;
|
class BlackoilPropertiesInterface;
|
||||||
|
|
||||||
|
/// Implements a reordering transport solver for compressible,
|
||||||
|
/// non-miscible two-phase flow.
|
||||||
class TransportModelCompressibleTwophase : public TransportModelInterface
|
class TransportModelCompressibleTwophase : public TransportModelInterface
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
@ -47,20 +49,23 @@ namespace Opm
|
|||||||
/// \param[in] darcyflux Array of signed face fluxes.
|
/// \param[in] darcyflux Array of signed face fluxes.
|
||||||
/// \param[in] pressure Array of cell pressures
|
/// \param[in] pressure Array of cell pressures
|
||||||
/// \param[in] surfacevol0 Array of surface volumes at start of timestep
|
/// \param[in] surfacevol0 Array of surface volumes at start of timestep
|
||||||
/// \param[in] porevolume Array of pore volumes.
|
/// \param[in] porevolume0 Array of pore volumes at start of timestep.
|
||||||
|
/// \param[in] porevolume Array of pore volumes at end of timestep.
|
||||||
/// \param[in] source Transport source term.
|
/// \param[in] source Transport source term.
|
||||||
/// \param[in] dt Time step.
|
/// \param[in] dt Time step.
|
||||||
/// \param[in, out] saturation Phase saturations.
|
/// \param[in, out] saturation Phase saturations.
|
||||||
|
/// \param[in, out] surfacevol Surface volume densities for each phase.
|
||||||
void solve(const double* darcyflux,
|
void solve(const double* darcyflux,
|
||||||
const double* pressure,
|
const double* pressure,
|
||||||
const double* surfacevol0,
|
const double* porevolume0,
|
||||||
const double* porevolume,
|
const double* porevolume,
|
||||||
const double* source,
|
const double* source,
|
||||||
const double dt,
|
const double dt,
|
||||||
std::vector<double>& saturation);
|
std::vector<double>& saturation,
|
||||||
|
std::vector<double>& surfacevol);
|
||||||
|
|
||||||
/// Initialise quantities needed by gravity solver.
|
/// Initialise quantities needed by gravity solver.
|
||||||
/// \param[in] grav gravity vector
|
/// \param[in] grav Gravity vector
|
||||||
void initGravity(const double* grav);
|
void initGravity(const double* grav);
|
||||||
|
|
||||||
/// Solve for gravity segregation.
|
/// Solve for gravity segregation.
|
||||||
@ -68,12 +73,17 @@ namespace Opm
|
|||||||
/// It assumes that the input columns contain cells in a single
|
/// It assumes that the input columns contain cells in a single
|
||||||
/// vertical stack, that do not interact with other columns (for
|
/// vertical stack, that do not interact with other columns (for
|
||||||
/// gravity segregation.
|
/// gravity segregation.
|
||||||
/// \TODO: Implement this.
|
/// \param[in] columns Vector of cell-columns.
|
||||||
|
/// \param[in] porevolume0 Array of pore volumes at start of timestep.
|
||||||
|
/// \param[in] dt Time step.
|
||||||
|
/// \param[in, out] saturation Phase saturations.
|
||||||
|
/// \param[in, out] surfacevol Surface volume densities for each phase.
|
||||||
void solveGravity(const std::vector<std::vector<int> >& columns,
|
void solveGravity(const std::vector<std::vector<int> >& columns,
|
||||||
const double* pressure,
|
const double* pressure,
|
||||||
const double* porevolume,
|
const double* porevolume0,
|
||||||
const double dt,
|
const double dt,
|
||||||
std::vector<double>& saturation);
|
std::vector<double>& saturation,
|
||||||
|
std::vector<double>& surfacevol);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
virtual void solveSingleCell(const int cell);
|
virtual void solveSingleCell(const int cell);
|
||||||
@ -82,6 +92,7 @@ namespace Opm
|
|||||||
const int pos,
|
const int pos,
|
||||||
const double* gravflux);
|
const double* gravflux);
|
||||||
int solveGravityColumn(const std::vector<int>& cells);
|
int solveGravityColumn(const std::vector<int>& cells);
|
||||||
|
void initGravityDynamic();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
const UnstructuredGrid& grid_;
|
const UnstructuredGrid& grid_;
|
||||||
@ -96,12 +107,16 @@ namespace Opm
|
|||||||
|
|
||||||
const double* darcyflux_; // one flux per grid face
|
const double* darcyflux_; // one flux per grid face
|
||||||
const double* surfacevol0_; // one per phase per cell
|
const double* surfacevol0_; // one per phase per cell
|
||||||
|
const double* porevolume0_; // one volume per cell
|
||||||
const double* porevolume_; // one volume per cell
|
const double* porevolume_; // one volume per cell
|
||||||
const double* source_; // one source per cell
|
const double* source_; // one source per cell
|
||||||
double dt_;
|
double dt_;
|
||||||
std::vector<double> saturation_; // P (= num. phases) per cell
|
std::vector<double> saturation_; // P (= num. phases) per cell
|
||||||
std::vector<double> fractionalflow_; // = m[0]/(m[0] + m[1]) per cell
|
std::vector<double> fractionalflow_; // = m[0]/(m[0] + m[1]) per cell
|
||||||
// For gravity segregation.
|
// For gravity segregation.
|
||||||
|
const double* gravity_;
|
||||||
|
std::vector<double> trans_;
|
||||||
|
std::vector<double> density_;
|
||||||
std::vector<double> gravflux_;
|
std::vector<double> gravflux_;
|
||||||
std::vector<double> mob_;
|
std::vector<double> mob_;
|
||||||
std::vector<double> s0_;
|
std::vector<double> s0_;
|
||||||
|
@ -53,6 +53,7 @@ namespace Opm
|
|||||||
dt_(0.0),
|
dt_(0.0),
|
||||||
saturation_(grid.number_of_cells, -1.0),
|
saturation_(grid.number_of_cells, -1.0),
|
||||||
fractionalflow_(grid.number_of_cells, -1.0),
|
fractionalflow_(grid.number_of_cells, -1.0),
|
||||||
|
reorder_iterations_(grid.number_of_cells, 0),
|
||||||
mob_(2*grid.number_of_cells, -1.0)
|
mob_(2*grid.number_of_cells, -1.0)
|
||||||
#ifdef EXPERIMENT_GAUSS_SEIDEL
|
#ifdef EXPERIMENT_GAUSS_SEIDEL
|
||||||
, ia_upw_(grid.number_of_cells + 1, -1),
|
, ia_upw_(grid.number_of_cells + 1, -1),
|
||||||
@ -101,11 +102,18 @@ namespace Opm
|
|||||||
&seq[0], &comp[0], &ncomp,
|
&seq[0], &comp[0], &ncomp,
|
||||||
&ia_downw_[0], &ja_downw_[0]);
|
&ia_downw_[0], &ja_downw_[0]);
|
||||||
#endif
|
#endif
|
||||||
|
std::fill(reorder_iterations_.begin(),reorder_iterations_.end(),0);
|
||||||
reorderAndTransport(grid_, darcyflux);
|
reorderAndTransport(grid_, darcyflux);
|
||||||
toBothSat(saturation_, saturation);
|
toBothSat(saturation_, saturation);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
const std::vector<int>& TransportModelTwophase::getReorderIterations() const
|
||||||
|
{
|
||||||
|
return reorder_iterations_;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// Residual function r(s) for a single-cell implicit Euler transport
|
// Residual function r(s) for a single-cell implicit Euler transport
|
||||||
//
|
//
|
||||||
// r(s) = s - s0 + dt/pv*( influx + outflux*f(s) )
|
// r(s) = s - s0 + dt/pv*( influx + outflux*f(s) )
|
||||||
@ -170,9 +178,11 @@ namespace Opm
|
|||||||
// if (std::fabs(r0) < tol_) {
|
// if (std::fabs(r0) < tol_) {
|
||||||
// return;
|
// return;
|
||||||
// }
|
// }
|
||||||
int iters_used;
|
int iters_used = 0;
|
||||||
// saturation_[cell] = modifiedRegulaFalsi(res, smin_[2*cell], smax_[2*cell], maxit_, tol_, iters_used);
|
// saturation_[cell] = modifiedRegulaFalsi(res, smin_[2*cell], smax_[2*cell], maxit_, tol_, iters_used);
|
||||||
saturation_[cell] = RootFinder::solve(res, saturation_[cell], 0.0, 1.0, maxit_, tol_, iters_used);
|
saturation_[cell] = RootFinder::solve(res, saturation_[cell], 0.0, 1.0, maxit_, tol_, iters_used);
|
||||||
|
// add if it is iteration on an out loop
|
||||||
|
reorder_iterations_[cell] = reorder_iterations_[cell] + iters_used;
|
||||||
fractionalflow_[cell] = fracFlow(saturation_[cell], cell);
|
fractionalflow_[cell] = fracFlow(saturation_[cell], cell);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -544,8 +554,9 @@ namespace Opm
|
|||||||
const int cell = cells[pos];
|
const int cell = cells[pos];
|
||||||
GravityResidual res(*this, cells, pos, gravflux);
|
GravityResidual res(*this, cells, pos, gravflux);
|
||||||
if (std::fabs(res(saturation_[cell])) > tol_) {
|
if (std::fabs(res(saturation_[cell])) > tol_) {
|
||||||
int iters_used;
|
int iters_used = 0;
|
||||||
saturation_[cell] = RootFinder::solve(res, smin_[2*cell], smax_[2*cell], maxit_, tol_, iters_used);
|
saturation_[cell] = RootFinder::solve(res, smin_[2*cell], smax_[2*cell], maxit_, tol_, iters_used);
|
||||||
|
reorder_iterations_[cell] = reorder_iterations_[cell] + iters_used;
|
||||||
}
|
}
|
||||||
saturation_[cell] = std::min(std::max(saturation_[cell], smin_[2*cell]), smax_[2*cell]);
|
saturation_[cell] = std::min(std::max(saturation_[cell], smin_[2*cell]), smax_[2*cell]);
|
||||||
mobility(saturation_[cell], cell, &mob_[2*cell]);
|
mobility(saturation_[cell], cell, &mob_[2*cell]);
|
||||||
|
@ -23,7 +23,7 @@
|
|||||||
#include <opm/core/transport/reorder/TransportModelInterface.hpp>
|
#include <opm/core/transport/reorder/TransportModelInterface.hpp>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
#include <map>
|
#include <map>
|
||||||
|
#include <ostream>
|
||||||
struct UnstructuredGrid;
|
struct UnstructuredGrid;
|
||||||
|
|
||||||
namespace Opm
|
namespace Opm
|
||||||
@ -75,6 +75,10 @@ namespace Opm
|
|||||||
const double dt,
|
const double dt,
|
||||||
std::vector<double>& saturation);
|
std::vector<double>& saturation);
|
||||||
|
|
||||||
|
//// Return the number of iterations used by the reordering solver.
|
||||||
|
//// \return vector of iteration per cell
|
||||||
|
const std::vector<int>& getReorderIterations() const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
virtual void solveSingleCell(const int cell);
|
virtual void solveSingleCell(const int cell);
|
||||||
virtual void solveMultiCell(const int num_cells, const int* cells);
|
virtual void solveMultiCell(const int num_cells, const int* cells);
|
||||||
@ -83,7 +87,6 @@ namespace Opm
|
|||||||
const int pos,
|
const int pos,
|
||||||
const double* gravflux);
|
const double* gravflux);
|
||||||
int solveGravityColumn(const std::vector<int>& cells);
|
int solveGravityColumn(const std::vector<int>& cells);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
const UnstructuredGrid& grid_;
|
const UnstructuredGrid& grid_;
|
||||||
const IncompPropertiesInterface& props_;
|
const IncompPropertiesInterface& props_;
|
||||||
@ -99,6 +102,8 @@ namespace Opm
|
|||||||
double dt_;
|
double dt_;
|
||||||
std::vector<double> saturation_; // one per cell, only water saturation!
|
std::vector<double> saturation_; // one per cell, only water saturation!
|
||||||
std::vector<double> fractionalflow_; // = m[0]/(m[0] + m[1]) per cell
|
std::vector<double> fractionalflow_; // = m[0]/(m[0] + m[1]) per cell
|
||||||
|
std::vector<int> reorder_iterations_;
|
||||||
|
//std::vector<double> reorder_fval_;
|
||||||
// For gravity segregation.
|
// For gravity segregation.
|
||||||
std::vector<double> gravflux_;
|
std::vector<double> gravflux_;
|
||||||
std::vector<double> mob_;
|
std::vector<double> mob_;
|
||||||
|
@ -512,11 +512,11 @@ namespace Opm
|
|||||||
State& state)
|
State& state)
|
||||||
{
|
{
|
||||||
const int num_phases = props.numPhases();
|
const int num_phases = props.numPhases();
|
||||||
if (num_phases != 2) {
|
|
||||||
THROW("initStateFromDeck(): currently handling only two-phase scenarios.");
|
|
||||||
}
|
|
||||||
state.init(grid, num_phases);
|
state.init(grid, num_phases);
|
||||||
if (deck.hasField("EQUIL")) {
|
if (deck.hasField("EQUIL")) {
|
||||||
|
if (num_phases != 2) {
|
||||||
|
THROW("initStateFromDeck(): EQUIL-based init currently handling only two-phase scenarios.");
|
||||||
|
}
|
||||||
// Set saturations depending on oil-water contact.
|
// Set saturations depending on oil-water contact.
|
||||||
const EQUIL& equil= deck.getEQUIL();
|
const EQUIL& equil= deck.getEQUIL();
|
||||||
if (equil.equil.size() != 1) {
|
if (equil.equil.size() != 1) {
|
||||||
@ -535,12 +535,28 @@ namespace Opm
|
|||||||
const std::vector<double>& sw_deck = deck.getFloatingPointValue("SWAT");
|
const std::vector<double>& sw_deck = deck.getFloatingPointValue("SWAT");
|
||||||
const std::vector<double>& p_deck = deck.getFloatingPointValue("PRESSURE");
|
const std::vector<double>& p_deck = deck.getFloatingPointValue("PRESSURE");
|
||||||
const int num_cells = grid.number_of_cells;
|
const int num_cells = grid.number_of_cells;
|
||||||
|
if (num_phases == 2) {
|
||||||
for (int c = 0; c < num_cells; ++c) {
|
for (int c = 0; c < num_cells; ++c) {
|
||||||
int c_deck = (grid.global_cell == NULL) ? c : grid.global_cell[c];
|
int c_deck = (grid.global_cell == NULL) ? c : grid.global_cell[c];
|
||||||
s[2*c] = sw_deck[c_deck];
|
s[2*c] = sw_deck[c_deck];
|
||||||
s[2*c + 1] = 1.0 - s[2*c];
|
s[2*c + 1] = 1.0 - s[2*c];
|
||||||
p[c] = p_deck[c_deck];
|
p[c] = p_deck[c_deck];
|
||||||
}
|
}
|
||||||
|
} else if (num_phases == 3) {
|
||||||
|
if (!deck.hasField("SGAS")) {
|
||||||
|
THROW("initStateFromDeck(): missing SGAS keyword in 3-phase init (only SWAT and PRESSURE found).");
|
||||||
|
}
|
||||||
|
const std::vector<double>& sg_deck = deck.getFloatingPointValue("SGAS");
|
||||||
|
for (int c = 0; c < num_cells; ++c) {
|
||||||
|
int c_deck = (grid.global_cell == NULL) ? c : grid.global_cell[c];
|
||||||
|
s[3*c] = sw_deck[c_deck];
|
||||||
|
s[3*c + 1] = 1.0 - (sw_deck[c_deck] + sg_deck[c_deck]);
|
||||||
|
s[3*c + 2] = sg_deck[c_deck];
|
||||||
|
p[c] = p_deck[c_deck];
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
THROW("initStateFromDeck(): init with SWAT etc. only available with 2 or 3 phases.");
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
THROW("initStateFromDeck(): we must either have EQUIL, or both SWAT and PRESSURE.");
|
THROW("initStateFromDeck(): we must either have EQUIL, or both SWAT and PRESSURE.");
|
||||||
}
|
}
|
||||||
|
@ -70,6 +70,25 @@ namespace Opm
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// @brief Computes porosity of all cells in a grid, with rock compressibility effects.
|
||||||
|
/// @param[in] grid a grid
|
||||||
|
/// @param[in] porosity_standard array of grid.number_of_cells porosity values (at standard conditions)
|
||||||
|
/// @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)
|
||||||
|
{
|
||||||
|
int num_cells = grid.number_of_cells;
|
||||||
|
porosity.resize(num_cells);
|
||||||
|
for (int i = 0; i < num_cells; ++i) {
|
||||||
|
porosity[i] = porosity_standard[i]*rock_comp.poroMult(pressure[i]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/// @brief Computes total saturated volumes over all grid cells.
|
/// @brief Computes total saturated volumes over all grid cells.
|
||||||
/// @param[in] pv the pore volume by cell.
|
/// @param[in] pv the pore volume by cell.
|
||||||
@ -574,8 +593,10 @@ namespace Opm
|
|||||||
{
|
{
|
||||||
int nw = well_bhp.size();
|
int nw = well_bhp.size();
|
||||||
ASSERT(nw == wells.number_of_wells);
|
ASSERT(nw == wells.number_of_wells);
|
||||||
if (props.numPhases() != 2) {
|
int np = props.numPhases();
|
||||||
THROW("WellReport for now assumes two phase flow.");
|
const int max_np = 3;
|
||||||
|
if (np > max_np) {
|
||||||
|
THROW("WellReport for now assumes #phases <= " << max_np);
|
||||||
}
|
}
|
||||||
const double* visc = props.viscosity();
|
const double* visc = props.viscosity();
|
||||||
std::vector<double> data_now;
|
std::vector<double> data_now;
|
||||||
@ -586,7 +607,8 @@ namespace Opm
|
|||||||
double well_rate_total = 0.0;
|
double well_rate_total = 0.0;
|
||||||
double well_rate_water = 0.0;
|
double well_rate_water = 0.0;
|
||||||
for (int perf = wells.well_connpos[w]; perf < wells.well_connpos[w + 1]; ++perf) {
|
for (int perf = wells.well_connpos[w]; perf < wells.well_connpos[w + 1]; ++perf) {
|
||||||
const double perf_rate = well_perfrates[perf]*(unit::day/unit::second);
|
const double perf_rate = unit::convert::to(well_perfrates[perf],
|
||||||
|
unit::cubic(unit::meter)/unit::day);
|
||||||
well_rate_total += perf_rate;
|
well_rate_total += perf_rate;
|
||||||
if (perf_rate > 0.0) {
|
if (perf_rate > 0.0) {
|
||||||
// Injection.
|
// Injection.
|
||||||
@ -594,11 +616,14 @@ namespace Opm
|
|||||||
} else {
|
} else {
|
||||||
// Production.
|
// Production.
|
||||||
const int cell = wells.well_cells[perf];
|
const int cell = wells.well_cells[perf];
|
||||||
double mob[2];
|
double mob[max_np];
|
||||||
props.relperm(1, &saturation[2*cell], &cell, mob, 0);
|
props.relperm(1, &saturation[2*cell], &cell, mob, 0);
|
||||||
mob[0] /= visc[0];
|
double tmob = 0;
|
||||||
mob[1] /= visc[1];
|
for(int i = 0; i < np; ++i) {
|
||||||
const double fracflow = mob[0]/(mob[0] + mob[1]);
|
mob[i] /= visc[i];
|
||||||
|
tmob += mob[i];
|
||||||
|
}
|
||||||
|
const double fracflow = mob[0]/tmob;
|
||||||
well_rate_water += perf_rate*fracflow;
|
well_rate_water += perf_rate*fracflow;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -627,8 +652,10 @@ namespace Opm
|
|||||||
// TODO: refactor, since this is almost identical to the other push().
|
// TODO: refactor, since this is almost identical to the other push().
|
||||||
int nw = well_bhp.size();
|
int nw = well_bhp.size();
|
||||||
ASSERT(nw == wells.number_of_wells);
|
ASSERT(nw == wells.number_of_wells);
|
||||||
if (props.numPhases() != 2) {
|
int np = props.numPhases();
|
||||||
THROW("WellReport for now assumes two phase flow.");
|
const int max_np = 3;
|
||||||
|
if (np > max_np) {
|
||||||
|
THROW("WellReport for now assumes #phases <= " << max_np);
|
||||||
}
|
}
|
||||||
std::vector<double> data_now;
|
std::vector<double> data_now;
|
||||||
data_now.reserve(1 + 3*nw);
|
data_now.reserve(1 + 3*nw);
|
||||||
@ -638,7 +665,8 @@ namespace Opm
|
|||||||
double well_rate_total = 0.0;
|
double well_rate_total = 0.0;
|
||||||
double well_rate_water = 0.0;
|
double well_rate_water = 0.0;
|
||||||
for (int perf = wells.well_connpos[w]; perf < wells.well_connpos[w + 1]; ++perf) {
|
for (int perf = wells.well_connpos[w]; perf < wells.well_connpos[w + 1]; ++perf) {
|
||||||
const double perf_rate = well_perfrates[perf]*(unit::day/unit::second);
|
const double perf_rate = unit::convert::to(well_perfrates[perf],
|
||||||
|
unit::cubic(unit::meter)/unit::day);
|
||||||
well_rate_total += perf_rate;
|
well_rate_total += perf_rate;
|
||||||
if (perf_rate > 0.0) {
|
if (perf_rate > 0.0) {
|
||||||
// Injection.
|
// Injection.
|
||||||
@ -646,13 +674,16 @@ namespace Opm
|
|||||||
} else {
|
} else {
|
||||||
// Production.
|
// Production.
|
||||||
const int cell = wells.well_cells[perf];
|
const int cell = wells.well_cells[perf];
|
||||||
double mob[2];
|
double mob[max_np];
|
||||||
props.relperm(1, &s[2*cell], &cell, mob, 0);
|
props.relperm(1, &s[np*cell], &cell, mob, 0);
|
||||||
double visc[2];
|
double visc[max_np];
|
||||||
props.viscosity(1, &p[cell], &z[2*cell], &cell, visc, 0);
|
props.viscosity(1, &p[cell], &z[np*cell], &cell, visc, 0);
|
||||||
mob[0] /= visc[0];
|
double tmob = 0;
|
||||||
mob[1] /= visc[1];
|
for(int i = 0; i < np; ++i) {
|
||||||
const double fracflow = mob[0]/(mob[0] + mob[1]);
|
mob[i] /= visc[i];
|
||||||
|
tmob += mob[i];
|
||||||
|
}
|
||||||
|
const double fracflow = mob[0]/(tmob);
|
||||||
well_rate_water += perf_rate*fracflow;
|
well_rate_water += perf_rate*fracflow;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -44,7 +44,7 @@ namespace Opm
|
|||||||
|
|
||||||
/// @brief Computes pore volume of all cells in a grid, with rock compressibility effects.
|
/// @brief Computes pore volume of all cells in a grid, with rock compressibility effects.
|
||||||
/// @param[in] grid a grid
|
/// @param[in] grid a grid
|
||||||
/// @param[in] porosity array of grid.number_of_cells porosity values
|
/// @param[in] porosity array of grid.number_of_cells porosity values (at reference pressure)
|
||||||
/// @param[in] rock_comp rock compressibility properties
|
/// @param[in] rock_comp rock compressibility properties
|
||||||
/// @param[in] pressure pressure by cell
|
/// @param[in] pressure pressure by cell
|
||||||
/// @param[out] porevol the pore volume by cell.
|
/// @param[out] porevol the pore volume by cell.
|
||||||
@ -54,6 +54,17 @@ namespace Opm
|
|||||||
const std::vector<double>& pressure,
|
const std::vector<double>& pressure,
|
||||||
std::vector<double>& porevol);
|
std::vector<double>& porevol);
|
||||||
|
|
||||||
|
/// @brief Computes porosity of all cells in a grid, with rock compressibility effects.
|
||||||
|
/// @param[in] grid a grid
|
||||||
|
/// @param[in] porosity_standard array of grid.number_of_cells porosity values (at reference presure)
|
||||||
|
/// @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);
|
||||||
|
|
||||||
/// @brief Computes total saturated volumes over all grid cells.
|
/// @brief Computes total saturated volumes over all grid cells.
|
||||||
/// @param[in] pv the pore volume by cell.
|
/// @param[in] pv the pore volume by cell.
|
||||||
|
@ -220,5 +220,35 @@ namespace Opm
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Computes the surface volume densities from saturations by the formula
|
||||||
|
/// z = A s
|
||||||
|
/// for a number of data points, where z is the surface volume density,
|
||||||
|
/// s is the saturation (both as column vectors) and A is the
|
||||||
|
/// phase-to-component relation matrix.
|
||||||
|
/// @param[in] n number of data points
|
||||||
|
/// @param[in] np number of phases, must be 2 or 3
|
||||||
|
/// @param[in] A array containing n square matrices of size num_phases^2,
|
||||||
|
/// in Fortran ordering, typically the output of a call
|
||||||
|
/// to the matrix() method of a BlackoilProperties* class.
|
||||||
|
/// @param[in] saturation concatenated saturation values (for all P phases)
|
||||||
|
/// @param[out] surfacevol concatenated surface-volume values (for all P phases)
|
||||||
|
void computeSurfacevol(const int n,
|
||||||
|
const int np,
|
||||||
|
const double* A,
|
||||||
|
const double* saturation,
|
||||||
|
double* surfacevol)
|
||||||
|
{
|
||||||
|
// Note: since this is a simple matrix-vector product, it can
|
||||||
|
// be done by a BLAS call, but then we have to reorder the A
|
||||||
|
// matrix data.
|
||||||
|
std::fill(surfacevol, surfacevol + n*np, 0.0);
|
||||||
|
for (int i = 0; i < n; ++i) {
|
||||||
|
for (int col = 0; col < np; ++col) {
|
||||||
|
for (int row = 0; row < np; ++row) {
|
||||||
|
surfacevol[i*np + row] += A[i*np*np + row + col*np] * saturation[i*np + col];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
} // namespace Opm
|
} // namespace Opm
|
||||||
|
@ -112,6 +112,25 @@ namespace Opm
|
|||||||
const std::vector<double>& s,
|
const std::vector<double>& s,
|
||||||
std::vector<double>& fractional_flows);
|
std::vector<double>& fractional_flows);
|
||||||
|
|
||||||
|
|
||||||
|
/// Computes the surface volume densities from saturations by the formula
|
||||||
|
/// z = A s
|
||||||
|
/// for a number of data points, where z is the surface volume density,
|
||||||
|
/// s is the saturation (both as column vectors) and A is the
|
||||||
|
/// phase-to-component relation matrix.
|
||||||
|
/// @param[in] n number of data points
|
||||||
|
/// @param[in] np number of phases, must be 2 or 3
|
||||||
|
/// @param[in] A array containing n square matrices of size num_phases,
|
||||||
|
/// in Fortran ordering, typically the output of a call
|
||||||
|
/// to the matrix() method of a BlackoilProperties* class.
|
||||||
|
/// @param[in] saturation concatenated saturation values (for all P phases)
|
||||||
|
/// @param[out] surfacevol concatenated surface-volume values (for all P phases)
|
||||||
|
void computeSurfacevol(const int n,
|
||||||
|
const int np,
|
||||||
|
const double* A,
|
||||||
|
const double* saturation,
|
||||||
|
double* surfacevol);
|
||||||
|
|
||||||
} // namespace Opm
|
} // namespace Opm
|
||||||
|
|
||||||
#endif // OPM_MISCUTILITIESBLACKOIL_HEADER_INCLUDED
|
#endif // OPM_MISCUTILITIESBLACKOIL_HEADER_INCLUDED
|
||||||
|
Loading…
Reference in New Issue
Block a user