From 7f485626a2145ca170dc77c9174cf24b3eeb599c Mon Sep 17 00:00:00 2001 From: Andreas Lauser Date: Thu, 19 Dec 2013 18:22:20 +0100 Subject: [PATCH] use the new parser to read the PVT and grid data from the deck the old code has not yet been removed, but in the long term, this is probably the way to go. --- examples/sim_2p_comp_ad.cpp | 6 +- examples/sim_fibo_ad.cpp | 12 ++- opm/autodiff/BlackoilPropsAdFromDeck.cpp | 113 ++++++++++++++++++++++- opm/autodiff/BlackoilPropsAdFromDeck.hpp | 6 +- 4 files changed, 129 insertions(+), 8 deletions(-) diff --git a/examples/sim_2p_comp_ad.cpp b/examples/sim_2p_comp_ad.cpp index 42d7009c3..d454b6af4 100644 --- a/examples/sim_2p_comp_ad.cpp +++ b/examples/sim_2p_comp_ad.cpp @@ -105,13 +105,13 @@ try Opm::DeckConstPtr newParserDeck = newParser->parse( deck_filename ); // Grid init - grid.reset(new GridManager(*deck)); + grid.reset(new GridManager(newParserDeck)); // Rock and fluid init - props.reset(new BlackoilPropertiesFromDeck(*deck, newParserDeck, *grid->c_grid(), param)); + props.reset(new BlackoilPropertiesFromDeck(newParserDeck, *grid->c_grid(), param)); // check_well_controls = param.getDefault("check_well_controls", false); // max_well_control_iterations = param.getDefault("max_well_control_iterations", 10); // Rock compressibility. - rock_comp.reset(new RockCompressibility(*deck)); + rock_comp.reset(new RockCompressibility(newParserDeck)); // Gravity. gravity[2] = deck->hasField("NOGRAV") ? 0.0 : unit::gravity; // Init state variables (saturation and pressure). diff --git a/examples/sim_fibo_ad.cpp b/examples/sim_fibo_ad.cpp index 57a07e3c8..8c20f9a4c 100644 --- a/examples/sim_fibo_ad.cpp +++ b/examples/sim_fibo_ad.cpp @@ -113,8 +113,16 @@ try Opm::EclipseWriter outputWriter(param, share_obj(*deck), share_obj(*grid->c_grid())); // Rock and fluid init - props.reset(new BlackoilPropertiesFromDeck(*deck, newParserDeck, *grid->c_grid(), param)); - new_props.reset(new BlackoilPropsAdFromDeck(*deck, newParserDeck, *grid->c_grid())); + +#if 0 + std::cout << "new parser\n"; + props.reset(new BlackoilPropertiesFromDeck(newParserDeck, *grid->c_grid(), param)); + new_props.reset(new BlackoilPropsAdFromDeck(newParserDeck, *grid->c_grid())); +#else + std::cout << "old parser\n"; + props.reset(new BlackoilPropertiesFromDeck(*deck, *grid->c_grid(), param)); + new_props.reset(new BlackoilPropsAdFromDeck(*deck, *grid->c_grid())); +#endif // check_well_controls = param.getDefault("check_well_controls", false); // max_well_control_iterations = param.getDefault("max_well_control_iterations", 10); // Rock compressibility. diff --git a/opm/autodiff/BlackoilPropsAdFromDeck.cpp b/opm/autodiff/BlackoilPropsAdFromDeck.cpp index 0a1be386f..5962319e7 100644 --- a/opm/autodiff/BlackoilPropsAdFromDeck.cpp +++ b/opm/autodiff/BlackoilPropsAdFromDeck.cpp @@ -33,10 +33,11 @@ #include #include +#include +#include namespace Opm { - // Making these typedef to make the code more readable. typedef BlackoilPropsAdFromDeck::ADB ADB; typedef BlackoilPropsAdFromDeck::V V; @@ -47,7 +48,6 @@ namespace Opm /// Constructor wrapping an opm-core black oil interface. BlackoilPropsAdFromDeck::BlackoilPropsAdFromDeck(const EclipseGridParser& deck, - Opm::DeckConstPtr newParserDeck, const UnstructuredGrid& grid, const bool init_rock) { @@ -132,6 +132,115 @@ namespace Opm } + /// Constructor wrapping an opm-core black oil interface. + BlackoilPropsAdFromDeck::BlackoilPropsAdFromDeck(Opm::DeckConstPtr newParserDeck, + const UnstructuredGrid& grid, + const bool init_rock) + { + if (init_rock){ + rock_.init(newParserDeck, grid); + } + const int region_number = 0; + + phase_usage_ = phaseUsageFromDeck(newParserDeck); + + // Surface densities. Accounting for different orders in eclipse and our code. + if (newParserDeck->hasKeyword("DENSITY")) { + const auto keyword = newParserDeck->getKeyword("DENSITY"); + const auto record = keyword->getRecord(region_number); + enum { ECL_oil = 0, ECL_water = 1, ECL_gas = 2 }; + if (phase_usage_.phase_used[Aqua]) { + densities_[phase_usage_.phase_pos[Aqua]] = record->getItem("WATER")->getSIDouble(0); + } + if (phase_usage_.phase_used[Vapour]) { + densities_[phase_usage_.phase_pos[Vapour]] = record->getItem("GAS")->getSIDouble(0); + } + if (phase_usage_.phase_used[Liquid]) { + densities_[phase_usage_.phase_pos[Liquid]] = record->getItem("OIL")->getSIDouble(0); + } + } else { + OPM_THROW(std::runtime_error, "Input is missing DENSITY\n"); + } + + // Set the properties. + props_.resize(phase_usage_.num_phases); + // Water PVT + if (phase_usage_.phase_used[Aqua]) { + if (newParserDeck->hasKeyword("PVTW")) { + std::vector columnNames{ + "PREF", "FVFREF", "COMPRESSIBILITY", "MUREF", "VISCOSIBILITY"}; + + Opm::DeckKeywordConstPtr keyword = newParserDeck->getKeyword("PVTW"); + Opm::SimpleTable pvtwTable(keyword, columnNames, /*recordIdx=*/region_number); + + props_[phase_usage_.phase_pos[Aqua]].reset(new SinglePvtConstCompr(pvtwTable)); + } else { + // Eclipse 100 default. + props_[phase_usage_.phase_pos[Aqua]].reset(new SinglePvtConstCompr(0.5*Opm::prefix::centi*Opm::unit::Poise)); + } + } + // Oil PVT + if (phase_usage_.phase_used[Liquid]) { + if (newParserDeck->hasKeyword("PVDO")) { + std::vector columnNames{ + "PO", "BO", "MUO"}; + + Opm::DeckKeywordConstPtr keyword = newParserDeck->getKeyword("PVDO"); + Opm::SimpleTable pvdoTable(keyword, columnNames, region_number); + + props_[phase_usage_.phase_pos[Liquid]].reset(new SinglePvtDeadSpline(pvdoTable)); + } + else if (newParserDeck->hasKeyword("PVTO")) { + std::vector outerColumnNames{ + "RS", "PBUBB", "RSSAT", "MU"}; + + std::vector innerColumnNames{ + "P", "RSSAT", "MU"}; + + Opm::DeckKeywordConstPtr pvtoKeyword = newParserDeck->getKeyword("PVTO"); + Opm::FullTable pvtoTable(pvtoKeyword, outerColumnNames, innerColumnNames); + + props_[phase_usage_.phase_pos[Liquid]].reset(new SinglePvtLiveOil(pvtoTable)); + } else if (newParserDeck->hasKeyword("PVCDO")) { + std::vector columnNames{ + "PREF", "BO", "CO", "MUREF", "CMUO"}; + + Opm::DeckKeywordConstPtr pvcdoKeyword = newParserDeck->getKeyword("PVCDO"); + Opm::SimpleTable pvcdoTable(pvcdoKeyword, columnNames, region_number); + + props_[phase_usage_.phase_pos[Liquid]].reset(new SinglePvtConstCompr(pvcdoTable)); + } else { + OPM_THROW(std::runtime_error, "Input is missing PVDO or PVTO\n"); + } + } + // Gas PVT + if (phase_usage_.phase_used[Vapour]) { + if (newParserDeck->hasKeyword("PVDG")) { + std::vector columnNames{ + "PG", "BG", "MUG"}; + + Opm::DeckKeywordConstPtr keyword = newParserDeck->getKeyword("PVDG"); + Opm::SimpleTable pvdgTable(keyword, columnNames, region_number); + + props_[phase_usage_.phase_pos[Vapour]].reset(new SinglePvtDeadSpline(pvdgTable)); + } else { + OPM_THROW(std::runtime_error, "Input is missing PVDG or PVTG\n"); + } + } + + SaturationPropsFromDeck* ptr + = new SaturationPropsFromDeck(); + satprops_.reset(ptr); + ptr->init(newParserDeck, grid, -1); + + if (phase_usage_.num_phases != satprops_->numPhases()) { + OPM_THROW(std::runtime_error, "BlackoilPropsAdFromDeck::BlackoilPropsAdFromDeck() - " + "Inconsistent number of phases in pvt data (" << phase_usage_.num_phases + << ") and saturation-dependent function data (" << satprops_->numPhases() << ")."); + } + } + + //////////////////////////// // Rock interface // //////////////////////////// diff --git a/opm/autodiff/BlackoilPropsAdFromDeck.hpp b/opm/autodiff/BlackoilPropsAdFromDeck.hpp index 18b0bb97f..95c372017 100644 --- a/opm/autodiff/BlackoilPropsAdFromDeck.hpp +++ b/opm/autodiff/BlackoilPropsAdFromDeck.hpp @@ -52,7 +52,11 @@ namespace Opm public: /// Constructor wrapping an opm-core black oil interface. BlackoilPropsAdFromDeck(const EclipseGridParser& deck, - Opm::DeckConstPtr newParserDeck, + const UnstructuredGrid& grid, + const bool init_rock = true ); + + /// Constructor wrapping an opm-core black oil interface. + BlackoilPropsAdFromDeck(Opm::DeckConstPtr newParserDeck, const UnstructuredGrid& grid, const bool init_rock = true );