From a4a0e5985cece3a7a6329f1f096903721167a001 Mon Sep 17 00:00:00 2001 From: Tor Harald Sandve Date: Thu, 22 Dec 2016 16:01:39 +0100 Subject: [PATCH] Make it optinal to apply SWATINIT The reasoning behind this to make it possible to initialize the case without SWATINIT in order to compute the same defaulted THPRES values as Ecl. The initialization needs to be re-computed to account for SWATINIT in the simulations. --- opm/core/simulator/initStateEquil.hpp | 27 ++++++++-------------- opm/core/simulator/initStateEquil_impl.hpp | 22 ++++++++++++++++-- 2 files changed, 30 insertions(+), 19 deletions(-) diff --git a/opm/core/simulator/initStateEquil.hpp b/opm/core/simulator/initStateEquil.hpp index 6eb58c548..a29cb135d 100644 --- a/opm/core/simulator/initStateEquil.hpp +++ b/opm/core/simulator/initStateEquil.hpp @@ -68,6 +68,8 @@ namespace Opm * \param[in] props Property object, pvt and capillary properties are used. * \param[in] deck Simulation deck, used to obtain EQUIL and related data. * \param[in] gravity Acceleration of gravity, assumed to be in Z direction. + * \param[in] applySwatInit Make it possible to not apply SWATINIT even if it + * is present in the deck */ template void initStateEquil(const Grid& grid, @@ -75,7 +77,8 @@ namespace Opm const Opm::Deck& deck, const Opm::EclipseState& eclipseState, const double gravity, - BlackoilState& state); + BlackoilState& state, + bool applySwatInit = true); /** @@ -246,13 +249,17 @@ namespace Opm const Opm::Deck& deck, const Opm::EclipseState& eclipseState, const Grid& G , - const double grav = unit::gravity) + const double grav = unit::gravity, + const std::vector& swat_init = {} + ) : pp_(props.numPhases(), std::vector(UgGridHelpers::numCells(G))), sat_(props.numPhases(), std::vector(UgGridHelpers::numCells(G))), rs_(UgGridHelpers::numCells(G)), - rv_(UgGridHelpers::numCells(G)) + rv_(UgGridHelpers::numCells(G)), + swat_init_(swat_init) + { // Get the equilibration records. const std::vector rec = getEquil(eclipseState); @@ -340,20 +347,6 @@ namespace Opm } } - - // Check for presence of kw SWATINIT - if (deck.hasKeyword("SWATINIT")) { - const std::vector& swat_init = eclipseState. - get3DProperties().getDoubleGridProperty("SWATINIT").getData(); - const int nc = UgGridHelpers::numCells(G); - swat_init_.resize(nc); - const int* gc = UgGridHelpers::globalCell(G); - for (int c = 0; c < nc; ++c) { - const int deck_pos = (gc == NULL) ? c : gc[c]; - swat_init_[c] = swat_init[deck_pos]; - } - } - // Compute pressures, saturations, rs and rv factors. calcPressSatRsRv(eqlmap, rec, props, G, grav); diff --git a/opm/core/simulator/initStateEquil_impl.hpp b/opm/core/simulator/initStateEquil_impl.hpp index f0d948e5e..29ba08d3a 100644 --- a/opm/core/simulator/initStateEquil_impl.hpp +++ b/opm/core/simulator/initStateEquil_impl.hpp @@ -882,6 +882,8 @@ namespace Opm * \param[in] props Property object, pvt and capillary properties are used. * \param[in] deck Simulation deck, used to obtain EQUIL and related data. * \param[in] gravity Acceleration of gravity, assumed to be in Z direction. + * \param[in] applySwatInit Make it possible to not apply SWATINIT even if it + * is present in the deck */ template void initStateEquil(const Grid& grid, @@ -889,10 +891,26 @@ namespace Opm const Opm::Deck& deck, const Opm::EclipseState& eclipseState, const double gravity, - BlackoilState& state) + BlackoilState& state, + bool applySwatinit = true) { + typedef EQUIL::DeckDependent::InitialStateComputer ISC; - ISC isc(props, deck, eclipseState, grid, gravity); + //Check for presence of kw SWATINIT + std::vector swat_init = {}; + if (eclipseState.get3DProperties().hasDeckDoubleGridProperty("SWATINIT") && applySwatinit) { + const std::vector& swat_init_ecl = eclipseState. + get3DProperties().getDoubleGridProperty("SWATINIT").getData(); + const int nc = UgGridHelpers::numCells(grid); + swat_init.resize(nc); + const int* gc = UgGridHelpers::globalCell(grid); + for (int c = 0; c < nc; ++c) { + const int deck_pos = (gc == NULL) ? c : gc[c]; + swat_init[c] = swat_init_ecl[deck_pos]; + } + } + + ISC isc(props, deck, eclipseState, grid, gravity, swat_init); const auto pu = props.phaseUsage(); const int ref_phase = pu.phase_used[BlackoilPhases::Liquid] ? pu.phase_pos[BlackoilPhases::Liquid]