Merge pull request #897 from totto82/crossflow

Add boolean flag to determine whether crossflow is allowed in a well
This commit is contained in:
Atgeirr Flø Rasmussen 2015-10-14 09:36:27 +02:00
commit 10b4d6c6f7
5 changed files with 33 additions and 7 deletions

View File

@ -102,10 +102,17 @@ struct Wells
*/ */
char **name; char **name;
/**
* Array of flags indicating whether crossflow is allowed or not
* if allow_cf[w] == 0 (false) then crossflow is not allowed in well w.
*/
int *allow_cf;
/** /**
* Internal management structure. * Internal management structure.
*/ */
void *data; void *data;
}; };
@ -185,6 +192,7 @@ create_wells(int nphases, int nwells, int nperf);
* ideally be track ordered. * ideally be track ordered.
* \param[in] WI Well production index per perforation, or NULL. * \param[in] WI Well production index per perforation, or NULL.
* \param[in] name Name of new well. NULL if no name. * \param[in] name Name of new well. NULL if no name.
* \param[in] allow_cf Flag to determine whether crossflow is allowed or not.
* \param[in,out] W Existing set of wells to which new well will * \param[in,out] W Existing set of wells to which new well will
* be added. * be added.
* *
@ -198,6 +206,7 @@ add_well(enum WellType type ,
const int *cells , const int *cells ,
const double *WI , const double *WI ,
const char *name , const char *name ,
int allow_cf ,
struct Wells *W ); struct Wells *W );

View File

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

View File

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

View File

@ -85,6 +85,7 @@ wells_allocate(int nwells, struct Wells *W)
void *type, *depth_ref, *comp_frac; void *type, *depth_ref, *comp_frac;
void *well_connpos; void *well_connpos;
void *ctrls, *name; void *ctrls, *name;
void *allow_cf;
np = W->number_of_phases; 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); comp_frac = realloc(W->comp_frac, np * nwells * sizeof *W->comp_frac);
ctrls = realloc(W->ctrls , 1 * nwells * sizeof *W->ctrls); ctrls = realloc(W->ctrls , 1 * nwells * sizeof *W->ctrls);
name = realloc(W->name , 1 * nwells * sizeof *W->name); 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, well_connpos = realloc(W->well_connpos,
(nwells + 1) * sizeof *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 (well_connpos != NULL) { W->well_connpos = well_connpos; ok++; }
if (ctrls != NULL) { W->ctrls = ctrls ; ok++; } if (ctrls != NULL) { W->ctrls = ctrls ; ok++; }
if (name != NULL) { W->name = name ; 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->type [w] = PRODUCER;
W->depth_ref[w] = -1.0; W->depth_ref[w] = -1.0;
W->name [w] = NULL; W->name [w] = NULL;
W->allow_cf [w] = 1;
for (p = 0; p < W->number_of_phases; ++p) { for (p = 0; p < W->number_of_phases; ++p) {
W->comp_frac[W->number_of_phases*w + p] = 0.0; 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->ctrls = NULL;
W->name = NULL; W->name = NULL;
W->allow_cf = NULL;
W->data = create_well_mgmt(); W->data = create_well_mgmt();
@ -326,6 +331,7 @@ destroy_wells(struct Wells *W)
free(W->comp_frac); free(W->comp_frac);
free(W->depth_ref); free(W->depth_ref);
free(W->type); free(W->type);
free(W->allow_cf);
} }
free(W); free(W);
@ -358,6 +364,7 @@ add_well(enum WellType type ,
const int *cells , const int *cells ,
const double *WI , /* Well index per perf (or NULL) */ const double *WI , /* Well index per perf (or NULL) */
const char *name , /* Well name (or NULL) */ const char *name , /* Well name (or NULL) */
int allow_cf ,
struct Wells *W ) struct Wells *W )
/* ---------------------------------------------------------------------- */ /* ---------------------------------------------------------------------- */
{ {
@ -398,6 +405,7 @@ add_well(enum WellType type ,
if (ok) { if (ok) {
W->type [nw] = type ; W->type [nw] = type ;
W->depth_ref[nw] = depth_ref; W->depth_ref[nw] = depth_ref;
W->allow_cf [nw] = allow_cf;
if (name != NULL) { if (name != NULL) {
/* May return NULL, but that's fine for the current /* 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; comp_frac = W->comp_frac != NULL ? W->comp_frac + w*np : NULL;
ok = add_well(W->type[ w ], W->depth_ref[ w ], nperf, 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) { if (ok) {
ok = (ctrl = well_controls_clone(W->ctrls[w])) != NULL; 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) if (verbose)
printf("Well controls are different for well[%d]:%s \n",i,W1->name[i]); 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 double ifrac[] = { 1.0, 0.0 };
const bool ok0 = add_well(INJECTOR, 0.0, 1, &ifrac[0], &cells[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 double pfrac[] = { 0.0, 0.0 };
const bool ok1 = add_well(PRODUCER, 0.0, 1, &pfrac[0], &cells[1], 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) { if (ok0 && ok1) {
BOOST_CHECK_EQUAL(W->number_of_phases, nphases); 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 double ifrac[] = { 1.0, 0.0 };
const bool ok = add_well(INJECTOR, 0.0, nperfs, &ifrac[0], &cells[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) { if (ok) {
const double distr[] = { 1.0, 0.0 }; const double distr[] = { 1.0, 0.0 };
@ -151,11 +151,11 @@ BOOST_AUTO_TEST_CASE(Copy)
const double ifrac[] = { 1.0, 0.0 }; const double ifrac[] = { 1.0, 0.0 };
const bool ok0 = add_well(INJECTOR, 0.0, 1, &ifrac[0], &cells[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 double pfrac[] = { 0.0, 0.0 };
const bool ok1 = add_well(PRODUCER, 0.0, 1, &pfrac[0], &cells[1], 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; bool ok = ok0 && ok1;
for (int w = 0; ok && (w < W1->number_of_wells); ++w) { for (int w = 0; ok && (w < W1->number_of_wells); ++w) {