From 3c0c94ff7123d1f4878ef47485267d5eafdf22d4 Mon Sep 17 00:00:00 2001 From: Joakim Hove Date: Thu, 5 Mar 2020 10:04:55 +0100 Subject: [PATCH 1/9] Remove stale comment --- opm/parser/eclipse/Deck/UDAValue.hpp | 2 -- 1 file changed, 2 deletions(-) diff --git a/opm/parser/eclipse/Deck/UDAValue.hpp b/opm/parser/eclipse/Deck/UDAValue.hpp index 2eec1bdca..ceeb838c3 100644 --- a/opm/parser/eclipse/Deck/UDAValue.hpp +++ b/opm/parser/eclipse/Deck/UDAValue.hpp @@ -72,8 +72,6 @@ private: double double_value; std::string string_value; - /* This 'mutable' modifier is a hack to avoid tampering with the overall - const-ness of the data in a deck item. */ Dimension dim; }; From 157d3e42790249fd87bdb372105bc5338b1a8f0a Mon Sep 17 00:00:00 2001 From: Joakim Hove Date: Wed, 4 Mar 2020 19:58:34 +0100 Subject: [PATCH 2/9] Add UDAValue constructor which takes dimension --- opm/parser/eclipse/Deck/UDAValue.hpp | 1 + src/opm/parser/eclipse/Deck/UDAValue.cpp | 4 ++++ 2 files changed, 5 insertions(+) diff --git a/opm/parser/eclipse/Deck/UDAValue.hpp b/opm/parser/eclipse/Deck/UDAValue.hpp index ceeb838c3..8bddd16dd 100644 --- a/opm/parser/eclipse/Deck/UDAValue.hpp +++ b/opm/parser/eclipse/Deck/UDAValue.hpp @@ -34,6 +34,7 @@ public: UDAValue(); explicit UDAValue(double); explicit UDAValue(const std::string&); + explicit UDAValue(const Dimension& dim); UDAValue(const UDAValue& src, const Dimension& dim); UDAValue(double data, const Dimension& dim); UDAValue(const std::string& data, const Dimension& dim); diff --git a/src/opm/parser/eclipse/Deck/UDAValue.cpp b/src/opm/parser/eclipse/Deck/UDAValue.cpp index 7a903c74b..274f880ef 100644 --- a/src/opm/parser/eclipse/Deck/UDAValue.cpp +++ b/src/opm/parser/eclipse/Deck/UDAValue.cpp @@ -36,6 +36,10 @@ UDAValue::UDAValue(double value, const Dimension& dim_): { } +UDAValue::UDAValue(const Dimension& dim_): + UDAValue(0, dim_) +{ +} UDAValue::UDAValue() : UDAValue(0) From 37d31aeac01a9ed605edce1238c7d43c1b0e5502 Mon Sep 17 00:00:00 2001 From: Joakim Hove Date: Thu, 5 Mar 2020 10:04:24 +0100 Subject: [PATCH 3/9] Remove UDAValue copy and modify constructor --- opm/parser/eclipse/Deck/UDAValue.hpp | 1 - src/opm/parser/eclipse/Deck/DeckItem.cpp | 18 ++++++++++++++---- src/opm/parser/eclipse/Deck/UDAValue.cpp | 6 ------ tests/parser/UDQTests.cpp | 2 +- 4 files changed, 15 insertions(+), 12 deletions(-) diff --git a/opm/parser/eclipse/Deck/UDAValue.hpp b/opm/parser/eclipse/Deck/UDAValue.hpp index 8bddd16dd..8f797c47c 100644 --- a/opm/parser/eclipse/Deck/UDAValue.hpp +++ b/opm/parser/eclipse/Deck/UDAValue.hpp @@ -35,7 +35,6 @@ public: explicit UDAValue(double); explicit UDAValue(const std::string&); explicit UDAValue(const Dimension& dim); - UDAValue(const UDAValue& src, const Dimension& dim); UDAValue(double data, const Dimension& dim); UDAValue(const std::string& data, const Dimension& dim); diff --git a/src/opm/parser/eclipse/Deck/DeckItem.cpp b/src/opm/parser/eclipse/Deck/DeckItem.cpp index e9b74b443..32aded777 100644 --- a/src/opm/parser/eclipse/Deck/DeckItem.cpp +++ b/src/opm/parser/eclipse/Deck/DeckItem.cpp @@ -162,11 +162,21 @@ UDAValue DeckItem::get( size_t index ) const { if (this->active_dimensions.empty()) return value; + // The UDA value held internally by the DeckItem does not have dimension set + // correctly we therefor need to create a new one with the correct dimension + // attached before returning. std::size_t dim_index = index % this->active_dimensions.size(); - if (value::defaulted(this->value_status[index])) - return UDAValue( value, this->default_dimensions[dim_index]); - else - return UDAValue( value, this->active_dimensions[dim_index]); + if (value::defaulted(this->value_status[index])) { + if (value.is()) + return UDAValue(value.get(), this->default_dimensions[dim_index]); + else + return UDAValue(value.get(), this->default_dimensions[dim_index]); + } else { + if (value.is()) + return UDAValue(value.get(), this->active_dimensions[dim_index]); + else + return UDAValue(value.get(), this->active_dimensions[dim_index]); + } } diff --git a/src/opm/parser/eclipse/Deck/UDAValue.cpp b/src/opm/parser/eclipse/Deck/UDAValue.cpp index 274f880ef..223e677d8 100644 --- a/src/opm/parser/eclipse/Deck/UDAValue.cpp +++ b/src/opm/parser/eclipse/Deck/UDAValue.cpp @@ -58,12 +58,6 @@ UDAValue::UDAValue(const std::string& value, const Dimension& dim_): { } -UDAValue::UDAValue(const UDAValue& src, const Dimension& new_dim): - UDAValue(src) -{ - this->dim = new_dim; -} - void UDAValue::assert_numeric() const { std::string msg = "Internal error: The support for use of UDQ/UDA is not complete in opm/flow. The string: '" + this->string_value + "' must be numeric"; diff --git a/tests/parser/UDQTests.cpp b/tests/parser/UDQTests.cpp index bb1dbdeb1..0714a1b56 100644 --- a/tests/parser/UDQTests.cpp +++ b/tests/parser/UDQTests.cpp @@ -1249,7 +1249,7 @@ BOOST_AUTO_TEST_CASE(UDA_VALUE) { BOOST_AUTO_TEST_CASE(UDA_VALUE_DIM) { UDAValue value0(1); Dimension dim("DUMMY", 10); - UDAValue value1(value0, dim); + UDAValue value1(1, dim); BOOST_CHECK_EQUAL( value0.get(), 1); BOOST_CHECK_EQUAL( value0.getSI(), 1); From f8c250be34fc47ecf3c416586f736242d59a483e Mon Sep 17 00:00:00 2001 From: Joakim Hove Date: Thu, 5 Mar 2020 10:05:02 +0100 Subject: [PATCH 4/9] UDAValue: change from ::reset() to ::operator=() --- opm/parser/eclipse/Deck/UDAValue.hpp | 5 +-- src/opm/parser/eclipse/Deck/UDAValue.cpp | 7 +++- .../EclipseState/Schedule/Well/Well.cpp | 2 +- .../Schedule/Well/WellInjectionProperties.cpp | 14 +++---- .../Well/WellProductionProperties.cpp | 21 +++++----- tests/parser/UDQTests.cpp | 4 +- tests/parser/WellTests.cpp | 40 +++++++++---------- 7 files changed, 47 insertions(+), 46 deletions(-) diff --git a/opm/parser/eclipse/Deck/UDAValue.hpp b/opm/parser/eclipse/Deck/UDAValue.hpp index 8f797c47c..355f30e7e 100644 --- a/opm/parser/eclipse/Deck/UDAValue.hpp +++ b/opm/parser/eclipse/Deck/UDAValue.hpp @@ -55,15 +55,14 @@ public: template bool is() const; - void reset(double value); - void reset(const std::string& value); - void assert_numeric() const; void assert_numeric(const std::string& error_msg) const; const Dimension& get_dim() const; bool operator==(const UDAValue& other) const; bool operator!=(const UDAValue& other) const; + UDAValue& operator=(double value); + UDAValue& operator=(const std::string& value); bool is_numeric() { return numeric_value; } diff --git a/src/opm/parser/eclipse/Deck/UDAValue.cpp b/src/opm/parser/eclipse/Deck/UDAValue.cpp index 223e677d8..b5361e47c 100644 --- a/src/opm/parser/eclipse/Deck/UDAValue.cpp +++ b/src/opm/parser/eclipse/Deck/UDAValue.cpp @@ -96,14 +96,17 @@ double UDAValue::getSI() const { return this->dim.convertRawToSi(this->double_value); } -void UDAValue::reset(double value) { + +UDAValue& UDAValue::operator=(double value) { this->double_value = value; this->numeric_value = true; + return *this; } -void UDAValue::reset(const std::string& value) { +UDAValue& UDAValue::operator=(const std::string& value) { this->string_value = value; this->numeric_value = false; + return *this; } template<> diff --git a/src/opm/parser/eclipse/EclipseState/Schedule/Well/Well.cpp b/src/opm/parser/eclipse/EclipseState/Schedule/Well/Well.cpp index b018ab3ef..746bcc5f0 100644 --- a/src/opm/parser/eclipse/EclipseState/Schedule/Well/Well.cpp +++ b/src/opm/parser/eclipse/EclipseState/Schedule/Well/Well.cpp @@ -273,7 +273,7 @@ bool Well::updateEconLimits(std::shared_ptr econ_limit void Well::switchToProducer() { auto p = std::make_shared(this->getInjectionProperties()); - p->BHPTarget.reset(0); + p->BHPTarget = 0; p->dropInjectionControl( Opm::Well::InjectorCMode::BHP ); this->updateInjection( p ); this->updateProducer(true); diff --git a/src/opm/parser/eclipse/EclipseState/Schedule/Well/WellInjectionProperties.cpp b/src/opm/parser/eclipse/EclipseState/Schedule/Well/WellInjectionProperties.cpp index b23bb1d92..21c6e73e3 100644 --- a/src/opm/parser/eclipse/EclipseState/Schedule/Well/WellInjectionProperties.cpp +++ b/src/opm/parser/eclipse/EclipseState/Schedule/Well/WellInjectionProperties.cpp @@ -150,14 +150,14 @@ namespace Opm { if (cmode == Well::WELTARGCMode::BHP){ if (this->predictionMode) { this->BHPTarget.assert_numeric("Can not combine UDA and WELTARG"); - this->BHPTarget.reset( newValue ); + this->BHPTarget = newValue; } else this->bhp_hist_limit = newValue * SiFactorP; } else if (cmode == WELTARGCMode::ORAT){ if(this->injectorType == InjectorType::OIL){ this->surfaceInjectionRate.assert_numeric("Can not combine UDA and WELTARG"); - this->surfaceInjectionRate.reset( newValue ); + this->surfaceInjectionRate = newValue; }else{ std::invalid_argument("Well type must be OIL to set the oil rate"); } @@ -165,7 +165,7 @@ namespace Opm { else if (cmode == WELTARGCMode::WRAT){ if (this->injectorType == InjectorType::WATER) { this->surfaceInjectionRate.assert_numeric("Can not combine UDA and WELTARG"); - this->surfaceInjectionRate.reset( newValue ); + this->surfaceInjectionRate = newValue; } else std::invalid_argument("Well type must be WATER to set the water rate"); @@ -173,21 +173,21 @@ namespace Opm { else if (cmode == WELTARGCMode::GRAT){ if(this->injectorType == InjectorType::GAS){ this->surfaceInjectionRate.assert_numeric("Can not combine UDA and WELTARG"); - this->surfaceInjectionRate.reset( newValue ); + this->surfaceInjectionRate = newValue; }else{ std::invalid_argument("Well type must be GAS to set the gas rate"); } } else if (cmode == WELTARGCMode::THP){ this->THPTarget.assert_numeric("Can not combine UDA and WELTARG"); - this->THPTarget.reset( newValue ); + this->THPTarget = newValue; } else if (cmode == WELTARGCMode::VFP){ this->VFPTableNumber = static_cast (newValue); } else if (cmode == WELTARGCMode::RESV){ this->surfaceInjectionRate.assert_numeric("Can not combine UDA and WELTARG"); - this->reservoirInjectionRate.reset( newValue ); + this->reservoirInjectionRate = newValue; } else if (cmode != WELTARGCMode::GUID){ throw std::invalid_argument("Invalid keyword (MODE) supplied"); @@ -206,7 +206,7 @@ namespace Opm { if (!record.getItem("RATE").defaultApplied(0)) { double injectionRate = record.getItem("RATE").get(0); - this->surfaceInjectionRate.reset( injectionRate ); + this->surfaceInjectionRate = injectionRate; } if ( record.getItem( "BHP" ).hasValue(0) ) this->BHPH = record.getItem("BHP").getSIDouble(0); diff --git a/src/opm/parser/eclipse/EclipseState/Schedule/Well/WellProductionProperties.cpp b/src/opm/parser/eclipse/EclipseState/Schedule/Well/WellProductionProperties.cpp index 59bf8fd68..c7665c6b4 100644 --- a/src/opm/parser/eclipse/EclipseState/Schedule/Well/WellProductionProperties.cpp +++ b/src/opm/parser/eclipse/EclipseState/Schedule/Well/WellProductionProperties.cpp @@ -101,8 +101,7 @@ namespace Opm { this->predictionMode = false; // update LiquidRate. The funnny constrction with explicitly making a new // UDAValue is to ensure that the UDAValue has the correct dimension. - this->LiquidRate = UDAValue(this->LiquidRate, this->OilRate.get_dim()); - this->LiquidRate.reset(this->WaterRate.get() + this->OilRate.get()); + this->LiquidRate = UDAValue(this->WaterRate.get() + this->OilRate.get(), this->OilRate.get_dim()); if ( record.getItem( "BHP" ).hasValue(0) ) this->BHPH = record.getItem("BHP").get(0).getSI(); @@ -208,8 +207,8 @@ namespace Opm { void Well::WellProductionProperties::handleWCONHIST(const DeckRecord& record) { this->init_rates(record); - this->LiquidRate.reset(0); - this->ResVRate.reset(0); + this->LiquidRate = 0; + this->ResVRate = 0; // when the well is switching to history matching producer from prediction mode // or switching from injector to producer @@ -229,40 +228,40 @@ namespace Opm { void Well::WellProductionProperties::handleWELTARG(Well::WELTARGCMode cmode, double newValue, double SiFactorP) { if (cmode == WELTARGCMode::ORAT){ this->OilRate.assert_numeric("Can not combine UDA and WELTARG"); - this->OilRate.reset( newValue ); + this->OilRate = newValue; this->addProductionControl( ProducerCMode::ORAT ); } else if (cmode == WELTARGCMode::WRAT){ this->WaterRate.assert_numeric("Can not combine UDA and WELTARG"); - this->WaterRate.reset( newValue ); + this->WaterRate = newValue; this->addProductionControl( ProducerCMode::WRAT ); } else if (cmode == WELTARGCMode::GRAT){ this->GasRate.assert_numeric("Can not combine UDA and WELTARG"); - this->GasRate.reset( newValue ); + this->GasRate = newValue; this->addProductionControl( ProducerCMode::GRAT ); } else if (cmode == WELTARGCMode::LRAT){ this->LiquidRate.assert_numeric("Can not combine UDA and WELTARG"); - this->LiquidRate.reset( newValue ); + this->LiquidRate = newValue; this->addProductionControl( ProducerCMode::LRAT ); } else if (cmode == WELTARGCMode::RESV){ this->ResVRate.assert_numeric("Can not combine UDA and WELTARG"); - this->ResVRate.reset( newValue ); + this->ResVRate = newValue; this->addProductionControl( ProducerCMode::RESV ); } else if (cmode == WELTARGCMode::BHP){ if (this->predictionMode) { this->BHPTarget.assert_numeric("Can not combine UDA and WELTARG"); - this->BHPTarget.reset( newValue ); + this->BHPTarget = newValue; } else this->bhp_hist_limit = newValue * SiFactorP; this->addProductionControl( ProducerCMode::BHP ); } else if (cmode == WELTARGCMode::THP){ this->THPTarget.assert_numeric("Can not combine UDA and WELTARG"); - this->THPTarget.reset(newValue ); + this->THPTarget = newValue; this->addProductionControl( ProducerCMode::THP ); } else if (cmode == WELTARGCMode::VFP) diff --git a/tests/parser/UDQTests.cpp b/tests/parser/UDQTests.cpp index 0714a1b56..6bc47284b 100644 --- a/tests/parser/UDQTests.cpp +++ b/tests/parser/UDQTests.cpp @@ -1217,10 +1217,10 @@ BOOST_AUTO_TEST_CASE(UDA_VALUE) { BOOST_CHECK(!value0.is()); BOOST_CHECK_EQUAL( value0.get(), 0); BOOST_CHECK_THROW( value0.get(), std::invalid_argument); - value0.reset( 10 ); + value0 = 10; BOOST_CHECK_EQUAL( value0.get(), 10); BOOST_CHECK_THROW( value0.get(), std::invalid_argument); - value0.reset( "STRING" ); + value0 = "STRING"; BOOST_CHECK_EQUAL( value0.get(), std::string("STRING")); BOOST_CHECK_THROW( value0.get(), std::invalid_argument); diff --git a/tests/parser/WellTests.cpp b/tests/parser/WellTests.cpp index ae339d708..3ea97363d 100644 --- a/tests/parser/WellTests.cpp +++ b/tests/parser/WellTests.cpp @@ -211,7 +211,7 @@ BOOST_AUTO_TEST_CASE(isProducerCorrectlySet) { /* Set a surface injection rate => Well becomes an Injector */ auto injectionProps1 = std::make_shared(well.getInjectionProperties()); - injectionProps1->surfaceInjectionRate.reset(100); + injectionProps1->surfaceInjectionRate = 100; well.updateInjection(injectionProps1); BOOST_CHECK_EQUAL( true , well.isInjector()); BOOST_CHECK_EQUAL( false , well.isProducer()); @@ -224,7 +224,7 @@ BOOST_AUTO_TEST_CASE(isProducerCorrectlySet) { /* Set a reservoir injection rate => Well becomes an Injector */ auto injectionProps2 = std::make_shared(well.getInjectionProperties()); - injectionProps2->reservoirInjectionRate.reset(200); + injectionProps2->reservoirInjectionRate = 200; well.updateInjection(injectionProps2); BOOST_CHECK_EQUAL( false , well.isProducer()); BOOST_CHECK_EQUAL( 200 , well.getInjectionProperties().reservoirInjectionRate.get()); @@ -238,9 +238,9 @@ BOOST_AUTO_TEST_CASE(isProducerCorrectlySet) { well.updateInjection(injectionProps3); auto properties = std::make_shared( well.getProductionProperties() ); - properties->OilRate.reset(100); - properties->GasRate.reset(200); - properties->WaterRate.reset(300); + properties->OilRate = 100; + properties->GasRate = 200; + properties->WaterRate = 300; well.updateProduction(properties); BOOST_CHECK_EQUAL( false , well.isInjector()); @@ -277,14 +277,14 @@ BOOST_AUTO_TEST_CASE(XHPLimitDefault) { auto productionProps = std::make_shared(well.getProductionProperties()); - productionProps->BHPTarget.reset(100); + productionProps->BHPTarget = 100; productionProps->addProductionControl(Opm::Well::ProducerCMode::BHP); well.updateProduction(productionProps); BOOST_CHECK_EQUAL( 100 , well.getProductionProperties().BHPTarget.get()); BOOST_CHECK_EQUAL( true, well.getProductionProperties().hasProductionControl( Opm::Well::ProducerCMode::BHP )); auto injProps = std::make_shared(well.getInjectionProperties()); - injProps->THPTarget.reset(200); + injProps->THPTarget = 200; well.updateInjection(injProps); BOOST_CHECK_EQUAL( 200 , well.getInjectionProperties().THPTarget.get()); BOOST_CHECK( !well.getInjectionProperties().hasInjectionControl( Opm::Well::InjectorCMode::THP )); @@ -318,26 +318,26 @@ BOOST_AUTO_TEST_CASE(WellHaveProductionControlLimit) { BOOST_CHECK( !well.getProductionProperties().hasProductionControl( Opm::Well::ProducerCMode::RESV )); auto properties1 = std::make_shared(well.getProductionProperties()); - properties1->OilRate.reset(100); + properties1->OilRate = 100; properties1->addProductionControl(Opm::Well::ProducerCMode::ORAT); well.updateProduction(properties1); BOOST_CHECK( well.getProductionProperties().hasProductionControl( Opm::Well::ProducerCMode::ORAT )); BOOST_CHECK( !well.getProductionProperties().hasProductionControl( Opm::Well::ProducerCMode::RESV )); auto properties2 = std::make_shared(well.getProductionProperties()); - properties2->ResVRate.reset( 100 ); + properties2->ResVRate = 100; properties2->addProductionControl(Opm::Well::ProducerCMode::RESV); well.updateProduction(properties2); BOOST_CHECK( well.getProductionProperties().hasProductionControl( Opm::Well::ProducerCMode::RESV )); auto properties3 = std::make_shared(well.getProductionProperties()); - properties3->OilRate.reset(100); - properties3->WaterRate.reset(100); - properties3->GasRate.reset(100); - properties3->LiquidRate.reset(100); - properties3->ResVRate.reset(100); - properties3->BHPTarget.reset(100); - properties3->THPTarget.reset(100); + properties3->OilRate = 100; + properties3->WaterRate = 100; + properties3->GasRate = 100; + properties3->LiquidRate = 100; + properties3->ResVRate = 100; + properties3->BHPTarget = 100; + properties3->THPTarget = 100; properties3->addProductionControl(Opm::Well::ProducerCMode::ORAT); properties3->addProductionControl(Opm::Well::ProducerCMode::LRAT); properties3->addProductionControl(Opm::Well::ProducerCMode::BHP); @@ -364,22 +364,22 @@ BOOST_AUTO_TEST_CASE(WellHaveInjectionControlLimit) { BOOST_CHECK( !well.getInjectionProperties().hasInjectionControl( Opm::Well::InjectorCMode::RESV )); auto injProps1 = std::make_shared(well.getInjectionProperties()); - injProps1->surfaceInjectionRate.reset(100); + injProps1->surfaceInjectionRate = 100; injProps1->addInjectionControl(Opm::Well::InjectorCMode::RATE); well.updateInjection(injProps1); BOOST_CHECK( well.getInjectionProperties().hasInjectionControl( Opm::Well::InjectorCMode::RATE )); BOOST_CHECK( !well.getInjectionProperties().hasInjectionControl( Opm::Well::InjectorCMode::RESV )); auto injProps2 = std::make_shared(well.getInjectionProperties()); - injProps2->reservoirInjectionRate.reset(100); + injProps2->reservoirInjectionRate = 100; injProps2->addInjectionControl(Opm::Well::InjectorCMode::RESV); well.updateInjection(injProps2); BOOST_CHECK( well.getInjectionProperties().hasInjectionControl( Opm::Well::InjectorCMode::RESV )); auto injProps3 = std::make_shared(well.getInjectionProperties()); - injProps3->BHPTarget.reset(100); + injProps3->BHPTarget = 100; injProps3->addInjectionControl(Opm::Well::InjectorCMode::BHP); - injProps3->THPTarget.reset(100); + injProps3->THPTarget = 100; injProps3->addInjectionControl(Opm::Well::InjectorCMode::THP); well.updateInjection(injProps3); From 874c734628494a9d9959a7ff0e01f96ae5cf0891 Mon Sep 17 00:00:00 2001 From: Joakim Hove Date: Wed, 4 Mar 2020 20:45:56 +0100 Subject: [PATCH 5/9] Remove name property from UnitSystem dimension --- opm/parser/eclipse/Units/Dimension.hpp | 6 ++---- opm/parser/eclipse/Units/UnitSystem.hpp | 2 +- src/opm/parser/eclipse/Units/Dimension.cpp | 17 +++------------ src/opm/parser/eclipse/Units/UnitSystem.cpp | 10 ++++----- tests/parser/DeckTests.cpp | 16 +++++++------- tests/parser/UDQTests.cpp | 2 +- tests/parser/UnitTests.cpp | 24 +++++---------------- 7 files changed, 24 insertions(+), 53 deletions(-) diff --git a/opm/parser/eclipse/Units/Dimension.hpp b/opm/parser/eclipse/Units/Dimension.hpp index daea8c0cc..d8392c122 100644 --- a/opm/parser/eclipse/Units/Dimension.hpp +++ b/opm/parser/eclipse/Units/Dimension.hpp @@ -27,8 +27,8 @@ namespace Opm { class Dimension { public: Dimension(); - Dimension(const std::string& name, double SIfactor, - double SIoffset = 0.0, bool sanityCheck = true); + Dimension(double SIfactor, + double SIoffset = 0.0); double getSIScaling() const; double getSIScalingRaw() const; @@ -38,7 +38,6 @@ namespace Opm { double convertSiToRaw(double siValue) const; bool equal(const Dimension& other) const; - const std::string& getName() const; bool isCompositable() const; static Dimension newComposite(const std::string& dim, double SIfactor, double SIoffset = 0.0); @@ -46,7 +45,6 @@ namespace Opm { bool operator!=( const Dimension& ) const; private: - std::string m_name; double m_SIfactor; double m_SIoffset; }; diff --git a/opm/parser/eclipse/Units/UnitSystem.hpp b/opm/parser/eclipse/Units/UnitSystem.hpp index 206a9fe4f..94feb7606 100644 --- a/opm/parser/eclipse/Units/UnitSystem.hpp +++ b/opm/parser/eclipse/Units/UnitSystem.hpp @@ -87,8 +87,8 @@ namespace Opm { UnitType getType() const; int ecl_id() const; + void addDimension(const std::string& dimension , const Dimension& dim); void addDimension(const std::string& dimension, double SIfactor, double SIoffset = 0.0); - void addDimension( Dimension ); const Dimension& getNewDimension(const std::string& dimension); const Dimension& getDimension(const std::string& dimension) const; bool hasDimension(const std::string& dimension) const; diff --git a/src/opm/parser/eclipse/Units/Dimension.cpp b/src/opm/parser/eclipse/Units/Dimension.cpp index 8011190a1..ec33f2fe0 100644 --- a/src/opm/parser/eclipse/Units/Dimension.cpp +++ b/src/opm/parser/eclipse/Units/Dimension.cpp @@ -25,22 +25,16 @@ namespace Opm { - Dimension::Dimension() : - m_name("Dimensionless") + Dimension::Dimension() { this->m_SIfactor = 1.0; this->m_SIoffset = 0.0; } - Dimension::Dimension(const std::string& name, double SIfactor, - double SIoffset, bool sanityCheck) + Dimension::Dimension(double SIfactor, + double SIoffset) { - for (auto iter = name.begin(); iter != name.end() && sanityCheck; ++iter) { - if (!isalpha(*iter) && (*iter) != '1') - throw std::invalid_argument("Invalid dimension name"); - } - m_name = name; m_SIfactor = SIfactor; m_SIoffset = SIoffset; } @@ -76,9 +70,6 @@ namespace Opm { return (siValue - m_SIoffset)/m_SIfactor; } - const std::string& Dimension::getName() const { - return m_name; - } // only dimensions with zero offset are compositable... bool Dimension::isCompositable() const @@ -86,7 +77,6 @@ namespace Opm { Dimension Dimension::newComposite(const std::string& dim , double SIfactor, double SIoffset) { Dimension dimension; - dimension.m_name = dim; dimension.m_SIfactor = SIfactor; dimension.m_SIoffset = SIoffset; return dimension; @@ -98,7 +88,6 @@ namespace Opm { } bool Dimension::operator==( const Dimension& rhs ) const { - if( this->m_name != rhs.m_name ) return false; if( this->m_SIfactor == rhs.m_SIfactor && this->m_SIoffset == rhs.m_SIoffset ) return true; diff --git a/src/opm/parser/eclipse/Units/UnitSystem.cpp b/src/opm/parser/eclipse/Units/UnitSystem.cpp index 42389b024..f9fa2e87f 100644 --- a/src/opm/parser/eclipse/Units/UnitSystem.cpp +++ b/src/opm/parser/eclipse/Units/UnitSystem.cpp @@ -1144,7 +1144,7 @@ namespace { const Dimension& UnitSystem::getNewDimension(const std::string& dimension) { if( !hasDimension( dimension ) ) - this->addDimension( this->parse( dimension ) ); + this->addDimension( dimension, this->parse( dimension ) ); return getDimension( dimension ); } @@ -1163,14 +1163,12 @@ namespace { return this->m_use_count; } - - void UnitSystem::addDimension( Dimension dimension ) { - const auto dimname = dimension.getName(); - this->m_dimensions[ dimname ] = std::move( dimension ); + void UnitSystem::addDimension(const std::string& dimension , const Dimension& dim) { + this->m_dimensions[ dimension ] = std::move(dim); } void UnitSystem::addDimension(const std::string& dimension , double SIfactor, double SIoffset) { - this->addDimension( Dimension { dimension, SIfactor, SIoffset } ); + this->addDimension(dimension, Dimension(SIfactor, SIoffset)); } const std::string& UnitSystem::getName() const { diff --git a/tests/parser/DeckTests.cpp b/tests/parser/DeckTests.cpp index bf15d24de..009dc3b98 100644 --- a/tests/parser/DeckTests.cpp +++ b/tests/parser/DeckTests.cpp @@ -295,7 +295,7 @@ BOOST_AUTO_TEST_CASE(GetSIWithoutDimensionThrows) { } BOOST_AUTO_TEST_CASE(GetSISingleDimensionCorrect) { - Dimension dim{ "Length" , 100 }; + Dimension dim{ 100 }; DeckItem item( "HEI", double(), { dim }, { dim } ); item.push_back(1.0 , 100 ); @@ -305,8 +305,8 @@ BOOST_AUTO_TEST_CASE(GetSISingleDimensionCorrect) { } BOOST_AUTO_TEST_CASE(GetSISingleDefault) { - Dimension dim{ "Length" , 1 }; - Dimension defaultDim{ "Length" , 100 }; + Dimension dim{ 1 }; + Dimension defaultDim{ 100 }; DeckItem item( "HEI", double() , {dim}, {defaultDim}); item.push_backDefault( 1.0 ); @@ -315,11 +315,11 @@ BOOST_AUTO_TEST_CASE(GetSISingleDefault) { } BOOST_AUTO_TEST_CASE(GetSIMultipleDim) { - Dimension dim1{ "Length" , 2 }; - Dimension dim2{ "Length" , 4 }; - Dimension dim3{ "Length" , 8 }; - Dimension dim4{ "Length" ,16 }; - Dimension defaultDim{ "Length" , 100 }; + Dimension dim1{ 2 }; + Dimension dim2{ 4 }; + Dimension dim3{ 8 }; + Dimension dim4{ 16 }; + Dimension defaultDim{ 100 }; DeckItem item( "HEI", double(), {dim1, dim2, dim3, dim4}, {defaultDim, defaultDim, defaultDim, defaultDim} ); item.push_back( 1.0, 16 ); diff --git a/tests/parser/UDQTests.cpp b/tests/parser/UDQTests.cpp index 6bc47284b..bed801b3d 100644 --- a/tests/parser/UDQTests.cpp +++ b/tests/parser/UDQTests.cpp @@ -1248,7 +1248,7 @@ BOOST_AUTO_TEST_CASE(UDA_VALUE) { BOOST_AUTO_TEST_CASE(UDA_VALUE_DIM) { UDAValue value0(1); - Dimension dim("DUMMY", 10); + Dimension dim(10); UDAValue value1(1, dim); BOOST_CHECK_EQUAL( value0.get(), 1); diff --git a/tests/parser/UnitTests.cpp b/tests/parser/UnitTests.cpp index c37b7eff2..491e129db 100644 --- a/tests/parser/UnitTests.cpp +++ b/tests/parser/UnitTests.cpp @@ -37,28 +37,16 @@ BOOST_AUTO_TEST_CASE(DefDim) { } BOOST_AUTO_TEST_CASE(CreateDimension) { - Dimension length("Length" , 1); - BOOST_CHECK_EQUAL("Length" , length.getName()); + Dimension length(1); BOOST_CHECK_EQUAL(1 , length.getSIScaling()); } BOOST_AUTO_TEST_CASE(makeComposite) { auto composite = Dimension::newComposite("Length*Length*Length/Time" , 100); - BOOST_CHECK_EQUAL("Length*Length*Length/Time" , composite.getName()); BOOST_CHECK_EQUAL(100 , composite.getSIScaling()); } -BOOST_AUTO_TEST_CASE(CreateDimensionInvalidNameThrows) { - BOOST_CHECK_THROW(Dimension(" " , 1) , std::invalid_argument); - BOOST_CHECK_THROW(Dimension(".LX" , 1) , std::invalid_argument); - BOOST_CHECK_THROW(Dimension("*" , 1) , std::invalid_argument); - BOOST_CHECK_THROW(Dimension("/" , 1) , std::invalid_argument); - BOOST_CHECK_THROW(Dimension("2" , 1) , std::invalid_argument); - BOOST_CHECK_NO_THROW(Dimension("1" , 1)); -} - - BOOST_AUTO_TEST_CASE(CreateUnitSystem) { UnitSystem system(UnitSystem::UnitType::UNIT_TYPE_METRIC); BOOST_CHECK_EQUAL("Metric" , system.getName()); @@ -112,7 +100,6 @@ BOOST_AUTO_TEST_CASE(UnitSystemParseInvalidThrows) { system.addDimension("Time" , 9.0 ); auto volumePerTime = system.parse( "Length*Length*Length/Time" ); - BOOST_CHECK_EQUAL("Length*Length*Length/Time" , volumePerTime.getName() ); BOOST_CHECK_EQUAL(3.0 , volumePerTime.getSIScaling()); } @@ -123,6 +110,7 @@ static void checkSystemHasRequiredDimensions( const UnitSystem& system) { BOOST_CHECK( system.hasDimension("Length")); BOOST_CHECK( system.hasDimension("Mass")); BOOST_CHECK( system.hasDimension("Time")); + BOOST_CHECK( system.hasDimension("Permeability")); BOOST_CHECK( system.hasDimension("Pressure")); BOOST_CHECK( system.hasDimension("Temperature")); @@ -174,14 +162,12 @@ BOOST_AUTO_TEST_CASE(CreateInputSystem) { BOOST_AUTO_TEST_CASE(DimensionEqual) { - Dimension d1("Length" , 1); - Dimension d2("Length" , 1); - Dimension d3("Time" , 1); - Dimension d4("Length" , 2); + Dimension d1(1); + Dimension d2(1); + Dimension d4(2); BOOST_CHECK_EQUAL( true , d1.equal(d1) ); BOOST_CHECK_EQUAL( true , d1.equal(d2) ); - BOOST_CHECK_EQUAL( false , d1.equal(d3) ); BOOST_CHECK_EQUAL( false , d1.equal(d4) ); } From 4b0ee9d0bba9388feb0c563f8aaf492df84a69a6 Mon Sep 17 00:00:00 2001 From: Joakim Hove Date: Thu, 5 Mar 2020 10:12:47 +0100 Subject: [PATCH 6/9] Remove method Dimension::newComposite() --- opm/parser/eclipse/Units/Dimension.hpp | 1 - src/opm/parser/eclipse/Units/Dimension.cpp | 7 ------- src/opm/parser/eclipse/Units/UnitSystem.cpp | 4 ++-- tests/parser/UnitTests.cpp | 5 ----- 4 files changed, 2 insertions(+), 15 deletions(-) diff --git a/opm/parser/eclipse/Units/Dimension.hpp b/opm/parser/eclipse/Units/Dimension.hpp index d8392c122..72bfcb6b8 100644 --- a/opm/parser/eclipse/Units/Dimension.hpp +++ b/opm/parser/eclipse/Units/Dimension.hpp @@ -39,7 +39,6 @@ namespace Opm { bool equal(const Dimension& other) const; bool isCompositable() const; - static Dimension newComposite(const std::string& dim, double SIfactor, double SIoffset = 0.0); bool operator==( const Dimension& ) const; bool operator!=( const Dimension& ) const; diff --git a/src/opm/parser/eclipse/Units/Dimension.cpp b/src/opm/parser/eclipse/Units/Dimension.cpp index ec33f2fe0..5b1eafa8f 100644 --- a/src/opm/parser/eclipse/Units/Dimension.cpp +++ b/src/opm/parser/eclipse/Units/Dimension.cpp @@ -75,13 +75,6 @@ namespace Opm { bool Dimension::isCompositable() const { return m_SIoffset == 0.0; } - Dimension Dimension::newComposite(const std::string& dim , double SIfactor, double SIoffset) { - Dimension dimension; - dimension.m_SIfactor = SIfactor; - dimension.m_SIoffset = SIoffset; - return dimension; - } - bool Dimension::equal(const Dimension& other) const { return *this == other; diff --git a/src/opm/parser/eclipse/Units/UnitSystem.cpp b/src/opm/parser/eclipse/Units/UnitSystem.cpp index f9fa2e87f..549d34c21 100644 --- a/src/opm/parser/eclipse/Units/UnitSystem.cpp +++ b/src/opm/parser/eclipse/Units/UnitSystem.cpp @@ -1195,7 +1195,7 @@ namespace { SIfactor *= dim.getSIScaling(); } - return Dimension::newComposite( dimension , SIfactor ); + return Dimension( SIfactor ); } Dimension UnitSystem::parse(const std::string& dimension) const { @@ -1214,7 +1214,7 @@ namespace { if (dividend.getSIOffset() != 0.0 || divisor.getSIOffset() != 0.0) throw std::invalid_argument("Composite dimensions cannot currently require a conversion offset"); - return Dimension::newComposite( dimension, dividend.getSIScaling() / divisor.getSIScaling() ); + return Dimension( dividend.getSIScaling() / divisor.getSIScaling() ); } diff --git a/tests/parser/UnitTests.cpp b/tests/parser/UnitTests.cpp index 491e129db..f3110657c 100644 --- a/tests/parser/UnitTests.cpp +++ b/tests/parser/UnitTests.cpp @@ -41,11 +41,6 @@ BOOST_AUTO_TEST_CASE(CreateDimension) { BOOST_CHECK_EQUAL(1 , length.getSIScaling()); } -BOOST_AUTO_TEST_CASE(makeComposite) { - auto composite = Dimension::newComposite("Length*Length*Length/Time" , 100); - BOOST_CHECK_EQUAL(100 , composite.getSIScaling()); -} - BOOST_AUTO_TEST_CASE(CreateUnitSystem) { UnitSystem system(UnitSystem::UnitType::UNIT_TYPE_METRIC); From ac79a7a1b11bb3c0fa702a2c9c8a96b8a9453761 Mon Sep 17 00:00:00 2001 From: Joakim Hove Date: Wed, 4 Mar 2020 20:46:26 +0100 Subject: [PATCH 7/9] Add UnitSystem::getDimension( measure ) method --- opm/parser/eclipse/Units/UnitSystem.hpp | 3 +++ src/opm/parser/eclipse/Units/UnitSystem.cpp | 6 ++++++ 2 files changed, 9 insertions(+) diff --git a/opm/parser/eclipse/Units/UnitSystem.hpp b/opm/parser/eclipse/Units/UnitSystem.hpp index 94feb7606..7c5006cec 100644 --- a/opm/parser/eclipse/Units/UnitSystem.hpp +++ b/opm/parser/eclipse/Units/UnitSystem.hpp @@ -91,6 +91,9 @@ namespace Opm { void addDimension(const std::string& dimension, double SIfactor, double SIoffset = 0.0); const Dimension& getNewDimension(const std::string& dimension); const Dimension& getDimension(const std::string& dimension) const; + Dimension getDimension(measure m) const; + + bool hasDimension(const std::string& dimension) const; bool equal(const UnitSystem& other) const; const std::map& getDimensions() const; diff --git a/src/opm/parser/eclipse/Units/UnitSystem.cpp b/src/opm/parser/eclipse/Units/UnitSystem.cpp index 549d34c21..6067b0ddb 100644 --- a/src/opm/parser/eclipse/Units/UnitSystem.cpp +++ b/src/opm/parser/eclipse/Units/UnitSystem.cpp @@ -1158,6 +1158,12 @@ namespace { return iter->second; } + Dimension UnitSystem::getDimension(measure m) const { + double si_factor = this->measure_table_to_si[ static_cast< int >( m ) ]; + double si_offset = this->measure_table_to_si_offset[ static_cast( m ) ]; + return Dimension(si_factor, si_offset); + } + std::size_t UnitSystem::use_count() const { return this->m_use_count; From 17ec37ae4ef22b51cc41e6bc3d5c632c84a65867 Mon Sep 17 00:00:00 2001 From: Joakim Hove Date: Wed, 4 Mar 2020 20:56:16 +0100 Subject: [PATCH 8/9] WellProductionProperties - init with correct UDA dimensions --- .../EclipseState/Schedule/Well/Well.hpp | 2 +- .../EclipseState/Schedule/Well/Well.cpp | 4 +-- .../Well/WellProductionProperties.cpp | 26 +++++++++++++------ tests/parser/WellTests.cpp | 16 +++++++----- 4 files changed, 30 insertions(+), 18 deletions(-) diff --git a/opm/parser/eclipse/EclipseState/Schedule/Well/Well.hpp b/opm/parser/eclipse/EclipseState/Schedule/Well/Well.hpp index 980639aaf..909533c59 100644 --- a/opm/parser/eclipse/EclipseState/Schedule/Well/Well.hpp +++ b/opm/parser/eclipse/EclipseState/Schedule/Well/Well.hpp @@ -317,7 +317,7 @@ public: bool operator!=(const WellProductionProperties& other) const; WellProductionProperties(); - WellProductionProperties(const std::string& name_arg); + WellProductionProperties(const UnitSystem& units, const std::string& name_arg); WellProductionProperties(const std::string& wname, const UDAValue& oilRate, const UDAValue& waterRate, diff --git a/src/opm/parser/eclipse/EclipseState/Schedule/Well/Well.cpp b/src/opm/parser/eclipse/EclipseState/Schedule/Well/Well.cpp index 746bcc5f0..daaf9ccdd 100644 --- a/src/opm/parser/eclipse/EclipseState/Schedule/Well/Well.cpp +++ b/src/opm/parser/eclipse/EclipseState/Schedule/Well/Well.cpp @@ -132,10 +132,10 @@ Well::Well(const std::string& wname_arg, brine_properties(std::make_shared()), tracer_properties(std::make_shared()), connections(std::make_shared(headI, headJ)), - production(std::make_shared(wname)), + production(std::make_shared(unit_system, wname)), injection(std::make_shared(wname)) { - auto p = std::make_shared(wname); + auto p = std::make_shared(this->unit_system, this->wname); p->whistctl_cmode = whistctl_cmode; this->updateProduction(p); } diff --git a/src/opm/parser/eclipse/EclipseState/Schedule/Well/WellProductionProperties.cpp b/src/opm/parser/eclipse/EclipseState/Schedule/Well/WellProductionProperties.cpp index c7665c6b4..0e7820d35 100644 --- a/src/opm/parser/eclipse/EclipseState/Schedule/Well/WellProductionProperties.cpp +++ b/src/opm/parser/eclipse/EclipseState/Schedule/Well/WellProductionProperties.cpp @@ -33,17 +33,27 @@ namespace Opm { - Well::WellProductionProperties::WellProductionProperties() - : BHPH(0.0), THPH(0.0), VFPTableNumber(0), - ALQValue(0.0), predictionMode(false), - controlMode(ProducerCMode::NONE), - whistctl_cmode(ProducerCMode::NONE), - m_productionControls(0) + Well::WellProductionProperties::WellProductionProperties() : + WellProductionProperties(UnitSystem(UnitSystem::UnitType::UNIT_TYPE_METRIC), "") {} - Well::WellProductionProperties::WellProductionProperties(const std::string& name_arg) : + Well::WellProductionProperties::WellProductionProperties(const UnitSystem& units, const std::string& name_arg) : name(name_arg), - predictionMode( true ) + OilRate(units.getDimension(UnitSystem::measure::liquid_surface_rate)), + WaterRate(units.getDimension(UnitSystem::measure::liquid_surface_rate)), + GasRate(units.getDimension(UnitSystem::measure::gas_surface_rate)), + LiquidRate(units.getDimension(UnitSystem::measure::liquid_surface_rate)), + ResVRate(units.getDimension(UnitSystem::measure::rate)), + BHPTarget(units.getDimension(UnitSystem::measure::pressure)), + THPTarget(units.getDimension(UnitSystem::measure::pressure)), + BHPH(0.0), + THPH(0.0), + VFPTableNumber(0), + ALQValue(0.0), + predictionMode(true), + controlMode(ProducerCMode::CMODE_UNDEFINED), + whistctl_cmode(ProducerCMode::CMODE_UNDEFINED), + m_productionControls(0) {} diff --git a/tests/parser/WellTests.cpp b/tests/parser/WellTests.cpp index 3ea97363d..2bcafc556 100644 --- a/tests/parser/WellTests.cpp +++ b/tests/parser/WellTests.cpp @@ -493,10 +493,10 @@ namespace { Opm::Well::WellProductionProperties properties(const std::string& input) { Opm::Parser parser; - + Opm::UnitSystem unit_system(Opm::UnitSystem::UnitType::UNIT_TYPE_METRIC); auto deck = parser.parseString(input); const auto& record = deck.getKeyword("WCONHIST").getRecord(0); - Opm::Well::WellProductionProperties hist("W"); + Opm::Well::WellProductionProperties hist(unit_system, "W"); hist.handleWCONHIST(record); @@ -542,14 +542,14 @@ namespace { return input; } - + Opm::UnitSystem unit_system(Opm::UnitSystem::UnitType::UNIT_TYPE_METRIC); Opm::Well::WellProductionProperties properties(const std::string& input) { Opm::Parser parser; auto deck = parser.parseString(input); const auto& kwd = deck.getKeyword("WCONPROD"); const auto& record = kwd.getRecord(0); - Opm::Well::WellProductionProperties pred("W"); + Opm::Well::WellProductionProperties pred(unit_system, "W"); pred.handleWCONPROD("WELL", record); return pred; @@ -767,7 +767,8 @@ BOOST_AUTO_TEST_CASE(BHP_CMODE) BOOST_AUTO_TEST_CASE(CMODE_DEFAULT) { - const Opm::Well::WellProductionProperties Pproperties("W"); + auto unit_system = UnitSystem::newMETRIC(); + const Opm::Well::WellProductionProperties Pproperties(unit_system, "W"); const Opm::Well::WellInjectionProperties Iproperties("W"); BOOST_CHECK( Pproperties.controlMode == Opm::Well::ProducerCMode::CMODE_UNDEFINED ); @@ -778,8 +779,9 @@ BOOST_AUTO_TEST_CASE(CMODE_DEFAULT) { BOOST_AUTO_TEST_CASE(WELL_CONTROLS) { - Opm::Well well("WELL", "GROUP", 0, 0, 0, 0, 1000, Opm::Phase::OIL, Opm::Well::ProducerCMode::CMODE_UNDEFINED, Opm::Connection::Order::DEPTH, UnitSystem::newMETRIC(), 0, 1.0, false, false); - Opm::Well::WellProductionProperties prod("OP1"); + auto unit_system = UnitSystem::newMETRIC(); + Opm::Well well("WELL", "GROUP", 0, 0, 0, 0, 1000, Opm::Phase::OIL, Opm::Well::ProducerCMode::CMODE_UNDEFINED, Opm::Connection::Order::DEPTH, unit_system, 0, 1.0, false, false); + Opm::Well::WellProductionProperties prod(unit_system, "OP1"); Opm::SummaryState st(std::chrono::system_clock::now()); well.productionControls(st); From 8501a7ead41f20b658531ccd03258bdf3d0fb72e Mon Sep 17 00:00:00 2001 From: Joakim Hove Date: Thu, 5 Mar 2020 09:03:54 +0100 Subject: [PATCH 9/9] Construct UDA values in WellInjectionProperties with correct unit --- .../EclipseState/Schedule/Well/Well.hpp | 2 +- .../EclipseState/Schedule/Well/Well.cpp | 2 +- .../Schedule/Well/WellInjectionProperties.cpp | 26 +++++++++---------- tests/parser/WellTests.cpp | 2 +- 4 files changed, 16 insertions(+), 16 deletions(-) diff --git a/opm/parser/eclipse/EclipseState/Schedule/Well/Well.hpp b/opm/parser/eclipse/EclipseState/Schedule/Well/Well.hpp index 909533c59..f8b920be7 100644 --- a/opm/parser/eclipse/EclipseState/Schedule/Well/Well.hpp +++ b/opm/parser/eclipse/EclipseState/Schedule/Well/Well.hpp @@ -211,7 +211,7 @@ public: bool operator!=(const WellInjectionProperties& other) const; WellInjectionProperties(); - WellInjectionProperties(const std::string& wname); + WellInjectionProperties(const UnitSystem& units, const std::string& wname); WellInjectionProperties(const std::string& wname, const UDAValue& surfaceInjRate, const UDAValue& reservoirInjRate, diff --git a/src/opm/parser/eclipse/EclipseState/Schedule/Well/Well.cpp b/src/opm/parser/eclipse/EclipseState/Schedule/Well/Well.cpp index daaf9ccdd..1882302b2 100644 --- a/src/opm/parser/eclipse/EclipseState/Schedule/Well/Well.cpp +++ b/src/opm/parser/eclipse/EclipseState/Schedule/Well/Well.cpp @@ -133,7 +133,7 @@ Well::Well(const std::string& wname_arg, tracer_properties(std::make_shared()), connections(std::make_shared(headI, headJ)), production(std::make_shared(unit_system, wname)), - injection(std::make_shared(wname)) + injection(std::make_shared(unit_system, wname)) { auto p = std::make_shared(this->unit_system, this->wname); p->whistctl_cmode = whistctl_cmode; diff --git a/src/opm/parser/eclipse/EclipseState/Schedule/Well/WellInjectionProperties.cpp b/src/opm/parser/eclipse/EclipseState/Schedule/Well/WellInjectionProperties.cpp index 21c6e73e3..9f01ec787 100644 --- a/src/opm/parser/eclipse/EclipseState/Schedule/Well/WellInjectionProperties.cpp +++ b/src/opm/parser/eclipse/EclipseState/Schedule/Well/WellInjectionProperties.cpp @@ -37,26 +37,26 @@ namespace Opm { Well::WellInjectionProperties::WellInjectionProperties() - : temperature(0.0), BHPH(0.0), THPH(0.0), VFPTableNumber(0), - predictionMode(false), injectionControls(0), - injectorType(InjectorType::WATER), - controlMode(InjectorCMode::CMODE_UNDEFINED) + : WellInjectionProperties(UnitSystem(UnitSystem::UnitType::UNIT_TYPE_METRIC), "") { } - Well::WellInjectionProperties::WellInjectionProperties(const std::string& wname) + + Well::WellInjectionProperties::WellInjectionProperties(const UnitSystem& units, const std::string& wname) : name(wname), + surfaceInjectionRate(units.getDimension(UnitSystem::measure::identity)), + reservoirInjectionRate(units.getDimension(UnitSystem::measure::rate)), + BHPTarget(units.getDimension(UnitSystem::measure::pressure)), + THPTarget(units.getDimension(UnitSystem::measure::pressure)), + temperature(Metric::TemperatureOffset + ParserKeywords::STCOND::TEMPERATURE::defaultValue), + BHPH(0), + THPH(0), + VFPTableNumber(0), + predictionMode(true), + injectionControls(0), injectorType(InjectorType::WATER), controlMode(InjectorCMode::CMODE_UNDEFINED) { - temperature= - Metric::TemperatureOffset - + ParserKeywords::STCOND::TEMPERATURE::defaultValue; - BHPH=0.0; - THPH=0.0; - VFPTableNumber=0; - predictionMode=true; - injectionControls=0; } Well::WellInjectionProperties::WellInjectionProperties(const std::string& wname, diff --git a/tests/parser/WellTests.cpp b/tests/parser/WellTests.cpp index 2bcafc556..6a17bf1d4 100644 --- a/tests/parser/WellTests.cpp +++ b/tests/parser/WellTests.cpp @@ -769,7 +769,7 @@ BOOST_AUTO_TEST_CASE(BHP_CMODE) BOOST_AUTO_TEST_CASE(CMODE_DEFAULT) { auto unit_system = UnitSystem::newMETRIC(); const Opm::Well::WellProductionProperties Pproperties(unit_system, "W"); - const Opm::Well::WellInjectionProperties Iproperties("W"); + const Opm::Well::WellInjectionProperties Iproperties(unit_system, "W"); BOOST_CHECK( Pproperties.controlMode == Opm::Well::ProducerCMode::CMODE_UNDEFINED ); BOOST_CHECK( Iproperties.controlMode == Opm::Well::InjectorCMode::CMODE_UNDEFINED );