From a3a9e12388f910f3631243af1a996af4cdfb845a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?B=C3=A5rd=20Skaflestad?= Date: Tue, 20 Mar 2012 23:17:52 +0100 Subject: [PATCH] Implement RESV constraint assembly. --- opm/core/pressure/tpfa/ifs_tpfa.c | 33 +++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/opm/core/pressure/tpfa/ifs_tpfa.c b/opm/core/pressure/tpfa/ifs_tpfa.c index a3b5fbe7..773d7f84 100644 --- a/opm/core/pressure/tpfa/ifs_tpfa.c +++ b/opm/core/pressure/tpfa/ifs_tpfa.c @@ -235,6 +235,39 @@ assemble_rate_well(int nc, int w, struct ifs_tpfa_data *h ) /* ---------------------------------------------------------------------- */ { + int c, i, wdof; + size_t jc, jw; + double trans, resv; + + struct WellControls *ctrls; + + ctrls = W->ctrls[ w ]; + wdof = nc + w; + resv = ctrls->target[ ctrls->current ]; + + for (i = W->well_connpos[w]; i < W->well_connpos[w + 1]; i++) { + + c = W->well_cells [ i ]; + trans = mt[ c ] * W->WI[ i ]; + + /* c->w connection */ + jc = csrmatrix_elm_index(c, c , h->A); + jw = csrmatrix_elm_index(c, wdof, h->A); + + h->A->sa[ jc ] += trans; + h->A->sa[ jw ] -= trans; + h->b [ c ] += trans * wdp[ i ]; + + /* w->c connection */ + jc = csrmatrix_elm_index(wdof, c , h->A); + jw = csrmatrix_elm_index(wdof, wdof, h->A); + + h->A->sa[ jc ] -= trans; + h->A->sa[ jw ] += trans; + h->b [ wdof ] -= trans * wdp[ i ]; + } + + h->b[ wdof ] += resv; }