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.
This commit is contained in:
Bård Skaflestad 2021-12-20 21:27:28 +01:00
parent aa77a9c6e9
commit f1fd4726e3

View File

@ -1,23 +1,38 @@
#include <opm/input/eclipse/Deck/DeckKeyword.hpp>
#include <opm/input/eclipse/EclipseState/InitConfig/Equil.hpp> #include <opm/input/eclipse/EclipseState/InitConfig/Equil.hpp>
#include <opm/input/eclipse/Deck/DeckKeyword.hpp>
#include <opm/input/eclipse/Parser/ParserKeywords/E.hpp>
#include <vector>
#include <stddef.h>
namespace Opm { namespace Opm {
EquilRecord::EquilRecord() : EquilRecord::EquilRecord()
EquilRecord(0.0, 0.0, 0.0, 0.0, 0.0, 0.0, false, false, 0.0) : 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) : EquilRecord::EquilRecord(const double datum_depth_arg, const double datum_depth_pc_arg,
datum_depth(datum_depth_arg), const double woc_depth , const double woc_pc,
datum_depth_ps(datum_depth_pc_arg), const double goc_depth , const double goc_pc,
water_oil_contact_depth(woc_depth), const bool live_oil_init ,
water_oil_contact_capillary_pressure(woc_pc), const bool wet_gas_init ,
gas_oil_contact_depth(goc_depth), const int target_accuracy)
gas_oil_contact_capillary_pressure(goc_pc), : datum_depth(datum_depth_arg)
live_oil_init_proc(live_oil_init), , datum_depth_ps(datum_depth_pc_arg)
wet_gas_init_proc(wet_gas_init), , water_oil_contact_depth(woc_depth)
init_target_accuracy(target_accuracy) , 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 { double EquilRecord::datumDepth() const {
@ -70,22 +85,27 @@ namespace Opm {
init_target_accuracy == data.init_target_accuracy; init_target_accuracy == data.init_target_accuracy;
} }
/* */ /* ----------------------------------------------------------------- */
Equil::Equil( const DeckKeyword& keyword ) Equil::Equil( const DeckKeyword& keyword )
{ {
for (const auto& record : keyword) { using ParserKeywords::EQUIL;
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<int>(0) <= 0;
auto wet_gas_init = record.getItem(7).get<int>(0) <= 0;
auto target_accuracy = record.getItem(8).get<int>(0);
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<EQUIL::DATUM_DEPTH>().getSIDouble(0);
const auto datum_depth_pc_arg = record.getItem<EQUIL::DATUM_PRESSURE>().getSIDouble(0);
const auto woc_depth = record.getItem<EQUIL::OWC>().getSIDouble(0);
const auto woc_pc = record.getItem<EQUIL::PC_OWC>().getSIDouble(0);
const auto goc_depth = record.getItem<EQUIL::GOC>().getSIDouble(0);
const auto goc_pc = record.getItem<EQUIL::PC_GOC>().getSIDouble(0);
const auto live_oil_init = record.getItem<EQUIL::BLACK_OIL_INIT>().get<int>(0) <= 0;
const auto wet_gas_init = record.getItem<EQUIL::BLACK_OIL_INIT_WG>().get<int>(0) <= 0;
const auto target_accuracy = record.getItem<EQUIL::OIP_INIT>().get<int>(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);
} }
} }