diff --git a/ThirdParty/custom-opm-common/CMakeLists_files.cmake b/ThirdParty/custom-opm-common/CMakeLists_files.cmake index 9fa3b05546..5a2cdda979 100644 --- a/ThirdParty/custom-opm-common/CMakeLists_files.cmake +++ b/ThirdParty/custom-opm-common/CMakeLists_files.cmake @@ -100,11 +100,8 @@ if(ENABLE_ECL_INPUT) src/opm/parser/eclipse/EclipseState/Schedule/Action/ActionValue.cpp src/opm/parser/eclipse/EclipseState/Schedule/Action/ASTNode.cpp src/opm/parser/eclipse/EclipseState/Schedule/Action/Condition.cpp - src/opm/parser/eclipse/EclipseState/Schedule/Action/State.cpp src/opm/parser/eclipse/EclipseState/Schedule/ArrayDimChecker.cpp src/opm/parser/eclipse/EclipseState/Schedule/Events.cpp - src/opm/parser/eclipse/EclipseState/Schedule/GasLiftOpt.cpp - src/opm/parser/eclipse/EclipseState/Schedule/Group/GPMaint.cpp src/opm/parser/eclipse/EclipseState/Schedule/Group/Group.cpp src/opm/parser/eclipse/EclipseState/Schedule/Group/GuideRate.cpp src/opm/parser/eclipse/EclipseState/Schedule/Group/GuideRateConfig.cpp @@ -118,12 +115,9 @@ if(ENABLE_ECL_INPUT) src/opm/parser/eclipse/EclipseState/Schedule/MSW/Compsegs.cpp src/opm/parser/eclipse/EclipseState/Schedule/MSW/Segment.cpp src/opm/parser/eclipse/EclipseState/Schedule/MSW/WellSegments.cpp - src/opm/parser/eclipse/EclipseState/Schedule/MSW/AICD.cpp - src/opm/parser/eclipse/EclipseState/Schedule/MSW/SICD.cpp + src/opm/parser/eclipse/EclipseState/Schedule/MSW/updatingConnectionsWithSegments.cpp + src/opm/parser/eclipse/EclipseState/Schedule/MSW/SpiralICD.cpp src/opm/parser/eclipse/EclipseState/Schedule/MSW/Valve.cpp - src/opm/parser/eclipse/EclipseState/Schedule/Network/Branch.cpp - src/opm/parser/eclipse/EclipseState/Schedule/Network/ExtNetwork.cpp - src/opm/parser/eclipse/EclipseState/Schedule/Network/Node.cpp src/opm/parser/eclipse/EclipseState/Schedule/OilVaporizationProperties.cpp src/opm/parser/eclipse/EclipseState/Schedule/RFTConfig.cpp src/opm/parser/eclipse/EclipseState/Schedule/RPTConfig.cpp @@ -161,7 +155,6 @@ if(ENABLE_ECL_INPUT) src/opm/parser/eclipse/EclipseState/Tables/TableColumn.cpp src/opm/parser/eclipse/EclipseState/Tables/TableContainer.cpp src/opm/parser/eclipse/EclipseState/Tables/TableIndex.cpp - src/opm/parser/eclipse/EclipseState/Tables/TLMixpar.cpp src/opm/parser/eclipse/EclipseState/Tables/TableManager.cpp src/opm/parser/eclipse/EclipseState/Tables/TableSchema.cpp src/opm/parser/eclipse/EclipseState/Tables/Tables.cpp @@ -169,7 +162,6 @@ if(ENABLE_ECL_INPUT) src/opm/parser/eclipse/EclipseState/Tables/Rock2dtrTable.cpp src/opm/parser/eclipse/EclipseState/Tables/PvtwsaltTable.cpp src/opm/parser/eclipse/EclipseState/Tables/BrineDensityTable.cpp - src/opm/parser/eclipse/EclipseState/Tables/RwgsaltTable.cpp src/opm/parser/eclipse/EclipseState/Tables/SolventDensityTable.cpp src/opm/parser/eclipse/EclipseState/Schedule/UDQ/UDQASTNode.cpp src/opm/parser/eclipse/EclipseState/Schedule/UDQ/UDQParams.cpp @@ -199,6 +191,7 @@ if(ENABLE_ECL_INPUT) src/opm/parser/eclipse/Units/Dimension.cpp src/opm/parser/eclipse/Units/UnitSystem.cpp src/opm/parser/eclipse/Utility/Functional.cpp + src/opm/parser/eclipse/Utility/Stringview.cpp ) @@ -343,7 +336,6 @@ if(ENABLE_ECL_INPUT) tests/parser/MultiRegTests.cpp tests/parser/MultisegmentWellTests.cpp tests/parser/MULTREGTScannerTests.cpp - tests/parser/NetworkTests.cpp tests/parser/OrderedMapTests.cpp tests/parser/ParseContextTests.cpp tests/parser/ParseContext_EXIT1.cpp @@ -393,7 +385,6 @@ if(ENABLE_ECL_OUTPUT) tests/test_AggregateConnectionData.cpp tests/test_AggregateUDQData.cpp tests/test_ArrayDimChecker.cpp - tests/test_data_GuideRateValue.cpp tests/test_EclipseIO.cpp tests/test_DoubHEAD.cpp tests/test_InteHEAD.cpp @@ -437,8 +428,6 @@ if(ENABLE_ECL_OUTPUT) tests/SPE1CASE1A.SMSPEC tests/SPE9_CP_PACKED.DATA tests/SOFR_TEST.DATA - tests/UDQ_BASE.DATA - tests/UDQ_RESTART.DATA tests/UDQ_TEST_WCONPROD_IUAD-2.DATA tests/UDQ_ACTIONX_TEST1.DATA tests/UDQ_ACTIONX_TEST1_U.DATA @@ -487,8 +476,6 @@ if(ENABLE_ECL_INPUT) #examples/opmi.cpp #examples/opmpack.cpp #examples/opmhash.cpp - #examples/wellgraph.cpp - #examples/make_lodsmry.cpp ) endif() @@ -501,7 +488,6 @@ if(ENABLE_ECL_INPUT) examples/opmi.cpp examples/opmpack.cpp examples/opmhash.cpp - examples/make_lodsmry.cpp ) endif() @@ -548,6 +534,7 @@ if(ENABLE_ECL_INPUT) list(APPEND PUBLIC_HEADER_FILES opm/io/eclipse/SummaryNode.hpp opm/json/JsonObject.hpp + opm/parser/eclipse/Utility/Stringview.hpp opm/parser/eclipse/Utility/Functional.hpp opm/parser/eclipse/Utility/Typetools.hpp opm/parser/eclipse/Generator/KeywordGenerator.hpp @@ -603,11 +590,8 @@ if(ENABLE_ECL_INPUT) opm/parser/eclipse/EclipseState/Tables/SpecrockTable.hpp opm/parser/eclipse/EclipseState/Tables/PvtwsaltTable.hpp opm/parser/eclipse/EclipseState/Tables/BrineDensityTable.hpp - opm/parser/eclipse/EclipseState/Tables/PermfactTable.hpp - opm/parser/eclipse/EclipseState/Tables/RwgsaltTable.hpp - opm/parser/eclipse/EclipseState/Tables/SaltvdTable.hpp - opm/parser/eclipse/EclipseState/Tables/SaltpvdTable.hpp opm/parser/eclipse/EclipseState/Tables/SolventDensityTable.hpp + opm/parser/eclipse/EclipseState/Tables/SaltvdTable.hpp opm/parser/eclipse/EclipseState/Tables/PlydhflfTable.hpp opm/parser/eclipse/EclipseState/Tables/PlymwinjTable.hpp opm/parser/eclipse/EclipseState/Tables/PlyshlogTable.hpp @@ -617,7 +601,6 @@ if(ENABLE_ECL_INPUT) opm/parser/eclipse/EclipseState/Tables/SpecheatTable.hpp opm/parser/eclipse/EclipseState/Tables/SgcwmisTable.hpp opm/parser/eclipse/EclipseState/Tables/Sof2Table.hpp - opm/parser/eclipse/EclipseState/Tables/TLMixpar.hpp opm/parser/eclipse/EclipseState/Tables/TableManager.hpp opm/parser/eclipse/EclipseState/Tables/SwfnTable.hpp opm/parser/eclipse/EclipseState/Tables/EnptvdTable.hpp @@ -627,8 +610,6 @@ if(ENABLE_ECL_INPUT) opm/parser/eclipse/EclipseState/Tables/JFunc.hpp opm/parser/eclipse/EclipseState/Tables/TableIndex.hpp opm/parser/eclipse/EclipseState/Tables/PvtgTable.hpp - opm/parser/eclipse/EclipseState/Tables/PvtgwTable.hpp - opm/parser/eclipse/EclipseState/Tables/PvtgwoTable.hpp opm/parser/eclipse/EclipseState/Tables/Tabdims.hpp opm/parser/eclipse/EclipseState/Tables/TableSchema.hpp opm/parser/eclipse/EclipseState/Tables/RocktabTable.hpp @@ -685,12 +666,7 @@ if(ENABLE_ECL_INPUT) opm/parser/eclipse/EclipseState/Schedule/Action/Condition.hpp opm/parser/eclipse/EclipseState/Schedule/Action/ASTNode.hpp opm/parser/eclipse/EclipseState/Schedule/Action/PyAction.hpp - opm/parser/eclipse/EclipseState/Schedule/Action/State.hpp opm/parser/eclipse/EclipseState/Schedule/ArrayDimChecker.hpp - opm/parser/eclipse/EclipseState/Schedule/GasLiftOpt.hpp - opm/parser/eclipse/EclipseState/Schedule/Network/Branch.hpp - opm/parser/eclipse/EclipseState/Schedule/Network/ExtNetwork.hpp - opm/parser/eclipse/EclipseState/Schedule/Network/Node.hpp opm/parser/eclipse/EclipseState/Schedule/TimeMap.hpp opm/parser/eclipse/EclipseState/Schedule/VFPInjTable.hpp opm/parser/eclipse/EclipseState/Schedule/VFPProdTable.hpp @@ -717,7 +693,6 @@ if(ENABLE_ECL_INPUT) opm/parser/eclipse/EclipseState/Schedule/Schedule.hpp opm/parser/eclipse/EclipseState/Schedule/ScheduleTypes.hpp opm/parser/eclipse/EclipseState/Schedule/Tuning.hpp - opm/parser/eclipse/EclipseState/Schedule/Group/GPMaint.hpp opm/parser/eclipse/EclipseState/Schedule/Group/GTNode.hpp opm/parser/eclipse/EclipseState/Schedule/Group/Group.hpp opm/parser/eclipse/EclipseState/Schedule/Group/GuideRate.hpp @@ -733,8 +708,8 @@ if(ENABLE_ECL_INPUT) opm/parser/eclipse/EclipseState/Schedule/MSW/Segment.hpp opm/parser/eclipse/EclipseState/Schedule/MSW/Segment.hpp opm/parser/eclipse/EclipseState/Schedule/MSW/WellSegments.hpp - opm/parser/eclipse/EclipseState/Schedule/MSW/AICD.hpp - opm/parser/eclipse/EclipseState/Schedule/MSW/SICD.hpp + opm/parser/eclipse/EclipseState/Schedule/MSW/updatingConnectionsWithSegments.hpp + opm/parser/eclipse/EclipseState/Schedule/MSW/SpiralICD.hpp opm/parser/eclipse/EclipseState/SimulationConfig/ThresholdPressure.hpp opm/parser/eclipse/EclipseState/SimulationConfig/BCConfig.hpp opm/parser/eclipse/EclipseState/SimulationConfig/RockConfig.hpp @@ -789,10 +764,9 @@ if(ENABLE_ECL_OUTPUT) opm/io/eclipse/rst/well.hpp opm/output/data/Aquifer.hpp opm/output/data/Cells.hpp - opm/output/data/GuideRateValue.hpp - opm/output/data/Groups.hpp opm/output/data/Solution.hpp opm/output/data/Wells.hpp + opm/output/data/Groups.hpp opm/output/eclipse/VectorItems/aquifer.hpp opm/output/eclipse/VectorItems/connection.hpp opm/output/eclipse/VectorItems/group.hpp @@ -837,6 +811,5 @@ endif() if (CMAKE_CXX_COMPILER_ID STREQUAL "MSVC") list( APPEND PUBLIC_HEADER_FILES cross-platform/windows/Substitutes.hpp - cross-platform/PortableEndian.hpp ) endif() diff --git a/ThirdParty/custom-opm-common/generated-opm-common/ParserKeywords/G.cpp b/ThirdParty/custom-opm-common/generated-opm-common/ParserKeywords/G.cpp index bbc54fb096..04475902c3 100644 --- a/ThirdParty/custom-opm-common/generated-opm-common/ParserKeywords/G.cpp +++ b/ThirdParty/custom-opm-common/generated-opm-common/ParserKeywords/G.cpp @@ -1952,13 +1952,11 @@ GLIFTOPT::GLIFTOPT( ) : ParserKeyword("GLIFTOPT") { ParserItem item("MAX_LIFT_GAS_SUPPLY", ParserItem::itype::DOUBLE); item.setDefault( double(-100000000000000000000.000000) ); - item.push_backDimension("GasSurfaceVolume/Time"); record.addItem(item); } { ParserItem item("MAX_TOTAL_GAS_RATE", ParserItem::itype::DOUBLE); item.setDefault( double(-100000000000000000000.000000) ); - item.push_backDimension("GasSurfaceVolume/Time"); record.addItem(item); } addRecord( record ); @@ -2168,7 +2166,6 @@ GPMAINT::GPMAINT( ) : ParserKeyword("GPMAINT") } { ParserItem item("FIP_FAMILY", ParserItem::itype::STRING); - item.setDefault( std::string("FIPNUM") ); record.addItem(item); } { @@ -2194,7 +2191,6 @@ const std::string GPMAINT::GROUP::itemName = "GROUP"; const std::string GPMAINT::FLOW_TARGET::itemName = "FLOW_TARGET"; const std::string GPMAINT::REGION::itemName = "REGION"; const std::string GPMAINT::FIP_FAMILY::itemName = "FIP_FAMILY"; -const std::string GPMAINT::FIP_FAMILY::defaultValue = "FIPNUM"; const std::string GPMAINT::PRESSURE_TARGET::itemName = "PRESSURE_TARGET"; const std::string GPMAINT::PROP_CONSTANT::itemName = "PROP_CONSTANT"; const std::string GPMAINT::TIME_CONSTANT::itemName = "TIME_CONSTANT"; diff --git a/ThirdParty/custom-opm-common/generated-opm-common/ParserKeywords/L.cpp b/ThirdParty/custom-opm-common/generated-opm-common/ParserKeywords/L.cpp index b7513ce83b..0ce74c8eff 100644 --- a/ThirdParty/custom-opm-common/generated-opm-common/ParserKeywords/L.cpp +++ b/ThirdParty/custom-opm-common/generated-opm-common/ParserKeywords/L.cpp @@ -310,18 +310,15 @@ LIFTOPT::LIFTOPT( ) : ParserKeyword("LIFTOPT") ParserRecord record; { ParserItem item("INCREMENT_SIZE", ParserItem::itype::DOUBLE); - item.push_backDimension("GasSurfaceVolume/Time"); record.addItem(item); } { ParserItem item("MIN_ECONOMIC_GRADIENT", ParserItem::itype::DOUBLE); - item.push_backDimension("LiquidSurfaceVolume/GasSurfaceVolume"); record.addItem(item); } { ParserItem item("MIN_INTERVAL_BETWEEN_GAS_LIFT_OPTIMIZATIONS", ParserItem::itype::DOUBLE); item.setDefault( double(0) ); - item.push_backDimension("Time"); record.addItem(item); } { diff --git a/ThirdParty/custom-opm-common/generated-opm-common/ParserKeywords/N.cpp b/ThirdParty/custom-opm-common/generated-opm-common/ParserKeywords/N.cpp index 0ab096f03a..9eb512731e 100644 --- a/ThirdParty/custom-opm-common/generated-opm-common/ParserKeywords/N.cpp +++ b/ThirdParty/custom-opm-common/generated-opm-common/ParserKeywords/N.cpp @@ -625,11 +625,6 @@ NODEPROP::NODEPROP( ) : ParserKeyword("NODEPROP") item.setDefault( std::string("NO") ); record.addItem(item); } - { - ParserItem item("ADD_GAS_LIFT_GAS", ParserItem::itype::STRING); - item.setDefault( std::string("NO") ); - record.addItem(item); - } { ParserItem item("CHOKE_GROUP", ParserItem::itype::STRING); record.addItem(item); @@ -651,8 +646,6 @@ const std::string NODEPROP::NAME::itemName = "NAME"; const std::string NODEPROP::PRESSURE::itemName = "PRESSURE"; const std::string NODEPROP::AS_CHOKE::itemName = "AS_CHOKE"; const std::string NODEPROP::AS_CHOKE::defaultValue = "NO"; -const std::string NODEPROP::ADD_GAS_LIFT_GAS::itemName = "ADD_GAS_LIFT_GAS"; -const std::string NODEPROP::ADD_GAS_LIFT_GAS::defaultValue = "NO"; const std::string NODEPROP::CHOKE_GROUP::itemName = "CHOKE_GROUP"; const std::string NODEPROP::SOURCE_SINK_GROUP::itemName = "SOURCE_SINK_GROUP"; const std::string NODEPROP::NETWORK_VALUE_TYPE::itemName = "NETWORK_VALUE_TYPE"; diff --git a/ThirdParty/custom-opm-common/generated-opm-common/ParserKeywords/O.cpp b/ThirdParty/custom-opm-common/generated-opm-common/ParserKeywords/O.cpp index 1e9ae47730..14a51924de 100644 --- a/ThirdParty/custom-opm-common/generated-opm-common/ParserKeywords/O.cpp +++ b/ThirdParty/custom-opm-common/generated-opm-common/ParserKeywords/O.cpp @@ -318,7 +318,7 @@ OPERATER::OPERATER( ) : ParserKeyword("OPERATER") { ParserRecord record; { - ParserItem item("TARGET_ARRAY", ParserItem::itype::STRING); + ParserItem item("RESULT_ARRAY", ParserItem::itype::STRING); record.addItem(item); } { @@ -352,7 +352,7 @@ OPERATER::OPERATER( ) : ParserKeyword("OPERATER") } } const std::string OPERATER::keywordName = "OPERATER"; -const std::string OPERATER::TARGET_ARRAY::itemName = "TARGET_ARRAY"; +const std::string OPERATER::RESULT_ARRAY::itemName = "RESULT_ARRAY"; const std::string OPERATER::REGION_NUMBER::itemName = "REGION_NUMBER"; const std::string OPERATER::OPERATION::itemName = "OPERATION"; const std::string OPERATER::ARRAY_PARAMETER::itemName = "ARRAY_PARAMETER"; diff --git a/ThirdParty/custom-opm-common/generated-opm-common/ParserKeywords/P.cpp b/ThirdParty/custom-opm-common/generated-opm-common/ParserKeywords/P.cpp index cfdd0ce932..6a4b11349e 100644 --- a/ThirdParty/custom-opm-common/generated-opm-common/ParserKeywords/P.cpp +++ b/ThirdParty/custom-opm-common/generated-opm-common/ParserKeywords/P.cpp @@ -646,17 +646,19 @@ const int PERMAVE::EXPO_2::defaultValue = -1; PERMFACT::PERMFACT( ) : ParserKeyword("PERMFACT") { - setSizeType(OTHER_KEYWORD_IN_DECK); - initSizeKeyword("EQLDIMS","NTEQUL",0); + setSizeType(SLASH_TERMINATED); addValidSectionName("PROPS"); clearDeckNames(); addDeckName("PERMFACT"); { ParserRecord record; { - ParserItem item("DATA", ParserItem::itype::DOUBLE); - item.setSizeType(ParserItem::item_size::ALL); + ParserItem item("POROSITY", ParserItem::itype::DOUBLE); item.push_backDimension("1"); + record.addItem(item); + } + { + ParserItem item("PERMFACTMULT", ParserItem::itype::DOUBLE); item.push_backDimension("1"); record.addItem(item); } @@ -664,7 +666,8 @@ PERMFACT::PERMFACT( ) : ParserKeyword("PERMFACT") } } const std::string PERMFACT::keywordName = "PERMFACT"; -const std::string PERMFACT::DATA::itemName = "DATA"; +const std::string PERMFACT::POROSITY::itemName = "POROSITY"; +const std::string PERMFACT::PERMFACTMULT::itemName = "PERMFACTMULT"; PERMJFUN::PERMJFUN( ) : ParserKeyword("PERMJFUN") diff --git a/ThirdParty/custom-opm-common/generated-opm-common/ParserKeywords/R.cpp b/ThirdParty/custom-opm-common/generated-opm-common/ParserKeywords/R.cpp index 218646623f..f5d5bea5a0 100644 --- a/ThirdParty/custom-opm-common/generated-opm-common/ParserKeywords/R.cpp +++ b/ThirdParty/custom-opm-common/generated-opm-common/ParserKeywords/R.cpp @@ -2193,16 +2193,26 @@ RWGSALT::RWGSALT( ) : ParserKeyword("RWGSALT") { setSizeType(OTHER_KEYWORD_IN_DECK); initSizeKeyword("TABDIMS","NTPVT",0); + setTableCollection( true ); addValidSectionName("PROPS"); clearDeckNames(); addDeckName("RWGSALT"); { ParserRecord record; + { + ParserItem item("RESERVOIR_PRESSURE", ParserItem::itype::DOUBLE); + item.push_backDimension("Pressure"); + record.addItem(item); + } + { + ParserItem item("SALT_CONCENTRATION", ParserItem::itype::DOUBLE); + item.setSizeType(ParserItem::item_size::ALL); + item.push_backDimension("Mass/Length*Length*Length"); + record.addItem(item); + } { ParserItem item("DATA", ParserItem::itype::DOUBLE); item.setSizeType(ParserItem::item_size::ALL); - item.push_backDimension("Pressure"); - item.push_backDimension("Mass/Length*Length*Length"); item.push_backDimension("OilDissolutionFactor"); record.addItem(item); } @@ -2210,6 +2220,8 @@ RWGSALT::RWGSALT( ) : ParserKeyword("RWGSALT") } } const std::string RWGSALT::keywordName = "RWGSALT"; +const std::string RWGSALT::RESERVOIR_PRESSURE::itemName = "RESERVOIR_PRESSURE"; +const std::string RWGSALT::SALT_CONCENTRATION::itemName = "SALT_CONCENTRATION"; const std::string RWGSALT::DATA::itemName = "DATA"; diff --git a/ThirdParty/custom-opm-common/generated-opm-common/ParserKeywords/S.cpp b/ThirdParty/custom-opm-common/generated-opm-common/ParserKeywords/S.cpp index 8f603562cc..017701514b 100644 --- a/ThirdParty/custom-opm-common/generated-opm-common/ParserKeywords/S.cpp +++ b/ThirdParty/custom-opm-common/generated-opm-common/ParserKeywords/S.cpp @@ -1542,7 +1542,7 @@ const std::string SOLVDIMS::data::itemName = "data"; SOLVDIRS::SOLVDIRS( ) : ParserKeyword("SOLVDIRS") { - setFixedSize( (size_t) 1); + setSizeType(SLASH_TERMINATED); addValidSectionName("GRID"); clearDeckNames(); addDeckName("SOLVDIRS"); diff --git a/ThirdParty/custom-opm-common/generated-opm-common/ParserKeywords/W.cpp b/ThirdParty/custom-opm-common/generated-opm-common/ParserKeywords/W.cpp index fd177cf87e..2c88319d00 100644 --- a/ThirdParty/custom-opm-common/generated-opm-common/ParserKeywords/W.cpp +++ b/ThirdParty/custom-opm-common/generated-opm-common/ParserKeywords/W.cpp @@ -2652,7 +2652,7 @@ WELTARG::WELTARG( ) : ParserKeyword("WELTARG") record.addItem(item); } { - ParserItem item("NEW_VALUE", ParserItem::itype::UDA); + ParserItem item("NEW_VALUE", ParserItem::itype::DOUBLE); record.addItem(item); } addRecord( record ); @@ -4193,62 +4193,61 @@ WSEGAICD::WSEGAICD( ) : ParserKeyword("WSEGAICD") record.addItem(item); } { - ParserItem item("SEG1", ParserItem::itype::INT); + ParserItem item("SEGMENT1", ParserItem::itype::INT); + item.setDefault( 0 ); record.addItem(item); } { - ParserItem item("SEG2", ParserItem::itype::INT); + ParserItem item("SEGMENT2", ParserItem::itype::INT); + item.setDefault( 0 ); record.addItem(item); } { - ParserItem item("STRENGTH", ParserItem::itype::DOUBLE); - item.push_backDimension("Pressure*Time*Time/GeometricVolume*GeometricVolume"); + ParserItem item("AICD_STRENGTH", ParserItem::itype::DOUBLE); + item.setDefault( double(0) ); record.addItem(item); } { - ParserItem item("LENGTH", ParserItem::itype::DOUBLE); + ParserItem item("ICD_LENGTH", ParserItem::itype::DOUBLE); item.setDefault( double(12.000000) ); item.push_backDimension("Length"); record.addItem(item); } { - ParserItem item("DENSITY_CALI", ParserItem::itype::DOUBLE); + ParserItem item("RHO", ParserItem::itype::DOUBLE); item.setDefault( double(1000.250000) ); - item.push_backDimension("Density"); + item.push_backDimension("Mass/Length*Length*Length"); record.addItem(item); } { - ParserItem item("VISCOSITY_CALI", ParserItem::itype::DOUBLE); + ParserItem item("VISCOSITY", ParserItem::itype::DOUBLE); item.setDefault( double(1.450000) ); item.push_backDimension("Viscosity"); record.addItem(item); } { - ParserItem item("CRITICAL_VALUE", ParserItem::itype::DOUBLE); + ParserItem item("WATER_LIMIT", ParserItem::itype::DOUBLE); item.setDefault( double(0.500000) ); - item.push_backDimension("1"); record.addItem(item); } { - ParserItem item("WIDTH_TRANS", ParserItem::itype::DOUBLE); + ParserItem item("TRANSITION_WIDTH", ParserItem::itype::DOUBLE); item.setDefault( double(0.050000) ); - item.push_backDimension("1"); record.addItem(item); } { - ParserItem item("MAX_VISC_RATIO", ParserItem::itype::DOUBLE); + ParserItem item("MAX_SOMETHING", ParserItem::itype::DOUBLE); item.setDefault( double(5.000000) ); - item.push_backDimension("1"); record.addItem(item); } { - ParserItem item("METHOD_SCALING_FACTOR", ParserItem::itype::INT); + ParserItem item("SCALING_METHOD", ParserItem::itype::INT); item.setDefault( -1 ); record.addItem(item); } { - ParserItem item("MAX_ABS_RATE", ParserItem::itype::DOUBLE); - item.push_backDimension("GeometricVolume/Time"); + ParserItem item("MAX_QICD", ParserItem::itype::DOUBLE); + item.push_backDimension("ReservoirVolume/Time"); record.addItem(item); } { @@ -4260,7 +4259,7 @@ WSEGAICD::WSEGAICD( ) : ParserKeyword("WSEGAICD") record.addItem(item); } { - ParserItem item("STATUS", ParserItem::itype::STRING); + ParserItem item("ICD_FLAG", ParserItem::itype::STRING); item.setDefault( std::string("OPEN") ); record.addItem(item); } @@ -4280,7 +4279,7 @@ WSEGAICD::WSEGAICD( ) : ParserKeyword("WSEGAICD") record.addItem(item); } { - ParserItem item("OIL_VISC_FRACTION", ParserItem::itype::DOUBLE); + ParserItem item("OIL_VSIC_FRACTION", ParserItem::itype::DOUBLE); item.setDefault( double(1.000000) ); record.addItem(item); } @@ -4299,36 +4298,39 @@ WSEGAICD::WSEGAICD( ) : ParserKeyword("WSEGAICD") } const std::string WSEGAICD::keywordName = "WSEGAICD"; const std::string WSEGAICD::WELL::itemName = "WELL"; -const std::string WSEGAICD::SEG1::itemName = "SEG1"; -const std::string WSEGAICD::SEG2::itemName = "SEG2"; -const std::string WSEGAICD::STRENGTH::itemName = "STRENGTH"; -const std::string WSEGAICD::LENGTH::itemName = "LENGTH"; -const double WSEGAICD::LENGTH::defaultValue = 12.000000; -const std::string WSEGAICD::DENSITY_CALI::itemName = "DENSITY_CALI"; -const double WSEGAICD::DENSITY_CALI::defaultValue = 1000.250000; -const std::string WSEGAICD::VISCOSITY_CALI::itemName = "VISCOSITY_CALI"; -const double WSEGAICD::VISCOSITY_CALI::defaultValue = 1.450000; -const std::string WSEGAICD::CRITICAL_VALUE::itemName = "CRITICAL_VALUE"; -const double WSEGAICD::CRITICAL_VALUE::defaultValue = 0.500000; -const std::string WSEGAICD::WIDTH_TRANS::itemName = "WIDTH_TRANS"; -const double WSEGAICD::WIDTH_TRANS::defaultValue = 0.050000; -const std::string WSEGAICD::MAX_VISC_RATIO::itemName = "MAX_VISC_RATIO"; -const double WSEGAICD::MAX_VISC_RATIO::defaultValue = 5.000000; -const std::string WSEGAICD::METHOD_SCALING_FACTOR::itemName = "METHOD_SCALING_FACTOR"; -const int WSEGAICD::METHOD_SCALING_FACTOR::defaultValue = -1; -const std::string WSEGAICD::MAX_ABS_RATE::itemName = "MAX_ABS_RATE"; +const std::string WSEGAICD::SEGMENT1::itemName = "SEGMENT1"; +const int WSEGAICD::SEGMENT1::defaultValue = 0; +const std::string WSEGAICD::SEGMENT2::itemName = "SEGMENT2"; +const int WSEGAICD::SEGMENT2::defaultValue = 0; +const std::string WSEGAICD::AICD_STRENGTH::itemName = "AICD_STRENGTH"; +const double WSEGAICD::AICD_STRENGTH::defaultValue = 0.000000; +const std::string WSEGAICD::ICD_LENGTH::itemName = "ICD_LENGTH"; +const double WSEGAICD::ICD_LENGTH::defaultValue = 12.000000; +const std::string WSEGAICD::RHO::itemName = "RHO"; +const double WSEGAICD::RHO::defaultValue = 1000.250000; +const std::string WSEGAICD::VISCOSITY::itemName = "VISCOSITY"; +const double WSEGAICD::VISCOSITY::defaultValue = 1.450000; +const std::string WSEGAICD::WATER_LIMIT::itemName = "WATER_LIMIT"; +const double WSEGAICD::WATER_LIMIT::defaultValue = 0.500000; +const std::string WSEGAICD::TRANSITION_WIDTH::itemName = "TRANSITION_WIDTH"; +const double WSEGAICD::TRANSITION_WIDTH::defaultValue = 0.050000; +const std::string WSEGAICD::MAX_SOMETHING::itemName = "MAX_SOMETHING"; +const double WSEGAICD::MAX_SOMETHING::defaultValue = 5.000000; +const std::string WSEGAICD::SCALING_METHOD::itemName = "SCALING_METHOD"; +const int WSEGAICD::SCALING_METHOD::defaultValue = -1; +const std::string WSEGAICD::MAX_QICD::itemName = "MAX_QICD"; const std::string WSEGAICD::FLOW_RATE_EXPONENT::itemName = "FLOW_RATE_EXPONENT"; const std::string WSEGAICD::VISC_EXPONENT::itemName = "VISC_EXPONENT"; -const std::string WSEGAICD::STATUS::itemName = "STATUS"; -const std::string WSEGAICD::STATUS::defaultValue = "OPEN"; +const std::string WSEGAICD::ICD_FLAG::itemName = "ICD_FLAG"; +const std::string WSEGAICD::ICD_FLAG::defaultValue = "OPEN"; const std::string WSEGAICD::OIL_FLOW_FRACTION::itemName = "OIL_FLOW_FRACTION"; const double WSEGAICD::OIL_FLOW_FRACTION::defaultValue = 1.000000; const std::string WSEGAICD::WATER_FLOW_FRACTION::itemName = "WATER_FLOW_FRACTION"; const double WSEGAICD::WATER_FLOW_FRACTION::defaultValue = 1.000000; const std::string WSEGAICD::GAS_FLOW_FRACTION::itemName = "GAS_FLOW_FRACTION"; const double WSEGAICD::GAS_FLOW_FRACTION::defaultValue = 1.000000; -const std::string WSEGAICD::OIL_VISC_FRACTION::itemName = "OIL_VISC_FRACTION"; -const double WSEGAICD::OIL_VISC_FRACTION::defaultValue = 1.000000; +const std::string WSEGAICD::OIL_VSIC_FRACTION::itemName = "OIL_VSIC_FRACTION"; +const double WSEGAICD::OIL_VSIC_FRACTION::defaultValue = 1.000000; const std::string WSEGAICD::WATER_VISC_FRACTION::itemName = "WATER_VISC_FRACTION"; const double WSEGAICD::WATER_VISC_FRACTION::defaultValue = 1.000000; const std::string WSEGAICD::GAS_VISC_FRACTION::itemName = "GAS_VISC_FRACTION"; diff --git a/ThirdParty/custom-opm-common/generated-opm-common/include/opm/parser/eclipse/Parser/ParserKeywords/G.hpp b/ThirdParty/custom-opm-common/generated-opm-common/include/opm/parser/eclipse/Parser/ParserKeywords/G.hpp index db9ceae010..6cf3f61a5c 100644 --- a/ThirdParty/custom-opm-common/generated-opm-common/include/opm/parser/eclipse/Parser/ParserKeywords/G.hpp +++ b/ThirdParty/custom-opm-common/generated-opm-common/include/opm/parser/eclipse/Parser/ParserKeywords/G.hpp @@ -1647,7 +1647,6 @@ namespace ParserKeywords { class FIP_FAMILY { public: static const std::string itemName; - static const std::string defaultValue; }; class PRESSURE_TARGET { diff --git a/ThirdParty/custom-opm-common/generated-opm-common/include/opm/parser/eclipse/Parser/ParserKeywords/N.hpp b/ThirdParty/custom-opm-common/generated-opm-common/include/opm/parser/eclipse/Parser/ParserKeywords/N.hpp index b7fcec2d73..2de8397b91 100644 --- a/ThirdParty/custom-opm-common/generated-opm-common/include/opm/parser/eclipse/Parser/ParserKeywords/N.hpp +++ b/ThirdParty/custom-opm-common/generated-opm-common/include/opm/parser/eclipse/Parser/ParserKeywords/N.hpp @@ -484,12 +484,6 @@ namespace ParserKeywords { static const std::string defaultValue; }; - class ADD_GAS_LIFT_GAS { - public: - static const std::string itemName; - static const std::string defaultValue; - }; - class CHOKE_GROUP { public: static const std::string itemName; diff --git a/ThirdParty/custom-opm-common/generated-opm-common/include/opm/parser/eclipse/Parser/ParserKeywords/O.hpp b/ThirdParty/custom-opm-common/generated-opm-common/include/opm/parser/eclipse/Parser/ParserKeywords/O.hpp index f8fdde593d..2bba6d1c03 100644 --- a/ThirdParty/custom-opm-common/generated-opm-common/include/opm/parser/eclipse/Parser/ParserKeywords/O.hpp +++ b/ThirdParty/custom-opm-common/generated-opm-common/include/opm/parser/eclipse/Parser/ParserKeywords/O.hpp @@ -223,7 +223,7 @@ namespace ParserKeywords { OPERATER(); static const std::string keywordName; - class TARGET_ARRAY { + class RESULT_ARRAY { public: static const std::string itemName; }; diff --git a/ThirdParty/custom-opm-common/generated-opm-common/include/opm/parser/eclipse/Parser/ParserKeywords/P.hpp b/ThirdParty/custom-opm-common/generated-opm-common/include/opm/parser/eclipse/Parser/ParserKeywords/P.hpp index c320bc6f2d..3019b47300 100644 --- a/ThirdParty/custom-opm-common/generated-opm-common/include/opm/parser/eclipse/Parser/ParserKeywords/P.hpp +++ b/ThirdParty/custom-opm-common/generated-opm-common/include/opm/parser/eclipse/Parser/ParserKeywords/P.hpp @@ -417,7 +417,12 @@ namespace ParserKeywords { PERMFACT(); static const std::string keywordName; - class DATA { + class POROSITY { + public: + static const std::string itemName; + }; + + class PERMFACTMULT { public: static const std::string itemName; }; diff --git a/ThirdParty/custom-opm-common/generated-opm-common/include/opm/parser/eclipse/Parser/ParserKeywords/R.hpp b/ThirdParty/custom-opm-common/generated-opm-common/include/opm/parser/eclipse/Parser/ParserKeywords/R.hpp index 8ff88ec187..3b150cdd63 100644 --- a/ThirdParty/custom-opm-common/generated-opm-common/include/opm/parser/eclipse/Parser/ParserKeywords/R.hpp +++ b/ThirdParty/custom-opm-common/generated-opm-common/include/opm/parser/eclipse/Parser/ParserKeywords/R.hpp @@ -1504,6 +1504,16 @@ namespace ParserKeywords { RWGSALT(); static const std::string keywordName; + class RESERVOIR_PRESSURE { + public: + static const std::string itemName; + }; + + class SALT_CONCENTRATION { + public: + static const std::string itemName; + }; + class DATA { public: static const std::string itemName; diff --git a/ThirdParty/custom-opm-common/generated-opm-common/include/opm/parser/eclipse/Parser/ParserKeywords/W.hpp b/ThirdParty/custom-opm-common/generated-opm-common/include/opm/parser/eclipse/Parser/ParserKeywords/W.hpp index 3c30c3ecc8..384dcf3907 100644 --- a/ThirdParty/custom-opm-common/generated-opm-common/include/opm/parser/eclipse/Parser/ParserKeywords/W.hpp +++ b/ThirdParty/custom-opm-common/generated-opm-common/include/opm/parser/eclipse/Parser/ParserKeywords/W.hpp @@ -3110,64 +3110,67 @@ namespace ParserKeywords { static const std::string itemName; }; - class SEG1 { - public: - static const std::string itemName; - }; - - class SEG2 { - public: - static const std::string itemName; - }; - - class STRENGTH { - public: - static const std::string itemName; - }; - - class LENGTH { - public: - static const std::string itemName; - static const double defaultValue; - }; - - class DENSITY_CALI { - public: - static const std::string itemName; - static const double defaultValue; - }; - - class VISCOSITY_CALI { - public: - static const std::string itemName; - static const double defaultValue; - }; - - class CRITICAL_VALUE { - public: - static const std::string itemName; - static const double defaultValue; - }; - - class WIDTH_TRANS { - public: - static const std::string itemName; - static const double defaultValue; - }; - - class MAX_VISC_RATIO { - public: - static const std::string itemName; - static const double defaultValue; - }; - - class METHOD_SCALING_FACTOR { + class SEGMENT1 { public: static const std::string itemName; static const int defaultValue; }; - class MAX_ABS_RATE { + class SEGMENT2 { + public: + static const std::string itemName; + static const int defaultValue; + }; + + class AICD_STRENGTH { + public: + static const std::string itemName; + static const double defaultValue; + }; + + class ICD_LENGTH { + public: + static const std::string itemName; + static const double defaultValue; + }; + + class RHO { + public: + static const std::string itemName; + static const double defaultValue; + }; + + class VISCOSITY { + public: + static const std::string itemName; + static const double defaultValue; + }; + + class WATER_LIMIT { + public: + static const std::string itemName; + static const double defaultValue; + }; + + class TRANSITION_WIDTH { + public: + static const std::string itemName; + static const double defaultValue; + }; + + class MAX_SOMETHING { + public: + static const std::string itemName; + static const double defaultValue; + }; + + class SCALING_METHOD { + public: + static const std::string itemName; + static const int defaultValue; + }; + + class MAX_QICD { public: static const std::string itemName; }; @@ -3182,7 +3185,7 @@ namespace ParserKeywords { static const std::string itemName; }; - class STATUS { + class ICD_FLAG { public: static const std::string itemName; static const std::string defaultValue; @@ -3206,7 +3209,7 @@ namespace ParserKeywords { static const double defaultValue; }; - class OIL_VISC_FRACTION { + class OIL_VSIC_FRACTION { public: static const std::string itemName; static const double defaultValue; diff --git a/ThirdParty/custom-opm-common/opm-common/CMakeLists.txt b/ThirdParty/custom-opm-common/opm-common/CMakeLists.txt index 3098e978ea..3807817e66 100644 --- a/ThirdParty/custom-opm-common/opm-common/CMakeLists.txt +++ b/ThirdParty/custom-opm-common/opm-common/CMakeLists.txt @@ -153,12 +153,6 @@ if (OPM_ENABLE_PYTHON) endif() endif() -# Add dependency of Shlwapi.lib for Windows platforms -if (CMAKE_CXX_COMPILER_ID STREQUAL "MSVC") - target_link_libraries(opmcommon Shlwapi) -endif() - - # all setup common to the OPM library modules is done here include (OpmLibMain) @@ -199,11 +193,15 @@ if(ENABLE_ECL_INPUT) # test_util/summary.cpp # ) - #foreach(target compareECL convertECL summary) + #add_executable(test_esmry_lod + # test_util/test_esmry_lod.cpp + # ) + + #foreach(target compareECL convertECL summary test_esmry_lod) # target_link_libraries(${target} opmcommon) # install(TARGETS ${target} DESTINATION bin) #endforeach() - + # Add the tests set(_libs opmcommon ${Boost_UNIT_TEST_FRAMEWORK_LIBRARY}) @@ -261,11 +259,10 @@ if (OPM_ENABLE_PYTHON) list(APPEND _opmcommon_include_dirs ${_ecl_include_dirs}) string(REPLACE ";" ":" _setup_include_dirs "${_opmcommon_include_dirs}") - get_target_property(_opmcommon_lib_dirs opmcommon LINK_DIRECTORIES) if (CMAKE_PREFIX_PATH) - list(APPEND _opmcommon_lib_dirs ${PROJECT_BINARY_DIR}/lib ${CMAKE_PREFIX_PATH}/${CMAKE_INSTALL_LIBDIR}) + set(_opmcommon_lib_dirs ${PROJECT_BINARY_DIR}/lib ${CMAKE_PREFIX_PATH}/${CMAKE_INSTALL_LIBDIR}) else() - list(APPEND _opmcommon_lib_dirs ${PROJECT_BINARY_DIR}/lib) + set(_opmcommon_lib_dirs ${PROJECT_BINARY_DIR}/lib) endif() string(REPLACE ";" ":" _setup_lib_dirs "${_opmcommon_lib_dirs}") @@ -291,11 +288,6 @@ if (OPM_ENABLE_PYTHON) set( _rpath_arg "") endif() - set(opm-common_PYTHON_PACKAGE_VERSION ${OPM_PYTHON_PACKAGE_VERSION_TAG}) - - # Generate versioned setup.py - configure_file (${PROJECT_SOURCE_DIR}/python/setup.py.in ${PROJECT_BINARY_DIR}/python/setup.py) - file(COPY ${PROJECT_SOURCE_DIR}/python/README.md DESTINATION ${PROJECT_BINARY_DIR}/python) execute_process(COMMAND ${PYTHON_EXECUTABLE} target_name.py WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}/python OUTPUT_VARIABLE python_lib_target) @@ -303,19 +295,19 @@ if (OPM_ENABLE_PYTHON) add_custom_target(copy_python ALL COMMAND ${PYTHON_EXECUTABLE} ${PROJECT_SOURCE_DIR}/python/install.py ${PROJECT_SOURCE_DIR}/python ${PROJECT_BINARY_DIR} 0) - add_custom_command(OUTPUT python/opm/${python_lib_target} + add_custom_command(OUTPUT python/python/opm/${python_lib_target} DEPENDS ${PYTHON_CXX_DEPENDS} DEPENDS copy_python COMMAND ${PYTHON_EXECUTABLE} ${PROJECT_BINARY_DIR}/python/setup.py build build_ext - --build-lib=${PROJECT_BINARY_DIR}/python + --build-lib=${PROJECT_BINARY_DIR}/python/python/opm --library-dirs=${_setup_lib_dirs} ${_rpath_arg} --include-dirs=${_setup_include_dirs} WORKING_DIRECTORY ${PROJECT_BINARY_DIR}/python - COMMENT "Building python bindings at python/opm/${python_lib_target}") - add_custom_target(opmcommon_python ALL DEPENDS python/opm/${python_lib_target}) + COMMENT "Building python bindings") + add_custom_target(opmcommon_python ALL DEPENDS python/python/opm/${python_lib_target}) add_dependencies(opmcommon_python opmcommon) # The install target is based on manually copying the python file tree to the @@ -330,7 +322,7 @@ if (OPM_ENABLE_PYTHON) # setup.py install manually - optionally with the generated script # setup-install.sh - and completely bypass cmake in the installation phase. if (OPM_INSTALL_PYTHON) - install( CODE "execute_process(COMMAND ${PYTHON_EXECUTABLE} ${PROJECT_BINARY_DIR}/python/install.py ${PROJECT_BINARY_DIR}/python/opm ${DEST_PREFIX}${CMAKE_INSTALL_PREFIX}/${PYTHON_INSTALL_PREFIX} 1)") + install( CODE "execute_process(COMMAND ${PYTHON_EXECUTABLE} ${PROJECT_BINARY_DIR}/python/install.py ${PROJECT_BINARY_DIR}/python/python/opm ${DEST_PREFIX}${CMAKE_INSTALL_PREFIX}/${PYTHON_INSTALL_PREFIX} 1)") endif() # Observe that if the opmcommon library has been built as a shared library the @@ -338,11 +330,11 @@ if (OPM_ENABLE_PYTHON) # testing. add_test(NAME python_tests WORKING_DIRECTORY ${PROJECT_BINARY_DIR}/python - COMMAND ${CMAKE_COMMAND} -E env LD_LIBRARY_PATH=${PROJECT_BINARY_DIR}/lib ${PYTHON_EXECUTABLE} setup.py build_ext --dry-run --build-lib ${PROJECT_BINARY_DIR}/python test + COMMAND ${CMAKE_COMMAND} -E env LD_LIBRARY_PATH=${PROJECT_BINARY_DIR}/lib ${PYTHON_EXECUTABLE} setup.py build_ext --dry-run --build-lib ${PROJECT_BINARY_DIR}/python/python/opm test ) set_target_properties(opmcommon PROPERTIES POSITION_INDEPENDENT_CODE ON) - set_directory_properties(PROPERTIES ADDITIONAL_MAKE_CLEAN_FILES ${PROJECT_BINARY_DIR}/python) + set_directory_properties(PROPERTIES ADDITIONAL_MAKE_CLEAN_FILES ${PROJECT_BINARY_DIR}/python/python) # ------------------------------------------------------------------------- # Let cmake configure some small shell scripts which can be used to simplify @@ -352,11 +344,6 @@ if (OPM_ENABLE_PYTHON) DESTINATION ${PROJECT_BINARY_DIR} FILE_PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE ) - configure_file(python/setup-package.sh.in tmp/setup-package.sh) - file( COPY ${PROJECT_BINARY_DIR}/tmp/setup-package.sh - DESTINATION ${PROJECT_BINARY_DIR} - FILE_PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE ) - configure_file(python/setup-test.sh.in tmp/setup-test.sh) file( COPY ${PROJECT_BINARY_DIR}/tmp/setup-test.sh DESTINATION ${PROJECT_BINARY_DIR} diff --git a/ThirdParty/custom-opm-common/opm-common/CMakeLists_files.cmake b/ThirdParty/custom-opm-common/opm-common/CMakeLists_files.cmake index eadb36cc74..5a2cdda979 100644 --- a/ThirdParty/custom-opm-common/opm-common/CMakeLists_files.cmake +++ b/ThirdParty/custom-opm-common/opm-common/CMakeLists_files.cmake @@ -100,11 +100,8 @@ if(ENABLE_ECL_INPUT) src/opm/parser/eclipse/EclipseState/Schedule/Action/ActionValue.cpp src/opm/parser/eclipse/EclipseState/Schedule/Action/ASTNode.cpp src/opm/parser/eclipse/EclipseState/Schedule/Action/Condition.cpp - src/opm/parser/eclipse/EclipseState/Schedule/Action/State.cpp src/opm/parser/eclipse/EclipseState/Schedule/ArrayDimChecker.cpp src/opm/parser/eclipse/EclipseState/Schedule/Events.cpp - src/opm/parser/eclipse/EclipseState/Schedule/GasLiftOpt.cpp - src/opm/parser/eclipse/EclipseState/Schedule/Group/GPMaint.cpp src/opm/parser/eclipse/EclipseState/Schedule/Group/Group.cpp src/opm/parser/eclipse/EclipseState/Schedule/Group/GuideRate.cpp src/opm/parser/eclipse/EclipseState/Schedule/Group/GuideRateConfig.cpp @@ -118,12 +115,9 @@ if(ENABLE_ECL_INPUT) src/opm/parser/eclipse/EclipseState/Schedule/MSW/Compsegs.cpp src/opm/parser/eclipse/EclipseState/Schedule/MSW/Segment.cpp src/opm/parser/eclipse/EclipseState/Schedule/MSW/WellSegments.cpp - src/opm/parser/eclipse/EclipseState/Schedule/MSW/AICD.cpp - src/opm/parser/eclipse/EclipseState/Schedule/MSW/SICD.cpp + src/opm/parser/eclipse/EclipseState/Schedule/MSW/updatingConnectionsWithSegments.cpp + src/opm/parser/eclipse/EclipseState/Schedule/MSW/SpiralICD.cpp src/opm/parser/eclipse/EclipseState/Schedule/MSW/Valve.cpp - src/opm/parser/eclipse/EclipseState/Schedule/Network/Branch.cpp - src/opm/parser/eclipse/EclipseState/Schedule/Network/ExtNetwork.cpp - src/opm/parser/eclipse/EclipseState/Schedule/Network/Node.cpp src/opm/parser/eclipse/EclipseState/Schedule/OilVaporizationProperties.cpp src/opm/parser/eclipse/EclipseState/Schedule/RFTConfig.cpp src/opm/parser/eclipse/EclipseState/Schedule/RPTConfig.cpp @@ -161,7 +155,6 @@ if(ENABLE_ECL_INPUT) src/opm/parser/eclipse/EclipseState/Tables/TableColumn.cpp src/opm/parser/eclipse/EclipseState/Tables/TableContainer.cpp src/opm/parser/eclipse/EclipseState/Tables/TableIndex.cpp - src/opm/parser/eclipse/EclipseState/Tables/TLMixpar.cpp src/opm/parser/eclipse/EclipseState/Tables/TableManager.cpp src/opm/parser/eclipse/EclipseState/Tables/TableSchema.cpp src/opm/parser/eclipse/EclipseState/Tables/Tables.cpp @@ -169,7 +162,6 @@ if(ENABLE_ECL_INPUT) src/opm/parser/eclipse/EclipseState/Tables/Rock2dtrTable.cpp src/opm/parser/eclipse/EclipseState/Tables/PvtwsaltTable.cpp src/opm/parser/eclipse/EclipseState/Tables/BrineDensityTable.cpp - src/opm/parser/eclipse/EclipseState/Tables/RwgsaltTable.cpp src/opm/parser/eclipse/EclipseState/Tables/SolventDensityTable.cpp src/opm/parser/eclipse/EclipseState/Schedule/UDQ/UDQASTNode.cpp src/opm/parser/eclipse/EclipseState/Schedule/UDQ/UDQParams.cpp @@ -199,6 +191,7 @@ if(ENABLE_ECL_INPUT) src/opm/parser/eclipse/Units/Dimension.cpp src/opm/parser/eclipse/Units/UnitSystem.cpp src/opm/parser/eclipse/Utility/Functional.cpp + src/opm/parser/eclipse/Utility/Stringview.cpp ) @@ -343,7 +336,6 @@ if(ENABLE_ECL_INPUT) tests/parser/MultiRegTests.cpp tests/parser/MultisegmentWellTests.cpp tests/parser/MULTREGTScannerTests.cpp - tests/parser/NetworkTests.cpp tests/parser/OrderedMapTests.cpp tests/parser/ParseContextTests.cpp tests/parser/ParseContext_EXIT1.cpp @@ -393,7 +385,6 @@ if(ENABLE_ECL_OUTPUT) tests/test_AggregateConnectionData.cpp tests/test_AggregateUDQData.cpp tests/test_ArrayDimChecker.cpp - tests/test_data_GuideRateValue.cpp tests/test_EclipseIO.cpp tests/test_DoubHEAD.cpp tests/test_InteHEAD.cpp @@ -437,8 +428,6 @@ if(ENABLE_ECL_OUTPUT) tests/SPE1CASE1A.SMSPEC tests/SPE9_CP_PACKED.DATA tests/SOFR_TEST.DATA - tests/UDQ_BASE.DATA - tests/UDQ_RESTART.DATA tests/UDQ_TEST_WCONPROD_IUAD-2.DATA tests/UDQ_ACTIONX_TEST1.DATA tests/UDQ_ACTIONX_TEST1_U.DATA @@ -487,8 +476,6 @@ if(ENABLE_ECL_INPUT) #examples/opmi.cpp #examples/opmpack.cpp #examples/opmhash.cpp - #examples/wellgraph.cpp - #examples/make_lodsmry.cpp ) endif() @@ -501,7 +488,6 @@ if(ENABLE_ECL_INPUT) examples/opmi.cpp examples/opmpack.cpp examples/opmhash.cpp - examples/make_lodsmry.cpp ) endif() @@ -548,6 +534,7 @@ if(ENABLE_ECL_INPUT) list(APPEND PUBLIC_HEADER_FILES opm/io/eclipse/SummaryNode.hpp opm/json/JsonObject.hpp + opm/parser/eclipse/Utility/Stringview.hpp opm/parser/eclipse/Utility/Functional.hpp opm/parser/eclipse/Utility/Typetools.hpp opm/parser/eclipse/Generator/KeywordGenerator.hpp @@ -603,11 +590,8 @@ if(ENABLE_ECL_INPUT) opm/parser/eclipse/EclipseState/Tables/SpecrockTable.hpp opm/parser/eclipse/EclipseState/Tables/PvtwsaltTable.hpp opm/parser/eclipse/EclipseState/Tables/BrineDensityTable.hpp - opm/parser/eclipse/EclipseState/Tables/PermfactTable.hpp - opm/parser/eclipse/EclipseState/Tables/RwgsaltTable.hpp - opm/parser/eclipse/EclipseState/Tables/SaltvdTable.hpp - opm/parser/eclipse/EclipseState/Tables/SaltpvdTable.hpp opm/parser/eclipse/EclipseState/Tables/SolventDensityTable.hpp + opm/parser/eclipse/EclipseState/Tables/SaltvdTable.hpp opm/parser/eclipse/EclipseState/Tables/PlydhflfTable.hpp opm/parser/eclipse/EclipseState/Tables/PlymwinjTable.hpp opm/parser/eclipse/EclipseState/Tables/PlyshlogTable.hpp @@ -617,7 +601,6 @@ if(ENABLE_ECL_INPUT) opm/parser/eclipse/EclipseState/Tables/SpecheatTable.hpp opm/parser/eclipse/EclipseState/Tables/SgcwmisTable.hpp opm/parser/eclipse/EclipseState/Tables/Sof2Table.hpp - opm/parser/eclipse/EclipseState/Tables/TLMixpar.hpp opm/parser/eclipse/EclipseState/Tables/TableManager.hpp opm/parser/eclipse/EclipseState/Tables/SwfnTable.hpp opm/parser/eclipse/EclipseState/Tables/EnptvdTable.hpp @@ -627,8 +610,6 @@ if(ENABLE_ECL_INPUT) opm/parser/eclipse/EclipseState/Tables/JFunc.hpp opm/parser/eclipse/EclipseState/Tables/TableIndex.hpp opm/parser/eclipse/EclipseState/Tables/PvtgTable.hpp - opm/parser/eclipse/EclipseState/Tables/PvtgwTable.hpp - opm/parser/eclipse/EclipseState/Tables/PvtgwoTable.hpp opm/parser/eclipse/EclipseState/Tables/Tabdims.hpp opm/parser/eclipse/EclipseState/Tables/TableSchema.hpp opm/parser/eclipse/EclipseState/Tables/RocktabTable.hpp @@ -685,12 +666,7 @@ if(ENABLE_ECL_INPUT) opm/parser/eclipse/EclipseState/Schedule/Action/Condition.hpp opm/parser/eclipse/EclipseState/Schedule/Action/ASTNode.hpp opm/parser/eclipse/EclipseState/Schedule/Action/PyAction.hpp - opm/parser/eclipse/EclipseState/Schedule/Action/State.hpp opm/parser/eclipse/EclipseState/Schedule/ArrayDimChecker.hpp - opm/parser/eclipse/EclipseState/Schedule/GasLiftOpt.hpp - opm/parser/eclipse/EclipseState/Schedule/Network/Branch.hpp - opm/parser/eclipse/EclipseState/Schedule/Network/ExtNetwork.hpp - opm/parser/eclipse/EclipseState/Schedule/Network/Node.hpp opm/parser/eclipse/EclipseState/Schedule/TimeMap.hpp opm/parser/eclipse/EclipseState/Schedule/VFPInjTable.hpp opm/parser/eclipse/EclipseState/Schedule/VFPProdTable.hpp @@ -717,7 +693,6 @@ if(ENABLE_ECL_INPUT) opm/parser/eclipse/EclipseState/Schedule/Schedule.hpp opm/parser/eclipse/EclipseState/Schedule/ScheduleTypes.hpp opm/parser/eclipse/EclipseState/Schedule/Tuning.hpp - opm/parser/eclipse/EclipseState/Schedule/Group/GPMaint.hpp opm/parser/eclipse/EclipseState/Schedule/Group/GTNode.hpp opm/parser/eclipse/EclipseState/Schedule/Group/Group.hpp opm/parser/eclipse/EclipseState/Schedule/Group/GuideRate.hpp @@ -733,8 +708,8 @@ if(ENABLE_ECL_INPUT) opm/parser/eclipse/EclipseState/Schedule/MSW/Segment.hpp opm/parser/eclipse/EclipseState/Schedule/MSW/Segment.hpp opm/parser/eclipse/EclipseState/Schedule/MSW/WellSegments.hpp - opm/parser/eclipse/EclipseState/Schedule/MSW/AICD.hpp - opm/parser/eclipse/EclipseState/Schedule/MSW/SICD.hpp + opm/parser/eclipse/EclipseState/Schedule/MSW/updatingConnectionsWithSegments.hpp + opm/parser/eclipse/EclipseState/Schedule/MSW/SpiralICD.hpp opm/parser/eclipse/EclipseState/SimulationConfig/ThresholdPressure.hpp opm/parser/eclipse/EclipseState/SimulationConfig/BCConfig.hpp opm/parser/eclipse/EclipseState/SimulationConfig/RockConfig.hpp @@ -789,10 +764,9 @@ if(ENABLE_ECL_OUTPUT) opm/io/eclipse/rst/well.hpp opm/output/data/Aquifer.hpp opm/output/data/Cells.hpp - opm/output/data/GuideRateValue.hpp - opm/output/data/Groups.hpp opm/output/data/Solution.hpp opm/output/data/Wells.hpp + opm/output/data/Groups.hpp opm/output/eclipse/VectorItems/aquifer.hpp opm/output/eclipse/VectorItems/connection.hpp opm/output/eclipse/VectorItems/group.hpp diff --git a/ThirdParty/custom-opm-common/opm-common/GenerateKeywords.cmake b/ThirdParty/custom-opm-common/opm-common/GenerateKeywords.cmake index ce0cf75496..ef291e43f8 100644 --- a/ThirdParty/custom-opm-common/opm-common/GenerateKeywords.cmake +++ b/ThirdParty/custom-opm-common/opm-common/GenerateKeywords.cmake @@ -20,6 +20,7 @@ set(genkw_SOURCES src/opm/json/JsonObject.cpp src/opm/parser/eclipse/Parser/raw/StarToken.cpp src/opm/parser/eclipse/Units/Dimension.cpp src/opm/parser/eclipse/Units/UnitSystem.cpp + src/opm/parser/eclipse/Utility/Stringview.cpp src/opm/common/OpmLog/OpmLog.cpp src/opm/common/OpmLog/Logger.cpp src/opm/common/OpmLog/StreamLog.cpp diff --git a/ThirdParty/custom-opm-common/opm-common/cmake/Modules/Finddune-geometry.cmake b/ThirdParty/custom-opm-common/opm-common/cmake/Modules/Finddune-geometry.cmake index 502ce20ff6..ff6bd1fb66 100644 --- a/ThirdParty/custom-opm-common/opm-common/cmake/Modules/Finddune-geometry.cmake +++ b/ThirdParty/custom-opm-common/opm-common/cmake/Modules/Finddune-geometry.cmake @@ -33,7 +33,8 @@ find_opm_package ( # test program "#include int main (void) { - Dune::GeometryType gt = Dune::GeometryTypes::quadrilateral; + Dune::GeometryType gt; + gt.makeQuadrilateral(); Dune::QuadratureRules::rule(gt, 2).size(); return 0; } diff --git a/ThirdParty/custom-opm-common/opm-common/cmake/Modules/OpmFind.cmake b/ThirdParty/custom-opm-common/opm-common/cmake/Modules/OpmFind.cmake index 3c8c55d90b..1cab56d56c 100644 --- a/ThirdParty/custom-opm-common/opm-common/cmake/Modules/OpmFind.cmake +++ b/ThirdParty/custom-opm-common/opm-common/cmake/Modules/OpmFind.cmake @@ -106,13 +106,8 @@ macro (find_and_append_package_to prefix name) # if we're told not to look for the package, pretend it was never found if (CMAKE_DISABLE_FIND_PACKAGE_${name}) - # If required send an error - cmake_parse_arguments(FIND "REQUIRED" "" "" ${ARGN} ) - set (${name}_FOUND FALSE) - set (${NAME}_FOUND FALSE) - if (FIND_REQUIRED) - message(SEND_ERROR "package ${name} but disable with CMAKE_DISABLE_FIND_PACKAGE_${name}") - endif () + set (${name}_FOUND FALSE) + set (${NAME}_FOUND FALSE) else () # List of components might differ for every module. Therefore we will # need to research for a library multiple times. _search_components diff --git a/ThirdParty/custom-opm-common/opm-common/cmake/Modules/OpmLibMain.cmake b/ThirdParty/custom-opm-common/opm-common/cmake/Modules/OpmLibMain.cmake index 84bb55e007..cd22b7332a 100644 --- a/ThirdParty/custom-opm-common/opm-common/cmake/Modules/OpmLibMain.cmake +++ b/ThirdParty/custom-opm-common/opm-common/cmake/Modules/OpmLibMain.cmake @@ -62,10 +62,7 @@ include (UseOptimization) # turn on all warnings; this must be done before adding any # dependencies, in case they alter the list of warnings -option(OPM_DISABLE_WARNINGS "Disable warning flags" OFF) -if(NOT OPM_DISABLE_WARNINGS) - include (UseWarnings) -endif() +include (UseWarnings) # parallel programming include (UseOpenMP) diff --git a/ThirdParty/custom-opm-common/opm-common/cmake/Modules/OpmPackage.cmake b/ThirdParty/custom-opm-common/opm-common/cmake/Modules/OpmPackage.cmake index 9eb489dfee..b096d403dc 100644 --- a/ThirdParty/custom-opm-common/opm-common/cmake/Modules/OpmPackage.cmake +++ b/ThirdParty/custom-opm-common/opm-common/cmake/Modules/OpmPackage.cmake @@ -115,34 +115,26 @@ macro (find_opm_package module deps header lib defs prog conf) # without config.h config_cmd_line (${module}_CMD_CONFIG ${module}_CONFIG_VARS) - if(prog) - # check that we can compile a small test-program - include (CMakePushCheckState) - cmake_push_check_state () - include (CheckCXXSourceCompiles) - # only add these if they are actually found; otherwise it won't - # compile and the variable won't be set - append_found (${module}_INCLUDE_DIRS CMAKE_REQUIRED_INCLUDES) - append_found (${module}_LIBRARIES CMAKE_REQUIRED_LIBRARIES) - # since we don't have any config.h yet - list (APPEND CMAKE_REQUIRED_DEFINITIONS ${${module}_DEFINITIONS}) - list (APPEND CMAKE_REQUIRED_DEFINITIONS ${${module}_CMD_CONFIG}) - check_cxx_source_compiles ("${prog}" HAVE_${MODULE}) - cmake_pop_check_state () - else(prog) - if(${module}_FOUND) - # No test code provided, mark compilation as successful - # if module was founf - set(HAVE_${MODULE} 1) - endif(${module}_FOUND) - endif(prog) + # check that we can compile a small test-program + include (CMakePushCheckState) + cmake_push_check_state () + include (CheckCXXSourceCompiles) + # only add these if they are actually found; otherwise it won't + # compile and the variable won't be set + append_found (${module}_INCLUDE_DIRS CMAKE_REQUIRED_INCLUDES) + append_found (${module}_LIBRARIES CMAKE_REQUIRED_LIBRARIES) + # since we don't have any config.h yet + list (APPEND CMAKE_REQUIRED_DEFINITIONS ${${module}_DEFINITIONS}) + list (APPEND CMAKE_REQUIRED_DEFINITIONS ${${module}_CMD_CONFIG}) + check_cxx_source_compiles ("${prog}" HAVE_${MODULE}) + cmake_pop_check_state () # write status message in the same manner as everyone else include (FindPackageHandleStandardArgs) find_package_handle_standard_args ( ${module} DEFAULT_MSG - ${module}_INCLUDE_DIRS ${module}_LIBRARIES ${module}_FOUND ${module}_ALL_PREREQS HAVE_${MODULE} + ${module}_INCLUDE_DIRS ${module}_LIBRARIES ${module}_FOUND ${module}_ALL_PREREQS ) # some genius that coded the FindPackageHandleStandardArgs figured out diff --git a/ThirdParty/custom-opm-common/opm-common/cmake/Modules/UseVersion.cmake b/ThirdParty/custom-opm-common/opm-common/cmake/Modules/UseVersion.cmake index 07f3729691..0d8e0e840a 100644 --- a/ThirdParty/custom-opm-common/opm-common/cmake/Modules/UseVersion.cmake +++ b/ThirdParty/custom-opm-common/opm-common/cmake/Modules/UseVersion.cmake @@ -24,16 +24,9 @@ if (cmake_build_type_upper_ MATCHES DEBUG) "#define PROJECT_VERSION_NAME \"${${project}_LABEL}\"\n" "#define PROJECT_VERSION_HASH \"debug\"\n" "#define PROJECT_VERSION \"${${project}_LABEL} (debug)\"\n" + "#define BUILD_TIMESTAMP \"${build_timestamp}\"\n" "#endif // OPM_GENERATED_OPM_VERSION_HEADER_INCLUDED\n" ) - - # Write header file with build timestamp - file (WRITE "${PROJECT_BINARY_DIR}/project-timestamp.h" - "#ifndef OPM_GENERATED_OPM_TIMESTAMP_HEADER_INCLUDED\n" - "#define OPM_GENERATED_OPM_TIMESTAMP_HEADER_INCLUDED\n" - "#define BUILD_TIMESTAMP \"${build_timestamp}\"\n" - "#endif // OPM_GENERATED_OPM_TIMESTAMP_HEADER_INCLUDED\n" - ) else () if (NOT GIT_FOUND) find_package (Git) @@ -50,15 +43,9 @@ else () "#define PROJECT_VERSION_NAME \"${${project}_LABEL}\"\n" "#define PROJECT_VERSION_HASH \"unknown git version\"\n" "#define PROJECT_VERSION \"${${project}_LABEL} (unknown git version)\"\n" + "#define BUILD_TIMESTAMP \"${build_timestamp}\"\n" "#endif // OPM_GENERATED_OPM_VERSION_HEADER_INCLUDED\n" ) - # Write header file with build timestamp - file (WRITE "${PROJECT_BINARY_DIR}/project-timestamp.h" - "#ifndef OPM_GENERATED_OPM_TIMESTAMP_HEADER_INCLUDED\n" - "#define OPM_GENERATED_OPM_TIMESTAMP_HEADER_INCLUDED\n" - "#define BUILD_TIMESTAMP \"${build_timestamp}\"\n" - "#endif // OPM_GENERATED_OPM_TIMESTAMP_HEADER_INCLUDED\n" - ) else () add_custom_target (update-version ALL COMMAND ${CMAKE_COMMAND} diff --git a/ThirdParty/custom-opm-common/opm-common/cmake/Scripts/WriteVerSHA.cmake b/ThirdParty/custom-opm-common/opm-common/cmake/Scripts/WriteVerSHA.cmake index 774fe9df72..b9ae4aa6af 100644 --- a/ThirdParty/custom-opm-common/opm-common/cmake/Scripts/WriteVerSHA.cmake +++ b/ThirdParty/custom-opm-common/opm-common/cmake/Scripts/WriteVerSHA.cmake @@ -56,6 +56,7 @@ file (WRITE "${PROJECT_BINARY_DIR}/project-version.tmp" "#define PROJECT_VERSION_NAME \"${PROJECT_LABEL}\"\n" "#define PROJECT_VERSION_HASH \"${sha1}\"\n" "#define PROJECT_VERSION \"${PROJECT_LABEL} (${sha1})\"\n" + "#define BUILD_TIMESTAMP \"${build_timestamp}\"\n" "#endif // OPM_GENERATED_OPM_VERSION_HEADER_INCLUDED\n" ) @@ -65,11 +66,3 @@ file (WRITE "${PROJECT_BINARY_DIR}/project-version.tmp" execute_process (COMMAND ${CMAKE_COMMAND} -E copy_if_different "${PROJECT_BINARY_DIR}/project-version.tmp" "${PROJECT_BINARY_DIR}/project-version.h" ) - -# Write header file with build timestamp -file (WRITE "${PROJECT_BINARY_DIR}/project-timestamp.h" - "#ifndef OPM_GENERATED_OPM_TIMESTAMP_HEADER_INCLUDED\n" - "#define OPM_GENERATED_OPM_TIMESTAMP_HEADER_INCLUDED\n" - "#define BUILD_TIMESTAMP \"${build_timestamp}\"\n" - "#endif // OPM_GENERATED_OPM_TIMESTAMP_HEADER_INCLUDED\n" - ) diff --git a/ThirdParty/custom-opm-common/opm-common/cross-platform/windows/PortableEndian.hpp b/ThirdParty/custom-opm-common/opm-common/cross-platform/windows/PortableEndian.hpp new file mode 100644 index 0000000000..50838835c5 --- /dev/null +++ b/ThirdParty/custom-opm-common/opm-common/cross-platform/windows/PortableEndian.hpp @@ -0,0 +1,16 @@ +#ifndef PORTABLE_ENDIAN_H__ +#define PORTABLE_ENDIAN_H__ + +#if (defined(_WIN16) || defined(_WIN32) || defined(_WIN64)) && !defined(__WINDOWS__) + +# define __WINDOWS__ + +#endif + +#if defined(__WINDOWS__) +#define __builtin_bswap16(x) _byteswap_ushort((x)) +#define __builtin_bswap32(x) _byteswap_ulong((x)) +#define __builtin_bswap64(x) _byteswap_uint64((x)) +#endif + +#endif // PORTABLE_ENDIAN_H__ \ No newline at end of file diff --git a/ThirdParty/custom-opm-common/opm-common/debian/changelog b/ThirdParty/custom-opm-common/opm-common/debian/changelog index 91d8582a27..67930415fe 100644 --- a/ThirdParty/custom-opm-common/opm-common/debian/changelog +++ b/ThirdParty/custom-opm-common/opm-common/debian/changelog @@ -1,4 +1,4 @@ -opm-common (2019.04-pre~xenial) xenial; urgency=medium +opm-common (2020.04-1~xenial) xenial; urgency=medium * New release diff --git a/ThirdParty/custom-opm-common/opm-common/examples/make_lodsmry.cpp b/ThirdParty/custom-opm-common/opm-common/examples/make_lodsmry.cpp deleted file mode 100644 index d7b57d9498..0000000000 --- a/ThirdParty/custom-opm-common/opm-common/examples/make_lodsmry.cpp +++ /dev/null @@ -1,109 +0,0 @@ -/* - Copyright 2019 Equinor ASA. - - This file is part of the Open Porous Media project (OPM). - - OPM is free software: you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - OPM is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with OPM. If not, see . -*/ - - -#include -#include -#include -#include - -#include "config.h" - -#if HAVE_OPENMP -#include -#endif - -#include -#include -#include - - -static void printHelp() { - - std::cout << "\nThis program create one or more lodsmry files, designed for effective load on the demand. \n" - << "These files are created with input from the smspec and unsmry file. \n" - << "\nIn addition, the program takes these options (which must be given before the arguments):\n\n" - << "-f if LODSMRY file exist, this will be replaced. Default behaviour is that existing file is kept.\n" - << "-n Maximum number of threads to be used if mulitple files should be created.\n" - << "-h Print help and exit.\n\n"; -} - - -int main(int argc, char **argv) { - - int c = 0; - int max_threads [[maybe_unused]] = -1; - bool force = false; - - while ((c = getopt(argc, argv, "fn:h")) != -1) { - switch (c) { - case 'f': - force = true; - break; - case 'h': - printHelp(); - return 0; - case 'n': - max_threads = atoi(optarg); - break; - default: - return EXIT_FAILURE; - } - } - - int argOffset = optind; - -#if HAVE_OPENMP - int available_threads = omp_get_max_threads(); - - if (max_threads < 0) - max_threads = available_threads-2; - else if (max_threads > (available_threads - 1)) - max_threads = available_threads-1; - - if (max_threads > (argc-argOffset)) - max_threads = argc-argOffset; - - omp_set_num_threads(max_threads); -#endif - - auto lap0 = std::chrono::system_clock::now(); - - #pragma omp parallel for - for (int f = argOffset; f < argc; f ++){ - Opm::filesystem::path inputFileName = argv[f]; - - Opm::filesystem::path lodFileName = inputFileName.parent_path() / inputFileName.stem(); - lodFileName = lodFileName += ".LODSMRY"; - - if (Opm::EclIO::fileExists(lodFileName) && (force)) - remove (lodFileName); - - Opm::EclIO::ESmry smryFile(argv[f]); - if (!smryFile.make_lodsmry_file()){ - std::cout << "\n! Warning, smspec already have one lod file, existing kept use option -f to replace this" << std::endl; - } - } - - auto lap1 = std::chrono::system_clock::now(); - std::chrono::duration elapsed_seconds1 = lap1-lap0; - std::cout << "\nruntime for creating " << (argc-argOffset) << " LODSMRY files: " << elapsed_seconds1.count() << " seconds\n" << std::endl; - - return 0; -} diff --git a/ThirdParty/custom-opm-common/opm-common/examples/wellgraph.cpp b/ThirdParty/custom-opm-common/opm-common/examples/wellgraph.cpp deleted file mode 100644 index 078901589c..0000000000 --- a/ThirdParty/custom-opm-common/opm-common/examples/wellgraph.cpp +++ /dev/null @@ -1,135 +0,0 @@ -/* - Copyright 2013, 2020 Equinor ASA. - - This file is part of the Open Porous Media project (OPM). - - OPM is free software: you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - OPM is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with OPM. If not, see . -*/ - -#include -#include -#include - -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include -#include - - -inline void createDot(const Opm::Schedule& schedule, const std::string& casename) -{ - std::cout << "Writing " << casename << ".gv .... "; std::cout.flush(); - std::ofstream os(casename + ".gv"); - os << "// This file was written by the 'wellgraph' utility from OPM.\n"; - os << "// Find the source code at github.com/OPM.\n"; - os << "// Convert output to PDF with 'dot -Tpdf " << casename << ".gv > " << casename << ".pdf'\n"; - os << "strict digraph \"" << casename << "\"\n{\n"; - const auto groupnames = schedule.groupNames(); - const std::size_t last = schedule.getTimeMap().last(); - // Group -> Group relations. - for (const auto& gn : groupnames) { - const auto& g = schedule.getGroup(gn, last); - const auto& children = g.groups(); - if (!children.empty()) { - os << " \"" << gn << "\" -> {"; - for (const auto& child : children) { - os << " \"" << child << '"'; - } - os << " }\n"; - } - } - // Group -> Well relations. - os << " node [shape=box]\n"; - for (const auto& gn : groupnames) { - const auto& g = schedule.getGroup(gn, last); - const auto& children = g.wells(); - if (!children.empty()) { - os << " \"" << gn << "\" -> {"; - for (const auto& child : children) { - os << " \"" << child << '"'; - } - os << " }\n"; - } - } - // Color wells by injector or producer. - for (const auto& w : schedule.getWellsatEnd()) { - os << " \"" << w.name() << '"'; - if (w.isProducer() && w.isInjector()) { - os << " [color=purple]\n"; - } else if (w.isProducer()) { - os << " [color=red]\n"; - } else { - os << " [color=blue]\n"; - } - } - os << "}\n"; - std::cout << "complete." << std::endl; -} - - -inline Opm::Schedule loadSchedule(const std::string& deck_file) -{ - Opm::ParseContext parseContext({{Opm::ParseContext::PARSE_RANDOM_SLASH, Opm::InputError::IGNORE}, - {Opm::ParseContext::PARSE_MISSING_DIMS_KEYWORD, Opm::InputError::WARN}, - {Opm::ParseContext::SUMMARY_UNKNOWN_WELL, Opm::InputError::WARN}, - {Opm::ParseContext::SUMMARY_UNKNOWN_GROUP, Opm::InputError::WARN}}); - Opm::ErrorGuard errors; - Opm::Parser parser; - auto python = std::make_shared(); - - std::cout << "Loading and parsing deck: " << deck_file << " ..... "; std::cout.flush(); - auto deck = parser.parseFile(deck_file, parseContext, errors); - std::cout << "complete.\n"; - - std::cout << "Creating EclipseState .... "; std::cout.flush(); - Opm::EclipseState state( deck ); - std::cout << "complete.\n"; - - std::cout << "Creating Schedule .... "; std::cout.flush(); - Opm::Schedule schedule( deck, state, python); - std::cout << "complete." << std::endl; - - return schedule; -} - - -int main(int argc, char** argv) -{ - std::ostringstream os; - std::shared_ptr string_log = std::make_shared(os, Opm::Log::DefaultMessageTypes); - Opm::OpmLog::addBackend( "STRING" , string_log); - try { - for (int iarg = 1; iarg < argc; iarg++) { - const std::string filename = argv[iarg]; - const auto sched = loadSchedule(filename); - const auto casename = Opm::filesystem::path(filename).stem(); - createDot(sched, casename); - } - } catch (const std::exception& e) { - std::cout << "\n\n***** Caught an exception: " << e.what() << std::endl; - std::cout << "\n\n***** Printing log: "<< std::endl; - std::cout << os.str(); - std::cout << "\n\n***** Exiting due to errors." << std::endl; - } -} - diff --git a/ThirdParty/custom-opm-common/opm-common/msim/include/opm/msim/msim.hpp b/ThirdParty/custom-opm-common/opm-common/msim/include/opm/msim/msim.hpp index 3f235648f2..0b5370b33b 100644 --- a/ThirdParty/custom-opm-common/opm-common/msim/include/opm/msim/msim.hpp +++ b/ThirdParty/custom-opm-common/opm-common/msim/include/opm/msim/msim.hpp @@ -14,8 +14,6 @@ #include #include -#include -#include namespace Opm { @@ -25,11 +23,6 @@ class ParseContext; class Parser; class Python; class SummaryState; - -namespace Action { -class State; -} - class msim { public: @@ -38,18 +31,16 @@ public: msim(const EclipseState& state); - Opm::UDAValue uda_val(); - void well_rate(const std::string& well, data::Rates::opt rate, std::function func); void solution(const std::string& field, std::function func); void run(Schedule& schedule, EclipseIO& io, bool report_only); - void post_step(Schedule& schedule, Action::State& action_state, SummaryState& st, data::Solution& sol, data::Wells& well_data, data::GroupValues& group_data, size_t report_step); + void post_step(Schedule& schedule, SummaryState& st, data::Solution& sol, data::Wells& well_data, size_t report_step); private: - void run_step(const Schedule& schedule, Action::State& action_state, SummaryState& st, data::Solution& sol, data::Wells& well_data, data::GroupValues& group_data, size_t report_step, EclipseIO& io) const; - void run_step(const Schedule& schedule, Action::State& action_state, SummaryState& st, data::Solution& sol, data::Wells& well_data, data::GroupValues& group_data, size_t report_step, double dt, EclipseIO& io) const; - void output(Action::State& action_state, SummaryState& st, size_t report_step, bool substep, double seconds_elapsed, const data::Solution& sol, const data::Wells& well_data, const data::GroupValues& group_data, EclipseIO& io) const; - void simulate(const Schedule& schedule, const SummaryState& st, data::Solution& sol, data::Wells& well_data, data::GroupValues& group_data, size_t report_step, double seconds_elapsed, double time_step) const; + void run_step(const Schedule& schedule, SummaryState& st, data::Solution& sol, data::Wells& well_data, size_t report_step, EclipseIO& io) const; + void run_step(const Schedule& schedule, SummaryState& st, data::Solution& sol, data::Wells& well_data, size_t report_step, double dt, EclipseIO& io) const; + void output(SummaryState& st, size_t report_step, bool substep, double seconds_elapsed, const data::Solution& sol, const data::Wells& well_data, EclipseIO& io) const; + void simulate(const Schedule& schedule, const SummaryState& st, data::Solution& sol, data::Wells& well_data, size_t report_step, double seconds_elapsed, double time_step) const; EclipseState state; std::map>> well_rates; diff --git a/ThirdParty/custom-opm-common/opm-common/msim/src/msim.cpp b/ThirdParty/custom-opm-common/opm-common/msim/src/msim.cpp index 8402679378..04ca9f1d58 100644 --- a/ThirdParty/custom-opm-common/opm-common/msim/src/msim.cpp +++ b/ThirdParty/custom-opm-common/opm-common/msim/src/msim.cpp @@ -29,7 +29,6 @@ #include #include -#include #include #include #include @@ -45,41 +44,35 @@ void msim::run(Schedule& schedule, EclipseIO& io, bool report_only) { const double week = 7 * 86400; data::Solution sol; SummaryState st(std::chrono::system_clock::from_time_t(schedule.getStartTime())); - Action::State action_state; Python python; io.writeInitial(); for (size_t report_step = 1; report_step < schedule.size(); report_step++) { data::Wells well_data; - data::GroupValues group_data; if (report_only) - run_step(schedule, action_state, st, sol, well_data, group_data, report_step, io); + run_step(schedule, st, sol, well_data, report_step, io); else { double time_step = std::min(week, 0.5*schedule.stepLength(report_step - 1)); - run_step(schedule, action_state, st, sol, well_data, group_data, report_step, time_step, io); + run_step(schedule, st, sol, well_data, report_step, time_step, io); } - post_step(schedule, action_state, st, sol, well_data, group_data, report_step); + post_step(schedule, st, sol, well_data, report_step); const auto& exit_status = schedule.exitStatus(); if (exit_status.has_value()) return; } } -UDAValue msim::uda_val() { - return UDAValue(); -} - -void msim::post_step(Schedule& schedule, Action::State& action_state, SummaryState& st, data::Solution& /* sol */, data::Wells& /* well_data */, data::GroupValues& /* group_data */, size_t report_step) { +void msim::post_step(Schedule& schedule, SummaryState& st, data::Solution& /* sol */, data::Wells& /* well_data */, size_t report_step) { const auto& actions = schedule.actions(report_step); if (actions.empty()) return; - Action::Context context( st , schedule.getWListManager(report_step)); + Action::Context context( st ); auto sim_time = schedule.simTime(report_step); - for (const auto& action : actions.pending(action_state, sim_time)) { - auto result = action->eval(context); + for (const auto& action : actions.pending(sim_time)) { + auto result = action->eval(sim_time, context); if (result) schedule.applyAction(report_step, *action, result); } @@ -90,12 +83,12 @@ void msim::post_step(Schedule& schedule, Action::State& action_state, SummarySta -void msim::run_step(const Schedule& schedule, Action::State& action_state, SummaryState& st, data::Solution& sol, data::Wells& well_data, data::GroupValues& group_data, size_t report_step, EclipseIO& io) const { - this->run_step(schedule, action_state, st, sol, well_data, group_data, report_step, schedule.stepLength(report_step - 1), io); +void msim::run_step(const Schedule& schedule, SummaryState& st, data::Solution& sol, data::Wells& well_data, size_t report_step, EclipseIO& io) const { + this->run_step(schedule, st, sol, well_data, report_step, schedule.stepLength(report_step - 1), io); } -void msim::run_step(const Schedule& schedule, Action::State& action_state, SummaryState& st, data::Solution& sol, data::Wells& well_data, data::GroupValues& group_data, size_t report_step, double dt, EclipseIO& io) const { +void msim::run_step(const Schedule& schedule, SummaryState& st, data::Solution& sol, data::Wells& well_data, size_t report_step, double dt, EclipseIO& io) const { double start_time = schedule.seconds(report_step - 1); double end_time = schedule.seconds(report_step); double seconds_elapsed = start_time; @@ -105,7 +98,9 @@ void msim::run_step(const Schedule& schedule, Action::State& action_state, Summa if ((seconds_elapsed + time_step) > end_time) time_step = end_time - seconds_elapsed; - this->simulate(schedule, st, sol, well_data, group_data, report_step, seconds_elapsed, time_step); + this->simulate(schedule, st, sol, well_data, report_step, seconds_elapsed, time_step); + + Opm::data::Group group_data; seconds_elapsed += time_step; @@ -118,24 +113,21 @@ void msim::run_step(const Schedule& schedule, Action::State& action_state, Summa group_data, {}); - this->output(action_state, - st, + this->output(st, report_step, (seconds_elapsed < end_time), seconds_elapsed, sol, well_data, - group_data, io); } } -void msim::output(Action::State& action_state, SummaryState& st, size_t report_step, bool substep, double seconds_elapsed, const data::Solution& sol, const data::Wells& well_data, const data::GroupValues& group_data, EclipseIO& io) const { - RestartValue value(sol, well_data, group_data); - io.writeTimeStep(action_state, - st, +void msim::output(SummaryState& st, size_t report_step, bool substep, double seconds_elapsed, const data::Solution& sol, const data::Wells& well_data, EclipseIO& io) const { + RestartValue value(sol, well_data); + io.writeTimeStep(st, report_step, substep, seconds_elapsed, @@ -143,7 +135,7 @@ void msim::output(Action::State& action_state, SummaryState& st, size_t report_s } -void msim::simulate(const Schedule& schedule, const SummaryState& st, data::Solution& sol, data::Wells& well_data, data::GroupValues& /* group_data */, size_t report_step, double seconds_elapsed, double time_step) const { +void msim::simulate(const Schedule& schedule, const SummaryState& st, data::Solution& sol, data::Wells& well_data, size_t report_step, double seconds_elapsed, double time_step) const { for (const auto& sol_pair : this->solutions) { auto func = sol_pair.second; func(this->state, schedule, sol, report_step, seconds_elapsed + time_step); diff --git a/ThirdParty/custom-opm-common/opm-common/opm/common/utility/numeric/RootFinders.hpp b/ThirdParty/custom-opm-common/opm-common/opm/common/utility/numeric/RootFinders.hpp index b1e0b5b17f..4a698529b6 100644 --- a/ThirdParty/custom-opm-common/opm-common/opm/common/utility/numeric/RootFinders.hpp +++ b/ThirdParty/custom-opm-common/opm-common/opm/common/utility/numeric/RootFinders.hpp @@ -43,7 +43,7 @@ namespace Opm { OPM_THROW(std::runtime_error, "Maximum number of iterations exceeded: " << maxiter << "\n" << "Current interval is [" << std::min(x0, x1) << ", " - << std::max(x0, x1) << "] abs(x0-x1) " << std::abs(x0-x1)); + << std::max(x0, x1) << "]"); return -1e100; // Never reached. } }; @@ -64,7 +64,7 @@ namespace Opm OPM_REPORT; std::cerr << "Maximum number of iterations exceeded: " << maxiter << ", current interval is [" << std::min(x0, x1) << ", " - << std::max(x0, x1) << "] abs(x0-x1) " << std::abs(x0-x1); + << std::max(x0, x1) << "]"; return 0.5*(x0 + x1); } }; @@ -124,7 +124,7 @@ namespace Opm iterations_used = 0; // In every iteraton, x1 is the last point computed, // and x0 is the last point computed that makes it a bracket. - while (fabs(x1 - x0) >= eps) { + while (fabs(x1 - x0) >= 1e-9*eps) { double xnew = regulaFalsiStep(x0, x1, f0, f1); double fnew = f(xnew); // cout << "xnew = " << xnew << " fnew = " << fnew << endl; @@ -221,7 +221,7 @@ namespace Opm iterations_used = 0; // In every iteraton, x1 is the last point computed, // and x0 is the last point computed that makes it a bracket. - while (fabs(x1 - x0) >= eps) { + while (fabs(x1 - x0) >= 1e-9*eps) { double xnew = regulaFalsiStep(x0, x1, f0, f1); double fnew = f(xnew); // cout << "xnew = " << xnew << " fnew = " << fnew << endl; @@ -327,7 +327,7 @@ namespace Opm // and x0 is the last point computed that makes it a bracket. double width = fabs(x1 - x0); double contraction = 1.0; - while (width >= eps) { + while (width >= 1e-9 * eps) { // If we are contracting sufficiently to at least halve // the interval width in two iterations we use regula // falsi. Otherwise, we take a bisection step to avoid diff --git a/ThirdParty/custom-opm-common/opm-common/opm/io/eclipse/ESmry.hpp b/ThirdParty/custom-opm-common/opm-common/opm/io/eclipse/ESmry.hpp index a1a0676607..81b6adf8fc 100644 --- a/ThirdParty/custom-opm-common/opm-common/opm/io/eclipse/ESmry.hpp +++ b/ThirdParty/custom-opm-common/opm-common/opm/io/eclipse/ESmry.hpp @@ -57,8 +57,6 @@ public: void LoadData(const std::vector& vectList) const; void LoadData() const; - bool make_lodsmry_file(); - std::chrono::system_clock::time_point startdate() const { return startdat; } const std::vector& keywordList() const; @@ -67,7 +65,7 @@ public: int timestepIdxAtReportstepStart(const int reportStep) const; - size_t numberOfTimeSteps() const { return nTstep; } + size_t numberOfTimeSteps() const { return timeStepList.size(); } const std::string& get_unit(const std::string& name) const; const std::string& get_unit(const SummaryNode& node) const; @@ -76,11 +74,9 @@ public: void write_rsm_file(std::optional = std::nullopt) const; private: - Opm::filesystem::path inputFileName, lodFileName; + Opm::filesystem::path inputFileName; int nI, nJ, nK, nSpecFiles; - bool fromSingleRun, lodEnabeled; - uint64_t lod_offset, lod_arr_size; - size_t nVect, nTstep; + size_t nVect; std::vector formattedFiles; std::vector dataFileList; @@ -133,9 +129,6 @@ private: std::vector> getListOfArrays(std::string filename, bool formatted); std::vector makeKeywPosVector(int speInd) const; - std::string read_string_from_disk(std::fstream& fileH, uint64_t size) const; - void inspect_lodsmry(); - void Load_from_lodsmry(const std::vector& keywIndVect) const; }; }} // namespace Opm::EclIO diff --git a/ThirdParty/custom-opm-common/opm-common/opm/io/eclipse/EclUtil.hpp b/ThirdParty/custom-opm-common/opm-common/opm/io/eclipse/EclUtil.hpp index 7e0501f964..c80873fe34 100644 --- a/ThirdParty/custom-opm-common/opm-common/opm/io/eclipse/EclUtil.hpp +++ b/ThirdParty/custom-opm-common/opm-common/opm/io/eclipse/EclUtil.hpp @@ -23,8 +23,6 @@ #include #include -#include -#include namespace Opm { namespace EclIO { @@ -33,8 +31,6 @@ namespace Opm { namespace EclIO { float flipEndianFloat(float num); double flipEndianDouble(double num); bool isEOF(std::fstream* fileH); - bool fileExists(const std::string& filename); - bool isFormatted(const std::string& filename); std::tuple block_size_data_binary(eclArrType arrType); std::tuple block_size_data_formatted(eclArrType arrType); @@ -53,25 +49,6 @@ namespace Opm { namespace EclIO { void readFormattedHeader(std::fstream& fileH, std::string& arrName, int64_t &num, Opm::EclIO::eclArrType &arrType); - template - std::vector readBinaryArray(std::fstream& fileH, const int64_t size, Opm::EclIO::eclArrType type, - std::function& flip); - - std::vector readBinaryInteArray(std::fstream &fileH, const int64_t size); - std::vector readBinaryRealArray(std::fstream& fileH, const int64_t size); - std::vector readBinaryDoubArray(std::fstream& fileH, const int64_t size); - std::vector readBinaryLogiArray(std::fstream &fileH, const int64_t size); - std::vector readBinaryCharArray(std::fstream& fileH, const int64_t size); - - template - std::vector readFormattedArray(const std::string& file_str, const int size, int64_t fromPos, - std::function& process); - - std::vector readFormattedInteArray(const std::string& file_str, const int64_t size, int64_t fromPos); - std::vector readFormattedCharArray(const std::string& file_str, const int64_t size, int64_t fromPos); - std::vector readFormattedRealArray(const std::string& file_str, const int64_t size, int64_t fromPos); - std::vector readFormattedLogiArray(const std::string& file_str, const int64_t size, int64_t fromPos); - std::vector readFormattedDoubArray(const std::string& file_str, const int64_t size, int64_t fromPos); }} // namespace Opm::EclIO diff --git a/ThirdParty/custom-opm-common/opm-common/opm/io/eclipse/SummaryNode.hpp b/ThirdParty/custom-opm-common/opm-common/opm/io/eclipse/SummaryNode.hpp index 428abedaa7..f29543c031 100644 --- a/ThirdParty/custom-opm-common/opm-common/opm/io/eclipse/SummaryNode.hpp +++ b/ThirdParty/custom-opm-common/opm-common/opm/io/eclipse/SummaryNode.hpp @@ -25,7 +25,7 @@ #include #include -namespace Opm { namespace EclIO { +namespace Opm::EclIO { struct SummaryNode { enum class Category { @@ -72,6 +72,6 @@ struct SummaryNode { std::optional display_number(number_renderer) const; }; - }} // namespace Opm::EclIO +} // namespace Opm::EclIO #endif // OPM_IO_SUMMARYNODE_HPP diff --git a/ThirdParty/custom-opm-common/opm-common/opm/io/eclipse/rst/well.hpp b/ThirdParty/custom-opm-common/opm-common/opm/io/eclipse/rst/well.hpp index e54ba58d9b..2db54ad332 100644 --- a/ThirdParty/custom-opm-common/opm-common/opm/io/eclipse/rst/well.hpp +++ b/ThirdParty/custom-opm-common/opm-common/opm/io/eclipse/rst/well.hpp @@ -94,7 +94,6 @@ struct RstWell { double gas_rate; double liquid_rate; double void_rate; - double thp; double flow_bhp; double wct; double gor; diff --git a/ThirdParty/custom-opm-common/opm-common/opm/json/JsonObject.hpp b/ThirdParty/custom-opm-common/opm-common/opm/json/JsonObject.hpp index 2e35215a63..3872a9ca2f 100644 --- a/ThirdParty/custom-opm-common/opm-common/opm/json/JsonObject.hpp +++ b/ThirdParty/custom-opm-common/opm-common/opm/json/JsonObject.hpp @@ -30,26 +30,12 @@ namespace Json { class JsonObject { public: - JsonObject(); - explicit JsonObject(const Opm::filesystem::path& jsonFile ); explicit JsonObject(const std::string& inline_json); explicit JsonObject(const char * inline_json); explicit JsonObject(cJSON * root); ~JsonObject(); - void add(double value); - void add(int value); - void add(const std::string& value); - JsonObject add_array(); - JsonObject add_object(); - void add_item(const std::string& key, double value); - void add_item(const std::string& key, int value); - void add_item(const std::string& key, const std::string& value); - JsonObject add_array(const std::string& key); - JsonObject add_object(const std::string& key); - std::string dump() const; - bool has_item(const std::string& key) const; JsonObject get_array_item( size_t index ) const; JsonObject get_item(const std::string& key) const; diff --git a/ThirdParty/custom-opm-common/opm-common/opm/output/data/Cells.hpp b/ThirdParty/custom-opm-common/opm-common/opm/output/data/Cells.hpp index ce51bbdddd..42d8897250 100644 --- a/ThirdParty/custom-opm-common/opm-common/opm/output/data/Cells.hpp +++ b/ThirdParty/custom-opm-common/opm-common/opm/output/data/Cells.hpp @@ -36,10 +36,10 @@ namespace data { from the TargetType enum which indicates why they they have been added to the container - and where they are headed. - RESTART_SOLUTION : Cell-based quantities that are output to the - SOLUTION section of the restart file. ECLIPSE-compatible names. - Many, but not necessarily all, of these quantities are required - for restarting the simulator. + RESTART_SOLUTION : Fields which represent primary variables, and + are reqired for restart. Typically pressure and + suturation. WIll end up in the SOLUTION section of the restart + file. RESTART_AUXILIARY : Fields with extra information, not required for restart. Examples of this include fluid in place values or @@ -52,10 +52,6 @@ namespace data { will not be output anywhere else. INIT : Fields which should go to the INIT file. - - RESTART_OPM_EXTENDED: Cell-based quantities that are specific to - OPM-Flow. Output only to extended OPM restart files. Specifically - not output to ECLIPSE-compatible restart files. */ @@ -64,7 +60,6 @@ namespace data { RESTART_AUXILIARY, SUMMARY, INIT, - RESTART_OPM_EXTENDED, }; /** diff --git a/ThirdParty/custom-opm-common/opm-common/opm/output/data/Groups.hpp b/ThirdParty/custom-opm-common/opm-common/opm/output/data/Groups.hpp index 633b322a28..1555e0c18e 100644 --- a/ThirdParty/custom-opm-common/opm-common/opm/output/data/Groups.hpp +++ b/ThirdParty/custom-opm-common/opm-common/opm/output/data/Groups.hpp @@ -20,119 +20,63 @@ #ifndef OPM_OUTPUT_GROUPS_HPP #define OPM_OUTPUT_GROUPS_HPP +#include #include +#include #include #include #include +#include +#include #include -#include - #include -namespace Opm { namespace data { +namespace Opm { - struct GroupConstraints { + namespace data { + + struct currentGroupConstraints { Opm::Group::ProductionCMode currentProdConstraint; Opm::Group::InjectionCMode currentGasInjectionConstraint; Opm::Group::InjectionCMode currentWaterInjectionConstraint; template void write(MessageBufferType& buffer) const; - template void read(MessageBufferType& buffer); - bool operator==(const GroupConstraints& other) const - { - return this->currentProdConstraint == other.currentProdConstraint && - this->currentGasInjectionConstraint == other.currentGasInjectionConstraint && - this->currentWaterInjectionConstraint == other.currentWaterInjectionConstraint; - } - - inline GroupConstraints& set(Opm::Group::ProductionCMode cpc, - Opm::Group::InjectionCMode cgic, - Opm::Group::InjectionCMode cwic); + inline currentGroupConstraints& set( Opm::Group::ProductionCMode cpc, + Opm::Group::InjectionCMode cgic, + Opm::Group::InjectionCMode cwic); }; - struct GroupGuideRates { - GuideRateValue production{}; - GuideRateValue injection{}; - template - void write(MessageBufferType& buffer) const - { - this->production.write(buffer); - this->injection .write(buffer); - } - - template - void read(MessageBufferType& buffer) - { - this->production.read(buffer); - this->injection .read(buffer); - } - - bool operator==(const GroupGuideRates& other) const - { - return this->production == other.production - && this->injection == other.injection; - } - }; - - struct GroupData { - GroupConstraints currentControl; - GroupGuideRates guideRates{}; - - template - void write(MessageBufferType& buffer) const - { - this->currentControl.write(buffer); - this->guideRates .write(buffer); - } - - template - void read(MessageBufferType& buffer) - { - this->currentControl.read(buffer); - this->guideRates .read(buffer); - } - - bool operator==(const GroupData& other) const - { - return this->currentControl == other.currentControl - && this->guideRates == other.guideRates; - } - }; - - class GroupValues : public std::map { + class Group : public std::map { public: + template - void write(MessageBufferType& buffer) const - { + void write(MessageBufferType& buffer) const { unsigned int size = this->size(); buffer.write(size); - - for (const auto& [gname, gdata] : *this) { - buffer.write(gname); - gdata .write(buffer); + for (const auto& witr : *this) { + const std::string& name = witr.first; + buffer.write(name); + const auto& pi_constr = witr.second; + pi_constr.write(buffer); } } template - void read(MessageBufferType& buffer) - { - unsigned int size; + void read(MessageBufferType& buffer) { + unsigned int size; buffer.read(size); - for (size_t i = 0; i < size; ++i) { std::string name; buffer.read(name); - - auto gdata = GroupData{}; - gdata.read(buffer); - - this->emplace(name, gdata); + currentGroupConstraints cgc; + cgc.read(buffer); + this->emplace(name, cgc); } } }; @@ -140,28 +84,26 @@ namespace Opm { namespace data { /* IMPLEMENTATIONS */ template - void GroupConstraints::write(MessageBufferType& buffer) const { + void currentGroupConstraints::write(MessageBufferType& buffer) const { buffer.write(this->currentProdConstraint); buffer.write(this->currentGasInjectionConstraint); buffer.write(this->currentWaterInjectionConstraint); } template - void GroupConstraints::read(MessageBufferType& buffer) { + void currentGroupConstraints::read(MessageBufferType& buffer) { buffer.read(this->currentProdConstraint); buffer.read(this->currentGasInjectionConstraint); buffer.read(this->currentWaterInjectionConstraint); } - inline GroupConstraints& - GroupConstraints::set(Opm::Group::ProductionCMode cpc, - Opm::Group::InjectionCMode cgic, - Opm::Group::InjectionCMode cwic) - { + + inline currentGroupConstraints& currentGroupConstraints::set( Opm::Group::ProductionCMode cpc, + Opm::Group::InjectionCMode cgic, + Opm::Group::InjectionCMode cwic) { this->currentGasInjectionConstraint = cgic; this->currentWaterInjectionConstraint = cwic; this->currentProdConstraint = cpc; - return *this; } diff --git a/ThirdParty/custom-opm-common/opm-common/opm/output/data/GuideRateValue.hpp b/ThirdParty/custom-opm-common/opm-common/opm/output/data/GuideRateValue.hpp deleted file mode 100644 index 6554bf57ea..0000000000 --- a/ThirdParty/custom-opm-common/opm-common/opm/output/data/GuideRateValue.hpp +++ /dev/null @@ -1,156 +0,0 @@ -/* - Copyright (c) 2020 Equinor ASA - - This file is part of the Open Porous Media project (OPM). - - OPM is free software: you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - OPM is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with OPM. If not, see . -*/ - -#ifndef OPM_OUTPUT_DATA_GUIDERATEVALUE_HPP -#define OPM_OUTPUT_DATA_GUIDERATEVALUE_HPP - -#include -#include -#include -#include -#include - -namespace Opm { namespace data { - - class GuideRateValue { - public: - enum class Item : std::size_t { - Oil, Gas, Water, ResV, - - // -- Must be last enumerator -- - NumItems, - }; - - void clear() - { - this->mask_.reset(); - this->value_.fill(0.0); - } - - constexpr bool has(const Item p) const - { - const auto i = this->index(p); - - return (i < Size) && this->mask_[i]; - } - - bool operator==(const GuideRateValue& vec) const - { - return (this->mask_ == vec.mask_) - && (this->value_ == vec.value_); - } - - double get(const Item p) const - { - if (! this->has(p)) { - throw std::invalid_argument { - "Request for Unset Item Value for " + this->itemName(p) - }; - } - - return this->value_[ this->index(p) ]; - } - - GuideRateValue& set(const Item p, const double value) - { - const auto i = this->index(p); - - if (i >= Size) { - throw std::invalid_argument { - "Cannot Assign Item Value for Unsupported Item '" - + this->itemName(p) + '\'' - }; - } - - this->mask_.set(i); - this->value_[i] = value; - - return *this; - } - - GuideRateValue& operator+=(const GuideRateValue& rhs) - { - for (auto i = 0*Size; i < Size; ++i) { - if (rhs.mask_[i]) { - this->mask_.set(i); - this->value_[i] += rhs.value_[i]; - } - } - - return *this; - } - - template - void write(MessageBufferType& buffer) const - { - auto maskrep = this->mask_.to_ullong(); - buffer.write(maskrep); - - for (const auto& x : this->value_) { - buffer.write(x); - } - } - - template - void read(MessageBufferType& buffer) - { - this->clear(); - - { - auto mask = 0ull; - buffer.read(mask); - - this->mask_ = std::bitset(mask); - } - - for (auto& x : this->value_) { - buffer.read(x); - } - } - - private: - enum { Size = static_cast(Item::NumItems) }; - - std::bitset mask_{}; - std::array value_{}; - - constexpr std::size_t index(const Item p) const noexcept - { - return static_cast(p); - } - - std::string itemName(const Item p) const - { - switch (p) { - case Item::Oil: return "Oil"; - case Item::Gas: return "Gas"; - case Item::Water: return "Water"; - case Item::ResV: return "ResV"; - - case Item::NumItems: - return "Out of bounds (NumItems)"; - } - - return "Unknown (" + std::to_string(this->index(p)) + ')'; - } - }; - -}} // namespace Opm::data - -#endif // OPM_OUTPUT_DATA_GUIDERATEVALUE_HPP diff --git a/ThirdParty/custom-opm-common/opm-common/opm/output/data/Wells.hpp b/ThirdParty/custom-opm-common/opm-common/opm/output/data/Wells.hpp index 0b001d9916..bb5a8497d2 100644 --- a/ThirdParty/custom-opm-common/opm-common/opm/output/data/Wells.hpp +++ b/ThirdParty/custom-opm-common/opm-common/opm/output/data/Wells.hpp @@ -30,8 +30,6 @@ #include #include -#include - #include namespace Opm { @@ -68,7 +66,6 @@ namespace Opm { well_potential_water = (1 << 14), well_potential_oil = (1 << 15), well_potential_gas = (1 << 16), - brine = (1 << 17), }; using enum_size = std::underlying_type< opt >::type; @@ -120,7 +117,6 @@ namespace Opm { double well_potential_water = 0.0; double well_potential_oil = 0.0; double well_potential_gas = 0.0; - double brine = 0.0; }; struct Connection { @@ -255,7 +251,6 @@ namespace Opm { std::vector< Connection > connections; std::unordered_map segments; CurrentControl current_control; - GuideRateValue guide_rates{}; inline bool flowing() const noexcept; template @@ -296,8 +291,7 @@ namespace Opm { control == well2.control && connections == well2.connections && segments == well2.segments && - current_control == well2.current_control && - guide_rates == well2.guide_rates; + current_control == well2.current_control; } }; @@ -410,8 +404,7 @@ namespace Opm { productivity_index_oil == rate.productivity_index_oil && well_potential_water == rate.well_potential_water && well_potential_oil == rate.well_potential_oil && - well_potential_gas == rate.well_potential_gas && - brine == rate.brine; + well_potential_gas == rate.well_potential_gas; } @@ -443,7 +436,6 @@ namespace Opm { case opt::well_potential_water: return this->well_potential_water; case opt::well_potential_oil: return this->well_potential_oil; case opt::well_potential_gas: return this->well_potential_gas; - case opt::brine: return this->brine; } throw std::invalid_argument( @@ -490,7 +482,6 @@ namespace Opm { buffer.write(this->well_potential_water); buffer.write(this->well_potential_oil); buffer.write(this->well_potential_gas); - buffer.write(this->brine); } template @@ -547,7 +538,6 @@ namespace Opm { } this->current_control.write(buffer); - this->guide_rates.write(buffer); } template @@ -570,7 +560,6 @@ namespace Opm { buffer.read(this->well_potential_water); buffer.read(this->well_potential_oil); buffer.read(this->well_potential_gas); - buffer.read(this->brine); } template @@ -640,7 +629,6 @@ namespace Opm { } this->current_control.read(buffer); - this->guide_rates.read(buffer); } }} // Opm::data diff --git a/ThirdParty/custom-opm-common/opm-common/opm/output/eclipse/AggregateActionxData.hpp b/ThirdParty/custom-opm-common/opm-common/opm/output/eclipse/AggregateActionxData.hpp index 4aa38e54ed..69b9fb85c5 100644 --- a/ThirdParty/custom-opm-common/opm-common/opm/output/eclipse/AggregateActionxData.hpp +++ b/ThirdParty/custom-opm-common/opm-common/opm/output/eclipse/AggregateActionxData.hpp @@ -41,10 +41,6 @@ namespace Opm { class Schedule; class UDQInput; class UDQActive; - - namespace Action { - class State; - } } // Opm @@ -56,11 +52,10 @@ class AggregateActionxData public: explicit AggregateActionxData(const std::vector& actDims); - void captureDeclaredActionxData( const Opm::Schedule& sched, - const Opm::Action::State& action_state, - const Opm::SummaryState& st, - const std::vector& actDims, - const std::size_t simStep); + void captureDeclaredActionxData( const Opm::Schedule& sched, + const Opm::SummaryState& st, + const std::vector& actDims, + const std::size_t simStep); const std::vector& getIACT() const { diff --git a/ThirdParty/custom-opm-common/opm-common/opm/output/eclipse/AggregateGroupData.hpp b/ThirdParty/custom-opm-common/opm-common/opm/output/eclipse/AggregateGroupData.hpp index 21ee3c7467..9a93c1cc0a 100644 --- a/ThirdParty/custom-opm-common/opm-common/opm/output/eclipse/AggregateGroupData.hpp +++ b/ThirdParty/custom-opm-common/opm-common/opm/output/eclipse/AggregateGroupData.hpp @@ -74,12 +74,8 @@ public: "GOPT", "GWPT", "GGPT", "GVPT", "GWIT", "GGIT", "GVIT", "GOPTH", "GWPTH", "GGPTH", - "GWITH", "GGITH", - "GOPGR", "GWPGR", "GGPGR", "GVPGR", - "GOIGR", "GWIGR", "GGIGR", - }; + "GWITH", "GGITH"}; - // Note: guide rates don't exist at the FIELD level. const std::vector restart_field_keys = {"FOPP", "FWPP", "FOPR", "FWPR", "FGPR", "FVPR", "FWIR", "FGIR", "FWCT", "FGOR", "FOPT", "FWPT", "FGPT", "FVPT", "FWIT", @@ -105,13 +101,6 @@ public: {"GVIT", 17}, {"GOPP", 22}, {"GWPP", 23}, - {"GOPGR", 85}, - {"GWPGR", 86}, - {"GGPGR", 87}, - {"GVPGR", 88}, - {"GOIGR", 89}, - {"GWIGR", 91}, - {"GGIGR", 93}, {"GOPTH", 135}, {"GWPTH", 139}, {"GWITH", 140}, @@ -132,26 +121,6 @@ public: {inj_cmode_enum::SALE, 0}, }; - // Note: guide rates don't exist at the FIELD level. - const std::map ICntlModeToiCMode = { - {0, inj_cmode_enum::NONE}, - {1, inj_cmode_enum::RATE}, - {2, inj_cmode_enum::RESV}, - {3, inj_cmode_enum::REIN}, - {4, inj_cmode_enum::VREP}, }; - - using p_cmode = Opm::Group::ProductionCMode; - const std::map PCntlModeToPCMode = { - {0, p_cmode::NONE}, - {1, p_cmode::ORAT}, - {2, p_cmode::WRAT}, - {3, p_cmode::GRAT}, - {4, p_cmode::LRAT}, - {9, p_cmode::CRAT}, - {5, p_cmode::RESV}, - {6, p_cmode::PRBL}, - }; - const std::map fieldKeyToIndex = { {"FOPR", 0}, {"FWPR", 1}, diff --git a/ThirdParty/custom-opm-common/opm-common/opm/output/eclipse/AggregateUDQData.hpp b/ThirdParty/custom-opm-common/opm-common/opm/output/eclipse/AggregateUDQData.hpp index 8e0c6999cb..c166ff1291 100644 --- a/ThirdParty/custom-opm-common/opm-common/opm/output/eclipse/AggregateUDQData.hpp +++ b/ThirdParty/custom-opm-common/opm-common/opm/output/eclipse/AggregateUDQData.hpp @@ -94,12 +94,12 @@ void captureDeclaredUDQData(const Opm::Schedule& sched, { return this->dUDW_.data(); } - + const std::vector& getDUDG() const { return this->dUDG_.data(); } - + const std::vector& getDUDF() const { return this->dUDF_.data(); @@ -127,10 +127,10 @@ private: /// Aggregate 'DUDW' array (Double Precision) for all UDQ data. (Dimension = max no wells * noOfUDQ's) WindowedArray dUDW_; - + /// Aggregate 'DUDG' array (Double Precision) for all UDQ data. (Dimension = (max no groups + 1) * noOfUDQ's) WindowedArray dUDG_; - + /// Aggregate 'DUDF' array (Double Precision) for all UDQ data. (Dimension = Number of FU - UDQ's, with value equal to the actual constraint) WindowedArray dUDF_; diff --git a/ThirdParty/custom-opm-common/opm-common/opm/output/eclipse/AggregateWellData.hpp b/ThirdParty/custom-opm-common/opm-common/opm/output/eclipse/AggregateWellData.hpp index d4b9542fbd..1f8a43c038 100644 --- a/ThirdParty/custom-opm-common/opm-common/opm/output/eclipse/AggregateWellData.hpp +++ b/ThirdParty/custom-opm-common/opm-common/opm/output/eclipse/AggregateWellData.hpp @@ -33,9 +33,6 @@ namespace Opm { class Schedule; class SummaryState; class UnitSystem; - namespace Action { - class State; - } } // Opm namespace Opm { namespace data { @@ -43,18 +40,22 @@ namespace Opm { namespace data { }} // Opm::data namespace Opm { namespace RestartIO { namespace Helpers { + + struct ActionResStatus { + std::vector result; + std::vector name; + }; class AggregateWellData { public: explicit AggregateWellData(const std::vector& inteHead); - void captureDeclaredWellData(const Schedule& sched, - const UnitSystem& units, - const std::size_t sim_step, - const ::Opm::Action::State& action_state, - const ::Opm::SummaryState& smry, - const std::vector& inteHead); + void captureDeclaredWellData(const Schedule& sched, + const UnitSystem& units, + const std::size_t sim_step, + const ::Opm::SummaryState& smry, + const std::vector& inteHead); void captureDynamicWellData(const Opm::Schedule& sched, const std::size_t sim_step, @@ -85,8 +86,8 @@ namespace Opm { namespace RestartIO { namespace Helpers { return this->zWell_.data(); } - - + + private: /// Aggregate 'IWEL' array (Integer) for all wells. WindowedArray iWell_; diff --git a/ThirdParty/custom-opm-common/opm-common/opm/output/eclipse/EclipseIO.hpp b/ThirdParty/custom-opm-common/opm-common/opm/output/eclipse/EclipseIO.hpp index 0c4d4aaea2..f815d9967d 100644 --- a/ThirdParty/custom-opm-common/opm-common/opm/output/eclipse/EclipseIO.hpp +++ b/ThirdParty/custom-opm-common/opm-common/opm/output/eclipse/EclipseIO.hpp @@ -45,7 +45,7 @@ class EclipseState; class Schedule; class SummaryConfig; class SummaryState; -namespace Action { class State; } + /*! * \brief A class to write the reservoir state and the well state of a * blackoil simulation to disk using the Eclipse binary format. @@ -174,8 +174,7 @@ public: * hardcoded static map misc_units in Summary.cpp. */ - void writeTimeStep( const Action::State& action_state, - const SummaryState& st, + void writeTimeStep( const SummaryState& st, int report_step, bool isSubstep, double seconds_elapsed, @@ -221,7 +220,7 @@ public: missing, if the bool is false missing keywords will be ignored (there will *not* be an empty vector in the return value). */ - RestartValue loadRestart(Action::State& action_state, SummaryState& summary_state, const std::vector& solution_keys, const std::vector& extra_keys = {}) const; + RestartValue loadRestart(SummaryState& summary_state, const std::vector& solution_keys, const std::vector& extra_keys = {}) const; const out::Summary& summary(); EclipseIO( const EclipseIO& ) = delete; diff --git a/ThirdParty/custom-opm-common/opm-common/opm/output/eclipse/RestartIO.hpp b/ThirdParty/custom-opm-common/opm-common/opm/output/eclipse/RestartIO.hpp index 6653f6d7ff..b06e3d4ed9 100644 --- a/ThirdParty/custom-opm-common/opm-common/opm/output/eclipse/RestartIO.hpp +++ b/ThirdParty/custom-opm-common/opm-common/opm/output/eclipse/RestartIO.hpp @@ -46,12 +46,6 @@ namespace Opm { namespace EclIO { namespace OutputStream { }}} -namespace Opm { namespace Action { - - class State; - -}} - /* The two free functions RestartIO::save() and RestartIO::load() can be used to save and load reservoir and well state from restart @@ -82,14 +76,12 @@ namespace Opm { namespace RestartIO { const EclipseState& es, const EclipseGrid& grid, const Schedule& schedule, - const Action::State& action_state, const SummaryState& sumState, bool write_double = false); RestartValue load(const std::string& filename, int report_step, - Action::State& action_state, SummaryState& summary_state, const std::vector& solution_keys, const EclipseState& es, diff --git a/ThirdParty/custom-opm-common/opm-common/opm/output/eclipse/RestartValue.hpp b/ThirdParty/custom-opm-common/opm-common/opm/output/eclipse/RestartValue.hpp index 3103565f12..793386fbd0 100644 --- a/ThirdParty/custom-opm-common/opm-common/opm/output/eclipse/RestartValue.hpp +++ b/ThirdParty/custom-opm-common/opm-common/opm/output/eclipse/RestartValue.hpp @@ -28,7 +28,6 @@ #include #include #include -#include namespace Opm { @@ -71,11 +70,10 @@ namespace Opm { using ExtraVector = std::vector>>; data::Solution solution; data::Wells wells; - data::GroupValues groups; ExtraVector extra; std::vector aquifer; - RestartValue(data::Solution sol, data::Wells wells_arg, data::GroupValues groups_arg); + RestartValue(data::Solution sol, data::Wells wells_arg); RestartValue() {} @@ -91,7 +89,6 @@ namespace Opm { { return solution == val2.solution && wells == val2.wells && - groups == val2.groups && extra == val2.extra; } }; diff --git a/ThirdParty/custom-opm-common/opm-common/opm/output/eclipse/Summary.hpp b/ThirdParty/custom-opm-common/opm-common/opm/output/eclipse/Summary.hpp index 8413aa8a57..178e071178 100644 --- a/ThirdParty/custom-opm-common/opm-common/opm/output/eclipse/Summary.hpp +++ b/ThirdParty/custom-opm-common/opm-common/opm/output/eclipse/Summary.hpp @@ -38,7 +38,7 @@ namespace Opm { namespace Opm { namespace data { class WellRates; - class GroupValues; + class Group; }} // namespace Opm::data namespace Opm { namespace out { @@ -65,7 +65,7 @@ public: const EclipseState& es, const Schedule& schedule, const data::WellRates& well_solution, - const data::GroupValues& group_solution, + const data::Group& group_solution, const GlobalProcessParameters& single_values, const RegionParameters& region_values = {}, const BlockValues& block_values = {}) const; diff --git a/ThirdParty/custom-opm-common/opm-common/opm/output/eclipse/VectorItems/group.hpp b/ThirdParty/custom-opm-common/opm-common/opm/output/eclipse/VectorItems/group.hpp index 57103fccbc..a084f8504d 100644 --- a/ThirdParty/custom-opm-common/opm-common/opm/output/eclipse/VectorItems/group.hpp +++ b/ThirdParty/custom-opm-common/opm-common/opm/output/eclipse/VectorItems/group.hpp @@ -34,10 +34,6 @@ namespace Opm { namespace RestartIO { namespace Helpers { namespace VectorItems }; enum inj_index : std::vector::size_type { - oilSurfRateLimit = 10, // Group's oil surface volume injection rate target/limit - oilResRateLimit = 11, // Group's oil reservoir volume injection rate target/limit - oilReinjectionLimit = 12, // Group's oil reinjection fraction target/limit - oilVoidageLimit = 13, // Group's oil voidage injection fraction target/limit waterSurfRateLimit = 15, //i Group's water surface volume injection rate target/limit waterResRateLimit = 16, // Group's water reservoir volume injection rate target/limit waterReinjectionLimit = 17, // Group's water reinjection fraction target/limit @@ -78,26 +74,6 @@ namespace Opm { namespace RestartIO { namespace Helpers { namespace VectorItems OilPrPot = 22, // Group's oil production potential WatPrPot = 23, // Group's water production potential - OilPrGuideRate = 85, // Group's producer guide rate for oil. - WatPrGuideRate = 86, // Group's producer guide rate for water. - GasPrGuideRate = 87, // Group's producer guide rate for gas. - VoidPrGuideRate = 88, // Group's producer guide rate for reservoir voidage volume. - - OilInjGuideRate = 89, // Group's injection guide rate for oil. - WatInjGuideRate = 91, // Group's injection guide rate for water. - WatInjGuideRate_2 = 92, // Second copy of group's injection guide rate for water. - // Not fully characterised. - GasInjGuideRate = 93, // Groups injection guide rate for gas. - - OilPrGuideRate_2 = 127, // Second copy of group's producer guide rate for oil. - // Not fully characterised. - WatPrGuideRate_2 = 128, // Second copy of group's producer guide rate for water. - // Not fully characterised. - GasPrGuideRate_2 = 129, // Second copy of group's producer guide rate for gas. - // Not fully characterised. - VoidPrGuideRate_2 = 130, // Second copy of group's producer guide rate for - // reservoir voidage volume. Not fully characterised. - HistOilPrTotal = 135, // Group's total cumulative oil // production (observed/historical rates) HistWatPrTotal = 139, // Group's total cumulative water diff --git a/ThirdParty/custom-opm-common/opm-common/opm/output/eclipse/VectorItems/msw.hpp b/ThirdParty/custom-opm-common/opm-common/opm/output/eclipse/VectorItems/msw.hpp index 8c0052ea6d..f0e1661e95 100644 --- a/ThirdParty/custom-opm-common/opm-common/opm/output/eclipse/VectorItems/msw.hpp +++ b/ThirdParty/custom-opm-common/opm-common/opm/output/eclipse/VectorItems/msw.hpp @@ -55,8 +55,6 @@ namespace Opm { namespace RestartIO { namespace Helpers { namespace VectorItems GasFlowFract = 10, // Normalised Gas flow rate fraction Pressure = 11, // Segment pressure - item31 = 30, // Very close to Normalised Water flow rate fraction - value used pr today - item40 = 39, // Unknown ValveLength = 40, // Length of valve diff --git a/ThirdParty/custom-opm-common/opm-common/opm/output/eclipse/VectorItems/well.hpp b/ThirdParty/custom-opm-common/opm-common/opm/output/eclipse/VectorItems/well.hpp index 62ec241176..5892c29571 100644 --- a/ThirdParty/custom-opm-common/opm-common/opm/output/eclipse/VectorItems/well.hpp +++ b/ThirdParty/custom-opm-common/opm-common/opm/output/eclipse/VectorItems/well.hpp @@ -43,7 +43,7 @@ namespace Opm { namespace RestartIO { namespace Helpers { namespace VectorItems // simulation deck (WCONINJE, WCONPROD). item18 = 17, // Unknown - XFlow = 22, + XFlow = 22, item25 = 24, // Unknown item32 = 31, // Unknown item48 = 47, // Unknown @@ -113,11 +113,10 @@ namespace Opm { namespace RestartIO { namespace Helpers { namespace VectorItems BHPTarget = 6, // Well's bottom hole pressure target DatumDepth = 9, // Well's reference depth for BHP - Alq_value = 10, // Well's artificial lift quantity DrainageRadius = 17, // Well's drainage radius - item 7 from WELSPECS EfficiencyFactor1 = 24, // Item2 from WEFAC; this value is repeated at two locations. - EfficiencyFactor2 = 31, // Item2 from WEFAC + EfficiencyFactor2 = 31, // HistLiqRateTarget = 33, // Well's historical/observed liquid // rate target/limit @@ -136,7 +135,7 @@ namespace Opm { namespace RestartIO { namespace Helpers { namespace VectorItems GasPrRate = 2, // Well's gas production rate LiqPrRate = 3, // Well's liquid production rate VoidPrRate = 4, // Well's reservoir voidage production rate - TubHeadPr = 5, // Well's tubing head pressure + FlowBHP = 6, // Well's flowing/producing bottom hole pressure WatCut = 7, // Well's producing water cut GORatio = 8, // Well's producing gas/oil ratio @@ -158,12 +157,6 @@ namespace Opm { namespace RestartIO { namespace Helpers { namespace VectorItems BHPTarget = 41, // Well's current BHP Target/Limit - PrimGuideRate = 48, // Well's "primary" guide rate (oil for producers, - // preferred phase for injectors) - WatPrGuideRate = 49, // Well's producer guide rate for water - GasPrGuideRate = 50, // Well's producer guide rate for gas - VoidPrGuideRate = 68, // Well's producer guide rate for reservoir voidag volume - HistOilPrTotal = 75, // Well's total cumulative oil production // (observed/historical rates) HistWatPrTotal = 76, // Well's total cumulative water @@ -176,15 +169,6 @@ namespace Opm { namespace RestartIO { namespace Helpers { namespace VectorItems HistGasInjTotal = 82, // Well's total cumulative gas injection // (observed/historical rates) - PrimGuideRate_2 = 91, // Second copy of well's primary guide rate. - // Not fully characterised. - WatPrGuideRate_2 = 92, // Second copy of well's producer guide rate for water. - // Not fully characterised. - GasPrGuideRate_2 = 93, // Second copy of well's producer guide rate for gas - // Not fully characterised. - VoidPrGuideRate_2 = 94, // Second copy of well's producer guide rate for reservoir voidage - // Not fully characterised. - WatVoidPrRate = 122, // Well's voidage production rate GasVoidPrRate = 123, // Well's voidage production rate }; diff --git a/ThirdParty/custom-opm-common/opm-common/opm/output/eclipse/WriteRPT.hpp b/ThirdParty/custom-opm-common/opm-common/opm/output/eclipse/WriteRPT.hpp index d989133421..3dc9cc0543 100644 --- a/ThirdParty/custom-opm-common/opm-common/opm/output/eclipse/WriteRPT.hpp +++ b/ThirdParty/custom-opm-common/opm-common/opm/output/eclipse/WriteRPT.hpp @@ -26,7 +26,6 @@ namespace Opm { class Schedule; class EclipseGrid; - class UnitSystem; namespace RptIO { @@ -36,13 +35,12 @@ namespace Opm { unsigned value, const Schedule& schedule, const EclipseGrid& grid, - const UnitSystem& unit_system, std::size_t time_step ); namespace workers { - void write_WELSPECS(std::ostream&, unsigned, const Schedule&, const EclipseGrid& grid, const UnitSystem&, std::size_t); + void write_WELSPECS(std::ostream&, unsigned, const Schedule&, const EclipseGrid& grid, std::size_t); } } } #endif // OPM_WRITE_RPT_HPP diff --git a/ThirdParty/custom-opm-common/opm-common/opm/parser/eclipse/Deck/UDAValue.hpp b/ThirdParty/custom-opm-common/opm-common/opm/parser/eclipse/Deck/UDAValue.hpp index efe7b610a4..8791a64cc7 100644 --- a/ThirdParty/custom-opm-common/opm-common/opm/parser/eclipse/Deck/UDAValue.hpp +++ b/ThirdParty/custom-opm-common/opm-common/opm/parser/eclipse/Deck/UDAValue.hpp @@ -54,9 +54,6 @@ public: double getSI() const; bool zero() const; - //epsilon limit = 1.E-20 (~= 0.) - double epsilonLimit() const; - template bool is() const; @@ -68,7 +65,6 @@ public: bool operator!=(const UDAValue& other) const; UDAValue& operator=(double value); UDAValue& operator=(const std::string& value); - void update_value(const UDAValue& other); bool is_numeric() { return numeric_value; } diff --git a/ThirdParty/custom-opm-common/opm-common/opm/parser/eclipse/EclipseState/EclipseConfig.hpp b/ThirdParty/custom-opm-common/opm-common/opm/parser/eclipse/EclipseState/EclipseConfig.hpp index 90c12c541a..313e010cf1 100644 --- a/ThirdParty/custom-opm-common/opm-common/opm/parser/eclipse/EclipseState/EclipseConfig.hpp +++ b/ThirdParty/custom-opm-common/opm-common/opm/parser/eclipse/EclipseState/EclipseConfig.hpp @@ -38,10 +38,9 @@ namespace Opm { static EclipseConfig serializeObject(); - InitConfig& init(); + const InitConfig& init() const; IOConfig& io(); const IOConfig& io() const; - const InitConfig& init() const; const InitConfig& getInitConfig() const; bool operator==(const EclipseConfig& data) const; diff --git a/ThirdParty/custom-opm-common/opm-common/opm/parser/eclipse/EclipseState/EclipseState.hpp b/ThirdParty/custom-opm-common/opm-common/opm/parser/eclipse/EclipseState/EclipseState.hpp index 0b120100c0..e2db5a7ff2 100644 --- a/ThirdParty/custom-opm-common/opm-common/opm/parser/eclipse/EclipseState/EclipseState.hpp +++ b/ThirdParty/custom-opm-common/opm-common/opm/parser/eclipse/EclipseState/EclipseState.hpp @@ -77,8 +77,6 @@ namespace Opm { IOConfig& getIOConfig(); const InitConfig& getInitConfig() const; - InitConfig& getInitConfig(); - const SimulationConfig& getSimulationConfig() const; virtual const EclipseGrid& getInputGrid() const; diff --git a/ThirdParty/custom-opm-common/opm-common/opm/parser/eclipse/EclipseState/Grid/EclipseGrid.hpp b/ThirdParty/custom-opm-common/opm-common/opm/parser/eclipse/EclipseState/Grid/EclipseGrid.hpp index bd16388c18..d6f3317ab9 100644 --- a/ThirdParty/custom-opm-common/opm-common/opm/parser/eclipse/EclipseState/Grid/EclipseGrid.hpp +++ b/ThirdParty/custom-opm-common/opm-common/opm/parser/eclipse/EclipseState/Grid/EclipseGrid.hpp @@ -110,7 +110,6 @@ namespace Opm { double getPinchThresholdThickness( ) const; PinchMode::ModeEnum getPinchOption( ) const; PinchMode::ModeEnum getMultzOption( ) const; - PinchMode::ModeEnum getPinchGapMode( ) const; MinpvMode::ModeEnum getMinpvMode() const; const std::vector& getMinpvVector( ) const; @@ -197,7 +196,6 @@ namespace Opm { Value m_pinch; PinchMode::ModeEnum m_pinchoutMode; PinchMode::ModeEnum m_multzMode; - PinchMode::ModeEnum m_pinchGapMode; bool m_circle = false; diff --git a/ThirdParty/custom-opm-common/opm-common/opm/parser/eclipse/EclipseState/Grid/PinchMode.hpp b/ThirdParty/custom-opm-common/opm-common/opm/parser/eclipse/EclipseState/Grid/PinchMode.hpp index 06ba68c0a3..13abf082cd 100644 --- a/ThirdParty/custom-opm-common/opm-common/opm/parser/eclipse/EclipseState/Grid/PinchMode.hpp +++ b/ThirdParty/custom-opm-common/opm-common/opm/parser/eclipse/EclipseState/Grid/PinchMode.hpp @@ -28,9 +28,7 @@ namespace Opm { enum ModeEnum { ALL = 1, TOPBOT = 2, - TOP = 3, - GAP = 4, - NOGAP = 5, + TOP = 3 }; const std::string PinchMode2String(const ModeEnum enumValue); diff --git a/ThirdParty/custom-opm-common/opm-common/opm/parser/eclipse/EclipseState/Grid/SatfuncPropertyInitializers.hpp b/ThirdParty/custom-opm-common/opm-common/opm/parser/eclipse/EclipseState/Grid/SatfuncPropertyInitializers.hpp index 66082785ab..445d241093 100644 --- a/ThirdParty/custom-opm-common/opm-common/opm/parser/eclipse/EclipseState/Grid/SatfuncPropertyInitializers.hpp +++ b/ThirdParty/custom-opm-common/opm-common/opm/parser/eclipse/EclipseState/Grid/SatfuncPropertyInitializers.hpp @@ -19,50 +19,227 @@ #ifndef ECLIPSE_SATFUNCPROPERTY_INITIALIZERS_HPP #define ECLIPSE_SATFUNCPROPERTY_INITIALIZERS_HPP -#include #include #include namespace Opm { + class Phases; class TableManager; -} -namespace Opm { namespace satfunc { +namespace satfunc { - struct RawTableEndPoints - { - struct { - std::vector gas; - std::vector water; - } connate; + std::vector SGLEndpoint(const TableManager&, + const Phases&, + const std::vector&, + const std::vector&, + const std::vector&); - struct { - std::vector oil_in_gas; - std::vector oil_in_water; - std::vector gas; - std::vector water; - } critical; + std::vector ISGLEndpoint(const TableManager&, + const Phases&, + const std::vector&, + const std::vector&, + const std::vector&); - struct { - std::vector gas; - std::vector water; - } maximum; - }; + std::vector SGUEndpoint(const TableManager&, + const Phases&, + const std::vector&, + const std::vector&, + const std::vector&); - std::shared_ptr - getRawTableEndpoints(const Opm::TableManager& tm, - const Opm::Phases& phases, - const double tolcrit); + std::vector ISGUEndpoint(const TableManager&, + const Phases&, + const std::vector&, + const std::vector&, + const std::vector&); + + std::vector SWLEndpoint(const TableManager&, + const Phases&, + const std::vector&, + const std::vector&, + const std::vector&); + + std::vector ISWLEndpoint(const TableManager&, + const Phases&, + const std::vector&, + const std::vector&, + const std::vector&); + + std::vector SWUEndpoint(const TableManager&, + const Phases&, + const std::vector&, + const std::vector&, + const std::vector&); + + std::vector ISWUEndpoint(const TableManager&, + const Phases&, + const std::vector&, + const std::vector&, + const std::vector&); + + std::vector SGCREndpoint(const TableManager&, + const Phases&, + const std::vector&, + const std::vector&, + const std::vector&); + + std::vector ISGCREndpoint(const TableManager&, + const Phases&, + const std::vector&, + const std::vector&, + const std::vector&); + + std::vector SOWCREndpoint(const TableManager&, + const Phases&, + const std::vector&, + const std::vector&, + const std::vector&); + + std::vector ISOWCREndpoint(const TableManager&, + const Phases&, + const std::vector&, + const std::vector&, + const std::vector&); + + std::vector SOGCREndpoint(const TableManager&, + const Phases&, + const std::vector&, + const std::vector&, + const std::vector&); + + std::vector ISOGCREndpoint(const TableManager&, + const Phases&, + const std::vector&, + const std::vector&, + const std::vector&); + + std::vector SWCREndpoint(const TableManager&, + const Phases&, + const std::vector&, + const std::vector&, + const std::vector&); + + std::vector ISWCREndpoint(const TableManager&, + const Phases&, + const std::vector&, + const std::vector&, + const std::vector&); + + std::vector PCWEndpoint(const TableManager&, + const Phases&, + const std::vector&, + const std::vector&, + const std::vector&); + + std::vector IPCWEndpoint(const TableManager&, + const Phases&, + const std::vector&, + const std::vector&, + const std::vector&); + + std::vector PCGEndpoint(const TableManager&, + const Phases&, + const std::vector&, + const std::vector&, + const std::vector&); + + std::vector IPCGEndpoint(const TableManager&, + const Phases&, + const std::vector&, + const std::vector&, + const std::vector&); + + std::vector KRWEndpoint(const TableManager&, + const Phases&, + const std::vector&, + const std::vector&, + const std::vector&); + + std::vector IKRWEndpoint(const TableManager&, + const Phases&, + const std::vector&, + const std::vector&, + const std::vector&); + + std::vector KRWREndpoint(const TableManager&, + const Phases&, + const std::vector&, + const std::vector&, + const std::vector&); + + std::vector IKRWREndpoint(const TableManager&, + const Phases&, + const std::vector&, + const std::vector&, + const std::vector&); + + std::vector KROEndpoint(const TableManager&, + const Phases&, + const std::vector&, + const std::vector&, + const std::vector&); + + std::vector IKROEndpoint(const TableManager&, + const Phases&, + const std::vector&, + const std::vector&, + const std::vector&); + + std::vector KRORWEndpoint(const TableManager&, + const Phases&, + const std::vector&, + const std::vector&, + const std::vector&); + + std::vector IKRORWEndpoint(const TableManager&, + const Phases&, + const std::vector&, + const std::vector&, + const std::vector&); + + std::vector KRORGEndpoint(const TableManager&, + const Phases&, + const std::vector&, + const std::vector&, + const std::vector&); + + std::vector IKRORGEndpoint(const TableManager&, + const Phases&, + const std::vector&, + const std::vector&, + const std::vector&); + + std::vector KRGEndpoint(const TableManager&, + const Phases&, + const std::vector&, + const std::vector&, + const std::vector&); + + std::vector IKRGEndpoint(const TableManager&, + const Phases&, + const std::vector&, + const std::vector&, + const std::vector&); + + std::vector KRGREndpoint(const TableManager&, + const Phases&, + const std::vector&, + const std::vector&, + const std::vector&); + + std::vector IKRGREndpoint(const TableManager&, + const Phases&, + const std::vector&, + const std::vector&, + const std::vector&); std::vector init(const std::string& kewyord, const TableManager& tables, const Phases& phases, - const RawTableEndPoints& ep, const std::vector& cell_depth, const std::vector& num, const std::vector& endnum); - -}} // namespace Opm::satfunc +} +} #endif // ECLIPSE_SATFUNCPROPERTY_INITIALIZERS_HPP diff --git a/ThirdParty/custom-opm-common/opm-common/opm/parser/eclipse/EclipseState/IOConfig/IOConfig.hpp b/ThirdParty/custom-opm-common/opm-common/opm/parser/eclipse/EclipseState/IOConfig/IOConfig.hpp index c94004fbba..0212446805 100644 --- a/ThirdParty/custom-opm-common/opm-common/opm/parser/eclipse/EclipseState/IOConfig/IOConfig.hpp +++ b/ThirdParty/custom-opm-common/opm-common/opm/parser/eclipse/EclipseState/IOConfig/IOConfig.hpp @@ -165,7 +165,7 @@ namespace Opm { const std::string& getEclipseInputPath() const; void overrideNOSIM(bool nosim); - void consistentFileFlags(); + std::string getRestartFileName(const std::string& restart_base, int report_step, bool output) const; diff --git a/ThirdParty/custom-opm-common/opm-common/opm/parser/eclipse/EclipseState/Runspec.hpp b/ThirdParty/custom-opm-common/opm-common/opm/parser/eclipse/EclipseState/Runspec.hpp index fc7cc219ad..e24704af0e 100644 --- a/ThirdParty/custom-opm-common/opm-common/opm/parser/eclipse/EclipseState/Runspec.hpp +++ b/ThirdParty/custom-opm-common/opm-common/opm/parser/eclipse/EclipseState/Runspec.hpp @@ -278,7 +278,6 @@ public: const EclHysterConfig& hysterPar() const noexcept; const Actdims& actdims() const noexcept; const SatFuncControls& saturationFunctionControls() const noexcept; - int nupcol() const noexcept; bool operator==(const Runspec& data) const; @@ -306,7 +305,6 @@ private: EclHysterConfig hystpar; Actdims m_actdims; SatFuncControls m_sfuncctrl; - int m_nupcol; }; diff --git a/ThirdParty/custom-opm-common/opm-common/opm/parser/eclipse/EclipseState/Schedule/Action/ActionContext.hpp b/ThirdParty/custom-opm-common/opm-common/opm/parser/eclipse/EclipseState/Schedule/Action/ActionContext.hpp index 5c6fe11114..039ebfda87 100644 --- a/ThirdParty/custom-opm-common/opm-common/opm/parser/eclipse/EclipseState/Schedule/Action/ActionContext.hpp +++ b/ThirdParty/custom-opm-common/opm-common/opm/parser/eclipse/EclipseState/Schedule/Action/ActionContext.hpp @@ -25,7 +25,6 @@ #include #include -#include namespace Opm { namespace Action { @@ -38,7 +37,7 @@ namespace Action { class Context { public: - explicit Context(const SummaryState& summary_state, const WListManager& wlm); + explicit Context(const SummaryState& summary_state); /* The get methods will first check the internal storage in the 'values' map @@ -51,11 +50,9 @@ public: void add(const std::string& func, double value); std::vector wells(const std::string& func) const; - const WListManager& wlist_manager() const; private: const SummaryState& summary_state; - const WListManager& wlm; std::map values; }; } diff --git a/ThirdParty/custom-opm-common/opm-common/opm/parser/eclipse/EclipseState/Schedule/Action/ActionResult.hpp b/ThirdParty/custom-opm-common/opm-common/opm/parser/eclipse/EclipseState/Schedule/Action/ActionResult.hpp index ba5b33c636..d8a5686927 100644 --- a/ThirdParty/custom-opm-common/opm-common/opm/parser/eclipse/EclipseState/Schedule/Action/ActionResult.hpp +++ b/ThirdParty/custom-opm-common/opm-common/opm/parser/eclipse/EclipseState/Schedule/Action/ActionResult.hpp @@ -101,9 +101,9 @@ public: void add_well(const std::string& well); Result& operator|=(const Result& other); - Result& operator=(const Result& src); + Result& operator=(const Result& src); Result& operator&=(const Result& other); - + private: void assign(bool value); bool result; diff --git a/ThirdParty/custom-opm-common/opm-common/opm/parser/eclipse/EclipseState/Schedule/Action/ActionX.hpp b/ThirdParty/custom-opm-common/opm-common/opm/parser/eclipse/EclipseState/Schedule/Action/ActionX.hpp index 77f9331fc8..0771d5afd6 100644 --- a/ThirdParty/custom-opm-common/opm-common/opm/parser/eclipse/EclipseState/Schedule/Action/ActionX.hpp +++ b/ThirdParty/custom-opm-common/opm-common/opm/parser/eclipse/EclipseState/Schedule/Action/ActionX.hpp @@ -36,7 +36,6 @@ namespace Opm { class DeckKeyword; namespace Action { -class State; /* The ActionX class internalizes the ACTIONX keyword. This keyword represents a @@ -72,15 +71,13 @@ public: static ActionX serializeObject(); void addKeyword(const DeckKeyword& kw); - bool ready(const State& state, std::time_t sim_time) const; - Action::Result eval(const Action::Context& context) const; + bool ready(std::time_t sim_time) const; + Action::Result eval(std::time_t sim_time, const Action::Context& context) const; std::string name() const { return this->m_name; } size_t max_run() const { return this->m_max_run; } double min_wait() const { return this->m_min_wait; } - std::size_t id() const; - void update_id(std::size_t id); std::time_t start_time() const { return this->m_start_time; } std::vector::const_iterator begin() const; std::vector::const_iterator end() const; @@ -102,10 +99,11 @@ public: serializer(m_max_run); serializer(m_min_wait); serializer(m_start_time); - serializer(m_id); serializer.vector(keywords); condition.serializeOp(serializer); serializer.vector(m_conditions); + serializer(run_count); + serializer(last_run); } private: @@ -113,11 +111,12 @@ private: size_t m_max_run = 0; double m_min_wait = 0.0; std::time_t m_start_time; - std::size_t m_id = 0; std::vector keywords; Action::AST condition; std::vector m_conditions; + mutable size_t run_count = 0; + mutable std::time_t last_run = 0; }; } diff --git a/ThirdParty/custom-opm-common/opm-common/opm/parser/eclipse/EclipseState/Schedule/Action/Actions.hpp b/ThirdParty/custom-opm-common/opm-common/opm/parser/eclipse/EclipseState/Schedule/Action/Actions.hpp index c8e4b89f35..5775c982a9 100644 --- a/ThirdParty/custom-opm-common/opm-common/opm/parser/eclipse/EclipseState/Schedule/Action/Actions.hpp +++ b/ThirdParty/custom-opm-common/opm-common/opm/parser/eclipse/EclipseState/Schedule/Action/Actions.hpp @@ -31,8 +31,6 @@ namespace Opm { namespace Action { -class State; - /* The Actions class is a container of ACTIONX keywords. The main functionality is to provide a list of ACTIONX keywords which are ready to be evaluated. @@ -50,10 +48,10 @@ public: bool empty() const; void add(const ActionX& action); void add(const PyAction& pyaction); - bool ready(const State& state, std::time_t sim_time) const; + bool ready(std::time_t sim_time) const; const ActionX& get(const std::string& name) const; const ActionX& get(std::size_t index) const; - std::vector pending(const State& state, std::time_t sim_time) const; + std::vector pending(std::time_t sim_time) const; std::vector pending_python() const; std::vector::const_iterator begin() const; diff --git a/ThirdParty/custom-opm-common/opm-common/opm/parser/eclipse/EclipseState/Schedule/Action/State.hpp b/ThirdParty/custom-opm-common/opm-common/opm/parser/eclipse/EclipseState/Schedule/Action/State.hpp deleted file mode 100644 index b839756a61..0000000000 --- a/ThirdParty/custom-opm-common/opm-common/opm/parser/eclipse/EclipseState/Schedule/Action/State.hpp +++ /dev/null @@ -1,59 +0,0 @@ -/* - Copyright 2020 Equinor ASA. - - This file is part of the Open Porous Media project (OPM). - - OPM is free software: you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - OPM is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with OPM. If not, see . -*/ - -#ifndef ACTION_STATE_HPP -#define ACTION_STATE_HPP - -#include -#include - -namespace Opm { -namespace Action { - -class ActionX; -class State { - -struct RunState { - RunState(std::time_t sim_time) : - run_count(1), - last_run(sim_time) - {} - - void add_run(std::time_t sim_time) { - this->last_run = sim_time; - this->run_count += 1; - } - - - std::size_t run_count; - std::time_t last_run; -}; - -public: - void add_run(const ActionX& action, std::time_t sim_time); - std::size_t run_count(const ActionX& action) const; - std::time_t run_time(const ActionX& action) const; -private: - std::map, RunState> run_state; -}; - - -} -} -#endif diff --git a/ThirdParty/custom-opm-common/opm-common/opm/parser/eclipse/EclipseState/Schedule/GasLiftOpt.hpp b/ThirdParty/custom-opm-common/opm-common/opm/parser/eclipse/EclipseState/Schedule/GasLiftOpt.hpp deleted file mode 100644 index 4c6a00004f..0000000000 --- a/ThirdParty/custom-opm-common/opm-common/opm/parser/eclipse/EclipseState/Schedule/GasLiftOpt.hpp +++ /dev/null @@ -1,253 +0,0 @@ -/* - Copyright 2020 Equinor ASA. - - This file is part of the Open Porous Media project (OPM). - - OPM is free software: you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - OPM is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with OPM. If not, see . -*/ -#ifndef GAS_LIFT_OPT_HPP -#define GAS_LIFT_OPT_HPP - -#include -#include -#include - -namespace Opm { - -class GasLiftOpt { -public: - - class Group { - public: - Group() = default; - - Group(const std::string& name) : - m_name(name) - {} - - const std::optional& max_lift_gas() const { - return this->m_max_lift_gas; - } - - void max_lift_gas(double value) { - if (value >= 0) - this->m_max_lift_gas = value; - } - - const std::optional& max_total_gas() const { - return this->m_max_total_gas; - } - - void max_total_gas(double value) { - if (value >= 0) - this->m_max_total_gas = value; - } - - const std::string& name() const { - return this->m_name; - } - - template - void serializeOp(Serializer& serializer) - { - serializer(m_name); - serializer(m_max_lift_gas); - serializer(m_max_total_gas); - } - - - static Group serializeObject() { - Group group; - group.m_name = "GR"; - group.m_max_lift_gas = 100; - group.m_max_total_gas = 200; - return group; - } - - - bool operator==(const Group& other) const { - return this->m_name == other.m_name && - this->m_max_lift_gas == other.m_max_lift_gas && - this->m_max_total_gas == other.m_max_total_gas; - } - - private: - std::string m_name; - std::optional m_max_lift_gas; - std::optional m_max_total_gas; - }; - - - class Well { - public: - Well() = default; - Well(const std::string& name, bool use_glo) : - m_name(name), - m_use_glo(use_glo) - {} - - const std::string& name() const { - return this->m_name; - } - - bool use_glo() const { - return this->m_use_glo; - } - - void max_rate(double value) { - this->m_max_rate = value; - } - - - /* - The semantics of the max_rate is quite complicated: - - 1. If the std::optional has a value that value should be - used as the maximum rate and all is fine. - - 2. If the std::optional does not a have well we must check - the value of Well::use_glo(): - - False: The maximum gas lift should have been set with WCONPROD / - WELTARG - this code does not provide a value in that case. - - True: If the well should be controlled with gas lift optimization - the value to use should be the largest ALQ value in the wells - VFP table. - */ - const std::optional& max_rate() const { - return this->m_max_rate; - } - - void weight_factor(double value) { - if (this->m_use_glo) - this->m_weight = value; - } - - double weight_factor() const { - return this->m_weight; - } - - void inc_weight_factor(double value) { - if (this->m_use_glo) - this->m_inc_weight = value; - } - - double inc_weight_factor() const { - return this->m_inc_weight; - } - - void min_rate(double value) { - if (this->m_use_glo) - this->m_min_rate = value; - } - - double min_rate() const { - return this->m_min_rate; - } - - void alloc_extra_gas(bool value) { - if (this->m_use_glo) - this->m_alloc_extra_gas = value; - } - - bool alloc_extra_gas() const { - return this->m_alloc_extra_gas; - } - - template - void serializeOp(Serializer& serializer) - { - serializer(m_name); - serializer(m_use_glo); - serializer(m_max_rate); - serializer(m_min_rate); - serializer(m_weight); - serializer(m_inc_weight); - serializer(m_alloc_extra_gas); - } - - static Well serializeObject() { - Well well; - well.m_name = "WELL"; - well.m_max_rate = 2000; - well.m_min_rate = 56; - well.m_use_glo = true; - well.m_weight = 1.25; - well.m_inc_weight = 0.25; - well.m_alloc_extra_gas = false; - return well; - } - - bool operator==(const Well& other) const { - return this->m_name == other.m_name && - this->m_max_rate == other.m_max_rate && - this->m_min_rate == other.m_min_rate && - this->m_use_glo == other.m_use_glo && - this->m_weight == other.m_weight && - this->m_inc_weight == other.m_inc_weight && - this->m_alloc_extra_gas == other.m_alloc_extra_gas; - } - - private: - std::string m_name; - std::optional m_max_rate; - double m_min_rate = 0; - bool m_use_glo; - double m_weight = 1; - double m_inc_weight = 0; - bool m_alloc_extra_gas = false; - }; - - GasLiftOpt() = default; - - const Group& group(const std::string& gname) const; - const Well& well(const std::string& wname) const; - - double gaslift_increment() const; - void gaslift_increment(double gaslift_increment); - double min_eco_gradient() const; - void min_eco_gradient(double min_eco_gradient); - void min_wait(double min_wait); - void all_newton(double all_newton); - void add_group(const Group& group); - void add_well(const Well& well); - bool active() const; - - static GasLiftOpt serializeObject(); - bool operator==(const GasLiftOpt& other) const; - - template - void serializeOp(Serializer& serializer) - { - serializer(m_increment); - serializer(m_min_eco_gradient); - serializer(m_min_wait); - serializer(m_all_newton); - serializer.map(m_groups); - serializer.map(m_wells); - } -private: - double m_increment = 0; - double m_min_eco_gradient; - double m_min_wait; - bool m_all_newton = true; - - std::map m_groups; - std::map m_wells; -}; - -} - -#endif diff --git a/ThirdParty/custom-opm-common/opm-common/opm/parser/eclipse/EclipseState/Schedule/Group/GPMaint.hpp b/ThirdParty/custom-opm-common/opm-common/opm/parser/eclipse/EclipseState/Schedule/Group/GPMaint.hpp deleted file mode 100644 index 0046506c19..0000000000 --- a/ThirdParty/custom-opm-common/opm-common/opm/parser/eclipse/EclipseState/Schedule/Group/GPMaint.hpp +++ /dev/null @@ -1,75 +0,0 @@ -/* - Copyright 2020 Equinor ASA. - - This file is part of the Open Porous Media project (OPM). - - OPM is free software: you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - OPM is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with OPM. If not, see . -*/ - -#ifndef GPMAINT_HPP -#define GPMAINT_HPP - -#include -#include - -namespace Opm { - -class DeckRecord; - -class GPMaint { -public: - -enum class FlowTarget { - RESV_PROD = 0, - RESV_OINJ = 1, - RESV_WINJ = 2, - RESV_GINJ = 3, - SURF_OINJ = 4, - SURF_WINJ = 5, - SURF_GINJ = 6, -}; - - GPMaint() = default; - explicit GPMaint(const DeckRecord& record); - static GPMaint serializeObject(); - - double pressure_target() const; - double prop_constant() const; - double time_constant() const; - std::optional> region() const; - FlowTarget flow_target() const; - bool operator==(const GPMaint& other) const; - template - void serializeOp(Serializer& serializer) - { - serializer(m_flow_target); - serializer(m_region_number); - serializer(m_region_name); - serializer(m_pressure_target); - serializer(m_prop_constant); - serializer(m_time_constant); - } - -private: - static FlowTarget FlowTargetFromString(const std::string& stringvalue); - FlowTarget m_flow_target; - int m_region_number; - std::string m_region_name; - double m_pressure_target; - double m_prop_constant; - double m_time_constant; -}; -} - -#endif diff --git a/ThirdParty/custom-opm-common/opm-common/opm/parser/eclipse/EclipseState/Schedule/Group/GTNode.hpp b/ThirdParty/custom-opm-common/opm-common/opm/parser/eclipse/EclipseState/Schedule/Group/GTNode.hpp index bbf64d8375..4245fafc8f 100644 --- a/ThirdParty/custom-opm-common/opm-common/opm/parser/eclipse/EclipseState/Schedule/Group/GTNode.hpp +++ b/ThirdParty/custom-opm-common/opm-common/opm/parser/eclipse/EclipseState/Schedule/Group/GTNode.hpp @@ -41,8 +41,6 @@ public: const std::string& parent_name() const; const Group& group() const; - std::size_t level() const; - std::vector all_nodes() const; private: const Group m_group; std::size_t m_level; diff --git a/ThirdParty/custom-opm-common/opm-common/opm/parser/eclipse/EclipseState/Schedule/Group/Group.hpp b/ThirdParty/custom-opm-common/opm-common/opm/parser/eclipse/EclipseState/Schedule/Group/Group.hpp index 63299666b5..66102a05f3 100644 --- a/ThirdParty/custom-opm-common/opm-common/opm/parser/eclipse/EclipseState/Schedule/Group/Group.hpp +++ b/ThirdParty/custom-opm-common/opm-common/opm/parser/eclipse/EclipseState/Schedule/Group/Group.hpp @@ -24,19 +24,15 @@ #include #include #include -#include #include #include #include -#include #include namespace Opm { class SummaryState; -class UDQConfig; -class UDQActive; class Group { public: @@ -118,7 +114,7 @@ struct GroupInjectionProperties { UDAValue target_void_fraction; std::string reinj_group; std::string voidage_group; - bool available_group_control = true; + bool available_group_control; static GroupInjectionProperties serializeObject(); @@ -156,12 +152,6 @@ struct InjectionControls { }; struct GroupProductionProperties { - GroupProductionProperties() = default; - GroupProductionProperties(const std::string& gname) : - name(gname) - {} - - std::string name; ProductionCMode cmode = ProductionCMode::NONE; ExceedAction exceed_action = ExceedAction::NONE; UDAValue oil_target; @@ -169,7 +159,7 @@ struct GroupProductionProperties { UDAValue gas_target; UDAValue liquid_target; double guide_rate; - GuideRateTarget guide_rate_def = GuideRateTarget::NO_GUIDE_RATE; + GuideRateTarget guide_rate_def; double resv_target = 0; bool available_group_control = true; static GroupProductionProperties serializeObject(); @@ -177,12 +167,10 @@ struct GroupProductionProperties { int production_controls = 0; bool operator==(const GroupProductionProperties& other) const; bool operator!=(const GroupProductionProperties& other) const; - bool updateUDQActive(const UDQConfig& udq_config, UDQActive& active) const; template void serializeOp(Serializer& serializer) { - serializer(name); serializer(cmode); serializer(exceed_action); oil_target.serializeOp(serializer); @@ -206,7 +194,7 @@ struct ProductionControls { double gas_target; double liquid_target; double guide_rate; - GuideRateTarget guide_rate_def = GuideRateTarget::NO_GUIDE_RATE; + GuideRateTarget guide_rate_def; double resv_target = 0; int production_controls = 0; bool has_control(ProductionCMode control) const; @@ -265,9 +253,6 @@ struct ProductionControls { bool has_control(InjectionCMode control) const; bool productionGroupControlAvailable() const; bool injectionGroupControlAvailable(const Phase phase) const; - const std::optional& gpmaint() const; - void set_gpmaint(GPMaint gpmaint); - void set_gpmaint(); bool operator==(const Group& data) const; const Phase& topup_phase() const; @@ -291,7 +276,6 @@ struct ProductionControls { serializer.map(injection_properties); production_properties.serializeOp(serializer); serializer(m_topup_phase); - serializer(m_gpmaint); } private: @@ -313,9 +297,8 @@ private: IOrderSet m_groups; std::map injection_properties; - GroupProductionProperties production_properties; + GroupProductionProperties production_properties{}; std::pair m_topup_phase{Phase::WATER, false}; - std::optional m_gpmaint; }; Group::GroupType operator |(Group::GroupType lhs, Group::GroupType rhs); diff --git a/ThirdParty/custom-opm-common/opm-common/opm/parser/eclipse/EclipseState/Schedule/MSW/AICD.hpp b/ThirdParty/custom-opm-common/opm-common/opm/parser/eclipse/EclipseState/Schedule/MSW/AICD.hpp deleted file mode 100644 index e3c5bd5d76..0000000000 --- a/ThirdParty/custom-opm-common/opm-common/opm/parser/eclipse/EclipseState/Schedule/MSW/AICD.hpp +++ /dev/null @@ -1,69 +0,0 @@ -/* - Copyright 2020 Equinor ASA. - - This file is part of the Open Porous Media project (OPM). - - OPM is free software: you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - OPM is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with OPM. If not, see . -*/ - -#ifndef AICD_HPP_HEADER_INCLUDED -#define AICD_HPP_HEADER_INCLUDED - -#include -#include -#include -#include - -#include - -namespace Opm { - - class DeckRecord; - class DeckKeyword; - - class AutoICD : public SICD { - public: - AutoICD() = default; - AutoICD(const DeckRecord& record); - - static AutoICD serializeObject(); - - // the function will return a map - // [ - // "WELL1" : [, ...] - // .... - static std::map > > - fromWSEGAICD(const DeckKeyword& wsegaicd); - - bool operator==(const AutoICD& data) const; - - template - void serializeOp(Serializer& serializer) - { - AutoICD::serializeOp(serializer); - } - - private: - double m_flow_rate_exponent; - double m_visc_exponent; - double m_oil_density_exponent; - double m_water_density_exponent; - double m_gas_density_exponent; - double m_oil_viscosity_exponent; - double m_water_viscosity_exponent; - double m_gas_viscosity_exponent; - }; -} - -#endif diff --git a/ThirdParty/custom-opm-common/opm-common/opm/parser/eclipse/EclipseState/Schedule/MSW/Segment.hpp b/ThirdParty/custom-opm-common/opm-common/opm/parser/eclipse/EclipseState/Schedule/MSW/Segment.hpp index ceed817d32..2984371807 100644 --- a/ThirdParty/custom-opm-common/opm-common/opm/parser/eclipse/EclipseState/Schedule/MSW/Segment.hpp +++ b/ThirdParty/custom-opm-common/opm-common/opm/parser/eclipse/EclipseState/Schedule/MSW/Segment.hpp @@ -20,16 +20,13 @@ #ifndef SEGMENT_HPP_HEADER_INCLUDED #define SEGMENT_HPP_HEADER_INCLUDED -#include -#include +#include #include -#include -#include -#include - - namespace Opm { + class SpiralICD; + class Valve; + namespace RestartIO { struct RstSegment; } @@ -37,29 +34,6 @@ namespace Opm { namespace Opm { - /* - The current serialization of std::variant<> requires that all the types in - the variant have serializeOp() method, that is why this RegularSegment - type is introduced, ideally the icd variant should just have - std::monostate to represent the regular non ICD segment. - */ - struct RegularSegment : std::monostate { - - template - void serializeOp(Serializer&) { - } - - static RegularSegment serializeObject() { - return RegularSegment(); - } - - - bool operator==(const RegularSegment& ) { - return true; - } - }; - - class Segment { public: @@ -76,7 +50,7 @@ namespace Opm { Segment(const Segment& src, double new_depth, double new_length); Segment(const Segment& src, double new_volume); Segment(int segment_number_in, int branch_in, int outlet_segment_in, double length_in, double depth_in, - double internal_diameter_in, double roughness_in, double cross_area_in, double volume_in, bool data_ready_in); + double internal_diameter_in, double roughness_in, double cross_area_in, double volume_in, bool data_ready_in, SegmentType segment_type_in); Segment(const RestartIO::RstSegment& rst_segment); static Segment serializeObject(); @@ -84,7 +58,6 @@ namespace Opm { int segmentNumber() const; int branchNumber() const; int outletSegment() const; - double perfLength() const; double totalLength() const; double depth() const; double internalDiameter() const; @@ -105,37 +78,13 @@ namespace Opm { bool operator==( const Segment& ) const; bool operator!=( const Segment& ) const; - const SICD& spiralICD() const; - const AutoICD& autoICD() const; - const Valve& valve() const; + const std::shared_ptr& spiralICD() const; + const Valve* valve() const; - void updatePerfLength(double perf_length); - void updateSpiralICD(const SICD& spiral_icd); - void updateAutoICD(const AutoICD& aicd); + void updateSpiralICD(const SpiralICD& spiral_icd); void updateValve(const Valve& valve, const double segment_length); - void updateValve(const Valve& valve); void addInletSegment(const int segment_number); - bool isRegular() const - { - return std::holds_alternative(this->m_icd); - } - - inline bool isSpiralICD() const - { - return std::holds_alternative(this->m_icd); - } - - inline bool isAICD() const - { - return std::holds_alternative(this->m_icd); - } - - inline bool isValve() const - { - return std::holds_alternative(this->m_icd); - } - template void serializeOp(Serializer& serializer) { @@ -150,12 +99,12 @@ namespace Opm { serializer(m_cross_area); serializer(m_volume); serializer(m_data_ready); - serializer(m_perf_length); - serializer(m_icd); + serializer(m_segment_type); + serializer(m_spiral_icd); + serializer(m_valve); } private: - void updateValve__(Valve& valve, const double segment_length); // segment number // it should work as a ID. int m_segment_number; @@ -201,8 +150,17 @@ namespace Opm { // the volume will be updated at a final step. bool m_data_ready; - std::optional m_perf_length; - std::variant m_icd; + // indicate the type of the segment + // regular, spiral ICD, or Valve. + SegmentType m_segment_type; + + // information related to SpiralICD. It is nullptr for segments are not + // spiral ICD type + std::shared_ptr m_spiral_icd; + + // information related to sub-critical valve. It is nullptr for segments are not + // of type of Valve + std::shared_ptr m_valve; // We are not handling the length of segment projected onto the X-axis and Y-axis. // They are not used in the simulations and we are not supporting the plotting. @@ -210,6 +168,20 @@ namespace Opm { // while they are not supported by the keyword at the moment. }; + inline bool isRegular(const Segment& segment) + { + return segment.segmentType() == Segment::SegmentType::REGULAR; + } + + inline bool isSpiralICD(const Segment& segment) + { + return segment.segmentType() == Segment::SegmentType::SICD; + } + + inline bool isValve(const Segment& segment) + { + return segment.segmentType() == Segment::SegmentType::VALVE; + } } #endif diff --git a/ThirdParty/custom-opm-common/opm-common/opm/parser/eclipse/EclipseState/Schedule/MSW/SICD.hpp b/ThirdParty/custom-opm-common/opm-common/opm/parser/eclipse/EclipseState/Schedule/MSW/SpiralICD.hpp similarity index 68% rename from ThirdParty/custom-opm-common/opm-common/opm/parser/eclipse/EclipseState/Schedule/MSW/SICD.hpp rename to ThirdParty/custom-opm-common/opm-common/opm/parser/eclipse/EclipseState/Schedule/MSW/SpiralICD.hpp index 75c3bc9299..5f414aef24 100644 --- a/ThirdParty/custom-opm-common/opm-common/opm/parser/eclipse/EclipseState/Schedule/MSW/SICD.hpp +++ b/ThirdParty/custom-opm-common/opm-common/opm/parser/eclipse/EclipseState/Schedule/MSW/SpiralICD.hpp @@ -27,17 +27,18 @@ #include #include -#include -#include namespace Opm { - class SICD { + class DeckRecord; + class DeckKeyword; + + class SpiralICD { public: - SICD(); - explicit SICD(const DeckRecord& record); - SICD(double strength, + SpiralICD(); + explicit SpiralICD(const DeckRecord& record); + SpiralICD(double strength, double length, double densityCalibration, double viscosityCalibration, @@ -49,13 +50,13 @@ namespace Opm { ICDStatus status, double scalingFactor); - static SICD serializeObject(); + static SpiralICD serializeObject(); // the function will return a map // [ // "WELL1" : [, ...] // .... - static std::map > > + static std::map > > fromWSEGSICD(const DeckKeyword& wsegsicd); double maxAbsoluteRate() const; @@ -72,7 +73,7 @@ namespace Opm { void updateScalingFactor(const double segment_length, const double completion_length); double scalingFactor() const; int ecl_status() const; - bool operator==(const SICD& data) const; + bool operator==(const SpiralICD& data) const; template void serializeOp(Serializer& serializer) @@ -90,33 +91,6 @@ namespace Opm { serializer(m_scaling_factor); } - template - static std::map > > - fromWSEG(const DeckKeyword& wseg) { - std::map > > res; - - for (const DeckRecord &record : wseg) { - const std::string well_name = record.getItem("WELL").getTrimmedString(0); - - const int start_segment = record.getItem("SEG1").get(0); - const int end_segment = record.getItem("SEG2").get(0); - - if (start_segment < 2 || end_segment < 2 || end_segment < start_segment) { - const std::string message = "Segment numbers " + std::to_string(start_segment) + " and " - + std::to_string(end_segment) + " specified in WSEGSICD for well " + - well_name - + " are illegal "; - throw std::invalid_argument(message); - } - - const ICD spiral_icd(record); - for (int seg = start_segment; seg <= end_segment; seg++) { - res[well_name].push_back(std::make_pair(seg, spiral_icd)); - } - } - return res; - } - private: double m_strength; double m_length; diff --git a/ThirdParty/custom-opm-common/opm-common/opm/parser/eclipse/EclipseState/Schedule/MSW/WellSegments.hpp b/ThirdParty/custom-opm-common/opm-common/opm/parser/eclipse/EclipseState/Schedule/MSW/WellSegments.hpp index 0180dd747a..ff075ddc55 100644 --- a/ThirdParty/custom-opm-common/opm-common/opm/parser/eclipse/EclipseState/Schedule/MSW/WellSegments.hpp +++ b/ThirdParty/custom-opm-common/opm-common/opm/parser/eclipse/EclipseState/Schedule/MSW/WellSegments.hpp @@ -20,16 +20,14 @@ #ifndef SEGMENTSET_HPP_HEADER_INCLUDED #define SEGMENTSET_HPP_HEADER_INCLUDED -#include -#include #include +#include #include namespace Opm { - class SICD; + class SpiralICD; class Valve; - class WellConnections; } namespace Opm { @@ -86,7 +84,6 @@ namespace Opm { const Segment& operator[](size_t idx) const; void orderSegments(); - void updatePerfLength(const WellConnections& connections); bool operator==( const WellSegments& ) const; bool operator!=( const WellSegments& ) const; @@ -94,10 +91,9 @@ namespace Opm { double segmentLength(const int segment_number) const; double segmentDepthChange(const int segment_number) const; std::vector branchSegments(int branch) const; - std::set branches() const; // it returns true if there is no error encountered during the update - bool updateWSEGSICD(const std::vector >& sicd_pairs); + bool updateWSEGSICD(const std::vector >& sicd_pairs); bool updateWSEGVALV(const std::vector >& valve_pairs); const std::vector::const_iterator begin() const; diff --git a/ThirdParty/custom-opm-common/opm-common/opm/parser/eclipse/EclipseState/Schedule/MSW/icd.hpp b/ThirdParty/custom-opm-common/opm-common/opm/parser/eclipse/EclipseState/Schedule/MSW/icd.hpp index 484b07218b..cca81a2b25 100644 --- a/ThirdParty/custom-opm-common/opm-common/opm/parser/eclipse/EclipseState/Schedule/MSW/icd.hpp +++ b/ThirdParty/custom-opm-common/opm-common/opm/parser/eclipse/EclipseState/Schedule/MSW/icd.hpp @@ -28,6 +28,13 @@ enum class ICDStatus { SHUT }; +template +T from_int(int int_status); + +template +int to_int(T status); + } + #endif diff --git a/ThirdParty/custom-opm-common/opm-common/opm/parser/eclipse/EclipseState/Schedule/MSW/updatingConnectionsWithSegments.hpp b/ThirdParty/custom-opm-common/opm-common/opm/parser/eclipse/EclipseState/Schedule/MSW/updatingConnectionsWithSegments.hpp new file mode 100644 index 0000000000..c9c4d6df52 --- /dev/null +++ b/ThirdParty/custom-opm-common/opm-common/opm/parser/eclipse/EclipseState/Schedule/MSW/updatingConnectionsWithSegments.hpp @@ -0,0 +1,35 @@ +/* + Copyright 2017 SINTEF Digital, Mathematics and Cybernetics. + + This file is part of the Open Porous Media project (OPM). + + OPM is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + OPM is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with OPM. If not, see . +*/ + +#ifndef UPDATING_CONNECTIONS_WITH_SEGMENTS +#define UPDATING_CONNECTIONS_WITH_SEGMENTS + +#include + +#include +#include +#include + +namespace Opm { + WellConnections * newConnectionsWithSegments(const DeckKeyword& compsegs, const WellConnections& input_connections, + const WellSegments& segments, const EclipseGrid& grid, + const ParseContext& parseContext, ErrorGuard& errors); +} + +#endif diff --git a/ThirdParty/custom-opm-common/opm-common/opm/parser/eclipse/EclipseState/Schedule/Network/Branch.hpp b/ThirdParty/custom-opm-common/opm-common/opm/parser/eclipse/EclipseState/Schedule/Network/Branch.hpp deleted file mode 100644 index 6e88ec434f..0000000000 --- a/ThirdParty/custom-opm-common/opm-common/opm/parser/eclipse/EclipseState/Schedule/Network/Branch.hpp +++ /dev/null @@ -1,74 +0,0 @@ -/* - Copyright 2020 Equinor ASA. - - This file is part of the Open Porous Media project (OPM). - - OPM is free software: you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - OPM is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with OPM. If not, see . -*/ - - -#ifndef NETWORK_BRANCH_HPP -#define NETWORK_BRANCH_HPP - -#include -#include - -namespace Opm { -namespace Network { - -class Branch { -public: - - enum class AlqEQ { - OIL_DENSITY, - GAS_DENSITY, - ALQ_INPUT - }; - - - static AlqEQ AlqEqfromString(const std::string& input_string); - - Branch() = default; - Branch(const std::string& downtree_node, const std::string& uptree_node, int vfp_table, double alq); - Branch(const std::string& downtree_node, const std::string& uptree_node, int vfp_table, AlqEQ alq_eq); - - const std::string& downtree_node() const; - const std::string& uptree_node() const; - std::optional vfp_table() const; - AlqEQ alq_eq() const; - std::optional alq_value() const; - - static Branch serializeObject(); - bool operator==(const Branch& other) const; - - template - void serializeOp(Serializer& serializer) - { - serializer(m_downtree_node); - serializer(m_uptree_node); - serializer(m_vfp_table); - serializer(m_alq_value); - serializer(m_alq_eq); - } -private: - std::string m_downtree_node; - std::string m_uptree_node; - int m_vfp_table; - std::optional m_alq_value; - AlqEQ m_alq_eq; -}; - -} -} -#endif diff --git a/ThirdParty/custom-opm-common/opm-common/opm/parser/eclipse/EclipseState/Schedule/Network/ExtNetwork.hpp b/ThirdParty/custom-opm-common/opm-common/opm/parser/eclipse/EclipseState/Schedule/Network/ExtNetwork.hpp deleted file mode 100644 index ad11ce05f8..0000000000 --- a/ThirdParty/custom-opm-common/opm-common/opm/parser/eclipse/EclipseState/Schedule/Network/ExtNetwork.hpp +++ /dev/null @@ -1,67 +0,0 @@ -/* - Copyright 2020 Equinor ASA. - - This file is part of the Open Porous Media project (OPM). - - OPM is free software: you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - OPM is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with OPM. If not, see . -*/ - - -#ifndef EXT_NETWORK_HPP -#define EXT_NETWORK_HPP - -#include -#include -#include -#include - -#include -#include - -namespace Opm { -namespace Network { - - -class ExtNetwork { -public: - ExtNetwork() = default; - bool active() const; - bool has_node(const std::string& name) const; - void add_node(Node node); - void add_branch(Branch branch); - void drop_branch(const std::string& uptree_node, const std::string& downtree_node); - const Node& node(const std::string& name) const; - const Node& root() const; - std::vector downtree_branches(const std::string& node) const; - std::optional uptree_branch(const std::string& node) const; - - - bool operator==(const ExtNetwork& other) const; - static ExtNetwork serializeObject(); - - template - void serializeOp(Serializer& serializer) - { - serializer.vector(m_branches); - serializer.map(m_nodes); - } - -private: - std::vector m_branches; - std::map m_nodes; -}; - -} -} -#endif diff --git a/ThirdParty/custom-opm-common/opm-common/opm/parser/eclipse/EclipseState/Schedule/Network/Node.hpp b/ThirdParty/custom-opm-common/opm-common/opm/parser/eclipse/EclipseState/Schedule/Network/Node.hpp deleted file mode 100644 index 90deb1e65f..0000000000 --- a/ThirdParty/custom-opm-common/opm-common/opm/parser/eclipse/EclipseState/Schedule/Network/Node.hpp +++ /dev/null @@ -1,64 +0,0 @@ -/* - Copyright 2020 Equinor ASA. - - This file is part of the Open Porous Media project (OPM). - - OPM is free software: you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - OPM is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with OPM. If not, see . -*/ - - -#ifndef NETWORK_NODE_HPP -#define NETWORK_NODE_HPP - -#include -#include - -namespace Opm { -namespace Network { - -class Node { -public: - Node() = default; - Node(const std::string& name); - - const std::string& name() const; - const std::optional& terminal_pressure() const; - bool as_choke() const; - bool add_gas_lift_gas() const; - const std::optional& target_group() const; - - void terminal_pressure(double pressure); - void add_gas_lift_gas(bool add_gas); - void as_choke(const std::string& target_group); - - static Node serializeObject(); - bool operator==(const Node& other) const; - - template - void serializeOp(Serializer& serializer) - { - serializer(m_name); - serializer(m_terminal_pressure); - serializer(m_add_gas_lift_gas); - serializer(m_choke_target_group); - } -private: - std::string m_name; - std::optional m_terminal_pressure; - std::optional m_choke_target_group; - bool m_add_gas_lift_gas = false; -}; -} -} -#endif diff --git a/ThirdParty/custom-opm-common/opm-common/opm/parser/eclipse/EclipseState/Schedule/Schedule.hpp b/ThirdParty/custom-opm-common/opm-common/opm/parser/eclipse/EclipseState/Schedule/Schedule.hpp index af5c8e5da7..0d6658be16 100644 --- a/ThirdParty/custom-opm-common/opm-common/opm/parser/eclipse/EclipseState/Schedule/Schedule.hpp +++ b/ThirdParty/custom-opm-common/opm-common/opm/parser/eclipse/EclipseState/Schedule/Schedule.hpp @@ -24,7 +24,6 @@ #include #include -#include #include #include #include @@ -41,7 +40,6 @@ #include #include #include -#include #include #include #include @@ -202,16 +200,6 @@ namespace Opm std::vector groupNames(size_t timeStep) const; std::vector groupNames(const std::string& pattern) const; std::vector groupNames() const; - /* - The restart_groups function returns a vector of groups pointers which - is organized as follows: - - 1. The number of elements is WELLDIMS::MAXGROUPS + 1 - 2. The elements are sorted according to group.insert_index(). - 3. If there are less than WELLDIMS::MAXGROUPS nullptr is used. - 4. The very last element corresponds to the FIELD group. - */ - std::vector restart_groups(size_t timeStep) const; void updateWell(std::shared_ptr well, size_t reportStep); std::vector changed_wells(size_t reportStep) const; @@ -275,10 +263,6 @@ namespace Opm void applyAction(size_t reportStep, const Action::ActionX& action, const Action::Result& result); int getNupcol(size_t reportStep) const; - - const Network::ExtNetwork& network(std::size_t report_step) const; - const GasLiftOpt& glo(std::size_t report_step) const; - bool operator==(const Schedule& data) const; std::shared_ptr python() const; @@ -321,8 +305,6 @@ namespace Opm gconsump.serializeOp(serializer); global_whistctl_mode.template serializeOp(serializer); m_actions.serializeOp(serializer); - m_network.serializeOp(serializer); - m_glo.serializeOp(serializer); rft_config.serializeOp(serializer); m_nupcol.template serializeOp(serializer); restart_config.serializeOp(serializer); @@ -358,8 +340,6 @@ namespace Opm DynamicState> gconsump; DynamicState global_whistctl_mode; DynamicState> m_actions; - DynamicState> m_network; - DynamicState> m_glo; RFTConfig rft_config; DynamicState m_nupcol; RestartConfig restart_config; @@ -387,8 +367,6 @@ namespace Opm const UnitSystem& unit_system); DynamicState> rpt_config; - void updateNetwork(std::shared_ptr network, std::size_t report_step); - GTNode groupTree(const std::string& root_node, std::size_t report_step, std::size_t level, const std::optional& parent_name) const; void updateGroup(std::shared_ptr group, size_t reportStep); bool checkGroups(const ParseContext& parseContext, ErrorGuard& errors); @@ -440,15 +418,9 @@ namespace Opm void handleLINCOM( const DeckKeyword& keyword, size_t currentStep); void handleWEFAC( const DeckKeyword& keyword, size_t currentStep, const ParseContext& parseContext, ErrorGuard& errors); - void handleBRANPROP( const DeckKeyword& keyword, size_t currentStep); - void handleNODEPROP( const DeckKeyword& keyword, size_t currentStep); - void handleLIFTOPT(const DeckKeyword& keyword, std::size_t currentStep); - void handleGLIFTOPT(const DeckKeyword& keyword, std::size_t currentStep, const ParseContext& parseContext, ErrorGuard& errors); - void handleWLIFTOPT(const DeckKeyword& keyword, std::size_t currentStep, const ParseContext& parseContext, ErrorGuard& errors); void handleTUNING( const DeckKeyword& keyword, size_t currentStep); void handlePYACTION( std::shared_ptr python, const std::string& input_path, const DeckKeyword& keyword, size_t currentStep); void handleNUPCOL( const DeckKeyword& keyword, size_t currentStep); - void handleGPMAINT( const DeckKeyword& keyword, size_t currentStep, const ParseContext& parseContext, ErrorGuard& errors); void handleGRUPTREE( const DeckKeyword& keyword, size_t currentStep, const UnitSystem& unit_system, const ParseContext& parseContext, ErrorGuard& errors); void handleGRUPNET( const DeckKeyword& keyword, size_t currentStep, const UnitSystem& unit_system); void handleWRFT( const DeckKeyword& keyword, size_t currentStep); diff --git a/ThirdParty/custom-opm-common/opm-common/opm/parser/eclipse/EclipseState/Schedule/SummaryState.hpp b/ThirdParty/custom-opm-common/opm-common/opm/parser/eclipse/EclipseState/Schedule/SummaryState.hpp index 1b53f488ef..90e93eb4f4 100644 --- a/ThirdParty/custom-opm-common/opm-common/opm/parser/eclipse/EclipseState/Schedule/SummaryState.hpp +++ b/ThirdParty/custom-opm-common/opm-common/opm/parser/eclipse/EclipseState/Schedule/SummaryState.hpp @@ -20,13 +20,12 @@ #ifndef SUMMARY_STATE_H #define SUMMARY_STATE_H -#include -#include -#include #include +#include +#include #include #include -#include +#include namespace Opm{ @@ -63,8 +62,6 @@ namespace Opm{ st.has_well_var("OPY", "WGOR") => False */ -class UDQSet; - class SummaryState { public: typedef std::unordered_map::const_iterator const_iterator; @@ -76,10 +73,6 @@ public: */ void set(const std::string& key, double value); - bool erase(const std::string& key); - bool erase_well_var(const std::string& well, const std::string& var); - bool erase_group_var(const std::string& group, const std::string& var); - bool has(const std::string& key) const; bool has_well_var(const std::string& well, const std::string& var) const; bool has_group_var(const std::string& group, const std::string& var) const; @@ -88,19 +81,15 @@ public: void update_well_var(const std::string& well, const std::string& var, double value); void update_group_var(const std::string& group, const std::string& var, double value); void update_elapsed(double delta); - void update_udq(const UDQSet& udq_set); double get(const std::string&) const; - double get(const std::string&, double) const; double get_elapsed() const; double get_well_var(const std::string& well, const std::string& var) const; double get_group_var(const std::string& group, const std::string& var) const; - double get_well_var(const std::string& well, const std::string& var, double) const; - double get_group_var(const std::string& group, const std::string& var, double) const; - const std::vector& wells() const; + std::vector wells() const; std::vector wells(const std::string& var) const; - const std::vector& groups() const; + std::vector groups() const; std::vector groups(const std::string& var) const; std::vector serialize() const; void deserialize(const std::vector& buffer); @@ -116,12 +105,10 @@ private: // The first key is the variable and the second key is the well. std::unordered_map> well_values; std::unordered_set m_wells; - mutable std::optional> well_names; // The first key is the variable and the second key is the group. std::unordered_map> group_values; std::unordered_set m_groups; - mutable std::optional> group_names; }; diff --git a/ThirdParty/custom-opm-common/opm-common/opm/parser/eclipse/EclipseState/Schedule/UDQ/UDQActive.hpp b/ThirdParty/custom-opm-common/opm-common/opm/parser/eclipse/EclipseState/Schedule/UDQ/UDQActive.hpp index e2225f7aaf..a06cd743a1 100644 --- a/ThirdParty/custom-opm-common/opm-common/opm/parser/eclipse/EclipseState/Schedule/UDQ/UDQActive.hpp +++ b/ThirdParty/custom-opm-common/opm-common/opm/parser/eclipse/EclipseState/Schedule/UDQ/UDQActive.hpp @@ -48,10 +48,10 @@ public: udq(udq_arg), input_index(input_index_arg), use_index(use_index_arg), + wgname(wgname_arg), control(control_arg), uad_code(UDQ::uadCode(control_arg)), - use_count(1), - wgname(wgname_arg) + use_count(1) {} bool operator==(const Record& other) const { @@ -85,16 +85,12 @@ public: std::string udq; std::size_t input_index; std::size_t use_index = 0; + std::string wgname; UDAControl control; int uad_code; - std::string wg_name() const; std::size_t use_count; - private: - // The wgname is need in the update process, but it should - // not be exported out. - std::string wgname; }; - + class InputRecord { public: InputRecord() : diff --git a/ThirdParty/custom-opm-common/opm-common/opm/parser/eclipse/EclipseState/Schedule/UDQ/UDQConfig.hpp b/ThirdParty/custom-opm-common/opm-common/opm/parser/eclipse/EclipseState/Schedule/UDQ/UDQConfig.hpp index 9ec22096c5..ed76b434ba 100644 --- a/ThirdParty/custom-opm-common/opm-common/opm/parser/eclipse/EclipseState/Schedule/UDQ/UDQConfig.hpp +++ b/ThirdParty/custom-opm-common/opm-common/opm/parser/eclipse/EclipseState/Schedule/UDQ/UDQConfig.hpp @@ -38,7 +38,6 @@ namespace Opm { class DeckRecord; class Deck; - class SummaryState; class UDQConfig { public: UDQConfig() = default; @@ -56,7 +55,6 @@ namespace Opm { void add_assign(const std::string& quantity, const std::vector& selector, double value); void add_define(const std::string& quantity, const std::vector& expression); - void eval(SummaryState& st) const; std::vector definitions() const; std::vector definitions(UDQVarType var_type) const; std::vector input() const; diff --git a/ThirdParty/custom-opm-common/opm-common/opm/parser/eclipse/EclipseState/Schedule/UDQ/UDQEnums.hpp b/ThirdParty/custom-opm-common/opm-common/opm/parser/eclipse/EclipseState/Schedule/UDQ/UDQEnums.hpp index 66767c3a5a..45887544bf 100644 --- a/ThirdParty/custom-opm-common/opm-common/opm/parser/eclipse/EclipseState/Schedule/UDQ/UDQEnums.hpp +++ b/ThirdParty/custom-opm-common/opm-common/opm/parser/eclipse/EclipseState/Schedule/UDQ/UDQEnums.hpp @@ -179,8 +179,6 @@ namespace UDQ { std::string typeName(UDQVarType var_type); UDAKeyword keyword(UDAControl control); int uadCode(UDAControl control); - - constexpr double restart_default = -0.3E+21; } } diff --git a/ThirdParty/custom-opm-common/opm-common/opm/parser/eclipse/EclipseState/Schedule/UDQ/UDQSet.hpp b/ThirdParty/custom-opm-common/opm-common/opm/parser/eclipse/EclipseState/Schedule/UDQ/UDQSet.hpp index bd407208be..88e8e4590d 100644 --- a/ThirdParty/custom-opm-common/opm-common/opm/parser/eclipse/EclipseState/Schedule/UDQ/UDQSet.hpp +++ b/ThirdParty/custom-opm-common/opm-common/opm/parser/eclipse/EclipseState/Schedule/UDQ/UDQSet.hpp @@ -95,7 +95,6 @@ public: std::vector defined_values() const; std::size_t defined_size() const; const std::string& name() const; - void name(const std::string& name); UDQVarType var_type() const; private: UDQSet() = default; diff --git a/ThirdParty/custom-opm-common/opm-common/opm/parser/eclipse/EclipseState/Schedule/VFPInjTable.hpp b/ThirdParty/custom-opm-common/opm-common/opm/parser/eclipse/EclipseState/Schedule/VFPInjTable.hpp index 7d4615d309..2b17eec4ab 100644 --- a/ThirdParty/custom-opm-common/opm-common/opm/parser/eclipse/EclipseState/Schedule/VFPInjTable.hpp +++ b/ThirdParty/custom-opm-common/opm-common/opm/parser/eclipse/EclipseState/Schedule/VFPInjTable.hpp @@ -24,7 +24,6 @@ #include #include -#include namespace Opm { diff --git a/ThirdParty/custom-opm-common/opm-common/opm/parser/eclipse/EclipseState/Schedule/Well/Connection.hpp b/ThirdParty/custom-opm-common/opm-common/opm/parser/eclipse/EclipseState/Schedule/Well/Connection.hpp index 4fd991fbdd..157fb94fc0 100644 --- a/ThirdParty/custom-opm-common/opm-common/opm/parser/eclipse/EclipseState/Schedule/Well/Connection.hpp +++ b/ThirdParty/custom-opm-common/opm-common/opm/parser/eclipse/EclipseState/Schedule/Well/Connection.hpp @@ -27,7 +27,6 @@ #include #include #include -#include #include #include @@ -95,6 +94,8 @@ namespace RestartIO { const Direction direction, const CTFKind ctf_kind, const std::size_t sort_value, + const double segDistStart, + const double segDistEnd, const bool defaultSatTabId); Connection(const RestartIO::RstConnection& rst_connection, const EclipseGrid& grid, const FieldPropsManager& fp); @@ -128,11 +129,13 @@ namespace RestartIO { void updateSegment(int segment_number_arg, double center_depth_arg, std::size_t compseg_insert_index, - const std::pair& perf_range); + double start, + double end); std::size_t sort_value() const; const bool& getDefaultSatTabId() const; void setDefaultSatTabId(bool id); - const std::optional>& perf_range() const; + const double& getSegDistStart() const; + const double& getSegDistEnd() const; std::string str() const; bool ctfAssignedFromInput() const { @@ -159,7 +162,8 @@ namespace RestartIO { serializer(m_global_index); serializer(m_ctfkind); serializer(m_sort_value); - serializer(m_perf_range); + serializer(m_segDistStart); + serializer(m_segDistEnd); serializer(m_defaultSatTabId); serializer(segment_number); } @@ -232,7 +236,8 @@ namespace RestartIO { */ std::size_t m_sort_value; - std::optional> m_perf_range; + double m_segDistStart; + double m_segDistEnd; bool m_defaultSatTabId; // related segment number diff --git a/ThirdParty/custom-opm-common/opm-common/opm/parser/eclipse/EclipseState/Schedule/Well/WList.hpp b/ThirdParty/custom-opm-common/opm-common/opm/parser/eclipse/EclipseState/Schedule/Well/WList.hpp index 6b05d192f3..e075b9c9a5 100644 --- a/ThirdParty/custom-opm-common/opm-common/opm/parser/eclipse/EclipseState/Schedule/Well/WList.hpp +++ b/ThirdParty/custom-opm-common/opm-common/opm/parser/eclipse/EclipseState/Schedule/Well/WList.hpp @@ -16,9 +16,6 @@ You should have received a copy of the GNU General Public License along with OPM. If not, see . */ -#ifndef WLIST_HPP -#define WLIST_HPP - #include #include #include @@ -54,5 +51,3 @@ private: }; } - -#endif diff --git a/ThirdParty/custom-opm-common/opm-common/opm/parser/eclipse/EclipseState/Schedule/Well/WListManager.hpp b/ThirdParty/custom-opm-common/opm-common/opm/parser/eclipse/EclipseState/Schedule/Well/WListManager.hpp index aa759f340b..e5b918d776 100644 --- a/ThirdParty/custom-opm-common/opm-common/opm/parser/eclipse/EclipseState/Schedule/Well/WListManager.hpp +++ b/ThirdParty/custom-opm-common/opm-common/opm/parser/eclipse/EclipseState/Schedule/Well/WListManager.hpp @@ -16,9 +16,6 @@ You should have received a copy of the GNU General Public License along with OPM. If not, see . */ -#ifndef WLISTMANAGER_HPP -#define WLISTMANAGER_HPP - #include #include #include @@ -41,7 +38,7 @@ public: void delWell(const std::string& well); bool operator==(const WListManager& data) const; - std::vector wells(const std::string& wlist_pattern) const; + template void serializeOp(Serializer& serializer) { @@ -53,4 +50,3 @@ private: }; } -#endif diff --git a/ThirdParty/custom-opm-common/opm-common/opm/parser/eclipse/EclipseState/Schedule/Well/Well.hpp b/ThirdParty/custom-opm-common/opm-common/opm/parser/eclipse/EclipseState/Schedule/Well/Well.hpp index 1e076d8e49..1f9e76c7ed 100644 --- a/ThirdParty/custom-opm-common/opm-common/opm/parser/eclipse/EclipseState/Schedule/Well/Well.hpp +++ b/ThirdParty/custom-opm-common/opm-common/opm/parser/eclipse/EclipseState/Schedule/Well/Well.hpp @@ -49,7 +49,6 @@ struct WellInjectionProperties; class WellProductionProperties; class UDQActive; class UDQConfig; -class SICD; namespace RestartIO { struct RstWell; @@ -251,7 +250,7 @@ public: static WellInjectionProperties serializeObject(); - void handleWELTARG(WELTARGCMode cmode, const UDAValue& new_arg, double SIFactorP); + void handleWELTARG(WELTARGCMode cmode, double newValue, double SIFactorP); void handleWCONINJE(const DeckRecord& record, bool availableForGroupControl, const std::string& well_name); void handleWCONINJH(const DeckRecord& record, bool is_producer, const std::string& well_name); bool hasInjectionControl(InjectorCMode controlModeArg) const { @@ -382,7 +381,7 @@ public: static bool effectiveHistoryProductionControl(ProducerCMode cmode); void handleWCONPROD( const std::string& well, const DeckRecord& record); void handleWCONHIST( const DeckRecord& record); - void handleWELTARG( WELTARGCMode cmode, const UDAValue& new_arg, double SiFactorP); + void handleWELTARG( WELTARGCMode cmode, double newValue, double SiFactorP); void resetDefaultBHPLimit(); void clearControls(); ProductionControls controls(const SummaryState& st, double udq_default) const; @@ -539,7 +538,7 @@ public: bool updateEconLimits(std::shared_ptr econ_limits); bool updateProduction(std::shared_ptr production); bool updateInjection(std::shared_ptr injection); - bool updateWSEGSICD(const std::vector >& sicd_pairs); + bool updateWSEGSICD(const std::vector >& sicd_pairs); bool updateWSEGVALV(const std::vector >& valve_pairs); bool handleWELSEGS(const DeckKeyword& keyword); diff --git a/ThirdParty/custom-opm-common/opm-common/opm/parser/eclipse/EclipseState/Schedule/Well/WellConnections.hpp b/ThirdParty/custom-opm-common/opm-common/opm/parser/eclipse/EclipseState/Schedule/Well/WellConnections.hpp index dd348ef1e1..9c10d8c1e9 100644 --- a/ThirdParty/custom-opm-common/opm-common/opm/parser/eclipse/EclipseState/Schedule/Well/WellConnections.hpp +++ b/ThirdParty/custom-opm-common/opm-common/opm/parser/eclipse/EclipseState/Schedule/Well/WellConnections.hpp @@ -54,6 +54,8 @@ namespace Opm { const Connection::Direction direction = Connection::Direction::Z, const Connection::CTFKind ctf_kind = Connection::CTFKind::DeckValue, const std::size_t seqIndex = 0, + const double segDistStart= 0.0, + const double segDistEnd= 0.0, const bool defaultSatTabId = true); void loadCOMPDAT(const DeckRecord& record, const EclipseGrid& grid, const FieldPropsManager& field_properties); @@ -66,7 +68,6 @@ namespace Opm { const Connection& getFromIJK(const int i, const int j, const int k) const; const Connection& lowest() const; Connection& getFromIJK(const int i, const int j, const int k); - double segment_perf_length(int segment) const; const_iterator begin() const { return this->m_connections.begin(); } const_iterator end() const { return this->m_connections.end(); } @@ -116,6 +117,8 @@ namespace Opm { const Connection::Direction direction = Connection::Direction::Z, const Connection::CTFKind ctf_kind = Connection::CTFKind::DeckValue, const std::size_t seqIndex = 0, + const double segDistStart= 0.0, + const double segDistEnd= 0.0, const bool defaultSatTabId = true); void loadCOMPDAT(const DeckRecord& record, diff --git a/ThirdParty/custom-opm-common/opm-common/opm/parser/eclipse/EclipseState/Tables/PermfactTable.hpp b/ThirdParty/custom-opm-common/opm-common/opm/parser/eclipse/EclipseState/Tables/PermfactTable.hpp deleted file mode 100644 index 3ac9f64164..0000000000 --- a/ThirdParty/custom-opm-common/opm-common/opm/parser/eclipse/EclipseState/Tables/PermfactTable.hpp +++ /dev/null @@ -1,38 +0,0 @@ -/* - Copyright (C) 2020 by Equinor. - Copyright (C) 2020 by TNO. - - This file is part of the Open Porous Media project (OPM). - - OPM is free software: you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - OPM is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with OPM. If not, see . - */ -#ifndef OPM_PARSER_PERMFACT_TABLE_HPP -#define OPM_PARSER_PERMFACT_TABLE_HPP - -#include "SimpleTable.hpp" - -namespace Opm { - - class DeckItem; - - class PermfactTable : public SimpleTable { - public: - PermfactTable( const DeckItem& item ); - - const TableColumn& getPorosityChangeColumn() const; - const TableColumn& getPermeabilityMultiplierColumn() const; - }; -} - -#endif diff --git a/ThirdParty/custom-opm-common/opm-common/opm/parser/eclipse/EclipseState/Tables/PvtgwTable.hpp b/ThirdParty/custom-opm-common/opm-common/opm/parser/eclipse/EclipseState/Tables/PvtgwTable.hpp deleted file mode 100644 index c4da8a7d90..0000000000 --- a/ThirdParty/custom-opm-common/opm-common/opm/parser/eclipse/EclipseState/Tables/PvtgwTable.hpp +++ /dev/null @@ -1,40 +0,0 @@ -/* - Copyright (C) 2020 by Equinor - Copyright (C) 2020 by TNO - - This file is part of the Open Porous Media project (OPM). - - OPM is free software: you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - OPM is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with OPM. If not, see . - */ -#ifndef OPM_PARSER_PVTGW_TABLE_HPP -#define OPM_PARSER_PVTGW_TABLE_HPP - -#include - -namespace Opm { - - class DeckKeyword; - - class PvtgwTable : public PvtxTable { - public: - PvtgwTable() = default; - PvtgwTable( const DeckKeyword& keyword, size_t tableIdx); - - static PvtgwTable serializeObject(); - - bool operator==(const PvtgwTable& data) const; - }; -} - -#endif diff --git a/ThirdParty/custom-opm-common/opm-common/opm/parser/eclipse/EclipseState/Tables/PvtgwoTable.hpp b/ThirdParty/custom-opm-common/opm-common/opm/parser/eclipse/EclipseState/Tables/PvtgwoTable.hpp deleted file mode 100644 index 50ae4373d8..0000000000 --- a/ThirdParty/custom-opm-common/opm-common/opm/parser/eclipse/EclipseState/Tables/PvtgwoTable.hpp +++ /dev/null @@ -1,40 +0,0 @@ -/* - Copyright (C) 2020 by Equinor - Copyright (C) 2020 by TNO - - This file is part of the Open Porous Media project (OPM). - - OPM is free software: you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - OPM is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with OPM. If not, see . - */ -#ifndef OPM_PARSER_PVTGWO_TABLE_HPP -#define OPM_PARSER_PVTGWO_TABLE_HPP - -#include - -namespace Opm { - - class DeckKeyword; - - class PvtgwoTable : public PvtxTable { - public: - PvtgwoTable() = default; - PvtgwoTable( const DeckKeyword& keyword, size_t tableIdx); - - static PvtgwoTable serializeObject(); - - bool operator==(const PvtgwoTable& data) const; - }; -} - -#endif diff --git a/ThirdParty/custom-opm-common/opm-common/opm/parser/eclipse/EclipseState/Tables/RwgsaltTable.hpp b/ThirdParty/custom-opm-common/opm-common/opm/parser/eclipse/EclipseState/Tables/RwgsaltTable.hpp deleted file mode 100644 index 40b387f5e5..0000000000 --- a/ThirdParty/custom-opm-common/opm-common/opm/parser/eclipse/EclipseState/Tables/RwgsaltTable.hpp +++ /dev/null @@ -1,58 +0,0 @@ -/* - Copyright (C) 2020 by Equinor - Copyright (C) 2020 by TNO - - This file is part of the Open Porous Media project (OPM). - - OPM is free software: you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - OPM is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with OPM. If not, see . - */ -#ifndef OPM_PARSER_RWGSALT_TABLE_HPP -#define OPM_PARSER_RWGSALT_TABLE_HPP - -#include - -namespace Opm { - - class DeckKeyword; - - class RwgsaltTable { - public: - RwgsaltTable(); - - static RwgsaltTable serializeObject(); - - void init(const Opm::DeckRecord& record1); - size_t size() const; - std::vector getPressureColumn() const; - std::vector getSaltConcentrationColumn() const; - std::vector getVaporizedWaterGasRatioColumn() const; - const std::vector& getTableValues() const; - - bool operator==(const RwgsaltTable& data) const; - - template - void serializeOp(Serializer& serializer) - { - serializer(m_tableValues); - } - - protected: - - std::vector m_tableValues; - - }; - -} - -#endif diff --git a/ThirdParty/custom-opm-common/opm-common/opm/parser/eclipse/EclipseState/Tables/SaltpvdTable.hpp b/ThirdParty/custom-opm-common/opm-common/opm/parser/eclipse/EclipseState/Tables/SaltpvdTable.hpp deleted file mode 100644 index 32cbcb5b6e..0000000000 --- a/ThirdParty/custom-opm-common/opm-common/opm/parser/eclipse/EclipseState/Tables/SaltpvdTable.hpp +++ /dev/null @@ -1,38 +0,0 @@ -/* - Copyright (C) 2020 by Equinor. - Copyright (C) 2020 by TNO. - - This file is part of the Open Porous Media project (OPM). - - OPM is free software: you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - OPM is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with OPM. If not, see . - */ -#ifndef OPM_PARSER_SALTPVD_TABLE_HPP -#define OPM_PARSER_SALTPVD_TABLE_HPP - -#include "SimpleTable.hpp" - -namespace Opm { - - class DeckItem; - - class SaltpvdTable : public SimpleTable { - public: - SaltpvdTable( const DeckItem& item ); - - const TableColumn& getDepthColumn() const; - const TableColumn& getSaltpColumn() const; - }; -} - -#endif diff --git a/ThirdParty/custom-opm-common/opm-common/opm/parser/eclipse/EclipseState/Tables/TLMixpar.hpp b/ThirdParty/custom-opm-common/opm-common/opm/parser/eclipse/EclipseState/Tables/TLMixpar.hpp deleted file mode 100644 index 9f40f2707a..0000000000 --- a/ThirdParty/custom-opm-common/opm-common/opm/parser/eclipse/EclipseState/Tables/TLMixpar.hpp +++ /dev/null @@ -1,81 +0,0 @@ -/* - Copyright (C) 2020 Statoil ASA - - This file is part of the Open Porous Media project (OPM). - - OPM is free software: you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - OPM is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with OPM. If not, see . - */ - -#ifndef TLMIXPAR_HPP -#define TLMIXPAR_HPP - -#include -#include - -namespace Opm { -class Deck; - -struct TLMixRecord { - double viscosity_parameter; - double density_parameter; - - TLMixRecord() = default; - TLMixRecord(double v, double d) : - viscosity_parameter(v), - density_parameter(d) - {}; - - - bool operator==(const TLMixRecord& other) const { - return this->viscosity_parameter == other.viscosity_parameter && - this->density_parameter == other.density_parameter; - } - - template - void serializeOp(Serializer& serializer) - { - serializer(viscosity_parameter); - serializer(density_parameter); - } - -}; - - -class TLMixpar { -public: - - TLMixpar() = default; - TLMixpar(const Deck& deck); - static TLMixpar serializeObject(); - std::size_t size() const; - bool empty() const; - const TLMixRecord& operator[](const std::size_t index) const; - - bool operator==(const TLMixpar& other) const { - return this->data == other.data; - } - - template - void serializeOp(Serializer& serializer) - { - serializer.vector(data); - } - -private: - std::vector data; -}; -} - - -#endif diff --git a/ThirdParty/custom-opm-common/opm-common/opm/parser/eclipse/EclipseState/Tables/TableManager.hpp b/ThirdParty/custom-opm-common/opm-common/opm/parser/eclipse/EclipseState/Tables/TableManager.hpp index bd4c322433..c45e4ef795 100644 --- a/ThirdParty/custom-opm-common/opm-common/opm/parser/eclipse/EclipseState/Tables/TableManager.hpp +++ b/ThirdParty/custom-opm-common/opm-common/opm/parser/eclipse/EclipseState/Tables/TableManager.hpp @@ -33,15 +33,12 @@ #include #include -#include -#include #include #include #include #include #include #include -#include #include #include #include @@ -60,7 +57,6 @@ #include #include #include -#include namespace Opm { @@ -81,7 +77,7 @@ namespace Opm { const Eqldims& getEqldims() const; const Aqudims& getAqudims() const; const Regdims& getRegdims() const; - const TLMixpar& getTLMixpar() const; + /* WIll return max{ Tabdims::NTFIP , Regdims::NTFIP }. */ @@ -101,8 +97,6 @@ namespace Opm { const TableContainer& getPbvdTables() const; const TableContainer& getPdvdTables() const; const TableContainer& getSaltvdTables() const; - const TableContainer& getSaltpvdTables() const; - const TableContainer& getPermfactTables() const; const TableContainer& getEnkrvdTables() const; const TableContainer& getEnptvdTables() const; const TableContainer& getImkrvdTables() const; @@ -137,8 +131,6 @@ namespace Opm { const JFunc& getJFunc() const; const std::vector& getPvtgTables() const; - const std::vector& getPvtgwTables() const; - const std::vector& getPvtgwoTables() const; const std::vector& getPvtoTables() const; const std::vector& getRock2dTables() const; const std::vector& getRock2dtrTables() const; @@ -152,7 +144,6 @@ namespace Opm { std::size_t gas_comp_index() const; const PvtwTable& getPvtwTable() const; const std::vector& getPvtwSaltTables() const; - const std::vector& getRwgSaltTables() const; const std::vector& getBrineDensityTables() const; const std::vector& getSolventDensityTables() const; @@ -164,6 +155,7 @@ namespace Opm { const PlmixparTable& getPlmixparTable() const; const ShrateTable& getShrateTable() const; const Stone1exTable& getStone1exTable() const; + const TlmixparTable& getTlmixparTable() const; const WatdentTable& getWatdentTable() const; const std::map& getPlymwinjTables() const; const std::map& getSkprwatTables() const; @@ -200,8 +192,6 @@ namespace Opm { serializer(split.rockMax); serializer.map(split.rockMap); serializer.vector(m_pvtgTables); - serializer.vector(m_pvtgwTables); - serializer.vector(m_pvtgwoTables); serializer.vector(m_pvtoTables); serializer.vector(m_rock2dTables); serializer.vector(m_rock2dtrTables); @@ -213,10 +203,10 @@ namespace Opm { m_plmixparTable.serializeOp(serializer); m_shrateTable.serializeOp(serializer); m_stone1exTable.serializeOp(serializer); + m_tlmixparTable.serializeOp(serializer); m_viscrefTable.serializeOp(serializer); m_watdentTable.serializeOp(serializer); serializer.vector(m_pvtwsaltTables); - serializer.vector(m_rwgsaltTables); serializer.vector(m_bdensityTables); serializer.vector(m_sdensityTables); serializer.map(m_plymwinjTables); @@ -237,7 +227,6 @@ namespace Opm { stcond.serializeOp(serializer); serializer(m_gas_comp_index); serializer(m_rtemp); - m_tlmixpar.serializeOp(serializer); if (!serializer.isSerializing()) { m_simpleTables = simpleTables; if (split.plyshMax > 0) { @@ -331,22 +320,6 @@ namespace Opm { assert(regionIdx == numTables); } - template - void initRwgsaltTables(const Deck& deck, std::vector& rwgtables ) { - - size_t numTables = m_tabdims.getNumPVTTables(); - rwgtables.resize(numTables); - - const auto& keyword = deck.getKeyword("RWGSALT"); - size_t regionIdx = 0; - for (const auto& record : keyword) { - rwgtables[regionIdx].init(record); - ++regionIdx; - } - assert(regionIdx == numTables); - } - - template void initBrineTables(const Deck& deck, std::vector& brinetables ) { @@ -491,8 +464,6 @@ namespace Opm { std::map m_simpleTables; std::vector m_pvtgTables; - std::vector m_pvtgwTables; - std::vector m_pvtgwoTables; std::vector m_pvtoTables; std::vector m_rock2dTables; std::vector m_rock2dtrTables; @@ -504,10 +475,10 @@ namespace Opm { PlmixparTable m_plmixparTable; ShrateTable m_shrateTable; Stone1exTable m_stone1exTable; + TlmixparTable m_tlmixparTable; ViscrefTable m_viscrefTable; WatdentTable m_watdentTable; std::vector m_pvtwsaltTables; - std::vector m_rwgsaltTables; std::vector m_bdensityTables; std::vector m_sdensityTables; std::map m_plymwinjTables; @@ -518,7 +489,6 @@ namespace Opm { Regdims m_regdims; Eqldims m_eqldims; Aqudims m_aqudims; - TLMixpar m_tlmixpar; bool hasImptvd = false;// if deck has keyword IMPTVD bool hasEnptvd = false;// if deck has keyword ENPTVD diff --git a/ThirdParty/custom-opm-common/opm-common/opm/parser/eclipse/Parser/Parser.hpp b/ThirdParty/custom-opm-common/opm-common/opm/parser/eclipse/Parser/Parser.hpp index 140fdaaea0..8a8b0e6218 100644 --- a/ThirdParty/custom-opm-common/opm-common/opm/parser/eclipse/Parser/Parser.hpp +++ b/ThirdParty/custom-opm-common/opm-common/opm/parser/eclipse/Parser/Parser.hpp @@ -34,6 +34,7 @@ #include #include +#include namespace Json { class JsonObject; @@ -84,8 +85,8 @@ namespace Opm { bool hasKeyword( const std::string& ) const; const ParserKeyword& getKeyword(const std::string& name) const; - bool isRecognizedKeyword( const std::string_view& deckKeywordName) const; - const ParserKeyword& getParserKeywordFromDeckName(const std::string_view& deckKeywordName) const; + bool isRecognizedKeyword( const string_view& deckKeywordName) const; + const ParserKeyword& getParserKeywordFromDeckName(const string_view& deckKeywordName) const; std::vector getAllDeckNames () const; void loadKeywords(const Json::JsonObject& jsonKeywords); @@ -134,18 +135,18 @@ namespace Opm { private: bool hasWildCardKeyword(const std::string& keyword) const; - const ParserKeyword* matchingKeyword(const std::string_view& keyword) const; + const ParserKeyword* matchingKeyword(const string_view& keyword) const; void addDefaultKeywords(); // std::vector< std::unique_ptr< const ParserKeyword > > keyword_storage; std::list keyword_storage; // associative map of deck names and the corresponding ParserKeyword object - std::map< std::string_view, const ParserKeyword* > m_deckParserKeywords; + std::map< string_view, const ParserKeyword* > m_deckParserKeywords; // associative map of the parser internal names and the corresponding // ParserKeyword object for keywords which match a regular expression - std::map< std::string_view, const ParserKeyword* > m_wildCardKeywords; + std::map< string_view, const ParserKeyword* > m_wildCardKeywords; std::vector> code_keywords; }; diff --git a/ThirdParty/custom-opm-common/opm-common/opm/parser/eclipse/Parser/ParserKeyword.hpp b/ThirdParty/custom-opm-common/opm-common/opm/parser/eclipse/Parser/ParserKeyword.hpp index 0936206248..b072c1b03c 100644 --- a/ThirdParty/custom-opm-common/opm-common/opm/parser/eclipse/Parser/ParserKeyword.hpp +++ b/ThirdParty/custom-opm-common/opm-common/opm/parser/eclipse/Parser/ParserKeyword.hpp @@ -39,6 +39,7 @@ namespace Opm { class ErrorGuard; class ParserDoubleItem; class RawKeyword; + class string_view; class ErrorGuard; /* @@ -90,10 +91,10 @@ namespace Opm { static bool validInternalName(const std::string& name); - static bool validDeckName(const std::string_view& name); + static bool validDeckName(const string_view& name); bool hasMatchRegex() const; void setMatchRegex(const std::string& deckNameRegexp); - bool matches(const std::string_view& ) const; + bool matches(const string_view& ) const; bool hasDimension() const; void addRecord( ParserRecord ); void addDataRecord( ParserRecord ); @@ -158,7 +159,7 @@ namespace Opm { bool double_records = false; std::string code_end; - static bool validNameStart(const std::string_view& name); + static bool validNameStart(const string_view& name); void initDeckNames( const Json::JsonObject& jsonConfig ); void initSectionNames( const Json::JsonObject& jsonConfig ); void initMatchRegex( const Json::JsonObject& jsonObject ); diff --git a/ThirdParty/custom-opm-common/opm-common/opm/parser/eclipse/Units/UnitSystem.hpp b/ThirdParty/custom-opm-common/opm-common/opm/parser/eclipse/Units/UnitSystem.hpp index 9823eef690..e864a2891b 100644 --- a/ThirdParty/custom-opm-common/opm-common/opm/parser/eclipse/Units/UnitSystem.hpp +++ b/ThirdParty/custom-opm-common/opm-common/opm/parser/eclipse/Units/UnitSystem.hpp @@ -74,7 +74,6 @@ namespace Opm { gas_productivity_index, energy, icd_strength, - polymer_density, _count // New entries must be added *before* this }; diff --git a/ThirdParty/custom-opm-common/opm-common/opm/parser/eclipse/Utility/Stringview.hpp b/ThirdParty/custom-opm-common/opm-common/opm/parser/eclipse/Utility/Stringview.hpp new file mode 100644 index 0000000000..7e699da30e --- /dev/null +++ b/ThirdParty/custom-opm-common/opm-common/opm/parser/eclipse/Utility/Stringview.hpp @@ -0,0 +1,289 @@ +/* + Copyright (C) 2016 by Statoil ASA + + This file is part of the Open Porous Media project (OPM). + + OPM is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + OPM is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with OPM. If not, see . + */ + +#ifndef OPM_UTILITY_SUBSTRING_HPP +#define OPM_UTILITY_SUBSTRING_HPP + +#include +#include +#include +#include +#include + +namespace Opm { + /* + * string_view is a simple view-into-substring feature whose primary + * usecase is to avoid deep copying strings in the inner loops of the + * parser. Relies on whatever it's viewing into is kept alive (as all + * iterators do): + * + * auto rec = make_raw_record(); + * string_view view = rec.getItem( 3 ); + * + * view.size(); view[ 10 ]; // ok + * ~rec(); + * view[ 3 ]; // not ok + * + * This is desired to fill out a gap in the C++ standard library, since + * string_view has yet to be standardised + * + * http://en.cppreference.com/w/cpp/experimental/basic_string_view + */ + class string_view { + public: + using const_iterator = const char*; + + inline string_view() = default; + inline string_view( const_iterator, const_iterator ); + inline string_view( const_iterator, size_t ); + //cppcheck-suppress noExplicitConstructor + inline string_view( const std::string& ); + inline string_view( const std::string&, size_t ); + //cppcheck-suppress noExplicitConstructor + inline string_view( const char* ); + + inline const_iterator begin() const; + inline const_iterator end() const; + + inline char front() const; + inline char back() const; + + inline char operator[]( size_t ) const; + inline bool operator<( const string_view& ) const; + inline bool operator==( const string_view& ) const; + + inline bool empty() const; + inline size_t size() const; + inline size_t length() const; + + inline std::string string() const; + inline std::string substr( size_t from = 0 ) const; + inline std::string substr( size_t from, size_t len ) const; + + inline bool starts_with(const std::string& str) const; + inline std::size_t find(const std::string& substring) const; + inline std::size_t find(char c) const; + private: + const_iterator fst = nullptr; + const_iterator lst = nullptr; + }; + + /* + * The implementation of string_view is inline and therefore the definitions + * are also in this file. The reason for this is performance; string_view's + * logic is trivial and function call and indirection overhead is significant + * compared to the useful work it does. Additionally, string_view is a *very* + * much used class in the inner loops of the parser - inlining the + * implementation measured to improve performance by some 10%. + */ + + + // Non-member operators using string_view. + + std::ostream& operator<<( std::ostream& stream, const Opm::string_view& view ); + + inline std::string operator+( std::string str, const Opm::string_view& view ) { + return str.append( view.begin(), view.end() ); + } + + inline std::string operator+( const Opm::string_view& view, const std::string& str ) { + return view.string().append( str.begin(), str.end() ); + } + + inline bool operator==( const Opm::string_view& view, const std::string& rhs ) { + return rhs.size() == view.size() && + std::equal( view.begin(), view.end(), std::begin( rhs ) ); + } + + inline bool operator==( const Opm::string_view& view, const char* rhs ) { + return std::strlen( rhs ) == view.size() && + std::equal( view.begin(), view.end(), rhs ); + } + + inline bool operator==( const std::string& lhs, const Opm::string_view& view ) { + return view == lhs; + } + + inline bool operator==( const char* lhs, const Opm::string_view& view ) { + return view == lhs; + } + + inline bool operator!=( const Opm::string_view& view, const std::string& rhs ) { + return !( view == rhs ); + } + + inline bool operator!=( const std::string& lhs, const Opm::string_view& view ) { + return !( view == lhs ); + } + + inline bool operator!=( const Opm::string_view& view, const char* rhs ) { + return !( view == rhs ); + } + + inline bool operator!=( const char* lhs, const Opm::string_view& view ) { + return !( view == lhs ); + } + + + // Member functions of string_view. + + inline string_view::string_view( const_iterator first, + const_iterator last ) : + fst( first ), + lst( last ) + {} + + inline string_view::string_view( const_iterator first , + size_t count ) : + fst( first ), + lst( first + count ) + {} + + inline string_view::string_view( const std::string& str ) : + string_view( str.data(), str.size() ) + {} + + inline string_view::string_view( const std::string& str, size_t count ) : + string_view( str.data(), count ) + {} + + inline string_view::string_view( const char* str ) : + string_view( str, str + std::strlen( str ) ) + {} + + inline string_view::const_iterator string_view::begin() const { + return this->fst; + } + + inline string_view::const_iterator string_view::end() const { + return this->lst; + } + + inline char string_view::front() const { + return *this->fst; + } + + inline char string_view::back() const { + return *(this->lst - 1); + } + + inline char string_view::operator[]( size_t i ) const { + return *(this->begin() + i); + } + + inline bool string_view::operator<( const string_view& rhs ) const { + return std::lexicographical_compare( this->begin(), this->end(), + rhs.begin(), rhs.end() ); + } + + inline bool string_view::operator==( const string_view& rhs ) const { + return std::equal( this->begin(), this->end(), rhs.begin() ); + } + + inline bool string_view::empty() const { + return std::distance( this->begin(), this->end() ) == 0; + } + + inline size_t string_view::size() const { + return std::distance( this->begin(), this->end() ); + } + + inline size_t string_view::length() const { + return std::distance( this->begin(), this->end() ); + } + + inline std::string string_view::string() const { + return this->substr(); + } + + inline std::string string_view::substr( size_t from ) const { + return this->substr( from, this->size() ); + } + + inline std::string string_view::substr( size_t from, size_t len ) const { + if( from > this->size() ) + throw std::out_of_range( "'from' is greater than length" ); + + if (from + len > this->size()) + return std::string( this->begin() + from, this->lst ); + + return std::string( this->begin() + from, this->begin() + len + from); + } + + inline std::size_t string_view::find(const std::string& substring) const { + auto substring_size = substring.size(); + if (substring_size > this->size()) + return std::string::npos; + + auto substring_data = substring.data(); + auto pos = this->fst; + auto last_pos = this->lst - substring.size() + 1; + + while (pos != last_pos) { + std::size_t si = 0; + while (substring_data[si] == *(pos + si)) { + si += 1; + if (si == substring_size) + return pos - this->fst; + } + ++pos; + } + + return std::string::npos; + } + + inline std::size_t string_view::find(char c) const { + auto pos = this->fst; + + while (pos != this->lst) { + if (*pos == c) + return pos - this->fst; + + ++pos; + } + + return std::string::npos; + } + + + inline bool string_view::starts_with(const std::string& str) const { + auto str_size = str.size(); + if (str_size > this->size()) + return false; + + auto str_data = str.data(); + auto pos = this->fst; + + std::size_t si = 0; + while (true) { + if (*pos != str_data[si]) + return false; + + ++pos; + ++si; + + if (si == str_size) + return true; + } + } + + +} + +#endif //OPM_UTILITY_SUBSTRING_HPP diff --git a/ThirdParty/custom-opm-common/opm-common/python/Dockerfile b/ThirdParty/custom-opm-common/opm-common/python/Dockerfile deleted file mode 100644 index 3dca12a62a..0000000000 --- a/ThirdParty/custom-opm-common/opm-common/python/Dockerfile +++ /dev/null @@ -1,12 +0,0 @@ -# Dockerfile to generate PyPI packages. Needs to be run from the opm-common root folder -# Example use: -# sudo docker build -t manylinux2014_opm:built . -f python/Dockerfile - -FROM quay.io/pypa/manylinux2014_x86_64 -ARG version_tag="" -WORKDIR /tmp/opm-common -RUN echo "Using package version tag: $version_tag" -ADD . . -RUN /bin/bash /tmp/opm-common/python/generate-pypi-package.sh $version_tag -# docker run -e PLAT=manylinux2014_x86_64 -it lindkvis/manylinux2014_opm:latest - diff --git a/ThirdParty/custom-opm-common/opm-common/python/Dockerfile.create b/ThirdParty/custom-opm-common/opm-common/python/Dockerfile.create deleted file mode 100644 index 784af93468..0000000000 --- a/ThirdParty/custom-opm-common/opm-common/python/Dockerfile.create +++ /dev/null @@ -1,8 +0,0 @@ -# Docker file to generate a Docker image capable of building PyPI packages -# Example use: -# Use sudo docker build -t lindkvis/manylinux2014_opm:latest -f Dockerfile.create . - -FROM quay.io/pypa/manylinux2014_x86_64 -WORKDIR /tmp -COPY setup-docker-image.sh . -RUN /bin/bash /tmp/setup-docker-image.sh diff --git a/ThirdParty/custom-opm-common/opm-common/python/README.md b/ThirdParty/custom-opm-common/opm-common/python/README.md deleted file mode 100644 index 0369a5709a..0000000000 --- a/ThirdParty/custom-opm-common/opm-common/python/README.md +++ /dev/null @@ -1,2 +0,0 @@ -Python bindings for the OPM-common module of the Open Porous Media project. - diff --git a/ThirdParty/custom-opm-common/opm-common/python/cxx/eclipse_config.cpp b/ThirdParty/custom-opm-common/opm-common/python/cxx/eclipse_config.cpp index 9d07d67f2e..4bdf062b80 100644 --- a/ThirdParty/custom-opm-common/opm-common/python/cxx/eclipse_config.cpp +++ b/ThirdParty/custom-opm-common/opm-common/python/cxx/eclipse_config.cpp @@ -14,7 +14,7 @@ void python::common::export_EclipseConfig(py::module& module) { py::class_< EclipseConfig >( module, "EclipseConfig" ) - .def( "init", py::overload_cast<>(&EclipseConfig::init, py::const_)); + .def( "init", &EclipseConfig::init, ref_internal); py::class_< SummaryConfig >( module, "SummaryConfig") .def(py::init([](const Deck& deck, const EclipseState& state, const Schedule& schedule) { diff --git a/ThirdParty/custom-opm-common/opm-common/python/cxx/schedule.cpp b/ThirdParty/custom-opm-common/opm-common/python/cxx/schedule.cpp index b49557d533..fcfc1b45c5 100644 --- a/ThirdParty/custom-opm-common/opm-common/python/cxx/schedule.cpp +++ b/ThirdParty/custom-opm-common/opm-common/python/cxx/schedule.cpp @@ -103,7 +103,6 @@ void python::common::export_Schedule(py::module& module) { .def( "open_well", &Schedule::open_well) .def( "stop_well", &Schedule::stop_well) .def( "get_wells", &Schedule::getWells) - .def("well_names", py::overload_cast(&Schedule::wellNames, py::const_)) .def( "get_well", &get_well) .def( "__contains__", &has_well ) .def( "group", &Schedule::getGroup, ref_internal); diff --git a/ThirdParty/custom-opm-common/opm-common/python/cxx/summary_state.cpp b/ThirdParty/custom-opm-common/opm-common/python/cxx/summary_state.cpp index 6299bc4a46..c6809d8d5e 100644 --- a/ThirdParty/custom-opm-common/opm-common/python/cxx/summary_state.cpp +++ b/ThirdParty/custom-opm-common/opm-common/python/cxx/summary_state.cpp @@ -46,13 +46,13 @@ void python::common::export_SummaryState(py::module& module) { .def("update", &SummaryState::update) .def("update_well_var", &SummaryState::update_well_var) .def("update_group_var", &SummaryState::update_group_var) - .def("well_var", py::overload_cast(&SummaryState::get_well_var, py::const_)) - .def("group_var", py::overload_cast(&SummaryState::get_group_var, py::const_)) + .def("well_var", &SummaryState::get_well_var) + .def("group_var", &SummaryState::get_group_var) .def("elapsed", &SummaryState::get_elapsed) .def_property_readonly("groups", groups) .def_property_readonly("wells", wells) .def("__contains__", &SummaryState::has) .def("has_well_var", &SummaryState::has_well_var) .def("has_group_var", &SummaryState::has_group_var) - .def("__getitem__", py::overload_cast(&SummaryState::get, py::const_)); + .def("__getitem__", &SummaryState::get); } diff --git a/ThirdParty/custom-opm-common/opm-common/python/enable-python.sh.in b/ThirdParty/custom-opm-common/opm-common/python/enable-python.sh.in index c30a391bfe..2f4bcb67a9 100644 --- a/ThirdParty/custom-opm-common/opm-common/python/enable-python.sh.in +++ b/ThirdParty/custom-opm-common/opm-common/python/enable-python.sh.in @@ -1,5 +1,5 @@ #!/bin/bash -export PYTHONPATH=@PROJECT_BINARY_DIR@/python:$PYTHONPATH +export PYTHONPATH=@PROJECT_BINARY_DIR@/python/python:$PYTHONPATH export LD_LIBRARY_PATH=@_setup_lib_dirs@:$LD_LIBRARY_PATH diff --git a/ThirdParty/custom-opm-common/opm-common/python/generate-pypi-package.sh b/ThirdParty/custom-opm-common/opm-common/python/generate-pypi-package.sh deleted file mode 100644 index d4c089656b..0000000000 --- a/ThirdParty/custom-opm-common/opm-common/python/generate-pypi-package.sh +++ /dev/null @@ -1,57 +0,0 @@ -#!/bin/bash - -# Run in docker container -# docker run -e PLAT=manylinux2014_x86_64 -it quay.io/pypa/manylinux2014_x86_64 - -VERSION_TAG=${1:-""} - -#export PYTHON27=/usr/bin/python2.7 -export PYTHON35=/opt/python/cp35-cp35m/bin/python -export PYTHON36=/opt/python/cp36-cp36m/bin/python -export PYTHON37=/opt/python/cp37-cp37m/bin/python -export PYTHON38=/opt/python/cp38-cp38/bin/python - -/bin/bash /tmp/opm-common/python/setup-docker-image.sh - -cd /tmp/opm-common - -# Delete the folder if it already exists -if [ -d build ]; then - rm -rf build -fi - -mkdir build && cd build - -cmake3 -DPYTHON_EXECUTABLE=${PYTHON35} -DBOOST_INCLUDEDIR=/usr/include/boost169 -DBOOST_LIBRARYDIR=/usr/lib64/boost169 \ --DOPM_ENABLE_PYTHON=ON -DOPM_PYTHON_PACKAGE_VERSION_TAG=${VERSION_TAG} .. - -# make step is necessary until the generated ParserKeywords/*.hpp are generated in the Python step -make -j2 - -./setup-package.sh -${PYTHON35} -m auditwheel repair python/dist/*cp35*.whl - -# Run setup-package.sh four times (Python 3.5, 3.6, 3.7 and 3.8) -cmake3 -DPYTHON_EXECUTABLE=${PYTHON36} -DBOOST_INCLUDEDIR=/usr/include/boost169 -DBOOST_LIBRARYDIR=/usr/lib64/boost169 \ --DOPM_ENABLE_PYTHON=ON -DOPM_PYTHON_PACKAGE_VERSION_TAG=${VERSION_TAG} .. -./setup-package.sh -${PYTHON36} -m auditwheel repair python/dist/*cp36*.whl - -cmake3 -DPYTHON_EXECUTABLE=${PYTHON37} -DBOOST_INCLUDEDIR=/usr/include/boost169 -DBOOST_LIBRARYDIR=/usr/lib64/boost169 \ --DOPM_ENABLE_PYTHON=ON -DOPM_PYTHON_PACKAGE_VERSION_TAG=${VERSION_TAG} .. -./setup-package.sh -${PYTHON37} -m auditwheel repair python/dist/*cp37*.whl - -cmake3 -DPYTHON_EXECUTABLE=${PYTHON38} -DBOOST_INCLUDEDIR=/usr/include/boost169 -DBOOST_LIBRARYDIR=/usr/lib64/boost169 \ --DOPM_ENABLE_PYTHON=ON -DOPM_PYTHON_PACKAGE_VERSION_TAG=${VERSION_TAG} .. -./setup-package.sh -${PYTHON38} -m auditwheel repair python/dist/*cp38*.whl - -#cmake3 -DPYTHON_EXECUTABLE=${PYTHON27} -DBOOST_INCLUDEDIR=/usr/include/boost169 -DBOOST_LIBRARYDIR=/usr/lib64/boost169 \ -#-DOPM_ENABLE_PYTHON=ON -DOPM_ENABLE_DYNAMIC_BOOST=OFF -DOPM_ENABLE_DYNAMIC_PYTHON_LINKING=OFF .. -#./setup-package.sh -#${PYTHON27} -m auditwheel repair python/dist/*cp27*.whl - - -# Example of upload -# /usr/bin/python3 -m twine upload --repository testpypi wheelhouse/* diff --git a/ThirdParty/custom-opm-common/opm-common/python/install.py b/ThirdParty/custom-opm-common/opm-common/python/install.py index 933a0f4458..f67fd037ce 100644 --- a/ThirdParty/custom-opm-common/opm-common/python/install.py +++ b/ThirdParty/custom-opm-common/opm-common/python/install.py @@ -8,7 +8,7 @@ src_root = sys.argv[1] target_prefix = sys.argv[2] install = int(sys.argv[3]) target_destdir = os.environ.get("DESTDIR", "") -if target_destdir != "": +if not target_destdir is "": target_prefix = target_destdir + target_prefix if not os.path.isdir(src_root): diff --git a/ThirdParty/custom-opm-common/opm-common/python/pypi-howto.txt b/ThirdParty/custom-opm-common/opm-common/python/pypi-howto.txt deleted file mode 100644 index b55d9d516a..0000000000 --- a/ThirdParty/custom-opm-common/opm-common/python/pypi-howto.txt +++ /dev/null @@ -1,20 +0,0 @@ -# How to build pypi-packages: - -* For initial python package version. Run in the opm-common root folder: - -sudo docker build -t manylinux2014_opm:built . -f python/Dockerfile - -* This will create a docker image with a version looking like '2020.10' with package - wheels ready for upload in /tmp/opm-common/build/wheelhouse -* For subsequent python package versions, add a version_tag build argument including a dot '.': - -sudo docker build -t manylinux2014_opm:built --build-arg version_tag=".1" . -f python/Dockerfile - -* This will create a python package version looking like '2020.10.1'. -* Once the image is finished, run it: - -sudo docker run -it manylinux2014_opm:built - -* The package wheels can then be uploaded to test-pypi with: - -/opt/python/cp38-cp38/bin/python -m twine upload -u __token__ -p TOKEN_VALUE --repository testpypi /tmp/opm-common/build/wheelhouse/*.whl diff --git a/ThirdParty/custom-opm-common/opm-common/python/opm/__init__.py b/ThirdParty/custom-opm-common/opm-common/python/python/opm/__init__.py similarity index 100% rename from ThirdParty/custom-opm-common/opm-common/python/opm/__init__.py rename to ThirdParty/custom-opm-common/opm-common/python/python/opm/__init__.py diff --git a/ThirdParty/custom-opm-common/opm-common/python/opm/_common.py b/ThirdParty/custom-opm-common/opm-common/python/python/opm/_common.py similarity index 100% rename from ThirdParty/custom-opm-common/opm-common/python/opm/_common.py rename to ThirdParty/custom-opm-common/opm-common/python/python/opm/_common.py diff --git a/ThirdParty/custom-opm-common/opm-common/python/opm/io/__init__.py b/ThirdParty/custom-opm-common/opm-common/python/python/opm/io/__init__.py similarity index 100% rename from ThirdParty/custom-opm-common/opm-common/python/opm/io/__init__.py rename to ThirdParty/custom-opm-common/opm-common/python/python/opm/io/__init__.py diff --git a/ThirdParty/custom-opm-common/opm-common/python/opm/io/deck/__init__.py b/ThirdParty/custom-opm-common/opm-common/python/python/opm/io/deck/__init__.py similarity index 100% rename from ThirdParty/custom-opm-common/opm-common/python/opm/io/deck/__init__.py rename to ThirdParty/custom-opm-common/opm-common/python/python/opm/io/deck/__init__.py diff --git a/ThirdParty/custom-opm-common/opm-common/python/opm/io/ecl/__init__.py b/ThirdParty/custom-opm-common/opm-common/python/python/opm/io/ecl/__init__.py similarity index 100% rename from ThirdParty/custom-opm-common/opm-common/python/opm/io/ecl/__init__.py rename to ThirdParty/custom-opm-common/opm-common/python/python/opm/io/ecl/__init__.py diff --git a/ThirdParty/custom-opm-common/opm-common/python/opm/io/ecl_state/__init__.py b/ThirdParty/custom-opm-common/opm-common/python/python/opm/io/ecl_state/__init__.py similarity index 100% rename from ThirdParty/custom-opm-common/opm-common/python/opm/io/ecl_state/__init__.py rename to ThirdParty/custom-opm-common/opm-common/python/python/opm/io/ecl_state/__init__.py diff --git a/ThirdParty/custom-opm-common/opm-common/python/opm/io/log.py b/ThirdParty/custom-opm-common/opm-common/python/python/opm/io/log.py similarity index 100% rename from ThirdParty/custom-opm-common/opm-common/python/opm/io/log.py rename to ThirdParty/custom-opm-common/opm-common/python/python/opm/io/log.py diff --git a/ThirdParty/custom-opm-common/opm-common/python/opm/io/parser/__init__.py b/ThirdParty/custom-opm-common/opm-common/python/python/opm/io/parser/__init__.py similarity index 100% rename from ThirdParty/custom-opm-common/opm-common/python/opm/io/parser/__init__.py rename to ThirdParty/custom-opm-common/opm-common/python/python/opm/io/parser/__init__.py diff --git a/ThirdParty/custom-opm-common/opm-common/python/opm/io/schedule/__init__.py b/ThirdParty/custom-opm-common/opm-common/python/python/opm/io/schedule/__init__.py similarity index 100% rename from ThirdParty/custom-opm-common/opm-common/python/opm/io/schedule/__init__.py rename to ThirdParty/custom-opm-common/opm-common/python/python/opm/io/schedule/__init__.py diff --git a/ThirdParty/custom-opm-common/opm-common/python/opm/io/sim/__init__.py b/ThirdParty/custom-opm-common/opm-common/python/python/opm/io/sim/__init__.py similarity index 100% rename from ThirdParty/custom-opm-common/opm-common/python/opm/io/sim/__init__.py rename to ThirdParty/custom-opm-common/opm-common/python/python/opm/io/sim/__init__.py diff --git a/ThirdParty/custom-opm-common/opm-common/python/opm/io/summary/__init__.py b/ThirdParty/custom-opm-common/opm-common/python/python/opm/io/summary/__init__.py similarity index 100% rename from ThirdParty/custom-opm-common/opm-common/python/opm/io/summary/__init__.py rename to ThirdParty/custom-opm-common/opm-common/python/python/opm/io/summary/__init__.py diff --git a/ThirdParty/custom-opm-common/opm-common/python/opm/tools/__init__.py b/ThirdParty/custom-opm-common/opm-common/python/python/opm/tools/__init__.py similarity index 100% rename from ThirdParty/custom-opm-common/opm-common/python/opm/tools/__init__.py rename to ThirdParty/custom-opm-common/opm-common/python/python/opm/tools/__init__.py diff --git a/ThirdParty/custom-opm-common/opm-common/python/opm/tools/time_vector.py b/ThirdParty/custom-opm-common/opm-common/python/python/opm/tools/time_vector.py similarity index 100% rename from ThirdParty/custom-opm-common/opm-common/python/opm/tools/time_vector.py rename to ThirdParty/custom-opm-common/opm-common/python/python/opm/tools/time_vector.py diff --git a/ThirdParty/custom-opm-common/opm-common/python/setup-build.sh.in b/ThirdParty/custom-opm-common/opm-common/python/setup-build.sh.in index 7f214b6765..b09a28b0cb 100644 --- a/ThirdParty/custom-opm-common/opm-common/python/setup-build.sh.in +++ b/ThirdParty/custom-opm-common/opm-common/python/setup-build.sh.in @@ -10,11 +10,11 @@ cp -r @PROJECT_SOURCE_DIR@/python @PROJECT_BINARY_DIR@ cd @PROJECT_BINARY_DIR@/python -rm -f opm/libopmcommon_python* +rm -f python/opm/libopmcommon_python* export CC=@CMAKE_CXX_COMPILER@ -@PYTHON_EXECUTABLE@ setup.py build build_ext \ +@PYTHON_EXECUTABLE@ setup.py build build_ext --build-lib=python/opm \ --library-dirs=@_setup_lib_dirs@ \ @_rpath_arg@ \ --include-dirs=@_setup_include_dirs@ diff --git a/ThirdParty/custom-opm-common/opm-common/python/setup-docker-image.sh b/ThirdParty/custom-opm-common/opm-common/python/setup-docker-image.sh deleted file mode 100644 index acb701881a..0000000000 --- a/ThirdParty/custom-opm-common/opm-common/python/setup-docker-image.sh +++ /dev/null @@ -1,24 +0,0 @@ -#!/bin/bash - -# Script to be run on a manylinux2014 docker image to complete it for OPM usage. -# i.e. docker run -i -t quay.io/pypa/manylinux2014_x86_64 < setup-docker-image.sh - -# A ready made Docker image is available at Dockerhub: -# docker run -i -t lindkvis/manylinux2014_opm:latest - -yum-config-manager --add-repo \ -https://www.opm-project.org/package/opm.repo -yum install -y cmake3 ccache boost169-devel boost169-static -yum install -y blas-devel suitesparse-devel trilinos-openmpi-devel - -#${PYTHON27} -m pip install pip --upgrade -#${PYTHON27} -m pip install wheel setuptools twine pytest-runner auditwheel -${PYTHON35} -m pip install pip --upgrade -${PYTHON35} -m pip install wheel setuptools twine pytest-runner auditwheel -${PYTHON36} -m pip install pip --upgrade -${PYTHON36} -m pip install wheel setuptools twine pytest-runner auditwheel -${PYTHON37} -m pip install pip --upgrade -${PYTHON37} -m pip install wheel setuptools twine pytest-runner auditwheel -${PYTHON38} -m pip install pip --upgrade -${PYTHON38} -m pip install wheel setuptools twine pytest-runner auditwheel - diff --git a/ThirdParty/custom-opm-common/opm-common/python/setup-package.sh.in b/ThirdParty/custom-opm-common/opm-common/python/setup-package.sh.in deleted file mode 100644 index 8469ee1ea4..0000000000 --- a/ThirdParty/custom-opm-common/opm-common/python/setup-package.sh.in +++ /dev/null @@ -1,20 +0,0 @@ -#!/bin/bash -# This cmake template file can be used to create a small shell script which can -# be used to generate a -# script setup-build.sh from this templated file - that script can be used to -# run the python setup.py process without going through cmake. -# -# The script in question is purely a convenience for Python development, it is -# fully optional to use it, and it is not used by the main cmake based build -# system. - -cp -r @PROJECT_SOURCE_DIR@/python @PROJECT_BINARY_DIR@ -cd @PROJECT_BINARY_DIR@/python -rm -rf opm/libopmcommon_python* - -export CC=@CMAKE_CXX_COMPILER@ - -@PYTHON_EXECUTABLE@ setup.py sdist bdist_wheel build_ext \ ---library-dirs=@_setup_lib_dirs@ \ -@_rpath_arg@ \ ---include-dirs=@_setup_include_dirs@ diff --git a/ThirdParty/custom-opm-common/opm-common/python/setup-test.sh.in b/ThirdParty/custom-opm-common/opm-common/python/setup-test.sh.in index 0646c6b224..185696e1e1 100644 --- a/ThirdParty/custom-opm-common/opm-common/python/setup-test.sh.in +++ b/ThirdParty/custom-opm-common/opm-common/python/setup-test.sh.in @@ -10,8 +10,8 @@ cp -r @PROJECT_SOURCE_DIR@/python @PROJECT_BINARY_DIR@ cd @PROJECT_BINARY_DIR@/python -export PYTHONPATH=@PROJECT_BINARY_DIR@/python:$PYTHONPATH +export PYTHONPATH=@PROJECT_BINARY_DIR@/python/python:$PYTHONPATH export LD_LIBRARY_PATH=@PROJECT_BINARY_DIR@/lib:@_setup_lib_dirs@:$LD_LIBRARY_PATH -@PYTHON_EXECUTABLE@ setup.py build_ext --dry-run +@PYTHON_EXECUTABLE@ setup.py build_ext --dry-run --build-lib=python/opm test diff --git a/ThirdParty/custom-opm-common/opm-common/python/setup.py.in b/ThirdParty/custom-opm-common/opm-common/python/setup.py similarity index 78% rename from ThirdParty/custom-opm-common/opm-common/python/setup.py.in rename to ThirdParty/custom-opm-common/opm-common/python/setup.py index 88afc1229f..ce15bbe14f 100644 --- a/ThirdParty/custom-opm-common/opm-common/python/setup.py.in +++ b/ThirdParty/custom-opm-common/opm-common/python/setup.py @@ -40,7 +40,7 @@ if 'build' in sys.argv: ext_modules = [ Extension( - 'opm.libopmcommon_python', + 'libopmcommon_python', [ 'cxx/unit_system.cpp', 'cxx/connection.cpp', @@ -67,22 +67,13 @@ ext_modules = [ undef_macros=["NDEBUG"], include_dirs=["pybind11/include"], extra_compile_args=['-std=c++17', '-fopenmp'], - extra_link_args=['-fopenmp', @opm-common_PYTHON_LINKAGE@] + extra_link_args=['-fopenmp'] ) ] -with open("README.md", "r") as fh: - long_description = fh.read() - setup( - name='opm', - version = '@opm-common_VERSION@' + '@opm-common_PYTHON_PACKAGE_VERSION@', - url='http://www.opm-project.org', - author='The Open Porous Media Project', - author_email='opmuser@gmail.com', - description='OPM-Common Python bindings', - long_description=long_description, - long_description_content_type="text/markdown", + name='Opm', + package_dir = {'': 'python'}, packages=[ 'opm', 'opm.io', @@ -94,14 +85,10 @@ setup( 'opm.tools' ], ext_modules=ext_modules, + package_data={'opm': ['libopmcommon_python{}'.format(suffix)]}, include_package_data=True, license='Open Source', zip_safe=False, test_suite='tests', setup_requires=["pytest-runner", 'setuptools_scm'], - python_requires='>=3.5', - classifiers=[ - "Programming Language :: Python :: 3", - "License :: OSI Approved :: GNU General Public License v3 (GPLv3)", - ], ) diff --git a/ThirdParty/custom-opm-common/opm-common/python/tests/test_schedule.py b/ThirdParty/custom-opm-common/opm-common/python/tests/test_schedule.py index 4950cc9aba..b05c9bb975 100644 --- a/ThirdParty/custom-opm-common/opm-common/python/tests/test_schedule.py +++ b/ThirdParty/custom-opm-common/opm-common/python/tests/test_schedule.py @@ -75,15 +75,5 @@ class TestSchedule(unittest.TestCase): rst = sch.restart - def test_well_names(self): - deck = Parser().parse(test_path('spe3/SPE3CASE1.DATA')) - state = EclipseState(deck) - sch = Schedule( deck, state ) - wnames = sch.well_names("*") - self.assertTrue("PROD" in wnames) - self.assertTrue("INJ" in wnames) - self.assertEqual(len(wnames), 2) - - if __name__ == "__main__": unittest.main() diff --git a/ThirdParty/custom-opm-common/opm-common/redhat/opm-common.spec b/ThirdParty/custom-opm-common/opm-common/redhat/opm-common.spec index 0521015a27..19c4e834d1 100644 --- a/ThirdParty/custom-opm-common/opm-common/redhat/opm-common.spec +++ b/ThirdParty/custom-opm-common/opm-common/redhat/opm-common.spec @@ -5,7 +5,7 @@ %define tag final Name: opm-common -Version: 2018.10 +Version: 2020.04 Release: 0 Summary: Open Porous Media - common helpers and buildsystem License: GPL-3.0 diff --git a/ThirdParty/custom-opm-common/opm-common/src/opm/io/eclipse/ESmry.cpp b/ThirdParty/custom-opm-common/opm-common/src/opm/io/eclipse/ESmry.cpp index 6dadb2efc9..7b704b3a30 100644 --- a/ThirdParty/custom-opm-common/opm-common/src/opm/io/eclipse/ESmry.cpp +++ b/ThirdParty/custom-opm-common/opm-common/src/opm/io/eclipse/ESmry.cpp @@ -21,7 +21,6 @@ #include #include #include -#include #include #include @@ -34,7 +33,6 @@ #include #include #include -#include /* @@ -89,12 +87,10 @@ ESmry::ESmry(const std::string &filename, bool loadBaseRunData) : inputFileName { filename }, summaryNodes { } { - fromSingleRun = !loadBaseRunData; Opm::filesystem::path rootName = inputFileName.parent_path() / inputFileName.stem(); - // if only root name (without any extension) given as first argument in constructor - // binary will then be assumed + // if root name (without any extension) given as first argument in constructor, binary will then be assumed if (inputFileName.extension()=="") inputFileName+=".SMSPEC"; @@ -105,16 +101,6 @@ ESmry::ESmry(const std::string &filename, bool loadBaseRunData) : const bool formatted = inputFileName.extension()==".SMSPEC" ? false : true; formattedFiles.push_back(formatted); - if (formatted) - lodFileName = rootName += ".FLODSMRY"; - else - lodFileName = rootName += ".LODSMRY"; - - if ((!loadBaseRunData) && (Opm::filesystem::exists(lodFileName))) - lodEnabeled = true; - else - lodEnabeled = false; - Opm::filesystem::path path = Opm::filesystem::current_path(); updatePathAndRootName(path, rootName); @@ -134,38 +120,28 @@ ESmry::ESmry(const std::string &filename, bool loadBaseRunData) : "SUMTHIN", } ; - std::vector smspecList; - std::vector vectList = {"DIMENS", "RESTART", "KEYWORDS", "NUMS", "UNITS"}; - // Read data from the summary into local data members. { - smspecList.emplace_back(EclFile(smspec_file.string())); + EclFile smspec(smspec_file.string()); - auto arrays = smspecList.back().getList(); - std::vector vectIndices; + smspec.loadData(); // loading all data - for (size_t n = 0; n < arrays.size(); n++) - if(std::find(vectList.begin(), vectList.end(), std::get<0>(arrays[n])) != vectList.end()) - vectIndices.push_back(static_cast(n)); - - smspecList.back().loadData(vectIndices); - - const std::vector dimens = smspecList.back().get("DIMENS"); + const std::vector dimens = smspec.get("DIMENS"); nI = dimens[1]; // This is correct -- dimens[0] is something else! nJ = dimens[2]; nK = dimens[3]; - const std::vector restartArray = smspecList.back().get("RESTART"); - const std::vector keywords = smspecList.back().get("KEYWORDS"); - const std::vector wgnames = smspecList.back().get("WGNAMES"); - const std::vector nums = smspecList.back().get("NUMS"); - const std::vector units = smspecList.back().get("UNITS"); + const std::vector restartArray = smspec.get("RESTART"); + const std::vector keywords = smspec.get("KEYWORDS"); + const std::vector wgnames = smspec.get("WGNAMES"); + const std::vector nums = smspec.get("NUMS"); + const std::vector units = smspec.get("UNITS"); std::vector combindKeyList; combindKeyList.reserve(dimens[0]); - this->startdat = make_date(smspecList.back().get("STARTDAT")); + this->startdat = make_date(smspec.get("STARTDAT")); for (unsigned int i=0; i vectIndices; - - for (size_t n = 0; n < arrays.size(); n++) - if(std::find(vectList.begin(), vectList.end(), std::get<0>(arrays[n])) != vectList.end()) - vectIndices.push_back(static_cast(n)); - - smspecList.back().loadData(vectIndices); - - const std::vector dimens = smspecList.back().get("DIMENS"); - const std::vector restartArray = smspecList.back().get("RESTART"); - const std::vector keywords = smspecList.back().get("KEYWORDS"); - const std::vector wgnames = smspecList.back().get("WGNAMES"); - const std::vector nums = smspecList.back().get("NUMS"); - const std::vector units = smspecList.back().get("UNITS"); + const std::vector dimens = smspec_rst.get("DIMENS"); + const std::vector restartArray = smspec_rst.get("RESTART"); + const std::vector keywords = smspec_rst.get("KEYWORDS"); + const std::vector wgnames = smspec_rst.get("WGNAMES"); + const std::vector nums = smspec_rst.get("NUMS"); + const std::vector units = smspec_rst.get("UNITS"); std::vector combindKeyList; combindKeyList.reserve(dimens[0]); - this->startdat = make_date(smspecList.back().get("STARTDAT")); + this->startdat = make_date(smspec_rst.get("STARTDAT")); for (size_t i = 0; i < keywords.size(); i++) { const std::string keyString = makeKeyString(keywords[i], wgnames[i], nums[i]); @@ -274,7 +243,10 @@ ESmry::ESmry(const std::string &filename, bool loadBaseRunData) : auto smry = smryArray[specInd]; - const std::vector dimens = smspecList[specInd].get("DIMENS"); + EclFile smspec(std::get<0>(smry)); + smspec.loadData(); + + const std::vector dimens = smspec.get("DIMENS"); nI = dimens[1]; nJ = dimens[2]; @@ -282,9 +254,9 @@ ESmry::ESmry(const std::string &filename, bool loadBaseRunData) : nParamsSpecFile[specInd] = dimens[0]; - const std::vector keywords = smspecList[specInd].get("KEYWORDS"); - const std::vector wgnames = smspecList[specInd].get("WGNAMES"); - const std::vector nums = smspecList[specInd].get("NUMS"); + const std::vector keywords = smspec.get("KEYWORDS"); + const std::vector wgnames = smspec.get("WGNAMES"); + const std::vector nums = smspec.get("NUMS"); for (size_t i=0; i < keywords.size(); i++) { const std::string keyw = makeKeyString(keywords[i], wgnames[i], nums[i]); @@ -316,284 +288,132 @@ ESmry::ESmry(const std::string &filename, bool loadBaseRunData) : vectorLoaded.push_back(false); } - if (lodEnabeled) - { - // inspecting formatted or binary lod file. lodsmry possible only if - // loadBaseRunData=false + int dataFileIndex = -1; - inspect_lodsmry(); + while (specInd >= 0){ - } else { + int reportStepNumber = fromReportStepNumber; - // inspecting time step data, unified summary or multiple summary files both formatted or binary. - // this also include base run data if loadBaseRunData=true and restart runs exists. + if (specInd > 0) { + auto rstFrom = smryArray[specInd-1]; + toReportStepNumber = std::get<1>(rstFrom); + } else { + toReportStepNumber = std::numeric_limits::max(); + } - int dataFileIndex = -1; + Opm::filesystem::path smspecFile(std::get<0>(smryArray[specInd])); + rootName = smspecFile.parent_path() / smspecFile.stem(); - while (specInd >= 0) { + // check if multiple or unified result files should be used + // to import data, no information in smspec file regarding this + // if both unified and non-unified files exists, will use most recent based on + // time stamp - int reportStepNumber = fromReportStepNumber; + Opm::filesystem::path unsmryFile = rootName; - if (specInd > 0) { - auto rstFrom = smryArray[specInd-1]; - toReportStepNumber = std::get<1>(rstFrom); - } else { - toReportStepNumber = std::numeric_limits::max(); - } + unsmryFile += formattedFiles[specInd] ? ".FUNSMRY" : ".UNSMRY"; + const bool use_unified = Opm::filesystem::exists(unsmryFile.string()); - Opm::filesystem::path smspecFile(std::get<0>(smryArray[specInd])); - rootName = smspecFile.parent_path() / smspecFile.stem(); + const std::vector multFileList = checkForMultipleResultFiles(rootName, formattedFiles[specInd]); - // check if multiple or unified result files should be used - // to import data, no information in smspec file regarding this - // if both unified and non-unified files exists, will use most recent based on - // time stamp + std::vector resultsFileList; - Opm::filesystem::path unsmryFile = rootName; + if ((!use_unified) && (multFileList.size()==0)){ + throw std::runtime_error("neigther unified or non-unified result files found"); + } else if ((use_unified) && (multFileList.size()>0)){ + auto time_multiple = Opm::filesystem::last_write_time(multFileList.back()); + auto time_unified = Opm::filesystem::last_write_time(unsmryFile); - unsmryFile += formattedFiles[specInd] ? ".FUNSMRY" : ".UNSMRY"; - const bool use_unified = Opm::filesystem::exists(unsmryFile.string()); - - const std::vector multFileList = checkForMultipleResultFiles(rootName, formattedFiles[specInd]); - - std::vector resultsFileList; - - if ((!use_unified) && (multFileList.size()==0)) { - throw std::runtime_error("neigther unified or non-unified result files found"); - } else if ((use_unified) && (multFileList.size()>0)) { - auto time_multiple = Opm::filesystem::last_write_time(multFileList.back()); - auto time_unified = Opm::filesystem::last_write_time(unsmryFile); - - if (time_multiple > time_unified) { - resultsFileList=multFileList; - } else { - resultsFileList.push_back(unsmryFile.string()); - } - - } else if (use_unified) { - resultsFileList.push_back(unsmryFile.string()); - } else { + if (time_multiple > time_unified){ resultsFileList=multFileList; + } else { + resultsFileList.push_back(unsmryFile.string()); } - std::vector arraySourceList; + } else if (use_unified){ + resultsFileList.push_back(unsmryFile.string()); + } else { + resultsFileList=multFileList; + } - for (std::string fileName : resultsFileList) + // make array list with reference to source files (unifed or non unified) + + std::vector arraySourceList; + + for (std::string fileName : resultsFileList) + { + std::vector> arrayList; + arrayList = this->getListOfArrays(fileName, formattedFiles[specInd]); + + for (size_t n = 0; n < arrayList.size(); n++) { + ArrSourceEntry t1 = std::make_tuple(std::get<0>(arrayList[n]), fileName, n, std::get<1>(arrayList[n])); + arraySourceList.push_back(t1); + } + } + + // loop through arrays and for each ministep, store data file, location of params table + // + // 2 or 3 arrays pr time step. + // If timestep is a report step: MINISTEP, PARAMS and SEQHDR + // else : MINISTEP and PARAMS + + + size_t i = std::get<0>(arraySourceList[0]) == "SEQHDR" ? 1 : 0 ; + + while (i < arraySourceList.size()){ + + if (std::get<0>(arraySourceList[i]) != "MINISTEP"){ + std::string message="Reading summary file, expecting keyword MINISTEP, found '" + std::get<0>(arraySourceList[i]) + "'"; + throw std::invalid_argument(message); + } + + if (std::get<0>(arraySourceList[i+1]) != "PARAMS") { + std::string message="Reading summary file, expecting keyword PARAMS, found '" + std::get<0>(arraySourceList[i]) + "'"; + throw std::invalid_argument(message); + } + + i++; + + if (std::find(dataFileList.begin(), dataFileList.end(), std::get<1>(arraySourceList[i])) == dataFileList.end()) { - std::vector> arrayList; - arrayList = this->getListOfArrays(fileName, formattedFiles[specInd]); - - for (size_t n = 0; n < arrayList.size(); n++) { - ArrSourceEntry t1 = std::make_tuple(std::get<0>(arrayList[n]), fileName, n, std::get<1>(arrayList[n])); - arraySourceList.push_back(t1); - } + dataFileList.push_back(std::get<1>(arraySourceList[i])); + dataFileIndex++; } - // loop through arrays and for each ministep, store data file, location of params table - // - // 2 or 3 arrays pr time step. - // If timestep is a report step: MINISTEP, PARAMS and SEQHDR - // else : MINISTEP and PARAMS + TimeStepEntry t1 = std::make_tuple(specInd, dataFileIndex, std::get<3>(arraySourceList[i])); + timeStepList.push_back(t1); + i++; - size_t i = std::get<0>(arraySourceList[0]) == "SEQHDR" ? 1 : 0 ; - - while (i < arraySourceList.size()) { - - if (std::get<0>(arraySourceList[i]) != "MINISTEP") { - std::string message="Reading summary file, expecting keyword MINISTEP, found '" + std::get<0>(arraySourceList[i]) + "'"; - throw std::invalid_argument(message); - } - - if (std::get<0>(arraySourceList[i+1]) != "PARAMS") { - std::string message="Reading summary file, expecting keyword PARAMS, found '" + std::get<0>(arraySourceList[i]) + "'"; - throw std::invalid_argument(message); - } - - i++; - - if (std::find(dataFileList.begin(), dataFileList.end(), std::get<1>(arraySourceList[i])) == dataFileList.end()) - { - dataFileList.push_back(std::get<1>(arraySourceList[i])); - dataFileIndex++; - } - - TimeStepEntry t1 = std::make_tuple(specInd, dataFileIndex, std::get<3>(arraySourceList[i])); - timeStepList.push_back(t1); - - i++; - - if (i < arraySourceList.size()) { - if (std::get<0>(arraySourceList[i]) == "SEQHDR") { - i++; - reportStepNumber++; - seqIndex.push_back(step); - } - } else { + if (i < arraySourceList.size()){ + if (std::get<0>(arraySourceList[i]) == "SEQHDR") { + i++; reportStepNumber++; seqIndex.push_back(step); } - - if (reportStepNumber >= toReportStepNumber) { - i = arraySourceList.size(); - } - - step++; + } else { + reportStepNumber++; + seqIndex.push_back(step); } - fromReportStepNumber = toReportStepNumber; - - specInd--; - - nTstep = timeStepList.size(); - } - } -} - -void ESmry::inspect_lodsmry() -{ - std::string arrName; - int64_t arr_size; - Opm::EclIO::eclArrType arrType; - - std::fstream fileH; - - if (formattedFiles[0]) { - fileH.open(lodFileName, std::ios::in); - Opm::EclIO::readFormattedHeader(fileH, arrName, arr_size, arrType); - } else { - fileH.open(lodFileName, std::ios::in | std::ios::binary); - Opm::EclIO::readBinaryHeader(fileH, arrName, arr_size, arrType); - } - - if ((arrName != "KEYCHECK") or (arrType != Opm::EclIO::CHAR)) - OPM_THROW(std::invalid_argument, "reading keycheck, invalid lod file"); - - std::vector keycheck; - - if (formattedFiles[0]) { - uint64_t size = Opm::EclIO::sizeOnDiskFormatted(arr_size, Opm::EclIO::CHAR) + 1; - std::string fileStr = read_string_from_disk(fileH, size); - - keycheck = Opm::EclIO::readFormattedCharArray(fileStr, arr_size, 0); - } else { - keycheck = Opm::EclIO::readBinaryCharArray(fileH, arr_size); - } - - if ((arr_size / nVect != 3) or (arr_size % nVect != 0)) - OPM_THROW(std::invalid_argument, "reading keycheck, invalid lod file"); - - for (size_t n = 0; n < nVect; n++) { - size_t ind = n*3; - std::string test_str = keycheck[ind] + keycheck[ind+1] + keycheck[ind+2]; - - if (keyword[n].size() > 24) { - if (keyword[n].substr(0,24) != test_str) { - OPM_THROW(std::invalid_argument, "keycheck not maching keyword array"); - } - } else { - if (keyword[n] != test_str) { - OPM_THROW(std::invalid_argument, "keycheck not maching keyword array"); + if (reportStepNumber >= toReportStepNumber) { + i = arraySourceList.size(); } + + step++; } + + fromReportStepNumber = toReportStepNumber; + + specInd--; } - - if (formattedFiles[0]) - Opm::EclIO::readFormattedHeader(fileH, arrName, arr_size, arrType); - else - Opm::EclIO::readBinaryHeader(fileH, arrName, arr_size, arrType); - - if ((arrName != "RSTEP ") or (arrType != Opm::EclIO::LOGI)) - OPM_THROW(std::invalid_argument, "reading rstep, invalid lod file"); - - std::vector rstep; - - if (formattedFiles[0]) { - uint64_t size = Opm::EclIO::sizeOnDiskFormatted(arr_size, Opm::EclIO::LOGI) + 1; - std::string fileStr = read_string_from_disk(fileH, size); - - rstep = Opm::EclIO::readFormattedLogiArray(fileStr, arr_size, 0); - } else { - rstep = readBinaryLogiArray(fileH, arr_size); - } - - for (size_t m = 0; m < rstep.size(); m++) - if (rstep[m]) - seqIndex.push_back(m); - - lod_offset = static_cast(fileH.tellg()); - nTstep = rstep.size(); - - if (formattedFiles[0]) - lod_arr_size = sizeOnDiskFormatted(nTstep, Opm::EclIO::REAL); - else - lod_arr_size = sizeOnDiskBinary(nTstep, Opm::EclIO::REAL); - - fileH.close(); -} - -std::string ESmry::read_string_from_disk(std::fstream& fileH, uint64_t size) const -{ - char* buffer; - buffer = new char [size]; - fileH.read (buffer, size); - std::string fileStr = std::string(buffer, size); - delete[] buffer; - - return fileStr; -} - -void ESmry::Load_from_lodsmry(const std::vector& keywIndVect) const -{ - std::fstream fileH; - - if (formattedFiles[0]) - fileH.open(lodFileName, std::ios::in); - else - fileH.open(lodFileName, std::ios::in | std::ios::binary); - - for (auto ind : keywIndVect) { - std::string arrName; - int64_t size; - Opm::EclIO::eclArrType arrType; - - uint64_t pos = lod_offset + lod_arr_size*static_cast(ind); - - if (formattedFiles[0]) - pos = pos + static_cast(ind * 31); // adding size of formatted headers - else - pos = pos + static_cast(ind * 24); // adding size of binary headers - - fileH.seekg (pos, fileH.beg); - - if (formattedFiles[0]) - readFormattedHeader(fileH, arrName, size, arrType); - else - readBinaryHeader(fileH, arrName, size, arrType); - - arrName = Opm::EclIO::trimr(arrName); - - std::string checkName = "V" + std::to_string(ind); - - if (arrName != checkName) - OPM_THROW(std::invalid_argument, "lodsmry, wrong header expecting " + checkName + " found " + arrName); - - if (formattedFiles[0]) { - uint64_t size_buffer = lod_arr_size + 1; - std::string fileStr = read_string_from_disk(fileH, size_buffer); - vectorData[ind] = Opm::EclIO::readFormattedRealArray(fileStr, nTstep, 0); - } else { - vectorData[ind] = readBinaryRealArray(fileH, size); - } - } - - fileH.close(); } void ESmry::LoadData(const std::vector& vectList) const { size_t nvect = vectList.size(); + size_t ntstep = timeStepList.size(); std::vector keywIndVect; keywIndVect.reserve(nvect); @@ -607,104 +427,90 @@ void ESmry::LoadData(const std::vector& vectList) const } for (auto ind : keywIndVect) - vectorData[ind].reserve(nTstep); + vectorData[ind].reserve(ntstep); - if (lodEnabeled) - { - Load_from_lodsmry(keywIndVect); + std::fstream fileH; - } else { + auto specInd = std::get<0>(timeStepList[0]); + auto dataFileIndex = std::get<1>(timeStepList[0]); + uint64_t stepFilePos = std::get<2>(timeStepList[0]); - std::fstream fileH; + if (formattedFiles[specInd]) + fileH.open(dataFileList[dataFileIndex], std::ios::in); + else + fileH.open(dataFileList[dataFileIndex], std::ios::in | std::ios::binary); - auto specInd = std::get<0>(timeStepList[0]); - auto dataFileIndex = std::get<1>(timeStepList[0]); - uint64_t stepFilePos = std::get<2>(timeStepList[0]); - uint64_t blockSize_f; + for (auto ministep : timeStepList) { + if (dataFileIndex != std::get<1>(ministep)) { + fileH.close(); + specInd = std::get<0>(ministep); + dataFileIndex = std::get<1>(ministep); - { - int nLinesBlock = MaxBlockSizeReal / numColumnsReal; - int rest = MaxBlockSizeReal % numColumnsReal; - - if (rest > 0) - nLinesBlock++; - - blockSize_f= static_cast(MaxNumBlockReal * numColumnsReal * columnWidthReal + nLinesBlock); + if (formattedFiles[specInd]) + fileH.open(dataFileList[dataFileIndex], std::ios::in ); + else + fileH.open(dataFileList[dataFileIndex], std::ios::in | std::ios::binary); } - if (formattedFiles[specInd]) - fileH.open(dataFileList[dataFileIndex], std::ios::in); - else - fileH.open(dataFileList[dataFileIndex], std::ios::in | std::ios::binary); + stepFilePos = std::get<2>(ministep);; - for (auto ministep : timeStepList) { + for (auto ind : keywIndVect) { + auto it = arrayPos[specInd].find(ind); - if (dataFileIndex != std::get<1>(ministep)) { - fileH.close(); - specInd = std::get<0>(ministep); - dataFileIndex = std::get<1>(ministep); + if (it == arrayPos[specInd].end()) { + // undefined vector in current summary file. Typically when loading + // base restart run and including base run data. Vectors can be added to restart runs + vectorData[ind].push_back(nanf("")); + } else { + int paramPos = it->second; - if (formattedFiles[specInd]) - fileH.open(dataFileList[dataFileIndex], std::ios::in ); - else - fileH.open(dataFileList[dataFileIndex], std::ios::in | std::ios::binary); - } + if (formattedFiles[specInd]) { + uint64_t elementPos = 0; + int nBlocks = paramPos /MaxBlockSizeReal; + int sizeOfLastBlock = paramPos % MaxBlockSizeReal; - stepFilePos = std::get<2>(ministep);; + if (nBlocks > 0) { + int nLinesBlock = MaxNumBlockReal / numColumnsReal; + int rest = MaxNumBlockReal % numColumnsReal; - for (auto ind : keywIndVect) { + if (rest > 0) + nLinesBlock++; - auto it = arrayPos[specInd].find(ind); - - if (it == arrayPos[specInd].end()) { - // undefined vector in current summary file. Typically when loading - // base restart run and including base run data. Vectors can be added to restart runs - vectorData[ind].push_back(nanf("")); - } else { - int paramPos = it->second; - - if (formattedFiles[specInd]) { - uint64_t elementPos = 0; - int nBlocks = paramPos / MaxBlockSizeReal; - int sizeOfLastBlock = paramPos % MaxBlockSizeReal; - - if (nBlocks > 0) - elementPos = static_cast(nBlocks * blockSize_f); - - int nLines = sizeOfLastBlock / numColumnsReal; - elementPos = stepFilePos + elementPos + static_cast(sizeOfLastBlock * columnWidthReal + nLines); - - fileH.seekg (elementPos, fileH.beg); - - char* buffer; - size_t size = columnWidthReal; - buffer = new char [size]; - fileH.read (buffer, size); - double dtmpv = std::stod(std::string(buffer, size)); - vectorData[ind].push_back(static_cast(dtmpv)); - - delete[] buffer; - - } else { - - uint64_t nFullBlocks = static_cast(paramPos/(MaxBlockSizeReal / sizeOfReal)); - uint64_t elementPos = ((2 * nFullBlocks) + 1)*static_cast(sizeOfInte); - elementPos += static_cast(paramPos)* static_cast(sizeOfReal) + stepFilePos; - - fileH.seekg (elementPos, fileH.beg); - - float value; - fileH.read(reinterpret_cast(&value), sizeOfReal); - - vectorData[ind].push_back(Opm::EclIO::flipEndianFloat(value)); + uint64_t blockSize = static_cast(MaxNumBlockReal * numColumnsReal + nLinesBlock); + elementPos = static_cast(nBlocks * blockSize); } + + int nLines = sizeOfLastBlock / numColumnsReal; + elementPos = stepFilePos + elementPos + static_cast(sizeOfLastBlock * columnWidthReal + nLines); + + fileH.seekg (elementPos, fileH.beg); + + char* buffer; + size_t size = columnWidthReal; + buffer = new char [size]; + fileH.read (buffer, size); + double dtmpv = std::stod(std::string(buffer, size)); + vectorData[ind].push_back(static_cast(dtmpv)); + + delete[] buffer; + + } else { + + uint64_t nFullBlocks = static_cast(paramPos/(MaxBlockSizeReal / sizeOfReal)); + uint64_t elementPos = ((2 * nFullBlocks) + 1)*static_cast(sizeOfInte); + elementPos += static_cast(paramPos)* static_cast(sizeOfReal) + stepFilePos; + fileH.seekg (elementPos, fileH.beg); + + float value; + fileH.read(reinterpret_cast(&value), sizeOfReal); + vectorData[ind].push_back(Opm::EclIO::flipEndianFloat(value)); } } } - - fileH.close(); } + fileH.close(); + for (auto ind : keywIndVect) vectorLoaded[ind] = true; } @@ -732,116 +538,108 @@ std::vector ESmry::makeKeywPosVector(int specInd) const { void ESmry::LoadData() const { - if (lodEnabeled) { + std::fstream fileH; - this ->LoadData(keyword); + auto specInd = std::get<0>(timeStepList[0]); + auto dataFileIndex = std::get<1>(timeStepList[0]); + uint64_t stepFilePos = std::get<2>(timeStepList[0]); - } else { - std::fstream fileH; + std::vector keywpos = makeKeywPosVector(specInd); - auto specInd = std::get<0>(timeStepList[0]); - auto dataFileIndex = std::get<1>(timeStepList[0]); - uint64_t stepFilePos = std::get<2>(timeStepList[0]); + if (formattedFiles[specInd]) + fileH.open(dataFileList[dataFileIndex], std::ios::in); + else + fileH.open(dataFileList[dataFileIndex], std::ios::in | std::ios::binary); - std::vector keywpos = makeKeywPosVector(specInd); + for (auto ministep : timeStepList) { - if (formattedFiles[specInd]) - fileH.open(dataFileList[dataFileIndex], std::ios::in); - else - fileH.open(dataFileList[dataFileIndex], std::ios::in | std::ios::binary); + if (dataFileIndex != std::get<1>(ministep)) { + fileH.close(); - for (auto ministep : timeStepList) { - - if (dataFileIndex != std::get<1>(ministep)) { - fileH.close(); - - if (specInd != std::get<0>(ministep)) { - specInd = std::get<0>(ministep); - keywpos = makeKeywPosVector(specInd); - } - - dataFileIndex = std::get<1>(ministep); - - if (formattedFiles[specInd]) - fileH.open(dataFileList[dataFileIndex], std::ios::in ); - else - fileH.open(dataFileList[dataFileIndex], std::ios::in | std::ios::binary); + if (specInd != std::get<0>(ministep)){ + specInd = std::get<0>(ministep); + keywpos = makeKeywPosVector(specInd); } - stepFilePos = std::get<2>(ministep); - int maxNumberOfElements = MaxBlockSizeReal / sizeOfReal; - fileH.seekg (stepFilePos, fileH.beg); + dataFileIndex = std::get<1>(ministep); - if (formattedFiles[specInd]) { + if (formattedFiles[specInd]) + fileH.open(dataFileList[dataFileIndex], std::ios::in ); + else + fileH.open(dataFileList[dataFileIndex], std::ios::in | std::ios::binary); + } - char* buffer; - size_t size = sizeOnDiskFormatted(nParamsSpecFile[specInd], Opm::EclIO::REAL)+1; - buffer = new char [size]; - fileH.read (buffer, size); + stepFilePos = std::get<2>(ministep); + int maxNumberOfElements = MaxBlockSizeReal / sizeOfReal; + fileH.seekg (stepFilePos, fileH.beg); - std::string fileStr = std::string(buffer, size); - size_t p = 0; - int64_t p1= 0; + if (formattedFiles[specInd]) { + char* buffer; + size_t size = sizeOnDiskFormatted(nParamsSpecFile[specInd], Opm::EclIO::REAL)+1; + buffer = new char [size]; + fileH.read (buffer, size); - for (int i=0; i< nParamsSpecFile[specInd]; i++) { - p1 = fileStr.find_first_not_of(' ',p1); - int64_t p2 = fileStr.find_first_of(' ', p1); + std::string fileStr = std::string(buffer, size); + size_t p = 0; + int64_t p1= 0; - if ((keywpos[p] > -1) && (!vectorLoaded[keywpos[p]])) { - double dtmpv = std::stod(fileStr.substr(p1, p2-p1)); - vectorData[keywpos[p]].push_back(static_cast(dtmpv)); - } + for (int i=0; i< nParamsSpecFile[specInd]; i++) { + p1 = fileStr.find_first_not_of(' ',p1); + int64_t p2 = fileStr.find_first_of(' ', p1); + + if (keywpos[p] > -1) { + double dtmpv = std::stod(fileStr.substr(p1, p2-p1)); + vectorData[keywpos[p]].push_back(static_cast(dtmpv)); + } + + p1 = fileStr.find_first_not_of(' ',p2); + p++; + } + + delete[] buffer; + } else { + int64_t rest = static_cast(nParamsSpecFile[specInd]); + size_t p = 0; + + while (rest > 0) { + int dhead; + fileH.read(reinterpret_cast(&dhead), sizeof(dhead)); + dhead = Opm::EclIO::flipEndianInt(dhead); + int num = dhead / sizeOfInte; + + if ((num > maxNumberOfElements) || (num < 0)) + OPM_THROW(std::runtime_error, "??Error reading binary data, inconsistent header data or incorrect number of elements"); + + for (int i = 0; i < num; i++) { + float value; + fileH.read(reinterpret_cast(&value), sizeOfReal); + + if (keywpos[p] > -1) + vectorData[keywpos[p]].push_back(Opm::EclIO::flipEndianFloat(value)); - p1 = fileStr.find_first_not_of(' ',p2); p++; } - delete[] buffer; + rest -= num; - } else { - int64_t rest = static_cast(nParamsSpecFile[specInd]); - size_t p = 0; - - while (rest > 0) { - int dhead; - fileH.read(reinterpret_cast(&dhead), sizeof(dhead)); - dhead = Opm::EclIO::flipEndianInt(dhead); - int num = dhead / sizeOfInte; - - if ((num > maxNumberOfElements) || (num < 0)) - OPM_THROW(std::runtime_error, "??Error reading binary data, inconsistent header data or incorrect number of elements"); - - for (int i = 0; i < num; i++) { - float value; - fileH.read(reinterpret_cast(&value), sizeOfReal); - - if ((keywpos[p] > -1) && (!vectorLoaded[keywpos[p]])) - vectorData[keywpos[p]].push_back(Opm::EclIO::flipEndianFloat(value)); - - p++; - } - - rest -= num; - - if (( num < maxNumberOfElements && rest != 0) || - (num == maxNumberOfElements && rest < 0)) { - std::string message = "Error reading binary data, incorrect number of elements"; - OPM_THROW(std::runtime_error, message); - } - - int dtail; - fileH.read(reinterpret_cast(&dtail), sizeof(dtail)); - dtail = Opm::EclIO::flipEndianInt(dtail); - - if (dhead != dtail) - OPM_THROW(std::runtime_error, "Error reading binary data, tail not matching header."); + if (( num < maxNumberOfElements && rest != 0) || + (num == maxNumberOfElements && rest < 0)) { + std::string message = "Error reading binary data, incorrect number of elements"; + OPM_THROW(std::runtime_error, message); } + + int dtail; + fileH.read(reinterpret_cast(&dtail), sizeof(dtail)); + dtail = Opm::EclIO::flipEndianInt(dtail); + + if (dhead != dtail) + OPM_THROW(std::runtime_error, "Error reading binary data, tail not matching header."); } } - - for (size_t n=0; n < nVect; n++) - vectorLoaded[n] = true; } + + for (size_t n=0; n < nVect; n++) + vectorLoaded[n] = true; } @@ -849,80 +647,24 @@ std::vector> ESmry::getListOfArrays(std::string filename, bool formatted) { std::vector> resultVect; - - FILE *ptr; - char arrName[9]; - char numstr[13]; - - int64_t num; + std::fstream fileH; if (formatted) - ptr = fopen(filename.c_str(),"r"); // r for read, files opened as text files + fileH.open(filename, std::ios::in); else - ptr = fopen(filename.c_str(),"rb"); // r for read, b for binary + fileH.open(filename, std::ios::in | std::ios::binary); - bool endOfFile = false; - - while (!endOfFile) - { + while (!Opm::EclIO::isEOF(&fileH)) { + std::string arrName(8,' '); Opm::EclIO::eclArrType arrType; + int64_t num; if (formatted) - { - fseek(ptr, 2, SEEK_CUR); + Opm::EclIO::readFormattedHeader(fileH,arrName,num,arrType); + else + Opm::EclIO::readBinaryHeader(fileH,arrName,num,arrType); - if (fread(arrName, 8, 1, ptr) != 1 ) - throw std::runtime_error("fread error when loading summary data"); - - arrName[8]='\0'; - - fseek(ptr, 1, SEEK_CUR); - - if (fread(numstr, 12, 1, ptr) != 1) - throw std::runtime_error("fread error when loading summary data"); - - numstr[12]='\0'; - - int num_int = std::stoi(numstr); - num = static_cast(num_int); - - fseek(ptr, 8, SEEK_CUR); - - if ((strcmp(arrName, "SEQHDR ") == 0) || (strcmp(arrName, "MINISTEP") == 0)) - arrType = Opm::EclIO::INTE; - else if (strcmp(arrName, "PARAMS ") == 0) - arrType = Opm::EclIO::REAL; - else { - throw std::invalid_argument("unknown array in summary data file "); - } - - } else { - int num_int; - - fseek(ptr, 4, SEEK_CUR); - - if (fread(arrName, 8, 1, ptr) != 1) - throw std::runtime_error("fread error when loading summary data"); - - arrName[8]='\0'; - - if (fread(&num_int, 4, 1, ptr) != 1) - throw std::runtime_error("fread error when loading summary data"); - - num = static_cast(Opm::EclIO::flipEndianInt(num_int)); - - fseek(ptr, 8, SEEK_CUR); - - if ((strcmp(arrName, "SEQHDR ") == 0) || (strcmp(arrName, "MINISTEP") == 0)) - arrType = Opm::EclIO::INTE; - else if (strcmp(arrName, "PARAMS ") == 0) - arrType = Opm::EclIO::REAL; - else { - throw std::invalid_argument("unknown array in UNSMRY file "); - } - } - - uint64_t filePos = static_cast(ftell(ptr)); + uint64_t filePos = fileH.tellg(); std::tuple t1; t1 = std::make_tuple(Opm::EclIO::trimr(arrName), filePos); @@ -931,106 +673,20 @@ ESmry::getListOfArrays(std::string filename, bool formatted) if (num > 0) { if (formatted) { uint64_t sizeOfNextArray = sizeOnDiskFormatted(num, arrType); - fseek(ptr, static_cast(sizeOfNextArray), SEEK_CUR); + fileH.seekg(static_cast(sizeOfNextArray), std::ios_base::cur); + } else { uint64_t sizeOfNextArray = sizeOnDiskBinary(num, arrType); - fseek(ptr, static_cast(sizeOfNextArray), SEEK_CUR); + fileH.seekg(static_cast(sizeOfNextArray), std::ios_base::cur); } } - - if (fgetc(ptr) == EOF) - endOfFile = true; - else - fseek(ptr, -1, SEEK_CUR); } - fclose(ptr); + fileH.close(); return resultVect; } -bool ESmry::make_lodsmry_file() -{ - // check that loadBaseRunData is not set, this function only works for single smspec files - // function will not replace existing lodsmry files (since this is already loaded by this class) - // if lodsmry file exist, this function will return false and do nothing. - - if (!fromSingleRun) - OPM_THROW(std::invalid_argument, "creating lodsmry file only possible when loadBaseRunData=false"); - - Opm::filesystem::path path = inputFileName.parent_path(); - Opm::filesystem::path rootName = inputFileName.stem(); - Opm::filesystem::path smryDataFile; - - if (formattedFiles[0]) - smryDataFile = path / rootName += ".FLODSMRY"; - else - smryDataFile = path / rootName += ".LODSMRY"; - - if (Opm::EclIO::fileExists(smryDataFile)) - { - return false; - - } else { - - std::vector keycheck; - keycheck.reserve(keyword.size()); - - std::string str1; - std::string str2; - std::string str3; - - for (auto key : keyword){ - - str2=""; - str3=""; - - if (key.size() > 24) - str1 = key.substr(0,24); - else - str1 = key; - - if (str1.size() > 8){ - str2 = str1.substr(8); - str1 = str1.substr(0,8); - } - - if (str2.size() > 8){ - str3 = str2.substr(8); - str2 = str2.substr(0,8); - } - - keycheck.push_back(str1); - keycheck.push_back(str2); - keycheck.push_back(str3); - } - - std::vector is_rstep; - is_rstep.reserve(timeStepList.size()); - - for (size_t i = 0; i < timeStepList.size(); i++) - if(std::find(seqIndex.begin(), seqIndex.end(), i) != seqIndex.end()) - is_rstep.push_back(true); - else - is_rstep.push_back(false); - - this->LoadData(); - - { - Opm::EclIO::EclOutput outFile(smryDataFile, formattedFiles[0], std::ios::out); - outFile.write("KEYCHECK", keycheck); - outFile.write("RSTEP", is_rstep); - - for (size_t n = 0; n < vectorData.size(); n++ ) { - std::string vect_name="V" + std::to_string(n); - outFile.write(vect_name, vectorData[n]); - } - } - - return true; - } -} - std::vector ESmry::checkForMultipleResultFiles(const Opm::filesystem::path& rootN, bool formatted) const { diff --git a/ThirdParty/custom-opm-common/opm-common/src/opm/io/eclipse/EclFile.cpp b/ThirdParty/custom-opm-common/opm-common/src/opm/io/eclipse/EclFile.cpp index e906e0a710..e3f9c7212e 100644 --- a/ThirdParty/custom-opm-common/opm-common/src/opm/io/eclipse/EclFile.cpp +++ b/ThirdParty/custom-opm-common/opm-common/src/opm/io/eclipse/EclFile.cpp @@ -34,6 +34,247 @@ #include +// anonymous namespace for EclFile + +namespace { + +bool fileExists(const std::string& filename){ + + std::ifstream fileH(filename.c_str()); + return fileH.good(); +} + +bool isFormatted(const std::string& filename) +{ + const auto p = filename.find_last_of("."); + if (p == std::string::npos) + OPM_THROW(std::invalid_argument, + "Purported ECLIPSE Filename'" + filename + "'does not contain extension"); + return std::strchr("ABCFGH", static_cast(filename[p+1])) != nullptr; +} + + +template +std::vector readBinaryArray(std::fstream& fileH, const int64_t size, Opm::EclIO::eclArrType type, + std::function& flip) +{ + std::vector arr; + + auto sizeData = block_size_data_binary(type); + int sizeOfElement = std::get<0>(sizeData); + int maxBlockSize = std::get<1>(sizeData); + int maxNumberOfElements = maxBlockSize / sizeOfElement; + + arr.reserve(size); + + int64_t rest = size; + while (rest > 0) { + int dhead; + fileH.read(reinterpret_cast(&dhead), sizeof(dhead)); + dhead = Opm::EclIO::flipEndianInt(dhead); + + int num = dhead / sizeOfElement; + + if ((num > maxNumberOfElements) || (num < 0)) { + OPM_THROW(std::runtime_error, "Error reading binary data, inconsistent header data or incorrect number of elements"); + } + + for (int i = 0; i < num; i++) { + T2 value; + fileH.read(reinterpret_cast(&value), sizeOfElement); + arr.push_back(flip(value)); + } + + rest -= num; + + if (( num < maxNumberOfElements && rest != 0) || + (num == maxNumberOfElements && rest < 0)) { + std::string message = "Error reading binary data, incorrect number of elements"; + OPM_THROW(std::runtime_error, message); + } + + int dtail; + fileH.read(reinterpret_cast(&dtail), sizeof(dtail)); + dtail = Opm::EclIO::flipEndianInt(dtail); + + if (dhead != dtail) { + OPM_THROW(std::runtime_error, "Error reading binary data, tail not matching header."); + } + } + + return arr; +} + + +std::vector readBinaryInteArray(std::fstream &fileH, const int64_t size) +{ + std::function f = Opm::EclIO::flipEndianInt; + return readBinaryArray(fileH, size, Opm::EclIO::INTE, f); +} + + +std::vector readBinaryRealArray(std::fstream& fileH, const int64_t size) +{ + std::function f = Opm::EclIO::flipEndianFloat; + return readBinaryArray(fileH, size, Opm::EclIO::REAL, f); +} + + +std::vector readBinaryDoubArray(std::fstream& fileH, const int64_t size) +{ + std::function f = Opm::EclIO::flipEndianDouble; + return readBinaryArray(fileH, size, Opm::EclIO::DOUB, f); +} + +std::vector readBinaryLogiArray(std::fstream &fileH, const int64_t size) +{ + std::function f = [](unsigned int intVal) + { + bool value; + if (intVal == Opm::EclIO::true_value) { + value = true; + } else if (intVal == Opm::EclIO::false_value) { + value = false; + } else { + OPM_THROW(std::runtime_error, "Error reading logi value"); + } + + return value; + }; + return readBinaryArray(fileH, size, Opm::EclIO::LOGI, f); +} + + +std::vector readBinaryCharArray(std::fstream& fileH, const int64_t size) +{ + using Char8 = std::array; + std::function f = [](const Char8& val) + { + std::string res(val.begin(), val.end()); + return Opm::EclIO::trimr(res); + }; + return readBinaryArray(fileH, size, Opm::EclIO::CHAR, f); +} + + +template +std::vector readFormattedArray(const std::string& file_str, const int size, int64_t fromPos, + std::function& process) +{ + std::vector arr; + + arr.reserve(size); + + int64_t p1=fromPos; + + for (int i=0; i< size; i++) { + p1 = file_str.find_first_not_of(' ',p1); + int64_t p2 = file_str.find_first_of(' ', p1); + + arr.push_back(process(file_str.substr(p1, p2-p1))); + + p1 = file_str.find_first_not_of(' ',p2); + } + + return arr; + +} + + +std::vector readFormattedInteArray(const std::string& file_str, const int64_t size, int64_t fromPos) +{ + + std::function f = [](const std::string& val) + { + return std::stoi(val); + }; + + return readFormattedArray(file_str, size, fromPos, f); +} + + +std::vector readFormattedCharArray(const std::string& file_str, const int64_t size, int64_t fromPos) +{ + std::vector arr; + arr.reserve(size); + + int64_t p1=fromPos; + + for (int i=0; i< size; i++) { + p1 = file_str.find_first_of('\'',p1); + std::string value = file_str.substr(p1 + 1, 8); + + if (value == " ") { + arr.push_back(""); + } else { + arr.push_back(Opm::EclIO::trimr(value)); + } + + p1 = p1+10; + } + + return arr; +} + + +std::vector readFormattedRealArray(const std::string& file_str, const int64_t size, int64_t fromPos) +{ + + std::function f = [](const std::string& val) + { + // tskille: temporary fix, need to be discussed. OPM flow writes numbers + // that are outside valid range for float, and function stof will fail + double dtmpv = std::stod(val); + return dtmpv; + }; + + return readFormattedArray(file_str, size, fromPos, f); +} + + +std::vector readFormattedLogiArray(const std::string& file_str, const int64_t size, int64_t fromPos) +{ + + std::function f = [](const std::string& val) + { + if (val[0] == 'T') { + return true; + } else if (val[0] == 'F') { + return false; + } else { + std::string message="Could not convert '" + val + "' to a bool value "; + OPM_THROW(std::invalid_argument, message); + } + }; + + return readFormattedArray(file_str, size, fromPos, f); +} + +std::vector readFormattedDoubArray(const std::string& file_str, const int64_t size, int64_t fromPos) +{ + + std::function f = [](std::string val) + { + auto p1 = val.find_first_of("D"); + + if (p1 == std::string::npos) { + auto p2 = val.find_first_of("-+", 1); + if (p2 != std::string::npos) { + val = val.insert(p2,"E"); + } + } else { + val.replace(p1,1,"E"); + } + + return std::stod(val); + }; + + return readFormattedArray(file_str, size, fromPos, f); +} + +} // anonymous namespace + +// ========================================================================== namespace Opm { namespace EclIO { @@ -64,7 +305,7 @@ EclFile::EclFile(const std::string& filename, bool preload) : inputFilename(file std::string arrName(8,' '); eclArrType arrType; int64_t num; - + if (formatted) { readFormattedHeader(fileH,arrName,num,arrType); } else { @@ -82,7 +323,7 @@ EclFile::EclFile(const std::string& filename, bool preload) : inputFilename(file arrayLoaded.push_back(false); - if (num > 0){ + if (num > 0){ if (formatted) { uint64_t sizeOfNextArray = sizeOnDiskFormatted(num, arrType); fileH.seekg(static_cast(sizeOfNextArray), std::ios_base::cur); diff --git a/ThirdParty/custom-opm-common/opm-common/src/opm/io/eclipse/EclUtil.cpp b/ThirdParty/custom-opm-common/opm-common/src/opm/io/eclipse/EclUtil.cpp index c0207521b3..1f28a5c650 100644 --- a/ThirdParty/custom-opm-common/opm-common/src/opm/io/eclipse/EclUtil.cpp +++ b/ThirdParty/custom-opm-common/opm-common/src/opm/io/eclipse/EclUtil.cpp @@ -23,11 +23,9 @@ #include #include -#include #include #include #include -#include int Opm::EclIO::flipEndianInt(int num) @@ -63,21 +61,6 @@ double Opm::EclIO::flipEndianDouble(double num) return value; } -bool Opm::EclIO::fileExists(const std::string& filename){ - - std::ifstream fileH(filename.c_str()); - return fileH.good(); -} - -bool Opm::EclIO::isFormatted(const std::string& filename) -{ - const auto p = filename.find_last_of("."); - if (p == std::string::npos) - OPM_THROW(std::invalid_argument, - "Purported ECLIPSE Filename'" + filename + "'does not contain extension"); - return std::strchr("ABCFGH", static_cast(filename[p+1])) != nullptr; -} - bool Opm::EclIO::isEOF(std::fstream* fileH) { int num; @@ -357,222 +340,3 @@ void Opm::EclIO::readFormattedHeader(std::fstream& fileH, std::string& arrName, OPM_THROW(std::runtime_error, "Header name should be 8 characters"); } } - -template -std::vector Opm::EclIO::readBinaryArray(std::fstream& fileH, const int64_t size, Opm::EclIO::eclArrType type, - std::function& flip) -{ - std::vector arr; - - auto sizeData = block_size_data_binary(type); - int sizeOfElement = std::get<0>(sizeData); - int maxBlockSize = std::get<1>(sizeData); - int maxNumberOfElements = maxBlockSize / sizeOfElement; - - arr.reserve(size); - - int64_t rest = size; - while (rest > 0) { - int dhead; - fileH.read(reinterpret_cast(&dhead), sizeof(dhead)); - dhead = Opm::EclIO::flipEndianInt(dhead); - - int num = dhead / sizeOfElement; - - if ((num > maxNumberOfElements) || (num < 0)) { - OPM_THROW(std::runtime_error, "Error reading binary data, inconsistent header data or incorrect number of elements"); - } - - for (int i = 0; i < num; i++) { - T2 value; - fileH.read(reinterpret_cast(&value), sizeOfElement); - arr.push_back(flip(value)); - } - - rest -= num; - - if (( num < maxNumberOfElements && rest != 0) || - (num == maxNumberOfElements && rest < 0)) { - std::string message = "Error reading binary data, incorrect number of elements"; - OPM_THROW(std::runtime_error, message); - } - - int dtail; - fileH.read(reinterpret_cast(&dtail), sizeof(dtail)); - dtail = Opm::EclIO::flipEndianInt(dtail); - - if (dhead != dtail) { - OPM_THROW(std::runtime_error, "Error reading binary data, tail not matching header."); - } - } - - return arr; -} - - -std::vector Opm::EclIO::readBinaryInteArray(std::fstream &fileH, const int64_t size) -{ - std::function f = Opm::EclIO::flipEndianInt; - return readBinaryArray(fileH, size, Opm::EclIO::INTE, f); -} - - -std::vector Opm::EclIO::readBinaryRealArray(std::fstream& fileH, const int64_t size) -{ - std::function f = Opm::EclIO::flipEndianFloat; - return readBinaryArray(fileH, size, Opm::EclIO::REAL, f); -} - - -std::vector Opm::EclIO::readBinaryDoubArray(std::fstream& fileH, const int64_t size) -{ - std::function f = Opm::EclIO::flipEndianDouble; - return readBinaryArray(fileH, size, Opm::EclIO::DOUB, f); -} - -std::vector Opm::EclIO::readBinaryLogiArray(std::fstream &fileH, const int64_t size) -{ - std::function f = [](unsigned int intVal) - { - bool value; - if (intVal == Opm::EclIO::true_value) { - value = true; - } else if (intVal == Opm::EclIO::false_value) { - value = false; - } else { - OPM_THROW(std::runtime_error, "Error reading logi value"); - } - - return value; - }; - return readBinaryArray(fileH, size, Opm::EclIO::LOGI, f); -} - - -std::vector Opm::EclIO::readBinaryCharArray(std::fstream& fileH, const int64_t size) -{ - using Char8 = std::array; - std::function f = [](const Char8& val) - { - std::string res(val.begin(), val.end()); - return Opm::EclIO::trimr(res); - }; - return readBinaryArray(fileH, size, Opm::EclIO::CHAR, f); -} - - -template -std::vector Opm::EclIO::readFormattedArray(const std::string& file_str, const int size, int64_t fromPos, - std::function& process) -{ - std::vector arr; - - arr.reserve(size); - - int64_t p1=fromPos; - - for (int i=0; i< size; i++) { - p1 = file_str.find_first_not_of(' ',p1); - int64_t p2 = file_str.find_first_of(' ', p1); - - arr.push_back(process(file_str.substr(p1, p2-p1))); - - p1 = file_str.find_first_not_of(' ',p2); - } - - return arr; - -} - - -std::vector Opm::EclIO::readFormattedInteArray(const std::string& file_str, const int64_t size, int64_t fromPos) -{ - - std::function f = [](const std::string& val) - { - return std::stoi(val); - }; - - return readFormattedArray(file_str, size, fromPos, f); -} - - -std::vector Opm::EclIO::readFormattedCharArray(const std::string& file_str, const int64_t size, int64_t fromPos) -{ - std::vector arr; - arr.reserve(size); - - int64_t p1=fromPos; - - for (int i=0; i< size; i++) { - p1 = file_str.find_first_of('\'',p1); - std::string value = file_str.substr(p1 + 1, 8); - - if (value == " ") { - arr.push_back(""); - } else { - arr.push_back(Opm::EclIO::trimr(value)); - } - - p1 = p1+10; - } - - return arr; -} - - -std::vector Opm::EclIO::readFormattedRealArray(const std::string& file_str, const int64_t size, int64_t fromPos) -{ - - std::function f = [](const std::string& val) - { - // tskille: temporary fix, need to be discussed. OPM flow writes numbers - // that are outside valid range for float, and function stof will fail - double dtmpv = std::stod(val); - return dtmpv; - }; - - return readFormattedArray(file_str, size, fromPos, f); -} - - -std::vector Opm::EclIO::readFormattedLogiArray(const std::string& file_str, const int64_t size, int64_t fromPos) -{ - - std::function f = [](const std::string& val) - { - if (val[0] == 'T') { - return true; - } else if (val[0] == 'F') { - return false; - } else { - std::string message="Could not convert '" + val + "' to a bool value "; - OPM_THROW(std::invalid_argument, message); - } - }; - - return readFormattedArray(file_str, size, fromPos, f); -} - -std::vector Opm::EclIO::readFormattedDoubArray(const std::string& file_str, const int64_t size, int64_t fromPos) -{ - - std::function f = [](std::string val) - { - auto p1 = val.find_first_of("D"); - - if (p1 == std::string::npos) { - auto p2 = val.find_first_of("-+", 1); - if (p2 != std::string::npos) { - val = val.insert(p2,"E"); - } - } else { - val.replace(p1,1,"E"); - } - - return std::stod(val); - }; - - return readFormattedArray(file_str, size, fromPos, f); -} - diff --git a/ThirdParty/custom-opm-common/opm-common/src/opm/io/eclipse/SummaryNode.cpp b/ThirdParty/custom-opm-common/opm-common/src/opm/io/eclipse/SummaryNode.cpp index 3e410c0d12..1c1fb833af 100644 --- a/ThirdParty/custom-opm-common/opm-common/src/opm/io/eclipse/SummaryNode.cpp +++ b/ThirdParty/custom-opm-common/opm-common/src/opm/io/eclipse/SummaryNode.cpp @@ -120,7 +120,7 @@ bool Opm::EclIO::SummaryNode::is_user_defined() const { "SURFWNUM", } ; - static const std::regex user_defined_regex { "[ABCFGRSW]U[A-Z0-9]+" } ; + static const std::regex user_defined_regex { "[ABCFGRSW]U[A-Z]+" } ; const bool matched { std::regex_match(keyword, user_defined_regex) } ; const bool blacklisted { udq_blacklist.find(keyword) != udq_blacklist.end() } ; diff --git a/ThirdParty/custom-opm-common/opm-common/src/opm/io/eclipse/rst/segment.cpp b/ThirdParty/custom-opm-common/opm-common/src/opm/io/eclipse/rst/segment.cpp index 2a5aad35c8..cf70677f24 100644 --- a/ThirdParty/custom-opm-common/opm-common/src/opm/io/eclipse/rst/segment.cpp +++ b/ThirdParty/custom-opm-common/opm-common/src/opm/io/eclipse/rst/segment.cpp @@ -23,8 +23,6 @@ #include #include -#include "src/opm/parser/eclipse/EclipseState/Schedule/MSW/icd_convert.hpp" - namespace VI = ::Opm::RestartIO::Helpers::VectorItems; namespace Opm { diff --git a/ThirdParty/custom-opm-common/opm-common/src/opm/io/eclipse/rst/well.cpp b/ThirdParty/custom-opm-common/opm-common/src/opm/io/eclipse/rst/well.cpp index fa6a3bb9de..7d3ca9b57b 100644 --- a/ThirdParty/custom-opm-common/opm-common/src/opm/io/eclipse/rst/well.cpp +++ b/ThirdParty/custom-opm-common/opm-common/src/opm/io/eclipse/rst/well.cpp @@ -87,7 +87,6 @@ RstWell::RstWell(const ::Opm::UnitSystem& unit_system, gas_rate( unit_system.to_si(M::gas_surface_rate, xwel[VI::XWell::GasPrRate])), liquid_rate( unit_system.to_si(M::rate, xwel[VI::XWell::LiqPrRate])), void_rate( unit_system.to_si(M::rate, xwel[VI::XWell::VoidPrRate])), - thp( unit_system.to_si(M::pressure, xwel[VI::XWell::TubHeadPr])), flow_bhp( unit_system.to_si(M::pressure, xwel[VI::XWell::FlowBHP])), wct( unit_system.to_si(M::water_cut, xwel[VI::XWell::WatCut])), gor( unit_system.to_si(M::gas_oil_ratio, xwel[VI::XWell::GORatio])), diff --git a/ThirdParty/custom-opm-common/opm-common/src/opm/json/JsonObject.cpp b/ThirdParty/custom-opm-common/opm-common/src/opm/json/JsonObject.cpp index 5be7638131..1774d97041 100644 --- a/ThirdParty/custom-opm-common/opm-common/src/opm/json/JsonObject.cpp +++ b/ThirdParty/custom-opm-common/opm-common/src/opm/json/JsonObject.cpp @@ -47,78 +47,6 @@ namespace Json { } - JsonObject::JsonObject() { - this->owner = true; - this->root = cJSON_CreateObject(); - } - - - void JsonObject::add_item(const std::string& key, const std::string& value) { - cJSON_AddStringToObject(this->root, key.c_str(), value.c_str()); - } - - void JsonObject::add_item(const std::string& key, int value) { - cJSON_AddNumberToObject(this->root, key.c_str(), value); - } - - void JsonObject::add_item(const std::string& key, double value) { - cJSON_AddNumberToObject(this->root, key.c_str(), value); - } - - JsonObject JsonObject::add_array(const std::string& key) { - return JsonObject( cJSON_AddArrayToObject(this->root, key.c_str()) ); - } - - JsonObject JsonObject::add_object(const std::string& key) { - return JsonObject( cJSON_AddObjectToObject(this->root, key.c_str()) ); - } - - void JsonObject::add(const std::string& value) { - if (this->is_array()) - cJSON_AddItemToArray(this->root, cJSON_CreateString( value.c_str() )); - else - throw std::invalid_argument("Item is not an array"); - } - - void JsonObject::add(int value) { - if (this->is_array()) - cJSON_AddItemToArray(this->root, cJSON_CreateNumber( value )); - else - throw std::invalid_argument("Item is not an array"); - } - - void JsonObject::add(double value) { - if (this->is_array()) - cJSON_AddItemToArray(this->root, cJSON_CreateNumber( value )); - else - throw std::invalid_argument("Item is not an array"); - } - - JsonObject JsonObject::add_array() { - if (this->is_array()) { - cJSON_AddItemToArray(this->root, cJSON_CreateArray()); - return JsonObject( this->get_array_item( this->size() - 1)); - } - else - throw std::invalid_argument("Item is not an array"); - } - - JsonObject JsonObject::add_object() { - if (this->is_array()) { - cJSON_AddItemToArray(this->root, cJSON_CreateObject( )); - return JsonObject( this->get_array_item( this->size() - 1)); - } else - throw std::invalid_argument("Item is not an array"); - } - - std::string JsonObject::dump() const { - char * c_str = cJSON_Print( this->root ); - std::string str(c_str); - free( c_str ); - return str; - } - - JsonObject::JsonObject(const Opm::filesystem::path& jsonFile ) { std::ifstream stream(jsonFile.string().c_str()); diff --git a/ThirdParty/custom-opm-common/opm-common/src/opm/output/eclipse/AggregateActionxData.cpp b/ThirdParty/custom-opm-common/opm-common/src/opm/output/eclipse/AggregateActionxData.cpp index f45b797f30..656217298e 100644 --- a/ThirdParty/custom-opm-common/opm-common/src/opm/output/eclipse/AggregateActionxData.cpp +++ b/ThirdParty/custom-opm-common/opm-common/src/opm/output/eclipse/AggregateActionxData.cpp @@ -42,9 +42,8 @@ #include #include #include -#include -#include #include +#include // ##################################################################### // Class Opm::RestartIO::Helpers @@ -480,18 +479,18 @@ const std::map cmpToIndex = { } Opm::Action::Result - act_res(const Opm::Schedule& sched, const Opm::Action::State& action_state, const Opm::SummaryState& smry, const std::size_t sim_step, std::vector::const_iterator act_x) { + act_res(const Opm::Schedule& sched, const Opm::SummaryState& smry, const std::size_t sim_step, std::vector::const_iterator act_x) { + Opm::Action::Result ar(false); + Opm::Action::Context context(smry); auto sim_time = sched.simTime(sim_step); - if (act_x->ready(action_state, sim_time)) { - Opm::Action::Context context(smry, sched.getWListManager(sim_step)); - return act_x->eval(context); - } else - return Opm::Action::Result(false); + if (act_x->ready(sim_time)) { + ar = act_x->eval(sim_time, context); + } + return {ar}; } template void staticContrib(std::vector::const_iterator actx_it, - const Opm::Action::State& action_state, const Opm::SummaryState& st, const Opm::Schedule& sched, const std::size_t simStep, @@ -501,7 +500,7 @@ const std::map cmpToIndex = { int noEPZacn = 16; double undef_high_val = 1.0E+20; const auto& wells = sched.getWells(simStep); - const auto ar = sACN::act_res(sched, action_state, st, simStep, actx_it); + const auto ar = sACN::act_res(sched, st, simStep, actx_it); // write out the schedule Actionx conditions const auto& actx_cond = actx_it->conditions(); for (const auto& z_data : actx_cond) { @@ -575,19 +574,24 @@ const std::map cmpToIndex = { //Treat well, group and field left hand side conditions if (it_lhsq != lhsQuantityToIndex.end()) { + std::string wn = ""; //Well variable - if (it_lhsq->first == "W" && ar) { + if (it_lhsq->first == "W") { //find the well that violates action if relevant - auto well_iter = std::find_if(wells.begin(), wells.end(), [&ar](const Opm::Well& well) { return ar.has_well(well.name()); }); - if (well_iter != wells.end()) { - const auto& wn = well_iter->name(); - - if (st.has_well_var(wn, z_data.lhs.quantity)) { - sAcn[ind + 4] = st.get_well_var(wn, z_data.lhs.quantity); - sAcn[ind + 6] = st.get_well_var(wn, z_data.lhs.quantity); - sAcn[ind + 8] = st.get_well_var(wn, z_data.lhs.quantity); + for (const auto& well : wells) + { + if (ar.has_well(well.name())) { + //set well name + wn = well.name(); + break; } } + + if ((it_lhsq->first == "W") && (st.has_well_var(wn, z_data.lhs.quantity)) ) { + sAcn[ind + 4] = st.get_well_var(wn, z_data.lhs.quantity); + sAcn[ind + 6] = st.get_well_var(wn, z_data.lhs.quantity); + sAcn[ind + 8] = st.get_well_var(wn, z_data.lhs.quantity); + } } //group variable if ((it_lhsq->first == "G") && (st.has_group_var(z_data.lhs.args[0], z_data.lhs.quantity))) { @@ -628,11 +632,10 @@ AggregateActionxData(const std::vector& actDims) void Opm::RestartIO::Helpers::AggregateActionxData:: -captureDeclaredActionxData( const Opm::Schedule& sched, - const Opm::Action::State& action_state, - const Opm::SummaryState& st, - const std::vector& actDims, - const std::size_t simStep) +captureDeclaredActionxData( const Opm::Schedule& sched, + const Opm::SummaryState& st, + const std::vector& actDims, + const std::size_t simStep) { const auto& acts = sched.actions(simStep); std::size_t act_ind = 0; @@ -669,7 +672,7 @@ captureDeclaredActionxData( const Opm::Schedule& sched, { auto s_acn = this->sACN_[act_ind]; - sACN::staticContrib(actx_it, action_state, st, sched, simStep, s_acn); + sACN::staticContrib(actx_it, st, sched, simStep, s_acn); } act_ind +=1; diff --git a/ThirdParty/custom-opm-common/opm-common/src/opm/output/eclipse/AggregateConnectionData.cpp b/ThirdParty/custom-opm-common/opm-common/src/opm/output/eclipse/AggregateConnectionData.cpp index 59ebca6627..4f01dbb501 100644 --- a/ThirdParty/custom-opm-common/opm-common/src/opm/output/eclipse/AggregateConnectionData.cpp +++ b/ThirdParty/custom-opm-common/opm-common/src/opm/output/eclipse/AggregateConnectionData.cpp @@ -169,16 +169,12 @@ namespace { sConn[Ix::EffectiveKH] = scprop(M::effective_Kh, conn.Kh()); - sConn[Ix::SkinFactor] = conn.skinFactor(); + sConn[Ix::SkinFactor] = conn.skinFactor(); sConn[Ix::item12] = sConn[Ix::ConnTrans]; - - if (conn.attachedToSegment()) { - const auto& [start, end] = *conn.perf_range(); - sConn[Ix::SegDistStart] = scprop(M::length, start); - sConn[Ix::SegDistEnd] = scprop(M::length, end); - } + sConn[Ix::SegDistEnd] = scprop(M::length, conn.getSegDistEnd()); + sConn[Ix::SegDistStart] = scprop(M::length, conn.getSegDistStart()); sConn[Ix::item30] = -1.0e+20f; sConn[Ix::item31] = -1.0e+20f; diff --git a/ThirdParty/custom-opm-common/opm-common/src/opm/output/eclipse/AggregateGroupData.cpp b/ThirdParty/custom-opm-common/opm-common/src/opm/output/eclipse/AggregateGroupData.cpp index de062be2ac..340cd228c0 100644 --- a/ThirdParty/custom-opm-common/opm-common/src/opm/output/eclipse/AggregateGroupData.cpp +++ b/ThirdParty/custom-opm-common/opm-common/src/opm/output/eclipse/AggregateGroupData.cpp @@ -20,8 +20,6 @@ #include #include #include -#include -#include #include #include @@ -34,15 +32,10 @@ #include #include #include +#include #include #include -#define ENABLE_GCNTL_DEBUG_OUTPUT 0 - -#if ENABLE_GCNTL_DEBUG_OUTPUT -#include -#endif // ENABLE_GCNTL_DEBUG_OUTPUT - // ##################################################################### // Class Opm::RestartIO::Helpers::AggregateGroupData // --------------------------------------------------------------------- @@ -53,13 +46,13 @@ namespace { // maximum number of groups std::size_t ngmaxz(const std::vector& inteHead) { - return inteHead[Opm::RestartIO::Helpers::VectorItems::NGMAXZ]; + return inteHead[20]; } // maximum number of wells in any group int nwgmax(const std::vector& inteHead) { - return inteHead[Opm::RestartIO::Helpers::VectorItems::NWGMAX]; + return inteHead[19]; } @@ -77,26 +70,6 @@ void groupLoop(const std::vector& groups, } } -template < typename T> -std::pair findInVector(const std::vector & vecOfElements, const T & element) -{ - std::pair result; - - // Find given element in vector - auto it = std::find(vecOfElements.begin(), vecOfElements.end(), element); - - if (it != vecOfElements.end()) - { - result.second = std::distance(vecOfElements.begin(), it); - result.first = true; - } - else - { - result.first = false; - result.second = -1; - } - return result; -} int currentGroupLevel(const Opm::Schedule& sched, const Opm::Group& group, const size_t simStep) { @@ -116,286 +89,6 @@ int currentGroupLevel(const Opm::Schedule& sched, const Opm::Group& group, const } } -bool groupProductionControllable(const Opm::Schedule& sched, const Opm::SummaryState& sumState, const Opm::Group& group, const size_t simStep) -{ - using wellCtrlMode = ::Opm::RestartIO::Helpers::VectorItems::IWell::Value::WellCtrlMode; - bool controllable = false; - if (group.defined( simStep )) { - if (!group.wellgroup()) { - if(!group.groups().empty()) { - for (const auto& group_name : group.groups()) { - if (groupProductionControllable(sched, sumState, sched.getGroup(group_name, simStep), simStep)) { - controllable = true; - continue; - } - } - } - } - else { - for (const auto& well_name : group.wells()) { - const auto& well = sched.getWell(well_name, simStep); - if (well.isProducer()) { - int cur_prod_ctrl = 0; - // Find control mode for well - std::string well_key_1 = "WMCTL:" + well_name; - if (sumState.has(well_key_1)) { - cur_prod_ctrl = static_cast(sumState.get(well_key_1)); - } - if (cur_prod_ctrl == wellCtrlMode::Group) { - controllable = true; - continue; - } - } - } - } - return controllable; - } else { - std::stringstream str; - str << "actual group has not been defined at report time: " << simStep; - throw std::invalid_argument(str.str()); - } -} - -bool groupInjectionControllable(const Opm::Schedule& sched, const Opm::SummaryState& sumState, const Opm::Group& group, const Opm::Phase& iPhase, const size_t simStep) -{ - using wellCtrlMode = ::Opm::RestartIO::Helpers::VectorItems::IWell::Value::WellCtrlMode; - bool controllable = false; - if (group.defined( simStep )) { - if (!group.wellgroup()) { - if(!group.groups().empty()) { - for (const auto& group_name : group.groups()) { - if (groupInjectionControllable(sched, sumState, sched.getGroup(group_name, simStep), iPhase, simStep)) { - controllable = true; - continue; - } - } - } - } - else { - for (const auto& well_name : group.wells()) { - const auto& well = sched.getWell(well_name, simStep); - if (well.isInjector()) { - if (((iPhase == Opm::Phase::WATER) && (well.injectionControls(sumState).injector_type == Opm::InjectorType::WATER)) || - ((iPhase == Opm::Phase::GAS) && (well.injectionControls(sumState).injector_type == Opm::InjectorType::GAS)) - ) { - int cur_inj_ctrl = 0; - // Find control mode for well - std::string well_key_1 = "WMCTL:" + well_name; - if (sumState.has(well_key_1)) { - cur_inj_ctrl = static_cast(sumState.get(well_key_1)); - } - if (cur_inj_ctrl == wellCtrlMode::Group) { - controllable = true; - continue; - } - } - } - } - } - return controllable; - } else { - std::stringstream str; - str << "actual group has not been defined at report time: " << simStep; - throw std::invalid_argument(str.str()); - } -} - - - -int higherLevelProdControlGroupSeqIndex(const Opm::Schedule& sched, - const Opm::SummaryState& sumState, - const Opm::Group& group, - const size_t simStep) -// -// returns the sequence number of higher (highest) level group with active control different from (NONE or FLD) -// -{ - int ctrl_grup_seq_no = -1; - if (group.defined( simStep )) { - auto current = group; - double cur_prod_ctrl = -1.; - while (current.name() != "FIELD" && ctrl_grup_seq_no < 0) { - current = sched.getGroup(current.parent(), simStep); - cur_prod_ctrl = -1.; - if (sumState.has_group_var(current.name(), "GMCTP")) { - cur_prod_ctrl = sumState.get_group_var(current.name(), "GMCTP"); - } - else { -#if ENABLE_GCNTL_DEBUG_OUTPUT - std::cout << "Current group control is not defined for group: " << current.name() << " at timestep: " << simStep << std::endl; -#endif // ENABLE_GCNTL_DEBUG_OUTPUT - cur_prod_ctrl = 0.; - } - if (cur_prod_ctrl > 0. && ctrl_grup_seq_no < 0) { - ctrl_grup_seq_no = current.insert_index(); - } - } - return ctrl_grup_seq_no; - } - else { - std::stringstream str; - str << "actual group has not been defined at report time: " << simStep; - throw std::invalid_argument(str.str()); - } -} - -int higherLevelProdControlMode(const Opm::Schedule& sched, - const Opm::SummaryState& sumState, - const Opm::Group& group, - const size_t simStep) -// -// returns the sequence number of higher (highest) level group with active control different from (NONE or FLD) -// -{ - int ctrl_mode = -1; - if (group.defined( simStep )) { - auto current = group; - double cur_prod_ctrl = -1.; - while (current.name() != "FIELD" && ctrl_mode < 0.) { - current = sched.getGroup(current.parent(), simStep); - cur_prod_ctrl = -1.; - if (sumState.has_group_var(current.name(), "GMCTP")) { - cur_prod_ctrl = sumState.get_group_var(current.name(), "GMCTP"); - } - else { -#if ENABLE_GCNTL_DEBUG_OUTPUT - std::cout << "Current group control is not defined for group: " << current.name() << " at timestep: " << simStep << std::endl; -#endif // ENABLE_GCNTL_DEBUG_OUTPUT - cur_prod_ctrl = 0.; - } - if (cur_prod_ctrl > 0. && ctrl_mode < 0) { - ctrl_mode = static_cast(cur_prod_ctrl); - } - } - return ctrl_mode; - } - else { - std::stringstream str; - str << "actual group has not been defined at report time: " << simStep; - throw std::invalid_argument(str.str()); - } -} - - - - - -int higherLevelInjControlGroupSeqIndex(const Opm::Schedule& sched, - const Opm::SummaryState& sumState, - const Opm::Group& group, - const std::string curInjCtrlKey, - const size_t simStep) -// -// returns the sequence number of higher (highest) level group with active control different from (NONE or FLD) -// -{ - int ctrl_grup_seq_no = -1; - if (group.defined( simStep )) { - auto current = group; - double cur_inj_ctrl = -1.; - while (current.name() != "FIELD" && ctrl_grup_seq_no < 0) { - current = sched.getGroup(current.parent(), simStep); - cur_inj_ctrl = -1.; - if (sumState.has_group_var(current.name(), curInjCtrlKey)) { - cur_inj_ctrl = sumState.get_group_var(current.name(), curInjCtrlKey); - } - else { -#if ENABLE_GCNTL_DEBUG_OUTPUT - std::cout << "Current injection group control: " << curInjCtrlKey << " is not defined for group: " << current.name() << " at timestep: " << simStep << std::endl; -#endif // ENABLE_GCNTL_DEBUG_OUTPUT - cur_inj_ctrl = 0.; - } - if (cur_inj_ctrl > 0. && ctrl_grup_seq_no < 0) { - ctrl_grup_seq_no = current.insert_index(); - } - } - return ctrl_grup_seq_no; - } - else { - std::stringstream str; - str << "actual group has not been defined at report time: " << simStep; - throw std::invalid_argument(str.str()); - } -} - -std::vector groupParentSeqIndex(const Opm::Schedule& sched, - const Opm::Group& group, - const size_t simStep) -// -// returns a vector with the group sequence index of all parent groups from current parent group to Field level -// -{ - std::vector seq_numbers; - if (group.defined( simStep )) { - auto current = group; - while (current.name() != "FIELD") { - current = sched.getGroup(current.parent(), simStep); - seq_numbers.push_back(current.insert_index()); - } - return seq_numbers; - } - else { - std::stringstream str; - str << "actual group has not been defined at report time: " << simStep; - throw std::invalid_argument(str.str()); - } -} - - - -bool higherLevelProdCMode_NotNoneFld(const Opm::Schedule& sched, - const Opm::SummaryState& sumState, - const Opm::Group& group, - const size_t simStep) -{ - bool ctrl_mode_not_none_fld = false; - if (group.defined( simStep )) { - auto current = group; - while (current.name() != "FIELD" && ctrl_mode_not_none_fld == false) { - current = sched.getGroup(current.parent(), simStep); - const auto& prod_cmode = current.productionControls(sumState).cmode; - if ((prod_cmode != Opm::Group::ProductionCMode::FLD) || (prod_cmode!= Opm::Group::ProductionCMode::NONE)) { - ctrl_mode_not_none_fld = true; - } - } - return ctrl_mode_not_none_fld; - } - else { - std::stringstream str; - str << "actual group has not been defined at report time: " << simStep; - throw std::invalid_argument(str.str()); - } -} - -int higherLevelInjCMode_NotNoneFld_SeqIndex(const Opm::Schedule& sched, - const Opm::SummaryState& sumState, - const Opm::Group& group, - const Opm::Phase& phase, - const size_t simStep) -{ - int ctrl_mode_not_none_fld = -1; - if (group.defined( simStep )) { - auto current = group; - while (current.name() != "FIELD" && ctrl_mode_not_none_fld < 0) { - current = sched.getGroup(current.parent(), simStep); - const auto& inj_cmode = (current.hasInjectionControl(phase)) ? - current.injectionControls(phase, sumState).cmode : Opm::Group::InjectionCMode::NONE; - if ((inj_cmode != Opm::Group::InjectionCMode::FLD) || (inj_cmode!= Opm::Group::InjectionCMode::NONE)) { - if (ctrl_mode_not_none_fld == -1) { - ctrl_mode_not_none_fld = current.insert_index(); - } - } - } - return ctrl_mode_not_none_fld; - } - else { - std::stringstream str; - str << "actual group has not been defined at report time: " << simStep; - throw std::invalid_argument(str.str()); - } -} - - int groupType(const Opm::Group& group) { if (group.wellgroup()) return 0; @@ -411,10 +104,12 @@ std::size_t groupSize(const Opm::Group& group) { return group.groups().size(); } + namespace IGrp { std::size_t entriesPerGroup(const std::vector& inteHead) { - return inteHead[Opm::RestartIO::Helpers::VectorItems::NIGRPZ]; + // INTEHEAD[36] = NIGRPZ + return inteHead[36]; } Opm::RestartIO::Helpers::WindowedArray @@ -435,11 +130,9 @@ void staticContrib(const Opm::Schedule& sched, const int ngmaxz, const std::size_t simStep, const Opm::SummaryState& sumState, - const std::map& pCtrlToPCmode, - const std::map& cmodeToNum, + const std::map cmodeToNum, IGrpArray& iGrp) { - const bool is_field = group.name() == "FIELD"; if (group.wellgroup()) { int igrpCount = 0; //group has child wells @@ -461,403 +154,83 @@ void staticContrib(const Opm::Schedule& sched, //assign the number of child wells or child groups to // location nwgmax iGrp[nwgmax] = groupSize(group); - - // Find number of active production wells and injection wells for group - const double g_act_pwells = is_field ? sumState.get("FMWPR", 0) : sumState.get_group_var(group.name(), "GMWPR", 0); - const double g_act_iwells = is_field ? sumState.get("FMWIN", 0) : sumState.get_group_var(group.name(), "GMWIN", 0); - iGrp[nwgmax + 33] = g_act_pwells + g_act_iwells; - - //Treat groups that have production - if ((group.getGroupType() == Opm::Group::GroupType::NONE) || (group.getGroupType() == Opm::Group::GroupType::PRODUCTION) - || (group.getGroupType() == Opm::Group::GroupType::MIXED)) { - - const auto& prod_cmode = group.productionControls(sumState).cmode; - const auto& prod_guide_rate_def = group.productionControls(sumState).guide_rate_def; - const auto& p_exceed_act = group.productionControls(sumState).exceed_action; - // Find production control mode for group - const double cur_prod_ctrl = is_field ? sumState.get("FMCTP", -1) : sumState.get_group_var(group.name(), "GMCTP", -1); - Opm::Group::ProductionCMode pctl_mode = Opm::Group::ProductionCMode::NONE; - if (cur_prod_ctrl >= 0) { - const auto it_ctrl = pCtrlToPCmode.find(cur_prod_ctrl); - if (it_ctrl != pCtrlToPCmode.end()) { - pctl_mode = it_ctrl->second; - } - } -#if ENABLE_GCNTL_DEBUG_OUTPUT - else { - //std::stringstream str; - //str << "Current group production control is not defined for group: " << group.name() << " at timestep: " << simStep; - std::cout << "Current group production control is not defined for group: " << group.name() << " at timestep: " << simStep << std::endl; - //throw std::invalid_argument(str.str()); - } -#endif // ENABLE_GCNTL_DEBUG_OUTPUT - - /*IGRP[NWGMAX + 5] - - the value is determined by a relatively complex logic, a pseudo code scetch follows: - if (group is free to respond to higher level production rate target_reinj_fraction) - iGrp[nwgmax + 5] = 0 - else if (group::control mode > 0) (controlled by own limit) - iGrp[nwgmax + 5] = -1 - else if (a higher level group control is active constraint) - if (group control mode is NOT == ("FLD" OR "NONE")) - iGrp[nwgmax + 5] = group_sequence_no_of controlling group - else - iGrp[nwgmax + 5] = 1 - else if (a higher level group has a control mode NOT == ("FLD" OR "NONE")) - if (group control mode is NOT == ("FLD" OR "NONE")) - iGrp[nwgmax + 5] = -1 - else - iGrp[nwgmax + 5] = 1 - else if (group control mode is == ("FLD" OR "NONE")) - iGrp[nwgmax + 5] = -1 - else - iGrp[nwgmax + 5] = -1 - - */ - if (group.name() != "FIELD") { - //default value + + /*IGRP[NWGMAX + 5] + = -1 group under higher group control + = 0 for NONE (no control) + = 1 group under rate control + */ + + if ((group.getGroupType() == Opm::Group::GroupType::NONE) || (group.getGroupType() == Opm::Group::GroupType::PRODUCTION) ) { + const auto& prod_cmode = group.production_cmode(); + + if (prod_cmode == Opm::Group::ProductionCMode::FLD) { iGrp[nwgmax + 5] = -1; - int higher_lev_ctrl = higherLevelProdControlGroupSeqIndex(sched, sumState, group, simStep); - int higher_lev_ctrl_mode = higherLevelProdControlMode(sched, sumState, group, simStep); - //Start branching for determining iGrp[nwgmax + 5] - //use default value if group is not available for group control - if (groupProductionControllable(sched, sumState, group, simStep)) { - //this section applies if group is controllable - i.e. has wells that may be controlled - if (!group.productionGroupControlAvailable() && (higher_lev_ctrl <= 0)) { - //group can respond to higher level control - iGrp[nwgmax + 5] = 0; - } - else if (((pctl_mode != Opm::Group::ProductionCMode::NONE)) && (higher_lev_ctrl < 0)) { - //group is constrained by its own limits or controls - // if (pctl_mode != Opm::Group::ProductionCMode::FLD) - need to use this test? - else remove - iGrp[nwgmax + 5] = -1; // only value that seems to work when no group at higher level has active control - } - else if (higher_lev_ctrl > 0) { - if (((prod_cmode == Opm::Group::ProductionCMode::FLD) || (prod_cmode == Opm::Group::ProductionCMode::NONE)) - && (group.productionControls(sumState).guide_rate_def != Opm::Group::GuideRateTarget::NO_GUIDE_RATE)) { - iGrp[nwgmax + 5] = higher_lev_ctrl; - } - else { - iGrp[nwgmax + 5] = 1; - } - } - else if (higherLevelProdCMode_NotNoneFld(sched, sumState, group, simStep)) { - if ((prod_cmode != Opm::Group::ProductionCMode::FLD) || (prod_cmode!= Opm::Group::ProductionCMode::NONE)) { - iGrp[nwgmax + 5] = -1; - } - else { - iGrp[nwgmax + 5] = 1; - } - } - else if ((prod_cmode == Opm::Group::ProductionCMode::FLD) || (prod_cmode == Opm::Group::ProductionCMode::NONE)) { - iGrp[nwgmax + 5] = -1; - } - else { - iGrp[nwgmax + 5] = -1; - } - } - else if (prod_cmode == Opm::Group::ProductionCMode::NONE){ - iGrp[nwgmax + 5] = 1; - } - - // Set iGrp for [nwgmax + 7] - /* - For the reduction option RATE the value is generally = 4 - - For the reduction option NONE the values are as shown below, however, this is not a very likely case. - - = 0 for group with "FLD" or "NONE" - = 4 for "GRAT" FIELD - = -40000 for production group with "ORAT" - = -4000 for production group with "WRAT" - = -400 for production group with "GRAT" - = -40 for production group with "LRAT" - - Other reduction options are currently not covered in the code - */ - - if (higher_lev_ctrl > 0 && (group.getGroupType() != Opm::Group::GroupType::NONE)) { - iGrp[nwgmax + 1] = ( prod_guide_rate_def != Opm::Group::GuideRateTarget::NO_GUIDE_RATE ) ? higher_lev_ctrl_mode : 0; - } - else { - switch (pctl_mode) { - case Opm::Group::ProductionCMode::NONE: - iGrp[nwgmax + 1] = 0; - break; - case Opm::Group::ProductionCMode::ORAT: - iGrp[nwgmax + 1] = 1; - break; - case Opm::Group::ProductionCMode::WRAT: - iGrp[nwgmax + 1] = 2; - break; - case Opm::Group::ProductionCMode::GRAT: - iGrp[nwgmax + 1] = 3; - break; - case Opm::Group::ProductionCMode::LRAT: - iGrp[nwgmax + 1] = 4; - break; - case Opm::Group::ProductionCMode::RESV: - iGrp[nwgmax + 1] = 5; - break; - case Opm::Group::ProductionCMode::FLD: - iGrp[nwgmax + 1] = 0; // need to be checked!! - break; - default: - iGrp[nwgmax + 1] = 0; - } - } - iGrp[nwgmax + 9] = iGrp[nwgmax + 1]; - - switch (prod_cmode) { - case Opm::Group::ProductionCMode::NONE: - iGrp[nwgmax + 6] = 0; - iGrp[nwgmax + 7] = (p_exceed_act == Opm::Group::ExceedAction::NONE) ? 0 : 4; - iGrp[nwgmax + 10] = 0; - break; - case Opm::Group::ProductionCMode::ORAT: - iGrp[nwgmax + 6] = 0; - iGrp[nwgmax + 7] = (p_exceed_act == Opm::Group::ExceedAction::NONE) ? -40000 : 4; - iGrp[nwgmax + 10] = 1; - break; - case Opm::Group::ProductionCMode::WRAT: - iGrp[nwgmax + 6] = 0; - iGrp[nwgmax + 7] = (p_exceed_act == Opm::Group::ExceedAction::NONE) ? -4000 : 4; - iGrp[nwgmax + 10] = 2; - break; - case Opm::Group::ProductionCMode::GRAT: - iGrp[nwgmax + 6] = 0; - iGrp[nwgmax + 7] = (p_exceed_act == Opm::Group::ExceedAction::NONE) ? -400 : 4; - iGrp[nwgmax + 10] = 3; - break; - case Opm::Group::ProductionCMode::LRAT: - iGrp[nwgmax + 6] = 0; - iGrp[nwgmax + 7] = (p_exceed_act == Opm::Group::ExceedAction::NONE) ? -40 : 4; - iGrp[nwgmax + 10] = 4; - break; - case Opm::Group::ProductionCMode::RESV: - iGrp[nwgmax + 6] = 0; - iGrp[nwgmax + 7] = (p_exceed_act == Opm::Group::ExceedAction::NONE) ? -4 : 4; // need to be checked - iGrp[nwgmax + 10] = 5; - break; - case Opm::Group::ProductionCMode::FLD: - iGrp[nwgmax + 6] = 0; - if (( higher_lev_ctrl > 0 ) && ( prod_guide_rate_def != Opm::Group::GuideRateTarget::NO_GUIDE_RATE )) { - iGrp[nwgmax + 6] = 8; - } - iGrp[nwgmax + 7] = (p_exceed_act == Opm::Group::ExceedAction::NONE) ? 4 : 4; - iGrp[nwgmax + 10] = 0; // need to be checked!! - break; - default: - iGrp[nwgmax + 6] = 0; - iGrp[nwgmax + 7] = 0; - iGrp[nwgmax + 10] = 0; // need to be checked!! - } } - else { // group name is "FIELD" - iGrp[nwgmax + 6] = 0; - iGrp[nwgmax + 7] = 0; - switch (prod_cmode) { - case Opm::Group::ProductionCMode::NONE: - iGrp[nwgmax + 10] = 0; - break; - case Opm::Group::ProductionCMode::ORAT: - iGrp[nwgmax + 10] = 1; - break; - case Opm::Group::ProductionCMode::WRAT: - iGrp[nwgmax + 10] = 2; - break; - case Opm::Group::ProductionCMode::GRAT: - iGrp[nwgmax + 10] = 3; - break; - case Opm::Group::ProductionCMode::LRAT: - iGrp[nwgmax + 10] = 4; - break; - case Opm::Group::ProductionCMode::RESV: - iGrp[nwgmax + 10] = 5; - break; - case Opm::Group::ProductionCMode::FLD: - iGrp[nwgmax + 10] = 0; - break; - default: - iGrp[nwgmax + 10] = 0; - } + else if (prod_cmode == Opm::Group::ProductionCMode::NONE) { + iGrp[nwgmax + 5] = 0; } - } - //default value - - iGrp[nwgmax + 17] = -1; - iGrp[nwgmax + 22] = -1; - if (group.isInjectionGroup() || (group.getGroupType() == Opm::Group::GroupType::MIXED) || (group.getGroupType() == Opm::Group::GroupType::NONE)) { - auto group_parent_list = groupParentSeqIndex(sched, group, simStep); - - //set "default value" in case a group is only injection group - if (group.isInjectionGroup() && !group.isProductionGroup()) { + else { iGrp[nwgmax + 5] = 1; } - //use default value if group is not available for group control - if (groupInjectionControllable(sched, sumState, group, Opm::Phase::WATER, simStep)) { - if ((group.hasInjectionControl(Opm::Phase::WATER)) || (group.getGroupType() == Opm::Group::GroupType::NONE)){ - const double cur_winj_ctrl = is_field ? sumState.get("FMCTW", -1) : sumState.get_group_var(group.name(), "GMCTW", -1); - const auto& winj_cmode = (group.hasInjectionControl(Opm::Phase::WATER))? - group.injectionControls(Opm::Phase::WATER, sumState).cmode : Opm::Group::InjectionCMode::NONE; - if (!is_field) { - int higher_lev_winj_ctrl = higherLevelInjControlGroupSeqIndex(sched, sumState, group, "GMCTW", simStep); - int higher_lev_winj_cmode = higherLevelInjCMode_NotNoneFld_SeqIndex(sched, sumState, group, Opm::Phase::WATER, simStep); - std::size_t winj_control_ind = 0; - std::size_t inj_cmode_ind = 0; - //WATER INJECTION GROUP CONTROL + // Set iGrp for [nwgmax + 7] + /* + = 0 for group with "FLD" or "NONE" + = 4 for "GRAT" FIELD + = -40000 for production group with "ORAT" + = -4000 for production group with "WRAT" + = -400 for production group with "GRAT" + = -40 for production group with "LRAT" + */ - //Start branching for determining iGrp[nwgmax + 17] - if (cur_winj_ctrl > 0.) { - iGrp[nwgmax + 17] = 0; - } - if (!group.injectionGroupControlAvailable(Opm::Phase::WATER) && (higher_lev_winj_ctrl <= 0)) { - //group can respond to higher level control - iGrp[nwgmax + 17] = 0; - } - else if (higher_lev_winj_ctrl > 0 || higher_lev_winj_cmode > 0) { - if ((winj_cmode != Opm::Group::InjectionCMode::FLD) || (winj_cmode!= Opm::Group::InjectionCMode::NONE)) { - if (!(higher_lev_winj_ctrl == higher_lev_winj_cmode)) { - - auto result = findInVector(group_parent_list, higher_lev_winj_ctrl); - if (result.first) { - winj_control_ind = result.second; - } - else { - winj_control_ind = 99999; - } - - result = findInVector(group_parent_list, higher_lev_winj_cmode); - if (result.first) { - inj_cmode_ind = result.second; - } - else { - inj_cmode_ind = 99999; - } - - if (winj_control_ind < inj_cmode_ind) { - iGrp[nwgmax + 17] = higher_lev_winj_ctrl; - } - else { - iGrp[nwgmax + 17] = higher_lev_winj_cmode; - } - iGrp[nwgmax + 17] = higher_lev_winj_ctrl; - } - else { - iGrp[nwgmax + 17] = higher_lev_winj_ctrl; - } - } - else { - iGrp[nwgmax + 17] = 1; - } - } - else { - iGrp[nwgmax + 17] = -1; - } - } - else { // group name "FIELD" - iGrp[nwgmax + 17] = 0; - iGrp[nwgmax + 22] = 0; - } - //item[nwgmax + 16] - mode for operation for water injection - // 1 - RATE - // 2 - RESV - // 3 - REIN - // 4 - VREP - // 0 - ellers - const auto& inj_mode = (group.hasInjectionControl(Opm::Phase::WATER)) ? - group.injectionControls(Opm::Phase::WATER, sumState).cmode : Opm::Group::InjectionCMode::NONE; - const auto it = cmodeToNum.find(inj_mode); - if (it != cmodeToNum.end()) { - iGrp[nwgmax + 16] = it->second; - iGrp[nwgmax + 18] = iGrp[nwgmax + 16]; - iGrp[nwgmax + 19] = iGrp[nwgmax + 16]; - } + if ((prod_cmode == Opm::Group::ProductionCMode::NONE) || prod_cmode == Opm::Group::ProductionCMode::FLD) { + iGrp[nwgmax + 7] = 0; + } + else if ((prod_cmode == Opm::Group::ProductionCMode::ORAT)) { + iGrp[nwgmax + 7] = -40000; + } + else if ((prod_cmode == Opm::Group::ProductionCMode::WRAT)) { + iGrp[nwgmax + 7] = -4000; + } + else if ((prod_cmode == Opm::Group::ProductionCMode::GRAT)) { + iGrp[nwgmax + 7] = -400; + if (group.name() == "FIELD") { + iGrp[nwgmax + 7] = 4; + } + } + else if ((prod_cmode == Opm::Group::ProductionCMode::LRAT)) { + iGrp[nwgmax + 7] = -40; + } + } + //Set injection group status + //item[nwgmax + 16] - mode for operation for injection group + // 1 - RATE + // 2 - RESV + // 3 - REIN + // 4 - VREP + // 0 - ellers + + if (group.isInjectionGroup()) { + if (group.hasInjectionControl(Opm::Phase::WATER)) { + const auto& inj_cntl = group.injectionControls(Opm::Phase::WATER, sumState); + const auto& inj_mode = inj_cntl.cmode; + const auto it = cmodeToNum.find(inj_mode); + if (it != cmodeToNum.end()) { + iGrp[nwgmax + 16] = it->second; + iGrp[nwgmax + 18] = iGrp[nwgmax + 16]; + iGrp[nwgmax + 19] = iGrp[nwgmax + 16]; } } - //use default value if group is not available for group control - if (groupInjectionControllable(sched, sumState, group, Opm::Phase::GAS, simStep)) { - if ((group.hasInjectionControl(Opm::Phase::GAS)) || (group.getGroupType() == Opm::Group::GroupType::NONE)) { - const double cur_ginj_ctrl = is_field ? sumState.get("FMCTG", -1) : sumState.get_group_var(group.name(), "GMCTG", -1); - const auto& ginj_cmode = (group.hasInjectionControl(Opm::Phase::GAS))? - group.injectionControls(Opm::Phase::GAS, sumState).cmode : Opm::Group::InjectionCMode::NONE; - if (!is_field) { - int higher_lev_ginj_ctrl = higherLevelInjControlGroupSeqIndex(sched, sumState, group, "GMCTG", simStep); - int higher_lev_ginj_cmode = higherLevelInjCMode_NotNoneFld_SeqIndex(sched, sumState, group, Opm::Phase::GAS, simStep); - std::size_t ginj_control_ind = 0; - std::size_t inj_cmode_ind = 0; - //GAS INJECTION GROUP CONTROL - //Start branching for determining iGrp[nwgmax + 22] - if (cur_ginj_ctrl > 0.) { - iGrp[nwgmax + 22] = 0; - } - if (!group.injectionGroupControlAvailable(Opm::Phase::GAS) && (higher_lev_ginj_ctrl <= 0)) { - //group can respond to higher level control - iGrp[nwgmax + 22] = 0; - } - else if (higher_lev_ginj_ctrl > 0 || higher_lev_ginj_cmode > 0) { - if ((ginj_cmode != Opm::Group::InjectionCMode::FLD) || (ginj_cmode!= Opm::Group::InjectionCMode::NONE)) { - if (!(higher_lev_ginj_ctrl == higher_lev_ginj_cmode)) { - - auto result = findInVector(group_parent_list, higher_lev_ginj_ctrl); - if (result.first) { - ginj_control_ind = result.second; - } - else { - ginj_control_ind = 99999; - } - - result = findInVector(group_parent_list, higher_lev_ginj_cmode); - if (result.first) { - inj_cmode_ind = result.second; - } - else { - inj_cmode_ind = 99999; - } - - if (ginj_control_ind < inj_cmode_ind) { - iGrp[nwgmax + 22] = higher_lev_ginj_ctrl; - } - else { - iGrp[nwgmax + 22] = higher_lev_ginj_cmode; - } - iGrp[nwgmax + 22] = higher_lev_ginj_ctrl; - } - else { - iGrp[nwgmax + 22] = higher_lev_ginj_ctrl; - } - } - else { - iGrp[nwgmax + 22] = 1; - } - } - else { - iGrp[nwgmax + 22] = -1; - } - } - else { // group name "FIELD" - iGrp[nwgmax + 17] = 0; - iGrp[nwgmax + 22] = 0; - //parameters connected to oil injection - not implemented in flow yet - iGrp[nwgmax+11] = 0; - iGrp[nwgmax+12] = 0; - - } - //item[nwgmax + 21] - mode for operation for gas injection - // 1 - RATE - // 2 - RESV - // 3 - REIN - // 4 - VREP - // 0 - ellers - const auto& inj_mode = (group.hasInjectionControl(Opm::Phase::GAS)) ? - group.injectionControls(Opm::Phase::GAS, sumState).cmode : Opm::Group::InjectionCMode::NONE; - const auto it = cmodeToNum.find(inj_mode); - if (it != cmodeToNum.end()) { - iGrp[nwgmax + 21] = it->second; - iGrp[nwgmax + 23] = iGrp[nwgmax + 21]; - iGrp[nwgmax + 24] = iGrp[nwgmax + 21]; - } + if (group.hasInjectionControl(Opm::Phase::GAS)) { + const auto& inj_cntl = group.injectionControls(Opm::Phase::GAS, sumState); + const auto& inj_mode = inj_cntl.cmode; + const auto it = cmodeToNum.find(inj_mode); + if (it != cmodeToNum.end()) { + iGrp[nwgmax + 21] = it->second; + iGrp[nwgmax + 23] = iGrp[nwgmax + 21]; + iGrp[nwgmax + 24] = iGrp[nwgmax + 21]; } } } @@ -872,9 +245,10 @@ void staticContrib(const Opm::Schedule& sched, // if (group.name() != "FIELD") { - //parameters connected to oil injection - not implemented in flow yet - iGrp[nwgmax+11] = 0; + //iGrp[nwgmax+ 5] = -1; iGrp[nwgmax+12] = -1; + iGrp[nwgmax+17] = -1; + iGrp[nwgmax+22] = -1; //assign values to group number (according to group sequence) iGrp[nwgmax+88] = group.insert_index(); @@ -909,7 +283,8 @@ void staticContrib(const Opm::Schedule& sched, namespace SGrp { std::size_t entriesPerGroup(const std::vector& inteHead) { - return inteHead[Opm::RestartIO::Helpers::VectorItems::NSGRPZ]; + // INTEHEAD[37] = NSGRPZ + return inteHead[37]; } Opm::RestartIO::Helpers::WindowedArray @@ -984,10 +359,12 @@ void staticContrib(const Opm::Group& group, if (prod_cntl.oil_target > 0.) { sGrp[Isp::OilRateLimit] = sgprop(M::liquid_surface_rate, prod_cntl.oil_target); + sGrp[37] = sGrp[Isp::OilRateLimit]; sGrp[52] = sGrp[Isp::OilRateLimit]; // "ORAT" control } if (prod_cntl.water_target > 0.) { - sGrp[Isp::WatRateLimit] = sgprop(M::liquid_surface_rate, prod_cntl.water_target); + sGrp[Isp::WatRateLimit > 0.] = sgprop(M::liquid_surface_rate, prod_cntl.water_target); + sGrp[38] = sGrp[Isp::WatRateLimit]; sGrp[53] = sGrp[Isp::WatRateLimit]; //"WRAT" control } if (prod_cntl.gas_target > 0.) { @@ -996,35 +373,24 @@ void staticContrib(const Opm::Group& group, } if (prod_cntl.liquid_target > 0.) { sGrp[Isp::LiqRateLimit] = sgprop(M::liquid_surface_rate, prod_cntl.liquid_target); - sGrp[54] = sGrp[Isp::LiqRateLimit]; //"LRAT" control + sGrp[40] = sGrp[Isp::LiqRateLimit]; } } - - if ((group.name() == "FIELD") && (group.getGroupType() == Opm::Group::GroupType::NONE)) { - sGrp[2] = 0.; - sGrp[14] = 0.; - sGrp[19] = 0.; - sGrp[24] = 0.; - } if (group.isInjectionGroup()) { if (group.hasInjectionControl(Opm::Phase::GAS)) { const auto& inj_cntl = group.injectionControls(Opm::Phase::GAS, sumState); if (inj_cntl.surface_max_rate > 0.) { sGrp[Isi::gasSurfRateLimit] = sgprop(M::gas_surface_rate, inj_cntl.surface_max_rate); - sGrp[65] = sGrp[Isi::gasSurfRateLimit]; } if (inj_cntl.resv_max_rate > 0.) { - sGrp[Isi::gasResRateLimit] = sgprop(M::rate, inj_cntl.resv_max_rate); - sGrp[66] = sGrp[Isi::gasResRateLimit]; + sGrp[Isi::gasResRateLimit > 0.] = sgprop(M::rate, inj_cntl.resv_max_rate); } if (inj_cntl.target_reinj_fraction > 0.) { sGrp[Isi::gasReinjectionLimit] = inj_cntl.target_reinj_fraction; - sGrp[67] = sGrp[Isi::gasReinjectionLimit]; } if (inj_cntl.target_void_fraction > 0.) { sGrp[Isi::gasVoidageLimit] = inj_cntl.target_void_fraction; - sGrp[68] = sGrp[Isi::gasVoidageLimit]; } } @@ -1032,42 +398,17 @@ void staticContrib(const Opm::Group& group, const auto& inj_cntl = group.injectionControls(Opm::Phase::WATER, sumState); if (inj_cntl.surface_max_rate > 0.) { sGrp[Isi::waterSurfRateLimit] = sgprop(M::liquid_surface_rate, inj_cntl.surface_max_rate); - sGrp[61] = sGrp[Isi::waterSurfRateLimit]; } if (inj_cntl.resv_max_rate > 0.) { - sGrp[Isi::waterResRateLimit] = sgprop(M::rate, inj_cntl.resv_max_rate); - sGrp[62] = sGrp[Isi::waterResRateLimit]; + sGrp[Isi::waterResRateLimit > 0.] = sgprop(M::rate, inj_cntl.resv_max_rate); } if (inj_cntl.target_reinj_fraction > 0.) { sGrp[Isi::waterReinjectionLimit] = inj_cntl.target_reinj_fraction; - sGrp[63] = sGrp[Isi::waterReinjectionLimit]; } if (inj_cntl.target_void_fraction > 0.) { sGrp[Isi::waterVoidageLimit] = inj_cntl.target_void_fraction; - sGrp[64] = sGrp[Isi::waterVoidageLimit]; } } - - if (group.hasInjectionControl(Opm::Phase::OIL)) { - const auto& inj_cntl = group.injectionControls(Opm::Phase::OIL, sumState); - if (inj_cntl.surface_max_rate > 0.) { - sGrp[Isi::oilSurfRateLimit] = sgprop(M::liquid_surface_rate, inj_cntl.surface_max_rate); - sGrp[57] = sGrp[Isi::oilSurfRateLimit]; - } - if (inj_cntl.resv_max_rate > 0.) { - sGrp[Isi::oilResRateLimit] = sgprop(M::rate, inj_cntl.resv_max_rate); - sGrp[58] = sGrp[Isi::oilResRateLimit]; - } - if (inj_cntl.target_reinj_fraction > 0.) { - sGrp[Isi::oilReinjectionLimit] = inj_cntl.target_reinj_fraction; - sGrp[59] = sGrp[Isi::oilReinjectionLimit]; - } - if (inj_cntl.target_void_fraction > 0.) { - sGrp[Isi::oilVoidageLimit] = inj_cntl.target_void_fraction; - sGrp[60] = sGrp[Isi::oilVoidageLimit]; - } - } - } } } // SGrp @@ -1075,7 +416,8 @@ void staticContrib(const Opm::Group& group, namespace XGrp { std::size_t entriesPerGroup(const std::vector& inteHead) { - return inteHead[Opm::RestartIO::Helpers::VectorItems::NXGRPZ]; + // INTEHEAD[38] = NXGRPZ + return inteHead[38]; } Opm::RestartIO::Helpers::WindowedArray @@ -1099,8 +441,6 @@ void dynamicContrib(const std::vector& restart_group_keys, const Opm::SummaryState& sumState, XGrpArray& xGrp) { - using Ix = ::Opm::RestartIO::Helpers::VectorItems::XGroup::index; - std::string groupName = group.name(); const std::vector& keys = (groupName == "FIELD") ? restart_field_keys : restart_group_keys; @@ -1117,20 +457,14 @@ void dynamicContrib(const std::vector& restart_group_keys, xGrp[itr->second] = keyValue; } } - - xGrp[Ix::OilPrGuideRate_2] = xGrp[Ix::OilPrGuideRate]; - xGrp[Ix::WatPrGuideRate_2] = xGrp[Ix::WatPrGuideRate]; - xGrp[Ix::GasPrGuideRate_2] = xGrp[Ix::GasPrGuideRate]; - xGrp[Ix::VoidPrGuideRate_2] = xGrp[Ix::VoidPrGuideRate]; - - xGrp[Ix::WatInjGuideRate_2] = xGrp[Ix::WatInjGuideRate]; } } // XGrp namespace ZGrp { std::size_t entriesPerGroup(const std::vector& inteHead) { - return inteHead[Opm::RestartIO::Helpers::VectorItems::NZGRPZ]; + // INTEHEAD[39] = NZGRPZ + return inteHead[39]; } Opm::RestartIO::Helpers::WindowedArray< @@ -1180,7 +514,13 @@ captureDeclaredGroupData(const Opm::Schedule& sched, const Opm::SummaryState& sumState, const std::vector& inteHead) { - const auto& curGroups = sched.restart_groups(simStep); + std::vector curGroups(ngmaxz(inteHead), nullptr); + for (const auto& group_name : sched.groupNames(simStep)) { + const auto& group = sched.getGroup(group_name, simStep); + int ind = (group.name() == "FIELD") + ? ngmaxz(inteHead)-1 : group.insert_index()-1; + curGroups[ind] = std::addressof(group); + } groupLoop(curGroups, [&sched, simStep, sumState, this] (const Group& group, const std::size_t groupID) -> void @@ -1188,7 +528,7 @@ captureDeclaredGroupData(const Opm::Schedule& sched, auto ig = this->iGroup_[groupID]; IGrp::staticContrib(sched, group, this->nWGMax_, this->nGMaxz_, - simStep, sumState, this->PCntlModeToPCMode, this->cmodeToNum, ig); + simStep, sumState, this->cmodeToNum, ig); }); // Define Static Contributions to SGrp Array. diff --git a/ThirdParty/custom-opm-common/opm-common/src/opm/output/eclipse/AggregateMSWData.cpp b/ThirdParty/custom-opm-common/opm-common/src/opm/output/eclipse/AggregateMSWData.cpp index 68e3152285..233f95794c 100644 --- a/ThirdParty/custom-opm-common/opm-common/src/opm/output/eclipse/AggregateMSWData.cpp +++ b/ThirdParty/custom-opm-common/opm-common/src/opm/output/eclipse/AggregateMSWData.cpp @@ -24,7 +24,7 @@ #include #include -#include +#include #include #include #include @@ -424,8 +424,8 @@ namespace { VectorItems::ISeg::index; const auto& sicd = segment.spiralICD(); - iSeg[baseIndex + Ix::ICDScalingMode] = sicd.methodFlowScaling(); - iSeg[baseIndex + Ix::ICDOpenShutFlag] = sicd.ecl_status(); + iSeg[baseIndex + Ix::ICDScalingMode] = sicd->methodFlowScaling(); + iSeg[baseIndex + Ix::ICDOpenShutFlag] = sicd->ecl_status(); } template @@ -433,7 +433,7 @@ namespace { const std::size_t baseIndex, ISegArray& iSeg) { - if (segment.isSpiralICD()) { + if (isSpiralICD(segment)) { assignSpiralICDCharacteristics(segment, baseIndex, iSeg); } } @@ -474,7 +474,7 @@ namespace { iSeg[iS + 8] = seg_reorder[ind]; iSeg[iS + Ix::SegmentType] = segment.ecl_type_id(); - if (! segment.isRegular()) { + if (! isRegular(segment)) { assignSegmentTypeCharacteristics(segment, iS, iSeg); } } @@ -543,17 +543,17 @@ namespace { using Ix = ::Opm::RestartIO::Helpers::VectorItems::RSeg::index; using M = ::Opm::UnitSystem::measure; - const auto& valve = segment.valve(); + const auto* valve = segment.valve(); rSeg[baseIndex + Ix::ValveLength] = - usys.from_si(M::length, valve.pipeAdditionalLength()); + usys.from_si(M::length, valve->pipeAdditionalLength()); rSeg[baseIndex + Ix::ValveArea] = - usys.from_si(M::length, usys.from_si(M::length, valve.conCrossArea())); + usys.from_si(M::length, usys.from_si(M::length, valve->conCrossArea())); - rSeg[baseIndex + Ix::ValveFlowCoeff] = valve.conFlowCoefficient(); + rSeg[baseIndex + Ix::ValveFlowCoeff] = valve->conFlowCoefficient(); rSeg[baseIndex + Ix::ValveMaxArea] = - usys.from_si(M::length, usys.from_si(M::length, valve.conMaxCrossArea())); + usys.from_si(M::length, usys.from_si(M::length, valve->conMaxCrossArea())); const auto Cu = valveFlowUnitCoefficient(usys.getType()); const auto CvAc = rSeg[baseIndex + Ix::ValveFlowCoeff] @@ -577,27 +577,27 @@ namespace { const auto& sicd = segment.spiralICD(); rSeg[baseIndex + Ix::DeviceBaseStrength] = - usys.from_si(M::icd_strength, sicd.strength()); + usys.from_si(M::icd_strength, sicd->strength()); rSeg[baseIndex + Ix::CalibrFluidDensity] = - usys.from_si(M::density, sicd.densityCalibration()); + usys.from_si(M::density, sicd->densityCalibration()); rSeg[baseIndex + Ix::CalibrFluidViscosity] = - usys.from_si(M::viscosity, sicd.viscosityCalibration()); + usys.from_si(M::viscosity, sicd->viscosityCalibration()); - rSeg[baseIndex + Ix::CriticalWaterFraction] = sicd.criticalValue(); + rSeg[baseIndex + Ix::CriticalWaterFraction] = sicd->criticalValue(); rSeg[baseIndex + Ix::TransitionRegWidth] = - sicd.widthTransitionRegion(); + sicd->widthTransitionRegion(); rSeg[baseIndex + Ix::MaxEmulsionRatio] = - sicd.maxViscosityRatio(); + sicd->maxViscosityRatio(); rSeg[baseIndex + Ix::MaxValidFlowRate] = - usys.from_si(M::geometric_volume_rate, sicd.maxAbsoluteRate()); + usys.from_si(M::geometric_volume_rate, sicd->maxAbsoluteRate()); rSeg[baseIndex + Ix::ICDLength] = - usys.from_si(M::length, sicd.length()); + usys.from_si(M::length, sicd->length()); } template @@ -606,11 +606,11 @@ namespace { const int baseIndex, RSegArray& rSeg) { - if (segment.isSpiralICD()) { + if (isSpiralICD(segment)) { assignSpiralICDCharacteristics(segment, usys, baseIndex, rSeg); } - if (segment.isValve()) { + if (isValve(segment)) { assignValveCharacteristics(segment, usys, baseIndex, rSeg); } } @@ -641,9 +641,7 @@ namespace { const auto& wname = well.name(); const auto wPKey = "WBHP:" + wname; const auto& wRatesIt = wr.find(wname); - // - //Do not calculate well segment rates for shut wells - bool haveWellRes = (well.getStatus() != Opm::Well::Status::SHUT) ? (wRatesIt != wr.end()) : false; + bool haveWellRes = wRatesIt != wr.end(); const auto volFromLengthUnitConv = units.from_si(M::length, units.from_si(M::length, units.from_si(M::length, 1.))); const auto areaFromLengthUnitConv = units.from_si(M::length, units.from_si(M::length, 1.)); // @@ -700,9 +698,6 @@ namespace { rSeg[iS + Ix::WatFlowFract] = (std::abs(temp_w) > 0) ? temp_w / rSeg[8] : 0.; rSeg[iS + Ix::GasFlowFract] = (std::abs(temp_g) > 0) ? temp_g / rSeg[8] : 0.; - - rSeg[iS + Ix::item31] = rSeg[iS + Ix::WatFlowFract]; - // value is 1. based on tests on several data sets rSeg[iS + Ix::item40] = 1.; @@ -756,8 +751,6 @@ namespace { rSeg[iS + Ix::WatFlowFract] = (std::abs(temp_w) > 0) ? temp_w / rSeg[iS + 8] : 0.; rSeg[iS + Ix::GasFlowFract] = (std::abs(temp_g) > 0) ? temp_g / rSeg[iS + 8] : 0.; - rSeg[iS + Ix::item31] = rSeg[iS + Ix::WatFlowFract]; - rSeg[iS + Ix::item40] = 1.; rSeg[iS + Ix::item106] = 1.0; @@ -767,7 +760,7 @@ namespace { rSeg[iS + Ix::item110] = 1.0; rSeg[iS + Ix::item111] = 1.0; - if (! segment.isRegular()) { + if (! isRegular(segment)) { assignSegmentTypeCharacteristics(segment, units, iS, rSeg); } } diff --git a/ThirdParty/custom-opm-common/opm-common/src/opm/output/eclipse/AggregateUDQData.cpp b/ThirdParty/custom-opm-common/opm-common/src/opm/output/eclipse/AggregateUDQData.cpp index 921c682d98..859077f8bf 100644 --- a/ThirdParty/custom-opm-common/opm-common/src/opm/output/eclipse/AggregateUDQData.cpp +++ b/ThirdParty/custom-opm-common/opm-common/src/opm/output/eclipse/AggregateUDQData.cpp @@ -64,10 +64,11 @@ namespace { return inteHead[163]; } - // Categorize function in terms of which token-types are used in formula + + // Categorize function in terms of which token-types are used in formula int define_type(const std::set tokens) { int type = -4; - std::vector type_1 = { + std::vector type_1 = { Opm::UDQTokenType::elemental_func_sorta, Opm::UDQTokenType::elemental_func_sortd, Opm::UDQTokenType::elemental_func_undef, @@ -76,17 +77,18 @@ namespace { Opm::UDQTokenType::scalar_func_aveg, Opm::UDQTokenType::scalar_func_aveh, Opm::UDQTokenType::scalar_func_max, - Opm::UDQTokenType::scalar_func_min, + Opm::UDQTokenType::scalar_func_min, Opm::UDQTokenType::binary_op_div }; - + int num_type_1 = 0; for (const auto& tok_type : type_1) { num_type_1 += tokens.count(tok_type); - } + } type = (num_type_1 > 0) ? -1 : -4; return type; } + namespace iUdq { @@ -132,7 +134,7 @@ namespace { } template - void staticContrib(const Opm::UDQActive::Record& udq_record, IUADArray& iUad, int use_cnt_diff) + void staticContrib(const Opm::UDQActive::Record& udq_record, IUADArray& iUad) { iUad[0] = udq_record.uad_code; iUad[1] = udq_record.input_index + 1; @@ -141,7 +143,7 @@ namespace { iUad[2] = 1; iUad[3] = udq_record.use_count; - iUad[4] = udq_record.use_index + 1 - use_cnt_diff; + iUad[4] = udq_record.use_index + 1; } } // iUad @@ -277,11 +279,11 @@ namespace { { //initialize array to the default value for the array for (std::size_t ind = 0; ind < nwmaxz; ind++) { - dUdw[ind] = Opm::UDQ::restart_default; + dUdw[ind] = -0.3E+21; } for (std::size_t ind = 0; ind < wnames.size(); ind++) { if (st.has_well_var(wnames[ind], udq)) { - dUdw[ind] = st.get_well_var(wnames[ind], udq); + dUdw[ind] = st.get_well_var(wnames[ind], udq); } } } @@ -310,14 +312,14 @@ namespace { //initialize array to the default value for the array for (std::size_t ind = 0; ind < groups.size(); ind++) { if ((groups[ind] == nullptr) || (ind == ngmaxz-1)) { - dUdg[ind] = Opm::UDQ::restart_default; + dUdg[ind] = -0.3E+21; } else { - if (st.has_group_var((*groups[ind]).name(), udq)) { - dUdg[ind] = st.get_group_var((*groups[ind]).name(), udq); + if (st.has_group_var((*groups[ind]).name(), udq)) { + dUdg[ind] = st.get_group_var((*groups[ind]).name(), udq); } else { - dUdg[ind] = Opm::UDQ::restart_default; + dUdg[ind] = -0.3E+21; } } } @@ -343,14 +345,14 @@ namespace { DUDFArray& dUdf) { //set value for group name "FIELD" - if (st.has(udq)) { - dUdf[0] = st.get(udq); + if (st.has(udq)) { + dUdf[0] = st.get(udq); } else { - dUdf[0] = Opm::UDQ::restart_default; + dUdf[0] = -0.3E+21; } } - } // dUdf + } // dUdf } @@ -378,12 +380,30 @@ std::pair findInVector(const std::vector & vecOfElements, const return result; } +// Make ordered list of current groups +const std::vector currentGroups(const Opm::Schedule& sched, + const std::size_t simStep, + const std::vector& inteHead ) +{ + std::vector curGroups(ngmaxz(inteHead), nullptr); + for (const auto& group_name : sched.groupNames(simStep)) { + const auto& group = sched.getGroup(group_name, simStep); + + //The FIELD group is the first group according to the insert_index() + //In the Eclipse compatible restart file, the FILED group is put at the end of the list of groups (ngmaxz(inteHead)-1) + int ind = (group.name() == "FIELD") + ? ngmaxz(inteHead)-1 : group.insert_index()-1; + curGroups[ind] = std::addressof(group); + + } + return curGroups; +} const std::vector Opm::RestartIO::Helpers::igphData::ig_phase(const Opm::Schedule& sched, const std::size_t simStep, const std::vector& inteHead ) { - const auto curGroups = sched.restart_groups(simStep); + const auto curGroups = currentGroups(sched, simStep, inteHead); std::vector inj_phase(ngmaxz(inteHead), 0); for (std::size_t ind = 0; ind < curGroups.size(); ind++) { if (curGroups[ind] != nullptr) { @@ -415,7 +435,7 @@ const std::vector iuap_data(const Opm::Schedule& sched, //construct the current list of well or group sequence numbers to output the IUAP array std::vector wg_no; Opm::UDAKeyword wg_key; - + for (std::size_t ind = 0; ind < iuap.size(); ind++) { auto& ctrl = iuap[ind].control; wg_key = Opm::UDQ::keyword(ctrl); @@ -425,20 +445,18 @@ const std::vector iuap_data(const Opm::Schedule& sched, } else if ((wg_key == Opm::UDAKeyword::GCONPROD) || (wg_key == Opm::UDAKeyword::GCONINJE)) { const auto& group = sched.getGroup(iuap[ind].wgname, simStep); - if (iuap[ind].wgname != "FIELD") { - wg_no.push_back(group.insert_index() - 1); - } + wg_no.push_back(group.insert_index()); } else { std::cout << "Invalid Control keyword: " << static_cast(ctrl) << std::endl; throw std::invalid_argument("UDQ - variable: " + iuap[ind].udq ); } - + } return wg_no; } - + Opm::RestartIO::Helpers::AggregateUDQData:: AggregateUDQData(const std::vector& udqDims) : iUDQ_ (iUdq::allocate(udqDims)), @@ -485,29 +503,24 @@ captureDeclaredUDQData(const Opm::Schedule& sched, str << "Inconsistent total number of udqs: " << cnt_udq << " and sum of well, group and field udqs: " << nudq; OpmLog::error(str.str()); } - - + + auto udq_active = sched.udqActive(simStep); if (udq_active) { const auto& udq_records = udq_active.get_iuad(); int cnt_iuad = 0; for (std::size_t index = 0; index < udq_records.size(); index++) { const auto& record = udq_records[index]; - auto i_uad = this->iUAD_[cnt_iuad]; - const auto& ctrl = record.control; - const auto wg_key = Opm::UDQ::keyword(ctrl); - if (!(((wg_key == Opm::UDAKeyword::GCONPROD) || (wg_key == Opm::UDAKeyword::GCONINJE)) && (record.wg_name() == "FIELD"))) { - int use_count_diff = static_cast(index) - cnt_iuad; - iUad::staticContrib(record, i_uad, use_count_diff); - cnt_iuad += 1; - } + auto i_uad = this->iUAD_[index]; + iUad::staticContrib(record, i_uad); + cnt_iuad += 1; } if (cnt_iuad != inteHead[VI::intehead::NO_IUADS]) { std::stringstream str; str << "Inconsistent number of iuad's: " << cnt_iuad << " number of iuad's from intehead " << inteHead[VI::intehead::NO_IUADS]; OpmLog::error(str.str()); } - + const auto& iuap_records = udq_active.get_iuap(); int cnt_iuap = 0; const auto iuap_vect = iuap_data(sched, simStep,iuap_records); @@ -540,7 +553,7 @@ captureDeclaredUDQData(const Opm::Schedule& sched, OpmLog::error(str.str()); } } - + std::size_t i_wudq = 0; const auto& wnames = sched.wellNames(simStep); const auto nwmax = nwmaxz(inteHead); @@ -559,9 +572,9 @@ captureDeclaredUDQData(const Opm::Schedule& sched, str << "Inconsistent number of dudw's: " << cnt_dudw << " number of dudw's from intehead " << inteHead[VI::intehead::NO_WELL_UDQS]; OpmLog::error(str.str()); } - + std::size_t i_gudq = 0; - const auto curGroups = sched.restart_groups(simStep); + const auto curGroups = currentGroups(sched, simStep, inteHead); const auto ngmax = ngmaxz(inteHead); int cnt_dudg = 0; for (const auto& udq_input : udqCfg.input()) { @@ -578,7 +591,7 @@ captureDeclaredUDQData(const Opm::Schedule& sched, str << "Inconsistent number of dudg's: " << cnt_dudg << " number of dudg's from intehead " << inteHead[VI::intehead::NO_GROUP_UDQS]; OpmLog::error(str.str()); } - + std::size_t i_fudq = 0; int cnt_dudf = 0; for (const auto& udq_input : udqCfg.input()) { @@ -596,6 +609,6 @@ captureDeclaredUDQData(const Opm::Schedule& sched, OpmLog::error(str.str()); } - + } diff --git a/ThirdParty/custom-opm-common/opm-common/src/opm/output/eclipse/AggregateWellData.cpp b/ThirdParty/custom-opm-common/opm-common/src/opm/output/eclipse/AggregateWellData.cpp index cc02d2e771..fb7d87357c 100644 --- a/ThirdParty/custom-opm-common/opm-common/src/opm/output/eclipse/AggregateWellData.cpp +++ b/ThirdParty/custom-opm-common/opm-common/src/opm/output/eclipse/AggregateWellData.cpp @@ -29,7 +29,6 @@ #include #include #include -#include #include #include #include @@ -38,7 +37,6 @@ #include #include #include -#include #include #include @@ -285,29 +283,6 @@ namespace { iWell[Ix::item11] = -1000; } - template - void dynamicContribStop(const Opm::data::Well& xw, - IWellArray& iWell) - { - using Ix = VI::IWell::index; - - const auto any_flowing_conn = - std::any_of(std::begin(xw.connections), - std::end (xw.connections), - [](const Opm::data::Connection& c) - { - return c.rates.flowing(); - }); - - iWell[Ix::item9] = any_flowing_conn - ? 0 : -1; - - //item11 = 1 for an open well - iWell[Ix::item11] = any_flowing_conn - ? 0 : -1; - - } - template void dynamicContribOpen(const Opm::Well& well, const Opm::data::Well& xw, @@ -330,9 +305,7 @@ namespace { iWell[Ix::item9] = any_flowing_conn ? iWell[Ix::ActWCtrl] : -1; - //item11 = 1 for an open well - iWell[Ix::item11] = any_flowing_conn - ? 1 : -1; + iWell[Ix::item11] = 1; } } // IWell @@ -418,18 +391,6 @@ namespace { std::copy(b, e, std::begin(sWell)); } - float getRateLimit(const Opm::UnitSystem& units, Opm::UnitSystem::measure u, const double& rate) - { - float rLimit = 1.0e+20f; - if (rate > 0.0) { - rLimit = static_cast(units.from_si(u, rate)); - } - else if (rate < 0.0) { - rLimit = 0.0; - } - - return rLimit; - }; template void staticContrib(const Opm::Well& well, const Opm::UnitSystem& units, @@ -443,7 +404,7 @@ namespace { { return static_cast(units.from_si(u, x)); }; - + assignDefaultSWell(sWell); if (well.isProducer()) { @@ -497,21 +458,6 @@ namespace { ? swprop(M::pressure, pc.bhp_limit) : swprop(M::pressure, 1.0*::Opm::unit::atm); sWell[Ix::HistBHPTarget] = sWell[Ix::BHPTarget]; - - //alq_value - has no unit conversion according to parser code - if (pc.alq_value != 0.0) { - sWell[Ix::Alq_value] = pc.alq_value; - } - - if (predMode) { - //if (well.getStatus() == Opm::Well::Status::OPEN) { - sWell[Ix::OilRateTarget] = getRateLimit(units, M::liquid_surface_rate, pc.oil_rate); - sWell[Ix::WatRateTarget] = getRateLimit(units, M::liquid_surface_rate, pc.water_rate); - sWell[Ix::GasRateTarget] = getRateLimit(units, M::gas_surface_rate, pc.gas_rate); - sWell[Ix::LiqRateTarget] = getRateLimit(units, M::liquid_surface_rate, pc.liquid_rate); - sWell[Ix::ResVRateTarget] = getRateLimit(units, M::rate, pc.resv_rate); - //} - } } else if (well.isInjector()) { const auto& ic = well.injectionControls(smry); @@ -554,7 +500,6 @@ namespace { sWell[Ix::DatumDepth] = swprop(M::length, datumDepth(well)); sWell[Ix::DrainageRadius] = swprop(M::length, well.getDrainageRadius()); sWell[Ix::EfficiencyFactor1] = well.getEfficiencyFactor(); - sWell[Ix::EfficiencyFactor2] = sWell[Ix::EfficiencyFactor1]; /* Restart files from Eclipse indicate that the efficiency factor is found in two items in the restart file; since only one of the @@ -623,7 +568,7 @@ namespace { + xWell[Ix::WatPrRate]; xWell[Ix::VoidPrRate] = get("WVPR"); - xWell[Ix::TubHeadPr] = get("WTHP"); + xWell[Ix::FlowBHP] = get("WBHP"); xWell[Ix::WatCut] = get("WWCT"); xWell[Ix::GORatio] = get("WGOR"); @@ -637,11 +582,6 @@ namespace { xWell[Ix::item37] = xWell[Ix::WatPrRate]; xWell[Ix::item38] = xWell[Ix::GasPrRate]; - xWell[Ix::PrimGuideRate] = xWell[Ix::PrimGuideRate_2] = get("WOPGR"); - xWell[Ix::WatPrGuideRate] = xWell[Ix::WatPrGuideRate_2] = get("WWPGR"); - xWell[Ix::GasPrGuideRate] = xWell[Ix::GasPrGuideRate_2] = get("WGPGR"); - xWell[Ix::VoidPrGuideRate] = xWell[Ix::VoidPrGuideRate_2] = get("WVPGR"); - xWell[Ix::HistOilPrTotal] = get("WOPTH"); xWell[Ix::HistWatPrTotal] = get("WWPTH"); xWell[Ix::HistGasPrTotal] = get("WGPTH"); @@ -653,7 +593,6 @@ namespace { { using Ix = ::Opm::RestartIO::Helpers::VectorItems::XWell::index; - xWell[Ix::TubHeadPr] = get("WTHP"); xWell[Ix::FlowBHP] = get("WBHP"); // Note: Assign both water and gas cumulatives to support @@ -688,8 +627,6 @@ namespace { // Not fully characterised. xWell[Ix::item37] = xWell[Ix::WatPrRate]; - xWell[Ix::PrimGuideRate] = xWell[Ix::PrimGuideRate_2] = -get("WWIGR"); - xWell[Ix::WatVoidPrRate] = -get("WWVIR"); } @@ -724,31 +661,9 @@ namespace { // Not fully characterised. xWell[Ix::item38] = xWell[Ix::GasPrRate]; - xWell[Ix::PrimGuideRate] = xWell[Ix::PrimGuideRate_2] = -get("WGIGR"); - xWell[Ix::GasVoidPrRate] = xWell[Ix::VoidPrRate]; } - template - void assignOilInjector(const std::string& well, - const ::Opm::SummaryState& smry, - XWellArray& xWell) - { - using Ix = ::Opm::RestartIO::Helpers::VectorItems::XWell::index; - - auto get = [&smry, &well](const std::string& vector) - { - const auto key = vector + ':' + well; - - return smry.has(key) ? smry.get(key) : 0.0; - }; - - xWell[Ix::TubHeadPr] = get("WTHP"); - xWell[Ix::FlowBHP] = get("WBHP"); - - xWell[Ix::PrimGuideRate] = xWell[Ix::PrimGuideRate_2] = -get("WOIGR"); - } - template void dynamicContrib(const ::Opm::Well& well, const ::Opm::SummaryState& smry, @@ -763,7 +678,7 @@ namespace { switch (itype) { case IType::OIL: - assignOilInjector(well.name(), smry, xWell); + // Do nothing. break; case IType::WATER: @@ -807,33 +722,32 @@ namespace { }; } - std::vector> - act_res_stat(const Opm::Schedule& sched, const Opm::Action::State& action_state, const Opm::SummaryState& smry, const std::size_t sim_step) { - std::vector> results; + Opm::RestartIO::Helpers::ActionResStatus + act_res_stat(const Opm::Schedule& sched, const Opm::SummaryState& smry, const std::size_t sim_step) { + std::vector act_res; + std::vector act_name; const auto& acts = sched.actions(sim_step); - Opm::Action::Context context(smry, sched.getWListManager(sim_step)); + Opm::Action::Context context(smry); auto sim_time = sched.simTime(sim_step); - for (const auto& action : acts.pending(action_state, sim_time)) { - auto result = action->eval(context); - if (result) - results.emplace_back( action->name(), std::move(result) ); + for (const auto& action : acts.pending(sim_time)) { + act_res.push_back(action->eval(sim_time, context)); + act_name.push_back(action->name()); } - return results; + return {act_res, act_name}; } template - void staticContrib(const Opm::Well& well, const std::vector>& actResStat, ZWellArray& zWell) + void staticContrib(const Opm::Well& well, const Opm::RestartIO::Helpers::ActionResStatus& actResStat, ZWellArray& zWell) { using Ix = ::Opm::RestartIO::Helpers::VectorItems::ZWell::index; zWell[Ix::WellName] = well.name(); //loop over actions to assign action name for relevant wells - for (const auto& [action_name, action_result] : actResStat) { - if (action_result.has_well(well.name())) { - zWell[Ix::ActionX] = action_name; + for (std::size_t ind = 0; ind < actResStat.result.size(); ind++) { + if (actResStat.result[ind].has_well(well.name())) { + zWell[Ix::ActionX] = actResStat.name[ind]; } } } - } // ZWell } // Anonymous @@ -855,7 +769,6 @@ Opm::RestartIO::Helpers::AggregateWellData:: captureDeclaredWellData(const Schedule& sched, const UnitSystem& units, const std::size_t sim_step, - const ::Opm::Action::State& action_state, const ::Opm::SummaryState& smry, const std::vector& inteHead) { @@ -896,7 +809,7 @@ captureDeclaredWellData(const Schedule& sched, }); { - const auto actResStat = ZWell::act_res_stat(sched, action_state, smry, sim_step); + const auto actResStat = ZWell::act_res_stat(sched, smry, sim_step); // Static contributions to ZWEL array. wellLoop(wells, [&actResStat, this](const Well& well, const std::size_t wellID) -> void @@ -911,7 +824,7 @@ captureDeclaredWellData(const Schedule& sched, void Opm::RestartIO::Helpers::AggregateWellData:: -captureDynamicWellData(const Opm::Schedule& sched, +captureDynamicWellData(const Schedule& sched, const std::size_t sim_step, const Opm::data::WellRates& xw, const ::Opm::SummaryState& smry) @@ -925,13 +838,8 @@ captureDynamicWellData(const Opm::Schedule& sched, auto iWell = this->iWell_[wellID]; auto i = xw.find(well.name()); - if ((i == std::end(xw)) || (well.getStatus() != Opm::Well::Status::OPEN)) { - if ((i == std::end(xw)) || (well.getStatus() == Opm::Well::Status::SHUT)) { - IWell::dynamicContribShut(iWell); - } - else { - IWell::dynamicContribStop(i->second, iWell); - } + if ((i == std::end(xw)) || !i->second.flowing()) { + IWell::dynamicContribShut(iWell); } else { IWell::dynamicContribOpen(well, i->second, iWell); diff --git a/ThirdParty/custom-opm-common/opm-common/src/opm/output/eclipse/CreateInteHead.cpp b/ThirdParty/custom-opm-common/opm-common/src/opm/output/eclipse/CreateInteHead.cpp index 2e18ad34e3..77fbe55221 100644 --- a/ThirdParty/custom-opm-common/opm-common/src/opm/output/eclipse/CreateInteHead.cpp +++ b/ThirdParty/custom-opm-common/opm-common/src/opm/output/eclipse/CreateInteHead.cpp @@ -154,39 +154,6 @@ namespace { return std::count_if(input.begin(), input.end(), [](const Opm::UDQInput inp) { return (inp.var_type() == Opm::UDQVarType::GROUP_VAR); }); } - int noIuads(const Opm::Schedule& sched, - const std::size_t rptStep, - const std::size_t simStep) - { - if (rptStep == std::size_t{0}) { - return 0; - } - - const auto& udqAct = sched.udqActive(simStep); - const auto& iuad = udqAct.get_iuad(); - - return std::count_if(iuad.begin(), iuad.end(), [](const Opm::UDQActive::Record rec) { - return (!(((Opm::UDQ::keyword(rec.control) == Opm::UDAKeyword::GCONPROD) || (Opm::UDQ::keyword(rec.control) == Opm::UDAKeyword::GCONINJE)) - && (rec.wg_name() == "FIELD"))); }); - } - - int noIuaps(const Opm::Schedule& sched, - const std::size_t rptStep, - const std::size_t simStep) - { - if (rptStep == std::size_t{0}) { - return 0; - } - - const auto& udqAct = sched.udqActive(simStep); - const auto& iuap = udqAct.get_iuap(); - - return std::count_if(iuap.begin(), iuap.end(), [](const Opm::UDQActive::InputRecord rec) { - return (!(((Opm::UDQ::keyword(rec.control) == Opm::UDAKeyword::GCONPROD) || (Opm::UDQ::keyword(rec.control) == Opm::UDAKeyword::GCONINJE)) - && (rec.wgname == "FIELD"))); }); - } - - int noFieldUdqs(const Opm::Schedule& sched, const std::size_t rptStep, const std::size_t simStep) @@ -316,12 +283,13 @@ namespace { } const auto& udq_par = rspec.udqParams(); + const auto& udqActive = sched.udqActive(simStep); const auto r_seed = udq_par.rand_seed(); const auto no_wudq = noWellUdqs(sched, rptStep, simStep); const auto no_gudq = noGroupUdqs(sched, rptStep, simStep); const auto no_fudq = noFieldUdqs(sched, rptStep, simStep); - const auto no_iuads = noIuads(sched, rptStep, simStep); - const auto no_iuaps = noIuaps(sched, rptStep, simStep); + const auto no_iuads = udqActive.IUAD_size(); + const auto no_iuaps = udqActive.IUAP_size(); return { r_seed, diff --git a/ThirdParty/custom-opm-common/opm-common/src/opm/output/eclipse/CreateUdqDims.cpp b/ThirdParty/custom-opm-common/opm-common/src/opm/output/eclipse/CreateUdqDims.cpp index 62931a9b34..3017e4eaf4 100644 --- a/ThirdParty/custom-opm-common/opm-common/src/opm/output/eclipse/CreateUdqDims.cpp +++ b/ThirdParty/custom-opm-common/opm-common/src/opm/output/eclipse/CreateUdqDims.cpp @@ -86,12 +86,12 @@ std::vector Opm::RestartIO::Helpers:: createUdqDims(const Schedule& sched, const std::size_t lookup_step, - const std::vector& inteHead) + const std::vector& inteHead) { const auto& udqCfg = sched.getUDQConfig(lookup_step); - std::vector udqDims; + std::vector udqDims; udqDims.resize(13,0); - + udqDims[ 0] = udqCfg.size(); udqDims[ 1] = entriesPerIUDQ(); udqDims[ 2] = inteHead[VI::intehead::NO_IUADS]; diff --git a/ThirdParty/custom-opm-common/opm-common/src/opm/output/eclipse/EclipseIO.cpp b/ThirdParty/custom-opm-common/opm-common/src/opm/output/eclipse/EclipseIO.cpp index 93f7ed1f03..85f979cbb1 100644 --- a/ThirdParty/custom-opm-common/opm-common/src/opm/output/eclipse/EclipseIO.cpp +++ b/ThirdParty/custom-opm-common/opm-common/src/opm/output/eclipse/EclipseIO.cpp @@ -187,8 +187,7 @@ void EclipseIO::writeInitial( data::Solution simProps, std::mapimpl->es.getUnits(); - - RptIO::write_report(ss, report.first, report.second, schedule, grid, unit_system, report_step); - + RptIO::write_report(ss, report.first, report.second, schedule, grid, report_step); auto log_string = ss.str(); if (!log_string.empty()) OpmLog::note(log_string); @@ -276,7 +272,7 @@ void EclipseIO::writeTimeStep(const Action::State& action_state, } -RestartValue EclipseIO::loadRestart(Action::State& action_state, SummaryState& summary_state, const std::vector& solution_keys, const std::vector& extra_keys) const { +RestartValue EclipseIO::loadRestart(SummaryState& summary_state, const std::vector& solution_keys, const std::vector& extra_keys) const { const auto& es = this->impl->es; const auto& grid = this->impl->grid; const auto& schedule = this->impl->schedule; @@ -287,7 +283,7 @@ RestartValue EclipseIO::loadRestart(Action::State& action_state, SummaryState& s report_step, false ); - return RestartIO::load(filename, report_step, action_state, summary_state, solution_keys, + return RestartIO::load(filename, report_step, summary_state, solution_keys, es, grid, schedule, extra_keys); } diff --git a/ThirdParty/custom-opm-common/opm-common/src/opm/output/eclipse/LoadRestart.cpp b/ThirdParty/custom-opm-common/opm-common/src/opm/output/eclipse/LoadRestart.cpp index 7c41d6c7f1..ac914ef4fd 100644 --- a/ThirdParty/custom-opm-common/opm-common/src/opm/output/eclipse/LoadRestart.cpp +++ b/ThirdParty/custom-opm-common/opm-common/src/opm/output/eclipse/LoadRestart.cpp @@ -31,7 +31,6 @@ #include #include #include -#include #include #include @@ -51,7 +50,6 @@ #include #include #include -#include #include #include @@ -96,21 +94,11 @@ namespace { static Opm::EclIO::eclArrType T; }; - template<> - struct ArrayType - { - static Opm::EclIO::eclArrType T; - }; - - Opm::EclIO::eclArrType ArrayType::T = ::Opm::EclIO::eclArrType::INTE; - Opm::EclIO::eclArrType ArrayType::T = ::Opm::EclIO::eclArrType::REAL; - Opm::EclIO::eclArrType ArrayType::T = ::Opm::EclIO::eclArrType::DOUB; - Opm::EclIO::eclArrType ArrayType::T = ::Opm::EclIO::eclArrType::CHAR; + Opm::EclIO::eclArrType ArrayType::T = ::Opm::EclIO::eclArrType::INTE; + Opm::EclIO::eclArrType ArrayType::T = ::Opm::EclIO::eclArrType::REAL; + Opm::EclIO::eclArrType ArrayType::T = ::Opm::EclIO::eclArrType::DOUB; } - - - class RestartFileView { public: @@ -140,8 +128,8 @@ public: { if (this->rst_file_ == nullptr) { return false; } - const auto& coll_iter = this->vectors_.find(ArrayType::T); - return (coll_iter != this->vectors_.end() && this->collectionContains(coll_iter->second, vector)); + return this->vectors_ + .at(ArrayType::T).count(vector) > 0; } template @@ -176,13 +164,6 @@ private: int report_step_; std::size_t sim_step_; TypedColl vectors_; - - bool collectionContains(const VectorColl& coll, - const std::string& vector) const - { - return coll.find(vector) != coll.end(); - } - }; RestartFileView::RestartFileView(const std::string& filename, @@ -202,6 +183,7 @@ RestartFileView::RestartFileView(const std::string& filename, const auto& type = std::get<1>(vector); switch (type) { + case ::Opm::EclIO::eclArrType::CHAR: case ::Opm::EclIO::eclArrType::LOGI: case ::Opm::EclIO::eclArrType::MESS: // Currently ignored @@ -251,48 +233,6 @@ namespace { return { begin, end }; } } -// --------------------------------------------------------------------- -class UDQVectors -{ -public: - template - using Window = boost::iterator_range::const_iterator>; - - UDQVectors(std::shared_ptr rst_view) : - rstView_(rst_view) - { - const auto& intehead = rst_view->getKeyword("INTEHEAD"); - this->num_wells = intehead[VI::intehead::NWMAXZ]; - this->num_groups = intehead[VI::intehead::NGMAXZ]; - } - - Window next_dudw() { - return getDataWindow(this->rstView_->getKeyword("DUDW"), - this->num_wells, this->udq_well_index++); - } - - Window next_dudg() { - return getDataWindow(this->rstView_->getKeyword("DUDG"), - this->num_groups, this->udq_group_index++); - } - - double next_dudf() { - return this->rstView_->getKeyword("DUDF")[ this->udq_field_index++ ]; - } - - const std::vector& zudn() { - return this->rstView_->getKeyword("ZUDN"); - } - -private: - std::size_t num_wells; - std::size_t num_groups; - std::shared_ptr rstView_; - - std::size_t udq_well_index = 0; - std::size_t udq_group_index = 0; - std::size_t udq_field_index = 0; -}; // --------------------------------------------------------------------- @@ -1231,8 +1171,7 @@ namespace { // 2) Restore other well quantities (really only xw.bhp) xw.bhp = usys.to_si(M::pressure, xwel[VI::XWell::index::FlowBHP]); - xw.thp = usys.to_si(M::pressure, xwel[VI::XWell::index::TubHeadPr]); - xw.temperature = 0.0; + xw.thp = xw.temperature = 0.0; // 3) Restore connection flow rates (xw.connections[i].rates) // and pressure values (xw.connections[i].pressure). @@ -1447,48 +1386,6 @@ namespace { smry.update(key("GITH"), xgrp[VI::XGroup::index::HistGasInjTotal]); } - - void restore_udq(::Opm::SummaryState& smry, - const ::Opm::Schedule& schedule, - std::shared_ptr& rst_view) - { - if (!rst_view->hasKeyword(std::string("ZUDN"))) - return; - - const auto sim_step = rst_view->simStep(); - const auto& wnames = schedule.wellNames(sim_step); - const auto& groups = schedule.restart_groups(sim_step); - UDQVectors udq_vectors(rst_view); - - for (const auto& udq : udq_vectors.zudn()) { - if (udq[0] == 'W') { - const auto& dudw = udq_vectors.next_dudw(); - for (std::size_t well_index = 0; well_index < wnames.size(); well_index++) { - const auto& value = dudw[well_index]; - if (value != ::Opm::UDQ::restart_default) - smry.update_well_var(wnames[well_index], udq, value); - } - } - - if (udq[0] == 'G') { - const auto& dudg = udq_vectors.next_dudg(); - for (std::size_t group_index = 0; group_index < groups.size(); group_index++) { - const auto& value = dudg[group_index]; - if (value != ::Opm::UDQ::restart_default) { - const auto& group_name = groups[group_index]->name(); - smry.update_group_var(group_name, udq, value); - } - } - } - - if (udq[0] == 'F') { - const auto& value = udq_vectors.next_dudf(); - if (value != ::Opm::UDQ::restart_default) - smry.update(udq, value); - } - } - } - void restore_cumulative(::Opm::SummaryState& smry, const ::Opm::Schedule& schedule, std::shared_ptr rst_view) @@ -1543,7 +1440,6 @@ namespace Opm { namespace RestartIO { RestartValue load(const std::string& filename, int report_step, - Action::State& /* action_state */, SummaryState& summary_state, const std::vector& solution_keys, const EclipseState& es, @@ -1562,9 +1458,8 @@ namespace Opm { namespace RestartIO { auto xw = rst_view->hasKeyword("OPM_XWEL") ? restore_wells_opm(es, grid, schedule, *rst_view) : restore_wells_ecl(es, grid, schedule, rst_view); - data::GroupValues xg; - auto rst_value = RestartValue{ std::move(xr), std::move(xw) , std::move(xg)}; + auto rst_value = RestartValue{ std::move(xr), std::move(xw) }; if (! extra_keys.empty()) { restoreExtra(extra_keys, es.getUnits(), *rst_view, rst_value); @@ -1574,8 +1469,8 @@ namespace Opm { namespace RestartIO { restore_aquifers(es, rst_view, rst_value); } - restore_udq(summary_state, schedule, rst_view); restore_cumulative(summary_state, schedule, std::move(rst_view)); + return rst_value; } diff --git a/ThirdParty/custom-opm-common/opm-common/src/opm/output/eclipse/RestartIO.cpp b/ThirdParty/custom-opm-common/opm-common/src/opm/output/eclipse/RestartIO.cpp index 519c70a102..abb54c9c06 100644 --- a/ThirdParty/custom-opm-common/opm-common/src/opm/output/eclipse/RestartIO.cpp +++ b/ThirdParty/custom-opm-common/opm-common/src/opm/output/eclipse/RestartIO.cpp @@ -59,7 +59,6 @@ #include #include #include -#include #include namespace Opm { namespace RestartIO { @@ -319,7 +318,6 @@ namespace { const int sim_step, const EclipseState& es, const Schedule& schedule, - const Action::State& action_state, const SummaryState& sum_state, EclIO::OutputStream::Restart& rstFile) { @@ -333,7 +331,7 @@ namespace { const auto actDims = Opm::RestartIO::Helpers::createActionxDims(es.runspec(), schedule, simStep); auto actionxData = Opm::RestartIO::Helpers::AggregateActionxData(actDims); - actionxData.captureDeclaredActionxData(schedule, action_state, sum_state, actDims, simStep); + actionxData.captureDeclaredActionxData(schedule, sum_state, actDims, simStep); if (actDims[0] >= 1) { rstFile.write("IACT", actionxData.getIACT()); @@ -354,13 +352,12 @@ namespace { const Schedule& schedule, const std::vector& well_names, const data::Wells& wells, - const Opm::Action::State& action_state, const Opm::SummaryState& sumState, const std::vector& ih, EclIO::OutputStream::Restart& rstFile) { auto wellData = Helpers::AggregateWellData(ih); - wellData.captureDeclaredWellData(schedule, units, sim_step, action_state, sumState, ih); + wellData.captureDeclaredWellData(schedule, units, sim_step, sumState, ih); wellData.captureDynamicWellData(schedule, sim_step, wells, sumState); @@ -398,7 +395,6 @@ namespace { const EclipseGrid& grid, const Schedule& schedule, const data::WellRates& wellSol, - const Opm::Action::State& action_state, const Opm::SummaryState& sumState, const std::vector& inteHD, EclIO::OutputStream::Restart& rstFile) @@ -423,7 +419,7 @@ namespace { writeWell(sim_step, ecl_compatible_rst, phases, units, grid, schedule, wells, - wellSol, action_state, sumState, inteHD, rstFile); + wellSol, sumState, inteHD, rstFile); } } @@ -460,81 +456,6 @@ namespace { return smax; } - std::vector - solutionVectorNames(const RestartValue& value) - { - auto vectors = std::vector{}; - vectors.reserve(value.solution.size()); - - for (const auto& [name, vector] : value.solution) { - if (vector.target == data::TargetType::RESTART_SOLUTION) { - vectors.push_back(name); - } - } - - return vectors; - } - - std::vector - extendedSolutionVectorNames(const RestartValue& value) - { - auto vectors = std::vector{}; - vectors.reserve(value.solution.size()); - - for (const auto& [name, vector] : value.solution) { - if ((vector.target == data::TargetType::RESTART_AUXILIARY) || - (vector.target == data::TargetType::RESTART_OPM_EXTENDED)) - { - vectors.push_back(name); - } - } - - return vectors; - } - - template - void writeSolutionVectors(const RestartValue& value, - const std::vector& vectors, - const bool write_double, - OutputVector&& writeVector) - { - for (const auto& vector : vectors) { - writeVector(vector, value.solution.data(vector), write_double); - } - } - - template - void writeRegularSolutionVectors(const RestartValue& value, - const bool write_double, - OutputVector&& writeVector) - { - writeSolutionVectors(value, solutionVectorNames(value), write_double, - std::forward(writeVector)); - } - - template - void writeExtendedSolutionVectors(const RestartValue& value, - const bool write_double, - OutputVector&& writeVector) - { - writeSolutionVectors(value, extendedSolutionVectorNames(value), write_double, - std::forward(writeVector)); - } - - template - void writeExtraVectors(const RestartValue& value, - OutputVector&& writeVector) - { - for (const auto& elm : value.extra) { - const std::string& key = elm.first.key; - if (extraInSolution(key)) { - // Observe that the extra data is unconditionally - // output as double precision. - writeVector(key, elm.second, true); - } - } - } - template void writeEclipseCompatHysteresis(const RestartValue& value, const bool write_double, @@ -575,6 +496,8 @@ namespace { const std::vector& inteHD, EclIO::OutputStream::Restart& rstFile) { + rstFile.message("STARTSOL"); + auto write = [&rstFile] (const std::string& key, const std::vector& data, @@ -590,23 +513,39 @@ namespace { } }; - rstFile.message("STARTSOL"); - - writeRegularSolutionVectors(value, write_double_arg, write); + for (const auto& elm : value.solution) { + if (elm.second.target == data::TargetType::RESTART_SOLUTION) + { + write(elm.first, elm.second.data, write_double_arg); + } + } writeUDQ(report_step, sim_step, schedule, sum_state, inteHD, rstFile); - - writeExtraVectors(value, write); + + for (const auto& elm : value.extra) { + const std::string& key = elm.first.key; + if (extraInSolution(key)) { + // Observe that the extra data is unconditionally + // output as double precision. + write(key, elm.second, true); + } + } if (ecl_compatible_rst && haveHysteresis(value)) { writeEclipseCompatHysteresis(value, write_double_arg, write); } - if (! ecl_compatible_rst) { - writeExtendedSolutionVectors(value, write_double_arg, write); + rstFile.message("ENDSOL"); + + if (ecl_compatible_rst) { + return; } - rstFile.message("ENDSOL"); + for (const auto& elm : value.solution) { + if (elm.second.target == data::TargetType::RESTART_AUXILIARY) { + write(elm.first, elm.second.data, write_double_arg); + } + } } void writeExtraData(const RestartValue::ExtraVector& extra_data, @@ -654,7 +593,6 @@ void save(EclIO::OutputStream::Restart& rstFile, const EclipseState& es, const EclipseGrid& grid, const Schedule& schedule, - const Action::State& action_state, const SummaryState& sumState, bool write_double) { @@ -679,11 +617,11 @@ void save(EclIO::OutputStream::Restart& rstFile, if (report_step > 0) { writeDynamicData(sim_step, ecl_compatible_rst, es.runspec().phases(), - units, grid, schedule, value.wells, action_state, sumState, + units, grid, schedule, value.wells, sumState, inteHD, rstFile); } - writeActionx(report_step, sim_step, es, schedule, action_state, sumState, rstFile); + writeActionx(report_step, sim_step, es, schedule, sumState, rstFile); writeSolution(value, schedule, sumState, report_step, sim_step, ecl_compatible_rst, write_double, inteHD, rstFile); diff --git a/ThirdParty/custom-opm-common/opm-common/src/opm/output/eclipse/RestartValue.cpp b/ThirdParty/custom-opm-common/opm-common/src/opm/output/eclipse/RestartValue.cpp index 20e23a9d63..bcecaec10b 100644 --- a/ThirdParty/custom-opm-common/opm-common/src/opm/output/eclipse/RestartValue.cpp +++ b/ThirdParty/custom-opm-common/opm-common/src/opm/output/eclipse/RestartValue.cpp @@ -32,10 +32,9 @@ namespace Opm { - RestartValue::RestartValue(data::Solution sol, data::Wells wells_arg, data::GroupValues groups_arg) : + RestartValue::RestartValue(data::Solution sol, data::Wells wells_arg) : solution(std::move(sol)), - wells(std::move(wells_arg)), - groups(std::move(groups_arg)) + wells(std::move(wells_arg)) { } diff --git a/ThirdParty/custom-opm-common/opm-common/src/opm/output/eclipse/Summary.cpp b/ThirdParty/custom-opm-common/opm-common/src/opm/output/eclipse/Summary.cpp index ebea8849d8..6ed7ef06e4 100644 --- a/ThirdParty/custom-opm-common/opm-common/src/opm/output/eclipse/Summary.cpp +++ b/ThirdParty/custom-opm-common/opm-common/src/opm/output/eclipse/Summary.cpp @@ -42,9 +42,8 @@ #include #include -#include #include - +#include #include #include @@ -143,25 +142,19 @@ namespace { { const auto& vectors = requiredRestartVectors(); const std::vector extra_well_vectors { - { "WTHP", Opm::EclIO::SummaryNode::Type::Pressure }, { "WBHP", Opm::EclIO::SummaryNode::Type::Pressure }, { "WGVIR", Opm::EclIO::SummaryNode::Type::Rate }, { "WWVIR", Opm::EclIO::SummaryNode::Type::Rate }, - { "WMCTL", Opm::EclIO::SummaryNode::Type::Mode }, }; const std::vector extra_group_vectors { { "GMCTG", Opm::EclIO::SummaryNode::Type::Mode }, { "GMCTP", Opm::EclIO::SummaryNode::Type::Mode }, { "GMCTW", Opm::EclIO::SummaryNode::Type::Mode }, - { "GMWPR", Opm::EclIO::SummaryNode::Type::Mode }, - { "GMWIN", Opm::EclIO::SummaryNode::Type::Mode }, }; const std::vector extra_field_vectors { { "FMCTG", Opm::EclIO::SummaryNode::Type::Mode }, { "FMCTP", Opm::EclIO::SummaryNode::Type::Mode }, { "FMCTW", Opm::EclIO::SummaryNode::Type::Mode }, - { "FMWPR", Opm::EclIO::SummaryNode::Type::Mode }, - { "FMWIN", Opm::EclIO::SummaryNode::Type::Mode }, }; std::vector entities {} ; @@ -195,7 +188,6 @@ namespace { if (grp_name != "FIELD") { makeEntities('G', Opm::EclIO::SummaryNode::Category::Group, grp_name); makeExtraEntities(extra_group_vectors, Opm::EclIO::SummaryNode::Category::Group, grp_name); - } } @@ -266,6 +258,7 @@ using rt = Opm::data::Rates::opt; using measure = Opm::UnitSystem::measure; constexpr const bool injector = true; constexpr const bool producer = false; +constexpr const bool polymer = true; /* Some numerical value with its unit tag embedded to enable caller to apply * unit conversion. This removes a lot of boilerplate. ad-hoc solution to poor @@ -296,10 +289,6 @@ measure div_unit( measure denom, measure div ) { div == measure::time ) return measure::mass; - if( denom == measure::mass_rate && - div == measure::liquid_surface_rate ) - return measure::polymer_density; - return measure::identity; } @@ -380,7 +369,7 @@ struct fn_args { int num; const Opm::SummaryState& st; const Opm::data::Wells& wells; - const Opm::data::GroupValues& groups; + const Opm::data::Group& group; const Opm::out::RegionCache& regionCache; const Opm::EclipseGrid& grid; const std::vector< std::pair< std::string, double > > eff_factors; @@ -440,7 +429,7 @@ double efac( const std::vector>& eff_factors, cons return (it != eff_factors.end()) ? it->second : 1; } -template< rt phase, bool injection = true > +template< rt phase, bool injection = true, bool polymer = false > inline quantity rate( const fn_args& args ) { double sum = 0.0; @@ -450,7 +439,11 @@ inline quantity rate( const fn_args& args ) { double eff_fac = efac( args.eff_factors, name ); - const auto v = args.wells.at(name).rates.get(phase, 0.0) * eff_fac; + double concentration = polymer + ? sched_well.getPolymerProperties().m_polymerConcentration + : 1; + + const auto v = args.wells.at(name).rates.get(phase, 0.0) * eff_fac * concentration; if( ( v > 0 ) == injection ) sum += v; @@ -458,7 +451,7 @@ inline quantity rate( const fn_args& args ) { if( !injection ) sum *= -1; - if (phase == rt::polymer || phase == rt::brine) return { sum, measure::mass_rate }; + if( polymer ) return { sum, measure::mass_rate }; return { sum, rate_unit< phase >() }; } @@ -478,7 +471,7 @@ inline quantity flowing( const fn_args& args ) { measure::identity }; } -template< rt phase, bool injection = true> +template< rt phase, bool injection = true, bool polymer = false > inline quantity crate( const fn_args& args ) { const quantity zero = { 0, rate_unit< phase >() }; // The args.num value is the literal value which will go to the @@ -502,15 +495,19 @@ inline quantity crate( const fn_args& args ) { if( completion == well_data.connections.end() ) return zero; double eff_fac = efac( args.eff_factors, name ); - auto v = completion->rates.get( phase, 0.0 ) * eff_fac; + double concentration = polymer + ? well.getPolymerProperties().m_polymerConcentration + : 1; + + auto v = completion->rates.get( phase, 0.0 ) * eff_fac * concentration; if( ( v > 0 ) != injection ) return zero; if( !injection ) v *= -1; - if( phase == rt::polymer || phase == rt::brine ) return { v, measure::mass_rate }; + if( polymer ) return { v, measure::mass_rate }; return { v, rate_unit< phase >() }; } -template< rt phase> +template< rt phase, bool polymer = false > inline quantity srate( const fn_args& args ) { const quantity zero = { 0, rate_unit< phase >() }; // The args.num value is the literal value which will go to the @@ -531,11 +528,15 @@ inline quantity srate( const fn_args& args ) { if( segment == well_data.segments.end() ) return zero; double eff_fac = efac( args.eff_factors, name ); - auto v = segment->second.rates.get( phase, 0.0 ) * eff_fac; + double concentration = polymer + ? well.getPolymerProperties().m_polymerConcentration + : 1; + + auto v = segment->second.rates.get( phase, 0.0 ) * eff_fac * concentration; //switch sign of rate - opposite convention in flow vs eclipse v *= -1; - if( phase == rt::polymer || phase == rt::brine ) return { v, measure::mass_rate }; + if( polymer ) return { v, measure::mass_rate }; return { v, rate_unit< phase >() }; } @@ -721,11 +722,11 @@ inline quantity potential_rate( const fn_args& args ) { if (sched_well.isInjector() && outputInjector) { const auto v = args.wells.at(name).rates.get(phase, 0.0); - sum += v * efac(args.eff_factors, name); + sum += v; } else if (sched_well.isProducer() && outputProducer) { const auto v = args.wells.at(name).rates.get(phase, 0.0); - sum += v * efac(args.eff_factors, name); + sum += v; } } @@ -750,9 +751,9 @@ inline quantity group_control( const fn_args& args ) { // production control if (Producer) { - auto it_g = args.groups.find(g_name); - if (it_g != args.groups.end()) { - const auto& value = it_g->second.currentControl.currentProdConstraint; + const auto it_g = args.group.find(g_name); + if (it_g != args.group.end()) { + const auto& value = it_g->second.currentProdConstraint; auto it_c = pCModeToPCntlMode.find(value); if (it_c == pCModeToPCntlMode.end()) { std::stringstream str; @@ -764,9 +765,9 @@ inline quantity group_control( const fn_args& args ) { } // water injection control else if (waterInjector){ - auto it_g = args.groups.find(g_name); - if (it_g != args.groups.end()) { - const auto& value = it_g->second.currentControl.currentWaterInjectionConstraint; + const auto it_g = args.group.find(g_name); + if (it_g != args.group.end()) { + const auto& value = it_g->second.currentWaterInjectionConstraint; auto it_c = iCModeToICntlMode.find(value); if (it_c == iCModeToICntlMode.end()) { std::stringstream str; @@ -779,9 +780,9 @@ inline quantity group_control( const fn_args& args ) { // gas injection control else if (gasInjector){ - auto it_g = args.groups.find(g_name); - if (it_g != args.groups.end()) { - const auto& value = it_g->second.currentControl.currentGasInjectionConstraint; + const auto it_g = args.group.find(g_name); + if (it_g != args.group.end()) { + const auto& value = it_g->second.currentGasInjectionConstraint; auto it_c = iCModeToICntlMode.find(value); if (it_c == iCModeToICntlMode.end()) { std::stringstream str; @@ -883,8 +884,7 @@ static const std::unordered_map< std::string, ofun > funs = { { "WOIR", rate< rt::oil, injector > }, { "WGIR", rate< rt::gas, injector > }, { "WNIR", rate< rt::solvent, injector > }, - { "WCIR", rate< rt::polymer, injector > }, - { "WSIR", rate< rt::brine, injector > }, + { "WCIR", rate< rt::wat, injector, polymer > }, { "WVIR", sum( sum( rate< rt::reservoir_water, injector >, rate< rt::reservoir_oil, injector > ), rate< rt::reservoir_gas, injector > ) }, @@ -892,8 +892,7 @@ static const std::unordered_map< std::string, ofun > funs = { { "WOIT", mul( rate< rt::oil, injector >, duration ) }, { "WGIT", mul( rate< rt::gas, injector >, duration ) }, { "WNIT", mul( rate< rt::solvent, injector >, duration ) }, - { "WCIT", mul( rate< rt::polymer, injector >, duration ) }, - { "WSIT", mul( rate< rt::brine, injector >, duration ) }, + { "WCIT", mul( rate< rt::wat, injector, polymer >, duration ) }, { "WVIT", mul( sum( sum( rate< rt::reservoir_water, injector >, rate< rt::reservoir_oil, injector > ), rate< rt::reservoir_gas, injector > ), duration ) }, @@ -901,10 +900,6 @@ static const std::unordered_map< std::string, ofun > funs = { { "WOPR", rate< rt::oil, producer > }, { "WGPR", rate< rt::gas, producer > }, { "WNPR", rate< rt::solvent, producer > }, - { "WCPR", rate< rt::polymer, producer > }, - { "WSPR", rate< rt::brine, producer > }, - { "WCPC", div( rate< rt::polymer, producer >, rate< rt::wat, producer >) }, - { "WSPC", div( rate< rt::brine, producer >, rate< rt::wat, producer >) }, { "WGPRS", rate< rt::dissolved_gas, producer > }, { "WGPRF", sub( rate< rt::gas, producer >, rate< rt::dissolved_gas, producer > ) }, @@ -919,10 +914,9 @@ static const std::unordered_map< std::string, ofun > funs = { { "WOPT", mul( rate< rt::oil, producer >, duration ) }, { "WGPT", mul( rate< rt::gas, producer >, duration ) }, { "WNPT", mul( rate< rt::solvent, producer >, duration ) }, - { "WCPT", mul( rate< rt::polymer, producer >, duration ) }, - { "WSPT", mul( rate< rt::brine, producer >, duration ) }, { "WLPT", mul( sum( rate< rt::wat, producer >, rate< rt::oil, producer > ), duration ) }, + { "WGPTS", mul( rate< rt::dissolved_gas, producer >, duration )}, { "WGPTF", sub( mul( rate< rt::gas, producer >, duration ), mul( rate< rt::dissolved_gas, producer >, duration ))}, @@ -953,16 +947,14 @@ static const std::unordered_map< std::string, ofun > funs = { { "GOIR", rate< rt::oil, injector > }, { "GGIR", rate< rt::gas, injector > }, { "GNIR", rate< rt::solvent, injector > }, - { "GCIR", rate< rt::polymer, injector > }, - { "GSIR", rate< rt::brine, injector > }, + { "GCIR", rate< rt::wat, injector, polymer > }, { "GVIR", sum( sum( rate< rt::reservoir_water, injector >, rate< rt::reservoir_oil, injector > ), rate< rt::reservoir_gas, injector > ) }, { "GWIT", mul( rate< rt::wat, injector >, duration ) }, { "GOIT", mul( rate< rt::oil, injector >, duration ) }, { "GGIT", mul( rate< rt::gas, injector >, duration ) }, { "GNIT", mul( rate< rt::solvent, injector >, duration ) }, - { "GCIT", mul( rate< rt::polymer, injector >, duration ) }, - { "GSIT", mul( rate< rt::brine, injector >, duration ) }, + { "GCIT", mul( rate< rt::wat, injector, polymer >, duration ) }, { "GVIT", mul( sum( sum( rate< rt::reservoir_water, injector >, rate< rt::reservoir_oil, injector > ), rate< rt::reservoir_gas, injector > ), duration ) }, @@ -970,10 +962,6 @@ static const std::unordered_map< std::string, ofun > funs = { { "GOPR", rate< rt::oil, producer > }, { "GGPR", rate< rt::gas, producer > }, { "GNPR", rate< rt::solvent, producer > }, - { "GCPR", rate< rt::polymer, producer > }, - { "GSPR", rate< rt::brine, producer > }, - { "GCPC", div( rate< rt::polymer, producer >, rate< rt::wat, producer >) }, - { "GSPC", div( rate< rt::brine, producer >, rate< rt::wat, producer >) }, { "GOPRS", rate< rt::vaporized_oil, producer > }, { "GOPRF", sub (rate < rt::oil, producer >, rate< rt::vaporized_oil, producer > ) }, { "GLPR", sum( rate< rt::wat, producer >, rate< rt::oil, producer > ) }, @@ -984,7 +972,6 @@ static const std::unordered_map< std::string, ofun > funs = { { "GOPT", mul( rate< rt::oil, producer >, duration ) }, { "GGPT", mul( rate< rt::gas, producer >, duration ) }, { "GNPT", mul( rate< rt::solvent, producer >, duration ) }, - { "GCPT", mul( rate< rt::polymer, producer >, duration ) }, { "GOPTS", mul( rate< rt::vaporized_oil, producer >, duration ) }, { "GOPTF", mul( sub (rate < rt::oil, producer >, rate< rt::vaporized_oil, producer > ), @@ -1083,8 +1070,7 @@ static const std::unordered_map< std::string, ofun > funs = { { "CWIR", crate< rt::wat, injector > }, { "CGIR", crate< rt::gas, injector > }, - { "CCIR", crate< rt::polymer, injector > }, - { "CSIR", crate< rt::brine, injector > }, + { "CCIR", crate< rt::wat, injector, polymer > }, { "CWIT", mul( crate< rt::wat, injector >, duration ) }, { "CGIT", mul( crate< rt::gas, injector >, duration ) }, { "CNIT", mul( crate< rt::solvent, injector >, duration ) }, @@ -1092,8 +1078,6 @@ static const std::unordered_map< std::string, ofun > funs = { { "CWPR", crate< rt::wat, producer > }, { "COPR", crate< rt::oil, producer > }, { "CGPR", crate< rt::gas, producer > }, - { "CCPR", crate< rt::polymer, producer > }, - { "CSPR", crate< rt::brine, producer > }, { "CGFR", sub(crate, crate) }, { "COFR", sub(crate, crate) }, { "CWFR", sub(crate, crate) }, @@ -1106,20 +1090,14 @@ static const std::unordered_map< std::string, ofun > funs = { { "COPT", mul( crate< rt::oil, producer >, duration ) }, { "CGPT", mul( crate< rt::gas, producer >, duration ) }, { "CNPT", mul( crate< rt::solvent, producer >, duration ) }, - { "CCIT", mul( crate< rt::polymer, injector >, duration ) }, - { "CCPT", mul( crate< rt::polymer, producer >, duration ) }, - { "CSIT", mul( crate< rt::brine, injector >, duration ) }, - { "CSPT", mul( crate< rt::brine, producer >, duration ) }, + { "CCIT", mul( crate< rt::wat, injector, polymer >, duration ) }, + { "CCPT", mul( crate< rt::wat, producer, polymer >, duration ) }, { "CTFAC", trans_factors }, { "FWPR", rate< rt::wat, producer > }, { "FOPR", rate< rt::oil, producer > }, { "FGPR", rate< rt::gas, producer > }, { "FNPR", rate< rt::solvent, producer > }, - { "FCPR", rate< rt::polymer, producer > }, - { "FSPR", rate< rt::brine, producer > }, - { "FCPC", div( rate< rt::polymer, producer >, rate< rt::wat, producer >) }, - { "FSPC", div( rate< rt::brine, producer >, rate< rt::wat, producer >) }, { "FVPR", sum( sum( rate< rt::reservoir_water, producer>, rate< rt::reservoir_oil, producer >), rate< rt::reservoir_gas, producer>)}, { "FGPRS", rate< rt::dissolved_gas, producer > }, @@ -1132,8 +1110,6 @@ static const std::unordered_map< std::string, ofun > funs = { { "FOPT", mul( rate< rt::oil, producer >, duration ) }, { "FGPT", mul( rate< rt::gas, producer >, duration ) }, { "FNPT", mul( rate< rt::solvent, producer >, duration ) }, - { "FCPT", mul( rate< rt::polymer, producer >, duration ) }, - { "FSPT", mul( rate< rt::brine, producer >, duration ) }, { "FLPT", mul( sum( rate< rt::wat, producer >, rate< rt::oil, producer > ), duration ) }, { "FVPT", mul(sum (sum( rate< rt::reservoir_water, producer>, rate< rt::reservoir_oil, producer >), @@ -1149,10 +1125,8 @@ static const std::unordered_map< std::string, ofun > funs = { { "FOIR", rate< rt::oil, injector > }, { "FGIR", rate< rt::gas, injector > }, { "FNIR", rate< rt::solvent, injector > }, - { "FCIR", rate< rt::polymer, injector > }, - { "FCPR", rate< rt::polymer, producer > }, - { "FSIR", rate< rt::brine, injector > }, - { "FSPR", rate< rt::brine, producer > }, + { "FCIR", rate< rt::wat, injector, polymer > }, + { "FCPR", rate< rt::wat, producer, polymer > }, { "FVIR", sum( sum( rate< rt::reservoir_water, injector>, rate< rt::reservoir_oil, injector >), rate< rt::reservoir_gas, injector>)}, @@ -1161,10 +1135,8 @@ static const std::unordered_map< std::string, ofun > funs = { { "FOIT", mul( rate< rt::oil, injector >, duration ) }, { "FGIT", mul( rate< rt::gas, injector >, duration ) }, { "FNIT", mul( rate< rt::solvent, injector >, duration ) }, - { "FCIT", mul( rate< rt::polymer, injector >, duration ) }, - { "FCPT", mul( rate< rt::polymer, producer >, duration ) }, - { "FSIT", mul( rate< rt::brine, injector >, duration ) }, - { "FSPT", mul( rate< rt::brine, producer >, duration ) }, + { "FCIT", mul( rate< rt::wat, injector, polymer >, duration ) }, + { "FCPT", mul( rate< rt::wat, producer, polymer >, duration ) }, { "FLIT", mul( sum( rate< rt::wat, injector >, rate< rt::oil, injector > ), duration ) }, { "FVIT", mul( sum( sum( rate< rt::reservoir_water, injector>, rate< rt::reservoir_oil, injector >), @@ -1400,6 +1372,63 @@ bool need_wells(const Opm::EclIO::SummaryNode& node) { throw std::runtime_error("Unhandled summary node category in need_wells"); } +void eval_udq(const Opm::Schedule& schedule, std::size_t sim_step, Opm::SummaryState& st) +{ + using namespace Opm; + + const UDQConfig& udq = schedule.getUDQConfig(sim_step); + const auto& func_table = udq.function_table(); + UDQContext context(func_table, st); + { + const std::vector wells = st.wells(); + + for (const auto& assign : udq.assignments(UDQVarType::WELL_VAR)) { + auto ws = assign.eval(wells); + for (const auto& well : wells) { + const auto& udq_value = ws[well]; + if (udq_value) + st.update_well_var(well, ws.name(), udq_value.value()); + } + } + + for (const auto& def : udq.definitions(UDQVarType::WELL_VAR)) { + auto ws = def.eval(context); + for (const auto& well : wells) { + const auto& udq_value = ws[well]; + if (udq_value) + st.update_well_var(well, def.keyword(), udq_value.value()); + } + } + } + + { + const std::vector groups = st.groups(); + + for (const auto& assign : udq.assignments(UDQVarType::GROUP_VAR)) { + auto ws = assign.eval(groups); + for (const auto& group : groups) { + const auto& udq_value = ws[group]; + if (udq_value) + st.update_group_var(group, ws.name(), udq_value.value()); + } + } + + for (const auto& def : udq.definitions(UDQVarType::GROUP_VAR)) { + auto ws = def.eval(context); + for (const auto& group : groups) { + const auto& udq_value = ws[group]; + if (udq_value) + st.update_group_var(group, def.keyword(), udq_value.value()); + } + } + } + + for (const auto& def : udq.definitions(UDQVarType::FIELD_VAR)) { + auto field_udq = def.eval(context); + if (field_udq[0]) + st.update(def.keyword(), field_udq[0].value()); + } +} void updateValue(const Opm::EclIO::SummaryNode& node, const double value, Opm::SummaryState& st) { @@ -1494,7 +1523,7 @@ namespace Evaluator { struct SimulatorResults { const Opm::data::WellRates& wellSol; - const Opm::data::GroupValues& groupSol; + const Opm::data::Group& groupSol; const std::map& single; const std::map>& region; const std::map, double>& block; @@ -2020,7 +2049,7 @@ namespace Evaluator { const auto& kw = this->node_->keyword; return this->udq_.has_unit(kw) - ? this->udq_.unit(kw) : ""; + ? this->udq_.unit(kw) : "?????"; } } // namespace Evaluator @@ -2230,7 +2259,7 @@ public: const int sim_step, const double duration, const data::WellRates& well_solution, - const data::GroupValues& group_solution, + const data::Group& group_solution, const GlobalProcessParameters& single_values, const RegionParameters& region_values, const BlockValues& block_values, @@ -2332,7 +2361,7 @@ eval(const EclipseState& es, const int sim_step, const double duration, const data::WellRates& well_solution, - const data::GroupValues& group_solution, + const data::Group& group_solution, const GlobalProcessParameters& single_values, const RegionParameters& region_values, const BlockValues& block_values, @@ -2633,7 +2662,7 @@ void Summary::eval(SummaryState& st, const EclipseState& es, const Schedule& schedule, const data::WellRates& well_solution, - const data::GroupValues& group_solution, + const data::Group& group_solution, const GlobalProcessParameters& single_values, const RegionParameters& region_values, const BlockValues& block_values) const @@ -2657,8 +2686,8 @@ void Summary::eval(SummaryState& st, well_solution, group_solution, single_values, region_values, block_values, st); - const auto& udq = schedule.getUDQConfig(sim_step); - udq.eval(st); + eval_udq(schedule, sim_step, st); + st.update_elapsed(duration); } diff --git a/ThirdParty/custom-opm-common/opm-common/src/opm/output/eclipse/Tables.cpp b/ThirdParty/custom-opm-common/opm-common/src/opm/output/eclipse/Tables.cpp index b83c6c4979..dca0d46336 100644 --- a/ThirdParty/custom-opm-common/opm-common/src/opm/output/eclipse/Tables.cpp +++ b/ThirdParty/custom-opm-common/opm-common/src/opm/output/eclipse/Tables.cpp @@ -232,7 +232,7 @@ namespace { namespace SatFunc { std::transform(begin, end, dest, [tolcrit](const double kr) -> double { - return (kr > tolcrit) ? kr : 0.0; + return (kr < tolcrit) ? 0.0 : kr; }); } diff --git a/ThirdParty/custom-opm-common/opm-common/src/opm/output/eclipse/WriteRPT.cpp b/ThirdParty/custom-opm-common/opm-common/src/opm/output/eclipse/WriteRPT.cpp index d568d74070..2474bc7737 100644 --- a/ThirdParty/custom-opm-common/opm-common/src/opm/output/eclipse/WriteRPT.cpp +++ b/ThirdParty/custom-opm-common/opm-common/src/opm/output/eclipse/WriteRPT.cpp @@ -24,7 +24,7 @@ namespace Opm::RptIO { - using report_function = std::function; + using report_function = std::function; static const std::unordered_map report_functions { { "WELSPECS", workers::write_WELSPECS }, @@ -36,12 +36,11 @@ namespace Opm::RptIO { unsigned value, const Opm::Schedule& schedule, const Opm::EclipseGrid& grid, - const Opm::UnitSystem& unit_system, std::size_t report_step ) { const auto function { report_functions.find(report) } ; if (function != report_functions.end()) { - function->second(os, value, schedule, grid, unit_system, report_step); + function->second(os, value, schedule, grid, report_step); } } } diff --git a/ThirdParty/custom-opm-common/opm-common/src/opm/output/eclipse/report/WELSPECS.cpp b/ThirdParty/custom-opm-common/opm-common/src/opm/output/eclipse/report/WELSPECS.cpp index db6645acda..0eda8e4c5d 100644 --- a/ThirdParty/custom-opm-common/opm-common/src/opm/output/eclipse/report/WELSPECS.cpp +++ b/ThirdParty/custom-opm-common/opm-common/src/opm/output/eclipse/report/WELSPECS.cpp @@ -21,12 +21,9 @@ #include #include -#include -#include -#include #include -#include +#include namespace { @@ -71,59 +68,45 @@ namespace { } } - std::string underline(const std::string& string) { - return std::string(string.size(), divider_character); - } - struct context { const Opm::Schedule& sched; const Opm::EclipseGrid& grid; - const Opm::UnitSystem& unit_system; }; - std::string format_number(const Opm::UnitSystem& unit_system, Opm::UnitSystem::measure measure, double number, std::size_t width) { - return std::to_string(unit_system.from_si(measure, number)).substr(0, width); - } - template - const std::string& unimplemented(const T&, const context&, std::size_t, std::size_t) { + const std::string& unimplemented(const T&, const context&, std::size_t) { static const std::string s { } ; return s; } + template + bool add_separator(const T&, std::size_t line_number) { + return line_number == 0; + } + template struct column { - using fetch_function = std::function; + using fetch_function = std::function; using format_function = std::function; std::size_t internal_width; std::array header; - fetch_function fetch { unimplemented } ; - format_function format { centre_align } ; + fetch_function fetch = unimplemented; + format_function format = centre_align; - std::optional dimension { std::nullopt } ; - - void print(std::ostream& os, const T& data, const context& ctx, std::size_t sub_report, std::size_t line_number) const { - std::string string_data { fetch(data, ctx, sub_report, line_number) } ; + void print(std::ostream& os, const T& data, const context& ctx, std::size_t line_number) const { + std::string string_data { fetch(data, ctx, line_number) } ; format(string_data, internal_width, line_number); centre_align(string_data, total_width()); os << string_data; } - std::string header_line(std::size_t row, context ctx) const { - if (row == header_height && dimension) { - return ctx.unit_system.name(dimension.value()); - } else { - return header[row]; - } - } - - void print_header(std::ostream& os, std::size_t row, context ctx) const { - std::string line { header_line(row, ctx) } ; - centre_align(line, total_width()); - os << line; + void print_header(std::ostream& os, std::size_t row) const { + std::string header_line { header[row] } ; + centre_align(header_line, total_width()); + os << header_line; } constexpr std::size_t total_width() const { @@ -134,6 +117,7 @@ namespace { template struct table: std::vector> { using std::vector>::vector; + using separator_function = std::function; std::size_t total_width() const { std::size_t r { 1 + this->size() } ; @@ -149,27 +133,30 @@ namespace { os << std::string(total_width(), padding) << record_separator; } - void print_header(std::ostream& os, context ctx) const { + void print_header(std::ostream& os) const { print_divider(os); + for (size_t i { 0 }; i < header_height; ++i) { for (const auto& column : *this) { os << field_separator; - column.print_header(os, i, ctx); + column.print_header(os, i); } os << field_separator << record_separator; } - print_divider(os); } - void print_data(std::ostream& os, const std::vector& lines, const context& ctx, std::size_t sub_report) const { - std::size_t line_number { 0 } ; + void print_data(std::ostream& os, const std::vector& lines, const context& ctx, const separator_function& separator, std::size_t& line_number) const { for (const auto& line : lines) { + if (separator(line, line_number)) { + print_divider(os); + } for (const auto& column : *this) { os << field_separator; - column.print(os, line, ctx, sub_report, line_number); + + column.print(os, line, ctx, line_number); } os << field_separator << record_separator; @@ -181,43 +168,55 @@ namespace { template - struct report { + struct subreport { + using transform_function = std::function(const InputType&)>; + using separator_function = typename table::separator_function; std::string title; std::string decor; table column_definition; const context ctx; + char bottom_border; + transform_function transform; + separator_function separator; - report(const std::string& _title, const table& _coldef, const context& _ctx) + subreport(const std::string& _title, const table& _coldef, const context& _ctx, char _bottom_border = '-', separator_function _sf = add_separator, transform_function _tf = &OutputType::transform) : title { _title } , decor { underline(title) } , column_definition { _coldef } , ctx { _ctx } + , bottom_border { _bottom_border } + , transform { _tf } + , separator { _sf } { centre_align(title, column_definition.total_width()); centre_align(decor, column_definition.total_width()); } - void print_header(std::ostream& os) const { + std::string underline(const std::string& string) const { + return std::string(string.size(), divider_character); + } + + void print(std::ostream& os, const std::vector& data, const std::vector>& footnotes) const { os << title << record_separator; os << decor << record_separator; + + std::size_t line_number { 0 } ; + os << section_separator; - column_definition.print_header(os, ctx); - } - void print_data(std::ostream& os, const std::vector& data, std::size_t sub_report = 0, char bottom_border = '-') const { - column_definition.print_data(os, data, this->ctx, sub_report); - column_definition.print_divider(os, bottom_border); - } - - void print_footer(std::ostream& os, const std::vector>& footnotes) const { - for (const auto& fnote: footnotes) { - os << fnote.first << ": " << fnote.second << record_separator; + column_definition.print_header(os); + for (const auto element : data) { + column_definition.print_data(os, transform(element), this->ctx, separator, line_number); } + column_definition.print_divider(os, bottom_border); + for (const auto& fnote: footnotes) + os << fnote.first << ": " << fnote.second << std::endl; - os << section_separator; + os << std::endl << std::endl; } }; + } namespace { @@ -281,15 +280,19 @@ namespace { struct WellWrapper { const Opm::Well& well; - std::string well_name(const context&, std::size_t, std::size_t) const { + static std::vector transform(const Opm::Well& well) { + return {{ well }} ; + } + + std::string well_name(const context&, std::size_t) const { return well.name(); } - std::string group_name(const context&, std::size_t, std::size_t) const { + std::string group_name(const context&, std::size_t) const { return well.groupName(); } - std::string wellhead_location(const context&, std::size_t, std::size_t) const { + std::string wellhead_location(const context&, std::size_t) const { auto i { std::to_string(well.getHeadI() + 1) }, j { std::to_string(well.getHeadJ() + 1) } ; right_align(i, 3); @@ -298,11 +301,11 @@ namespace { return i + ", " + j; } - std::string reference_depth(const context& ctx, std::size_t, std::size_t) const { - return format_number(ctx.unit_system, Opm::UnitSystem::measure::length, well.getRefDepth(), 6); + std::string reference_depth(const context&, std::size_t) const { + return std::to_string(well.getRefDepth()).substr(0,6); } - std::string preferred_phase(const context&, std::size_t, std::size_t) const { + std::string preferred_phase(const context&, std::size_t) const { std::ostringstream ss; ss << well.getPreferredPhase(); @@ -310,41 +313,43 @@ namespace { return ss.str().substr(0, 3); } - std::string pvt_tab(const context&, std::size_t, std::size_t) const { + std::string pvt_tab(const context&, std::size_t) const { return std::to_string( well.pvt_table_number() ); } - std::string shut_status(const context&, std::size_t, std::size_t) const { + std::string shut_status(const context&, std::size_t) const { return Opm::Well::Status2String(well.getStatus()); } - std::string region_number(const context&, std::size_t, std::size_t) const { + std::string region_number(const context&, std::size_t) const { return std::to_string( well.fip_region_number() ); } - std::string dens_calc(const context&, std::size_t, std::size_t) const { - return well.segmented_density_calculation() ? "SEG" : "AVG"; + std::string dens_calc(const context&, std::size_t) const { + if (well.segmented_density_calculation()) + return "SEG"; + return "AVG"; } /* Don't know what the D-FACTOR represents, but all examples just show 0; we have therefor hardcoded that for now. */ - std::string D_factor(const context&, std::size_t, std::size_t) const { + std::string D_factor(const context&, std::size_t) const { return "0"; } - std::string cross_flow(const context&, std::size_t, std::size_t) const { + std::string cross_flow(const context&, std::size_t) const { return well.getAllowCrossFlow() ? "YES" : "NO"; } - std::string drainage_radius(const context& ctx, std::size_t, std::size_t) const { + std::string drainage_radius(const context&, std::size_t) const { if (well.getDrainageRadius() == 0) return "P.EQUIV.R"; - return format_number(ctx.unit_system, Opm::UnitSystem::measure::length, well.getDrainageRadius(), 6); + return std::to_string(well.getDrainageRadius()).substr(0,6); } - std::string gas_inflow(const context&, std::size_t, std::size_t) const { + std::string gas_inflow(const context&, std::size_t) const { return Opm::Well::GasInflowEquation2String( well.gas_inflow_equation() ); } }; @@ -353,9 +358,9 @@ namespace { { 8, { "WELL" , "NAME" , }, &WellWrapper::well_name , left_align }, { 8, { "GROUP" , "NAME" , }, &WellWrapper::group_name , left_align }, { 8, { "WELLHEAD" , "LOCATION" , "( I, J )" }, &WellWrapper::wellhead_location, left_align }, - { 8, { "B.H.REF" , "DEPTH" , "METRES" }, &WellWrapper::reference_depth , right_align, Opm::UnitSystem::measure::length }, + { 8, { "B.H.REF" , "DEPTH" , "METRES" }, &WellWrapper::reference_depth , right_align }, { 5, { "PREF-" , "ERRED" , "PHASE" }, &WellWrapper::preferred_phase , }, - { 8, { "DRAINAGE" , "RADIUS" , "METRES" }, &WellWrapper::drainage_radius , right_align, Opm::UnitSystem::measure::length }, + { 8, { "DRAINAGE" , "RADIUS" , "METRES" }, &WellWrapper::drainage_radius , }, { 4, { "GAS" , "INFL" , "EQUN" }, &WellWrapper::gas_inflow , }, { 7, { "SHUT-IN" , "INSTRCT" , }, &WellWrapper::shut_status , }, { 5, { "CROSS" , "FLOW" , "ABLTY" }, &WellWrapper::cross_flow , }, @@ -366,55 +371,11 @@ namespace { -void report_well_specification_data(std::ostream& os, const std::vector& data, const context& ctx) { - report well_specification { "WELL SPECIFICATION DATA", well_specification_table, ctx}; - std::vector wrapper_data; - std::transform(data.begin(), data.end(), std::back_inserter(wrapper_data), [](const Opm::Well& well) { return WellWrapper { well } ; }); - - well_specification.print_header(os); - well_specification.print_data(os, wrapper_data); - well_specification.print_footer(os, {{1, "The WELL D-FACTOR is not implemented - and the report will always show the default value 0."}}); -} - -} - -namespace { - - struct GroupWrapper { - const Opm::GTNode& node; - - const std::string& group_name(const context&, std::size_t, std::size_t) const { - return node.group().name(); - } - - std::string group_level(const context&, std::size_t, std::size_t) const { - return std::to_string(node.level()); - } - - const std::string& group_parent(const context&, std::size_t, std::size_t) const { - return node.parent_name(); - } - }; - - const table group_levels_table { - { 8, { "GROUP" , "NAME" }, &GroupWrapper::group_name , left_align }, - { 5, { "LEVEL" , }, &GroupWrapper::group_level , }, - { 8, { "PARENT" , "GROUP" }, &GroupWrapper::group_parent, left_align }, - }; - - void report_group_levels_data(std::ostream& os, const context& ctx, std::size_t report_step) { - const report group_levels { "GROUP LEVELS", group_levels_table, ctx } ; - group_levels.print_header(os); - - std::vector data { } ; - const Opm::GTNode root { ctx.sched.groupTree(report_step) } ; - std::vector nodes { root.all_nodes() } ; - - std::transform(++nodes.begin(), nodes.end(), std::back_inserter(data), [](const Opm::GTNode* node) { return GroupWrapper { *node } ; }); - - group_levels.print_data(os, data); - group_levels.print_footer(os, {}); +void subreport_well_specification_data(std::ostream& os, const std::vector& data, const context& ctx) { + subreport well_specification { "WELL SPECIFICATION DATA", well_specification_table, ctx}; + well_specification.print(os, data, {{1, "The WELL D-FACTOR is not implemented - and the report will always show the default value 0."}}); } + } namespace { @@ -423,14 +384,14 @@ namespace { const Opm::Well& well; const Opm::Connection& connection; - const std::string& well_name(const context&, std::size_t, std::size_t) const { + const std::string& well_name(const context&, std::size_t) const { return well.name(); } - std::string grid_block(const context&, std::size_t, std::size_t) const { + std::string grid_block(const context&, std::size_t) const { const std::array ijk { connection.getI() + 1, connection.getJ() + 1, connection.getK() + 1 } ; - auto compose_coordinates { [](std::string& out, int in) -> std::string { + auto compose_coordinates = [](std::string& out, int in) -> std::string { constexpr auto delimiter { ',' } ; std::string coordinate_part { std::to_string(in) } ; right_align(coordinate_part, 3); @@ -438,62 +399,72 @@ namespace { return out.empty() ? coordinate_part : out + delimiter + coordinate_part; - } }; + }; return std::accumulate(std::begin(ijk), std::end(ijk), std::string {}, compose_coordinates); } - std::string cmpl_no(const context&, std::size_t, std::size_t) const { + std::string cmpl_no(const context&, std::size_t) const { return std::to_string(connection.complnum()); } - std::string centre_depth(const context& ctx, std::size_t, std::size_t) const { - return format_number(ctx.unit_system, Opm::UnitSystem::measure::length, connection.depth(), 6); + std::string centre_depth(const context&, std::size_t) const { + return std::to_string(connection.depth()).substr(0, 6); } - std::string open_shut(const context&, std::size_t, std::size_t) const { + std::string open_shut(const context&, std::size_t) const { return Opm::Connection::State2String(connection.state()); } - std::string sat_tab(const context&, std::size_t, std::size_t) const { + std::string sat_tab(const context&, std::size_t) const { return std::to_string(connection.satTableId()); } - std::string conn_factor(const context& ctx, std::size_t, std::size_t) const { - return format_number(ctx.unit_system, Opm::UnitSystem::measure::transmissibility, connection.CF(), 10); + std::string conn_factor(const context&, std::size_t) const { + return std::to_string(connection.CF()).substr(0, 10); } - std::string int_diam(const context& ctx, std::size_t, std::size_t) const { - return format_number(ctx.unit_system, Opm::UnitSystem::measure::length, connection.rw() * 2, 8); + std::string int_diam(const context&, std::size_t) const { + return std::to_string(connection.rw() * 2).substr(0, 8); } - std::string kh_value(const context&, std::size_t, std::size_t) const { + std::string kh_value(const context&, std::size_t) const { return std::to_string(connection.Kh()).substr(0, 9); } - std::string skin_factor(const context&, std::size_t, std::size_t) const { + std::string skin_factor(const context&, std::size_t) const { return std::to_string(connection.skinFactor()).substr(0, 8); } - std::string sat_scaling(const context&, std::size_t, std::size_t) const { + std::string sat_scaling(const context&, std::size_t) const { return ""; } - const std::string dfactor(const context&, std::size_t, std::size_t) const { + const std::string dfactor(const context&, std::size_t) const { return "0"; } + static std::vector transform(const Opm::Well& well) { + const auto &connections { well.getConnections() } ; + std::vector out; + + for (const auto& connection : connections) { + out.push_back({ well, connection }); + } + + return out; + } }; const table connection_table { { 7, {"WELL" ,"NAME" , }, &WellConnection::well_name , left_align }, { 12, {"GRID" ,"BLOCK" , }, &WellConnection::grid_block , }, { 3, {"CMPL" ,"NO#" , }, &WellConnection::cmpl_no , right_align }, - { 7, {"CENTRE" ,"DEPTH" ,"METRES" }, &WellConnection::centre_depth , right_align, Opm::UnitSystem::measure::length }, + { 7, {"CENTRE" ,"DEPTH" ,"METRES" }, &WellConnection::centre_depth , right_align }, { 3, {"OPEN" ,"SHUT" , }, &WellConnection::open_shut , }, { 3, {"SAT" ,"TAB" , }, &WellConnection::sat_tab , }, - { 11, {"CONNECTION" ,"FACTOR*" ,"CPM3/D/B" }, &WellConnection::conn_factor , right_align, Opm::UnitSystem::measure::transmissibility }, - { 6, {"INT" ,"DIAM" ,"METRES" }, &WellConnection::int_diam , right_align, Opm::UnitSystem::measure::length }, + { 8, {"CONNECTION" ,"FACTOR*" ,"CPM3/D/B" }, &WellConnection::conn_factor , right_align }, + { 6, {"INT" ,"DIAM" ,"METRES" }, &WellConnection::int_diam , right_align }, { 7, {"K H" ,"VALUE" ,"MD.METRE" }, &WellConnection::kh_value , right_align }, { 6, {"SKIN" ,"FACTOR" , }, &WellConnection::skin_factor , right_align }, { 10, {"CONNECTION" ,"D-FACTOR 1" ,"DAY/SM3" }, &WellConnection::dfactor , }, @@ -503,160 +474,90 @@ namespace { namespace { - struct SegmentConnection { + struct WellSegment { const Opm::Well& well; const Opm::Connection& connection; const Opm::Segment& segment; - const std::pair& perf_range; + bool branch_separator; - const std::string& well_name(const context&, std::size_t, std::size_t) const { + const std::string& well_name(const context&, std::size_t) const { return well.name(); } - std::string connection_grid(const context& ctx, std::size_t sub_report, std::size_t n) const { + std::string connection_grid(const context& ctx, std::size_t n) const { const WellConnection wc { well, connection } ; - return wc.grid_block(ctx, sub_report, n); + return wc.grid_block(ctx, n); } - std::string segment_number(const context&, std::size_t, std::size_t) const { + std::string well_name_seg(const context& ctx, std::size_t n) const { + if (n == 0) { + return well_name(ctx, n); + } else if (n == 1) { + return Opm::WellSegments::CompPressureDropToString(well.getSegments().compPressureDrop()); + } else { + return unimplemented(this, ctx, n); + } + } + + std::string segment_number(const context&, std::size_t) const { return std::to_string(segment.segmentNumber()); } - std::string branch_id(const context&, std::size_t, std::size_t) const { + std::string branch_id(const context&, std::size_t) const { return std::to_string(segment.branchNumber()); } - std::string perf_start_length(const context& ctx, std::size_t, std::size_t) const { - return format_number(ctx.unit_system, Opm::UnitSystem::measure::length, perf_range.first, 6); - } - - std::string perf_mid_length(const context& ctx, std::size_t, std::size_t) const { - return format_number(ctx.unit_system, Opm::UnitSystem::measure::length, (perf_range.first + perf_range.second) / 2.0, 6); - } - - std::string perf_end_length(const context& ctx, std::size_t, std::size_t) const { - return format_number(ctx.unit_system, Opm::UnitSystem::measure::length, perf_range.second, 6); - } - - std::string length_end_segmt(const context& ctx, std::size_t, std::size_t) const { - return format_number(ctx.unit_system, Opm::UnitSystem::measure::length, segment.totalLength(), 6); - } - - std::string connection_depth(const context& ctx, std::size_t, std::size_t) const { - return format_number(ctx.unit_system, Opm::UnitSystem::measure::length, connection.depth(), 6); - } - - std::string segment_depth(const context& ctx, std::size_t, std::size_t) const { - return format_number(ctx.unit_system, Opm::UnitSystem::measure::length, segment.depth(), 6); - } - - std::string grid_block_depth(const context& ctx, std::size_t, std::size_t) const { - return format_number(ctx.unit_system, Opm::UnitSystem::measure::length, ctx.grid.getCellDepth( connection.global_index() ), 6); - } - - - static void ws_format(std::string& string, std::size_t, std::size_t i) { - if (i == 0) { - left_align(string, 8, i); + std::string branch_number(const context& ctx, std::size_t n) const { + if (branch_separator) { + return branch_id(ctx, n); } else { - right_align(string, 8, i); + return unimplemented(this, ctx, n); } } - }; - - - - struct WellSegment { - const Opm::Well& well; - const Opm::Segment& segment; - - std::string well_name_seg(const context&, std::size_t sub_report, std::size_t n) const { - if (sub_report > 0) - return ""; - - if (n == 0) - return well.name(); - - if (n == 1) - return Opm::WellSegments::CompPressureDropToString(well.getSegments().compPressureDrop()); - - return ""; + std::string connection_depth(const context&, std::size_t) const { + return std::to_string(connection.depth()).substr(0, 6); } - std::string segment_number(const context&, std::size_t, std::size_t) const { - return std::to_string(segment.segmentNumber()); + std::string segment_depth(const context&, std::size_t) const { + return std::to_string(segment.depth()).substr(0, 6); } - std::string branch_number(const context&, std::size_t, std::size_t n) const { - if (n == 0) - return std::to_string(segment.branchNumber()); - return ""; + std::string length_end_segmt(const context&, std::size_t) const { + return std::to_string(segment.totalLength()).substr(0, 6); } - std::string main_inlet(const context&, std::size_t, std::size_t) const { - const auto& inlets { segment.inletSegments() } ; - - if (inlets.size() != 0) { - return std::to_string(segment.inletSegments().front()); - } else { - return "0"; - } + std::string total_length(const context&, std::size_t) const { + return std::to_string(segment.totalLength()).substr(0, 6); } - std::string outlet(const context&, std::size_t, std::size_t) const { - return std::to_string(segment.outletSegment()); + std::string t_v_depth(const context&, std::size_t) const { + return std::to_string(segment.depth()).substr(0, 6); } - std::string total_length(const context& ctx, std::size_t, std::size_t) const { - return format_number(ctx.unit_system, Opm::UnitSystem::measure::length, segment.totalLength(), 6); - } - - std::string length(const context& ctx, std::size_t sub_report, std::size_t line_number) const { - if (segment.segmentNumber() == 1) - return total_length(ctx, sub_report, line_number); - - const auto& segments { well.getSegments() } ; - const auto& outlet_segment { segments.getFromSegmentNumber( segment.outletSegment() ) } ; - return format_number(ctx.unit_system, Opm::UnitSystem::measure::length, segment.totalLength() - outlet_segment.totalLength(), 6); - } - - std::string t_v_depth(const context& ctx, std::size_t, std::size_t) const { - return format_number(ctx.unit_system, Opm::UnitSystem::measure::length, segment.depth(), 6); - } - - std::string depth_change(const context& ctx, std::size_t sub_report, std::size_t line_number) const { - if (segment.segmentNumber() == 1) - return t_v_depth(ctx, sub_report, line_number); - - const auto& segments { well.getSegments() } ; - const auto& outlet_segment { segments.getFromSegmentNumber( segment.outletSegment() ) } ; - return format_number(ctx.unit_system, Opm::UnitSystem::measure::length, segment.depth() - outlet_segment.depth(), 6); - } - - std::string internal_diameter(const context& ctx, std::size_t, std::size_t) const { + std::string internal_diameter(const context&, std::size_t) const { const auto number { segment.internalDiameter() } ; if (number != Opm::Segment::invalidValue()) { - return format_number(ctx.unit_system, Opm::UnitSystem::measure::length, number, 6); + return std::to_string(number).substr(0, 6); } else { return "0"; } } - std::string roughness(const context& ctx, std::size_t, std::size_t) const { + std::string roughness(const context&, std::size_t) const { const auto number { segment.roughness() } ; if (number != Opm::Segment::invalidValue()) { - return format_number(ctx.unit_system, Opm::UnitSystem::measure::length, number, 8); + return std::to_string(number).substr(0, 8); } else { return "0"; } } - std::string cross_section(const context&, std::size_t, std::size_t) const { + std::string cross_section(const context&, std::size_t) const { const auto number { segment.crossArea() } ; if (number != Opm::Segment::invalidValue()) { @@ -666,14 +567,43 @@ namespace { } } - std::string volume(const context& ctx, std::size_t, std::size_t) const { - return format_number(ctx.unit_system, Opm::UnitSystem::measure::volume, segment.volume(), 5); + std::string volume(const context&, std::size_t) const { + return std::to_string(segment.volume()).substr(0, 5); } - std::string pressure_drop_mult(const context&, std::size_t, std::size_t) const { - return std::to_string(1.0).substr(0, 5); + std::string main_inlet(const context&, std::size_t) const { + const auto& inlets { segment.inletSegments() } ; + + if (inlets.size() != 0) { + return std::to_string(segment.inletSegments().front()); + } else { + return "0"; + } + } + std::string outlet(const context&, std::size_t) const { + return std::to_string(segment.outletSegment()); + } + + + static std::vector transform(const Opm::Well& well) { + const auto &connections { well.getConnections() } ; + std::vector out; + + int branch_number { 0 } ; + + for (const auto& connection : connections) { + const auto& segment { well.getSegments().getFromSegmentNumber(connection.segment()) } ; + const auto& separator { branch_number != segment.branchNumber() } ; + + out.push_back({ well, connection, segment, separator }); + + branch_number = segment.branchNumber(); + } + + return out; + } static void ws_format(std::string& string, std::size_t, std::size_t i) { if (i == 0) { @@ -683,169 +613,78 @@ namespace { } } + static bool segment_structure_separator(const WellSegment& segment, std::size_t) { + return segment.branch_separator; + } + + std::string grid_block_depth(const context& ctx, std::size_t) const { + return std::to_string( ctx.grid.getCellDepth( connection.global_index() )).substr(0,6); + } }; - const table msw_connection_table { - { 8, {"WELL" , "NAME" , }, &SegmentConnection::well_name , left_header }, - { 9, {"CONNECTION" , "" , }, &SegmentConnection::connection_grid , }, - { 5, {"SEGMENT" , "NUMBER" , }, &SegmentConnection::segment_number , right_align }, - { 8, {"BRANCH" , "ID" , }, &SegmentConnection::branch_id , }, - { 9, {"TUB LENGTH" , "START PERFS", "METRES" }, &SegmentConnection::perf_start_length, right_align, Opm::UnitSystem::measure::length }, - { 9, {"TUB LENGTH" , "END PERFS" , "METRES" }, &SegmentConnection::perf_end_length , right_align, Opm::UnitSystem::measure::length }, - { 9, {"TUB LENGTH" , "CENTR PERFS", "METRES" }, &SegmentConnection::perf_mid_length , right_align, Opm::UnitSystem::measure::length }, - { 9, {"TUB LENGTH" , "END SEGMT" , "METRES" }, &SegmentConnection::length_end_segmt , right_align, Opm::UnitSystem::measure::length }, - { 8, {"CONNECTION" , "DEPTH" , "METRES" }, &SegmentConnection::connection_depth , right_align, Opm::UnitSystem::measure::length }, - { 8, {"SEGMENT" , "DEPTH" , "METRES" }, &SegmentConnection::segment_depth , right_align, Opm::UnitSystem::measure::length }, - { 9, {"GRID BLOCK" , "DEPTH" , "METRES" }, &SegmentConnection::grid_block_depth , right_align, Opm::UnitSystem::measure::length }, + const table msw_connection_table = { + { 8, {"WELL" , "NAME" , }, &WellSegment::well_name , left_header }, + { 9, {"CONNECTION" , "" , }, &WellSegment::connection_grid , }, + { 5, {"SEGMENT" , "NUMBER" , }, &WellSegment::segment_number , right_align }, + { 8, {"BRANCH" , "ID" , }, &WellSegment::branch_id , }, + { 9, {"TUB LENGTH" , "START PERFS", "METRES" }, unimplemented , right_align }, + { 9, {"TUB LENGTH" , "END PERFS" , "METRES" }, unimplemented , right_align }, + { 9, {"TUB LENGTH" , "CENTR PERFS", "METRES" }, unimplemented , right_align }, + { 9, {"TUB LENGTH" , "END SEGMT" , "METRES" }, &WellSegment::length_end_segmt, right_align }, + { 8, {"CONNECTION" , "DEPTH" , "METRES" }, &WellSegment::connection_depth, right_align }, + { 8, {"SEGMENT" , "DEPTH" , "METRES" }, &WellSegment::segment_depth , right_align }, + { 9, {"GRID BLOCK" , "DEPTH" , "METRES" }, &WellSegment::grid_block_depth, right_align }, }; - const table msw_well_table { - { 6, { "WELLNAME" , "AND" , "SEG TYPE" }, &WellSegment::well_name_seg , &WellSegment::ws_format }, - { 3, { "SEG" , "NO" , "" }, &WellSegment::segment_number , right_align }, - { 3, { "BRN" , "NO" , "" }, &WellSegment::branch_number , right_align }, - { 5, { "MAIN" , "INLET" , "SEGMENT" }, &WellSegment::main_inlet , right_align }, - { 5, { "" , "OUTLET" , "SEGMENT" }, &WellSegment::outlet , right_align }, - { 7, { "SEGMENT" , "LENGTH" , "METRES" }, &WellSegment::length , right_align , Opm::UnitSystem::measure::length }, - { 8, { "TOT LENGTH", "TO END" , "METRES" }, &WellSegment::total_length , right_align , Opm::UnitSystem::measure::length }, - { 8, { "DEPTH" , "CHANGE" , "METRES" }, &WellSegment::depth_change , right_align , Opm::UnitSystem::measure::length }, - { 8, { "T.V. DEPTH", "AT END" , "METRES" }, &WellSegment::t_v_depth , right_align , Opm::UnitSystem::measure::length }, - { 6, { "DIA OR F" , "SCALING" , "METRES" }, &WellSegment::internal_diameter , right_align , Opm::UnitSystem::measure::length }, - { 8, { "VFP TAB OR", "ABS ROUGHN" , "METRES" }, &WellSegment::roughness , right_align , Opm::UnitSystem::measure::length }, - { 7, { "AREA" , "X-SECTN" , "M**2" }, &WellSegment::cross_section , right_align }, - { 7, { "VOLUME" , "" , "M3" }, &WellSegment::volume , right_align , Opm::UnitSystem::measure::volume }, - { 8, { "P DROP" , "MULT" , "FACTOR 1" }, &WellSegment::pressure_drop_mult , right_align }, + const table msw_well_table = { + { 6, { "WELLNAME" , "AND" , "SEG TYPE" }, &WellSegment::well_name_seg , &WellSegment::ws_format }, + { 3, { "SEG" , "NO" , "" }, &WellSegment::segment_number , right_align }, + { 3, { "BRN" , "NO" , "" }, &WellSegment::branch_number , right_align }, + { 5, { "MAIN" , "INLET" , "SEGMENT" }, &WellSegment::main_inlet , right_align }, + { 5, { "" , "OUTLET" , "SEGMENT" }, &WellSegment::outlet , right_align }, + { 7, { "SEGMENT" , "LENGTH" , "METRES" }, unimplemented , right_align }, + { 8, { "TOT LENGTH", "TO END" , "METRES" }, &WellSegment::total_length , right_align }, + { 8, { "DEPTH" , "CHANGE" , "METRES" }, unimplemented , right_align }, + { 8, { "T.V. DEPTH", "AT END" , "METRES" }, &WellSegment::t_v_depth , right_align }, + { 6, { "DIA OR F" , "SCALING" , "METRES" }, &WellSegment::internal_diameter, right_align }, + { 8, { "VFP TAB OR", "ABS ROUGHN" , "METRES" }, &WellSegment::roughness , right_align }, + { 7, { "AREA" , "X-SECTN" , "M**2" }, &WellSegment::cross_section , right_align }, + { 7, { "VOLUME" , "" , "M3" }, &WellSegment::volume , right_align }, + { 8, { "P DROP" , "MULT" , "FACTOR" }, unimplemented , right_align }, }; } namespace { - const std::string hierarchy_title { "HIERARCHICAL DESCRIPTION OF GROUP CONTROL STRUCTURE" } ; - const std::string hierarchy_underline { underline(hierarchy_title) } ; - - constexpr char horizontal_line { '-' } ; - constexpr char vertical_line { '|' } ; - constexpr char indent_character { ' ' } ; - - std::string decorate_hierarchy_name(const std::string& name, bool first_line, bool last_child) { - if (first_line) { - return std::string(vertical_line, 1) + std::string(horizontal_line, 3) + name; - } else if (last_child) { - return std::string(indent_character, 4) + name; - } else { - return std::string(vertical_line, 1) + std::string(indent_character, 3) + name; - } - } - - std::vector lines_for_node(const Opm::GTNode& node) { - std::vector lines { node.group().name() } ; - - const std::vector& children { node.groups() } ; - - if (children.size()) { - lines.push_back(std::string(vertical_line, 1)); - - std::size_t i { 0 } ; - for (const auto& child : children) { - ++i; - std::vector child_lines { lines_for_node(child) } ; - - bool first_line { true } ; - for (const auto& line : child_lines) { - lines.push_back(decorate_hierarchy_name(line, first_line, i == children.size())); - - first_line = false; - } - } - } - - return lines; - } - - void report_group_hierarchy_data(std::ostream& os, const context& ctx, std::size_t report_step = 0) { - os << hierarchy_title << record_separator - << hierarchy_underline << record_separator - << section_separator; - - for (const auto& line : lines_for_node(ctx.sched.groupTree(report_step))) { - os << line << record_separator; - } - - os << section_separator << std::flush; +void subreport_well_connection_data(std::ostream& os, const std::vector& data, const context& ctx) { + const subreport well_connection { "WELL CONNECTION DATA", connection_table, ctx}; + well_connection.print(os, data, {{1, "The well connection D-FACTOR is not implemented in opm and the report will always show 0."}, + {2, "The saturation scaling data has not been implemented in the report and will show blank"}}); } } -namespace { - -void report_well_connection_data(std::ostream& os, const std::vector& data, const context& ctx) { - const report well_connection { "WELL CONNECTION DATA", connection_table, ctx}; - well_connection.print_header(os); - - std::size_t sub_report { 0 } ; - for (const auto& well : data) { - std::vector wrapper_data; - const auto& connections { well.getConnections() } ; - std::transform(connections.begin(), connections.end(), std::back_inserter(wrapper_data), [&well](const Opm::Connection& connection) { return WellConnection { well, connection } ; }); - - well_connection.print_data(os, wrapper_data, sub_report); - sub_report++; - } - well_connection.print_footer(os, {{1, "The well connection D-FACTOR is not implemented in opm and the report will always show 0."}, - {2, "The saturation scaling data has not been implemented in the report and will always be blank."}}); -} - -} - -void Opm::RptIO::workers::write_WELSPECS(std::ostream& os, unsigned, const Opm::Schedule& schedule, const Opm::EclipseGrid& grid, const Opm::UnitSystem& unit_system, std::size_t report_step) { - auto well_names { schedule.changed_wells(report_step) } ; +void Opm::RptIO::workers::write_WELSPECS(std::ostream& os, unsigned, const Opm::Schedule& schedule, const Opm::EclipseGrid& grid, std::size_t report_step) { + auto well_names = schedule.changed_wells(report_step); if (well_names.empty()) return; - context ctx { schedule, grid, unit_system } ; + context ctx{schedule, grid}; std::vector changed_wells; std::transform(well_names.begin(), well_names.end(), std::back_inserter(changed_wells), [&report_step, &schedule](const std::string& wname) { return schedule.getWell(wname, report_step); }); write_report_header(os, schedule, report_step); - report_well_specification_data(os, changed_wells, ctx); - report_well_connection_data(os, changed_wells, ctx); + subreport_well_specification_data(os, changed_wells, ctx); + subreport_well_connection_data(os, changed_wells, ctx); for (const auto& well : changed_wells) { if (well.isMultiSegment()) { - { - const report msw_data { "MULTI-SEGMENT WELL: SEGMENT STRUCTURE", msw_well_table, ctx}; - msw_data.print_header(os); - std::size_t sub_report { 0 } ; - const auto& segments { well.getSegments() } ; - for (const auto& branch : segments.branches()) { - std::vector wrapper_data; - const auto& branch_segments { segments.branchSegments(branch) } ; - std::transform(branch_segments.begin(), branch_segments.end(), std::back_inserter(wrapper_data), [&well](const Opm::Segment& segment) { return WellSegment { well, segment } ; }); + const subreport msw_data { "MULTI-SEGMENT WELL: SEGMENT STRUCTURE", msw_well_table, ctx, '=', &WellSegment::segment_structure_separator}; + const subreport msw_connection { "MULTI-SEGMENT WELL: CONNECTION DATA", msw_connection_table, ctx, '='}; - sub_report++; - if (sub_report == (segments.branches().size())) - msw_data.print_data(os, wrapper_data, sub_report - 1, '='); - else - msw_data.print_data(os, wrapper_data, sub_report - 1, '-'); - } - msw_data.print_footer(os, {{1, "The pressure drop multiplier is not implemented in opm/flow and will always show the default value 1.0."}}); - } - { - const report msw_connection { "MULTI-SEGMENT WELL: CONNECTION DATA", msw_connection_table, ctx}; - msw_connection.print_header(os); - { - std::vector wrapper_data; - const auto& connections { well.getConnections() } ; - const auto& segments { well.getSegments() } ; - std::transform(connections.begin(), connections.end(), std::back_inserter(wrapper_data), - [&well, &segments] (const Opm::Connection& connection) { return SegmentConnection { well, connection, segments.getFromSegmentNumber(connection.segment()), *connection.perf_range() } ; }); - msw_connection.print_data(os, wrapper_data, 0, '='); - } - msw_connection.print_footer(os, {}); - } + msw_data.print(os, { well }, {}); + msw_connection.print(os, { well }, {}); } } - - report_group_hierarchy_data(os, ctx); - report_group_levels_data(os, ctx, report_step); } diff --git a/ThirdParty/custom-opm-common/opm-common/src/opm/parser/eclipse/Deck/DeckItem.cpp b/ThirdParty/custom-opm-common/opm-common/src/opm/parser/eclipse/Deck/DeckItem.cpp index 828f906132..fc4b630620 100644 --- a/ThirdParty/custom-opm-common/opm-common/src/opm/parser/eclipse/Deck/DeckItem.cpp +++ b/ThirdParty/custom-opm-common/opm-common/src/opm/parser/eclipse/Deck/DeckItem.cpp @@ -160,7 +160,7 @@ T DeckItem::get( size_t index ) const { throw std::out_of_range("Invalid index"); if (!value::has_value(this->value_status[index])) - throw std::invalid_argument("Tried to get unitialized value from DeckItem index: " + std::to_string(index)); + throw std::invalid_argument("Invalid arguemnt"); return this->value_ref< T >()[index]; } diff --git a/ThirdParty/custom-opm-common/opm-common/src/opm/parser/eclipse/Deck/UDAValue.cpp b/ThirdParty/custom-opm-common/opm-common/src/opm/parser/eclipse/Deck/UDAValue.cpp index 7698a6f3e3..14dd0fa23e 100644 --- a/ThirdParty/custom-opm-common/opm-common/src/opm/parser/eclipse/Deck/UDAValue.cpp +++ b/ThirdParty/custom-opm-common/opm-common/src/opm/parser/eclipse/Deck/UDAValue.cpp @@ -82,9 +82,6 @@ void UDAValue::assert_numeric(const std::string& error_msg) const { throw std::invalid_argument(error_msg); } -double UDAValue::epsilonLimit() const { - return 1.E-20; -} template<> bool UDAValue::is() const { @@ -123,8 +120,6 @@ UDAValue& UDAValue::operator=(const std::string& value) { return *this; } - - template<> std::string UDAValue::get() const { if (!this->numeric_value) @@ -169,16 +164,6 @@ std::ostream& operator<<( std::ostream& stream, const UDAValue& uda_value ) { return stream; } -void UDAValue::update_value(const UDAValue& other) { - if (other.is()) { - this->double_value = other.get(); - this->numeric_value = true; - } else { - this->string_value = other.get(); - this->numeric_value = false; - } -} - } diff --git a/ThirdParty/custom-opm-common/opm-common/src/opm/parser/eclipse/EclipseState/EclipseConfig.cpp b/ThirdParty/custom-opm-common/opm-common/src/opm/parser/eclipse/EclipseState/EclipseConfig.cpp index 959bf9dd0d..97d4253973 100644 --- a/ThirdParty/custom-opm-common/opm-common/src/opm/parser/eclipse/EclipseState/EclipseConfig.cpp +++ b/ThirdParty/custom-opm-common/opm-common/src/opm/parser/eclipse/EclipseState/EclipseConfig.cpp @@ -50,17 +50,14 @@ namespace Opm { return result; } - - InitConfig& EclipseConfig::init() { - return const_cast(this->m_initConfig); - } - const InitConfig& EclipseConfig::init() const{ + + const InitConfig& EclipseConfig::init() const { return m_initConfig; } - + // [[deprecated]] --- use init() - const InitConfig& EclipseConfig::getInitConfig() const{ + const InitConfig& EclipseConfig::getInitConfig() const { return init(); } diff --git a/ThirdParty/custom-opm-common/opm-common/src/opm/parser/eclipse/EclipseState/EclipseState.cpp b/ThirdParty/custom-opm-common/opm-common/src/opm/parser/eclipse/EclipseState/EclipseState.cpp index 26b505d999..5622c05908 100644 --- a/ThirdParty/custom-opm-common/opm-common/src/opm/parser/eclipse/EclipseState/EclipseState.cpp +++ b/ThirdParty/custom-opm-common/opm-common/src/opm/parser/eclipse/EclipseState/EclipseState.cpp @@ -129,10 +129,6 @@ namespace Opm { return m_eclipseConfig.getInitConfig(); } - /// [[deprecated]] --- use cfg().init() - InitConfig& EclipseState::getInitConfig() { - return m_eclipseConfig.init(); - } /// [[deprecated]] --- use cfg() const EclipseConfig& EclipseState::getEclipseConfig() const { return cfg(); diff --git a/ThirdParty/custom-opm-common/opm-common/src/opm/parser/eclipse/EclipseState/Grid/EclipseGrid.cpp b/ThirdParty/custom-opm-common/opm-common/src/opm/parser/eclipse/EclipseState/Grid/EclipseGrid.cpp index 26e519b3aa..d1053e5f52 100644 --- a/ThirdParty/custom-opm-common/opm-common/src/opm/parser/eclipse/EclipseState/Grid/EclipseGrid.cpp +++ b/ThirdParty/custom-opm-common/opm-common/src/opm/parser/eclipse/EclipseState/Grid/EclipseGrid.cpp @@ -68,8 +68,7 @@ EclipseGrid::EclipseGrid(std::array& dims , m_minpvMode(MinpvMode::ModeEnum::Inactive), m_pinch("PINCH"), m_pinchoutMode(PinchMode::ModeEnum::TOPBOT), - m_multzMode(PinchMode::ModeEnum::TOP), - m_pinchGapMode(PinchMode::ModeEnum::GAP) + m_multzMode(PinchMode::ModeEnum::TOP) { initCornerPointGrid( coord , zcorn , actnum , mapaxes ); } @@ -85,8 +84,7 @@ EclipseGrid::EclipseGrid(const std::string& fileName ) m_minpvMode(MinpvMode::ModeEnum::Inactive), m_pinch("PINCH"), m_pinchoutMode(PinchMode::ModeEnum::TOPBOT), - m_multzMode(PinchMode::ModeEnum::TOP), - m_pinchGapMode(PinchMode::ModeEnum::GAP) + m_multzMode(PinchMode::ModeEnum::TOP) { Opm::EclIO::EclFile egridfile(fileName); @@ -101,8 +99,7 @@ EclipseGrid::EclipseGrid(size_t nx, size_t ny , size_t nz, m_minpvMode(MinpvMode::ModeEnum::Inactive), m_pinch("PINCH"), m_pinchoutMode(PinchMode::ModeEnum::TOPBOT), - m_multzMode(PinchMode::ModeEnum::TOP), - m_pinchGapMode(PinchMode::ModeEnum::GAP) + m_multzMode(PinchMode::ModeEnum::TOP) { m_coord.reserve((nx+1)*(ny+1)*6); @@ -210,8 +207,7 @@ EclipseGrid::EclipseGrid(const Deck& deck, const int * actnum) m_minpvMode(MinpvMode::ModeEnum::Inactive), m_pinch("PINCH"), m_pinchoutMode(PinchMode::ModeEnum::TOPBOT), - m_multzMode(PinchMode::ModeEnum::TOP), - m_pinchGapMode(PinchMode::ModeEnum::GAP) + m_multzMode(PinchMode::ModeEnum::TOP) { if (deck.hasKeyword("GDFILE")){ @@ -313,8 +309,6 @@ EclipseGrid::EclipseGrid(const Deck& deck, const int * actnum) auto multzString = record.getItem().get< std::string >(0); m_multzMode = PinchMode::PinchModeFromString(multzString); - auto pinchGapString = record.getItem().get< std::string >(0); - m_pinchGapMode = PinchMode::PinchModeFromString(pinchGapString); } if (deck.hasKeyword() && deck.hasKeyword()) { @@ -490,10 +484,6 @@ EclipseGrid::EclipseGrid(const Deck& deck, const int * actnum) return m_minpvMode; } - PinchMode::ModeEnum EclipseGrid::getPinchGapMode() const { - return m_pinchGapMode; - } - const std::vector& EclipseGrid::getMinpvVector( ) const { return m_minpvVector; } diff --git a/ThirdParty/custom-opm-common/opm-common/src/opm/parser/eclipse/EclipseState/Grid/FieldProps.cpp b/ThirdParty/custom-opm-common/opm-common/src/opm/parser/eclipse/EclipseState/Grid/FieldProps.cpp index 9e3665b9b3..e8fd4afd73 100644 --- a/ThirdParty/custom-opm-common/opm-common/src/opm/parser/eclipse/EclipseState/Grid/FieldProps.cpp +++ b/ThirdParty/custom-opm-common/opm-common/src/opm/parser/eclipse/EclipseState/Grid/FieldProps.cpp @@ -57,6 +57,7 @@ static const std::map unit_string = {{"PERMX", "Permea {"TRANX", "Transmissibility"}, {"TRANY", "Transmissibility"}, {"TRANZ", "Transmissibility"}, + {"NTG", "1"}, {"RS", "GasDissolutionFactor"}, {"RV", "OilDissolutionFactor"}, {"TEMPI", "Temperature"}, @@ -409,7 +410,6 @@ FieldProps::FieldProps(const Deck& deck, const Phases& phases, const EclipseGrid ny(grid.getNY()), nz(grid.getNZ()), m_phases(phases), - m_satfuncctrl(deck), m_actnum(grid.getACTNUM()), cell_volume(extract_cell_volume(grid)), cell_depth(extract_cell_depth(grid)), @@ -578,9 +578,16 @@ FieldProps::FieldData& FieldProps::init_get(const std::string& keyword) if (keyword == ParserKeywords::TEMPI::keywordName) this->init_tempi(this->double_data[keyword]); - if (keywords::PROPS::satfunc.count(keyword) == 1) + if (keywords::PROPS::satfunc.count(keyword) == 1) { this->init_satfunc(keyword, this->double_data[keyword]); + if (this->tables.hasTables("SGOF")) { + const auto shift_iter = keywords::PROPS::sogcr_shift.find(keyword); + if (shift_iter != keywords::PROPS::sogcr_shift.end()) + this->subtract_swl(this->double_data[keyword], shift_iter->second); + } + } + return this->double_data[keyword]; } @@ -757,26 +764,11 @@ void FieldProps::apply(ScalarOperation op, FieldData& data, T scalar_value, c max_value(data, scalar_value, index_list); } -double FieldProps::get_alpha(const std::string& func_name, const std::string& target_array, double raw_alpha) { - if ( !(func_name == "ADDX" || func_name == "MAXLIM" || func_name == "MINLIM") ) - return raw_alpha; - - return this->getSIValue(target_array, raw_alpha); -} - -double FieldProps::get_beta(const std::string& func_name, const std::string& target_array, double raw_beta) { - if ( func_name != "MULTA") - return raw_beta; - - return this->getSIValue(target_array, raw_beta); -} - template void FieldProps::apply(const DeckRecord& record, FieldData& target_data, const FieldData& src_data, const std::vector& index_list) { const std::string& func_name = record.getItem("OPERATION").get< std::string >(0); - const std::string& target_array = record.getItem("TARGET_ARRAY").get(0); - const double alpha = this->get_alpha(func_name, target_array, record.getItem("PARAM1").get< double >(0)); - const double beta = this->get_beta( func_name, target_array, record.getItem("PARAM2").get< double >(0)); + const double alpha = record.getItem("PARAM1").get< double >(0); + const double beta = record.getItem("PARAM2").get< double >(0); Operate::function func = Operate::get( func_name, alpha, beta ); bool check_target = (func_name == "MULTIPLY" || func_name == "POLY"); @@ -1057,16 +1049,31 @@ void FieldProps::scanEDITSection(const EDITSection& edit_section) { void FieldProps::init_satfunc(const std::string& keyword, FieldData& satfunc) { - if (this->m_rtep == nullptr) - this->m_rtep = satfunc::getRawTableEndpoints(this->tables, this->m_phases, - this->m_satfuncctrl.minimumRelpermMobilityThreshold()); - const auto& endnum = this->get("ENDNUM"); - const auto& satreg = (keyword[0] == 'I') - ? this->get("IMBNUM") - : this->get("SATNUM"); + if (keyword[0] == 'I') { + const auto& imbnum = this->get("IMBNUM"); + satfunc.default_update(satfunc::init(keyword, this->tables, this->m_phases, this->cell_depth, imbnum, endnum)); + } else { + const auto& satnum = this->get("SATNUM"); + satfunc.default_update(satfunc::init(keyword, this->tables, this->m_phases, this->cell_depth, satnum, endnum)); + } +} - satfunc.default_update(satfunc::init(keyword, this->tables, this->m_phases, *this->m_rtep, this->cell_depth, satreg, endnum)); +/** + * Special purpose operation to make various *SOGCR* data elements + * account for (scaled) connate water saturation. + * + * Must only be called if run uses SGOF, because that table is implicitly + * defined in terms of connate water saturation. Subtracts SWL only + * if the data item was defaulted (i.e., extracted from unscaled table). + */ +void FieldProps::subtract_swl(FieldProps::FieldData& sogcr, const std::string& swl_kw) +{ + const auto& swl = this->init_get(swl_kw); + for (std::size_t i = 0; i < sogcr.size(); i++) { + if (value::defaulted(sogcr.value_status[i])) + sogcr.data[i] -= swl.data[i]; + } } diff --git a/ThirdParty/custom-opm-common/opm-common/src/opm/parser/eclipse/EclipseState/Grid/FieldProps.hpp b/ThirdParty/custom-opm-common/opm-common/src/opm/parser/eclipse/EclipseState/Grid/FieldProps.hpp index 31d474c9f3..c4e9271dfb 100644 --- a/ThirdParty/custom-opm-common/opm-common/src/opm/parser/eclipse/EclipseState/Grid/FieldProps.hpp +++ b/ThirdParty/custom-opm-common/opm-common/src/opm/parser/eclipse/EclipseState/Grid/FieldProps.hpp @@ -19,7 +19,6 @@ #ifndef FIELDPROPS_HPP #define FIELDPROPS_HPP -#include #include #include #include @@ -28,7 +27,6 @@ #include #include #include -#include #include namespace Opm { @@ -346,8 +344,6 @@ private: void handle_region_operation(const DeckKeyword& keyword); void handle_COPY(const DeckKeyword& keyword, Box box, bool region); void distribute_toplayer(FieldProps::FieldData& field_data, const std::vector& deck_data, const Box& box); - double get_beta(const std::string& func_name, const std::string& target_array, double raw_beta); - double get_alpha(const std::string& func_name, const std::string& target_array, double raw_alpha); void handle_keyword(const DeckKeyword& keyword, Box& box); void handle_double_keyword(Section section, const DeckKeyword& keyword, const Box& box); @@ -355,18 +351,17 @@ private: void init_satfunc(const std::string& keyword, FieldData& satfunc); void init_porv(FieldData& porv); void init_tempi(FieldData& tempi); + void subtract_swl(FieldProps::FieldData& sogcr, const std::string& swl_kw); const UnitSystem unit_system; std::size_t nx,ny,nz; Phases m_phases; - SatFuncControls m_satfuncctrl; std::vector m_actnum; std::vector cell_volume; std::vector cell_depth; const std::string m_default_region; const EclipseGrid * grid_ptr; // A bit undecided whether to properly use the grid or not ... const TableManager& tables; - std::shared_ptr m_rtep; std::vector multregp; std::unordered_map> int_data; std::unordered_map> double_data; diff --git a/ThirdParty/custom-opm-common/opm-common/src/opm/parser/eclipse/EclipseState/Grid/PinchMode.cpp b/ThirdParty/custom-opm-common/opm-common/src/opm/parser/eclipse/EclipseState/Grid/PinchMode.cpp index 21169f624c..e3d87d8556 100644 --- a/ThirdParty/custom-opm-common/opm-common/src/opm/parser/eclipse/EclipseState/Grid/PinchMode.cpp +++ b/ThirdParty/custom-opm-common/opm-common/src/opm/parser/eclipse/EclipseState/Grid/PinchMode.cpp @@ -40,13 +40,6 @@ namespace Opm { case ModeEnum::TOP: stringValue = "TOP"; break; - - case ModeEnum::GAP: - stringValue = "GAP"; - break; - case ModeEnum::NOGAP: - stringValue = "NOGAP"; - break; } return stringValue; @@ -59,8 +52,6 @@ namespace Opm { if (s == "ALL") { mode = ModeEnum::ALL; } else if (s == "TOPBOT") { mode = ModeEnum::TOPBOT; } else if (s == "TOP") { mode = ModeEnum::TOP; } - else if (s == "GAP") { mode = ModeEnum::GAP; } - else if (s == "NOGAP") { mode = ModeEnum::NOGAP; } else { std::string msg = "Unsupported pinchout mode " + s; throw std::invalid_argument(msg); diff --git a/ThirdParty/custom-opm-common/opm-common/src/opm/parser/eclipse/EclipseState/Grid/SatfuncPropertyInitializers.cpp b/ThirdParty/custom-opm-common/opm-common/src/opm/parser/eclipse/EclipseState/Grid/SatfuncPropertyInitializers.cpp index d117c986ef..f188960b8f 100644 --- a/ThirdParty/custom-opm-common/opm-common/src/opm/parser/eclipse/EclipseState/Grid/SatfuncPropertyInitializers.cpp +++ b/ThirdParty/custom-opm-common/opm-common/src/opm/parser/eclipse/EclipseState/Grid/SatfuncPropertyInitializers.cpp @@ -14,10 +14,16 @@ OPM. If not, see . */ -#include +#include + +#include +#include +#include +#include #include #include +#include #include #include #include @@ -27,40 +33,11 @@ #include #include #include -#include #include #include - #include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include - -// Note on deriving critical saturations: All table scanners are implemented -// in terms of std::lower_bound(begin, end, tolcrit, predicate) which returns -// the first position in [begin, end) for which -// -// predicate(*iter, tolcrit) -// -// is false. Using predicate = std::greater<>{} thus determines the first -// position in the sequence for which the elements is less than or equal to -// 'tolcrit'. Similarly, a predicate equivalent to '<=' returns the first -// position for which the elements is strictly greater than 'tolcrit'. - -namespace { - - using ::Opm::satfunc::RawTableEndPoints; +namespace Opm { /* * See the "Saturation Functions" chapter in the Eclipse Technical @@ -73,26 +50,23 @@ namespace { */ enum class SatfuncFamily { none = 0, I = 1, II = 2 }; - SatfuncFamily - getSaturationFunctionFamily(const Opm::TableManager& tm, - const Opm::Phases& ph) + static SatfuncFamily + getSaturationFunctionFamily(const TableManager& tm, + const Phases& ph) { const auto wat = ph.active(::Opm::Phase::WATER); const auto oil = ph.active(::Opm::Phase::OIL); const auto gas = ph.active(::Opm::Phase::GAS); - const auto threeP = gas && oil && wat; - const auto twoP = (!gas && oil && wat) || (gas && oil && !wat) ; const auto family1 = // SGOF/SLGOF and/or SWOF (gas && (tm.hasTables("SGOF") || tm.hasTables("SLGOF"))) || (wat && tm.hasTables("SWOF")); - // note: we allow for SOF2 to be part of family1 for threeP + solvent simulations. const auto family2 = // SGFN, SOF{2,3}, SWFN (gas && tm.hasTables("SGFN")) || (oil && ((threeP && tm.hasTables("SOF3")) || - (twoP && tm.hasTables("SOF2")))) || + tm.hasTables("SOF2"))) || (wat && tm.hasTables("SWFN")); if (gas && tm.hasTables("SGOF") && tm.hasTables("SLGOF")) { @@ -115,9 +89,11 @@ namespace { return SatfuncFamily::none; } - std::vector - findMinWaterSaturation(const Opm::TableManager& tm, - const Opm::Phases& ph) + enum class limit { min, max }; + + static std::vector< double > + findMinWaterSaturation(const TableManager& tm, + const Phases& ph) { const auto num_tables = tm.getTabdims().getNumSatTables(); @@ -128,24 +104,24 @@ namespace { const auto& swfnTables = tm.getSwfnTables(); const auto famI = [&swofTables]( int i ) { - return swofTables.getTable( i ).getSwColumn().front(); + return swofTables.getTable< SwofTable >( i ).getSwColumn().front(); }; const auto famII = [&swfnTables]( int i ) { - return swfnTables.getTable( i ).getSwColumn().front(); + return swfnTables.getTable< SwfnTable >( i ).getSwColumn().front(); }; switch( getSaturationFunctionFamily( tm, ph ) ) { - case SatfuncFamily::I: return map( famI, Opm::fun::iota( num_tables ) ); - case SatfuncFamily::II: return map( famII, Opm::fun::iota( num_tables ) ); + case SatfuncFamily::I: return map( famI, fun::iota( num_tables ) ); + case SatfuncFamily::II: return map( famII, fun::iota( num_tables ) ); default: throw std::domain_error("No valid saturation keyword family specified"); } } - std::vector - findMaxWaterSaturation(const Opm::TableManager& tm, - const Opm::Phases& ph) + static std::vector< double > + findMaxWaterSaturation(const TableManager& tm, + const Phases& ph) { const auto num_tables = tm.getTabdims().getNumSatTables(); @@ -156,24 +132,24 @@ namespace { const auto& swfnTables = tm.getSwfnTables(); const auto famI = [&swofTables]( int i ) { - return swofTables.getTable( i ).getSwColumn().back(); + return swofTables.getTable< SwofTable >( i ).getSwColumn().back(); }; const auto famII = [&swfnTables]( int i ) { - return swfnTables.getTable( i ).getSwColumn().back(); + return swfnTables.getTable< SwfnTable >( i ).getSwColumn().back(); }; switch( getSaturationFunctionFamily( tm, ph ) ) { - case SatfuncFamily::I: return map( famI, Opm::fun::iota( num_tables ) ); - case SatfuncFamily::II: return map( famII, Opm::fun::iota( num_tables ) ); + case SatfuncFamily::I: return map( famI, fun::iota( num_tables ) ); + case SatfuncFamily::II: return map( famII, fun::iota( num_tables ) ); default: throw std::domain_error("No valid saturation keyword family specified"); } } - std::vector - findMinGasSaturation(const Opm::TableManager& tm, - const Opm::Phases& ph) + static std::vector< double > + findMinGasSaturation(const TableManager& tm, + const Phases& ph) { const auto num_tables = tm.getTabdims().getNumSatTables(); @@ -185,15 +161,15 @@ namespace { const auto& sgfnTables = tm.getSgfnTables(); const auto famI_sgof = [&sgofTables]( int i ) { - return sgofTables.getTable( i ).getSgColumn().front(); + return sgofTables.getTable< SgofTable >( i ).getSgColumn().front(); }; const auto famI_slgof = [&slgofTables]( int i ) { - return 1.0 - slgofTables.getTable( i ).getSlColumn().back(); + return 1.0 - slgofTables.getTable< SlgofTable >( i ).getSlColumn().back(); }; const auto famII = [&sgfnTables]( int i ) { - return sgfnTables.getTable( i ).getSgColumn().front(); + return sgfnTables.getTable< SgfnTable >( i ).getSgColumn().front(); }; switch( getSaturationFunctionFamily( tm, ph ) ) { @@ -202,21 +178,21 @@ namespace { throw std::runtime_error( "Saturation keyword family I requires either sgof or slgof non-empty" ); if( !sgofTables.empty() ) - return Opm::fun::map( famI_sgof, Opm::fun::iota( num_tables ) ); + return fun::map( famI_sgof, fun::iota( num_tables ) ); else - return Opm::fun::map( famI_slgof, Opm::fun::iota( num_tables ) ); + return fun::map( famI_slgof, fun::iota( num_tables ) ); case SatfuncFamily::II: - return Opm::fun::map( famII, Opm::fun::iota( num_tables ) ); + return fun::map( famII, fun::iota( num_tables ) ); default: throw std::domain_error("No valid saturation keyword family specified"); } } - std::vector - findMaxGasSaturation(const Opm::TableManager& tm, - const Opm::Phases& ph) + static std::vector< double > + findMaxGasSaturation(const TableManager& tm, + const Phases& ph) { const auto num_tables = tm.getTabdims().getNumSatTables(); @@ -228,15 +204,15 @@ namespace { const auto& sgfnTables = tm.getSgfnTables(); const auto famI_sgof = [&sgofTables]( int i ) { - return sgofTables.getTable( i ).getSgColumn().back(); + return sgofTables.getTable< SgofTable >( i ).getSgColumn().back(); }; const auto famI_slgof = [&slgofTables]( int i ) { - return 1.0 - slgofTables.getTable( i ).getSlColumn().front(); + return 1.0 - slgofTables.getTable< SlgofTable >( i ).getSlColumn().front(); }; const auto famII = [&sgfnTables]( int i ) { - return sgfnTables.getTable( i ).getSgColumn().back(); + return sgfnTables.getTable< SgfnTable >( i ).getSgColumn().back(); }; switch( getSaturationFunctionFamily( tm, ph ) ) { @@ -245,79 +221,51 @@ namespace { throw std::runtime_error( "Saturation keyword family I requires either sgof or slgof non-empty" ); if( !sgofTables.empty() ) - return Opm::fun::map( famI_sgof, Opm::fun::iota( num_tables ) ); + return fun::map( famI_sgof, fun::iota( num_tables ) ); else - return Opm::fun::map( famI_slgof, Opm::fun::iota( num_tables ) ); + return fun::map( famI_slgof, fun::iota( num_tables ) ); case SatfuncFamily::II: - return Opm::fun::map( famII, Opm::fun::iota( num_tables ) ); + return fun::map( famII, fun::iota( num_tables ) ); default: throw std::domain_error("No valid saturation keyword family specified"); } } - template - auto crit_sat_index(const Opm::TableColumn& col, - const double tolcrit, - Predicate&& pred) - { - using SizeT = std::remove_const_t< - std::remove_reference_t - >; + /* + * These functions have been ported from an older implementation to instead + * use std::upper_bound and more from to make code -intent- + * clearer. This also made some (maybe intentional) details easier to spot. + * A short discussion: + * + * I don't know if not finding any element larger than 0.0 in the tables + * was ever supposed to happen (or even possible), in which case the vector + * elements remained at their initial value of 0.0. This behaviour has been + * preserved, but is now explicit. The original code was also not clear if + * it was possible to look up columns at index -1 (see critical_water for + * an example), but the new version is explicit about this. Unfortuately + * I'm not familiar enough with the maths or internal structure to make + * more than a guess here, but most of this behaviour should be preserved. + * + */ - auto begin = col.begin(); - auto pos = std::lower_bound(begin, col.end(), tolcrit, - std::forward(pred)); + template< typename T > + static inline double critical_water( const T& table ) { - assert ((pos != col.end()) && - "Detected relative permeability function " - "without immobile state"); + const auto& col = table.getKrwColumn(); + const auto end = col.begin() + table.numRows(); + const auto critical = std::upper_bound( col.begin(), end, 0.0 ); + const auto index = std::distance( col.begin(), critical ); - return static_cast(std::distance(begin, pos)); + if( index == 0 || critical == end ) return 0.0; + + return table.getSwColumn()[ index - 1 ]; } - double crit_sat_increasing_KR(const Opm::TableColumn& sat, - const Opm::TableColumn& kr, - const double tolcrit) - { - // First position for which Kr(S) > tolcrit. - const auto i = crit_sat_index(kr, tolcrit, - [](const double kr1, const double kr2) - { - // kr1 <= kr2. Kr2 is 'tolcrit'. - return ! (kr2 < kr1); - }); - - return sat[i - 1]; // Last saturation for which Kr(S) <= tolcrit - } - - double crit_sat_decreasing_KR(const Opm::TableColumn& sat, - const Opm::TableColumn& kr, - const double tolcrit) - { - // First position for which Kr(S) <= tolcrit. - const auto i = crit_sat_index(kr, tolcrit, std::greater<>{}); - return sat[i]; - } - - /// Maximum water saturation for which Krw(Sw) <= tolcrit. - /// - /// Expected Table Format: - /// [Sw, Krw(Sw), ...other...] - /// - /// Krw increasing. - template - double critical_water(const T& table, const double tolcrit) - { - return crit_sat_increasing_KR(table.getSwColumn(), - table.getKrwColumn(), tolcrit); - } - - std::vector - findCriticalWater(const Opm::TableManager& tm, - const Opm::Phases& ph, - const double tolcrit) + static std::vector< double > + findCriticalWater(const TableManager& tm, + const Phases& ph) { const auto num_tables = tm.getTabdims().getNumSatTables(); @@ -327,57 +275,46 @@ namespace { const auto& swofTables = tm.getSwofTables(); const auto& swfnTables = tm.getSwfnTables(); - const auto famI = [&swofTables, tolcrit](const int i) -> double - { - return critical_water(swofTables.getTable(i), tolcrit); + const auto famI = [&swofTables]( int i ) { + return critical_water( swofTables.getTable< SwofTable >( i ) ); }; - const auto famII = [&swfnTables, tolcrit](const int i) -> double - { - return critical_water(swfnTables.getTable(i), tolcrit); + const auto famII = [&swfnTables]( int i ) { + return critical_water( swfnTables.getTable< SwfnTable >( i ) ); }; switch( getSaturationFunctionFamily( tm, ph ) ) { - case SatfuncFamily::I: return Opm::fun::map( famI, Opm::fun::iota( num_tables ) ); - case SatfuncFamily::II: return Opm::fun::map( famII, Opm::fun::iota( num_tables ) ); + case SatfuncFamily::I: return fun::map( famI, fun::iota( num_tables ) ); + case SatfuncFamily::II: return fun::map( famII, fun::iota( num_tables ) ); default: throw std::domain_error("No valid saturation keyword family specified"); } } - /// Maximum gas saturation for which Krg(Sg) <= tolcrit. - /// - /// Expected Table Format: - /// [Sg, Krg(Sg), ...other...] - /// - /// Krg increasing. - template - double critical_gas(const T& table, const double tolcrit) - { - return crit_sat_increasing_KR(table.getSgColumn(), - table.getKrgColumn(), tolcrit); + template< typename T > + static inline double critical_gas( const T& table ) { + const auto& col = table.getKrgColumn(); + const auto end = col.begin() + table.numRows(); + const auto critical = std::upper_bound( col.begin(), end, 0.0 ); + const auto index = std::distance( col.begin(), critical ); + + if( index == 0 || critical == end ) return 0.0; + + return table.getSgColumn()[ index - 1 ]; } - /// Maximum gas saturation for which Krg(Sg) <= tolcrit. - /// - /// Table Format (Sl = So + Swco): - /// [Sl, Krg(Sl), Krog(Sl), Pcgo(Sl)] - /// - /// Krg decreasing, Krog increasing, Pcog not increasing. - double critical_gas(const Opm::SlgofTable& slgofTable, - const double tolcrit) - { - const auto sl_at_crit_gas = - crit_sat_decreasing_KR(slgofTable.getSlColumn(), - slgofTable.getKrgColumn(), tolcrit); + static inline double critical_gas( const SlgofTable& slgofTable ) { + const auto& col = slgofTable.getKrgColumn(); + const auto critical = std::upper_bound( col.begin(), col.end(), 0.0 ); + const auto index = std::distance( col.begin(), critical ); - // Sg = 1 - Sl - return 1.0 - sl_at_crit_gas; + if( index == 0 || critical == col.end() ) return 0.0; + + return slgofTable.getSlColumn()[ index - 1 ]; } - std::vector - findCriticalGas(const Opm::TableManager& tm, - const Opm::Phases& ph, - const double tolcrit) + static std::vector< double > + findCriticalGas(const TableManager& tm, + const Phases& ph) { const auto num_tables = tm.getTabdims().getNumSatTables(); @@ -388,19 +325,16 @@ namespace { const auto& sgofTables = tm.getSgofTables(); const auto& slgofTables = tm.getSlgofTables(); - const auto famI_sgof = [&sgofTables, tolcrit](const int i) -> double - { - return critical_gas(sgofTables.getTable(i), tolcrit); + const auto famI_sgof = [&sgofTables]( int i ) { + return critical_gas( sgofTables.getTable< SgofTable >( i ) ); }; - const auto famI_slgof = [&slgofTables, tolcrit](const int i) -> double - { - return critical_gas(slgofTables.getTable(i), tolcrit); + const auto famI_slgof = [&slgofTables]( int i ) { + return critical_gas( slgofTables.getTable< SlgofTable >( i ) ); }; - const auto famII = [&sgfnTables, tolcrit](const int i) -> double - { - return critical_gas(sgfnTables.getTable(i), tolcrit); + const auto famII = [&sgfnTables]( int i ) { + return critical_gas( sgfnTables.getTable< SgfnTable >( i ) ); }; switch( getSaturationFunctionFamily( tm, ph ) ) { @@ -409,65 +343,54 @@ namespace { throw std::runtime_error( "Saturation keyword family I requires either sgof or slgof non-empty" ); if( !sgofTables.empty() ) - return Opm::fun::map( famI_sgof, Opm::fun::iota( num_tables ) ); + return fun::map( famI_sgof, fun::iota( num_tables ) ); else - return Opm::fun::map( famI_slgof, Opm::fun::iota( num_tables ) ); + return fun::map( famI_slgof, fun::iota( num_tables ) ); case SatfuncFamily::II: - return Opm::fun::map( famII, Opm::fun::iota( num_tables ) ); + return fun::map( famII, fun::iota( num_tables ) ); default: throw std::domain_error("No valid saturation keyword family specified"); } } - /// Maximum oil saturation for which Krow(So) <= tolcrit. - /// - /// Table Format: - /// [Sw, Krw(Sw), Krow(Sw), Pcow(Sw)] - /// - /// Krw increasing, Krow decreasing, Pcow not increasing. - double critical_oil_water(const Opm::SwofTable& swofTable, - const double tolcrit) - { - const auto sw_at_crit_oil = - crit_sat_decreasing_KR(swofTable.getSwColumn(), - swofTable.getKrowColumn(), tolcrit); + static inline double critical_oil_water( const SwofTable& swofTable ) { + const auto& col = swofTable.getKrowColumn(); - // So = 1 - Sw - return 1.0 - sw_at_crit_oil; + using reverse = std::reverse_iterator< decltype( col.begin() ) >; + auto rbegin = reverse( col.begin() + swofTable.numRows() ); + auto rend = reverse( col.begin() ); + const auto critical = std::upper_bound( rbegin, rend, 0.0 ); + const auto index = std::distance( col.begin(), critical.base() - 1 ); + + if( critical == rend ) return 0.0; + + return 1 - swofTable.getSwColumn()[ index + 1 ]; } - /// Maximum oil saturation for which Kro(So) <= tolcrit. - /// - /// Table Format: - /// [So, Kro(So)] - /// - /// Kro increasing. - double critical_oil(const Opm::Sof2Table& sof2Table, - const double tolcrit) - { - return crit_sat_increasing_KR(sof2Table.getSoColumn(), - sof2Table.getKroColumn(), tolcrit); + static inline double critical_oil( const Sof2Table& sof2Table ) { + const auto& col = sof2Table.getKroColumn(); + const auto critical = std::upper_bound( col.begin(), col.end(), 0.0 ); + const auto index = std::distance( col.begin(), critical ); + + if( index == 0 || critical == col.end() ) return 0.0; + + return sof2Table.getSoColumn()[ index - 1 ]; } - /// Maximum oil saturation for which Kro(So) <= tolcrit. - /// - /// Table Format: - /// [So, Krow(So), Krog(So)] - /// - /// Krow increasing, Krog increasing. - double critical_oil(const Opm::Sof3Table& sof3Table, - const Opm::TableColumn& col, - const double tolcrit) - { - return crit_sat_increasing_KR(sof3Table.getSoColumn(), col, tolcrit); + static inline double critical_oil( const Sof3Table& sof3Table, const TableColumn& col ) { + const auto critical = std::upper_bound( col.begin(), col.end(), 0.0 ); + const auto index = std::distance( col.begin(), critical ); + + if( index == 0 || critical == col.end() ) return 0.0; + + return sof3Table.getSoColumn()[ index - 1 ]; } - std::vector - findCriticalOilWater(const Opm::TableManager& tm, - const Opm::Phases& ph, - const double tolcrit) + static std::vector< double > + findCriticalOilWater(const TableManager& tm, + const Phases& ph) { const auto num_tables = tm.getTabdims().getNumSatTables(); @@ -479,68 +402,58 @@ namespace { const auto& sof2Tables = tm.getSof2Tables(); const auto& sof3Tables = tm.getSof3Tables(); - const auto famI = [&swofTables, tolcrit](const int i) -> double - { - return critical_oil_water(swofTables.getTable(i), tolcrit); + const auto famI = [&swofTables]( int i ) { + return critical_oil_water( swofTables.getTable< SwofTable >( i ) ); }; - const auto famII_2p = [&sof2Tables, tolcrit](const int i) -> double - { - return critical_oil(sof2Tables.getTable(i), tolcrit); + const auto famII_2p = [&sof2Tables]( int i ) { + return critical_oil( sof2Tables.getTable< Sof2Table >( i ) ); }; - const auto famII_3p = [&sof3Tables, tolcrit](const int i) -> double - { - const auto& tb = sof3Tables.getTable(i); - return critical_oil(tb, tb.getKrowColumn(), tolcrit); + const auto famII_3p = [&sof3Tables]( int i ) { + const auto& tb = sof3Tables.getTable< Sof3Table >( i ); + return critical_oil( tb, tb.getKrowColumn() ); }; switch( getSaturationFunctionFamily( tm, ph ) ) { - case SatfuncFamily::I: return Opm::fun::map( famI, Opm::fun::iota( num_tables ) ); + case SatfuncFamily::I: return fun::map( famI, fun::iota( num_tables ) ); case SatfuncFamily::II: return ph.active(::Opm::Phase::GAS) - ? Opm::fun::map( famII_3p, Opm::fun::iota( num_tables ) ) - : Opm::fun::map( famII_2p, Opm::fun::iota( num_tables ) ); + ? fun::map( famII_3p, fun::iota( num_tables ) ) + : fun::map( famII_2p, fun::iota( num_tables ) ); default: throw std::domain_error("No valid saturation keyword family specified"); } } - /// Maximum oil saturation for which Krog(So) <= tolcrit. - /// - /// Table Format: - /// [Sg, Krg(Sg), Krog(Sg), Pcgo(Sg)] - /// - /// Krg increasing, Krog decreasing, Pcgo not decreasing. - double critical_oil_gas(const Opm::SgofTable& sgofTable, - const double tolcrit) - { - const auto sg_at_crit_oil = - crit_sat_decreasing_KR(sgofTable.getSgColumn(), - sgofTable.getKrogColumn(), tolcrit); + static inline double critical_oil_gas( const SgofTable& sgofTable ) { + const auto& col = sgofTable.getKrogColumn(); - // So = 1 - Sg - return 1.0 - sg_at_crit_oil; + using reverse = std::reverse_iterator< decltype( col.begin() ) >; + auto rbegin = reverse( col.begin() + sgofTable.numRows() ); + auto rend = reverse( col.begin() ); + const auto critical = std::upper_bound( rbegin, rend, 0.0 ); + if( critical == rend ) { + return 0.0; + } + const auto index = std::distance( col.begin(), critical.base() - 1 ); + return 1.0 - sgofTable.getSgColumn()[ index + 1 ]; } - /// Maximum oil saturation for which Krog(So) <= tolcrit. - /// - /// Table Format (Sl = So + Swco): - /// [Sl, Krg(Sl), Krog(Sl), Pcgo(Sl)] - /// - /// Krg decreasing, Krog increasing, Pcgo not increasing. - double critical_oil_gas(const Opm::SlgofTable& slgofTable, - const double tolcrit) - { - return crit_sat_increasing_KR(slgofTable.getSlColumn(), - slgofTable.getKrogColumn(), tolcrit); + static inline double critical_oil_gas( const SlgofTable& sgofTable ) { + + const auto& col = sgofTable.getKrogColumn(); + const auto critical = std::upper_bound( col.begin(), col.end(), 0.0 ); + if (critical == col.end()) { + return 0.0; + } + const auto index = std::distance( col.begin(), critical - 1); + return sgofTable.getSlColumn()[ index ]; } - std::vector - findCriticalOilGas(const Opm::TableManager& tm, - const Opm::Phases& ph, - const std::vector& swco, - const double tolcrit) + static std::vector< double > + findCriticalOilGas(const TableManager& tm, + const Phases& ph) { const auto num_tables = tm.getTabdims().getNumSatTables(); @@ -553,25 +466,21 @@ namespace { const auto& sof2Tables = tm.getSof2Tables(); const auto& sof3Tables = tm.getSof3Tables(); - const auto famI_sgof = [&sgofTables, &swco, tolcrit](const int i) -> double - { - return critical_oil_gas(sgofTables.getTable(i), tolcrit) - swco[i]; + const auto famI_sgof = [&sgofTables]( int i ) { + return critical_oil_gas( sgofTables.getTable< SgofTable >( i ) ); }; - const auto famI_slgof = [&slgofTables, &swco, tolcrit](const int i) -> double - { - return critical_oil_gas(slgofTables.getTable(i), tolcrit) - swco[i]; + const auto famI_slgof = [&slgofTables]( int i ) { + return critical_oil_gas( slgofTables.getTable< SlgofTable >( i ) ); }; - const auto famII_2p = [&sof2Tables, tolcrit](const int i) -> double - { - return critical_oil(sof2Tables.getTable(i), tolcrit); + const auto famII_2p = [&sof2Tables]( int i ) { + return critical_oil( sof2Tables.getTable< Sof2Table >( i ) ); }; - const auto famII_3p = [&sof3Tables, tolcrit](const int i) -> double - { - const auto& tb = sof3Tables.getTable(i); - return critical_oil(tb, tb.getKrogColumn(), tolcrit); + const auto famII_3p = [&sof3Tables]( int i ) { + const auto& tb = sof3Tables.getTable< Sof3Table >( i ); + return critical_oil( tb, tb.getKrogColumn() ); }; switch( getSaturationFunctionFamily( tm, ph ) ) { @@ -580,23 +489,23 @@ namespace { throw std::runtime_error( "Saturation keyword family I requires either sgof or slgof non-empty" ); if( !sgofTables.empty() ) - return Opm::fun::map( famI_sgof, Opm::fun::iota( num_tables ) ); + return fun::map( famI_sgof, fun::iota( num_tables ) ); else - return Opm::fun::map( famI_slgof, Opm::fun::iota( num_tables ) ); + return fun::map( famI_slgof, fun::iota( num_tables ) ); case SatfuncFamily::II: return ph.active(::Opm::Phase::WATER) - ? Opm::fun::map( famII_3p, Opm::fun::iota( num_tables ) ) - : Opm::fun::map( famII_2p, Opm::fun::iota( num_tables ) ); + ? fun::map( famII_3p, fun::iota( num_tables ) ) + : fun::map( famII_2p, fun::iota( num_tables ) ); default: throw std::domain_error("No valid saturation keyword family specified"); } } - std::vector - findMaxKrg(const Opm::TableManager& tm, - const Opm::Phases& ph) + static std::vector< double > + findMaxKrg(const TableManager& tm, + const Phases& ph) { const auto num_tables = tm.getTabdims().getNumSatTables(); @@ -608,15 +517,15 @@ namespace { const auto& sgfnTables = tm.getSgfnTables(); const auto& famI_sgof = [&sgofTables]( int i ) { - return sgofTables.getTable( i ).getKrgColumn().back(); + return sgofTables.getTable< SgofTable >( i ).getKrgColumn().back(); }; const auto& famI_slgof = [&slgofTables]( int i ) { - return slgofTables.getTable( i ).getKrgColumn().front(); + return slgofTables.getTable< SlgofTable >( i ).getKrgColumn().front(); }; const auto& famII = [&sgfnTables]( int i ) { - return sgfnTables.getTable( i ).getKrgColumn().back(); + return sgfnTables.getTable< SgfnTable >( i ).getKrgColumn().back(); }; switch( getSaturationFunctionFamily( tm, ph ) ) { @@ -624,20 +533,19 @@ namespace { if( sgofTables.empty() && slgofTables.empty() ) throw std::runtime_error( "Saturation keyword family I requires either sgof or slgof non-empty" ); if( !sgofTables.empty() ) - return Opm::fun::map( famI_sgof, Opm::fun::iota( num_tables ) ); + return fun::map( famI_sgof, fun::iota( num_tables ) ); else - return Opm::fun::map( famI_slgof, Opm::fun::iota( num_tables ) ); + return fun::map( famI_slgof, fun::iota( num_tables ) ); case SatfuncFamily::II: - return Opm::fun::map( famII, Opm::fun::iota( num_tables ) ); + return fun::map( famII, fun::iota( num_tables ) ); default: throw std::domain_error("No valid saturation keyword family specified"); } } - std::vector - findKrgr(const Opm::TableManager& tm, - const Opm::Phases& ph, - const RawTableEndPoints& ep) + static std::vector< double > + findKrgr(const TableManager& tm, + const Phases& ph) { const auto num_tables = tm.getTabdims().getNumSatTables(); @@ -648,43 +556,16 @@ namespace { const auto& slgofTables = tm.getSlgofTables(); const auto& sgfnTables = tm.getSgfnTables(); - auto sr = std::vector(num_tables, 0.0); - if (ph.active(Opm::Phase::OIL)) { - // G/O or G/O/W system - for (auto tblID = 0*num_tables; tblID < num_tables; ++tblID) { - sr[tblID] = 1.0 - (ep.critical.oil_in_gas[tblID] + - ep.connate .water [tblID]); - } - } - else { - // G/W system - for (auto tblID = 0*num_tables; tblID < num_tables; ++tblID) { - sr[tblID] = 1.0 - ep.critical.water[tblID]; - } - } - - const auto famI_sgof = [&sgofTables, &sr](const int i) -> double - { - const auto& sgof = sgofTables.getTable(i); - const auto ix = sgof.getSgColumn().lookup(sr[i]); - - return sgof.getKrgColumn().eval(ix); + const auto& famI_sgof = [&sgofTables]( int i ) { + return sgofTables.getTable< SgofTable >( i ).getKrgColumn().front(); }; - const auto famI_slgof = [&slgofTables, &sr](const int i) -> double - { - const auto& slgof = slgofTables.getTable(i); - const auto ix = slgof.getSlColumn().lookup(1.0 - sr[i]); // Sg -> Sl - - return slgof.getKrgColumn().eval(ix); + const auto& famI_slgof = [&slgofTables]( int i ) { + return slgofTables.getTable< SlgofTable >( i ).getKrgColumn().back(); }; - const auto famII = [&sgfnTables, &sr](const int i) -> double - { - const auto& sgfn = sgfnTables.getTable(i); - const auto ix = sgfn.getSgColumn().lookup(sr[i]); - - return sgfn.getKrgColumn().eval(ix); + const auto& famII = [&sgfnTables]( int i ) { + return sgfnTables.getTable< SgfnTable >( i ).getKrgColumn().back(); }; switch( getSaturationFunctionFamily( tm, ph ) ) { @@ -692,20 +573,19 @@ namespace { if( sgofTables.empty() && slgofTables.empty() ) throw std::runtime_error( "Saturation keyword family I requires either sgof or slgof non-empty" ); if( !sgofTables.empty() ) - return Opm::fun::map( famI_sgof, Opm::fun::iota( num_tables ) ); + return fun::map( famI_sgof, fun::iota( num_tables ) ); else - return Opm::fun::map( famI_slgof, Opm::fun::iota( num_tables ) ); + return fun::map( famI_slgof, fun::iota( num_tables ) ); case SatfuncFamily::II: - return Opm::fun::map( famII, Opm::fun::iota( num_tables ) ); + return fun::map( famII, fun::iota( num_tables ) ); default: throw std::domain_error("No valid saturation keyword family specified"); } } - std::vector - findKrwr(const Opm::TableManager& tm, - const Opm::Phases& ph, - const RawTableEndPoints& ep) + static std::vector< double > + findKrwr(const TableManager& tm, + const Phases& ph) { const auto num_tables = tm.getTabdims().getNumSatTables(); @@ -715,51 +595,27 @@ namespace { const auto& swofTables = tm.getSwofTables(); const auto& swfnTables = tm.getSwfnTables(); - auto sr = std::vector(num_tables, 0.0); - if (ph.active(Opm::Phase::OIL)) { - // O/W or G/O/W system - for (auto tblID = 0*num_tables; tblID < num_tables; ++tblID) { - sr[tblID] = 1.0 - (ep.critical.oil_in_water[tblID] + - ep.connate .gas [tblID]); - } - } - else { - // G/W system - for (auto tblID = 0*num_tables; tblID < num_tables; ++tblID) { - sr[tblID] = 1.0 - ep.critical.gas[tblID]; - } - } - - const auto& famI = [&swofTables, &sr](const int i) -> double - { - const auto& swof = swofTables.getTable(i); - const auto ix = swof.getSwColumn().lookup(sr[i]); - - return swof.getKrwColumn().eval(ix); + const auto& famI = [&swofTables]( int i ) { + return swofTables.getTable< SwofTable >( i ).getKrwColumn().front(); }; - const auto& famII = [&swfnTables, &sr](const int i) -> double - { - const auto& swfn = swfnTables.getTable(i); - const auto ix = swfn.getSwColumn().lookup(sr[i]); - - return swfn.getKrwColumn().eval(ix); + const auto& famII = [&swfnTables]( int i ) { + return swfnTables.getTable< SwfnTable >( i ).getKrwColumn().front(); }; switch( getSaturationFunctionFamily( tm, ph ) ) { case SatfuncFamily::I: - return Opm::fun::map( famI, Opm::fun::iota( num_tables ) ); + return fun::map( famI, fun::iota( num_tables ) ); case SatfuncFamily::II: - return Opm::fun::map( famII, Opm::fun::iota( num_tables ) ); + return fun::map( famII, fun::iota( num_tables ) ); default: throw std::domain_error("No valid saturation keyword family specified"); } } - std::vector - findKrorw(const Opm::TableManager& tm, - const Opm::Phases& ph, - const RawTableEndPoints& ep) + static std::vector< double > + findKrorw(const TableManager& tm, + const Phases& ph) { const auto num_tables = tm.getTabdims().getNumSatTables(); @@ -771,49 +627,46 @@ namespace { const auto& sof2Tables = tm.getSof2Tables(); const auto& sof3Tables = tm.getSof3Tables(); - const auto famI = [&swofTables, &ep](const int i) -> double - { - const auto& swof = swofTables.getTable(i); - const auto sr = ep.critical.water[i] + ep.connate.gas[i]; - const auto ix = swof.getSwColumn().lookup(sr); + const auto& famI = [&swofTables]( int i ) { + const auto& swofTable = swofTables.getTable< SwofTable >( i ); + const auto& krwCol = swofTable.getKrwColumn(); + const auto crit = std::upper_bound( krwCol.begin(), krwCol.end(), 0.0 ); + const auto index = std::distance( krwCol.begin(), crit ); - return swof.getKrowColumn().eval(ix); + if( crit == krwCol.end() ) return 0.0; + + return swofTable.getKrowColumn()[ index - 1 ]; }; - const auto famII_3p = [&sof3Tables, &ep](const int i) -> double - { - const auto& sof3 = sof3Tables.getTable(i); - const auto sr = 1.0 - ep.critical.water[i] - ep.connate.gas[i]; - const auto ix = sof3.getSoColumn().lookup(sr); - - return sof3.getKrowColumn().eval(ix); + const auto crit_water = findCriticalWater( tm, ph ); + const auto min_gas = findMinGasSaturation( tm, ph ); + const auto& famII_3p = [&sof3Tables,&crit_water,&min_gas]( int i ) { + const double OilSatAtcritialWaterSat = 1.0 - crit_water[ i ] - min_gas[ i ]; + return sof3Tables.getTable< Sof3Table >( i ) + .evaluate("KROW", OilSatAtcritialWaterSat); }; - const auto famII_2p = [&sof2Tables, &ep](const int i) -> double - { - const auto& sof2 = sof2Tables.getTable(i); - const auto sr = 1.0 - ep.critical.water[i] - ep.connate.gas[i]; - const auto ix = sof2.getSoColumn().lookup(sr); - - return sof2.getKroColumn().eval(ix); + const auto famII_2p = [&sof2Tables,&crit_water,&min_gas]( int i ) { + const double OilSatAtcritialWaterSat = 1.0 - crit_water[ i ] - min_gas[ i ]; + return sof2Tables.getTable< Sof2Table >( i ) + .evaluate("KRO", OilSatAtcritialWaterSat); }; switch( getSaturationFunctionFamily( tm, ph ) ) { case SatfuncFamily::I: - return Opm::fun::map( famI, Opm::fun::iota( num_tables ) ); + return fun::map( famI, fun::iota( num_tables ) ); case SatfuncFamily::II: return ph.active(::Opm::Phase::GAS) - ? Opm::fun::map( famII_3p, Opm::fun::iota( num_tables ) ) - : Opm::fun::map( famII_2p, Opm::fun::iota( num_tables ) ); + ? fun::map( famII_3p, fun::iota( num_tables ) ) + : fun::map( famII_2p, fun::iota( num_tables ) ); default: throw std::domain_error("No valid saturation keyword family specified"); } } - std::vector - findKrorg(const Opm::TableManager& tm, - const Opm::Phases& ph, - const RawTableEndPoints& ep) + static std::vector< double > + findKrorg(const TableManager& tm, + const Phases& ph) { const auto num_tables = tm.getTabdims().getNumSatTables(); @@ -826,39 +679,44 @@ namespace { const auto& sof2Tables = tm.getSof2Tables(); const auto& sof3Tables = tm.getSof3Tables(); - const auto famI_sgof = [&sgofTables, &ep](const int i) -> double - { - const auto& sgof = sgofTables.getTable(i); - const auto ix = sgof.getSgColumn().lookup(ep.critical.gas[i]); + const auto& famI_sgof = [&sgofTables]( int i ) { + const auto& sgofTable = sgofTables.getTable< SgofTable >( i ); + const auto& krgCol = sgofTable.getKrgColumn(); + const auto crit = std::upper_bound( krgCol.begin(), krgCol.end(), 0.0 ); + const auto index = std::distance( krgCol.begin(), crit ); - // So = 1 - Sgcr - Swl - return sgof.getKrogColumn().eval(ix); + if( crit == krgCol.end() ) return 0.0; + + return sgofTable.getKrogColumn()[ index - 1 ]; }; - const auto famI_slgof = [&slgofTables, &ep](const int i) -> double - { - const auto& slgof = slgofTables.getTable(i); - const auto ix = slgof.getSlColumn().lookup(1.0 - ep.critical.gas[i]); + const auto& famI_slgof = [&slgofTables]( int i ) { + const auto& slgofTable = slgofTables.getTable< SlgofTable >( i ); + const auto& col = slgofTable.getKrgColumn(); + using reverse = std::reverse_iterator< decltype( col.begin() ) >; + auto rbegin = reverse( col.begin() + slgofTable.numRows() ); + auto rend = reverse( col.begin() ); + const auto crit = std::upper_bound( rbegin, rend, 0.0 ); + // base() points to the next element in the forward order + const auto index = std::distance( col.begin(), crit.base()); - return slgof.getKrogColumn().eval(ix); + if( crit == rend ) return 0.0; + + return slgofTable.getKrogColumn()[ index ]; }; - const auto famII_3p = [&sof3Tables, &ep](const int i) -> double - { - const auto& sof3 = sof3Tables.getTable(i); - const auto sr = 1.0 - ep.critical.gas[i] - ep.connate.water[i]; - const auto ix = sof3.getSoColumn().lookup(sr); - - return sof3.getKrogColumn().eval(ix); + const auto crit_gas = findCriticalGas( tm, ph ); + const auto min_water = findMinWaterSaturation( tm, ph ); + const auto& famII_3p = [&sof3Tables,&crit_gas,&min_water]( int i ) { + const double OilSatAtcritialGasSat = 1.0 - crit_gas[ i ] - min_water[ i ]; + return sof3Tables.getTable< Sof3Table >( i ) + .evaluate("KROG", OilSatAtcritialGasSat); }; - const auto famII_2p = [&sof2Tables, &ep](const int i) -> double - { - const auto& sof2 = sof2Tables.getTable(i); - const auto sr = 1.0 - ep.critical.gas[i] - ep.connate.water[i]; - const auto ix = sof2.getSoColumn().lookup(sr); - - return sof2.getKroColumn().eval(ix); + const auto famII_2p = [&sof2Tables,&crit_gas,&min_water]( int i ) { + const double OilSatAtcritialGasSat = 1.0 - crit_gas[ i ] - min_water[ i ]; + return sof2Tables.getTable< Sof2Table >( i ) + .evaluate("KRO", OilSatAtcritialGasSat); }; switch( getSaturationFunctionFamily( tm, ph ) ) { @@ -866,13 +724,13 @@ namespace { if( sgofTables.empty() && slgofTables.empty() ) throw std::runtime_error( "Saturation keyword family I requires either sgof or slgof non-empty" ); if( !sgofTables.empty() ) - return Opm::fun::map( famI_sgof, Opm::fun::iota( num_tables ) ); + return fun::map( famI_sgof, fun::iota( num_tables ) ); else - return Opm::fun::map( famI_slgof, Opm::fun::iota( num_tables ) ); + return fun::map( famI_slgof, fun::iota( num_tables ) ); case SatfuncFamily::II: return ph.active(::Opm::Phase::WATER) - ? Opm::fun::map( famII_3p, Opm::fun::iota( num_tables ) ) - : Opm::fun::map( famII_2p, Opm::fun::iota( num_tables ) ); + ? fun::map( famII_3p, fun::iota( num_tables ) ) + : fun::map( famII_2p, fun::iota( num_tables ) ); default: throw std::domain_error("No valid saturation keyword family specified"); } @@ -887,9 +745,9 @@ namespace { * is not taken into account which means that some twophase quantity must be * scaled. */ - std::vector - findMaxPcog(const Opm::TableManager& tm, - const Opm::Phases& ph) + static std::vector< double > + findMaxPcog(const TableManager& tm, + const Phases& ph) { const auto num_tables = tm.getTabdims().getNumSatTables(); @@ -902,15 +760,15 @@ namespace { const auto& sgfnTables = tm.getSgfnTables(); const auto& famI_sgof = [&sgofTables]( int i ) { - return sgofTables.getTable( i ).getPcogColumn().back(); + return sgofTables.getTable< SgofTable >( i ).getPcogColumn().back(); }; const auto& famI_slgof = [&slgofTables]( int i ) { - return slgofTables.getTable( i ).getPcogColumn().front(); + return slgofTables.getTable< SlgofTable >( i ).getPcogColumn().front(); }; const auto& famII = [&sgfnTables]( int i ) { - return sgfnTables.getTable( i ).getPcogColumn().back(); + return sgfnTables.getTable< SgfnTable >( i ).getPcogColumn().back(); }; switch( getSaturationFunctionFamily( tm, ph ) ) { @@ -918,19 +776,19 @@ namespace { if( sgofTables.empty() && slgofTables.empty() ) throw std::runtime_error( "Saturation keyword family I requires either sgof or slgof non-empty" ); if( !sgofTables.empty() ) - return Opm::fun::map( famI_sgof, Opm::fun::iota( num_tables ) ); + return fun::map( famI_sgof, fun::iota( num_tables ) ); else - return Opm::fun::map( famI_slgof, Opm::fun::iota( num_tables ) ); + return fun::map( famI_slgof, fun::iota( num_tables ) ); case SatfuncFamily::II: - return Opm::fun::map( famII, Opm::fun::iota( num_tables ) ); + return fun::map( famII, fun::iota( num_tables ) ); default: throw std::domain_error("No valid saturation keyword family specified"); } } - std::vector - findMaxPcow(const Opm::TableManager& tm, - const Opm::Phases& ph) + static std::vector< double > + findMaxPcow(const TableManager& tm, + const Phases& ph) { const auto num_tables = tm.getTabdims().getNumSatTables(); @@ -942,26 +800,26 @@ namespace { const auto& swfnTables = tm.getSwfnTables(); const auto& famI = [&swofTables]( int i ) { - return swofTables.getTable( i ).getPcowColumn().front(); + return swofTables.getTable< SwofTable >( i ).getPcowColumn().front(); }; const auto& famII = [&swfnTables]( int i ) { - return swfnTables.getTable( i ).getPcowColumn().front(); + return swfnTables.getTable< SwfnTable >( i ).getPcowColumn().front(); }; switch( getSaturationFunctionFamily( tm, ph ) ) { case SatfuncFamily::I: - return Opm::fun::map( famI, Opm::fun::iota( num_tables ) ); + return fun::map( famI, fun::iota( num_tables ) ); case SatfuncFamily::II: - return Opm::fun::map( famII, Opm::fun::iota( num_tables ) ); + return fun::map( famII, fun::iota( num_tables ) ); default: throw std::domain_error("No valid saturation keyword family specified"); } } - std::vector - findMaxKro(const Opm::TableManager& tm, - const Opm::Phases& ph) + static std::vector< double > + findMaxKro(const TableManager& tm, + const Phases& ph) { const auto num_tables = tm.getTabdims().getNumSatTables(); @@ -979,33 +837,33 @@ namespace { // meaning that the first entry in the KRO column--in each // saturation region--is equal in keywords SGOF and SWOF. return wat - ? other_f1.getTable( i ).getKrowColumn().front() - : other_f1.getTable( i ).getKrogColumn().front(); + ? other_f1.getTable< SwofTable >( i ).getKrowColumn().front() + : other_f1.getTable< SgofTable >( i ).getKrogColumn().front(); }; const auto& famII_2p = [&sof2Tables]( int i ) { - return sof2Tables.getTable( i ).getKroColumn().back(); + return sof2Tables.getTable< Sof2Table >( i ).getKroColumn().back(); }; const auto& famII_3p = [&sof3Tables]( int i ) { - return sof3Tables.getTable( i ).getKrowColumn().back(); + return sof3Tables.getTable< Sof3Table >( i ).getKrowColumn().back(); }; switch( getSaturationFunctionFamily( tm, ph ) ) { case SatfuncFamily::I: - return Opm::fun::map( famI, Opm::fun::iota( num_tables ) ); + return fun::map( famI, fun::iota( num_tables ) ); case SatfuncFamily::II: return ph.active(::Opm::Phase::GAS) && ph.active(::Opm::Phase::WATER) - ? Opm::fun::map( famII_3p, Opm::fun::iota( num_tables ) ) - : Opm::fun::map( famII_2p, Opm::fun::iota( num_tables ) ); + ? fun::map( famII_3p, fun::iota( num_tables ) ) + : fun::map( famII_2p, fun::iota( num_tables ) ); default: throw std::domain_error("No valid saturation keyword family specified"); } } - std::vector - findMaxKrw(const Opm::TableManager& tm, - const Opm::Phases& ph) + static std::vector< double > + findMaxKrw(const TableManager& tm, + const Phases& ph) { const auto num_tables = tm.getTabdims().getNumSatTables(); @@ -1016,30 +874,30 @@ namespace { const auto& swfnTables = tm.getSwfnTables(); const auto& famI = [&swofTables]( int i ) { - return swofTables.getTable( i ).getKrwColumn().back(); + return swofTables.getTable< SwofTable >( i ).getKrwColumn().back(); }; const auto& famII = [&swfnTables]( int i ) { - return swfnTables.getTable( i ).getKrwColumn().back(); + return swfnTables.getTable< SwfnTable >( i ).getKrwColumn().back(); }; switch( getSaturationFunctionFamily( tm, ph ) ) { case SatfuncFamily::I: - return Opm::fun::map( famI, Opm::fun::iota( num_tables ) ); + return fun::map( famI, fun::iota( num_tables ) ); case SatfuncFamily::II: - return Opm::fun::map( famII, Opm::fun::iota( num_tables ) ); + return fun::map( famII, fun::iota( num_tables ) ); default: throw std::domain_error("No valid saturation keyword family specified"); } } - double selectValue(const Opm::TableContainer& depthTables, - int tableIdx, - const std::string& columnName, - double cellDepth, - double fallbackValue, - bool useOneMinusTableValue) - { + static double selectValue( const TableContainer& depthTables, + int tableIdx, + const std::string& columnName, + double cellDepth, + double fallbackValue, + bool useOneMinusTableValue) { + if( tableIdx < 0 ) return fallbackValue; const auto& table = depthTables.getTable( tableIdx ); @@ -1057,33 +915,19 @@ namespace { return value; } - void checkSatRegions(const std::size_t cellIdx, - const int satfunc, - const int endfunc, - const std::string& satregname) - { - if ((satfunc < 0) || (endfunc < 0)) { - throw std::invalid_argument { - "Region Index Out of Bounds in Active Cell " - + std::to_string(cellIdx) + ". " + satregname + " = " - + std::to_string(satfunc + 1) + ", ENDNUM = " - + std::to_string(endfunc + 1) - }; - } - } - std::vector - satnumApply(size_t size, - const std::string& columnName, - const std::vector< double >& fallbackValues, - const Opm::TableManager& tableManager, - const std::vector& cell_depth, - const std::vector& satnum_data, - const std::vector& endnum_data, - bool useOneMinusTableValue) - { + static std::vector< double > satnumApply( size_t size, + const std::string& columnName, + const std::vector< double >& fallbackValues, + const TableManager& tableManager, + const std::vector& cell_depth, + const std::vector * actnum, + const std::vector& satnum_data, + const std::vector& endnum_data, + bool useOneMinusTableValue ) { + + std::vector< double > values( size, 0 ); - // Actually assign the defaults. If the ENPVD keyword was specified in the deck, // this currently cannot be done because we would need the Z-coordinate of the // cell and we would need to know how the simulator wants to interpolate between @@ -1095,8 +939,23 @@ namespace { int satTableIdx = satnum_data[cellIdx] - 1; int endNum = endnum_data[cellIdx] - 1; + if (actnum && ((*actnum)[cellIdx] == 0)) { + // Pick from appropriate saturation region if defined + // in this cell, else use region 1 (satTableIdx == 0). + values[cellIdx] = (satTableIdx >= 0) + ? fallbackValues[satTableIdx] : fallbackValues[0]; + continue; + } + // Active cell better have {SAT,END}NUM > 0. - checkSatRegions(cellIdx, satTableIdx, endNum, "SATNUM"); + if ((satTableIdx < 0) || (endNum < 0)) { + throw std::invalid_argument { + "Region Index Out of Bounds in Active Cell " + + std::to_string(cellIdx) + ". SATNUM = " + + std::to_string(satTableIdx + 1) + ", ENDNUM = " + + std::to_string(endNum + 1) + }; + } values[cellIdx] = selectValue(enptvdTables, (useEnptvd && endNum >= 0) ? endNum : -1, @@ -1109,16 +968,18 @@ namespace { return values; } - std::vector - imbnumApply(size_t size, - const std::string& columnName, - const std::vector< double >& fallBackValues, - const Opm::TableManager& tableManager, - const std::vector& cell_depth, - const std::vector& imbnum_data, - const std::vector& endnum_data, - bool useOneMinusTableValue ) - { + + + static std::vector< double > imbnumApply( size_t size, + const std::string& columnName, + const std::vector< double >& fallBackValues, + const TableManager& tableManager, + const std::vector& cell_depth, + const std::vector * actnum, + const std::vector& imbnum_data, + const std::vector& endnum_data, + bool useOneMinusTableValue ) { + std::vector< double > values( size, 0 ); // Actually assign the defaults. if the ENPVD keyword was specified in the deck, @@ -1127,13 +988,28 @@ namespace { // sampling points. Both of these are outside the scope of opm-parser, so we just // assign a NaN in this case... const bool useImptvd = tableManager.useImptvd(); - const Opm::TableContainer& imptvdTables = tableManager.getImptvdTables(); + const TableContainer& imptvdTables = tableManager.getImptvdTables(); for( size_t cellIdx = 0; cellIdx < values.size(); cellIdx++ ) { int imbTableIdx = imbnum_data[ cellIdx ] - 1; int endNum = endnum_data[ cellIdx ] - 1; + if (actnum && ((*actnum)[cellIdx] == 0)) { + // Pick from appropriate saturation region if defined + // in this cell, else use region 1 (imbTableIdx == 0). + values[cellIdx] = (imbTableIdx >= 0) + ? fallBackValues[imbTableIdx] : fallBackValues[0]; + continue; + } + // Active cell better have {IMB,END}NUM > 0. - checkSatRegions(cellIdx, imbTableIdx, endNum, "IMBNUM"); + if ((imbTableIdx < 0) || (endNum < 0)) { + throw std::invalid_argument { + "Region Index Out of Bounds in Active Cell " + + std::to_string(cellIdx) + ". IMBNUM = " + + std::to_string(imbTableIdx + 1) + ", ENDNUM = " + + std::to_string(endNum + 1) + }; + } values[cellIdx] = selectValue(imptvdTables, (useImptvd && endNum >= 0) ? endNum : -1, @@ -1146,507 +1022,436 @@ namespace { return values; } - std::vector - SGLEndpoint(const Opm::TableManager& tableManager, - const Opm::Phases& /* phases */, - const RawTableEndPoints& ep, - const std::vector& cell_depth, - const std::vector& satnum, - const std::vector& endnum) + +namespace satfunc { + + + std::vector< double > SGLEndpoint( const TableManager & tableManager, + const Phases& phases, + const std::vector& cell_depth, + const std::vector& satnum, + const std::vector& endnum) { - return satnumApply(cell_depth.size(), "SGCO", ep.connate.gas, - tableManager, cell_depth, satnum, endnum, false); + const auto min_gas = findMinGasSaturation( tableManager, phases ); + return satnumApply( cell_depth.size(), "SGCO", min_gas, tableManager, + cell_depth, nullptr, satnum, endnum, false ); } - std::vector - ISGLEndpoint(const Opm::TableManager& tableManager, - const Opm::Phases& /* phases */, - const RawTableEndPoints& ep, - const std::vector& cell_depth, - const std::vector& imbnum, - const std::vector& endnum) + std::vector< double > ISGLEndpoint( const TableManager & tableManager, + const Phases& phases, + const std::vector& cell_depth, + const std::vector& imbnum, + const std::vector& endnum) { - return imbnumApply(cell_depth.size(), "SGCO", ep.connate.gas, - tableManager, cell_depth, imbnum, endnum, false); + const auto min_gas = findMinGasSaturation( tableManager, phases ); + return imbnumApply( cell_depth.size(), "SGCO", min_gas, tableManager, + cell_depth, nullptr, imbnum, endnum, false ); } - std::vector - SGUEndpoint(const Opm::TableManager& tableManager, - const Opm::Phases& /* phases */, - const RawTableEndPoints& ep, - const std::vector& cell_depth, - const std::vector& satnum, - const std::vector& endnum) + std::vector< double > SGUEndpoint( const TableManager & tableManager, + const Phases& phases, + const std::vector& cell_depth, + const std::vector& satnum, + const std::vector& endnum) { - return satnumApply(cell_depth.size(), "SGMAX", ep.maximum.gas, - tableManager, cell_depth, satnum, endnum, false); + const auto max_gas = findMaxGasSaturation( tableManager, phases ); + return satnumApply( cell_depth.size(), "SGMAX", max_gas, tableManager, + cell_depth, nullptr, satnum, endnum, false ); } - std::vector - ISGUEndpoint(const Opm::TableManager& tableManager, - const Opm::Phases& /* phases */, - const RawTableEndPoints& ep, - const std::vector& cell_depth, - const std::vector& imbnum, - const std::vector& endnum) + std::vector< double > ISGUEndpoint( const TableManager & tableManager, + const Phases& phases, + const std::vector& cell_depth, + const std::vector& imbnum, + const std::vector& endnum) { - return imbnumApply(cell_depth.size(), "SGMAX", ep.maximum.gas, - tableManager, cell_depth, imbnum, endnum, false); + const auto max_gas = findMaxGasSaturation( tableManager, phases ); + return imbnumApply( cell_depth.size(), "SGMAX", max_gas, tableManager, + cell_depth, nullptr, imbnum, endnum, false ); } - std::vector - SWLEndpoint(const Opm::TableManager& tableManager, - const Opm::Phases& /* phases */, - const RawTableEndPoints& ep, - const std::vector& cell_depth, - const std::vector& satnum, - const std::vector& endnum) + std::vector< double > SWLEndpoint( const TableManager & tableManager, + const Phases& phases, + const std::vector& cell_depth, + const std::vector& satnum, + const std::vector& endnum) { - return satnumApply(cell_depth.size(), "SWCO", ep.connate.water, - tableManager, cell_depth, satnum, endnum, false); + const auto min_water = findMinWaterSaturation( tableManager, phases ); + return satnumApply( cell_depth.size(), "SWCO", min_water, tableManager, + cell_depth, nullptr, satnum, endnum, false ); } - std::vector - ISWLEndpoint(const Opm::TableManager& tableManager, - const Opm::Phases& /* phases */, - const RawTableEndPoints& ep, - const std::vector& cell_depth, - const std::vector& imbnum, - const std::vector& endnum) + std::vector< double > ISWLEndpoint( const TableManager & tableManager, + const Phases& phases, + const std::vector& cell_depth, + const std::vector& imbnum, + const std::vector& endnum) { - return imbnumApply(cell_depth.size(), "SWCO", ep.connate.water, - tableManager, cell_depth, imbnum, endnum, false); + const auto min_water = findMinWaterSaturation( tableManager, phases ); + return imbnumApply( cell_depth.size(), "SWCO", min_water, tableManager, + cell_depth, nullptr, imbnum, endnum, false ); } - std::vector - SWUEndpoint(const Opm::TableManager& tableManager, - const Opm::Phases& /* phases */, - const RawTableEndPoints& ep, - const std::vector& cell_depth, - const std::vector& satnum, - const std::vector& endnum) + std::vector< double > SWUEndpoint( const TableManager & tableManager, + const Phases& phases, + const std::vector& cell_depth, + const std::vector& satnum, + const std::vector& endnum) { - return satnumApply(cell_depth.size(), "SWMAX", ep.maximum.water, - tableManager, cell_depth, satnum, endnum, true); + const auto max_water = findMaxWaterSaturation( tableManager, phases ); + return satnumApply( cell_depth.size(), "SWMAX", max_water, tableManager, + cell_depth, nullptr, satnum, endnum, true ); } - std::vector - ISWUEndpoint(const Opm::TableManager& tableManager, - const Opm::Phases& /* phases */, - const RawTableEndPoints& ep, - const std::vector& cell_depth, - const std::vector& imbnum, - const std::vector& endnum) + std::vector< double > ISWUEndpoint( const TableManager & tableManager, + const Phases& phases, + const std::vector& cell_depth, + const std::vector& imbnum, + const std::vector& endnum) { - return imbnumApply(cell_depth.size(), "SWMAX", ep.maximum.water, - tableManager, cell_depth, imbnum, endnum, true); + const auto max_water = findMaxWaterSaturation( tableManager, phases ); + return imbnumApply( cell_depth.size(), "SWMAX", max_water, tableManager, + cell_depth, nullptr, imbnum, endnum, true); } - std::vector - SGCREndpoint(const Opm::TableManager& tableManager, - const Opm::Phases& /* phases */, - const RawTableEndPoints& ep, - const std::vector& cell_depth, - const std::vector& satnum, - const std::vector& endnum) + std::vector< double > SGCREndpoint( const TableManager & tableManager, + const Phases& phases, + const std::vector& cell_depth, + const std::vector& satnum, + const std::vector& endnum) { - return satnumApply(cell_depth.size(), "SGCRIT", ep.critical.gas, - tableManager, cell_depth, satnum, endnum, false); + const auto crit_gas = findCriticalGas( tableManager, phases ); + return satnumApply( cell_depth.size(), "SGCRIT", crit_gas, tableManager, + cell_depth, nullptr, satnum, endnum, false ); } - std::vector - ISGCREndpoint(const Opm::TableManager& tableManager, - const Opm::Phases& /* phases */, - const RawTableEndPoints& ep, - const std::vector& cell_depth, - const std::vector& imbnum, - const std::vector& endnum) + std::vector< double > ISGCREndpoint( const TableManager & tableManager, + const Phases& phases, + const std::vector& cell_depth, + const std::vector& imbnum, + const std::vector& endnum) { - return imbnumApply(cell_depth.size(), "SGCRIT", ep.critical.gas, - tableManager, cell_depth, imbnum, endnum, false); + const auto crit_gas = findCriticalGas( tableManager, phases ); + return imbnumApply( cell_depth.size(), "SGCRIT", crit_gas, tableManager, + cell_depth, nullptr, imbnum, endnum, false ); } - std::vector - SOWCREndpoint(const Opm::TableManager& tableManager, - const Opm::Phases& /* phases */, - const RawTableEndPoints& ep, - const std::vector& cell_depth, - const std::vector& satnum, - const std::vector& endnum) + std::vector< double > SOWCREndpoint( const TableManager & tableManager, + const Phases& phases, + const std::vector& cell_depth, + const std::vector& satnum, + const std::vector& endnum) { - return satnumApply(cell_depth.size(), "SOWCRIT", ep.critical.oil_in_water, - tableManager, cell_depth, satnum, endnum, false); + const auto oil_water = findCriticalOilWater( tableManager, phases ); + return satnumApply( cell_depth.size(), "SOWCRIT", oil_water, tableManager, + cell_depth, nullptr, satnum, endnum, false ); } - std::vector - ISOWCREndpoint(const Opm::TableManager& tableManager, - const Opm::Phases& /* phases */, - const RawTableEndPoints& ep, - const std::vector& cell_depth, - const std::vector& imbnum, - const std::vector& endnum) + std::vector< double > ISOWCREndpoint( const TableManager & tableManager, + const Phases& phases, + const std::vector& cell_depth, + const std::vector& imbnum, + const std::vector& endnum) { - return imbnumApply(cell_depth.size(), "SOWCRIT", ep.critical.oil_in_water, - tableManager, cell_depth, imbnum, endnum, false); + const auto oil_water = findCriticalOilWater( tableManager, phases ); + return imbnumApply( cell_depth.size(), "SOWCRIT", oil_water, tableManager, + cell_depth, nullptr, imbnum, endnum, false ); } - std::vector - SOGCREndpoint(const Opm::TableManager& tableManager, - const Opm::Phases& /* phases */, - const RawTableEndPoints& ep, - const std::vector& cell_depth, - const std::vector& satnum, - const std::vector& endnum) + std::vector< double > SOGCREndpoint( const TableManager & tableManager, + const Phases& phases, + const std::vector& cell_depth, + const std::vector& satnum, + const std::vector& endnum) { - return satnumApply(cell_depth.size(), "SOGCRIT", ep.critical.oil_in_gas, - tableManager, cell_depth, satnum, endnum, false); + const auto crit_oil_gas = findCriticalOilGas( tableManager, phases ); + return satnumApply( cell_depth.size(), "SOGCRIT", crit_oil_gas, tableManager, + cell_depth, nullptr, satnum, endnum, false ); } - std::vector - ISOGCREndpoint(const Opm::TableManager& tableManager, - const Opm::Phases& /* phases */, - const RawTableEndPoints& ep, - const std::vector& cell_depth, - const std::vector& imbnum, - const std::vector& endnum) + std::vector< double > ISOGCREndpoint( const TableManager & tableManager, + const Phases& phases, + const std::vector& cell_depth, + const std::vector& imbnum, + const std::vector& endnum) { - return imbnumApply(cell_depth.size(), "SOGCRIT", ep.critical.oil_in_gas, - tableManager, cell_depth, imbnum, endnum, false); + const auto crit_oil_gas = findCriticalOilGas( tableManager, phases ); + return imbnumApply( cell_depth.size(), "SOGCRIT", crit_oil_gas, tableManager, + cell_depth, nullptr, imbnum, endnum, false ); } - std::vector - SWCREndpoint(const Opm::TableManager& tableManager, - const Opm::Phases& /* phases */, - const RawTableEndPoints& ep, - const std::vector& cell_depth, - const std::vector& satnum, - const std::vector& endnum) + std::vector< double > SWCREndpoint( const TableManager & tableManager, + const Phases& phases, + const std::vector& cell_depth, + const std::vector& satnum, + const std::vector& endnum) { - return satnumApply(cell_depth.size(), "SWCRIT", ep.critical.water, - tableManager, cell_depth, satnum, endnum, false); + const auto crit_water = findCriticalWater( tableManager, phases ); + return satnumApply( cell_depth.size(), "SWCRIT", crit_water, tableManager, + cell_depth, nullptr, satnum, endnum, false ); } - std::vector - ISWCREndpoint(const Opm::TableManager& tableManager, - const Opm::Phases& /* phases */, - const RawTableEndPoints& ep, - const std::vector& cell_depth, - const std::vector& imbnum, - const std::vector& endnum) + std::vector< double > ISWCREndpoint( const TableManager & tableManager, + const Phases& phases, + const std::vector& cell_depth, + const std::vector& imbnum, + const std::vector& endnum) { - return imbnumApply(cell_depth.size(), "SWCRIT", ep.critical.water, - tableManager, cell_depth, imbnum, endnum, false); + const auto crit_water = findCriticalWater( tableManager, phases ); + return imbnumApply( cell_depth.size(), "SWCRIT", crit_water, tableManager, + cell_depth, nullptr, imbnum, endnum, false ); } - std::vector - PCWEndpoint(const Opm::TableManager& tableManager, - const Opm::Phases& phases, - const RawTableEndPoints& /* ep */, - const std::vector& cell_depth, - const std::vector& satnum, - const std::vector& endnum) + std::vector< double > PCWEndpoint( const TableManager & tableManager, + const Phases& phases, + const std::vector& cell_depth, + const std::vector& satnum, + const std::vector& endnum) { - const auto max_pcow = findMaxPcow(tableManager, phases); - return satnumApply(cell_depth.size(), "PCW", max_pcow, tableManager, - cell_depth, satnum, endnum, false); + const auto max_pcow = findMaxPcow( tableManager, phases ); + return satnumApply( cell_depth.size(), "PCW", max_pcow, tableManager, + cell_depth, nullptr, satnum, endnum, false ); } - std::vector - IPCWEndpoint(const Opm::TableManager& tableManager, - const Opm::Phases& phases, - const RawTableEndPoints& /* ep */, - const std::vector& cell_depth, - const std::vector& imbnum, - const std::vector& endnum) + std::vector< double > IPCWEndpoint( const TableManager & tableManager, + const Phases& phases, + const std::vector& cell_depth, + const std::vector& imbnum, + const std::vector& endnum) { - const auto max_pcow = findMaxPcow(tableManager, phases); - return imbnumApply(cell_depth.size(), "IPCW", max_pcow, tableManager, - cell_depth, imbnum, endnum, false); + const auto max_pcow = findMaxPcow( tableManager, phases ); + return imbnumApply( cell_depth.size(), "IPCW", max_pcow, tableManager, + cell_depth, nullptr, imbnum, endnum, false ); } - std::vector - PCGEndpoint(const Opm::TableManager& tableManager, - const Opm::Phases& phases, - const RawTableEndPoints& /* ep */, - const std::vector& cell_depth, - const std::vector& satnum, - const std::vector& imbnum) + std::vector< double > PCGEndpoint( const TableManager & tableManager, + const Phases& phases, + const std::vector& cell_depth, + const std::vector& satnum, + const std::vector& imbnum) { - const auto max_pcog = findMaxPcog(tableManager, phases); - return satnumApply(cell_depth.size(), "PCG", max_pcog, tableManager, - cell_depth, satnum, imbnum, false ); + const auto max_pcog = findMaxPcog( tableManager, phases ); + return satnumApply( cell_depth.size(), "PCG", max_pcog, tableManager, + cell_depth, nullptr, satnum, imbnum, false ); } - std::vector - IPCGEndpoint(const Opm::TableManager& tableManager, - const Opm::Phases& phases, - const RawTableEndPoints& /* ep */, - const std::vector& cell_depth, - const std::vector& imbnum, - const std::vector& endnum) + std::vector< double > IPCGEndpoint( const TableManager & tableManager, + const Phases& phases, + const std::vector& cell_depth, + const std::vector& imbnum, + const std::vector& endnum) { - const auto max_pcog = findMaxPcog(tableManager, phases); - return imbnumApply(cell_depth.size(), "IPCG", max_pcog, tableManager, - cell_depth, imbnum, endnum, false); + const auto max_pcog = findMaxPcog( tableManager, phases ); + return imbnumApply( cell_depth.size(), "IPCG", max_pcog, tableManager, + cell_depth, nullptr, imbnum, endnum, false ); } - std::vector - KRWEndpoint(const Opm::TableManager& tableManager, - const Opm::Phases& phases, - const RawTableEndPoints& /* ep */, - const std::vector& cell_depth, - const std::vector& satnum, - const std::vector& endnum) + std::vector< double > KRWEndpoint( const TableManager & tableManager, + const Phases& phases, + const std::vector& cell_depth, + const std::vector& satnum, + const std::vector& endnum) { - const auto max_krw = findMaxKrw(tableManager, phases); - return satnumApply(cell_depth.size(), "KRW", max_krw, tableManager, - cell_depth, satnum, endnum, false); + const auto max_krw = findMaxKrw( tableManager, phases ); + return satnumApply( cell_depth.size(), "KRW", max_krw, tableManager, + cell_depth, nullptr, satnum, endnum, false ); } - std::vector - IKRWEndpoint(const Opm::TableManager& tableManager, - const Opm::Phases& phases, - const RawTableEndPoints& /* ep */, - const std::vector& cell_depth, - const std::vector& imbnum, - const std::vector& endnum) + std::vector< double > IKRWEndpoint( const TableManager & tableManager, + const Phases& phases, + const std::vector& cell_depth, + const std::vector& imbnum, + const std::vector& endnum) { - const auto max_krw = findMaxKrw(tableManager, phases); - return imbnumApply(cell_depth.size(), "IKRW", max_krw, tableManager, - cell_depth, imbnum, endnum, false ); + const auto krwr = findKrwr( tableManager, phases ); + return imbnumApply( cell_depth.size(), "IKRW", krwr, tableManager, + cell_depth, nullptr, imbnum, endnum, false ); } - std::vector - KRWREndpoint(const Opm::TableManager& tableManager, - const Opm::Phases& phases, - const RawTableEndPoints& ep, - const std::vector& cell_depth, - const std::vector& satnum, - const std::vector& endnum) + std::vector< double > KRWREndpoint( const TableManager & tableManager, + const Phases& phases, + const std::vector& cell_depth, + const std::vector& satnum, + const std::vector& endnum) { - const auto krwr = findKrwr(tableManager, phases, ep); - return satnumApply(cell_depth.size(), "KRWR", krwr, tableManager, - cell_depth, satnum, endnum, false); + const auto krwr = findKrwr( tableManager, phases ); + return satnumApply( cell_depth.size(), "KRWR", krwr, tableManager, + cell_depth, nullptr, satnum, endnum, false ); } - std::vector - IKRWREndpoint(const Opm::TableManager& tableManager, - const Opm::Phases& phases, - const RawTableEndPoints& ep, - const std::vector& cell_depth, - const std::vector& imbnum, - const std::vector& endnum) + std::vector< double > IKRWREndpoint( const TableManager & tableManager, + const Phases& phases, + const std::vector& cell_depth, + const std::vector& imbnum, + const std::vector& endnum) { - const auto krwr = findKrwr(tableManager, phases, ep); - return imbnumApply(cell_depth.size(), "IKRWR", krwr, tableManager, - cell_depth, imbnum, endnum, false); + const auto krwr = findKrwr( tableManager, phases ); + return imbnumApply( cell_depth.size(), "IKRWR", krwr, tableManager, + cell_depth, nullptr, imbnum, endnum, false ); } - std::vector - KROEndpoint(const Opm::TableManager& tableManager, - const Opm::Phases& phases, - const RawTableEndPoints& /* ep */, - const std::vector& cell_depth, - const std::vector& satnum, - const std::vector& endnum) + std::vector< double > KROEndpoint( const TableManager & tableManager, + const Phases& phases, + const std::vector& cell_depth, + const std::vector& satnum, + const std::vector& endnum) { - const auto max_kro = findMaxKro(tableManager, phases); - return satnumApply(cell_depth.size(), "KRO", max_kro, tableManager, - cell_depth, satnum, endnum, false); + const auto max_kro = findMaxKro( tableManager, phases ); + return satnumApply( cell_depth.size(), "KRO", max_kro, tableManager, + cell_depth, nullptr, satnum, endnum, false ); } - std::vector - IKROEndpoint(const Opm::TableManager& tableManager, - const Opm::Phases& phases, - const RawTableEndPoints& /* ep */, - const std::vector& cell_depth, - const std::vector& imbnum, - const std::vector& endnum) + std::vector< double > IKROEndpoint( const TableManager & tableManager, + const Phases& phases, + const std::vector& cell_depth, + const std::vector& imbnum, + const std::vector& endnum) { - const auto max_kro = findMaxKro(tableManager, phases); - return imbnumApply(cell_depth.size(), "IKRO", max_kro, tableManager, - cell_depth, imbnum, endnum, false); + const auto max_kro = findMaxKro( tableManager,phases ); + return imbnumApply( cell_depth.size(), "IKRO", max_kro, tableManager, + cell_depth, nullptr, imbnum, endnum, false ); } - std::vector - KRORWEndpoint(const Opm::TableManager& tableManager, - const Opm::Phases& phases, - const RawTableEndPoints& ep, - const std::vector& cell_depth, - const std::vector& satnum, - const std::vector& endnum) + std::vector< double > KRORWEndpoint( const TableManager & tableManager, + const Phases& phases, + const std::vector& cell_depth, + const std::vector& satnum, + const std::vector& endnum) { - const auto krorw = findKrorw(tableManager, phases, ep); - return satnumApply(cell_depth.size(), "KRORW", krorw, tableManager, - cell_depth, satnum, endnum, false); + const auto krorw = findKrorw( tableManager, phases ); + return satnumApply( cell_depth.size(), "KRORW", krorw, tableManager, + cell_depth, nullptr, satnum, endnum, false ); } - std::vector - IKRORWEndpoint(const Opm::TableManager& tableManager, - const Opm::Phases& phases, - const RawTableEndPoints& ep, - const std::vector& cell_depth, - const std::vector& imbnum, - const std::vector& endnum) + std::vector< double > IKRORWEndpoint( const TableManager & tableManager, + const Phases& phases, + const std::vector& cell_depth, + const std::vector& imbnum, + const std::vector& endnum) { - const auto krorw = findKrorw(tableManager, phases, ep); - return imbnumApply(cell_depth.size(), "IKRORW", krorw, tableManager, - cell_depth, imbnum, endnum, false); + const auto krorw = findKrorw( tableManager, phases ); + return imbnumApply( cell_depth.size(), "IKRORW", krorw, tableManager, + cell_depth, nullptr, imbnum, endnum, false ); } - std::vector - KRORGEndpoint(const Opm::TableManager& tableManager, - const Opm::Phases& phases, - const RawTableEndPoints& ep, - const std::vector& cell_depth, - const std::vector& satnum, - const std::vector& endnum) + std::vector< double > KRORGEndpoint( const TableManager & tableManager, + const Phases& phases, + const std::vector& cell_depth, + const std::vector& satnum, + const std::vector& endnum) { - const auto krorg = findKrorg(tableManager, phases, ep); - return satnumApply(cell_depth.size(), "KRORG", krorg, tableManager, - cell_depth, satnum, endnum, false); + const auto krorg = findKrorg( tableManager, phases ); + return satnumApply( cell_depth.size(), "KRORG", krorg, tableManager, + cell_depth, nullptr, satnum, endnum, false ); } - std::vector - IKRORGEndpoint(const Opm::TableManager& tableManager, - const Opm::Phases& phases, - const RawTableEndPoints& ep, - const std::vector& cell_depth, - const std::vector& imbnum, - const std::vector& endnum) + std::vector< double > IKRORGEndpoint( const TableManager & tableManager, + const Phases& phases, + const std::vector& cell_depth, + const std::vector& imbnum, + const std::vector& endnum) { - const auto krorg = findKrorg(tableManager, phases, ep); - return imbnumApply(cell_depth.size(), "IKRORG", krorg, tableManager, - cell_depth, imbnum, endnum, false); + const auto krorg = findKrorg( tableManager, phases ); + return imbnumApply( cell_depth.size(), "IKRORG", krorg, tableManager, + cell_depth, nullptr, imbnum, endnum, false ); } - std::vector - KRGEndpoint(const Opm::TableManager& tableManager, - const Opm::Phases& phases, - const RawTableEndPoints& /* ep */, - const std::vector& cell_depth, - const std::vector& satnum, - const std::vector& endnum) + std::vector< double > KRGEndpoint( const TableManager & tableManager, + const Phases& phases, + const std::vector& cell_depth, + const std::vector& satnum, + const std::vector& endnum) { - const auto max_krg = findMaxKrg(tableManager, phases); - return satnumApply(cell_depth.size(), "KRG", max_krg, tableManager, - cell_depth, satnum, endnum, false); + const auto max_krg = findMaxKrg( tableManager, phases ); + return satnumApply( cell_depth.size(), "KRG", max_krg, tableManager, + cell_depth, nullptr, satnum, endnum, false ); } - std::vector - IKRGEndpoint(const Opm::TableManager& tableManager, - const Opm::Phases& phases, - const RawTableEndPoints& /* ep */, - const std::vector& cell_depth, - const std::vector& imbnum, - const std::vector& endnum) + std::vector< double > IKRGEndpoint( const TableManager & tableManager, + const Phases& phases, + const std::vector& cell_depth, + const std::vector& imbnum, + const std::vector& endnum) { - const auto max_krg = findMaxKrg(tableManager, phases); - return imbnumApply(cell_depth.size(), "IKRG", max_krg, tableManager, - cell_depth, imbnum, endnum, false); + const auto max_krg = findMaxKrg( tableManager, phases ); + return imbnumApply( cell_depth.size(), "IKRG", max_krg, tableManager, + cell_depth, nullptr, imbnum, endnum, false ); } - std::vector - KRGREndpoint(const Opm::TableManager& tableManager, - const Opm::Phases& phases, - const RawTableEndPoints& ep, - const std::vector& cell_depth, - const std::vector& satnum, - const std::vector& endnum) + std::vector< double > KRGREndpoint( const TableManager & tableManager, + const Phases& phases, + const std::vector& cell_depth, + const std::vector& satnum, + const std::vector& endnum) { - const auto krgr = findKrgr(tableManager, phases, ep); - return satnumApply(cell_depth.size(), "KRGR", krgr, tableManager, - cell_depth, satnum, endnum, false); + const auto krgr = findKrgr( tableManager, phases ); + return satnumApply( cell_depth.size(), "KRGR", krgr, tableManager, + cell_depth, nullptr, satnum, endnum, false ); } - std::vector - IKRGREndpoint(const Opm::TableManager& tableManager, - const Opm::Phases& phases, - const RawTableEndPoints& ep, - const std::vector& cell_depth, - const std::vector& imbnum, - const std::vector& endnum) + std::vector< double > IKRGREndpoint( const TableManager & tableManager, + const Phases& phases, + const std::vector& cell_depth, + const std::vector& imbnum, + const std::vector& endnum) { - const auto krgr = findKrgr(tableManager, phases, ep); - return imbnumApply(cell_depth.size(), "IKRGR", krgr, tableManager, - cell_depth, imbnum, endnum, false); + const auto krgr = findKrgr( tableManager, phases ); + return imbnumApply( cell_depth.size(), "IKRGR", krgr, tableManager, + cell_depth, nullptr, imbnum, endnum, false ); } -} // namespace Anonymous -std::shared_ptr -Opm::satfunc::getRawTableEndpoints(const Opm::TableManager& tm, - const Opm::Phases& phases, - const double tolcrit) -{ - auto ep = std::make_shared(); + std::vector init(const std::string& keyword, + const TableManager& tables, + const Phases& phases, + const std::vector& cell_depth, + const std::vector& num, + const std::vector& endnum) + { + using func_type = decltype(&IKRGEndpoint); - ep->connate.gas = findMinGasSaturation(tm, phases); - ep->connate.water = findMinWaterSaturation(tm, phases); +#define dirfunc(base, func) {base, func}, \ + {base "X", func}, {base "X-", func}, \ + {base "Y", func}, {base "Y-", func}, \ + {base "Z", func}, {base "Z-", func} - ep->critical.oil_in_gas = findCriticalOilGas(tm, phases, ep->connate.water, tolcrit); - ep->critical.oil_in_water = findCriticalOilWater(tm, phases, tolcrit); - ep->critical.gas = findCriticalGas(tm, phases, tolcrit); - ep->critical.water = findCriticalWater(tm, phases, tolcrit); + static const std::map func_table = { + // Drainage Imbibition + {"SGLPC", SGLEndpoint}, {"ISGLPC", ISGLEndpoint}, + {"SWLPC", SWLEndpoint}, {"ISWLPC", ISWLEndpoint}, - ep->maximum.gas = findMaxGasSaturation(tm, phases); - ep->maximum.water = findMaxWaterSaturation(tm, phases); + dirfunc("SGL", SGLEndpoint), dirfunc("ISGL", ISGLEndpoint), + dirfunc("SGU", SGUEndpoint), dirfunc("ISGU", ISGUEndpoint), + dirfunc("SWL", SWLEndpoint), dirfunc("ISWL", ISWLEndpoint), + dirfunc("SWU", SWUEndpoint), dirfunc("ISWU", ISWUEndpoint), - return ep; -} + dirfunc("SGCR", SGCREndpoint), dirfunc("ISGCR", ISGCREndpoint), + dirfunc("SOGCR", SOGCREndpoint), dirfunc("ISOGCR", ISOGCREndpoint), + dirfunc("SOWCR", SOWCREndpoint), dirfunc("ISOWCR", ISOWCREndpoint), + dirfunc("SWCR", SWCREndpoint), dirfunc("ISWCR", ISWCREndpoint), -std::vector -Opm::satfunc::init(const std::string& keyword, - const TableManager& tables, - const Phases& phases, - const RawTableEndPoints& ep, - const std::vector& cell_depth, - const std::vector& num, - const std::vector& endnum) -{ - using func_type = decltype(&IKRGEndpoint); + dirfunc("PCG", PCGEndpoint), dirfunc("IPCG", IPCGEndpoint), + dirfunc("PCW", PCWEndpoint), dirfunc("IPCW", IPCWEndpoint), -#define dirfunc(base, func) \ - {base, func}, \ - {base "X", func}, {base "X-", func}, \ - {base "Y", func}, {base "Y-", func}, \ - {base "Z", func}, {base "Z-", func} - - static const std::map func_table = { - // Drainage Imbibition - {"SGLPC", SGLEndpoint}, {"ISGLPC", ISGLEndpoint}, - {"SWLPC", SWLEndpoint}, {"ISWLPC", ISWLEndpoint}, - - dirfunc("SGL", SGLEndpoint), dirfunc("ISGL", ISGLEndpoint), - dirfunc("SGU", SGUEndpoint), dirfunc("ISGU", ISGUEndpoint), - dirfunc("SWL", SWLEndpoint), dirfunc("ISWL", ISWLEndpoint), - dirfunc("SWU", SWUEndpoint), dirfunc("ISWU", ISWUEndpoint), - - dirfunc("SGCR", SGCREndpoint), dirfunc("ISGCR", ISGCREndpoint), - dirfunc("SOGCR", SOGCREndpoint), dirfunc("ISOGCR", ISOGCREndpoint), - dirfunc("SOWCR", SOWCREndpoint), dirfunc("ISOWCR", ISOWCREndpoint), - dirfunc("SWCR", SWCREndpoint), dirfunc("ISWCR", ISWCREndpoint), - - dirfunc("PCG", PCGEndpoint), dirfunc("IPCG", IPCGEndpoint), - dirfunc("PCW", PCWEndpoint), dirfunc("IPCW", IPCWEndpoint), - - dirfunc("KRG", KRGEndpoint), dirfunc("IKRG", IKRGEndpoint), - dirfunc("KRGR", KRGREndpoint), dirfunc("IKRGR", IKRGREndpoint), - dirfunc("KRO", KROEndpoint), dirfunc("IKRO", IKROEndpoint), - dirfunc("KRORW", KRORWEndpoint), dirfunc("IKRORW", IKRORWEndpoint), - dirfunc("KRORG", KRORGEndpoint), dirfunc("IKRORG", IKRORGEndpoint), - dirfunc("KRW", KRWEndpoint), dirfunc("IKRW", IKRWEndpoint), - dirfunc("KRWR", KRWREndpoint), dirfunc("IKRWR", IKRWREndpoint), - }; + dirfunc("KRG", KRGEndpoint), dirfunc("IKRG", IKRGEndpoint), + dirfunc("KRGR", KRGREndpoint), dirfunc("IKRGR", IKRGREndpoint), + dirfunc("KRO", KROEndpoint), dirfunc("IKRO", IKROEndpoint), + dirfunc("KRORW", KRORWEndpoint), dirfunc("IKRORW", IKRORWEndpoint), + dirfunc("KRORG", KRORGEndpoint), dirfunc("IKRORG", IKRORGEndpoint), + dirfunc("KRW", KRWEndpoint), dirfunc("IKRW", IKRWEndpoint), + dirfunc("KRWR", KRWREndpoint), dirfunc("IKRWR", IKRWREndpoint), + }; #undef dirfunc - auto func = func_table.find(keyword); - if (func == func_table.end()) - throw std::invalid_argument { - "Unsupported saturation function scaling '" - + keyword + '\'' - }; + auto func = func_table.find(keyword); + if (func == func_table.end()) + throw std::invalid_argument { + "Unsupported saturation function scaling '" + + keyword + '\'' + }; - return func->second(tables, phases, ep, cell_depth, num, endnum); -} + return func->second(tables, phases, cell_depth, num, endnum); + } +} // namespace satfunc +} // namespace Opm diff --git a/ThirdParty/custom-opm-common/opm-common/src/opm/parser/eclipse/EclipseState/IOConfig/IOConfig.cpp b/ThirdParty/custom-opm-common/opm-common/src/opm/parser/eclipse/EclipseState/IOConfig/IOConfig.cpp index 7b893f8088..5384d7d069 100644 --- a/ThirdParty/custom-opm-common/opm-common/src/opm/parser/eclipse/EclipseState/IOConfig/IOConfig.cpp +++ b/ThirdParty/custom-opm-common/opm-common/src/opm/parser/eclipse/EclipseState/IOConfig/IOConfig.cpp @@ -193,11 +193,6 @@ namespace Opm { return m_UNIFOUT; } - void IOConfig::consistentFileFlags(){ - m_UNIFIN = getUNIFOUT(); - m_FMTIN = getFMTOUT(); - } - bool IOConfig::getFMTIN() const { return m_FMTIN; } diff --git a/ThirdParty/custom-opm-common/opm-common/src/opm/parser/eclipse/EclipseState/Runspec.cpp b/ThirdParty/custom-opm-common/opm-common/src/opm/parser/eclipse/EclipseState/Runspec.cpp index 9e405885ae..ec1e7a6997 100644 --- a/ThirdParty/custom-opm-common/opm-common/src/opm/parser/eclipse/EclipseState/Runspec.cpp +++ b/ThirdParty/custom-opm-common/opm-common/src/opm/parser/eclipse/EclipseState/Runspec.cpp @@ -20,13 +20,10 @@ #include #include -#include -#include #include #include #include #include -#include namespace Opm { @@ -41,7 +38,7 @@ Phase get_phase( const std::string& str ) { if( str == "POLYMW" ) return Phase::POLYMW; if( str == "FOAM" ) return Phase::FOAM; if( str == "BRINE" ) return Phase::BRINE; - + throw std::invalid_argument( "Unknown phase '" + str + "'" ); } @@ -314,22 +311,8 @@ Runspec::Runspec( const Deck& deck ) : udq_params( deck ), hystpar( deck ), m_actdims( deck ), - m_sfuncctrl( deck ), - m_nupcol( ParserKeywords::NUPCOL::NUM_ITER::defaultValue ) -{ - if (DeckSection::hasRUNSPEC(deck)) { - const RUNSPECSection runspecSection{deck}; - if (runspecSection.hasKeyword("NUPCOL")) { - using NC = ParserKeywords::NUPCOL; - const auto& item = runspecSection.getKeyword().getRecord(0).getItem(); - m_nupcol = item.get(0); - if (item.defaultApplied(0)) { - std::string msg = "OPM Flow uses 12 as default NUPCOL value"; - OpmLog::note(msg); - } - } - } -} + m_sfuncctrl( deck ) +{} Runspec Runspec::serializeObject() { @@ -383,11 +366,6 @@ const SatFuncControls& Runspec::saturationFunctionControls() const noexcept return this->m_sfuncctrl; } -int Runspec::nupcol() const noexcept -{ - return this->m_nupcol; -} - /* Returns an integer in the range 0...7 which can be used to indicate available phases in Eclipse restart and init files. diff --git a/ThirdParty/custom-opm-common/opm-common/src/opm/parser/eclipse/EclipseState/Schedule/Action/ASTNode.cpp b/ThirdParty/custom-opm-common/opm-common/src/opm/parser/eclipse/EclipseState/Schedule/Action/ASTNode.cpp index cb7869f214..169ccd334c 100644 --- a/ThirdParty/custom-opm-common/opm-common/src/opm/parser/eclipse/EclipseState/Schedule/Action/ASTNode.cpp +++ b/ThirdParty/custom-opm-common/opm-common/src/opm/parser/eclipse/EclipseState/Schedule/Action/ASTNode.cpp @@ -26,9 +26,6 @@ #include #include #include -#include - -#include namespace { std::string strip_quotes(const std::string& s) { @@ -116,27 +113,16 @@ Action::Value ASTNode::value(const Action::Context& context) const { The matching code is special case to handle one-argument cases with well patterns like 'P*'. */ - if ((this->arg_list.size() == 1) && (this->arg_list[0].find("*") != std::string::npos)) { + if ((this->arg_list.size() == 1) && (arg_list[0].find("*") != std::string::npos)) { if (this->func_type != FuncType::well) throw std::logic_error(": attempted to action-evaluate list not of type well."); - const auto& well_arg = this->arg_list[0]; Action::Value well_values; - std::vector wnames; - - if (well_arg[0] == '*' && well_arg.size() > 1) { - const auto& wlm = context.wlist_manager(); - wnames = wlm.wells(well_arg); - } else { - int fnmatch_flags = 0; - for (const auto& well : context.wells(this->func)) { - if (fnmatch(well_arg.c_str(), well.c_str(), fnmatch_flags) == 0) - wnames.push_back(well); - } + int fnmatch_flags = 0; + for (const auto& well : context.wells(this->func)) { + if (fnmatch(this->arg_list[0].c_str(), well.c_str(), fnmatch_flags) == 0) + well_values.add_well(well, context.get(this->func, well)); } - for (const auto& wname : wnames) - well_values.add_well(wname, context.get(this->func, wname)); - return well_values; } else { std::string arg_key = this->arg_list[0]; diff --git a/ThirdParty/custom-opm-common/opm-common/src/opm/parser/eclipse/EclipseState/Schedule/Action/ActionContext.cpp b/ThirdParty/custom-opm-common/opm-common/src/opm/parser/eclipse/EclipseState/Schedule/Action/ActionContext.cpp index c73e73b3b6..d6c55c1535 100644 --- a/ThirdParty/custom-opm-common/opm-common/src/opm/parser/eclipse/EclipseState/Schedule/Action/ActionContext.cpp +++ b/ThirdParty/custom-opm-common/opm-common/src/opm/parser/eclipse/EclipseState/Schedule/Action/ActionContext.cpp @@ -19,6 +19,7 @@ #include #include +#include namespace Opm { namespace Action { @@ -27,9 +28,8 @@ namespace Action { this->values[func + ":" + arg] = value; } - Context::Context(const SummaryState& summary_state_arg, const WListManager& wlm_) : - summary_state(summary_state_arg), - wlm(wlm_) + Context::Context(const SummaryState& summary_state_arg) : + summary_state(summary_state_arg) { for (const auto& pair : TimeMap::eclipseMonthIndices()) this->add(pair.first, pair.second); @@ -57,9 +57,5 @@ namespace Action { return this->summary_state.wells(key); } - - const WListManager& Context::wlist_manager() const { - return this->wlm; - } } } diff --git a/ThirdParty/custom-opm-common/opm-common/src/opm/parser/eclipse/EclipseState/Schedule/Action/ActionResult.cpp b/ThirdParty/custom-opm-common/opm-common/src/opm/parser/eclipse/EclipseState/Schedule/Action/ActionResult.cpp index 8c1f90b305..0ba760609c 100644 --- a/ThirdParty/custom-opm-common/opm-common/src/opm/parser/eclipse/EclipseState/Schedule/Action/ActionResult.cpp +++ b/ThirdParty/custom-opm-common/opm-common/src/opm/parser/eclipse/EclipseState/Schedule/Action/ActionResult.cpp @@ -19,7 +19,6 @@ #include #include -#include #include @@ -45,7 +44,7 @@ Result::Result(bool result_arg, const WellSet& wells) : Result::Result(const Result& src) { this->result = src.result; - if (src.matching_wells) + if (src.matching_wells) this->matching_wells.reset( new WellSet(*src.matching_wells) ); } @@ -54,9 +53,6 @@ Result::operator bool() const { } std::vector Result::wells() const { - if (!this->result) - throw std::logic_error("Programming error: trying to check wells in ActionResult which is false"); - if (this->matching_wells) return this->matching_wells->wells(); else @@ -87,11 +83,11 @@ Result& Result::operator&=(const Result& other) { return *this; } -Result& Result::operator=(const Result& src) +Result& Result::operator=(const Result& src) { this->result = src.result; if (src.matching_wells) this->matching_wells.reset( new WellSet(*src.matching_wells) ); - + return *this; } @@ -106,9 +102,6 @@ void Result::add_well(const std::string& well) { } bool Result::has_well(const std::string& well) const { - if (!this->result) - throw std::logic_error("Programming error: trying to check wells in ActionResult which is false"); - if (!this->matching_wells) return false; diff --git a/ThirdParty/custom-opm-common/opm-common/src/opm/parser/eclipse/EclipseState/Schedule/Action/ActionValue.cpp b/ThirdParty/custom-opm-common/opm-common/src/opm/parser/eclipse/EclipseState/Schedule/Action/ActionValue.cpp index 661f2b6236..e7f59a103d 100644 --- a/ThirdParty/custom-opm-common/opm-common/src/opm/parser/eclipse/EclipseState/Schedule/Action/ActionValue.cpp +++ b/ThirdParty/custom-opm-common/opm-common/src/opm/parser/eclipse/EclipseState/Schedule/Action/ActionValue.cpp @@ -2,6 +2,7 @@ #include + namespace Opm { namespace Action { diff --git a/ThirdParty/custom-opm-common/opm-common/src/opm/parser/eclipse/EclipseState/Schedule/Action/ActionX.cpp b/ThirdParty/custom-opm-common/opm-common/src/opm/parser/eclipse/EclipseState/Schedule/Action/ActionX.cpp index 1d059bfb77..cff045a762 100644 --- a/ThirdParty/custom-opm-common/opm-common/src/opm/parser/eclipse/EclipseState/Schedule/Action/ActionX.cpp +++ b/ThirdParty/custom-opm-common/opm-common/src/opm/parser/eclipse/EclipseState/Schedule/Action/ActionX.cpp @@ -24,7 +24,6 @@ #include #include #include -#include #include "ActionParser.hpp" @@ -97,6 +96,8 @@ ActionX ActionX::serializeObject() cond.cmp = Condition::Comparator::GREATER_EQUAL; cond.cmp_string = "test3"; result.m_conditions = {cond}; + result.run_count = 4; + result.last_run = 5; return result; } @@ -108,27 +109,35 @@ void ActionX::addKeyword(const DeckKeyword& kw) { -Action::Result ActionX::eval(const Action::Context& context) const { - return this->condition.eval(context); +Action::Result ActionX::eval(std::time_t sim_time, const Action::Context& context) const { + if (!this->ready(sim_time)) + return Action::Result(false); + + auto result = this->condition.eval(context); + + if (result) { + this->run_count += 1; + this->last_run = sim_time; + } + + return result; } -bool ActionX::ready(const State& state, std::time_t sim_time) const { - auto run_count = state.run_count(*this); - if (run_count >= this->max_run()) +bool ActionX::ready(std::time_t sim_time) const { + if (this->run_count >= this->max_run()) return false; if (sim_time < this->start_time()) return false; - if (run_count == 0) + if (this->run_count == 0) return true; if (this->min_wait() <= 0) return true; - auto last_run = state.run_time(*this); - return std::difftime(sim_time, last_run) > this->min_wait(); + return std::difftime(sim_time, this->last_run) > this->min_wait(); } @@ -174,24 +183,17 @@ const std::vector& ActionX::conditions() const { return this->m_conditions; } -std::size_t ActionX::id() const { - return this->m_id; -} - -void ActionX::update_id(std::size_t id) { - this->m_id = id; -} - bool ActionX::operator==(const ActionX& data) const { return this->name() == data.name() && this->max_run() == data.max_run() && this->min_wait() == data.min_wait() && this->start_time() == data.start_time() && - this->id() == data.id() && this->keywords == data.keywords && this->condition == data.condition && - this->conditions() == data.conditions(); + this->conditions() == data.conditions() && + this->run_count == data.run_count && + this->last_run == data.last_run; } } diff --git a/ThirdParty/custom-opm-common/opm-common/src/opm/parser/eclipse/EclipseState/Schedule/Action/Actions.cpp b/ThirdParty/custom-opm-common/opm-common/src/opm/parser/eclipse/EclipseState/Schedule/Action/Actions.cpp index 15903a9878..b8dba9e521 100644 --- a/ThirdParty/custom-opm-common/opm-common/src/opm/parser/eclipse/EclipseState/Schedule/Action/Actions.cpp +++ b/ThirdParty/custom-opm-common/opm-common/src/opm/parser/eclipse/EclipseState/Schedule/Action/Actions.cpp @@ -55,11 +55,8 @@ void Actions::add(const ActionX& action) { auto iter = std::find_if( this->actions.begin(), this->actions.end(), [&action](const ActionX& arg) { return arg.name() == action.name(); }); if (iter == this->actions.end()) this->actions.push_back(action); - else { - auto id = iter->id() + 1; + else *iter = action; - iter->update_id(id); - } } void Actions::add(const PyAction& pyaction) { @@ -92,9 +89,9 @@ int Actions::max_input_lines() const { } -bool Actions::ready(const State& state, std::time_t sim_time) const { +bool Actions::ready(std::time_t sim_time) const { for (const auto& action : this->actions) { - if (action.ready(state, sim_time)) + if (action.ready(sim_time)) return true; } return false; @@ -111,10 +108,10 @@ std::vector Actions::pending_python() const { } -std::vector Actions::pending(const State& state, std::time_t sim_time) const { +std::vector Actions::pending(std::time_t sim_time) const { std::vector action_vector; for (const auto& action : this->actions) { - if (action.ready(state, sim_time)) + if (action.ready(sim_time)) action_vector.push_back( &action ); } return action_vector; diff --git a/ThirdParty/custom-opm-common/opm-common/src/opm/parser/eclipse/EclipseState/Schedule/Action/State.cpp b/ThirdParty/custom-opm-common/opm-common/src/opm/parser/eclipse/EclipseState/Schedule/Action/State.cpp deleted file mode 100644 index 862950c4f2..0000000000 --- a/ThirdParty/custom-opm-common/opm-common/src/opm/parser/eclipse/EclipseState/Schedule/Action/State.cpp +++ /dev/null @@ -1,61 +0,0 @@ -/* - Copyright 2020 Equinor ASA. - - This file is part of the Open Porous Media project (OPM). - - OPM is free software: you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - OPM is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with OPM. If not, see . -*/ - -#include -#include -#include - -#include -#include - -namespace Opm { -namespace Action { - -namespace { -std::pair action_id(const ActionX& action) { - return std::make_pair(action.name(), action.id()); -} -} - - -std::size_t State::run_count(const ActionX& action) const { - auto count_iter = this->run_state.find(action_id(action)); - if (count_iter == this->run_state.end()) - return 0; - - return count_iter->second.run_count; -} - -std::time_t State::run_time(const ActionX& action) const { - auto state = this->run_state.at(action_id(action)); - return state.last_run; -} - - -void State::add_run(const ActionX& action, std::time_t run_time) { - const auto& id = action_id(action); - auto count_iter = this->run_state.find(id); - if (count_iter == this->run_state.end()) - this->run_state.insert( std::make_pair(id, run_time) ); - else - count_iter->second.add_run(run_time); -} - -} -} diff --git a/ThirdParty/custom-opm-common/opm-common/src/opm/parser/eclipse/EclipseState/Schedule/GasLiftOpt.cpp b/ThirdParty/custom-opm-common/opm-common/src/opm/parser/eclipse/EclipseState/Schedule/GasLiftOpt.cpp deleted file mode 100644 index 96bb4420ee..0000000000 --- a/ThirdParty/custom-opm-common/opm-common/src/opm/parser/eclipse/EclipseState/Schedule/GasLiftOpt.cpp +++ /dev/null @@ -1,108 +0,0 @@ -/* - Copyright 2020 Equinor ASA. - - This file is part of the Open Porous Media project (OPM). - - OPM is free software: you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - OPM is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with OPM. If not, see . -*/ - -#include - -#include - -namespace Opm { - -bool GasLiftOpt::active() const { - return (this->m_increment > 0); -} - -void GasLiftOpt::gaslift_increment(double gaslift_increment) { - this->m_increment = gaslift_increment; -} - -double GasLiftOpt::gaslift_increment() const { - return this->m_increment; -} - -void GasLiftOpt::min_eco_gradient(double min_eco_gradient) { - this->m_min_eco_gradient = min_eco_gradient; -} - -double GasLiftOpt::min_eco_gradient() const { - return this->m_min_eco_gradient; -} - -void GasLiftOpt::min_wait(double min_wait) { - this->m_min_wait = min_wait; -} - -void GasLiftOpt::all_newton(double all_newton) { - this->m_all_newton = all_newton; -} - -const GasLiftOpt::Group& GasLiftOpt::group(const std::string& gname) const { - const auto iter = this->m_groups.find(gname); - if (iter == this->m_groups.end()) - throw std::out_of_range("No such group: " + gname + " configured for gas lift optimization"); - - return iter->second; -} - - -void GasLiftOpt::add_group(const Group& group) { - auto iter = this->m_groups.find(group.name()); - if (iter == this->m_groups.end()) - this->m_groups.insert( std::make_pair(group.name(), group) ); - else - iter->second = group; -} - - -void GasLiftOpt::add_well(const Well& well) { - auto iter = this->m_wells.find(well.name()); - if (iter == this->m_wells.end()) - this->m_wells.insert( std::make_pair(well.name(), well) ); - else - iter->second = well; -} - - -const GasLiftOpt::Well& GasLiftOpt::well(const std::string& wname) const { - const auto iter = this->m_wells.find(wname); - if (iter == this->m_wells.end()) - throw std::out_of_range("No such well: " + wname + " configured for gas lift optimization"); - - return iter->second; -} - -GasLiftOpt GasLiftOpt::serializeObject() { - GasLiftOpt glo; - glo.m_increment = 0; - glo.m_min_eco_gradient = 100; - glo.m_min_wait = 1; - glo.m_all_newton = true; - return glo; -} - -bool GasLiftOpt::operator==(const GasLiftOpt& other) const { - return this->m_increment == other.m_increment && - this->m_min_eco_gradient == other.m_min_eco_gradient && - this->m_min_wait == other.m_min_wait && - this->m_all_newton == other.m_all_newton && - this->m_groups == other.m_groups && - this->m_wells == other.m_wells; -} - -} - diff --git a/ThirdParty/custom-opm-common/opm-common/src/opm/parser/eclipse/EclipseState/Schedule/Group/GPMaint.cpp b/ThirdParty/custom-opm-common/opm-common/src/opm/parser/eclipse/EclipseState/Schedule/Group/GPMaint.cpp deleted file mode 100644 index 2c73c0a328..0000000000 --- a/ThirdParty/custom-opm-common/opm-common/src/opm/parser/eclipse/EclipseState/Schedule/Group/GPMaint.cpp +++ /dev/null @@ -1,101 +0,0 @@ -/* - Copyright 2020 Equinor ASA. - - This file is part of the Open Porous Media project (OPM). - - OPM is free software: you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - OPM is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with OPM. If not, see . -*/ - -#include -#include -#include - -namespace Opm { - -GPMaint::GPMaint(const DeckRecord& record) -{ - using GP = ParserKeywords::GPMAINT; - this->m_flow_target = FlowTargetFromString( record.getItem().get(0) ); - this->m_region_number = record.getItem().get(0); - this->m_region_name = record.getItem().get(0); - this->m_pressure_target = record.getItem().getSIDouble(0); - this->m_prop_constant = record.getItem().getSIDouble(0); - this->m_time_constant = record.getItem().getSIDouble(0); -} - - -GPMaint::FlowTarget GPMaint::flow_target() const { - return this->m_flow_target; -} - -double GPMaint::pressure_target() const { - return this->m_pressure_target; -} - -double GPMaint::prop_constant() const { - return this->m_prop_constant; -} - -double GPMaint::time_constant() const { - return this->m_time_constant; -} - -GPMaint GPMaint::serializeObject() { - GPMaint gpm; - gpm.m_flow_target = FlowTarget::SURF_GINJ; - gpm.m_region_name = "FIPNUM"; - gpm.m_region_number = 26; - return gpm; -} - -std::optional> GPMaint::region() const { - if (this->m_region_number == 0) - return {}; - - return std::make_pair(this->m_region_name, this->m_region_number); -} - -GPMaint::FlowTarget GPMaint::FlowTargetFromString(const std::string& string_value) { - if (string_value == "PROD") - return GPMaint::FlowTarget::RESV_PROD; - - if (string_value == "OINJ") - return GPMaint::FlowTarget::RESV_OINJ; - - if (string_value == "WINJ") - return GPMaint::FlowTarget::RESV_WINJ; - - if (string_value == "GINJ") - return GPMaint::FlowTarget::RESV_GINJ; - - if (string_value == "OINS") - return GPMaint::FlowTarget::SURF_OINJ; - - if (string_value == "WINS") - return GPMaint::FlowTarget::SURF_WINJ; - - if (string_value == "GINS") - return GPMaint::FlowTarget::SURF_GINJ; - - throw std::invalid_argument("The string: " + string_value + " could not be converted to a valid FLOW target"); -} - - -bool GPMaint::operator==(const GPMaint& other) const { - return this->m_flow_target == other.m_flow_target && - this->m_region_name == other.m_region_name && - this->m_region_number == other.m_region_number; -} - -} diff --git a/ThirdParty/custom-opm-common/opm-common/src/opm/parser/eclipse/EclipseState/Schedule/Group/GTNode.cpp b/ThirdParty/custom-opm-common/opm-common/src/opm/parser/eclipse/EclipseState/Schedule/Group/GTNode.cpp index ebfc0c650f..6e8d53f84d 100644 --- a/ThirdParty/custom-opm-common/opm-common/src/opm/parser/eclipse/EclipseState/Schedule/Group/GTNode.cpp +++ b/ThirdParty/custom-opm-common/opm-common/src/opm/parser/eclipse/EclipseState/Schedule/Group/GTNode.cpp @@ -60,19 +60,5 @@ const std::vector& GTNode::groups() const { return this->m_child_groups; } -std::vector GTNode::all_nodes() const { - std::vector nodes { this }; - - for (const auto& child_group : m_child_groups) { - const auto child_nodes { child_group.all_nodes() } ; - nodes.insert(nodes.end(), child_nodes.begin(), child_nodes.end()); - } - - return nodes; -} - -std::size_t GTNode::level() const { - return this->m_level; -} } diff --git a/ThirdParty/custom-opm-common/opm-common/src/opm/parser/eclipse/EclipseState/Schedule/Group/Group.cpp b/ThirdParty/custom-opm-common/opm-common/src/opm/parser/eclipse/EclipseState/Schedule/Group/Group.cpp index 204c788c5e..3ac662c666 100644 --- a/ThirdParty/custom-opm-common/opm-common/src/opm/parser/eclipse/EclipseState/Schedule/Group/Group.cpp +++ b/ThirdParty/custom-opm-common/opm-common/src/opm/parser/eclipse/EclipseState/Schedule/Group/Group.cpp @@ -20,8 +20,6 @@ #include #include -#include -#include #include "../eval_uda.hpp" @@ -41,8 +39,7 @@ Group::Group(const std::string& name, std::size_t insert_index_arg, std::size_t group_type(GroupType::NONE), gefac(1), transfer_gefac(true), - vfp_table(0), - production_properties(name) + vfp_table(0) { // All groups are initially created as children of the "FIELD" group. if (name != "FIELD") @@ -207,8 +204,7 @@ bool Group::GroupInjectionProperties::operator!=(const GroupInjectionProperties& Group::GroupProductionProperties Group::GroupProductionProperties::serializeObject() { - Group::GroupProductionProperties result("Group123"); - result.name = "Group123"; + Group::GroupProductionProperties result; result.cmode = ProductionCMode::PRBL; result.exceed_action = ExceedAction::WELL; result.oil_target = UDAValue(1.0); @@ -226,7 +222,6 @@ Group::GroupProductionProperties Group::GroupProductionProperties::serializeObje bool Group::GroupProductionProperties::operator==(const GroupProductionProperties& other) const { return - this->name == other.name && this->cmode == other.cmode && this->exceed_action == other.exceed_action && this->oil_target == other.oil_target && @@ -240,18 +235,6 @@ bool Group::GroupProductionProperties::operator==(const GroupProductionPropertie this->resv_target == other.resv_target; } -bool Group::GroupProductionProperties::updateUDQActive(const UDQConfig& udq_config, UDQActive& active) const { - int update_count = 0; - - update_count += active.update(udq_config, this->oil_target, this->name, UDAControl::GCONPROD_OIL_TARGET); - update_count += active.update(udq_config, this->water_target, this->name, UDAControl::GCONPROD_WATER_TARGET); - update_count += active.update(udq_config, this->gas_target, this->name, UDAControl::GCONPROD_GAS_TARGET); - update_count += active.update(udq_config, this->liquid_target, this->name, UDAControl::GCONPROD_LIQUID_TARGET); - - return (update_count > 0); -} - - bool Group::productionGroupControlAvailable() const { if (this->m_name == "FIELD") return false; @@ -273,8 +256,6 @@ bool Group::GroupProductionProperties::operator!=(const GroupProductionPropertie return !(*this == other); } - - bool Group::hasType(GroupType gtype) const { return ((this->group_type & gtype) == gtype); } @@ -439,9 +420,6 @@ Group::ProductionControls Group::productionControls(const SummaryState& st) cons return pc; } - - - Group::InjectionControls Group::injectionControls(Phase phase, const SummaryState& st) const { Group::InjectionControls ic; const auto& inj = this->injection_properties.at(phase); @@ -486,18 +464,6 @@ bool Group::has_control(Group::ProductionCMode control) const { return detail::has_control(production_properties.production_controls, control); } -const std::optional& Group::gpmaint() const { - return this->m_gpmaint; -} - -void Group::set_gpmaint(GPMaint gpmaint) { - this->m_gpmaint = std::move(gpmaint); -} - -void Group::set_gpmaint() { - this->m_gpmaint = std::nullopt; -} - const std::string Group::ExceedAction2String( ExceedAction enumValue ) { switch(enumValue) { @@ -677,7 +643,6 @@ bool Group::operator==(const Group& data) const this->m_groups == data.m_groups && this->m_topup_phase == data.m_topup_phase && this->injection_properties == data.injection_properties && - this->m_gpmaint == data.m_gpmaint && this->productionProperties() == data.productionProperties(); } diff --git a/ThirdParty/custom-opm-common/opm-common/src/opm/parser/eclipse/EclipseState/Schedule/MSW/AICD.cpp b/ThirdParty/custom-opm-common/opm-common/src/opm/parser/eclipse/EclipseState/Schedule/MSW/AICD.cpp deleted file mode 100644 index 50bda2080f..0000000000 --- a/ThirdParty/custom-opm-common/opm-common/src/opm/parser/eclipse/EclipseState/Schedule/MSW/AICD.cpp +++ /dev/null @@ -1,69 +0,0 @@ -/* - Copyright 2020 Equinor ASA. - - This file is part of the Open Porous Media project (OPM). - - OPM is free software: you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - OPM is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with OPM. If not, see . -*/ - - -#include -#include - -namespace Opm { - -AutoICD AutoICD::serializeObject() { - AutoICD aicd; - return aicd; -} - -using AICD = ParserKeywords::WSEGAICD; -AutoICD::AutoICD(const DeckRecord& record) : - SICD(record), - m_flow_rate_exponent(record.getItem().get(0)), - m_visc_exponent(record.getItem().get(0)), - m_oil_density_exponent(record.getItem().get(0)), - m_water_density_exponent(record.getItem().get(0)), - m_gas_density_exponent(record.getItem().get(0)), - m_oil_viscosity_exponent(record.getItem().get(0)), - m_water_viscosity_exponent(record.getItem().get(0)), - m_gas_viscosity_exponent(record.getItem().get(0)) -{ - -} - - -// the function will return a map -// [ -// "WELL1" : [, ...] -// .... -std::map > > -AutoICD::fromWSEGAICD(const DeckKeyword& wsegaicd) { - return SICD::fromWSEG(wsegaicd); -} - - -bool AutoICD::operator==(const AutoICD& other) const { - return SICD::operator==(other) && - this->m_flow_rate_exponent == other.m_flow_rate_exponent && - this->m_visc_exponent == other.m_visc_exponent && - this->m_oil_density_exponent == other.m_oil_density_exponent && - this->m_water_density_exponent == other.m_water_density_exponent && - this->m_gas_density_exponent == other.m_gas_density_exponent && - this->m_oil_viscosity_exponent == other.m_oil_viscosity_exponent && - this->m_water_viscosity_exponent == other.m_water_viscosity_exponent && - this->m_gas_viscosity_exponent == other.m_gas_viscosity_exponent; -} - -} diff --git a/ThirdParty/custom-opm-common/opm-common/src/opm/parser/eclipse/EclipseState/Schedule/MSW/Compsegs.cpp b/ThirdParty/custom-opm-common/opm-common/src/opm/parser/eclipse/EclipseState/Schedule/MSW/Compsegs.cpp index 7599cbca7a..a6878abcd9 100644 --- a/ThirdParty/custom-opm-common/opm-common/src/opm/parser/eclipse/EclipseState/Schedule/MSW/Compsegs.cpp +++ b/ThirdParty/custom-opm-common/opm-common/src/opm/parser/eclipse/EclipseState/Schedule/MSW/Compsegs.cpp @@ -26,45 +26,16 @@ #include #include #include -#include #include #include -#include -#include #include "Compsegs.hpp" namespace Opm { -namespace Compsegs { - -struct Record { - int m_i; - int m_j; - int m_k; - // the branch number on the main stem is always 1. - // lateral branches should be numbered bigger than 1. - // a suboridnate branch must have a higher branch number than parent branch. - int m_branch_number; - double m_distance_start; - double m_distance_end; - Connection::Direction m_dir; - - double center_depth; - // we do not handle thermal length for the moment - // double m_thermal_length; - int segment_number; - std::size_t m_seqIndex; - - Record(int i_in, int j_in, int k_in, int branch_number_in, double distance_start_in, double distance_end_in, - Connection::Direction dir_in, double center_depth_in, int segment_number_in, std::size_t seqIndex_in); - - void calculateCenterDepthWithSegments(const WellSegments& segment_set); -}; - - Record::Record(int i_in, int j_in, int k_in, int branch_number_in, double distance_start_in, double distance_end_in, + Compsegs::Compsegs(int i_in, int j_in, int k_in, int branch_number_in, double distance_start_in, double distance_end_in, Connection::Direction dir_in, double center_depth_in, int segment_number_in, size_t seqIndex_in) : m_i(i_in), m_j(j_in), @@ -79,112 +50,10 @@ struct Record { { } + std::vector< Compsegs > Compsegs::compsegsFromCOMPSEGSKeyword(const DeckKeyword& compsegsKeyword, const EclipseGrid& grid, + const ParseContext& parseContext, ErrorGuard& errors) { - void Record::calculateCenterDepthWithSegments(const WellSegments& segment_set) { - - // the depth and distance of the segment to the well head - const Segment& segment = segment_set.getFromSegmentNumber(segment_number); - const double segment_depth = segment.depth(); - const double segment_distance = segment.totalLength(); - - // for top segment, no interpolation is needed - if (segment_number == 1) { - center_depth = segment_depth; - return; - } - - // for other cases, interpolation between two segments is needed. - // looking for the other segment needed for interpolation - // by default, it uses the outlet segment to do the interpolation - int interpolation_segment_number = segment.outletSegment(); - - const double center_distance = (m_distance_start + m_distance_end) / 2.0; - // if the perforation is further than the segment and the segment has inlet segments in the same branch - // we use the inlet segment to do the interpolation - if (center_distance > segment_distance) { - for (const int inlet : segment.inletSegments()) { - const int inlet_index = segment_set.segmentNumberToIndex(inlet); - if (segment_set[inlet_index].branchNumber() == m_branch_number) { - interpolation_segment_number = inlet; - break; - } - } - } - - if (interpolation_segment_number == 0) { - throw std::runtime_error("Failed in finding a segment to do the interpolation with segment " - + std::to_string(segment_number)); - } - - // performing the interpolation - const Segment& interpolation_segment = segment_set.getFromSegmentNumber(interpolation_segment_number); - const double interpolation_detph = interpolation_segment.depth(); - const double interpolation_distance = interpolation_segment.totalLength(); - - const double depth_change_segment = segment_depth - interpolation_detph; - const double segment_length = segment_distance - interpolation_distance; - - if (segment_length == 0.) { - throw std::runtime_error("Zero segment length is botained when doing interpolation between segment " - + std::to_string(segment_number) + " and segment " + std::to_string(interpolation_segment_number) ); - } - - center_depth = segment_depth + (center_distance - segment_distance) / segment_length * depth_change_segment; - } - - - -namespace { - - void processCOMPSEGS__(std::vector< Record >& compsegs, const WellSegments& segment_set) { - // for the current cases we have at the moment, the distance information is specified explicitly, - // while the depth information is defaulted though, which need to be obtained from the related segment - for( auto& compseg : compsegs ) { - - // need to determine the related segment number first - if (compseg.segment_number != 0) continue; - - const double center_distance = (compseg.m_distance_start + compseg.m_distance_end) / 2.0; - const int branch_number = compseg.m_branch_number; - - int segment_number = 0; - double min_distance_difference = 1.e100; // begin with a big value - for (std::size_t i_segment = 0; i_segment < segment_set.size(); ++i_segment) { - const Segment& current_segment = segment_set[i_segment]; - if( branch_number != current_segment.branchNumber() ) continue; - - const double distance = current_segment.totalLength(); - const double distance_difference = std::abs(center_distance - distance); - if (distance_difference < min_distance_difference) { - min_distance_difference = distance_difference; - segment_number = current_segment.segmentNumber(); - } - } - - if (segment_number == 0) { - std::ostringstream sstr; - sstr << "The connection specified in COMPSEGS with index of " << compseg.m_i + 1 << " " - << compseg.m_j + 1 << " " << compseg.m_k + 1 << " failed in finding a related segment"; - throw std::runtime_error(sstr.str()); - } - - compseg.segment_number = segment_number; - - // when depth is default or zero, we obtain the depth of the connection based on the information - // of the related segments - if (compseg.center_depth == 0.) { - compseg.calculateCenterDepthWithSegments(segment_set); - } - } - } - - std::vector< Record > compsegsFromCOMPSEGSKeyword(const DeckKeyword& compsegsKeyword, - const WellSegments& segments, - const EclipseGrid& grid, - const ParseContext& parseContext, - ErrorGuard& errors) { - - std::vector< Record > compsegs; + std::vector< Compsegs > compsegs; // The first record in the keyword only contains the well name // looping from the second record in the keyword @@ -286,7 +155,7 @@ namespace { segment_number, seqIndex); } - } else { // a range is defined. genrate a range of Record + } else { // a range is defined. genrate a range of Compsegs std::ostringstream sstr; sstr << "COMPSEGS entries can only be input for single connection, not supporting COMPSEGS entries specified with a range yet.\n" << " well " << well_name << " " << I + 1 << " " << J + 1 << " " << K + 1 << " in keyword COMPSEGS\n"; @@ -294,104 +163,128 @@ namespace { } } - processCOMPSEGS__(compsegs, segments); return compsegs; } -} + void Compsegs::processCOMPSEGS(std::vector< Compsegs >& compsegs, const WellSegments& segment_set) { + // for the current cases we have at the moment, the distance information is specified explicitly, + // while the depth information is defaulted though, which need to be obtained from the related segment + for( auto& compseg : compsegs ) { - std::pair - processCOMPSEGS(const DeckKeyword& compsegs, - const WellConnections& input_connections, - const WellSegments& input_segments, - const EclipseGrid& grid, - const ParseContext& parseContext, - ErrorGuard& errors) - { - const auto& compsegs_vector = Compsegs::compsegsFromCOMPSEGSKeyword( compsegs, input_segments, grid, parseContext, errors); - WellSegments new_segment_set = input_segments; - WellConnections new_connection_set = input_connections; + // need to determine the related segment number first + if (compseg.segment_number != 0) continue; - for (const auto& compseg : compsegs_vector) { - const int i = compseg.m_i; - const int j = compseg.m_j; - const int k = compseg.m_k; - if (grid.cellActive(i, j, k)) { - Connection& connection = new_connection_set.getFromIJK(i, j, k); - connection.updateSegment(compseg.segment_number, - compseg.center_depth, - compseg.m_seqIndex, - { compseg.m_distance_start, compseg.m_distance_end }); + const double center_distance = (compseg.m_distance_start + compseg.m_distance_end) / 2.0; + const int branch_number = compseg.m_branch_number; + + int segment_number = 0; + double min_distance_difference = 1.e100; // begin with a big value + for (std::size_t i_segment = 0; i_segment < segment_set.size(); ++i_segment) { + const Segment& current_segment = segment_set[i_segment]; + if( branch_number != current_segment.branchNumber() ) continue; + + const double distance = current_segment.totalLength(); + const double distance_difference = std::abs(center_distance - distance); + if (distance_difference < min_distance_difference) { + min_distance_difference = distance_difference; + segment_number = current_segment.segmentNumber(); } } - for (const auto& connection : new_connection_set) { - if (!connection.attachedToSegment()) - throw std::runtime_error("Not all the connections are attached with a segment. " - "The information from COMPSEGS is not complete"); + if (segment_number == 0) { + std::ostringstream sstr; + sstr << "The connection specified in COMPSEGS with index of " << compseg.m_i + 1 << " " + << compseg.m_j + 1 << " " << compseg.m_k + 1 << " failed in finding a related segment"; + throw std::runtime_error(sstr.str()); } - new_segment_set.updatePerfLength( new_connection_set ); - return std::make_pair( WellConnections( std::move( new_connection_set ) ), - WellSegments( std::move(new_segment_set))); - } + compseg.segment_number = segment_number; -namespace { - // Duplicated from Well.cpp - Connection::Order order_from_int(int int_value) { - switch(int_value) { - case 0: - return Connection::Order::TRACK; - case 1: - return Connection::Order::DEPTH; - case 2: - return Connection::Order::INPUT; - default: - throw std::invalid_argument("Invalid integer value: " + std::to_string(int_value) + " encountered when determining connection ordering"); + // when depth is default or zero, we obtain the depth of the connection based on the information + // of the related segments + if (compseg.center_depth == 0.) { + compseg.calculateCenterDepthWithSegments(segment_set); + } } } -} + void Compsegs::calculateCenterDepthWithSegments(const WellSegments& segment_set) { - std::pair - rstUpdate(const RestartIO::RstWell& rst_well, - std::vector rst_connections, - const std::unordered_map& rst_segments) + // the depth and distance of the segment to the well head + const Segment& segment = segment_set.getFromSegmentNumber(segment_number); + const double segment_depth = segment.depth(); + const double segment_distance = segment.totalLength(); + + // for top segment, no interpolation is needed + if (segment_number == 1) { + center_depth = segment_depth; + return; + } + + // for other cases, interpolation between two segments is needed. + // looking for the other segment needed for interpolation + // by default, it uses the outlet segment to do the interpolation + int interpolation_segment_number = segment.outletSegment(); + + const double center_distance = (m_distance_start + m_distance_end) / 2.0; + // if the perforation is further than the segment and the segment has inlet segments in the same branch + // we use the inlet segment to do the interpolation + if (center_distance > segment_distance) { + for (const int inlet : segment.inletSegments()) { + const int inlet_index = segment_set.segmentNumberToIndex(inlet); + if (segment_set[inlet_index].branchNumber() == m_branch_number) { + interpolation_segment_number = inlet; + break; + } + } + } + + if (interpolation_segment_number == 0) { + throw std::runtime_error("Failed in finding a segment to do the interpolation with segment " + + std::to_string(segment_number)); + } + + // performing the interpolation + const Segment& interpolation_segment = segment_set.getFromSegmentNumber(interpolation_segment_number); + const double interpolation_detph = interpolation_segment.depth(); + const double interpolation_distance = interpolation_segment.totalLength(); + + const double depth_change_segment = segment_depth - interpolation_detph; + const double segment_length = segment_distance - interpolation_distance; + + if (segment_length == 0.) { + throw std::runtime_error("Zero segment length is botained when doing interpolation between segment " + + std::to_string(segment_number) + " and segment " + std::to_string(interpolation_segment_number) ); + } + + center_depth = segment_depth + (center_distance - segment_distance) / segment_length * depth_change_segment; + } + + void + Compsegs::updateConnectionsWithSegment(const std::vector& compsegs, + const EclipseGrid& grid, + WellConnections& connection_set) { - for (auto& connection : rst_connections) { - int segment_id = connection.segment(); - if (segment_id > 0) { - const auto& segment = rst_segments.at(segment_id); - connection.updateSegmentRST(segment.segmentNumber(), - segment.depth()); + + for (const auto& compseg : compsegs) { + const int i = compseg.m_i; + const int j = compseg.m_j; + const int k = compseg.m_k; + if (grid.cellActive(i, j, k)) { + Connection& connection = connection_set.getFromIJK(i, j, k); + connection.updateSegment(compseg.segment_number, + compseg.center_depth, + compseg.m_seqIndex, + compseg.m_distance_start, + compseg.m_distance_end); } } - WellConnections connections(order_from_int(rst_well.completion_ordering), - rst_well.ij[0], - rst_well.ij[1], - rst_connections); - - std::vector segments_list; - /* - The ordering of the segments in the WellSegments structure seems a - bit random; in some parts of the code the segment_number seems to - be treated like a random integer ID, whereas in other parts it - seems to be treated like a running index. Here the segments in - WellSegments are sorted according to the segment number - observe - that this is somewhat important because the first top segment is - treated differently from the other segment. - */ - for (const auto& segment_pair : rst_segments) - segments_list.push_back( std::move(segment_pair.second) ); - - std::sort( segments_list.begin(), segments_list.end(),[](const Segment& seg1, const Segment& seg2) { return seg1.segmentNumber() < seg2.segmentNumber(); } ); - auto comp_pressure_drop = WellSegments::CompPressureDrop::HFA; - - WellSegments segments( comp_pressure_drop, segments_list); - segments.updatePerfLength( connections ); - - return std::make_pair( std::move(connections), std::move(segments)); + for (size_t ic = 0; ic < connection_set.size(); ++ic) { + if (!(connection_set.get(ic).attachedToSegment())) { + throw std::runtime_error("Not all the connections are attached with a segment. " + "The information from COMPSEGS is not complete"); + } + } } } -} diff --git a/ThirdParty/custom-opm-common/opm-common/src/opm/parser/eclipse/EclipseState/Schedule/MSW/Compsegs.hpp b/ThirdParty/custom-opm-common/opm-common/src/opm/parser/eclipse/EclipseState/Schedule/MSW/Compsegs.hpp index 44c975ad98..612e24fe05 100644 --- a/ThirdParty/custom-opm-common/opm-common/src/opm/parser/eclipse/EclipseState/Schedule/MSW/Compsegs.hpp +++ b/ThirdParty/custom-opm-common/opm-common/src/opm/parser/eclipse/EclipseState/Schedule/MSW/Compsegs.hpp @@ -21,49 +21,55 @@ #ifndef COMPSEGS_HPP_ #define COMPSEGS_HPP_ -#include -#include +#include +#include + +#include +#include +#include namespace Opm { - class Segment; - class Connection; class WellConnections; class DeckKeyword; class WellSegments; class EclipseGrid; - class ParseContext; - class ErrorGuard; -namespace RestartIO { - struct RstWell; -} + struct Compsegs { + int m_i; + int m_j; + int m_k; + // the branch number on the main stem is always 1. + // lateral branches should be numbered bigger than 1. + // a suboridnate branch must have a higher branch number than parent branch. + int m_branch_number; + double m_distance_start; + double m_distance_end; + Connection::Direction m_dir; -namespace Compsegs { + double center_depth; + // we do not handle thermal length for the moment + // double m_thermal_length; + int segment_number; + std::size_t m_seqIndex; + Compsegs(int i_in, int j_in, int k_in, int branch_number_in, double distance_start_in, double distance_end_in, + Connection::Direction dir_in, double center_depth_in, int segment_number_in, std::size_t seqIndex_in); -/* - The COMPSEGS keyword defines a link between connections and segments. This - linking is circular because information about the segments is embedded in the - connections, and visa versa. The function creates new WellSegments and - WellConnections instances where the segment <--> connection linking has been - established. -*/ + void calculateCenterDepthWithSegments(const WellSegments& segment_set); - std::pair - processCOMPSEGS(const DeckKeyword& compsegs, - const WellConnections& input_connections, - const WellSegments& input_segments, - const EclipseGrid& grid, - const ParseContext& parseContext, - ErrorGuard& errors); + static std::vector< Compsegs > compsegsFromCOMPSEGSKeyword(const DeckKeyword& compsegsKeyword, const EclipseGrid& grid, + const ParseContext& parseContext, ErrorGuard& errors); + // get the segment number information and depth information based on the information from WellSegments + static void processCOMPSEGS(std::vector< Compsegs >& compsegs, const WellSegments& segment_set); - std::pair - rstUpdate(const RestartIO::RstWell& rst_well, - std::vector input_connections, - const std::unordered_map& input_segments); -} + // update the segment related information for Connections + static void updateConnectionsWithSegment(const std::vector< Compsegs >& compsegs, + const EclipseGrid& grid, + WellConnections& connection_set); + + }; } diff --git a/ThirdParty/custom-opm-common/opm-common/src/opm/parser/eclipse/EclipseState/Schedule/MSW/Segment.cpp b/ThirdParty/custom-opm-common/opm-common/src/opm/parser/eclipse/EclipseState/Schedule/MSW/Segment.cpp index 4d6c600574..be6c0333b2 100644 --- a/ThirdParty/custom-opm-common/opm-common/src/opm/parser/eclipse/EclipseState/Schedule/MSW/Segment.cpp +++ b/ThirdParty/custom-opm-common/opm-common/src/opm/parser/eclipse/EclipseState/Schedule/MSW/Segment.cpp @@ -19,12 +19,13 @@ #include #include -#include +#include #include #include -#include + #include +#include namespace Opm { namespace { @@ -71,27 +72,28 @@ namespace { m_roughness(if_invalid_value(rst_segment.roughness)), m_cross_area(if_invalid_value(rst_segment.area)), m_volume(rst_segment.volume), - m_data_ready(true) + m_data_ready(true), + m_segment_type(rst_segment.segment_type) { - if (rst_segment.segment_type == SegmentType::SICD) { + if (this->m_segment_type == SegmentType::SICD) { double scalingFactor = -1; // The scaling factor will be and updated from the simulator. - SICD icd(rst_segment.base_strength, - rst_segment.icd_length, - rst_segment.fluid_density, - rst_segment.fluid_viscosity, - rst_segment.critical_water_fraction, - rst_segment.transition_region_width, - rst_segment.max_emulsion_ratio, - rst_segment.icd_scaling_mode, - rst_segment.max_valid_flow_rate, - rst_segment.icd_status, - scalingFactor); + SpiralICD icd(rst_segment.base_strength, + rst_segment.icd_length, + rst_segment.fluid_density, + rst_segment.fluid_viscosity, + rst_segment.critical_water_fraction, + rst_segment.transition_region_width, + rst_segment.max_emulsion_ratio, + rst_segment.icd_scaling_mode, + rst_segment.max_valid_flow_rate, + rst_segment.icd_status, + scalingFactor); this->updateSpiralICD(icd); } - if (rst_segment.segment_type == SegmentType::VALVE) { + if (this->m_segment_type == SegmentType::VALVE) { /* These three variables are currently not stored in the restart file; here we initialize with the default values, but if they have @@ -112,7 +114,15 @@ namespace { pipeCrossA, rst_segment.icd_status); - this->updateValve(valve); + /* + The segment length argument should be the length of this + particular segment; in the input phase that is calculated from the + WellSegments::segmentLength() function which also uses the outlet + segment. + */ + double segment_length = -1; + throw std::logic_error("Sorry can not create a Valve segment from restart file"); + this->updateValve(valve, segment_length); } } @@ -120,7 +130,7 @@ namespace { Segment::Segment(int segment_number_in, int branch_in, int outlet_segment_in, double length_in, double depth_in, double internal_diameter_in, double roughness_in, double cross_area_in, - double volume_in, bool data_ready_in) + double volume_in, bool data_ready_in, SegmentType segment_type_in) : m_segment_number(segment_number_in), m_branch(branch_in), m_outlet_segment(outlet_segment_in), @@ -130,7 +140,8 @@ namespace { m_roughness(roughness_in), m_cross_area(cross_area_in), m_volume(volume_in), - m_data_ready(data_ready_in) + m_data_ready(data_ready_in), + m_segment_type(segment_type_in) { } @@ -168,7 +179,10 @@ namespace { result.m_cross_area = 10.0; result.m_volume = 11.0; result.m_data_ready = true; - result.m_icd = SICD::serializeObject(); + result.m_segment_type = SegmentType::SICD; + result.m_spiral_icd = std::make_shared(SpiralICD::serializeObject()); + result.m_valve = std::make_shared(Valve::serializeObject()); + return result; } @@ -196,9 +210,6 @@ namespace { return m_depth; } - double Segment::perfLength() const { - return *this->m_perf_length; - } double Segment::internalDiameter() const { return m_internal_diameter; @@ -223,19 +234,7 @@ namespace { } Segment::SegmentType Segment::segmentType() const { - if (this->isRegular()) - return SegmentType::REGULAR; - - if (this->isSpiralICD()) - return SegmentType::SICD; - - if (this->isAICD()) - return SegmentType::AICD; - - if (this->isValve()) - return SegmentType::VALVE; - - throw std::logic_error("This just should not happen "); + return m_segment_type; } const std::vector& Segment::inletSegments() const { @@ -260,8 +259,6 @@ namespace { && this->m_roughness == rhs.m_roughness && this->m_cross_area == rhs.m_cross_area && this->m_volume == rhs.m_volume - && this->m_perf_length == rhs.m_perf_length - && this->m_icd == rhs.m_icd && this->m_data_ready == rhs.m_data_ready; } @@ -269,80 +266,58 @@ namespace { return !this->operator==(rhs); } - void Segment::updateSpiralICD(const SICD& spiral_icd) { - this->m_icd = spiral_icd; + void Segment::updateSpiralICD(const SpiralICD& spiral_icd) { + m_segment_type = SegmentType::SICD; + m_spiral_icd = std::make_shared(spiral_icd); } - const SICD& Segment::spiralICD() const { - return std::get(this->m_icd); + const std::shared_ptr& Segment::spiralICD() const { + return m_spiral_icd; } - void Segment::updateAutoICD(const AutoICD& aicd) { - this->m_icd = aicd; - } - - const AutoICD& Segment::autoICD() const { - return std::get(this->m_icd); - } - - - - void Segment::updateValve(const Valve& input_valve) { - // we need to update some values for the vale - auto valve = input_valve; - if (valve.pipeAdditionalLength() < 0) - throw std::logic_error("Bug in handling of pipe length for valves"); - - if (valve.pipeDiameter() < 0.) { - valve.setPipeDiameter(m_internal_diameter); - } else { - this->m_internal_diameter = valve.pipeDiameter(); - } - - if (valve.pipeRoughness() < 0.) { - valve.setPipeRoughness(m_roughness); - } else { - this->m_roughness = valve.pipeRoughness(); - } - - if (valve.pipeCrossArea() < 0.) { - valve.setPipeCrossArea(m_cross_area); - } else { - this->m_cross_area = valve.pipeCrossArea(); - } - - if (valve.conMaxCrossArea() < 0.) { - valve.setConMaxCrossArea(valve.pipeCrossArea()); - } - - this->m_icd= valve; - } - - - void Segment::updateValve__(Valve& valve, const double segment_length) { - if (valve.pipeAdditionalLength() < 0) - valve.setPipeAdditionalLength(segment_length); - - this->updateValve(valve); - } void Segment::updateValve(const Valve& valve, const double segment_length) { - auto new_valve = valve; - this->updateValve__(new_valve, segment_length); + // we need to update some values for the vale + auto valve_ptr = std::make_shared(valve); + + if (valve_ptr->pipeAdditionalLength() < 0.) { // defaulted for this + valve_ptr->setPipeAdditionalLength(segment_length); + } + + if (valve_ptr->pipeDiameter() < 0.) { + valve_ptr->setPipeDiameter(m_internal_diameter); + } else { + this->m_internal_diameter = valve_ptr->pipeDiameter(); + } + + if (valve_ptr->pipeRoughness() < 0.) { + valve_ptr->setPipeRoughness(m_roughness); + } else { + this->m_roughness = valve_ptr->pipeRoughness(); + } + + if (valve_ptr->pipeCrossArea() < 0.) { + valve_ptr->setPipeCrossArea(m_cross_area); + } else { + this->m_cross_area = valve_ptr->pipeCrossArea(); + } + + if (valve_ptr->conMaxCrossArea() < 0.) { + valve_ptr->setConMaxCrossArea(valve_ptr->pipeCrossArea()); + } + + this->m_valve = valve_ptr; + + m_segment_type = SegmentType::VALVE; } - void Segment::updatePerfLength(double perf_length) { - this->m_perf_length = perf_length; - } - - - const Valve& Segment::valve() const { - return std::get(this->m_icd); + const Valve* Segment::valve() const { + return m_valve.get(); } int Segment::ecl_type_id() const { - switch (this->segmentType()) { + switch (this->m_segment_type) { case SegmentType::REGULAR: return -1; case SegmentType::SICD: diff --git a/ThirdParty/custom-opm-common/opm-common/src/opm/parser/eclipse/EclipseState/Schedule/MSW/SICD.cpp b/ThirdParty/custom-opm-common/opm-common/src/opm/parser/eclipse/EclipseState/Schedule/MSW/SpiralICD.cpp similarity index 73% rename from ThirdParty/custom-opm-common/opm-common/src/opm/parser/eclipse/EclipseState/Schedule/MSW/SICD.cpp rename to ThirdParty/custom-opm-common/opm-common/src/opm/parser/eclipse/EclipseState/Schedule/MSW/SpiralICD.cpp index f5c83d6b95..ac7b7ab0a9 100644 --- a/ThirdParty/custom-opm-common/opm-common/src/opm/parser/eclipse/EclipseState/Schedule/MSW/SICD.cpp +++ b/ThirdParty/custom-opm-common/opm-common/src/opm/parser/eclipse/EclipseState/Schedule/MSW/SpiralICD.cpp @@ -19,24 +19,22 @@ */ #include -#include +#include #include #include #include #include -#include "src/opm/parser/eclipse/EclipseState/Schedule/MSW/icd_convert.hpp" - namespace Opm { - SICD::SICD() - : SICD(0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0, 0.0, ICDStatus::SHUT, 1.0) + SpiralICD::SpiralICD() + : SpiralICD(0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0, 0.0, ICDStatus::SHUT, 1.0) { } - SICD::SICD(double strength, + SpiralICD::SpiralICD(double strength, double length, double densityCalibration, double viscosityCalibration, @@ -62,7 +60,7 @@ namespace Opm { } - SICD::SICD(const DeckRecord& record) + SpiralICD::SpiralICD(const DeckRecord& record) : m_strength(record.getItem("STRENGTH").getSIDouble(0)), m_length(record.getItem("LENGTH").getSIDouble(0)), m_density_calibration(record.getItem("DENSITY_CALI").getSIDouble(0)), @@ -83,9 +81,9 @@ namespace Opm { } - SICD SICD::serializeObject() + SpiralICD SpiralICD::serializeObject() { - SICD result; + SpiralICD result; result.m_strength = 1.0; result.m_length = 2.0; result.m_density_calibration = 3.0; @@ -101,60 +99,79 @@ namespace Opm { return result; } - - - - std::map > > - SICD::fromWSEGSICD(const DeckKeyword& wsegsicd) + std::map > > + SpiralICD::fromWSEGSICD(const DeckKeyword& wsegsicd) { - return SICD::fromWSEG(wsegsicd); + std::map > > res; + + for (const DeckRecord &record : wsegsicd) { + const std::string well_name = record.getItem("WELL").getTrimmedString(0); + + const int start_segment = record.getItem("SEG1").get(0); + const int end_segment = record.getItem("SEG2").get(0); + + if (start_segment < 2 || end_segment < 2 || end_segment < start_segment) { + const std::string message = "Segment numbers " + std::to_string(start_segment) + " and " + + std::to_string(end_segment) + " specified in WSEGSICD for well " + + well_name + + " are illegal "; + throw std::invalid_argument(message); + } + + const SpiralICD spiral_icd(record); + for (int seg = start_segment; seg <= end_segment; seg++) { + res[well_name].push_back(std::make_pair(seg, spiral_icd)); + } + } + + return res; } - double SICD::maxAbsoluteRate() const { + double SpiralICD::maxAbsoluteRate() const { return m_max_absolute_rate; } - ICDStatus SICD::status() const { + ICDStatus SpiralICD::status() const { return m_status; } - double SICD::strength() const { + double SpiralICD::strength() const { return m_strength; } - double SICD::length() const { + double SpiralICD::length() const { return m_length; } - double SICD::densityCalibration() const { + double SpiralICD::densityCalibration() const { return m_density_calibration; } - double SICD::viscosityCalibration() const + double SpiralICD::viscosityCalibration() const { return m_viscosity_calibration; } - double SICD::criticalValue() const { + double SpiralICD::criticalValue() const { return m_critical_value; } - double SICD::widthTransitionRegion() const + double SpiralICD::widthTransitionRegion() const { return m_width_transition_region; } - double SICD::maxViscosityRatio() const + double SpiralICD::maxViscosityRatio() const { return m_max_viscosity_ratio; } - int SICD::methodFlowScaling() const + int SpiralICD::methodFlowScaling() const { return m_method_flow_scaling; } - double SICD::scalingFactor() const + double SpiralICD::scalingFactor() const { if (m_scaling_factor <= 0.) throw std::runtime_error("the scaling factor has invalid value " + std::to_string(m_scaling_factor)); @@ -162,7 +179,7 @@ namespace Opm { return m_scaling_factor; } - void SICD::updateScalingFactor(const double outlet_segment_length, const double completion_length) + void SpiralICD::updateScalingFactor(const double outlet_segment_length, const double completion_length) { if (m_method_flow_scaling < 0) { if (m_length > 0.) { // icd length / outlet segment length @@ -190,7 +207,7 @@ namespace Opm { } - bool SICD::operator==(const SICD& data) const { + bool SpiralICD::operator==(const SpiralICD& data) const { return this->strength() == data.strength() && this->length() == data.length() && this->densityCalibration() == data.densityCalibration() && @@ -204,7 +221,7 @@ namespace Opm { this->scalingFactor() == data.scalingFactor(); } -int SICD::ecl_status() const { +int SpiralICD::ecl_status() const { return to_int(this->m_status); } diff --git a/ThirdParty/custom-opm-common/opm-common/src/opm/parser/eclipse/EclipseState/Schedule/MSW/WellSegments.cpp b/ThirdParty/custom-opm-common/opm-common/src/opm/parser/eclipse/EclipseState/Schedule/MSW/WellSegments.cpp index 9d6f2dd9a3..58811ffd58 100644 --- a/ThirdParty/custom-opm-common/opm-common/src/opm/parser/eclipse/EclipseState/Schedule/MSW/WellSegments.cpp +++ b/ThirdParty/custom-opm-common/opm-common/src/opm/parser/eclipse/EclipseState/Schedule/MSW/WellSegments.cpp @@ -31,9 +31,8 @@ #include #include #include -#include #include -#include +#include #include #include @@ -142,12 +141,12 @@ namespace Opm { if (length_depth_type == LengthDepth::INC) { m_segments.emplace_back( 1, 1, 0, 0., 0., invalid_value, invalid_value, invalid_value, - volume_top, false); + volume_top, false , Segment::SegmentType::REGULAR); } else if (length_depth_type == LengthDepth::ABS) { m_segments.emplace_back( 1, 1, 0, length_top, depth_top, invalid_value, invalid_value, invalid_value, - volume_top, true); + volume_top, true , Segment::SegmentType::REGULAR); } // read all the information out from the DECK first then process to get all the required information @@ -207,13 +206,13 @@ namespace Opm { if (length_depth_type == LengthDepth::INC) { m_segments.emplace_back( i, branch, outlet_segment, segment_length, depth_change, - diameter, roughness, area, volume, false); + diameter, roughness, area, volume, false , Segment::SegmentType::REGULAR); } else if (i == segment2) { m_segments.emplace_back( i, branch, outlet_segment, segment_length, depth_change, - diameter, roughness, area, volume, true); + diameter, roughness, area, volume, true , Segment::SegmentType::REGULAR); } else { m_segments.emplace_back( i, branch, outlet_segment, invalid_value, invalid_value, - diameter, roughness, area, volume, false); + diameter, roughness, area, volume, false , Segment::SegmentType::REGULAR); } } } @@ -471,14 +470,6 @@ namespace Opm { } - std::set WellSegments::branches() const { - std::set bset; - for (const auto& segment : this->m_segments) - bset.insert( segment.branchNumber() ); - return bset; - } - - std::vector WellSegments::branchSegments(int branch) const { std::vector segments; std::unordered_set segment_set; @@ -508,7 +499,7 @@ namespace Opm { return segments; } - bool WellSegments::updateWSEGSICD(const std::vector >& sicd_pairs) { + bool WellSegments::updateWSEGSICD(const std::vector >& sicd_pairs) { if (m_comp_pressure_drop == CompPressureDrop::H__) { const std::string msg = "to use spiral ICD segment you have to activate the frictional pressure drop calculation"; throw std::runtime_error(msg); @@ -516,7 +507,7 @@ namespace Opm { for (const auto& pair_elem : sicd_pairs) { const int segment_number = pair_elem.first; - const SICD& spiral_icd = pair_elem.second; + const SpiralICD& spiral_icd = pair_elem.second; Segment segment = this->getFromSegmentNumber(segment_number); segment.updateSpiralICD(spiral_icd); this->addSegment(segment); @@ -622,12 +613,4 @@ WellSegments::MultiPhaseModel WellSegments::MultiPhaseModelFromString(const std: } } - -void WellSegments::updatePerfLength(const WellConnections& connections) { - for (auto& segment : this->m_segments) { - auto perf_length = connections.segment_perf_length( segment.segmentNumber() ); - segment.updatePerfLength(perf_length); - } -} - } diff --git a/ThirdParty/custom-opm-common/opm-common/src/opm/parser/eclipse/EclipseState/Schedule/MSW/icd.cpp b/ThirdParty/custom-opm-common/opm-common/src/opm/parser/eclipse/EclipseState/Schedule/MSW/icd.cpp index 48cdea8381..4baebffe4d 100644 --- a/ThirdParty/custom-opm-common/opm-common/src/opm/parser/eclipse/EclipseState/Schedule/MSW/icd.cpp +++ b/ThirdParty/custom-opm-common/opm-common/src/opm/parser/eclipse/EclipseState/Schedule/MSW/icd.cpp @@ -20,8 +20,6 @@ #include #include -#include "icd_convert.hpp" - namespace Opm { template <> diff --git a/ThirdParty/custom-opm-common/opm-common/src/opm/parser/eclipse/EclipseState/Schedule/MSW/icd_convert.hpp b/ThirdParty/custom-opm-common/opm-common/src/opm/parser/eclipse/EclipseState/Schedule/MSW/icd_convert.hpp deleted file mode 100644 index 9812b965e8..0000000000 --- a/ThirdParty/custom-opm-common/opm-common/src/opm/parser/eclipse/EclipseState/Schedule/MSW/icd_convert.hpp +++ /dev/null @@ -1,14 +0,0 @@ -#ifndef OPM_ICD_CONVERT_HPP -#define OPM_ICD_CONVERT_HPP - -namespace Opm { - -template -T from_int(int int_status); - -template -int to_int(T status); - -} - -#endif diff --git a/ThirdParty/custom-opm-common/opm-common/src/opm/parser/eclipse/EclipseState/Schedule/MSW/updatingConnectionsWithSegments.cpp b/ThirdParty/custom-opm-common/opm-common/src/opm/parser/eclipse/EclipseState/Schedule/MSW/updatingConnectionsWithSegments.cpp new file mode 100644 index 0000000000..6f7bb93275 --- /dev/null +++ b/ThirdParty/custom-opm-common/opm-common/src/opm/parser/eclipse/EclipseState/Schedule/MSW/updatingConnectionsWithSegments.cpp @@ -0,0 +1,39 @@ +/* + Copyright 2017 SINTEF Digital, Mathematics and Cybernetics. + + This file is part of the Open Porous Media project (OPM). + + OPM is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + OPM is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with OPM. If not, see . +*/ + +#include +#include + +#include "Compsegs.hpp" + +namespace Opm { + WellConnections * newConnectionsWithSegments(const DeckKeyword& compsegs, + const WellConnections& input_connections, + const WellSegments& segment_set, + const EclipseGrid& grid, + const ParseContext& parseContext, + ErrorGuard& errors) + { + WellConnections new_connection_set = input_connections; + std::vector compsegs_vector = Compsegs::compsegsFromCOMPSEGSKeyword( compsegs, grid, parseContext, errors); + Compsegs::processCOMPSEGS(compsegs_vector, segment_set); + Compsegs::updateConnectionsWithSegment(compsegs_vector, grid, new_connection_set); + return new WellConnections( std::move( new_connection_set ) ); + } +} diff --git a/ThirdParty/custom-opm-common/opm-common/src/opm/parser/eclipse/EclipseState/Schedule/Network/Branch.cpp b/ThirdParty/custom-opm-common/opm-common/src/opm/parser/eclipse/EclipseState/Schedule/Network/Branch.cpp deleted file mode 100644 index a674fc2fe2..0000000000 --- a/ThirdParty/custom-opm-common/opm-common/src/opm/parser/eclipse/EclipseState/Schedule/Network/Branch.cpp +++ /dev/null @@ -1,105 +0,0 @@ -/* - Copyright 2020 Equinor ASA. - - This file is part of the Open Porous Media project (OPM). - - OPM is free software: you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - OPM is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with OPM. If not, see . -*/ - - -#include - -#include - -namespace Opm { -namespace Network { - -namespace { - -constexpr int invalid_vfp_table = 9999; - -} - - -Branch Branch::serializeObject() { - Branch object; - return object; -} - - -Branch::Branch(const std::string& downtree_node, const std::string& uptree_node, int vfp_table, double alq) : - m_downtree_node(downtree_node), - m_uptree_node(uptree_node), - m_vfp_table(vfp_table), - m_alq_value(alq), - m_alq_eq(AlqEQ::ALQ_INPUT) -{ -} - -Branch::Branch(const std::string& downtree_node, const std::string& uptree_node, int vfp_table, AlqEQ alq_eq): - m_downtree_node(downtree_node), - m_uptree_node(uptree_node), - m_vfp_table(vfp_table), - m_alq_eq(alq_eq) -{ - if (alq_eq == AlqEQ::ALQ_INPUT) - throw std::logic_error("Wrong constructor - must supply ALQ value"); -} - -const std::string& Branch::uptree_node() const { - return this->m_uptree_node; -} - -const std::string& Branch::downtree_node() const { - return this->m_downtree_node; -} - -bool Branch::operator==(const Branch& other) const { - return this->m_downtree_node == other.m_downtree_node && - this->m_uptree_node == other.m_uptree_node && - this->m_vfp_table == other.m_vfp_table && - this->m_alq_value == other.m_alq_value && - this->m_alq_eq == other.m_alq_eq; -} - -Branch::AlqEQ Branch::AlqEqfromString(const std::string& input_string) { - if (input_string == "NONE") - return AlqEQ::ALQ_INPUT; - - if (input_string == "DENO") - return AlqEQ::OIL_DENSITY; - - if (input_string == "DENG") - return AlqEQ::GAS_DENSITY; - - throw std::invalid_argument("Invalid input for ALQ surface density eq: " + input_string); -} - -std::optional Branch::vfp_table() const { - if (this->m_vfp_table == invalid_vfp_table) - return {}; - else - return this->m_vfp_table; -} - -Branch::AlqEQ Branch::alq_eq() const { - return this->m_alq_eq; -} - -std::optional Branch::alq_value() const { - return this->m_alq_value; -} - -} -} diff --git a/ThirdParty/custom-opm-common/opm-common/src/opm/parser/eclipse/EclipseState/Schedule/Network/ExtNetwork.cpp b/ThirdParty/custom-opm-common/opm-common/src/opm/parser/eclipse/EclipseState/Schedule/Network/ExtNetwork.cpp deleted file mode 100644 index c6120dd6a7..0000000000 --- a/ThirdParty/custom-opm-common/opm-common/src/opm/parser/eclipse/EclipseState/Schedule/Network/ExtNetwork.cpp +++ /dev/null @@ -1,151 +0,0 @@ -/* - Copyright 2020 Equinor ASA. - - This file is part of the Open Porous Media project (OPM). - - OPM is free software: you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - OPM is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with OPM. If not, see . -*/ -#include -#include - -#include -#include - -namespace Opm { -namespace Network { - -ExtNetwork ExtNetwork::serializeObject() { - ExtNetwork object; - return object; -} - - -bool ExtNetwork::active() const { - return !this->m_branches.empty() && !this->m_nodes.empty(); -} - -bool ExtNetwork::operator==(const ExtNetwork&) const { - return true; -} - - -bool ExtNetwork::has_node(const std::string& name) const { - return (this->m_nodes.count(name) > 0); -} - -const Node& ExtNetwork::node(const std::string& name) const { - const auto node_iter = this->m_nodes.find( name ); - if (node_iter == this->m_nodes.end()) - throw std::out_of_range("No such node: " + name); - - return node_iter->second; -} - - -const Node& ExtNetwork::root() const { - if (this->m_nodes.empty()) - throw std::invalid_argument("No root defined for empty network"); - - auto node_ptr = &(this->m_nodes.begin()->second); - while (true) { - auto next_branch = this->uptree_branch(node_ptr->name()); - if (!next_branch) - break; - - node_ptr = &(this->node( next_branch->uptree_node() )); - } - - return *node_ptr; -} - -void ExtNetwork::add_branch(Branch branch) -{ - this->m_branches.push_back( std::move(branch) ); -} - -void ExtNetwork::drop_branch(const std::string& uptree_node, const std::string& downtree_node) { - auto downtree_branches = this->downtree_branches( downtree_node ); - if (downtree_branches.empty()) { - auto branch_iter = std::find_if(this->m_branches.begin(), this->m_branches.end(), [&uptree_node, &downtree_node](const Branch& b) { return (b.uptree_node() == uptree_node && b.downtree_node() == downtree_node); }); - if (branch_iter != this->m_branches.end()) - this->m_branches.erase( branch_iter ); - - this->m_nodes.erase( downtree_node ); - } else { - for (const auto& branch : downtree_branches) - this->drop_branch(branch.uptree_node(), branch.downtree_node()); - } -} - - -std::optional ExtNetwork::uptree_branch(const std::string& node) const { - if (!this->has_node(node)) - throw std::out_of_range("No such node: " + node); - - std::vector branches; - std::copy_if(this->m_branches.begin(), this->m_branches.end(), std::back_inserter(branches), [&node](const Branch& b) { return b.downtree_node() == node; }); - if (branches.empty()) - return {}; - - if (branches.size() == 1) - return std::move(branches[0]); - - throw std::logic_error("Bug - more than upstree branch for node: " + node); -} - - -std::vector ExtNetwork::downtree_branches(const std::string& node) const { - if (!this->has_node(node)) - throw std::out_of_range("No such node: " + node); - - std::vector branches; - std::copy_if(this->m_branches.begin(), this->m_branches.end(), std::back_inserter(branches), [&node](const Branch& b) { return b.uptree_node() == node; }); - return branches; -} - -/* - The validation of the network structure is very weak. The current validation - goes as follows: - - 1. A branch is defined with and uptree and downtree node; the node names used - in the Branch definition is totally unchecked. - - 2. When a node is added we check that the name of the node corresponds to a - node name referred to in one of the previous branch definitions. - - The algorithm feels quite illogical, but from the documentation it seems to be - the only possibility. -*/ - -void ExtNetwork::add_node(Node node) -{ - std::string name = node.name(); - auto branch = std::find_if(this->m_branches.begin(), this->m_branches.end(), - [&name](const Branch& b) { return b.uptree_node() == name || b.downtree_node() == name;}); - - if (branch == this->m_branches.end()) - throw std::invalid_argument("Node: " + name + " is not referenced by any branch and would be dangling."); - - - if (branch->downtree_node() == name) { - if (node.as_choke() && branch->vfp_table().has_value()) - throw std::invalid_argument("Node: " + name + " should serve as a choke => upstream branch can not have VFP table"); - } - - - this->m_nodes.insert({ name, std::move(node) }); -} - -} -} diff --git a/ThirdParty/custom-opm-common/opm-common/src/opm/parser/eclipse/EclipseState/Schedule/Network/Node.cpp b/ThirdParty/custom-opm-common/opm-common/src/opm/parser/eclipse/EclipseState/Schedule/Network/Node.cpp deleted file mode 100644 index 634e45a40f..0000000000 --- a/ThirdParty/custom-opm-common/opm-common/src/opm/parser/eclipse/EclipseState/Schedule/Network/Node.cpp +++ /dev/null @@ -1,72 +0,0 @@ -/* - Copyright 2020 Equinor ASA. - - This file is part of the Open Porous Media project (OPM). - - OPM is free software: you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - OPM is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with OPM. If not, see . -*/ -#include - -#include - -namespace Opm { -namespace Network { - -Node::Node(const std::string& name) : - m_name(name) -{} - -const std::string& Node::name() const { - return this->m_name; -} - -const std::optional& Node::target_group() const { - return this->m_choke_target_group; -} - -const std::optional& Node::terminal_pressure() const { - return this->m_terminal_pressure; -} - -bool Node::add_gas_lift_gas() const { - return this->m_add_gas_lift_gas; -} - -bool Node::as_choke() const { - return this->m_choke_target_group.has_value(); -} - -void Node::terminal_pressure(double pressure) { - this->m_terminal_pressure = pressure; -} - -void Node::add_gas_lift_gas(bool add_gas) { - this->m_add_gas_lift_gas = add_gas; -} - -void Node::as_choke(const std::string& target_group) { - this->m_choke_target_group = target_group; -} - - -bool Node::operator==(const Node& other) const { - return this->m_name == other.m_name && - this->m_terminal_pressure == other.m_terminal_pressure && - this->m_add_gas_lift_gas == other.m_add_gas_lift_gas && - this->m_choke_target_group == other.m_choke_target_group; -} - - -} -} diff --git a/ThirdParty/custom-opm-common/opm-common/src/opm/parser/eclipse/EclipseState/Schedule/Schedule.cpp b/ThirdParty/custom-opm-common/opm-common/src/opm/parser/eclipse/EclipseState/Schedule/Schedule.cpp index f18bb84302..41cc1e97b3 100644 --- a/ThirdParty/custom-opm-common/opm-common/src/opm/parser/eclipse/EclipseState/Schedule/Schedule.cpp +++ b/ThirdParty/custom-opm-common/opm-common/src/opm/parser/eclipse/EclipseState/Schedule/Schedule.cpp @@ -24,7 +24,6 @@ #endif #include -#include #include #include #include @@ -41,7 +40,6 @@ #include #include #include -#include #include #include #include @@ -56,7 +54,8 @@ #include #include #include -#include +#include +#include #include #include @@ -67,7 +66,6 @@ #include #include #include -#include #include #include #include @@ -82,7 +80,6 @@ #include #include "Well/injection.hpp" -#include "MSW/Compsegs.hpp" namespace Opm { @@ -153,10 +150,8 @@ std::pair restart_info(const RestartIO::RstState * rst gconsump(this->m_timeMap, std::make_shared() ), global_whistctl_mode(this->m_timeMap, Well::ProducerCMode::CMODE_UNDEFINED), m_actions(this->m_timeMap, std::make_shared()), - m_network(this->m_timeMap, std::make_shared()), - m_glo(this->m_timeMap, std::make_shared()), rft_config(this->m_timeMap), - m_nupcol(this->m_timeMap, runspec.nupcol()), + m_nupcol(this->m_timeMap, ParserKeywords::NUPCOL::NUM_ITER::defaultValue), restart_config(m_timeMap, deck, parseContext, errors), rpt_config(this->m_timeMap, std::make_shared()) { @@ -268,8 +263,6 @@ Schedule::Schedule(const Deck& deck, const EclipseState& es, const ParseContext& result.wtest_config = {{std::make_shared(WellTestConfig::serializeObject())}, 1}; result.wlist_manager = {{std::make_shared(WListManager::serializeObject())}, 1}; result.udq_config = {{std::make_shared(UDQConfig::serializeObject())}, 1}; - result.m_network = {{std::make_shared(Network::ExtNetwork::serializeObject())}, 1}; - result.m_glo = {{std::make_shared(GasLiftOpt::serializeObject())}, 1}; result.udq_active = {{std::make_shared(UDQActive::serializeObject())}, 1}; result.guide_rate_config = {{std::make_shared(GuideRateConfig::serializeObject())}, 1}; result.gconsale = {{std::make_shared(GConSale::serializeObject())}, 1}; @@ -415,9 +408,6 @@ Schedule::Schedule(const Deck& deck, const EclipseState& es, const ParseContext& else if (keyword.name() == "GRUPTREE") handleGRUPTREE(keyword, currentStep, unit_system, parseContext, errors); - else if (keyword.name() == "GPMAINT") - handleGPMAINT(keyword, currentStep, parseContext, errors); - else if (keyword.name() == "GRUPNET") handleGRUPNET(keyword, currentStep, unit_system); @@ -496,21 +486,6 @@ Schedule::Schedule(const Deck& deck, const EclipseState& es, const ParseContext& else if (keyword.name() == "NUPCOL") handleNUPCOL(keyword, currentStep); - else if (keyword.name() == "NODEPROP") - handleNODEPROP(keyword, currentStep); - - else if (keyword.name() == "BRANPROP") - handleBRANPROP(keyword, currentStep); - - else if (keyword.name() == "LIFTOPT") - handleLIFTOPT(keyword, currentStep); - - else if (keyword.name() == "GLIFTOPT") - handleGLIFTOPT(keyword, currentStep, parseContext, errors); - - else if (keyword.name() == "WLIFTOPT") - handleWLIFTOPT(keyword, currentStep, parseContext, errors); - else if (keyword.name() == "PYACTION") handlePYACTION(python, input_path, keyword, currentStep); @@ -549,7 +524,7 @@ Schedule::Schedule(const Deck& deck, const EclipseState& es, const ParseContext& while (true) { const auto& keyword = section.getKeyword(keywordIdx); if (keyword.name() == "ACTIONX") { - Action::ActionX action(keyword, this->m_timeMap.getStartTime(currentStep)); + Action::ActionX action(keyword, this->m_timeMap.getStartTime(currentStep + 1)); while (true) { keywordIdx++; if (keywordIdx == section.size()) @@ -1336,22 +1311,19 @@ Schedule::Schedule(const Deck& deck, const EclipseState& es, const ParseContext& void Schedule::handleWLIST(const DeckKeyword& keyword, size_t currentStep) { const std::string legal_actions = "NEW:ADD:DEL:MOV"; + const auto& current = *this->wlist_manager.get(currentStep); + std::shared_ptr new_wlm(new WListManager(current)); for (const auto& record : keyword) { const std::string& name = record.getItem("NAME").getTrimmedString(0); const std::string& action = record.getItem("ACTION").getTrimmedString(0); - const std::vector& well_args = record.getItem("WELLS").getData(); - std::vector wells; - std::shared_ptr new_wlm = std::make_shared( *this->wlist_manager.get(currentStep) ); + const std::vector& wells = record.getItem("WELLS").getData(); if (legal_actions.find(action) == std::string::npos) throw std::invalid_argument("The action:" + action + " is not recognized."); - for (const auto& well_arg : well_args) { - const auto& names = this->wellNames(well_arg, currentStep); - if (names.empty() && well_arg.find("*") == std::string::npos) - throw std::invalid_argument("The well: " + well_arg + " has not been defined in the WELSPECS"); - - std::move(names.begin(), names.end(), std::back_inserter(wells)); + for (const auto& well : wells) { + if (!this->hasWell(well)) + throw std::invalid_argument("The well: " + well + " has not been defined in the WELSPECS"); } if (name[0] != '*') @@ -1377,8 +1349,8 @@ Schedule::Schedule(const Deck& deck, const EclipseState& es, const ParseContext& wlist.add(well); } - this->wlist_manager.update(currentStep, new_wlm); } + this->wlist_manager.update(currentStep, new_wlm); } void Schedule::handleUDQ(const DeckKeyword& keyword, size_t currentStep) { @@ -1639,7 +1611,8 @@ Schedule::Schedule(const Deck& deck, const EclipseState& es, const ParseContext& const std::string& wellNamePattern = record.getItem("WELL").getTrimmedString(0); const auto cmode = Well::WELTARGCModeFromString(record.getItem("CMODE").getTrimmedString(0)); - const auto new_arg = record.getItem("NEW_VALUE").get< UDAValue >(0); + double newValue = record.getItem("NEW_VALUE").get< double >(0); + const auto well_names = wellNames( wellNamePattern, currentStep ); if( well_names.empty() ) @@ -1652,20 +1625,16 @@ Schedule::Schedule(const Deck& deck, const EclipseState& es, const ParseContext& bool update = false; if (well2->isProducer()) { auto prop = std::make_shared(well2->getProductionProperties()); - prop->handleWELTARG(cmode, new_arg, SiFactorP); + prop->handleWELTARG(cmode, newValue, SiFactorP); update = well2->updateProduction(prop); if (cmode == Well::WELTARGCMode::GUID) - update |= well2->updateWellGuideRate(new_arg.get()); - - auto udq = std::make_shared(this->udqActive(currentStep)); - if (prop->updateUDQActive(this->getUDQConfig(currentStep), *udq)) - this->updateUDQActive(currentStep, udq); + update |= well2->updateWellGuideRate(newValue); } else { auto inj = std::make_shared(well2->getInjectionProperties()); - inj->handleWELTARG(cmode, new_arg, SiFactorP); + inj->handleWELTARG(cmode, newValue, SiFactorP); update = well2->updateInjection(inj); if (cmode == Well::WELTARGCMode::GUID) - update |= well2->updateWellGuideRate(new_arg.get()); + update |= well2->updateWellGuideRate(newValue); } if (update) this->updateWell(std::move(well2), currentStep); @@ -1771,12 +1740,12 @@ Schedule::Schedule(const Deck& deck, const EclipseState& es, const ParseContext& } } } - bool availableForGroupControl = DeckItem::to_bool(record.getItem("RESPOND_TO_PARENT").getTrimmedString(0)) && (group_name != "FIELD"); - + auto resv_target = record.getItem("RESERVOIR_FLUID_TARGET").getSIDouble(0); + bool availableForGroupControl = DeckItem::to_bool(record.getItem("RESPOND_TO_PARENT").getTrimmedString(0)) + && (group_name != "FIELD"); { auto group_ptr = std::make_shared(this->getGroup(group_name, currentStep)); - Group::GroupProductionProperties production(group_name); - auto resv_target = record.getItem("RESERVOIR_FLUID_TARGET").getSIDouble(0); + Group::GroupProductionProperties production; production.cmode = controlMode; production.oil_target = oil_target; production.gas_target = gas_target; @@ -1820,10 +1789,6 @@ Schedule::Schedule(const Deck& deck, const EclipseState& es, const ParseContext& this->updateGroup(std::move(group_ptr), currentStep); m_events.addEvent( ScheduleEvents::GROUP_PRODUCTION_UPDATE , currentStep); this->addWellGroupEvent(group_name, ScheduleEvents::GROUP_PRODUCTION_UPDATE, currentStep); - - auto udq = std::make_shared(this->udqActive(currentStep)); - if (production.updateUDQActive(this->getUDQConfig(currentStep), *udq)) - this->updateUDQActive(currentStep, udq); } } } @@ -2049,9 +2014,38 @@ Schedule::Schedule(const Deck& deck, const EclipseState& es, const ParseContext& auto well2 = std::shared_ptr(new Well( this->getWell(name, currentStep))); auto connections = std::shared_ptr( new WellConnections( well2->getConnections())); connections->loadCOMPDAT(record, grid, fp); + /* + This block implements the following dubious logic. + + 1. All competions are shut. + 2. A new open completion is added. + 3. A currently SHUT well is opened. + + This code assumes that the reason the well is initially + shut is due to all the shut completions, if the well was + explicitly shut for another reason the explicit opening of + the well might be in error? + */ + /*if (all_shut0) { + if (!connections->allConnectionsShut()) { + if (well2->getStatus() == WellCommon::StatusEnum::SHUT) { + printf("Running all_shut inner loop\n"); + if (this->updateWellStatus(well2->name(), currentStep, WellCommon::StatusEnum::OPEN)) + // Refresh pointer if the status has updated current slot. Ugly + well2 = std::shared_ptr(new Well(this->getWell(name, currentStep))); + } + } + } + */ if (well2->updateConnections(connections, grid, fp.get_int("PVTNUM"))) this->updateWell(well2, currentStep); + if (well2->getStatus() == Well::Status::SHUT) { + std::string msg = + "All completions in well " + well2->name() + " is shut at " + std::to_string ( m_timeMap.getTimePassedUntil(currentStep) / (60*60*24) ) + " days. \n" + + "The well is therefore also shut."; + OpmLog::note(msg); + } } this->addWellGroupEvent(name, ScheduleEvents::COMPLETION_CHANGE, currentStep); } @@ -2087,24 +2081,17 @@ Schedule::Schedule(const Deck& deck, const EclipseState& es, const ParseContext& void Schedule::handleWSEGSICD( const DeckKeyword& keyword, size_t currentStep) { - std::map > > spiral_icds = SICD::fromWSEGSICD(keyword); + const std::map > > spiral_icds = + SpiralICD::fromWSEGSICD(keyword); - for (auto& map_elem : spiral_icds) { + for (const auto& map_elem : spiral_icds) { const std::string& well_name_pattern = map_elem.first; const auto well_names = this->wellNames(well_name_pattern, currentStep); - std::vector >& sicd_pairs = map_elem.second; + const std::vector >& sicd_pairs = map_elem.second; for (const auto& well_name : well_names) { auto& dynamic_state = this->wells_static.at(well_name); auto well_ptr = std::make_shared( *dynamic_state[currentStep] ); - - const auto& connections = well_ptr->getConnections(); - const auto& segments = well_ptr->getSegments(); - for (auto& [segment_nr, sicd] : sicd_pairs) { - const auto& outlet_segment_length = segments.segmentLength( segments.getFromSegmentNumber(segment_nr).outletSegment() ); - sicd.updateScalingFactor(outlet_segment_length, connections.segment_perf_length(segment_nr)); - } - if (well_ptr -> updateWSEGSICD(sicd_pairs) ) this->updateWell(std::move(well_ptr), currentStep); } @@ -2156,46 +2143,22 @@ Schedule::Schedule(const Deck& deck, const EclipseState& es, const ParseContext& } } - void Schedule::handleGRUPTREE( const DeckKeyword& keyword, size_t currentStep, const UnitSystem& unit_system, const ParseContext& parseContext, ErrorGuard& errors) { +void Schedule::handleGRUPTREE( const DeckKeyword& keyword, size_t currentStep, const UnitSystem& unit_system, const ParseContext& parseContext, ErrorGuard& errors) { for( const auto& record : keyword ) { const std::string& childName = trim_wgname(keyword, record.getItem("CHILD_GROUP").get(0), parseContext, errors); const std::string& parentName = trim_wgname(keyword, record.getItem("PARENT_GROUP").get(0), parseContext, errors); - if (!hasGroup(childName)) - addGroup( childName , currentStep, unit_system ); - if (!hasGroup(parentName)) addGroup( parentName , currentStep, unit_system ); + if (!hasGroup(childName)) + addGroup( childName , currentStep, unit_system ); + this->addGroupToGroup(parentName, childName, currentStep); } } - void Schedule::handleGPMAINT( const DeckKeyword& keyword, size_t currentStep, const ParseContext& parseContext, ErrorGuard& errors) { - for( const auto& record : keyword ) { - const std::string& groupNamePattern = record.getItem("GROUP").getTrimmedString(0); - const auto group_names = this->groupNames(groupNamePattern); - - if (group_names.empty()) - invalidNamePattern(groupNamePattern, currentStep, parseContext, errors, keyword); - - using GP = ParserKeywords::GPMAINT; - for (const auto& group_name : group_names) { - auto group_ptr = std::make_shared(this->getGroup(group_name, currentStep)); - const auto& target_string = record.getItem().get(0); - if (target_string == "NONE") - group_ptr->set_gpmaint(); - else { - GPMaint gpmaint(record); - group_ptr->set_gpmaint(std::move(gpmaint)); - } - this->updateGroup(std::move(group_ptr), currentStep); - } - } - } - - void Schedule::handleGRUPNET( const DeckKeyword& keyword, size_t currentStep, const UnitSystem& unit_system) { for( const auto& record : keyword ) { const auto& groupName = record.getItem("NAME").getTrimmedString(0); @@ -2560,7 +2523,11 @@ void Schedule::invalidNamePattern( const std::string& namePattern, std::size_t // WLIST if (pattern[0] == '*' && pattern.size() > 1) { const auto& wlm = this->getWListManager(timeStep); - return wlm.wells(pattern); + if (wlm.hasList(pattern)) { + const auto& wlist = wlm.getList(pattern); + return { wlist.begin(), wlist.end() }; + } else + return {}; } // Normal pattern matching @@ -2685,20 +2652,6 @@ void Schedule::invalidNamePattern( const std::string& namePattern, std::size_t return names; } - std::vector Schedule::restart_groups(std::size_t timeStep) const { - std::size_t wdmax = this->m_runspec.wellDimensions().maxGroupsInField(); - std::vector rst_groups(wdmax + 1 , nullptr ); - for (const auto& group_name : this->groupNames(timeStep)) { - const auto& group = this->getGroup(group_name, timeStep); - - if (group.name() == "FIELD") - rst_groups.back() = &group; - else - rst_groups[group.insert_index() - 1] = &group; - } - return rst_groups; - } - void Schedule::addGroup(const std::string& groupName, size_t timeStep, const UnitSystem& unit_system) { const size_t gseqIndex = this->groups.size(); @@ -2848,13 +2801,8 @@ void Schedule::invalidNamePattern( const std::string& namePattern, std::size_t for (const auto& wname : well_names) { const auto& well = this->getWell(wname, timeStep); const auto& connections = well.getConnections(); - if (connections.allConnectionsShut() && well.getStatus() != Well::Status::SHUT) { - std::string msg = - "All completions in well " + well.name() + " is shut at " + std::to_string ( m_timeMap.getTimePassedUntil(timeStep) / (60*60*24) ) + " days. \n" + - "The well is therefore also shut."; - OpmLog::note(msg); + if (connections.allConnectionsShut()) this->updateWellStatus( well.name(), timeStep, Well::Status::SHUT, false); - } } } @@ -3073,8 +3021,6 @@ void Schedule::invalidNamePattern( const std::string& namePattern, std::size_t this->m_runspec == data.m_runspec && compareMap(this->vfpprod_tables, data.vfpprod_tables) && compareMap(this->vfpinj_tables, data.vfpinj_tables) && - compareDynState(this->m_network, data.m_network) && - compareDynState(this->m_glo, data.m_glo) && compareDynState(this->wtest_config, data.wtest_config) && compareDynState(this->wlist_manager, data.wlist_manager) && compareDynState(this->udq_config, data.udq_config) && @@ -3090,7 +3036,6 @@ void Schedule::invalidNamePattern( const std::string& namePattern, std::size_t this->restart_config == data.restart_config && this->wellgroup_events == data.wellgroup_events; } - namespace { // Duplicated from Well.cpp Connection::Order order_from_int(int int_value) { @@ -3105,6 +3050,7 @@ Connection::Order order_from_int(int int_value) { throw std::invalid_argument("Invalid integer value: " + std::to_string(int_value) + " encountered when determining connection ordering"); } } + } void Schedule::load_rst(const RestartIO::RstState& rst_state, const EclipseGrid& grid, const FieldPropsManager& fp, const UnitSystem& unit_system) @@ -3117,27 +3063,49 @@ void Schedule::load_rst(const RestartIO::RstState& rst_state, const EclipseGrid& for (const auto& rst_well : rst_state.wells) { Opm::Well well(rst_well, report_step, unit_system, udq_undefined); - std::vector rst_connections; + std::vector connections; + std::unordered_map segments; for (const auto& rst_conn : rst_well.connections) - rst_connections.emplace_back(rst_conn, grid, fp); + connections.emplace_back(rst_conn, grid, fp); - if (rst_well.segments.empty()) { - Opm::WellConnections connections(order_from_int(rst_well.completion_ordering), - rst_well.ij[0], - rst_well.ij[1], - rst_connections); - well.updateConnections( std::make_shared( std::move(connections) ), grid, fp.get_int("PVTNUM")); - } else { - std::unordered_map rst_segments; - for (const auto& rst_segment : rst_well.segments) { - Opm::Segment segment(rst_segment); - rst_segments.insert(std::make_pair(rst_segment.segment, std::move(segment))); + for (const auto& rst_segment : rst_well.segments) { + Opm::Segment segment(rst_segment); + segments.insert(std::make_pair(rst_segment.segment, std::move(segment))); + } + + for (auto& connection : connections) { + int segment_id = connection.segment(); + if (segment_id > 0) { + const auto& segment = segments.at(segment_id); + connection.updateSegmentRST(segment.segmentNumber(), + segment.depth()); } + } - auto [connections, segments] = Compsegs::rstUpdate(rst_well, rst_connections, rst_segments); - well.updateConnections( std::make_shared(std::move(connections)), grid, fp.get_int("PVTNUM")); - well.updateSegments( std::make_shared(std::move(segments) )); + { + std::shared_ptr well_connections = std::make_shared(order_from_int(rst_well.completion_ordering), rst_well.ij[0], rst_well.ij[1], connections); + well.updateConnections( std::move(well_connections), grid, fp.get_int("PVTNUM") ); + } + + if (!segments.empty()) { + std::vector segments_list; + /* + The ordering of the segments in the WellSegments structure seems a + bit random; in some parts of the code the segment_number seems to + be treated like a random integer ID, whereas in other parts it + seems to be treated like a running index. Here the segments in + WellSegments are sorted according to the segment number - observe + that this is somewhat important because the first top segment is + treated differently from the other segment. + */ + for (const auto& segment_pair : segments) + segments_list.push_back( std::move(segment_pair.second) ); + + std::sort( segments_list.begin(), segments_list.end(),[](const Segment& seg1, const Segment& seg2) { return seg1.segmentNumber() < seg2.segmentNumber(); } ); + auto comp_pressure_drop = WellSegments::CompPressureDrop::HFA; + std::shared_ptr well_segments = std::make_shared(comp_pressure_drop, segments_list); + well.updateSegments( std::move(well_segments) ); } this->addWell(well, report_step); @@ -3153,161 +3121,6 @@ std::shared_ptr Schedule::python() const return this->python_handle; } - -void Schedule::updateNetwork(std::shared_ptr network, std::size_t report_step) { - this->m_network.update(report_step, std::move(network)); -} - -const Network::ExtNetwork& Schedule::network(std::size_t report_step) const { - return *this->m_network[report_step]; -} - - -void Schedule::handleNODEPROP(const DeckKeyword& keyword, std::size_t report_step) { - using NP = ParserKeywords::NODEPROP; - auto ext_network = std::make_shared( this->network(report_step) ); - for (const auto& record : keyword) { - const auto& name = record.getItem().get(0); - const auto& pressure_item = record.getItem(); - bool as_choke = DeckItem::to_bool( record.getItem().get(0)); - bool add_gas_lift_gas = DeckItem::to_bool( record.getItem().get(0)); - Network::Node node{ name }; - - if (pressure_item.hasValue(0) && (pressure_item.get(0) > 0)) - node.terminal_pressure( pressure_item.getSIDouble(0) ); - - if (as_choke) { - std::string target_group = name; - const auto& target_item = record.getItem(); - if (target_item.hasValue(0)) - target_group = target_item.get(0); - - if (target_group != name) { - if (this->hasGroup(name, report_step)) { - const auto& group = this->getGroup(name, report_step); - if (group.numWells() > 0) - throw std::invalid_argument("A manifold group must respond to its own target"); - } - } - node.as_choke( target_group ); - } - node.add_gas_lift_gas( add_gas_lift_gas ); - ext_network->add_node( node ); - } - this->updateNetwork(ext_network, report_step); -} - -const GasLiftOpt& Schedule::glo(std::size_t report_step) const { - return *this->m_glo[report_step]; -} - -void Schedule::handleLIFTOPT(const DeckKeyword& keyword, std::size_t report_step) { - using LO = ParserKeywords::LIFTOPT; - auto glo = std::make_shared( this->glo(report_step) ); - const auto& record = keyword.getRecord(0); - double gaslift_increment = record.getItem().getSIDouble(0); - double min_eco_gradient = record.getItem().getSIDouble(0); - double min_wait = record.getItem().getSIDouble(0); - bool all_newton = DeckItem::to_bool( record.getItem().get(0) ); - - glo->gaslift_increment(gaslift_increment); - glo->min_eco_gradient(min_eco_gradient); - glo->min_wait(min_wait); - glo->all_newton(all_newton); - - this->m_glo.update(report_step, std::move(glo)); -} - - -void Schedule::handleGLIFTOPT(const DeckKeyword& keyword, std::size_t report_step, const ParseContext& parseContext, ErrorGuard& errors) { - using GLO = ParserKeywords::GLIFTOPT; - auto glo = std::make_shared( this->glo(report_step) ); - for (const auto& record : keyword) { - const std::string& groupNamePattern = record.getItem().getTrimmedString(0); - const auto group_names = this->groupNames(groupNamePattern); - if (group_names.empty()) - invalidNamePattern(groupNamePattern, report_step, parseContext, errors, keyword); - - const auto& max_total_item = record.getItem(); - const auto& max_gas_item = record.getItem(); - double max_lift_gas_value = -1; - double max_total_gas_value = -1; - - if (max_gas_item.hasValue(0)) - max_lift_gas_value = max_gas_item.getSIDouble(0); - - if (max_total_item.hasValue(0)) - max_total_gas_value = max_total_item.getSIDouble(0); - - for (const auto& gname : group_names) { - auto group = GasLiftOpt::Group(gname); - group.max_lift_gas(max_lift_gas_value); - group.max_total_gas(max_total_gas_value); - - glo->add_group(group); - } - } - this->m_glo.update(report_step, std::move(glo)); -} - -void Schedule::handleWLIFTOPT(const DeckKeyword& keyword, std::size_t report_step, const ParseContext& parseContext, ErrorGuard& errors) { - using WLO = ParserKeywords::WLIFTOPT; - auto glo = std::make_shared( this->glo(report_step) ); - - for (const auto& record : keyword) { - const std::string& wellNamePattern = record.getItem().getTrimmedString(0); - bool use_glo = DeckItem::to_bool( record.getItem().get(0)); - bool alloc_extra_gas = DeckItem::to_bool( record.getItem().get(0)); - double weight_factor = record.getItem().get(0); - double inc_weight_factor = record.getItem().get(0); - double min_rate = record.getItem().getSIDouble(0); - const auto& max_rate_item = record.getItem(); - - const auto well_names = this->wellNames(wellNamePattern); - if (well_names.empty()) - invalidNamePattern(wellNamePattern, report_step, parseContext, errors, keyword); - - for (const auto& wname : well_names) { - auto well = GasLiftOpt::Well(wname, use_glo); - - if (max_rate_item.hasValue(0)) - well.max_rate( max_rate_item.getSIDouble(0) ); - - well.weight_factor(weight_factor); - well.inc_weight_factor(inc_weight_factor); - well.min_rate(min_rate); - well.alloc_extra_gas(alloc_extra_gas); - - glo->add_well(well); - } - } - - this->m_glo.update(report_step, std::move(glo)); -} - -void Schedule::handleBRANPROP(const DeckKeyword& keyword, std::size_t report_step) { - using BP = ParserKeywords::BRANPROP; - auto ext_network = std::make_shared( this->network(report_step) ); - for (const auto& record : keyword) { - const auto& downtree_node = record.getItem().get(0); - const auto& uptree_node = record.getItem().get(0); - int vfp_table = record.getItem().get(0); - if (vfp_table == 0) - ext_network->drop_branch( uptree_node, downtree_node ); - else { - auto alq_eq = Network::Branch::AlqEqfromString( record.getItem().get(0)); - if (alq_eq == Network::Branch::AlqEQ::ALQ_INPUT) { - double alq_value = record.getItem().get(0); - ext_network->add_branch( Network::Branch(downtree_node, uptree_node, vfp_table, alq_value)); - } else - ext_network->add_branch( Network::Branch(downtree_node, uptree_node, vfp_table, alq_eq)); - } - } - this->updateNetwork(ext_network, report_step); -} - - - namespace { /* The insane trickery here (thank you Stackoverflow!) is to be able to provide a diff --git a/ThirdParty/custom-opm-common/opm-common/src/opm/parser/eclipse/EclipseState/Schedule/SummaryState.cpp b/ThirdParty/custom-opm-common/opm-common/src/opm/parser/eclipse/EclipseState/Schedule/SummaryState.cpp index aa4bfb05c4..7d0ca885ba 100644 --- a/ThirdParty/custom-opm-common/opm-common/src/opm/parser/eclipse/EclipseState/Schedule/SummaryState.cpp +++ b/ThirdParty/custom-opm-common/opm-common/src/opm/parser/eclipse/EclipseState/Schedule/SummaryState.cpp @@ -27,7 +27,6 @@ #include "cross-platform/windows/Substitutes.hpp" #endif -#include #include namespace Opm{ @@ -37,7 +36,7 @@ namespace { static const std::vector totals = {"OPT" , "GPT" , "WPT" , "GIT", "WIT", "OPTF" , "OPTS" , "OIT" , "OVPT" , "OVIT" , "MWT" , "WVPT" , "WVIT" , "GMT" , "GPTF" , "SGT" , "GST" , "FGT" , "GCT" , "GIMT" , "WGPT" , "WGIT" , "EGT" , "EXGT" , "GVPT" , "GVIT" , "LPT" , "VPT" , "VIT" , "NPT" , "NIT", - "CPT", "CIT", "SPT", "SIT"}; + "CPT", "CIT"}; auto sep_pos = key.find(':'); @@ -56,42 +55,8 @@ namespace { return is_total(key.substr(0,sep_pos)); } - - using map2 = std::unordered_map>; - - bool has_var(const map2& values, const std::string& var1, const std::string var2) { - const auto& var1_iter = values.find(var1); - if (var1_iter == values.end()) - return false; - - const auto& var2_iter = var1_iter->second.find(var2); - if (var2_iter == var1_iter->second.end()) - return false; - - return true; - } - - bool erase_var(map2& values, const std::string& var1, const std::string var2) { - const auto& var1_iter = values.find(var1); - if (var1_iter == values.end()) - return false; - - return (var1_iter->second.erase(var2) > 0); - } - - std::vector var2_list(const map2& values, const std::string& var1) { - const auto& var1_iter = values.find(var1); - if (var1_iter == values.end()) - return {}; - - std::vector l; - for (const auto& pair : var1_iter->second) - l.push_back(pair.first); - return l; - } } - SummaryState::SummaryState(std::chrono::system_clock::time_point sim_start_arg): sim_start(sim_start_arg) { @@ -136,10 +101,7 @@ namespace { this->values[key] = value; this->group_values[var][group] = value; } - if (this->m_groups.count(group) == 0) { - this->m_groups.insert(group); - this->group_names.reset(); - } + this->m_groups.insert(group); } void SummaryState::update_well_var(const std::string& well, const std::string& var, double value) { @@ -151,37 +113,7 @@ namespace { this->values[key] = value; this->well_values[var][well] = value; } - if (this->m_wells.count(well) == 0) { - this->m_wells.insert(well); - this->well_names.reset(); - } - } - - void SummaryState::update_udq(const UDQSet& udq_set) { - auto var_type = udq_set.var_type(); - if (var_type == UDQVarType::WELL_VAR) { - const std::vector wells = this->wells(); - for (const auto& well : wells) { - const auto& udq_value = udq_set[well]; - if (udq_value) - this->update_well_var(well, udq_set.name(), udq_value.value()); - else - this->erase_well_var(well, udq_set.name()); - } - } else if (var_type == UDQVarType::GROUP_VAR) { - const std::vector groups = this->groups(); - for (const auto& group : groups) { - const auto& udq_value = udq_set[group]; - if (udq_value) - this->update_group_var(group, udq_set.name(), udq_value.value()); - else - this->erase_group_var(group, udq_set.name()); - } - } else { - const auto& udq_var = udq_set[0]; - if (udq_var) - this->update(udq_set.name(), udq_var.value()); - } + this->m_wells.insert(well); } @@ -189,41 +121,11 @@ namespace { this->values[key] = value; } - bool SummaryState::erase(const std::string& key) { - return (this->values.erase(key) > 0); - } - - bool SummaryState::erase_well_var(const std::string& well, const std::string& var) { - std::string key = var + ":" + well; - if (!this->erase(key)) - return false; - - erase_var(this->well_values, var, well); - this->well_names.reset(); - return true; - } - - bool SummaryState::erase_group_var(const std::string& group, const std::string& var) { - std::string key = var + ":" + group; - if (!this->erase(key)) - return false; - - erase_var(this->group_values, var, group); - this->group_names.reset(); - return true; - } bool SummaryState::has(const std::string& key) const { return (this->values.find(key) != this->values.end()); } - double SummaryState::get(const std::string& key, double default_value) const { - const auto iter = this->values.find(key); - if (iter == this->values.end()) - return default_value; - - return iter->second; - } double SummaryState::get(const std::string& key) const { const auto iter = this->values.find(key); @@ -234,35 +136,37 @@ namespace { } bool SummaryState::has_well_var(const std::string& well, const std::string& var) const { - return has_var(this->well_values, var, well); + const auto& var_iter = this->well_values.find(var); + if (var_iter == this->well_values.end()) + return false; + + const auto& well_iter = var_iter->second.find(well); + if (well_iter == var_iter->second.end()) + return false; + + return true; } double SummaryState::get_well_var(const std::string& well, const std::string& var) const { return this->well_values.at(var).at(well); } - double SummaryState::get_well_var(const std::string& well, const std::string& var, double default_value) const { - if (this->has_well_var(well, var)) - return this->get_well_var(well, var); - - return default_value; - } - bool SummaryState::has_group_var(const std::string& group, const std::string& var) const { - return has_var(this->group_values, var, group); + const auto& var_iter = this->group_values.find(var); + if (var_iter == this->group_values.end()) + return false; + + const auto& group_iter = var_iter->second.find(group); + if (group_iter == var_iter->second.end()) + return false; + + return true; } double SummaryState::get_group_var(const std::string& group, const std::string& var) const { return this->group_values.at(var).at(group); } - double SummaryState::get_group_var(const std::string& group, const std::string& var, double default_value) const { - if (this->has_group_var(group, var)) - return this->get_group_var(group, var); - - return default_value; - } - SummaryState::const_iterator SummaryState::begin() const { return this->values.begin(); } @@ -274,28 +178,36 @@ namespace { std::vector SummaryState::wells(const std::string& var) const { - return var2_list(this->well_values, var); + const auto& var_iter = this->well_values.find(var); + if (var_iter == this->well_values.end()) + return {}; + + std::vector wells; + for (const auto& pair : var_iter->second) + wells.push_back(pair.first); + return wells; } - const std::vector& SummaryState::wells() const { - if (!this->well_names) - this->well_names = std::vector(this->m_wells.begin(), this->m_wells.end()); - - return *this->well_names; + std::vector SummaryState::wells() const { + return std::vector(this->m_wells.begin(), this->m_wells.end()); } std::vector SummaryState::groups(const std::string& var) const { - return var2_list(this->group_values, var); + const auto& var_iter = this->group_values.find(var); + if (var_iter == this->group_values.end()) + return {}; + + std::vector groups; + for (const auto& pair : var_iter->second) + groups.push_back(pair.first); + return groups; } - const std::vector& SummaryState::groups() const { - if (!this->group_names) - this->group_names = std::vector(this->m_groups.begin(), this->m_groups.end()); - - return *this->group_names; + std::vector SummaryState::groups() const { + return std::vector(this->m_groups.begin(), this->m_groups.end()); } std::size_t SummaryState::num_wells() const { diff --git a/ThirdParty/custom-opm-common/opm-common/src/opm/parser/eclipse/EclipseState/Schedule/UDQ/UDQActive.cpp b/ThirdParty/custom-opm-common/opm-common/src/opm/parser/eclipse/EclipseState/Schedule/UDQ/UDQActive.cpp index 9313293d0d..d2649d6c99 100644 --- a/ThirdParty/custom-opm-common/opm-common/src/opm/parser/eclipse/EclipseState/Schedule/UDQ/UDQActive.cpp +++ b/ThirdParty/custom-opm-common/opm-common/src/opm/parser/eclipse/EclipseState/Schedule/UDQ/UDQActive.cpp @@ -50,11 +50,6 @@ UDQActive::operator bool() const { return this->input_data.size() > 0; } - -std::string UDQActive::Record::wg_name() const { - return this->wgname; -} - std::string UDQActive::udq_hash(const std::string& udq, UDAControl control) { return udq + std::to_string(static_cast(control)); } diff --git a/ThirdParty/custom-opm-common/opm-common/src/opm/parser/eclipse/EclipseState/Schedule/UDQ/UDQConfig.cpp b/ThirdParty/custom-opm-common/opm-common/src/opm/parser/eclipse/EclipseState/Schedule/UDQ/UDQConfig.cpp index 2db07f88d8..56d1ac7a98 100644 --- a/ThirdParty/custom-opm-common/opm-common/src/opm/parser/eclipse/EclipseState/Schedule/UDQ/UDQConfig.cpp +++ b/ThirdParty/custom-opm-common/opm-common/src/opm/parser/eclipse/EclipseState/Schedule/UDQ/UDQConfig.cpp @@ -18,7 +18,6 @@ */ #include -#include #include #include #include @@ -289,34 +288,6 @@ namespace Opm { this->type_count == data.type_count; } - void UDQConfig::eval(SummaryState& st) const { - const auto& func_table = this->function_table(); - UDQContext context(func_table, st); - for (const auto& assign : this->assignments(UDQVarType::WELL_VAR)) { - auto ws = assign.eval(st.wells()); - st.update_udq(ws); - } - - for (const auto& def : this->definitions(UDQVarType::WELL_VAR)) { - auto ws = def.eval(context); - st.update_udq(ws); - } - - for (const auto& assign : this->assignments(UDQVarType::GROUP_VAR)) { - auto ws = assign.eval(st.groups()); - st.update_udq(ws); - } - - for (const auto& def : this->definitions(UDQVarType::GROUP_VAR)) { - auto ws = def.eval(context); - st.update_udq(ws); - } - - for (const auto& def : this->definitions(UDQVarType::FIELD_VAR)) { - auto field_udq = def.eval(context); - st.update_udq(field_udq); - } - } } diff --git a/ThirdParty/custom-opm-common/opm-common/src/opm/parser/eclipse/EclipseState/Schedule/UDQ/UDQDefine.cpp b/ThirdParty/custom-opm-common/opm-common/src/opm/parser/eclipse/EclipseState/Schedule/UDQ/UDQDefine.cpp index 26f1b6180d..2d5b1454db 100644 --- a/ThirdParty/custom-opm-common/opm-common/src/opm/parser/eclipse/EclipseState/Schedule/UDQ/UDQDefine.cpp +++ b/ThirdParty/custom-opm-common/opm-common/src/opm/parser/eclipse/EclipseState/Schedule/UDQ/UDQDefine.cpp @@ -18,7 +18,7 @@ */ #include #include -#include + #ifdef _WIN32 #include @@ -47,8 +47,7 @@ std::vector quote_split(const std::string& item) { while (true) { auto quote_pos1 = item.find(quote_char, offset); if (quote_pos1 == std::string::npos) { - if (offset < item.size()) - items.push_back(item.substr(offset)); + items.push_back(item.substr(offset)); break; } @@ -86,37 +85,6 @@ UDQDefine::UDQDefine(const UDQParams& udq_params_arg, UDQDefine(udq_params_arg, keyword, deck_data, ParseContext(), ErrorGuard()) {} -namespace { -std::optional next_token(const std::string& item, std::size_t offset, const std::vector& splitters) { - if (offset == item.size()) - return {}; - - if (std::isdigit(item[offset])) { - std::size_t token_size = 0; - try { - auto substring = item.substr(offset); - std::ignore = std::stod(substring, &token_size); - } catch (const std::invalid_argument &) {} - - if (token_size > 0) - return item.substr(offset, token_size); - } - - std::optional token = item.substr(offset); - std::size_t min_pos = std::string::npos; - for (const auto& splitter : splitters) { - auto pos = item.find(splitter, offset); - if (pos < min_pos) { - min_pos = pos; - if (pos == offset) - token = splitter; - else - token = item.substr(offset, pos - offset); - } - } - return token; -} -} // Anonymous namespace UDQDefine::UDQDefine(const UDQParams& udq_params, const std::string& keyword, @@ -136,26 +104,32 @@ UDQDefine::UDQDefine(const UDQParams& udq_params, const std::vector splitters = {"TU*[]", "(", ")", "[", "]", ",", "+", "-", "/", "*", "==", "!=", "^", ">=", "<=", ">", "<"}; size_t offset = 0; - while (true) { - auto token = next_token(item, offset, splitters); - if (token) { - tokens.push_back( *token ); - offset += token->size(); - } else - break; + size_t pos = 0; + while (pos < item.size()) { + size_t splitter_index = 0; + while (splitter_index < splitters.size()) { + const std::string& splitter = splitters[splitter_index]; + size_t find_pos = item.find(splitter, pos); + if (find_pos == pos) { + if (pos > offset) + tokens.push_back(item.substr(offset, pos - offset)); + tokens.push_back(splitter); + pos = find_pos + 1; + offset = pos; + break; + } + splitter_index++; + } + if (splitter_index == splitters.size()) + pos += 1; } + if (pos > offset) + tokens.push_back(item.substr(offset, pos - offset)); + } } - /* - This is hysterical special casing; the parser does not correctly handle a - leading '-' to change sign; we just hack it up by adding a fictious '0' - token in front. - */ - if (tokens[0] == "-") - tokens.insert( tokens.begin(), "0" ); - - this->ast = std::make_shared( UDQParser::parse(udq_params, this->m_var_type, this->m_keyword, tokens, parseContext, errors) ); + this->string_data = ""; for (std::size_t index = 0; index < deck_data.size(); index++) { this->string_data += deck_data[index]; @@ -254,7 +228,6 @@ UDQSet UDQDefine::eval(const UDQContext& context) const { } } - res.name( this->m_keyword ); return res; } diff --git a/ThirdParty/custom-opm-common/opm-common/src/opm/parser/eclipse/EclipseState/Schedule/UDQ/UDQParser.cpp b/ThirdParty/custom-opm-common/opm-common/src/opm/parser/eclipse/EclipseState/Schedule/UDQ/UDQParser.cpp index 9e4854ecc2..80ef72eece 100644 --- a/ThirdParty/custom-opm-common/opm-common/src/opm/parser/eclipse/EclipseState/Schedule/UDQ/UDQParser.cpp +++ b/ThirdParty/custom-opm-common/opm-common/src/opm/parser/eclipse/EclipseState/Schedule/UDQ/UDQParser.cpp @@ -293,7 +293,7 @@ UDQASTNode UDQParser::parse(const UDQParams& udq_params, UDQVarType target_type, if (!parser.empty()) { size_t index = parser.current_pos; auto current = parser.current(); - std::string msg = "Extra unhandled data starting with token[" + std::to_string(index) + "] = '" + current.value + "'"; + std::string msg = "Extra unhandled data starting with token[" + std::to_string(index) + "] = " + current.value; parseContext.handleError(ParseContext::UDQ_PARSE_ERROR, msg, errors); return UDQASTNode( udq_params.undefinedValue() ); } diff --git a/ThirdParty/custom-opm-common/opm-common/src/opm/parser/eclipse/EclipseState/Schedule/UDQ/UDQSet.cpp b/ThirdParty/custom-opm-common/opm-common/src/opm/parser/eclipse/EclipseState/Schedule/UDQ/UDQSet.cpp index 0728c1307e..df018362bc 100644 --- a/ThirdParty/custom-opm-common/opm-common/src/opm/parser/eclipse/EclipseState/Schedule/UDQ/UDQSet.cpp +++ b/ThirdParty/custom-opm-common/opm-common/src/opm/parser/eclipse/EclipseState/Schedule/UDQ/UDQSet.cpp @@ -23,16 +23,15 @@ #endif #include -#include #include namespace Opm { -UDQScalar::UDQScalar(double value) -{ - this->assign(value); -} +UDQScalar::UDQScalar(double value) : + m_value(value), + m_defined(true) +{} UDQScalar::UDQScalar(const std::string& wgname) : m_wgname(wgname) @@ -44,7 +43,7 @@ bool UDQScalar::defined() const { double UDQScalar::value() const { if (!this->m_defined) - throw std::invalid_argument("UDQSCalar: Value not defined wgname: " + this->m_wgname); + throw std::invalid_argument("UDQSCalar: Value not defined"); return this->m_value; } @@ -55,55 +54,55 @@ const std::string& UDQScalar::wgname() const { void UDQScalar::assign(double value) { this->m_value = value; - this->m_defined = std::isfinite(value); + this->m_defined = true; } void UDQScalar::operator-=(const UDQScalar& rhs) { if (this->m_defined && rhs.m_defined) - this->assign(this->m_value - rhs.m_value); + this->m_value -= rhs.m_value; else this->m_defined = false; } void UDQScalar::operator-=(double rhs) { if (this->m_defined) - this->assign(this->m_value - rhs); + this->m_value -= rhs; } void UDQScalar::operator/=(const UDQScalar& rhs) { if (this->m_defined && rhs.m_defined) - this->assign(this->m_value / rhs.m_value); + this->m_value /= rhs.m_value; else this->m_defined = false; } void UDQScalar::operator/=(double rhs) { if (this->m_defined) - this->assign(this->m_value / rhs); + this->m_value /= rhs; } void UDQScalar::operator+=(const UDQScalar& rhs) { if (this->m_defined && rhs.m_defined) - this->assign(this->m_value + rhs.m_value); + this->m_value += rhs.m_value; else this->m_defined = false; } void UDQScalar::operator+=(double rhs) { if (this->m_defined) - this->assign(this->m_value + rhs); + this->m_value += rhs; } void UDQScalar::operator*=(const UDQScalar& rhs) { if (this->m_defined && rhs.m_defined) - this->assign(this->m_value * rhs.m_value); + this->m_value *= rhs.m_value; else this->m_defined = false; } void UDQScalar::operator*=(double rhs) { if (this->m_defined) - this->assign(this->m_value * rhs); + this->m_value *= rhs; } @@ -116,10 +115,6 @@ const std::string& UDQSet::name() const { return this->m_name; } -void UDQSet::name(const std::string& name) { - this->m_name = name; -} - UDQSet::UDQSet(const std::string& name, UDQVarType var_type, const std::vector& wgnames) : m_name(name), m_var_type(var_type) diff --git a/ThirdParty/custom-opm-common/opm-common/src/opm/parser/eclipse/EclipseState/Schedule/Well/Connection.cpp b/ThirdParty/custom-opm-common/opm-common/src/opm/parser/eclipse/EclipseState/Schedule/Well/Connection.cpp index 737d53af0b..3eecb18d11 100644 --- a/ThirdParty/custom-opm-common/opm-common/src/opm/parser/eclipse/EclipseState/Schedule/Well/Connection.cpp +++ b/ThirdParty/custom-opm-common/opm-common/src/opm/parser/eclipse/EclipseState/Schedule/Well/Connection.cpp @@ -53,8 +53,10 @@ namespace Opm { const int satTableId, const Direction directionArg, const CTFKind ctf_kind, - const std::size_t sort_value, - const bool defaultSatTabId) + const std::size_t sort_value, + const double segDistStart, + const double segDistEnd, + const bool defaultSatTabId) : direction(directionArg), center_depth(depth), open_state(stateArg), @@ -69,6 +71,8 @@ namespace Opm { m_ctfkind(ctf_kind), m_global_index(global_index), m_sort_value(sort_value), + m_segDistStart(segDistStart), + m_segDistEnd(segDistEnd), m_defaultSatTabId(defaultSatTabId) { } @@ -92,6 +96,8 @@ Connection::Connection(const RestartIO::RstConnection& rst_connection, const Ecl m_ctfkind(rst_connection.cf_kind), m_global_index(grid.getGlobalIndex(this->ijk[0], this->ijk[1], this->ijk[2])), m_sort_value(rst_connection.rst_index), + m_segDistStart(rst_connection.segdist_start), + m_segDistEnd(rst_connection.segdist_end), m_defaultSatTabId(defaultSatTabId), segment_number(rst_connection.segment) { @@ -100,13 +106,12 @@ Connection::Connection(const RestartIO::RstConnection& rst_connection, const Ecl auto active_index = grid.activeIndex(this->ijk[0], this->ijk[1], this->ijk[2]); this->sat_tableId = satnum[active_index]; } - if (this->segment_number > 0) - this->m_perf_range = std::make_pair(rst_connection.segdist_start, rst_connection.segdist_end); + } Connection::Connection() : Connection(0, 0, 0, 0, 0, 0.0, State::SHUT, 0.0, 0.0, 0.0, 0.0, 0.0, - 0, Direction::X, CTFKind::DeckValue, 0, false) + 0, Direction::X, CTFKind::DeckValue, 0, 0.0, 0.0, false) {} Connection Connection::serializeObject() @@ -125,8 +130,8 @@ Connection::Connection(const RestartIO::RstConnection& rst_connection, const Ecl result.ijk = {9, 10, 11}; result.m_ctfkind = CTFKind::Defaulted; result.m_global_index = 12; - result.m_perf_range = std::make_pair(14,15); result.m_sort_value = 14; + result.m_segDistEnd = 15.0; result.m_defaultSatTabId = true; result.segment_number = 16; @@ -173,10 +178,15 @@ Connection::Connection(const RestartIO::RstConnection& rst_connection, const Ecl return this->direction; } -const std::optional>& Connection::perf_range() const { - return this->m_perf_range; + const double& Connection::getSegDistStart() const { + return m_segDistStart; } + const double& Connection::getSegDistEnd() const { + return m_segDistEnd; + } + + void Connection::setDefaultSatTabId(bool id) { m_defaultSatTabId = id; } @@ -228,11 +238,13 @@ const std::optional>& Connection::perf_range() const { void Connection::updateSegment(int segment_number_arg, double center_depth_arg, std::size_t compseg_insert_index, - const std::pair& perf_range) { + double start, + double end) { this->segment_number = segment_number_arg; this->center_depth = center_depth_arg; this->m_sort_value = compseg_insert_index; - this->m_perf_range = perf_range; + this->m_segDistStart = start; + this->m_segDistEnd = end; } void Connection::updateSegmentRST(int segment_number_arg, diff --git a/ThirdParty/custom-opm-common/opm-common/src/opm/parser/eclipse/EclipseState/Schedule/Well/WListManager.cpp b/ThirdParty/custom-opm-common/opm-common/src/opm/parser/eclipse/EclipseState/Schedule/Well/WListManager.cpp index b26806967f..d7b487d6bf 100644 --- a/ThirdParty/custom-opm-common/opm-common/src/opm/parser/eclipse/EclipseState/Schedule/Well/WListManager.cpp +++ b/ThirdParty/custom-opm-common/opm-common/src/opm/parser/eclipse/EclipseState/Schedule/Well/WListManager.cpp @@ -22,10 +22,9 @@ #include #endif -#include - #include #include + namespace Opm { WListManager WListManager::serializeObject() @@ -67,21 +66,4 @@ namespace Opm { return this->wlists == data.wlists; } - std::vector WListManager::wells(const std::string& wlist_pattern) const { - if (this->hasList(wlist_pattern)) { - const auto& wlist = this->getList(wlist_pattern); - return { wlist.begin(), wlist.end() }; - } else { - std::unordered_set well_set; - auto pattern = wlist_pattern.substr(1); - for (const auto& [name, wlist] : this->wlists) { - auto wlist_name = name.substr(1); - int flags = 0; - if (fnmatch(pattern.c_str(), wlist_name.c_str(), flags) == 0) - well_set.insert(wlist.begin(), wlist.end()); - } - return { well_set.begin(), well_set.end() }; - } - } - } diff --git a/ThirdParty/custom-opm-common/opm-common/src/opm/parser/eclipse/EclipseState/Schedule/Well/Well.cpp b/ThirdParty/custom-opm-common/opm-common/src/opm/parser/eclipse/EclipseState/Schedule/Well/Well.cpp index 305756628d..92c44fd7fc 100644 --- a/ThirdParty/custom-opm-common/opm-common/src/opm/parser/eclipse/EclipseState/Schedule/Well/Well.cpp +++ b/ThirdParty/custom-opm-common/opm-common/src/opm/parser/eclipse/EclipseState/Schedule/Well/Well.cpp @@ -22,13 +22,11 @@ #include #include #include +#include #include #include #include #include -#include - -#include "../MSW/Compsegs.hpp" #ifdef _WIN32 #include "cross-platform/windows/Substitutes.hpp" @@ -624,6 +622,9 @@ bool Well::updateConnections(std::shared_ptr connections_arg) { connections_arg->order( ); if (*this->connections != *connections_arg) { this->connections = connections_arg; + //if (this->connections->allConnectionsShut()) {} + // This status update breaks line 825 in ScheduleTests + //this->status = WellCommon::StatusEnum::SHUT; return true; } @@ -653,12 +654,9 @@ bool Well::updateSolventFraction(double solvent_fraction_arg) { bool Well::handleCOMPSEGS(const DeckKeyword& keyword, const EclipseGrid& grid, const ParseContext& parseContext, ErrorGuard& errors) { - auto [new_connections, new_segments] = Compsegs::processCOMPSEGS(keyword, *this->connections, *this->segments , grid, - parseContext, errors); - - this->updateConnections( std::make_shared(std::move(new_connections)) ); - this->updateSegments( std::make_shared( std::move(new_segments)) ); - return true; + std::shared_ptr new_connection_set( newConnectionsWithSegments(keyword, *this->connections, *this->segments , grid, + parseContext, errors) ); + return this->updateConnections(std::move(new_connection_set)); } const std::string& Well::groupName() const { @@ -967,7 +965,7 @@ bool Well::updatePVTTable(int pvt_table_) { } -bool Well::updateWSEGSICD(const std::vector >& sicd_pairs) { +bool Well::updateWSEGSICD(const std::vector >& sicd_pairs) { auto new_segments = std::make_shared(*this->segments); if (new_segments->updateWSEGSICD(sicd_pairs)) { this->segments = new_segments; diff --git a/ThirdParty/custom-opm-common/opm-common/src/opm/parser/eclipse/EclipseState/Schedule/Well/WellConnections.cpp b/ThirdParty/custom-opm-common/opm-common/src/opm/parser/eclipse/EclipseState/Schedule/Well/WellConnections.cpp index c721b43c95..433e416dc3 100644 --- a/ThirdParty/custom-opm-common/opm-common/src/opm/parser/eclipse/EclipseState/Schedule/Well/WellConnections.cpp +++ b/ThirdParty/custom-opm-common/opm-common/src/opm/parser/eclipse/EclipseState/Schedule/Well/WellConnections.cpp @@ -196,13 +196,15 @@ inline std::array< size_t, 3> directionIndices(const Opm::Connection::Direction const Connection::Direction direction, const Connection::CTFKind ctf_kind, const std::size_t seqIndex, + const double segDistStart, + const double segDistEnd, const bool defaultSatTabId) { int conn_i = (i < 0) ? this->headI : i; int conn_j = (j < 0) ? this->headJ : j; Connection conn(conn_i, conn_j, k, global_index, complnum, depth, state, CF, Kh, rw, r0, skin_factor, satTableId, direction, ctf_kind, - seqIndex, defaultSatTabId); + seqIndex, segDistStart, segDistEnd, defaultSatTabId); this->add(conn); } @@ -221,6 +223,8 @@ inline std::array< size_t, 3> directionIndices(const Opm::Connection::Direction const Connection::Direction direction, const Connection::CTFKind ctf_kind, const std::size_t seqIndex, + const double segDistStart, + const double segDistEnd, const bool defaultSatTabId) { int complnum = (this->m_connections.size() + 1); @@ -240,6 +244,8 @@ inline std::array< size_t, 3> directionIndices(const Opm::Connection::Direction direction, ctf_kind, seqIndex, + segDistStart, + segDistEnd, defaultSatTabId); } @@ -379,14 +385,13 @@ inline std::array< size_t, 3> directionIndices(const Opm::Connection::Direction r0, skin_factor, satTableId, - direction, - ctf_kind, - noConn, - defaultSatTable); + direction, ctf_kind, + noConn, 0., 0., defaultSatTable); } else { std::size_t css_ind = prev->sort_value(); int conSegNo = prev->segment(); - const auto& perf_range = prev->perf_range(); + double conSDStart = prev->getSegDistStart(); + double conSDEnd = prev->getSegDistEnd(); double depth = grid.getCellDepth(I,J,k); *prev = Connection(I,J,k, grid.getGlobalIndex(I,J,k), @@ -399,15 +404,14 @@ inline std::array< size_t, 3> directionIndices(const Opm::Connection::Direction r0, skin_factor, satTableId, - direction, - ctf_kind, - prev->sort_value(), - defaultSatTable); + direction, ctf_kind, + prev->sort_value(), conSDStart, conSDEnd, defaultSatTable); prev->updateSegment(conSegNo, depth, css_ind, - *perf_range); + conSDStart, + conSDEnd); } } } @@ -572,17 +576,4 @@ inline std::array< size_t, 3> directionIndices(const Opm::Connection::Direction m_connections.erase(new_end, m_connections.end()); } - - double WellConnections::segment_perf_length(int segment) const { - double perf_length = 0; - for (const auto& conn : this->m_connections) { - if (conn.segment() == segment) { - const auto& [start, end] = *conn.perf_range(); - perf_length += end - start; - } - } - return perf_length; - } - - } diff --git a/ThirdParty/custom-opm-common/opm-common/src/opm/parser/eclipse/EclipseState/Schedule/Well/WellInjectionProperties.cpp b/ThirdParty/custom-opm-common/opm-common/src/opm/parser/eclipse/EclipseState/Schedule/Well/WellInjectionProperties.cpp index a43c7835ab..847f4fdca2 100644 --- a/ThirdParty/custom-opm-common/opm-common/src/opm/parser/eclipse/EclipseState/Schedule/Well/WellInjectionProperties.cpp +++ b/ThirdParty/custom-opm-common/opm-common/src/opm/parser/eclipse/EclipseState/Schedule/Well/WellInjectionProperties.cpp @@ -134,39 +134,52 @@ namespace Opm { - void Well::WellInjectionProperties::handleWELTARG(WELTARGCMode cmode, const UDAValue& new_arg, double SiFactorP) { + void Well::WellInjectionProperties::handleWELTARG(WELTARGCMode cmode, double newValue, double SiFactorP) { if (cmode == Well::WELTARGCMode::BHP){ if (this->predictionMode) { - this->BHPTarget.update_value( new_arg ); + this->BHPTarget.assert_numeric("Can not combine UDA and WELTARG"); + this->BHPTarget = newValue; } else - this->bhp_hist_limit = new_arg.get() * SiFactorP; + this->bhp_hist_limit = newValue * SiFactorP; } else if (cmode == WELTARGCMode::ORAT){ - if (this->injectorType == InjectorType::OIL) - this->surfaceInjectionRate.update_value( new_arg ); - else + if(this->injectorType == InjectorType::OIL){ + this->surfaceInjectionRate.assert_numeric("Can not combine UDA and WELTARG"); + this->surfaceInjectionRate = newValue; + }else{ std::invalid_argument("Well type must be OIL to set the oil rate"); + } } else if (cmode == WELTARGCMode::WRAT){ - if (this->injectorType == InjectorType::WATER) - this->surfaceInjectionRate.update_value( new_arg ); + if (this->injectorType == InjectorType::WATER) { + this->surfaceInjectionRate.assert_numeric("Can not combine UDA and WELTARG"); + this->surfaceInjectionRate = newValue; + } else std::invalid_argument("Well type must be WATER to set the water rate"); } else if (cmode == WELTARGCMode::GRAT){ - if(this->injectorType == InjectorType::GAS) - this->surfaceInjectionRate.update_value( new_arg ); - else + if(this->injectorType == InjectorType::GAS){ + this->surfaceInjectionRate.assert_numeric("Can not combine UDA and WELTARG"); + this->surfaceInjectionRate = newValue; + }else{ std::invalid_argument("Well type must be GAS to set the gas rate"); + } } - else if (cmode == WELTARGCMode::THP) - this->THPTarget.update_value( new_arg ); - else if (cmode == WELTARGCMode::VFP) - this->VFPTableNumber = static_cast(new_arg.get()); - else if (cmode == WELTARGCMode::RESV) - this->reservoirInjectionRate.update_value( new_arg ); - else if (cmode != WELTARGCMode::GUID) + else if (cmode == WELTARGCMode::THP){ + this->THPTarget.assert_numeric("Can not combine UDA and WELTARG"); + 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 = newValue; + } + else if (cmode != WELTARGCMode::GUID){ throw std::invalid_argument("Invalid keyword (MODE) supplied"); + } } diff --git a/ThirdParty/custom-opm-common/opm-common/src/opm/parser/eclipse/EclipseState/Schedule/Well/WellProductionProperties.cpp b/ThirdParty/custom-opm-common/opm-common/src/opm/parser/eclipse/EclipseState/Schedule/Well/WellProductionProperties.cpp index 720bba2a31..47cce3bded 100644 --- a/ThirdParty/custom-opm-common/opm-common/src/opm/parser/eclipse/EclipseState/Schedule/Well/WellProductionProperties.cpp +++ b/ThirdParty/custom-opm-common/opm-common/src/opm/parser/eclipse/EclipseState/Schedule/Well/WellProductionProperties.cpp @@ -218,40 +218,47 @@ namespace Opm { - void Well::WellProductionProperties::handleWELTARG(Well::WELTARGCMode cmode, const UDAValue& new_arg, double SiFactorP) { + void Well::WellProductionProperties::handleWELTARG(Well::WELTARGCMode cmode, double newValue, double SiFactorP) { if (cmode == WELTARGCMode::ORAT){ - this->OilRate.update_value( new_arg ); + this->OilRate.assert_numeric("Can not combine UDA and WELTARG"); + this->OilRate = newValue; this->addProductionControl( ProducerCMode::ORAT ); } else if (cmode == WELTARGCMode::WRAT){ - this->WaterRate.update_value( new_arg ); + this->WaterRate.assert_numeric("Can not combine UDA and WELTARG"); + this->WaterRate = newValue; this->addProductionControl( ProducerCMode::WRAT ); } else if (cmode == WELTARGCMode::GRAT){ - this->GasRate.update_value( new_arg ); + this->GasRate.assert_numeric("Can not combine UDA and WELTARG"); + this->GasRate = newValue; this->addProductionControl( ProducerCMode::GRAT ); } else if (cmode == WELTARGCMode::LRAT){ - this->LiquidRate.update_value( new_arg ); + this->LiquidRate.assert_numeric("Can not combine UDA and WELTARG"); + this->LiquidRate = newValue; this->addProductionControl( ProducerCMode::LRAT ); } else if (cmode == WELTARGCMode::RESV){ - this->ResVRate.update_value( new_arg ); + this->ResVRate.assert_numeric("Can not combine UDA and WELTARG"); + this->ResVRate = newValue; this->addProductionControl( ProducerCMode::RESV ); } else if (cmode == WELTARGCMode::BHP){ - if (this->predictionMode) - this->BHPTarget.update_value( new_arg ); - else - this->bhp_hist_limit = new_arg.get() * SiFactorP; + if (this->predictionMode) { + this->BHPTarget.assert_numeric("Can not combine UDA and WELTARG"); + this->BHPTarget = newValue; + } else + this->bhp_hist_limit = newValue * SiFactorP; this->addProductionControl( ProducerCMode::BHP ); } else if (cmode == WELTARGCMode::THP){ - this->THPTarget.update_value( new_arg ); + this->THPTarget.assert_numeric("Can not combine UDA and WELTARG"); + this->THPTarget = newValue; this->addProductionControl( ProducerCMode::THP ); } else if (cmode == WELTARGCMode::VFP) - this->VFPTableNumber = static_cast(new_arg.get()); + this->VFPTableNumber = static_cast (newValue); else if (cmode != WELTARGCMode::GUID) throw std::invalid_argument("Invalid keyword (MODE) supplied"); } diff --git a/ThirdParty/custom-opm-common/opm-common/src/opm/parser/eclipse/EclipseState/Schedule/eval_uda.cpp b/ThirdParty/custom-opm-common/opm-common/src/opm/parser/eclipse/EclipseState/Schedule/eval_uda.cpp index f5cd257ecd..f902d3e19e 100644 --- a/ThirdParty/custom-opm-common/opm-common/src/opm/parser/eclipse/EclipseState/Schedule/eval_uda.cpp +++ b/ThirdParty/custom-opm-common/opm-common/src/opm/parser/eclipse/EclipseState/Schedule/eval_uda.cpp @@ -41,9 +41,7 @@ namespace UDA { output_value = st.get(string_var); // We do not handle negative rates. - // If negative rates occur a very small positive value is used to avoid 0.0 - // since 0.0 means default which is no rate limit (a large positive value) - output_value = std::max(value.epsilonLimit(), output_value); + output_value = std::max(0.0, output_value); return value.get_dim().convertRawToSi(output_value); } @@ -67,9 +65,7 @@ double eval_group_uda(const UDAValue& value, const std::string& group, const Sum output_value = st.get(string_var); // We do not handle negative rates. - // If negative rates occur a very small positive value is used to avoid 0.0 - // since 0.0 means default which is no rate limit (a large positive value) - output_value = std::max(value.epsilonLimit(), output_value); + output_value = std::max(0.0, output_value); return value.get_dim().convertRawToSi(output_value); } diff --git a/ThirdParty/custom-opm-common/opm-common/src/opm/parser/eclipse/EclipseState/SummaryConfig/SummaryConfig.cpp b/ThirdParty/custom-opm-common/opm-common/src/opm/parser/eclipse/EclipseState/SummaryConfig/SummaryConfig.cpp index 406bcc723e..a02e360a02 100644 --- a/ThirdParty/custom-opm-common/opm-common/src/opm/parser/eclipse/EclipseState/SummaryConfig/SummaryConfig.cpp +++ b/ThirdParty/custom-opm-common/opm-common/src/opm/parser/eclipse/EclipseState/SummaryConfig/SummaryConfig.cpp @@ -65,7 +65,7 @@ namespace { }; const std::vector GMWSET_keywords = { - "GMWPT", "GMWPR", "GMWPA", "GMWPU", "GMWPG", "GMWPO", "GMWPS", + "GMCTG", "GMWPT", "GMWPR", "GMWPA", "GMWPU", "GMWPG", "GMWPO", "GMWPS", "GMWPV", "GMWPP", "GMWPL", "GMWIT", "GMWIN", "GMWIA", "GMWIU", "GMWIG", "GMWIS", "GMWIV", "GMWIP", "GMWDR", "GMWDT", "GMWWO", "GMWWT" }; diff --git a/ThirdParty/custom-opm-common/opm-common/src/opm/parser/eclipse/EclipseState/Tables/RwgsaltTable.cpp b/ThirdParty/custom-opm-common/opm-common/src/opm/parser/eclipse/EclipseState/Tables/RwgsaltTable.cpp deleted file mode 100644 index 3203fe5515..0000000000 --- a/ThirdParty/custom-opm-common/opm-common/src/opm/parser/eclipse/EclipseState/Tables/RwgsaltTable.cpp +++ /dev/null @@ -1,99 +0,0 @@ -/* - Copyright (C) 2020 by Equinor - Copyright (C) 2020 by TNO - - This file is part of the Open Porous Media project (OPM). - - OPM is free software: you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - OPM is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with OPM. If not, see . - */ - -#include -#include -#include -#include -#include - -namespace Opm { - - static const size_t numEntries = 3; - RwgsaltTable::RwgsaltTable() - { - } - - RwgsaltTable RwgsaltTable::serializeObject() - { - RwgsaltTable result; - result.m_tableValues = {1.0, 2.0, 3.0}; - - return result; - } - - void RwgsaltTable::init(const Opm::DeckRecord& record1) - { - m_tableValues = record1.getItem("DATA").getSIDoubleData(); - } - - size_t RwgsaltTable::size() const - { - return m_tableValues.size()/numEntries; - } - - const std::vector& RwgsaltTable::getTableValues() const - { - return m_tableValues; - } - - std::vector RwgsaltTable::getPressureColumn() const - { - size_t tableindex = 0; - std::vector pressure(this->size()); - for(size_t i=0; isize(); ++i){ - pressure[i] = m_tableValues[tableindex]; - tableindex = tableindex+numEntries; - } - return pressure; - - } - - std::vector RwgsaltTable::getSaltConcentrationColumn() const - { - size_t tableindex = 1; - std::vector saltConc(this->size()); - for(size_t i=0; isize(); ++i){ - saltConc[i] = m_tableValues[tableindex]; - tableindex = tableindex+numEntries; - } - return saltConc; - - } - - std::vector RwgsaltTable::getVaporizedWaterGasRatioColumn() const - { - size_t tableindex = 2; - std::vector vaporizedwatergasratio(this->size()); - for(size_t i=0; isize(); ++i){ - vaporizedwatergasratio[i] = m_tableValues[tableindex]; - tableindex = tableindex+numEntries; - } - return vaporizedwatergasratio; - - } - - bool RwgsaltTable::operator==(const RwgsaltTable& data) const - { - return m_tableValues == data.m_tableValues; - } - -} - diff --git a/ThirdParty/custom-opm-common/opm-common/src/opm/parser/eclipse/EclipseState/Tables/TLMixpar.cpp b/ThirdParty/custom-opm-common/opm-common/src/opm/parser/eclipse/EclipseState/Tables/TLMixpar.cpp deleted file mode 100644 index 91a054a4eb..0000000000 --- a/ThirdParty/custom-opm-common/opm-common/src/opm/parser/eclipse/EclipseState/Tables/TLMixpar.cpp +++ /dev/null @@ -1,63 +0,0 @@ -/* - Copyright 2020 Statoil ASA. - - This file is part of the Open Porous Media project (OPM). - - OPM is free software: you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - OPM is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with OPM. If not, see . - */ - - -#include -#include -#include - -namespace Opm { - -TLMixpar::TLMixpar(const Deck& deck) { - using TLM = ParserKeywords::TLMIXPAR; - if (!deck.hasKeyword()) - return; - - const auto& keyword = deck.getKeyword(); - for (const auto& record : keyword) { - const double viscosity_parameter = record.getItem().getSIDouble(0); - double density_parameter = viscosity_parameter; - const auto& density_item = record.getItem(); - if (density_item.hasValue(0)) - density_parameter = density_item.getSIDouble(0); - - this->data.emplace_back(viscosity_parameter, density_parameter); - } -} - - -bool TLMixpar::empty() const { - return this->data.empty(); -} - -std::size_t TLMixpar::size() const { - return this->data.size(); -} - -TLMixpar TLMixpar::serializeObject() { - TLMixpar tlm; - return tlm; -} - - -const TLMixRecord& TLMixpar::operator[](const std::size_t index) const { - return this->data.at(index); -} - -} diff --git a/ThirdParty/custom-opm-common/opm-common/src/opm/parser/eclipse/EclipseState/Tables/TableManager.cpp b/ThirdParty/custom-opm-common/opm-common/src/opm/parser/eclipse/EclipseState/Tables/TableManager.cpp index db9bc98e8e..92d4551bb6 100644 --- a/ThirdParty/custom-opm-common/opm-common/src/opm/parser/eclipse/EclipseState/Tables/TableManager.cpp +++ b/ThirdParty/custom-opm-common/opm-common/src/opm/parser/eclipse/EclipseState/Tables/TableManager.cpp @@ -66,9 +66,7 @@ #include #include #include -#include #include -#include #include #include #include @@ -101,7 +99,6 @@ namespace Opm { : m_tabdims( Tabdims(deck)), m_aqudims( Aqudims(deck)), - m_tlmixpar( deck ), hasImptvd (deck.hasKeyword("IMPTVD")), hasEnptvd (deck.hasKeyword("ENPTVD")), hasEqlnum (deck.hasKeyword("EQLNUM")) @@ -116,8 +113,6 @@ namespace Opm { initDims( deck ); initSimpleTables( deck ); initFullTables(deck, "PVTG", m_pvtgTables); - initFullTables(deck, "PVTGW", m_pvtgwTables); - initFullTables(deck, "PVTGWO", m_pvtgwoTables); initFullTables(deck, "PVTO", m_pvtoTables); if( deck.hasKeyword( "PVTW" ) ) @@ -152,9 +147,6 @@ namespace Opm { if ( deck.hasKeyword( "PVTWSALT") ) initPvtwsaltTables(deck, m_pvtwsaltTables ); - if ( deck.hasKeyword( "RWGSALT") ) - initRwgsaltTables(deck, m_rwgsaltTables ); - if ( deck.hasKeyword( "BDENSITY") ) initBrineTables(deck, m_bdensityTables ); @@ -190,6 +182,10 @@ namespace Opm { hasShrate = true; } + if (deck.hasKeyword()) { + this->m_tlmixparTable = TlmixparTable(deck.getKeyword("TLMIXPAR")); + } + if (deck.hasKeyword()) { this->m_plyvmhTable = PlyvmhTable(deck.getKeyword("PLYVMH")); } @@ -202,8 +198,6 @@ namespace Opm { TableManager& TableManager::operator=(const TableManager& data) { m_simpleTables = data.m_simpleTables; m_pvtgTables = data.m_pvtgTables; - m_pvtgwTables = data.m_pvtgwTables; - m_pvtgwoTables = data.m_pvtgwoTables; m_pvtoTables = data.m_pvtoTables; m_rock2dTables = data.m_rock2dTables; m_rock2dtrTables = data.m_rock2dtrTables; @@ -214,10 +208,10 @@ namespace Opm { m_plmixparTable = data.m_plmixparTable; m_shrateTable = data.m_shrateTable; m_stone1exTable = data.m_stone1exTable; + m_tlmixparTable = data.m_tlmixparTable; m_viscrefTable = data.m_viscrefTable; m_watdentTable = data.m_watdentTable; m_pvtwsaltTables = data.m_pvtwsaltTables; - m_rwgsaltTables = data.m_rwgsaltTables; m_bdensityTables = data.m_bdensityTables; m_sdensityTables = data.m_sdensityTables; m_plymwinjTables = data.m_plymwinjTables; @@ -239,7 +233,6 @@ namespace Opm { watDenT = data.watDenT; stcond = data.stcond; m_gas_comp_index = data.m_gas_comp_index; - m_tlmixpar = data.m_tlmixpar; return *this; } @@ -249,8 +242,6 @@ namespace Opm { TableManager result; result.m_simpleTables = {{"test", TableContainer::serializeObject()}}; result.m_pvtgTables = {PvtgTable::serializeObject()}; - result.m_pvtgwTables = {PvtgwTable::serializeObject()}; - result.m_pvtgwoTables = {PvtgwoTable::serializeObject()}; result.m_pvtoTables = {PvtoTable::serializeObject()}; result.m_rock2dTables = {Rock2dTable::serializeObject()}; result.m_rock2dtrTables = {Rock2dtrTable::serializeObject()}; @@ -262,10 +253,10 @@ namespace Opm { result.m_plmixparTable = PlmixparTable::serializeObject(); result.m_shrateTable = ShrateTable::serializeObject(); result.m_stone1exTable = Stone1exTable::serializeObject(); + result.m_tlmixparTable = TlmixparTable::serializeObject(); result.m_viscrefTable = ViscrefTable::serializeObject(); result.m_watdentTable = WatdentTable::serializeObject(); result.m_pvtwsaltTables = {PvtwsaltTable::serializeObject()}; - result.m_rwgsaltTables = {RwgsaltTable::serializeObject()}; result.m_bdensityTables = {BrineDensityTable::serializeObject()}; result.m_sdensityTables = {SolventDensityTable::serializeObject()}; result.m_plymwinjTables = {{1, Opm::PlymwinjTable::serializeObject()}}; @@ -285,7 +276,7 @@ namespace Opm { result.stcond = StandardCond::serializeObject(); result.m_gas_comp_index = 77; result.m_rtemp = 1.0; - result.m_tlmixpar = TLMixpar::serializeObject(); + return result; } @@ -408,8 +399,6 @@ namespace Opm { addTables( "PBVD", m_eqldims.getNumEquilRegions()); addTables( "PDVD", m_eqldims.getNumEquilRegions()); addTables( "SALTVD", m_eqldims.getNumEquilRegions()); - addTables( "SALTPVD", m_eqldims.getNumEquilRegions()); - addTables( "PERMFACT", m_eqldims.getNumEquilRegions()); addTables( "AQUTAB", m_aqudims.getNumInfluenceTablesCT()); { @@ -472,9 +461,7 @@ namespace Opm { initSimpleTableContainer(deck, "RVVD" , m_eqldims.getNumEquilRegions()); initSimpleTableContainer(deck, "PBVD" , m_eqldims.getNumEquilRegions()); initSimpleTableContainer(deck, "PDVD" , m_eqldims.getNumEquilRegions()); - initSimpleTableContainer(deck, "SALTPVD" , m_eqldims.getNumEquilRegions()); initSimpleTableContainer(deck, "SALTVD" , m_eqldims.getNumEquilRegions()); - initSimpleTableContainer(deck, "PERMFACT" , m_eqldims.getNumEquilRegions()); initSimpleTableContainer(deck, "AQUTAB" , m_aqudims.getNumInfluenceTablesCT()); { size_t numEndScaleTables = ParserKeywords::ENDSCALE::NUM_TABLES::defaultValue; @@ -859,14 +846,6 @@ namespace Opm { return getTables("SALTVD"); } - const TableContainer& TableManager::getSaltpvdTables() const { - return getTables("SALTPVD"); - } - - const TableContainer& TableManager::getPermfactTables() const { - return getTables("PERMFACT"); - } - const TableContainer& TableManager::getEnkrvdTables() const { return getTables("ENKRVD"); } @@ -965,14 +944,6 @@ namespace Opm { return m_pvtgTables; } - const std::vector& TableManager::getPvtgwTables() const { - return m_pvtgwTables; - } - - const std::vector& TableManager::getPvtgwoTables() const { - return m_pvtgwoTables; - } - const std::vector& TableManager::getPvtoTables() const { return m_pvtoTables; } @@ -1001,10 +972,6 @@ namespace Opm { return this->m_pvtwsaltTables; } - const std::vector& TableManager::getRwgSaltTables() const { - return this->m_rwgsaltTables; - } - const std::vector& TableManager::getBrineDensityTables() const { return this->m_bdensityTables; } @@ -1064,8 +1031,8 @@ namespace Opm { return m_stone1exTable; } - const TLMixpar& TableManager::getTLMixpar() const { - return m_tlmixpar; + const TlmixparTable& TableManager::getTlmixparTable() const { + return m_tlmixparTable; } const JFunc& TableManager::getJFunc() const { @@ -1144,8 +1111,6 @@ namespace Opm { return m_simpleTables == data.m_simpleTables && m_pvtgTables == data.m_pvtgTables && - m_pvtgwTables == data.m_pvtgwTables && - m_pvtgwoTables == data.m_pvtgwoTables && m_pvtoTables == data.m_pvtoTables && m_rock2dTables == data.m_rock2dTables && m_rock2dtrTables == data.m_rock2dtrTables && @@ -1156,16 +1121,15 @@ namespace Opm { m_plyvmhTable == data.m_plyvmhTable && m_shrateTable == data.m_shrateTable && m_stone1exTable == data.m_stone1exTable && + m_tlmixparTable == data.m_tlmixparTable && m_viscrefTable == data.m_viscrefTable && m_watdentTable == data.m_watdentTable && m_pvtwsaltTables == data.m_pvtwsaltTables && - m_rwgsaltTables == data.m_rwgsaltTables && m_bdensityTables == data.m_bdensityTables && m_sdensityTables == data.m_sdensityTables && m_plymwinjTables == data.m_plymwinjTables && m_skprwatTables == data.m_skprwatTables && m_skprpolyTables == data.m_skprpolyTables && - m_tlmixpar == data.m_tlmixpar && m_tabdims == data.m_tabdims && m_regdims == data.m_regdims && m_eqldims == data.m_eqldims && diff --git a/ThirdParty/custom-opm-common/opm-common/src/opm/parser/eclipse/EclipseState/Tables/Tables.cpp b/ThirdParty/custom-opm-common/opm-common/src/opm/parser/eclipse/EclipseState/Tables/Tables.cpp index 6f54a544d4..d33fa286b3 100644 --- a/ThirdParty/custom-opm-common/opm-common/src/opm/parser/eclipse/EclipseState/Tables/Tables.cpp +++ b/ThirdParty/custom-opm-common/opm-common/src/opm/parser/eclipse/EclipseState/Tables/Tables.cpp @@ -52,8 +52,6 @@ #include #include #include -#include -#include #include #include #include @@ -63,9 +61,7 @@ #include #include #include -#include #include -#include #include #include #include @@ -112,60 +108,6 @@ bool PvtgTable::operator==(const PvtgTable& data) const { return static_cast(*this) == static_cast(data); } -PvtgwTable::PvtgwTable( const DeckKeyword& keyword, size_t tableIdx ) : - PvtxTable("P") { - - m_underSaturatedSchema.addColumn( ColumnSchema( "RW" , Table::STRICTLY_DECREASING , Table::DEFAULT_NONE )); - m_underSaturatedSchema.addColumn( ColumnSchema( "BG" , Table::RANDOM , Table::DEFAULT_LINEAR )); - m_underSaturatedSchema.addColumn( ColumnSchema( "MUG" , Table::RANDOM , Table::DEFAULT_LINEAR )); - - m_saturatedSchema.addColumn( ColumnSchema( "PG" , Table::STRICTLY_INCREASING , Table::DEFAULT_NONE )); - m_saturatedSchema.addColumn( ColumnSchema( "RW" , Table::RANDOM , Table::DEFAULT_NONE )); - m_saturatedSchema.addColumn( ColumnSchema( "BG" , Table::RANDOM , Table::DEFAULT_LINEAR )); - m_saturatedSchema.addColumn( ColumnSchema( "MUG" , Table::RANDOM , Table::DEFAULT_LINEAR )); - - PvtxTable::init(keyword, tableIdx); - } - -PvtgwTable PvtgwTable::serializeObject() { - PvtgwTable result; - static_cast(result) = PvtxTable::serializeObject(); - - return result; -} - -bool PvtgwTable::operator==(const PvtgwTable& data) const { - return static_cast(*this) == static_cast(data); -} - -PvtgwoTable::PvtgwoTable( const DeckKeyword& keyword, size_t tableIdx ) : - PvtxTable("P") { - - m_underSaturatedSchema.addColumn( ColumnSchema( "RV" , Table::STRICTLY_DECREASING , Table::DEFAULT_NONE )); - m_underSaturatedSchema.addColumn( ColumnSchema( "RW" , Table::STRICTLY_DECREASING , Table::DEFAULT_NONE )); - m_underSaturatedSchema.addColumn( ColumnSchema( "BG" , Table::RANDOM , Table::DEFAULT_LINEAR )); - m_underSaturatedSchema.addColumn( ColumnSchema( "MUG" , Table::RANDOM , Table::DEFAULT_LINEAR )); - - m_saturatedSchema.addColumn( ColumnSchema( "PG" , Table::STRICTLY_INCREASING , Table::DEFAULT_NONE )); - m_saturatedSchema.addColumn( ColumnSchema( "RV" , Table::RANDOM , Table::DEFAULT_NONE )); - m_saturatedSchema.addColumn( ColumnSchema( "RW" , Table::RANDOM , Table::DEFAULT_NONE )); - m_saturatedSchema.addColumn( ColumnSchema( "BG" , Table::RANDOM , Table::DEFAULT_LINEAR )); - m_saturatedSchema.addColumn( ColumnSchema( "MUG" , Table::RANDOM , Table::DEFAULT_LINEAR )); - - PvtxTable::init(keyword, tableIdx); - } - -PvtgwoTable PvtgwoTable::serializeObject() { - PvtgwoTable result; - static_cast(result) = PvtxTable::serializeObject(); - - return result; -} - -bool PvtgwoTable::operator==(const PvtgwoTable& data) const { - return static_cast(*this) == static_cast(data); -} - PvtoTable::PvtoTable( const DeckKeyword& keyword, size_t tableIdx) : PvtxTable("RS") { m_underSaturatedSchema.addColumn( ColumnSchema( "P" , Table::STRICTLY_INCREASING , Table::DEFAULT_NONE )); @@ -1001,37 +943,6 @@ const TableColumn& SaltvdTable::getSaltColumn() const { return SimpleTable::getColumn(1); } -SaltpvdTable::SaltpvdTable( const DeckItem& item ) { - m_schema.addColumn( ColumnSchema( "DEPTH" , Table::STRICTLY_INCREASING , Table::DEFAULT_NONE )); - m_schema.addColumn( ColumnSchema( "SALTP" , Table::RANDOM , Table::DEFAULT_NONE )); - - SimpleTable::init(item); -} - -const TableColumn& SaltpvdTable::getDepthColumn() const { - return SimpleTable::getColumn(0); -} - -const TableColumn& SaltpvdTable::getSaltpColumn() const { - return SimpleTable::getColumn(1); -} - -PermfactTable::PermfactTable( const DeckItem& item ) { - m_schema.addColumn( ColumnSchema( "POROSITYCHANGE" , Table::STRICTLY_INCREASING , Table::DEFAULT_NONE )); - m_schema.addColumn( ColumnSchema( "PERMEABILIYMULTIPLIER" , Table::RANDOM , Table::DEFAULT_NONE )); - - SimpleTable::init(item); -} - -const TableColumn& PermfactTable::getPorosityChangeColumn() const { - return SimpleTable::getColumn(0); -} - -const TableColumn& PermfactTable::getPermeabilityMultiplierColumn() const { - return SimpleTable::getColumn(1); -} - - AqutabTable::AqutabTable( const DeckItem& item ) { m_schema.addColumn( ColumnSchema( "TD" , Table::STRICTLY_INCREASING , Table::DEFAULT_NONE ) ); m_schema.addColumn( ColumnSchema( "PD" , Table::RANDOM , Table::DEFAULT_LINEAR ) ); diff --git a/ThirdParty/custom-opm-common/opm-common/src/opm/parser/eclipse/Parser/Parser.cpp b/ThirdParty/custom-opm-common/opm-common/src/opm/parser/eclipse/Parser/Parser.cpp index d63a27f6e1..b2e0dc1ca0 100644 --- a/ThirdParty/custom-opm-common/opm-common/src/opm/parser/eclipse/Parser/Parser.cpp +++ b/ThirdParty/custom-opm-common/opm-common/src/opm/parser/eclipse/Parser/Parser.cpp @@ -48,6 +48,7 @@ #include #include #include +#include #include #include "raw/RawConsts.hpp" @@ -108,14 +109,9 @@ inline Itr find_terminator( Itr begin, Itr end, Term terminator ) { ABC '--Comment1' --Comment2 => ABC '--Comment1' ABC "-- Not balanced quote? => ABC "-- Not balanced quote? */ -static inline std::string_view strip_comments( std::string_view str ) { - auto terminator = find_terminator( str.begin(), str.end(), find_comment() ); - std::size_t size = std::distance(str.begin(), terminator); -#if __cplusplus >= 202002L - return { str.begin(), size }; -#else - return { str.data(), size }; -#endif +static inline string_view strip_comments( string_view str ) { + return { str.begin(), + find_terminator( str.begin(), str.end(), find_comment() ) }; } template< typename Itr > @@ -132,21 +128,14 @@ inline Itr trim_right( Itr begin, Itr end ) { return std::find_if_not( rbegin, rend, RawConsts::is_separator() ).base(); } -inline std::string_view trim( std::string_view str ) { +inline string_view trim( string_view str ) { auto fst = trim_left( str.begin(), str.end() ); auto lst = trim_right( fst, str.end() ); - std::size_t size = std::distance(fst, lst); -#if __cplusplus >= 202002L - return {fst, size}; -#else - const char* st = str.data(); - st += std::distance(str.begin(), fst); - return { st, size }; -#endif + return { fst, lst }; } -inline std::string_view del_after_first_slash( std::string_view view ) { - using itr = std::string_view::const_iterator; +inline string_view del_after_first_slash( string_view view ) { + using itr = string_view::const_iterator; const auto term = []( itr begin, itr end ) { return std::find( begin, end, '/' ); }; @@ -157,15 +146,11 @@ inline std::string_view del_after_first_slash( std::string_view view ) { /* we want to preserve terminating slashes */ if( slash != end ) ++slash; - std::size_t size = std::distance(begin, slash); -#if __cplusplus >= 202002L - return {begin, size}; -#else - return {view.data(), size}; -#endif + + return { begin, slash }; } -inline std::string_view del_after_last_slash( std::string_view view ) { +inline string_view del_after_last_slash( string_view view ) { auto begin = view.begin(); auto end = view.end(); auto slash = end; @@ -184,15 +169,11 @@ inline std::string_view del_after_last_slash( std::string_view view ) { /* we want to preserve terminating slashes */ if( slash != end ) ++slash; - std::size_t size = std::distance(begin, slash); -#if __cplusplus >= 202002L - return {begin, size}; -#else - return {view.data(), size}; -#endif + + return { begin, slash }; } -inline std::string_view del_after_slash(std::string_view view, bool raw_strings) { +inline string_view del_after_slash(string_view view, bool raw_strings) { if (raw_strings) return del_after_last_slash(view); else @@ -200,19 +181,13 @@ inline std::string_view del_after_slash(std::string_view view, bool raw_strings) } -inline bool getline( std::string_view& input, std::string_view& line ) { +inline bool getline( string_view& input, string_view& line ) { if( input.empty() ) return false; auto end = std::find( input.begin(), input.end(), '\n' ); -#if __cplusplus >= 202002L - line = std::string_view(input.begin(), end - input.begin()); - input = std::string_view(end + 1, input.end() - (end + 1)); -#else - line = std::string_view(input.data(), std::distance(input.begin(), end)); - const char* p = input.data(); - p += std::distance(input.begin(), end) + 1; - input = std::string_view(p, std::distance(end + 1, input.end())); -#endif + + line = string_view( input.begin(), end ); + input = string_view( end + 1, input.end() ); return true; /* we know that we always append a newline onto the input string, so we can @@ -231,7 +206,7 @@ inline std::string fast_clean( const std::string& str ) { std::string dst; dst.resize( str.size() ); - std::string_view input( str ), line; + string_view input( str ), line; auto dsti = dst.begin(); while( true ) { @@ -249,27 +224,6 @@ inline std::string fast_clean( const std::string& str ) { return dst; } -inline bool starts_with(const std::string_view& view, const std::string& str) { - auto str_size = str.size(); - if (str_size > view.size()) - return false; - - auto str_data = str.data(); - auto pos = view.begin(); - - std::size_t si = 0; - while (true) { - if (*pos != str_data[si]) - return false; - - ++pos; - ++si; - - if (si == str_size) - return true; - } -} - inline std::string clean( const std::vector>& code_keywords, const std::string& str ) { auto count = std::count_if(code_keywords.begin(), code_keywords.end(), [&str](const std::pair& code_pair) { @@ -282,38 +236,26 @@ inline std::string clean( const std::vector> std::string dst; dst.resize( str.size() ); - std::string_view input( str ), line; + string_view input( str ), line; auto dsti = dst.begin(); while( true ) { for (const auto& code_pair : code_keywords) { const auto& keyword = code_pair.first; - if (starts_with(input, keyword)) { + if (input.starts_with(keyword)) { std::string end_string = code_pair.second; auto end_pos = input.find(end_string); if (end_pos == std::string::npos) { std::copy(input.begin(), input.end(), dsti); dsti += std::distance( input.begin(), input.end() ); -#if __cplusplus >= 202002L - input = std::string_view(input.end(), 0); -#else - const char* p = input.data(); - p += std::distance(input.begin(), input.end()) + 1; - input = std::string_view(p, 0); -#endif + input = string_view(input.end(), input.end()); break; } else { end_pos += end_string.size(); std::copy(input.begin(), input.begin() + end_pos, dsti); dsti += end_pos; *dsti++ = '\n'; -#if __cplusplus >= 202002L - input = std::string_view(input.begin() + end_pos + 1, input.end() - (input.begin() + end_pos + 1)); -#else - const char* p = input.data(); - p += end_pos + 1; - input = std::string_view(p, std::distance(input.begin() + end_pos + 1, input.end())); -#endif + input = string_view(input.begin() + end_pos + 1, input.end()); break; } } @@ -338,31 +280,25 @@ inline std::string clean( const std::vector> -inline std::string make_deck_name(const std::string_view& str) { +inline std::string make_deck_name(const string_view& str) { auto first_sep = std::find_if( str.begin(), str.end(), RawConsts::is_separator() ); - return uppercase( std::string( str.substr( 0, first_sep - str.begin()) )); + return uppercase( str.substr(0, first_sep - str.begin()) ); } -inline std::string_view update_record_buffer(const std::string_view& record_buffer, const std::string_view& line) { +inline string_view update_record_buffer(const string_view& record_buffer, const string_view& line) { if (record_buffer.empty()) return line; - else { - std::size_t size = std::distance(record_buffer.begin(), line.end()); -#if __cplusplus >= 202002L - return { record_buffer.begin(), size }; -#else - return {record_buffer.data(), size}; -#endif - } + else + return { record_buffer.begin(), line.end() }; } -inline bool isTerminator(const std::string_view& line) { +inline bool isTerminator(const string_view& line) { return (line.size() == 1 && line.back() == RawConsts::slash); } -inline bool isTerminatedRecordString(const std::string_view& line) { +inline bool isTerminatedRecordString(const string_view& line) { return (line.back() == RawConsts::slash); } @@ -373,7 +309,7 @@ struct file { input( in ), path( p ) {} - std::string_view input; + string_view input; size_t lineNR = 0; Opm::filesystem::path path; }; @@ -402,7 +338,7 @@ class ParserState { void loadFile( const Opm::filesystem::path& ); void openRootFile( const Opm::filesystem::path& ); - void handleRandomText(const std::string_view& ) const; + void handleRandomText(const string_view& ) const; Opm::filesystem::path getIncludeFilePath( std::string ) const; void addPathAlias( const std::string& alias, const std::string& path ); @@ -410,8 +346,8 @@ class ParserState { size_t line() const; bool done() const; - std::string_view getline(); - void ungetline(const std::string_view& ln); + string_view getline(); + void ungetline(const string_view& ln); void closeFile(); private: @@ -449,8 +385,8 @@ bool ParserState::done() const { return this->input_stack.empty(); } -std::string_view ParserState::getline() { - std::string_view ln; +string_view ParserState::getline() { + string_view ln; str::getline( this->input_stack.top().input, ln ); this->input_stack.top().lineNR++; @@ -460,15 +396,12 @@ std::string_view ParserState::getline() { -void ParserState::ungetline(const std::string_view& line) { +void ParserState::ungetline(const string_view& line) { auto& file_view = this->input_stack.top().input; if (line.end() + 1 != file_view.begin()) throw std::invalid_argument("line view does not immediately proceed file_view"); -#if __cplusplus >= 202002L - file_view = std::string_view(line.begin(), file_view.end() - line.begin()); -#else - file_view = std::string_view(line.data(), std::distance(line.begin(), file_view.end())); -#endif + + file_view = string_view(line.begin(), file_view.end()); this->input_stack.top().lineNR--; } @@ -556,10 +489,10 @@ void ParserState::loadFile(const Opm::filesystem::path& inputFile) { * of the data section of any keyword. */ -void ParserState::handleRandomText(const std::string_view& keywordString ) const { +void ParserState::handleRandomText(const string_view& keywordString ) const { std::string errorKey; std::stringstream msg; - std::string trimmedCopy = std::string( keywordString ); + std::string trimmedCopy = keywordString.string(); if (trimmedCopy == "/") { @@ -703,7 +636,13 @@ RawKeyword * newRawKeyword(const ParserKeyword& parserKeyword, const std::string } -RawKeyword * newRawKeyword( const std::string& deck_name, ParserState& parserState, const Parser& parser, const std::string_view& line ) { +RawKeyword * newRawKeyword( const std::string& deck_name, ParserState& parserState, const Parser& parser, const string_view& line ) { + if (parser.isRecognizedKeyword(deck_name)) { + parserState.unknown_keyword = false; + const auto& parserKeyword = parser.getParserKeywordFromDeckName(deck_name); + return newRawKeyword(parserKeyword, deck_name, parserState, parser); + } + if (deck_name.size() > RawConsts::maxKeywordLength) { const std::string keyword8 = deck_name.substr(0, RawConsts::maxKeywordLength); if (parser.isRecognizedKeyword(keyword8)) { @@ -713,19 +652,9 @@ RawKeyword * newRawKeyword( const std::string& deck_name, ParserState& parserSta parserState.unknown_keyword = false; const auto& parserKeyword = parser.getParserKeywordFromDeckName( keyword8 ); return newRawKeyword(parserKeyword, keyword8, parserState, parser); - } else { - parserState.parseContext.handleUnknownKeyword( deck_name, parserState.errors ); - parserState.unknown_keyword = true; - return nullptr; } } - if (parser.isRecognizedKeyword(deck_name)) { - parserState.unknown_keyword = false; - const auto& parserKeyword = parser.getParserKeywordFromDeckName(deck_name); - return newRawKeyword(parserKeyword, deck_name, parserState, parser); - } - if( ParserKeyword::validDeckName(deck_name) ) { parserState.parseContext.handleUnknownKeyword( deck_name, parserState.errors ); parserState.unknown_keyword = true; @@ -768,7 +697,7 @@ void skipUDT( ParserState& parserState, const Parser& parser) { std::unique_ptr tryParseKeyword( ParserState& parserState, const Parser& parser) { bool is_title = false; std::unique_ptr rawKeyword; - std::string_view record_buffer(str::emptystr); + string_view record_buffer(str::emptystr); while( !parserState.done() ) { auto line = parserState.getline(); @@ -822,22 +751,14 @@ std::unique_ptr tryParseKeyword( ParserState& parserState, const Par if (rawKeyword->getSizeType() == Raw::CODE) { auto end_pos = line.find(parserKeyword.codeEnd()); if (end_pos != std::string::npos) { -#if __cplusplus >= 202002L - std::string_view line_content = { line.begin(), end_pos}; -#else - std::string_view line_content = {line.data(), end_pos}; -#endif + string_view line_content = { line.begin(), line.begin() + end_pos}; record_buffer = str::update_record_buffer( record_buffer, line_content ); RawRecord record(record_buffer, true); rawKeyword->addRecord(record); return rawKeyword; } else -#if __cplusplus >= 202002L - record_buffer = str::update_record_buffer(record_buffer.begin(), line); -#else - record_buffer = str::update_record_buffer(record_buffer.data(), line); -#endif + record_buffer = str::update_record_buffer( record_buffer.begin(), line ); continue; } @@ -872,12 +793,7 @@ std::unique_ptr tryParseKeyword( ParserState& parserState, const Par RawRecord record("opm/flow simulation"); rawKeyword->addRecord(record); } else { - std::size_t size = std::distance(record_buffer.begin(),record_buffer.end()); -#if __cplusplus >= 202002L - RawRecord record( std::string_view{ record_buffer.begin(), size }); -#else - RawRecord record(std::string_view {record_buffer.data(), size}); -#endif + RawRecord record( string_view{ record_buffer.begin(), record_buffer.end()}); rawKeyword->addRecord(record); } return rawKeyword; @@ -891,12 +807,7 @@ std::unique_ptr tryParseKeyword( ParserState& parserState, const Par if (str::isTerminatedRecordString(record_buffer)) { - std::size_t size = std::distance(record_buffer.begin(), record_buffer.end()) - 1; -#if __cplusplus >= 202002L - RawRecord record( std::string_view{ record_buffer.begin(), size }); -#else - RawRecord record(std::string_view {record_buffer.data(), size}); -#endif + RawRecord record( string_view{ record_buffer.begin(), record_buffer.end( ) - 1}); if (rawKeyword->addRecord(record)) return rawKeyword; @@ -1114,7 +1025,7 @@ bool parseState( ParserState& parserState, const Parser& parser ) { return m_deckParserKeywords.size(); } - const ParserKeyword* Parser::matchingKeyword(const std::string_view& name) const { + const ParserKeyword* Parser::matchingKeyword(const string_view& name) const { for (auto iter = m_wildCardKeywords.begin(); iter != m_wildCardKeywords.end(); ++iter) { if (iter->second->matches(name)) return iter->second; @@ -1126,7 +1037,7 @@ bool parseState( ParserState& parserState, const Parser& parser ) { return (m_wildCardKeywords.count(internalKeywordName) > 0); } - bool Parser::isRecognizedKeyword(const std::string_view& name ) const { + bool Parser::isRecognizedKeyword(const string_view& name ) const { if( !ParserKeyword::validDeckName( name ) ) return false; @@ -1144,7 +1055,7 @@ void Parser::addParserKeyword( ParserKeyword&& parserKeyword ) { * * A keyword can be added that overwrites some *but not all* deckname -> * keyword mappings. Keeping track of this is more hassle than worth for * what is essentially edge case usage. - * * We can store (and search) via std::string_view's from the keyword added + * * We can store (and search) via string_view's from the keyword added * first because we know that it will be kept around, i.e. we don't have to * deal with subtle lifetime issues. * * It means we aren't reliant on some internal name mapping, and can only @@ -1156,7 +1067,7 @@ void Parser::addParserKeyword( ParserKeyword&& parserKeyword ) { this->keyword_storage.push_back( std::move( parserKeyword ) ); const ParserKeyword * ptr = std::addressof(this->keyword_storage.back()); - std::string_view name( ptr->getName() ); + string_view name( ptr->getName() ); for (auto nameIt = ptr->deckNamesBegin(); nameIt != ptr->deckNamesEnd(); @@ -1178,15 +1089,15 @@ void Parser::addParserKeyword(const Json::JsonObject& jsonKeyword) { } bool Parser::hasKeyword( const std::string& name ) const { - return this->m_deckParserKeywords.find( std::string_view( name ) ) + return this->m_deckParserKeywords.find( string_view( name ) ) != this->m_deckParserKeywords.end(); } const ParserKeyword& Parser::getKeyword( const std::string& name ) const { - return getParserKeywordFromDeckName( std::string_view( name ) ); + return getParserKeywordFromDeckName( string_view( name ) ); } -const ParserKeyword& Parser::getParserKeywordFromDeckName(const std::string_view& name ) const { +const ParserKeyword& Parser::getParserKeywordFromDeckName(const string_view& name ) const { auto candidate = m_deckParserKeywords.find( name ); if( candidate != m_deckParserKeywords.end() ) return *candidate->second; @@ -1194,7 +1105,7 @@ const ParserKeyword& Parser::getParserKeywordFromDeckName(const std::string_view const auto* wildCardKeyword = matchingKeyword( name ); if ( !wildCardKeyword ) - throw std::invalid_argument( "Do not have parser keyword for parsing: " + std::string(name) ); + throw std::invalid_argument( "Do not have parser keyword for parsing: " + name ); return *wildCardKeyword; } @@ -1202,10 +1113,10 @@ const ParserKeyword& Parser::getParserKeywordFromDeckName(const std::string_view std::vector Parser::getAllDeckNames () const { std::vector keywords; for (auto iterator = m_deckParserKeywords.begin(); iterator != m_deckParserKeywords.end(); iterator++) { - keywords.push_back(std::string(iterator->first)); + keywords.push_back(iterator->first.string()); } for (auto iterator = m_wildCardKeywords.begin(); iterator != m_wildCardKeywords.end(); iterator++) { - keywords.push_back(std::string(iterator->first)); + keywords.push_back(iterator->first.string()); } return keywords; } diff --git a/ThirdParty/custom-opm-common/opm-common/src/opm/parser/eclipse/Parser/ParserItem.cpp b/ThirdParty/custom-opm-common/opm-common/src/opm/parser/eclipse/Parser/ParserItem.cpp index 100d6d6fbd..6d230b6a58 100644 --- a/ThirdParty/custom-opm-common/opm-common/src/opm/parser/eclipse/Parser/ParserItem.cpp +++ b/ThirdParty/custom-opm-common/opm-common/src/opm/parser/eclipse/Parser/ParserItem.cpp @@ -463,7 +463,7 @@ void scan_item( DeckItem& deck_item, const ParserItem& parser_item, RawRecord& r if (parse_raw) { while (record.size()) { auto token = record.pop_front(); - auto raw_string = RawString{ std::string(token) }; + auto raw_string = RawString{ token.string() }; deck_item.push_back( raw_string ); } return; @@ -516,7 +516,7 @@ void scan_item( DeckItem& deck_item, const ParserItem& parser_item, RawRecord& r if (parse_raw) { auto token = record.pop_front(); - auto raw_string = RawString{ std::string(token) }; + auto raw_string = RawString{ token.string() }; deck_item.push_back( raw_string ); return; } @@ -541,20 +541,15 @@ void scan_item( DeckItem& deck_item, const ParserItem& parser_item, RawRecord& r deck_item.push_backDummyDefault(); const auto value_start = token.size() - valueString.size(); - const std::size_t size = token.end() - (token.begin() + value_start); // replace the first occurence of "N*FOO" by a sequence of N-1 times // "FOO". this is slightly hacky, but it makes it work if the // number of defaults pass item boundaries... - // We can safely make a std::string_view of one_star because it + // We can safely make a string_view of one_star because it // has static storage static const char* one_star = "1*"; - std::string_view rep = !st.hasValue() - ? std::string_view {one_star} -#if __cplusplus >= 202002L - : std::string_view { token.begin() + value_start, size }; -#else - : std::string_view { std::string(token.begin() + value_start, token.end()) }; -#endif + string_view rep = !st.hasValue() + ? string_view{ one_star } + : string_view{ token.begin() + value_start, token.end() }; record.prepend( st.count() - 1, rep ); return; diff --git a/ThirdParty/custom-opm-common/opm-common/src/opm/parser/eclipse/Parser/ParserKeyword.cpp b/ThirdParty/custom-opm-common/opm-common/src/opm/parser/eclipse/Parser/ParserKeyword.cpp index 007cabc7c5..f95cd16b98 100644 --- a/ThirdParty/custom-opm-common/opm-common/src/opm/parser/eclipse/Parser/ParserKeyword.cpp +++ b/ThirdParty/custom-opm-common/opm-common/src/opm/parser/eclipse/Parser/ParserKeyword.cpp @@ -249,7 +249,7 @@ namespace Opm { } - bool ParserKeyword::validNameStart( const std::string_view& name) { + bool ParserKeyword::validNameStart( const string_view& name) { if (!isalpha(name[0])) return false; @@ -266,7 +266,7 @@ namespace Opm { } - bool ParserKeyword::validDeckName( const std::string_view& name) { + bool ParserKeyword::validDeckName( const string_view& name) { if( !validNameStart( name ) ) return false; @@ -651,11 +651,11 @@ void set_dimensions( ParserItem& item, } } - bool ParserKeyword::matches(const std::string_view& name ) const { + bool ParserKeyword::matches(const string_view& name ) const { if (!validDeckName(name )) return false; - else if( m_deckNames.count( std::string(name) ) ) + else if( m_deckNames.count( name.string() ) ) return true; else if (hasMatchRegex()) diff --git a/ThirdParty/custom-opm-common/opm-common/src/opm/parser/eclipse/Parser/raw/RawKeyword.cpp b/ThirdParty/custom-opm-common/opm-common/src/opm/parser/eclipse/Parser/raw/RawKeyword.cpp index bce3001427..c969e82e11 100644 --- a/ThirdParty/custom-opm-common/opm-common/src/opm/parser/eclipse/Parser/raw/RawKeyword.cpp +++ b/ThirdParty/custom-opm-common/opm-common/src/opm/parser/eclipse/Parser/raw/RawKeyword.cpp @@ -34,6 +34,9 @@ namespace { if (!ParserKeyword::validDeckName(name)) throw std::invalid_argument("Not a valid keyword:" + name); + if (name.size() > Opm::RawConsts::maxKeywordLength) + throw std::invalid_argument("Too long keyword:" + name); + if (name[0] == ' ') throw std::invalid_argument("Illegal whitespace start of keyword:" + name); diff --git a/ThirdParty/custom-opm-common/opm-common/src/opm/parser/eclipse/Parser/raw/RawKeyword.hpp b/ThirdParty/custom-opm-common/opm-common/src/opm/parser/eclipse/Parser/raw/RawKeyword.hpp index de8b883e3a..708745ee6c 100644 --- a/ThirdParty/custom-opm-common/opm-common/src/opm/parser/eclipse/Parser/raw/RawKeyword.hpp +++ b/ThirdParty/custom-opm-common/opm-common/src/opm/parser/eclipse/Parser/raw/RawKeyword.hpp @@ -33,6 +33,8 @@ namespace Opm { class RawRecord; + class string_view; + class RawKeyword { public: RawKeyword(const std::string& name, const std::string& filename, std::size_t lineNR, bool raw_string, Raw::KeywordSizeEnum sizeType); diff --git a/ThirdParty/custom-opm-common/opm-common/src/opm/parser/eclipse/Parser/raw/RawRecord.cpp b/ThirdParty/custom-opm-common/opm-common/src/opm/parser/eclipse/Parser/raw/RawRecord.cpp index 6ed4980c8c..9aaecd4d4a 100644 --- a/ThirdParty/custom-opm-common/opm-common/src/opm/parser/eclipse/Parser/raw/RawRecord.cpp +++ b/ThirdParty/custom-opm-common/opm-common/src/opm/parser/eclipse/Parser/raw/RawRecord.cpp @@ -23,6 +23,8 @@ #include #include +#include + #include "RawRecord.hpp" #include "RawConsts.hpp" @@ -34,34 +36,23 @@ namespace Opm { namespace { -std::deque< std::string_view > splitSingleRecordString( const std::string_view& record ) { - auto first_nonspace = []( std::string_view::const_iterator begin, - std::string_view::const_iterator end ) { +std::deque< string_view > splitSingleRecordString( const string_view& record ) { + auto first_nonspace = []( string_view::const_iterator begin, + string_view::const_iterator end ) { return std::find_if_not( begin, end, RawConsts::is_separator() ); }; - std::deque< std::string_view > dst; + std::deque< string_view > dst; auto current = record.begin(); while( (current = first_nonspace( current, record.end() )) != record.end() ) { if( *current == RawConsts::quote ) { auto quote_end = std::find( current + 1, record.end(), RawConsts::quote ) + 1; - - std::size_t size = std::distance(current, quote_end); -#if __cplusplus >= 202002L - dst.push_back( { current, size } ); -#else - dst.push_back( std::string_view(std::string(current, current + size))); -#endif + dst.push_back( { current, quote_end } ); current = quote_end; } else { auto token_end = std::find_if( current, record.end(), RawConsts::is_separator() ); - std::size_t size = std::distance(current, token_end); -#if __cplusplus >= 202002L - dst.push_back( { current, size } ); -#else - dst.push_back(std::string_view(std::string(current, current + size))); -#endif + dst.push_back( { current, token_end } ); current = token_end; } } @@ -86,7 +77,7 @@ inline bool even_quotes( const T& str ) { } - RawRecord::RawRecord(const std::string_view& singleRecordString, bool text) : + RawRecord::RawRecord(const string_view& singleRecordString, bool text) : m_sanitizedRecordString( singleRecordString ) { @@ -97,19 +88,29 @@ inline bool even_quotes( const T& str ) { if( !even_quotes( singleRecordString ) ) throw std::invalid_argument("Input string is not a complete record string, " - "offending string: '" + std::string(singleRecordString) + "'"); + "offending string: '" + singleRecordString + "'"); } } - RawRecord::RawRecord(const std::string_view& singleRecordString) : + RawRecord::RawRecord(const string_view& singleRecordString) : RawRecord(singleRecordString, false) {} - void RawRecord::prepend( size_t count, std::string_view tok ) { + void RawRecord::prepend( size_t count, string_view tok ) { this->m_recordItems.insert( this->m_recordItems.begin(), count, tok ); } + void RawRecord::dump() const { + std::cout << "RecordDump: "; + for (size_t i = 0; i < m_recordItems.size(); i++) { + std::cout + << this->m_recordItems[i] << "/" + << getItem( i ) << " "; + } + std::cout << std::endl; + } + std::string RawRecord::getRecordString() const { - return std::string(m_sanitizedRecordString); + return m_sanitizedRecordString.string(); } } diff --git a/ThirdParty/custom-opm-common/opm-common/src/opm/parser/eclipse/Parser/raw/RawRecord.hpp b/ThirdParty/custom-opm-common/opm-common/src/opm/parser/eclipse/Parser/raw/RawRecord.hpp index 33bdbfa703..dda439716e 100644 --- a/ThirdParty/custom-opm-common/opm-common/src/opm/parser/eclipse/Parser/raw/RawRecord.hpp +++ b/ThirdParty/custom-opm-common/opm-common/src/opm/parser/eclipse/Parser/raw/RawRecord.hpp @@ -23,9 +23,10 @@ #include #include #include -#include #include +#include + namespace Opm { /// Class representing the lowest level of the Raw datatypes, a record. A record is simply @@ -34,34 +35,36 @@ namespace Opm { class RawRecord { public: - RawRecord( const std::string_view&, bool text); - explicit RawRecord( const std::string_view&); + RawRecord( const string_view&, bool text); + explicit RawRecord( const string_view&); - inline std::string_view pop_front(); - inline std::string_view front() const; - void push_front( std::string_view token ); - void prepend( size_t count, std::string_view token ); + inline string_view pop_front(); + inline string_view front() const; + void push_front( string_view token ); + void prepend( size_t count, string_view token ); inline size_t size() const; std::string getRecordString() const; - inline std::string_view getItem(size_t index) const; + inline string_view getItem(size_t index) const; + + void dump() const; private: - std::string_view m_sanitizedRecordString; - std::deque< std::string_view > m_recordItems; + string_view m_sanitizedRecordString; + std::deque< string_view > m_recordItems; }; /* * These are frequently called, but fairly trivial in implementation, and * inlining the calls gives a decent low-effort performance benefit. */ - std::string_view RawRecord::pop_front() { + string_view RawRecord::pop_front() { auto front = m_recordItems.front(); this->m_recordItems.pop_front(); return front; } - std::string_view RawRecord::front() const { + string_view RawRecord::front() const { return this->m_recordItems.front(); } @@ -69,7 +72,7 @@ namespace Opm { return m_recordItems.size(); } - std::string_view RawRecord::getItem(size_t index) const { + string_view RawRecord::getItem(size_t index) const { return this->m_recordItems.at( index ); } } diff --git a/ThirdParty/custom-opm-common/opm-common/src/opm/parser/eclipse/Parser/raw/StarToken.cpp b/ThirdParty/custom-opm-common/opm-common/src/opm/parser/eclipse/Parser/raw/StarToken.cpp index caa6b2d50e..6d667c6901 100644 --- a/ThirdParty/custom-opm-common/opm-common/src/opm/parser/eclipse/Parser/raw/StarToken.cpp +++ b/ThirdParty/custom-opm-common/opm-common/src/opm/parser/eclipse/Parser/raw/StarToken.cpp @@ -26,6 +26,7 @@ #include +#include #include #include "StarToken.hpp" @@ -34,7 +35,7 @@ namespace qi = boost::spirit::qi; namespace Opm { - bool isStarToken(const std::string_view& token, + bool isStarToken(const string_view& token, std::string& countString, std::string& valueString) { // find first character which is not a digit @@ -59,25 +60,25 @@ namespace Opm { // possible.) else if (pos == 0) { countString = ""; - valueString = std::string(token.substr(pos + 1)); + valueString = token.substr(pos + 1); return true; } // if a star is prefixed by an unsigned integer N, then this should be // interpreted as "repeat value after star N times" - countString = std::string(token.substr(0, pos)); - valueString = std::string(token.substr(pos + 1)); + countString = token.substr(0, pos); + valueString = token.substr(pos + 1); return true; } template<> - int readValueToken< int >( std::string_view view ) { + int readValueToken< int >( string_view view ) { int n = 0; auto cursor = view.begin(); const bool ok = qi::parse( cursor, view.end(), qi::int_, n ); if( ok && cursor == view.end() ) return n; - throw std::invalid_argument( "Malformed integer '" + std::string(view) + "'" ); + throw std::invalid_argument( "Malformed integer '" + view + "'" ); } template< typename T > @@ -96,36 +97,36 @@ namespace Opm { }; template<> - double readValueToken< double >( std::string_view view ) { + double readValueToken< double >( string_view view ) { double n = 0; qi::real_parser< double, fortran_double< double > > double_; auto cursor = view.begin(); const auto ok = qi::parse( cursor, view.end(), double_, n ); if( ok && cursor == view.end() ) return n; - throw std::invalid_argument( "Malformed floating point number '" + std::string(view) + "'" ); + throw std::invalid_argument( "Malformed floating point number '" + view + "'" ); } template <> - std::string readValueToken< std::string >( std::string_view view ) { + std::string readValueToken< std::string >( string_view view ) { if( view.size() == 0 || view[ 0 ] != '\'' ) - return std::string(view); + return view.string(); if( view.size() < 2 || view[ view.size() - 1 ] != '\'') - throw std::invalid_argument("Unable to parse string '" + std::string(view) + "' as a string token"); + throw std::invalid_argument("Unable to parse string '" + view + "' as a string token"); - return std::string(view.substr(1, view.size() - 2 )); + return view.substr( 1, view.size() - 2 ); } template <> - RawString readValueToken( std::string_view view ) { - return { std::string( view ) }; + RawString readValueToken( string_view view ) { + return { view.string() }; } template<> - UDAValue readValueToken< UDAValue >( std::string_view view ) { + UDAValue readValueToken< UDAValue >( string_view view ) { double n = 0; qi::real_parser< double, fortran_double< double > > double_; auto cursor = view.begin(); @@ -135,13 +136,13 @@ namespace Opm { return UDAValue( readValueToken(view) ); } - void StarToken::init_( const std::string_view& token ) { + void StarToken::init_( const string_view& token ) { // special-case the interpretation of a lone star as "1*" but do not // allow constructs like "*123"... if (m_countString == "") { if (m_valueString != "") // TODO: decorate the deck with a warning instead? - throw std::invalid_argument("Not specifying a count also implies not specifying a value. Token: \'" + std::string(token) + "\'."); + throw std::invalid_argument("Not specifying a count also implies not specifying a value. Token: \'" + token + "\'."); // TODO: since this is explicitly forbidden by the documentation it might // be a good idea to decorate the deck with a warning? @@ -152,7 +153,7 @@ namespace Opm { if (cnt < 1) // TODO: decorate the deck with a warning instead? - throw std::invalid_argument("Specifing zero repetitions is not allowed. Token: \'" + std::string(token) + "\'."); + throw std::invalid_argument("Specifing zero repetitions is not allowed. Token: \'" + token + "\'."); m_count = static_cast(cnt); } diff --git a/ThirdParty/custom-opm-common/opm-common/src/opm/parser/eclipse/Parser/raw/StarToken.hpp b/ThirdParty/custom-opm-common/opm-common/src/opm/parser/eclipse/Parser/raw/StarToken.hpp index 3f9dfd2733..094f2f3e48 100644 --- a/ThirdParty/custom-opm-common/opm-common/src/opm/parser/eclipse/Parser/raw/StarToken.hpp +++ b/ThirdParty/custom-opm-common/opm-common/src/opm/parser/eclipse/Parser/raw/StarToken.hpp @@ -23,26 +23,27 @@ #include #include +#include #include namespace Opm { - bool isStarToken(const std::string_view& token, + bool isStarToken(const string_view& token, std::string& countString, std::string& valueString); template - T readValueToken( std::string_view ); + T readValueToken( string_view ); class StarToken { public: - StarToken(const std::string_view& token) + StarToken(const string_view& token) { if (!isStarToken(token, m_countString, m_valueString)) - throw std::invalid_argument("Token \""+ std::string(token) +"\" is not a repetition specifier"); + throw std::invalid_argument("Token \""+ token +"\" is not a repetition specifier"); init_(token); } - StarToken(const std::string_view& token, const std::string& countStr, const std::string& valueStr) + StarToken(const string_view& token, const std::string& countStr, const std::string& valueStr) : m_countString(countStr) , m_valueString(valueStr) { @@ -76,7 +77,7 @@ public: private: // internal initialization method. the m_countString and m_valueString attributes // must be set before calling this method. - void init_(const std::string_view& token); + void init_(const string_view& token); std::size_t m_count; std::string m_countString; diff --git a/ThirdParty/custom-opm-common/opm-common/src/opm/parser/eclipse/Units/UnitSystem.cpp b/ThirdParty/custom-opm-common/opm-common/src/opm/parser/eclipse/Units/UnitSystem.cpp index 6e018e5d70..1b5401905c 100644 --- a/ThirdParty/custom-opm-common/opm-common/src/opm/parser/eclipse/Units/UnitSystem.cpp +++ b/ThirdParty/custom-opm-common/opm-common/src/opm/parser/eclipse/Units/UnitSystem.cpp @@ -77,7 +77,6 @@ namespace { 0.0, 0.0, 0.0, - 0.0, }; static const double to_metric[] = { @@ -115,7 +114,6 @@ namespace { 1 / (Metric::GasSurfaceVolume / Metric::Time / Metric::Pressure), 1 / Metric::Energy, 1 / (Metric::Pressure / Opm::unit::square(Metric::GeomVolume / Metric::Time)), - 1 / Metric::PolymerDensity, }; static const double from_metric[] = { @@ -153,7 +151,6 @@ namespace { Metric::GasSurfaceVolume / Metric::Time / Metric::Pressure, Metric::Energy, Metric::Pressure / Opm::unit::square(Metric::GeomVolume / Metric::Time), - Metric::PolymerDensity, }; static constexpr const char* metric_names[static_cast(UnitSystem::measure::_count)] = { @@ -191,7 +188,6 @@ namespace { "SM3/DAY/BARS", "KJ", /* energy */ "BARS/(RM3/DAY)2", /* ICD strength parameter */ - "KG / SM3", /*polymer density */ }; static_assert( @@ -237,7 +233,6 @@ namespace { 0.0, 0.0, 0.0, - 0.0, }; static const double to_field[] = { @@ -275,7 +270,6 @@ namespace { 1 / (Field::GasSurfaceVolume / Field::Time / Field::Pressure), 1 / Field::Energy, 1 / (Field::Pressure / Opm::unit::square(Field::GeomVolume / Field::Time)), - 1 / Field::PolymerDensity, }; static const double from_field[] = { @@ -313,7 +307,6 @@ namespace { Field::GasSurfaceVolume / Field::Time / Field::Pressure, Field::Energy, Field::Pressure / Opm::unit::square(Field::GeomVolume / Field::Time), - Field::PolymerDensity, }; static constexpr const char* field_names[static_cast(UnitSystem::measure::_count)] = { @@ -351,7 +344,6 @@ namespace { "MSCF/DAY/PSIA", "BTU", /* energy */ "PSI/(RFT3/DAY)2", /* ICD strength parameter */ - "LB/STB", /*polymer density */ }; static_assert( @@ -397,7 +389,6 @@ namespace { 0.0, 0.0, 0.0, - 0.0, }; static const double to_lab[] = { @@ -435,7 +426,6 @@ namespace { 1 / (Lab::GasSurfaceVolume / Lab::Time / Lab::Pressure), 1 / Lab::Energy, 1 / (Lab::Pressure / Opm::unit::square(Lab::GeomVolume / Lab::Time)), - 1 / Lab::PolymerDensity, }; static const double from_lab[] = { @@ -473,13 +463,12 @@ namespace { Lab::GasSurfaceVolume / Lab::Time / Lab::Pressure, Lab::Energy, Lab::Pressure / Opm::unit::square(Lab::GeomVolume / Lab::Time), - Lab::PolymerDensity, }; static constexpr const char* lab_names[static_cast(UnitSystem::measure::_count)] = { "", "CM", - "HOURS", + "HRS", "G/CC", "ATM", "K", @@ -511,7 +500,6 @@ namespace { "SCC/HR/ATM", "J", /* energy */ "ATM/(RCC/H)2", /* ICD strength parameter */ - "G/SCC", /*polymer density */ }; static_assert( @@ -557,7 +545,6 @@ namespace { 0.0, 0.0, 0.0, - 0.0, }; static const double to_pvt_m[] = { @@ -595,7 +582,6 @@ namespace { 1 / (PVT_M::GasSurfaceVolume / PVT_M::Time / PVT_M::Pressure), 1 / PVT_M::Energy, 1 / (PVT_M::Pressure / Opm::unit::square(PVT_M::GeomVolume / PVT_M::Time)), - 1 / PVT_M::PolymerDensity, }; static const double from_pvt_m[] = { @@ -633,7 +619,6 @@ namespace { PVT_M::GasSurfaceVolume / PVT_M::Time / PVT_M::Pressure, PVT_M::Energy, PVT_M::Pressure / Opm::unit::square(PVT_M::GeomVolume / PVT_M::Time), - PVT_M::PolymerDensity, }; static constexpr const char* pvt_m_names[static_cast(UnitSystem::measure::_count)] = { @@ -670,8 +655,7 @@ namespace { "SM3/DAY/ATM", "SM3/DAY/ATM", "KJ" /* energy */, - "ATM/(RM3/DAY)2", /* ICD strength parameter */ - "KG/SM3", /*polymer density */ + "ATM/(RM3/DAY)2" /* ICD strength parameter */, }; static_assert( @@ -717,7 +701,6 @@ namespace { 0.0, 0.0, 0.0, - 0.0, }; static const double to_input[] = { @@ -755,7 +738,6 @@ namespace { 1, 1, 1, - 1, }; static const double from_input[] = { @@ -793,7 +775,6 @@ namespace { 1, 1, 1, - 1, }; static constexpr const char* input_names[static_cast(UnitSystem::measure::_count)] = { @@ -831,7 +812,6 @@ namespace { "SM3/DAY/BARS", "KJ", /* energy */ "BARS/(RM3/DAY)2", /* ICD strength parameter */ - "KG/SM3", /*polymer density */ }; static_assert( diff --git a/ThirdParty/custom-opm-common/opm-common/src/opm/parser/eclipse/Utility/Stringview.cpp b/ThirdParty/custom-opm-common/opm-common/src/opm/parser/eclipse/Utility/Stringview.cpp new file mode 100644 index 0000000000..0b06858ef1 --- /dev/null +++ b/ThirdParty/custom-opm-common/opm-common/src/opm/parser/eclipse/Utility/Stringview.cpp @@ -0,0 +1,9 @@ +#include +#include + +#include + +std::ostream& Opm::operator<<( std::ostream& stream, const Opm::string_view& view ) { + std::copy( view.begin(), view.end(), std::ostream_iterator< char >( stream ) ); + return stream; +} diff --git a/ThirdParty/custom-opm-common/opm-common/src/opm/parser/eclipse/share/keywords/000_Eclipse100/G/GLIFTOPT b/ThirdParty/custom-opm-common/opm-common/src/opm/parser/eclipse/share/keywords/000_Eclipse100/G/GLIFTOPT index dfb14715f3..f665e3042d 100644 --- a/ThirdParty/custom-opm-common/opm-common/src/opm/parser/eclipse/share/keywords/000_Eclipse100/G/GLIFTOPT +++ b/ThirdParty/custom-opm-common/opm-common/src/opm/parser/eclipse/share/keywords/000_Eclipse100/G/GLIFTOPT @@ -11,13 +11,11 @@ { "name": "MAX_LIFT_GAS_SUPPLY", "value_type": "DOUBLE", - "dimension" : "GasSurfaceVolume/Time", "default": -1e+20 }, { "name": "MAX_TOTAL_GAS_RATE", "value_type": "DOUBLE", - "dimension" : "GasSurfaceVolume/Time", "default": -1e+20 } ] diff --git a/ThirdParty/custom-opm-common/opm-common/src/opm/parser/eclipse/share/keywords/000_Eclipse100/G/GPMAINT b/ThirdParty/custom-opm-common/opm-common/src/opm/parser/eclipse/share/keywords/000_Eclipse100/G/GPMAINT index a68521965f..3d1a898b1b 100644 --- a/ThirdParty/custom-opm-common/opm-common/src/opm/parser/eclipse/share/keywords/000_Eclipse100/G/GPMAINT +++ b/ThirdParty/custom-opm-common/opm-common/src/opm/parser/eclipse/share/keywords/000_Eclipse100/G/GPMAINT @@ -18,8 +18,7 @@ }, { "name": "FIP_FAMILY", - "value_type": "STRING", - "default": "FIPNUM" + "value_type": "STRING" }, { "name": "PRESSURE_TARGET", diff --git a/ThirdParty/custom-opm-common/opm-common/src/opm/parser/eclipse/share/keywords/000_Eclipse100/L/LIFTOPT b/ThirdParty/custom-opm-common/opm-common/src/opm/parser/eclipse/share/keywords/000_Eclipse100/L/LIFTOPT index 470c2bcc94..4290ece3f3 100644 --- a/ThirdParty/custom-opm-common/opm-common/src/opm/parser/eclipse/share/keywords/000_Eclipse100/L/LIFTOPT +++ b/ThirdParty/custom-opm-common/opm-common/src/opm/parser/eclipse/share/keywords/000_Eclipse100/L/LIFTOPT @@ -7,18 +7,15 @@ "items": [ { "name": "INCREMENT_SIZE", - "value_type": "DOUBLE", - "dimension" : "GasSurfaceVolume/Time" + "value_type": "DOUBLE" }, { "name": "MIN_ECONOMIC_GRADIENT", - "value_type": "DOUBLE", - "dimension" : "LiquidSurfaceVolume/GasSurfaceVolume" + "value_type": "DOUBLE" }, { "name": "MIN_INTERVAL_BETWEEN_GAS_LIFT_OPTIMIZATIONS", "value_type": "DOUBLE", - "dimension" : "Time", "default": 0 }, { diff --git a/ThirdParty/custom-opm-common/opm-common/src/opm/parser/eclipse/share/keywords/000_Eclipse100/N/NODEPROP b/ThirdParty/custom-opm-common/opm-common/src/opm/parser/eclipse/share/keywords/000_Eclipse100/N/NODEPROP index ab6667c689..f4e6831547 100644 --- a/ThirdParty/custom-opm-common/opm-common/src/opm/parser/eclipse/share/keywords/000_Eclipse100/N/NODEPROP +++ b/ThirdParty/custom-opm-common/opm-common/src/opm/parser/eclipse/share/keywords/000_Eclipse100/N/NODEPROP @@ -18,11 +18,6 @@ "value_type": "STRING", "default": "NO" }, - { - "name": "ADD_GAS_LIFT_GAS", - "value_type": "STRING", - "default": "NO" - }, { "name": "CHOKE_GROUP", "value_type": "STRING" diff --git a/ThirdParty/custom-opm-common/opm-common/src/opm/parser/eclipse/share/keywords/000_Eclipse100/O/OPERATER b/ThirdParty/custom-opm-common/opm-common/src/opm/parser/eclipse/share/keywords/000_Eclipse100/O/OPERATER index ab751b0d45..3b182659f8 100644 --- a/ThirdParty/custom-opm-common/opm-common/src/opm/parser/eclipse/share/keywords/000_Eclipse100/O/OPERATER +++ b/ThirdParty/custom-opm-common/opm-common/src/opm/parser/eclipse/share/keywords/000_Eclipse100/O/OPERATER @@ -9,7 +9,7 @@ ], "items": [ { - "name": "TARGET_ARRAY", + "name": "RESULT_ARRAY", "value_type": "STRING" }, { diff --git a/ThirdParty/custom-opm-common/opm-common/src/opm/parser/eclipse/share/keywords/000_Eclipse100/S/SOLVDIRS b/ThirdParty/custom-opm-common/opm-common/src/opm/parser/eclipse/share/keywords/000_Eclipse100/S/SOLVDIRS index 26631dbee8..b38159892b 100644 --- a/ThirdParty/custom-opm-common/opm-common/src/opm/parser/eclipse/share/keywords/000_Eclipse100/S/SOLVDIRS +++ b/ThirdParty/custom-opm-common/opm-common/src/opm/parser/eclipse/share/keywords/000_Eclipse100/S/SOLVDIRS @@ -3,7 +3,6 @@ "sections": [ "GRID" ], - "size": 1, "items": [ { "name": "DIRECTION", diff --git a/ThirdParty/custom-opm-common/opm-common/src/opm/parser/eclipse/share/keywords/000_Eclipse100/W/WELTARG b/ThirdParty/custom-opm-common/opm-common/src/opm/parser/eclipse/share/keywords/000_Eclipse100/W/WELTARG index 8ab7394e1e..2b88ceac6e 100644 --- a/ThirdParty/custom-opm-common/opm-common/src/opm/parser/eclipse/share/keywords/000_Eclipse100/W/WELTARG +++ b/ThirdParty/custom-opm-common/opm-common/src/opm/parser/eclipse/share/keywords/000_Eclipse100/W/WELTARG @@ -14,7 +14,7 @@ }, { "name": "NEW_VALUE", - "value_type": "UDA" + "value_type": "DOUBLE" } ] } diff --git a/ThirdParty/custom-opm-common/opm-common/src/opm/parser/eclipse/share/keywords/000_Eclipse100/W/WSEGAICD b/ThirdParty/custom-opm-common/opm-common/src/opm/parser/eclipse/share/keywords/000_Eclipse100/W/WSEGAICD index d7a039c429..5ed58fe480 100644 --- a/ThirdParty/custom-opm-common/opm-common/src/opm/parser/eclipse/share/keywords/000_Eclipse100/W/WSEGAICD +++ b/ThirdParty/custom-opm-common/opm-common/src/opm/parser/eclipse/share/keywords/000_Eclipse100/W/WSEGAICD @@ -9,63 +9,62 @@ "value_type": "STRING" }, { - "name": "SEG1", - "value_type": "INT" + "name": "SEGMENT1", + "value_type": "INT", + "default": 0 }, { - "name": "SEG2", - "value_type": "INT" + "name": "SEGMENT2", + "value_type": "INT", + "default": 0 }, { - "name": "STRENGTH", + "name": "AICD_STRENGTH", "value_type": "DOUBLE", - "dimension": "Pressure*Time*Time/GeometricVolume*GeometricVolume" + "default": 0 }, { - "name": "LENGTH", + "name": "ICD_LENGTH", "value_type": "DOUBLE", "dimension": "Length", "default": 12 }, { - "name": "DENSITY_CALI", + "name": "RHO", "value_type": "DOUBLE", - "dimension": "Density", + "dimension": "Mass/Length*Length*Length", "default": 1000.25 }, { - "name": "VISCOSITY_CALI", + "name": "VISCOSITY", "value_type": "DOUBLE", "dimension": "Viscosity", "default": 1.45 }, { - "name": "CRITICAL_VALUE", + "name": "WATER_LIMIT", "value_type": "DOUBLE", - "dimension": "1", "default": 0.5 }, { - "name": "WIDTH_TRANS", + "name": "TRANSITION_WIDTH", "value_type": "DOUBLE", - "dimension": "1", "default": 0.05 }, { - "name": "MAX_VISC_RATIO", + "name": "MAX_SOMETHING", "value_type": "DOUBLE", - "dimension": "1", "default": 5 }, { - "name": "METHOD_SCALING_FACTOR", + "name": "SCALING_METHOD", "value_type": "INT", "default": -1 }, { - "name": "MAX_ABS_RATE", + "name": "MAX_QICD", "value_type": "DOUBLE", - "dimension": "GeometricVolume/Time" + "dimension": "ReservoirVolume/Time" }, { "name": "FLOW_RATE_EXPONENT", @@ -76,7 +75,7 @@ "value_type": "DOUBLE" }, { - "name": "STATUS", + "name": "ICD_FLAG", "value_type": "STRING", "default": "OPEN" }, @@ -96,7 +95,7 @@ "default": 1 }, { - "name": "OIL_VISC_FRACTION", + "name": "OIL_VSIC_FRACTION", "value_type": "DOUBLE", "default": 1 }, diff --git a/ThirdParty/custom-opm-common/opm-common/src/opm/parser/eclipse/share/keywords/900_OPM/P/PERMFACT b/ThirdParty/custom-opm-common/opm-common/src/opm/parser/eclipse/share/keywords/900_OPM/P/PERMFACT index a80ed1f552..3936e806fe 100644 --- a/ThirdParty/custom-opm-common/opm-common/src/opm/parser/eclipse/share/keywords/900_OPM/P/PERMFACT +++ b/ThirdParty/custom-opm-common/opm-common/src/opm/parser/eclipse/share/keywords/900_OPM/P/PERMFACT @@ -3,19 +3,16 @@ "sections": [ "PROPS" ], - "size": { - "keyword": "EQLDIMS", - "item": "NTEQUL" - }, "items": [ - { - "name": "DATA", + { + "name": "POROSITY", "value_type": "DOUBLE", - "size_type": "ALL", - "dimension": [ - "1", - "1" - ] - } + "dimension": "1" + }, + { + "name": "PERMFACTMULT", + "value_type": "DOUBLE", + "dimension": "1" + } ] } diff --git a/ThirdParty/custom-opm-common/opm-common/src/opm/parser/eclipse/share/keywords/900_OPM/R/RWGSALT b/ThirdParty/custom-opm-common/opm-common/src/opm/parser/eclipse/share/keywords/900_OPM/R/RWGSALT index c0ae7c5c59..1a2ae3fdbb 100644 --- a/ThirdParty/custom-opm-common/opm-common/src/opm/parser/eclipse/share/keywords/900_OPM/R/RWGSALT +++ b/ThirdParty/custom-opm-common/opm-common/src/opm/parser/eclipse/share/keywords/900_OPM/R/RWGSALT @@ -3,16 +3,27 @@ "sections": [ "PROPS" ], - "size": { + "num_tables": { "keyword": "TABDIMS", "item": "NTPVT" }, "items": [ { - "name": "DATA", + "name": "RESERVOIR_PRESSURE", + "value_type": "DOUBLE", + "dimension": "Pressure" + }, + { + "name": "SALT_CONCENTRATION", "value_type": "DOUBLE", "size_type": "ALL", - "dimension": ["Pressure","Mass/Length*Length*Length", "OilDissolutionFactor"] + "dimension": "Mass/Length*Length*Length" + }, + { + "name": "DATA", + "size_type": "ALL", + "value_type":"DOUBLE", + "dimension": "OilDissolutionFactor" } ] } diff --git a/ThirdParty/custom-opm-common/opm-common/test_util/EclRegressionTest.cpp b/ThirdParty/custom-opm-common/opm-common/test_util/EclRegressionTest.cpp index 744f0907bc..0f8e333fa5 100644 --- a/ThirdParty/custom-opm-common/opm-common/test_util/EclRegressionTest.cpp +++ b/ThirdParty/custom-opm-common/opm-common/test_util/EclRegressionTest.cpp @@ -895,26 +895,18 @@ void ECLRegressionTest::results_smry() std::vector arrayType2 (keywords1.size(), REAL); if (integrationTest) { - - auto isIntegrationKw = [](const std::string& kw) - { - static const auto kwlist = std::vector { - "WOPR", "WWPR", "WGPR", "WBHP", - "SPR", "SPRD", "SPRDH", "SPRDF", "SPRDA", - }; - - const auto p = kw.find_first_of(':'); - return std::find(kwlist.begin(), kwlist.end(), kw.substr(0, p)) != kwlist.end(); - }; - std::vector keywords; - for (const auto& kw : keywords1) { - if (! isIntegrationKw(kw)) { continue; } - - auto search2 = std::find(keywords2.begin(), keywords2.end(), kw); - if (search2 != keywords2.end()) { - keywords.push_back(kw); + for (size_t i = 0; i < keywords1.size(); i++) { + if (keywords1[i].substr(0,5) == "WOPR:" || + keywords1[i].substr(0,5) == "WWPR:" || + keywords1[i].substr(0,5) == "WGPR:" || + keywords1[i].substr(0,5) == "WBHP:" || + keywords1[i].substr(0,4) == "SPR:") { + auto search2 = std::find(keywords2.begin(), keywords2.end(), keywords1[i]); + if (search2 != keywords2.end()) { + keywords.push_back(keywords1[i]); + } } } diff --git a/ThirdParty/custom-opm-common/opm-common/test_util/convertECL.cpp b/ThirdParty/custom-opm-common/opm-common/test_util/convertECL.cpp index 2e944ae3d1..e2713b65ef 100644 --- a/ThirdParty/custom-opm-common/opm-common/test_util/convertECL.cpp +++ b/ThirdParty/custom-opm-common/opm-common/test_util/convertECL.cpp @@ -175,18 +175,18 @@ int main(int argc, char **argv) { return 0; } - std::map to_formatted = {{".EGRID", ".FEGRID"}, {".INIT", ".FINIT"}, {".SMSPEC", ".FSMSPEC"}, - {".UNSMRY", ".FUNSMRY"}, {".UNRST", ".FUNRST"}, {".RFT", ".FRFT"}, {".LODSMRY", ".FLODSMRY"}}; - - std::map to_binary = {{".FEGRID", ".EGRID"}, {".FINIT", ".INIT"}, {".FSMSPEC", ".SMSPEC"}, - {".FUNSMRY", ".UNSMRY"}, {".FUNRST", ".UNRST"}, {".FRFT", ".RFT"}, {".FLODSMRY", ".LODSMRY"}}; + std::map to_formatted = {{".EGRID", ".FEGRID"}, {".INIT", ".FINIT"}, {".SMSPEC", ".FSMSPEC"}, + {".UNSMRY", ".FUNSMRY"}, {".UNRST", ".FUNRST"}, {".RFT", ".FRFT"}}; + std::map to_binary = {{".FEGRID", ".EGRID"}, {".FINIT", ".INIT"}, {".FSMSPEC", ".SMSPEC"}, + {".FUNSMRY", ".UNSMRY"}, {".FUNRST", ".UNRST"}, {".FRFT", ".RFT"}}; + if (formattedOutput) { - + auto search = to_formatted.find(extension); - + if (search != to_formatted.end()){ - resFile = rootN + search->second; + resFile = rootN + search->second; } else if (extension.substr(1,1)=="X"){ resFile = rootN + ".F" + extension.substr(2); } else if (extension.substr(1,1)=="S"){ @@ -196,11 +196,11 @@ int main(int argc, char **argv) { exit(1); } } else { - + auto search = to_binary.find(extension); if (search != to_binary.end()){ - resFile = rootN + search->second; + resFile = rootN + search->second; } else if (extension.substr(1,1)=="F"){ resFile = rootN + ".X" + extension.substr(2); } else if (extension.substr(1,1)=="A"){ diff --git a/ThirdParty/custom-opm-common/opm-common/test_util/test_esmry_lod.cpp b/ThirdParty/custom-opm-common/opm-common/test_util/test_esmry_lod.cpp new file mode 100644 index 0000000000..0d955d3edb --- /dev/null +++ b/ThirdParty/custom-opm-common/opm-common/test_util/test_esmry_lod.cpp @@ -0,0 +1,230 @@ +#include +#include +#include +#include +#include + +#include +#include + +#include +#include + +using namespace Opm::EclIO; +using EclEntry = EclFile::EclEntry; + + +static void printHelp() { + + std::cout << "\nSmall test program used to test performance for ESmry class. Two arguments needed.\n" + << "\nfirst name of smspec file, and second is vector list:\n" + << "\nExample\n > test_esmry_lod -p out.txt TEST.SMSPEC \"FOPR FGPR\" \n\n" + << "\nIn addition, the program takes these options (which must be given before the arguments):\n\n" + << "-h Print help and exit.\n" + << "-p write selected vectors to file .\n\n"; +} + + +std::vector splitString(std::string str){ + + std::vector res_vect; + + int p1 = 0; + + while (p1 != -1 ) { + p1 = str.find_first_not_of(' ', p1); + int p2 = str.find_first_of(" ", p1+1); + res_vect.push_back(str.substr(p1, p2 - p1) ); + p1 = p2; + } + + return res_vect; +} + + +int main(int argc, char **argv) { + + int c = 0; + bool output = false; + bool compare = false; + bool loadOnDemand = false; + std::string outFileName = ""; + std::string refFileName = ""; + + while ((c = getopt(argc, argv, "hp:c:l")) != -1) { + switch (c) { + case 'h': + printHelp(); + return 0; + case 'p': + output=true; + outFileName = optarg; + break; + case 'c': + compare = true; + refFileName = optarg; + break; + case 'l': + loadOnDemand = true; + break; + + default: + return EXIT_FAILURE; + } + } + + int argOffset = optind; + + if (compare) { + + std::cout << "\ncompare " << argv[argOffset] << " vs ref: " << refFileName << std::endl; + + std::string filename = argv[argOffset]; + + auto lap1 = std::chrono::system_clock::now(); + + ESmry smry1(filename, false); + ESmry smry2(refFileName, false); + + smry1.LoadData(); + smry2.LoadData(); + + auto kwlist1 = smry1.keywordList(); + auto kwlist2 = smry2.keywordList(); + + if (kwlist1.size() !=kwlist2.size()) + throw std::runtime_error("size of keyword lists differ"); + + for (size_t n = 0; n < kwlist1.size(); n++) + if (kwlist1[n] != kwlist1[n]) + throw std::runtime_error("keyword element differ"); + + std::cout << kwlist1.size() << " vs " << kwlist2.size() << std::endl; + + for (auto keyw : kwlist1){ + auto v1 = smry1.get(keyw); + auto v2 = smry2.get(keyw); + + if (v1.size() != v2.size()) + throw std::runtime_error("size of vector differ"); + + for (size_t m = 0; m < v1.size(); m++) { + + float absDiff = abs( v1[m]- v2[m]); + + if (v2[m] > 0.0) + absDiff = absDiff / v2[m]; + + if (absDiff > 0.0000001) { + std::cout << "not equal. keyword: " << keyw << " v1: " << v1[m] << " vs v2: " << v2[m] << std::endl; + exit(1); + } + } + } + + auto lap2 = std::chrono::system_clock::now(); + std::chrono::duration elapsed_seconds2 = lap2-lap1; + + + std::cout << "runtime for test : " << elapsed_seconds2.count() << " seconds\n" << std::endl; + exit(0); + } + /* + do { + std::cout << '\n' << "Press a key to continue..."; + } while ( std::cin.get() != '\n' ); + */ + + // start reading + auto start = std::chrono::system_clock::now(); + std::string filename = argv[argOffset]; + + + ESmry smry1(filename, true); + //ESmry smry1(filename, false); + + auto lap1 = std::chrono::system_clock::now(); + std::chrono::duration elapsed_seconds1 = lap1-start; + + + if (argc < 3) + throw std::invalid_argument("second argument should be a vector list, example \"FOPR FWCT\""); + + std::string inputVectors(argv[argOffset+1]); + std::vector vectKeyList = splitString(inputVectors); + + if (loadOnDemand) { + std::cout << "\nloading vectors "; + for (auto key : vectKeyList) + std::cout << key << " "; + + std::cout << "\n" << std::endl; + + smry1.LoadData(vectKeyList); + } else { + + std::cout << "\nloading all vectors \n" << std::endl; + smry1.LoadData(); + } + + auto lap2 = std::chrono::system_clock::now(); + std::chrono::duration elapsed_seconds2 = lap2-lap1; + + + std::vector> dataList; + + for (auto key : vectKeyList){ + auto vect = smry1.get_at_rstep(key); + dataList.push_back(vect); + } + + auto lap3 = std::chrono::system_clock::now(); + std::chrono::duration elapsed_seconds3 = lap3-lap2; + + + std::cout << "runtime : " << argv[argOffset] << ": " << elapsed_seconds1.count() << " seconds\n" << std::endl; + std::cout << "runtime loading vector list: " << elapsed_seconds2.count() << " seconds\n" << std::endl; + std::cout << "runtime getting vectors vector list: " << elapsed_seconds3.count() << " seconds\n" << std::endl; + + std::chrono::duration elapsed_total = lap3-start; + std::cout << "runtime total: " << elapsed_total.count() << " seconds\n" << std::endl; + + if (output){ + + int colw = 15; + std::cout << "write to file " << outFileName << std::endl; + + std::ofstream outfile; + outfile.open(outFileName); + + outfile << std::setw(colw) << "ts"; + for (auto key : vectKeyList) + outfile << std::setw(colw) << key; + + outfile << std::endl; + + + for (size_t n =1; n < dataList.size(); n++) + if (dataList[n].size() != dataList[n-1].size()) + throw std::runtime_error("size of vectors differs "); + + for (size_t t = 0; t < dataList[0].size(); t++){ + outfile << std::setw(colw) << t; + + for (size_t n = 0; n < dataList.size(); n++) + outfile << std::setw(colw) << std::scientific << std::setprecision(8) << dataList[n][t]; + + outfile << std::endl; + } + + outfile.close(); + } + + /* + do { + std::cout << '\n' << "Press a key to exit ..."; + } while ( std::cin.get() != '\n' ); + */ + + return 0; +} diff --git a/ThirdParty/custom-opm-common/opm-common/tests/SUMMARY_EFF_FAC.DATA b/ThirdParty/custom-opm-common/opm-common/tests/SUMMARY_EFF_FAC.DATA index 8373018c06..3c22f681fb 100644 --- a/ThirdParty/custom-opm-common/opm-common/tests/SUMMARY_EFF_FAC.DATA +++ b/ThirdParty/custom-opm-common/opm-common/tests/SUMMARY_EFF_FAC.DATA @@ -88,17 +88,6 @@ GWCT GGOR / -GOPP -/ -GWPP -/ -GGPP -/ -GGPI -/ -GWPI -/ - FOPR FOPT @@ -107,12 +96,6 @@ FOIR FOIT -FOPP -FWPP -FGPP -FGPI -FWPI - COPR 'W_2' / / diff --git a/ThirdParty/custom-opm-common/opm-common/tests/UDQ_ACTIONX_TEST1.DATA b/ThirdParty/custom-opm-common/opm-common/tests/UDQ_ACTIONX_TEST1.DATA index 254e65e8e4..8fafc22d0a 100644 --- a/ThirdParty/custom-opm-common/opm-common/tests/UDQ_ACTIONX_TEST1.DATA +++ b/ThirdParty/custom-opm-common/opm-common/tests/UDQ_ACTIONX_TEST1.DATA @@ -403,7 +403,7 @@ GUIDERAT ACTIONX ACT01 10 / WWPR 'OP*' > 17 OR / -GMWPR 'TEST' > 14 AND / +GMWPR 'T*' > 14 AND / DAY > 3 / / WELOPEN @@ -433,7 +433,7 @@ DATES ACTIONX ACT03 13 / WWPR 'OPU02' > WWPR 'OPU01' OR / -GMWPR 'TEST' > 39 AND / +GMWPR 'T*' > 39 AND / YEAR > 2019 / / WELOPEN diff --git a/ThirdParty/custom-opm-common/opm-common/tests/UDQ_BASE.DATA b/ThirdParty/custom-opm-common/opm-common/tests/UDQ_BASE.DATA deleted file mode 100644 index ce3a18caa1..0000000000 --- a/ThirdParty/custom-opm-common/opm-common/tests/UDQ_BASE.DATA +++ /dev/null @@ -1,373 +0,0 @@ -RUNSPEC - -TITLE -2 PRODUCERS AND INJECTORS, 2 WELL GROUPS AND ONE INTERMEDIATE GROUP LEVEL BELOW THE FIELD LEVEL - -DIMENS - 10 5 10 / - -START - 1 'JAN' 2000 / - - -OIL - -WATER - -GAS - -DISGAS - -FIELD - -TABDIMS - 1 1 15 15 2 15 / - -EQLDIMS - 2 / - -WELLDIMS - 5 20 4 2 / - -UNIFIN -UNIFOUT - -FMTIN -FMTOUT --- Dimensions for used defined quantity facility --- max functions permitted in a quantity definition --- max arguments permitted in a quantity definition --- max user defined connection quantities --- max user defined field quantities --- max user defined group quantities --- max user defined region quantities --- max user defined segment quantities --- max user defined well quantities --- max user defined aquifer quantities --- max user defined block quantities --- whether new randon number generator seed computed for restart runs -UDQDIMS - 50 25 0 50 50 0 0 50 0 20 / - --- Dimensions for the user defined arguments facility --- number of keyword arguments in which UDQs replace numerical values --- ratained for back-compatibility --- total number of unique instances in which a UDQ is used in a keyword argument -UDADIMS - 10 1* 10 / - - --- RPTRUNSP - -GRID ========================================================= - ---NOGGF -BOX - 1 10 1 5 1 1 / - -TOPS -50*7000 / - -BOX -1 10 1 5 1 10 / - -DXV -10*100 / -DYV -5*100 / -DZV -2*20 100 7*20 / - -EQUALS --- 'DX' 100 / --- 'DY' 100 / - 'PERMX' 50 / - 'PERMZ' 5 / --- 'DZ' 20 / - 'PORO' 0.2 / --- 'TOPS' 7000 1 10 1 5 1 1 / - --'DZ' 100 1 10 1 5 3 3 / - 'PORO' 0.0 1 10 1 5 3 3 / - / - -COPY - PERMX PERMY / - / - -PORO - 500*0.15 / - -RPTGRID - -- Report Levels for Grid Section Data - -- - / - -PROPS ========================================================== - --- WATER RELATIVE PERMEABILITY AND CAPILLARY PRESSURE ARE TABULATED AS --- A FUNCTION OF WATER SATURATION. --- --- SWAT KRW PCOW -SWFN - - 0.12 0 0 - 1.0 0.00001 0 / - --- SIMILARLY FOR GAS --- --- SGAS KRG PCOG -SGFN - - 0 0 0 - 0.02 0 0 - 0.05 0.005 0 - 0.12 0.025 0 - 0.2 0.075 0 - 0.25 0.125 0 - 0.3 0.19 0 - 0.4 0.41 0 - 0.45 0.6 0 - 0.5 0.72 0 - 0.6 0.87 0 - 0.7 0.94 0 - 0.85 0.98 0 - 1.0 1.0 0 -/ - --- OIL RELATIVE PERMEABILITY IS TABULATED AGAINST OIL SATURATION --- FOR OIL-WATER AND OIL-GAS-CONNATE WATER CASES --- --- SOIL KROW KROG -SOF3 - - 0 0 0 - 0.18 0 0 - 0.28 0.0001 0.0001 - 0.38 0.001 0.001 - 0.43 0.01 0.01 - 0.48 0.021 0.021 - 0.58 0.09 0.09 - 0.63 0.2 0.2 - 0.68 0.35 0.35 - 0.76 0.7 0.7 - 0.83 0.98 0.98 - 0.86 0.997 0.997 - 0.879 1 1 - 0.88 1 1 / - - --- PVT PROPERTIES OF WATER --- --- REF. PRES. REF. FVF COMPRESSIBILITY REF VISCOSITY VISCOSIBILITY -PVTW - 4014.7 1.029 3.13D-6 0.31 0 / - --- ROCK COMPRESSIBILITY --- --- REF. PRES COMPRESSIBILITY -ROCK - 14.7 3.0D-6 / - --- SURFACE DENSITIES OF RESERVOIR FLUIDS --- --- OIL WATER GAS -DENSITY - 49.1 64.79 0.06054 / - --- PVT PROPERTIES OF DRY GAS (NO VAPOURISED OIL) --- WE WOULD USE PVTG TO SPECIFY THE PROPERTIES OF WET GAS --- --- PGAS BGAS VISGAS -PVDG - 14.7 166.666 0.008 - 264.7 12.093 0.0096 - 514.7 6.274 0.0112 - 1014.7 3.197 0.014 - 2014.7 1.614 0.0189 - 2514.7 1.294 0.0208 - 3014.7 1.080 0.0228 - 4014.7 0.811 0.0268 - 5014.7 0.649 0.0309 - 9014.7 0.386 0.047 / - --- PVT PROPERTIES OF LIVE OIL (WITH DISSOLVED GAS) --- WE WOULD USE PVDO TO SPECIFY THE PROPERTIES OF DEAD OIL --- --- FOR EACH VALUE OF RS THE SATURATION PRESSURE, FVF AND VISCOSITY --- ARE SPECIFIED. FOR RS=1.27 AND 1.618, THE FVF AND VISCOSITY OF --- UNDERSATURATED OIL ARE DEFINED AS A FUNCTION OF PRESSURE. DATA --- FOR UNDERSATURATED OIL MAY BE SUPPLIED FOR ANY RS, BUT MUST BE --- SUPPLIED FOR THE HIGHEST RS (1.618). --- --- RS POIL FVFO VISO -PVTO - 0.001 14.7 1.062 1.04 / - 0.0905 264.7 1.15 0.975 / - 0.18 514.7 1.207 0.91 / - 0.371 1014.7 1.295 0.83 / - 0.636 2014.7 1.435 0.695 / - 0.775 2514.7 1.5 0.641 / - 0.93 3014.7 1.565 0.594 / - 1.270 4014.7 1.695 0.51 - 5014.7 1.671 0.549 - 9014.7 1.579 0.74 / - 1.618 5014.7 1.827 0.449 - 9014.7 1.726 0.605 / -/ - - -RPTPROPS --- PROPS Reporting Options --- -/ - -REGIONS =========================================================== - - -FIPNUM - - 100*1 - 400*2 -/ - -EQLNUM - - 100*1 - 400*2 -/ - -RPTREGS - - / - -SOLUTION ============================================================ - -EQUIL - 7020.00 2700.00 7990.00 .00000 7020.00 .00000 0 0 5 / - 7200.00 3700.00 7300.00 .00000 7000.00 .00000 1 0 5 / - -RSVD 2 TABLES 3 NODES IN EACH FIELD 12:00 17 AUG 83 - 7000.0 1.0000 - 7990.0 1.0000 -/ - 7000.0 1.0000 - 7400.0 1.0000 -/ - -RPTRST --- Restart File Output Control --- -'BASIC=2' 'FLOWS' 'POT' 'PRES' / - - -SUMMARY =========================================================== - -FOPR - -WOPR - / - -FGPR - -FWPR - -FWIR - -FWCT - -FGOR - ---RUNSUM - -ALL - -MSUMLINS - -MSUMNEWT - -SEPARATE - -SCHEDULE =========================================================== - -DEBUG - 1 3 / - -DRSDT - 1.0E20 / - -RPTSCHED - 'PRES' 'SWAT' 'SGAS' 'RESTART=1' 'RS' 'WELLS=2' 'SUMMARY=2' - 'CPU=2' 'WELSPECS' 'NEWTON=2' / - - -GRUPTREE - 'GRP1' 'FIELD' / - 'WGRP1' 'GRP1' / - 'WGRP2' 'GRP1' / -/ - -WELSPECS - 'PROD1' 'WGRP1' 1 5 7030 'OIL' 0.0 'STD' 'STOP' / - 'PROD2' 'WGRP2' 1 5 7030 'OIL' 0.0 'STD' 'STOP' / - 'WINJ1' 'WGRP1' 10 1 7030 'WAT' 0.0 'STD' 'STOP' / - 'WINJ2' 'WGRP2' 10 1 7030 'WAT' 0.0 'STD' 'STOP' / -/ - -COMPDAT - - 'PROD1' 1 5 2 2 3* 0.2 3* 'X' / - 'PROD1' 2 5 2 2 3* 0.2 3* 'X' / - 'PROD1' 3 5 2 2 3* 0.2 3* 'X' / - 'PROD2' 4 5 2 2 3* 0.2 3* 'X' / - 'PROD2' 5 5 2 2 3* 0.2 3* 'X' / - - 'WINJ1' 10 1 9 9 3* 0.2 3* 'X' / - 'WINJ1' 9 1 9 9 3* 0.2 3* 'X' / - 'WINJ1' 8 1 9 9 3* 0.2 3* 'X' / - 'WINJ2' 7 1 9 9 3* 0.2 3* 'X' / - 'WINJ2' 6 1 9 9 3* 0.2 3* 'X' / -/ - - - -UDQ --- test ---oil & liquid capacities at GEFAC = 0.8995 -DEFINE WUOPRL (WOPR PROD1 - 150) * 0.90 / -DEFINE WULPRL (WLPR PROD1 - 200) * 0.90 / -DEFINE WUOPRU (WOPR PROD2 - 250) * 0.80 / -DEFINE GUOPRU (GOPR GRP1 - 449) * 0.77 / -DEFINE WULPRU (WLPR PROD2 - 300) * 0.80 / -ASSIGN WULPRL 400. / -DEFINE FULPR (FLPR - 543) * 0.65 / -DEFINE WUOPRL (WOPR PROD1 - 170) * 0.60 / --- units -UNITS WUOPRL SM3/DAY / -UNITS WULPRL SM3/DAY / -UNITS GUOPRU SM3/DAY / -UNITS WUOPRU SM3/DAY / -UNITS WULPRU SM3/DAY / -UNITS FULPR SM3/DAY / --- -/ - -WCONPROD - 'PROD1' 'OPEN' 'GRUP' WUOPRU 1* 1* WULPRU 1* 60.0 / single wells - 'PROD2' 'OPEN' 'GRUP' WUOPRU 1* 1* WULPRU 1* 60.0 / single wells -/ - - -DATES - 1 'FEB' 2000 / -/ - -DATES - 1 'MAR' 2000 / -/ - -DATES - 1 'APR' 2000 / -/ - - -END diff --git a/ThirdParty/custom-opm-common/opm-common/tests/UDQ_RESTART.DATA b/ThirdParty/custom-opm-common/opm-common/tests/UDQ_RESTART.DATA deleted file mode 100644 index fa9eb9f4b2..0000000000 --- a/ThirdParty/custom-opm-common/opm-common/tests/UDQ_RESTART.DATA +++ /dev/null @@ -1,376 +0,0 @@ -RUNSPEC - -TITLE -2 PRODUCERS AND INJECTORS, 2 WELL GROUPS AND ONE INTERMEDIATE GROUP LEVEL BELOW THE FIELD LEVEL - -DIMENS - 10 5 10 / - -START - 1 'JAN' 2000 / - - -OIL - -WATER - -GAS - -DISGAS - -FIELD - -TABDIMS - 1 1 15 15 2 15 / - -EQLDIMS - 2 / - -WELLDIMS - 5 20 4 2 / - -UNIFIN -UNIFOUT - -FMTIN -FMTOUT --- Dimensions for used defined quantity facility --- max functions permitted in a quantity definition --- max arguments permitted in a quantity definition --- max user defined connection quantities --- max user defined field quantities --- max user defined group quantities --- max user defined region quantities --- max user defined segment quantities --- max user defined well quantities --- max user defined aquifer quantities --- max user defined block quantities --- whether new randon number generator seed computed for restart runs -UDQDIMS - 50 25 0 50 50 0 0 50 0 20 / - --- Dimensions for the user defined arguments facility --- number of keyword arguments in which UDQs replace numerical values --- ratained for back-compatibility --- total number of unique instances in which a UDQ is used in a keyword argument -UDADIMS - 10 1* 10 / - - --- RPTRUNSP - -GRID ========================================================= - ---NOGGF -BOX - 1 10 1 5 1 1 / - -TOPS -50*7000 / - -BOX -1 10 1 5 1 10 / - -DXV -10*100 / -DYV -5*100 / -DZV -2*20 100 7*20 / - -EQUALS --- 'DX' 100 / --- 'DY' 100 / - 'PERMX' 50 / - 'PERMZ' 5 / --- 'DZ' 20 / - 'PORO' 0.2 / --- 'TOPS' 7000 1 10 1 5 1 1 / - --'DZ' 100 1 10 1 5 3 3 / - 'PORO' 0.0 1 10 1 5 3 3 / - / - -COPY - PERMX PERMY / - / - -PORO - 500*0.15 / - -RPTGRID - -- Report Levels for Grid Section Data - -- - / - -PROPS ========================================================== - --- WATER RELATIVE PERMEABILITY AND CAPILLARY PRESSURE ARE TABULATED AS --- A FUNCTION OF WATER SATURATION. --- --- SWAT KRW PCOW -SWFN - - 0.12 0 0 - 1.0 0.00001 0 / - --- SIMILARLY FOR GAS --- --- SGAS KRG PCOG -SGFN - - 0 0 0 - 0.02 0 0 - 0.05 0.005 0 - 0.12 0.025 0 - 0.2 0.075 0 - 0.25 0.125 0 - 0.3 0.19 0 - 0.4 0.41 0 - 0.45 0.6 0 - 0.5 0.72 0 - 0.6 0.87 0 - 0.7 0.94 0 - 0.85 0.98 0 - 1.0 1.0 0 -/ - --- OIL RELATIVE PERMEABILITY IS TABULATED AGAINST OIL SATURATION --- FOR OIL-WATER AND OIL-GAS-CONNATE WATER CASES --- --- SOIL KROW KROG -SOF3 - - 0 0 0 - 0.18 0 0 - 0.28 0.0001 0.0001 - 0.38 0.001 0.001 - 0.43 0.01 0.01 - 0.48 0.021 0.021 - 0.58 0.09 0.09 - 0.63 0.2 0.2 - 0.68 0.35 0.35 - 0.76 0.7 0.7 - 0.83 0.98 0.98 - 0.86 0.997 0.997 - 0.879 1 1 - 0.88 1 1 / - - --- PVT PROPERTIES OF WATER --- --- REF. PRES. REF. FVF COMPRESSIBILITY REF VISCOSITY VISCOSIBILITY -PVTW - 4014.7 1.029 3.13D-6 0.31 0 / - --- ROCK COMPRESSIBILITY --- --- REF. PRES COMPRESSIBILITY -ROCK - 14.7 3.0D-6 / - --- SURFACE DENSITIES OF RESERVOIR FLUIDS --- --- OIL WATER GAS -DENSITY - 49.1 64.79 0.06054 / - --- PVT PROPERTIES OF DRY GAS (NO VAPOURISED OIL) --- WE WOULD USE PVTG TO SPECIFY THE PROPERTIES OF WET GAS --- --- PGAS BGAS VISGAS -PVDG - 14.7 166.666 0.008 - 264.7 12.093 0.0096 - 514.7 6.274 0.0112 - 1014.7 3.197 0.014 - 2014.7 1.614 0.0189 - 2514.7 1.294 0.0208 - 3014.7 1.080 0.0228 - 4014.7 0.811 0.0268 - 5014.7 0.649 0.0309 - 9014.7 0.386 0.047 / - --- PVT PROPERTIES OF LIVE OIL (WITH DISSOLVED GAS) --- WE WOULD USE PVDO TO SPECIFY THE PROPERTIES OF DEAD OIL --- --- FOR EACH VALUE OF RS THE SATURATION PRESSURE, FVF AND VISCOSITY --- ARE SPECIFIED. FOR RS=1.27 AND 1.618, THE FVF AND VISCOSITY OF --- UNDERSATURATED OIL ARE DEFINED AS A FUNCTION OF PRESSURE. DATA --- FOR UNDERSATURATED OIL MAY BE SUPPLIED FOR ANY RS, BUT MUST BE --- SUPPLIED FOR THE HIGHEST RS (1.618). --- --- RS POIL FVFO VISO -PVTO - 0.001 14.7 1.062 1.04 / - 0.0905 264.7 1.15 0.975 / - 0.18 514.7 1.207 0.91 / - 0.371 1014.7 1.295 0.83 / - 0.636 2014.7 1.435 0.695 / - 0.775 2514.7 1.5 0.641 / - 0.93 3014.7 1.565 0.594 / - 1.270 4014.7 1.695 0.51 - 5014.7 1.671 0.549 - 9014.7 1.579 0.74 / - 1.618 5014.7 1.827 0.449 - 9014.7 1.726 0.605 / -/ - - -RPTPROPS --- PROPS Reporting Options --- -/ - -REGIONS =========================================================== - - -FIPNUM - - 100*1 - 400*2 -/ - -EQLNUM - - 100*1 - 400*2 -/ - -RPTREGS - - / - -SOLUTION ============================================================ - -RESTART - 'UDQ_BASE' 1 / - -RSVD 2 TABLES 3 NODES IN EACH FIELD 12:00 17 AUG 83 - 7000.0 1.0000 - 7990.0 1.0000 -/ - 7000.0 1.0000 - 7400.0 1.0000 -/ - -RPTRST --- Restart File Output Control --- -'BASIC=2' 'FLOWS' 'POT' 'PRES' / - - -SUMMARY =========================================================== - -FOPR - -WOPR - / - -FGPR - -FWPR - -FWIR - -FWCT - -FGOR - ---RUNSUM - -ALL - -MSUMLINS - -MSUMNEWT - -SEPARATE - -SCHEDULE =========================================================== - -DEBUG - 1 3 / - -DRSDT - 1.0E20 / - -RPTSCHED - 'PRES' 'SWAT' 'SGAS' 'RESTART=1' 'RS' 'WELLS=2' 'SUMMARY=2' - 'CPU=2' 'WELSPECS' 'NEWTON=2' / - -NOECHO - - -ECHO - -GRUPTREE - 'GRP1' 'FIELD' / - 'WGRP1' 'GRP1' / - 'WGRP2' 'GRP1' / -/ - -WELSPECS - 'PROD1' 'WGRP1' 1 5 7030 'OIL' 0.0 'STD' 'STOP' / - 'PROD2' 'WGRP2' 1 5 7030 'OIL' 0.0 'STD' 'STOP' / - 'WINJ1' 'WGRP1' 10 1 7030 'WAT' 0.0 'STD' 'STOP' / - 'WINJ2' 'WGRP2' 10 1 7030 'WAT' 0.0 'STD' 'STOP' / -/ - -COMPDAT - - 'PROD1' 1 5 2 2 3* 0.2 3* 'X' / - 'PROD1' 2 5 2 2 3* 0.2 3* 'X' / - 'PROD1' 3 5 2 2 3* 0.2 3* 'X' / - 'PROD2' 4 5 2 2 3* 0.2 3* 'X' / - 'PROD2' 5 5 2 2 3* 0.2 3* 'X' / - - 'WINJ1' 10 1 9 9 3* 0.2 3* 'X' / - 'WINJ1' 9 1 9 9 3* 0.2 3* 'X' / - 'WINJ1' 8 1 9 9 3* 0.2 3* 'X' / - 'WINJ2' 7 1 9 9 3* 0.2 3* 'X' / - 'WINJ2' 6 1 9 9 3* 0.2 3* 'X' / -/ - - - -UDQ --- test ---oil & liquid capacities at GEFAC = 0.8995 -DEFINE WUOPRL (WOPR PROD1 - 150) * 0.90 / -DEFINE WULPRL (WLPR PROD1 - 200) * 0.90 / -DEFINE WUOPRU (WOPR PROD2 - 250) * 0.80 / -DEFINE GUOPRU (GOPR GRP1 - 449) * 0.77 / -DEFINE WULPRU (WLPR PROD2 - 300) * 0.80 / -ASSIGN WULPRL 400. / -DEFINE FULPR (FLPR - 543) * 0.65 / -DEFINE WUOPRL (WOPR PROD1 - 170) * 0.60 / --- units -UNITS WUOPRL SM3/DAY / -UNITS WULPRL SM3/DAY / -UNITS GUOPRU SM3/DAY / -UNITS WUOPRU SM3/DAY / -UNITS WULPRU SM3/DAY / -UNITS FULPR SM3/DAY / --- -/ - -WCONPROD - 'PROD1' 'OPEN' 'GRUP' WUOPRU 1* 1* WULPRU 1* 60.0 / single wells - 'PROD2' 'OPEN' 'GRUP' WUOPRU 1* 1* WULPRU 1* 60.0 / single wells -/ - - -DATES - 1 'FEB' 2000 / -/ - - -DATES - 1 'MAR' 2000 / -/ - -DATES - 1 'APR' 2000 / -/ - -END diff --git a/ThirdParty/custom-opm-common/opm-common/tests/group_group.DATA b/ThirdParty/custom-opm-common/opm-common/tests/group_group.DATA index e24157b17a..4ac989d63a 100644 --- a/ThirdParty/custom-opm-common/opm-common/tests/group_group.DATA +++ b/ThirdParty/custom-opm-common/opm-common/tests/group_group.DATA @@ -84,7 +84,6 @@ FLPRH FGSR FGCR FNPR -- solvent -FCPR --FTPRSEA -- Injection Rates FVIR @@ -106,7 +105,6 @@ FGPTH FWPTH FGST FGCT -FCPT -- Injection Cummulatives FVIT FWIT @@ -322,12 +320,6 @@ GMWPR / GMWIN / - -GVPR -/ - -GVPT -/ -- Well Data -- Production Rates WWPR @@ -355,8 +347,6 @@ WLPT WLPTH / -WCPR -/ -- Production Cummulatives WWPT @@ -374,9 +364,6 @@ WGPTH WNPT / -WCPT -/ - -- Tracers --WTPRSEA --/ diff --git a/ThirdParty/custom-opm-common/opm-common/tests/json/jsonTests.cpp b/ThirdParty/custom-opm-common/opm-common/tests/json/jsonTests.cpp index 7a601bf9db..f9efe6bda9 100644 --- a/ThirdParty/custom-opm-common/opm-common/tests/json/jsonTests.cpp +++ b/ThirdParty/custom-opm-common/opm-common/tests/json/jsonTests.cpp @@ -280,35 +280,4 @@ BOOST_AUTO_TEST_CASE(to_string_ok) { } -BOOST_AUTO_TEST_CASE(create) { - Json::JsonObject json; - json.add_item("name", "Awesome 4D"); - json.add_item("size", 100); - json.add_item("pi", 3.14159265); - { - auto list = json.add_array("array"); - list.add("String"); - list.add(100); - list.add(2.7172); - } - { - auto dict = json.add_object("object"); - dict.add_item("key", "String"); - dict.add_item("int", 100); - dict.add_item("double", 2.7172); - } - std::string s = json.dump(); - Json::JsonObject json2(s); - BOOST_CHECK_EQUAL(json2.get_string("name"), "Awesome 4D"); - BOOST_CHECK_EQUAL(json2.get_int("size"), 100); - - auto array = json2.get_item("array"); - BOOST_CHECK( array.is_array() ); - BOOST_CHECK_EQUAL( array.size(), 3 ); - BOOST_CHECK_EQUAL( array.get_array_item(2).as_double(), 2.7172 ); - - auto dict = json2.get_item("object"); - BOOST_CHECK( dict.is_object() ); - BOOST_CHECK_EQUAL( dict.get_string("key"), "String"); -} diff --git a/ThirdParty/custom-opm-common/opm-common/tests/msim/test_msim_ACTIONX.cpp b/ThirdParty/custom-opm-common/opm-common/tests/msim/test_msim_ACTIONX.cpp index f5605a5bbc..aabec48799 100644 --- a/ThirdParty/custom-opm-common/opm-common/tests/msim/test_msim_ACTIONX.cpp +++ b/ThirdParty/custom-opm-common/opm-common/tests/msim/test_msim_ACTIONX.cpp @@ -343,8 +343,6 @@ BOOST_AUTO_TEST_CASE(UDA) { #include "uda.include" test_data td( uda_deck ); msim sim(td.state); - auto eps_lim = sim.uda_val().epsilonLimit(); - EclipseIO io(td.state, td.state.getInputGrid(), td.schedule, td.summary_config); sim.well_rate("P1", data::Rates::opt::wat, prod_wpr_P1); @@ -370,10 +368,8 @@ BOOST_AUTO_TEST_CASE(UDA) { std::string wwpr_key = std::string("WWPR:") + well; wwpr_sum += ecl_sum_get_general_var(ecl_sum, prev_tstep, wwpr_key.c_str()); } - wwpr_sum = 0.90 * wwpr_sum; - wwpr_sum = std::max(eps_lim, wwpr_sum); } - BOOST_CHECK_CLOSE( wwpr_sum, ecl_sum_get_general_var(ecl_sum, ecl_sum_iget_report_end(ecl_sum, report_step), "WWIR:INJ"), 1e-3); + BOOST_CHECK_CLOSE( 0.90 * wwpr_sum, ecl_sum_get_general_var(ecl_sum, ecl_sum_iget_report_end(ecl_sum, report_step), "WWIR:INJ"), 1e-3); } } } diff --git a/ThirdParty/custom-opm-common/opm-common/tests/parser/ACTIONX.cpp b/ThirdParty/custom-opm-common/opm-common/tests/parser/ACTIONX.cpp index ef75f8ec20..5865101ad2 100644 --- a/ThirdParty/custom-opm-common/opm-common/tests/parser/ACTIONX.cpp +++ b/ThirdParty/custom-opm-common/opm-common/tests/parser/ACTIONX.cpp @@ -37,10 +37,7 @@ #include #include #include -#include #include -#include -#include #include #include #include @@ -152,8 +149,7 @@ TSTEP BOOST_AUTO_TEST_CASE(TestActions) { Opm::SummaryState st(std::chrono::system_clock::now()); - Opm::WListManager wlm; - Opm::Action::Context context(st, wlm); + Opm::Action::Context context(st); Opm::Action::Actions config; std::vector matching_wells; auto python = std::make_shared(); @@ -183,19 +179,18 @@ BOOST_AUTO_TEST_CASE(TestActions) { config.add(py_action2); } const Opm::Action::ActionX& action2 = config.get("NAME"); - Opm::Action::State action_state; // The action2 instance has an empty condition, so it will never evaluate to true. - BOOST_CHECK(action2.ready( action_state, asTimeT(TimeStampUTC(TimeStampUTC::YMD{ 2000, 7, 1 })) )); - BOOST_CHECK(!action2.ready( action_state, asTimeT(TimeStampUTC(TimeStampUTC::YMD{ 2000, 6, 1 })) )); - BOOST_CHECK(!action2.eval(context)); + BOOST_CHECK(action2.ready( asTimeT(TimeStampUTC(TimeStampUTC::YMD{ 2000, 7, 1 })) )); + BOOST_CHECK(!action2.ready( asTimeT(TimeStampUTC(TimeStampUTC::YMD{ 2000, 6, 1 })) )); + BOOST_CHECK(!action2.eval(asTimeT(TimeStampUTC(TimeStampUTC::YMD{ 2000, 6, 1 })), context)); - auto pending = config.pending( action_state, asTimeT(TimeStampUTC(TimeStampUTC::YMD{ 2000, 8, 7 })) ); + auto pending = config.pending( asTimeT(TimeStampUTC(TimeStampUTC::YMD{ 2000, 8, 7 })) ); BOOST_CHECK_EQUAL( pending.size(), 2); for (auto& ptr : pending) { - BOOST_CHECK( ptr->ready( action_state, asTimeT(TimeStampUTC(TimeStampUTC::YMD{ 2000, 8, 7 })) )); - BOOST_CHECK( !ptr->eval( context)); + BOOST_CHECK( ptr->ready( asTimeT(TimeStampUTC(TimeStampUTC::YMD{ 2000, 8, 7 })) )); + BOOST_CHECK( !ptr->eval(asTimeT(TimeStampUTC(TimeStampUTC::YMD{ 2000, 8, 7 })), context)); } - BOOST_CHECK(!action2.eval(context)); + BOOST_CHECK(!action2.eval(asTimeT(TimeStampUTC(TimeStampUTC::YMD{ 2000, 8, 7 })), context)); const auto& python_actions = config.pending_python(); @@ -207,8 +202,7 @@ BOOST_AUTO_TEST_CASE(TestActions) { BOOST_AUTO_TEST_CASE(TestContext) { Opm::SummaryState st(std::chrono::system_clock::now()); st.update_well_var("OP1", "WOPR", 100); - Opm::WListManager wlm; - Opm::Action::Context context(st, wlm); + Opm::Action::Context context(st); BOOST_REQUIRE_THROW(context.get("func", "arg"), std::out_of_range); @@ -263,8 +257,7 @@ BOOST_AUTO_TEST_CASE(TestAction_AST_BASIC) { Action::AST ast2({"WWCT", "OPX", "=", "WWCT", "OPX"}); Action::AST ast3({"WWCT", "OPY", ">", "0.75"}); SummaryState st(std::chrono::system_clock::now()); - WListManager wlm; - Action::Context context(st, wlm); + Action::Context context(st); std::vector matching_wells; context.add("WWCT", "OPX", 100); @@ -282,8 +275,7 @@ BOOST_AUTO_TEST_CASE(TestAction_AST_OR_AND) { Action::AST ast_and({"WWCT", "OPX", ">", "0.75", "AND", "WWCT", "OPY", ">", "0.75"}); Action::AST par({"WWCT", "OPX", ">", "0.75", "AND", "(", "WWCT", "OPY", ">", "0.75", "OR", "WWCT", "OPZ", ">", "0.75", ")"}); SummaryState st(std::chrono::system_clock::now()); - WListManager wlm; - Action::Context context(st, wlm); + Action::Context context(st); context.add("WWCT", "OPX", 100); context.add("WWCT", "OPY", -100); @@ -319,8 +311,7 @@ BOOST_AUTO_TEST_CASE(TestAction_AST_OR_AND) { BOOST_AUTO_TEST_CASE(DATE) { Action::AST ast(std::vector{"MNTH", ">=", "JUN"}); SummaryState st(std::chrono::system_clock::now()); - WListManager wlm; - Action::Context context(st, wlm); + Action::Context context(st); context.add("MNTH", 6); BOOST_CHECK( ast.eval(context)); @@ -336,8 +327,7 @@ BOOST_AUTO_TEST_CASE(DATE) { BOOST_AUTO_TEST_CASE(MANUAL1) { Action::AST ast({"GGPR", "FIELD", ">", "50000", "AND", "WGOR", "PR", ">" ,"GGOR", "FIELD"}); SummaryState st(std::chrono::system_clock::now()); - WListManager wlm; - Action::Context context(st, wlm); + Action::Context context(st); context.add("GGPR", "FIELD", 60000 ); context.add("WGOR", "PR" , 300 ); @@ -358,8 +348,7 @@ BOOST_AUTO_TEST_CASE(MANUAL1) { BOOST_AUTO_TEST_CASE(MANUAL2) { Action::AST ast({"GWCT", "LIST1", ">", "0.70", "AND", "(", "GWPR", "LIST1", ">", "GWPR", "LIST2", "OR", "GWPR", "LIST1", ">", "GWPR", "LIST3", ")"}); SummaryState st(std::chrono::system_clock::now()); - WListManager wlm; - Action::Context context(st, wlm); + Action::Context context(st); context.add("GWCT", "LIST1", 1.0); context.add("GWPR", "LIST1", 1 ); @@ -395,8 +384,7 @@ BOOST_AUTO_TEST_CASE(MANUAL2) { BOOST_AUTO_TEST_CASE(MANUAL3) { Action::AST ast({"MNTH", ".GE.", "MAR", "AND", "MNTH", ".LE.", "OCT", "AND", "GMWL", "HIGH", ".GE.", "4"}); SummaryState st(std::chrono::system_clock::now()); - WListManager wlm; - Action::Context context(st, wlm); + Action::Context context(st); context.add("MNTH", 4); context.add("GMWL", "HIGH", 4); @@ -419,8 +407,7 @@ BOOST_AUTO_TEST_CASE(MANUAL3) { BOOST_AUTO_TEST_CASE(MANUAL4) { Action::AST ast({"GWCT", "FIELD", ">", "0.8", "AND", "DAY", ">", "1", "AND", "MNTH", ">", "JUN", "AND", "YEAR", ">=", "2021"}); SummaryState st(std::chrono::system_clock::now()); - WListManager wlm; - Action::Context context(st, wlm); + Action::Context context(st); context.add("MNTH", 7); context.add("DAY", 2); @@ -440,8 +427,7 @@ BOOST_AUTO_TEST_CASE(MANUAL4) { BOOST_AUTO_TEST_CASE(MANUAL5) { Action::AST ast({"WCG2", "PROD1", ">", "WCG5", "PROD2", "AND", "GCG3", "G1", ">", "GCG7", "G2", "OR", "FCG1", ">", "FCG7"}); SummaryState st(std::chrono::system_clock::now()); - WListManager wlm; - Action::Context context(st, wlm); + Action::Context context(st); context.add("WCG2", "PROD1", 100); context.add("WCG5", "PROD2", 50); @@ -481,8 +467,7 @@ BOOST_AUTO_TEST_CASE(MANUAL5) { BOOST_AUTO_TEST_CASE(LGR) { Action::AST ast({"LWCC" , "OPX", "LOCAL", "1", "2", "3", ">", "100"}); SummaryState st(std::chrono::system_clock::now()); - WListManager wlm; - Action::Context context(st, wlm); + Action::Context context(st); context.add("LWCC", "OPX:LOCAL:1:2:3", 200); BOOST_CHECK(ast.eval(context)); @@ -495,8 +480,7 @@ BOOST_AUTO_TEST_CASE(LGR) { BOOST_AUTO_TEST_CASE(Action_ContextTest) { SummaryState st(std::chrono::system_clock::now()); st.update("WWCT:OP1", 100); - WListManager wlm; - Action::Context context(st, wlm); + Action::Context context(st); BOOST_CHECK_EQUAL(context.get("WWCT", "OP1"), 100); @@ -512,8 +496,8 @@ BOOST_AUTO_TEST_CASE(Action_ContextTest) { BOOST_AUTO_TEST_CASE(TestGroupList) { Action::AST ast({"GWPR", "*", ">", "1.0"}); SummaryState st(std::chrono::system_clock::now()); - WListManager wlm; - Action::Context context(st, wlm); + + Action::Context context(st); BOOST_CHECK_THROW( ast.eval(context), std::logic_error ); } @@ -525,8 +509,7 @@ BOOST_AUTO_TEST_CASE(TestMatchingWells) { st.update_well_var("OPY", "WOPR", 0.50); st.update_well_var("OPZ", "WOPR", 2.0); - WListManager wlm; - Action::Context context(st, wlm); + Action::Context context(st); auto res = ast.eval(context); auto wells = res.wells(); BOOST_CHECK( res); @@ -535,7 +518,6 @@ BOOST_AUTO_TEST_CASE(TestMatchingWells) { BOOST_CHECK_EQUAL( wells[0], "OPZ" ); } - BOOST_AUTO_TEST_CASE(TestMatchingWells2) { Action::AST ast1({"WOPR", "P*", ">", "1.0"}); Action::AST ast2({"WOPR", "*", ">", "1.0"}); @@ -549,8 +531,7 @@ BOOST_AUTO_TEST_CASE(TestMatchingWells2) { st.update_well_var("IY", "WOPR", 0.50); st.update_well_var("IZ", "WOPR", 2.0); - WListManager wlm; - Action::Context context(st, wlm); + Action::Context context(st); auto res1 = ast1.eval(context); auto res2 = ast2.eval(context); auto wells1 = res1.wells(); @@ -579,8 +560,7 @@ BOOST_AUTO_TEST_CASE(TestMatchingWells_AND) { st.update_well_var("OPY", "WWCT", 0.0); // The WWCT check matches this well. st.update_well_var("OPZ", "WWCT", 1.0); - WListManager wlm; - Action::Context context(st, wlm); + Action::Context context(st); auto res = ast.eval(context); BOOST_CHECK(res); @@ -602,8 +582,7 @@ BOOST_AUTO_TEST_CASE(TestMatchingWells_OR) { st.update_well_var("OPY", "WWCT", 0.0); // The WWCT check matches this well. st.update_well_var("OPZ", "WWCT", 1.0); - WListManager wlm; - Action::Context context(st, wlm); + Action::Context context(st); auto res = ast.eval(context); auto wells = res.wells(); BOOST_CHECK(res); @@ -616,38 +595,10 @@ BOOST_AUTO_TEST_CASE(TestMatchingWells_OR) { BOOST_CHECK( std::find(wells.begin(), wells.end(), "OPY") != wells.end()); } -BOOST_AUTO_TEST_CASE(TestWLIST) { - WListManager wlm; - Action::AST ast({"WOPR", "*LIST1", ">", "1.0"}); - SummaryState st(std::chrono::system_clock::now()); - - st.update_well_var("W1", "WOPR", 2.0); - st.update_well_var("W2", "WOPR", 2.50); - st.update_well_var("W3", "WOPR", 2.0); - st.update_well_var("W4", "WOPR", 2.0); - st.update_well_var("W5", "WOPR", 2.0); - - - Action::Context context(st, wlm); - auto& wl = wlm.newList("*LIST1"); - wl.add("W1"); - wl.add("W3"); - wl.add("W5"); - auto res = ast.eval(context); - auto wells = res.wells(); - BOOST_CHECK(res); - BOOST_CHECK_EQUAL( wells.size(), 3); - for (const auto& w : {"W1", "W3", "W5"}) { - auto find_iter = std::find(wells.begin(), wells.end(), w); - BOOST_CHECK( find_iter != wells.end() ); - } -} - BOOST_AUTO_TEST_CASE(TestFieldAND) { Action::AST ast({"FMWPR", ">=", "4", "AND", "WUPR3", "OP*", "=", "1"}); SummaryState st(std::chrono::system_clock::now()); - WListManager wlm; - Action::Context context(st, wlm); + Action::Context context(st); st.update_well_var("OP1", "WUPR3", 3); st.update_well_var("OP2", "WUPR3", 2); @@ -657,9 +608,8 @@ BOOST_AUTO_TEST_CASE(TestFieldAND) { st.update("FMWPR", 1); { auto res = ast.eval(context); + auto wells = res.wells(); BOOST_CHECK(!res); - BOOST_CHECK_THROW(res.wells(), std::logic_error); - BOOST_CHECK_THROW(res.has_well("ABC"), std::logic_error); } st.update("FMWPR", 4); @@ -833,6 +783,19 @@ TSTEP +BOOST_AUTO_TEST_CASE(ACTIONRESULT_COPY_EMPTY) { + Action::Result res1(false); + auto res2 = res1; + + BOOST_CHECK(!res1); + BOOST_CHECK(!res2); + BOOST_CHECK(res1.wells() == std::vector()); + BOOST_CHECK(res2.wells() == std::vector()); + + BOOST_CHECK(!res1.has_well("NO")); + BOOST_CHECK(!res2.has_well("NO")); +} + BOOST_AUTO_TEST_CASE(ACTIONRESULT_COPY_WELLS) { Action::Result res1(true, {"W1", "W2", "W3"}); auto res2 = res1; @@ -846,84 +809,3 @@ BOOST_AUTO_TEST_CASE(ACTIONRESULT_COPY_WELLS) { BOOST_CHECK(res2.has_well(w)); } } - - -BOOST_AUTO_TEST_CASE(ActionState) { - Action::State st; - Action::ActionX action1("NAME", 100, 100, 100); action1.update_id(100); - Action::ActionX action2("NAME", 100, 100, 100); action1.update_id(200); - - BOOST_CHECK_EQUAL(0, st.run_count(action1)); - BOOST_CHECK_THROW( st.run_time(action1), std::out_of_range); - - st.add_run(action1, 100); - BOOST_CHECK_EQUAL(1, st.run_count(action1)); - BOOST_CHECK_EQUAL(100, st.run_time(action1)); - - st.add_run(action1, 1000); - BOOST_CHECK_EQUAL(2, st.run_count(action1)); - BOOST_CHECK_EQUAL(1000, st.run_time(action1)); - - BOOST_CHECK_EQUAL(0, st.run_count(action2)); - BOOST_CHECK_THROW( st.run_time(action2), std::out_of_range); - - st.add_run(action2, 100); - BOOST_CHECK_EQUAL(1, st.run_count(action2)); - BOOST_CHECK_EQUAL(100, st.run_time(action2)); - - st.add_run(action2, 1000); - BOOST_CHECK_EQUAL(2, st.run_count(action2)); - BOOST_CHECK_EQUAL(1000, st.run_time(action2)); -} - -BOOST_AUTO_TEST_CASE(ActionID) { - const auto deck_string = std::string{ R"( -SCHEDULE - -TSTEP -10 / - -ACTIONX -'A' / -WWCT 'OPX' > 0.75 AND / -FPR < 100 / -/ - -WELSPECS -'W1' 'OP' 1 1 3.33 'OIL' 7*/ -/ - -ENDACTIO - -TSTEP -10 / - - -ACTIONX -'A' / -WOPR 'OPX' = 1000 / -/ - -ENDACTIO - - )"}; - - Opm::Parser parser; - auto deck = parser.parseString(deck_string); - EclipseGrid grid1(10,10,10); - TableManager table ( deck ); - FieldPropsManager fp( deck, Phases{true, true, true}, grid1, table); - auto python = std::make_shared(); - - Runspec runspec (deck); - Schedule sched(deck, grid1, fp, runspec, python); - const auto& action1 = sched.actions(1).get("A"); - const auto& action2 = sched.actions(2).get("A"); - - BOOST_CHECK(action1.id() != action2.id()); - - Action::State st; - st.add_run(action1, 1000); - BOOST_CHECK_EQUAL( st.run_count(action1), 1); - BOOST_CHECK_EQUAL( st.run_count(action2), 0); -} diff --git a/ThirdParty/custom-opm-common/opm-common/tests/parser/ConnectionTests.cpp b/ThirdParty/custom-opm-common/opm-common/tests/parser/ConnectionTests.cpp index a96dc123d1..f9f7921838 100644 --- a/ThirdParty/custom-opm-common/opm-common/tests/parser/ConnectionTests.cpp +++ b/ThirdParty/custom-opm-common/opm-common/tests/parser/ConnectionTests.cpp @@ -71,8 +71,8 @@ BOOST_AUTO_TEST_CASE(AddCompletionSizeCorrect) { auto dir = Opm::Connection::Direction::Z; const auto kind = Opm::Connection::CTFKind::DeckValue; Opm::WellConnections completionSet(Opm::Connection::Order::TRACK, 1,1); - Opm::Connection completion1( 10,10,10, 100, 1, 0.0, Opm::Connection::State::OPEN , 99.88, 355.113, 0.25, 0.0, 0.0, 0, dir, kind, 0, true); - Opm::Connection completion2( 10,10,11, 102, 1, 0.0, Opm::Connection::State::SHUT , 99.88, 355.113, 0.25, 0.0, 0.0, 0, dir, kind, 0, true); + Opm::Connection completion1( 10,10,10, 100, 1, 0.0, Opm::Connection::State::OPEN , 99.88, 355.113, 0.25, 0.0, 0.0, 0, dir, kind, 0, 0., 0., true); + Opm::Connection completion2( 10,10,11, 102, 1, 0.0, Opm::Connection::State::SHUT , 99.88, 355.113, 0.25, 0.0, 0.0, 0, dir, kind, 0, 0., 0., true); completionSet.add( completion1 ); BOOST_CHECK_EQUAL( 1U , completionSet.size() ); @@ -86,8 +86,8 @@ BOOST_AUTO_TEST_CASE(AddCompletionSizeCorrect) { BOOST_AUTO_TEST_CASE(WellConnectionsGetOutOfRangeThrows) { auto dir = Opm::Connection::Direction::Z; const auto kind = Opm::Connection::CTFKind::DeckValue; - Opm::Connection completion1( 10,10,10, 100, 1, 0.0, Opm::Connection::State::OPEN , 99.88, 355.113, 0.25, 0.0, 0.0, 0, dir, kind, 0,true); - Opm::Connection completion2( 10,10,11, 102, 1, 0.0, Opm::Connection::State::SHUT , 99.88, 355.113, 0.25, 0.0, 0.0, 0, dir, kind, 0,true); + Opm::Connection completion1( 10,10,10, 100, 1, 0.0, Opm::Connection::State::OPEN , 99.88, 355.113, 0.25, 0.0, 0.0, 0, dir, kind, 0,0., 0., true); + Opm::Connection completion2( 10,10,11, 102, 1, 0.0, Opm::Connection::State::SHUT , 99.88, 355.113, 0.25, 0.0, 0.0, 0, dir, kind, 0,0., 0., true); Opm::WellConnections completionSet(Opm::Connection::Order::TRACK, 1,1); completionSet.add( completion1 ); BOOST_CHECK_EQUAL( 1U , completionSet.size() ); @@ -107,9 +107,9 @@ BOOST_AUTO_TEST_CASE(AddCompletionCopy) { auto dir = Opm::Connection::Direction::Z; const auto kind = Opm::Connection::CTFKind::DeckValue; - Opm::Connection completion1( 10,10,10, 100, 1, 0.0, Opm::Connection::State::OPEN , 99.88, 355.113, 0.25, 0.0, 0.0, 0, dir, kind, 0, true); - Opm::Connection completion2( 10,10,11, 101, 1, 0.0, Opm::Connection::State::SHUT , 99.88, 355.113, 0.25, 0.0, 0.0, 0, dir, kind, 0, true); - Opm::Connection completion3( 10,10,12, 102, 1, 0.0, Opm::Connection::State::SHUT , 99.88, 355.113, 0.25, 0.0, 0.0, 0, dir, kind, 0, true); + Opm::Connection completion1( 10,10,10, 100, 1, 0.0, Opm::Connection::State::OPEN , 99.88, 355.113, 0.25, 0.0, 0.0, 0, dir, kind, 0,0., 0., true); + Opm::Connection completion2( 10,10,11, 101, 1, 0.0, Opm::Connection::State::SHUT , 99.88, 355.113, 0.25, 0.0, 0.0, 0, dir, kind, 0,0., 0., true); + Opm::Connection completion3( 10,10,12, 102, 1, 0.0, Opm::Connection::State::SHUT , 99.88, 355.113, 0.25, 0.0, 0.0, 0, dir, kind, 0,0., 0., true); completionSet.add( completion1 ); completionSet.add( completion2 ); @@ -130,9 +130,9 @@ BOOST_AUTO_TEST_CASE(ActiveCompletions) { auto dir = Opm::Connection::Direction::Z; const auto kind = Opm::Connection::CTFKind::Defaulted; Opm::WellConnections completions(Opm::Connection::Order::TRACK, 10,10); - Opm::Connection completion1( 0,0,0, grid.getGlobalIndex(0,0,0), 1, 0.0, Opm::Connection::State::OPEN , 99.88, 355.113, 0.25, 0.0, 0.0, 0, dir, kind, 0, true); - Opm::Connection completion2( 0,0,1, grid.getGlobalIndex(0,0,1), 1, 0.0, Opm::Connection::State::SHUT , 99.88, 355.113, 0.25, 0.0, 0.0, 0, dir, kind, 0, true); - Opm::Connection completion3( 0,0,2, grid.getGlobalIndex(0,0,2), 1, 0.0, Opm::Connection::State::SHUT , 99.88, 355.113, 0.25, 0.0, 0.0, 0, dir, kind, 0, true); + Opm::Connection completion1( 0,0,0, grid.getGlobalIndex(0,0,0), 1, 0.0, Opm::Connection::State::OPEN , 99.88, 355.113, 0.25, 0.0, 0.0, 0, dir, kind, 0,0., 0., true); + Opm::Connection completion2( 0,0,1, grid.getGlobalIndex(0,0,1), 1, 0.0, Opm::Connection::State::SHUT , 99.88, 355.113, 0.25, 0.0, 0.0, 0, dir, kind, 0,0., 0., true); + Opm::Connection completion3( 0,0,2, grid.getGlobalIndex(0,0,2), 1, 0.0, Opm::Connection::State::SHUT , 99.88, 355.113, 0.25, 0.0, 0.0, 0, dir, kind, 0,0., 0., true); completions.add( completion1 ); completions.add( completion2 ); diff --git a/ThirdParty/custom-opm-common/opm-common/tests/parser/EclipseGridTests.cpp b/ThirdParty/custom-opm-common/opm-common/tests/parser/EclipseGridTests.cpp index ee409c6fbc..86a91a9b92 100644 --- a/ThirdParty/custom-opm-common/opm-common/tests/parser/EclipseGridTests.cpp +++ b/ThirdParty/custom-opm-common/opm-common/tests/parser/EclipseGridTests.cpp @@ -43,7 +43,6 @@ #include #include #include -#include #include @@ -212,27 +211,6 @@ static Opm::Deck createPinchedCPDeck() { return parser.parseString( deckData) ; } -static Opm::Deck createPinchedNOGAPCPDeck() { - const char* deckData = - "RUNSPEC\n" - "\n" - "DIMENS\n" - " 10 10 10 /\n" - "GRID\n" - "COORD\n" - " 726*1 / \n" - "ZCORN \n" - " 8000*1 / \n" - "ACTNUM \n" - " 1000*1 / \n" - "PINCH \n" - " 0.2 NOGAP / \n" - "EDIT\n" - "\n"; - - Opm::Parser parser; - return parser.parseString( deckData) ; -} static Opm::Deck createMinpvDefaultCPDeck() { const char* deckData = @@ -816,11 +794,9 @@ BOOST_AUTO_TEST_CASE(ConstructorNoSections) { BOOST_AUTO_TEST_CASE(ConstructorNORUNSPEC_PINCH) { auto deck1 = createCPDeck(); auto deck2 = createPinchedCPDeck(); - auto deck3 = createPinchedNOGAPCPDeck(); Opm::EclipseGrid grid1(deck1); Opm::EclipseGrid grid2(deck2); - Opm::EclipseGrid grid3(deck3); BOOST_CHECK(!grid1.equal( grid2 )); @@ -828,8 +804,6 @@ BOOST_AUTO_TEST_CASE(ConstructorNORUNSPEC_PINCH) { BOOST_CHECK_THROW(grid1.getPinchThresholdThickness(), std::logic_error); BOOST_CHECK(grid2.isPinchActive()); BOOST_CHECK_EQUAL(grid2.getPinchThresholdThickness(), 0.2); - BOOST_CHECK_EQUAL(grid2.getPinchGapMode(), Opm::PinchMode::ModeEnum::GAP); - BOOST_CHECK_EQUAL(grid3.getPinchGapMode(), Opm::PinchMode::ModeEnum::NOGAP); } BOOST_AUTO_TEST_CASE(ConstructorMINPV) { diff --git a/ThirdParty/custom-opm-common/opm-common/tests/parser/FieldPropsTests.cpp b/ThirdParty/custom-opm-common/opm-common/tests/parser/FieldPropsTests.cpp index 7ac1771ddb..96bea7c72d 100644 --- a/ThirdParty/custom-opm-common/opm-common/tests/parser/FieldPropsTests.cpp +++ b/ThirdParty/custom-opm-common/opm-common/tests/parser/FieldPropsTests.cpp @@ -19,11 +19,8 @@ #include #include -#include #include #include -#include -#include #define BOOST_TEST_MODULE FieldPropsTests @@ -33,7 +30,6 @@ #include -#include #include #include #include @@ -41,7 +37,6 @@ #include #include #include -#include #include #include "src/opm/parser/eclipse/EclipseState/Grid/FieldProps.hpp" @@ -590,960 +585,3 @@ MULTZ BOOST_CHECK_EQUAL( multz[0], 4 ); BOOST_CHECK_EQUAL( multx[0], 2 ); } - -BOOST_AUTO_TEST_CASE(OPERATE) { - std::string deck_string = R"( -GRID - -PORO - 6*1.0 / - -OPERATE - PORO 1 3 1 1 1 1 'MAXLIM' PORO 0.50 / - PORO 1 3 2 2 1 1 'MAXLIM' PORO 0.25 / -/ - - -PERMX - 6*1/ - -PERMY - 6*1000/ - -OPERATE - PERMX 1 3 1 1 1 1 'MINLIM' PERMX 2 / - PERMX 1 3 2 2 1 1 'MINLIM' PERMX 4 / - PERMY 1 3 1 1 1 1 'MAXLIM' PERMY 100 / - PERMY 1 3 2 2 1 1 'MAXLIM' PERMY 200 / - PERMZ 1 3 1 1 1 1 'MULTA' PERMY 2 1000 / - PERMZ 1 3 2 2 1 1 'MULTA' PERMX 3 300 / -/ - - - - -)"; - - UnitSystem unit_system(UnitSystem::UnitType::UNIT_TYPE_METRIC); - auto to_si = [&unit_system](double raw_value) { return unit_system.to_si(UnitSystem::measure::permeability, raw_value); }; - EclipseGrid grid(3,2,1); - Deck deck = Parser{}.parseString(deck_string); - FieldPropsManager fpm(deck, Phases{true, true, true}, grid, TableManager()); - const auto& poro = fpm.get_double("PORO"); - BOOST_CHECK_EQUAL(poro[0], 0.50); - BOOST_CHECK_EQUAL(poro[3], 0.25); - - const auto& permx = fpm.get_double("PERMX"); - BOOST_CHECK_EQUAL(permx[0], to_si(2)); - BOOST_CHECK_EQUAL(permx[3], to_si(4)); - - const auto& permy = fpm.get_double("PERMY"); - BOOST_CHECK_EQUAL(permy[0], to_si(100)); - BOOST_CHECK_EQUAL(permy[3], to_si(200)); - - const auto& permz = fpm.get_double("PERMZ"); - for (std::size_t i = 0; i < 3; i++) { - BOOST_CHECK_EQUAL(permz[i] , 2*permy[i] + to_si(1000)); - BOOST_CHECK_EQUAL(permz[i+3], 3*permx[i+3] + to_si(300)); - } -} - -namespace { - std::string satfunc_model_setup() - { - return { R"( -RUNSPEC - -DIMENS -6 6 3 / - -OIL -GAS -DISGAS -WATER -METRIC - -TABDIMS -/ - -GRID - -DXV - 6*100.0 / -DYV - 6*100.0 / -DZV - 3*5.0 / - -TOPS - 36*2000.0 / - -PERMX - 108*100.0 / -PERMY - 108*100.0 / -PERMZ - 108*10.0 / -PORO - 108*0.3 / - -PROPS - -DENSITY - 850.0 1014.1 1.02 / - -)" }; - - } - - std::string satfunc_family_I() - { - // Saturation Region 1 from opm-tests/model1/include/sattab_basemod1.sattab - - return { R"( -SWOF -0.071004 0.000000 1.000000 7.847999 -0.091004 0.000001 0.882459 4.365734 -0.111004 0.000046 0.775956 2.730007 -0.131004 0.000251 0.679729 1.845613 -0.151004 0.000739 0.593050 1.319233 -0.171004 0.001631 0.515222 0.983255 -0.191004 0.003052 0.445580 0.757089 -0.211004 0.005126 0.383490 0.598332 -0.231004 0.007976 0.328347 0.483059 -0.251004 0.011727 0.279578 0.396991 -0.271004 0.016503 0.236638 0.331205 -0.291004 0.022430 0.199013 0.279911 -0.311004 0.029632 0.166213 0.239222 -0.331004 0.038234 0.137781 0.206460 -0.351004 0.048361 0.113284 0.179731 -0.371004 0.060138 0.092316 0.157670 -0.391004 0.073691 0.074499 0.139272 -0.411004 0.089145 0.059479 0.123784 -0.431004 0.106626 0.046927 0.110637 -0.451004 0.126260 0.036540 0.099391 -0.471004 0.148171 0.028035 0.089704 -0.491004 0.172487 0.021156 0.081308 -0.511004 0.199332 0.015668 0.073987 -0.531004 0.228832 0.011357 0.067570 -0.551004 0.261115 0.008030 0.061917 -0.571004 0.296305 0.005516 0.056913 -0.591004 0.334530 0.003662 0.052467 -0.611004 0.375914 0.002333 0.048498 -0.631004 0.420585 0.001413 0.044944 -0.651004 0.468668 0.000804 0.041749 -0.671004 0.520291 0.000422 0.038868 -0.691004 0.575579 0.000199 0.036261 -0.711004 0.634659 0.000080 0.033897 -0.731004 0.697657 0.000026 0.031746 -0.751004 0.764701 0.000006 0.029784 -0.771004 0.835916 0.000001 0.027991 -0.791004 0.911429 0.000000 0.026347 -0.800794 0.950000 0.000000 0.025592 -0.990000 1* 0.000000 0.015139 -1.000000 1.000000 0.000000 0.000000 -/ - -SGOF -0.000000 0.000000 1.000000 0.000000 -0.030000 0.000000 0.896942 0.000000 -0.060000 0.002411 0.801286 0.000000 -0.090000 0.008238 0.712749 0.000000 -0.120000 0.016904 0.631047 0.000000 -0.150000 0.028151 0.555898 0.000000 -0.180000 0.041812 0.487020 0.000000 -0.210000 0.057767 0.424134 0.000000 -0.240000 0.075921 0.366958 0.000000 -0.270000 0.096200 0.315214 0.000000 -0.300000 0.118539 0.268622 0.000000 -0.330000 0.142884 0.226906 0.000000 -0.360000 0.169188 0.189789 0.000000 -0.390000 0.197407 0.156994 0.000000 -0.420000 0.227505 0.128247 0.000000 -0.450000 0.259448 0.103275 0.000000 -0.480000 0.293205 0.081803 0.000000 -0.510000 0.328748 0.063562 0.000000 -0.540000 0.366051 0.048280 0.000000 -0.570000 0.405089 0.035689 0.000000 -0.600000 0.445840 0.025521 0.000000 -0.630000 0.488284 0.017511 0.000000 -0.660000 0.532400 0.011396 0.000000 -0.690000 0.578171 0.006912 0.000000 -0.720000 0.625578 0.003801 0.000000 -0.750000 0.674606 0.001807 0.000000 -0.780000 0.725239 0.000675 0.000000 -0.810000 0.777461 0.000156 0.000000 -0.840000 0.831260 0.000009 0.000000 -0.858996 0.866135 0.000000 0.000000 -0.888996 0.922479 0.000000 0.000000 -0.918996 0.980364 0.000000 0.000000 -0.928996 1.000000 0.000000 0.000000 -/ -)" }; - } - - std::string satfunc_family_II() - { - // Saturation Region 1 from opm-tests/model1/include/sattab_basemod1.sattab - // rephrased as Family II. - - return { R"( -SWFN -0.071004 0.000000 7.847999 -0.091004 0.000001 4.365734 -0.111004 0.000046 2.730007 -0.131004 0.000251 1.845613 -0.151004 0.000739 1.319233 -0.171004 0.001631 0.983255 -0.191004 0.003052 0.757089 -0.211004 0.005126 0.598332 -0.231004 0.007976 0.483059 -0.251004 0.011727 0.396991 -0.271004 0.016503 0.331205 -0.291004 0.022430 0.279911 -0.311004 0.029632 0.239222 -0.331004 0.038234 0.206460 -0.351004 0.048361 0.179731 -0.371004 0.060138 0.157670 -0.391004 0.073691 0.139272 -0.411004 0.089145 0.123784 -0.431004 0.106626 0.110637 -0.451004 0.126260 0.099391 -0.471004 0.148171 0.089704 -0.491004 0.172487 0.081308 -0.511004 0.199332 0.073987 -0.531004 0.228832 0.067570 -0.551004 0.261115 0.061917 -0.571004 0.296305 0.056913 -0.591004 0.334530 0.052467 -0.611004 0.375914 0.048498 -0.631004 0.420585 0.044944 -0.651004 0.468668 0.041749 -0.671004 0.520291 0.038868 -0.691004 0.575579 0.036261 -0.711004 0.634659 0.033897 -0.731004 0.697657 0.031746 -0.751004 0.764701 0.029784 -0.771004 0.835916 0.027991 -0.791004 0.911429 0.026347 -0.800794 0.950000 0.025592 -0.990000 0.997490 0.015139 -1.000000 1.000000 0.000000 -/ - -SGFN -0.000000 0.000000 0.000000 -0.030000 0.000000 0.000000 -0.060000 0.002411 0.000000 -0.090000 0.008238 0.000000 -0.120000 0.016904 0.000000 -0.150000 0.028151 0.000000 -0.180000 0.041812 0.000000 -0.210000 0.057767 0.000000 -0.240000 0.075921 0.000000 -0.270000 0.096200 0.000000 -0.300000 0.118539 0.000000 -0.330000 0.142884 0.000000 -0.360000 0.169188 0.000000 -0.390000 0.197407 0.000000 -0.420000 0.227505 0.000000 -0.450000 0.259448 0.000000 -0.480000 0.293205 0.000000 -0.510000 0.328748 0.000000 -0.540000 0.366051 0.000000 -0.570000 0.405089 0.000000 -0.600000 0.445840 0.000000 -0.630000 0.488284 0.000000 -0.660000 0.532400 0.000000 -0.690000 0.578171 0.000000 -0.720000 0.625578 0.000000 -0.750000 0.674606 0.000000 -0.780000 0.725239 0.000000 -0.810000 0.777461 0.000000 -0.840000 0.831260 0.000000 -0.858996 0.866135 0.000000 -0.888996 0.922479 0.000000 -0.918996 0.980364 0.000000 -0.928996 1.000000 0.000000 -/ - -SOF3 -0.000000 0.000000 0.000000 -0.010000 0.000000 0.000000 -0.040000 0.000000 0.000000 -0.070000 0.000000 0.000000 -0.088996 0.000000 0.000009 -0.118996 0.000000 0.000156 -0.148996 0.000000 0.000675 -0.178996 0.000000 0.001807 -0.199206 0.000000 0.003150 -0.208996 0.000000 0.003801 -0.228996 0.000001 0.005875 -0.238996 0.000004 0.006912 -0.248996 0.000006 0.008407 -0.268996 0.000026 0.011396 -0.288996 0.000080 0.015473 -0.298996 0.000140 0.017511 -0.308996 0.000199 0.020181 -0.328996 0.000422 0.025521 -0.348996 0.000804 0.032300 -0.358996 0.001109 0.035689 -0.368996 0.001413 0.039886 -0.388996 0.002333 0.048280 -0.408996 0.003662 0.058468 -0.418996 0.004589 0.063562 -0.428996 0.005516 0.069642 -0.448996 0.008030 0.081803 -0.468996 0.011357 0.096118 -0.478996 0.013513 0.103275 -0.488996 0.015668 0.111599 -0.508996 0.021156 0.128247 -0.528996 0.028035 0.147412 -0.538996 0.032288 0.156994 -0.548996 0.036540 0.167926 -0.568996 0.046927 0.189789 -0.588996 0.059479 0.214534 -0.598996 0.066989 0.226906 -0.608996 0.074499 0.240811 -0.628996 0.092316 0.268622 -0.648996 0.113284 0.299683 -0.658996 0.125533 0.315214 -0.668996 0.137781 0.332462 -0.688996 0.166213 0.366958 -0.708996 0.199013 0.405075 -0.718996 0.217826 0.424134 -0.728996 0.236638 0.445096 -0.748996 0.279578 0.487020 -0.768996 0.328347 0.532939 -0.778996 0.355919 0.555898 -0.788996 0.383490 0.580948 -0.808996 0.445580 0.631047 -0.828996 0.515222 0.685515 -0.838996 0.554136 0.712749 -0.848996 0.593050 0.742261 -0.868996 0.679729 0.801286 -0.888996 0.775956 0.865057 -0.898996 0.829208 0.896942 -0.908996 0.882459 0.931295 -0.928996 1.000000 1.000000 -/ )" }; - } - - std::string tolCrit(const double t) - { - std::ostringstream os; - - os << "TOLCRIT\n " << std::scientific << std::setw(11) << t << "\n/\n"; - - return os.str(); - } - - std::string end() - { - return { R"( -END -)" }; - } -} // namespace Anonymous - -BOOST_AUTO_TEST_CASE(RawTableEndPoints_Family_I_TolCrit_Zero) { - const auto es = ::Opm::EclipseState { - ::Opm::Parser{}.parseString(satfunc_model_setup() + satfunc_family_I() + end()) - }; - - const auto& tm = es.getTableManager(); - const auto& ph = es.runspec().phases(); - const auto tolcrit = 0.0; - - auto rtepPtr = satfunc::getRawTableEndpoints(tm, ph, tolcrit); - - // Water end-points - { - const auto swl = rtepPtr->connate .water; - const auto swcr = rtepPtr->critical.water; - const auto swu = rtepPtr->maximum .water; - BOOST_CHECK_CLOSE(swl [0], 0.071004, 1.0e-10); - BOOST_CHECK_CLOSE(swcr[0], 0.071004, 1.0e-10); // == SWL. TOLCRIT = 0.0 - BOOST_CHECK_CLOSE(swu [0], 1.0 , 1.0e-10); - } - - // Oil end-points - { - const auto sowcr = rtepPtr->critical.oil_in_water; - const auto sogcr = rtepPtr->critical.oil_in_gas; - BOOST_CHECK_CLOSE(sowcr[0], 1.0 - 0.791004, 1.0e-10); // TOLCRIT = 0.0 - BOOST_CHECK_CLOSE(sogcr[0], 1.0 - 0.858996 - 0.071004, 1.0e-10); // Include SWL - } - - // Gas end-points - { - const auto sgl = rtepPtr->connate .gas; - const auto sgcr = rtepPtr->critical.gas; - const auto sgu = rtepPtr->maximum .gas; - BOOST_CHECK_CLOSE(sgl [0], 0.0, 1.0e-10); - BOOST_CHECK_CLOSE(sgcr[0], 0.03, 1.0e-10); - BOOST_CHECK_CLOSE(sgu [0], 0.928996, 1.0e-10); - } -} - -BOOST_AUTO_TEST_CASE(RawTableEndPoints_Family_II_TolCrit_Zero) { - const auto es = ::Opm::EclipseState { - ::Opm::Parser{}.parseString(satfunc_model_setup() + satfunc_family_II() + end()) - }; - - const auto& tm = es.getTableManager(); - const auto& ph = es.runspec().phases(); - const auto tolcrit = 0.0; - - auto rtepPtr = satfunc::getRawTableEndpoints(tm, ph, tolcrit); - - // Water end-points - { - const auto swl = rtepPtr->connate .water; - const auto swcr = rtepPtr->critical.water; - const auto swu = rtepPtr->maximum .water; - BOOST_CHECK_CLOSE(swl [0], 0.071004, 1.0e-10); - BOOST_CHECK_CLOSE(swcr[0], 0.071004, 1.0e-10); // == SWL. TOLCRIT = 0.0 - BOOST_CHECK_CLOSE(swu [0], 1.0 , 1.0e-10); - } - - // Oil end-points - { - const auto sowcr = rtepPtr->critical.oil_in_water; - const auto sogcr = rtepPtr->critical.oil_in_gas; - BOOST_CHECK_CLOSE(sowcr[0], 1.0 - 0.791004, 1.0e-10); // TOLCRIT = 0.0 - BOOST_CHECK_CLOSE(sogcr[0], 1.0 - 0.858996 - 0.071004, 1.0e-10); // Include SWL - } - - // Gas end-points - { - const auto sgl = rtepPtr->connate .gas; - const auto sgcr = rtepPtr->critical.gas; - const auto sgu = rtepPtr->maximum .gas; - BOOST_CHECK_CLOSE(sgl [0], 0.0, 1.0e-10); - BOOST_CHECK_CLOSE(sgcr[0], 0.03, 1.0e-10); - BOOST_CHECK_CLOSE(sgu [0], 0.928996, 1.0e-10); - } -} - -BOOST_AUTO_TEST_CASE(RawTableEndPoints_Family_I_TolCrit_Default) { - const auto es = ::Opm::EclipseState { - ::Opm::Parser{}.parseString(satfunc_model_setup() + satfunc_family_I() + end()) - }; - - const auto& tm = es.getTableManager(); - const auto& ph = es.runspec().phases(); - const auto tolcrit = es.runspec().saturationFunctionControls() - .minimumRelpermMobilityThreshold(); // 1.0e-6. - - auto rtepPtr = satfunc::getRawTableEndpoints(tm, ph, tolcrit); - - // Water end-points - { - const auto swl = rtepPtr->connate .water; - const auto swcr = rtepPtr->critical.water; - const auto swu = rtepPtr->maximum .water; - BOOST_CHECK_CLOSE(swl [0], 0.071004, 1.0e-10); - BOOST_CHECK_CLOSE(swcr[0], 0.091004, 1.0e-10); // Max Sw for which Krw(Sw) <= TOLCRIT - BOOST_CHECK_CLOSE(swu [0], 1.0 , 1.0e-10); - } - - // Oil end-points - { - const auto sowcr = rtepPtr->critical.oil_in_water; - const auto sogcr = rtepPtr->critical.oil_in_gas; - BOOST_CHECK_CLOSE(sowcr[0], 0.228996, 1.0e-10); // Max So for which Krow(So) <= TOLCRIT - BOOST_CHECK_CLOSE(sogcr[0], 0.070000, 1.0e-10); // Max So for which Krog(So) <= TOLCRIT - } - - // Gas end-points - { - const auto sgl = rtepPtr->connate .gas; - const auto sgcr = rtepPtr->critical.gas; - const auto sgu = rtepPtr->maximum .gas; - BOOST_CHECK_CLOSE(sgl [0], 0.0, 1.0e-10); - BOOST_CHECK_CLOSE(sgcr[0], 0.03, 1.0e-10); // Max Sg for which Krg(Sg) <= TOLCRIT - BOOST_CHECK_CLOSE(sgu [0], 0.928996, 1.0e-10); - } -} - -BOOST_AUTO_TEST_CASE(RawTableEndPoints_Family_II_TolCrit_Default) { - const auto es = ::Opm::EclipseState { - ::Opm::Parser{}.parseString(satfunc_model_setup() + satfunc_family_II() + end()) - }; - - const auto& tm = es.getTableManager(); - const auto& ph = es.runspec().phases(); - const auto tolcrit = es.runspec().saturationFunctionControls() - .minimumRelpermMobilityThreshold(); // 1.0e-6. - - auto rtepPtr = satfunc::getRawTableEndpoints(tm, ph, tolcrit); - - // Water end-points - { - const auto swl = rtepPtr->connate .water; - const auto swcr = rtepPtr->critical.water; - const auto swu = rtepPtr->maximum .water; - BOOST_CHECK_CLOSE(swl [0], 0.071004, 1.0e-10); - BOOST_CHECK_CLOSE(swcr[0], 0.091004, 1.0e-10); // Max Sw for which Krw(Sw) <= TOLCRIT - BOOST_CHECK_CLOSE(swu [0], 1.0 , 1.0e-10); - } - - // Oil end-points - { - const auto sowcr = rtepPtr->critical.oil_in_water; - const auto sogcr = rtepPtr->critical.oil_in_gas; - BOOST_CHECK_CLOSE(sowcr[0], 0.228996, 1.0e-10); // Max So for which Krow(So) <= TOLCRIT - BOOST_CHECK_CLOSE(sogcr[0], 0.070000, 1.0e-10); // Max So for which Krog(So) <= TOLCRIT - } - - // Gas end-points - { - const auto sgl = rtepPtr->connate .gas; - const auto sgcr = rtepPtr->critical.gas; - const auto sgu = rtepPtr->maximum .gas; - BOOST_CHECK_CLOSE(sgl [0], 0.0, 1.0e-10); - BOOST_CHECK_CLOSE(sgcr[0], 0.03, 1.0e-10); // Max Sg for which Krg(Sg) <= TOLCRIT - BOOST_CHECK_CLOSE(sgu [0], 0.928996, 1.0e-10); - } -} - -BOOST_AUTO_TEST_CASE(RawTableEndPoints_Family_I_TolCrit_Large) { - const auto es = ::Opm::EclipseState { - ::Opm::Parser{}.parseString(satfunc_model_setup() + satfunc_family_I() + end()) - }; - - const auto& tm = es.getTableManager(); - const auto& ph = es.runspec().phases(); - const auto tolcrit = 0.01; - - auto rtepPtr = satfunc::getRawTableEndpoints(tm, ph, tolcrit); - - // Water end-points - { - const auto swl = rtepPtr->connate .water; - const auto swcr = rtepPtr->critical.water; - const auto swu = rtepPtr->maximum .water; - BOOST_CHECK_CLOSE(swl [0], 0.071004, 1.0e-10); - BOOST_CHECK_CLOSE(swcr[0], 0.231004, 1.0e-10); // Max Sw for which Krw(Sw) <= TOLCRIT - BOOST_CHECK_CLOSE(swu [0], 1.0 , 1.0e-10); - } - - // Oil end-points - { - const auto sowcr = rtepPtr->critical.oil_in_water; - const auto sogcr = rtepPtr->critical.oil_in_gas; - BOOST_CHECK_CLOSE(sowcr[0], 0.448996, 1.0e-10); // Max So for which Krow(So) <= TOLCRIT - BOOST_CHECK_CLOSE(sogcr[0], 0.238996, 1.0e-10); // Max So for which Krog(So) <= TOLCRIT - } - - // Gas end-points - { - const auto sgl = rtepPtr->connate .gas; - const auto sgcr = rtepPtr->critical.gas; - const auto sgu = rtepPtr->maximum .gas; - BOOST_CHECK_CLOSE(sgl [0], 0.0, 1.0e-10); - BOOST_CHECK_CLOSE(sgcr[0], 0.09, 1.0e-10); // Max Sg for which Krg(Sg) <= TOLCRIT - BOOST_CHECK_CLOSE(sgu [0], 0.928996, 1.0e-10); - } -} - -BOOST_AUTO_TEST_CASE(RawTableEndPoints_Family_II_TolCrit_Large) { - const auto es = ::Opm::EclipseState { - ::Opm::Parser{}.parseString(satfunc_model_setup() + satfunc_family_II() + end()) - }; - - const auto& tm = es.getTableManager(); - const auto& ph = es.runspec().phases(); - const auto tolcrit = 0.01; - - auto rtepPtr = satfunc::getRawTableEndpoints(tm, ph, tolcrit); - - // Water end-points - { - const auto swl = rtepPtr->connate .water; - const auto swcr = rtepPtr->critical.water; - const auto swu = rtepPtr->maximum .water; - BOOST_CHECK_CLOSE(swl [0], 0.071004, 1.0e-10); - BOOST_CHECK_CLOSE(swcr[0], 0.231004, 1.0e-10); // Max Sw for which Krw(Sw) <= TOLCRIT - BOOST_CHECK_CLOSE(swu [0], 1.0 , 1.0e-10); - } - - // Oil end-points - { - const auto sowcr = rtepPtr->critical.oil_in_water; - const auto sogcr = rtepPtr->critical.oil_in_gas; - BOOST_CHECK_CLOSE(sowcr[0], 0.448996, 1.0e-10); // Max So for which Krow(So) <= TOLCRIT - BOOST_CHECK_CLOSE(sogcr[0], 0.248996, 1.0e-10); // Max So for which Krog(So) <= TOLCRIT - } - - // Gas end-points - { - const auto sgl = rtepPtr->connate .gas; - const auto sgcr = rtepPtr->critical.gas; - const auto sgu = rtepPtr->maximum .gas; - BOOST_CHECK_CLOSE(sgl [0], 0.0, 1.0e-10); - BOOST_CHECK_CLOSE(sgcr[0], 0.09, 1.0e-10); // Max Sg for which Krg(Sg) <= TOLCRIT - BOOST_CHECK_CLOSE(sgu [0], 0.928996, 1.0e-10); - } -} - -// ===================================================================== - -BOOST_AUTO_TEST_CASE(SatFunc_EndPts_Family_I_TolCrit_Zero) { - const auto es = ::Opm::EclipseState { - ::Opm::Parser{}.parseString(satfunc_model_setup() + tolCrit(0.0) + satfunc_family_I() + end()) - }; - - auto fp = es.fieldProps(); - - // Water end-points - { - const auto swl = fp.get_double("SWL"); - const auto swcr = fp.get_double("SWCR"); - const auto swu = fp.get_double("SWU"); - BOOST_CHECK_CLOSE(swl [0], 0.071004, 1.0e-10); - BOOST_CHECK_CLOSE(swcr[0], 0.071004, 1.0e-10); // == SWL. TOLCRIT = 0.0 - BOOST_CHECK_CLOSE(swu [0], 1.0 , 1.0e-10); - - const auto krwr = fp.get_double("KRWR"); // Krw(Sw=1-Sowcr-Sgl) = Krw(Sw=0.791004) - const auto krw = fp.get_double("KRW"); // Krw(Swmax) = Krw(Sw=1) - BOOST_CHECK_CLOSE(krwr[0], 0.911429, 1.0e-10); - BOOST_CHECK_CLOSE(krw [0], 1.0 , 1.0e-10); - - const auto pcw = fp.get_double("PCW"); - BOOST_CHECK_CLOSE(pcw[0], 7.847999*unit::barsa, 1.0e-10); - } - - // Oil end-points - { - const auto sowcr = fp.get_double("SOWCR"); - const auto sogcr = fp.get_double("SOGCR"); - BOOST_CHECK_CLOSE(sowcr[0], 1.0 - 0.791004, 1.0e-10); // TOLCRIT = 0.0 - BOOST_CHECK_CLOSE(sogcr[0], 1.0 - 0.858996 - 0.071004, 1.0e-10); // Include SWL - - const auto krorw = fp.get_double("KRORW"); // Krow(So=1-Swcr-Sgl) = Krow(So=0.928996) - const auto krorg = fp.get_double("KRORG"); // Krog(So=1-Sgcr-Swl) = Krog(So=0.898996) - const auto kro = fp.get_double("KRO"); // Krow(So=Somax) = Krog(So=Somax) - BOOST_CHECK_CLOSE(krorw[0], 1.0, 1.0e-10); // TOLCRIT = 0.0 - BOOST_CHECK_CLOSE(krorg[0], 0.896942, 1.0e-10); - BOOST_CHECK_CLOSE(kro [0], 1.0, 1.0e-10); - } - - // Gas end-points - { - const auto sgl = fp.get_double("SGL"); - const auto sgcr = fp.get_double("SGCR"); - const auto sgu = fp.get_double("SGU"); - BOOST_CHECK_CLOSE(sgl [0], 0.0, 1.0e-10); - BOOST_CHECK_CLOSE(sgcr[0], 0.03, 1.0e-10); - BOOST_CHECK_CLOSE(sgu [0], 0.928996, 1.0e-10); - - const auto krgr = fp.get_double("KRGR"); // Krg(Sg=1-Sogcr-Swl) = Krg(Sg=0.858996) - const auto krg = fp.get_double("KRG"); // Krg(Sgmax) = Krg(Sg=0.928996) - BOOST_CHECK_CLOSE(krgr[0], 0.866135, 1.0e-10); - BOOST_CHECK_CLOSE(krg [0], 1.0 , 1.0e-10); - - const auto pcg = fp.get_double("PCG"); - BOOST_CHECK_CLOSE(pcg[0], 0.0, 1.0e-10); - } -} - -BOOST_AUTO_TEST_CASE(SatFunc_EndPts_Family_II_TolCrit_Zero) { - const auto es = ::Opm::EclipseState { - ::Opm::Parser{}.parseString(satfunc_model_setup() + tolCrit(0.0) + satfunc_family_II() + end()) - }; - - auto fp = es.fieldProps(); - - // Water end-points - { - const auto swl = fp.get_double("SWL"); - const auto swcr = fp.get_double("SWCR"); - const auto swu = fp.get_double("SWU"); - BOOST_CHECK_CLOSE(swl [0], 0.071004, 1.0e-10); - BOOST_CHECK_CLOSE(swcr[0], 0.071004, 1.0e-10); // == SWL. TOLCRIT = 0.0 - BOOST_CHECK_CLOSE(swu [0], 1.0 , 1.0e-10); - - const auto krwr = fp.get_double("KRWR"); // Krw(Sw=1-Sowcr-Sgl) = Krw(Sw=0.791004) - const auto krw = fp.get_double("KRW"); // Krw(Swmax) = Krw(Sw=1) - BOOST_CHECK_CLOSE(krwr[0], 0.911429, 1.0e-10); - BOOST_CHECK_CLOSE(krw [0], 1.0 , 1.0e-10); - - const auto pcw = fp.get_double("PCW"); - BOOST_CHECK_CLOSE(pcw[0], 7.847999*unit::barsa, 1.0e-10); - } - - // Oil end-points - { - const auto sowcr = fp.get_double("SOWCR"); - const auto sogcr = fp.get_double("SOGCR"); - BOOST_CHECK_CLOSE(sowcr[0], 1.0 - 0.791004, 1.0e-10); // TOLCRIT = 0.0 - BOOST_CHECK_CLOSE(sogcr[0], 1.0 - 0.858996 - 0.071004, 1.0e-10); // Include SWL - - const auto krorw = fp.get_double("KRORW"); // Krow(So=1-Swcr-Sgl) = Krow(So=0.928996) - const auto krorg = fp.get_double("KRORG"); // Krog(So=1-Sgcr-Swl) = Krog(So=0.898996) - const auto kro = fp.get_double("KRO"); // Krow(So=Somax) = Krog(So=Somax) - BOOST_CHECK_CLOSE(krorw[0], 1.0, 1.0e-10); // TOLCRIT = 0.0 - BOOST_CHECK_CLOSE(krorg[0], 0.896942, 1.0e-10); - BOOST_CHECK_CLOSE(kro [0], 1.0, 1.0e-10); - } - - // Gas end-points - { - const auto sgl = fp.get_double("SGL"); - const auto sgcr = fp.get_double("SGCR"); - const auto sgu = fp.get_double("SGU"); - BOOST_CHECK_CLOSE(sgl [0], 0.0, 1.0e-10); - BOOST_CHECK_CLOSE(sgcr[0], 0.03, 1.0e-10); - BOOST_CHECK_CLOSE(sgu [0], 0.928996, 1.0e-10); - - const auto krgr = fp.get_double("KRGR"); // Krg(Sg=1-Sogcr-Swl) = Krg(Sg=0.858996) - const auto krg = fp.get_double("KRG"); // Krg(Sgmax) = Krg(Sg=0.928996) - BOOST_CHECK_CLOSE(krgr[0], 0.866135, 1.0e-10); - BOOST_CHECK_CLOSE(krg [0], 1.0 , 1.0e-10); - - const auto pcg = fp.get_double("PCG"); - BOOST_CHECK_CLOSE(pcg[0], 0.0, 1.0e-10); - } -} - -BOOST_AUTO_TEST_CASE(SatFunc_EndPts_Family_I_TolCrit_Default) { - // TOLCRIT = 1.0e-6 - const auto es = ::Opm::EclipseState { - ::Opm::Parser{}.parseString(satfunc_model_setup() + satfunc_family_I() + end()) - }; - - auto fp = es.fieldProps(); - - // Water end-points - { - const auto swl = fp.get_double("SWL"); - const auto swcr = fp.get_double("SWCR"); - const auto swu = fp.get_double("SWU"); - BOOST_CHECK_CLOSE(swl [0], 0.071004, 1.0e-10); - BOOST_CHECK_CLOSE(swcr[0], 0.091004, 1.0e-10); // Max Sw for which Krw(Sw) <= TOLCRIT - BOOST_CHECK_CLOSE(swu [0], 1.0 , 1.0e-10); - - const auto krwr = fp.get_double("KRWR"); // Krw(Sw=1-Sowcr-Sgl) = Krw(Sw=0.771004) - const auto krw = fp.get_double("KRW"); // Krw(Swmax) = Krw(Sw=1) - BOOST_CHECK_CLOSE(krwr[0], 0.835916, 1.0e-10); - BOOST_CHECK_CLOSE(krw [0], 1.0 , 1.0e-10); - - const auto pcw = fp.get_double("PCW"); - BOOST_CHECK_CLOSE(pcw[0], 7.847999*unit::barsa, 1.0e-10); - } - - // Oil end-points - { - const auto sowcr = fp.get_double("SOWCR"); - const auto sogcr = fp.get_double("SOGCR"); - BOOST_CHECK_CLOSE(sowcr[0], 1.0 - 0.771004, 1.0e-10); // Max So for which Krow(So) <= TOLCRIT. - BOOST_CHECK_CLOSE(sogcr[0], 1.0 - 0.858996 - 0.071004, 1.0e-10); // Include SWL - - const auto krorw = fp.get_double("KRORW"); // Krow(So=1-Swcr-Sgl) = Krow(So=0.908996) - const auto krorg = fp.get_double("KRORG"); // Krog(So=1-Sgcr-Swl) = Krog(So=0.898996) - const auto kro = fp.get_double("KRO"); // Krow(So=Somax) = Krog(So=Somax) - BOOST_CHECK_CLOSE(krorw[0], 0.882459, 1.0e-10); - BOOST_CHECK_CLOSE(krorg[0], 0.896942, 1.0e-10); - BOOST_CHECK_CLOSE(kro [0], 1.0, 1.0e-10); - } - - // Gas end-points - { - const auto sgl = fp.get_double("SGL"); - const auto sgcr = fp.get_double("SGCR"); - const auto sgu = fp.get_double("SGU"); - BOOST_CHECK_CLOSE(sgl [0], 0.0, 1.0e-10); - BOOST_CHECK_CLOSE(sgcr[0], 0.03, 1.0e-10); - BOOST_CHECK_CLOSE(sgu [0], 0.928996, 1.0e-10); - - const auto krgr = fp.get_double("KRGR"); // Krg(Sg=1-Sogcr-Swl) = Krg(Sg=0.858996) - const auto krg = fp.get_double("KRG"); // Krg(Sgmax) = Krg(Sg=0.928996) - BOOST_CHECK_CLOSE(krgr[0], 0.866135, 1.0e-10); - BOOST_CHECK_CLOSE(krg [0], 1.0 , 1.0e-10); - - const auto pcg = fp.get_double("PCG"); - BOOST_CHECK_CLOSE(pcg[0], 0.0, 1.0e-10); - } -} - -BOOST_AUTO_TEST_CASE(SatFunc_EndPts_Family_II_TolCrit_Default) { - // TOLCRIT = 1.0e-6 - const auto es = ::Opm::EclipseState { - ::Opm::Parser{}.parseString(satfunc_model_setup() + satfunc_family_II() + end()) - }; - - auto fp = es.fieldProps(); - - // Water end-points - { - const auto swl = fp.get_double("SWL"); - const auto swcr = fp.get_double("SWCR"); - const auto swu = fp.get_double("SWU"); - BOOST_CHECK_CLOSE(swl [0], 0.071004, 1.0e-10); - BOOST_CHECK_CLOSE(swcr[0], 0.091004, 1.0e-10); // Max Sw for which Krw(Sw) <= TOLCRIT - BOOST_CHECK_CLOSE(swu [0], 1.0 , 1.0e-10); - - const auto krwr = fp.get_double("KRWR"); // Krw(Sw=1-Sowcr-Sgl) = Krw(Sw=0.771004) - const auto krw = fp.get_double("KRW"); // Krw(Swmax) = Krw(Sw=1) - BOOST_CHECK_CLOSE(krwr[0], 0.835916, 1.0e-10); - BOOST_CHECK_CLOSE(krw [0], 1.0 , 1.0e-10); - - const auto pcw = fp.get_double("PCW"); - BOOST_CHECK_CLOSE(pcw[0], 7.847999*unit::barsa, 1.0e-10); - } - - // Oil end-points - { - const auto sowcr = fp.get_double("SOWCR"); - const auto sogcr = fp.get_double("SOGCR"); - BOOST_CHECK_CLOSE(sowcr[0], 0.228996, 1.0e-10); // Max So for which Krow(So) <= TOLCRIT - BOOST_CHECK_CLOSE(sogcr[0], 0.070000, 1.0e-10); // Max So for which Krow(So) <= TOLCRIT - - const auto krorw = fp.get_double("KRORW"); // Krow(So=1-Swcr-Sgl) = Krow(So=0.908996) - const auto krorg = fp.get_double("KRORG"); // Krog(So=1-Sgcr-Swl) = Krog(So=0.898996) - const auto kro = fp.get_double("KRO"); // Krow(So=Somax) = Krog(So=Somax) - BOOST_CHECK_CLOSE(krorw[0], 0.882459, 1.0e-10); - BOOST_CHECK_CLOSE(krorg[0], 0.896942, 1.0e-10); - BOOST_CHECK_CLOSE(kro [0], 1.0 , 1.0e-10); - } - - // Gas end-points - { - const auto sgl = fp.get_double("SGL"); - const auto sgcr = fp.get_double("SGCR"); // Max Sg for which Krg(Sg) <= TOLCRIT - const auto sgu = fp.get_double("SGU"); - BOOST_CHECK_CLOSE(sgl [0], 0.0, 1.0e-10); - BOOST_CHECK_CLOSE(sgcr[0], 0.03, 1.0e-10); - BOOST_CHECK_CLOSE(sgu [0], 0.928996, 1.0e-10); - - const auto krgr = fp.get_double("KRGR"); // Krg(Sg=1-Sogcr-Swl) = Krg(Sg=0.858996) - const auto krg = fp.get_double("KRG"); // Krg(Sgmax) = Krg(Sg=0.928996) - BOOST_CHECK_CLOSE(krgr[0], 0.866135, 1.0e-10); - BOOST_CHECK_CLOSE(krg [0], 1.0 , 1.0e-10); - - const auto pcg = fp.get_double("PCG"); - BOOST_CHECK_CLOSE(pcg[0], 0.0, 1.0e-10); - } -} - -BOOST_AUTO_TEST_CASE(SatFunc_EndPts_Family_I_TolCrit_Large) { - // TOLCRIT = 0.01 - const auto es = ::Opm::EclipseState { - ::Opm::Parser{}.parseString(satfunc_model_setup() + tolCrit(0.01) + satfunc_family_I() + end()) - }; - - auto fp = es.fieldProps(); - - // Water end-points - { - const auto swl = fp.get_double("SWL"); - const auto swcr = fp.get_double("SWCR"); - const auto swu = fp.get_double("SWU"); - BOOST_CHECK_CLOSE(swl [0], 0.071004, 1.0e-10); - BOOST_CHECK_CLOSE(swcr[0], 0.231004, 1.0e-10); // Max Sw for which Krw(Sw) <= TOLCRIT - BOOST_CHECK_CLOSE(swu [0], 1.0 , 1.0e-10); - - const auto krwr = fp.get_double("KRWR"); // Krw(Sw=1-Sowcr-Sgl) = Krw(Sw=0.551004) - const auto krw = fp.get_double("KRW"); // Krw(Swmax) = Krw(Sw=1) - BOOST_CHECK_CLOSE(krwr[0], 0.261115, 1.0e-10); - BOOST_CHECK_CLOSE(krw [0], 1.0 , 1.0e-10); - - const auto pcw = fp.get_double("PCW"); - BOOST_CHECK_CLOSE(pcw[0], 7.847999*unit::barsa, 1.0e-10); - } - - // Oil end-points - { - const auto sowcr = fp.get_double("SOWCR"); - const auto sogcr = fp.get_double("SOGCR"); - BOOST_CHECK_CLOSE(sowcr[0], 0.448996, 1.0e-10); // Max So for which Krow(So) <= TOLCRIT - BOOST_CHECK_CLOSE(sogcr[0], 0.238996, 1.0e-10); // Max So for which Krog(So) <= TOLCRIT - - const auto krorw = fp.get_double("KRORW"); // Krow(So=1-Swcr-Sgl) = Krow(So=0.768996) - const auto krorg = fp.get_double("KRORG"); // Krog(So=1-Sgcr-Swl) = Krog(So=0.838996) - const auto kro = fp.get_double("KRO"); // Krow(So=Somax) = Krog(So=Somax) - BOOST_CHECK_CLOSE(krorw[0], 0.328347, 1.0e-10); - BOOST_CHECK_CLOSE(krorg[0], 0.712749, 1.0e-10); - BOOST_CHECK_CLOSE(kro [0], 1.0, 1.0e-10); - } - - // Gas end-points - { - const auto sgl = fp.get_double("SGL"); - const auto sgcr = fp.get_double("SGCR"); - const auto sgu = fp.get_double("SGU"); - BOOST_CHECK_CLOSE(sgl [0], 0.0, 1.0e-10); - BOOST_CHECK_CLOSE(sgcr[0], 0.090000, 1.0e-10); // Max Sg for which Krg(Sg) <= TOLCRIT - BOOST_CHECK_CLOSE(sgu [0], 0.928996, 1.0e-10); - - const auto krgr = fp.get_double("KRGR"); // Krg(Sg=1-Sogcr-Swl) = Krg(Sg=0.690000) - const auto krg = fp.get_double("KRG"); // Krg(Sgmax) = Krg(Sg=0.928996) - BOOST_CHECK_CLOSE(krgr[0], 0.578171, 1.0e-10); - BOOST_CHECK_CLOSE(krg [0], 1.0 , 1.0e-10); - - const auto pcg = fp.get_double("PCG"); - BOOST_CHECK_CLOSE(pcg[0], 0.0, 1.0e-10); - } -} - -BOOST_AUTO_TEST_CASE(SatFunc_EndPts_Family_II_TolCrit_Large) { - // TOLCRIT = 0.01 - const auto es = ::Opm::EclipseState { - ::Opm::Parser{}.parseString(satfunc_model_setup() + tolCrit(0.01) + satfunc_family_II() + end()) - }; - - auto fp = es.fieldProps(); - - // Water end-points - { - const auto swl = fp.get_double("SWL"); - const auto swcr = fp.get_double("SWCR"); - const auto swu = fp.get_double("SWU"); - BOOST_CHECK_CLOSE(swl [0], 0.071004, 1.0e-10); - BOOST_CHECK_CLOSE(swcr[0], 0.231004, 1.0e-10); // Max Sw for which Krw(Sw) <= TOLCRIT - BOOST_CHECK_CLOSE(swu [0], 1.0 , 1.0e-10); - - const auto krwr = fp.get_double("KRWR"); // Krw(Sw=1-Sowcr-Sgl) = Krw(Sw=0.551004) - const auto krw = fp.get_double("KRW"); // Krw(Swmax) = Krw(Sw=1) - BOOST_CHECK_CLOSE(krwr[0], 0.261115, 1.0e-10); - BOOST_CHECK_CLOSE(krw [0], 1.0 , 1.0e-10); - - const auto pcw = fp.get_double("PCW"); - BOOST_CHECK_CLOSE(pcw[0], 7.847999*unit::barsa, 1.0e-10); - } - - // Oil end-points - { - const auto sowcr = fp.get_double("SOWCR"); - const auto sogcr = fp.get_double("SOGCR"); - BOOST_CHECK_CLOSE(sowcr[0], 0.448996, 1.0e-10); // Max So for which Krow(So) <= TOLCRIT - BOOST_CHECK_CLOSE(sogcr[0], 0.248996, 1.0e-10); // Max So for which Krog(So) <= TOLCRIT - - const auto krorw = fp.get_double("KRORW"); // Krow(So=1-Swcr-Sgl) = Krow(So=0.768996) - const auto krorg = fp.get_double("KRORG"); // Krog(So=1-Sgcr-Swl) = Krog(So=0.838996) - const auto kro = fp.get_double("KRO"); // Krow(So=Somax) = Krog(So=Somax) - BOOST_CHECK_CLOSE(krorw[0], 0.328347, 1.0e-10); - BOOST_CHECK_CLOSE(krorg[0], 0.712749, 1.0e-10); - BOOST_CHECK_CLOSE(kro [0], 1.0, 1.0e-10); - } - - // Gas end-points - { - const auto sgl = fp.get_double("SGL"); - const auto sgcr = fp.get_double("SGCR"); - const auto sgu = fp.get_double("SGU"); - BOOST_CHECK_CLOSE(sgl [0], 0.0, 1.0e-10); - BOOST_CHECK_CLOSE(sgcr[0], 0.090000, 1.0e-10); // Max Sg for which Krg(Sg) <= TOLCRIT - BOOST_CHECK_CLOSE(sgu [0], 0.928996, 1.0e-10); - - const auto krgr = fp.get_double("KRGR"); // Krg(Sg=1-Sogcr-Swl) = Krg(Sg=0.680000) - const auto krg = fp.get_double("KRG"); // Krg(Sgmax) = Krg(Sg=0.928996) - BOOST_CHECK_CLOSE(krgr[0], 0.562914, 1.0e-10); - BOOST_CHECK_CLOSE(krg [0], 1.0 , 1.0e-10); - - const auto pcg = fp.get_double("PCG"); - BOOST_CHECK_CLOSE(pcg[0], 0.0, 1.0e-10); - } -} diff --git a/ThirdParty/custom-opm-common/opm-common/tests/parser/GroupTests.cpp b/ThirdParty/custom-opm-common/opm-common/tests/parser/GroupTests.cpp index 1db4e9417a..943cf8dd4d 100644 --- a/ThirdParty/custom-opm-common/opm-common/tests/parser/GroupTests.cpp +++ b/ThirdParty/custom-opm-common/opm-common/tests/parser/GroupTests.cpp @@ -537,61 +537,3 @@ BOOST_AUTO_TEST_CASE(GCONINJE_GCONPROD) { BOOST_CHECK( g2.injectionGroupControlAvailable(Phase::GAS)); } } - -BOOST_AUTO_TEST_CASE(GPMAINT) { - const auto input = R"( -SCHEDULE - -GRUPTREE - 'PROD' 'FIELD' / - - 'M5S' 'PLAT-A' / - 'M5N' 'PLAT-A' / - - 'C1' 'M5N' / - 'F1' 'M5N' / - 'B1' 'M5S' / - 'G1' 'M5S' / - / - -GPMAINT - 'PROD' 'WINJ' 2 1* 100 0.25 1.0 / - 'C1' 'GINJ' 0 1* 100 0.25 1.0 / -/ - -TSTEP - 10 / - -GPMAINT - 'PROD' 'NONE' / -/ - -)"; - Opm::UnitSystem unitSystem = UnitSystem( UnitSystem::UnitType::UNIT_TYPE_METRIC ); - const auto sched = create_schedule(input); - { - const auto& prod_group = sched.getGroup("PROD", 0); - const auto& plat_group = sched.getGroup("PLAT-A", 0); - const auto& c1_group = sched.getGroup("C1", 0); - - const auto& gpm_prod = prod_group.gpmaint(); - BOOST_CHECK( gpm_prod ); - BOOST_CHECK(gpm_prod->flow_target() == GPMaint::FlowTarget::RESV_WINJ); - - auto [name, number] = *gpm_prod->region(); - BOOST_CHECK_EQUAL(number, 2); - BOOST_CHECK_EQUAL(name, "FIPNUM"); - - const auto& gpm_c1 = c1_group.gpmaint(); - BOOST_CHECK(!gpm_c1->region()); - - const auto& plat_prod = plat_group.gpmaint(); - BOOST_CHECK( !plat_prod ); - } - { - const auto& prod_group = sched.getGroup("PROD", 1); - const auto& gpm_prod = prod_group.gpmaint(); - BOOST_CHECK( !gpm_prod ); - } -} - diff --git a/ThirdParty/custom-opm-common/opm-common/tests/parser/MultisegmentWellTests.cpp b/ThirdParty/custom-opm-common/opm-common/tests/parser/MultisegmentWellTests.cpp index 2987ba4bbf..7c6dfc153f 100644 --- a/ThirdParty/custom-opm-common/opm-common/tests/parser/MultisegmentWellTests.cpp +++ b/ThirdParty/custom-opm-common/opm-common/tests/parser/MultisegmentWellTests.cpp @@ -20,7 +20,6 @@ #include #include #include -#include #include @@ -35,161 +34,16 @@ #include #include -#include +#include #include #include #include -#include "src/opm/parser/eclipse/EclipseState/Schedule/MSW/Compsegs.hpp" #include #include #include - -BOOST_AUTO_TEST_CASE(AICDWellTest) { - - auto dir = Opm::Connection::Direction::Z; - const auto kind = Opm::Connection::CTFKind::DeckValue; - Opm::WellConnections connection_set(Opm::Connection::Order::TRACK, 10,10); - Opm::EclipseGrid grid(20,20,20); - connection_set.add(Opm::Connection( 19, 0, 0,grid.getGlobalIndex(19,0,0), 1, 0.0, Opm::Connection::State::OPEN , 200, 17.29, 0.25, 0.0, 0.0, 0, dir, kind, 0, true) ); - connection_set.add(Opm::Connection( 19, 0, 1,grid.getGlobalIndex(19,0,1), 1, 0.0, Opm::Connection::State::OPEN , 200, 17.29, 0.25, 0.0, 0.0, 0, dir, kind, 0, true) ); - connection_set.add(Opm::Connection( 19, 0, 2,grid.getGlobalIndex(19,0,2), 1, 0.0, Opm::Connection::State::OPEN , 200, 17.29, 0.25, 0.0, 0.0, 0, dir, kind, 0, true) ); - - connection_set.add(Opm::Connection( 18, 0, 1,grid.getGlobalIndex(18,0,1), 1, 0.0, Opm::Connection::State::OPEN , 200, 17.29, 0.25, 0.0, 0.0, 0, Opm::Connection::Direction::X, kind, 0, true) ); - connection_set.add(Opm::Connection( 17, 0, 1,grid.getGlobalIndex(17,0,1), 1, 0.0, Opm::Connection::State::OPEN , 200, 17.29, 0.25, 0.0, 0.0, 0, Opm::Connection::Direction::X, kind, 0, true) ); - connection_set.add(Opm::Connection( 16, 0, 1,grid.getGlobalIndex(16,0,1), 1, 0.0, Opm::Connection::State::OPEN , 200, 17.29, 0.25, 0.0, 0.0, 0, Opm::Connection::Direction::X, kind, 0, true) ); - connection_set.add(Opm::Connection( 15, 0, 1,grid.getGlobalIndex(15,0,1), 1, 0.0, Opm::Connection::State::OPEN , 200, 17.29, 0.25, 0.0, 0.0, 0, Opm::Connection::Direction::X, kind, 0, true) ); - - BOOST_CHECK_EQUAL( 7U , connection_set.size() ); - - const std::string compsegs_string = R"( -WELSEGS -'PROD01' 2512.5 2512.5 1.0e-5 'ABS' 'HF-' 'HO' / -2 2 1 1 2537.5 2537.5 0.3 0.00010 / -3 3 1 2 2562.5 2562.5 0.2 0.00010 / -4 4 2 2 2737.5 2537.5 0.2 0.00010 / -6 6 2 4 3037.5 2539.5 0.2 0.00010 / -7 7 2 6 3337.5 2534.5 0.2 0.00010 / -8 8 3 7 3337.6 2534.5 0.2 0.00015 / -/ - -COMPSEGS -PROD01 / -20 1 1 1 2512.5 2525.0 / -20 1 2 1 2525.0 2550.0 / -20 1 3 1 2550.0 2575.0 / -19 1 2 2 2637.5 2837.5 / -18 1 2 2 2837.5 3037.5 / -17 1 2 2 3037.5 3237.5 / -16 1 2 3 3237.5 3437.5 / -/ - -WSEGAICD -'PROD01' 8 8 0.002 -0.7 1* 1* 0.6 1* 1* 2* 1.0 1.0 'SHUT' / -/ -)"; - - Opm::Parser parser; - Opm::Deck deck = parser.parseString(compsegs_string); - - const Opm::DeckKeyword compsegs = deck.getKeyword("COMPSEGS"); - BOOST_CHECK_EQUAL( 8U, compsegs.size() ); - - const Opm::DeckKeyword welsegs = deck.getKeyword("WELSEGS"); - Opm::WellSegments segment_set(welsegs); - - BOOST_CHECK_EQUAL(7U, segment_set.size()); - - Opm::ErrorGuard errorGuard; - Opm::ParseContext parseContext; - parseContext.update(Opm::ParseContext::SCHEDULE_COMPSEGS_INVALID, Opm::InputError::THROW_EXCEPTION); - parseContext.update(Opm::ParseContext::SCHEDULE_COMPSEGS_NOT_SUPPORTED, Opm::InputError::THROW_EXCEPTION); - const auto& [new_connection_set, new_segment_set] = Opm::Compsegs::processCOMPSEGS(compsegs, connection_set, segment_set, grid, parseContext, errorGuard); - - // checking the ICD segment - const Opm::DeckKeyword wsegaicd = deck.getKeyword("WSEGAICD"); - const auto aicd_map = Opm::AutoICD::fromWSEGAICD(wsegaicd); - BOOST_CHECK_EQUAL(1U, aicd_map.size()); - - const auto it = aicd_map.begin(); - const std::string& well_name = it->first; - BOOST_CHECK_EQUAL(well_name, "PROD01"); - - const auto& aicd_vector = it->second; - BOOST_CHECK_EQUAL(1U, aicd_vector.size()); - const int segment_number = aicd_vector[0].first; - const Opm::AutoICD& aicd0 = aicd_vector[0].second; - BOOST_CHECK_EQUAL(8, segment_number); - - Opm::Segment segment = segment_set.getFromSegmentNumber(segment_number); - segment.updateAutoICD(aicd0); - - BOOST_CHECK(Opm::Segment::SegmentType::AICD == segment.segmentType()); - - auto aicd = segment.autoICD(); - BOOST_CHECK_GT(aicd.maxAbsoluteRate(), 1.e99); - BOOST_CHECK(aicd.status()==Opm::ICDStatus::SHUT); - // 0.002 bars*day*day/Volume^2 - BOOST_CHECK_EQUAL(aicd.strength(), 0.002*1.e5*86400.*86400.); - BOOST_CHECK_EQUAL(aicd.length(), -0.7); - BOOST_CHECK_EQUAL(aicd.densityCalibration(), 1000.25); - // 1.45 cp - BOOST_CHECK_EQUAL(aicd.viscosityCalibration(), 1.45 * 0.001); - BOOST_CHECK_EQUAL(aicd.criticalValue(), 0.6); - BOOST_CHECK_EQUAL(aicd.widthTransitionRegion(), 0.05); - BOOST_CHECK_EQUAL(aicd.maxViscosityRatio(), 5.0); - BOOST_CHECK_EQUAL(aicd.methodFlowScaling(), -1); - // the scaling factor has not been updated properly, so it will throw - BOOST_CHECK_THROW(aicd.scalingFactor(), std::runtime_error); - - const int outlet_segment_number = segment.outletSegment(); - const double outlet_segment_length = segment_set.segmentLength(outlet_segment_number); - // only one connection attached to the outlet segment in this case - const Opm::Connection& connection = new_connection_set.getFromIJK(15, 0, 1); - const auto& perf_range = connection.perf_range(); - const auto connection_length = perf_range->second - perf_range->first; - aicd.updateScalingFactor(outlet_segment_length, connection_length); - - BOOST_CHECK_EQUAL(7U, new_segment_set.size()); - - // updated, so it should not throw - BOOST_CHECK_NO_THROW(aicd.scalingFactor()); - BOOST_CHECK_EQUAL(0.7, aicd.scalingFactor()); - - BOOST_CHECK_EQUAL(7U, new_connection_set.size()); - - const Opm::Connection& connection1 = new_connection_set.get(0); - const int segment_number_connection1 = connection1.segment(); - const double center_depth_connection1 = connection1.depth(); - BOOST_CHECK_EQUAL(segment_number_connection1, 1); - BOOST_CHECK_EQUAL(center_depth_connection1, 2512.5); - - const Opm::Connection& connection3 = new_connection_set.get(2); - const int segment_number_connection3 = connection3.segment(); - const double center_depth_connection3 = connection3.depth(); - BOOST_CHECK_EQUAL(segment_number_connection3, 3); - BOOST_CHECK_EQUAL(center_depth_connection3, 2562.5); - - const Opm::Connection& connection5 = new_connection_set.get(4); - const int segment_number_connection5 = connection5.segment(); - const double center_depth_connection5 = connection5.depth(); - BOOST_CHECK_EQUAL(segment_number_connection5, 6); - BOOST_CHECK_CLOSE(center_depth_connection5, 2538.83, 0.001); - - const Opm::Connection& connection6 = new_connection_set.get(5); - const int segment_number_connection6 = connection6.segment(); - const double center_depth_connection6 = connection6.depth(); - BOOST_CHECK_EQUAL(segment_number_connection6, 6); - BOOST_CHECK_CLOSE(center_depth_connection6, 2537.83, 0.001); - - const Opm::Connection& connection7 = new_connection_set.get(6); - const int segment_number_connection7 = connection7.segment(); - const double center_depth_connection7 = connection7.depth(); - BOOST_CHECK_EQUAL(segment_number_connection7, 8); - BOOST_CHECK_EQUAL(center_depth_connection7, 2534.5); - -} +#include BOOST_AUTO_TEST_CASE(MultisegmentWellTest) { @@ -197,42 +51,41 @@ BOOST_AUTO_TEST_CASE(MultisegmentWellTest) { const auto kind = Opm::Connection::CTFKind::DeckValue; Opm::WellConnections connection_set(Opm::Connection::Order::TRACK, 10,10); Opm::EclipseGrid grid(20,20,20); - connection_set.add(Opm::Connection( 19, 0, 0,grid.getGlobalIndex(19,0,0), 1, 0.0, Opm::Connection::State::OPEN , 200, 17.29, 0.25, 0.0, 0.0, 0, dir, kind, 0, true) ); - connection_set.add(Opm::Connection( 19, 0, 1,grid.getGlobalIndex(19,0,1), 1, 0.0, Opm::Connection::State::OPEN , 200, 17.29, 0.25, 0.0, 0.0, 0, dir, kind, 0, true) ); - connection_set.add(Opm::Connection( 19, 0, 2,grid.getGlobalIndex(19,0,2), 1, 0.0, Opm::Connection::State::OPEN , 200, 17.29, 0.25, 0.0, 0.0, 0, dir, kind, 0, true) ); + connection_set.add(Opm::Connection( 19, 0, 0,grid.getGlobalIndex(19,0,0), 1, 0.0, Opm::Connection::State::OPEN , 200, 17.29, 0.25, 0.0, 0.0, 0, dir, kind, 0, 0., 0., true) ); + connection_set.add(Opm::Connection( 19, 0, 1,grid.getGlobalIndex(19,0,1), 1, 0.0, Opm::Connection::State::OPEN , 200, 17.29, 0.25, 0.0, 0.0, 0, dir, kind, 0, 0., 0., true) ); + connection_set.add(Opm::Connection( 19, 0, 2,grid.getGlobalIndex(19,0,2), 1, 0.0, Opm::Connection::State::OPEN , 200, 17.29, 0.25, 0.0, 0.0, 0, dir, kind, 0, 0., 0., true) ); - connection_set.add(Opm::Connection( 18, 0, 1,grid.getGlobalIndex(18,0,1), 1, 0.0, Opm::Connection::State::OPEN , 200, 17.29, 0.25, 0.0, 0.0, 0, Opm::Connection::Direction::X, kind, 0, true) ); - connection_set.add(Opm::Connection( 17, 0, 1,grid.getGlobalIndex(17,0,1), 1, 0.0, Opm::Connection::State::OPEN , 200, 17.29, 0.25, 0.0, 0.0, 0, Opm::Connection::Direction::X, kind, 0, true) ); - connection_set.add(Opm::Connection( 16, 0, 1,grid.getGlobalIndex(16,0,1), 1, 0.0, Opm::Connection::State::OPEN , 200, 17.29, 0.25, 0.0, 0.0, 0, Opm::Connection::Direction::X, kind, 0, true) ); - connection_set.add(Opm::Connection( 15, 0, 1,grid.getGlobalIndex(15,0,1), 1, 0.0, Opm::Connection::State::OPEN , 200, 17.29, 0.25, 0.0, 0.0, 0, Opm::Connection::Direction::X, kind, 0, true) ); + connection_set.add(Opm::Connection( 18, 0, 1,grid.getGlobalIndex(18,0,1), 1, 0.0, Opm::Connection::State::OPEN , 200, 17.29, 0.25, 0.0, 0.0, 0, Opm::Connection::Direction::X, kind, 0, 0., 0., true) ); + connection_set.add(Opm::Connection( 17, 0, 1,grid.getGlobalIndex(17,0,1), 1, 0.0, Opm::Connection::State::OPEN , 200, 17.29, 0.25, 0.0, 0.0, 0, Opm::Connection::Direction::X, kind, 0, 0., 0., true) ); + connection_set.add(Opm::Connection( 16, 0, 1,grid.getGlobalIndex(16,0,1), 1, 0.0, Opm::Connection::State::OPEN , 200, 17.29, 0.25, 0.0, 0.0, 0, Opm::Connection::Direction::X, kind, 0, 0., 0., true) ); + connection_set.add(Opm::Connection( 15, 0, 1,grid.getGlobalIndex(15,0,1), 1, 0.0, Opm::Connection::State::OPEN , 200, 17.29, 0.25, 0.0, 0.0, 0, Opm::Connection::Direction::X, kind, 0, 0., 0., true) ); BOOST_CHECK_EQUAL( 7U , connection_set.size() ); - const std::string compsegs_string = R"( -WELSEGS -'PROD01' 2512.5 2512.5 1.0e-5 'ABS' 'HF-' 'HO' / -2 2 1 1 2537.5 2537.5 0.3 0.00010 / -3 3 1 2 2562.5 2562.5 0.2 0.00010 / -4 4 2 2 2737.5 2537.5 0.2 0.00010 / -6 6 2 4 3037.5 2539.5 0.2 0.00010 / -7 7 2 6 3337.5 2534.5 0.2 0.00010 / -8 8 3 7 3337.6 2534.5 0.2 0.00015 / -/ - -COMPSEGS -PROD01 / -20 1 1 1 2512.5 2525.0 / -20 1 2 1 2525.0 2550.0 / -20 1 3 1 2550.0 2575.0 / -19 1 2 2 2637.5 2837.5 / -18 1 2 2 2837.5 3037.5 / -17 1 2 2 3037.5 3237.5 / -16 1 2 3 3237.5 3437.5 / -/ -WSEGSICD -'PROD01' 8 8 0.002 -0.7 1* 1* 0.6 1* 1* 2* 'SHUT' / -/ -)"; + const std::string compsegs_string = + "WELSEGS \n" + "'PROD01' 2512.5 2512.5 1.0e-5 'ABS' 'HF-' 'HO' /\n" + "2 2 1 1 2537.5 2537.5 0.3 0.00010 /\n" + "3 3 1 2 2562.5 2562.5 0.2 0.00010 /\n" + "4 4 2 2 2737.5 2537.5 0.2 0.00010 /\n" + "6 6 2 4 3037.5 2539.5 0.2 0.00010 /\n" + "7 7 2 6 3337.5 2534.5 0.2 0.00010 /\n" + "8 8 3 7 3337.6 2534.5 0.2 0.00015 /\n" + "/\n" + "\n" + "COMPSEGS\n" + "PROD01 / \n" + "20 1 1 1 2512.5 2525.0 /\n" + "20 1 2 1 2525.0 2550.0 /\n" + "20 1 3 1 2550.0 2575.0 /\n" + "19 1 2 2 2637.5 2837.5 /\n" + "18 1 2 2 2837.5 3037.5 /\n" + "17 1 2 2 3037.5 3237.5 /\n" + "16 1 2 3 3237.5 3437.5 /\n" + "/\n" + "WSEGSICD\n" + "'PROD01' 8 8 0.002 -0.7 1* 1* 0.6 1* 1* 2* 'SHUT' /\n" + "/\n"; Opm::Parser parser; Opm::Deck deck = parser.parseString(compsegs_string); @@ -249,7 +102,8 @@ WSEGSICD Opm::ParseContext parseContext; parseContext.update(Opm::ParseContext::SCHEDULE_COMPSEGS_INVALID, Opm::InputError::THROW_EXCEPTION); parseContext.update(Opm::ParseContext::SCHEDULE_COMPSEGS_NOT_SUPPORTED, Opm::InputError::THROW_EXCEPTION); - const auto& [new_connection_set, new_segment_set] = Opm::Compsegs::processCOMPSEGS(compsegs, connection_set, segment_set, grid, parseContext, errorGuard); + std::unique_ptr new_connection_set{nullptr}; + BOOST_CHECK_NO_THROW(new_connection_set.reset(Opm::newConnectionsWithSegments(compsegs, connection_set, segment_set, grid, parseContext, errorGuard))); // checking the ICD segment const Opm::DeckKeyword wsegsicd = deck.getKeyword("WSEGSICD"); @@ -260,7 +114,7 @@ WSEGSICD BOOST_CHECK_EQUAL(8, start_segment); BOOST_CHECK_EQUAL(8, end_segment); - const auto sicd_map = Opm::SICD::fromWSEGSICD(wsegsicd); + const auto sicd_map = Opm::SpiralICD::fromWSEGSICD(wsegsicd); BOOST_CHECK_EQUAL(1U, sicd_map.size()); @@ -271,72 +125,69 @@ WSEGSICD const auto& sicd_vector = it->second; BOOST_CHECK_EQUAL(1U, sicd_vector.size()); const int segment_number = sicd_vector[0].first; - const Opm::SICD& sicd0 = sicd_vector[0].second; + const Opm::SpiralICD& sicd = sicd_vector[0].second; BOOST_CHECK_EQUAL(8, segment_number); Opm::Segment segment = segment_set.getFromSegmentNumber(segment_number); - segment.updateSpiralICD(sicd0); + segment.updateSpiralICD(sicd); BOOST_CHECK(Opm::Segment::SegmentType::SICD==segment.segmentType()); - auto sicd = segment.spiralICD(); - BOOST_CHECK_GT(sicd.maxAbsoluteRate(), 1.e99); - BOOST_CHECK(sicd.status()==Opm::ICDStatus::SHUT); + const std::shared_ptr sicd_ptr = segment.spiralICD(); + BOOST_CHECK_GT(sicd_ptr->maxAbsoluteRate(), 1.e99); + BOOST_CHECK(sicd_ptr->status()==Opm::ICDStatus::SHUT); // 0.002 bars*day*day/Volume^2 - BOOST_CHECK_EQUAL(sicd.strength(), 0.002*1.e5*86400.*86400.); - BOOST_CHECK_EQUAL(sicd.length(), -0.7); - BOOST_CHECK_EQUAL(sicd.densityCalibration(), 1000.25); + BOOST_CHECK_EQUAL(sicd_ptr->strength(), 0.002*1.e5*86400.*86400.); + BOOST_CHECK_EQUAL(sicd_ptr->length(), -0.7); + BOOST_CHECK_EQUAL(sicd_ptr->densityCalibration(), 1000.25); // 1.45 cp - BOOST_CHECK_EQUAL(sicd.viscosityCalibration(), 1.45 * 0.001); - BOOST_CHECK_EQUAL(sicd.criticalValue(), 0.6); - BOOST_CHECK_EQUAL(sicd.widthTransitionRegion(), 0.05); - BOOST_CHECK_EQUAL(sicd.maxViscosityRatio(), 5.0); - BOOST_CHECK_EQUAL(sicd.methodFlowScaling(), -1); + BOOST_CHECK_EQUAL(sicd_ptr->viscosityCalibration(), 1.45 * 0.001); + BOOST_CHECK_EQUAL(sicd_ptr->criticalValue(), 0.6); + BOOST_CHECK_EQUAL(sicd_ptr->widthTransitionRegion(), 0.05); + BOOST_CHECK_EQUAL(sicd_ptr->maxViscosityRatio(), 5.0); + BOOST_CHECK_EQUAL(sicd_ptr->methodFlowScaling(), -1); // the scaling factor has not been updated properly, so it will throw - BOOST_CHECK_THROW(sicd.scalingFactor(), std::runtime_error); + BOOST_CHECK_THROW(sicd_ptr->scalingFactor(), std::runtime_error); const int outlet_segment_number = segment.outletSegment(); const double outlet_segment_length = segment_set.segmentLength(outlet_segment_number); // only one connection attached to the outlet segment in this case - const Opm::Connection& connection = new_connection_set.getFromIJK(15, 0, 1); - const auto& perf_range = connection.perf_range(); - const auto connection_length = perf_range->second - perf_range->first; - sicd.updateScalingFactor(outlet_segment_length, connection_length); + const Opm::Connection& connection = new_connection_set->getFromIJK(15, 0, 1); + const double connection_length = connection.getSegDistEnd() - connection.getSegDistStart(); + sicd_ptr->updateScalingFactor(outlet_segment_length, connection_length); // updated, so it should not throw - BOOST_CHECK_NO_THROW(sicd.scalingFactor()); - BOOST_CHECK_EQUAL(0.7, sicd.scalingFactor()); + BOOST_CHECK_NO_THROW(sicd_ptr->scalingFactor()); + BOOST_CHECK_EQUAL(0.7, sicd_ptr->scalingFactor()); - BOOST_CHECK_EQUAL(7U, new_segment_set.size()); + BOOST_CHECK_EQUAL(7U, new_connection_set->size()); - BOOST_CHECK_EQUAL(7U, new_connection_set.size()); - - const Opm::Connection& connection1 = new_connection_set.get(0); + const Opm::Connection& connection1 = new_connection_set->get(0); const int segment_number_connection1 = connection1.segment(); const double center_depth_connection1 = connection1.depth(); BOOST_CHECK_EQUAL(segment_number_connection1, 1); BOOST_CHECK_EQUAL(center_depth_connection1, 2512.5); - const Opm::Connection& connection3 = new_connection_set.get(2); + const Opm::Connection& connection3 = new_connection_set->get(2); const int segment_number_connection3 = connection3.segment(); const double center_depth_connection3 = connection3.depth(); BOOST_CHECK_EQUAL(segment_number_connection3, 3); BOOST_CHECK_EQUAL(center_depth_connection3, 2562.5); - const Opm::Connection& connection5 = new_connection_set.get(4); + const Opm::Connection& connection5 = new_connection_set->get(4); const int segment_number_connection5 = connection5.segment(); const double center_depth_connection5 = connection5.depth(); BOOST_CHECK_EQUAL(segment_number_connection5, 6); BOOST_CHECK_CLOSE(center_depth_connection5, 2538.83, 0.001); - const Opm::Connection& connection6 = new_connection_set.get(5); + const Opm::Connection& connection6 = new_connection_set->get(5); const int segment_number_connection6 = connection6.segment(); const double center_depth_connection6 = connection6.depth(); BOOST_CHECK_EQUAL(segment_number_connection6, 6); BOOST_CHECK_CLOSE(center_depth_connection6, 2537.83, 0.001); - const Opm::Connection& connection7 = new_connection_set.get(6); + const Opm::Connection& connection7 = new_connection_set->get(6); const int segment_number_connection7 = connection7.segment(); const double center_depth_connection7 = connection7.depth(); BOOST_CHECK_EQUAL(segment_number_connection7, 8); @@ -349,14 +200,14 @@ BOOST_AUTO_TEST_CASE(WrongDistanceCOMPSEGS) { const auto kind = Opm::Connection::CTFKind::DeckValue; Opm::WellConnections connection_set(Opm::Connection::Order::TRACK, 10,10); Opm::EclipseGrid grid(20,20,20); - connection_set.add(Opm::Connection( 19, 0, 0, grid.getGlobalIndex(19,0,0),1, 0.0, Opm::Connection::State::OPEN , 200, 17.29, 0.25, 0.0, 0.0, 0, dir, kind, 0, true) ); - connection_set.add(Opm::Connection( 19, 0, 1, grid.getGlobalIndex(19,0,1),1, 0.0, Opm::Connection::State::OPEN , 200, 17.29, 0.25, 0.0, 0.0, 0, dir, kind, 0, true) ); - connection_set.add(Opm::Connection( 19, 0, 2, grid.getGlobalIndex(19,0,2),1, 0.0, Opm::Connection::State::OPEN , 200, 17.29, 0.25, 0.0, 0.0, 0, dir, kind, 0, true) ); + connection_set.add(Opm::Connection( 19, 0, 0, grid.getGlobalIndex(19,0,0),1, 0.0, Opm::Connection::State::OPEN , 200, 17.29, 0.25, 0.0, 0.0, 0, dir, kind, 0, 0., 0., true) ); + connection_set.add(Opm::Connection( 19, 0, 1, grid.getGlobalIndex(19,0,1),1, 0.0, Opm::Connection::State::OPEN , 200, 17.29, 0.25, 0.0, 0.0, 0, dir, kind, 0, 0., 0., true) ); + connection_set.add(Opm::Connection( 19, 0, 2, grid.getGlobalIndex(19,0,2),1, 0.0, Opm::Connection::State::OPEN , 200, 17.29, 0.25, 0.0, 0.0, 0, dir, kind, 0, 0., 0., true) ); - connection_set.add(Opm::Connection( 18, 0, 1, grid.getGlobalIndex(18,0,1),1, 0.0, Opm::Connection::State::OPEN , 200, 17.29, 0.25, 0.0, 0.0, 0, Opm::Connection::Direction::X, kind, 0, true) ); - connection_set.add(Opm::Connection( 17, 0, 1, grid.getGlobalIndex(17,0,1),1, 0.0, Opm::Connection::State::OPEN , 200, 17.29, 0.25, 0.0, 0.0, 0, Opm::Connection::Direction::X, kind, 0, true) ); - connection_set.add(Opm::Connection( 16, 0, 1, grid.getGlobalIndex(16,0,1),1, 0.0, Opm::Connection::State::OPEN , 200, 17.29, 0.25, 0.0, 0.0, 0, Opm::Connection::Direction::X, kind, 0, true) ); - connection_set.add(Opm::Connection( 15, 0, 1, grid.getGlobalIndex(15,0,1),1, 0.0, Opm::Connection::State::OPEN , 200, 17.29, 0.25, 0.0, 0.0, 0, Opm::Connection::Direction::X, kind, 0, true) ); + connection_set.add(Opm::Connection( 18, 0, 1, grid.getGlobalIndex(18,0,1),1, 0.0, Opm::Connection::State::OPEN , 200, 17.29, 0.25, 0.0, 0.0, 0, Opm::Connection::Direction::X, kind, 0, 0., 0., true) ); + connection_set.add(Opm::Connection( 17, 0, 1, grid.getGlobalIndex(17,0,1),1, 0.0, Opm::Connection::State::OPEN , 200, 17.29, 0.25, 0.0, 0.0, 0, Opm::Connection::Direction::X, kind, 0, 0., 0., true) ); + connection_set.add(Opm::Connection( 16, 0, 1, grid.getGlobalIndex(16,0,1),1, 0.0, Opm::Connection::State::OPEN , 200, 17.29, 0.25, 0.0, 0.0, 0, Opm::Connection::Direction::X, kind, 0, 0., 0., true) ); + connection_set.add(Opm::Connection( 15, 0, 1, grid.getGlobalIndex(15,0,1),1, 0.0, Opm::Connection::State::OPEN , 200, 17.29, 0.25, 0.0, 0.0, 0, Opm::Connection::Direction::X, kind, 0, 0., 0., true) ); BOOST_CHECK_EQUAL( 7U , connection_set.size() ); @@ -395,10 +246,10 @@ BOOST_AUTO_TEST_CASE(WrongDistanceCOMPSEGS) { Opm::ErrorGuard errorGuard; Opm::ParseContext parseContext; parseContext.update(Opm::ParseContext::SCHEDULE_COMPSEGS_INVALID, Opm::InputError::THROW_EXCEPTION); - BOOST_CHECK_THROW(Opm::Compsegs::processCOMPSEGS(compsegs, connection_set, segment_set, grid, parseContext, errorGuard), std::invalid_argument); + BOOST_CHECK_THROW(std::unique_ptr(Opm::newConnectionsWithSegments(compsegs, connection_set, segment_set, grid, parseContext, errorGuard)), std::invalid_argument); parseContext.update(Opm::ParseContext::SCHEDULE_COMPSEGS_INVALID, Opm::InputError::IGNORE); - BOOST_CHECK_NO_THROW(Opm::Compsegs::processCOMPSEGS(compsegs, connection_set, segment_set, grid, parseContext, errorGuard)); + BOOST_CHECK_NO_THROW(std::unique_ptr(Opm::newConnectionsWithSegments(compsegs, connection_set, segment_set, grid, parseContext, errorGuard))); } BOOST_AUTO_TEST_CASE(NegativeDepthCOMPSEGS) { @@ -406,14 +257,14 @@ BOOST_AUTO_TEST_CASE(NegativeDepthCOMPSEGS) { const auto kind = Opm::Connection::CTFKind::DeckValue; Opm::WellConnections connection_set(Opm::Connection::Order::TRACK, 10,10); Opm::EclipseGrid grid(20,20,20); - connection_set.add(Opm::Connection( 19, 0, 0, grid.getGlobalIndex(19,0,0),1, 0.0, Opm::Connection::State::OPEN , 200, 17.29, 0.25, 0.0, 0.0, 0, dir, kind, 0, true) ); - connection_set.add(Opm::Connection( 19, 0, 1, grid.getGlobalIndex(19,0,1),1, 0.0, Opm::Connection::State::OPEN , 200, 17.29, 0.25, 0.0, 0.0, 0, dir, kind, 0, true) ); - connection_set.add(Opm::Connection( 19, 0, 2, grid.getGlobalIndex(19,0,2),1, 0.0, Opm::Connection::State::OPEN , 200, 17.29, 0.25, 0.0, 0.0, 0, dir, kind, 0, true) ); + connection_set.add(Opm::Connection( 19, 0, 0, grid.getGlobalIndex(19,0,0),1, 0.0, Opm::Connection::State::OPEN , 200, 17.29, 0.25, 0.0, 0.0, 0, dir, kind, 0, 0., 0., true) ); + connection_set.add(Opm::Connection( 19, 0, 1, grid.getGlobalIndex(19,0,1),1, 0.0, Opm::Connection::State::OPEN , 200, 17.29, 0.25, 0.0, 0.0, 0, dir, kind, 0, 0., 0., true) ); + connection_set.add(Opm::Connection( 19, 0, 2, grid.getGlobalIndex(19,0,2),1, 0.0, Opm::Connection::State::OPEN , 200, 17.29, 0.25, 0.0, 0.0, 0, dir, kind, 0, 0., 0., true) ); - connection_set.add(Opm::Connection( 18, 0, 1, grid.getGlobalIndex(18,0,1),1, 0.0, Opm::Connection::State::OPEN , 200, 17.29, 0.25, 0.0, 0.0, 0, Opm::Connection::Direction::X, kind, 0, true) ); - connection_set.add(Opm::Connection( 17, 0, 1, grid.getGlobalIndex(17,0,1),1, 0.0, Opm::Connection::State::OPEN , 200, 17.29, 0.25, 0.0, 0.0, 0, Opm::Connection::Direction::X, kind, 0, true) ); - connection_set.add(Opm::Connection( 16, 0, 1, grid.getGlobalIndex(16,0,1),1, 0.0, Opm::Connection::State::OPEN , 200, 17.29, 0.25, 0.0, 0.0, 0, Opm::Connection::Direction::X, kind, 0, true) ); - connection_set.add(Opm::Connection( 15, 0, 1, grid.getGlobalIndex(15,0,1),1, 0.0, Opm::Connection::State::OPEN , 200, 17.29, 0.25, 0.0, 0.0, 0, Opm::Connection::Direction::X, kind, 0, true) ); + connection_set.add(Opm::Connection( 18, 0, 1, grid.getGlobalIndex(18,0,1),1, 0.0, Opm::Connection::State::OPEN , 200, 17.29, 0.25, 0.0, 0.0, 0, Opm::Connection::Direction::X, kind, 0, 0., 0., true) ); + connection_set.add(Opm::Connection( 17, 0, 1, grid.getGlobalIndex(17,0,1),1, 0.0, Opm::Connection::State::OPEN , 200, 17.29, 0.25, 0.0, 0.0, 0, Opm::Connection::Direction::X, kind, 0, 0., 0., true) ); + connection_set.add(Opm::Connection( 16, 0, 1, grid.getGlobalIndex(16,0,1),1, 0.0, Opm::Connection::State::OPEN , 200, 17.29, 0.25, 0.0, 0.0, 0, Opm::Connection::Direction::X, kind, 0, 0., 0., true) ); + connection_set.add(Opm::Connection( 15, 0, 1, grid.getGlobalIndex(15,0,1),1, 0.0, Opm::Connection::State::OPEN , 200, 17.29, 0.25, 0.0, 0.0, 0, Opm::Connection::Direction::X, kind, 0, 0., 0., true) ); BOOST_CHECK_EQUAL( 7U , connection_set.size() ); @@ -451,11 +302,12 @@ BOOST_AUTO_TEST_CASE(NegativeDepthCOMPSEGS) { Opm::ErrorGuard errorGuard; Opm::ParseContext parseContext; + std::unique_ptr wconns{nullptr}; parseContext.update(Opm::ParseContext::SCHEDULE_COMPSEGS_NOT_SUPPORTED, Opm::InputError::THROW_EXCEPTION); - BOOST_CHECK_THROW(Opm::Compsegs::processCOMPSEGS(compsegs, connection_set, segment_set, grid, parseContext, errorGuard), std::invalid_argument); + BOOST_CHECK_THROW(wconns.reset(Opm::newConnectionsWithSegments(compsegs, connection_set, segment_set, grid, parseContext, errorGuard)), std::invalid_argument); parseContext.update(Opm::ParseContext::SCHEDULE_COMPSEGS_NOT_SUPPORTED, Opm::InputError::IGNORE); - BOOST_CHECK_NO_THROW( Opm::Compsegs::processCOMPSEGS(compsegs, connection_set, segment_set, grid, parseContext, errorGuard) ); + BOOST_CHECK_NO_THROW(wconns.reset(Opm::newConnectionsWithSegments(compsegs, connection_set, segment_set, grid, parseContext, errorGuard))); } BOOST_AUTO_TEST_CASE(testwsegvalv) { @@ -463,14 +315,14 @@ BOOST_AUTO_TEST_CASE(testwsegvalv) { const auto kind = Opm::Connection::CTFKind::DeckValue; Opm::WellConnections connection_set(Opm::Connection::Order::TRACK, 10,10); Opm::EclipseGrid grid(20,20,20); - connection_set.add(Opm::Connection( 19, 0, 0, grid.getGlobalIndex(19,0,0), 1, 0.0, Opm::Connection::State::OPEN , 200, 17.29, 0.25, 0.0, 0.0, 0, dir, kind, 0, true) ); - connection_set.add(Opm::Connection( 19, 0, 1, grid.getGlobalIndex(19,0,1), 1, 0.0, Opm::Connection::State::OPEN , 200, 17.29, 0.25, 0.0, 0.0, 0, dir, kind, 0, true) ); - connection_set.add(Opm::Connection( 19, 0, 2, grid.getGlobalIndex(19,0,2), 1, 0.0, Opm::Connection::State::OPEN , 200, 17.29, 0.25, 0.0, 0.0, 0, dir, kind, 0, true) ); + connection_set.add(Opm::Connection( 19, 0, 0, grid.getGlobalIndex(19,0,0), 1, 0.0, Opm::Connection::State::OPEN , 200, 17.29, 0.25, 0.0, 0.0, 0, dir, kind, 0, 0., 0., true) ); + connection_set.add(Opm::Connection( 19, 0, 1, grid.getGlobalIndex(19,0,1), 1, 0.0, Opm::Connection::State::OPEN , 200, 17.29, 0.25, 0.0, 0.0, 0, dir, kind, 0, 0., 0., true) ); + connection_set.add(Opm::Connection( 19, 0, 2, grid.getGlobalIndex(19,0,2), 1, 0.0, Opm::Connection::State::OPEN , 200, 17.29, 0.25, 0.0, 0.0, 0, dir, kind, 0, 0., 0., true) ); - connection_set.add(Opm::Connection( 18, 0, 1, grid.getGlobalIndex(18,0,1), 1, 0.0, Opm::Connection::State::OPEN , 200, 17.29, 0.25, 0.0, 0.0, 0, Opm::Connection::Direction::X, kind, 0, true) ); - connection_set.add(Opm::Connection( 17, 0, 1, grid.getGlobalIndex(17,0,1), 1, 0.0, Opm::Connection::State::OPEN , 200, 17.29, 0.25, 0.0, 0.0, 0, Opm::Connection::Direction::X, kind, 0, true) ); - connection_set.add(Opm::Connection( 16, 0, 1, grid.getGlobalIndex(16,0,1), 1, 0.0, Opm::Connection::State::OPEN , 200, 17.29, 0.25, 0.0, 0.0, 0, Opm::Connection::Direction::X, kind, 0, true) ); - connection_set.add(Opm::Connection( 15, 0, 1, grid.getGlobalIndex(15,0,1), 1, 0.0, Opm::Connection::State::OPEN , 200, 17.29, 0.25, 0.0, 0.0, 0, Opm::Connection::Direction::X, kind, 0, true) ); + connection_set.add(Opm::Connection( 18, 0, 1, grid.getGlobalIndex(18,0,1), 1, 0.0, Opm::Connection::State::OPEN , 200, 17.29, 0.25, 0.0, 0.0, 0, Opm::Connection::Direction::X, kind, 0, 0., 0., true) ); + connection_set.add(Opm::Connection( 17, 0, 1, grid.getGlobalIndex(17,0,1), 1, 0.0, Opm::Connection::State::OPEN , 200, 17.29, 0.25, 0.0, 0.0, 0, Opm::Connection::Direction::X, kind, 0, 0., 0., true) ); + connection_set.add(Opm::Connection( 16, 0, 1, grid.getGlobalIndex(16,0,1), 1, 0.0, Opm::Connection::State::OPEN , 200, 17.29, 0.25, 0.0, 0.0, 0, Opm::Connection::Direction::X, kind, 0, 0., 0., true) ); + connection_set.add(Opm::Connection( 15, 0, 1, grid.getGlobalIndex(15,0,1), 1, 0.0, Opm::Connection::State::OPEN , 200, 17.29, 0.25, 0.0, 0.0, 0, Opm::Connection::Direction::X, kind, 0, 0., 0., true) ); BOOST_CHECK_EQUAL( 7U , connection_set.size() ); @@ -516,7 +368,8 @@ BOOST_AUTO_TEST_CASE(testwsegvalv) { Opm::ParseContext parseContext; parseContext.update(Opm::ParseContext::SCHEDULE_COMPSEGS_INVALID, Opm::InputError::THROW_EXCEPTION); parseContext.update(Opm::ParseContext::SCHEDULE_COMPSEGS_NOT_SUPPORTED, Opm::InputError::THROW_EXCEPTION); - BOOST_CHECK_NO_THROW( Opm::Compsegs::processCOMPSEGS(compsegs, connection_set, segment_set, grid, parseContext, errorGuard)); + std::unique_ptr new_connection_set{nullptr}; + BOOST_CHECK_NO_THROW(new_connection_set.reset(Opm::newConnectionsWithSegments(compsegs, connection_set, segment_set, grid, parseContext, errorGuard))); // checking the WSEGVALV segment const Opm::DeckKeyword wsegvalv = deck.getKeyword("WSEGVALV"); @@ -549,15 +402,15 @@ BOOST_AUTO_TEST_CASE(testwsegvalv) { segment1.updateValve(valve1, segment_length1); BOOST_CHECK(Opm::Segment::SegmentType::VALVE==segment1.segmentType()); - const Opm::Valve& valv1 = segment1.valve(); - BOOST_CHECK_EQUAL(valv1.conFlowCoefficient(), 0.002); - BOOST_CHECK_EQUAL(valv1.conCrossArea(), 5.); - BOOST_CHECK_EQUAL(valv1.conMaxCrossArea(), 0.031415926535897934); - BOOST_CHECK_CLOSE(valv1.pipeAdditionalLength(), 0.1, 1.e-10); - BOOST_CHECK_EQUAL(valv1.pipeDiameter(), 0.2); - BOOST_CHECK_EQUAL(valv1.pipeRoughness(), 0.00015); - BOOST_CHECK_EQUAL(valv1.pipeCrossArea(), 0.031415926535897934); - BOOST_CHECK(valv1.status()==Opm::ICDStatus::OPEN); + const Opm::Valve* valv1 = segment1.valve(); + BOOST_CHECK_EQUAL(valv1->conFlowCoefficient(), 0.002); + BOOST_CHECK_EQUAL(valv1->conCrossArea(), 5.); + BOOST_CHECK_EQUAL(valv1->conMaxCrossArea(), 0.031415926535897934); + BOOST_CHECK_CLOSE(valv1->pipeAdditionalLength(), 0.1, 1.e-10); + BOOST_CHECK_EQUAL(valv1->pipeDiameter(), 0.2); + BOOST_CHECK_EQUAL(valv1->pipeRoughness(), 0.00015); + BOOST_CHECK_EQUAL(valv1->pipeCrossArea(), 0.031415926535897934); + BOOST_CHECK(valv1->status()==Opm::ICDStatus::OPEN); const int segment_number2 = segvalv_vector[1].first; BOOST_CHECK_EQUAL(9, segment_number2); @@ -572,33 +425,30 @@ BOOST_AUTO_TEST_CASE(testwsegvalv) { segment2.updateValve(valve2, segment_length2); BOOST_CHECK(Opm::Segment::SegmentType::VALVE ==segment2.segmentType()); - const Opm::Valve& valv2 = segment2.valve(); - BOOST_CHECK_EQUAL(valv2.conFlowCoefficient(), 0.001); - BOOST_CHECK_EQUAL(valv2.conCrossArea(), 6.); - BOOST_CHECK_EQUAL(valv2.conMaxCrossArea(), 9.); - BOOST_CHECK_EQUAL(valv2.pipeAdditionalLength(), 0.0); - BOOST_CHECK_EQUAL(valv2.pipeDiameter(), 1.2); - BOOST_CHECK_EQUAL(valv2.pipeRoughness(), 0.1); - BOOST_CHECK_EQUAL(valv2.pipeCrossArea(), 8.); - BOOST_CHECK(valv2.status()==Opm::ICDStatus::SHUT); + const Opm::Valve* valv2 = segment2.valve(); + BOOST_CHECK_EQUAL(valv2->conFlowCoefficient(), 0.001); + BOOST_CHECK_EQUAL(valv2->conCrossArea(), 6.); + BOOST_CHECK_EQUAL(valv2->conMaxCrossArea(), 9.); + BOOST_CHECK_EQUAL(valv2->pipeAdditionalLength(), 0.0); + BOOST_CHECK_EQUAL(valv2->pipeDiameter(), 1.2); + BOOST_CHECK_EQUAL(valv2->pipeRoughness(), 0.1); + BOOST_CHECK_EQUAL(valv2->pipeCrossArea(), 8.); + BOOST_CHECK(valv2->status()==Opm::ICDStatus::SHUT); // valve changes the segment data - BOOST_CHECK_EQUAL(segment2.internalDiameter(), valv2.pipeDiameter()); - BOOST_CHECK_EQUAL(segment2.roughness(), valv2.pipeRoughness()); - BOOST_CHECK_EQUAL(segment2.crossArea(), valv2.pipeCrossArea()); -} - - -Opm::Schedule make_schedule(const std::string& fname) { - Opm::Parser parser; - Opm::Deck deck = parser.parseFile(fname); - Opm::EclipseState st(deck); - return Opm::Schedule(deck, st); + BOOST_CHECK_EQUAL(segment2.internalDiameter(), valv2->pipeDiameter()); + BOOST_CHECK_EQUAL(segment2.roughness(), valv2->pipeRoughness()); + BOOST_CHECK_EQUAL(segment2.crossArea(), valv2->pipeCrossArea()); } BOOST_AUTO_TEST_CASE(MSW_SEGMENT_LENGTH) { - const auto& sched = make_schedule("MSW.DATA"); + Opm::Parser parser; + Opm::Deck deck = parser.parseFile("MSW.DATA"); + Opm::EclipseState st(deck); + Opm::Schedule sched(deck, st); + + const auto& well = sched.getWell("PROD01", 0); const auto& segments = well.getSegments(); BOOST_CHECK_CLOSE( segments.segmentLength(1), 2512.50, 1e-5); @@ -613,7 +463,12 @@ BOOST_AUTO_TEST_CASE(MSW_SEGMENT_LENGTH) { } BOOST_AUTO_TEST_CASE(MSW_BRANCH_SEGMENTS) { - const auto& sched = make_schedule("MSW.DATA"); + Opm::Parser parser; + Opm::Deck deck = parser.parseFile("MSW.DATA"); + Opm::EclipseState st(deck); + Opm::Schedule sched(deck, st); + + const auto& well = sched.getWell("PROD01", 0); const auto& segments = well.getSegments(); { @@ -644,10 +499,3 @@ BOOST_AUTO_TEST_CASE(MSW_BRANCH_SEGMENTS) { } -BOOST_AUTO_TEST_CASE(Branches) { - const auto& sched = make_schedule("MSW.DATA"); - const auto& well = sched.getWell("PROD01", 0); - const auto& segments = well.getSegments(); - std::set expected = {1,2,3,4,5}; - BOOST_CHECK( expected == segments.branches() ); -} diff --git a/ThirdParty/custom-opm-common/opm-common/tests/parser/NetworkTests.cpp b/ThirdParty/custom-opm-common/opm-common/tests/parser/NetworkTests.cpp deleted file mode 100644 index c4b8197073..0000000000 --- a/ThirdParty/custom-opm-common/opm-common/tests/parser/NetworkTests.cpp +++ /dev/null @@ -1,268 +0,0 @@ -/* - Copyright 2020 Equinor ASA. - - This file is part of the Open Porous Media project (OPM). - - OPM is free software: you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - OPM is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with OPM. If not, see . -*/ - -#define BOOST_TEST_MODULE ScheduleTests - -#include - -#include -#include -#include -#include -#include -#include -#include -#include - -using namespace Opm; - -Schedule make_schedule(const std::string& schedule_string) { - Parser parser; - auto python = std::make_shared(); - Deck deck = parser.parseString(schedule_string); - EclipseGrid grid(10,10,10); - TableManager table ( deck ); - FieldPropsManager fp( deck, Phases{true, true, true}, grid, table); - Runspec runspec (deck); - Schedule schedule(deck, grid , fp, runspec, python); - return schedule; -} - - - -BOOST_AUTO_TEST_CASE(CreateNetwork) { - Network::ExtNetwork network; - BOOST_CHECK( !network.active() ); - auto schedule = make_schedule("SCHEDULE\n"); - auto network2 = schedule.network(0); - BOOST_CHECK( !network2.active() ); -} - - - -BOOST_AUTO_TEST_CASE(Branch) { - BOOST_CHECK_THROW( Network::Branch("down", "up", 100, Network::Branch::AlqEQ::ALQ_INPUT), std::logic_error); -} - - -BOOST_AUTO_TEST_CASE(INVALID_DOWNTREE_NODE) { - std::string deck_string = R"( -SCHEDULE - -GRUPTREE - 'PROD' 'FIELD' / - - 'M5S' 'PLAT-A' / - 'M5N' 'PLAT-A' / - - 'C1' 'M5N' / - 'F1' 'M5N' / - 'B1' 'M5S' / - 'G1' 'M5S' / -/ - -BRANPROP --- Downtree Uptree #VFP ALQ - B1X PLAT-A 5 1* / - C1 PLAT-A 4 1* / -/ - -NODEPROP --- Node_name Pr autoChock? addGasLift? Group_name - PLAT-A 21.0 NO NO 1* / - B1 1* NO NO 1* / - C1 1* NO NO 1* / -/ -)"; - - BOOST_CHECK_THROW( make_schedule(deck_string), std::invalid_argument); -} - - -BOOST_AUTO_TEST_CASE(INVALID_UPTREE_NODE) { - std::string deck_string = R"( -SCHEDULE - -GRUPTREE - 'PROD' 'FIELD' / - - 'M5S' 'PLAT-A' / - 'M5N' 'PLAT-A' / - - 'C1' 'M5N' / - 'F1' 'M5N' / - 'B1' 'M5S' / - 'G1' 'M5S' / -/ - -BRANPROP --- Downtree Uptree #VFP ALQ - B1 PLAT-AX 5 1* / - C1 PLAT-AX 4 1* / -/ - -NODEPROP --- Node_name Pr autoChock? addGasLift? Group_name - PLAT-A 21.0 NO NO 1* / - B1 1* NO NO 1* / - C1 1* NO NO 1* / -/ -)"; - - BOOST_CHECK_THROW( make_schedule(deck_string), std::invalid_argument); -} - -BOOST_AUTO_TEST_CASE(INVALID_VFP_NODE) { - std::string deck_string = R"( -SCHEDULE - -GRUPTREE - 'PROD' 'FIELD' / - - 'M5S' 'PLAT-A' / - 'M5N' 'PLAT-A' / - - 'C1' 'M5N' / - 'F1' 'M5N' / - 'B1' 'M5S' / - 'G1' 'M5S' / -/ - -BRANPROP --- Downtree Uptree #VFP ALQ - B1 PLAT-A 5 1* / - C1 PLAT-A 4 1* / --This is a choke branch - must have VFP=9999 -/ - -NODEPROP --- Node_name Pr autoChock? addGasLift? Group_name - PLAT-A 21.0 NO NO 1* / - B1 1* NO NO 1* / - C1 1* YES NO 1* / -/ -)"; - - BOOST_CHECK_THROW( make_schedule(deck_string), std::invalid_argument); -} - -BOOST_AUTO_TEST_CASE(OK) { - std::string deck_string = R"( -SCHEDULE - -GRUPTREE - 'PROD' 'FIELD' / - - 'M5S' 'PLAT-A' / - 'M5N' 'PLAT-A' / - - 'C1' 'M5N' / - 'F1' 'M5N' / - 'B1' 'M5S' / - 'G1' 'M5S' / -/ - -BRANPROP --- Downtree Uptree #VFP ALQ - B1 PLAT-A 9999 1* / - C1 PLAT-A 9999 1* / -/ - -NODEPROP --- Node_name Pr autoChock? addGasLift? Group_name - PLAT-A 21.0 NO NO 1* / - B1 1* YES NO 1* / - C1 1* YES NO 'GROUP' / -/ - -TSTEP - 10 / - -BRANPROP --- Downtree Uptree #VFP ALQ - C1 PLAT-A 0 1* / -/ - - -)"; - - auto sched = make_schedule(deck_string); - { - const auto& network = sched.network(0); - const auto& b1 = network.node("B1"); - BOOST_CHECK(b1.as_choke()); - BOOST_CHECK(!b1.add_gas_lift_gas()); - BOOST_CHECK(b1.name() == b1.target_group()); - BOOST_CHECK(!b1.terminal_pressure()); - - const auto& p = network.node("PLAT-A"); - BOOST_CHECK(p.terminal_pressure()); - BOOST_CHECK_EQUAL(p.terminal_pressure().value(), 21 * 100000); - BOOST_CHECK(p == network.root()); - - BOOST_CHECK_THROW(network.node("NO_SUCH_NODE"), std::out_of_range); - - - - BOOST_CHECK_EQUAL(network.downtree_branches("PLAT-A").size(), 2); - for (const auto& b : network.downtree_branches("PLAT-A")) { - BOOST_CHECK_EQUAL(b.uptree_node(), "PLAT-A"); - BOOST_CHECK(b.downtree_node() == "B1" || b.downtree_node() == "C1"); - } - - - const auto& platform_uptree = network.uptree_branch("PLAT-A"); - BOOST_CHECK(!platform_uptree.has_value()); - - const auto& B1_uptree = network.uptree_branch("B1"); - BOOST_CHECK(B1_uptree.has_value()); - BOOST_CHECK_EQUAL(B1_uptree->downtree_node(), "B1"); - BOOST_CHECK_EQUAL(B1_uptree->uptree_node(), "PLAT-A"); - - BOOST_CHECK(network.active()); - } - { - const auto& network = sched.network(1); - const auto& b1 = network.node("B1"); - BOOST_CHECK(b1.as_choke()); - BOOST_CHECK(!b1.add_gas_lift_gas()); - BOOST_CHECK(b1.name() == b1.target_group()); - BOOST_CHECK(!b1.terminal_pressure()); - - BOOST_CHECK_EQUAL(network.downtree_branches("PLAT-A").size(), 1); - for (const auto& b : network.downtree_branches("PLAT-A")) { - BOOST_CHECK_EQUAL(b.uptree_node(), "PLAT-A"); - BOOST_CHECK(b.downtree_node() == "B1"); - } - - - const auto& platform_uptree = network.uptree_branch("PLAT-A"); - BOOST_CHECK(!platform_uptree.has_value()); - - const auto& B1_uptree = network.uptree_branch("B1"); - BOOST_CHECK(B1_uptree.has_value()); - BOOST_CHECK_EQUAL(B1_uptree->downtree_node(), "B1"); - BOOST_CHECK_EQUAL(B1_uptree->uptree_node(), "PLAT-A"); - - BOOST_CHECK_THROW( network.uptree_branch("C1"), std::out_of_range); - BOOST_CHECK_THROW( network.node("C1"), std::out_of_range); - - BOOST_CHECK(network.active()); - } -} - diff --git a/ThirdParty/custom-opm-common/opm-common/tests/parser/ParserTests.cpp b/ThirdParty/custom-opm-common/opm-common/tests/parser/ParserTests.cpp index 34f254f1bb..81e27fce0d 100644 --- a/ThirdParty/custom-opm-common/opm-common/tests/parser/ParserTests.cpp +++ b/ThirdParty/custom-opm-common/opm-common/tests/parser/ParserTests.cpp @@ -1054,14 +1054,14 @@ BOOST_AUTO_TEST_CASE(parse_validRecord_noThrow) { auto record = createSimpleParserRecord(); ParseContext parseContext; ErrorGuard errors; - RawRecord raw( std::string_view( "100 443" ) ); + RawRecord raw( string_view( "100 443" ) ); UnitSystem unit_system; BOOST_CHECK_NO_THROW(record.parse(parseContext, errors, raw , unit_system, unit_system, "KEYWORD", "filename") ); } BOOST_AUTO_TEST_CASE(parse_validRecord_deckRecordCreated) { auto record = createSimpleParserRecord(); - RawRecord rawRecord( std::string_view( "100 443" ) ); + RawRecord rawRecord( string_view( "100 443" ) ); ParseContext parseContext; ErrorGuard errors; UnitSystem unit_system; @@ -1093,7 +1093,7 @@ static ParserRecord createMixedParserRecord() { BOOST_AUTO_TEST_CASE(parse_validMixedRecord_noThrow) { auto record = createMixedParserRecord(); - RawRecord rawRecord( std::string_view( "1 2 10.0 20.0 4 90.0") ); + RawRecord rawRecord( string_view( "1 2 10.0 20.0 4 90.0") ); ParseContext parseContext; ErrorGuard errors; UnitSystem unit_system; @@ -2318,23 +2318,3 @@ auto record = kw.getRecord(1); BOOST_CHECK_EQUAL( record.getItem(5).get(0), 0.9 ); BOOST_CHECK( !deck.hasKeyword("LANGMUIR") ); } - - - - -BOOST_AUTO_TEST_CASE(ParseLONGKeywords) { - Parser parser; - ParseContext parseContext; - ErrorGuard errors; - const auto deck_string = R"( -GUIDERATE -/ -)"; - - parseContext.update(ParseContext::PARSE_LONG_KEYWORD, Opm::InputError::THROW_EXCEPTION); - BOOST_CHECK_THROW(parser.parseString(deck_string, parseContext, errors), std::invalid_argument); - - parseContext.update(ParseContext::PARSE_LONG_KEYWORD, Opm::InputError::IGNORE); - auto deck = parser.parseString(deck_string, parseContext, errors); - BOOST_CHECK( deck.hasKeyword("GUIDERAT") ); -} diff --git a/ThirdParty/custom-opm-common/opm-common/tests/parser/RawKeywordTests.cpp b/ThirdParty/custom-opm-common/opm-common/tests/parser/RawKeywordTests.cpp index 5a9873a41d..35cc95594f 100644 --- a/ThirdParty/custom-opm-common/opm-common/tests/parser/RawKeywordTests.cpp +++ b/ThirdParty/custom-opm-common/opm-common/tests/parser/RawKeywordTests.cpp @@ -45,7 +45,7 @@ BOOST_AUTO_TEST_CASE(RawKeywordConstructor) { BOOST_AUTO_TEST_CASE(IsFinished) { std::string storage = "RecordString"; - std::string_view line(storage); + string_view line(storage); RawRecord rec(line); RawKeyword kw1("NAME", "file", 10, false, Raw::FIXED, 0); diff --git a/ThirdParty/custom-opm-common/opm-common/tests/parser/SaltTableTests.cpp b/ThirdParty/custom-opm-common/opm-common/tests/parser/SaltTableTests.cpp index d905a9c3c6..9a1e6626cf 100644 --- a/ThirdParty/custom-opm-common/opm-common/tests/parser/SaltTableTests.cpp +++ b/ThirdParty/custom-opm-common/opm-common/tests/parser/SaltTableTests.cpp @@ -25,15 +25,11 @@ #include #include #include -#include // generic table classes #include #include -#include #include -#include -#include #include // keyword specific table classes @@ -56,41 +52,27 @@ BOOST_AUTO_TEST_CASE( Brine ) { "TABDIMS\n" "1 1/\n" "\n" - "EQLDIMS\n" - "1 /\n" - "\n" "PVTWSALT\n" - " 1000 0.0/\n" + " 1000/\n" " 0 1 2 3 4 \n" " 10 11 12 13 14/\n" - "\n" - "RWGSALT\n" - " 300 0.0 0.00013 \n" - " 600 0.5 0.000132 \n" - "/ \n" - "PERMFACT\n" - "0 0 \n" - "0.5 0.5 \n" - "1 1 \n" - "1.5 1.5\n" - "/ \n" + " \n" "BDENSITY\n" " 1000 1050 /\n" "\n" - "SALTVD\n" - "500 0\n" - "550 50/\n" + "EQLDIMS\n" + "1 /\n" "\n" - "SALTPVD\n" - "500 0\n" - "550 0.5/\n"; + "SALTVD\n" + "500 0\n" + "550 50/\n"; Opm::Parser parser; auto deck = parser.parseString(deckData); Opm::TableManager tables(deck); const auto& PvtwsaltTables = tables.getPvtwSaltTables( ); - BOOST_CHECK_EQUAL(1 , PvtwsaltTables.size() ); + BOOST_CHECK_EQUAL( 1 , PvtwsaltTables.size() ); BOOST_CHECK_EQUAL(2, PvtwsaltTables[0].size()); const auto& PvtwsaltTable1 = PvtwsaltTables[0]; @@ -108,21 +90,6 @@ BOOST_AUTO_TEST_CASE( Brine ) { BOOST_CHECK_CLOSE (PvtwsaltTable1.getReferencePressureValue(), 1000*1e5, 1e-5); - const auto& RwgsaltTables = tables.getRwgSaltTables( ); - BOOST_CHECK_EQUAL(1 , RwgsaltTables.size() ); - BOOST_CHECK_EQUAL(2, RwgsaltTables[0].size()); - - const auto& RwgsaltTable1 = RwgsaltTables[0]; - - BOOST_CHECK_EQUAL (RwgsaltTable1.getPressureColumn().size(), 2); - BOOST_CHECK_CLOSE (RwgsaltTable1.getPressureColumn()[1], Metric::Pressure * 600, 1e-5); - - BOOST_CHECK_EQUAL (RwgsaltTable1.getSaltConcentrationColumn().size(), 2); - BOOST_CHECK_CLOSE (RwgsaltTable1.getSaltConcentrationColumn()[1], 0.5, 1e-5); - - BOOST_CHECK_EQUAL (RwgsaltTable1.getVaporizedWaterGasRatioColumn().size(), 2); - BOOST_CHECK_CLOSE (RwgsaltTable1.getVaporizedWaterGasRatioColumn()[0], 0.00013, 1e-5); - const auto& BdensityTables = tables.getBrineDensityTables( ); const auto& BdensityTable1 = BdensityTables[0]; @@ -133,21 +100,9 @@ BOOST_AUTO_TEST_CASE( Brine ) { const Opm::TableContainer& saltvdTables = tables.getSaltvdTables(); const auto& saltvdTable = saltvdTables.getTable(0); - BOOST_CHECK_EQUAL(saltvdTable.getDepthColumn().size(), 2); + BOOST_CHECK_EQUAL(saltvdTable.getDepthColumn() .size(), 2); BOOST_CHECK_CLOSE (saltvdTable.getSaltColumn() [1],50, 1e-5); - const Opm::TableContainer& saltpvdTables = tables.getSaltpvdTables(); - const auto& saltpvdTable = saltpvdTables.getTable(0); - - BOOST_CHECK_EQUAL(saltpvdTable.getDepthColumn().size(), 2); - BOOST_CHECK_CLOSE(saltpvdTable.getSaltpColumn() [1],0.5, 1e-5); - - const Opm::TableContainer& permfactTables = tables.getPermfactTables(); - const auto& permfactTable = permfactTables.getTable(0); - - BOOST_CHECK_EQUAL(permfactTable.getPorosityChangeColumn().size(), 4); - BOOST_CHECK_CLOSE(permfactTable.getPermeabilityMultiplierColumn() [3],1.5, 1e-5); - } diff --git a/ThirdParty/custom-opm-common/opm-common/tests/parser/ScheduleTests.cpp b/ThirdParty/custom-opm-common/opm-common/tests/parser/ScheduleTests.cpp index 0e089550df..1474c5f5e7 100644 --- a/ThirdParty/custom-opm-common/opm-common/tests/parser/ScheduleTests.cpp +++ b/ThirdParty/custom-opm-common/opm-common/tests/parser/ScheduleTests.cpp @@ -39,7 +39,6 @@ #include #include #include -#include #include #include @@ -59,19 +58,8 @@ using namespace Opm; - -Schedule make_schedule(const std::string& deck_string) { - const auto& deck = Parser{}.parseString(deck_string); - auto python = std::make_shared(); - EclipseGrid grid(10,10,10); - TableManager table ( deck ); - FieldPropsManager fp( deck, Phases{true, true, true}, grid, table); - Runspec runspec (deck); - return Schedule(deck, grid , fp, runspec, python); -} - - -static std::string createDeck() { +static Deck createDeck() { + Opm::Parser parser; std::string input = "START\n" "8 MAR 1998 /\n" @@ -79,10 +67,11 @@ static std::string createDeck() { "SCHEDULE\n" "\n"; - return input; + return parser.parseString(input); } -static std::string createDeckWithWells() { +static Deck createDeckWithWells() { + Opm::Parser parser; std::string input = "START -- 0 \n" "10 MAI 2007 / \n" @@ -102,10 +91,11 @@ static std::string createDeckWithWells() { " \'W_3\' \'OP\' 20 51 3.92 \'OIL\' 7* / \n" "/\n"; - return input; + return parser.parseString(input); } -static std::string createDeckWTEST() { +static Deck createDeckWTEST() { + Opm::Parser parser; std::string input = "START -- 0 \n" "10 MAI 2007 / \n" @@ -188,10 +178,12 @@ static std::string createDeckWTEST() { " 'BAN' 'WATER' 1* 1.0 / \n" "/\n"; - return input; + + return parser.parseString(input); } -static std::string createDeckForTestingCrossFlow() { +static Deck createDeckForTestingCrossFlow() { + Opm::Parser parser; std::string input = "START -- 0 \n" "10 MAI 2007 / \n" @@ -251,26 +243,27 @@ static std::string createDeckForTestingCrossFlow() { " 'BAN' 'WATER' 1* 1.0 / \n" "/\n"; - return input; + + return parser.parseString(input); } -static std::string createDeckWithWellsOrdered() { +static Deck createDeckWithWellsOrdered() { + Opm::Parser parser; std::string input = "START -- 0 \n" "10 MAI 2007 / \n" - "WELLDIMS\n" - " * * 3 /\n" "SCHEDULE\n" "WELSPECS\n" - " \'CW_1\' \'CG\' 3 3 3.33 \'OIL\' 7* / \n" - " \'BW_2\' \'BG\' 3 3 3.33 \'OIL\' 7* / \n" - " \'AW_3\' \'AG\' 2 5 3.92 \'OIL\' 7* / \n" + " \'CW_1\' \'CG\' 30 37 3.33 \'OIL\' 7* / \n" + " \'BW_2\' \'BG\' 30 37 3.33 \'OIL\' 7* / \n" + " \'AW_3\' \'AG\' 20 51 3.92 \'OIL\' 7* / \n" "/\n"; - return input; + return parser.parseString(input); } -static std::string createDeckWithWellsOrderedGRUPTREE() { +static Deck createDeckWithWellsOrderedGRUPTREE() { + Opm::Parser parser; std::string input = "START -- 0 \n" "10 MAI 2007 / \n" @@ -282,16 +275,17 @@ static std::string createDeckWithWellsOrderedGRUPTREE() { " CG2 PG2 /\n" "/\n" "WELSPECS\n" - " \'DW_0\' \'CG1\' 3 3 3.33 \'OIL\' 7* / \n" - " \'CW_1\' \'CG1\' 3 3 3.33 \'OIL\' 7* / \n" - " \'BW_2\' \'CG2\' 3 3 3.33 \'OIL\' 7* / \n" - " \'AW_3\' \'CG2\' 2 5 3.92 \'OIL\' 7* / \n" + " \'DW_0\' \'CG1\' 30 37 3.33 \'OIL\' 7* / \n" + " \'CW_1\' \'CG1\' 30 37 3.33 \'OIL\' 7* / \n" + " \'BW_2\' \'CG2\' 30 37 3.33 \'OIL\' 7* / \n" + " \'AW_3\' \'CG2\' 20 51 3.92 \'OIL\' 7* / \n" "/\n"; - return input; + return parser.parseString(input); } -static std::string createDeckWithWellsAndCompletionData() { +static Deck createDeckWithWellsAndCompletionData() { + Opm::Parser parser; std::string input = "START -- 0 \n" "1 NOV 1979 / \n" @@ -321,14 +315,13 @@ static std::string createDeckWithWellsAndCompletionData() { " 'OP_1' 0 * 3 9 'OPEN' 1* 32.948 0.311 3047.839 1* 1* 'X' 22.100 / \n" "/\n"; - return input; + return parser.parseString(input); } -static std::string createDeckRFTConfig() { - return R"(RUNSPEC +static Deck createDeckRFTConfig() { + return ::Opm::Parser{}.parseString(R"(RUNSPEC START -- 0 1 NOV 1979 / - SCHEDULE DATES -- 1 (sim step = 0) 1 DES 1979/ @@ -364,10 +357,9 @@ COMPDAT 'OP_1' 0 * 3 9 'OPEN' 1* 32.948 0.311 3047.839 1* 1* 'X' 22.100 / / END -)"; +)"); } - BOOST_AUTO_TEST_CASE(CreateScheduleDeckMissingReturnsDefaults) { Deck deck; Parser parser; @@ -382,7 +374,13 @@ BOOST_AUTO_TEST_CASE(CreateScheduleDeckMissingReturnsDefaults) { } BOOST_AUTO_TEST_CASE(CreateScheduleDeckWellsOrdered) { - const auto& schedule = make_schedule( createDeckWithWellsOrdered() ); + auto deck = createDeckWithWellsOrdered(); + auto python = std::make_shared(); + EclipseGrid grid(100,100,100); + TableManager table ( deck ); + FieldPropsManager fp( deck, Phases{true, true, true}, grid, table); + Runspec runspec (deck); + Schedule schedule(deck, grid , fp, runspec, python); auto well_names = schedule.wellNames(); BOOST_CHECK_EQUAL( "CW_1" , well_names[0]); @@ -394,16 +392,6 @@ BOOST_AUTO_TEST_CASE(CreateScheduleDeckWellsOrdered) { BOOST_CHECK_EQUAL( "CG", group_names[1]); BOOST_CHECK_EQUAL( "BG", group_names[2]); BOOST_CHECK_EQUAL( "AG", group_names[3]); - - auto restart_groups = schedule.restart_groups(0); - BOOST_REQUIRE_EQUAL(restart_groups.size(), 4); - for (std::size_t group_index = 0; group_index < restart_groups.size() - 1; group_index++) { - const auto& group_ptr = restart_groups[group_index]; - BOOST_CHECK_EQUAL(group_ptr->insert_index(), group_index + 1); - } - const auto& field_ptr = restart_groups.back(); - BOOST_CHECK_EQUAL(field_ptr->insert_index(), 0); - BOOST_CHECK_EQUAL(field_ptr->name(), "FIELD"); } @@ -416,7 +404,13 @@ bool has_well( const std::vector& wells, const std::string& well_name) { BOOST_AUTO_TEST_CASE(CreateScheduleDeckWellsOrderedGRUPTREE) { - const auto& schedule = make_schedule( createDeckWithWellsOrderedGRUPTREE() ); + auto deck = createDeckWithWellsOrderedGRUPTREE(); + auto python = std::make_shared(); + EclipseGrid grid(100,100,100); + TableManager table ( deck ); + FieldPropsManager fp( deck, Phases{true, true, true}, grid, table); + Runspec runspec (deck); + Schedule schedule(deck, grid , fp, runspec, python); BOOST_CHECK_THROW( schedule.getChildWells2( "NO_SUCH_GROUP" , 1 ), std::invalid_argument); { @@ -462,7 +456,13 @@ BOOST_AUTO_TEST_CASE(CreateScheduleDeckWellsOrderedGRUPTREE) { BOOST_AUTO_TEST_CASE(GroupTree2TEST) { - const auto& schedule = make_schedule( createDeckWithWellsOrderedGRUPTREE() ); + auto deck = createDeckWithWellsOrderedGRUPTREE(); + auto python = std::make_shared(); + EclipseGrid grid(100,100,100); + TableManager table ( deck ); + FieldPropsManager fp( deck, Phases{true, true, true}, grid, table); + Runspec runspec (deck); + Schedule schedule(deck, grid , fp, runspec, python); BOOST_CHECK_THROW( schedule.groupTree("NO_SUCH_GROUP", 0), std::invalid_argument); auto cg1 = schedule.getGroup("CG1", 0); @@ -487,16 +487,38 @@ BOOST_AUTO_TEST_CASE(GroupTree2TEST) { BOOST_AUTO_TEST_CASE(CreateScheduleDeckWithStart) { - const auto& schedule = make_schedule( createDeck() ); + auto deck = createDeck(); + auto python = std::make_shared(); + EclipseGrid grid(10,10,10); + TableManager table ( deck ); + FieldPropsManager fp( deck, Phases{true, true, true}, grid, table); + Runspec runspec (deck); + + Schedule schedule(deck, grid , fp, runspec, python); BOOST_CHECK_EQUAL( schedule.getStartTime() , TimeMap::mkdate(1998, 3 , 8 )); } BOOST_AUTO_TEST_CASE(CreateScheduleDeckWithSCHEDULENoThrow) { - BOOST_CHECK_NO_THROW( make_schedule( "SCHEDULE" )); + Parser parser; + Deck deck; + auto python = std::make_shared(); + EclipseGrid grid(10,10,10); + TableManager table ( deck ); + FieldPropsManager fp( deck, Phases{true, true, true}, grid, table); + deck.addKeyword( DeckKeyword( parser.getKeyword("SCHEDULE" ))); + Runspec runspec (deck); + + BOOST_CHECK_NO_THROW( Schedule( deck, grid , fp, runspec, python)); } BOOST_AUTO_TEST_CASE(EmptyScheduleHasNoWells) { - const auto& schedule = make_schedule( createDeck() ); + auto python = std::make_shared(); + EclipseGrid grid(10,10,10); + auto deck = createDeck(); + TableManager table ( deck ); + FieldPropsManager fp( deck, Phases{true, true, true}, grid, table); + Runspec runspec (deck);; + Schedule schedule(deck, grid , fp, runspec, python); BOOST_CHECK_EQUAL( 0U , schedule.numWells() ); BOOST_CHECK_EQUAL( false , schedule.hasWell("WELL1") ); BOOST_CHECK_THROW( schedule.getWell("WELL2", 0) , std::invalid_argument ); @@ -505,7 +527,13 @@ BOOST_AUTO_TEST_CASE(EmptyScheduleHasNoWells) { BOOST_AUTO_TEST_CASE(EmptyScheduleHasFIELDGroup) { - const auto& schedule = make_schedule( createDeck() ); + auto python = std::make_shared(); + EclipseGrid grid(10,10,10); + auto deck = createDeck(); + TableManager table ( deck ); + FieldPropsManager fp( deck, Phases{true, true, true}, grid, table); + Runspec runspec (deck); + Schedule schedule(deck , grid , fp, runspec, python); BOOST_CHECK_EQUAL( 1U , schedule.numGroups() ); BOOST_CHECK_EQUAL( true , schedule.hasGroup("FIELD") ); @@ -515,6 +543,39 @@ BOOST_AUTO_TEST_CASE(EmptyScheduleHasFIELDGroup) { BOOST_AUTO_TEST_CASE(HasGroup_At_Time) { const auto input = std::string { R"( +RUNSPEC +DIMENS + 5 5 5 / +OIL +WATER +TABDIMS +/ +WELLDIMS + 2 10 3 2 / +GRID +DXV + 5*100 / +DYV + 5*100 / +DZV + 5*5 / +TOPS + 25*2500 / +PORO + 125*0.15 / +PERMX + 125*500 / +COPY + 'PERMX' 'PERMY' / + 'PERMX' 'PERMZ' / +/ +MULTIPLY + 'PERMZ' 0.1 / +/ +PROPS +SWOF +0 0 1 0 +1 1 0 0 / SCHEDULE WELSPECS -- Group 'P' exists from the first report step @@ -538,7 +599,10 @@ END )" }; - const auto sched = make_schedule(input); + auto python = std::make_shared<::Opm::Python>(); + const auto deck = ::Opm::Parser{}.parseString(input); + const auto es = ::Opm::EclipseState{deck}; + const auto sched = ::Opm::Schedule{ deck, es, python }; BOOST_CHECK_MESSAGE(sched.hasGroup("P"), R"(Group "P" Must Exist)"); BOOST_CHECK_MESSAGE(sched.hasGroup("I"), R"(Group "I" Must Exist)"); @@ -560,7 +624,13 @@ END } BOOST_AUTO_TEST_CASE(WellsIterator_Empty_EmptyVectorReturned) { - const auto& schedule = make_schedule( createDeck() ); + auto python = std::make_shared(); + EclipseGrid grid(10,10,10); + auto deck = createDeck(); + TableManager table ( deck ); + FieldPropsManager fp( deck, Phases{true, true, true}, grid, table); + Runspec runspec (deck); + Schedule schedule(deck , grid , fp, runspec, python); const auto wells_alltimesteps = schedule.getWellsatEnd(); BOOST_CHECK_EQUAL(0U, wells_alltimesteps.size()); @@ -573,7 +643,13 @@ BOOST_AUTO_TEST_CASE(WellsIterator_Empty_EmptyVectorReturned) { } BOOST_AUTO_TEST_CASE(WellsIterator_HasWells_WellsReturned) { - const auto& schedule = make_schedule( createDeckWithWells() ); + auto python = std::make_shared(); + EclipseGrid grid(10,10,10); + auto deck = createDeckWithWells(); + TableManager table ( deck ); + FieldPropsManager fp( deck, Phases{true, true, true}, grid, table); + Runspec runspec (deck); + Schedule schedule(deck , grid , fp, runspec, python); size_t timeStep = 0; const auto wells_alltimesteps = schedule.getWellsatEnd(); @@ -587,7 +663,13 @@ BOOST_AUTO_TEST_CASE(WellsIterator_HasWells_WellsReturned) { BOOST_AUTO_TEST_CASE(ReturnNumWellsTimestep) { - const auto& schedule = make_schedule( createDeckWithWells() ); + auto python = std::make_shared(); + EclipseGrid grid(10,10,10); + auto deck = createDeckWithWells(); + TableManager table ( deck ); + FieldPropsManager fp( deck, Phases{true, true, true}, grid, table); + Runspec runspec (deck); + Schedule schedule(deck, grid , fp, runspec, python); BOOST_CHECK_EQUAL(schedule.numWells(0), 1); BOOST_CHECK_EQUAL(schedule.numWells(1), 1); @@ -596,7 +678,13 @@ BOOST_AUTO_TEST_CASE(ReturnNumWellsTimestep) { } BOOST_AUTO_TEST_CASE(TestCrossFlowHandling) { - const auto& schedule = make_schedule( createDeckForTestingCrossFlow() ); + auto python = std::make_shared(); + EclipseGrid grid(10,10,10); + auto deck = createDeckForTestingCrossFlow(); + TableManager table ( deck ); + FieldPropsManager fp( deck, Phases{true, true, true}, grid, table); + Runspec runspec (deck); + Schedule schedule(deck, grid , fp, runspec, python); BOOST_CHECK_EQUAL(schedule.getWell("BAN", 0).getAllowCrossFlow(), false); BOOST_CHECK_EQUAL(schedule.getWell("ALLOW", 0).getAllowCrossFlow(), true); @@ -609,7 +697,8 @@ BOOST_AUTO_TEST_CASE(TestCrossFlowHandling) { BOOST_CHECK(Well::Status::OPEN == schedule.getWell("BAN", 5).getStatus()); } -static std::string createDeckWithWellsAndConnectionDataWithWELOPEN() { +static Deck createDeckWithWellsAndConnectionDataWithWELOPEN() { + Opm::Parser parser; std::string input = "START -- 0 \n" "1 NOV 1979 / \n" @@ -659,11 +748,17 @@ static std::string createDeckWithWellsAndConnectionDataWithWELOPEN() { " 'OP_1' SHUT 0 0 0 0 0 / \n " "/\n"; - return input; + return parser.parseString(input); } BOOST_AUTO_TEST_CASE(CreateScheduleDeckWellsAndConnectionDataWithWELOPEN) { - const auto& schedule = make_schedule(createDeckWithWellsAndConnectionDataWithWELOPEN()); + auto python = std::make_shared(); + EclipseGrid grid(10,10,10); + auto deck = createDeckWithWellsAndConnectionDataWithWELOPEN(); + TableManager table ( deck ); + FieldPropsManager fp( deck, Phases{true, true, true}, grid, table); + Runspec runspec (deck); + Schedule schedule(deck ,grid , fp, runspec, python); { constexpr auto well_shut = Well::Status::SHUT; constexpr auto well_open = Well::Status::OPEN; @@ -742,7 +837,13 @@ BOOST_AUTO_TEST_CASE(CreateScheduleDeckWithWELOPEN_TryToOpenWellWithShutCompleti " 'OP_1' OPEN / \n " "/\n"; - const auto& schedule = make_schedule(input); + auto python = std::make_shared(); + EclipseGrid grid(10,10,10); + auto deck = parser.parseString(input); + TableManager table ( deck ); + FieldPropsManager fp( deck, Phases{true, true, true}, grid, table); + Runspec runspec (deck); + Schedule schedule(deck , grid , fp, runspec, python); const auto& well2_3 = schedule.getWell("OP_1",3); const auto& well2_4 = schedule.getWell("OP_1",4); BOOST_CHECK(Well::Status::SHUT == well2_3.getStatus()); @@ -797,7 +898,13 @@ BOOST_AUTO_TEST_CASE(CreateScheduleDeckWithWELOPEN_CombineShutCompletionsAndAddN " 12 NOV 2008 / \n" "/\n"; - const auto& schedule = make_schedule(input); + auto python = std::make_shared(); + EclipseGrid grid(10,10,10); + auto deck = parser.parseString(input); + TableManager table ( deck ); + FieldPropsManager fp( deck, Phases{true, true, true}, grid, table); + Runspec runspec (deck); + Schedule schedule(deck, grid , fp, runspec, python); const auto& well_3 = schedule.getWell("OP_1", 3); const auto& well_4 = schedule.getWell("OP_1", 4); const auto& well_5 = schedule.getWell("OP_1", 5); @@ -850,7 +957,13 @@ BOOST_AUTO_TEST_CASE(CreateScheduleDeckWithWRFT) { "/\n"; - const auto& schedule = make_schedule(input); + auto python = std::make_shared(); + EclipseGrid grid(10,10,10); + auto deck = parser.parseString(input); + TableManager table ( deck ); + FieldPropsManager fp( deck, Phases{true, true, true}, grid, table); + Runspec runspec (deck); + Schedule schedule(deck, grid , fp, runspec, python); const auto& rft_config = schedule.rftConfig(); BOOST_CHECK_EQUAL(2 , rft_config.firstRFTOutput()); @@ -903,8 +1016,13 @@ BOOST_AUTO_TEST_CASE(CreateScheduleDeckWithWRFTPLT) { "DATES -- 5\n" " 10 NOV 2008 / \n" "/\n"; - - const auto& schedule = make_schedule(input); + auto python = std::make_shared(); + EclipseGrid grid(10,10,10); + auto deck = parser.parseString(input); + TableManager table ( deck ); + FieldPropsManager fp( deck, Phases{true, true, true}, grid, table); + Runspec runspec (deck); + Schedule schedule(deck, grid , fp, runspec, python); const auto& well = schedule.getWell("OP_1", 4); BOOST_CHECK(Well::Status::OPEN == well.getStatus()); @@ -915,6 +1033,7 @@ BOOST_AUTO_TEST_CASE(CreateScheduleDeckWithWRFTPLT) { } BOOST_AUTO_TEST_CASE(createDeckWithWeltArg) { + Opm::Parser parser; std::string input = "START -- 0 \n" "19 JUN 2007 / \n" @@ -948,8 +1067,14 @@ BOOST_AUTO_TEST_CASE(createDeckWithWeltArg) { " OP_1 GUID 2300.14 /\n" "/\n"; - const auto& schedule = make_schedule(input); - Opm::UnitSystem unitSystem = UnitSystem( UnitSystem::UnitType::UNIT_TYPE_METRIC ); + auto deck = parser.parseString(input); + auto python = std::make_shared(); + EclipseGrid grid(10,10,10); + TableManager table ( deck ); + FieldPropsManager fp( deck, Phases{true, true, true}, grid, table); + Runspec runspec (deck); + Schedule schedule(deck, grid , fp, runspec, python); + Opm::UnitSystem unitSystem = deck.getActiveUnitSystem(); double siFactorL = unitSystem.parse("LiquidSurfaceVolume/Time").getSIScaling(); double siFactorG = unitSystem.parse("GasSurfaceVolume/Time").getSIScaling(); double siFactorP = unitSystem.parse("Pressure").getSIScaling(); @@ -981,74 +1106,8 @@ BOOST_AUTO_TEST_CASE(createDeckWithWeltArg) { } -BOOST_AUTO_TEST_CASE(createDeckWithWeltArg_UDA) { - std::string input = R"( -START -- 0 -19 JUN 2007 / -SCHEDULE -DATES -- 1 - 10 OKT 2008 / -/ - -UDQ - ASSIGN WUORAT 10 / - ASSIGN WUWRAT 20 / -/ - - -WELSPECS - 'OP_1' 'OP' 9 9 1* 'OIL' 1* 1* 1* 1* 1* 1* 1* / -/ -COMPDAT - 'OP_1' 9 9 1 1 'OPEN' 1* 32.948 0.311 3047.839 1* 1* 'X' 22.100 / - 'OP_1' 9 9 2 2 'OPEN' 1* 46.825 0.311 4332.346 1* 1* 'X' 22.123 / - 'OP_1' 9 9 3 9 'OPEN' 1* 32.948 0.311 3047.839 1* 1* 'X' 22.100 / -/ -WCONPROD - 'OP_1' 'OPEN' 'ORAT' 0.000 0.000 0.000 5* / -/ -DATES -- 2 - 20 JAN 2010 / -/ -WELTARG - OP_1 ORAT WUORAT / - OP_1 WRAT WUWRAT / -/ -)"; - - const auto& schedule = make_schedule(input); - SummaryState st(std::chrono::system_clock::now()); - Opm::UnitSystem unitSystem = UnitSystem( UnitSystem::UnitType::UNIT_TYPE_METRIC ); - double siFactorL = unitSystem.parse("LiquidSurfaceVolume/Time").getSIScaling(); - - st.update_well_var("OP_1", "WUORAT", 10); - st.update_well_var("OP_1", "WUWRAT", 20); - - const auto& well_1 = schedule.getWell("OP_1", 1); - const auto wpp_1 = well_1.getProductionProperties(); - BOOST_CHECK_EQUAL(wpp_1.OilRate.get(), 0); - BOOST_CHECK_EQUAL(wpp_1.WaterRate.get(), 0); - BOOST_CHECK (wpp_1.hasProductionControl( Opm::Well::ProducerCMode::ORAT) ); - BOOST_CHECK (!wpp_1.hasProductionControl( Opm::Well::ProducerCMode::RESV) ); - - - - const auto& well_2 = schedule.getWell("OP_1", 2); - const auto wpp_2 = well_2.getProductionProperties(); - BOOST_CHECK( wpp_2.OilRate.is() ); - BOOST_CHECK_EQUAL( wpp_2.OilRate.get(), "WUORAT" ); - BOOST_CHECK_EQUAL( wpp_2.WaterRate.get(), "WUWRAT" ); - const auto prod_controls = wpp_2.controls(st, 0); - - BOOST_CHECK_EQUAL(prod_controls.oil_rate, 10 * siFactorL); - BOOST_CHECK_EQUAL(prod_controls.water_rate, 20 * siFactorL); - - BOOST_CHECK (wpp_2.hasProductionControl( Opm::Well::ProducerCMode::ORAT) ); - BOOST_CHECK (wpp_2.hasProductionControl( Opm::Well::ProducerCMode::WRAT) ); -} - - BOOST_AUTO_TEST_CASE(createDeckWithWeltArgException) { + Opm::Parser parser; std::string input = "SCHEDULE\n" "WELTARG\n" @@ -1057,21 +1116,37 @@ BOOST_AUTO_TEST_CASE(createDeckWithWeltArgException) { " OP_1 RESV 1801.05 /\n" "/\n"; + auto deck = parser.parseString(input); + auto python = std::make_shared(); + EclipseGrid grid(10,10,10); + TableManager table ( deck ); + FieldPropsManager fp( deck, Phases{true, true, true}, grid, table); + Runspec runspec (deck); - BOOST_CHECK_THROW(make_schedule(input), std::invalid_argument); + BOOST_CHECK_THROW(Schedule(deck, grid , fp, runspec, python), + std::invalid_argument); } BOOST_AUTO_TEST_CASE(createDeckWithWeltArgException2) { + Opm::Parser parser; std::string input = "SCHEDULE\n" "WELTARG\n" " OP_1 LRAT /\n" " OP_1 RESV 1801.05 /\n" "/\n"; - BOOST_CHECK_THROW(make_schedule(input), std::invalid_argument); + + auto deck = parser.parseString(input); + auto python = std::make_shared(); + EclipseGrid grid(10,10,10); + TableManager table ( deck ); + FieldPropsManager fp( deck, Phases{true, true, true}, grid, table); + Runspec runspec (deck); + BOOST_CHECK_THROW(Schedule(deck, grid , fp, runspec, python), std::invalid_argument); } BOOST_AUTO_TEST_CASE(createDeckWithWPIMULT) { + Opm::Parser parser; std::string input = "START -- 0 \n" "19 JUN 2007 / \n" @@ -1108,7 +1183,14 @@ BOOST_AUTO_TEST_CASE(createDeckWithWPIMULT) { " 'OP_1' 9 9 3 9 'OPEN' 1* 32.948 0.311 3047.839 1* 1* 'X' 22.100 / \n" "/\n"; - const auto& schedule = make_schedule(input); + auto deck = parser.parseString(input); + auto python = std::make_shared(); + EclipseGrid grid(10,10,10); + TableManager table ( deck ); + FieldPropsManager fp( deck, Phases{true, true, true}, grid, table); + Runspec runspec (deck); + Schedule schedule(deck, grid , fp, runspec, python); + const auto& cs1 = schedule.getWell("OP_1", 1).getConnections(); const auto& cs2 = schedule.getWell("OP_1", 2).getConnections(); const auto& cs3 = schedule.getWell("OP_1", 3).getConnections(); @@ -1188,6 +1270,7 @@ BOOST_AUTO_TEST_CASE(WELSPECS_WGNAME_SPACE) { } BOOST_AUTO_TEST_CASE(createDeckModifyMultipleGCONPROD) { + Opm::Parser parser; const std::string input = R"( START -- 0 10 'JAN' 2000 / @@ -1223,10 +1306,16 @@ BOOST_AUTO_TEST_CASE(createDeckModifyMultipleGCONPROD) { / )"; - const auto& schedule = make_schedule(input); + auto deck = parser.parseString(input); + auto python = std::make_shared(); + EclipseGrid grid( deck ); + TableManager table ( deck ); + FieldPropsManager fp( deck, Phases{true, true, true}, grid, table); + Runspec runspec (deck); + Opm::Schedule schedule(deck, grid, fp, runspec, python); Opm::SummaryState st(std::chrono::system_clock::now()); - Opm::UnitSystem unitSystem = UnitSystem(UnitSystem::UnitType::UNIT_TYPE_METRIC); + Opm::UnitSystem unitSystem = deck.getActiveUnitSystem(); double siFactorL = unitSystem.parse("LiquidSurfaceVolume/Time").getSIScaling(); { @@ -1255,6 +1344,7 @@ BOOST_AUTO_TEST_CASE(createDeckModifyMultipleGCONPROD) { } BOOST_AUTO_TEST_CASE(createDeckWithDRSDT) { + Opm::Parser parser; std::string input = "START -- 0 \n" "19 JUN 2007 / \n" @@ -1266,7 +1356,13 @@ BOOST_AUTO_TEST_CASE(createDeckWithDRSDT) { "0.0003\n" "/\n"; - const auto& schedule = make_schedule(input); + auto deck = parser.parseString(input); + auto python = std::make_shared(); + EclipseGrid grid(10,10,10); + TableManager table ( deck ); + FieldPropsManager fp( deck, Phases{true, true, true}, grid, table); + Runspec runspec (deck); + Schedule schedule(deck, grid , fp, runspec, python); size_t currentStep = 1; BOOST_CHECK_EQUAL(schedule.hasOilVaporizationProperties(), true); const auto& ovap = schedule.getOilVaporizationProperties(currentStep); @@ -1279,6 +1375,7 @@ BOOST_AUTO_TEST_CASE(createDeckWithDRSDT) { } BOOST_AUTO_TEST_CASE(createDeckWithDRSDTR) { + Opm::Parser parser; std::string input = "START -- 0 \n" "19 JUN 2007 / \n" @@ -1294,7 +1391,13 @@ BOOST_AUTO_TEST_CASE(createDeckWithDRSDTR) { "1 /\n" "2 /\n"; - const auto& schedule = make_schedule(input); + auto deck = parser.parseString(input); + auto python = std::make_shared(); + EclipseGrid grid(10,10,10); + TableManager table ( deck ); + FieldPropsManager fp(deck, Phases{true, true, true}, grid, table); + Runspec runspec (deck); + Schedule schedule(deck, grid , fp, runspec, python); size_t currentStep = 1; BOOST_CHECK_EQUAL(schedule.hasOilVaporizationProperties(), true); const auto& ovap = schedule.getOilVaporizationProperties(currentStep); @@ -1312,6 +1415,7 @@ BOOST_AUTO_TEST_CASE(createDeckWithDRSDTR) { BOOST_AUTO_TEST_CASE(createDeckWithDRSDTthenDRVDT) { + Opm::Parser parser; std::string input = "START -- 0 \n" "19 JUN 2007 / \n" @@ -1335,7 +1439,13 @@ BOOST_AUTO_TEST_CASE(createDeckWithDRSDTthenDRVDT) { "2 0.100\n" "/\n"; - const auto& schedule = make_schedule(input); + auto deck = parser.parseString(input); + auto python = std::make_shared(); + EclipseGrid grid(10,10,10); + TableManager table ( deck ); + FieldPropsManager fp( deck, Phases{true, true, true}, grid, table); + Runspec runspec (deck); + Schedule schedule(deck, grid , fp, runspec, python); BOOST_CHECK_EQUAL(schedule.hasOilVaporizationProperties(), true); const OilVaporizationProperties& ovap1 = schedule.getOilVaporizationProperties(1); @@ -1359,6 +1469,7 @@ BOOST_AUTO_TEST_CASE(createDeckWithDRSDTthenDRVDT) { } BOOST_AUTO_TEST_CASE(createDeckWithVAPPARS) { + Opm::Parser parser; std::string input = "START -- 0 \n" "19 JUN 2007 / \n" @@ -1370,7 +1481,13 @@ BOOST_AUTO_TEST_CASE(createDeckWithVAPPARS) { "2 0.100\n" "/\n"; - const auto& schedule = make_schedule(input); + auto deck = parser.parseString(input); + auto python = std::make_shared(); + EclipseGrid grid(10,10,10); + TableManager table ( deck ); + FieldPropsManager fp( deck, Phases{true, true, true}, grid, table); + Runspec runspec (deck); + Schedule schedule(deck, grid , fp, runspec, python); size_t currentStep = 1; BOOST_CHECK_EQUAL(schedule.hasOilVaporizationProperties(), true); const OilVaporizationProperties& ovap = schedule.getOilVaporizationProperties(currentStep); @@ -1386,6 +1503,7 @@ BOOST_AUTO_TEST_CASE(createDeckWithVAPPARS) { BOOST_AUTO_TEST_CASE(createDeckWithOutOilVaporizationProperties) { + Opm::Parser parser; std::string input = "START -- 0 \n" "19 JUN 2007 / \n" @@ -1395,12 +1513,21 @@ BOOST_AUTO_TEST_CASE(createDeckWithOutOilVaporizationProperties) { "/\n"; - const auto& schedule = make_schedule(input); + auto deck = parser.parseString(input); + auto python = std::make_shared(); + EclipseGrid grid(10,10,10); + TableManager table ( deck ); + FieldPropsManager fp( deck, Phases{true, true, true}, grid, table); + Runspec runspec (deck); + Schedule schedule(deck, grid , fp, runspec, python); + BOOST_CHECK_EQUAL(schedule.hasOilVaporizationProperties(), false); + + } - BOOST_AUTO_TEST_CASE(changeBhpLimitInHistoryModeWithWeltarg) { + Opm::Parser parser; std::string input = "START -- 0 \n" "19 JUN 2007 / \n" @@ -1448,9 +1575,15 @@ BOOST_AUTO_TEST_CASE(changeBhpLimitInHistoryModeWithWeltarg) { "/\n" ; - const auto& sched = make_schedule(input); - const auto st = ::Opm::SummaryState{ std::chrono::system_clock::now() }; - UnitSystem unit_system(UnitSystem::UnitType::UNIT_TYPE_METRIC); + auto deck = parser.parseString(input); + auto python = std::make_shared(); + EclipseGrid grid(10,10,10); + TableManager table ( deck ); + FieldPropsManager fp( deck, Phases{true, true, true}, grid, table); + Runspec runspec (deck); + SummaryState st(std::chrono::system_clock::now()); + const auto& unit_system = deck.getActiveUnitSystem(); + Schedule sched(deck, grid , fp, runspec, python); // The BHP limit should not be effected by WCONHIST { @@ -1480,6 +1613,7 @@ BOOST_AUTO_TEST_CASE(changeBhpLimitInHistoryModeWithWeltarg) { } BOOST_AUTO_TEST_CASE(changeModeWithWHISTCTL) { + Opm::Parser parser; std::string input = "START -- 0 \n" "19 JUN 2007 / \n" @@ -1539,7 +1673,13 @@ BOOST_AUTO_TEST_CASE(changeModeWithWHISTCTL) { "/\n" ; - const auto& schedule = make_schedule(input); + auto deck = parser.parseString(input); + auto python = std::make_shared(); + EclipseGrid grid(10,10,10); + TableManager table ( deck ); + FieldPropsManager fp( deck, Phases{true, true, true}, grid, table); + Runspec runspec (deck); + Schedule schedule(deck, grid , fp, runspec, python); //Start BOOST_CHECK_THROW(schedule.getWell("P1", 0), std::invalid_argument); @@ -1604,6 +1744,7 @@ BOOST_AUTO_TEST_CASE(changeModeWithWHISTCTL) { } BOOST_AUTO_TEST_CASE(fromWCONHISTtoWCONPROD) { + Opm::Parser parser; std::string input = "START -- 0 \n" "19 JUN 2007 / \n" @@ -1639,7 +1780,14 @@ BOOST_AUTO_TEST_CASE(fromWCONHISTtoWCONPROD) { "/\n" ; - const auto& schedule = make_schedule(input); + auto deck = parser.parseString(input); + auto python = std::make_shared(); + EclipseGrid grid(10,10,10); + TableManager table ( deck ); + FieldPropsManager fp( deck, Phases{true, true, true}, grid, table); + Runspec runspec (deck); + Schedule schedule(deck, grid , fp, runspec, python); + //Start BOOST_CHECK_THROW(schedule.getWell("P1", 0), std::invalid_argument); BOOST_CHECK_THROW(schedule.getWell("P2", 0), std::invalid_argument); @@ -2856,15 +3004,14 @@ BOOST_AUTO_TEST_CASE(historic_BHP_and_THP) { } BOOST_AUTO_TEST_CASE(FilterCompletions2) { - const auto& deck = Parser{}.parseString(createDeckWithWellsAndCompletionData()); - auto python = std::make_shared(); EclipseGrid grid1(10,10,10); + std::vector actnum(1000,1); + auto deck = createDeckWithWellsAndCompletionData(); + auto python = std::make_shared(); TableManager table ( deck ); FieldPropsManager fp( deck, Phases{true, true, true}, grid1, table); Runspec runspec (deck); - Schedule schedule(deck, grid1, fp, runspec, python); - std::vector actnum = grid1.getACTNUM(); - + Schedule schedule(deck, grid1 , fp, runspec, python); { const auto& c1_1 = schedule.getWell("OP_1", 1).getConnections(); const auto& c1_3 = schedule.getWell("OP_1", 3).getConnections(); @@ -2896,7 +3043,7 @@ BOOST_AUTO_TEST_CASE(FilterCompletions2) { BOOST_AUTO_TEST_CASE(VFPINJ_TEST) { - const char *input = "\ + const char *deckData = "\ START\n \ 8 MAR 1998 /\n \ \n \ @@ -2947,8 +3094,15 @@ VFPINJ \n \ 1 1.5 2.5 3.5 / \n\ 2 4.5 5.5 6.5 / \n"; - const auto& schedule = make_schedule(input); + Opm::Parser parser; + auto deck = parser.parseString(deckData); + auto python = std::make_shared(); + EclipseGrid grid1(10,10,10); + TableManager table ( deck ); + FieldPropsManager fp( deck, Phases{true, true, true}, grid1, table); + Runspec runspec (deck); + Schedule schedule(deck, grid1 , fp, runspec, python); BOOST_CHECK( schedule.getEvents().hasEvent(ScheduleEvents::VFPINJ_UPDATE, 0)); BOOST_CHECK( !schedule.getEvents().hasEvent(ScheduleEvents::VFPINJ_UPDATE, 1)); @@ -3096,7 +3250,7 @@ BOOST_AUTO_TEST_CASE(POLYINJ_TEST) { // Test for WFOAM BOOST_AUTO_TEST_CASE(WFOAM_TEST) { - const char *input = + const char *deckData = "START\n" " 8 MAR 2018/\n" "GRID\n" @@ -3129,7 +3283,14 @@ BOOST_AUTO_TEST_CASE(WFOAM_TEST) { "TSTEP\n" " 1 /\n"; - const auto& schedule = make_schedule(input); + Opm::Parser parser; + auto deck = parser.parseString(deckData); + auto python = std::make_shared(); + EclipseGrid grid1(10,10,10); + TableManager table ( deck ); + FieldPropsManager fp( deck, Phases{true, true, true}, grid1, table); + Runspec runspec (deck); + Schedule schedule(deck, grid1 , fp, runspec, python); const auto& f0 = schedule.getWell("INJE01", 0).getFoamProperties(); const auto& f1 = schedule.getWell("INJE01", 1).getFoamProperties(); @@ -3142,7 +3303,13 @@ BOOST_AUTO_TEST_CASE(WFOAM_TEST) { BOOST_AUTO_TEST_CASE(WTEST_CONFIG) { - const auto& schedule = make_schedule(createDeckWTEST()); + auto deck = createDeckWTEST(); + auto python = std::make_shared(); + EclipseGrid grid1(10,10,10); + TableManager table ( deck ); + FieldPropsManager fp( deck, Phases{true, true, true}, grid1, table); + Runspec runspec (deck); + Schedule schedule(deck, grid1 , fp, runspec, python); const auto& wtest_config1 = schedule.wtestConfig(0); BOOST_CHECK_EQUAL(wtest_config1.size(), 2); @@ -3166,14 +3333,13 @@ bool has(const std::vector& l, const std::string& s) { BOOST_AUTO_TEST_CASE(WELL_STATIC) { - const auto& deck = Parser{}.parseString(createDeckWithWells()); + auto deck = createDeckWithWells(); auto python = std::make_shared(); EclipseGrid grid1(10,10,10); TableManager table ( deck ); FieldPropsManager fp( deck, Phases{true, true, true}, grid1, table); Runspec runspec (deck); - Schedule schedule(deck, grid1, fp, runspec, python); - + Schedule schedule(deck, grid1 , fp, runspec, python); BOOST_CHECK_THROW( schedule.getWell("NO_SUCH_WELL", 0), std::invalid_argument); BOOST_CHECK_THROW( schedule.getWell("W_3", 0), std::invalid_argument); @@ -3217,7 +3383,14 @@ BOOST_AUTO_TEST_CASE(WELL_STATIC) { BOOST_AUTO_TEST_CASE(WellNames) { - const auto& schedule = make_schedule(createDeckWTEST()); + auto deck = createDeckWTEST(); + auto python = std::make_shared(); + EclipseGrid grid1(10,10,10); + TableManager table ( deck ); + FieldPropsManager fp( deck, Phases{true, true, true}, grid1, table); + Runspec runspec (deck); + Schedule schedule(deck, grid1 , fp, runspec, python); + auto names = schedule.wellNames("NO_SUCH_WELL", 0); BOOST_CHECK_EQUAL(names.size(), 0); @@ -3328,7 +3501,13 @@ BOOST_AUTO_TEST_CASE(RFT_CONFIG) { BOOST_AUTO_TEST_CASE(RFT_CONFIG2) { - const auto& schedule = make_schedule(createDeckRFTConfig()); + auto deck = createDeckRFTConfig(); + auto python = std::make_shared(); + EclipseGrid grid1(10,10,10); + TableManager table ( deck ); + FieldPropsManager fp( deck, Phases{true, true, true}, grid1, table); + Runspec runspec (deck); + Schedule schedule(deck, grid1 , fp, runspec, python); const auto& rft_config = schedule.rftConfig(); BOOST_CHECK_EQUAL(2, rft_config.firstRFTOutput()); @@ -3336,12 +3515,10 @@ BOOST_AUTO_TEST_CASE(RFT_CONFIG2) { BOOST_AUTO_TEST_CASE(nupcol) { + Opm::Parser parser; std::string input = - "RUNSPEC\n" "START -- 0 \n" "19 JUN 2007 / \n" - "NUPCOL\n" - " 20 /\n" "SCHEDULE\n" "DATES\n -- 1\n" " 10 OKT 2008 / \n" @@ -3359,16 +3536,24 @@ BOOST_AUTO_TEST_CASE(nupcol) { ; - const auto& schedule = make_schedule(input); + auto deck = parser.parseString(input); + auto python = std::make_shared(); + EclipseGrid grid(10,10,10); + TableManager table ( deck ); + FieldPropsManager fp( deck, Phases{true, true, true}, grid, table); + Runspec runspec (deck); + Schedule schedule( deck, grid, fp, runspec, python); + { // Flow uses 12 as default - BOOST_CHECK_EQUAL(schedule.getNupcol(0),20); + BOOST_CHECK_EQUAL(schedule.getNupcol(0),12); BOOST_CHECK_EQUAL(schedule.getNupcol(1),12); BOOST_CHECK_EQUAL(schedule.getNupcol(2),10); } } BOOST_AUTO_TEST_CASE(TESTGuideRateConfig) { + Opm::Parser parser; std::string input = R"( START -- 0 10 MAI 2007 / @@ -3456,7 +3641,14 @@ COMPDAT )"; - const auto& schedule = make_schedule(input); + auto deck = parser.parseString(input); + auto python = std::make_shared(); + EclipseGrid grid(10,10,10); + TableManager table ( deck ); + FieldPropsManager fp( deck, Phases{true, true, true}, grid, table); + Runspec runspec (deck); + Schedule schedule( deck, grid, fp, runspec, python); + { const auto& grc = schedule.guideRateConfig(0); const auto& w1_node = grc.well("W1"); @@ -3519,7 +3711,35 @@ COMPDAT } BOOST_AUTO_TEST_CASE(Injection_Control_Mode_From_Well) { - const auto input = R"(RUNSPEC + const auto deck = ::Opm::Parser{}.parseString(R"(RUNSPEC +DIMENS + 10 10 10 +/ + +START -- 0 +20 MAR 2020 / + +GRID + +DXV + 10*100 / +DYV + 10*100 / +DZV + 10*1 / + +TOPS + 100*2000 / + +PERMX + 1000*300 / +PERMY + 1000*300 / +PERMZ + 1000*3 / + +PORO + 1000*0.25 / SCHEDULE WELSPECS @@ -3546,10 +3766,12 @@ TSTEP 30*30 / END -)"; +)"); - const auto sched = make_schedule(input); + auto python = std::make_shared<::Opm::Python>(); const auto st = ::Opm::SummaryState{ std::chrono::system_clock::now() }; + const auto es = ::Opm::EclipseState{ deck }; + const auto sched = ::Opm::Schedule{ deck, es, python }; BOOST_CHECK_EQUAL(eclipseControlMode(sched.getWell("W1", 10), st), -1); BOOST_CHECK_EQUAL(eclipseControlMode(sched.getWell("W2", 10), st), 3); @@ -3561,7 +3783,35 @@ END } BOOST_AUTO_TEST_CASE(Production_Control_Mode_From_Well) { - const auto input = R"(RUNSPEC + const auto deck = ::Opm::Parser{}.parseString(R"(RUNSPEC +DIMENS + 10 10 10 +/ + +START -- 0 +20 MAR 2020 / + +GRID + +DXV + 10*100 / +DYV + 10*100 / +DZV + 10*1 / + +TOPS + 100*2000 / + +PERMX + 1000*300 / +PERMY + 1000*300 / +PERMZ + 1000*3 / + +PORO + 1000*0.25 / SCHEDULE WELSPECS @@ -3590,10 +3840,12 @@ TSTEP 30*30 / END -)"; +)"); - const auto sched = make_schedule(input); + auto python = std::make_shared<::Opm::Python>(); const auto st = ::Opm::SummaryState{ std::chrono::system_clock::now() }; + const auto es = ::Opm::EclipseState{ deck }; + const auto sched = ::Opm::Schedule{ deck, es, python }; BOOST_CHECK_EQUAL(eclipseControlMode(sched.getWell("W1", 10), st), -1); BOOST_CHECK_EQUAL(eclipseControlMode(sched.getWell("W2", 10), st), 1); @@ -3621,85 +3873,3 @@ BOOST_AUTO_TEST_CASE(SKIPREST_VFP) { const auto& tables = sched.getVFPProdTables(3); BOOST_CHECK( !tables.empty() ); } - - - - -BOOST_AUTO_TEST_CASE(GASLIFT_OPT) { - GasLiftOpt glo; - BOOST_CHECK(!glo.active()); - BOOST_CHECK_THROW(glo.group("NO_SUCH_GROUP"), std::out_of_range); - BOOST_CHECK_THROW(glo.well("NO_SUCH_WELL"), std::out_of_range); -} - - -BOOST_AUTO_TEST_CASE(GASLIFT_OPT_DECK) { - const auto input = R"(-- Turns on gas lift optimization -SCHEDULE - -GRUPTREE - 'PROD' 'FIELD' / - - 'M5S' 'PLAT-A' / - 'M5N' 'PLAT-A' / - - 'C1' 'M5N' / - 'F1' 'M5N' / - 'B1' 'M5S' / - 'G1' 'M5S' / - / - -LIFTOPT - 12500 5E-3 0.0 YES / - - --- Group lift gas limits for gas lift optimization -GLIFTOPT - 'PLAT-A' 200000 / -- -/ - -WELSPECS ---WELL GROUP IHEEL JHEEL DREF PHASE DRAD INFEQ SIINS XFLOW PRTAB DENS - 'B-1H' 'B1' 11 3 1* OIL 1* 1* SHUT 1* 1* 1* / - 'B-2H' 'B1' 4 7 1* OIL 1* 1* SHUT 1* 1* 1* / - 'B-3H' 'B1' 11 12 1* OIL 1* 1* SHUT 1* 1* 1* / - 'C-1H' 'C1' 13 20 1* OIL 1* 1* SHUT 1* 1* 1* / - 'C-2H' 'C1' 12 27 1* OIL 1* 1* SHUT 1* 1* 1* / -/ - --- well savailable for gass lift --- minimum gas lift rate, enough to keep well flowing -WLIFTOPT - 'B-1H' YES 150000 1.01 -1.0 / - 'B-2H' YES 150000 1.01 -1.0 / - 'B-3H' YES 150000 1.01 -1.0 / - 'C-1H' YES 150000 1.01 -1.0 1.0 YES/ - 'C-2H' NO 150000 1.01 -1.0 / -/ -)"; - Opm::UnitSystem unitSystem = UnitSystem( UnitSystem::UnitType::UNIT_TYPE_METRIC ); - double siFactorG = unitSystem.parse("GasSurfaceVolume/Time").getSIScaling(); - const auto sched = make_schedule(input); - const auto& glo = sched.glo(0); - const auto& plat_group = glo.group("PLAT-A"); - BOOST_CHECK_EQUAL( *plat_group.max_lift_gas(), siFactorG * 200000); - BOOST_CHECK(!plat_group.max_total_gas().has_value()); - - - const auto& w1 = glo.well("B-1H"); - BOOST_CHECK(w1.use_glo()); - BOOST_CHECK_EQUAL(*w1.max_rate(), 150000 * siFactorG); - BOOST_CHECK_EQUAL(w1.weight_factor(), 1.01); - - const auto& w2 = glo.well("C-2H"); - BOOST_CHECK_EQUAL(w2.weight_factor(), 1.00); - BOOST_CHECK_EQUAL(w2.min_rate(), 0.00); - BOOST_CHECK_EQUAL(w2.inc_weight_factor(), 0.00); - BOOST_CHECK(!w2.alloc_extra_gas()); - - const auto& w3 = glo.well("C-1H"); - BOOST_CHECK_EQUAL(w3.min_rate(), -1.00 * siFactorG); - BOOST_CHECK_EQUAL(w3.inc_weight_factor(), 1.00); - BOOST_CHECK(w3.alloc_extra_gas()); -} - diff --git a/ThirdParty/custom-opm-common/opm-common/tests/parser/StringTests.cpp b/ThirdParty/custom-opm-common/opm-common/tests/parser/StringTests.cpp index 0838fe51e9..a79caf7876 100644 --- a/ThirdParty/custom-opm-common/opm-common/tests/parser/StringTests.cpp +++ b/ThirdParty/custom-opm-common/opm-common/tests/parser/StringTests.cpp @@ -3,6 +3,7 @@ #include #include +#include using namespace Opm; @@ -40,24 +41,145 @@ BOOST_AUTO_TEST_CASE( uppercase_move ) { BOOST_AUTO_TEST_CASE( uppercase_mixed_type ) { std::string src = "string"; - std::string_view view( src ); + string_view view( src ); std::string dst = "string"; uppercase( view, dst ); BOOST_CHECK_EQUAL( dst, "STRING" ); - BOOST_CHECK( view == "string" ); + BOOST_CHECK_EQUAL( view, "string" ); } BOOST_AUTO_TEST_CASE( write_parts_of_dst ) { std::string src = "string"; - std::string_view view( src ); + string_view view( src ); std::string dst = "stringmixed"; uppercase( view, dst ); BOOST_CHECK_EQUAL( dst, "STRINGmixed" ); - BOOST_CHECK( view == "string" ); + BOOST_CHECK_EQUAL( view, "string" ); +} + +BOOST_AUTO_TEST_CASE(fullStringView) { + std::string srcstr = "lorem ipsum"; + string_view view( srcstr ); + + BOOST_CHECK_EQUAL_COLLECTIONS( + srcstr.begin(), srcstr.end(), + view.begin(), view.end() ); +} + +BOOST_AUTO_TEST_CASE(viewCorrectSize) { + std::string srcstr = "lorem ipsum"; + + string_view full( srcstr ); + BOOST_CHECK_EQUAL( srcstr.size(), full.size() ); + + string_view view( srcstr, 5 ); + BOOST_CHECK_EQUAL( 5, view.size() ); + BOOST_CHECK_EQUAL( 5, view.length() ); +} + +BOOST_AUTO_TEST_CASE(viewOperatorAt) { + std::string srcstr = "lorem ipsum"; + string_view view( srcstr ); + + for( size_t i = 0; i < view.size(); ++i ) + BOOST_CHECK_EQUAL( view[ i ], srcstr[ i ] ); +} + +BOOST_AUTO_TEST_CASE(viewFrontBack) { + std::string srcstr = "lorem ipsum"; + string_view view( srcstr ); + + BOOST_CHECK_EQUAL( view.front(), 'l' ); + BOOST_CHECK_EQUAL( view.back(), 'm' ); +} + + +BOOST_AUTO_TEST_CASE(viewSubstr) { + std::string srcstr = "lorem ipsum"; + string_view view( srcstr ); + + BOOST_CHECK_NO_THROW( view.string() ); + BOOST_CHECK_EQUAL( srcstr, view.string() ); + BOOST_CHECK_EQUAL( srcstr, view.substr() ); + BOOST_CHECK_EQUAL( "", view.substr( 0, 0 ) ); + + BOOST_CHECK_EQUAL( srcstr.substr( 1 ), view.substr( 1 ) ); + BOOST_CHECK_EQUAL( srcstr, view.substr( 0, srcstr.size() + 1 )); + BOOST_CHECK_EQUAL( "", view.substr( 1, 0 )); + BOOST_CHECK_EQUAL( "", view.substr( 0, 0 ) ); + + BOOST_CHECK_THROW( view.substr( srcstr.size() + 1 ), std::out_of_range ); +} + +BOOST_AUTO_TEST_CASE(viewStream) { + std::string srcstr = "lorem ipsum"; + string_view view( srcstr ); + + std::stringstream str; + str << view; + + BOOST_CHECK_EQUAL( srcstr, str.str() ); +} + +BOOST_AUTO_TEST_CASE(equalityOperators) { + std::string srcstr = "lorem ipsum"; + std::string diffstr = "lorem"; + string_view view( srcstr ); + + BOOST_CHECK_EQUAL( srcstr, view ); + BOOST_CHECK_NE( diffstr, view ); + + BOOST_CHECK_EQUAL( view, srcstr ); + BOOST_CHECK_NE( view, diffstr ); + + BOOST_CHECK_EQUAL( "lorem ipsum", view ); + BOOST_CHECK_NE( "lorem", view ); + + BOOST_CHECK_EQUAL( view, "lorem ipsum" ); + BOOST_CHECK_NE( view, "lorem" ); +} + +BOOST_AUTO_TEST_CASE(plusOperator) { + std::string total = "lorem ipsum"; + std::string lhs = "lorem"; + std::string ws = " "; + std::string rhs = "ipsum"; + + string_view lhs_view( lhs ); + string_view rhs_view( rhs ); + + BOOST_CHECK_EQUAL( total, lhs_view + ws + rhs_view ); + BOOST_CHECK_EQUAL( lhs + ws, lhs_view + ws ); + BOOST_CHECK_EQUAL( ws + rhs, ws + rhs_view ); +} + + + +BOOST_AUTO_TEST_CASE(strncmp_function) { + std::string s = "A BB CCC DDDD"; + string_view view(s); + + BOOST_CHECK(!view.starts_with("this is a very long string -longer than the view")); + BOOST_CHECK(view.starts_with("A")); + BOOST_CHECK(view.starts_with("A BB")); + BOOST_CHECK(!view.starts_with("A BB D")); + BOOST_CHECK(view.starts_with(s)); + + BOOST_CHECK_EQUAL( view.find("A"), 0); + BOOST_CHECK_EQUAL( view.find("BB"), 2); + BOOST_CHECK_EQUAL( view.find("C"), 5); + BOOST_CHECK_EQUAL( view.find("CCCC"), std::string::npos); + BOOST_CHECK_EQUAL( view.find("DDDD"), 9); + + BOOST_CHECK_EQUAL( view.find('A'), 0); + BOOST_CHECK_EQUAL( view.find('B'), 2); + BOOST_CHECK_EQUAL( view.find('C'), 5); + BOOST_CHECK_EQUAL( view.find('X'), std::string::npos); + BOOST_CHECK_EQUAL( view.find('D'), 9); } diff --git a/ThirdParty/custom-opm-common/opm-common/tests/parser/SummaryConfigTests.cpp b/ThirdParty/custom-opm-common/opm-common/tests/parser/SummaryConfigTests.cpp index 3762f0b77e..21fa23c5f9 100644 --- a/ThirdParty/custom-opm-common/opm-common/tests/parser/SummaryConfigTests.cpp +++ b/ThirdParty/custom-opm-common/opm-common/tests/parser/SummaryConfigTests.cpp @@ -541,7 +541,7 @@ BOOST_AUTO_TEST_CASE( NUMERICAL_AQUIFERS ) { } static const auto GMWSET_keywords = { - "GMWPT", "GMWPR", "GMWPA", "GMWPU", "GMWPG", "GMWPO", "GMWPS", + "GMCTG", "GMWPT", "GMWPR", "GMWPA", "GMWPU", "GMWPG", "GMWPO", "GMWPS", "GMWPV", "GMWPP", "GMWPL", "GMWIT", "GMWIN", "GMWIA", "GMWIU", "GMWIG", "GMWIS", "GMWIV", "GMWIP", "GMWDR", "GMWDT", "GMWWO", "GMWWT" }; diff --git a/ThirdParty/custom-opm-common/opm-common/tests/parser/TableManagerTests.cpp b/ThirdParty/custom-opm-common/opm-common/tests/parser/TableManagerTests.cpp index b9c75fb244..b91d3c4e1d 100644 --- a/ThirdParty/custom-opm-common/opm-common/tests/parser/TableManagerTests.cpp +++ b/ThirdParty/custom-opm-common/opm-common/tests/parser/TableManagerTests.cpp @@ -46,7 +46,6 @@ #include #include -#include #include @@ -1792,35 +1791,3 @@ OILDENT BOOST_CHECK( gd == od ); BOOST_CHECK( wd.size() == 0); } - - - -BOOST_AUTO_TEST_CASE(TLMIXPAR) { - const auto deck_string = R"( -RUNSPEC - -MISCIBLE - 2 / - -PROPS - -TLMIXPAR - 0 0.25 / - 0.25 / - -)"; - Opm::Parser parser; - const auto& deck = parser.parseString(deck_string); - Opm::TLMixpar tlm(deck); - BOOST_CHECK_EQUAL(tlm.size(), 2); - - const auto& r0 = tlm[0]; - const auto& r1 = tlm[1]; - - BOOST_CHECK_EQUAL( r0.viscosity_parameter, 0); - BOOST_CHECK_EQUAL( r0.density_parameter, 0.25); - BOOST_CHECK_EQUAL( r1.viscosity_parameter, 0.25); - BOOST_CHECK_EQUAL( r1.density_parameter, 0.25); - - BOOST_CHECK_THROW(tlm[2], std::out_of_range); -} diff --git a/ThirdParty/custom-opm-common/opm-common/tests/parser/UDQTests.cpp b/ThirdParty/custom-opm-common/opm-common/tests/parser/UDQTests.cpp index a165f03d27..42c9e1a2f4 100644 --- a/ThirdParty/custom-opm-common/opm-common/tests/parser/UDQTests.cpp +++ b/ThirdParty/custom-opm-common/opm-common/tests/parser/UDQTests.cpp @@ -15,7 +15,6 @@ Copyright 2018 Statoil ASA. #define BOOST_TEST_MODULE UDQTests #include -#include #include #include @@ -40,24 +39,6 @@ Copyright 2018 Statoil ASA. using namespace Opm; -Schedule make_schedule(const std::string& input) { - Parser parser; - auto python = std::make_shared(); - - auto deck = parser.parseString(input); - if (deck.hasKeyword("DIMENS")) { - EclipseState es(deck); - return Schedule(deck, es, python); - } else { - EclipseGrid grid(10,10,10); - TableManager table ( deck ); - FieldPropsManager fp( deck, Phases{true, true, true}, grid, table); - Runspec runspec (deck); - return Schedule(deck, grid , fp, runspec, python); - } -} - - BOOST_AUTO_TEST_CASE(TYPE_COERCION) { BOOST_CHECK( UDQVarType::SCALAR == UDQ::coerce(UDQVarType::SCALAR, UDQVarType::SCALAR) ); @@ -110,6 +91,7 @@ BOOST_AUTO_TEST_CASE(SUBTRACT) BOOST_CHECK_EQUAL( res2[0].value(), 16.0); } + BOOST_AUTO_TEST_CASE(TEST) { UDQParams udqp; @@ -157,6 +139,23 @@ BOOST_AUTO_TEST_CASE(TEST) BOOST_CHECK_THROW( UDQDefine(udqp, "WUWI2", {"BPR", "1","1", "1", "*", "2.0"}), std::logic_error); } +Schedule make_schedule(const std::string& input) { + Parser parser; + auto python = std::make_shared(); + + auto deck = parser.parseString(input); + if (deck.hasKeyword("DIMENS")) { + EclipseState es(deck); + return Schedule(deck, es, python); + } else { + EclipseGrid grid(10,10,10); + TableManager table ( deck ); + FieldPropsManager fp( deck, Phases{true, true, true}, grid, table); + Runspec runspec (deck); + return Schedule(deck, grid , fp, runspec, python); + } +} + BOOST_AUTO_TEST_CASE(MIX_SCALAR) { UDQFunctionTable udqft; @@ -206,20 +205,6 @@ BOOST_AUTO_TEST_CASE(UDQFieldSetTest) { } } -BOOST_AUTO_TEST_CASE(UDQWellSetNANTest) { - std::vector wells = {"P1", "P2", "I1", "I2"}; - UDQSet ws = UDQSet::wells("NAME", wells); - - for (std::size_t i = 0; i < 4; i++) - ws.assign(i, i*1.0); - - BOOST_CHECK_EQUAL(ws.defined_size(), 4); - - ws.assign(1,std::numeric_limits::quiet_NaN()); - ws.assign(3,std::numeric_limits::quiet_NaN()); - BOOST_CHECK_EQUAL(ws.defined_size(), 2); -} - BOOST_AUTO_TEST_CASE(UDQWellSetTest) { std::vector wells = {"P1", "P2", "I1", "I2"}; @@ -902,11 +887,10 @@ BOOST_AUTO_TEST_CASE(FUNCTIONS_INVALID_ARGUMENT) { } BOOST_AUTO_TEST_CASE(UDQ_SET_DIV) { - UDQSet s("NAME", 6); + UDQSet s("NAME", 5); s.assign(0,1); s.assign(2,2); s.assign(4,5); - s.assign(5,0); auto result = 10 / s; BOOST_CHECK_EQUAL( result.defined_size(), 3); @@ -1050,54 +1034,9 @@ BOOST_AUTO_TEST_CASE(UDQ_SCALAR_SET) { auto well4 = res["P4"]; BOOST_CHECK( well4.defined() ); BOOST_CHECK_EQUAL(well4.value() , 1); - - BOOST_CHECK_EQUAL( "WUOPR", res.name() ); } } -BOOST_AUTO_TEST_CASE(UDQ_SORTD_NAN) { - UDQParams udqp; - UDQFunctionTable udqft; - UDQDefine def(udqp, "WUPR1" , {"1", "/", "(", "WWIR", "'OP*'" , ")"}); - UDQDefine def_sort(udqp , "WUPR3", {"SORTD", "(", "WUPR1", ")" }); - SummaryState st(std::chrono::system_clock::now()); - UDQContext context(udqft, st); - - st.update_well_var("OP1", "WWIR", 1.0); - st.update_well_var("OP2", "WWIR", 2.0); - st.update_well_var("OP3", "WWIR", 3.0); - st.update_well_var("OP4", "WWIR", 4.0); - - auto res1 = def.eval(context); - st.update_udq( res1 ); - - auto res_sort1 = def_sort.eval(context); - st.update_udq( res_sort1 ); - BOOST_CHECK_EQUAL(res_sort1["OP1"].value(), 1.0); - BOOST_CHECK_EQUAL(res_sort1["OP2"].value(), 2.0); - BOOST_CHECK_EQUAL(res_sort1["OP3"].value(), 3.0); - BOOST_CHECK_EQUAL(res_sort1["OP4"].value(), 4.0); - BOOST_CHECK( st.has_well_var("OP1", "WUPR3")); - BOOST_CHECK( st.has_well_var("OP4", "WUPR3")); - - st.update_well_var("OP1", "WWIR", 0); - auto res2 = def.eval(context); - BOOST_CHECK_EQUAL(res2.defined_size(), 3); - st.update_udq( res2 ); - BOOST_CHECK( !st.has_well_var("OP1", "WUPR1")); - BOOST_CHECK( st.has_well_var("OP4", "WUPR1")); - - auto res_sort2 = def_sort.eval(context); - st.update_udq( res_sort2 ); - BOOST_CHECK_EQUAL(res_sort2.defined_size(), 3); - BOOST_CHECK_EQUAL(res_sort2["OP2"].value(), 1.0); - BOOST_CHECK_EQUAL(res_sort2["OP3"].value(), 2.0); - BOOST_CHECK_EQUAL(res_sort2["OP4"].value(), 3.0); - BOOST_CHECK( !st.has_well_var("OP1", "WUPR3")); - BOOST_CHECK( st.has_well_var("OP4", "WUPR3")); -} - - BOOST_AUTO_TEST_CASE(UDQ_SORTA) { UDQParams udqp; @@ -1435,6 +1374,7 @@ BOOST_AUTO_TEST_CASE(UDQ_USAGE) { BOOST_CHECK_EQUAL( usage[1].use_count, 1); const auto& rec = usage[0]; + BOOST_CHECK_EQUAL(rec.wgname, "W1"); BOOST_CHECK_EQUAL(rec.udq, "WUX"); BOOST_CHECK(rec.control == UDAControl::WCONPROD_ORAT); @@ -1442,6 +1382,7 @@ BOOST_AUTO_TEST_CASE(UDQ_USAGE) { for (std::size_t index = 0; index < usage.IUAD_size(); index++) { const auto& record = usage[index]; BOOST_CHECK_EQUAL(record.input_index, 0); + BOOST_CHECK_EQUAL(record.wgname, "W1"); if (index == 0) BOOST_CHECK(record.control == UDAControl::WCONPROD_ORAT); @@ -1459,35 +1400,32 @@ BOOST_AUTO_TEST_CASE(IntegrationTest) { auto schedule = make_schedule(deck_string); { const auto& active = schedule.udqActive(1); - BOOST_CHECK_EQUAL(active.IUAD_size(), 6); + BOOST_CHECK_EQUAL(active.IUAD_size(), 4); BOOST_CHECK(active[0].control == UDAControl::WCONPROD_ORAT); BOOST_CHECK(active[1].control == UDAControl::WCONPROD_LRAT); BOOST_CHECK(active[2].control == UDAControl::WCONPROD_ORAT); BOOST_CHECK(active[3].control == UDAControl::WCONPROD_LRAT); - BOOST_CHECK(active[4].control == UDAControl::GCONPROD_LIQUID_TARGET); - BOOST_CHECK(active[5].control == UDAControl::GCONPROD_LIQUID_TARGET); + + BOOST_CHECK(active[0].wgname == "OPL02"); + BOOST_CHECK(active[1].wgname == "OPL02"); + BOOST_CHECK(active[2].wgname == "OPU02"); + BOOST_CHECK(active[3].wgname == "OPU02"); BOOST_CHECK(active[0].udq == "WUOPRL"); BOOST_CHECK(active[1].udq == "WULPRL"); BOOST_CHECK(active[2].udq == "WUOPRU"); BOOST_CHECK(active[3].udq == "WULPRU"); - BOOST_CHECK(active[4].udq == "GULPR1"); - BOOST_CHECK(active[5].udq == "GUOPR1"); BOOST_CHECK(active[0].input_index == 0); BOOST_CHECK(active[1].input_index == 1); BOOST_CHECK(active[2].input_index == 2); BOOST_CHECK(active[3].input_index == 3); - BOOST_CHECK(active[4].input_index == 4); - BOOST_CHECK(active[5].input_index == 5); BOOST_CHECK(active[0].use_count == 1); BOOST_CHECK(active[1].use_count == 1); BOOST_CHECK(active[2].use_count == 1); BOOST_CHECK(active[3].use_count == 1); - BOOST_CHECK(active[4].use_count == 2); - BOOST_CHECK(active[5].use_count == 1); } } @@ -1620,67 +1558,3 @@ WCONPROD } } - -BOOST_AUTO_TEST_CASE(UDQ_SCIENTIFIC_LITERAL) { - std::string deck_string = R"( -SCHEDULE -UDQ - DEFINE FU 0 -1.25E-2*(1.0E-1 + 2E-1) / -/ - -)"; - auto schedule = make_schedule(deck_string); - const auto& udq = schedule.getUDQConfig(0); - UDQParams udqp; - auto def0 = udq.definitions()[0]; - SummaryState st(std::chrono::system_clock::now()); - UDQFunctionTable udqft(udqp); - UDQContext context(udqft, st); - - auto res0 = def0.eval(context); - BOOST_CHECK_CLOSE( res0[0].value(), -0.00125*3, 1e-6); -} - - -BOOST_AUTO_TEST_CASE(UDQ_NEGATIVE_PREFIX_BASIC) { - std::string deck_string = R"( -SCHEDULE -UDQ - DEFINE FUMIN0 - 1.5*FWPR / - DEFINE FUMIN1 - 1.5*FWPR*(FGPR + FOPR)^3 - 2*FLPR / - DEFINE FU -2.539E-14 * (FUP1+FUP2)^3 + 1.4464E-8 *(FUP1+FUP2)^2 +0.00028875*(FUP1+FUP2)+2.8541 / -/ -)"; - - auto schedule = make_schedule(deck_string); - const auto& udq = schedule.getUDQConfig(0); - UDQParams udqp; - auto def0 = udq.definitions()[0]; - auto def1 = udq.definitions()[1]; - auto def2 = udq.definitions()[2]; - SummaryState st(std::chrono::system_clock::now()); - UDQFunctionTable udqft(udqp); - UDQContext context(udqft, st); - const double fwpr = 7; - const double fopr = 4; - const double fgpr = 7; - const double flpr = 13; - const double fup1 = 1025; - const double fup2 = 107; - st.update("FWPR", fwpr); - st.update("FOPR", fopr); - st.update("FGPR", fgpr); - st.update("FLPR", flpr); - st.update("FUP1", fup1); - st.update("FUP2", fup2); - - auto res0 = def0.eval(context); - BOOST_CHECK_EQUAL( res0[0].value(), -1.5*fwpr); - - auto res1 = def1.eval(context); - BOOST_CHECK_EQUAL( res1[0].value(), -1.5*fwpr*std::pow(fgpr+fopr, 3) - 2*flpr ); - - auto res2 = def2.eval(context); - BOOST_CHECK_CLOSE( res2[0].value(), -2.5394E-14 * std::pow(fup1 + fup2, 3) + 1.4464E-8*std::pow(fup1 + fup2, 2) + 0.00028875*(fup1 + fup2) + 2.8541, 1e-6); -} - diff --git a/ThirdParty/custom-opm-common/opm-common/tests/parser/WLIST.cpp b/ThirdParty/custom-opm-common/opm-common/tests/parser/WLIST.cpp index 23f6dce91b..f128d1911b 100644 --- a/ThirdParty/custom-opm-common/opm-common/tests/parser/WLIST.cpp +++ b/ThirdParty/custom-opm-common/opm-common/tests/parser/WLIST.cpp @@ -113,8 +113,6 @@ static std::string WELSPECS() { " \'W2\' \'OP\' 2 1 1.0 \'OIL\' 7* /\n" " \'W3\' \'OP\' 3 1 1.0 \'OIL\' 7* /\n" " \'W4\' \'OP\' 4 1 1.0 \'OIL\' 7* /\n" - " \'C1\' \'OP\' 3 1 1.0 \'OIL\' 7* /\n" - " \'C2\' \'OP\' 4 1 1.0 \'OIL\' 7* /\n" "/\n"; } @@ -218,9 +216,6 @@ BOOST_AUTO_TEST_CASE(Wlist) { " \'*LIST1\' \'NEW\' W1 W2 /\n" " \'*LIST1\' \'ADD\' W3 W4 /\n" " \'*LIST2\' \'NEW\' W1 W3 /\n" - " \'*LIST4\' \'NEW\' \'*LIST1\' /\n" - " \'*LIST5\' \'NEW\' \'W*\' /\n" - " \'*LIST6\' \'NEW\' \'I*\' /\n" "/\n" "DATES\n" "10 JLY 2007 /\n" @@ -236,15 +231,9 @@ BOOST_AUTO_TEST_CASE(Wlist) { const auto& wlm = sched.getWListManager(1); const auto& wl1 = wlm.getList("*LIST1"); const auto& wl2 = wlm.getList("*LIST2"); - const auto& wl4 = wlm.getList("*LIST4"); - const auto& wl5 = wlm.getList("*LIST5"); - const auto& wl6 = wlm.getList("*LIST6"); BOOST_CHECK_EQUAL(wl1.wells().size(), 4 ); BOOST_CHECK_EQUAL(wl2.wells().size(), 2 ); - BOOST_CHECK_EQUAL(wl4.wells().size(), 4 ); - BOOST_CHECK_EQUAL(wl5.wells().size(), 4 ); - BOOST_CHECK_EQUAL(wl6.wells().size(), 0 ); } { const auto& wlm = sched.getWListManager(2); @@ -264,37 +253,5 @@ BOOST_AUTO_TEST_CASE(Wlist) { BOOST_CHECK( wl3.has("W1")); BOOST_CHECK( wl3.has("W3")); - - const auto& wells1 = wlm.wells("*LIST1"); - BOOST_CHECK( wells1 == wl1.wells() ); } } - -template -bool vector_equal(const std::vector& v1, const std::vector& v2) { - std::unordered_set s1(v1.begin(), v1.end()); - std::unordered_set s2(v2.begin(), v2.end()); - return s1 == s2; -} - - -BOOST_AUTO_TEST_CASE(WlistPattern) { - std::string wlist = WELSPECS() + - "WLIST\n" - " \'*LIST1\' \'NEW\' W1 W2 /\n" - " \'*COLL1\' \'NEW\' C1 /\n" - " \'*BOLL2\' \'NEW\' C2 /\n" - " \'*LIST2\' \'NEW\' W1 W3 /\n" - "/\n" - "DATES\n" - "10 JLY 2007 /\n" - "10 AUG 2007 /\n" - "/\n"; - - auto sched = createSchedule(wlist); - const auto& wlm = sched.getWListManager(1); - BOOST_CHECK( vector_equal(wlm.wells("*LIST1"), {"W1", "W2"})); - BOOST_CHECK( vector_equal(wlm.wells("*LIST2"), {"W1", "W3"})); - BOOST_CHECK( vector_equal(wlm.wells("*LIST*"), {"W1", "W2", "W3"})); - BOOST_CHECK( vector_equal(wlm.wells("**OLL*"), {"C1", "C2"})); -} diff --git a/ThirdParty/custom-opm-common/opm-common/tests/parser/data/integration_tests/udq.data b/ThirdParty/custom-opm-common/opm-common/tests/parser/data/integration_tests/udq.data index 9bc8389a30..e7365e95c3 100644 --- a/ThirdParty/custom-opm-common/opm-common/tests/parser/data/integration_tests/udq.data +++ b/ThirdParty/custom-opm-common/opm-common/tests/parser/data/integration_tests/udq.data @@ -603,9 +603,6 @@ WCONINJE 'WIL*' 'WATER' 'SHUT' 'GRUP' 10500 1* 400 / / - - - UDQ -- test --oil & liquid capacities at GEFAC = 0.8995 @@ -613,8 +610,6 @@ DEFINE WUOPRL (WOPR OPL01 - 150) * 0.90 / DEFINE WULPRL (WLPR OPL01 - 200) * 0.90 / DEFINE WUOPRU (WOPR OPU01 - 250) * 0.80 / DEFINE WULPRU (WLPR OPU01 - 300) * 0.80 / -DEFINE GULPR1 (2500 - GOPR LOWER *0.03 - GOPR UPPER *0.15) * 0.899 / -DEFINE GUOPR1 (2500 - GOPR LOWER *0.03 - GOPR UPPER *0.15) * 0.899 / -- units UNITS WUOPRL SM3/DAY / UNITS WULPRL SM3/DAY / @@ -624,6 +619,11 @@ UNITS WULPRU SM3/DAY / / +GCONPROD + 'TEST' 'LRAT' 6000 2* 6000 'RATE' 'NO' / + 'LOWER' 'FLD' 6000 2* 6000 'RATE' 'YES' 1* 'FORM' / + 'UPPER' 'FLD' 3000 2* 6000 'RATE' 'YES' 1* 'FORM' / +/ GCONINJE @@ -645,11 +645,6 @@ WCONPROD 'OPU02' 'OPEN' 'GRUP' 'WUOPRU' 2* 'WULPRU' 1* 60 / / -GCONPROD - 'TEST' 'LRAT' 6000 2* 'GULPR1' 'RATE' 'NO' / - 'LOWER' 'FLD' 6000 2* 'GUOPR1' 'RATE' 'YES' 1* 'FORM' / - 'UPPER' 'FLD' 3000 2* 'GULPR1' 'RATE' 'YES' 1* 'FORM' / -/ DATES 1 'SEP' 2018 / diff --git a/ThirdParty/custom-opm-common/opm-common/tests/parser/data/parser/includeSymlinkTestdata/symlink1/case_symlink.data b/ThirdParty/custom-opm-common/opm-common/tests/parser/data/parser/includeSymlinkTestdata/symlink1/case_symlink.data index 4db9fd79ef..a83017d266 100644 --- a/ThirdParty/custom-opm-common/opm-common/tests/parser/data/parser/includeSymlinkTestdata/symlink1/case_symlink.data +++ b/ThirdParty/custom-opm-common/opm-common/tests/parser/data/parser/includeSymlinkTestdata/symlink1/case_symlink.data @@ -1 +1,3 @@ -actual_file_dir/case.data \ No newline at end of file +INCLUDE + 'include/include.inc' +/ diff --git a/ThirdParty/custom-opm-common/opm-common/tests/parser/data/parser/includeSymlinkTestdata/symlink2/include/symlink_include.inc b/ThirdParty/custom-opm-common/opm-common/tests/parser/data/parser/includeSymlinkTestdata/symlink2/include/symlink_include.inc deleted file mode 100644 index ced6ed6b44..0000000000 --- a/ThirdParty/custom-opm-common/opm-common/tests/parser/data/parser/includeSymlinkTestdata/symlink2/include/symlink_include.inc +++ /dev/null @@ -1 +0,0 @@ -../actual_inlude_file/include.inc \ No newline at end of file diff --git a/ThirdParty/custom-opm-common/opm-common/tests/parser/data/parser/includeSymlinkTestdata/symlink3/include/incl_symlink.inc b/ThirdParty/custom-opm-common/opm-common/tests/parser/data/parser/includeSymlinkTestdata/symlink3/include/incl_symlink.inc index e58537135e..c3e31e44a4 100644 --- a/ThirdParty/custom-opm-common/opm-common/tests/parser/data/parser/includeSymlinkTestdata/symlink3/include/incl_symlink.inc +++ b/ThirdParty/custom-opm-common/opm-common/tests/parser/data/parser/includeSymlinkTestdata/symlink3/include/incl_symlink.inc @@ -1 +1 @@ -../actual_include_file/include_oil.inc \ No newline at end of file +OIL diff --git a/ThirdParty/custom-opm-common/opm-common/tests/parser/data/parser/includeSymlinkTestdata/symlink4/path/case.data b/ThirdParty/custom-opm-common/opm-common/tests/parser/data/parser/includeSymlinkTestdata/symlink4/path/case.data index d77c117cdf..01e6596820 100644 --- a/ThirdParty/custom-opm-common/opm-common/tests/parser/data/parser/includeSymlinkTestdata/symlink4/path/case.data +++ b/ThirdParty/custom-opm-common/opm-common/tests/parser/data/parser/includeSymlinkTestdata/symlink4/path/case.data @@ -1 +1,3 @@ -../case.data \ No newline at end of file +INCLUDE +'oil.inc' +/ diff --git a/ThirdParty/custom-opm-common/opm-common/tests/summary_deck.DATA b/ThirdParty/custom-opm-common/opm-common/tests/summary_deck.DATA index 8246ae89d5..2e1dddde72 100644 --- a/ThirdParty/custom-opm-common/opm-common/tests/summary_deck.DATA +++ b/ThirdParty/custom-opm-common/opm-common/tests/summary_deck.DATA @@ -97,8 +97,6 @@ FGPRF FGPRS FOPRF FOPRS -FCPR -FSPR --FTPRSEA -- Injection Rates FVIR @@ -108,7 +106,6 @@ FGIR FNIR -- solvent FGIRH FCIR -FSIR -- Production Cummulatives FVPT FWPT @@ -127,8 +124,6 @@ FGPTF FOPTF FOPTS FVPRT -FCPT -FSPT -- Injection Cummulatives FVIT FWIT @@ -137,7 +132,6 @@ FGIT FNIT FGITH FCIT -FSIT -- In place FWIP FOIP @@ -347,10 +341,6 @@ GCIR / GCIT / -GSIR -/ -GSIT -/ GWIRH / GWITH @@ -433,16 +423,6 @@ GMWPR / GMWIN / - -GCPR -/ -GCPT -/ - -GSPR -/ -GSPT -/ -- Well Data -- Production Rates WWPR @@ -516,15 +496,9 @@ WNIR WCIR W_3 / -WSIR - W_3 -/ WCIT W_3 / -WSIT - W_3 -/ WNIT W_3 / @@ -637,17 +611,6 @@ WVIT WMCTL / -WCPR -/ - -WCPT -/ - -WSPR -/ - -WSPT -/ -- Water injection per connection CWIR * / @@ -703,14 +666,6 @@ CCIT '*' / / -CSIR - '*' / -/ - -CSIT - '*' / -/ - CWPT 'W_1' 1 1 1 / / diff --git a/ThirdParty/custom-opm-common/opm-common/tests/test_ActiveGridCells.cpp b/ThirdParty/custom-opm-common/opm-common/tests/test_ActiveGridCells.cpp index dd2430d6e7..fbf1935e7e 100644 --- a/ThirdParty/custom-opm-common/opm-common/tests/test_ActiveGridCells.cpp +++ b/ThirdParty/custom-opm-common/opm-common/tests/test_ActiveGridCells.cpp @@ -32,9 +32,9 @@ BOOST_AUTO_TEST_CASE(testLocal) { Opm::GridDims dims(nx, ny, nz); std::vector cells(9); std::set > inactive; - inactive.insert({0,0,0}); - inactive.insert({1,1,0}); - inactive.insert({1,0,1}); + inactive.insert({{0,0,0}}); + inactive.insert({{1,1,0}}); + inactive.insert({{1,0,1}}); for(std::size_t k = 0, index = 0; k < nz; ++k) { diff --git a/ThirdParty/custom-opm-common/opm-common/tests/test_AggregateActionxData.cpp b/ThirdParty/custom-opm-common/opm-common/tests/test_AggregateActionxData.cpp index d94e783b12..25248e4d5e 100644 --- a/ThirdParty/custom-opm-common/opm-common/tests/test_AggregateActionxData.cpp +++ b/ThirdParty/custom-opm-common/opm-common/tests/test_AggregateActionxData.cpp @@ -9,7 +9,6 @@ #include #include -#include #include #include #include @@ -37,10 +36,10 @@ #include namespace { - + Opm::Deck first_sim(std::string fname) { - return Opm::Parser{}.parseFile(fname); - } + return Opm::Parser{}.parseFile(fname); + } } Opm::SummaryState sum_state_TEST1() @@ -59,18 +58,18 @@ Opm::SummaryState sum_state_TEST1() state.update_group_var("UPPER", "GWPR", 36.); state.update_group_var("LOWER", "GWPR", 37.); state.update_group_var("TEST", "GWPR", 73.); - + state.update_group_var("UPPER", "GGPR", 460.); state.update_group_var("LOWER", "GGPR", 461.); state.update_group_var("TEST", "GGPR", 821.); - + state.update_group_var("TEST", "GMWPR", 4); - + state.update("FWPR", 73.); - + state.update("FMWPR", 4); - + return state; } @@ -92,7 +91,7 @@ struct SimulationCase Opm::Schedule sched; }; - + BOOST_AUTO_TEST_SUITE(Aggregate_Actionx) @@ -101,11 +100,10 @@ BOOST_AUTO_TEST_SUITE(Aggregate_Actionx) BOOST_AUTO_TEST_CASE (Declared_Actionx_data) { const auto simCase = SimulationCase{first_sim("UDQ_ACTIONX_TEST1.DATA")}; - + Opm::EclipseState es = simCase.es; Opm::Runspec rspec = es.runspec(); Opm::SummaryState st = sum_state_TEST1(); - Opm::Action::State action_state; Opm::Schedule sched = simCase.sched; Opm::EclipseGrid grid = simCase.grid; const auto& ioConfig = es.getIOConfig(); @@ -113,7 +111,7 @@ BOOST_AUTO_TEST_CASE (Declared_Actionx_data) // Report Step 1: 2008-10-10 --> 2011-01-20 - const auto rptStep = std::size_t{1}; + const auto rptStep = std::size_t{1}; std::string outputDir = "./"; std::string baseName = "UDQ_ACTIONX_TEST1"; Opm::EclIO::OutputStream::Restart rstFile { @@ -128,25 +126,25 @@ BOOST_AUTO_TEST_CASE (Declared_Actionx_data) createInteHead(es, grid, sched, secs_elapsed, rptStep, rptStep, rptStep); - //set dummy value for next_step_size + //set dummy value for next_step_size const double next_step_size= 0.1; - const auto dh = Opm::RestartIO::Helpers::createDoubHead(es, sched, rptStep, - secs_elapsed, next_step_size); - + const auto dh = Opm::RestartIO::Helpers::createDoubHead(es, sched, rptStep, + secs_elapsed, next_step_size); + const auto udqDims = Opm::RestartIO::Helpers::createUdqDims(sched, rptStep, ih); auto udqData = Opm::RestartIO::Helpers::AggregateUDQData(udqDims); udqData.captureDeclaredUDQData(sched, rptStep, st, ih); - + const auto actDims = Opm::RestartIO::Helpers::createActionxDims(rspec, sched, rptStep); auto actionxData = Opm::RestartIO::Helpers::AggregateActionxData(actDims); - actionxData.captureDeclaredActionxData(sched, action_state, st, actDims, rptStep); - + actionxData.captureDeclaredActionxData(sched, st, actDims, rptStep); + { /* Check of InteHEAD and DoubHEAD data for UDQ variables - - INTEHEAD - + + INTEHEAD + Intehead[156] - The number of ACTIONS Intehead[157] - The max number of lines of schedule data including ENDACTIO keyword for any ACTION @@ -156,23 +154,23 @@ BOOST_AUTO_TEST_CASE (Declared_Actionx_data) const auto rptStep_1 = std::size_t{0}; const auto ih_1 = Opm::RestartIO::Helpers::createInteHead(es, grid, sched, secs_elapsed, rptStep, rptStep_1 + 1, rptStep_1); - - BOOST_CHECK_EQUAL(ih_1[156] , 2); - BOOST_CHECK_EQUAL(ih_1[157] , 7); - - + + BOOST_CHECK_EQUAL(ih_1[156] , 2); + BOOST_CHECK_EQUAL(ih_1[157] , 7); + + const auto rptStep_2 = std::size_t{1}; const auto ih_2 = Opm::RestartIO::Helpers::createInteHead(es, grid, sched, secs_elapsed, rptStep, rptStep_2 + 1, rptStep_2); - BOOST_CHECK_EQUAL(ih_2[156] , 3); - BOOST_CHECK_EQUAL(ih_2[157] , 10); + BOOST_CHECK_EQUAL(ih_2[156] , 3); + BOOST_CHECK_EQUAL(ih_2[157] , 10); const auto rptStep_3 = std::size_t{2}; const auto ih_3 = Opm::RestartIO::Helpers::createInteHead(es, grid, sched, secs_elapsed, rptStep, rptStep_3 + 1, rptStep_3); - - BOOST_CHECK_EQUAL(ih_3[156] , 3); - BOOST_CHECK_EQUAL(ih_3[157] , 10); + + BOOST_CHECK_EQUAL(ih_3[156] , 3); + BOOST_CHECK_EQUAL(ih_3[157] , 10); } @@ -190,26 +188,26 @@ BOOST_AUTO_TEST_CASE (Declared_Actionx_data) //item [7]: is unknown, (=0) //item [8]: The number of times the action is triggered */ - - + + const auto& iAct = actionxData.getIACT(); - + auto start = 0*actDims[1]; - BOOST_CHECK_EQUAL(iAct[start + 0] , 0); - BOOST_CHECK_EQUAL(iAct[start + 1] , 10); - BOOST_CHECK_EQUAL(iAct[start + 2] , 1); + BOOST_CHECK_EQUAL(iAct[start + 0] , 0); + BOOST_CHECK_EQUAL(iAct[start + 1] , 10); + BOOST_CHECK_EQUAL(iAct[start + 2] , 1); BOOST_CHECK_EQUAL(iAct[start + 3] , 7); BOOST_CHECK_EQUAL(iAct[start + 4] , 0); BOOST_CHECK_EQUAL(iAct[start + 5] , 10); BOOST_CHECK_EQUAL(iAct[start + 6] , 0); BOOST_CHECK_EQUAL(iAct[start + 7] , 0); BOOST_CHECK_EQUAL(iAct[start + 8] , 3); - + start = 1*actDims[1]; BOOST_CHECK_EQUAL(iAct[start + 0] , 0); - BOOST_CHECK_EQUAL(iAct[start + 1] , 7); - BOOST_CHECK_EQUAL(iAct[start + 2] , 1); + BOOST_CHECK_EQUAL(iAct[start + 1] , 7); + BOOST_CHECK_EQUAL(iAct[start + 2] , 1); BOOST_CHECK_EQUAL(iAct[start + 3] , 7); BOOST_CHECK_EQUAL(iAct[start + 4] , 0); BOOST_CHECK_EQUAL(iAct[start + 5] , 11); @@ -218,9 +216,9 @@ BOOST_AUTO_TEST_CASE (Declared_Actionx_data) BOOST_CHECK_EQUAL(iAct[start + 8] , 3); start = 2*actDims[1]; - BOOST_CHECK_EQUAL(iAct[start + 0] , 0); - BOOST_CHECK_EQUAL(iAct[start + 1] , 4); - BOOST_CHECK_EQUAL(iAct[start + 2] , 1); + BOOST_CHECK_EQUAL(iAct[start + 0] , 0); + BOOST_CHECK_EQUAL(iAct[start + 1] , 4); + BOOST_CHECK_EQUAL(iAct[start + 2] , 1); BOOST_CHECK_EQUAL(iAct[start + 3] , 7); BOOST_CHECK_EQUAL(iAct[start + 4] , 0); BOOST_CHECK_EQUAL(iAct[start + 5] , 13); @@ -229,159 +227,159 @@ BOOST_AUTO_TEST_CASE (Declared_Actionx_data) BOOST_CHECK_EQUAL(iAct[start + 8] , 3); } - + { /* ZACT --length 4 times 8-chars pr ACTIONX keyword Name of action 4 times 8 chars (up to 8 chars for name) - + */ - + const auto& zAct = actionxData.getZACT(); - + auto start = 0*actDims[3]; - BOOST_CHECK_EQUAL(zAct[start + 0].c_str() , "ACT01 "); + BOOST_CHECK_EQUAL(zAct[start + 0].c_str() , "ACT01 "); start = 1*actDims[3]; - BOOST_CHECK_EQUAL(zAct[start + 0].c_str() , "ACT02 "); + BOOST_CHECK_EQUAL(zAct[start + 0].c_str() , "ACT02 "); start = 2*actDims[3]; - BOOST_CHECK_EQUAL(zAct[start + 0].c_str() , "ACT03 "); - + BOOST_CHECK_EQUAL(zAct[start + 0].c_str() , "ACT03 "); + } - + { /* ZLACT -- length = ACTDIMS_item3*(max-over-action of number of lines of data pr ACTION) */ - + const auto& zLact = actionxData.getZLACT(); - + //First action auto start_a = 0*actDims[4]; auto start = start_a + 0*actDims[8]; - BOOST_CHECK_EQUAL(zLact[start + 0].c_str() , "WELOPEN "); + BOOST_CHECK_EQUAL(zLact[start + 0].c_str() , "WELOPEN "); start = start_a + 1*actDims[8]; - BOOST_CHECK_EQUAL(zLact[start + 0].c_str() , " '?' '"); - BOOST_CHECK_EQUAL(zLact[start + 1].c_str() , "SHUT' 0 "); + BOOST_CHECK_EQUAL(zLact[start + 0].c_str() , " '?' '"); + BOOST_CHECK_EQUAL(zLact[start + 1].c_str() , "SHUT' 0 "); BOOST_CHECK_EQUAL(zLact[start + 2].c_str() , "0 0 / "); start = start_a + 2*actDims[8]; - BOOST_CHECK_EQUAL(zLact[start + 0].c_str() , "/ "); + BOOST_CHECK_EQUAL(zLact[start + 0].c_str() , "/ "); start = start_a + 3*actDims[8]; - BOOST_CHECK_EQUAL(zLact[start + 0].c_str() , "WELOPEN "); + BOOST_CHECK_EQUAL(zLact[start + 0].c_str() , "WELOPEN "); //Second action start_a = 1*actDims[4]; start = start_a + 0*actDims[8]; - BOOST_CHECK_EQUAL(zLact[start + 0].c_str() , "WELOPEN "); + BOOST_CHECK_EQUAL(zLact[start + 0].c_str() , "WELOPEN "); start = start_a + 1*actDims[8]; - BOOST_CHECK_EQUAL(zLact[start + 0].c_str() , " '?' '"); - BOOST_CHECK_EQUAL(zLact[start + 1].c_str() , "SHUT' 0 "); + BOOST_CHECK_EQUAL(zLact[start + 0].c_str() , " '?' '"); + BOOST_CHECK_EQUAL(zLact[start + 1].c_str() , "SHUT' 0 "); BOOST_CHECK_EQUAL(zLact[start + 2].c_str() , "0 0 / "); start = start_a + 2*actDims[8]; - BOOST_CHECK_EQUAL(zLact[start + 0].c_str() , "/ "); + BOOST_CHECK_EQUAL(zLact[start + 0].c_str() , "/ "); start = start_a + 3*actDims[8]; - BOOST_CHECK_EQUAL(zLact[start + 0].c_str() , "WELOPEN "); + BOOST_CHECK_EQUAL(zLact[start + 0].c_str() , "WELOPEN "); start = start_a + 4*actDims[8]; - BOOST_CHECK_EQUAL(zLact[start + 0].c_str() , " 'OPL0"); - BOOST_CHECK_EQUAL(zLact[start + 1].c_str() , "1' 'OPEN"); + BOOST_CHECK_EQUAL(zLact[start + 0].c_str() , " 'OPL0"); + BOOST_CHECK_EQUAL(zLact[start + 1].c_str() , "1' 'OPEN"); BOOST_CHECK_EQUAL(zLact[start + 2].c_str() , "' / "); start = start_a + 5*actDims[8]; - BOOST_CHECK_EQUAL(zLact[start + 0].c_str() , "/ "); - + BOOST_CHECK_EQUAL(zLact[start + 0].c_str() , "/ "); + start = start_a + 6*actDims[8]; - BOOST_CHECK_EQUAL(zLact[start + 0].c_str() , "ENDACTIO"); - + BOOST_CHECK_EQUAL(zLact[start + 0].c_str() , "ENDACTIO"); + } - + { /* ZACN //(Max number of conditions pr ACTIONX) * ((max no characters pr line = 104) / (8 - characters pr string)(104/8 = 13) */ - + const auto& zAcn = actionxData.getZACN(); - + //First action auto start_a = 0*actDims[5]; auto start = start_a + 0*13; - BOOST_CHECK_EQUAL(zAcn[start + 0].c_str() , "FMWPR "); - BOOST_CHECK_EQUAL(zAcn[start + 1].c_str() , " "); + BOOST_CHECK_EQUAL(zAcn[start + 0].c_str() , "FMWPR "); + BOOST_CHECK_EQUAL(zAcn[start + 1].c_str() , " "); BOOST_CHECK_EQUAL(zAcn[start + 2].c_str() , "> "); - BOOST_CHECK_EQUAL(zAcn[start + 3].c_str() , " "); + BOOST_CHECK_EQUAL(zAcn[start + 3].c_str() , " "); start = start_a + 1*13; - BOOST_CHECK_EQUAL(zAcn[start + 0].c_str() , "WUPR3 "); - BOOST_CHECK_EQUAL(zAcn[start + 1].c_str() , " "); + BOOST_CHECK_EQUAL(zAcn[start + 0].c_str() , "WUPR3 "); + BOOST_CHECK_EQUAL(zAcn[start + 1].c_str() , " "); BOOST_CHECK_EQUAL(zAcn[start + 2].c_str() , "> "); - BOOST_CHECK_EQUAL(zAcn[start + 3].c_str() , "OP* "); - BOOST_CHECK_EQUAL(zAcn[start + 4].c_str() , " "); - BOOST_CHECK_EQUAL(zAcn[start + 5].c_str() , " "); + BOOST_CHECK_EQUAL(zAcn[start + 3].c_str() , "OP* "); + BOOST_CHECK_EQUAL(zAcn[start + 4].c_str() , " "); + BOOST_CHECK_EQUAL(zAcn[start + 5].c_str() , " "); start = start_a + 2*13; - BOOST_CHECK_EQUAL(zAcn[start + 0].c_str() , " "); - BOOST_CHECK_EQUAL(zAcn[start + 1].c_str() , " "); + BOOST_CHECK_EQUAL(zAcn[start + 0].c_str() , " "); + BOOST_CHECK_EQUAL(zAcn[start + 1].c_str() , " "); BOOST_CHECK_EQUAL(zAcn[start + 2].c_str() , "> "); - BOOST_CHECK_EQUAL(zAcn[start + 3].c_str() , " "); - BOOST_CHECK_EQUAL(zAcn[start + 4].c_str() , " "); - - + BOOST_CHECK_EQUAL(zAcn[start + 3].c_str() , " "); + BOOST_CHECK_EQUAL(zAcn[start + 4].c_str() , " "); + + //Second action start_a = 1*actDims[5]; start = start_a + 0*13; - BOOST_CHECK_EQUAL(zAcn[start + 0].c_str() , "FMWPR "); - BOOST_CHECK_EQUAL(zAcn[start + 1].c_str() , " "); + BOOST_CHECK_EQUAL(zAcn[start + 0].c_str() , "FMWPR "); + BOOST_CHECK_EQUAL(zAcn[start + 1].c_str() , " "); BOOST_CHECK_EQUAL(zAcn[start + 2].c_str() , "> "); - BOOST_CHECK_EQUAL(zAcn[start + 3].c_str() , " "); + BOOST_CHECK_EQUAL(zAcn[start + 3].c_str() , " "); start = start_a + 1*13; - BOOST_CHECK_EQUAL(zAcn[start + 0].c_str() , "WGPR "); - BOOST_CHECK_EQUAL(zAcn[start + 1].c_str() , "GGPR "); + BOOST_CHECK_EQUAL(zAcn[start + 0].c_str() , "WGPR "); + BOOST_CHECK_EQUAL(zAcn[start + 1].c_str() , "GGPR "); BOOST_CHECK_EQUAL(zAcn[start + 2].c_str() , "> "); - BOOST_CHECK_EQUAL(zAcn[start + 3].c_str() , "OPL02 "); - BOOST_CHECK_EQUAL(zAcn[start + 4].c_str() , " "); + BOOST_CHECK_EQUAL(zAcn[start + 3].c_str() , "OPL02 "); + BOOST_CHECK_EQUAL(zAcn[start + 4].c_str() , " "); BOOST_CHECK_EQUAL(zAcn[start + 5].c_str() , " "); - BOOST_CHECK_EQUAL(zAcn[start + 6].c_str() , "LOWER "); + BOOST_CHECK_EQUAL(zAcn[start + 6].c_str() , "LOWER "); start = start_a + 2*13; - BOOST_CHECK_EQUAL(zAcn[start + 0].c_str() , " "); - BOOST_CHECK_EQUAL(zAcn[start + 1].c_str() , " "); + BOOST_CHECK_EQUAL(zAcn[start + 0].c_str() , " "); + BOOST_CHECK_EQUAL(zAcn[start + 1].c_str() , " "); BOOST_CHECK_EQUAL(zAcn[start + 2].c_str() , "> "); - BOOST_CHECK_EQUAL(zAcn[start + 3].c_str() , " "); - BOOST_CHECK_EQUAL(zAcn[start + 4].c_str() , " "); + BOOST_CHECK_EQUAL(zAcn[start + 3].c_str() , " "); + BOOST_CHECK_EQUAL(zAcn[start + 4].c_str() , " "); } - + { /* IACN - 26*Max number of conditions pr ACTIONX + 26*Max number of conditions pr ACTIONX */ - - + + const auto& iAcn = actionxData.getIACN(); - + auto start_a = 0*actDims[6]; auto start = start_a + 0*26; - BOOST_CHECK_EQUAL(iAcn[start + 0] , 0); - BOOST_CHECK_EQUAL(iAcn[start + 1] , 0); - BOOST_CHECK_EQUAL(iAcn[start + 2] , 0); + BOOST_CHECK_EQUAL(iAcn[start + 0] , 0); + BOOST_CHECK_EQUAL(iAcn[start + 1] , 0); + BOOST_CHECK_EQUAL(iAcn[start + 2] , 0); BOOST_CHECK_EQUAL(iAcn[start + 3] , 0); BOOST_CHECK_EQUAL(iAcn[start + 4] , 0); BOOST_CHECK_EQUAL(iAcn[start + 5] , 0); @@ -397,11 +395,11 @@ BOOST_AUTO_TEST_CASE (Declared_Actionx_data) BOOST_CHECK_EQUAL(iAcn[start + 15] , 0); BOOST_CHECK_EQUAL(iAcn[start + 16] , 1); BOOST_CHECK_EQUAL(iAcn[start + 17] , 0); - + start = start_a + 1*26; - BOOST_CHECK_EQUAL(iAcn[start + 0] , 0); - BOOST_CHECK_EQUAL(iAcn[start + 1] , 0); - BOOST_CHECK_EQUAL(iAcn[start + 2] , 0); + BOOST_CHECK_EQUAL(iAcn[start + 0] , 0); + BOOST_CHECK_EQUAL(iAcn[start + 1] , 0); + BOOST_CHECK_EQUAL(iAcn[start + 2] , 0); BOOST_CHECK_EQUAL(iAcn[start + 3] , 0); BOOST_CHECK_EQUAL(iAcn[start + 4] , 0); BOOST_CHECK_EQUAL(iAcn[start + 5] , 0); @@ -420,9 +418,9 @@ BOOST_AUTO_TEST_CASE (Declared_Actionx_data) start_a = 1*actDims[6]; start = start_a + 0*26; - BOOST_CHECK_EQUAL(iAcn[start + 0] , 0); - BOOST_CHECK_EQUAL(iAcn[start + 1] , 0); - BOOST_CHECK_EQUAL(iAcn[start + 2] , 0); + BOOST_CHECK_EQUAL(iAcn[start + 0] , 0); + BOOST_CHECK_EQUAL(iAcn[start + 1] , 0); + BOOST_CHECK_EQUAL(iAcn[start + 2] , 0); BOOST_CHECK_EQUAL(iAcn[start + 3] , 0); BOOST_CHECK_EQUAL(iAcn[start + 4] , 0); BOOST_CHECK_EQUAL(iAcn[start + 5] , 0); @@ -438,11 +436,11 @@ BOOST_AUTO_TEST_CASE (Declared_Actionx_data) BOOST_CHECK_EQUAL(iAcn[start + 15] , 0); BOOST_CHECK_EQUAL(iAcn[start + 16] , 1); BOOST_CHECK_EQUAL(iAcn[start + 17] , 0); - + start = start_a + 1*26; - BOOST_CHECK_EQUAL(iAcn[start + 0] , 0); - BOOST_CHECK_EQUAL(iAcn[start + 1] , 0); - BOOST_CHECK_EQUAL(iAcn[start + 2] , 0); + BOOST_CHECK_EQUAL(iAcn[start + 0] , 0); + BOOST_CHECK_EQUAL(iAcn[start + 1] , 0); + BOOST_CHECK_EQUAL(iAcn[start + 2] , 0); BOOST_CHECK_EQUAL(iAcn[start + 3] , 0); BOOST_CHECK_EQUAL(iAcn[start + 4] , 0); BOOST_CHECK_EQUAL(iAcn[start + 5] , 0); @@ -458,11 +456,11 @@ BOOST_AUTO_TEST_CASE (Declared_Actionx_data) BOOST_CHECK_EQUAL(iAcn[start + 15] , 0); BOOST_CHECK_EQUAL(iAcn[start + 16] , 1); BOOST_CHECK_EQUAL(iAcn[start + 17] , 0); - + start = start_a + 2*26; - BOOST_CHECK_EQUAL(iAcn[start + 0] , 0); - BOOST_CHECK_EQUAL(iAcn[start + 1] , 0); - BOOST_CHECK_EQUAL(iAcn[start + 2] , 0); + BOOST_CHECK_EQUAL(iAcn[start + 0] , 0); + BOOST_CHECK_EQUAL(iAcn[start + 1] , 0); + BOOST_CHECK_EQUAL(iAcn[start + 2] , 0); BOOST_CHECK_EQUAL(iAcn[start + 3] , 0); BOOST_CHECK_EQUAL(iAcn[start + 4] , 0); BOOST_CHECK_EQUAL(iAcn[start + 5] , 0); @@ -481,23 +479,23 @@ BOOST_AUTO_TEST_CASE (Declared_Actionx_data) } - - + + { /* SACN - 26*Max number of conditions pr ACTIONX + 26*Max number of conditions pr ACTIONX */ - - + + const auto& sAcn = actionxData.getSACN(); - + auto start_a = 0*actDims[6]; auto start = start_a + 0*16; - BOOST_CHECK_EQUAL(sAcn[start + 0] , 0); - BOOST_CHECK_EQUAL(sAcn[start + 1] , 0); - BOOST_CHECK_EQUAL(sAcn[start + 2] , 45); + BOOST_CHECK_EQUAL(sAcn[start + 0] , 0); + BOOST_CHECK_EQUAL(sAcn[start + 1] , 0); + BOOST_CHECK_EQUAL(sAcn[start + 2] , 45); BOOST_CHECK_EQUAL(sAcn[start + 3] , 0); BOOST_CHECK_EQUAL(sAcn[start + 4] , 4); BOOST_CHECK_EQUAL(sAcn[start + 5] , 45); @@ -511,11 +509,11 @@ BOOST_AUTO_TEST_CASE (Declared_Actionx_data) BOOST_CHECK_EQUAL(sAcn[start + 13] , 0); BOOST_CHECK_EQUAL(sAcn[start + 14] , 0); BOOST_CHECK_EQUAL(sAcn[start + 15] , 0); - + start = start_a + 1*16; - BOOST_CHECK_EQUAL(sAcn[start + 0] , 0); - BOOST_CHECK_EQUAL(sAcn[start + 1] , 0); - BOOST_CHECK_EQUAL(sAcn[start + 2] , 46); + BOOST_CHECK_EQUAL(sAcn[start + 0] , 0); + BOOST_CHECK_EQUAL(sAcn[start + 1] , 0); + BOOST_CHECK_EQUAL(sAcn[start + 2] , 46); BOOST_CHECK_EQUAL(sAcn[start + 3] , 0); BOOST_CHECK_EQUAL(sAcn[start + 4] , 0); BOOST_CHECK_EQUAL(sAcn[start + 5] , 46); @@ -529,11 +527,11 @@ BOOST_AUTO_TEST_CASE (Declared_Actionx_data) BOOST_CHECK_EQUAL(sAcn[start + 13] , 0); BOOST_CHECK_EQUAL(sAcn[start + 14] , 0); BOOST_CHECK_EQUAL(sAcn[start + 15] , 0); - + start = start_a + 2*16; - BOOST_CHECK_EQUAL(sAcn[start + 0] , 0); - BOOST_CHECK_EQUAL(sAcn[start + 1] , 0); - BOOST_CHECK_EQUAL(sAcn[start + 2] , 10); + BOOST_CHECK_EQUAL(sAcn[start + 0] , 0); + BOOST_CHECK_EQUAL(sAcn[start + 1] , 0); + BOOST_CHECK_EQUAL(sAcn[start + 2] , 10); BOOST_CHECK_EQUAL(sAcn[start + 3] , 0); BOOST_CHECK_EQUAL(sAcn[start + 4] , 1.E+20); BOOST_CHECK_EQUAL(sAcn[start + 5] , 1.E+20); @@ -549,7 +547,7 @@ BOOST_AUTO_TEST_CASE (Declared_Actionx_data) BOOST_CHECK_EQUAL(sAcn[start + 15] , 0); } - + } - + BOOST_AUTO_TEST_SUITE_END() diff --git a/ThirdParty/custom-opm-common/opm-common/tests/test_AggregateGroupData.cpp b/ThirdParty/custom-opm-common/opm-common/tests/test_AggregateGroupData.cpp index 6005302797..83351f838b 100644 --- a/ThirdParty/custom-opm-common/opm-common/tests/test_AggregateGroupData.cpp +++ b/ThirdParty/custom-opm-common/opm-common/tests/test_AggregateGroupData.cpp @@ -25,7 +25,6 @@ #include #include -#include #include #include @@ -437,35 +436,15 @@ END state.update("GOPR:GRP1", 235.); state.update("GGPR:GRP1", 100237.); state.update("GWPR:GRP1", 239.); - state.update("GOPGR:GRP1", 345.6); - state.update("GWPGR:GRP1", 456.7); - state.update("GGPGR:GRP1", 567.8); - state.update("GVPGR:GRP1", 678.9); - state.update("GOIGR:GRP1", 0.123); - state.update("GWIGR:GRP1", 1234.5); - state.update("GGIGR:GRP1", 2345.6); state.update("GOPR:WGRP1", 23.); state.update("GGPR:WGRP1", 50237.); state.update("GWPR:WGRP1", 29.); - state.update("GOPGR:WGRP1", 456.7); - state.update("GWPGR:WGRP1", 567.8); - state.update("GGPGR:WGRP1", 678.9); - state.update("GVPGR:WGRP1", 789.1); - state.update("GOIGR:WGRP1", 1.23); - state.update("GWIGR:WGRP1", 2345.6); - state.update("GGIGR:WGRP1", 3456.7); + state.update("GOPR:WGRP2", 43.); state.update("GGPR:WGRP2", 70237.); state.update("GWPR:WGRP2", 59.); - state.update("GOPGR:WGRP2", 56.7); - state.update("GWPGR:WGRP2", 67.8); - state.update("GGPGR:WGRP2", 78.9); - state.update("GVPGR:WGRP2", 89.1); - state.update("GOIGR:WGRP2", 12.3); - state.update("GWIGR:WGRP2", 345.6); - state.update("GGIGR:WGRP2", 456.7); state.update("FOPR", 3456.); state.update("FGPR", 2003456.); @@ -557,7 +536,6 @@ BOOST_AUTO_TEST_CASE (Declared_Group_Data) // XGRP (PROD) { - using Ix = ::Opm::RestartIO::Helpers::VectorItems::XGroup::index; auto start = 0*ih.nxgrpz; const auto& xGrp = agrpd.getXGroup(); @@ -565,55 +543,11 @@ BOOST_AUTO_TEST_CASE (Declared_Group_Data) BOOST_CHECK_EQUAL(xGrp[start + 1] , 239.); // Group GRP1 - GWPR BOOST_CHECK_EQUAL(xGrp[start + 2] , 100237.); // Group GRP1 - GGPR - BOOST_CHECK_CLOSE(xGrp[start + Ix::OilPrGuideRate], 345.6, 1.0e-10); - BOOST_CHECK_EQUAL(xGrp[start + Ix::OilPrGuideRate], - xGrp[start + Ix::OilPrGuideRate_2]); - - BOOST_CHECK_CLOSE(xGrp[start + Ix::WatPrGuideRate], 456.7, 1.0e-10); - BOOST_CHECK_EQUAL(xGrp[start + Ix::WatPrGuideRate], - xGrp[start + Ix::WatPrGuideRate_2]); - - BOOST_CHECK_CLOSE(xGrp[start + Ix::GasPrGuideRate], 567.8, 1.0e-10); - BOOST_CHECK_EQUAL(xGrp[start + Ix::GasPrGuideRate], - xGrp[start + Ix::GasPrGuideRate_2]); - - BOOST_CHECK_CLOSE(xGrp[start + Ix::VoidPrGuideRate], 678.9, 1.0e-10); - BOOST_CHECK_EQUAL(xGrp[start + Ix::VoidPrGuideRate], - xGrp[start + Ix::VoidPrGuideRate_2]); - - BOOST_CHECK_CLOSE(xGrp[start + Ix::OilInjGuideRate], 0.123, 1.0e-10); - BOOST_CHECK_CLOSE(xGrp[start + Ix::WatInjGuideRate], 1234.5, 1.0e-10); - BOOST_CHECK_EQUAL(xGrp[start + Ix::WatInjGuideRate], - xGrp[start + Ix::WatInjGuideRate_2]); - BOOST_CHECK_CLOSE(xGrp[start + Ix::GasInjGuideRate], 2345.6, 1.0e-10); - start = 1*ih.nxgrpz; BOOST_CHECK_EQUAL(xGrp[start + 0] , 23.); // Group WGRP1 - GOPR BOOST_CHECK_EQUAL(xGrp[start + 1] , 29.); // Group WGRP1 - GWPR BOOST_CHECK_EQUAL(xGrp[start + 2] , 50237.); // Group WGRP1 - GGPR - BOOST_CHECK_CLOSE(xGrp[start + Ix::OilPrGuideRate], 456.7, 1.0e-10); - BOOST_CHECK_EQUAL(xGrp[start + Ix::OilPrGuideRate], - xGrp[start + Ix::OilPrGuideRate_2]); - - BOOST_CHECK_CLOSE(xGrp[start + Ix::WatPrGuideRate], 567.8, 1.0e-10); - BOOST_CHECK_EQUAL(xGrp[start + Ix::WatPrGuideRate], - xGrp[start + Ix::WatPrGuideRate_2]); - - BOOST_CHECK_CLOSE(xGrp[start + Ix::GasPrGuideRate], 678.9, 1.0e-10); - BOOST_CHECK_EQUAL(xGrp[start + Ix::GasPrGuideRate], - xGrp[start + Ix::GasPrGuideRate_2]); - - BOOST_CHECK_CLOSE(xGrp[start + Ix::VoidPrGuideRate], 789.1, 1.0e-10); - BOOST_CHECK_EQUAL(xGrp[start + Ix::VoidPrGuideRate], - xGrp[start + Ix::VoidPrGuideRate_2]); - - BOOST_CHECK_CLOSE(xGrp[start + Ix::OilInjGuideRate], 1.23, 1.0e-10); - BOOST_CHECK_CLOSE(xGrp[start + Ix::WatInjGuideRate], 2345.6, 1.0e-10); - BOOST_CHECK_EQUAL(xGrp[start + Ix::WatInjGuideRate], - xGrp[start + Ix::WatInjGuideRate_2]); - BOOST_CHECK_CLOSE(xGrp[start + Ix::GasInjGuideRate], 3456.7, 1.0e-10); - start = 2*ih.nxgrpz; BOOST_CHECK_EQUAL(xGrp[start + 0] , 43.); // Group WGRP2 - GOPR BOOST_CHECK_EQUAL(xGrp[start + 1] , 59.); // Group WGRP2 - GWPR diff --git a/ThirdParty/custom-opm-common/opm-common/tests/test_AggregateMSWData.cpp b/ThirdParty/custom-opm-common/opm-common/tests/test_AggregateMSWData.cpp index b495febdac..b805c86d18 100644 --- a/ThirdParty/custom-opm-common/opm-common/tests/test_AggregateMSWData.cpp +++ b/ThirdParty/custom-opm-common/opm-common/tests/test_AggregateMSWData.cpp @@ -323,8 +323,8 @@ RPTREGS SOLUTION ============================================================ EQUIL - 7020.00 2700.00 7990.00 .00000 7200.00 .00000 0 0 5 / - 7200.00 3700.00 7300.00 .00000 7100.00 .00000 1 0 5 / + 7020.00 2700.00 7990.00 .00000 7020.00 .00000 0 0 5 / + 7200.00 3700.00 7300.00 .00000 7000.00 .00000 1 0 5 / RSVD 2 TABLES 3 NODES IN EACH FIELD 12:00 17 AUG 83 7000.0 1.0000 diff --git a/ThirdParty/custom-opm-common/opm-common/tests/test_AggregateWellData.cpp b/ThirdParty/custom-opm-common/opm-common/tests/test_AggregateWellData.cpp index ece593b952..10b2c3a6f3 100644 --- a/ThirdParty/custom-opm-common/opm-common/tests/test_AggregateWellData.cpp +++ b/ThirdParty/custom-opm-common/opm-common/tests/test_AggregateWellData.cpp @@ -25,7 +25,6 @@ #include #include -#include #include #include #include @@ -41,7 +40,6 @@ #include #include #include -#include #include #include @@ -94,178 +92,30 @@ OIL GAS WATER DISGAS +VAPOIL UNIFOUT UNIFIN DIMENS 10 10 10 / -WELLDIMS - 6 20 1 6 / -TABDIMS - 1 1 15 15 2 15 / -FIELD -EQLDIMS - 1 / GRID DXV -10*100. / +10*0.25 / DYV -10*100. / +10*0.25 / DZV -10*100. / +10*0.25 / TOPS -100*7000. / +100*0.25 / PORO 1000*0.2 / -PERMX -1000*100. / - -PERMY -1000*100. / - -PERMZ -1000*10. / +SOLUTION -PROPS ========================================================== - --- WATER RELATIVE PERMEABILITY AND CAPILLARY PRESSURE ARE TABULATED AS --- A FUNCTION OF WATER SATURATION. --- --- SWAT KRW PCOW -SWFN - - 0.12 0 0 - 1.0 0.00001 0 / - --- SIMILARLY FOR GAS --- --- SGAS KRG PCOG -SGFN - - 0 0 0 - 0.02 0 0 - 0.05 0.005 0 - 0.12 0.025 0 - 0.2 0.075 0 - 0.25 0.125 0 - 0.3 0.19 0 - 0.4 0.41 0 - 0.45 0.6 0 - 0.5 0.72 0 - 0.6 0.87 0 - 0.7 0.94 0 - 0.85 0.98 0 - 1.0 1.0 0 -/ - --- OIL RELATIVE PERMEABILITY IS TABULATED AGAINST OIL SATURATION --- FOR OIL-WATER AND OIL-GAS-CONNATE WATER CASES --- --- SOIL KROW KROG -SOF3 - - 0 0 0 - 0.18 0 0 - 0.28 0.0001 0.0001 - 0.38 0.001 0.001 - 0.43 0.01 0.01 - 0.48 0.021 0.021 - 0.58 0.09 0.09 - 0.63 0.2 0.2 - 0.68 0.35 0.35 - 0.76 0.7 0.7 - 0.83 0.98 0.98 - 0.86 0.997 0.997 - 0.879 1 1 - 0.88 1 1 / - - --- PVT PROPERTIES OF WATER --- --- REF. PRES. REF. FVF COMPRESSIBILITY REF VISCOSITY VISCOSIBILITY -PVTW - 4014.7 1.029 3.13D-6 0.31 0 / - --- ROCK COMPRESSIBILITY --- --- REF. PRES COMPRESSIBILITY -ROCK - 14.7 3.0D-6 / - --- SURFACE DENSITIES OF RESERVOIR FLUIDS --- --- OIL WATER GAS -DENSITY - 49.1 64.79 0.06054 / - --- PVT PROPERTIES OF DRY GAS (NO VAPOURISED OIL) --- WE WOULD USE PVTG TO SPECIFY THE PROPERTIES OF WET GAS --- --- PGAS BGAS VISGAS -PVDG - 14.7 166.666 0.008 - 264.7 12.093 0.0096 - 514.7 6.274 0.0112 - 1014.7 3.197 0.014 - 2014.7 1.614 0.0189 - 2514.7 1.294 0.0208 - 3014.7 1.080 0.0228 - 4014.7 0.811 0.0268 - 5014.7 0.649 0.0309 - 9014.7 0.386 0.047 / - --- PVT PROPERTIES OF LIVE OIL (WITH DISSOLVED GAS) --- WE WOULD USE PVDO TO SPECIFY THE PROPERTIES OF DEAD OIL --- --- FOR EACH VALUE OF RS THE SATURATION PRESSURE, FVF AND VISCOSITY --- ARE SPECIFIED. FOR RS=1.27 AND 1.618, THE FVF AND VISCOSITY OF --- UNDERSATURATED OIL ARE DEFINED AS A FUNCTION OF PRESSURE. DATA --- FOR UNDERSATURATED OIL MAY BE SUPPLIED FOR ANY RS, BUT MUST BE --- SUPPLIED FOR THE HIGHEST RS (1.618). --- --- RS POIL FVFO VISO -PVTO - 0.001 14.7 1.062 1.04 / - 0.0905 264.7 1.15 0.975 / - 0.18 514.7 1.207 0.91 / - 0.371 1014.7 1.295 0.83 / - 0.636 2014.7 1.435 0.695 / - 0.775 2514.7 1.5 0.641 / - 0.93 3014.7 1.565 0.594 / - 1.270 4014.7 1.695 0.51 - 5014.7 1.671 0.549 - 9014.7 1.579 0.74 / - 1.618 5014.7 1.827 0.449 - 9014.7 1.726 0.605 / -/ - - -REGIONS =========================================================== - - -FIPNUM - - 1000*1 -/ - -EQLNUM - - 1000*1 -/ - - -SOLUTION ============================================================ - -EQUIL -7020.00 2700.00 7990.00 .00000 7200.00 .00000 0 0 5 / - -RSVD 2 TABLES 3 NODES IN EACH FIELD 12:00 17 AUG 83 - 7000.0 1.0000 - 7990.0 1.0000 -/ +START -- 0 +1 NOV 1979 / SCHEDULE RPTRST @@ -299,10 +149,6 @@ WELSPECS COMPDAT 'OP_3' 9 9 1 1 'OPEN' 1* 32.948 0.311 3047.839 1* 1* 'X' 22.100 / / - -WELOPEN - 'OP_1' 'STOP' / -/ WCONPROD 'OP_3' 'OPEN' 'ORAT' 20000 4* 1000 / / @@ -391,7 +237,6 @@ TSTEP -- 8 state.update("WWCT:OP_1" , 0.625); state.update("WGOR:OP_1" , 234.5); state.update("WBHP:OP_1" , 314.15); - state.update("WTHP:OP_1" , 123.45); state.update("WOPTH:OP_1", 345.6); state.update("WWPTH:OP_1", 456.7); state.update("WGPTH:OP_1", 567.8); @@ -399,10 +244,6 @@ TSTEP -- 8 state.update("WGITH:OP_1", 0.0); state.update("WGVIR:OP_1", 0.0); state.update("WWVIR:OP_1", 0.0); - state.update("WOPGR:OP_1", 4.9); - state.update("WWPGR:OP_1", 3.8); - state.update("WGPGR:OP_1", 2.7); - state.update("WVPGR:OP_1", 6.1); state.update("WOPR:OP_2" , 0.0); state.update("WWPR:OP_2" , 0.0); @@ -420,7 +261,6 @@ TSTEP -- 8 state.update("WWCT:OP_2" , 0.0); state.update("WGOR:OP_2" , 0.0); state.update("WBHP:OP_2" , 400.6); - state.update("WTHP:OP_2" , 234.5); state.update("WOPTH:OP_2", 0.0); state.update("WWPTH:OP_2", 0.0); state.update("WGPTH:OP_2", 0.0); @@ -428,10 +268,6 @@ TSTEP -- 8 state.update("WGITH:OP_2", 3030.0); state.update("WGVIR:OP_2", 1234.0); state.update("WWVIR:OP_2", 4321.0); - state.update("WOIGR:OP_2", 4.9); - state.update("WWIGR:OP_2", 3.8); - state.update("WGIGR:OP_2", 2.7); - state.update("WVIGR:OP_2", 6.1); state.update("WOPR:OP_3" , 11.0); state.update("WWPR:OP_3" , 12.0); @@ -449,7 +285,6 @@ TSTEP -- 8 state.update("WWCT:OP_3" , 0.0625); state.update("WGOR:OP_3" , 1234.5); state.update("WBHP:OP_3" , 314.15); - state.update("WTHP:OP_3" , 246.9); state.update("WOPTH:OP_3", 2345.6); state.update("WWPTH:OP_3", 3456.7); state.update("WGPTH:OP_3", 4567.8); @@ -457,10 +292,6 @@ TSTEP -- 8 state.update("WGITH:OP_3", 0.0); state.update("WGVIR:OP_3", 0.0); state.update("WWVIR:OP_3", 43.21); - state.update("WOPGR:OP_3", 49.0); - state.update("WWPGR:OP_3", 38.9); - state.update("WGPGR:OP_3", 27.8); - state.update("WVPGR:OP_3", 61.2); return state; } @@ -483,22 +314,13 @@ TSTEP -- 8 c.rates.set(o::wat, 1.0) .set(o::oil, 2.0) .set(o::gas, 3.0); - auto& curr = xw["OP_1"].current_control; - curr.isProducer = true; - curr.prod = ::Opm::Well::ProducerCMode::GRAT; } { xw["OP_2"].bhp = 234.0; xw["OP_2"].rates.set(o::gas, 5.0); - //xw["OP_2"].connections.emplace_back(); - - //auto& c = xw["OP_2"].connections.back(); - //c.rates.set(o::gas, 4.0); - auto& curr = xw["OP_2"].current_control; - curr.isProducer = false; - curr.inj = ::Opm::Well::InjectorCMode::RATE; + xw["OP_2"].connections.emplace_back(); } return xw; @@ -512,17 +334,6 @@ TSTEP -- 8 { xw["OP_1"].bhp = 150.0; // Closed - - xw["OP_1"].connections.emplace_back(); - auto& c = xw["OP_1"].connections.back(); - - c.rates.set(o::wat, 1.0) - .set(o::oil, 2.0) - .set(o::gas, 3.0); - - auto& curr = xw["OP_1"].current_control; - curr.isProducer = true; - curr.prod = ::Opm::Well::ProducerCMode::NONE; } { @@ -576,7 +387,7 @@ BOOST_AUTO_TEST_CASE (Constructor) BOOST_AUTO_TEST_CASE (Declared_Well_Data) { const auto simCase = SimulationCase{first_sim()}; - Opm::Action::State action_state; + // Report Step 1: 2008-10-10 --> 2011-01-20 const auto rptStep = std::size_t{1}; @@ -589,7 +400,7 @@ BOOST_AUTO_TEST_CASE (Declared_Well_Data) const auto smry = sim_state(); auto awd = Opm::RestartIO::Helpers::AggregateWellData{ih.value}; awd.captureDeclaredWellData(simCase.sched, - simCase.es.getUnits(), rptStep, action_state, smry, ih.value); + simCase.es.getUnits(), rptStep, smry, ih.value); // IWEL (OP_1) { @@ -661,7 +472,7 @@ BOOST_AUTO_TEST_CASE (Declared_Well_Data) // No THP limit BOOST_CHECK_CLOSE(swell[i0 + Ix::THPTarget] , 0.0f, 1.0e-7f); BOOST_CHECK_CLOSE(swell[i0 + Ix::BHPTarget] , 1000.0f, 1.0e-7f); - BOOST_CHECK_CLOSE(swell[i0 + Ix::DatumDepth], 7050.00049f, 1.0e-7f); + BOOST_CHECK_CLOSE(swell[i0 + Ix::DatumDepth], 0.375f, 1.0e-7f); } // SWEL (OP_2) @@ -674,7 +485,7 @@ BOOST_AUTO_TEST_CASE (Declared_Well_Data) BOOST_CHECK_CLOSE(swell[i1 + Ix::THPTarget], 1.0e20f, 1.0e-7f); BOOST_CHECK_CLOSE(swell[i1 + Ix::BHPTarget], 400.0f, 1.0e-7f); - BOOST_CHECK_CLOSE(swell[i1 + Ix::DatumDepth], 7150.0f, 1.0e-7f); + BOOST_CHECK_CLOSE(swell[i1 + Ix::DatumDepth], 0.625f, 1.0e-7f); } // XWEL (OP_1) @@ -761,13 +572,8 @@ BOOST_AUTO_TEST_CASE (Dynamic_Well_Data_Step1) const auto& iwell = awd.getIWell(); - // - // These checks do not work because flow gives a well's status SHUT - // when all the connections are shut (no flowing connections) - // This needs to be corrected in flow - BOOST_CHECK_EQUAL(iwell[i1 + Ix::item9 ], -1); // No flowing conns. - BOOST_CHECK_EQUAL(iwell[i1 + Ix::item11], -1); // No flowing conns. + BOOST_CHECK_EQUAL(iwell[i1 + Ix::item11], 1); // Well open/shut flag } // XWEL (OP_1) @@ -783,7 +589,6 @@ BOOST_AUTO_TEST_CASE (Dynamic_Well_Data_Step1) BOOST_CHECK_CLOSE(xwell[i0 + Ix::LiqPrRate], 1.0 + 2.0, 1.0e-10); BOOST_CHECK_CLOSE(xwell[i0 + Ix::VoidPrRate], 4.0, 1.0e-10); - BOOST_CHECK_CLOSE(xwell[i0 + Ix::TubHeadPr], 123.45, 1.0e-10); BOOST_CHECK_CLOSE(xwell[i0 + Ix::FlowBHP], 314.15 , 1.0e-10); BOOST_CHECK_CLOSE(xwell[i0 + Ix::WatCut] , 0.625, 1.0e-10); BOOST_CHECK_CLOSE(xwell[i0 + Ix::GORatio], 234.5 , 1.0e-10); @@ -805,18 +610,6 @@ BOOST_AUTO_TEST_CASE (Dynamic_Well_Data_Step1) BOOST_CHECK_CLOSE(xwell[i0 + Ix::HistWatInjTotal], 0.0, 1.0e-10); BOOST_CHECK_CLOSE(xwell[i0 + Ix::HistGasInjTotal], 0.0, 1.0e-10); - - BOOST_CHECK_CLOSE(xwell[i0 + Ix::PrimGuideRate], 4.9, 1.0e-10); - BOOST_CHECK_EQUAL(xwell[i0 + Ix::PrimGuideRate], xwell[i0 + Ix::PrimGuideRate_2]); - - BOOST_CHECK_CLOSE(xwell[i0 + Ix::WatPrGuideRate], 3.8, 1.0e-10); - BOOST_CHECK_EQUAL(xwell[i0 + Ix::WatPrGuideRate], xwell[i0 + Ix::WatPrGuideRate_2]); - - BOOST_CHECK_CLOSE(xwell[i0 + Ix::GasPrGuideRate], 2.7, 1.0e-10); - BOOST_CHECK_EQUAL(xwell[i0 + Ix::GasPrGuideRate], xwell[i0 + Ix::GasPrGuideRate_2]); - - BOOST_CHECK_CLOSE(xwell[i0 + Ix::VoidPrGuideRate], 6.1, 1.0e-10); - BOOST_CHECK_EQUAL(xwell[i0 + Ix::VoidPrGuideRate], xwell[i0 + Ix::VoidPrGuideRate_2]); } // XWEL (OP_2) @@ -828,7 +621,6 @@ BOOST_AUTO_TEST_CASE (Dynamic_Well_Data_Step1) BOOST_CHECK_CLOSE(xwell[i1 + Ix::GasPrRate], -200.0, 1.0e-10); BOOST_CHECK_CLOSE(xwell[i1 + Ix::VoidPrRate], -1234.0, 1.0e-10); - BOOST_CHECK_CLOSE(xwell[i1 + Ix::TubHeadPr], 234.5, 1.0e-10); BOOST_CHECK_CLOSE(xwell[i1 + Ix::FlowBHP], 400.6, 1.0e-10); BOOST_CHECK_CLOSE(xwell[i1 + Ix::WatInjTotal], 1000.0, 1.0e-10); @@ -846,20 +638,6 @@ BOOST_AUTO_TEST_CASE (Dynamic_Well_Data_Step1) BOOST_CHECK_CLOSE(xwell[i1 + Ix::HistGasPrTotal] , 0.0, 1.0e-10); BOOST_CHECK_CLOSE(xwell[i1 + Ix::HistWatInjTotal], 1515.0, 1.0e-10); BOOST_CHECK_CLOSE(xwell[i1 + Ix::HistGasInjTotal], 3030.0, 1.0e-10); - - // Gas injector => primary guide rate == gas injection guide rate (with negative sign). - BOOST_CHECK_CLOSE(xwell[i1 + Ix::PrimGuideRate], -2.7, 1.0e-10); - BOOST_CHECK_EQUAL(xwell[i1 + Ix::PrimGuideRate], xwell[i1 + Ix::PrimGuideRate_2]); - - // Injector => all phase production guide rates are zero - BOOST_CHECK_CLOSE(xwell[i1 + Ix::WatPrGuideRate], 0.0, 1.0e-10); - BOOST_CHECK_EQUAL(xwell[i1 + Ix::WatPrGuideRate], xwell[i1 + Ix::WatPrGuideRate_2]); - - BOOST_CHECK_CLOSE(xwell[i1 + Ix::GasPrGuideRate], 0.0, 1.0e-10); - BOOST_CHECK_EQUAL(xwell[i1 + Ix::GasPrGuideRate], xwell[i1 + Ix::GasPrGuideRate_2]); - - BOOST_CHECK_CLOSE(xwell[i1 + Ix::VoidPrGuideRate], 0.0, 1.0e-10); - BOOST_CHECK_EQUAL(xwell[i1 + Ix::VoidPrGuideRate], xwell[i1 + Ix::VoidPrGuideRate_2]); } } @@ -890,10 +668,8 @@ BOOST_AUTO_TEST_CASE (Dynamic_Well_Data_Step2) const auto& iwell = awd.getIWell(); - - - BOOST_CHECK_EQUAL(iwell[i0 + Ix::item9] , 0); - BOOST_CHECK_EQUAL(iwell[i0 + Ix::item11], 0); + BOOST_CHECK_EQUAL(iwell[i0 + Ix::item9] , -1000); + BOOST_CHECK_EQUAL(iwell[i0 + Ix::item11], -1000); } // IWEL (OP_2) -- water injector @@ -922,7 +698,6 @@ BOOST_AUTO_TEST_CASE (Dynamic_Well_Data_Step2) BOOST_CHECK_CLOSE(xwell[i0 + Ix::LiqPrRate], 1.0 + 2.0, 1.0e-10); BOOST_CHECK_CLOSE(xwell[i0 + Ix::VoidPrRate], 4.0, 1.0e-10); - BOOST_CHECK_CLOSE(xwell[i0 + Ix::TubHeadPr], 123.45, 1.0e-10); BOOST_CHECK_CLOSE(xwell[i0 + Ix::FlowBHP], 314.15, 1.0e-10); BOOST_CHECK_CLOSE(xwell[i0 + Ix::WatCut] , 0.625, 1.0e-10); BOOST_CHECK_CLOSE(xwell[i0 + Ix::GORatio], 234.5, 1.0e-10); @@ -941,18 +716,6 @@ BOOST_AUTO_TEST_CASE (Dynamic_Well_Data_Step2) BOOST_CHECK_CLOSE(xwell[i0 + Ix::HistOilPrTotal], 345.6, 1.0e-10); BOOST_CHECK_CLOSE(xwell[i0 + Ix::HistWatPrTotal], 456.7, 1.0e-10); BOOST_CHECK_CLOSE(xwell[i0 + Ix::HistGasPrTotal], 567.8, 1.0e-10); - - BOOST_CHECK_CLOSE(xwell[i0 + Ix::PrimGuideRate], 4.9, 1.0e-10); - BOOST_CHECK_EQUAL(xwell[i0 + Ix::PrimGuideRate], xwell[i0 + Ix::PrimGuideRate_2]); - - BOOST_CHECK_CLOSE(xwell[i0 + Ix::WatPrGuideRate], 3.8, 1.0e-10); - BOOST_CHECK_EQUAL(xwell[i0 + Ix::WatPrGuideRate], xwell[i0 + Ix::WatPrGuideRate_2]); - - BOOST_CHECK_CLOSE(xwell[i0 + Ix::GasPrGuideRate], 2.7, 1.0e-10); - BOOST_CHECK_EQUAL(xwell[i0 + Ix::GasPrGuideRate], xwell[i0 + Ix::GasPrGuideRate_2]); - - BOOST_CHECK_CLOSE(xwell[i0 + Ix::VoidPrGuideRate], 6.1, 1.0e-10); - BOOST_CHECK_EQUAL(xwell[i0 + Ix::VoidPrGuideRate], xwell[i0 + Ix::VoidPrGuideRate_2]); } // XWEL (OP_2) -- water injector @@ -968,7 +731,6 @@ BOOST_AUTO_TEST_CASE (Dynamic_Well_Data_Step2) BOOST_CHECK_CLOSE(xwell[i1 + Ix::LiqPrRate], xwell[i1 + Ix::WatPrRate], 1.0e-10); - BOOST_CHECK_CLOSE(xwell[i1 + Ix::TubHeadPr], 234.5, 1.0e-10); BOOST_CHECK_CLOSE(xwell[i1 + Ix::FlowBHP], 400.6, 1.0e-10); BOOST_CHECK_CLOSE(xwell[i1 + Ix::WatInjTotal], 1000.0, 1.0e-10); @@ -988,20 +750,6 @@ BOOST_AUTO_TEST_CASE (Dynamic_Well_Data_Step2) // WWVIR BOOST_CHECK_CLOSE(xwell[i1 + Ix::WatVoidPrRate], -4321.0, 1.0e-10); - - // Water injector => primary guide rate == water injection guide rate (with negative sign). - BOOST_CHECK_CLOSE(xwell[i1 + Ix::PrimGuideRate], -3.8, 1.0e-10); - BOOST_CHECK_EQUAL(xwell[i1 + Ix::PrimGuideRate], xwell[i1 + Ix::PrimGuideRate_2]); - - // Injector => all phase production guide rates are zero - BOOST_CHECK_CLOSE(xwell[i1 + Ix::WatPrGuideRate], 0.0, 1.0e-10); - BOOST_CHECK_EQUAL(xwell[i1 + Ix::WatPrGuideRate], xwell[i1 + Ix::WatPrGuideRate_2]); - - BOOST_CHECK_CLOSE(xwell[i1 + Ix::GasPrGuideRate], 0.0, 1.0e-10); - BOOST_CHECK_EQUAL(xwell[i1 + Ix::GasPrGuideRate], xwell[i1 + Ix::GasPrGuideRate_2]); - - BOOST_CHECK_CLOSE(xwell[i1 + Ix::VoidPrGuideRate], 0.0, 1.0e-10); - BOOST_CHECK_EQUAL(xwell[i1 + Ix::VoidPrGuideRate], xwell[i1 + Ix::VoidPrGuideRate_2]); } // XWEL (OP_3) -- producer @@ -1017,7 +765,6 @@ BOOST_AUTO_TEST_CASE (Dynamic_Well_Data_Step2) BOOST_CHECK_CLOSE(xwell[i2 + Ix::LiqPrRate], 11.0 + 12.0, 1.0e-10); // LPR BOOST_CHECK_CLOSE(xwell[i2 + Ix::VoidPrRate], 14.0, 1.0e-10); - BOOST_CHECK_CLOSE(xwell[i2 + Ix::TubHeadPr], 246.9, 1.0e-10); BOOST_CHECK_CLOSE(xwell[i2 + Ix::FlowBHP], 314.15, 1.0e-10); BOOST_CHECK_CLOSE(xwell[i2 + Ix::WatCut] , 0.0625, 1.0e-10); BOOST_CHECK_CLOSE(xwell[i2 + Ix::GORatio], 1234.5, 1.0e-10); @@ -1038,18 +785,6 @@ BOOST_AUTO_TEST_CASE (Dynamic_Well_Data_Step2) BOOST_CHECK_CLOSE(xwell[i2 + Ix::HistOilPrTotal], 2345.6, 1.0e-10); BOOST_CHECK_CLOSE(xwell[i2 + Ix::HistWatPrTotal], 3456.7, 1.0e-10); BOOST_CHECK_CLOSE(xwell[i2 + Ix::HistGasPrTotal], 4567.8, 1.0e-10); - - BOOST_CHECK_CLOSE(xwell[i2 + Ix::PrimGuideRate], 49, 1.0e-10); - BOOST_CHECK_EQUAL(xwell[i2 + Ix::PrimGuideRate], xwell[i2 + Ix::PrimGuideRate_2]); - - BOOST_CHECK_CLOSE(xwell[i2 + Ix::WatPrGuideRate], 38.9, 1.0e-10); - BOOST_CHECK_EQUAL(xwell[i2 + Ix::WatPrGuideRate], xwell[i2 + Ix::WatPrGuideRate_2]); - - BOOST_CHECK_CLOSE(xwell[i2 + Ix::GasPrGuideRate], 27.8, 1.0e-10); - BOOST_CHECK_EQUAL(xwell[i2 + Ix::GasPrGuideRate], xwell[i2 + Ix::GasPrGuideRate_2]); - - BOOST_CHECK_CLOSE(xwell[i2 + Ix::VoidPrGuideRate], 61.2, 1.0e-10); - BOOST_CHECK_EQUAL(xwell[i2 + Ix::VoidPrGuideRate], xwell[i2 + Ix::VoidPrGuideRate_2]); } } @@ -1061,8 +796,6 @@ BOOST_AUTO_TEST_CASE(WELL_POD) { const auto rptStep = std::size_t{2}; const auto sim_step = rptStep - 1; Opm::SummaryState sumState(std::chrono::system_clock::now()); - const auto xw = well_rates_1(); - Opm::Action::State action_state; const auto ih = Opm::RestartIO::Helpers::createInteHead(simCase.es, simCase.grid, @@ -1073,11 +806,11 @@ BOOST_AUTO_TEST_CASE(WELL_POD) { sim_step); auto wellData = Opm::RestartIO::Helpers::AggregateWellData(ih); - wellData.captureDeclaredWellData(simCase.sched, units, sim_step, action_state, sumState, ih); - wellData.captureDynamicWellData(simCase.sched, sim_step, xw , sumState); + wellData.captureDeclaredWellData(simCase.sched, units, sim_step, sumState, ih); + wellData.captureDynamicWellData(simCase.sched, sim_step, {} , sumState); auto connectionData = Opm::RestartIO::Helpers::AggregateConnectionData(ih); - connectionData.captureDeclaredConnData(simCase.sched, simCase.grid, units, xw , sim_step); + connectionData.captureDeclaredConnData(simCase.sched, simCase.grid, units, {} , sim_step); const auto& iwel = wellData.getIWell(); const auto& swel = wellData.getSWell(); diff --git a/ThirdParty/custom-opm-common/opm-common/tests/test_EclipseIO.cpp b/ThirdParty/custom-opm-common/opm-common/tests/test_EclipseIO.cpp index 6e4965bded..9dae9bc1a8 100644 --- a/ThirdParty/custom-opm-common/opm-common/tests/test_EclipseIO.cpp +++ b/ThirdParty/custom-opm-common/opm-common/tests/test_EclipseIO.cpp @@ -35,7 +35,6 @@ #include #include #include -#include #include #include @@ -315,18 +314,15 @@ BOOST_AUTO_TEST_CASE(EclipseIOIntegration) { eclWriter.writeInitial( eGridProps , int_data ); data::Wells wells; - data::GroupValues groups; for( int i = first; i < last; ++i ) { data::Solution sol = createBlackoilState( i, 3 * 3 * 3 ); sol.insert("KRO", measure::identity , std::vector(3*3*3 , i), TargetType::RESTART_AUXILIARY); sol.insert("KRG", measure::identity , std::vector(3*3*3 , i*10), TargetType::RESTART_AUXILIARY); - Action::State action_state; - RestartValue restart_value(sol, wells, groups); + RestartValue restart_value(sol, wells); auto first_step = ecl_util_make_date( 10 + i, 11, 2008 ); - eclWriter.writeTimeStep( action_state, - st, + eclWriter.writeTimeStep( st, i, false, first_step - start_time, diff --git a/ThirdParty/custom-opm-common/opm-common/tests/test_RFT.cpp b/ThirdParty/custom-opm-common/opm-common/tests/test_RFT.cpp index f8f270c6dd..8df2c54c48 100644 --- a/ThirdParty/custom-opm-common/opm-common/tests/test_RFT.cpp +++ b/ThirdParty/custom-opm-common/opm-common/tests/test_RFT.cpp @@ -28,7 +28,6 @@ #include #include -#include #include #include #include @@ -38,7 +37,6 @@ #include #include #include -#include #include #include @@ -276,7 +274,6 @@ BOOST_AUTO_TEST_CASE(test_RFT) const auto step_time = timeStamp(::Opm::EclIO::ERft::RftDate{ 2008, 10, 10 }); SummaryState st(std::chrono::system_clock::now()); - Action::State action_state; data::Rates r1, r2; r1.set( data::Rates::opt::wat, 4.11 ); @@ -300,7 +297,6 @@ BOOST_AUTO_TEST_CASE(test_RFT) Opm::data::Solution solution = createBlackoilState(2, numCells); Opm::data::Wells wells; - Opm::data::GroupValues groups; using SegRes = decltype(wells["w"].segments); using Ctrl = decltype(wells["w"].current_control); @@ -308,10 +304,9 @@ BOOST_AUTO_TEST_CASE(test_RFT) wells["OP_1"] = { std::move(r1), 1.0, 1.1, 3.1, 1, std::move(well1_comps), SegRes{}, Ctrl{} }; wells["OP_2"] = { std::move(r2), 1.0, 1.1, 3.2, 1, std::move(well2_comps), SegRes{}, Ctrl{} }; - RestartValue restart_value(std::move(solution), std::move(wells), std::move(groups)); + RestartValue restart_value(std::move(solution), std::move(wells)); - eclipseWriter.writeTimeStep( action_state, - st, + eclipseWriter.writeTimeStep( st, 2, false, step_time - start_time, @@ -395,7 +390,6 @@ BOOST_AUTO_TEST_CASE(test_RFT2) Schedule schedule(deck, eclipseState, python); SummaryConfig summary_config( deck, schedule, eclipseState.getTableManager( )); SummaryState st(std::chrono::system_clock::now()); - Action::State action_state; const auto start_time = schedule.posixStartTime(); const auto& time_map = schedule.getTimeMap( ); @@ -434,10 +428,9 @@ BOOST_AUTO_TEST_CASE(test_RFT2) wells["OP_1"] = { std::move(r1), 1.0, 1.1, 3.1, 1, std::move(well1_comps), SegRes{}, Ctrl{} }; wells["OP_2"] = { std::move(r2), 1.0, 1.1, 3.2, 1, std::move(well2_comps), SegRes{}, Ctrl{} }; - RestartValue restart_value(std::move(solution), std::move(wells), data::GroupValues()); + RestartValue restart_value(std::move(solution), std::move(wells)); - eclipseWriter.writeTimeStep( action_state, - st, + eclipseWriter.writeTimeStep( st, step, false, step_time - start_time, diff --git a/ThirdParty/custom-opm-common/opm-common/tests/test_Restart.cpp b/ThirdParty/custom-opm-common/opm-common/tests/test_Restart.cpp index f4fa14b1c1..b3d85f076f 100644 --- a/ThirdParty/custom-opm-common/opm-common/tests/test_Restart.cpp +++ b/ThirdParty/custom-opm-common/opm-common/tests/test_Restart.cpp @@ -27,7 +27,6 @@ #include #include #include -#include #include #include @@ -39,9 +38,6 @@ #include #include #include -#include -#include -#include #include #include @@ -136,9 +132,6 @@ std::ostream& operator<<( std::ostream& stream, } -data::GroupValues mkGroups() { - return {}; -} data::Wells mkWells() { data::Rates r1, r2, rc1, rc2, rc3; @@ -368,23 +361,7 @@ struct Setup { }; -void init_st(SummaryState& st) { - st.update_well_var("PROD1", "WOPR", 100); - st.update_well_var("PROD1", "WLPR", 100); - st.update_well_var("PROD2", "WOPR", 100); - st.update_well_var("PROD2", "WLPR", 100); - st.update_well_var("WINJ1", "WOPR", 100); - st.update_well_var("WINJ1", "WLPR", 100); - st.update_well_var("WINJ2", "WOPR", 100); - st.update_well_var("WINJ2", "WLPR", 100); - - st.update_group_var("GRP1", "GOPR", 100); - st.update_group_var("WGRP1", "GOPR", 100); - st.update_group_var("WGRP1", "GOPR", 100); - st.update("FLPR", 100); -} - -RestartValue first_sim(const Setup& setup, Action::State& action_state, SummaryState& st, bool write_double) { +RestartValue first_sim(const Setup& setup, SummaryState& st, bool write_double) { EclipseIO eclWriter( setup.es, setup.grid, setup.schedule, setup.summary_config); auto num_cells = setup.grid.getNumActive( ); int report_step = 1; @@ -393,14 +370,9 @@ RestartValue first_sim(const Setup& setup, Action::State& action_state, SummaryS auto sol = mkSolution( num_cells ); auto wells = mkWells(); - auto groups = mkGroups(); - const auto& udq = setup.schedule.getUDQConfig(report_step); - RestartValue restart_value(sol, wells, groups); + RestartValue restart_value(sol, wells); - init_st(st); - udq.eval(st); - eclWriter.writeTimeStep( action_state, - st, + eclWriter.writeTimeStep( st, report_step, false, std::difftime(first_step, start_time), @@ -410,9 +382,9 @@ RestartValue first_sim(const Setup& setup, Action::State& action_state, SummaryS return restart_value; } -RestartValue second_sim(const Setup& setup, Action::State& action_state, SummaryState& summary_state, const std::vector& solution_keys) { +RestartValue second_sim(const Setup& setup, SummaryState& summary_state, const std::vector& solution_keys) { EclipseIO writer(setup.es, setup.grid, setup.schedule, setup.summary_config); - return writer.loadRestart( action_state, summary_state, solution_keys ); + return writer.loadRestart( summary_state, solution_keys ); } @@ -450,15 +422,14 @@ BOOST_AUTO_TEST_CASE(EclipseReadWriteWellStateData) { Setup base_setup("BASE_SIM.DATA"); SummaryState st(std::chrono::system_clock::now()); - Action::State action_state; - auto state1 = first_sim( base_setup , action_state, st, false ); + auto state1 = first_sim( base_setup , st, false ); Setup restart_setup("RESTART_SIM.DATA"); - auto state2 = second_sim( restart_setup , action_state, st , keys ); + auto state2 = second_sim( restart_setup , st , keys ); compare(state1, state2 , keys); - BOOST_CHECK_THROW( second_sim( restart_setup, action_state, st, {{"SOIL", UnitSystem::measure::pressure}} ) , std::runtime_error ); - BOOST_CHECK_THROW( second_sim( restart_setup, action_state, st, {{"SOIL", UnitSystem::measure::pressure, true}}) , std::runtime_error ); + BOOST_CHECK_THROW( second_sim( restart_setup, st, {{"SOIL", UnitSystem::measure::pressure}} ) , std::runtime_error ); + BOOST_CHECK_THROW( second_sim( restart_setup, st, {{"SOIL", UnitSystem::measure::pressure, true}}) , std::runtime_error ); } @@ -474,11 +445,9 @@ BOOST_AUTO_TEST_CASE(ECL_FORMATTED) { auto num_cells = base_setup.grid.getNumActive( ); auto cells = mkSolution( num_cells ); auto wells = mkWells(); - auto groups = mkGroups(); auto sumState = sim_state(); - Action::State action_state; { - RestartValue restart_value(cells, wells, groups); + RestartValue restart_value(cells, wells); io_config.setEclCompatibleRST( false ); restart_value.addExtra("EXTRA", UnitSystem::measure::pressure, {10,1,2,3}); @@ -498,7 +467,6 @@ BOOST_AUTO_TEST_CASE(ECL_FORMATTED) { base_setup.es, base_setup.grid, base_setup.schedule, - action_state, sumState, true); } @@ -527,7 +495,6 @@ BOOST_AUTO_TEST_CASE(ECL_FORMATTED) { base_setup.es, base_setup.grid, base_setup.schedule, - action_state, sumState, true); } @@ -585,12 +552,11 @@ BOOST_AUTO_TEST_CASE(EclipseReadWriteWellStateData_double) { test_area.copyIn("BASE_SIM.DATA"); Setup base_setup("BASE_SIM.DATA"); SummaryState st(std::chrono::system_clock::now()); - Action::State action_state; - auto state1 = first_sim( base_setup , action_state, st, true); + auto state1 = first_sim( base_setup , st, true); Setup restart_setup("RESTART_SIM.DATA"); - auto state2 = second_sim( restart_setup, action_state, st, solution_keys ); + auto state2 = second_sim( restart_setup, st, solution_keys ); compare_equal( state1 , state2 , solution_keys); } @@ -606,9 +572,7 @@ BOOST_AUTO_TEST_CASE(WriteWrongSOlutionSize) { auto num_cells = setup.grid.getNumActive( ) + 1; auto cells = mkSolution( num_cells ); auto wells = mkWells(); - auto groups = mkGroups(); Opm::SummaryState sumState(std::chrono::system_clock::now()); - Opm::Action::State action_state; const auto seqnum = 1; auto rstFile = OS::Restart { @@ -618,11 +582,10 @@ BOOST_AUTO_TEST_CASE(WriteWrongSOlutionSize) { BOOST_CHECK_THROW( RestartIO::save(rstFile, seqnum, 100, - RestartValue(cells, wells, groups), + RestartValue(cells, wells), setup.es, setup.grid , setup.schedule, - action_state, sumState), std::runtime_error); } @@ -634,8 +597,7 @@ BOOST_AUTO_TEST_CASE(ExtraData_KEYS) { auto num_cells = setup.grid.getNumActive( ); auto cells = mkSolution( num_cells ); auto wells = mkWells(); - auto groups = mkGroups(); - RestartValue restart_value(cells, wells, groups); + RestartValue restart_value(cells, wells); BOOST_CHECK_THROW( restart_value.addExtra("TOO-LONG-KEY", {0,1,2}), std::runtime_error); @@ -658,14 +620,12 @@ BOOST_AUTO_TEST_CASE(ExtraData_content) { test_area.copyIn("RESTART_SIM.DATA"); Setup setup("BASE_SIM.DATA"); { - Action::State action_state; auto num_cells = setup.grid.getNumActive( ); auto cells = mkSolution( num_cells ); auto wells = mkWells(); - auto groups = mkGroups(); const auto& units = setup.es.getUnits(); { - RestartValue restart_value(cells, wells, groups); + RestartValue restart_value(cells, wells); SummaryState st(std::chrono::system_clock::now()); const auto sumState = sim_state(); @@ -686,7 +646,6 @@ BOOST_AUTO_TEST_CASE(ExtraData_content) { setup.es, setup.grid, setup.schedule, - action_state, sumState); } @@ -702,10 +661,10 @@ BOOST_AUTO_TEST_CASE(ExtraData_content) { BOOST_CHECK_CLOSE( units.from_si( UnitSystem::measure::pressure, 3), ex[3], 0.00001); } - BOOST_CHECK_THROW( RestartIO::load( rstFile , 1 , action_state, st, {}, setup.es, setup.grid , setup.schedule, + BOOST_CHECK_THROW( RestartIO::load( rstFile , 1 , st, {}, setup.es, setup.grid , setup.schedule, {{"NOT-THIS", UnitSystem::measure::identity, true}}) , std::runtime_error ); { - const auto rst_value = RestartIO::load(rstFile , 1 , action_state, st, + const auto rst_value = RestartIO::load(rstFile , 1 , st, /* solution_keys = */ { RestartKey("SWAT", UnitSystem::measure::identity), RestartKey("NO" , UnitSystem::measure::identity, false) @@ -741,11 +700,10 @@ BOOST_AUTO_TEST_CASE(STORE_THPRES) { auto num_cells = base_setup.grid.getNumActive( ); auto cells = mkSolution( num_cells ); auto wells = mkWells(); - auto groups = mkGroups(); const auto outputDir = test_area.currentWorkingDirectory(); { - RestartValue restart_value(cells, wells, groups); - RestartValue restart_value2(cells, wells, groups); + RestartValue restart_value(cells, wells); + RestartValue restart_value2(cells, wells); /* Missing THPRES data in extra container. */ /* Because it proved to difficult to update the legacy simulators @@ -762,7 +720,6 @@ BOOST_AUTO_TEST_CASE(STORE_THPRES) { restart_value.addExtra("THRESHPR", UnitSystem::measure::pressure, {0,1}); const auto sumState = sim_state(); - Action::State action_state; /* THPRES data has wrong size in extra container. */ { @@ -778,7 +735,6 @@ BOOST_AUTO_TEST_CASE(STORE_THPRES) { base_setup.es, base_setup.grid, base_setup.schedule, - action_state, sumState), std::runtime_error); } @@ -800,9 +756,7 @@ BOOST_AUTO_TEST_CASE(STORE_THPRES) { restart_value2, base_setup.es, base_setup.grid, - base_setup.schedule, - action_state, - sumState); + base_setup.schedule, sumState); } { @@ -845,8 +799,7 @@ BOOST_AUTO_TEST_CASE(Restore_Cumulatives) const auto restart_value = RestartValue { mkSolution(setup.grid.getNumActive()), - mkWells(), - mkGroups() + mkWells() }; const auto sumState = sim_state(); @@ -855,18 +808,16 @@ BOOST_AUTO_TEST_CASE(Restore_Cumulatives) const auto rset = OS::ResultSet{ wa.currentWorkingDirectory(), "FILE" }; const auto seqnum = 1; { - Action::State action_state; auto rstFile = OS::Restart { rset, seqnum, OS::Formatted{ false }, OS::Unified{ true } }; RestartIO::save(rstFile, seqnum, 100, restart_value, - setup.es, setup.grid, setup.schedule, action_state, sumState); + setup.es, setup.grid, setup.schedule, sumState); } - Action::State action_state; SummaryState rstSumState(std::chrono::system_clock::now()); - RestartIO::load(OS::outputFileName(rset, "UNRST"), seqnum, action_state, rstSumState, + RestartIO::load(OS::outputFileName(rset, "UNRST"), seqnum, rstSumState, /* solution_keys = */ { RestartKey("SWAT", UnitSystem::measure::identity), }, @@ -989,74 +940,4 @@ BOOST_AUTO_TEST_CASE(Restore_Cumulatives) } -BOOST_AUTO_TEST_CASE(UDQ_RESTART) { - std::vector keys {{"PRESSURE" , UnitSystem::measure::pressure}, - {"SWAT" , UnitSystem::measure::identity}, - {"SGAS" , UnitSystem::measure::identity}}; - WorkArea test_area("test_udq_restart"); - test_area.copyIn("UDQ_BASE.DATA"); - test_area.copyIn("UDQ_RESTART.DATA"); - - Setup base_setup("UDQ_BASE.DATA"); - SummaryState st1(std::chrono::system_clock::now()); - SummaryState st2(std::chrono::system_clock::now()); - Action::State action_state; - auto state1 = first_sim( base_setup , action_state, st1, false ); - - Setup restart_setup("UDQ_RESTART.DATA"); - auto state2 = second_sim( restart_setup , action_state, st2 , keys ); - BOOST_CHECK(st1.wells() == st2.wells()); - BOOST_CHECK(st1.groups() == st2.groups()); - - const auto& udq = base_setup.schedule.getUDQConfig(1); - for (const auto& well : st1.wells()) { - for (const auto& def : udq.definitions(UDQVarType::WELL_VAR)) { - const auto& kw = def.keyword(); - BOOST_CHECK_EQUAL( st1.has_well_var(well, kw), st2.has_well_var(well, kw)); - if (st1.has_well_var(well, def.keyword())) - BOOST_CHECK_EQUAL(st1.get_well_var(well, kw), st2.get_well_var(well, kw)); - } - } - - for (const auto& group : st1.groups()) { - for (const auto& def : udq.definitions(UDQVarType::GROUP_VAR)) { - const auto& kw = def.keyword(); - BOOST_CHECK_EQUAL( st1.has_group_var(group, kw), st2.has_group_var(group, kw)); - if (st1.has_group_var(group, def.keyword())) - BOOST_CHECK_EQUAL(st1.get_group_var(group, kw), st2.get_group_var(group, kw)); - } - } - - for (const auto& well : st1.wells()) { - for (const auto& def : udq.assignments(UDQVarType::WELL_VAR)) { - const auto& kw = def.keyword(); - BOOST_CHECK_EQUAL( st1.has_well_var(well, kw), st2.has_well_var(well, kw)); - if (st1.has_well_var(well, def.keyword())) - BOOST_CHECK_EQUAL(st1.get_well_var(well, kw), st2.get_well_var(well, kw)); - } - } - - for (const auto& group : st1.groups()) { - for (const auto& def : udq.assignments(UDQVarType::GROUP_VAR)) { - const auto& kw = def.keyword(); - BOOST_CHECK_EQUAL( st1.has_group_var(group, kw), st2.has_group_var(group, kw)); - if (st1.has_group_var(group, def.keyword())) - BOOST_CHECK_EQUAL(st1.get_group_var(group, kw), st2.get_group_var(group, kw)); - } - } - - for (const auto& def : udq.assignments(UDQVarType::FIELD_VAR)) { - const auto& kw = def.keyword(); - BOOST_CHECK_EQUAL( st1.has(kw), st2.has(kw)); - if (st1.has(kw)) - BOOST_CHECK_EQUAL(st1.get(kw), st2.get(kw)); - } - - for (const auto& def : udq.definitions(UDQVarType::FIELD_VAR)) { - const auto& kw = def.keyword(); - BOOST_CHECK_EQUAL( st1.has(kw), st2.has(kw)); - if (st1.has(kw)) - BOOST_CHECK_EQUAL(st1.get(kw), st2.get(kw)); - } -} } diff --git a/ThirdParty/custom-opm-common/opm-common/tests/test_Summary.cpp b/ThirdParty/custom-opm-common/opm-common/tests/test_Summary.cpp index c3d46052fd..c592074a42 100644 --- a/ThirdParty/custom-opm-common/opm-common/tests/test_Summary.cpp +++ b/ThirdParty/custom-opm-common/opm-common/tests/test_Summary.cpp @@ -31,8 +31,8 @@ #include #include -#include #include +#include #include #include @@ -89,7 +89,7 @@ static const int day = 24 * 60 * 60; This is quite misleading, because the values prepared in the test input deck are NOT used. */ -static data::Wells result_wells(const bool w3_injector = true) { +static data::Wells result_wells() { /* populate with the following pattern: * * Wells are named W_1, W_2 etc, i.e. wells are 1 indexed. @@ -122,8 +122,6 @@ static data::Wells result_wells(const bool w3_injector = true) { rates1.set( rt::well_potential_water, -10.13 / day ); rates1.set( rt::well_potential_oil, -10.14 / day ); rates1.set( rt::well_potential_gas, -10.15 / day ); - rates1.set( rt::polymer, -10.16 / day ); - rates1.set( rt::brine, -10.17 / day ); data::Rates rates2; rates2.set( rt::wat, -20.0 / day ); @@ -141,8 +139,6 @@ static data::Wells result_wells(const bool w3_injector = true) { rates2.set( rt::well_potential_water, -20.13 / day ); rates2.set( rt::well_potential_oil, -20.14 / day ); rates2.set( rt::well_potential_gas, -20.15 / day ); - rates2.set( rt::polymer, -20.16 / day ); - rates2.set( rt::brine, -20.17 / day ); data::Rates rates3; rates3.set( rt::wat, 30.0 / day ); @@ -160,8 +156,6 @@ static data::Wells result_wells(const bool w3_injector = true) { rates3.set( rt::well_potential_water, 30.13 / day ); rates3.set( rt::well_potential_oil, 30.14 / day ); rates3.set( rt::well_potential_gas, 30.15 / day ); - rates3.set( rt::polymer, 30.16 / day ); - rates3.set( rt::brine, 30.17 / day ); data::Rates rates6; @@ -180,8 +174,6 @@ static data::Wells result_wells(const bool w3_injector = true) { rates6.set( rt::well_potential_water, 60.13 / day ); rates6.set( rt::well_potential_oil, 60.14 / day ); rates6.set( rt::well_potential_gas, 60.15 / day ); - rates6.set( rt::polymer, 60.16 / day ); - rates6.set( rt::brine, 60.17 / day ); /* completion rates */ data::Rates crates1; crates1.set( rt::wat, -100.0 / day ); @@ -215,8 +207,6 @@ static data::Wells result_wells(const bool w3_injector = true) { crates3.set( rt::reservoir_water, 300.6 / day ); crates3.set( rt::reservoir_oil, 300.7 / day ); crates3.set( rt::reservoir_gas, 300.8 / day ); - crates3.set( rt::polymer, 300.16 / day ); - crates3.set( rt::brine, 300.17 / day ); data::Rates crates6; crates6.set( rt::wat, 600.0 / day ); @@ -269,13 +259,8 @@ static data::Wells result_wells(const bool w3_injector = true) { well2.current_control.prod = ::Opm::Well::ProducerCMode::ORAT; data::Well well3 { rates3, 2.1 * ps, 2.2 * ps, 2.3 * ps, 3, { {well3_comp1} }, SegRes{}, Ctrl{} }; - well3.current_control.isProducer = !w3_injector; - if (! well3.current_control.isProducer) { // W_3 is injector - well3.current_control.inj = ::Opm::Well::InjectorCMode::BHP; - } - else { - well3.current_control.prod = ::Opm::Well::ProducerCMode::BHP; - } + well3.current_control.isProducer = false; + well3.current_control.inj = ::Opm::Well::InjectorCMode::BHP; data::Well well6 { rates6, 2.1 * ps, 2.2 * ps, 2.3 * ps, 3, { {well6_comp1} }, SegRes{}, Ctrl{} }; well6.current_control.isProducer = false; @@ -294,22 +279,22 @@ static data::Wells result_wells(const bool w3_injector = true) { return wellrates; } -static data::GroupValues result_groups() { +static data::Group result_groups() { - data::GroupValues groups; - data::GroupConstraints cgc_group; + data::Group groups; + data::currentGroupConstraints cgc_group; cgc_group.set(p_cmode::NONE, i_cmode::VREP, i_cmode::RATE); - groups["G_1"].currentControl = cgc_group; + groups.emplace("G_1", cgc_group); cgc_group.set(p_cmode::ORAT, i_cmode::RESV, i_cmode::FLD); - groups["G_2"].currentControl = cgc_group; + groups.emplace("G_2", cgc_group); cgc_group.set(p_cmode::GRAT, i_cmode::REIN, i_cmode::VREP); - groups["G_3"].currentControl = cgc_group; + groups.emplace("G_3", cgc_group); cgc_group.set(p_cmode::NONE, i_cmode::NONE, i_cmode::NONE); - groups["FIELD"].currentControl = cgc_group; + groups.emplace("FIELD", cgc_group); return groups; @@ -394,20 +379,20 @@ struct setup { Schedule schedule; SummaryConfig config; data::Wells wells; - data::GroupValues groups; + data::Group groups; std::string name; WorkArea ta; /*-----------------------------------------------------------------*/ - setup(std::string fname, const std::string& path = "summary_deck.DATA", const bool w3_injector = true) : + setup(std::string fname, const std::string& path = "summary_deck.DATA") : deck( Parser().parseFile( path) ), es( deck ), grid( es.getInputGrid() ), python( std::make_shared() ), schedule( deck, es, python), config( deck, schedule, es.getTableManager()), - wells( result_wells(w3_injector) ), + wells( result_wells() ), groups( result_groups() ), name( toupper(std::move(fname)) ), ta( "summary_test" ) @@ -464,8 +449,7 @@ BOOST_AUTO_TEST_CASE(well_keywords) { BOOST_CHECK_CLOSE( 20.0 + 20.1, ecl_sum_get_well_var( resp, 1, "W_2", "WLPR" ), 1e-5 ); BOOST_CHECK_CLOSE( 10.3, ecl_sum_get_well_var( resp, 1, "W_1", "WNPR" ), 1e-5 ); BOOST_CHECK_CLOSE( 20.3, ecl_sum_get_well_var( resp, 1, "W_2", "WNPR" ), 1e-5 ); - BOOST_CHECK_CLOSE( 10.16, ecl_sum_get_well_var( resp, 1, "W_1", "WCPR" ), 1e-5 ); - BOOST_CHECK_CLOSE( 10.17, ecl_sum_get_well_var( resp, 1, "W_1", "WSPR" ), 1e-5 ); + BOOST_CHECK_CLOSE( 10.4, ecl_sum_get_well_var( resp, 1, "W_1", "WGPRS" ), 1e-5 ); BOOST_CHECK_CLOSE( 20.4, ecl_sum_get_well_var( resp, 1, "W_2", "WGPRS" ), 1e-5 ); BOOST_CHECK_CLOSE( 10.2 - 10.4, ecl_sum_get_well_var( resp, 1, "W_1", "WGPRF" ), 1e-5 ); @@ -533,8 +517,6 @@ BOOST_AUTO_TEST_CASE(well_keywords) { ecl_sum_get_well_var( resp, 2, "W_1", "WVPT" ), 1e-5 ); BOOST_CHECK_CLOSE( 2 * (20.6 + 20.7 + 20.8), ecl_sum_get_well_var( resp, 2, "W_2", "WVPT" ), 1e-5 ); - BOOST_CHECK_CLOSE( 2 * 10.16, ecl_sum_get_well_var( resp, 2, "W_1", "WCPT" ), 1e-5 ); - BOOST_CHECK_CLOSE( 2 * 10.17, ecl_sum_get_well_var( resp, 2, "W_1", "WSPT" ), 1e-5 ); /* Production rates (history) */ BOOST_CHECK_CLOSE( 10, ecl_sum_get_well_var( resp, 1, "W_1", "WWPRH" ), 1e-5 ); @@ -558,21 +540,20 @@ BOOST_AUTO_TEST_CASE(well_keywords) { BOOST_CHECK_CLOSE( 30.8, ecl_sum_get_well_var( resp, 1, "W_3", "WGVIR" ), 1e-5 ); BOOST_CHECK_CLOSE( 30.2, ecl_sum_get_well_var( resp, 1, "W_3", "WGIR" ), 1e-5 ); BOOST_CHECK_CLOSE( 30.3, ecl_sum_get_well_var( resp, 1, "W_3", "WNIR" ), 1e-5 ); - BOOST_CHECK_CLOSE( 30.16, ecl_sum_get_well_var( resp, 1, "W_3", "WCIR" ), 1e-5 ); - BOOST_CHECK_CLOSE( 30.17, ecl_sum_get_well_var( resp, 1, "W_3", "WSIR" ), 1e-5 ); + BOOST_CHECK_CLOSE( 30.0 * 1.5, ecl_sum_get_well_var( resp, 1, "W_3", "WCIR" ), 1e-5 ); + BOOST_CHECK_CLOSE( 30.0 * 2.5, ecl_sum_get_well_var( resp, 2, "W_3", "WCIR" ), 1e-5 ); /* Injection totals */ BOOST_CHECK_CLOSE( 30.0, ecl_sum_get_well_var( resp, 1, "W_3", "WWIT" ), 1e-5 ); BOOST_CHECK_CLOSE( 30.2, ecl_sum_get_well_var( resp, 1, "W_3", "WGIT" ), 1e-5 ); BOOST_CHECK_CLOSE( 30.3, ecl_sum_get_well_var( resp, 1, "W_3", "WNIT" ), 1e-5 ); - BOOST_CHECK_CLOSE( 30.16, ecl_sum_get_well_var( resp, 1, "W_3", "WCIT" ), 1e-5 ); + BOOST_CHECK_CLOSE( 30.0 * 1.5, ecl_sum_get_well_var( resp, 1, "W_3", "WCIT" ), 1e-5 ); BOOST_CHECK_CLOSE( (30.6 + 30.7 + 30.8), ecl_sum_get_well_var( resp, 1, "W_3", "WVIT" ), 1e-5 ); BOOST_CHECK_CLOSE( 2 * 30.0, ecl_sum_get_well_var( resp, 2, "W_3", "WWIT" ), 1e-5 ); BOOST_CHECK_CLOSE( 2 * 30.2, ecl_sum_get_well_var( resp, 2, "W_3", "WGIT" ), 1e-5 ); BOOST_CHECK_CLOSE( 2 * 30.3, ecl_sum_get_well_var( resp, 2, "W_3", "WNIT" ), 1e-5 ); - BOOST_CHECK_CLOSE( 2 * 30.16, ecl_sum_get_well_var( resp, 2, "W_3", "WCIT" ), 1e-5 ); - BOOST_CHECK_CLOSE( 2 * 30.17, ecl_sum_get_well_var( resp, 2, "W_3", "WSIT" ), 1e-5 ); + BOOST_CHECK_CLOSE( 30.0 * 1.5 + 30.0 * 2.5, ecl_sum_get_well_var( resp, 2, "W_3", "WCIT" ), 1e-5 ); BOOST_CHECK_CLOSE( 2* (30.6 + 30.7 + 30.8), ecl_sum_get_well_var( resp, 2, "W_3", "WVIT" ), 1e-5 ); @@ -709,9 +690,6 @@ BOOST_AUTO_TEST_CASE(group_keywords) { BOOST_CHECK_CLOSE( 30.13 + 60.13, ecl_sum_get_group_var( resp, 1, "G_2", "GWPI" ), 1e-5 ); BOOST_CHECK_CLOSE( 30.15 + 60.15, ecl_sum_get_group_var( resp, 1, "G_2", "GGPI" ), 1e-5 ); - BOOST_CHECK_CLOSE( 10.16 + 20.16, ecl_sum_get_group_var( resp, 1, "G_1", "GCPR" ), 1e-5 ); - BOOST_CHECK_CLOSE( 10.17 + 20.17, ecl_sum_get_group_var( resp, 1, "G_1", "GSPR" ), 1e-5 ); - /* Production totals */ BOOST_CHECK_CLOSE( 10.0 + 20.0, ecl_sum_get_group_var( resp, 1, "G_1", "GWPT" ), 1e-5 ); BOOST_CHECK_CLOSE( 10.1 + 20.1, ecl_sum_get_group_var( resp, 1, "G_1", "GOPT" ), 1e-5 ); @@ -723,7 +701,6 @@ BOOST_AUTO_TEST_CASE(group_keywords) { BOOST_CHECK_CLOSE( (10.2 - 10.4) + (20.2 - 20.4), ecl_sum_get_group_var( resp, 1, "G_1", "GGPTF" ), 1e-5 ); BOOST_CHECK_CLOSE( 10.6 + 10.7 + 10.8 + 20.6 + 20.7 + 20.8, ecl_sum_get_group_var( resp, 1, "G_1", "GVPT" ), 1e-5 ); - BOOST_CHECK_CLOSE( 10.16 + 20.16, ecl_sum_get_group_var( resp, 1, "G_1", "GCPT" ), 1e-5 ); BOOST_CHECK_CLOSE( 2 * (10.0 + 20.0), ecl_sum_get_group_var( resp, 2, "G_1", "GWPT" ), 1e-5 ); BOOST_CHECK_CLOSE( 2 * (10.1 + 20.1), ecl_sum_get_group_var( resp, 2, "G_1", "GOPT" ), 1e-5 ); BOOST_CHECK_CLOSE( 2 * (10.2 + 20.2), ecl_sum_get_group_var( resp, 2, "G_1", "GGPT" ), 1e-5 ); @@ -734,7 +711,7 @@ BOOST_AUTO_TEST_CASE(group_keywords) { BOOST_CHECK_CLOSE( 2 * ((10.1 - 10.5) + (20.1 - 20.5)), ecl_sum_get_group_var( resp, 2, "G_1", "GOPTF" ), 1e-5 ); BOOST_CHECK_CLOSE( 2 * (10.6 + 10.7 + 10.8 + 20.6 + 20.7 + 20.8), ecl_sum_get_group_var( resp, 2, "G_1", "GVPT" ), 1e-5 ); - BOOST_CHECK_CLOSE( 2 * (10.16 + 20.16), ecl_sum_get_group_var( resp, 2, "G_1", "GCPT" ), 1e-5 ); + /* Production rates (history) */ BOOST_CHECK_CLOSE( 10.0 + 20.0, ecl_sum_get_group_var( resp, 1, "G_1", "GWPRH" ), 1e-5 ); BOOST_CHECK_CLOSE( 10.1 + 20.1, ecl_sum_get_group_var( resp, 1, "G_1", "GOPRH" ), 1e-5 ); @@ -760,8 +737,8 @@ BOOST_AUTO_TEST_CASE(group_keywords) { BOOST_CHECK_CLOSE( 30.0 + 60.0, ecl_sum_get_group_var( resp, 1, "G_2", "GWIR" ), 1e-5 ); BOOST_CHECK_CLOSE( 30.2 + 60.2, ecl_sum_get_group_var( resp, 1, "G_2", "GGIR" ), 1e-5 ); BOOST_CHECK_CLOSE( 30.3 + 60.3, ecl_sum_get_group_var( resp, 1, "G_2", "GNIR" ), 1e-5 ); - BOOST_CHECK_CLOSE( 30.16 + 60.16, ecl_sum_get_group_var( resp, 1, "G_2", "GCIR" ), 1e-5 ); - BOOST_CHECK_CLOSE( 30.17 + 60.17, ecl_sum_get_group_var( resp, 1, "G_2", "GSIR" ), 1e-5 ); + BOOST_CHECK_CLOSE( 30.0 * 1.5, ecl_sum_get_group_var( resp, 1, "G_2", "GCIR" ), 1e-5 ); + BOOST_CHECK_CLOSE( 30.0 * 2.5, ecl_sum_get_group_var( resp, 2, "G_2", "GCIR" ), 1e-5 ); BOOST_CHECK_CLOSE( (30.6 + 30.7 + 30.8 + 60.6 + 60.7 + 60.8), ecl_sum_get_group_var( resp, 1, "G_2", "GVIR" ), 1e-5 ); @@ -769,14 +746,13 @@ BOOST_AUTO_TEST_CASE(group_keywords) { BOOST_CHECK_CLOSE( 30.0 + 60.0, ecl_sum_get_group_var( resp, 1, "G_2", "GWIT" ), 1e-5 ); BOOST_CHECK_CLOSE( 30.2 + 60.2, ecl_sum_get_group_var( resp, 1, "G_2", "GGIT" ), 1e-5 ); BOOST_CHECK_CLOSE( 30.3 + 60.3, ecl_sum_get_group_var( resp, 1, "G_2", "GNIT" ), 1e-5 ); - BOOST_CHECK_CLOSE( 30.16 + 60.16, ecl_sum_get_group_var( resp, 1, "G_2", "GCIT" ), 1e-5 ); + BOOST_CHECK_CLOSE( 30.0 * 1.5, ecl_sum_get_group_var( resp, 1, "G_2", "GCIT" ), 1e-5 ); BOOST_CHECK_CLOSE( (30.6 + 30.7 + 30.8 + 60.6 + 60.7 + 60.8), ecl_sum_get_group_var( resp, 1, "G_2", "GVIT" ), 1e-5 ); BOOST_CHECK_CLOSE( 2 * (30.0 + 60.0), ecl_sum_get_group_var( resp, 2, "G_2", "GWIT" ), 1e-5 ); BOOST_CHECK_CLOSE( 2 * (30.2 + 60.2), ecl_sum_get_group_var( resp, 2, "G_2", "GGIT" ), 1e-5 ); BOOST_CHECK_CLOSE( 2 * (30.3 + 60.3), ecl_sum_get_group_var( resp, 2, "G_2", "GNIT" ), 1e-5 ); - BOOST_CHECK_CLOSE( 2 * (30.16 + 60.16), ecl_sum_get_group_var( resp, 2, "G_2", "GCIT" ), 1e-5 ); - BOOST_CHECK_CLOSE( 2 * (30.17 + 60.17), ecl_sum_get_group_var( resp, 2, "G_2", "GSIT" ), 1e-5 ); + BOOST_CHECK_CLOSE( 30.0 * 1.5 + 30.0 * 2.5, ecl_sum_get_group_var( resp, 2, "G_2", "GCIT" ), 1e-5 ); BOOST_CHECK_CLOSE( 2 * (30.6 + 30.7 + 30.8 + 60.6 + 60.7 + 60.8), ecl_sum_get_group_var( resp, 2, "G_2", "GVIT" ), 1e-5 ); @@ -917,17 +893,18 @@ BOOST_AUTO_TEST_CASE(completion_kewords) { /* Injection rates */ BOOST_CHECK_CLOSE( 300.0, ecl_sum_get_well_completion_var( resp, 1, "W_3", "CWIR", 3, 1, 1 ), 1e-5 ); BOOST_CHECK_CLOSE( 300.2, ecl_sum_get_well_completion_var( resp, 1, "W_3", "CGIR", 3, 1, 1 ), 1e-5 ); - BOOST_CHECK_CLOSE( 300.16, ecl_sum_get_well_completion_var( resp, 1, "W_3", "CCIR", 3, 1, 1 ), 1e-5 ); + BOOST_CHECK_CLOSE( 300.0 * 1.5, ecl_sum_get_well_completion_var( resp, 1, "W_3", "CCIR", 3, 1, 1 ), 1e-5 ); + BOOST_CHECK_CLOSE( 300.0 * 2.5, ecl_sum_get_well_completion_var( resp, 2, "W_3", "CCIR", 3, 1, 1 ), 1e-5 ); /* Injection totals */ BOOST_CHECK_CLOSE( 300.0, ecl_sum_get_well_completion_var( resp, 1, "W_3", "CWIT", 3, 1, 1 ), 1e-5 ); BOOST_CHECK_CLOSE( 300.2, ecl_sum_get_well_completion_var( resp, 1, "W_3", "CGIT", 3, 1, 1 ), 1e-5 ); BOOST_CHECK_CLOSE( 300.3, ecl_sum_get_well_completion_var( resp, 1, "W_3", "CNIT", 3, 1, 1 ), 1e-5 ); - BOOST_CHECK_CLOSE( 300.16, ecl_sum_get_well_completion_var( resp, 1, "W_3", "CCIT", 3, 1, 1 ), 1e-5 ); + BOOST_CHECK_CLOSE( 300.0 * 1.5, ecl_sum_get_well_completion_var( resp, 1, "W_3", "CCIT", 3, 1, 1 ), 1e-5 ); BOOST_CHECK_CLOSE( 2 * 300.0, ecl_sum_get_well_completion_var( resp, 2, "W_3", "CWIT", 3, 1, 1 ), 1e-5 ); BOOST_CHECK_CLOSE( 2 * 300.2, ecl_sum_get_well_completion_var( resp, 2, "W_3", "CGIT", 3, 1, 1 ), 1e-5 ); BOOST_CHECK_CLOSE( 2 * 300.3, ecl_sum_get_well_completion_var( resp, 2, "W_3", "CNIT", 3, 1, 1 ), 1e-5 ); - BOOST_CHECK_CLOSE( 2 * 300.16, + BOOST_CHECK_CLOSE( 300.0 * 1.5 + 300.0 * 2.5, ecl_sum_get_well_completion_var( resp, 2, "W_3", "CCIT", 3, 1, 1 ), 1e-5 ); /* Solvent flow rate + or - Note OPM uses negative values for producers, while CNFR outputs positive @@ -1012,9 +989,6 @@ BOOST_AUTO_TEST_CASE(field_keywords) { BOOST_CHECK_CLOSE( 30.15 + 60.15, ecl_sum_get_field_var( resp, 1, "FGPI" ), 1e-5 ); BOOST_CHECK_CLOSE( 30.13 + 60.13, ecl_sum_get_field_var( resp, 1, "FWPI" ), 1e-5 ); - BOOST_CHECK_CLOSE( 10.16 + 20.16, ecl_sum_get_field_var( resp, 1, "FCPR" ), 1e-5 ); - BOOST_CHECK_CLOSE( 10.17 + 20.17, ecl_sum_get_field_var( resp, 1, "FSPR" ), 1e-5 ); - /* Production totals */ BOOST_CHECK_CLOSE( 10.0 + 20.0, ecl_sum_get_field_var( resp, 1, "FWPT" ), 1e-5 ); BOOST_CHECK_CLOSE( 10.1 + 20.1, ecl_sum_get_field_var( resp, 1, "FOPT" ), 1e-5 ); @@ -1048,9 +1022,6 @@ BOOST_AUTO_TEST_CASE(field_keywords) { BOOST_CHECK_CLOSE( 2 * (10.1 - 10.5 + 20.1 - 20.5), ecl_sum_get_field_var( resp, 2, "FOPTF" ), 1e-5 ); - BOOST_CHECK_CLOSE( 2 * (10.16 + 20.16), ecl_sum_get_field_var( resp, 2, "FCPT" ), 1e-5 ); - BOOST_CHECK_CLOSE( 2 * (10.17 + 20.17), ecl_sum_get_field_var( resp, 2, "FSPT" ), 1e-5 ); - /* Production rates (history) */ BOOST_CHECK_CLOSE( 10.0 + 20.0, ecl_sum_get_field_var( resp, 1, "FWPRH" ), 1e-5 ); BOOST_CHECK_CLOSE( 10.1 + 20.1, ecl_sum_get_field_var( resp, 1, "FOPRH" ), 1e-5 ); @@ -1075,20 +1046,19 @@ BOOST_AUTO_TEST_CASE(field_keywords) { BOOST_CHECK_CLOSE( 30.0 + 60., ecl_sum_get_field_var( resp, 1, "FWIR" ), 1e-5 ); BOOST_CHECK_CLOSE( 30.2 + 60.2, ecl_sum_get_field_var( resp, 1, "FGIR" ), 1e-5 ); BOOST_CHECK_CLOSE( 30.6 + 30.7 + 30.8 + 60.6 + 60.7 + 60.8, ecl_sum_get_field_var( resp, 1, "FVIR" ), 1e-5 ); - BOOST_CHECK_CLOSE( 30.16 + 60.16, ecl_sum_get_field_var( resp, 1, "FCIR" ), 1e-5 ); - BOOST_CHECK_CLOSE( 30.17 + 60.17, ecl_sum_get_field_var( resp, 1, "FSIR" ), 1e-5 ); + BOOST_CHECK_CLOSE( 30.0 * 1.5, ecl_sum_get_field_var( resp, 1, "FCIR" ), 1e-5 ); + BOOST_CHECK_CLOSE( 30.0 * 2.5, ecl_sum_get_field_var( resp, 2, "FCIR" ), 1e-5 ); /* Injection totals */ BOOST_CHECK_CLOSE( 30.0 + 60., ecl_sum_get_field_var( resp, 1, "FWIT" ), 1e-5 ); BOOST_CHECK_CLOSE( 30.2 + 60.2, ecl_sum_get_field_var( resp, 1, "FGIT" ), 1e-5 ); BOOST_CHECK_CLOSE( 30.6 + 30.7 + 30.8 + 60.6 + 60.7 + 60.8, ecl_sum_get_field_var( resp, 1, "FVIT" ), 1e-5 ); - BOOST_CHECK_CLOSE( 30.16 + 60.16, ecl_sum_get_field_var( resp, 1, "FCIT" ), 1e-5 ); + BOOST_CHECK_CLOSE( 30.0 * 1.5, ecl_sum_get_field_var( resp, 1, "FCIT" ), 1e-5 ); BOOST_CHECK_CLOSE( 2 * (30.0 + 60.0), ecl_sum_get_field_var( resp, 2, "FWIT" ), 1e-5 ); BOOST_CHECK_CLOSE( 2 * (30.2 + 60.2), ecl_sum_get_field_var( resp, 2, "FGIT" ), 1e-5 ); BOOST_CHECK_CLOSE( 2 * (30.6 + 30.7 + 30.8 + 60.6 + 60.7 + 60.8), ecl_sum_get_field_var( resp, 2, "FVIT" ), 1e-5 ); - BOOST_CHECK_CLOSE( 2 * (30.16 + 60.16), ecl_sum_get_field_var( resp, 2, "FCIT" ), 1e-5 ); - BOOST_CHECK_CLOSE( 2 * (30.17 + 60.17), ecl_sum_get_field_var( resp, 2, "FSIT" ), 1e-5 ); + BOOST_CHECK_CLOSE( 30.0 * 1.5 + 30.0 * 2.5, ecl_sum_get_field_var( resp, 2, "FCIT" ), 1e-5 ); /* Injection totals (history) */ BOOST_CHECK_CLOSE( 30.0, ecl_sum_get_field_var( resp, 1, "FWITH" ), 1e-5 ); @@ -1609,34 +1579,8 @@ BOOST_AUTO_TEST_CASE(READ_WRITE_WELLDATA) { BOOST_CHECK_MESSAGE(curr.inj == ::Opm::Well::InjectorCMode::GRUP, "W_6 must be on GRUP control"); } -// Well/group tree structure (SUMMARY_EFF_FAC.DATA): -// -// W* are wells, G* are groups. -// -// +-------+ -// | FIELD | -// +---+---+ -// | -// +----------+-----------------+ -// | | -// +----+---+ +----+---+ -// | G | | G_4 | -// +----+---+ +----+---+ -// | | -// +--------+----------+ +----+---+ -// | | | G_3 | -// +----+---+ +----+---+ +----+---+ -// | G_1 | | G_2 | | -// +----+---+ +----+---+ +----+---+ -// | | | W_3 | -// +----+---+ +----+---+ +----+---+ -// | W_1 | | W_2 | -// +----+---+ +----+---+ -// - BOOST_AUTO_TEST_CASE(efficiency_factor) { - // W_3 is a producer in SUMMARY_EFF_FAC.DATA - setup cfg( "test_efficiency_factor", "SUMMARY_EFF_FAC.DATA", false ); + setup cfg( "test_efficiency_factor", "SUMMARY_EFF_FAC.DATA" ); out::Summary writer( cfg.es, cfg.config, cfg.grid, cfg.schedule, cfg.name ); SummaryState st(std::chrono::system_clock::now()); @@ -1655,48 +1599,12 @@ BOOST_AUTO_TEST_CASE(efficiency_factor) { BOOST_CHECK_CLOSE( 10.1, ecl_sum_get_well_var( resp, 1, "W_1", "WOPT" ), 1e-5 ); BOOST_CHECK_CLOSE( 2 * 10.1, ecl_sum_get_well_var( resp, 2, "W_1", "WOPT" ), 1e-5 ); - BOOST_CHECK_CLOSE( -10.13, ecl_sum_get_group_var( resp, 1, "G_1", "GWPP" ), 1e-5 ); - BOOST_CHECK_CLOSE( -10.14, ecl_sum_get_group_var( resp, 1, "G_1", "GOPP" ), 1e-5 ); - BOOST_CHECK_CLOSE( -10.15, ecl_sum_get_group_var( resp, 1, "G_1", "GGPP" ), 1e-5 ); - BOOST_CHECK_CLOSE( 0.0 , ecl_sum_get_group_var( resp, 1, "G_1", "GWPI" ), 1e-5 ); - BOOST_CHECK_CLOSE( 0.0 , ecl_sum_get_group_var( resp, 1, "G_1", "GGPI" ), 1e-5 ); - - BOOST_CHECK_CLOSE( -10.13, ecl_sum_get_group_var( resp, 2, "G_1", "GWPP" ), 1e-5 ); - BOOST_CHECK_CLOSE( -10.14, ecl_sum_get_group_var( resp, 2, "G_1", "GOPP" ), 1e-5 ); - BOOST_CHECK_CLOSE( -10.15, ecl_sum_get_group_var( resp, 2, "G_1", "GGPP" ), 1e-5 ); - BOOST_CHECK_CLOSE( 0.0 , ecl_sum_get_group_var( resp, 2, "G_1", "GWPI" ), 1e-5 ); - BOOST_CHECK_CLOSE( 0.0 , ecl_sum_get_group_var( resp, 2, "G_1", "GGPI" ), 1e-5 ); - /* WEFAC 0.2 assigned to W_2. * W_2 assigned to group G2. GEFAC G2 = 0.01 */ BOOST_CHECK_CLOSE( 20.1, ecl_sum_get_well_var( resp, 1, "W_2", "WOPR" ), 1e-5 ); BOOST_CHECK_CLOSE( 20.1 * 0.2 * 0.01, ecl_sum_get_well_var( resp, 1, "W_2", "WOPT" ), 1e-5 ); BOOST_CHECK_CLOSE( 2 * 20.1 * 0.2 * 0.01, ecl_sum_get_well_var( resp, 2, "W_2", "WOPT" ), 1e-5 ); - BOOST_CHECK_CLOSE( -20.13 * 0.2, ecl_sum_get_group_var( resp, 1, "G_2", "GWPP" ), 1e-5 ); - BOOST_CHECK_CLOSE( -20.14 * 0.2, ecl_sum_get_group_var( resp, 1, "G_2", "GOPP" ), 1e-5 ); - BOOST_CHECK_CLOSE( -20.15 * 0.2, ecl_sum_get_group_var( resp, 1, "G_2", "GGPP" ), 1e-5 ); - BOOST_CHECK_CLOSE( 0.0 , ecl_sum_get_group_var( resp, 1, "G_2", "GWPI" ), 1e-5 ); - BOOST_CHECK_CLOSE( 0.0 , ecl_sum_get_group_var( resp, 1, "G_2", "GGPI" ), 1e-5 ); - - BOOST_CHECK_CLOSE( -10.13 - (20.13 * 0.2 * 0.01), ecl_sum_get_group_var( resp, 1, "G", "GWPP" ), 1e-5 ); - BOOST_CHECK_CLOSE( -10.14 - (20.14 * 0.2 * 0.01), ecl_sum_get_group_var( resp, 1, "G", "GOPP" ), 1e-5 ); - BOOST_CHECK_CLOSE( -10.15 - (20.15 * 0.2 * 0.01), ecl_sum_get_group_var( resp, 1, "G", "GGPP" ), 1e-5 ); - BOOST_CHECK_CLOSE( 0.0 , ecl_sum_get_group_var( resp, 1, "G", "GWPI" ), 1e-5 ); - BOOST_CHECK_CLOSE( 0.0 , ecl_sum_get_group_var( resp, 1, "G", "GGPI" ), 1e-5 ); - - BOOST_CHECK_CLOSE( -20.13 * 0.2, ecl_sum_get_group_var( resp, 2, "G_2", "GWPP" ), 1e-5 ); - BOOST_CHECK_CLOSE( -20.14 * 0.2, ecl_sum_get_group_var( resp, 2, "G_2", "GOPP" ), 1e-5 ); - BOOST_CHECK_CLOSE( -20.15 * 0.2, ecl_sum_get_group_var( resp, 2, "G_2", "GGPP" ), 1e-5 ); - BOOST_CHECK_CLOSE( 0.0 , ecl_sum_get_group_var( resp, 2, "G_2", "GWPI" ), 1e-5 ); - BOOST_CHECK_CLOSE( 0.0 , ecl_sum_get_group_var( resp, 2, "G_2", "GGPI" ), 1e-5 ); - - BOOST_CHECK_CLOSE( -10.13 - (20.13 * 0.2 * 0.01), ecl_sum_get_group_var( resp, 2, "G", "GWPP" ), 1e-5 ); - BOOST_CHECK_CLOSE( -10.14 - (20.14 * 0.2 * 0.01), ecl_sum_get_group_var( resp, 2, "G", "GOPP" ), 1e-5 ); - BOOST_CHECK_CLOSE( -10.15 - (20.15 * 0.2 * 0.01), ecl_sum_get_group_var( resp, 2, "G", "GGPP" ), 1e-5 ); - BOOST_CHECK_CLOSE( 0.0 , ecl_sum_get_group_var( resp, 2, "G", "GWPI" ), 1e-5 ); - BOOST_CHECK_CLOSE( 0.0 , ecl_sum_get_group_var( resp, 2, "G", "GGPI" ), 1e-5 ); - /* WEFAC 0.3 assigned to W_3. * W_3 assigned to group G3. GEFAC G_3 = 0.02 * G_3 assigned to group G4. GEFAC G_4 = 0.03*/ @@ -1704,54 +1612,6 @@ BOOST_AUTO_TEST_CASE(efficiency_factor) { BOOST_CHECK_CLOSE( 30.1 * 0.3 * 0.02 * 0.03, ecl_sum_get_well_var( resp, 1, "W_3", "WOIT" ), 1e-5 ); BOOST_CHECK_CLOSE( 30.1 * 0.3 * 0.02 * 0.03 + 30.1 * 0.3 * 0.02 * 0.04, ecl_sum_get_well_var( resp, 2, "W_3", "WOIT" ), 1e-5 ); - BOOST_CHECK_CLOSE( 30.13 * 0.3, ecl_sum_get_group_var( resp, 1, "G_3", "GWPP" ), 1e-5 ); - BOOST_CHECK_CLOSE( 30.14 * 0.3, ecl_sum_get_group_var( resp, 1, "G_3", "GOPP" ), 1e-5 ); - BOOST_CHECK_CLOSE( 30.15 * 0.3, ecl_sum_get_group_var( resp, 1, "G_3", "GGPP" ), 1e-5 ); - BOOST_CHECK_CLOSE( 0.0 , ecl_sum_get_group_var( resp, 1, "G_3", "GWPI" ), 1e-5 ); - BOOST_CHECK_CLOSE( 0.0 , ecl_sum_get_group_var( resp, 1, "G_3", "GGPI" ), 1e-5 ); - - BOOST_CHECK_CLOSE( 30.13 * 0.3 * 0.02, ecl_sum_get_group_var( resp, 1, "G_4", "GWPP" ), 1e-5 ); - BOOST_CHECK_CLOSE( 30.14 * 0.3 * 0.02, ecl_sum_get_group_var( resp, 1, "G_4", "GOPP" ), 1e-5 ); - BOOST_CHECK_CLOSE( 30.15 * 0.3 * 0.02, ecl_sum_get_group_var( resp, 1, "G_4", "GGPP" ), 1e-5 ); - BOOST_CHECK_CLOSE( 0.0 , ecl_sum_get_group_var( resp, 1, "G_4", "GWPI" ), 1e-5 ); - BOOST_CHECK_CLOSE( 0.0 , ecl_sum_get_group_var( resp, 1, "G_4", "GGPI" ), 1e-5 ); - - BOOST_CHECK_CLOSE( 30.13 * 0.3, ecl_sum_get_group_var( resp, 2, "G_3", "GWPP" ), 1e-5 ); - BOOST_CHECK_CLOSE( 30.14 * 0.3, ecl_sum_get_group_var( resp, 2, "G_3", "GOPP" ), 1e-5 ); - BOOST_CHECK_CLOSE( 30.15 * 0.3, ecl_sum_get_group_var( resp, 2, "G_3", "GGPP" ), 1e-5 ); - BOOST_CHECK_CLOSE( 0.0 , ecl_sum_get_group_var( resp, 2, "G_3", "GWPI" ), 1e-5 ); - BOOST_CHECK_CLOSE( 0.0 , ecl_sum_get_group_var( resp, 2, "G_3", "GGPI" ), 1e-5 ); - - BOOST_CHECK_CLOSE( 30.13 * 0.3 * 0.02, ecl_sum_get_group_var( resp, 2, "G_4", "GWPP" ), 1e-5 ); - BOOST_CHECK_CLOSE( 30.14 * 0.3 * 0.02, ecl_sum_get_group_var( resp, 2, "G_4", "GOPP" ), 1e-5 ); - BOOST_CHECK_CLOSE( 30.15 * 0.3 * 0.02, ecl_sum_get_group_var( resp, 2, "G_4", "GGPP" ), 1e-5 ); - BOOST_CHECK_CLOSE( 0.0 , ecl_sum_get_group_var( resp, 2, "G_4", "GWPI" ), 1e-5 ); - BOOST_CHECK_CLOSE( 0.0 , ecl_sum_get_group_var( resp, 2, "G_4", "GGPI" ), 1e-5 ); - - BOOST_CHECK_CLOSE( - 10.13 - - (20.13 * 0.2 * 0.01) - + (30.13 * 0.3 * 0.02)*0.03, ecl_sum_get_field_var( resp, 1, "FWPP" ), 1e-5 ); - BOOST_CHECK_CLOSE( - 10.14 - - (20.14 * 0.2 * 0.01) - + (30.14 * 0.3 * 0.02)*0.03, ecl_sum_get_field_var( resp, 1, "FOPP" ), 1e-5 ); - BOOST_CHECK_CLOSE( - 10.15 - - (20.15 * 0.2 * 0.01) - + (30.15 * 0.3 * 0.02)*0.03, ecl_sum_get_field_var( resp, 1, "FGPP" ), 1e-5 ); - BOOST_CHECK_CLOSE( 0.0 , ecl_sum_get_field_var( resp, 1, "FWPI" ), 1e-5 ); - BOOST_CHECK_CLOSE( 0.0 , ecl_sum_get_field_var( resp, 1, "FGPI" ), 1e-5 ); - - BOOST_CHECK_CLOSE( - 10.13 - - (20.13 * 0.2 * 0.01) - + (30.13 * 0.3 * 0.02)*0.04, ecl_sum_get_field_var( resp, 2, "FWPP" ), 1e-5 ); - BOOST_CHECK_CLOSE( - 10.14 - - (20.14 * 0.2 * 0.01) - + (30.14 * 0.3 * 0.02)*0.04, ecl_sum_get_field_var( resp, 2, "FOPP" ), 1e-5 ); - BOOST_CHECK_CLOSE( - 10.15 - - (20.15 * 0.2 * 0.01) - + (30.15 * 0.3 * 0.02)*0.04, ecl_sum_get_field_var( resp, 2, "FGPP" ), 1e-5 ); - BOOST_CHECK_CLOSE( 0.0 , ecl_sum_get_field_var( resp, 2, "FWPI" ), 1e-5 ); - BOOST_CHECK_CLOSE( 0.0 , ecl_sum_get_field_var( resp, 2, "FGPI" ), 1e-5 ); - /* WEFAC 0.2 assigned to W_2. * W_2 assigned to group G2. GEFAC G2 = 0.01 */ BOOST_CHECK_CLOSE( 20.1 * 0.2, ecl_sum_get_group_var( resp, 1, "G_2", "GOPR" ), 1e-5 ); @@ -1801,7 +1661,7 @@ BOOST_AUTO_TEST_CASE(Test_SummaryState) { BOOST_CHECK_THROW(st.get("NO_SUCH_KEY"), std::out_of_range); BOOST_CHECK(st.has("WWCT:OP_2")); BOOST_CHECK(!st.has("NO_SUCH_KEY")); - BOOST_CHECK_EQUAL(st.get("WWCT:OP_99", -1), -1); + st.update_well_var("OP1", "WWCT", 0.75); st.update_well_var("OP2", "WWCT", 0.75); @@ -1813,9 +1673,6 @@ BOOST_AUTO_TEST_CASE(Test_SummaryState) { const auto& wopr_wells = st.wells("WOPR"); BOOST_CHECK_EQUAL( wopr_wells.size() , 0); - BOOST_CHECK_EQUAL( st.get_well_var("OP99", "WWCT", 0.50), 0.50); - - const auto& wwct_wells = st.wells("WWCT"); BOOST_CHECK_EQUAL( wwct_wells.size(), 2); @@ -1825,7 +1682,6 @@ BOOST_AUTO_TEST_CASE(Test_SummaryState) { BOOST_CHECK( st.has_group_var("G1", "GWCT")); BOOST_CHECK_EQUAL( st.get_group_var("G1", "GWCT"), 0.25); BOOST_CHECK_EQUAL( st.get_group_var("G1", "GWCT"), st.get("GWCT:G1")); - BOOST_CHECK_EQUAL( st.get_group_var("G99", "GWCT", 1.00), 1.00); const auto& gopr_groups = st.groups("GOPR"); BOOST_CHECK_EQUAL( gopr_groups.size() , 0); @@ -1850,19 +1706,6 @@ BOOST_AUTO_TEST_CASE(Test_SummaryState) { // The well 'OP_2' which was indirectly added with the // st.update("WWCT:OP_2", 100) call is *not* counted as a well! BOOST_CHECK_EQUAL(st.num_wells(), 3); - - - BOOST_CHECK( st.erase("WWCT:OP2") ); - BOOST_CHECK( !st.has("WWCT:OP2") ); - BOOST_CHECK( !st.erase("WWCT:OP2") ); - - BOOST_CHECK( st.erase_well_var("OP1", "WWCT") ); - BOOST_CHECK( !st.has_well_var("OP1", "WWCT")); - BOOST_CHECK( !st.has("WWCT:OP1") ); - - BOOST_CHECK( st.erase_group_var("G1", "GWCT") ); - BOOST_CHECK( !st.has_group_var("G1", "GWCT")); - BOOST_CHECK( !st.has("GWCT:G1") ); } BOOST_AUTO_TEST_SUITE_END() @@ -1896,13 +1739,10 @@ namespace { auto calculateRestartVectorsEffFac() -> decltype(calculateRestartVectors({"test.Restart.EffFac", - "SUMMARY_EFF_FAC.DATA", false})) + "SUMMARY_EFF_FAC.DATA"})) { - // W_3 is a producer in SUMMARY_EFF_FAC.DATA - const auto w3_injector = false; - return calculateRestartVectors({ - "test.Restart.EffFac", "SUMMARY_EFF_FAC.DATA", w3_injector + "test.Restart.EffFac", "SUMMARY_EFF_FAC.DATA" }); } diff --git a/ThirdParty/custom-opm-common/opm-common/tests/test_Summary_Group.cpp b/ThirdParty/custom-opm-common/opm-common/tests/test_Summary_Group.cpp index b6dcd075cd..0b85b8ec51 100644 --- a/ThirdParty/custom-opm-common/opm-common/tests/test_Summary_Group.cpp +++ b/ThirdParty/custom-opm-common/opm-common/tests/test_Summary_Group.cpp @@ -23,17 +23,13 @@ #include #include -#include -#include #include -#include #include #include -#include #include -#include #include -#include +#include +#include #include #include @@ -191,21 +187,21 @@ static data::Wells result_wells() { } -static data::GroupValues result_groups() { - data::GroupValues groups; - data::GroupConstraints cgc_group; +static data::Group result_groups() { + data::Group groups; + data::currentGroupConstraints cgc_group; cgc_group.set(p_cmode::NONE, i_cmode::VREP, i_cmode::RATE); - groups["TEST"].currentControl = cgc_group; + groups.emplace("TEST", cgc_group); cgc_group.set(p_cmode::ORAT, i_cmode::RESV, i_cmode::REIN); - groups["LOWER"].currentControl = cgc_group; + groups.emplace("LOWER", cgc_group); cgc_group.set(p_cmode::GRAT, i_cmode::REIN, i_cmode::VREP); - groups["UPPER"].currentControl = cgc_group; + groups.emplace("UPPER", cgc_group); cgc_group.set(p_cmode::NONE, i_cmode::NONE, i_cmode::NONE); - groups["FIELD"].currentControl = cgc_group; + groups.emplace("FIELD", cgc_group); return groups; } @@ -219,7 +215,7 @@ struct setup { Schedule schedule; SummaryConfig config; data::Wells wells; - data::GroupValues groups; + data::Group groups; std::string name; WorkArea ta; @@ -240,8 +236,6 @@ struct setup { }; } // Anonymous namespace -// ===================================================================== - BOOST_AUTO_TEST_SUITE(Summary) /* * Tests works by reading the Deck, write the summary output, then immediately diff --git a/ThirdParty/custom-opm-common/opm-common/tests/test_calculateCellVol.cpp b/ThirdParty/custom-opm-common/opm-common/tests/test_calculateCellVol.cpp index c4857fb05b..101bb99e35 100644 --- a/ThirdParty/custom-opm-common/opm-common/tests/test_calculateCellVol.cpp +++ b/ThirdParty/custom-opm-common/opm-common/tests/test_calculateCellVol.cpp @@ -22,6 +22,7 @@ #define BOOST_TEST_MODULE CubicTest #include +#include /* --- our own headers --- */ #include diff --git a/ThirdParty/custom-opm-common/opm-common/tests/test_cubic.cpp b/ThirdParty/custom-opm-common/opm-common/tests/test_cubic.cpp index 329036bbab..5210e7d4fd 100644 --- a/ThirdParty/custom-opm-common/opm-common/tests/test_cubic.cpp +++ b/ThirdParty/custom-opm-common/opm-common/tests/test_cubic.cpp @@ -40,6 +40,7 @@ #define BOOST_TEST_MODULE CubicTest #include +#include /* --- our own headers --- */ #include diff --git a/ThirdParty/custom-opm-common/opm-common/tests/test_data_GuideRateValue.cpp b/ThirdParty/custom-opm-common/opm-common/tests/test_data_GuideRateValue.cpp deleted file mode 100644 index c4d1487e51..0000000000 --- a/ThirdParty/custom-opm-common/opm-common/tests/test_data_GuideRateValue.cpp +++ /dev/null @@ -1,209 +0,0 @@ -/* - Copyright (c) 2020 Equinor ASA - - This file is part of the Open Porous Media project (OPM). - - OPM is free software: you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - OPM is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with OPM. If not, see . -*/ - -#define BOOST_TEST_MODULE data_GuideRateValue - -#include - -#include - -BOOST_AUTO_TEST_SUITE(GuideRate_Values) - -namespace { - class MessageBuffer - { - private: - std::stringstream str_{}; - - public: - template - void read(T& value) - { - this->str_.read(reinterpret_cast(&value), sizeof value); - } - - template - void write(T const& value) - { - this->str_.write(reinterpret_cast(&value), sizeof value); - } - - void write(const std::string& str) - { - const int size = str.size(); - this->write(size); - for (int k = 0; k < size; ++k) { - this->write(str[k]); - } - } - - void read(std::string& str) - { - int size = 0; - this->read(size); - str.resize(size); - for (int k = 0; k < size; ++k) { - this->read(str[k]); - } - } - }; -} - -BOOST_AUTO_TEST_CASE(Construct) -{ - using GRValue = ::Opm::data::GuideRateValue; - auto grvalue = GRValue{}; - - BOOST_CHECK_MESSAGE(! grvalue.has(GRValue::Item::Oil), "Default constructed GuideRateValue must not have Oil"); - BOOST_CHECK_MESSAGE(! grvalue.has(GRValue::Item::Gas), "Default constructed GuideRateValue must not have Gas"); - BOOST_CHECK_MESSAGE(! grvalue.has(GRValue::Item::Water), "Default constructed GuideRateValue must not have Water"); - BOOST_CHECK_MESSAGE(! grvalue.has(GRValue::Item::ResV), "Default constructed GuideRateValue must not have ResV"); - - BOOST_CHECK_MESSAGE(! grvalue.has(static_cast(1729)), - "Default constructed GuideRateValue must not have out-of-bounds phase 1729"); - - BOOST_CHECK_MESSAGE(! grvalue.has(static_cast(-1)), - "Default constructed GuideRateValue must not have out-of-bounds phase -1"); -} - -BOOST_AUTO_TEST_CASE(Set_and_Get) -{ - using GRValue = ::Opm::data::GuideRateValue; - auto grvalue = GRValue{}; - - BOOST_CHECK_THROW(grvalue.get(GRValue::Item::Oil), std::invalid_argument); - BOOST_CHECK_THROW(grvalue.get(static_cast(1729)), std::invalid_argument); - BOOST_CHECK_THROW(grvalue.get(static_cast(-1)), std::invalid_argument); - - grvalue.set(GRValue::Item::Oil, 123.456); - grvalue.set(GRValue::Item::Water, -0.98765); - grvalue.set(GRValue::Item::ResV, 567.89); - - BOOST_CHECK_THROW(grvalue.set(static_cast(355113), 0.1234), - std::invalid_argument); - - BOOST_CHECK_CLOSE(grvalue.get(GRValue::Item::Oil), 123.456, 1.0e-10); - BOOST_CHECK_CLOSE(grvalue.get(GRValue::Item::Water), -0.98765, 1.0e-10); - BOOST_CHECK_CLOSE(grvalue.get(GRValue::Item::ResV), 567.89, 1.0e-10); - - BOOST_CHECK_THROW(grvalue.get(GRValue::Item::Gas), std::invalid_argument); -} - -BOOST_AUTO_TEST_CASE(Copy_and_Assignment) -{ - using GRValue = ::Opm::data::GuideRateValue; - auto grvalue1 = GRValue{}; - - grvalue1.set(GRValue::Item::Oil, 123.456); - grvalue1.set(GRValue::Item::Water, -0.98765); - grvalue1.set(GRValue::Item::ResV, 567.89); - - const auto grvalue2{ grvalue1 }; - - BOOST_CHECK_CLOSE(grvalue2.get(GRValue::Item::Oil), 123.456, 1.0e-10); - BOOST_CHECK_CLOSE(grvalue2.get(GRValue::Item::Water), -0.98765, 1.0e-10); - BOOST_CHECK_CLOSE(grvalue2.get(GRValue::Item::ResV), 567.89, 1.0e-10); - - BOOST_CHECK_THROW(grvalue2.get(GRValue::Item::Gas), std::invalid_argument); - - auto grvalue3 = GRValue{}; - grvalue3 = grvalue2; - - BOOST_CHECK_CLOSE(grvalue3.get(GRValue::Item::Oil), 123.456, 1.0e-10); - BOOST_CHECK_CLOSE(grvalue3.get(GRValue::Item::Water), -0.98765, 1.0e-10); - BOOST_CHECK_CLOSE(grvalue3.get(GRValue::Item::ResV), 567.89, 1.0e-10); - - BOOST_CHECK_THROW(grvalue3.get(GRValue::Item::Gas), std::invalid_argument); -} - -BOOST_AUTO_TEST_CASE(Addition) -{ - using GRValue = ::Opm::data::GuideRateValue; - auto grvalue1 = GRValue{}; - - grvalue1.set(GRValue::Item::Oil, 123.456); - grvalue1.set(GRValue::Item::ResV, 567.89); - - auto grvalue2 = GRValue{}; - grvalue2.set(GRValue::Item::Water, -0.98765); - grvalue2.set(GRValue::Item::Oil, 123.321); - - grvalue1 += grvalue2; - - BOOST_CHECK_MESSAGE(grvalue1.has(GRValue::Item::Water), - "Operator '+=' must assign unset items"); - - BOOST_CHECK_CLOSE(grvalue1.get(GRValue::Item::Oil), 246.777, 1.0e-10); - BOOST_CHECK_CLOSE(grvalue1.get(GRValue::Item::Water), -0.98765, 1.0e-10); - BOOST_CHECK_CLOSE(grvalue1.get(GRValue::Item::ResV), 567.89, 1.0e-10); -} - -BOOST_AUTO_TEST_CASE(Clear) -{ - using GRValue = ::Opm::data::GuideRateValue; - auto grvalue = GRValue{}; - - grvalue.set(GRValue::Item::Oil, 123.456); - grvalue.set(GRValue::Item::Water, -0.98765); - grvalue.set(GRValue::Item::ResV, 567.89); - - grvalue.clear(); - - BOOST_CHECK_MESSAGE(! grvalue.has(GRValue::Item::Oil), "Cleared GuideRateValue must not have Oil"); - BOOST_CHECK_MESSAGE(! grvalue.has(GRValue::Item::Gas), "Cleared GuideRateValue must not have Gas"); - BOOST_CHECK_MESSAGE(! grvalue.has(GRValue::Item::Water), "Cleared GuideRateValue must not have Water"); - BOOST_CHECK_MESSAGE(! grvalue.has(GRValue::Item::ResV), "Cleared GuideRateValue must not have ResV"); -} - -BOOST_AUTO_TEST_CASE(Serialize_ReadWrite) -{ - using GRValue = ::Opm::data::GuideRateValue; - auto grvalue1 = GRValue{}; - - grvalue1.set(GRValue::Item::Oil, 123.456); - grvalue1.set(GRValue::Item::Water, -0.98765); - grvalue1.set(GRValue::Item::ResV, 567.89); - - auto buffer = MessageBuffer{}; - grvalue1.write(buffer); - - auto grvalue2 = GRValue{}; - grvalue2.read(buffer); - - BOOST_CHECK_MESSAGE( grvalue2.has(GRValue::Item::Oil), "Serialized GuideRateValue must have Oil"); - BOOST_CHECK_MESSAGE(! grvalue2.has(GRValue::Item::Gas), "Serialized GuideRateValue must NOT have Gas"); - BOOST_CHECK_MESSAGE( grvalue2.has(GRValue::Item::Water), "Serialized GuideRateValue must have Water"); - BOOST_CHECK_MESSAGE( grvalue2.has(GRValue::Item::ResV), "Serialized GuideRateValue must have Voidage"); - - BOOST_CHECK_MESSAGE(! grvalue2.has(static_cast(1729)), - "Serialized GuideRateValue must not have out-of-bounds phase 1729"); - - BOOST_CHECK_MESSAGE(! grvalue2.has(static_cast(-1)), - "Serialized GuideRateValue must not have out-of-bounds phase -1"); - - BOOST_CHECK_CLOSE(grvalue2.get(GRValue::Item::Oil), 123.456, 1.0e-10); - BOOST_CHECK_CLOSE(grvalue2.get(GRValue::Item::Water), -0.98765, 1.0e-10); - BOOST_CHECK_CLOSE(grvalue2.get(GRValue::Item::ResV), 567.89, 1.0e-10); - - BOOST_CHECK_THROW(grvalue2.get(GRValue::Item::Gas), std::invalid_argument); - - BOOST_CHECK_MESSAGE(grvalue1 == grvalue2, "Serialized GuideRateValue must equal its original value"); -} - -BOOST_AUTO_TEST_SUITE_END() diff --git a/ThirdParty/custom-opm-common/opm-common/tests/test_restartwellinfo.cpp b/ThirdParty/custom-opm-common/opm-common/tests/test_restartwellinfo.cpp index 3ca26f5986..0af5700ec4 100644 --- a/ThirdParty/custom-opm-common/opm-common/tests/test_restartwellinfo.cpp +++ b/ThirdParty/custom-opm-common/opm-common/tests/test_restartwellinfo.cpp @@ -36,7 +36,6 @@ #include #include -#include #include @@ -207,23 +206,20 @@ BOOST_AUTO_TEST_CASE(EclipseWriteRestartWellInfo) { Opm::EclipseIO eclipseWriter( es, grid , schedule, summary_config); int countTimeStep = schedule.getTimeMap().numTimesteps(); Opm::SummaryState st(std::chrono::system_clock::from_time_t(schedule.getStartTime())); - Opm::Action::State action_state; Opm::data::Solution solution; solution.insert( "PRESSURE", Opm::UnitSystem::measure::pressure , std::vector< double >( num_cells, 1 ) , Opm::data::TargetType::RESTART_SOLUTION); solution.insert( "SWAT" , Opm::UnitSystem::measure::identity , std::vector< double >( num_cells, 1 ) , Opm::data::TargetType::RESTART_SOLUTION); solution.insert( "SGAS" , Opm::UnitSystem::measure::identity , std::vector< double >( num_cells, 1 ) , Opm::data::TargetType::RESTART_SOLUTION); Opm::data::Wells wells; - Opm::data::GroupValues groups; for(int timestep = 0; timestep <= countTimeStep; ++timestep) { - eclipseWriter.writeTimeStep( action_state, - st, + eclipseWriter.writeTimeStep( st, timestep, false, schedule.seconds(timestep), - Opm::RestartValue(solution, wells, groups)); + Opm::RestartValue(solution, wells)); } for (int i=1; i <=4; i++) { diff --git a/ThirdParty/custom-opm-common/opm-common/tests/test_rst.cpp b/ThirdParty/custom-opm-common/opm-common/tests/test_rst.cpp index 33c4029416..6c5cea879b 100644 --- a/ThirdParty/custom-opm-common/opm-common/tests/test_rst.cpp +++ b/ThirdParty/custom-opm-common/opm-common/tests/test_rst.cpp @@ -40,7 +40,6 @@ #include #include #include -#include #include #include @@ -261,7 +260,6 @@ BOOST_AUTO_TEST_CASE(State_test) { const auto rptStep = std::size_t{4}; const auto sim_step = rptStep - 1; Opm::SummaryState sumState(std::chrono::system_clock::now()); - Opm::Action::State action_state; const auto ih = Opm::RestartIO::Helpers::createInteHead(simCase.es, simCase.grid, @@ -279,7 +277,7 @@ BOOST_AUTO_TEST_CASE(State_test) { 0, 0); auto wellData = Opm::RestartIO::Helpers::AggregateWellData(ih); - wellData.captureDeclaredWellData(simCase.sched, units, sim_step, action_state, sumState, ih); + wellData.captureDeclaredWellData(simCase.sched, units, sim_step, sumState, ih); wellData.captureDynamicWellData(simCase.sched, sim_step, {} , sumState); auto connectionData = Opm::RestartIO::Helpers::AggregateConnectionData(ih);