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
5 changed files with 33 additions and 7 deletions

View File

@@ -102,10 +102,17 @@ struct Wells
*/
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.
*/
void *data;
};
@@ -185,6 +192,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 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 +206,7 @@ add_well(enum WellType type ,
const int *cells ,
const double *WI ,
const char *name ,
int 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,8 @@ void WellsManager::createWellsFromSpecs(std::vector<WellConstPtr>& wells, size_t
wd.type = INJECTOR;
else
wd.type = PRODUCER;
wd.allowCrossFlow = well->getAllowCrossFlow();
well_data.push_back(wd);
}
}
@@ -293,6 +295,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;
void *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] = 1;
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 = NULL;
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) */
int 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] );
}
}