Add boolean flag to determine whether crossflow is allowed in a well

This PR adds allow_cf to the wells structure that determine whether
crossflow is allowed or not. An extra argument is added to addWell(..)
to specify the allow_cf flag.
This commit is contained in:
Tor Harald Sandve 2015-10-06 15:54:20 +02:00
parent d54899ba07
commit 40ec39fa71
5 changed files with 35 additions and 7 deletions

View File

@ -106,6 +106,11 @@ struct Wells
* Internal management structure.
*/
void *data;
/**
* Array of booleans, if true crossflow is allowed in the well.
*/
bool *allow_cf;
};
@ -185,6 +190,7 @@ create_wells(int nphases, int nwells, int nperf);
* ideally be track ordered.
* \param[in] WI Well production index per perforation, or NULL.
* \param[in] name Name of new well. NULL if no name.
* \param[in] allow_cf Boolean flag to determine whether crossflow is allowed or not.
* \param[in,out] W Existing set of wells to which new well will
* be added.
*
@ -198,6 +204,7 @@ add_well(enum WellType type ,
const int *cells ,
const double *WI ,
const char *name ,
bool allow_cf ,
struct Wells *W );

View File

@ -38,6 +38,7 @@ namespace Opm
struct WellData
{
WellType type;
bool allowCrossFlow;
// WellControlType control;
// double target;
double reference_bhp_depth;

View File

@ -247,6 +247,12 @@ void WellsManager::createWellsFromSpecs(std::vector<WellConstPtr>& wells, size_t
wd.type = INJECTOR;
else
wd.type = PRODUCER;
if (well->getAllowCrossFlow()) {
wd.allowCrossFlow = true;
} else {
wd.allowCrossFlow = false;
}
well_data.push_back(wd);
}
}
@ -293,6 +299,7 @@ void WellsManager::createWellsFromSpecs(std::vector<WellConstPtr>& wells, size_t
perf_cells.data(),
perf_prodind.data(),
well_names[w].c_str(),
well_data[w].allowCrossFlow,
w_);
if (!ok) {

View File

@ -85,6 +85,7 @@ wells_allocate(int nwells, struct Wells *W)
void *type, *depth_ref, *comp_frac;
void *well_connpos;
void *ctrls, *name;
bool *allow_cf;
np = W->number_of_phases;
@ -93,6 +94,7 @@ wells_allocate(int nwells, struct Wells *W)
comp_frac = realloc(W->comp_frac, np * nwells * sizeof *W->comp_frac);
ctrls = realloc(W->ctrls , 1 * nwells * sizeof *W->ctrls);
name = realloc(W->name , 1 * nwells * sizeof *W->name);
allow_cf = realloc(W->allow_cf , 1 * nwells * sizeof *W->allow_cf);
well_connpos = realloc(W->well_connpos,
(nwells + 1) * sizeof *W->well_connpos);
@ -104,8 +106,9 @@ wells_allocate(int nwells, struct Wells *W)
if (well_connpos != NULL) { W->well_connpos = well_connpos; ok++; }
if (ctrls != NULL) { W->ctrls = ctrls ; ok++; }
if (name != NULL) { W->name = name ; ok++; }
if (allow_cf != NULL) { W->allow_cf = allow_cf ; ok++; }
return ok == 6;
return ok == 7;
}
@ -143,6 +146,7 @@ initialise_new_wells(int nwells, struct Wells *W)
W->type [w] = PRODUCER;
W->depth_ref[w] = -1.0;
W->name [w] = NULL;
W->allow_cf [w] = false;
for (p = 0; p < W->number_of_phases; ++p) {
W->comp_frac[W->number_of_phases*w + p] = 0.0;
@ -274,6 +278,7 @@ create_wells(int nphases, int nwells, int nperf)
W->ctrls = NULL;
W->name = NULL;
W->allow_cf = false;
W->data = create_well_mgmt();
@ -326,6 +331,7 @@ destroy_wells(struct Wells *W)
free(W->comp_frac);
free(W->depth_ref);
free(W->type);
free(W->allow_cf);
}
free(W);
@ -358,6 +364,7 @@ add_well(enum WellType type ,
const int *cells ,
const double *WI , /* Well index per perf (or NULL) */
const char *name , /* Well name (or NULL) */
bool allow_cf ,
struct Wells *W )
/* ---------------------------------------------------------------------- */
{
@ -398,6 +405,7 @@ add_well(enum WellType type ,
if (ok) {
W->type [nw] = type ;
W->depth_ref[nw] = depth_ref;
W->allow_cf [nw] = allow_cf;
if (name != NULL) {
/* May return NULL, but that's fine for the current
@ -503,7 +511,7 @@ clone_wells(const struct Wells *W)
comp_frac = W->comp_frac != NULL ? W->comp_frac + w*np : NULL;
ok = add_well(W->type[ w ], W->depth_ref[ w ], nperf,
comp_frac, cells, WI, W->name[ w ], newWells);
comp_frac, cells, WI, W->name[ w ], W->allow_cf[ w ], newWells);
if (ok) {
ok = (ctrl = well_controls_clone(W->ctrls[w])) != NULL;
@ -580,6 +588,11 @@ wells_equal(const struct Wells *W1, const struct Wells *W2 , bool verbose)
if (verbose)
printf("Well controls are different for well[%d]:%s \n",i,W1->name[i]);
}
if (W1->allow_cf[i] != W2->allow_cf[i]) {
are_equal = false;
if (verbose)
printf("Well->allow_cf[%d] different %d %d \n",i , W1->type[i] , W2->type[i] );
}
}

View File

@ -56,11 +56,11 @@ BOOST_AUTO_TEST_CASE(Construction)
const double ifrac[] = { 1.0, 0.0 };
const bool ok0 = add_well(INJECTOR, 0.0, 1, &ifrac[0], &cells[0],
&WI, "INJECTOR", W.get());
&WI, "INJECTOR", true, W.get());
const double pfrac[] = { 0.0, 0.0 };
const bool ok1 = add_well(PRODUCER, 0.0, 1, &pfrac[0], &cells[1],
&WI, "PRODUCER", W.get());
&WI, "PRODUCER", true, W.get());
if (ok0 && ok1) {
BOOST_CHECK_EQUAL(W->number_of_phases, nphases);
@ -99,7 +99,7 @@ BOOST_AUTO_TEST_CASE(Controls)
const double ifrac[] = { 1.0, 0.0 };
const bool ok = add_well(INJECTOR, 0.0, nperfs, &ifrac[0], &cells[0],
&WI[0], "INJECTOR", W.get());
&WI[0], "INJECTOR", true, W.get());
if (ok) {
const double distr[] = { 1.0, 0.0 };
@ -151,11 +151,11 @@ BOOST_AUTO_TEST_CASE(Copy)
const double ifrac[] = { 1.0, 0.0 };
const bool ok0 = add_well(INJECTOR, 0.0, 1, &ifrac[0], &cells[0],
&WI, "INJECTOR", W1.get());
&WI, "INJECTOR", true, W1.get());
const double pfrac[] = { 0.0, 0.0 };
const bool ok1 = add_well(PRODUCER, 0.0, 1, &pfrac[0], &cells[1],
&WI, "PRODUCER", W1.get());
&WI, "PRODUCER", true, W1.get());
bool ok = ok0 && ok1;
for (int w = 0; ok && (w < W1->number_of_wells); ++w) {