From 427a2e67123f97bc2c1382840d115b451aabc56f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?B=C3=A5rd=20Skaflestad?= Date: Tue, 13 Mar 2012 14:42:38 +0100 Subject: [PATCH] Take gravity into effect when assembling Dirichlet boundary conditions. --- opm/core/pressure/tpfa/ifs_tpfa.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/opm/core/pressure/tpfa/ifs_tpfa.c b/opm/core/pressure/tpfa/ifs_tpfa.c index 5c7b27210..1ea5aec08 100644 --- a/opm/core/pressure/tpfa/ifs_tpfa.c +++ b/opm/core/pressure/tpfa/ifs_tpfa.c @@ -158,10 +158,11 @@ assemble_bc_contrib(struct UnstructuredGrid *G , struct ifs_tpfa_data *h ) /* ---------------------------------------------------------------------- */ { - int is_neumann; + int is_neumann, is_inflow; int f, c1, c2; size_t i, j, ix; + double s; is_neumann = 1; @@ -176,11 +177,15 @@ assemble_bc_contrib(struct UnstructuredGrid *G , assert ((c1 < 0) ^ (c2 < 0)); /* BCs on ext. faces only */ - c1 = (c1 >= 0) ? c1 : c2; + is_inflow = c1 >= 0; + + s = 2.0*is_inflow - 1.0; + c1 = is_inflow ? c1 : c2; ix = csrmatrix_elm_index(c1, c1, h->A); h->A->sa[ ix ] += trans[ f ]; h->b [ c1 ] += trans[ f ] * bc->value[ i ]; + h->b [ c1 ] -= s * trans[f] * h->pimpl->fgrav[f]; } }