Merge branch 'master' into ert

Conflicts:
	Makefile.am
This commit is contained in:
Atgeirr Flø Rasmussen 2012-09-26 09:07:57 +02:00
commit 6a01298312
7 changed files with 126 additions and 71 deletions

View File

@ -28,8 +28,8 @@ namespace Opm
{ {
rock_.init(deck, grid); rock_.init(deck, grid);
pvt_.init(deck, 200); pvt_.init(deck, 200);
SaturationPropsFromDeck<SatFuncStone2Uniform>* ptr SaturationPropsFromDeck<SatFuncSimpleUniform>* ptr
= new SaturationPropsFromDeck<SatFuncStone2Uniform>(); = new SaturationPropsFromDeck<SatFuncSimpleUniform>();
satprops_.reset(ptr); satprops_.reset(ptr);
ptr->init(deck, grid, 200); ptr->init(deck, grid, 200);
@ -50,30 +50,43 @@ namespace Opm
// Unfortunate lack of pointer smartness here... // Unfortunate lack of pointer smartness here...
const int sat_samples = param.getDefault("sat_tab_size", 200); const int sat_samples = param.getDefault("sat_tab_size", 200);
std::string threephase_model = param.getDefault<std::string>("threephase_model", "simple"); std::string threephase_model = param.getDefault<std::string>("threephase_model", "simple");
bool use_stone2 = (threephase_model == "stone2");
if (sat_samples > 1) { if (sat_samples > 1) {
if (use_stone2) { if (threephase_model == "stone2") {
SaturationPropsFromDeck<SatFuncStone2Uniform>* ptr SaturationPropsFromDeck<SatFuncStone2Uniform>* ptr
= new SaturationPropsFromDeck<SatFuncStone2Uniform>(); = new SaturationPropsFromDeck<SatFuncStone2Uniform>();
satprops_.reset(ptr); satprops_.reset(ptr);
ptr->init(deck, grid, sat_samples); ptr->init(deck, grid, sat_samples);
} else { } else if (threephase_model == "simple") {
SaturationPropsFromDeck<SatFuncSimpleUniform>* ptr SaturationPropsFromDeck<SatFuncSimpleUniform>* ptr
= new SaturationPropsFromDeck<SatFuncSimpleUniform>(); = new SaturationPropsFromDeck<SatFuncSimpleUniform>();
satprops_.reset(ptr); satprops_.reset(ptr);
ptr->init(deck, grid, sat_samples); ptr->init(deck, grid, sat_samples);
} else if (threephase_model == "gwseg") {
SaturationPropsFromDeck<SatFuncGwsegUniform>* ptr
= new SaturationPropsFromDeck<SatFuncGwsegUniform>();
satprops_.reset(ptr);
ptr->init(deck, grid, sat_samples);
} else {
THROW("Unknown threephase_model: " << threephase_model);
} }
} else { } else {
if (use_stone2) { if (threephase_model == "stone2") {
SaturationPropsFromDeck<SatFuncStone2Nonuniform>* ptr SaturationPropsFromDeck<SatFuncStone2Nonuniform>* ptr
= new SaturationPropsFromDeck<SatFuncStone2Nonuniform>(); = new SaturationPropsFromDeck<SatFuncStone2Nonuniform>();
satprops_.reset(ptr); satprops_.reset(ptr);
ptr->init(deck, grid, sat_samples); ptr->init(deck, grid, sat_samples);
} else { } else if (threephase_model == "simple") {
SaturationPropsFromDeck<SatFuncSimpleNonuniform>* ptr SaturationPropsFromDeck<SatFuncSimpleNonuniform>* ptr
= new SaturationPropsFromDeck<SatFuncSimpleNonuniform>(); = new SaturationPropsFromDeck<SatFuncSimpleNonuniform>();
satprops_.reset(ptr); satprops_.reset(ptr);
ptr->init(deck, grid, sat_samples); ptr->init(deck, grid, sat_samples);
} else if (threephase_model == "gwseg") {
SaturationPropsFromDeck<SatFuncGwsegNonuniform>* ptr
= new SaturationPropsFromDeck<SatFuncGwsegNonuniform>();
satprops_.reset(ptr);
ptr->init(deck, grid, sat_samples);
} else {
THROW("Unknown threephase_model: " << threephase_model);
} }
} }

View File

@ -26,6 +26,7 @@
#include <opm/core/fluid/blackoil/BlackoilPhases.hpp> #include <opm/core/fluid/blackoil/BlackoilPhases.hpp>
#include <opm/core/fluid/SatFuncStone2.hpp> #include <opm/core/fluid/SatFuncStone2.hpp>
#include <opm/core/fluid/SatFuncSimple.hpp> #include <opm/core/fluid/SatFuncSimple.hpp>
#include <opm/core/fluid/SatFuncGwseg.hpp>
#include <vector> #include <vector>
struct UnstructuredGrid; struct UnstructuredGrid;

View File

@ -26,6 +26,10 @@
#include <opm/core/utility/have_boost_redef.hpp> #include <opm/core/utility/have_boost_redef.hpp>
// Silence compatibility warning from DUNE headers since we don't use
// the deprecated member anyway (in this compilation unit)
#define DUNE_COMMON_FIELDVECTOR_SIZE_IS_METHOD 1
// TODO: clean up includes. // TODO: clean up includes.
#include <dune/common/deprecated.hh> #include <dune/common/deprecated.hh>
#include <dune/istl/bvector.hh> #include <dune/istl/bvector.hh>

View File

@ -123,7 +123,7 @@ namespace Opm
WellState& well_state) WellState& well_state)
{ {
const int nc = grid_.number_of_cells; const int nc = grid_.number_of_cells;
const int nw = wells_->number_of_wells; const int nw = (wells_ != 0) ? wells_->number_of_wells : 0;
// Set up dynamic data. // Set up dynamic data.
computePerSolveDynamicData(dt, state, well_state); computePerSolveDynamicData(dt, state, well_state);
@ -454,8 +454,8 @@ namespace Opm
// std::vector<double> wellperf_A_; // std::vector<double> wellperf_A_;
// std::vector<double> wellperf_phasemob_; // std::vector<double> wellperf_phasemob_;
const int np = props_.numPhases(); const int np = props_.numPhases();
const int nw = wells_->number_of_wells; const int nw = (wells_ != 0) ? wells_->number_of_wells : 0;
const int nperf = wells_->well_connpos[nw]; const int nperf = (wells_ != 0) ? wells_->well_connpos[nw] : 0;
wellperf_A_.resize(nperf*np*np); wellperf_A_.resize(nperf*np*np);
wellperf_phasemob_.resize(nperf*np); wellperf_phasemob_.resize(nperf*np);
// The A matrix is set equal to the perforation grid cells' // The A matrix is set equal to the perforation grid cells'
@ -512,9 +512,9 @@ namespace Opm
const double* z = &state.surfacevol()[0]; const double* z = &state.surfacevol()[0];
UnstructuredGrid* gg = const_cast<UnstructuredGrid*>(&grid_); UnstructuredGrid* gg = const_cast<UnstructuredGrid*>(&grid_);
CompletionData completion_data; CompletionData completion_data;
completion_data.gpot = &wellperf_gpot_[0]; completion_data.gpot = ! wellperf_gpot_.empty() ? &wellperf_gpot_[0] : 0;
completion_data.A = &wellperf_A_[0]; completion_data.A = ! wellperf_A_.empty() ? &wellperf_A_[0] : 0;
completion_data.phasemob = &wellperf_phasemob_[0]; completion_data.phasemob = ! wellperf_phasemob_.empty() ? &wellperf_phasemob_[0] : 0;
cfs_tpfa_res_wells wells_tmp; cfs_tpfa_res_wells wells_tmp;
wells_tmp.W = const_cast<Wells*>(wells_); wells_tmp.W = const_cast<Wells*>(wells_);
wells_tmp.data = &completion_data; wells_tmp.data = &completion_data;
@ -599,9 +599,9 @@ namespace Opm
{ {
UnstructuredGrid* gg = const_cast<UnstructuredGrid*>(&grid_); UnstructuredGrid* gg = const_cast<UnstructuredGrid*>(&grid_);
CompletionData completion_data; CompletionData completion_data;
completion_data.gpot = const_cast<double*>(&wellperf_gpot_[0]); completion_data.gpot = ! wellperf_gpot_.empty() ? const_cast<double*>(&wellperf_gpot_[0]) : 0;
completion_data.A = const_cast<double*>(&wellperf_A_[0]); completion_data.A = ! wellperf_A_.empty() ? const_cast<double*>(&wellperf_A_[0]) : 0;
completion_data.phasemob = const_cast<double*>(&wellperf_phasemob_[0]); completion_data.phasemob = ! wellperf_phasemob_.empty() ? const_cast<double*>(&wellperf_phasemob_[0]) : 0;
cfs_tpfa_res_wells wells_tmp; cfs_tpfa_res_wells wells_tmp;
wells_tmp.W = const_cast<Wells*>(wells_); wells_tmp.W = const_cast<Wells*>(wells_);
wells_tmp.data = &completion_data; wells_tmp.data = &completion_data;
@ -609,6 +609,9 @@ namespace Opm
forces.wells = &wells_tmp; forces.wells = &wells_tmp;
forces.src = NULL; forces.src = NULL;
double* wpress = ! well_state.bhp ().empty() ? & well_state.bhp ()[0] : 0;
double* wflux = ! well_state.perfRates().empty() ? & well_state.perfRates()[0] : 0;
cfs_tpfa_res_flux(gg, cfs_tpfa_res_flux(gg,
&forces, &forces,
props_.numPhases(), props_.numPhases(),
@ -617,9 +620,9 @@ namespace Opm
&face_phasemob_[0], &face_phasemob_[0],
&face_gravcap_[0], &face_gravcap_[0],
&state.pressure()[0], &state.pressure()[0],
&well_state.bhp()[0], wpress,
&state.faceflux()[0], &state.faceflux()[0],
&well_state.perfRates()[0]); wflux);
cfs_tpfa_res_fpress(gg, cfs_tpfa_res_fpress(gg,
props_.numPhases(), props_.numPhases(),
&htrans_[0], &htrans_[0],

View File

@ -142,7 +142,7 @@ impl_allocate(struct UnstructuredGrid *G ,
nnu = G->number_of_cells; nnu = G->number_of_cells;
nwperf = 0; nwperf = 0;
if (wells != NULL) { assert (wells->W != NULL); if ((wells != NULL) && (wells->W != NULL)) {
nnu += wells->W->number_of_wells; nnu += wells->W->number_of_wells;
nwperf = wells->W->well_connpos[ wells->W->number_of_wells ]; nwperf = wells->W->well_connpos[ wells->W->number_of_wells ];
} }
@ -185,13 +185,15 @@ construct_matrix(struct UnstructuredGrid *G ,
/* ---------------------------------------------------------------------- */ /* ---------------------------------------------------------------------- */
{ {
int f, c1, c2, w, i, nc, nnu; int f, c1, c2, w, i, nc, nnu;
int wells_present;
size_t nnz; size_t nnz;
struct CSRMatrix *A; struct CSRMatrix *A;
nc = nnu = G->number_of_cells; nc = nnu = G->number_of_cells;
if (wells != NULL) {
assert (wells->W != NULL); wells_present = (wells != NULL) && (wells->W != NULL);
if (wells_present) {
nnu += wells->W->number_of_wells; nnu += wells->W->number_of_wells;
} }
@ -214,7 +216,7 @@ construct_matrix(struct UnstructuredGrid *G ,
} }
} }
if (wells != NULL) { if (wells_present) {
/* Well <-> cell connections */ /* Well <-> cell connections */
struct Wells *W = wells->W; struct Wells *W = wells->W;
@ -252,7 +254,7 @@ construct_matrix(struct UnstructuredGrid *G ,
} }
} }
if (wells != NULL) { if (wells_present) {
/* Fill well <-> cell connections */ /* Fill well <-> cell connections */
struct Wells *W = wells->W; struct Wells *W = wells->W;
@ -741,6 +743,29 @@ assemble_completion_to_cell(int c, int wdof, int np, double dt,
} }
/* ---------------------------------------------------------------------- */
static void
welleq_coeff_shut(int np, struct cfs_tpfa_res_data *h,
double *res, double *w2c, double *w2w)
/* ---------------------------------------------------------------------- */
{
int p;
double fwi;
const double *dpflux_w;
/* Sum reservoir phase flux derivatives set by
* compute_darcyflux_and_deriv(). */
dpflux_w = h->pimpl->flux_work + (1 * np);
for (p = 0, fwi = 0.0; p < np; p++) {
fwi += dpflux_w[ p ];
}
*res = 0.0;
*w2c = 0.0;
*w2w = fwi;
}
/* ---------------------------------------------------------------------- */ /* ---------------------------------------------------------------------- */
static void static void
welleq_coeff_bhp(int np, double dp, struct cfs_tpfa_res_data *h, welleq_coeff_bhp(int np, double dp, struct cfs_tpfa_res_data *h,
@ -815,9 +840,10 @@ assemble_completion_to_well(int w, int c, int nc, int np,
ctrl = W->ctrls[ w ]; ctrl = W->ctrls[ w ];
if (ctrl->current < 0) { if (ctrl->current < 0) {
assert (0); /* Shut wells currently not supported */ /* Interpreting a negative current control index to mean a shut well */
welleq_coeff_shut(np, h, &res, &w2c, &w2w);
} }
else {
switch (ctrl->type[ ctrl->current ]) { switch (ctrl->type[ ctrl->current ]) {
case BHP : case BHP :
welleq_coeff_bhp(np, pw - ctrl->target[ ctrl->current ], welleq_coeff_bhp(np, pw - ctrl->target[ ctrl->current ],
@ -833,6 +859,7 @@ assemble_completion_to_well(int w, int c, int nc, int np,
assert (0); /* Surface rate currently not supported */ assert (0); /* Surface rate currently not supported */
break; break;
} }
}
/* Assemble completion contributions */ /* Assemble completion contributions */
wdof = nc + w; wdof = nc + w;
@ -854,7 +881,7 @@ assemble_well_contrib(struct cfs_tpfa_res_wells *wells ,
struct cfs_tpfa_res_data *h ) struct cfs_tpfa_res_data *h )
{ {
int w, i, c, np, np2, nc; int w, i, c, np, np2, nc;
int is_neumann; int is_neumann, is_open;
double pw, dp; double pw, dp;
double *WI, *gpot, *pmobp; double *WI, *gpot, *pmobp;
const double *Ac, *dAc; const double *Ac, *dAc;
@ -876,6 +903,7 @@ assemble_well_contrib(struct cfs_tpfa_res_wells *wells ,
for (w = i = 0; w < W->number_of_wells; w++) { for (w = i = 0; w < W->number_of_wells; w++) {
pw = wpress[ w ]; pw = wpress[ w ];
is_open = W->ctrls[w]->current >= 0;
for (; i < W->well_connpos[w + 1]; for (; i < W->well_connpos[w + 1];
i++, gpot += np, pmobp += np) { i++, gpot += np, pmobp += np) {
@ -888,7 +916,9 @@ assemble_well_contrib(struct cfs_tpfa_res_wells *wells ,
init_completion_contrib(i, np, Ac, dAc, h->pimpl); init_completion_contrib(i, np, Ac, dAc, h->pimpl);
if (is_open) {
assemble_completion_to_cell(c, nc + w, np, dt, h); assemble_completion_to_cell(c, nc + w, np, dt, h);
}
/* Prepare for RESV controls */ /* Prepare for RESV controls */
compute_darcyflux_and_deriv(np, WI[i], dp, pmobp, gpot, compute_darcyflux_and_deriv(np, WI[i], dp, pmobp, gpot,
@ -1127,8 +1157,7 @@ cfs_tpfa_res_construct(struct UnstructuredGrid *G ,
nf = G->number_of_faces; nf = G->number_of_faces;
nwperf = 0; nwperf = 0;
if (wells != NULL) { if ((wells != NULL) && (wells->W != NULL)) {
assert (wells->W != NULL);
nwperf = wells->W->well_connpos[ wells->W->number_of_wells ]; nwperf = wells->W->well_connpos[ wells->W->number_of_wells ];
} }
@ -1194,7 +1223,9 @@ cfs_tpfa_res_assemble(struct UnstructuredGrid *G ,
assemble_cell_contrib(G, c, h); assemble_cell_contrib(G, c, h);
} }
if ((forces != NULL) && (forces->wells != NULL)) { if ((forces != NULL) &&
(forces->wells != NULL) &&
(forces->wells->W != NULL)) {
compute_well_compflux_and_deriv(forces->wells, cq->nphases, compute_well_compflux_and_deriv(forces->wells, cq->nphases,
cpress, wpress, h->pimpl); cpress, wpress, h->pimpl);
@ -1297,8 +1328,9 @@ cfs_tpfa_res_flux(struct UnstructuredGrid *G ,
{ {
compute_flux(G, np, trans, pmobf, gravcap_f, cpress, fflux); compute_flux(G, np, trans, pmobf, gravcap_f, cpress, fflux);
if ((forces != NULL) && (forces->wells != NULL) && if ((forces != NULL) &&
(wpress != NULL) && (wflux != NULL)) { (forces->wells != NULL) &&
(forces->wells->W != NULL) && (wpress != NULL) && (wflux != NULL)) {
compute_wflux(np, forces->wells, pmobc, cpress, wpress, wflux); compute_wflux(np, forces->wells, pmobc, cpress, wpress, wflux);
} }

View File

@ -374,7 +374,10 @@ namespace Opm
if (perf_rate > 0.0) { if (perf_rate > 0.0) {
// perf_rate is a total inflow rate, we want a water rate. // perf_rate is a total inflow rate, we want a water rate.
if (wells->type[w] != INJECTOR) { if (wells->type[w] != INJECTOR) {
std::cout << "**** Warning: crossflow in well with index " << w << " ignored." << std::endl; std::cout << "**** Warning: crossflow in well "
<< w << " perf " << perf - wells->well_connpos[w]
<< " ignored. Rate was "
<< perf_rate/Opm::unit::day << " m^3/day." << std::endl;
perf_rate = 0.0; perf_rate = 0.0;
} else { } else {
ASSERT(std::fabs(comp_frac[0] + comp_frac[1] - 1.0) < 1e-6); ASSERT(std::fabs(comp_frac[0] + comp_frac[1] - 1.0) < 1e-6);

View File

@ -717,7 +717,6 @@ namespace Opm
if (deck.hasField("WELOPEN")) { if (deck.hasField("WELOPEN")) {
const WELOPEN& welopen = deck.getWELOPEN(); const WELOPEN& welopen = deck.getWELOPEN();
for (size_t i = 0; i < welopen.welopen.size(); ++i) { for (size_t i = 0; i < welopen.welopen.size(); ++i) {
WelopenLine line = welopen.welopen[i]; WelopenLine line = welopen.welopen[i];
std::string wellname = line.well_; std::string wellname = line.well_;
@ -725,22 +724,22 @@ namespace Opm
if (it == well_names_to_index.end()) { if (it == well_names_to_index.end()) {
THROW("Trying to open/shut well with name: \"" << wellname<<"\" but it's not registered under WELSPECS."); THROW("Trying to open/shut well with name: \"" << wellname<<"\" but it's not registered under WELSPECS.");
} }
int index = it->second; const int index = it->second;
if (line.openshutflag_ == "SHUT") { if (line.openshutflag_ == "SHUT") {
// We currently don't care if the well is open or not. int& cur_ctrl = w_->ctrls[index]->current;
/// \TODO Should this perhaps be allowed? I.e. should it be if(well_shut) { shutwell(); } else { /* do nothing*/ }? if (cur_ctrl >= 0) {
//ASSERT(w_->ctrls[index]->current < 0); cur_ctrl = ~cur_ctrl;
}
ASSERT(w_->ctrls[index]->current < 0);
} else if (line.openshutflag_ == "OPEN") { } else if (line.openshutflag_ == "OPEN") {
//ASSERT(w_->ctrls[index]->current >= 0); int& cur_ctrl = w_->ctrls[index]->current;
if (cur_ctrl < 0) {
cur_ctrl = ~cur_ctrl;
}
ASSERT(w_->ctrls[index]->current >= 0);
} else { } else {
THROW("Unknown Open/close keyword: \"" << line.openshutflag_<< "\". Allowed values: OPEN, SHUT."); THROW("Unknown Open/close keyword: \"" << line.openshutflag_<< "\". Allowed values: OPEN, SHUT.");
} }
// We revert back to it's original control.
// Note that this is OK as ~~ = id.
w_->ctrls[index]->current = ~w_->ctrls[index]->current;
} }
} }