From 8340d26890bcbe53aa31c9d61dec40e4892bca89 Mon Sep 17 00:00:00 2001 From: babrodtk Date: Fri, 24 Feb 2017 17:10:25 +0100 Subject: [PATCH] Adds hysteresis output and input (for restarting) --- opm/autodiff/BlackoilModelEbos.hpp | 24 +++++++++++ opm/autodiff/Compat.cpp | 22 +++++++++- .../SimulatorFullyImplicitBlackoilEbos.hpp | 43 ++++++++++++++----- .../SimulatorFullyImplicitBlackoilOutput.hpp | 32 +++++++++++++- 4 files changed, 108 insertions(+), 13 deletions(-) diff --git a/opm/autodiff/BlackoilModelEbos.hpp b/opm/autodiff/BlackoilModelEbos.hpp index f26132841..6b2be1d38 100644 --- a/opm/autodiff/BlackoilModelEbos.hpp +++ b/opm/autodiff/BlackoilModelEbos.hpp @@ -1250,6 +1250,20 @@ namespace Opm { simData.registerCellData( "SOMAX", 1 ); VectorType& somax = simData.getCellData( "SOMAX" ); + // Two components for hysteresis parameters + // pcSwMdc/krnSwMdc, one for oil-water and one for gas-oil + simData.registerCellData( "PCSWMDC_GO", 1 ); + simData.registerCellData( "KRNSWMDC_GO", 1 ); + + simData.registerCellData( "PCSWMDC_OW", 1 ); + simData.registerCellData( "KRNSWMDC_OW", 1 ); + + VectorType& pcSwMdc_go = simData.getCellData( "PCSWMDC_GO" ); + VectorType& krnSwMdc_go = simData.getCellData( "KRNSWMDC_GO" ); + + VectorType& pcSwMdc_ow = simData.getCellData( "PCSWMDC_OW" ); + VectorType& krnSwMdc_ow = simData.getCellData( "KRNSWMDC_OW" ); + std::vector failed_cells_pb; std::vector failed_cells_pd; const auto& gridView = ebosSimulator().gridView(); @@ -1276,6 +1290,16 @@ namespace Opm { somax[cellIdx] = ebosSimulator().model().maxOilSaturation(cellIdx); + const auto matLawManager = ebosSimulator().problem().materialLawManager(); + matLawManager->oilWaterHysteresisParams( + pcSwMdc_ow[cellIdx], + krnSwMdc_ow[cellIdx], + cellIdx); + matLawManager->gasOilHysteresisParams( + pcSwMdc_go[cellIdx], + krnSwMdc_go[cellIdx], + cellIdx); + if (aqua_active) { saturation[ satIdx + aqua_pos ] = fs.saturation(FluidSystem::waterPhaseIdx).value(); bWater[cellIdx] = fs.invB(FluidSystem::waterPhaseIdx).value(); diff --git a/opm/autodiff/Compat.cpp b/opm/autodiff/Compat.cpp index 4cd5f11de..d844bad39 100644 --- a/opm/autodiff/Compat.cpp +++ b/opm/autodiff/Compat.cpp @@ -170,7 +170,7 @@ void solutionToSim( const data::Solution& sol, state.getCellData( "RV" ) = sol.data( "RV" ); } - if (sol.has( "SSOL" ) ) { + if ( sol.has( "SSOL" ) ) { state.getCellData("SSOL") = sol.data("SSOL"); } @@ -178,6 +178,26 @@ void solutionToSim( const data::Solution& sol, state.registerCellData("SOMAX", 1); state.getCellData("SOMAX") = sol.data("SOMAX"); } + + if ( sol.has( "PCSWM_OW" ) ) { + state.registerCellData("PCSWMDC_OW", 1); + state.getCellData("PCSWMDC_OW") = sol.data("PCSWM_OW"); + } + + if ( sol.has( "KRNSW_OW" ) ) { + state.registerCellData("KRNSWMDC_OW", 1); + state.getCellData("KRNSWMDC_OW") = sol.data("KRNSW_OW"); + } + + if ( sol.has( "PCSWM_GO" ) ) { + state.registerCellData("PCSWMDC_GO", 1); + state.getCellData("PCSWMDC_GO") = sol.data("PCSWM_GO"); + } + + if ( sol.has( "KRNSW_GO" ) ) { + state.registerCellData("KRNSWMDC_GO", 1); + state.getCellData("KRNSWMDC_GO") = sol.data("KRNSW_GO"); + } } diff --git a/opm/autodiff/SimulatorFullyImplicitBlackoilEbos.hpp b/opm/autodiff/SimulatorFullyImplicitBlackoilEbos.hpp index a1c225009..63c677243 100644 --- a/opm/autodiff/SimulatorFullyImplicitBlackoilEbos.hpp +++ b/opm/autodiff/SimulatorFullyImplicitBlackoilEbos.hpp @@ -149,17 +149,7 @@ public: // This is a restart, populate WellState and ReservoirState state objects from restart file output_writer_.initFromRestartFile(props_.phaseUsage(), grid(), state, prev_well_state, extra); initHydroCarbonState(state, props_.phaseUsage(), Opm::UgGridHelpers::numCells(grid()), has_disgas_, has_vapoil_); - { - const int num_cells = Opm::UgGridHelpers::numCells(grid()); - - typedef std::vector VectorType; - - const VectorType& somax = state.getCellData( "SOMAX" ); - - for (int cellIdx = 0; cellIdx < num_cells; ++cellIdx) { - ebosSimulator_.model().setMaxOilSaturation(somax[cellIdx], cellIdx); - } - } + initHysteresisParams(state); } // Create timers and file for writing timing info. @@ -796,6 +786,37 @@ protected: } } + void initHysteresisParams(ReservoirState& state) { + const int num_cells = Opm::UgGridHelpers::numCells(grid()); + + typedef std::vector VectorType; + + const VectorType& somax = state.getCellData( "SOMAX" ); + + for (int cellIdx = 0; cellIdx < num_cells; ++cellIdx) { + ebosSimulator_.model().setMaxOilSaturation(somax[cellIdx], cellIdx); + } + + VectorType& pcSwMdc_ow = state.getCellData( "PCSWMDC_OW" ); + VectorType& krnSwMdc_ow = state.getCellData( "KRNSWMDC_OW" ); + + VectorType& pcSwMdc_go = state.getCellData( "PCSWMDC_GO" ); + VectorType& krnSwMdc_go = state.getCellData( "KRNSWMDC_GO" ); + + for (int cellIdx = 0; cellIdx < num_cells; ++cellIdx) { + auto matLawManager = ebosSimulator_.problem().materialLawManager(); + matLawManager->setOilWaterHysteresisParams( + pcSwMdc_ow[cellIdx], + krnSwMdc_ow[cellIdx], + cellIdx); + matLawManager->setGasOilHysteresisParams( + pcSwMdc_go[cellIdx], + krnSwMdc_go[cellIdx], + cellIdx); + } + } + + // Data. Simulator& ebosSimulator_; diff --git a/opm/autodiff/SimulatorFullyImplicitBlackoilOutput.hpp b/opm/autodiff/SimulatorFullyImplicitBlackoilOutput.hpp index 209eb3fef..2c0156a28 100644 --- a/opm/autodiff/SimulatorFullyImplicitBlackoilOutput.hpp +++ b/opm/autodiff/SimulatorFullyImplicitBlackoilOutput.hpp @@ -425,7 +425,11 @@ namespace Opm {"TEMP" , UnitSystem::measure::temperature}, {"RS" , UnitSystem::measure::gas_oil_ratio}, {"RV" , UnitSystem::measure::oil_gas_ratio}, - {"SOMAX", UnitSystem::measure::identity}}; + {"SOMAX", UnitSystem::measure::identity}, + {"PCSWM_OW", UnitSystem::measure::identity}, + {"KRNSW_OW", UnitSystem::measure::identity}, + {"PCSWM_GO", UnitSystem::measure::identity}, + {"KRNSW_GO", UnitSystem::measure::identity}}; std::map extra_keys {{"OPMEXTRA" , false}}; if (restart_double_si_) { @@ -784,6 +788,32 @@ namespace Opm data::TargetType::RESTART_AUXILIARY); } + if (sd.hasCellData("PCSWMDC_OW")) { + output.insert("PCSWM_OW", //FIXME: Eight-long variable name + Opm::UnitSystem::measure::identity, + std::move( sd.getCellData("PCSWMDC_OW") ), + data::TargetType::RESTART_AUXILIARY); + } + if (sd.hasCellData("KRNSWMDC_OW")) { + output.insert("KRNSW_OW", + Opm::UnitSystem::measure::identity, + std::move( sd.getCellData("KRNSWMDC_OW") ), + data::TargetType::RESTART_AUXILIARY); + } + + if (sd.hasCellData("PCSWMDC_GO")) { + output.insert("PCSWM_GO", //FIXME: Eight-long variable name + Opm::UnitSystem::measure::identity, + std::move( sd.getCellData("PCSWMDC_GO") ), + data::TargetType::RESTART_AUXILIARY); + } + if (sd.hasCellData("KRNSWMDC_GO")) { + output.insert("KRNSW_GO", + Opm::UnitSystem::measure::identity, + std::move( sd.getCellData("KRNSWMDC_GO") ), + data::TargetType::RESTART_AUXILIARY); + } + //Warn for any unhandled keyword if (log) { for (auto& keyValue : rstKeywords) {