From f1fd4726e38df382174e2932dc7ad4c47b690f86 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?B=C3=A5rd=20Skaflestad?= Date: Mon, 20 Dec 2021 21:27:28 +0100 Subject: [PATCH] Switch to Using Named Items For Extracting EQUIL Keyword Data This is more self-documenting that numeric item indices. While here, also switch to constructing the EQUIL record in place instead of forming a temporary and moving it into the vector. --- .../eclipse/EclipseState/InitConfig/Equil.cpp | 74 ++++++++++++------- 1 file changed, 47 insertions(+), 27 deletions(-) diff --git a/src/opm/input/eclipse/EclipseState/InitConfig/Equil.cpp b/src/opm/input/eclipse/EclipseState/InitConfig/Equil.cpp index ddf387121..afa041f3a 100644 --- a/src/opm/input/eclipse/EclipseState/InitConfig/Equil.cpp +++ b/src/opm/input/eclipse/EclipseState/InitConfig/Equil.cpp @@ -1,23 +1,38 @@ -#include #include +#include +#include + +#include + +#include + namespace Opm { - EquilRecord::EquilRecord() : - EquilRecord(0.0, 0.0, 0.0, 0.0, 0.0, 0.0, false, false, 0.0) - { - } + EquilRecord::EquilRecord() + : EquilRecord(0.0, 0.0, + 0.0, 0.0, + 0.0, 0.0, + false, + false, + 0) + {} - EquilRecord::EquilRecord( double datum_depth_arg, double datum_depth_pc_arg, double woc_depth, double woc_pc, double goc_depth, double goc_pc, bool live_oil_init, bool wet_gas_init, int target_accuracy) : - datum_depth(datum_depth_arg), - datum_depth_ps(datum_depth_pc_arg), - water_oil_contact_depth(woc_depth), - water_oil_contact_capillary_pressure(woc_pc), - gas_oil_contact_depth(goc_depth), - gas_oil_contact_capillary_pressure(goc_pc), - live_oil_init_proc(live_oil_init), - wet_gas_init_proc(wet_gas_init), - init_target_accuracy(target_accuracy) + EquilRecord::EquilRecord(const double datum_depth_arg, const double datum_depth_pc_arg, + const double woc_depth , const double woc_pc, + const double goc_depth , const double goc_pc, + const bool live_oil_init , + const bool wet_gas_init , + const int target_accuracy) + : datum_depth(datum_depth_arg) + , datum_depth_ps(datum_depth_pc_arg) + , water_oil_contact_depth(woc_depth) + , water_oil_contact_capillary_pressure(woc_pc) + , gas_oil_contact_depth(goc_depth) + , gas_oil_contact_capillary_pressure(goc_pc) + , live_oil_init_proc(live_oil_init) + , wet_gas_init_proc(wet_gas_init) + , init_target_accuracy(target_accuracy) {} double EquilRecord::datumDepth() const { @@ -70,22 +85,27 @@ namespace Opm { init_target_accuracy == data.init_target_accuracy; } - /* */ + /* ----------------------------------------------------------------- */ Equil::Equil( const DeckKeyword& keyword ) { - for (const auto& record : keyword) { - auto datum_depth_arg = record.getItem( 0 ).getSIDouble( 0 ); - auto datum_depth_pc_arg = record.getItem( 1 ).getSIDouble( 0 ); - auto woc_depth = record.getItem(2).getSIDouble(0); - auto woc_pc = record.getItem(3).getSIDouble(0); - auto goc_depth = record.getItem(4).getSIDouble(0); - auto goc_pc = record.getItem(5).getSIDouble(0); - auto live_oil_init = record.getItem(6).get(0) <= 0; - auto wet_gas_init = record.getItem(7).get(0) <= 0; - auto target_accuracy = record.getItem(8).get(0); + using ParserKeywords::EQUIL; - this->m_records.push_back( EquilRecord(datum_depth_arg, datum_depth_pc_arg, woc_depth, woc_pc, goc_depth, goc_pc, live_oil_init, wet_gas_init, target_accuracy) ); + for (const auto& record : keyword) { + const auto datum_depth_arg = record.getItem().getSIDouble(0); + const auto datum_depth_pc_arg = record.getItem().getSIDouble(0); + const auto woc_depth = record.getItem().getSIDouble(0); + const auto woc_pc = record.getItem().getSIDouble(0); + const auto goc_depth = record.getItem().getSIDouble(0); + const auto goc_pc = record.getItem().getSIDouble(0); + const auto live_oil_init = record.getItem().get(0) <= 0; + const auto wet_gas_init = record.getItem().get(0) <= 0; + const auto target_accuracy = record.getItem().get(0); + + this->m_records.emplace_back(datum_depth_arg, datum_depth_pc_arg, + woc_depth , woc_pc, + goc_depth , goc_pc, + live_oil_init, wet_gas_init, target_accuracy); } }