mirror of
https://github.com/OPM/opm-simulators.git
synced 2024-12-18 21:43:27 -06:00
Removed struct WellControlManagement and replaced with simple integer field cpty in the WellControls structure.
This commit is contained in:
parent
8acdf34653
commit
157d0870f2
@ -86,10 +86,10 @@ struct WellControls
|
||||
*/
|
||||
int current;
|
||||
|
||||
/**
|
||||
* Internal management structure.
|
||||
*/
|
||||
void *data;
|
||||
/*
|
||||
The capacity allocated.
|
||||
*/
|
||||
int cpty;
|
||||
};
|
||||
|
||||
bool
|
||||
@ -105,9 +105,6 @@ void
|
||||
well_controls_destroy(struct WellControls *ctrl);
|
||||
|
||||
|
||||
struct WellControlMgmt {
|
||||
int cpty;
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
@ -42,26 +42,6 @@
|
||||
#include <stdlib.h>
|
||||
|
||||
|
||||
static void
|
||||
destroy_ctrl_mgmt(struct WellControlMgmt *m)
|
||||
{
|
||||
free(m);
|
||||
}
|
||||
|
||||
|
||||
static struct WellControlMgmt *
|
||||
create_ctrl_mgmt(void)
|
||||
{
|
||||
struct WellControlMgmt *m;
|
||||
|
||||
m = malloc(1 * sizeof *m);
|
||||
|
||||
if (m != NULL) {
|
||||
m->cpty = 0;
|
||||
}
|
||||
|
||||
return m;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -71,7 +51,6 @@ well_controls_destroy(struct WellControls *ctrl)
|
||||
/* ---------------------------------------------------------------------- */
|
||||
{
|
||||
if (ctrl != NULL) {
|
||||
destroy_ctrl_mgmt(ctrl->data);
|
||||
free (ctrl->distr);
|
||||
free (ctrl->target);
|
||||
free (ctrl->type);
|
||||
@ -99,12 +78,7 @@ well_controls_create(void)
|
||||
ctrl->distr = NULL;
|
||||
ctrl->current = -1;
|
||||
|
||||
ctrl->data = create_ctrl_mgmt();
|
||||
|
||||
if (ctrl->data == NULL) {
|
||||
well_controls_destroy(ctrl);
|
||||
ctrl = NULL;
|
||||
}
|
||||
ctrl->cpty = 0;
|
||||
}
|
||||
|
||||
return ctrl;
|
||||
@ -119,8 +93,6 @@ well_controls_reserve(int nctrl, int nphases, struct WellControls *ctrl)
|
||||
int c, p, ok;
|
||||
void *type, *target, *distr;
|
||||
|
||||
struct WellControlMgmt *m;
|
||||
|
||||
type = realloc(ctrl->type , nctrl * 1 * sizeof *ctrl->type );
|
||||
target = realloc(ctrl->target, nctrl * 1 * sizeof *ctrl->target);
|
||||
distr = realloc(ctrl->distr , nctrl * nphases * sizeof *ctrl->distr );
|
||||
@ -133,17 +105,16 @@ well_controls_reserve(int nctrl, int nphases, struct WellControls *ctrl)
|
||||
ctrl->number_of_phases = nphases;
|
||||
|
||||
if (ok == 3) {
|
||||
m = ctrl->data;
|
||||
for (c = m->cpty; c < nctrl; c++) {
|
||||
for (c = ctrl->cpty; c < nctrl; c++) {
|
||||
ctrl->type [c] = BHP;
|
||||
ctrl->target[c] = -1.0;
|
||||
}
|
||||
|
||||
for (p = m->cpty * ctrl->number_of_phases; p < nctrl * ctrl->number_of_phases; ++p) {
|
||||
for (p = ctrl->cpty * ctrl->number_of_phases; p < nctrl * ctrl->number_of_phases; ++p) {
|
||||
ctrl->distr[ p ] = 0.0;
|
||||
}
|
||||
|
||||
m->cpty = nctrl;
|
||||
ctrl->cpty = nctrl;
|
||||
}
|
||||
|
||||
return ok == 3;
|
||||
@ -166,10 +137,7 @@ well_controls_equal(const struct WellControls *ctrls1, const struct WellControls
|
||||
are_equal &= (memcmp(ctrls1->type, ctrls2->type, ctrls1->num * sizeof *ctrls1->type ) == 0);
|
||||
are_equal &= (memcmp(ctrls1->target, ctrls2->target, ctrls1->num * sizeof *ctrls1->target ) == 0);
|
||||
are_equal &= (memcmp(ctrls1->distr, ctrls2->distr, ctrls1->num * ctrls1->number_of_phases * sizeof *ctrls1->distr ) == 0);
|
||||
|
||||
struct WellControlMgmt* mgmt1 = (struct WellControlMgmt*)(ctrls1->data);
|
||||
struct WellControlMgmt* mgmt2 = (struct WellControlMgmt*)(ctrls2->data);
|
||||
are_equal &= (mgmt1->cpty == mgmt2->cpty);
|
||||
are_equal &= (ctrls1->cpty == ctrls2->cpty);
|
||||
|
||||
return are_equal;
|
||||
}
|
||||
|
@ -430,7 +430,6 @@ append_well_controls(enum WellControlType type,
|
||||
{
|
||||
int ok, alloc, np;
|
||||
struct WellControls *ctrl;
|
||||
struct WellControlMgmt *m;
|
||||
|
||||
assert (W != NULL);
|
||||
assert ((0 <= well_index) && (well_index < W->number_of_wells));
|
||||
@ -440,11 +439,10 @@ append_well_controls(enum WellControlType type,
|
||||
|
||||
assert (ctrl != NULL);
|
||||
|
||||
m = ctrl->data;
|
||||
ok = ctrl->num < m->cpty;
|
||||
ok = ctrl->num < ctrl->cpty;
|
||||
|
||||
if (! ok) {
|
||||
alloc = alloc_size(ctrl->num, 1, m->cpty);
|
||||
alloc = alloc_size(ctrl->num, 1, ctrl->cpty);
|
||||
ok = well_controls_reserve(alloc, np, ctrl);
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user