From f3a9dac5bb28f52c71d7ddc6b362346a2f8851e6 Mon Sep 17 00:00:00 2001 From: Tor Harald Sandve Date: Fri, 15 Aug 2014 08:56:35 +0200 Subject: [PATCH 1/2] The water/gas pressures are only calculated if woc and goc lies within the reservoar The water/gas pressure is set to -inf when woc and goc is above or below the reservoar. --- opm/core/simulator/initStateEquil_impl.hpp | 61 +++++++++++++++++----- 1 file changed, 49 insertions(+), 12 deletions(-) diff --git a/opm/core/simulator/initStateEquil_impl.hpp b/opm/core/simulator/initStateEquil_impl.hpp index 5e68a1762..01db93997 100644 --- a/opm/core/simulator/initStateEquil_impl.hpp +++ b/opm/core/simulator/initStateEquil_impl.hpp @@ -394,20 +394,28 @@ namespace Opm assign(G, opress, z0, cells, press); + // Default pressure at WOC and GOC to -inf po_woc = -std::numeric_limits::max(); po_goc = -std::numeric_limits::max(); const double woc = reg.zwoc(); - // Compute Oil pressure at WOC - if (z0 > woc) { po_woc = opress[0](woc); } // WOC above datum - else if (z0 < woc) { po_woc = opress[1](woc); } // WOC below datum - else { po_woc = p0; } // WOC *at* datum + // Compute Oil pressure at WOC, + // if WOC is within the reservoir. + if ( ( woc > span[0] ) & ( woc < span[1] ) ){ + if (z0 > woc) { po_woc = opress[0](woc); } // WOC above datum + else if (z0 < woc) { po_woc = opress[1](woc); } // WOC below datum + else { po_woc = p0; } // WOC *at* datum + } const double goc = reg.zgoc(); - // Compute Oil pressure at GOC - if (z0 > goc) { po_goc = opress[0](goc); } // GOC above datum - else if (z0 < goc) { po_goc = opress[1](goc); } // GOC below datum - else { po_goc = p0; } // GOC *at* datum + // Compute Oil pressure at GOC, + // if GOC is within the reservoir. + if ( ( goc > span[0] ) & ( goc < span[1] ) ){ + if (z0 > goc) { po_goc = opress[0](goc); } // GOC above datum + else if (z0 < goc) { po_goc = opress[1](goc); } // GOC below datum + else { po_goc = p0; } // GOC *at* datum + } + } template 0 ){ + + PhasePressure::water(G, reg, span, grav, po_woc, + cells, press[ wix ]); + } else { + std::vector::size_type local_index = 0; + for (typename CellRange::const_iterator ci = cells.begin(); ci != cells.end(); ++ci, ++local_index) { + const int cell = *ci; + press[wix][cell] = po_woc; + } + } + + } if (PhaseUsed::gas(pu)) { const int gix = PhaseIndex::gas(pu); - PhasePressure::gas(G, reg, span, grav, po_goc, - cells, press[ gix ]); + + // If woc is above or below the reservoar, + // po_woc is -inf and the water pressure + // is set to -inf. + if (po_goc > 0){ + + PhasePressure::gas(G, reg, span, grav, po_goc, + cells, press[ gix ]); + } else { + std::vector::size_type local_index = 0; + for (typename CellRange::const_iterator ci = cells.begin(); ci != cells.end(); ++ci, ++local_index) { + const int cell = *ci; + press[gix][cell] = po_goc; + } + } + } } } // namespace Details From c1fc8aeb7def2e87b8c7297497c03ce68036292e Mon Sep 17 00:00:00 2001 From: Tor Harald Sandve Date: Mon, 18 Aug 2014 08:57:23 +0200 Subject: [PATCH 2/2] Fixes issues pointed out in the PR comments --- opm/core/simulator/initStateEquil_impl.hpp | 19 ++++--------------- 1 file changed, 4 insertions(+), 15 deletions(-) diff --git a/opm/core/simulator/initStateEquil_impl.hpp b/opm/core/simulator/initStateEquil_impl.hpp index 01db93997..84e146673 100644 --- a/opm/core/simulator/initStateEquil_impl.hpp +++ b/opm/core/simulator/initStateEquil_impl.hpp @@ -401,7 +401,7 @@ namespace Opm const double woc = reg.zwoc(); // Compute Oil pressure at WOC, // if WOC is within the reservoir. - if ( ( woc > span[0] ) & ( woc < span[1] ) ){ + if ( ( woc > span[0] ) && ( woc < span[1] ) ){ if (z0 > woc) { po_woc = opress[0](woc); } // WOC above datum else if (z0 < woc) { po_woc = opress[1](woc); } // WOC below datum else { po_woc = p0; } // WOC *at* datum @@ -410,7 +410,7 @@ namespace Opm const double goc = reg.zgoc(); // Compute Oil pressure at GOC, // if GOC is within the reservoir. - if ( ( goc > span[0] ) & ( goc < span[1] ) ){ + if ( ( goc > span[0] ) && ( goc < span[1] ) ){ if (z0 > goc) { po_goc = opress[0](goc); } // GOC above datum else if (z0 < goc) { po_goc = opress[1](goc); } // GOC below datum else { po_goc = p0; } // GOC *at* datum @@ -487,18 +487,12 @@ namespace Opm // po_woc is -inf and the water pressure // is set to -inf. if ( po_woc > 0 ){ - PhasePressure::water(G, reg, span, grav, po_woc, cells, press[ wix ]); } else { - std::vector::size_type local_index = 0; - for (typename CellRange::const_iterator ci = cells.begin(); ci != cells.end(); ++ci, ++local_index) { - const int cell = *ci; - press[wix][cell] = po_woc; - } + press[wix].assign(cells.size(),po_woc); } - } if (PhaseUsed::gas(pu)) { @@ -508,15 +502,10 @@ namespace Opm // po_woc is -inf and the water pressure // is set to -inf. if (po_goc > 0){ - PhasePressure::gas(G, reg, span, grav, po_goc, cells, press[ gix ]); } else { - std::vector::size_type local_index = 0; - for (typename CellRange::const_iterator ci = cells.begin(); ci != cells.end(); ++ci, ++local_index) { - const int cell = *ci; - press[gix][cell] = po_goc; - } + press[gix].assign(cells.size(),po_goc); } }