Merge branch 'master' into reorder_tof
This commit is contained in:
@@ -468,6 +468,8 @@ add_well(enum WellType type ,
|
||||
|
||||
struct WellMgmt *m;
|
||||
|
||||
assert (W != NULL);
|
||||
|
||||
nw = W->number_of_wells;
|
||||
nperf_tot = W->well_connpos[nw];
|
||||
|
||||
@@ -532,6 +534,7 @@ append_well_controls(enum WellControlType type,
|
||||
struct WellControlMgmt *m;
|
||||
|
||||
assert (W != NULL);
|
||||
assert ((0 <= well_index) && (well_index < W->number_of_wells));
|
||||
|
||||
ctrl = W->ctrls[well_index];
|
||||
np = W->number_of_phases;
|
||||
@@ -567,8 +570,13 @@ void
|
||||
set_current_control(int well_index, int current_control, struct Wells *W)
|
||||
/* ---------------------------------------------------------------------- */
|
||||
{
|
||||
assert (W != NULL);
|
||||
assert ((0 <= well_index) && (well_index < W->number_of_wells));
|
||||
|
||||
assert (W->ctrls[well_index] != NULL);
|
||||
|
||||
assert (current_control < W->ctrls[well_index]->num);
|
||||
|
||||
W->ctrls[well_index]->current = current_control;
|
||||
}
|
||||
|
||||
@@ -578,7 +586,85 @@ void
|
||||
clear_well_controls(int well_index, struct Wells *W)
|
||||
/* ---------------------------------------------------------------------- */
|
||||
{
|
||||
assert (W != NULL);
|
||||
assert ((0 <= well_index) && (well_index < W->number_of_wells));
|
||||
|
||||
if (W->ctrls[well_index] != NULL) {
|
||||
W->ctrls[well_index]->num = 0;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* ---------------------------------------------------------------------- */
|
||||
struct Wells *
|
||||
clone_wells(const struct Wells *W)
|
||||
/* ---------------------------------------------------------------------- */
|
||||
{
|
||||
int c, np, nperf, ok, pos, w;
|
||||
double target;
|
||||
const int *cells;
|
||||
const double *WI, *comp_frac, *distr;
|
||||
enum WellControlType type;
|
||||
const struct WellControls *ctrls;
|
||||
|
||||
struct Wells *ret;
|
||||
|
||||
if (W == NULL) {
|
||||
ret = NULL;
|
||||
}
|
||||
else {
|
||||
np = W->number_of_phases;
|
||||
ret = create_wells(W->number_of_phases, W->number_of_wells,
|
||||
W->well_connpos[ W->number_of_wells ]);
|
||||
|
||||
if (ret != NULL) {
|
||||
pos = W->well_connpos[ 0 ];
|
||||
ok = 1;
|
||||
|
||||
for (w = 0; ok && (w < W->number_of_wells); w++) {
|
||||
nperf = W->well_connpos[w + 1] - pos;
|
||||
cells = W->well_cells + pos;
|
||||
|
||||
WI = W->WI != NULL ? W->WI + pos : NULL;
|
||||
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 ], ret);
|
||||
|
||||
/* Capacity should be sufficient from create_wells() */
|
||||
assert (ok);
|
||||
|
||||
ctrls = W->ctrls[ w ];
|
||||
|
||||
if (ok) {
|
||||
ok = well_controls_reserve(ctrls->num, np, ret->ctrls[ w ]);
|
||||
|
||||
for (c = 0; ok && (c < ctrls->num); c++) {
|
||||
type = ctrls->type [ c ];
|
||||
target = ctrls->target[ c ];
|
||||
distr = & ctrls->distr [ c * np ];
|
||||
|
||||
ok = append_well_controls(type, target, distr, w, ret);
|
||||
|
||||
/* Capacity *should* be sufficient from
|
||||
* well_controls_reserve() */
|
||||
assert (ok);
|
||||
}
|
||||
}
|
||||
|
||||
if (ok) {
|
||||
set_current_control(w, ctrls->current, ret);
|
||||
}
|
||||
|
||||
pos = W->well_connpos[w + 1];
|
||||
}
|
||||
|
||||
if (! ok) {
|
||||
destroy_wells(ret);
|
||||
ret = NULL;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
@@ -235,6 +235,19 @@ void
|
||||
destroy_wells(struct Wells *W);
|
||||
|
||||
|
||||
/**
|
||||
* Create a deep-copy (i.e., clone) of an existing Wells object, including its
|
||||
* controls.
|
||||
*
|
||||
* @param[in] W Existing Wells object.
|
||||
* @return Complete clone of the input object. Dispose of resources using
|
||||
* function destroy_wells() when no longer needed. Returns @c NULL in case of
|
||||
* allocation failure.
|
||||
*/
|
||||
struct Wells *
|
||||
clone_wells(const struct Wells *W);
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -226,6 +226,14 @@ namespace Opm
|
||||
|
||||
|
||||
|
||||
/// Construct from existing wells object.
|
||||
WellsManager::WellsManager(struct Wells* W)
|
||||
: w_(clone_wells(W))
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
|
||||
/// Construct wells from deck.
|
||||
WellsManager::WellsManager(const Opm::EclipseGridParser& deck,
|
||||
const UnstructuredGrid& grid,
|
||||
|
||||
@@ -41,7 +41,14 @@ namespace Opm
|
||||
{
|
||||
public:
|
||||
/// Default constructor -- no wells.
|
||||
WellsManager();
|
||||
WellsManager();
|
||||
|
||||
/// Construct from existing wells object.
|
||||
/// WellsManager is not properly initialised in the sense that the logic to
|
||||
/// manage control switching does not exist.
|
||||
///
|
||||
/// @param[in] W Existing wells object.
|
||||
WellsManager(struct Wells* W);
|
||||
|
||||
/// Construct from input deck and grid.
|
||||
/// The permeability argument may be zero if the input contain
|
||||
|
||||
Reference in New Issue
Block a user