From 83e000c91f957dd6a329ddd8504f0def7fe4bfb9 Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Thu, 13 Oct 2016 13:37:07 +0200 Subject: [PATCH] #804 Updated opm-parser based on a3496df501a4369fd827fbf0ff893d03deff425f --- ThirdParty/custom-opm-parser/CMakeLists.txt | 311 +----- .../custom-opm-parser/CMakeLists_files.cmake | 304 ++++++ .../generated-source/ParserKeywords.cpp | 639 +++++++++++++ .../generated-source/ParserKeywords0.cpp | 10 +- .../generated-source/ParserKeywords1.cpp | 8 +- .../generated-source/ParserKeywords2.cpp | 4 + .../generated-source/ParserKeywords3.cpp | 5 + .../parser/eclipse/Parser/ParserKeywords.hpp | 1 + .../eclipse/Parser/ParserKeywords/A.hpp | 129 +++ .../eclipse/Parser/ParserKeywords/D.hpp | 21 + .../eclipse/Parser/ParserKeywords/G.hpp | 25 + .../eclipse/Parser/ParserKeywords/J.hpp | 53 ++ .../eclipse/Parser/ParserKeywords/M.hpp | 24 + .../eclipse/Parser/ParserKeywords/R.hpp | 13 + .../eclipse/Parser/ParserKeywords/T.hpp | 13 + .../eclipse/Parser/ParserKeywords/W.hpp | 192 ++++ .../generated-source/inlineKeywordTest.cpp | 247 +++++ .../opm-parser/CMakeLists.txt | 31 +- .../custom-opm-parser/opm-parser/appveyor.yml | 36 + .../opm-parser/debian/control | 53 +- .../debian/libopm-cparser1-dev.install | 1 + .../opm-parser/debian/libopm-cparser1.install | 1 + .../debian/libopm-parser1-bin.install | 1 + .../debian/libopm-parser1-dev.install | 2 +- .../opm-parser/debian/libopm-parser1.install | 2 +- .../debian/python-opm-parser.install | 1 + .../custom-opm-parser/opm-parser/debian/rules | 3 +- .../opm-parser/jenkins/README.md | 21 +- .../opm-parser/jenkins/build-opm-parser.sh | 50 - .../opm-parser/jenkins/build-pr.sh | 53 -- .../opm-parser/jenkins/build.sh | 53 +- .../opm/parser/eclipse/Applications/opmi.cpp | 22 +- .../opm/parser/eclipse/CMakeLists.txt | 60 +- .../opm/parser/eclipse/Deck/Deck.cpp | 20 +- .../opm/parser/eclipse/Deck/Deck.hpp | 2 + .../opm/parser/eclipse/Deck/DeckItem.cpp | 24 +- .../opm/parser/eclipse/Deck/DeckRecord.cpp | 23 +- .../opm/parser/eclipse/Deck/DeckRecord.hpp | 2 +- .../opm/parser/eclipse/Deck/DeckTimeStep.cpp | 30 - .../parser/eclipse/Deck/SCHEDULESection.cpp | 71 -- .../parser/eclipse/Deck/SCHEDULESection.hpp | 49 - .../opm/parser/eclipse/Deck/Section.cpp | 7 +- .../opm/parser/eclipse/Deck/Section.hpp | 15 + .../parser/eclipse/Deck/tests/CMakeLists.txt | 3 +- .../Deck/tests/DeckDoubleItemTests.cpp | 2 - .../eclipse/Deck/tests/DeckIntItemTests.cpp | 2 - .../eclipse/Deck/tests/DeckKeywordTests.cpp | 2 - .../eclipse/Deck/tests/DeckRecordTests.cpp | 2 + .../Deck/tests/DeckStringItemTests.cpp | 2 - .../parser/eclipse/Deck/tests/DeckTests.cpp | 14 +- .../eclipse/Deck/tests/DeckTimeStepTests.cpp | 136 --- .../eclipse/Deck/tests/SectionTests.cpp | 1 - .../EclipseState/Eclipse3DProperties.cpp | 159 +++- .../EclipseState/Eclipse3DProperties.hpp | 23 +- .../eclipse/EclipseState/EclipseConfig.cpp | 66 +- .../eclipse/EclipseState/EclipseConfig.hpp | 34 +- .../eclipse/EclipseState/EclipseState.cpp | 103 +- .../eclipse/EclipseState/EclipseState.hpp | 32 +- .../eclipse/EclipseState/Grid/EclipseGrid.cpp | 377 ++++---- .../eclipse/EclipseState/Grid/EclipseGrid.hpp | 184 ++-- .../EclipseState/Grid/FaultCollection.cpp | 61 +- .../EclipseState/Grid/FaultCollection.hpp | 20 +- .../eclipse/EclipseState/Grid/FaultFace.hpp | 6 +- .../eclipse/EclipseState/Grid/GridDims.cpp | 119 +++ .../eclipse/EclipseState/Grid/GridDims.hpp | 70 ++ .../EclipseState/Grid/GridProperties.cpp | 106 ++- .../EclipseState/Grid/GridProperties.hpp | 40 +- .../EclipseState/Grid/GridProperty.cpp | 73 +- .../EclipseState/Grid/GridProperty.hpp | 25 + .../EclipseState/Grid/MULTREGTScanner.cpp | 21 +- .../EclipseState/Grid/MULTREGTScanner.hpp | 13 +- .../parser/eclipse/EclipseState/Grid/NNC.cpp | 25 +- .../parser/eclipse/EclipseState/Grid/NNC.hpp | 6 +- .../Grid/SatfuncPropertyInitializers.cpp | 10 +- .../eclipse/EclipseState/Grid/TransMult.cpp | 16 +- .../eclipse/EclipseState/Grid/TransMult.hpp | 14 +- .../EclipseState/Grid/tests/ADDREGTests.cpp | 26 +- .../EclipseState/Grid/tests/BoxTests.cpp | 2 - .../EclipseState/Grid/tests/CopyRegTests.cpp | 18 +- .../Grid/tests/EclipseGridTests.cpp | 271 ++++-- .../EclipseState/Grid/tests/EqualRegTests.cpp | 24 +- .../EclipseState/Grid/tests/FaultTests.cpp | 2 - .../Grid/tests/GridPropertiesTests.cpp | 2 - .../Grid/tests/GridPropertyTests.cpp | 58 +- .../Grid/tests/MULTREGTScannerTests.cpp | 38 +- .../EclipseState/Grid/tests/MultiRegTests.cpp | 18 +- .../EclipseState/Grid/tests/PORVTests.cpp | 61 +- .../SatfuncPropertyInitializersTests.cpp | 6 +- .../EclipseState/IOConfig/IOConfig.cpp | 422 +------- .../EclipseState/IOConfig/IOConfig.hpp | 103 +- .../EclipseState/IOConfig/RestartConfig.cpp | 650 +++++++++++++ .../EclipseState/IOConfig/RestartConfig.hpp | 375 ++++++++ .../IOConfig/tests/CMakeLists.txt | 3 + .../IOConfig/tests/IOConfigTest.cpp | 637 +------------ .../IOConfig/tests/RestartConfigTests.cpp | 901 ++++++++++++++++++ .../EclipseState/Schedule/Completion.cpp | 67 +- .../EclipseState/Schedule/Completion.hpp | 12 +- .../EclipseState/Schedule/CompletionSet.cpp | 26 +- .../EclipseState/Schedule/CompletionSet.hpp | 7 +- .../EclipseState/Schedule/DynamicState.hpp | 16 +- .../EclipseState/Schedule/DynamicVector.hpp | 2 - .../eclipse/EclipseState/Schedule/Group.cpp | 42 +- .../eclipse/EclipseState/Schedule/Group.hpp | 10 +- .../EclipseState/Schedule/GroupTree.cpp | 5 + .../EclipseState/Schedule/GroupTree.hpp | 9 + .../EclipseState/Schedule/MSW/Compsegs.cpp | 22 +- .../Schedule/OilVaporizationProperties.cpp | 64 +- .../Schedule/OilVaporizationProperties.hpp | 22 +- .../EclipseState/Schedule/Schedule.cpp | 649 ++++++------- .../EclipseState/Schedule/Schedule.hpp | 84 +- .../EclipseState/Schedule/ScheduleEnums.cpp | 172 ++-- .../EclipseState/Schedule/ScheduleEnums.hpp | 32 +- .../eclipse/EclipseState/Schedule/TimeMap.cpp | 74 +- .../eclipse/EclipseState/Schedule/TimeMap.hpp | 10 +- .../eclipse/EclipseState/Schedule/Tuning.cpp | 10 +- .../eclipse/EclipseState/Schedule/Tuning.hpp | 8 +- .../eclipse/EclipseState/Schedule/Well.cpp | 98 +- .../eclipse/EclipseState/Schedule/Well.hpp | 38 +- .../Schedule/WellEconProductionLimits.cpp | 122 +++ .../Schedule/WellEconProductionLimits.hpp | 169 ++++ .../Schedule/WellProductionProperties.cpp | 25 +- .../eclipse/EclipseState/Schedule/WellSet.cpp | 12 +- .../eclipse/EclipseState/Schedule/WellSet.hpp | 15 +- .../Schedule/tests/CompletionSetTests.cpp | 18 +- .../Schedule/tests/CompletionTests.cpp | 14 +- .../Schedule/tests/DynamicStateTests.cpp | 2 + .../Schedule/tests/GeomodifierTests.cpp | 11 +- .../Schedule/tests/GroupTests.cpp | 57 +- .../Schedule/tests/ScheduleTests.cpp | 275 ++++-- .../Schedule/tests/TimeMapTest.cpp | 6 - .../Schedule/tests/TuningTests.cpp | 176 ++-- .../Schedule/tests/WellSetTests.cpp | 33 +- .../Schedule/tests/WellSolventTests.cpp | 14 +- .../EclipseState/Schedule/tests/WellTests.cpp | 112 +-- .../tests/SimulationConfigTest.cpp | 2 - .../tests/ThresholdPressureTest.cpp | 2 - .../SummaryConfig/SummaryConfig.cpp | 475 +++++---- .../SummaryConfig/SummaryConfig.hpp | 25 +- .../tests/SummaryConfigTests.cpp | 211 +++- .../EclipseState/Tables/ColumnSchema.cpp | 8 +- .../eclipse/EclipseState/Tables/Tables.cpp | 4 +- .../EclipseState/Tables/VFPInjTable.hpp | 2 - .../EclipseState/Tables/VFPProdTable.cpp | 7 +- .../EclipseState/Tables/VFPProdTable.hpp | 2 - .../Tables/tests/ColumnSchemaTests.cpp | 2 - .../Tables/tests/PvtxTableTests.cpp | 2 - .../Tables/tests/SimpleTableTests.cpp | 2 - .../Tables/tests/TableColumnTests.cpp | 2 - .../Tables/tests/TableContainerTests.cpp | 4 +- .../Tables/tests/TableManagerTests.cpp | 4 +- .../Tables/tests/TableSchemaTests.cpp | 2 - .../parser/eclipse/EclipseState/checkDeck.cpp | 2 +- .../tests/Eclipse3DPropertiesTests.cpp | 71 +- .../EclipseState/tests/EclipseStateTests.cpp | 241 +++-- .../eclipse/Generator/KeywordGenerator.cpp | 80 +- .../eclipse/Generator/KeywordGenerator.hpp | 1 - .../Generator/tests/KeywordLoaderTests.cpp | 8 +- .../eclipse/IntegrationTests/BoxTest.cpp | 4 +- .../eclipse/IntegrationTests/CMakeLists.txt | 3 +- .../IntegrationTests/CompletionsFromDeck.cpp | 94 +- .../EclipseGridCreateFromDeck.cpp | 8 +- .../IOConfigIntegrationTest.cpp | 30 +- .../eclipse/IntegrationTests/IncludeTest.cpp | 3 +- .../IntegrationTests/IntegrationTests.cpp | 6 +- .../eclipse/IntegrationTests/NNCTests.cpp | 7 - .../IntegrationTests/ParseMULTREGT.cpp | 52 +- .../IntegrationTests/ParseMULTSEGWELL.cpp | 2 - .../IntegrationTests/ParseMiscible.cpp | 2 - .../eclipse/IntegrationTests/ParsePVTO.cpp | 2 - .../eclipse/IntegrationTests/ParseSLGOF.cpp | 2 - .../eclipse/IntegrationTests/ParseTOPS.cpp | 4 +- .../eclipse/IntegrationTests/ParseVFPPROD.cpp | 2 - .../ParseWellWithWildcards.cpp | 16 +- .../IntegrationTests/ResinsightTest.cpp | 32 +- .../ScheduleCreateFromDeck.cpp | 282 ++++-- .../TransMultIntegrationTests.cpp | 18 +- .../parser/eclipse/Parser/ParseContext.cpp | 8 + .../parser/eclipse/Parser/ParseContext.hpp | 15 + .../opm/parser/eclipse/Parser/Parser.cpp | 115 +-- .../opm/parser/eclipse/Parser/ParserItem.hpp | 17 +- .../parser/eclipse/Parser/ParserKeyword.cpp | 2 +- .../parser/eclipse/Parser/ParserRecord.cpp | 11 +- .../opm/parser/eclipse/Parser/UnitSystem.cpp | 142 --- .../Parser/tests/MessageContainerTest.cpp | 2 - .../Parser/tests/ParseContextTests.cpp | 31 +- .../Parser/tests/ParserKeywordTests.cpp | 4 +- .../eclipse/Parser/tests/ParserTests.cpp | 27 +- .../opm/parser/eclipse/RawDeck/RawConsts.hpp | 54 +- .../opm/parser/eclipse/RawDeck/RawRecord.cpp | 77 +- .../opm/parser/eclipse/RawDeck/RawRecord.hpp | 4 +- .../opm/parser/eclipse/RawDeck/StarToken.cpp | 71 +- .../eclipse/RawDeck/tests/RawRecordTests.cpp | 8 +- .../eclipse/Units/ConversionFactors.hpp | 190 ++-- .../opm/parser/eclipse/Units/UnitSystem.cpp | 240 ++++- .../opm/parser/eclipse/Units/UnitSystem.hpp | 16 + .../eclipse/Units/tests/COMPSEGUnits.cpp | 4 +- .../parser/eclipse/Units/tests/UnitTests.cpp | 38 + .../opm/parser/eclipse/Utility/Functional.cpp | 4 +- .../opm/parser/eclipse/Utility/Stringview.hpp | 14 +- .../eclipse/Utility/tests/FunctionalTests.cpp | 2 - .../eclipse/Utility/tests/StringTests.cpp | 2 - .../eclipse/Utility/tests/StringviewTests.cpp | 2 - .../opm/parser/eclipse/python/CMakeLists.txt | 26 +- .../eclipse/python/c_inter/CMakeLists.txt | 2 + .../parser/eclipse/python/c_inter/cdeck.cc | 10 + .../eclipse/python/c_inter/cdeck_item.cc | 8 + .../eclipse/python/c_inter/cdeck_keyword.cc | 7 + .../eclipse/python/c_inter/cdeck_record.cc | 6 + .../eclipse/python/c_inter/ceclipse_grid.cc | 21 + .../eclipse/python/c_inter/cparse_context.cc | 19 +- .../parser/eclipse/python/c_inter/cparser.cc | 8 + .../eclipse/python/c_inter/cschedule.cc | 34 + .../parser/eclipse/python/c_inter/ctable.cc | 9 + .../eclipse/python/c_inter/ctable_index.cc | 4 + .../eclipse/python/c_inter/ctable_manager.cc | 8 + .../parser/eclipse/python/cmake/python.cmake | 8 +- .../eclipse/python/python/CMakeLists.txt | 3 + .../eclipse/python/python/opm/__init__.py | 8 +- .../eclipse/python/python/opm/deck/deck.py | 4 +- .../python/python/opm/deck/deck_item.py | 2 +- .../python/python/opm/deck/deck_keyword.py | 2 +- .../python/python/opm/deck/deck_record.py | 2 +- .../python/python/opm/deck/item_type_enum.py | 2 +- .../python/opm/ecl_state/CMakeLists.txt | 3 +- .../python/opm/ecl_state/grid/CMakeLists.txt | 6 + .../python/opm/ecl_state/grid/__init__.py | 1 + .../python/opm/ecl_state/grid/eclipse_grid.py | 18 + .../opm/ecl_state/schedule/CMakeLists.txt | 6 + .../python/opm/ecl_state/schedule/__init__.py | 1 + .../python/opm/ecl_state/schedule/schedule.py | 35 + .../python/opm/ecl_state/tables/table.py | 2 +- .../opm/ecl_state/tables/table_index.py | 2 +- .../opm/ecl_state/tables/table_manager.py | 4 +- .../python/python/opm/parser/error_action.py | 2 +- .../python/python/opm/parser/parse_context.py | 10 +- .../python/python/opm/parser/parser.py | 4 +- .../parser/eclipse/python/python/opm_test.py | 8 + .../python/tests/ecl_state/CMakeLists.txt | 8 +- .../tests/ecl_state/grid/CMakeLists.txt | 7 + .../python/tests/ecl_state/grid/__init__.py} | 0 .../python/tests/ecl_state/grid/test_grid.py | 18 + .../tests/ecl_state/schedule/CMakeLists.txt | 7 + .../tests/ecl_state/schedule/__init__.py | 0 .../tests/ecl_state/schedule/test_schedule.py | 37 + .../tests/ecl_state/table/CMakeLists.txt | 7 + .../python/tests/ecl_state/table/__init__.py | 0 .../{ => table}/test_table_manager.py | 0 .../share/keywords/000_Eclipse100/A/AQUANCON | 15 + .../share/keywords/000_Eclipse100/A/AQUFETP | 11 + .../000_Eclipse100/A/AQUIFER_PROBE_ANALYTIC | 8 + .../share/keywords/000_Eclipse100/D/DATUM | 4 + .../share/keywords/000_Eclipse100/D/DUMPFLUX | 1 + .../share/keywords/000_Eclipse100/G/GRAVITY | 5 + .../share/keywords/000_Eclipse100/J/JFUNC | 8 + .../share/keywords/000_Eclipse100/M/MULTREGP | 8 + .../share/keywords/000_Eclipse100/R/RPTREGS | 3 + .../share/keywords/000_Eclipse100/T/TNUM | 4 + .../share/keywords/000_Eclipse100/W/WDRILTIM | 5 + .../share/keywords/000_Eclipse100/W/WECON | 17 + .../share/keywords/000_Eclipse100/W/WLIFT | 14 + .../opm-parser/redhat/opm-parser.spec | 57 +- .../testdata/integration_tests/BOX/BOXTEST1 | 8 + .../IOConfig/RPTRST_DECK.DATA | 8 + .../integration_tests/IOConfig/RPT_TEST2.DATA | 10 +- .../integration_tests/IOConfig/SPE9_END.DATA | 174 ++++ .../SCHEDULE/SCHEDULE_COMPDAT1 | 127 +-- .../integration_tests/SCHEDULE/SCHEDULE_WECON | 44 + .../SCHEDULE/SCHEDULE_WELLS2 | 2 + .../testdata/integration_tests/TRANS/Deck1 | 8 + 269 files changed, 9563 insertions(+), 4741 deletions(-) create mode 100644 ThirdParty/custom-opm-parser/CMakeLists_files.cmake create mode 100644 ThirdParty/custom-opm-parser/generated-source/include/opm/parser/eclipse/Parser/ParserKeywords/J.hpp create mode 100644 ThirdParty/custom-opm-parser/opm-parser/appveyor.yml create mode 100644 ThirdParty/custom-opm-parser/opm-parser/debian/libopm-cparser1-dev.install create mode 100644 ThirdParty/custom-opm-parser/opm-parser/debian/libopm-cparser1.install create mode 100644 ThirdParty/custom-opm-parser/opm-parser/debian/libopm-parser1-bin.install create mode 100644 ThirdParty/custom-opm-parser/opm-parser/debian/python-opm-parser.install delete mode 100644 ThirdParty/custom-opm-parser/opm-parser/jenkins/build-opm-parser.sh delete mode 100644 ThirdParty/custom-opm-parser/opm-parser/jenkins/build-pr.sh delete mode 100644 ThirdParty/custom-opm-parser/opm-parser/opm/parser/eclipse/Deck/DeckTimeStep.cpp delete mode 100644 ThirdParty/custom-opm-parser/opm-parser/opm/parser/eclipse/Deck/SCHEDULESection.cpp delete mode 100644 ThirdParty/custom-opm-parser/opm-parser/opm/parser/eclipse/Deck/SCHEDULESection.hpp delete mode 100644 ThirdParty/custom-opm-parser/opm-parser/opm/parser/eclipse/Deck/tests/DeckTimeStepTests.cpp create mode 100644 ThirdParty/custom-opm-parser/opm-parser/opm/parser/eclipse/EclipseState/Grid/GridDims.cpp create mode 100644 ThirdParty/custom-opm-parser/opm-parser/opm/parser/eclipse/EclipseState/Grid/GridDims.hpp create mode 100644 ThirdParty/custom-opm-parser/opm-parser/opm/parser/eclipse/EclipseState/IOConfig/RestartConfig.cpp create mode 100644 ThirdParty/custom-opm-parser/opm-parser/opm/parser/eclipse/EclipseState/IOConfig/RestartConfig.hpp create mode 100644 ThirdParty/custom-opm-parser/opm-parser/opm/parser/eclipse/EclipseState/IOConfig/tests/RestartConfigTests.cpp create mode 100644 ThirdParty/custom-opm-parser/opm-parser/opm/parser/eclipse/EclipseState/Schedule/WellEconProductionLimits.cpp create mode 100644 ThirdParty/custom-opm-parser/opm-parser/opm/parser/eclipse/EclipseState/Schedule/WellEconProductionLimits.hpp delete mode 100644 ThirdParty/custom-opm-parser/opm-parser/opm/parser/eclipse/Parser/UnitSystem.cpp create mode 100644 ThirdParty/custom-opm-parser/opm-parser/opm/parser/eclipse/python/c_inter/ceclipse_grid.cc create mode 100644 ThirdParty/custom-opm-parser/opm-parser/opm/parser/eclipse/python/c_inter/cschedule.cc create mode 100644 ThirdParty/custom-opm-parser/opm-parser/opm/parser/eclipse/python/python/opm/ecl_state/grid/CMakeLists.txt create mode 100644 ThirdParty/custom-opm-parser/opm-parser/opm/parser/eclipse/python/python/opm/ecl_state/grid/__init__.py create mode 100644 ThirdParty/custom-opm-parser/opm-parser/opm/parser/eclipse/python/python/opm/ecl_state/grid/eclipse_grid.py create mode 100644 ThirdParty/custom-opm-parser/opm-parser/opm/parser/eclipse/python/python/opm/ecl_state/schedule/CMakeLists.txt create mode 100644 ThirdParty/custom-opm-parser/opm-parser/opm/parser/eclipse/python/python/opm/ecl_state/schedule/__init__.py create mode 100644 ThirdParty/custom-opm-parser/opm-parser/opm/parser/eclipse/python/python/opm/ecl_state/schedule/schedule.py create mode 100644 ThirdParty/custom-opm-parser/opm-parser/opm/parser/eclipse/python/python/opm_test.py create mode 100644 ThirdParty/custom-opm-parser/opm-parser/opm/parser/eclipse/python/tests/ecl_state/grid/CMakeLists.txt rename ThirdParty/{Ert/devel/debian/docs => custom-opm-parser/opm-parser/opm/parser/eclipse/python/tests/ecl_state/grid/__init__.py} (100%) create mode 100644 ThirdParty/custom-opm-parser/opm-parser/opm/parser/eclipse/python/tests/ecl_state/grid/test_grid.py create mode 100644 ThirdParty/custom-opm-parser/opm-parser/opm/parser/eclipse/python/tests/ecl_state/schedule/CMakeLists.txt create mode 100644 ThirdParty/custom-opm-parser/opm-parser/opm/parser/eclipse/python/tests/ecl_state/schedule/__init__.py create mode 100644 ThirdParty/custom-opm-parser/opm-parser/opm/parser/eclipse/python/tests/ecl_state/schedule/test_schedule.py create mode 100644 ThirdParty/custom-opm-parser/opm-parser/opm/parser/eclipse/python/tests/ecl_state/table/CMakeLists.txt create mode 100644 ThirdParty/custom-opm-parser/opm-parser/opm/parser/eclipse/python/tests/ecl_state/table/__init__.py rename ThirdParty/custom-opm-parser/opm-parser/opm/parser/eclipse/python/tests/ecl_state/{ => table}/test_table_manager.py (100%) create mode 100644 ThirdParty/custom-opm-parser/opm-parser/opm/parser/share/keywords/000_Eclipse100/A/AQUANCON create mode 100644 ThirdParty/custom-opm-parser/opm-parser/opm/parser/share/keywords/000_Eclipse100/A/AQUFETP create mode 100644 ThirdParty/custom-opm-parser/opm-parser/opm/parser/share/keywords/000_Eclipse100/A/AQUIFER_PROBE_ANALYTIC create mode 100644 ThirdParty/custom-opm-parser/opm-parser/opm/parser/share/keywords/000_Eclipse100/D/DATUM create mode 100644 ThirdParty/custom-opm-parser/opm-parser/opm/parser/share/keywords/000_Eclipse100/D/DUMPFLUX create mode 100644 ThirdParty/custom-opm-parser/opm-parser/opm/parser/share/keywords/000_Eclipse100/G/GRAVITY create mode 100644 ThirdParty/custom-opm-parser/opm-parser/opm/parser/share/keywords/000_Eclipse100/J/JFUNC create mode 100644 ThirdParty/custom-opm-parser/opm-parser/opm/parser/share/keywords/000_Eclipse100/M/MULTREGP create mode 100644 ThirdParty/custom-opm-parser/opm-parser/opm/parser/share/keywords/000_Eclipse100/R/RPTREGS create mode 100644 ThirdParty/custom-opm-parser/opm-parser/opm/parser/share/keywords/000_Eclipse100/T/TNUM create mode 100644 ThirdParty/custom-opm-parser/opm-parser/opm/parser/share/keywords/000_Eclipse100/W/WDRILTIM create mode 100644 ThirdParty/custom-opm-parser/opm-parser/opm/parser/share/keywords/000_Eclipse100/W/WECON create mode 100644 ThirdParty/custom-opm-parser/opm-parser/opm/parser/share/keywords/000_Eclipse100/W/WLIFT create mode 100644 ThirdParty/custom-opm-parser/opm-parser/testdata/integration_tests/IOConfig/SPE9_END.DATA create mode 100644 ThirdParty/custom-opm-parser/opm-parser/testdata/integration_tests/SCHEDULE/SCHEDULE_WECON diff --git a/ThirdParty/custom-opm-parser/CMakeLists.txt b/ThirdParty/custom-opm-parser/CMakeLists.txt index b03f09c261..9eccc59c89 100644 --- a/ThirdParty/custom-opm-parser/CMakeLists.txt +++ b/ThirdParty/custom-opm-parser/CMakeLists.txt @@ -1,11 +1,9 @@ cmake_minimum_required (VERSION 2.8) - # -DBOOST_FILESYSTEM_VERSION=3 -DBOOST_TEST_DYN_LINK -DHAVE_CASE_SENSITIVE_FILESYSTEM=1 -DHAVE_REGEX=1 -DOPM_PARSER_DECK_API=1 -Wall -std=c++11 -fopenmp -Wall -g -O0 -DDEBUG -ggdb3 - if(MSVC) - add_definitions( "/W3 /D_CRT_SECURE_NO_WARNINGS /wd4996" ) + add_definitions( "/W3 /D_CRT_SECURE_NO_WARNINGS /wd4996 /wd4244 /wd4267" ) set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /MP") else() #always set these flags to make opm-parser compile on Linux @@ -19,319 +17,20 @@ project (custom-opm-parser) include_directories( ${Boost_INCLUDE_DIRS} - ${ResInsight_SOURCE_DIR}/ThirdParty/custom-opm-common/opm-common/ ${ERT_INCLUDE_DIRS} ) - - -# TODO: opm-parser should hold a cmake file with source code files only -#include(opm-parser/CMakeLists_files.cmake) - -set( rawdeck_source -RawDeck/StarToken.cpp -RawDeck/RawKeyword.cpp -RawDeck/RawRecord.cpp ) - -set( unit_source -Units/UnitSystem.cpp -Units/Dimension.cpp) - -set( deck_source -Deck/Deck.cpp -Deck/DeckKeyword.cpp -Deck/DeckRecord.cpp -Deck/DeckItem.cpp -Deck/Section.cpp -Deck/SCHEDULESection.cpp -Deck/DeckTimeStep.cpp -) - -set( parser_source -Parser/ParseContext.cpp -Parser/MessageContainer.cpp -Parser/ParserEnums.cpp -Parser/ParserKeyword.cpp -Parser/Parser.cpp -Parser/ParserRecord.cpp -Parser/ParserItem.cpp -Parser/ParserIntItem.cpp -Parser/ParserDoubleItem.cpp -Parser/ParserStringItem.cpp -) - -set( generator_source -Generator/KeywordGenerator.cpp -Generator/KeywordLoader.cpp ) - -set( build_parser_source -Parser/ParseContext.cpp -Parser/MessageContainer.cpp -Parser/ParserEnums.cpp -Parser/ParserKeyword.cpp -Parser/ParserRecord.cpp -Parser/ParserItem.cpp -Parser/ParserIntItem.cpp -Parser/ParserDoubleItem.cpp -Parser/ParserStringItem.cpp -${generator_source} -) - -set (state_source -EclipseState/EclipseState.cpp -EclipseState/EclipseConfig.cpp -EclipseState/Eclipse3DProperties.cpp -EclipseState/Messages.cpp -# -EclipseState/checkDeck.cpp -# -EclipseState/Schedule/OilVaporizationProperties.cpp -EclipseState/Schedule/TimeMap.cpp -EclipseState/Schedule/Schedule.cpp -EclipseState/Schedule/Well.cpp -EclipseState/Schedule/WellProductionProperties.cpp -EclipseState/Schedule/WellInjectionProperties.cpp -EclipseState/Schedule/WellPolymerProperties.cpp -EclipseState/Schedule/MSW/Segment.cpp -EclipseState/Schedule/MSW/SegmentSet.cpp -EclipseState/Schedule/MSW/Compsegs.cpp -EclipseState/Schedule/WellSet.cpp -EclipseState/Schedule/Group.cpp -EclipseState/Schedule/Completion.cpp -EclipseState/Schedule/CompletionSet.cpp -EclipseState/Schedule/ScheduleEnums.cpp -EclipseState/Schedule/GroupTreeNode.cpp -EclipseState/Schedule/GroupTree.cpp -EclipseState/Schedule/Tuning.cpp -EclipseState/Schedule/Events.cpp -# -EclipseState/Tables/SimpleTable.cpp -EclipseState/Tables/VFPProdTable.cpp -EclipseState/Tables/VFPInjTable.cpp -EclipseState/Tables/TableManager.cpp -EclipseState/Tables/TableContainer.cpp -EclipseState/Tables/TableColumn.cpp -EclipseState/Tables/ColumnSchema.cpp -EclipseState/Tables/TableSchema.cpp -EclipseState/Tables/TableIndex.cpp -EclipseState/Tables/PvtxTable.cpp -EclipseState/Tables/Tables.cpp -# -EclipseState/Grid/SatfuncPropertyInitializers.cpp -EclipseState/Grid/GridProperty.cpp -EclipseState/Grid/GridProperties.cpp -EclipseState/Grid/Box.cpp -EclipseState/Grid/BoxManager.cpp -EclipseState/Grid/FaceDir.cpp -EclipseState/Grid/TransMult.cpp -EclipseState/Grid/MULTREGTScanner.cpp -EclipseState/Grid/EclipseGrid.cpp -EclipseState/Grid/FaultFace.cpp -EclipseState/Grid/Fault.cpp -EclipseState/Grid/FaultCollection.cpp -EclipseState/Grid/NNC.cpp -EclipseState/Grid/PinchMode.cpp -# -EclipseState/InitConfig/InitConfig.cpp -EclipseState/InitConfig/Equil.cpp -EclipseState/SimulationConfig/SimulationConfig.cpp -EclipseState/SimulationConfig/ThresholdPressure.cpp -EclipseState/SummaryConfig/SummaryConfig.cpp -EclipseState/IOConfig/IOConfig.cpp) -# - -set( utility_source -Utility/Functional.cpp -Utility/Stringview.cpp -) - -set( HEADER_FILES -RawDeck/RawConsts.hpp -RawDeck/RawKeyword.hpp -RawDeck/RawRecord.hpp -RawDeck/StarToken.hpp -RawDeck/RawEnums.hpp -# -Deck/Deck.hpp -Deck/DeckKeyword.hpp -Deck/DeckRecord.hpp -Deck/DeckItem.hpp -Deck/Section.hpp -Deck/SCHEDULESection.hpp -Deck/DeckTimeStep.hpp -# -Parser/ParserEnums.hpp -Parser/ParserKeyword.hpp -Parser/Parser.hpp -Parser/ParserRecord.hpp -Parser/ParserItem.hpp -Parser/ParserIntItem.hpp -Parser/ParserDoubleItem.hpp -Parser/ParserStringItem.hpp -Parser/InputErrorAction.hpp -Parser/ParseContext.hpp -Parser/MessageContainer.hpp -# -Generator/KeywordLoader.hpp -Generator/KeywordGenerator.hpp -# -Units/UnitSystem.hpp -Units/Dimension.hpp -Units/ConversionFactors.hpp -# -EclipseState/EclipseState.hpp -EclipseState/EclipseConfig.hpp -EclipseState/Eclipse3DProperties.hpp -EclipseState/Messages.hpp -# -EclipseState/checkDeck.hpp -# -EclipseState/Schedule/OilVaporizationProperties.hpp -EclipseState/Schedule/TimeMap.hpp -EclipseState/Schedule/Schedule.hpp -EclipseState/Schedule/Well.hpp -EclipseState/Schedule/WellProductionProperties.hpp -EclipseState/Schedule/WellInjectionProperties.hpp -EclipseState/Schedule/WellPolymerProperties.hpp -EclipseState/Schedule/MSW/Segment.hpp -EclipseState/Schedule/MSW/SegmentSet.hpp -EclipseState/Schedule/MSW/Compsegs.hpp -EclipseState/Schedule/WellSet.hpp -EclipseState/Schedule/Group.hpp -EclipseState/Schedule/DynamicState.hpp -EclipseState/Schedule/DynamicVector.hpp -EclipseState/Schedule/Completion.hpp -EclipseState/Schedule/CompletionSet.hpp -EclipseState/Schedule/ScheduleEnums.hpp -EclipseState/Schedule/GroupTreeNode.hpp -EclipseState/Schedule/GroupTree.hpp -EclipseState/Schedule/Tuning.hpp -EclipseState/Schedule/Events.hpp -# -EclipseState/Util/RecordVector.hpp -EclipseState/Util/OrderedMap.hpp -EclipseState/Util/Value.hpp -# -EclipseState/Grid/EclipseGrid.hpp -EclipseState/Grid/GridProperty.hpp -EclipseState/Grid/GridProperties.hpp -EclipseState/Grid/SatfuncPropertyInitializers.hpp -EclipseState/Grid/Box.hpp -EclipseState/Grid/BoxManager.hpp -EclipseState/Grid/FaceDir.hpp -EclipseState/Grid/MinpvMode.hpp -EclipseState/Grid/PinchMode.hpp -EclipseState/Grid/MULTREGTScanner.hpp -EclipseState/Grid/TransMult.hpp -EclipseState/Grid/FaultFace.hpp -EclipseState/Grid/Fault.hpp -EclipseState/Grid/FaultCollection.hpp -EclipseState/Grid/NNC.hpp -# -EclipseState/InitConfig/InitConfig.hpp -EclipseState/InitConfig/Equil.hpp -EclipseState/SimulationConfig/SimulationConfig.hpp -EclipseState/SimulationConfig/ThresholdPressure.hpp -EclipseState/SummaryConfig/SummaryConfig.hpp -EclipseState/IOConfig/IOConfig.hpp -# -EclipseState/Tables/Tabdims.hpp -EclipseState/Tables/Eqldims.hpp -EclipseState/Tables/Regdims.hpp -EclipseState/Tables/PlyadsTable.hpp -EclipseState/Tables/PvtoTable.hpp -EclipseState/Tables/RocktabTable.hpp -EclipseState/Tables/PvdoTable.hpp -EclipseState/Tables/PvdgTable.hpp -EclipseState/Tables/PvdsTable.hpp -EclipseState/Tables/SimpleTable.hpp -EclipseState/Tables/PlymaxTable.hpp -EclipseState/Tables/PlyrockTable.hpp -EclipseState/Tables/SwofTable.hpp -EclipseState/Tables/SgwfnTable.hpp -EclipseState/Tables/SwfnTable.hpp -EclipseState/Tables/SgfnTable.hpp -EclipseState/Tables/SsfnTable.hpp -EclipseState/Tables/Sof2Table.hpp -EclipseState/Tables/Sof3Table.hpp -EclipseState/Tables/EnptvdTable.hpp -EclipseState/Tables/PlyviscTable.hpp -EclipseState/Tables/PlydhflfTable.hpp -EclipseState/Tables/PlyshlogTable.hpp -EclipseState/Tables/EnkrvdTable.hpp -EclipseState/Tables/ImkrvdTable.hpp -EclipseState/Tables/SgofTable.hpp -EclipseState/Tables/SlgofTable.hpp -EclipseState/Tables/PvtxTable.hpp -EclipseState/Tables/ImptvdTable.hpp -EclipseState/Tables/RsvdTable.hpp -EclipseState/Tables/RvvdTable.hpp -EclipseState/Tables/RtempvdTable.hpp -EclipseState/Tables/OilvisctTable.hpp -EclipseState/Tables/GasvisctTable.hpp -EclipseState/Tables/WatvisctTable.hpp -EclipseState/Tables/PvtgTable.hpp -EclipseState/Tables/VFPProdTable.hpp -EclipseState/Tables/VFPInjTable.hpp -EclipseState/Tables/TableManager.hpp -EclipseState/Tables/TableContainer.hpp -EclipseState/Tables/SorwmisTable.hpp -EclipseState/Tables/SgcwmisTable.hpp -EclipseState/Tables/MiscTable.hpp -EclipseState/Tables/PmiscTable.hpp -EclipseState/Tables/TlpmixpaTable.hpp -EclipseState/Tables/MsfnTable.hpp -EclipseState/Tables/TableColumn.hpp -EclipseState/Tables/ColumnSchema.hpp -EclipseState/Tables/TableEnums.hpp -EclipseState/Tables/TableSchema.hpp -EclipseState/Tables/TableIndex.hpp -# -Utility/Functional.hpp -Utility/Stringview.hpp) - - - - include_directories( opm-parser generated-source/include ) -set(opm_parser_source_files - ${generated_source} - ${state_source} - ${rawdeck_source} - ${parser_source} - ${deck_source} - ${unit_source} - ${generator_source} - ${utility_source} -) - -foreach (file ${opm_parser_source_files} ) - list(APPEND incl_path "opm-parser/opm/parser/eclipse/${file}" ) -endforeach() - - -set(opm_parser_generated_source_files - generated-source/ParserKeywords.cpp -generated-source/ParserKeywords0.cpp -generated-source/ParserKeywords1.cpp -generated-source/ParserKeywords2.cpp -generated-source/ParserKeywords3.cpp -) - -# JSON files included directly, not as a separate lib as in original build configuration -set (json_source - opm-parser/opm/json/JsonObject.cpp - opm-parser/opm/json/cjson/cJSON.c -) +# TODO: opm-parser should hold a cmake file with source code files only +#include(opm-parser/CMakeLists_files.cmake) +include ( CMakeLists_files.cmake ) add_library(${PROJECT_NAME} STATIC - ${incl_path} - ${json_source} - ${opm_parser_generated_source_files} + ${opm_parser_source_files} ) diff --git a/ThirdParty/custom-opm-parser/CMakeLists_files.cmake b/ThirdParty/custom-opm-parser/CMakeLists_files.cmake new file mode 100644 index 0000000000..44eb6da7d0 --- /dev/null +++ b/ThirdParty/custom-opm-parser/CMakeLists_files.cmake @@ -0,0 +1,304 @@ +# +# All the source files in the opm-parser project +# + +set( rawdeck_source +RawDeck/StarToken.cpp +RawDeck/RawKeyword.cpp +RawDeck/RawRecord.cpp ) + +set( unit_source +Units/UnitSystem.cpp +Units/Dimension.cpp) + +set( deck_source +Deck/Deck.cpp +Deck/DeckKeyword.cpp +Deck/DeckRecord.cpp +Deck/DeckItem.cpp +Deck/Section.cpp +) + +set( parser_source +Parser/ParseContext.cpp +Parser/MessageContainer.cpp +Parser/ParserEnums.cpp +Parser/ParserKeyword.cpp +Parser/Parser.cpp +Parser/ParserRecord.cpp +Parser/ParserItem.cpp +Parser/ParserIntItem.cpp +Parser/ParserDoubleItem.cpp +Parser/ParserStringItem.cpp +) + +set( generator_source +Generator/KeywordGenerator.cpp +Generator/KeywordLoader.cpp ) + +set( build_parser_source +Parser/ParseContext.cpp +Parser/MessageContainer.cpp +Parser/ParserEnums.cpp +Parser/ParserKeyword.cpp +Parser/ParserRecord.cpp +Parser/ParserItem.cpp +Parser/ParserIntItem.cpp +Parser/ParserDoubleItem.cpp +Parser/ParserStringItem.cpp +${generator_source} +) + +set (state_source +EclipseState/EclipseState.cpp +EclipseState/EclipseConfig.cpp +EclipseState/Eclipse3DProperties.cpp +EclipseState/Messages.cpp +# +EclipseState/checkDeck.cpp +# +EclipseState/Schedule/OilVaporizationProperties.cpp +EclipseState/Schedule/TimeMap.cpp +EclipseState/Schedule/Schedule.cpp +EclipseState/Schedule/Well.cpp +EclipseState/Schedule/WellProductionProperties.cpp +EclipseState/Schedule/WellInjectionProperties.cpp +EclipseState/Schedule/WellPolymerProperties.cpp +EclipseState/Schedule/WellEconProductionLimits.cpp +EclipseState/Schedule/MSW/Segment.cpp +EclipseState/Schedule/MSW/SegmentSet.cpp +EclipseState/Schedule/MSW/Compsegs.cpp +EclipseState/Schedule/WellSet.cpp +EclipseState/Schedule/Group.cpp +EclipseState/Schedule/Completion.cpp +EclipseState/Schedule/CompletionSet.cpp +EclipseState/Schedule/ScheduleEnums.cpp +EclipseState/Schedule/GroupTreeNode.cpp +EclipseState/Schedule/GroupTree.cpp +EclipseState/Schedule/Tuning.cpp +EclipseState/Schedule/Events.cpp +# +EclipseState/Tables/SimpleTable.cpp +EclipseState/Tables/VFPProdTable.cpp +EclipseState/Tables/VFPInjTable.cpp +EclipseState/Tables/TableManager.cpp +EclipseState/Tables/TableContainer.cpp +EclipseState/Tables/TableColumn.cpp +EclipseState/Tables/ColumnSchema.cpp +EclipseState/Tables/TableSchema.cpp +EclipseState/Tables/TableIndex.cpp +EclipseState/Tables/PvtxTable.cpp +EclipseState/Tables/Tables.cpp +# +EclipseState/Grid/SatfuncPropertyInitializers.cpp +EclipseState/Grid/GridDims.cpp +EclipseState/Grid/GridProperty.cpp +EclipseState/Grid/GridProperties.cpp +EclipseState/Grid/Box.cpp +EclipseState/Grid/BoxManager.cpp +EclipseState/Grid/FaceDir.cpp +EclipseState/Grid/TransMult.cpp +EclipseState/Grid/MULTREGTScanner.cpp +EclipseState/Grid/EclipseGrid.cpp +EclipseState/Grid/FaultFace.cpp +EclipseState/Grid/Fault.cpp +EclipseState/Grid/FaultCollection.cpp +EclipseState/Grid/NNC.cpp +EclipseState/Grid/PinchMode.cpp +# +EclipseState/InitConfig/InitConfig.cpp +EclipseState/InitConfig/Equil.cpp +EclipseState/SimulationConfig/SimulationConfig.cpp +EclipseState/SimulationConfig/ThresholdPressure.cpp +EclipseState/SummaryConfig/SummaryConfig.cpp +EclipseState/IOConfig/RestartConfig.cpp +EclipseState/IOConfig/IOConfig.cpp) +# + +set( utility_source +Utility/Functional.cpp +Utility/Stringview.cpp +) + +set( HEADER_FILES +RawDeck/RawConsts.hpp +RawDeck/RawKeyword.hpp +RawDeck/RawRecord.hpp +RawDeck/StarToken.hpp +RawDeck/RawEnums.hpp +# +Deck/Deck.hpp +Deck/DeckKeyword.hpp +Deck/DeckRecord.hpp +Deck/DeckItem.hpp +Deck/Section.hpp +# +Parser/ParserEnums.hpp +Parser/ParserKeyword.hpp +Parser/Parser.hpp +Parser/ParserRecord.hpp +Parser/ParserItem.hpp +Parser/ParserIntItem.hpp +Parser/ParserDoubleItem.hpp +Parser/ParserStringItem.hpp +Parser/InputErrorAction.hpp +Parser/ParseContext.hpp +Parser/MessageContainer.hpp +# +Generator/KeywordLoader.hpp +Generator/KeywordGenerator.hpp +# +Units/UnitSystem.hpp +Units/Dimension.hpp +Units/ConversionFactors.hpp +# +EclipseState/EclipseState.hpp +EclipseState/EclipseConfig.hpp +EclipseState/Eclipse3DProperties.hpp +EclipseState/Messages.hpp +# +EclipseState/checkDeck.hpp +# +EclipseState/Schedule/OilVaporizationProperties.hpp +EclipseState/Schedule/TimeMap.hpp +EclipseState/Schedule/Schedule.hpp +EclipseState/Schedule/Well.hpp +EclipseState/Schedule/WellProductionProperties.hpp +EclipseState/Schedule/WellInjectionProperties.hpp +EclipseState/Schedule/WellPolymerProperties.hpp +EclipseState/Schedule/WellEconProductionLimits.hpp +EclipseState/Schedule/MSW/Segment.hpp +EclipseState/Schedule/MSW/SegmentSet.hpp +EclipseState/Schedule/MSW/Compsegs.hpp +EclipseState/Schedule/WellSet.hpp +EclipseState/Schedule/Group.hpp +EclipseState/Schedule/DynamicState.hpp +EclipseState/Schedule/DynamicVector.hpp +EclipseState/Schedule/Completion.hpp +EclipseState/Schedule/CompletionSet.hpp +EclipseState/Schedule/ScheduleEnums.hpp +EclipseState/Schedule/GroupTreeNode.hpp +EclipseState/Schedule/GroupTree.hpp +EclipseState/Schedule/Tuning.hpp +EclipseState/Schedule/Events.hpp +# +EclipseState/Util/RecordVector.hpp +EclipseState/Util/OrderedMap.hpp +EclipseState/Util/Value.hpp +# +EclipseState/Grid/Box.hpp +EclipseState/Grid/BoxManager.hpp +EclipseState/Grid/EclipseGrid.hpp +EclipseState/Grid/FaceDir.hpp +EclipseState/Grid/FaultCollection.hpp +EclipseState/Grid/FaultFace.hpp +EclipseState/Grid/Fault.hpp +EclipseState/Grid/GridDims.hpp +EclipseState/Grid/GridProperties.hpp +EclipseState/Grid/GridProperty.hpp +EclipseState/Grid/MinpvMode.hpp +EclipseState/Grid/MULTREGTScanner.hpp +EclipseState/Grid/NNC.hpp +EclipseState/Grid/PinchMode.hpp +EclipseState/Grid/SatfuncPropertyInitializers.hpp +EclipseState/Grid/TransMult.hpp +# +EclipseState/InitConfig/InitConfig.hpp +EclipseState/InitConfig/Equil.hpp +EclipseState/SimulationConfig/SimulationConfig.hpp +EclipseState/SimulationConfig/ThresholdPressure.hpp +EclipseState/SummaryConfig/SummaryConfig.hpp +EclipseState/IOConfig/RestartConfig.hpp +EclipseState/IOConfig/IOConfig.hpp +# +EclipseState/Tables/Tabdims.hpp +EclipseState/Tables/Eqldims.hpp +EclipseState/Tables/Regdims.hpp +EclipseState/Tables/PlyadsTable.hpp +EclipseState/Tables/PvtoTable.hpp +EclipseState/Tables/RocktabTable.hpp +EclipseState/Tables/PvdoTable.hpp +EclipseState/Tables/PvdgTable.hpp +EclipseState/Tables/PvdsTable.hpp +EclipseState/Tables/SimpleTable.hpp +EclipseState/Tables/PlymaxTable.hpp +EclipseState/Tables/PlyrockTable.hpp +EclipseState/Tables/SwofTable.hpp +EclipseState/Tables/SgwfnTable.hpp +EclipseState/Tables/SwfnTable.hpp +EclipseState/Tables/SgfnTable.hpp +EclipseState/Tables/SsfnTable.hpp +EclipseState/Tables/Sof2Table.hpp +EclipseState/Tables/Sof3Table.hpp +EclipseState/Tables/EnptvdTable.hpp +EclipseState/Tables/PlyviscTable.hpp +EclipseState/Tables/PlydhflfTable.hpp +EclipseState/Tables/PlyshlogTable.hpp +EclipseState/Tables/EnkrvdTable.hpp +EclipseState/Tables/ImkrvdTable.hpp +EclipseState/Tables/SgofTable.hpp +EclipseState/Tables/SlgofTable.hpp +EclipseState/Tables/PvtxTable.hpp +EclipseState/Tables/ImptvdTable.hpp +EclipseState/Tables/RsvdTable.hpp +EclipseState/Tables/RvvdTable.hpp +EclipseState/Tables/RtempvdTable.hpp +EclipseState/Tables/OilvisctTable.hpp +EclipseState/Tables/GasvisctTable.hpp +EclipseState/Tables/WatvisctTable.hpp +EclipseState/Tables/PvtgTable.hpp +EclipseState/Tables/VFPProdTable.hpp +EclipseState/Tables/VFPInjTable.hpp +EclipseState/Tables/TableManager.hpp +EclipseState/Tables/TableContainer.hpp +EclipseState/Tables/SorwmisTable.hpp +EclipseState/Tables/SgcwmisTable.hpp +EclipseState/Tables/MiscTable.hpp +EclipseState/Tables/PmiscTable.hpp +EclipseState/Tables/TlpmixpaTable.hpp +EclipseState/Tables/MsfnTable.hpp +EclipseState/Tables/TableColumn.hpp +EclipseState/Tables/ColumnSchema.hpp +EclipseState/Tables/TableEnums.hpp +EclipseState/Tables/TableSchema.hpp +EclipseState/Tables/TableIndex.hpp +# +Utility/Functional.hpp +Utility/Stringview.hpp) + +set(opm_parser_generated_source_files + generated-source/ParserKeywords.cpp + generated-source/ParserKeywords0.cpp + generated-source/ParserKeywords1.cpp + generated-source/ParserKeywords2.cpp + generated-source/ParserKeywords3.cpp +) + +# JSON files included directly, not as a separate lib as in original build configuration +set (json_source + opm-parser/opm/json/JsonObject.cpp + opm-parser/opm/json/cjson/cJSON.c +) + +# Assemble all the files and add path as needed + +set(opm_parser_source_files_short_path + ${generated_source} + ${state_source} + ${rawdeck_source} + ${parser_source} + ${deck_source} + ${unit_source} + ${generator_source} + ${utility_source} +) + +foreach (file ${opm_parser_source_files_short_path} ) + list(APPEND opm_parser_source_files_long_path "opm-parser/opm/parser/eclipse/${file}" ) +endforeach() + +set(opm_parser_source_files + ${opm_parser_source_files_long_path} + ${json_source} + ${opm_parser_generated_source_files} +) diff --git a/ThirdParty/custom-opm-parser/generated-source/ParserKeywords.cpp b/ThirdParty/custom-opm-parser/generated-source/ParserKeywords.cpp index 8ef2d0ab5f..e27b025f17 100644 --- a/ThirdParty/custom-opm-parser/generated-source/ParserKeywords.cpp +++ b/ThirdParty/custom-opm-parser/generated-source/ParserKeywords.cpp @@ -232,6 +232,89 @@ API::API( ) : ParserKeyword("API") { const std::string API::keywordName = "API"; +AQUANCON::AQUANCON( ) : ParserKeyword("AQUANCON") { + setSizeType(SLASH_TERMINATED); + setDescription(""); + clearValidSectionNames(); + addValidSectionName("GRID"); + addValidSectionName("SOLUTION"); + clearDeckNames(); + addDeckName("AQUANCON"); + { + std::shared_ptr record = std::make_shared(); + { + ParserItemPtr item(new ParserIntItem("AQUIFER_ID",Opm::SINGLE)); + item->setDescription(""); + record->addItem(item); + } + { + ParserItemPtr item(new ParserIntItem("I1",Opm::SINGLE)); + item->setDescription(""); + record->addItem(item); + } + { + ParserItemPtr item(new ParserIntItem("I2",Opm::SINGLE)); + item->setDescription(""); + record->addItem(item); + } + { + ParserItemPtr item(new ParserIntItem("J1",Opm::SINGLE)); + item->setDescription(""); + record->addItem(item); + } + { + ParserItemPtr item(new ParserIntItem("J2",Opm::SINGLE)); + item->setDescription(""); + record->addItem(item); + } + { + ParserItemPtr item(new ParserIntItem("K1",Opm::SINGLE)); + item->setDescription(""); + record->addItem(item); + } + { + ParserItemPtr item(new ParserIntItem("K2",Opm::SINGLE)); + item->setDescription(""); + record->addItem(item); + } + { + ParserItemPtr item(new ParserStringItem("FACE",Opm::SINGLE)); + item->setDescription(""); + record->addItem(item); + } + { + ParserItemPtr item(new ParserDoubleItem("INFLUX_COEFF",Opm::SINGLE)); + item->setDescription(""); + item->push_backDimension("Length*Length"); + record->addItem(item); + } + { + ParserItemPtr item(new ParserDoubleItem("INFLUX_MULT",Opm::SINGLE)); + item->setDescription(""); + record->addItem(item); + } + { + ParserItemPtr item(new ParserStringItem("CONNECT_ADJOINING_ACTIVE_CELL",Opm::SINGLE)); + item->setDescription(""); + record->addItem(item); + } + addRecord( record ); + } +} +const std::string AQUANCON::keywordName = "AQUANCON"; +const std::string AQUANCON::AQUIFER_ID::itemName = "AQUIFER_ID"; +const std::string AQUANCON::I1::itemName = "I1"; +const std::string AQUANCON::I2::itemName = "I2"; +const std::string AQUANCON::J1::itemName = "J1"; +const std::string AQUANCON::J2::itemName = "J2"; +const std::string AQUANCON::K1::itemName = "K1"; +const std::string AQUANCON::K2::itemName = "K2"; +const std::string AQUANCON::FACE::itemName = "FACE"; +const std::string AQUANCON::INFLUX_COEFF::itemName = "INFLUX_COEFF"; +const std::string AQUANCON::INFLUX_MULT::itemName = "INFLUX_MULT"; +const std::string AQUANCON::CONNECT_ADJOINING_ACTIVE_CELL::itemName = "CONNECT_ADJOINING_ACTIVE_CELL"; + + AQUCON::AQUCON( ) : ParserKeyword("AQUCON") { setSizeType(SLASH_TERMINATED); setDescription(""); @@ -396,6 +479,104 @@ const std::string AQUDIMS::MXAAQL::itemName = "MXAAQL"; const int AQUDIMS::MXAAQL::defaultValue = 0; +AQUFETP::AQUFETP( ) : ParserKeyword("AQUFETP") { + setSizeType(OTHER_KEYWORD_IN_DECK); + initSizeKeyword("AQUDIMS","NANAQU"); + setDescription(""); + clearValidSectionNames(); + addValidSectionName("SCHEDULE"); + addValidSectionName("SOLUTION"); + clearDeckNames(); + addDeckName("AQUFETP"); + { + std::shared_ptr record = std::make_shared(); + { + ParserItemPtr item(new ParserIntItem("ID",Opm::SINGLE)); + item->setDescription(""); + record->addItem(item); + } + { + ParserItemPtr item(new ParserDoubleItem("DATUM_DEPTH",Opm::SINGLE)); + item->setDescription(""); + item->push_backDimension("Length"); + record->addItem(item); + } + { + ParserItemPtr item(new ParserDoubleItem("P0",Opm::SINGLE)); + item->setDescription(""); + item->push_backDimension("Pressure"); + record->addItem(item); + } + { + ParserItemPtr item(new ParserDoubleItem("V0",Opm::SINGLE)); + item->setDescription(""); + item->push_backDimension("Length*Length*Length"); + record->addItem(item); + } + { + ParserItemPtr item(new ParserDoubleItem("COMPRESSIBILITY",Opm::SINGLE)); + item->setDescription(""); + item->push_backDimension("1/Pressure"); + record->addItem(item); + } + { + ParserItemPtr item(new ParserDoubleItem("PI",Opm::SINGLE)); + item->setDescription(""); + item->push_backDimension("ReservoirVolume/Pressure*Time"); + record->addItem(item); + } + { + ParserItemPtr item(new ParserIntItem("WATER_TABLE",Opm::SINGLE)); + item->setDescription(""); + record->addItem(item); + } + { + ParserItemPtr item(new ParserDoubleItem("SALINITY",Opm::SINGLE)); + item->setDescription(""); + item->push_backDimension("Salinity"); + record->addItem(item); + } + { + ParserItemPtr item(new ParserDoubleItem("TEMP",Opm::SINGLE)); + item->setDescription(""); + record->addItem(item); + } + addRecord( record ); + } +} +const std::string AQUFETP::keywordName = "AQUFETP"; +const std::string AQUFETP::ID::itemName = "ID"; +const std::string AQUFETP::DATUM_DEPTH::itemName = "DATUM_DEPTH"; +const std::string AQUFETP::P0::itemName = "P0"; +const std::string AQUFETP::V0::itemName = "V0"; +const std::string AQUFETP::COMPRESSIBILITY::itemName = "COMPRESSIBILITY"; +const std::string AQUFETP::PI::itemName = "PI"; +const std::string AQUFETP::WATER_TABLE::itemName = "WATER_TABLE"; +const std::string AQUFETP::SALINITY::itemName = "SALINITY"; +const std::string AQUFETP::TEMP::itemName = "TEMP"; + + +AQUIFER_PROBE_ANALYTIC::AQUIFER_PROBE_ANALYTIC( ) : ParserKeyword("AQUIFER_PROBE_ANALYTIC") { + setFixedSize( (size_t) 1); + setDescription(""); + clearValidSectionNames(); + addValidSectionName("SUMMARY"); + clearDeckNames(); + setMatchRegex("AA.+"); + { + std::shared_ptr record = std::make_shared(); + { + ParserItemPtr item(new ParserIntItem("data",Opm::ALL)); + item->setDescription(""); + record->addDataItem(item); + } + addDataRecord( record ); + } +} +const std::string AQUIFER_PROBE_ANALYTIC::keywordName = "AQUIFER_PROBE_ANALYTIC"; +const std::string AQUIFER_PROBE_ANALYTIC::data::itemName = "data"; + + AQUNUM::AQUNUM( ) : ParserKeyword("AQUNUM") { setSizeType(SLASH_TERMINATED); setDescription(""); @@ -1462,6 +1643,28 @@ const std::string DATES::TIME::itemName = "TIME"; const std::string DATES::TIME::defaultValue = "00:00:00.000"; +DATUM::DATUM( ) : ParserKeyword("DATUM") { + setFixedSize( (size_t) 1); + setDescription(""); + clearValidSectionNames(); + addValidSectionName("SOLUTION"); + clearDeckNames(); + addDeckName("DATUM"); + { + std::shared_ptr record = std::make_shared(); + { + ParserItemPtr item(new ParserDoubleItem("DEPTH",Opm::SINGLE)); + item->setDescription(""); + item->push_backDimension("Length"); + record->addItem(item); + } + addRecord( record ); + } +} +const std::string DATUM::keywordName = "DATUM"; +const std::string DATUM::DEPTH::itemName = "DEPTH"; + + DENSITY::DENSITY( ) : ParserKeyword("DENSITY") { setSizeType(OTHER_KEYWORD_IN_DECK); initSizeKeyword("TABDIMS","NTPVT"); @@ -1686,6 +1889,17 @@ const std::string DRVDT::keywordName = "DRVDT"; const std::string DRVDT::DRVDT_MAX::itemName = "DRVDT_MAX"; +DUMPFLUX::DUMPFLUX( ) : ParserKeyword("DUMPFLUX") { + setFixedSize( (size_t) 0); + setDescription(""); + clearValidSectionNames(); + addValidSectionName("GRID"); + clearDeckNames(); + addDeckName("DUMPFLUX"); +} +const std::string DUMPFLUX::keywordName = "DUMPFLUX"; + + DX::DX( ) : ParserKeyword("DX") { setFixedSize( (size_t) 1); setDescription(""); @@ -3701,6 +3915,43 @@ const std::string GEFAC::TRANSFER_EXT_NET::itemName = "TRANSFER_EXT_NET"; const std::string GEFAC::TRANSFER_EXT_NET::defaultValue = "YES"; +GRAVITY::GRAVITY( ) : ParserKeyword("GRAVITY") { + setSizeType(OTHER_KEYWORD_IN_DECK); + initSizeKeyword("TABDIMS","NTPVT"); + setDescription(""); + clearValidSectionNames(); + addValidSectionName("PROPS"); + clearDeckNames(); + addDeckName("GRAVITY"); + { + std::shared_ptr record = std::make_shared(); + { + ParserItemPtr item(new ParserDoubleItem("API_GRAVITY",Opm::SINGLE)); + item->setDescription(""); + item->push_backDimension("1"); + record->addItem(item); + } + { + ParserItemPtr item(new ParserDoubleItem("WATER_SP_GRAVITY",Opm::SINGLE,1)); + item->setDescription(""); + record->addItem(item); + } + { + ParserItemPtr item(new ParserDoubleItem("GAS_SP_GRAVITY",Opm::SINGLE,0.77729999999999999)); + item->setDescription(""); + record->addItem(item); + } + addRecord( record ); + } +} +const std::string GRAVITY::keywordName = "GRAVITY"; +const std::string GRAVITY::API_GRAVITY::itemName = "API_GRAVITY"; +const std::string GRAVITY::WATER_SP_GRAVITY::itemName = "WATER_SP_GRAVITY"; +const double GRAVITY::WATER_SP_GRAVITY::defaultValue = 1; +const std::string GRAVITY::GAS_SP_GRAVITY::itemName = "GAS_SP_GRAVITY"; +const double GRAVITY::GAS_SP_GRAVITY::defaultValue = 0.7773; + + GRID::GRID( ) : ParserKeyword("GRID") { setFixedSize( (size_t) 0); setDescription(""); @@ -4494,6 +4745,65 @@ const std::string ISWU::keywordName = "ISWU"; const std::string ISWU::data::itemName = "data"; +JFUNC::JFUNC( ) : ParserKeyword("JFUNC") { + setFixedSize( (size_t) 1); + setDescription(""); + clearValidSectionNames(); + addValidSectionName("GRID"); + clearDeckNames(); + addDeckName("JFUNC"); + { + std::shared_ptr record = std::make_shared(); + { + ParserItemPtr item(new ParserStringItem("FLAG",Opm::SINGLE,"BOTH")); + item->setDescription(""); + record->addItem(item); + } + { + ParserItemPtr item(new ParserDoubleItem("OW_SURFACE_TENSION",Opm::SINGLE,-1)); + item->setDescription(""); + item->push_backDimension("SurfaceTension"); + record->addItem(item); + } + { + ParserItemPtr item(new ParserDoubleItem("GO_SURFACE_TENSION",Opm::SINGLE,-1)); + item->setDescription(""); + item->push_backDimension("SurfaceTension"); + record->addItem(item); + } + { + ParserItemPtr item(new ParserDoubleItem("ALPHA_FACTOR",Opm::SINGLE,0.5)); + item->setDescription(""); + record->addItem(item); + } + { + ParserItemPtr item(new ParserDoubleItem("BETA_FACTOR",Opm::SINGLE,0.5)); + item->setDescription(""); + record->addItem(item); + } + { + ParserItemPtr item(new ParserStringItem("DIRECTION",Opm::SINGLE,"XY")); + item->setDescription(""); + record->addItem(item); + } + addRecord( record ); + } +} +const std::string JFUNC::keywordName = "JFUNC"; +const std::string JFUNC::FLAG::itemName = "FLAG"; +const std::string JFUNC::FLAG::defaultValue = "BOTH"; +const std::string JFUNC::OW_SURFACE_TENSION::itemName = "OW_SURFACE_TENSION"; +const double JFUNC::OW_SURFACE_TENSION::defaultValue = -1; +const std::string JFUNC::GO_SURFACE_TENSION::itemName = "GO_SURFACE_TENSION"; +const double JFUNC::GO_SURFACE_TENSION::defaultValue = -1; +const std::string JFUNC::ALPHA_FACTOR::itemName = "ALPHA_FACTOR"; +const double JFUNC::ALPHA_FACTOR::defaultValue = 0.5; +const std::string JFUNC::BETA_FACTOR::itemName = "BETA_FACTOR"; +const double JFUNC::BETA_FACTOR::defaultValue = 0.5; +const std::string JFUNC::DIRECTION::itemName = "DIRECTION"; +const std::string JFUNC::DIRECTION::defaultValue = "XY"; + + MAPAXES::MAPAXES( ) : ParserKeyword("MAPAXES") { setFixedSize( (size_t) 1); setDescription(""); @@ -5217,6 +5527,41 @@ const std::string MULTPV::keywordName = "MULTPV"; const std::string MULTPV::data::itemName = "data"; +MULTREGP::MULTREGP( ) : ParserKeyword("MULTREGP") { + setSizeType(SLASH_TERMINATED); + setDescription(""); + clearValidSectionNames(); + addValidSectionName("EDIT"); + addValidSectionName("GRID"); + clearDeckNames(); + addDeckName("MULTREGP"); + { + std::shared_ptr record = std::make_shared(); + { + ParserItemPtr item(new ParserIntItem("REGION",Opm::SINGLE)); + item->setDescription(""); + record->addItem(item); + } + { + ParserItemPtr item(new ParserDoubleItem("MULTIPLIER",Opm::SINGLE)); + item->setDescription(""); + record->addItem(item); + } + { + ParserItemPtr item(new ParserStringItem("REGION_TYPE",Opm::SINGLE,"M")); + item->setDescription(""); + record->addItem(item); + } + addRecord( record ); + } +} +const std::string MULTREGP::keywordName = "MULTREGP"; +const std::string MULTREGP::REGION::itemName = "REGION"; +const std::string MULTREGP::MULTIPLIER::itemName = "MULTIPLIER"; +const std::string MULTREGP::REGION_TYPE::itemName = "REGION_TYPE"; +const std::string MULTREGP::REGION_TYPE::defaultValue = "M"; + + MULTREGT::MULTREGT( ) : ParserKeyword("MULTREGT") { setSizeType(SLASH_TERMINATED); setDescription(""); @@ -9079,6 +9424,27 @@ const std::string RPTPROPS::keywordName = "RPTPROPS"; const std::string RPTPROPS::mnemonics::itemName = "mnemonics"; +RPTREGS::RPTREGS( ) : ParserKeyword("RPTREGS") { + setFixedSize( (size_t) 1); + setDescription(""); + clearValidSectionNames(); + addValidSectionName("REGIONS"); + clearDeckNames(); + addDeckName("RPTREGS"); + { + std::shared_ptr record = std::make_shared(); + { + ParserItemPtr item(new ParserStringItem("MNEMONIC_LIST",Opm::ALL)); + item->setDescription(""); + record->addItem(item); + } + addRecord( record ); + } +} +const std::string RPTREGS::keywordName = "RPTREGS"; +const std::string RPTREGS::MNEMONIC_LIST::itemName = "MNEMONIC_LIST"; + + RPTRST::RPTRST( ) : ParserKeyword("RPTRST") { setFixedSize( (size_t) 1); setDescription(""); @@ -10767,6 +11133,27 @@ const std::string TLPMIXPA::keywordName = "TLPMIXPA"; const std::string TLPMIXPA::DATA::itemName = "DATA"; +TNUM::TNUM( ) : ParserKeyword("TNUM") { + setFixedSize( (size_t) 1); + setDescription(""); + clearValidSectionNames(); + addValidSectionName("REGIONS"); + clearDeckNames(); + setMatchRegex("TNUM(F|S).{1,3}"); + { + std::shared_ptr record = std::make_shared(); + { + ParserItemPtr item(new ParserIntItem("data",Opm::ALL)); + item->setDescription(""); + record->addDataItem(item); + } + addDataRecord( record ); + } +} +const std::string TNUM::keywordName = "TNUM"; +const std::string TNUM::data::itemName = "data"; + + TOPS::TOPS( ) : ParserKeyword("TOPS") { setFixedSize( (size_t) 1); setDescription(""); @@ -12421,6 +12808,175 @@ const std::string WCONPROD::E300_ITEM19::itemName = "E300_ITEM19"; const std::string WCONPROD::E300_ITEM20::itemName = "E300_ITEM20"; +WDRILTIM::WDRILTIM( ) : ParserKeyword("WDRILTIM") { + setSizeType(SLASH_TERMINATED); + setDescription(""); + clearValidSectionNames(); + addValidSectionName("SCHEDULE"); + clearDeckNames(); + addDeckName("WDRILTIM"); + { + std::shared_ptr record = std::make_shared(); + { + ParserItemPtr item(new ParserStringItem("WELL",Opm::SINGLE)); + item->setDescription(""); + record->addItem(item); + } + { + ParserItemPtr item(new ParserDoubleItem("DRILL_TIME",Opm::SINGLE)); + item->setDescription(""); + item->push_backDimension("Time"); + record->addItem(item); + } + { + ParserItemPtr item(new ParserStringItem("WORKOVER_CLOSE",Opm::SINGLE)); + item->setDescription(""); + record->addItem(item); + } + { + ParserItemPtr item(new ParserIntItem("COMPARTMENT",Opm::SINGLE)); + item->setDescription(""); + record->addItem(item); + } + addRecord( record ); + } +} +const std::string WDRILTIM::keywordName = "WDRILTIM"; +const std::string WDRILTIM::WELL::itemName = "WELL"; +const std::string WDRILTIM::DRILL_TIME::itemName = "DRILL_TIME"; +const std::string WDRILTIM::WORKOVER_CLOSE::itemName = "WORKOVER_CLOSE"; +const std::string WDRILTIM::COMPARTMENT::itemName = "COMPARTMENT"; + + +WECON::WECON( ) : ParserKeyword("WECON") { + setSizeType(SLASH_TERMINATED); + setDescription(""); + clearValidSectionNames(); + addValidSectionName("SCHEDULE"); + clearDeckNames(); + addDeckName("WECON"); + { + std::shared_ptr record = std::make_shared(); + { + ParserItemPtr item(new ParserStringItem("WELL",Opm::SINGLE)); + item->setDescription(""); + record->addItem(item); + } + { + ParserItemPtr item(new ParserDoubleItem("MIN_OIL_PRODUCTION",Opm::SINGLE,0)); + item->setDescription(""); + item->push_backDimension("LiquidSurfaceVolume/Time"); + record->addItem(item); + } + { + ParserItemPtr item(new ParserDoubleItem("MIN_GAS_PRODUCTION",Opm::SINGLE,0)); + item->setDescription(""); + item->push_backDimension("GasSurfaceVolume/Time"); + record->addItem(item); + } + { + ParserItemPtr item(new ParserDoubleItem("MAX_WATER_CUT",Opm::SINGLE,0)); + item->setDescription(""); + record->addItem(item); + } + { + ParserItemPtr item(new ParserDoubleItem("MAX_GAS_OIL_RATIO",Opm::SINGLE,0)); + item->setDescription(""); + record->addItem(item); + } + { + ParserItemPtr item(new ParserDoubleItem("MAX_WATER_GAS_RATIO",Opm::SINGLE,0)); + item->setDescription(""); + record->addItem(item); + } + { + ParserItemPtr item(new ParserStringItem("WORKOVER_RATIO_LIMIT",Opm::SINGLE,"NONE")); + item->setDescription(""); + record->addItem(item); + } + { + ParserItemPtr item(new ParserStringItem("END_RUN_FLAG",Opm::SINGLE,"NO")); + item->setDescription(""); + record->addItem(item); + } + { + ParserItemPtr item(new ParserStringItem("FOLLOW_ON_WELL",Opm::SINGLE,"'")); + item->setDescription(""); + record->addItem(item); + } + { + ParserItemPtr item(new ParserStringItem("LIMITED_QUANTITY",Opm::SINGLE,"RATE")); + item->setDescription(""); + record->addItem(item); + } + { + ParserItemPtr item(new ParserDoubleItem("SECOND_MAX_WATER_CUT",Opm::SINGLE,0)); + item->setDescription(""); + record->addItem(item); + } + { + ParserItemPtr item(new ParserStringItem("WORKOVER_SECOND_WATER_CUT_LIMIT",Opm::SINGLE)); + item->setDescription(""); + record->addItem(item); + } + { + ParserItemPtr item(new ParserDoubleItem("MAX_GAS_LIQUID_RATIO",Opm::SINGLE,0)); + item->setDescription(""); + record->addItem(item); + } + { + ParserItemPtr item(new ParserDoubleItem("MIN_LIQUID_PRODCUTION_RATE",Opm::SINGLE,0)); + item->setDescription(""); + item->push_backDimension("LiquidSurfaceVolume/Time"); + record->addItem(item); + } + { + ParserItemPtr item(new ParserDoubleItem("MAX_TEMP",Opm::SINGLE)); + item->setDescription(""); + item->push_backDimension("Temperature"); + record->addItem(item); + } + { + ParserItemPtr item(new ParserDoubleItem("MIN_RES_FLUID_RATE",Opm::SINGLE,0)); + item->setDescription(""); + item->push_backDimension("ReservoirVolume/Time"); + record->addItem(item); + } + addRecord( record ); + } +} +const std::string WECON::keywordName = "WECON"; +const std::string WECON::WELL::itemName = "WELL"; +const std::string WECON::MIN_OIL_PRODUCTION::itemName = "MIN_OIL_PRODUCTION"; +const double WECON::MIN_OIL_PRODUCTION::defaultValue = 0; +const std::string WECON::MIN_GAS_PRODUCTION::itemName = "MIN_GAS_PRODUCTION"; +const double WECON::MIN_GAS_PRODUCTION::defaultValue = 0; +const std::string WECON::MAX_WATER_CUT::itemName = "MAX_WATER_CUT"; +const double WECON::MAX_WATER_CUT::defaultValue = 0; +const std::string WECON::MAX_GAS_OIL_RATIO::itemName = "MAX_GAS_OIL_RATIO"; +const double WECON::MAX_GAS_OIL_RATIO::defaultValue = 0; +const std::string WECON::MAX_WATER_GAS_RATIO::itemName = "MAX_WATER_GAS_RATIO"; +const double WECON::MAX_WATER_GAS_RATIO::defaultValue = 0; +const std::string WECON::WORKOVER_RATIO_LIMIT::itemName = "WORKOVER_RATIO_LIMIT"; +const std::string WECON::WORKOVER_RATIO_LIMIT::defaultValue = "NONE"; +const std::string WECON::END_RUN_FLAG::itemName = "END_RUN_FLAG"; +const std::string WECON::END_RUN_FLAG::defaultValue = "NO"; +const std::string WECON::FOLLOW_ON_WELL::itemName = "FOLLOW_ON_WELL"; +const std::string WECON::FOLLOW_ON_WELL::defaultValue = "'"; +const std::string WECON::LIMITED_QUANTITY::itemName = "LIMITED_QUANTITY"; +const std::string WECON::LIMITED_QUANTITY::defaultValue = "RATE"; +const std::string WECON::SECOND_MAX_WATER_CUT::itemName = "SECOND_MAX_WATER_CUT"; +const double WECON::SECOND_MAX_WATER_CUT::defaultValue = 0; +const std::string WECON::WORKOVER_SECOND_WATER_CUT_LIMIT::itemName = "WORKOVER_SECOND_WATER_CUT_LIMIT"; +const std::string WECON::MAX_GAS_LIQUID_RATIO::itemName = "MAX_GAS_LIQUID_RATIO"; +const double WECON::MAX_GAS_LIQUID_RATIO::defaultValue = 0; +const std::string WECON::MIN_LIQUID_PRODCUTION_RATE::itemName = "MIN_LIQUID_PRODCUTION_RATE"; +const double WECON::MIN_LIQUID_PRODCUTION_RATE::defaultValue = 0; +const std::string WECON::MAX_TEMP::itemName = "MAX_TEMP"; +const std::string WECON::MIN_RES_FLUID_RATE::itemName = "MIN_RES_FLUID_RATE"; +const double WECON::MIN_RES_FLUID_RATE::defaultValue = 0; + + WELLDIMS::WELLDIMS( ) : ParserKeyword("WELLDIMS") { setFixedSize( (size_t) 1); setDescription(""); @@ -13239,6 +13795,89 @@ const std::string WHISTCTL::BPH_TERMINATE::itemName = "BPH_TERMINATE"; const std::string WHISTCTL::BPH_TERMINATE::defaultValue = "NO"; +WLIFT::WLIFT( ) : ParserKeyword("WLIFT") { + setSizeType(SLASH_TERMINATED); + setDescription(""); + clearValidSectionNames(); + addValidSectionName("SCHEDULE"); + clearDeckNames(); + addDeckName("WLIFT"); + { + std::shared_ptr record = std::make_shared(); + { + ParserItemPtr item(new ParserStringItem("WELL",Opm::SINGLE)); + item->setDescription(""); + record->addItem(item); + } + { + ParserItemPtr item(new ParserDoubleItem("TRIGGER_LIMIT",Opm::SINGLE)); + item->setDescription(""); + record->addItem(item); + } + { + ParserItemPtr item(new ParserStringItem("TRIGGRE_PHASE",Opm::SINGLE)); + item->setDescription(""); + record->addItem(item); + } + { + ParserItemPtr item(new ParserIntItem("NEW_VFP_TABLE",Opm::SINGLE)); + item->setDescription(""); + record->addItem(item); + } + { + ParserItemPtr item(new ParserDoubleItem("NEW_ALQ_VALUE",Opm::SINGLE)); + item->setDescription(""); + record->addItem(item); + } + { + ParserItemPtr item(new ParserDoubleItem("NEW_WEFAC",Opm::SINGLE)); + item->setDescription(""); + record->addItem(item); + } + { + ParserItemPtr item(new ParserDoubleItem("WWCT_LIMIT",Opm::SINGLE)); + item->setDescription(""); + record->addItem(item); + } + { + ParserItemPtr item(new ParserDoubleItem("NEW_THP_LIMIT",Opm::SINGLE)); + item->setDescription(""); + item->push_backDimension("Pressure"); + record->addItem(item); + } + { + ParserItemPtr item(new ParserDoubleItem("WGOR_LIMIT",Opm::SINGLE)); + item->setDescription(""); + record->addItem(item); + } + { + ParserItemPtr item(new ParserDoubleItem("ALQ_SHIFT",Opm::SINGLE)); + item->setDescription(""); + record->addItem(item); + } + { + ParserItemPtr item(new ParserDoubleItem("THP_SHIFT",Opm::SINGLE)); + item->setDescription(""); + item->push_backDimension("Pressure"); + record->addItem(item); + } + addRecord( record ); + } +} +const std::string WLIFT::keywordName = "WLIFT"; +const std::string WLIFT::WELL::itemName = "WELL"; +const std::string WLIFT::TRIGGER_LIMIT::itemName = "TRIGGER_LIMIT"; +const std::string WLIFT::TRIGGRE_PHASE::itemName = "TRIGGRE_PHASE"; +const std::string WLIFT::NEW_VFP_TABLE::itemName = "NEW_VFP_TABLE"; +const std::string WLIFT::NEW_ALQ_VALUE::itemName = "NEW_ALQ_VALUE"; +const std::string WLIFT::NEW_WEFAC::itemName = "NEW_WEFAC"; +const std::string WLIFT::WWCT_LIMIT::itemName = "WWCT_LIMIT"; +const std::string WLIFT::NEW_THP_LIMIT::itemName = "NEW_THP_LIMIT"; +const std::string WLIFT::WGOR_LIMIT::itemName = "WGOR_LIMIT"; +const std::string WLIFT::ALQ_SHIFT::itemName = "ALQ_SHIFT"; +const std::string WLIFT::THP_SHIFT::itemName = "THP_SHIFT"; + + WPAVE::WPAVE( ) : ParserKeyword("WPAVE") { setFixedSize( (size_t) 1); setDescription(""); diff --git a/ThirdParty/custom-opm-parser/generated-source/ParserKeywords0.cpp b/ThirdParty/custom-opm-parser/generated-source/ParserKeywords0.cpp index 03e6890ab8..c390d1333f 100644 --- a/ThirdParty/custom-opm-parser/generated-source/ParserKeywords0.cpp +++ b/ThirdParty/custom-opm-parser/generated-source/ParserKeywords0.cpp @@ -12,6 +12,7 @@ namespace Opm { namespace ParserKeywords { +void addDefaultKeywords0(Parser& p); void addDefaultKeywords0(Parser& p) { p.addKeyword< ParserKeywords::ACTDIMS >(); p.addKeyword< ParserKeywords::ACTNUM >(); @@ -20,8 +21,11 @@ p.addKeyword< ParserKeywords::ADDREG >(); p.addKeyword< ParserKeywords::ADSALNOD >(); p.addKeyword< ParserKeywords::ALL >(); p.addKeyword< ParserKeywords::API >(); +p.addKeyword< ParserKeywords::AQUANCON >(); p.addKeyword< ParserKeywords::AQUCON >(); p.addKeyword< ParserKeywords::AQUDIMS >(); +p.addKeyword< ParserKeywords::AQUFETP >(); +p.addKeyword< ParserKeywords::AQUIFER_PROBE_ANALYTIC >(); p.addKeyword< ParserKeywords::AQUNUM >(); p.addKeyword< ParserKeywords::BLOCK_PROBE >(); p.addKeyword< ParserKeywords::BLOCK_PROBE300 >(); @@ -40,6 +44,7 @@ p.addKeyword< ParserKeywords::CREF >(); p.addKeyword< ParserKeywords::CREFS >(); p.addKeyword< ParserKeywords::DATE >(); p.addKeyword< ParserKeywords::DATES >(); +p.addKeyword< ParserKeywords::DATUM >(); p.addKeyword< ParserKeywords::DENSITY >(); p.addKeyword< ParserKeywords::DEPTH >(); p.addKeyword< ParserKeywords::DEPTHZ >(); @@ -49,6 +54,7 @@ p.addKeyword< ParserKeywords::DREF >(); p.addKeyword< ParserKeywords::DREFS >(); p.addKeyword< ParserKeywords::DRSDT >(); p.addKeyword< ParserKeywords::DRVDT >(); +p.addKeyword< ParserKeywords::DUMPFLUX >(); p.addKeyword< ParserKeywords::DX >(); p.addKeyword< ParserKeywords::DXV >(); p.addKeyword< ParserKeywords::DY >(); @@ -94,7 +100,5 @@ p.addKeyword< ParserKeywords::GCONPROD >(); p.addKeyword< ParserKeywords::GDORIENT >(); p.addKeyword< ParserKeywords::GECON >(); p.addKeyword< ParserKeywords::GEFAC >(); -p.addKeyword< ParserKeywords::GRID >(); -p.addKeyword< ParserKeywords::GRIDFILE >(); -p.addKeyword< ParserKeywords::GRIDOPTS >(); +p.addKeyword< ParserKeywords::GRAVITY >(); }}} diff --git a/ThirdParty/custom-opm-parser/generated-source/ParserKeywords1.cpp b/ThirdParty/custom-opm-parser/generated-source/ParserKeywords1.cpp index 827f9dc492..f7a6f2af1c 100644 --- a/ThirdParty/custom-opm-parser/generated-source/ParserKeywords1.cpp +++ b/ThirdParty/custom-opm-parser/generated-source/ParserKeywords1.cpp @@ -12,7 +12,11 @@ namespace Opm { namespace ParserKeywords { +void addDefaultKeywords1(Parser& p); void addDefaultKeywords1(Parser& p) { +p.addKeyword< ParserKeywords::GRID >(); +p.addKeyword< ParserKeywords::GRIDFILE >(); +p.addKeyword< ParserKeywords::GRIDOPTS >(); p.addKeyword< ParserKeywords::GRIDUNIT >(); p.addKeyword< ParserKeywords::GROUP_PROBE >(); p.addKeyword< ParserKeywords::GRUPNET >(); @@ -33,6 +37,7 @@ p.addKeyword< ParserKeywords::ISOWCR >(); p.addKeyword< ParserKeywords::ISWCR >(); p.addKeyword< ParserKeywords::ISWL >(); p.addKeyword< ParserKeywords::ISWU >(); +p.addKeyword< ParserKeywords::JFUNC >(); p.addKeyword< ParserKeywords::MAPAXES >(); p.addKeyword< ParserKeywords::MAPUNITS >(); p.addKeyword< ParserKeywords::MAXVALUE >(); @@ -53,6 +58,7 @@ p.addKeyword< ParserKeywords::MULTIPLY >(); p.addKeyword< ParserKeywords::MULTIREG >(); p.addKeyword< ParserKeywords::MULTNUM >(); p.addKeyword< ParserKeywords::MULTPV >(); +p.addKeyword< ParserKeywords::MULTREGP >(); p.addKeyword< ParserKeywords::MULTREGT >(); p.addKeyword< ParserKeywords::MULT_XYZ >(); p.addKeyword< ParserKeywords::MW >(); @@ -95,6 +101,4 @@ p.addKeyword< ParserKeywords::PERMYZ >(); p.addKeyword< ParserKeywords::PERMZ >(); p.addKeyword< ParserKeywords::PERMZX >(); p.addKeyword< ParserKeywords::PIMTDIMS >(); -p.addKeyword< ParserKeywords::PIMULTAB >(); -p.addKeyword< ParserKeywords::PINCH >(); }}} diff --git a/ThirdParty/custom-opm-parser/generated-source/ParserKeywords2.cpp b/ThirdParty/custom-opm-parser/generated-source/ParserKeywords2.cpp index 413ba94eae..3d93f81f4e 100644 --- a/ThirdParty/custom-opm-parser/generated-source/ParserKeywords2.cpp +++ b/ThirdParty/custom-opm-parser/generated-source/ParserKeywords2.cpp @@ -12,7 +12,10 @@ namespace Opm { namespace ParserKeywords { +void addDefaultKeywords2(Parser& p); void addDefaultKeywords2(Parser& p) { +p.addKeyword< ParserKeywords::PIMULTAB >(); +p.addKeyword< ParserKeywords::PINCH >(); p.addKeyword< ParserKeywords::PLMIXPAR >(); p.addKeyword< ParserKeywords::PLYADS >(); p.addKeyword< ParserKeywords::PLYADSS >(); @@ -52,6 +55,7 @@ p.addKeyword< ParserKeywords::RPTGRID >(); p.addKeyword< ParserKeywords::RPTONLY >(); p.addKeyword< ParserKeywords::RPTONLYO >(); p.addKeyword< ParserKeywords::RPTPROPS >(); +p.addKeyword< ParserKeywords::RPTREGS >(); p.addKeyword< ParserKeywords::RPTRST >(); p.addKeyword< ParserKeywords::RPTRUNSP >(); p.addKeyword< ParserKeywords::RPTSCHED >(); diff --git a/ThirdParty/custom-opm-parser/generated-source/ParserKeywords3.cpp b/ThirdParty/custom-opm-parser/generated-source/ParserKeywords3.cpp index 95e66da024..a0509a4a45 100644 --- a/ThirdParty/custom-opm-parser/generated-source/ParserKeywords3.cpp +++ b/ThirdParty/custom-opm-parser/generated-source/ParserKeywords3.cpp @@ -12,6 +12,7 @@ namespace Opm { namespace ParserKeywords { +void addDefaultKeywords3(Parser& p); void addDefaultKeywords3(Parser& p) { p.addKeyword< ParserKeywords::SSOL >(); p.addKeyword< ParserKeywords::START >(); @@ -38,6 +39,7 @@ p.addKeyword< ParserKeywords::THPRES >(); p.addKeyword< ParserKeywords::TITLE >(); p.addKeyword< ParserKeywords::TLMIXPAR >(); p.addKeyword< ParserKeywords::TLPMIXPA >(); +p.addKeyword< ParserKeywords::TNUM >(); p.addKeyword< ParserKeywords::TOPS >(); p.addKeyword< ParserKeywords::TRACER >(); p.addKeyword< ParserKeywords::TRACERS >(); @@ -68,6 +70,8 @@ p.addKeyword< ParserKeywords::WCONINJ >(); p.addKeyword< ParserKeywords::WCONINJE >(); p.addKeyword< ParserKeywords::WCONINJH >(); p.addKeyword< ParserKeywords::WCONPROD >(); +p.addKeyword< ParserKeywords::WDRILTIM >(); +p.addKeyword< ParserKeywords::WECON >(); p.addKeyword< ParserKeywords::WELLDIMS >(); p.addKeyword< ParserKeywords::WELL_PROBE >(); p.addKeyword< ParserKeywords::WELOPEN >(); @@ -76,6 +80,7 @@ p.addKeyword< ParserKeywords::WELSPECS >(); p.addKeyword< ParserKeywords::WELTARG >(); p.addKeyword< ParserKeywords::WGRUPCON >(); p.addKeyword< ParserKeywords::WHISTCTL >(); +p.addKeyword< ParserKeywords::WLIFT >(); p.addKeyword< ParserKeywords::WPAVE >(); p.addKeyword< ParserKeywords::WPIMULT >(); p.addKeyword< ParserKeywords::WPITAB >(); diff --git a/ThirdParty/custom-opm-parser/generated-source/include/opm/parser/eclipse/Parser/ParserKeywords.hpp b/ThirdParty/custom-opm-parser/generated-source/include/opm/parser/eclipse/Parser/ParserKeywords.hpp index f8f650715f..eb2b02aa5d 100644 --- a/ThirdParty/custom-opm-parser/generated-source/include/opm/parser/eclipse/Parser/ParserKeywords.hpp +++ b/ThirdParty/custom-opm-parser/generated-source/include/opm/parser/eclipse/Parser/ParserKeywords.hpp @@ -13,6 +13,7 @@ namespace ParserKeywords { #include #include #include +#include #include #include #include diff --git a/ThirdParty/custom-opm-parser/generated-source/include/opm/parser/eclipse/Parser/ParserKeywords/A.hpp b/ThirdParty/custom-opm-parser/generated-source/include/opm/parser/eclipse/Parser/ParserKeywords/A.hpp index b4327053a1..5fc85fbdec 100644 --- a/ThirdParty/custom-opm-parser/generated-source/include/opm/parser/eclipse/Parser/ParserKeywords/A.hpp +++ b/ThirdParty/custom-opm-parser/generated-source/include/opm/parser/eclipse/Parser/ParserKeywords/A.hpp @@ -156,6 +156,69 @@ namespace ParserKeywords { + class AQUANCON : public ParserKeyword { + public: + AQUANCON(); + static const std::string keywordName; + + class AQUIFER_ID { + public: + static const std::string itemName; + }; + + class I1 { + public: + static const std::string itemName; + }; + + class I2 { + public: + static const std::string itemName; + }; + + class J1 { + public: + static const std::string itemName; + }; + + class J2 { + public: + static const std::string itemName; + }; + + class K1 { + public: + static const std::string itemName; + }; + + class K2 { + public: + static const std::string itemName; + }; + + class FACE { + public: + static const std::string itemName; + }; + + class INFLUX_COEFF { + public: + static const std::string itemName; + }; + + class INFLUX_MULT { + public: + static const std::string itemName; + }; + + class CONNECT_ADJOINING_ACTIVE_CELL { + public: + static const std::string itemName; + }; + }; + + + class AQUCON : public ParserKeyword { public: AQUCON(); @@ -285,6 +348,72 @@ namespace ParserKeywords { + class AQUFETP : public ParserKeyword { + public: + AQUFETP(); + static const std::string keywordName; + + class ID { + public: + static const std::string itemName; + }; + + class DATUM_DEPTH { + public: + static const std::string itemName; + }; + + class P0 { + public: + static const std::string itemName; + }; + + class V0 { + public: + static const std::string itemName; + }; + + class COMPRESSIBILITY { + public: + static const std::string itemName; + }; + + class PI { + public: + static const std::string itemName; + }; + + class WATER_TABLE { + public: + static const std::string itemName; + }; + + class SALINITY { + public: + static const std::string itemName; + }; + + class TEMP { + public: + static const std::string itemName; + }; + }; + + + + class AQUIFER_PROBE_ANALYTIC : public ParserKeyword { + public: + AQUIFER_PROBE_ANALYTIC(); + static const std::string keywordName; + + class data { + public: + static const std::string itemName; + }; + }; + + + class AQUNUM : public ParserKeyword { public: AQUNUM(); diff --git a/ThirdParty/custom-opm-parser/generated-source/include/opm/parser/eclipse/Parser/ParserKeywords/D.hpp b/ThirdParty/custom-opm-parser/generated-source/include/opm/parser/eclipse/Parser/ParserKeywords/D.hpp index 57261e5e6b..934314eed1 100644 --- a/ThirdParty/custom-opm-parser/generated-source/include/opm/parser/eclipse/Parser/ParserKeywords/D.hpp +++ b/ThirdParty/custom-opm-parser/generated-source/include/opm/parser/eclipse/Parser/ParserKeywords/D.hpp @@ -41,6 +41,19 @@ namespace ParserKeywords { + class DATUM : public ParserKeyword { + public: + DATUM(); + static const std::string keywordName; + + class DEPTH { + public: + static const std::string itemName; + }; + }; + + + class DENSITY : public ParserKeyword { public: DENSITY(); @@ -182,6 +195,14 @@ namespace ParserKeywords { + class DUMPFLUX : public ParserKeyword { + public: + DUMPFLUX(); + static const std::string keywordName; + }; + + + class DX : public ParserKeyword { public: DX(); diff --git a/ThirdParty/custom-opm-parser/generated-source/include/opm/parser/eclipse/Parser/ParserKeywords/G.hpp b/ThirdParty/custom-opm-parser/generated-source/include/opm/parser/eclipse/Parser/ParserKeywords/G.hpp index 796c1c32d0..e51c7d3491 100644 --- a/ThirdParty/custom-opm-parser/generated-source/include/opm/parser/eclipse/Parser/ParserKeywords/G.hpp +++ b/ThirdParty/custom-opm-parser/generated-source/include/opm/parser/eclipse/Parser/ParserKeywords/G.hpp @@ -333,6 +333,31 @@ namespace ParserKeywords { + class GRAVITY : public ParserKeyword { + public: + GRAVITY(); + static const std::string keywordName; + + class API_GRAVITY { + public: + static const std::string itemName; + }; + + class WATER_SP_GRAVITY { + public: + static const std::string itemName; + static const double defaultValue; + }; + + class GAS_SP_GRAVITY { + public: + static const std::string itemName; + static const double defaultValue; + }; + }; + + + class GRID : public ParserKeyword { public: GRID(); diff --git a/ThirdParty/custom-opm-parser/generated-source/include/opm/parser/eclipse/Parser/ParserKeywords/J.hpp b/ThirdParty/custom-opm-parser/generated-source/include/opm/parser/eclipse/Parser/ParserKeywords/J.hpp new file mode 100644 index 0000000000..c8072410b2 --- /dev/null +++ b/ThirdParty/custom-opm-parser/generated-source/include/opm/parser/eclipse/Parser/ParserKeywords/J.hpp @@ -0,0 +1,53 @@ +#ifndef PARSER_KEYWORDS_J_HPP +#define PARSER_KEYWORDS_J_HPP +#include +namespace Opm { +namespace ParserKeywords { + + class JFUNC : public ParserKeyword { + public: + JFUNC(); + static const std::string keywordName; + + class FLAG { + public: + static const std::string itemName; + static const std::string defaultValue; + }; + + class OW_SURFACE_TENSION { + public: + static const std::string itemName; + static const double defaultValue; + }; + + class GO_SURFACE_TENSION { + public: + static const std::string itemName; + static const double defaultValue; + }; + + class ALPHA_FACTOR { + public: + static const std::string itemName; + static const double defaultValue; + }; + + class BETA_FACTOR { + public: + static const std::string itemName; + static const double defaultValue; + }; + + class DIRECTION { + public: + static const std::string itemName; + static const std::string defaultValue; + }; + }; + + + +} +} +#endif diff --git a/ThirdParty/custom-opm-parser/generated-source/include/opm/parser/eclipse/Parser/ParserKeywords/M.hpp b/ThirdParty/custom-opm-parser/generated-source/include/opm/parser/eclipse/Parser/ParserKeywords/M.hpp index cb49e3041e..4dc5f6ff85 100644 --- a/ThirdParty/custom-opm-parser/generated-source/include/opm/parser/eclipse/Parser/ParserKeywords/M.hpp +++ b/ThirdParty/custom-opm-parser/generated-source/include/opm/parser/eclipse/Parser/ParserKeywords/M.hpp @@ -494,6 +494,30 @@ namespace ParserKeywords { + class MULTREGP : public ParserKeyword { + public: + MULTREGP(); + static const std::string keywordName; + + class REGION { + public: + static const std::string itemName; + }; + + class MULTIPLIER { + public: + static const std::string itemName; + }; + + class REGION_TYPE { + public: + static const std::string itemName; + static const std::string defaultValue; + }; + }; + + + class MULTREGT : public ParserKeyword { public: MULTREGT(); diff --git a/ThirdParty/custom-opm-parser/generated-source/include/opm/parser/eclipse/Parser/ParserKeywords/R.hpp b/ThirdParty/custom-opm-parser/generated-source/include/opm/parser/eclipse/Parser/ParserKeywords/R.hpp index a2eb565f4b..83bfe61190 100644 --- a/ThirdParty/custom-opm-parser/generated-source/include/opm/parser/eclipse/Parser/ParserKeywords/R.hpp +++ b/ThirdParty/custom-opm-parser/generated-source/include/opm/parser/eclipse/Parser/ParserKeywords/R.hpp @@ -328,6 +328,19 @@ namespace ParserKeywords { + class RPTREGS : public ParserKeyword { + public: + RPTREGS(); + static const std::string keywordName; + + class MNEMONIC_LIST { + public: + static const std::string itemName; + }; + }; + + + class RPTRST : public ParserKeyword { public: RPTRST(); diff --git a/ThirdParty/custom-opm-parser/generated-source/include/opm/parser/eclipse/Parser/ParserKeywords/T.hpp b/ThirdParty/custom-opm-parser/generated-source/include/opm/parser/eclipse/Parser/ParserKeywords/T.hpp index 8dd6f2204e..80d21085a8 100644 --- a/ThirdParty/custom-opm-parser/generated-source/include/opm/parser/eclipse/Parser/ParserKeywords/T.hpp +++ b/ThirdParty/custom-opm-parser/generated-source/include/opm/parser/eclipse/Parser/ParserKeywords/T.hpp @@ -298,6 +298,19 @@ namespace ParserKeywords { + class TNUM : public ParserKeyword { + public: + TNUM(); + static const std::string keywordName; + + class data { + public: + static const std::string itemName; + }; + }; + + + class TOPS : public ParserKeyword { public: TOPS(); diff --git a/ThirdParty/custom-opm-parser/generated-source/include/opm/parser/eclipse/Parser/ParserKeywords/W.hpp b/ThirdParty/custom-opm-parser/generated-source/include/opm/parser/eclipse/Parser/ParserKeywords/W.hpp index 99d3f3cf93..b484eccf1a 100644 --- a/ThirdParty/custom-opm-parser/generated-source/include/opm/parser/eclipse/Parser/ParserKeywords/W.hpp +++ b/ThirdParty/custom-opm-parser/generated-source/include/opm/parser/eclipse/Parser/ParserKeywords/W.hpp @@ -410,6 +410,135 @@ namespace ParserKeywords { + class WDRILTIM : public ParserKeyword { + public: + WDRILTIM(); + static const std::string keywordName; + + class WELL { + public: + static const std::string itemName; + }; + + class DRILL_TIME { + public: + static const std::string itemName; + }; + + class WORKOVER_CLOSE { + public: + static const std::string itemName; + }; + + class COMPARTMENT { + public: + static const std::string itemName; + }; + }; + + + + class WECON : public ParserKeyword { + public: + WECON(); + static const std::string keywordName; + + class WELL { + public: + static const std::string itemName; + }; + + class MIN_OIL_PRODUCTION { + public: + static const std::string itemName; + static const double defaultValue; + }; + + class MIN_GAS_PRODUCTION { + public: + static const std::string itemName; + static const double defaultValue; + }; + + class MAX_WATER_CUT { + public: + static const std::string itemName; + static const double defaultValue; + }; + + class MAX_GAS_OIL_RATIO { + public: + static const std::string itemName; + static const double defaultValue; + }; + + class MAX_WATER_GAS_RATIO { + public: + static const std::string itemName; + static const double defaultValue; + }; + + class WORKOVER_RATIO_LIMIT { + public: + static const std::string itemName; + static const std::string defaultValue; + }; + + class END_RUN_FLAG { + public: + static const std::string itemName; + static const std::string defaultValue; + }; + + class FOLLOW_ON_WELL { + public: + static const std::string itemName; + static const std::string defaultValue; + }; + + class LIMITED_QUANTITY { + public: + static const std::string itemName; + static const std::string defaultValue; + }; + + class SECOND_MAX_WATER_CUT { + public: + static const std::string itemName; + static const double defaultValue; + }; + + class WORKOVER_SECOND_WATER_CUT_LIMIT { + public: + static const std::string itemName; + }; + + class MAX_GAS_LIQUID_RATIO { + public: + static const std::string itemName; + static const double defaultValue; + }; + + class MIN_LIQUID_PRODCUTION_RATE { + public: + static const std::string itemName; + static const double defaultValue; + }; + + class MAX_TEMP { + public: + static const std::string itemName; + }; + + class MIN_RES_FLUID_RATE { + public: + static const std::string itemName; + static const double defaultValue; + }; + }; + + + class WELLDIMS : public ParserKeyword { public: WELLDIMS(); @@ -855,6 +984,69 @@ namespace ParserKeywords { + class WLIFT : public ParserKeyword { + public: + WLIFT(); + static const std::string keywordName; + + class WELL { + public: + static const std::string itemName; + }; + + class TRIGGER_LIMIT { + public: + static const std::string itemName; + }; + + class TRIGGRE_PHASE { + public: + static const std::string itemName; + }; + + class NEW_VFP_TABLE { + public: + static const std::string itemName; + }; + + class NEW_ALQ_VALUE { + public: + static const std::string itemName; + }; + + class NEW_WEFAC { + public: + static const std::string itemName; + }; + + class WWCT_LIMIT { + public: + static const std::string itemName; + }; + + class NEW_THP_LIMIT { + public: + static const std::string itemName; + }; + + class WGOR_LIMIT { + public: + static const std::string itemName; + }; + + class ALQ_SHIFT { + public: + static const std::string itemName; + }; + + class THP_SHIFT { + public: + static const std::string itemName; + }; + }; + + + class WPAVE : public ParserKeyword { public: WPAVE(); diff --git a/ThirdParty/custom-opm-parser/generated-source/inlineKeywordTest.cpp b/ThirdParty/custom-opm-parser/generated-source/inlineKeywordTest.cpp index 13eda8f8aa..a68fc9eedd 100644 --- a/ThirdParty/custom-opm-parser/generated-source/inlineKeywordTest.cpp +++ b/ThirdParty/custom-opm-parser/generated-source/inlineKeywordTest.cpp @@ -146,6 +146,25 @@ BOOST_AUTO_TEST_CASE(TESTAPIKeyword) { } } +BOOST_AUTO_TEST_CASE(TESTAQUANCONKeyword) { + std::string jsonFile = "E:/Jenkins/jobs/opm-parser-create-keywords/workspace/opm-parser/opm/parser/share/keywords/000_Eclipse100/A/AQUANCON"; + boost::filesystem::path jsonPath( jsonFile ); + Json::JsonObject jsonConfig( jsonPath ); + ParserKeyword jsonKeyword(jsonConfig); + ParserKeywords::AQUANCON inlineKeyword; + BOOST_CHECK( jsonKeyword.equal( inlineKeyword )); + if (jsonKeyword.hasDimension()) { + ParserRecordConstPtr parserRecord = jsonKeyword.getRecord(0); + for (size_t i=0; i < parserRecord->size(); i++){ + ParserItemConstPtr item = parserRecord->get( i ); + for (size_t j=0; j < item->numDimensions(); j++) { + std::string dimString = item->getDimension(j); + BOOST_CHECK_NO_THROW( unitSystem->getNewDimension( dimString )); + } + } + } +} + BOOST_AUTO_TEST_CASE(TESTAQUCONKeyword) { std::string jsonFile = "E:/Jenkins/jobs/opm-parser-create-keywords/workspace/opm-parser/opm/parser/share/keywords/000_Eclipse100/A/AQUCON"; boost::filesystem::path jsonPath( jsonFile ); @@ -184,6 +203,44 @@ BOOST_AUTO_TEST_CASE(TESTAQUDIMSKeyword) { } } +BOOST_AUTO_TEST_CASE(TESTAQUFETPKeyword) { + std::string jsonFile = "E:/Jenkins/jobs/opm-parser-create-keywords/workspace/opm-parser/opm/parser/share/keywords/000_Eclipse100/A/AQUFETP"; + boost::filesystem::path jsonPath( jsonFile ); + Json::JsonObject jsonConfig( jsonPath ); + ParserKeyword jsonKeyword(jsonConfig); + ParserKeywords::AQUFETP inlineKeyword; + BOOST_CHECK( jsonKeyword.equal( inlineKeyword )); + if (jsonKeyword.hasDimension()) { + ParserRecordConstPtr parserRecord = jsonKeyword.getRecord(0); + for (size_t i=0; i < parserRecord->size(); i++){ + ParserItemConstPtr item = parserRecord->get( i ); + for (size_t j=0; j < item->numDimensions(); j++) { + std::string dimString = item->getDimension(j); + BOOST_CHECK_NO_THROW( unitSystem->getNewDimension( dimString )); + } + } + } +} + +BOOST_AUTO_TEST_CASE(TESTAQUIFER_PROBE_ANALYTICKeyword) { + std::string jsonFile = "E:/Jenkins/jobs/opm-parser-create-keywords/workspace/opm-parser/opm/parser/share/keywords/000_Eclipse100/A/AQUIFER_PROBE_ANALYTIC"; + boost::filesystem::path jsonPath( jsonFile ); + Json::JsonObject jsonConfig( jsonPath ); + ParserKeyword jsonKeyword(jsonConfig); + ParserKeywords::AQUIFER_PROBE_ANALYTIC inlineKeyword; + BOOST_CHECK( jsonKeyword.equal( inlineKeyword )); + if (jsonKeyword.hasDimension()) { + ParserRecordConstPtr parserRecord = jsonKeyword.getRecord(0); + for (size_t i=0; i < parserRecord->size(); i++){ + ParserItemConstPtr item = parserRecord->get( i ); + for (size_t j=0; j < item->numDimensions(); j++) { + std::string dimString = item->getDimension(j); + BOOST_CHECK_NO_THROW( unitSystem->getNewDimension( dimString )); + } + } + } +} + BOOST_AUTO_TEST_CASE(TESTAQUNUMKeyword) { std::string jsonFile = "E:/Jenkins/jobs/opm-parser-create-keywords/workspace/opm-parser/opm/parser/share/keywords/000_Eclipse100/A/AQUNUM"; boost::filesystem::path jsonPath( jsonFile ); @@ -526,6 +583,25 @@ BOOST_AUTO_TEST_CASE(TESTDATESKeyword) { } } +BOOST_AUTO_TEST_CASE(TESTDATUMKeyword) { + std::string jsonFile = "E:/Jenkins/jobs/opm-parser-create-keywords/workspace/opm-parser/opm/parser/share/keywords/000_Eclipse100/D/DATUM"; + boost::filesystem::path jsonPath( jsonFile ); + Json::JsonObject jsonConfig( jsonPath ); + ParserKeyword jsonKeyword(jsonConfig); + ParserKeywords::DATUM inlineKeyword; + BOOST_CHECK( jsonKeyword.equal( inlineKeyword )); + if (jsonKeyword.hasDimension()) { + ParserRecordConstPtr parserRecord = jsonKeyword.getRecord(0); + for (size_t i=0; i < parserRecord->size(); i++){ + ParserItemConstPtr item = parserRecord->get( i ); + for (size_t j=0; j < item->numDimensions(); j++) { + std::string dimString = item->getDimension(j); + BOOST_CHECK_NO_THROW( unitSystem->getNewDimension( dimString )); + } + } + } +} + BOOST_AUTO_TEST_CASE(TESTDENSITYKeyword) { std::string jsonFile = "E:/Jenkins/jobs/opm-parser-create-keywords/workspace/opm-parser/opm/parser/share/keywords/000_Eclipse100/D/DENSITY"; boost::filesystem::path jsonPath( jsonFile ); @@ -697,6 +773,25 @@ BOOST_AUTO_TEST_CASE(TESTDRVDTKeyword) { } } +BOOST_AUTO_TEST_CASE(TESTDUMPFLUXKeyword) { + std::string jsonFile = "E:/Jenkins/jobs/opm-parser-create-keywords/workspace/opm-parser/opm/parser/share/keywords/000_Eclipse100/D/DUMPFLUX"; + boost::filesystem::path jsonPath( jsonFile ); + Json::JsonObject jsonConfig( jsonPath ); + ParserKeyword jsonKeyword(jsonConfig); + ParserKeywords::DUMPFLUX inlineKeyword; + BOOST_CHECK( jsonKeyword.equal( inlineKeyword )); + if (jsonKeyword.hasDimension()) { + ParserRecordConstPtr parserRecord = jsonKeyword.getRecord(0); + for (size_t i=0; i < parserRecord->size(); i++){ + ParserItemConstPtr item = parserRecord->get( i ); + for (size_t j=0; j < item->numDimensions(); j++) { + std::string dimString = item->getDimension(j); + BOOST_CHECK_NO_THROW( unitSystem->getNewDimension( dimString )); + } + } + } +} + BOOST_AUTO_TEST_CASE(TESTDXKeyword) { std::string jsonFile = "E:/Jenkins/jobs/opm-parser-create-keywords/workspace/opm-parser/opm/parser/share/keywords/000_Eclipse100/D/DX"; boost::filesystem::path jsonPath( jsonFile ); @@ -1552,6 +1647,25 @@ BOOST_AUTO_TEST_CASE(TESTGEFACKeyword) { } } +BOOST_AUTO_TEST_CASE(TESTGRAVITYKeyword) { + std::string jsonFile = "E:/Jenkins/jobs/opm-parser-create-keywords/workspace/opm-parser/opm/parser/share/keywords/000_Eclipse100/G/GRAVITY"; + boost::filesystem::path jsonPath( jsonFile ); + Json::JsonObject jsonConfig( jsonPath ); + ParserKeyword jsonKeyword(jsonConfig); + ParserKeywords::GRAVITY inlineKeyword; + BOOST_CHECK( jsonKeyword.equal( inlineKeyword )); + if (jsonKeyword.hasDimension()) { + ParserRecordConstPtr parserRecord = jsonKeyword.getRecord(0); + for (size_t i=0; i < parserRecord->size(); i++){ + ParserItemConstPtr item = parserRecord->get( i ); + for (size_t j=0; j < item->numDimensions(); j++) { + std::string dimString = item->getDimension(j); + BOOST_CHECK_NO_THROW( unitSystem->getNewDimension( dimString )); + } + } + } +} + BOOST_AUTO_TEST_CASE(TESTGRIDKeyword) { std::string jsonFile = "E:/Jenkins/jobs/opm-parser-create-keywords/workspace/opm-parser/opm/parser/share/keywords/000_Eclipse100/G/GRID"; boost::filesystem::path jsonPath( jsonFile ); @@ -1989,6 +2103,25 @@ BOOST_AUTO_TEST_CASE(TESTISWUKeyword) { } } +BOOST_AUTO_TEST_CASE(TESTJFUNCKeyword) { + std::string jsonFile = "E:/Jenkins/jobs/opm-parser-create-keywords/workspace/opm-parser/opm/parser/share/keywords/000_Eclipse100/J/JFUNC"; + boost::filesystem::path jsonPath( jsonFile ); + Json::JsonObject jsonConfig( jsonPath ); + ParserKeyword jsonKeyword(jsonConfig); + ParserKeywords::JFUNC inlineKeyword; + BOOST_CHECK( jsonKeyword.equal( inlineKeyword )); + if (jsonKeyword.hasDimension()) { + ParserRecordConstPtr parserRecord = jsonKeyword.getRecord(0); + for (size_t i=0; i < parserRecord->size(); i++){ + ParserItemConstPtr item = parserRecord->get( i ); + for (size_t j=0; j < item->numDimensions(); j++) { + std::string dimString = item->getDimension(j); + BOOST_CHECK_NO_THROW( unitSystem->getNewDimension( dimString )); + } + } + } +} + BOOST_AUTO_TEST_CASE(TESTMAPAXESKeyword) { std::string jsonFile = "E:/Jenkins/jobs/opm-parser-create-keywords/workspace/opm-parser/opm/parser/share/keywords/000_Eclipse100/M/MAPAXES"; boost::filesystem::path jsonPath( jsonFile ); @@ -2369,6 +2502,25 @@ BOOST_AUTO_TEST_CASE(TESTMULTPVKeyword) { } } +BOOST_AUTO_TEST_CASE(TESTMULTREGPKeyword) { + std::string jsonFile = "E:/Jenkins/jobs/opm-parser-create-keywords/workspace/opm-parser/opm/parser/share/keywords/000_Eclipse100/M/MULTREGP"; + boost::filesystem::path jsonPath( jsonFile ); + Json::JsonObject jsonConfig( jsonPath ); + ParserKeyword jsonKeyword(jsonConfig); + ParserKeywords::MULTREGP inlineKeyword; + BOOST_CHECK( jsonKeyword.equal( inlineKeyword )); + if (jsonKeyword.hasDimension()) { + ParserRecordConstPtr parserRecord = jsonKeyword.getRecord(0); + for (size_t i=0; i < parserRecord->size(); i++){ + ParserItemConstPtr item = parserRecord->get( i ); + for (size_t j=0; j < item->numDimensions(); j++) { + std::string dimString = item->getDimension(j); + BOOST_CHECK_NO_THROW( unitSystem->getNewDimension( dimString )); + } + } + } +} + BOOST_AUTO_TEST_CASE(TESTMULTREGTKeyword) { std::string jsonFile = "E:/Jenkins/jobs/opm-parser-create-keywords/workspace/opm-parser/opm/parser/share/keywords/000_Eclipse100/M/MULTREGT"; boost::filesystem::path jsonPath( jsonFile ); @@ -3946,6 +4098,25 @@ BOOST_AUTO_TEST_CASE(TESTRPTPROPSKeyword) { } } +BOOST_AUTO_TEST_CASE(TESTRPTREGSKeyword) { + std::string jsonFile = "E:/Jenkins/jobs/opm-parser-create-keywords/workspace/opm-parser/opm/parser/share/keywords/000_Eclipse100/R/RPTREGS"; + boost::filesystem::path jsonPath( jsonFile ); + Json::JsonObject jsonConfig( jsonPath ); + ParserKeyword jsonKeyword(jsonConfig); + ParserKeywords::RPTREGS inlineKeyword; + BOOST_CHECK( jsonKeyword.equal( inlineKeyword )); + if (jsonKeyword.hasDimension()) { + ParserRecordConstPtr parserRecord = jsonKeyword.getRecord(0); + for (size_t i=0; i < parserRecord->size(); i++){ + ParserItemConstPtr item = parserRecord->get( i ); + for (size_t j=0; j < item->numDimensions(); j++) { + std::string dimString = item->getDimension(j); + BOOST_CHECK_NO_THROW( unitSystem->getNewDimension( dimString )); + } + } + } +} + BOOST_AUTO_TEST_CASE(TESTRPTRSTKeyword) { std::string jsonFile = "E:/Jenkins/jobs/opm-parser-create-keywords/workspace/opm-parser/opm/parser/share/keywords/000_Eclipse100/R/RPTRST"; boost::filesystem::path jsonPath( jsonFile ); @@ -5276,6 +5447,25 @@ BOOST_AUTO_TEST_CASE(TESTTLPMIXPAKeyword) { } } +BOOST_AUTO_TEST_CASE(TESTTNUMKeyword) { + std::string jsonFile = "E:/Jenkins/jobs/opm-parser-create-keywords/workspace/opm-parser/opm/parser/share/keywords/000_Eclipse100/T/TNUM"; + boost::filesystem::path jsonPath( jsonFile ); + Json::JsonObject jsonConfig( jsonPath ); + ParserKeyword jsonKeyword(jsonConfig); + ParserKeywords::TNUM inlineKeyword; + BOOST_CHECK( jsonKeyword.equal( inlineKeyword )); + if (jsonKeyword.hasDimension()) { + ParserRecordConstPtr parserRecord = jsonKeyword.getRecord(0); + for (size_t i=0; i < parserRecord->size(); i++){ + ParserItemConstPtr item = parserRecord->get( i ); + for (size_t j=0; j < item->numDimensions(); j++) { + std::string dimString = item->getDimension(j); + BOOST_CHECK_NO_THROW( unitSystem->getNewDimension( dimString )); + } + } + } +} + BOOST_AUTO_TEST_CASE(TESTTOPSKeyword) { std::string jsonFile = "E:/Jenkins/jobs/opm-parser-create-keywords/workspace/opm-parser/opm/parser/share/keywords/000_Eclipse100/T/TOPS"; boost::filesystem::path jsonPath( jsonFile ); @@ -5846,6 +6036,44 @@ BOOST_AUTO_TEST_CASE(TESTWCONPRODKeyword) { } } +BOOST_AUTO_TEST_CASE(TESTWDRILTIMKeyword) { + std::string jsonFile = "E:/Jenkins/jobs/opm-parser-create-keywords/workspace/opm-parser/opm/parser/share/keywords/000_Eclipse100/W/WDRILTIM"; + boost::filesystem::path jsonPath( jsonFile ); + Json::JsonObject jsonConfig( jsonPath ); + ParserKeyword jsonKeyword(jsonConfig); + ParserKeywords::WDRILTIM inlineKeyword; + BOOST_CHECK( jsonKeyword.equal( inlineKeyword )); + if (jsonKeyword.hasDimension()) { + ParserRecordConstPtr parserRecord = jsonKeyword.getRecord(0); + for (size_t i=0; i < parserRecord->size(); i++){ + ParserItemConstPtr item = parserRecord->get( i ); + for (size_t j=0; j < item->numDimensions(); j++) { + std::string dimString = item->getDimension(j); + BOOST_CHECK_NO_THROW( unitSystem->getNewDimension( dimString )); + } + } + } +} + +BOOST_AUTO_TEST_CASE(TESTWECONKeyword) { + std::string jsonFile = "E:/Jenkins/jobs/opm-parser-create-keywords/workspace/opm-parser/opm/parser/share/keywords/000_Eclipse100/W/WECON"; + boost::filesystem::path jsonPath( jsonFile ); + Json::JsonObject jsonConfig( jsonPath ); + ParserKeyword jsonKeyword(jsonConfig); + ParserKeywords::WECON inlineKeyword; + BOOST_CHECK( jsonKeyword.equal( inlineKeyword )); + if (jsonKeyword.hasDimension()) { + ParserRecordConstPtr parserRecord = jsonKeyword.getRecord(0); + for (size_t i=0; i < parserRecord->size(); i++){ + ParserItemConstPtr item = parserRecord->get( i ); + for (size_t j=0; j < item->numDimensions(); j++) { + std::string dimString = item->getDimension(j); + BOOST_CHECK_NO_THROW( unitSystem->getNewDimension( dimString )); + } + } + } +} + BOOST_AUTO_TEST_CASE(TESTWELLDIMSKeyword) { std::string jsonFile = "E:/Jenkins/jobs/opm-parser-create-keywords/workspace/opm-parser/opm/parser/share/keywords/000_Eclipse100/W/WELLDIMS"; boost::filesystem::path jsonPath( jsonFile ); @@ -5998,6 +6226,25 @@ BOOST_AUTO_TEST_CASE(TESTWHISTCTLKeyword) { } } +BOOST_AUTO_TEST_CASE(TESTWLIFTKeyword) { + std::string jsonFile = "E:/Jenkins/jobs/opm-parser-create-keywords/workspace/opm-parser/opm/parser/share/keywords/000_Eclipse100/W/WLIFT"; + boost::filesystem::path jsonPath( jsonFile ); + Json::JsonObject jsonConfig( jsonPath ); + ParserKeyword jsonKeyword(jsonConfig); + ParserKeywords::WLIFT inlineKeyword; + BOOST_CHECK( jsonKeyword.equal( inlineKeyword )); + if (jsonKeyword.hasDimension()) { + ParserRecordConstPtr parserRecord = jsonKeyword.getRecord(0); + for (size_t i=0; i < parserRecord->size(); i++){ + ParserItemConstPtr item = parserRecord->get( i ); + for (size_t j=0; j < item->numDimensions(); j++) { + std::string dimString = item->getDimension(j); + BOOST_CHECK_NO_THROW( unitSystem->getNewDimension( dimString )); + } + } + } +} + BOOST_AUTO_TEST_CASE(TESTWPAVEKeyword) { std::string jsonFile = "E:/Jenkins/jobs/opm-parser-create-keywords/workspace/opm-parser/opm/parser/share/keywords/000_Eclipse100/W/WPAVE"; boost::filesystem::path jsonPath( jsonFile ); diff --git a/ThirdParty/custom-opm-parser/opm-parser/CMakeLists.txt b/ThirdParty/custom-opm-parser/opm-parser/CMakeLists.txt index 0b6527d57b..cbe48e383b 100644 --- a/ThirdParty/custom-opm-parser/opm-parser/CMakeLists.txt +++ b/ThirdParty/custom-opm-parser/opm-parser/CMakeLists.txt @@ -5,6 +5,12 @@ enable_language(C) include(CTest) include(TestCXXAcceptsFlag) +if(NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES) + message(STATUS "No build type specified - defaulting to 'Debug'.") + set(CMAKE_BUILD_TYPE "Debug" CACHE STRING "Choose build type." FORCE) + set_property(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS "Release" "Debug" "RelWithDebInfo" "MinSizeRel") +endif() + # project information is in dune.module. Read this file and set variables. # we cannot generate dune.module since it is read by dunecontrol before # the build starts, so it makes sense to keep the data there then. @@ -77,20 +83,19 @@ endif (USE_RUNPATH) if (MSVC) add_definitions( "/W3 /D_CRT_SECURE_NO_WARNINGS /wd4996 /wd4244 /wd4267") - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /MP") + set(CMAKE_CXX_FLAGS "/MP ${CMAKE_CXX_FLAGS}") else() - if (NOT DEFINED CMAKE_CXX_FLAGS) - SET( CMAKE_CXX_FLAGS "-pipe -std=c++0x -pedantic -Wall -Wextra -Wformat-nonliteral -Wcast-align -Wpointer-arith -Wmissing-declarations -Wcast-qual -Wshadow -Wwrite-strings -Wchar-subscripts -Wredundant-decls") - endif() - SET( CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS} ${CMAKE_CXX_FLAGS_DEBUG} -O0 -DDEBUG -ggdb3") - SET( CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS} ${CMAKE_CXX_FLAGS_RELEASE} -O3 -DNDEBUG -mtune=native") + # The cmake macros are expanded *after* our flags so that options can be + # overriden via -DCMAKE_FLAGS from the command line or ccmake + SET( CMAKE_CXX_FLAGS "-pipe -std=c++0x ${CMAKE_CXX_FLAGS}") + SET( CMAKE_CXX_FLAGS_DEBUG "-pedantic -Wall -Wextra -Wformat-nonliteral -Wcast-align -Wpointer-arith -Wmissing-declarations -Wcast-qual -Wshadow -Wwrite-strings -Wchar-subscripts -Wredundant-decls ${CMAKE_CXX_FLAGS_DEBUG}") + SET( CMAKE_CXX_FLAGS_DEBUG "-O0 -DDEBUG -ggdb3 ${CMAKE_CXX_FLAGS} ${CMAKE_CXX_FLAGS_DEBUG} ") + SET( CMAKE_CXX_FLAGS_RELEASE "-O3 -DNDEBUG -mtune=native ${CMAKE_CXX_FLAGS} ${CMAKE_CXX_FLAGS_RELEASE}") endif(MSVC) -if (NOT DEFINED CMAKE_C_FLAGS) - SET( CMAKE_C_FLAGS "-pipe -Wall -Wno-unknown-pragmas -std=c99") -endif() -SET( CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS} ${CMAKE_C_FLAGS_DEBUG} -O0 -DDEBUG -ggdb3") -SET( CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS} ${CMAKE_C_FLAGS_RELEASE} -O3 -DNDEBUG -mtune=native") +SET( CMAKE_C_FLAGS "-pipe -Wall -Wno-unknown-pragmas -std=c99 ${CMAKE_C_FLAGS}") +SET( CMAKE_C_FLAGS_DEBUG "-O0 -DDEBUG -ggdb3 ${CMAKE_C_FLAGS} ${CMAKE_C_FLAGS_DEBUG} ") +SET( CMAKE_C_FLAGS_RELEASE "-O3 -DNDEBUG -mtune=native ${CMAKE_C_FLAGS} ${CMAKE_C_FLAGS_RELEASE}") if (BOOST_ROOT AND NOT DEFINED Boost_NO_SYSTEM_PATHS) @@ -111,7 +116,7 @@ add_definitions(-DOPM_PARSER_DECK_API=1) # Requires BOOST filesystem version 3, thus 1.44 is necessary. add_definitions(-DBOOST_FILESYSTEM_VERSION=3) find_package(Boost 1.44.0 COMPONENTS filesystem date_time system unit_test_framework regex REQUIRED) -include_directories(${Boost_INCLUDE_DIRS}) +include_directories(SYSTEM ${Boost_INCLUDE_DIRS}) include_directories(BEFORE ${PROJECT_SOURCE_DIR}) include_directories(${PROJECT_BINARY_DIR}) @@ -137,8 +142,6 @@ endif() include( cmake/Modules/CheckCaseSensitiveFileSystem.cmake ) add_definitions("-DHAVE_CASE_SENSITIVE_FILESYSTEM=${HAVE_CASE_SENSITIVE_FILESYSTEM}") -find_package(opm-common) -include_directories( ${opm-common_INCLUDE_DIRS} ) include( Findopm-data ) find_package(ERT) diff --git a/ThirdParty/custom-opm-parser/opm-parser/appveyor.yml b/ThirdParty/custom-opm-parser/opm-parser/appveyor.yml new file mode 100644 index 0000000000..4cbf25f6ad --- /dev/null +++ b/ThirdParty/custom-opm-parser/opm-parser/appveyor.yml @@ -0,0 +1,36 @@ +version: 1.0.{build} +clone_depth: 1 + +configuration: + - Debug + - Release + +os: Visual Studio 2015 +image: Visual Studio 2015 + +platform: + - x64 + +environment: + BOOST_ROOT: C:\Libraries\boost_1_59_0\boost + BOOST_INCLUDEDIR: C:\Libraries\boost_1_59_0 + BOOST_LIBRARYDIR: C:\Libraries\boost_1_59_0\lib64-msvc-14.0 + BOOST_FLAGS: -DBoost_USE_MULTITHREAD=ON -DBUILD_SHARED_LIBS=OFF -DBoost_USE_STATIC_LIBS=TRUE -DBOOST_ALL_DYN_LINK=OFF + BOOST_OPTIONS: -DBOOST_ROOT=%BOOST_ROOT% -DBOOST_LIBRARYDIR=%BOOST_LIBRARYDIR% -DBOOST_INCLUDEDIR=%BOOST_INCLUDEDIR% %BOOST_FLAGS% + COMMON_ROOT: "C:/Program Files/Project/share/opm/" + ERT_ROOT: "C:/Program Files/ERT" + GEN: "Visual Studio 14 2015 Win64" + +build_script: + - git clone https://github.com/OPM/opm-common.git + - git clone https://github.com/Ensembles/ert.git + - cd ert + - cmake C:\projects\opm-parser\ert -G"%GEN%" -DCMAKE_BUILD_TYPE=%configuration% -DERT_BUILD_CXX=ON -DBUILD_SHARED_LIBS=OFF -DBUILD_PYTHON=OFF + - cmake --build . --target install --config %configuration% + - cd ../opm-common + - cmake C:\projects\opm-parser\opm-common -G"%GEN%" %BOOST_OPTIONS% -DCMAKE_BUILD_TYPE=%configuration% -DBUILD_TESTING=OFF + - cmake --build . --config %configuration% --target install + - cd .. + - cmake C:\projects\opm-parser -G"%GEN%" %BOOST_OPTIONS% -DOPM_COMMON_ROOT="%COMMON_ROOT%" -DCMAKE_PREFIX_PATH="%ERT_ROOT%" -DCMAKE_BUILD_TYPE=%configuration% + - cmake --build . --config %configuration% + - ctest -C %configuration% --output-on-failure diff --git a/ThirdParty/custom-opm-parser/opm-parser/debian/control b/ThirdParty/custom-opm-parser/opm-parser/debian/control index faac199a17..26794d82c9 100644 --- a/ThirdParty/custom-opm-parser/opm-parser/debian/control +++ b/ThirdParty/custom-opm-parser/opm-parser/debian/control @@ -5,7 +5,8 @@ Build-Depends: build-essential, debhelper (>= 9), pkg-config, libopm-common-dev, cmake, libtinyxml-dev, bc, libboost-filesystem-dev, zlib1g-dev, libert.ecl-dev, git, libtool, doxygen, libboost-date-time-dev, texlive-latex-extra, texlive-latex-recommended, ghostscript, - libboost-system-dev, libboost-test-dev, libboost-regex-dev + libboost-system-dev, libboost-test-dev, libboost-regex-dev, + python-ert.ecl, python-cwrap Standards-Version: 3.9.2 Section: libs Homepage: http://opm-project.org @@ -30,7 +31,17 @@ Multi-Arch: same Depends: ${shlibs:Depends}, ${misc:Depends} Provides: libopm-parser Description: OPM parser library - The OPM parser library is the eclipse parser library within OPM + The OPM parser library is the eclipse parser library within OPM + +Package: libopm-parser1-bin +Section: science +Pre-Depends: ${misc:Pre-Depends}, multiarch-support +Architecture: any +Multi-Arch: same +Depends: ${shlibs:Depends}, ${misc:Depends} +Provides: libopm-parser-bin +Description: OPM parser library -- applications + The OPM parser library is the eclipse parser library within OPM Package: libopm-parser1-dbg Section: debug @@ -39,3 +50,41 @@ Multi-Arch: foreign Provides: libopm-parser-dbg Depends: libopm-parser1 (= ${binary:Version}), ${misc:Depends} Description: OPM parser library -- debug symbols + +Package: libopm-cparser1-dev +Section: libdevel +Architecture: any +Multi-Arch: foreign +Depends: libopm-cparser1 (= ${binary:Version}) +Provides: libopm-cparser-dev +Description: OPM parser c wrapping library -- development files + The OPM parser library is the eclipse parser library within OPM. + This package contains the development for the c wrapping library + +Package: libopm-cparser1 +Section: libs +Pre-Depends: ${misc:Pre-Depends}, multiarch-support +Architecture: any +Multi-Arch: same +Depends: ${shlibs:Depends}, ${misc:Depends} +Provides: libopm-cparser +Description: OPM parser c wrapping library + The OPM parser library is the eclipse parser library within OPM. This + package contains a small C wrapper library for libopm-parser. + +Package: libopm-cparser1-dbg +Section: debug +Architecture: any +Multi-Arch: foreign +Provides: libopm-cparser-dbg +Depends: libopm-cparser1 (= ${binary:Version}), ${misc:Depends} +Description: OPM parser c wrapping library -- debug symbols + +Package: python-opm-parser +Section: python +Architecture: any +Depends: ${shlibs:Depends}, ${misc:Depends}, python-ert.ecl, + python-cwrap, libopm-cparser +Description: OPM parser library -- python bindings + The OPM parser library is the eclipse parser library within OPM + of reservoir models. This package contains the python bindings. diff --git a/ThirdParty/custom-opm-parser/opm-parser/debian/libopm-cparser1-dev.install b/ThirdParty/custom-opm-parser/opm-parser/debian/libopm-cparser1-dev.install new file mode 100644 index 0000000000..1d60972b79 --- /dev/null +++ b/ThirdParty/custom-opm-parser/opm-parser/debian/libopm-cparser1-dev.install @@ -0,0 +1 @@ +usr/lib/*/libcopm*.so diff --git a/ThirdParty/custom-opm-parser/opm-parser/debian/libopm-cparser1.install b/ThirdParty/custom-opm-parser/opm-parser/debian/libopm-cparser1.install new file mode 100644 index 0000000000..0a7fed10ea --- /dev/null +++ b/ThirdParty/custom-opm-parser/opm-parser/debian/libopm-cparser1.install @@ -0,0 +1 @@ +usr/lib/*/libcopm*.so.* diff --git a/ThirdParty/custom-opm-parser/opm-parser/debian/libopm-parser1-bin.install b/ThirdParty/custom-opm-parser/opm-parser/debian/libopm-parser1-bin.install new file mode 100644 index 0000000000..1df36c612f --- /dev/null +++ b/ThirdParty/custom-opm-parser/opm-parser/debian/libopm-parser1-bin.install @@ -0,0 +1 @@ +usr/bin/* diff --git a/ThirdParty/custom-opm-parser/opm-parser/debian/libopm-parser1-dev.install b/ThirdParty/custom-opm-parser/opm-parser/debian/libopm-parser1-dev.install index 66aca48a25..b265500689 100644 --- a/ThirdParty/custom-opm-parser/opm-parser/debian/libopm-parser1-dev.install +++ b/ThirdParty/custom-opm-parser/opm-parser/debian/libopm-parser1-dev.install @@ -1,5 +1,5 @@ usr/include/* -usr/lib/*/lib*.so +usr/lib/*/libopm*.so usr/lib/dunecontrol/* usr/share/cmake/* usr/lib/*/pkgconfig/* diff --git a/ThirdParty/custom-opm-parser/opm-parser/debian/libopm-parser1.install b/ThirdParty/custom-opm-parser/opm-parser/debian/libopm-parser1.install index 3ddde58419..de5875ee26 100644 --- a/ThirdParty/custom-opm-parser/opm-parser/debian/libopm-parser1.install +++ b/ThirdParty/custom-opm-parser/opm-parser/debian/libopm-parser1.install @@ -1 +1 @@ -usr/lib/*/lib*.so.* +usr/lib/*/libopm*.so.* diff --git a/ThirdParty/custom-opm-parser/opm-parser/debian/python-opm-parser.install b/ThirdParty/custom-opm-parser/opm-parser/debian/python-opm-parser.install new file mode 100644 index 0000000000..670205536d --- /dev/null +++ b/ThirdParty/custom-opm-parser/opm-parser/debian/python-opm-parser.install @@ -0,0 +1 @@ +usr/lib/python2.7/*/opm/* diff --git a/ThirdParty/custom-opm-parser/opm-parser/debian/rules b/ThirdParty/custom-opm-parser/opm-parser/debian/rules index 0a0f2e9f68..e0b67b43d9 100644 --- a/ThirdParty/custom-opm-parser/opm-parser/debian/rules +++ b/ThirdParty/custom-opm-parser/opm-parser/debian/rules @@ -20,10 +20,11 @@ override_dh_auto_build: # consider using -DUSE_VERSIONED_DIR=ON if backporting override_dh_auto_configure: - dh_auto_configure --buildsystem=cmake -- -DCMAKE_BUILD_TYPE=Release -DBUILD_SHARED_LIBS=1 + dh_auto_configure --buildsystem=cmake -- -DCMAKE_BUILD_TYPE=Release -DBUILD_SHARED_LIBS=1 -DENABLE_PYTHON=1 override_dh_installdocs: dh_installdocs --link-doc=libopm-parser1 override_dh_strip: dh_strip -plibopm-parser1 --dbg-package=libopm-parser1-dbg + dh_strip -plibopm-cparser1 --dbg-package=libopm-cparser1-dbg diff --git a/ThirdParty/custom-opm-parser/opm-parser/jenkins/README.md b/ThirdParty/custom-opm-parser/opm-parser/jenkins/README.md index 0f7540ba31..abed8fa18a 100644 --- a/ThirdParty/custom-opm-parser/opm-parser/jenkins/README.md +++ b/ThirdParty/custom-opm-parser/opm-parser/jenkins/README.md @@ -1,21 +1,14 @@ # opm-parser jenkins build scripts: -**build-opm-parser.sh**: -This is a helper script which contains a function for building, -testing and cloning opm-parser and its dependencies. - **build.sh**: This script will build dependencies, then build opm-parser and execute its tests. -It is intended for post-merge builds of the master branch. - -**build-pr.sh**: -This script will build dependencies, then build opm-parser and execute its tests. -It inspects the $ghbPrBuildComment environmental variable to obtain a pull request -to use for for ert and opm-common (defaults to master) -and then builds $sha1 of opm-parser. +It also inspects the $ghbPrBuildComment environmental variable and builds +downstreams if requested. It inspects the $ghbPrBuildComment +environmental variable to obtain a pull request to use for the modules. It is intended for pre-merge builds of pull requests. -You specify a given pull request to use for opm-common through the trigger. -The trigger line needs to contain ert=<pull request number> and/or -opm-common=<pull request number>. +To specify a given pull request to use for upstreams and downstreams, +trigger line needs to contain <module-name>=<pull request number>. + +To build with downstreams the trigger line needs to contain 'with downstreams'. diff --git a/ThirdParty/custom-opm-parser/opm-parser/jenkins/build-opm-parser.sh b/ThirdParty/custom-opm-parser/opm-parser/jenkins/build-opm-parser.sh deleted file mode 100644 index a91a6ccaa6..0000000000 --- a/ThirdParty/custom-opm-parser/opm-parser/jenkins/build-opm-parser.sh +++ /dev/null @@ -1,50 +0,0 @@ -#!/bin/bash - -function build_opm_parser { - # Build ERT - pushd . - mkdir -p $WORKSPACE/deps/ert - cd $WORKSPACE/deps/ert - git init . - git remote add origin https://github.com/Ensembles/ert - git fetch --depth 1 origin $ERT:branch_to_build - test $? -eq 0 || exit 1 - git checkout branch_to_build - popd - - pushd . - mkdir -p serial/build-ert - cd serial/build-ert - cmake $WORKSPACE/deps/ert/devel -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=$WORKSPACE/serial/install - make install - popd - - # Build opm-common - pushd . - mkdir -p $WORKSPACE/deps/opm-common - cd $WORKSPACE/deps/opm-common - git init . - git remote add origin https://github.com/OPM/opm-common - git fetch --depth 1 origin $OPM_COMMON_REVISION:branch_to_build - test $? -eq 0 || exit 1 - git checkout branch_to_build - popd - source $WORKSPACE/deps/opm-common/jenkins/build-opm-module.sh - - pushd . - mkdir serial/build-opm-common - cd serial/build-opm-common - build_module "-DCMAKE_INSTALL_PREFIX=$WORKSPACE/serial/install" 0 $WORKSPACE/deps/opm-common - popd - - # Setup opm-data - source $WORKSPACE/deps/opm-common/jenkins/setup-opm-data.sh - - # Build opm-parser - pushd . - mkdir serial/build-opm-parser - cd serial/build-opm-parser - build_module "-DCMAKE_PREFIX_PATH=$WORKSPACE/serial/install -DCMAKE_INSTALL_PREFIX=$WORKSPACE/serial/install -DOPM_DATA_ROOT=$OPM_DATA_ROOT" 1 $WORKSPACE - test $? -eq 0 || exit 1 - popd -} diff --git a/ThirdParty/custom-opm-parser/opm-parser/jenkins/build-pr.sh b/ThirdParty/custom-opm-parser/opm-parser/jenkins/build-pr.sh deleted file mode 100644 index 4518a43c14..0000000000 --- a/ThirdParty/custom-opm-parser/opm-parser/jenkins/build-pr.sh +++ /dev/null @@ -1,53 +0,0 @@ -#!/bin/bash - -source `dirname $0`/build-opm-parser.sh - -# Upstream revisions -ERT_REVISION=master -OPM_COMMON_REVISION=master - -if grep -q "ert=" <<< $ghprbCommentBody -then - ERT_REVISION=pull/`echo $ghprbCommentBody | sed -r 's/.*ert=([0-9]+).*/\1/g'`/merge -fi -if grep -q "opm-common=" <<< $ghprbCommentBody -then - OPM_COMMON_REVISION=pull/`echo $ghprbCommentBody | sed -r 's/.*opm-common=([0-9]+).*/\1/g'`/merge -fi - -echo "Building with ert=$ERT_REVISION opm-common=$OPM_COMMON_REVISION opm-parser=$sha1" - -build_opm_parser -test $? -eq 0 || exit 1 - -# If no downstream builds we are done -if ! grep -q "with downstreams" <<< $ghprbCommentBody -then - cp serial/build-opm-parser/testoutput.xml . - exit 0 -fi - -source $WORKSPACE/deps/opm-common/jenkins/build-opm-module.sh - -# Downstream revisions -declare -a downstreams -downstreams=(opm-material - opm-output - opm-core - opm-grid - opm-simulators - opm-upscaling - ewoms) - -declare -A downstreamRev -downstreamRev[opm-material]=master -downstreamRev[opm-core]=master -downstreamRev[opm-grid]=master -downstreamRev[opm-output]=master -downstreamRev[opm-simulators]=master -downstreamRev[opm-upscaling]=master -downstreamRev[ewoms]=master - -build_downstreams opm-parser - -test $? -eq 0 || exit 1 diff --git a/ThirdParty/custom-opm-parser/opm-parser/jenkins/build.sh b/ThirdParty/custom-opm-parser/opm-parser/jenkins/build.sh index 60727f138c..9a1aaea185 100644 --- a/ThirdParty/custom-opm-parser/opm-parser/jenkins/build.sh +++ b/ThirdParty/custom-opm-parser/opm-parser/jenkins/build.sh @@ -1,11 +1,54 @@ #!/bin/bash -source `dirname $0`/build-opm-parser.sh +declare -a upstreams +upstreams=(opm-common + ert) -ERT_REVISION=master -OPM_COMMON_REVISION=master +declare -A upstreamRev +upstreamRev[opm-common]=master +upstreamRev[ert]=master -build_opm_parser +if grep -q "opm-common=" <<< $ghprbCommentBody +then + upstreamRev[opm-common]=pull/`echo $ghprbCommentBody | sed -r 's/.*opm-common=([0-9]+).*/\1/g'`/merge +fi + +# Downstream revisions +declare -a downstreams +downstreams=(opm-material + opm-output + opm-core + opm-grid + opm-simulators + opm-upscaling + ewoms) + +declare -A downstreamRev +downstreamRev[opm-material]=master +downstreamRev[opm-core]=master +downstreamRev[opm-grid]=master +downstreamRev[opm-output]=master +downstreamRev[opm-simulators]=master +downstreamRev[opm-upscaling]=master +downstreamRev[ewoms]=master + +# Clone opm-common +pushd . +mkdir -p $WORKSPACE/deps/opm-common +cd $WORKSPACE/deps/opm-common +git init . +git remote add origin https://github.com/OPM/opm-common +git fetch --depth 1 origin ${upstreamRev[opm-common]}:branch_to_build test $? -eq 0 || exit 1 +git checkout branch_to_build +popd -cp serial/build-opm-parser/testoutput.xml . +source $WORKSPACE/deps/opm-common/jenkins/build-opm-module.sh + +parseRevisions +printHeader opm-parser + +# Setup opm-data +source $WORKSPACE/deps/opm-common/jenkins/setup-opm-data.sh + +build_module_full opm-parser diff --git a/ThirdParty/custom-opm-parser/opm-parser/opm/parser/eclipse/Applications/opmi.cpp b/ThirdParty/custom-opm-parser/opm-parser/opm/parser/eclipse/Applications/opmi.cpp index 0eb024f644..b344f4e6d0 100644 --- a/ThirdParty/custom-opm-parser/opm-parser/opm/parser/eclipse/Applications/opmi.cpp +++ b/ThirdParty/custom-opm-parser/opm-parser/opm/parser/eclipse/Applications/opmi.cpp @@ -21,12 +21,28 @@ #include #include +#include #include #include #include -void loadDeck( const char * deck_file) { +inline void dumpMessages( const Opm::MessageContainer& messageContainer) { + auto extractMessage = [](const Opm::Message& msg) { + const auto& location = msg.location; + if (location) + return location.filename + ":" + std::to_string( location.lineno ) + " " + msg.message; + else + return msg.message; + }; + + + for(const auto& msg : messageContainer) + std::cout << extractMessage(msg) << std::endl; +} + + +inline void loadDeck( const char * deck_file) { Opm::ParseContext parseContext; Opm::ParserPtr parser(new Opm::Parser()); std::shared_ptr deck; @@ -35,8 +51,10 @@ void loadDeck( const char * deck_file) { std::cout << "Loading deck: " << deck_file << " ..... "; std::cout.flush(); deck = parser->parseFile(deck_file, parseContext); std::cout << "parse complete - creating EclipseState .... "; std::cout.flush(); - state = std::make_shared( deck , parseContext ); + state = std::make_shared( *deck , parseContext ); std::cout << "complete." << std::endl; + + dumpMessages( deck->getMessageContainer() ); } diff --git a/ThirdParty/custom-opm-parser/opm-parser/opm/parser/eclipse/CMakeLists.txt b/ThirdParty/custom-opm-parser/opm-parser/opm/parser/eclipse/CMakeLists.txt index 3711915d19..2fb980f146 100644 --- a/ThirdParty/custom-opm-parser/opm-parser/opm/parser/eclipse/CMakeLists.txt +++ b/ThirdParty/custom-opm-parser/opm-parser/opm/parser/eclipse/CMakeLists.txt @@ -1,23 +1,23 @@ include_directories(BEFORE ${PROJECT_BINARY_DIR}/generated-source/include) add_subdirectory(Parser/tests) -#add_subdirectory(Generator/tests) -#add_subdirectory(RawDeck/tests) -#add_subdirectory(Deck/tests) -#add_subdirectory(Units/tests) -#add_subdirectory(EclipseState/tests) -#add_subdirectory(EclipseState/Schedule/tests) -#add_subdirectory(EclipseState/SimulationConfig/tests) -#add_subdirectory(EclipseState/Tables/tests) -#add_subdirectory(EclipseState/Grid/tests) -#add_subdirectory(EclipseState/Util/tests) -#add_subdirectory(EclipseState/IOConfig/tests) -#add_subdirectory(EclipseState/InitConfig/tests) -#add_subdirectory(EclipseState/SummaryConfig/tests) -#add_subdirectory(Utility/tests) +add_subdirectory(Generator/tests) +add_subdirectory(RawDeck/tests) +add_subdirectory(Deck/tests) +add_subdirectory(Units/tests) +add_subdirectory(EclipseState/tests) +add_subdirectory(EclipseState/Schedule/tests) +add_subdirectory(EclipseState/SimulationConfig/tests) +add_subdirectory(EclipseState/Tables/tests) +add_subdirectory(EclipseState/Grid/tests) +add_subdirectory(EclipseState/Util/tests) +add_subdirectory(EclipseState/IOConfig/tests) +add_subdirectory(EclipseState/InitConfig/tests) +add_subdirectory(EclipseState/SummaryConfig/tests) +add_subdirectory(Utility/tests) -#add_subdirectory(Applications) -#add_subdirectory(IntegrationTests) +add_subdirectory(Applications) +add_subdirectory(IntegrationTests) set( rawdeck_source RawDeck/StarToken.cpp @@ -34,8 +34,6 @@ Deck/DeckKeyword.cpp Deck/DeckRecord.cpp Deck/DeckItem.cpp Deck/Section.cpp -Deck/SCHEDULESection.cpp -Deck/DeckTimeStep.cpp ) set( parser_source @@ -83,6 +81,7 @@ EclipseState/Schedule/Well.cpp EclipseState/Schedule/WellProductionProperties.cpp EclipseState/Schedule/WellInjectionProperties.cpp EclipseState/Schedule/WellPolymerProperties.cpp +EclipseState/Schedule/WellEconProductionLimits.cpp EclipseState/Schedule/MSW/Segment.cpp EclipseState/Schedule/MSW/SegmentSet.cpp EclipseState/Schedule/MSW/Compsegs.cpp @@ -109,6 +108,7 @@ EclipseState/Tables/PvtxTable.cpp EclipseState/Tables/Tables.cpp # EclipseState/Grid/SatfuncPropertyInitializers.cpp +EclipseState/Grid/GridDims.cpp EclipseState/Grid/GridProperty.cpp EclipseState/Grid/GridProperties.cpp EclipseState/Grid/Box.cpp @@ -128,6 +128,7 @@ EclipseState/InitConfig/Equil.cpp EclipseState/SimulationConfig/SimulationConfig.cpp EclipseState/SimulationConfig/ThresholdPressure.cpp EclipseState/SummaryConfig/SummaryConfig.cpp +EclipseState/IOConfig/RestartConfig.cpp EclipseState/IOConfig/IOConfig.cpp) # @@ -148,8 +149,6 @@ Deck/DeckKeyword.hpp Deck/DeckRecord.hpp Deck/DeckItem.hpp Deck/Section.hpp -Deck/SCHEDULESection.hpp -Deck/DeckTimeStep.hpp # Parser/ParserEnums.hpp Parser/ParserKeyword.hpp @@ -184,6 +183,7 @@ EclipseState/Schedule/Well.hpp EclipseState/Schedule/WellProductionProperties.hpp EclipseState/Schedule/WellInjectionProperties.hpp EclipseState/Schedule/WellPolymerProperties.hpp +EclipseState/Schedule/WellEconProductionLimits.hpp EclipseState/Schedule/MSW/Segment.hpp EclipseState/Schedule/MSW/SegmentSet.hpp EclipseState/Schedule/MSW/Compsegs.hpp @@ -203,27 +203,29 @@ EclipseState/Util/RecordVector.hpp EclipseState/Util/OrderedMap.hpp EclipseState/Util/Value.hpp # -EclipseState/Grid/EclipseGrid.hpp -EclipseState/Grid/GridProperty.hpp -EclipseState/Grid/GridProperties.hpp -EclipseState/Grid/SatfuncPropertyInitializers.hpp EclipseState/Grid/Box.hpp EclipseState/Grid/BoxManager.hpp +EclipseState/Grid/EclipseGrid.hpp EclipseState/Grid/FaceDir.hpp -EclipseState/Grid/MinpvMode.hpp -EclipseState/Grid/PinchMode.hpp -EclipseState/Grid/MULTREGTScanner.hpp -EclipseState/Grid/TransMult.hpp +EclipseState/Grid/FaultCollection.hpp EclipseState/Grid/FaultFace.hpp EclipseState/Grid/Fault.hpp -EclipseState/Grid/FaultCollection.hpp +EclipseState/Grid/GridDims.hpp +EclipseState/Grid/GridProperties.hpp +EclipseState/Grid/GridProperty.hpp +EclipseState/Grid/MinpvMode.hpp +EclipseState/Grid/MULTREGTScanner.hpp EclipseState/Grid/NNC.hpp +EclipseState/Grid/PinchMode.hpp +EclipseState/Grid/SatfuncPropertyInitializers.hpp +EclipseState/Grid/TransMult.hpp # EclipseState/InitConfig/InitConfig.hpp EclipseState/InitConfig/Equil.hpp EclipseState/SimulationConfig/SimulationConfig.hpp EclipseState/SimulationConfig/ThresholdPressure.hpp EclipseState/SummaryConfig/SummaryConfig.hpp +EclipseState/IOConfig/RestartConfig.hpp EclipseState/IOConfig/IOConfig.hpp # EclipseState/Tables/Tabdims.hpp diff --git a/ThirdParty/custom-opm-parser/opm-parser/opm/parser/eclipse/Deck/Deck.cpp b/ThirdParty/custom-opm-parser/opm-parser/opm/parser/eclipse/Deck/Deck.cpp index dde742d6f0..90e3c6752b 100644 --- a/ThirdParty/custom-opm-parser/opm-parser/opm/parser/eclipse/Deck/Deck.cpp +++ b/ThirdParty/custom-opm-parser/opm-parser/opm/parser/eclipse/Deck/Deck.cpp @@ -120,11 +120,7 @@ namespace Opm { DeckView( limits.first, limits.second ) {} - Deck::Deck() : - Deck( std::vector< DeckKeyword >() ) - { - m_dataFile = ""; - } + Deck::Deck() : Deck( std::vector< DeckKeyword >() ) {} Deck::Deck( std::vector< DeckKeyword >&& x ) : DeckView( x.begin(), x.end() ), @@ -132,13 +128,21 @@ namespace Opm { m_dataFile("") {} + Deck::Deck( std::initializer_list< DeckKeyword > ilist ) : + Deck( std::vector< DeckKeyword >( ilist ) ) + {} + + Deck::Deck( std::initializer_list< std::string > ilist ) : + Deck( std::vector< DeckKeyword >( ilist.begin(), ilist.end() ) ) + {} + void Deck::addKeyword( DeckKeyword&& keyword ) { this->keywordList.push_back( std::move( keyword ) ); - auto first = this->keywordList.begin(); - auto last = this->keywordList.end(); + auto fst = this->keywordList.begin(); + auto lst = this->keywordList.end(); - this->add( &this->keywordList.back(), first, last ); + this->add( &this->keywordList.back(), fst, lst ); } void Deck::addKeyword( const DeckKeyword& keyword ) { diff --git a/ThirdParty/custom-opm-parser/opm-parser/opm/parser/eclipse/Deck/Deck.hpp b/ThirdParty/custom-opm-parser/opm-parser/opm/parser/eclipse/Deck/Deck.hpp index 8b8e26f5f3..b4744336e8 100644 --- a/ThirdParty/custom-opm-parser/opm-parser/opm/parser/eclipse/Deck/Deck.hpp +++ b/ThirdParty/custom-opm-parser/opm-parser/opm/parser/eclipse/Deck/Deck.hpp @@ -120,6 +120,8 @@ namespace Opm { using iterator = std::vector< DeckKeyword >::iterator; Deck(); + Deck( std::initializer_list< DeckKeyword > ); + Deck( std::initializer_list< std::string > ); void addKeyword( DeckKeyword&& keyword ); void addKeyword( const DeckKeyword& keyword ); diff --git a/ThirdParty/custom-opm-parser/opm-parser/opm/parser/eclipse/Deck/DeckItem.cpp b/ThirdParty/custom-opm-parser/opm-parser/opm/parser/eclipse/Deck/DeckItem.cpp index 28775eb7ce..9460d77eb3 100644 --- a/ThirdParty/custom-opm-parser/opm-parser/opm/parser/eclipse/Deck/DeckItem.cpp +++ b/ThirdParty/custom-opm-parser/opm-parser/opm/parser/eclipse/Deck/DeckItem.cpp @@ -111,12 +111,12 @@ namespace Opm { template< typename T > - DeckTypeItem< T >::DeckTypeItem( const std::string& name, size_t size ) : + DeckTypeItem< T >::DeckTypeItem( const std::string& nm, size_t sz ) : DeckItemBase( type_to_tag< T >() ), - item_name( name ) + item_name( nm ) { - this->dataPointDefaulted.reserve( size ); - this->data.reserve( size ); + this->dataPointDefaulted.reserve( sz ); + this->data.reserve( sz ); } template< typename T > @@ -212,21 +212,21 @@ namespace Opm { } const std::vector< double >& DeckItemT< double >::assertSIData() const { - const auto dim_size = dimensions.size(); - if( dim_size <= 0 ) - throw std::invalid_argument("No dimension has been set for item:" + this->name() + " can not ask for SI data"); - // we already converted this item to SI? - if( this->SIdata.size() > 0 ) return this->SIdata; + if( !this->SIdata.empty() ) return this->SIdata; + + if( this->dimensions.empty() ) + throw std::invalid_argument("No dimension has been set for item:" + this->name() + " can not ask for SI data"); /* * This is an unobservable state change - SIData is lazily converted to * SI units, so externally the object still behaves as const */ - const auto size = this->size(); - this->SIdata.resize( size ); + const auto dim_size = dimensions.size(); + const auto sz = this->size(); + this->SIdata.resize( sz ); - for( size_t index = 0; index < size; index++ ) { + for( size_t index = 0; index < sz; index++ ) { const auto dimIndex = index % dim_size; this->SIdata[ index ] = this->dimensions[ dimIndex ] ->convertRawToSi( this->get( index ) ); diff --git a/ThirdParty/custom-opm-parser/opm-parser/opm/parser/eclipse/Deck/DeckRecord.cpp b/ThirdParty/custom-opm-parser/opm-parser/opm/parser/eclipse/Deck/DeckRecord.cpp index fdf9bcdaf5..d2b53834b5 100644 --- a/ThirdParty/custom-opm-parser/opm-parser/opm/parser/eclipse/Deck/DeckRecord.cpp +++ b/ThirdParty/custom-opm-parser/opm-parser/opm/parser/eclipse/Deck/DeckRecord.cpp @@ -18,6 +18,7 @@ */ +#include #include #include #include @@ -29,8 +30,26 @@ namespace Opm { - DeckRecord::DeckRecord( size_t size ) { - this->m_items.reserve( size ); + DeckRecord::DeckRecord( std::vector< DeckItem >&& items ) : + m_items( std::move( items ) ) { + + std::unordered_set< std::string > names; + for( const auto& item : this->m_items ) + names.insert( item.name() ); + + if( names.size() == this->m_items.size() ) + return; + + names.clear(); + std::string msg = "Duplicate item names in DeckRecord:"; + for( const auto& item : this->m_items ) { + if( names.count( item.name() ) != 0 ) + msg += std::string( " " ) += item.name(); + + names.insert( item.name() ); + } + + throw std::invalid_argument( msg ); } size_t DeckRecord::size() const { diff --git a/ThirdParty/custom-opm-parser/opm-parser/opm/parser/eclipse/Deck/DeckRecord.hpp b/ThirdParty/custom-opm-parser/opm-parser/opm/parser/eclipse/Deck/DeckRecord.hpp index 47e180e38a..752f91c3ab 100644 --- a/ThirdParty/custom-opm-parser/opm-parser/opm/parser/eclipse/Deck/DeckRecord.hpp +++ b/ThirdParty/custom-opm-parser/opm-parser/opm/parser/eclipse/Deck/DeckRecord.hpp @@ -33,7 +33,7 @@ namespace Opm { typedef std::vector< DeckItem >::const_iterator const_iterator; DeckRecord() = default; - DeckRecord( size_t ); + DeckRecord( std::vector< DeckItem >&& ); size_t size() const; void addItem( DeckItem&& deckItem ); diff --git a/ThirdParty/custom-opm-parser/opm-parser/opm/parser/eclipse/Deck/DeckTimeStep.cpp b/ThirdParty/custom-opm-parser/opm-parser/opm/parser/eclipse/Deck/DeckTimeStep.cpp deleted file mode 100644 index bd6602fc8c..0000000000 --- a/ThirdParty/custom-opm-parser/opm-parser/opm/parser/eclipse/Deck/DeckTimeStep.cpp +++ /dev/null @@ -1,30 +0,0 @@ -/* - Copyright 2015 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 - - -namespace Opm { - - DeckTimeStep::DeckTimeStep() { - } -} - - diff --git a/ThirdParty/custom-opm-parser/opm-parser/opm/parser/eclipse/Deck/SCHEDULESection.cpp b/ThirdParty/custom-opm-parser/opm-parser/opm/parser/eclipse/Deck/SCHEDULESection.cpp deleted file mode 100644 index 5b8e7639d2..0000000000 --- a/ThirdParty/custom-opm-parser/opm-parser/opm/parser/eclipse/Deck/SCHEDULESection.cpp +++ /dev/null @@ -1,71 +0,0 @@ -/* - Copyright 2015 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 -#include -#include - -namespace Opm { - - SCHEDULESection::SCHEDULESection( const Deck& deck ) : - Section(deck, "SCHEDULE"), unit_system( deck.getActiveUnitSystem() ) - { - populateDeckTimeSteps(); - } - - - DeckTimeStepConstPtr SCHEDULESection::getDeckTimeStep(size_t timestep) const { - if (timestep < m_decktimesteps.size()) { - return m_decktimesteps[timestep]; - } else { - throw std::out_of_range("No DeckTimeStep in ScheduleSection for timestep " + std::to_string(timestep)); - } - } - - - void SCHEDULESection::populateDeckTimeSteps() { - DeckTimeStepPtr currentTimeStep = std::make_shared(); - - for( const auto& keyword : *this ) { - if (keyword.name() == "TSTEP") { - const auto& items = keyword.getDataRecord().getDataItem(); - for (size_t item_iter = 0; item_iter < items.size(); ++item_iter) { - m_decktimesteps.push_back(currentTimeStep); - currentTimeStep = std::make_shared(); - } - } else if (keyword.name() == "DATES") { - for (auto record_iter = keyword.begin(); record_iter != keyword.end(); ++record_iter ) { - m_decktimesteps.push_back(currentTimeStep); - currentTimeStep = std::make_shared(); - } - } else { - currentTimeStep->addKeyword(keyword); - } - } - //push last step - m_decktimesteps.push_back(currentTimeStep); - } - - const UnitSystem& SCHEDULESection::getActiveUnitSystem() const { - return this->unit_system; - } -} diff --git a/ThirdParty/custom-opm-parser/opm-parser/opm/parser/eclipse/Deck/SCHEDULESection.hpp b/ThirdParty/custom-opm-parser/opm-parser/opm/parser/eclipse/Deck/SCHEDULESection.hpp deleted file mode 100644 index 10fd33dd0b..0000000000 --- a/ThirdParty/custom-opm-parser/opm-parser/opm/parser/eclipse/Deck/SCHEDULESection.hpp +++ /dev/null @@ -1,49 +0,0 @@ -/* - Copyright 2015 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 SCHEDULESECTION_HPP -#define SCHEDULESECTION_HPP - - -#include - -#include - -namespace Opm { - - class DeckTimeStep; - - class SCHEDULESection : public Section { - - public: - SCHEDULESection( const Deck& deck); - std::shared_ptr< const DeckTimeStep > getDeckTimeStep(size_t timestep) const; - - const UnitSystem& getActiveUnitSystem() const; - - - private: - void populateDeckTimeSteps(); - std::vector< std::shared_ptr< DeckTimeStep > > m_decktimesteps; - const UnitSystem& unit_system; - - }; -} - -#endif // SCHEDULESECTION_HPP diff --git a/ThirdParty/custom-opm-parser/opm-parser/opm/parser/eclipse/Deck/Section.cpp b/ThirdParty/custom-opm-parser/opm-parser/opm/parser/eclipse/Deck/Section.cpp index 6a97830919..f0e8ec90b4 100644 --- a/ThirdParty/custom-opm-parser/opm-parser/opm/parser/eclipse/Deck/Section.cpp +++ b/ThirdParty/custom-opm-parser/opm-parser/opm/parser/eclipse/Deck/Section.cpp @@ -63,13 +63,18 @@ namespace Opm { Section::Section( const Deck& deck, const std::string& section ) : DeckView( find_section( deck, section ) ), - section_name( section ) + section_name( section ), + units( deck.getActiveUnitSystem() ) {} const std::string& Section::name() const { return this->section_name; } + const UnitSystem& Section::unitSystem() const { + return this->units; + } + bool Section::hasRUNSPEC(const Deck& deck) { return deck.hasKeyword( "RUNSPEC" ); } bool Section::hasGRID(const Deck& deck) { return deck.hasKeyword( "GRID" ); } bool Section::hasEDIT(const Deck& deck) { return deck.hasKeyword( "EDIT" ); } diff --git a/ThirdParty/custom-opm-parser/opm-parser/opm/parser/eclipse/Deck/Section.hpp b/ThirdParty/custom-opm-parser/opm-parser/opm/parser/eclipse/Deck/Section.hpp index a21f4b5ea8..2bbbf28b56 100644 --- a/ThirdParty/custom-opm-parser/opm-parser/opm/parser/eclipse/Deck/Section.hpp +++ b/ThirdParty/custom-opm-parser/opm-parser/opm/parser/eclipse/Deck/Section.hpp @@ -35,6 +35,7 @@ class Section : public DeckView { Section( const Deck& deck, const std::string& startKeyword ); const std::string& name() const; + const UnitSystem& unitSystem() const; static bool hasRUNSPEC( const Deck& ); static bool hasGRID( const Deck& ); @@ -53,43 +54,57 @@ class Section : public DeckView { private: std::string section_name; + const UnitSystem& units; }; class RUNSPECSection : public Section { public: + using Section::const_iterator; RUNSPECSection(const Deck& deck) : Section(deck, "RUNSPEC") {} }; class GRIDSection : public Section { public: + using Section::const_iterator; GRIDSection(const Deck& deck) : Section(deck, "GRID") {} }; class EDITSection : public Section { public: + using Section::const_iterator; EDITSection(const Deck& deck) : Section(deck, "EDIT") {} }; class PROPSSection : public Section { public: + using Section::const_iterator; PROPSSection(const Deck& deck) : Section(deck, "PROPS") {} }; class REGIONSSection : public Section { public: + using Section::const_iterator; REGIONSSection(const Deck& deck) : Section(deck, "REGIONS") {} }; class SOLUTIONSection : public Section { public: + using Section::const_iterator; SOLUTIONSection(const Deck& deck) : Section(deck, "SOLUTION") {} }; class SUMMARYSection : public Section { public: + using Section::const_iterator; SUMMARYSection(const Deck& deck) : Section(deck, "SUMMARY") {} }; + + class SCHEDULESection : public Section { + public: + using Section::const_iterator; + SCHEDULESection(const Deck& deck) : Section(deck, "SCHEDULE") {} + }; } #endif // SECTION_HPP diff --git a/ThirdParty/custom-opm-parser/opm-parser/opm/parser/eclipse/Deck/tests/CMakeLists.txt b/ThirdParty/custom-opm-parser/opm-parser/opm/parser/eclipse/Deck/tests/CMakeLists.txt index 759f5a0686..d8e441b6bf 100644 --- a/ThirdParty/custom-opm-parser/opm-parser/opm/parser/eclipse/Deck/tests/CMakeLists.txt +++ b/ThirdParty/custom-opm-parser/opm-parser/opm/parser/eclipse/Deck/tests/CMakeLists.txt @@ -1,6 +1,5 @@ foreach(tapp DeckRecordTests DeckIntItemTests DeckDoubleItemTests - DeckStringItemTests DeckTests DeckKeywordTests SectionTests - DeckTimeStepTests) + DeckStringItemTests DeckTests DeckKeywordTests SectionTests) opm_add_test(run${tapp} SOURCES ${tapp}.cpp LIBRARIES opmparser ${Boost_LIBRARIES}) endforeach() diff --git a/ThirdParty/custom-opm-parser/opm-parser/opm/parser/eclipse/Deck/tests/DeckDoubleItemTests.cpp b/ThirdParty/custom-opm-parser/opm-parser/opm/parser/eclipse/Deck/tests/DeckDoubleItemTests.cpp index bb7e5021ea..f39e970ed9 100644 --- a/ThirdParty/custom-opm-parser/opm-parser/opm/parser/eclipse/Deck/tests/DeckDoubleItemTests.cpp +++ b/ThirdParty/custom-opm-parser/opm-parser/opm/parser/eclipse/Deck/tests/DeckDoubleItemTests.cpp @@ -20,9 +20,7 @@ #define BOOST_TEST_MODULE DeckItemTests -#include #include -#include #include #include diff --git a/ThirdParty/custom-opm-parser/opm-parser/opm/parser/eclipse/Deck/tests/DeckIntItemTests.cpp b/ThirdParty/custom-opm-parser/opm-parser/opm/parser/eclipse/Deck/tests/DeckIntItemTests.cpp index d3cb0b9a0c..9985828596 100644 --- a/ThirdParty/custom-opm-parser/opm-parser/opm/parser/eclipse/Deck/tests/DeckIntItemTests.cpp +++ b/ThirdParty/custom-opm-parser/opm-parser/opm/parser/eclipse/Deck/tests/DeckIntItemTests.cpp @@ -19,9 +19,7 @@ #define BOOST_TEST_MODULE DeckItemTests -#include #include -#include #include #include diff --git a/ThirdParty/custom-opm-parser/opm-parser/opm/parser/eclipse/Deck/tests/DeckKeywordTests.cpp b/ThirdParty/custom-opm-parser/opm-parser/opm/parser/eclipse/Deck/tests/DeckKeywordTests.cpp index b89fab0d69..9549d71e9b 100644 --- a/ThirdParty/custom-opm-parser/opm-parser/opm/parser/eclipse/Deck/tests/DeckKeywordTests.cpp +++ b/ThirdParty/custom-opm-parser/opm-parser/opm/parser/eclipse/Deck/tests/DeckKeywordTests.cpp @@ -22,9 +22,7 @@ #define BOOST_TEST_MODULE DeckKeywordTests -#include #include -#include #include diff --git a/ThirdParty/custom-opm-parser/opm-parser/opm/parser/eclipse/Deck/tests/DeckRecordTests.cpp b/ThirdParty/custom-opm-parser/opm-parser/opm/parser/eclipse/Deck/tests/DeckRecordTests.cpp index 26df6c183c..e66056142d 100644 --- a/ThirdParty/custom-opm-parser/opm-parser/opm/parser/eclipse/Deck/tests/DeckRecordTests.cpp +++ b/ThirdParty/custom-opm-parser/opm-parser/opm/parser/eclipse/Deck/tests/DeckRecordTests.cpp @@ -71,6 +71,8 @@ BOOST_AUTO_TEST_CASE(addItem_differentItemsSameName_throws) { DeckRecord deckRecord; deckRecord.addItem( mkIntItem( "TEST" ) ); BOOST_CHECK_THROW( deckRecord.addItem( mkIntItem( "TEST" ) ), std::invalid_argument ); + std::vector< DeckItem > items = { mkIntItem( "TEST" ), mkIntItem( "TEST" ) }; + BOOST_CHECK_THROW( DeckRecord( std::move( items ) ), std::invalid_argument ); } BOOST_AUTO_TEST_CASE(get_byIndex_returnsItem) { diff --git a/ThirdParty/custom-opm-parser/opm-parser/opm/parser/eclipse/Deck/tests/DeckStringItemTests.cpp b/ThirdParty/custom-opm-parser/opm-parser/opm/parser/eclipse/Deck/tests/DeckStringItemTests.cpp index 5bc1c44f8b..f78b3c7269 100644 --- a/ThirdParty/custom-opm-parser/opm-parser/opm/parser/eclipse/Deck/tests/DeckStringItemTests.cpp +++ b/ThirdParty/custom-opm-parser/opm-parser/opm/parser/eclipse/Deck/tests/DeckStringItemTests.cpp @@ -21,9 +21,7 @@ #define BOOST_TEST_MODULE DeckStringItemTests -#include #include -#include #include diff --git a/ThirdParty/custom-opm-parser/opm-parser/opm/parser/eclipse/Deck/tests/DeckTests.cpp b/ThirdParty/custom-opm-parser/opm-parser/opm/parser/eclipse/Deck/tests/DeckTests.cpp index 3a7c032690..fb3733e564 100644 --- a/ThirdParty/custom-opm-parser/opm-parser/opm/parser/eclipse/Deck/tests/DeckTests.cpp +++ b/ThirdParty/custom-opm-parser/opm-parser/opm/parser/eclipse/Deck/tests/DeckTests.cpp @@ -22,9 +22,7 @@ #define BOOST_TEST_MODULE DeckTests -#include #include -#include #include #include @@ -37,6 +35,18 @@ BOOST_AUTO_TEST_CASE(Initialize) { BOOST_REQUIRE_NO_THROW(DeckConstPtr deckConstPtr(new Deck())); } +BOOST_AUTO_TEST_CASE(Initializer_lists) { + DeckKeyword foo( "foo" ); + DeckKeyword bar( "bar" ); + + std::string foostr( "foo" ); + std::string barstr( "bar" ); + + BOOST_REQUIRE_NO_THROW( Deck( { foo, bar } ) ); + BOOST_REQUIRE_NO_THROW( Deck( { foostr, barstr } ) ); + BOOST_REQUIRE_NO_THROW( Deck( { "Kappa", "Phi" } ) ); +} + BOOST_AUTO_TEST_CASE(hasKeyword_empty_returnFalse) { Deck deck; BOOST_CHECK_EQUAL(false, deck.hasKeyword("Bjarne")); diff --git a/ThirdParty/custom-opm-parser/opm-parser/opm/parser/eclipse/Deck/tests/DeckTimeStepTests.cpp b/ThirdParty/custom-opm-parser/opm-parser/opm/parser/eclipse/Deck/tests/DeckTimeStepTests.cpp deleted file mode 100644 index da568a0708..0000000000 --- a/ThirdParty/custom-opm-parser/opm-parser/opm/parser/eclipse/Deck/tests/DeckTimeStepTests.cpp +++ /dev/null @@ -1,136 +0,0 @@ -/* - Copyright 2015 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 . - */ - - -#define BOOST_TEST_MODULE DeckTimeStepTests - -#include -#include -#include -#include -#include -#include -#include - - -using namespace Opm; - -BOOST_AUTO_TEST_CASE(testDeckTimeStepInitialize) { - - BOOST_CHECK_NO_THROW(DeckTimeStep deckTimeStep); -} - -BOOST_AUTO_TEST_CASE(testDeckTimeStepTSTEP) { - Opm::Parser parser; - std::string input = - "START -- 0 \n" - "19 JUN 2007 / \n" - "SCHEDULE\n" - "DATES -- 1,2\n" - " 10 OKT 2008 / \n" - " 11 OKT 2008 / \n" - "/\n" - "WELSPECS\n" - " 'OP_1' 'OP' 9 9 1* 'OIL' 1* 1* 1* 1* 1* 1* 1* / \n" - "/\n" - "COMPDAT\n" - " 'OP_1' 9 9 1 1 'OPEN' 1* 32.948 0.311 3047.839 1* 1* 'X' 22.100 / \n" - " 'OP_1' 9 9 2 2 'OPEN' 1* 46.825 0.311 4332.346 1* 1* 'X' 22.123 / \n" - " 'OP_1' 9 9 3 9 'OPEN' 1* 32.948 0.311 3047.839 1* 1* 'X' 22.100 / \n" - "/\n" - "DATES -- 3,4\n" - " 20 JAN 2010 / \n" - " 21 JAN 2010 / \n" - "/\n"; - - - ParseContext parseContext; - DeckPtr deck = parser.parseString(input, parseContext); - - SCHEDULESection scheduleSection = SCHEDULESection(*deck); - DeckTimeStepConstPtr step1 = scheduleSection.getDeckTimeStep(0); - DeckTimeStepConstPtr step2 = scheduleSection.getDeckTimeStep(1); - DeckTimeStepConstPtr step3 = scheduleSection.getDeckTimeStep(2); - DeckTimeStepConstPtr step4 = scheduleSection.getDeckTimeStep(3); - BOOST_CHECK_EQUAL(step1->hasKeyword("WELSPECS"), false); - BOOST_CHECK_EQUAL(step2->hasKeyword("WELSPECS"), false); - BOOST_CHECK_EQUAL(step3->hasKeyword("WELSPECS"), true); - BOOST_CHECK_EQUAL(step4->hasKeyword("WELSPECS"), false); - -} - - - -BOOST_AUTO_TEST_CASE(testDeckTimeStepDATES) { - Opm::Parser parser; - std::string input = - "RUNSPEC\n" - "INIT\n" - "UNIFOUT\n" - "OIL\n" - "GAS\n" - "WATER\n" - "METRIC\n" - "DIMENS\n" - "3 3 3/\n" - "GRID\n" - "DXV\n" - "1.0 2.0 3.0 /\n" - "DYV\n" - "4.0 5.0 6.0 /\n" - "DZV\n" - "7.0 8.0 9.0 /\n" - "TOPS\n" - "9*100 /\n" - "PROPS\n" - "PORO\n" - "27*0.3 /\n" - "PERMX\n" - "27*1 /\n" - "SOLUTION\n" - "RPTRST\n" - "BASIC=2\n" - "/\n" - "SCHEDULE\n" - "TSTEP\n" - "1.0 2.0 3.0 4.0 /\n" - "WELSPECS\n" - "'INJ' 'G' 1 1 2000 'GAS' /\n" - "'PROD' 'G' 3 3 1000 'OIL' /\n" - "/\n"; - - ParseContext parseContext; - DeckPtr deck = parser.parseString(input, parseContext); - - SCHEDULESection scheduleSection = SCHEDULESection(*deck); - DeckTimeStepConstPtr step1 = scheduleSection.getDeckTimeStep(0); - DeckTimeStepConstPtr step2 = scheduleSection.getDeckTimeStep(1); - DeckTimeStepConstPtr step3 = scheduleSection.getDeckTimeStep(2); - DeckTimeStepConstPtr step4 = scheduleSection.getDeckTimeStep(3); - DeckTimeStepConstPtr step5 = scheduleSection.getDeckTimeStep(4); - BOOST_CHECK_EQUAL(step1->hasKeyword("WELSPECS"), false); - BOOST_CHECK_EQUAL(step2->hasKeyword("WELSPECS"), false); - BOOST_CHECK_EQUAL(step3->hasKeyword("WELSPECS"), false); - BOOST_CHECK_EQUAL(step4->hasKeyword("WELSPECS"), false); - BOOST_CHECK_EQUAL(step5->hasKeyword("WELSPECS"), true); - -} - - - diff --git a/ThirdParty/custom-opm-parser/opm-parser/opm/parser/eclipse/Deck/tests/SectionTests.cpp b/ThirdParty/custom-opm-parser/opm-parser/opm/parser/eclipse/Deck/tests/SectionTests.cpp index acc5163d56..bf07879756 100644 --- a/ThirdParty/custom-opm-parser/opm-parser/opm/parser/eclipse/Deck/tests/SectionTests.cpp +++ b/ThirdParty/custom-opm-parser/opm-parser/opm/parser/eclipse/Deck/tests/SectionTests.cpp @@ -28,7 +28,6 @@ #include #include -#include #include #include diff --git a/ThirdParty/custom-opm-parser/opm-parser/opm/parser/eclipse/EclipseState/Eclipse3DProperties.cpp b/ThirdParty/custom-opm-parser/opm-parser/opm/parser/eclipse/EclipseState/Eclipse3DProperties.cpp index b650652163..cd1dc27921 100644 --- a/ThirdParty/custom-opm-parser/opm-parser/opm/parser/eclipse/EclipseState/Eclipse3DProperties.cpp +++ b/ThirdParty/custom-opm-parser/opm-parser/opm/parser/eclipse/EclipseState/Eclipse3DProperties.cpp @@ -1,5 +1,5 @@ /* - Copyright 2013 Statoil ASA. + Copyright 2016 Statoil ASA. This file is part of the Open Porous Media project (OPM). @@ -19,26 +19,23 @@ #include #include +#include -#include #include #include #include -#include #include #include #include #include #include #include -#include #include -#include -#include #include namespace Opm { - namespace GridPropertyPostProcessor { + + namespace { void distTopLayer( std::vector& values, const EclipseGrid* eclipseGrid ) @@ -52,9 +49,26 @@ namespace Opm { } } - /// initPORV uses doubleGridProperties: PORV, PORO, NTG, MULTPV + // this funcion applies a single pore volume multiplier (i.e., it deals with a single + // record of the MULTREGP keyword) + void applyPorosityRegionMultiplier_(std::vector& porev, + const std::vector& regionId, + int multRegionId, + double multValue) + { + for (unsigned i = 0; i < porev.size(); ++i) { + if (regionId[i] == multRegionId) + porev[i] *= multValue; + } + } + + /// this function initializes the pore volume of all cells. it uses the raw keyword + /// 'MULTREGP', the integer grid properties 'FLUXNUM', 'MULTNUM' and 'OPERNUM' as + /// well as the double grid properties 'PORV', 'PORO', 'NTG' and 'MULTPV' void initPORV( std::vector& values, + const Deck* deck, const EclipseGrid* eclipseGrid, + const GridProperties* intGridProperties, const GridProperties* doubleGridProperties) { const auto iter = std::find_if( values.begin(), values.end(), []( double value ) { return std::isnan(value); }); @@ -83,6 +97,54 @@ namespace Opm { for (size_t globalIndex = 0; globalIndex < multpvData.size(); globalIndex++) values[globalIndex] *= multpvData[globalIndex]; } + + // deal with the region multiplier for porosity + if (deck->hasKeyword("MULTREGP")) { + const DeckKeyword& multregpKeyword = deck->getKeyword("MULTREGP"); + for (unsigned recordIdx = 0; recordIdx < multregpKeyword.size(); ++recordIdx) { + const DeckRecord& multregpRecord = multregpKeyword.getRecord(recordIdx); + + int regionId = multregpRecord.getItem("REGION").template get(0); + std::string regionType = multregpRecord.getItem("REGION_TYPE").template get(0); + double multValue = multregpRecord.getItem("MULTIPLIER").template get(0); + uppercase(regionType, regionType); + + // deal with the "convenience" feature of ECL: if the region index is + // zero or negative, the record is ignored. + if (regionId <= 0) + continue; + + // implement a (documented) ECL bug: the region index must be unique + // (i.e., it is impossible to specify multipliers for different + // region types with the same index). Also, only the last occurence + // of each region counts. + unsigned record2Idx = recordIdx + 1; + for (; record2Idx < multregpKeyword.size(); ++record2Idx) { + const DeckRecord& multregpRecord2 = multregpKeyword.getRecord(record2Idx); + int region2Idx = multregpRecord2.getItem("REGION").template get(0); + if (region2Idx == regionId) + break; + } + if (record2Idx < multregpKeyword.size()) + // the region was specified twice + continue; + + if (regionType == "M") { + const GridProperty& multnumProp = intGridProperties->getKeyword("MULTNUM"); + applyPorosityRegionMultiplier_(values, multnumProp.getData(), regionId, multValue); + } + else if (regionType == "F") { + const GridProperty& fluxnumProp = intGridProperties->getKeyword("FLUXNUM"); + applyPorosityRegionMultiplier_(values, fluxnumProp.getData(), regionId, multValue); + } + else if (regionType == "O") { + const GridProperty& opernumProp = intGridProperties->getKeyword("OPERNUM"); + applyPorosityRegionMultiplier_(values, opernumProp.getData(), regionId, multValue); + } + else + throw std::logic_error("Unknown or illegal region type for MULTREGP keyword: '"+regionType+"'"); + } + } } @@ -187,7 +249,7 @@ namespace Opm { const auto tempLookup = std::bind( temperature_lookup, _1, tableManager, eclipseGrid, intGridProperties ); - const auto distributeTopLayer = std::bind( &GridPropertyPostProcessor::distTopLayer, _1, eclipseGrid ); + const auto distributeTopLayer = std::bind( &distTopLayer, _1, eclipseGrid ); std::vector< GridProperties< double >::SupportedKeywordInfo > supportedDoubleKeywords; @@ -396,19 +458,21 @@ namespace Opm { { - auto initPORV = std::bind(&GridPropertyPostProcessor::initPORV, + auto initPORVProcessor = std::bind(&initPORV, std::placeholders::_1, + &deck, &eclipseGrid, + &m_intGridProperties, &m_doubleGridProperties); m_doubleGridProperties.postAddKeyword( "PORV", std::numeric_limits::quiet_NaN(), - initPORV, + initPORVProcessor, "Volume" ); } { - auto actnumPP = std::bind(&GridPropertyPostProcessor::ACTNUMPostProcessor, + auto actnumPP = std::bind(&ACTNUMPostProcessor, std::placeholders::_1, &m_doubleGridProperties); @@ -422,34 +486,28 @@ namespace Opm { } bool Eclipse3DProperties::supportsGridProperty(const std::string& keyword) const { - auto kw = uppercase(keyword); - return m_doubleGridProperties.supportsKeyword( kw ) || m_intGridProperties.supportsKeyword( kw ); + return m_doubleGridProperties.supportsKeyword( keyword ) || m_intGridProperties.supportsKeyword( keyword ); } bool Eclipse3DProperties::hasDeckIntGridProperty(const std::string& keyword) const { - auto kw = uppercase(keyword); - if (!m_intGridProperties.supportsKeyword(kw)) - return false; - //throw std::logic_error("Integer grid property " + kw + " is unsupported!"); + if (!m_intGridProperties.supportsKeyword( keyword )) + throw std::logic_error("Integer grid property " + keyword + " is unsupported!"); - return m_intGridProperties.hasKeyword( kw ); + return m_intGridProperties.hasKeyword( keyword ); } bool Eclipse3DProperties::hasDeckDoubleGridProperty(const std::string& keyword) const { - auto kw = uppercase(keyword); - if (!m_doubleGridProperties.supportsKeyword(kw)) - return false; - //throw std::logic_error("Double grid property " + kw + " is unsupported!"); + if (!m_doubleGridProperties.supportsKeyword( keyword )) + throw std::logic_error("Double grid property " + keyword + " is unsupported!"); - return m_doubleGridProperties.hasKeyword( kw ); + return m_doubleGridProperties.hasKeyword( keyword ); } const GridProperty& Eclipse3DProperties::getIntGridProperty( const std::string& keyword ) const { - auto kw = uppercase(keyword); - auto& gridProperty = const_cast< Eclipse3DProperties* >( this )->m_intGridProperties.getKeyword( kw ); + auto& gridProperty = const_cast< Eclipse3DProperties* >( this )->m_intGridProperties.getKeyword( keyword ); gridProperty.runPostProcessor(); return gridProperty; } @@ -458,12 +516,20 @@ namespace Opm { /// gets property from doubleGridProperty --- and calls the runPostProcessor const GridProperty& Eclipse3DProperties::getDoubleGridProperty( const std::string& keyword ) const { - auto kw = uppercase(keyword); - auto& gridProperty = const_cast< Eclipse3DProperties* >( this )->m_doubleGridProperties.getKeyword( kw ); + auto& gridProperty = const_cast< Eclipse3DProperties* >( this )->m_doubleGridProperties.getKeyword( keyword ); gridProperty.runPostProcessor(); return gridProperty; } + const GridProperties& Eclipse3DProperties::getIntProperties() const { + return m_intGridProperties; + } + + const GridProperties& Eclipse3DProperties::getDoubleProperties() const { + return m_doubleGridProperties; + } + + std::string Eclipse3DProperties::getDefaultRegionKeyword() const { return m_defaultRegion; } @@ -478,10 +544,9 @@ namespace Opm { } std::vector< int > Eclipse3DProperties::getRegions( const std::string& keyword ) const { - auto kw = uppercase(keyword); - if( !this->hasDeckIntGridProperty( kw ) ) return {}; + if( !this->hasDeckIntGridProperty( keyword ) ) return {}; - const auto& property = this->getIntGridProperty( kw ); + const auto& property = this->getIntGridProperty( keyword ); std::set< int > regions( property.getData().begin(), property.getData().end() ); @@ -638,34 +703,34 @@ namespace Opm { if (deckKeyword.name() == "BOX") handleBOXKeyword(deckKeyword, boxManager); - if (deckKeyword.name() == "ENDBOX") + else if (deckKeyword.name() == "ENDBOX") handleENDBOXKeyword(boxManager); - if (deckKeyword.name() == "COPY") + else if (deckKeyword.name() == "COPY") handleCOPYKeyword( deckKeyword , boxManager); - if (deckKeyword.name() == "EQUALS") + else if (deckKeyword.name() == "EQUALS") handleEQUALSKeyword(deckKeyword, boxManager); - if (deckKeyword.name() == "ADD") + else if (deckKeyword.name() == "ADD") handleADDKeyword( deckKeyword , boxManager); - if (deckKeyword.name() == "MULTIPLY") + else if (deckKeyword.name() == "MULTIPLY") handleMULTIPLYKeyword(deckKeyword, boxManager); - if (deckKeyword.name() == "EQUALREG") + else if (deckKeyword.name() == "EQUALREG") handleEQUALREGKeyword(deckKeyword); - if (deckKeyword.name() == "ADDREG") + else if (deckKeyword.name() == "ADDREG") handleADDREGKeyword(deckKeyword); - if (deckKeyword.name() == "MULTIREG") + else if (deckKeyword.name() == "MULTIREG") handleMULTIREGKeyword(deckKeyword); - if (deckKeyword.name() == "COPYREG") + else if (deckKeyword.name() == "COPYREG") handleCOPYREGKeyword(deckKeyword); boxManager.endKeyword(); @@ -710,7 +775,7 @@ namespace Opm { void Eclipse3DProperties::handleADDREGKeyword( const DeckKeyword& deckKeyword) { for( const auto& record : deckKeyword ) { - const std::string targetArray = uppercase(record.getItem("ARRAY").get< std::string >(0)); + const std::string& targetArray = record.getItem("ARRAY").get< std::string >(0); const auto& regionProperty = getRegion( record.getItem("REGION_NAME") ); if (m_intGridProperties.hasKeyword( targetArray )) @@ -726,7 +791,7 @@ namespace Opm { void Eclipse3DProperties::handleMULTIREGKeyword( const DeckKeyword& deckKeyword) { for( const auto& record : deckKeyword ) { - const std::string targetArray = uppercase(record.getItem("ARRAY").get< std::string >(0)); + const std::string& targetArray = record.getItem("ARRAY").get< std::string >(0); const auto& regionProperty = getRegion( record.getItem("REGION_NAME") ); if (m_intGridProperties.supportsKeyword( targetArray )) @@ -741,7 +806,7 @@ namespace Opm { void Eclipse3DProperties::handleCOPYREGKeyword( const DeckKeyword& deckKeyword) { for( const auto& record : deckKeyword ) { - const std::string srcArray = uppercase(record.getItem("ARRAY").get< std::string >(0)); + const std::string& srcArray = record.getItem("ARRAY").get< std::string >(0); const auto& regionProperty = getRegion( record.getItem("REGION_NAME") ); if (m_intGridProperties.hasKeyword( srcArray )) @@ -758,7 +823,7 @@ namespace Opm { void Eclipse3DProperties::handleMULTIPLYKeyword( const DeckKeyword& deckKeyword, BoxManager& boxManager) { for( const auto& record : deckKeyword ) { - const std::string field = uppercase(record.getItem("field").get< std::string >(0)); + const std::string& field = record.getItem("field").get< std::string >(0); if (m_doubleGridProperties.hasKeyword( field )) m_doubleGridProperties.handleMULTIPLYRecord( record , boxManager ); @@ -778,7 +843,7 @@ namespace Opm { */ void Eclipse3DProperties::handleADDKeyword( const DeckKeyword& deckKeyword, BoxManager& boxManager) { for( const auto& record : deckKeyword ) { - const std::string field = uppercase(record.getItem("field").get< std::string >(0)); + const std::string& field = record.getItem("field").get< std::string >(0); if (m_doubleGridProperties.hasKeyword( field )) m_doubleGridProperties.handleADDRecord( record , boxManager ); @@ -793,7 +858,7 @@ namespace Opm { void Eclipse3DProperties::handleCOPYKeyword( const DeckKeyword& deckKeyword, BoxManager& boxManager) { for( const auto& record : deckKeyword ) { - const std::string field = uppercase(record.getItem("src").get< std::string >(0)); + const std::string& field = record.getItem("src").get< std::string >(0); if (m_doubleGridProperties.hasKeyword( field )) m_doubleGridProperties.handleCOPYRecord( record , boxManager ); @@ -808,7 +873,7 @@ namespace Opm { void Eclipse3DProperties::handleEQUALSKeyword( const DeckKeyword& deckKeyword, BoxManager& boxManager) { for( const auto& record : deckKeyword ) { - const std::string field = uppercase(record.getItem("field").get< std::string >(0)); + const std::string& field = record.getItem("field").get< std::string >(0); if (m_doubleGridProperties.supportsKeyword( field )) m_doubleGridProperties.handleEQUALSRecord( record , boxManager ); diff --git a/ThirdParty/custom-opm-parser/opm-parser/opm/parser/eclipse/EclipseState/Eclipse3DProperties.hpp b/ThirdParty/custom-opm-parser/opm-parser/opm/parser/eclipse/EclipseState/Eclipse3DProperties.hpp index ed492ed8a9..495238e89b 100644 --- a/ThirdParty/custom-opm-parser/opm-parser/opm/parser/eclipse/EclipseState/Eclipse3DProperties.hpp +++ b/ThirdParty/custom-opm-parser/opm-parser/opm/parser/eclipse/EclipseState/Eclipse3DProperties.hpp @@ -1,5 +1,5 @@ /* - Copyright 2013 Statoil ASA. + Copyright 2016 Statoil ASA. This file is part of the Open Porous Media project (OPM). @@ -19,13 +19,16 @@ #ifndef OPM_ECLIPSE_PROPERTIES_HPP #define OPM_ECLIPSE_PROPERTIES_HPP -#include -#include -#include +#include +#include -#include +#include +#include +#include +#include #include -#include +#include +#include namespace Opm { @@ -36,13 +39,8 @@ namespace Opm { class DeckKeyword; class DeckRecord; class EclipseGrid; - class EclipseState; - class InitConfig; - class IOConfig; - class Schedule; class Section; class TableManager; - class TransMult; class UnitSystem; /// Class representing properties on 3D grid for use in EclipseState. @@ -62,6 +60,9 @@ namespace Opm { const GridProperty& getIntGridProperty ( const std::string& keyword ) const; const GridProperty& getDoubleGridProperty ( const std::string& keyword ) const; + const GridProperties& getIntProperties() const; + const GridProperties& getDoubleProperties() const; + bool hasDeckIntGridProperty(const std::string& keyword) const; bool hasDeckDoubleGridProperty(const std::string& keyword) const; bool supportsGridProperty(const std::string& keyword) const; diff --git a/ThirdParty/custom-opm-parser/opm-parser/opm/parser/eclipse/EclipseState/EclipseConfig.cpp b/ThirdParty/custom-opm-parser/opm-parser/opm/parser/eclipse/EclipseState/EclipseConfig.cpp index 4cae472049..29daf4276a 100644 --- a/ThirdParty/custom-opm-parser/opm-parser/opm/parser/eclipse/EclipseState/EclipseConfig.cpp +++ b/ThirdParty/custom-opm-parser/opm-parser/opm/parser/eclipse/EclipseState/EclipseConfig.cpp @@ -20,12 +20,14 @@ #include #include +#include #include #include #include -#include +#include #include #include +#include #include #include #include @@ -34,25 +36,53 @@ namespace Opm { EclipseConfig::EclipseConfig(const Deck& deck, const Eclipse3DProperties& eclipse3DProperties, - std::shared_ptr< EclipseGrid > inputGrid, - const Schedule& schedule) : + const GridDims& inputGrid, + const Schedule& schedule, + const ParseContext& parseContext) : m_ioConfig( std::make_shared(deck)), - m_initConfig( std::make_shared(deck)), - m_simulationConfig(std::make_shared(deck, eclipse3DProperties)), - m_summaryConfig( deck, schedule, eclipse3DProperties, inputGrid->getNXYZ()) + m_initConfig( deck), + m_simulationConfig(deck, eclipse3DProperties), + m_summaryConfig( deck, schedule, eclipse3DProperties, parseContext , inputGrid.getNXYZ()), + m_restartConfig( deck ) { - // Hmmm - would have thought this should iterate through the SCHEDULE section as well? - if (Section::hasSOLUTION(deck)) { - std::shared_ptr solutionSection = std::make_shared(deck); - m_ioConfig->handleSolutionSection(schedule.getTimeMap(), solutionSection); - } - m_ioConfig->initFirstOutput(schedule); + m_ioConfig->initFirstRFTOutput(schedule); } - const SummaryConfig& EclipseConfig::getSummaryConfig() const { + + const InitConfig& EclipseConfig::init() const { + return m_initConfig; + } + + const IOConfig& EclipseConfig::io() const { + return *m_ioConfig; + } + + IOConfig& EclipseConfig::io() { + return *m_ioConfig; + } + + const SimulationConfig& EclipseConfig::simulation() const { + return m_simulationConfig; + } + + const SummaryConfig& EclipseConfig::summary() const { return m_summaryConfig; } + const RestartConfig& EclipseConfig::restart() const { + return this->m_restartConfig; + } + + // [[deprecated]] --- use summary() + const SummaryConfig& EclipseConfig::getSummaryConfig() const { + return summary(); + } + + // [[deprecated]] --- use restart() + const RestartConfig& EclipseConfig::getRestartConfig() const { + return this->restart(); + } + IOConfigConstPtr EclipseConfig::getIOConfigConst() const { return m_ioConfig; } @@ -61,11 +91,13 @@ namespace Opm { return m_ioConfig; } - InitConfigConstPtr EclipseConfig::getInitConfig() const { - return m_initConfig; + // [[deprecated]] --- use init() + const InitConfig& EclipseConfig::getInitConfig() const { + return init(); } - SimulationConfigConstPtr EclipseConfig::getSimulationConfig() const { - return m_simulationConfig; + // [[deprecated]] --- use simulation() + const SimulationConfig& EclipseConfig::getSimulationConfig() const { + return simulation(); } } diff --git a/ThirdParty/custom-opm-parser/opm-parser/opm/parser/eclipse/EclipseState/EclipseConfig.hpp b/ThirdParty/custom-opm-parser/opm-parser/opm/parser/eclipse/EclipseState/EclipseConfig.hpp index d2e76ed717..248c80511a 100644 --- a/ThirdParty/custom-opm-parser/opm-parser/opm/parser/eclipse/EclipseState/EclipseConfig.hpp +++ b/ThirdParty/custom-opm-parser/opm-parser/opm/parser/eclipse/EclipseState/EclipseConfig.hpp @@ -23,35 +23,47 @@ #include #include +#include +#include +#include namespace Opm { class Deck; + class GridDims; class Eclipse3DProperties; class IOConfig; - class InitConfig; - class SimulationConfig; - + class ParseContext; class EclipseConfig { public: EclipseConfig(const Deck& deck, const Eclipse3DProperties& eclipse3DProperties, - std::shared_ptr< EclipseGrid > inputGrid, - const Schedule& schedule); + const GridDims& gridDims, + const Schedule& schedule, + const ParseContext& parseContext); - std::shared_ptr< const IOConfig > getIOConfigConst() const; - std::shared_ptr< IOConfig > getIOConfig() const; - std::shared_ptr< const InitConfig > getInitConfig() const; - std::shared_ptr< const SimulationConfig > getSimulationConfig() const; + const InitConfig& init() const; + const IOConfig& io() const; + IOConfig& io(); + const SimulationConfig & simulation() const; + const SummaryConfig& summary() const; + const RestartConfig& restart() const; + + std::shared_ptr getIOConfigConst() const; + std::shared_ptr getIOConfig() const; + const InitConfig& getInitConfig() const; + const SimulationConfig & getSimulationConfig() const; const SummaryConfig& getSummaryConfig() const; + const RestartConfig& getRestartConfig() const; private: std::shared_ptr m_ioConfig; - std::shared_ptr m_initConfig; - std::shared_ptr m_simulationConfig; + const InitConfig m_initConfig; + const SimulationConfig m_simulationConfig; SummaryConfig m_summaryConfig; + RestartConfig m_restartConfig; }; } diff --git a/ThirdParty/custom-opm-parser/opm-parser/opm/parser/eclipse/EclipseState/EclipseState.cpp b/ThirdParty/custom-opm-parser/opm-parser/opm/parser/eclipse/EclipseState/EclipseState.cpp index b4edd63b72..f3e7093be7 100644 --- a/ThirdParty/custom-opm-parser/opm-parser/opm/parser/eclipse/EclipseState/EclipseState.cpp +++ b/ThirdParty/custom-opm-parser/opm-parser/opm/parser/eclipse/EclipseState/EclipseState.cpp @@ -30,6 +30,7 @@ #include #include #include +#include #include #include #include @@ -56,16 +57,17 @@ namespace Opm { EclipseState::EclipseState(const Deck& deck, ParseContext parseContext) : m_parseContext( parseContext ), m_tables( deck ), + m_gridDims( deck ), m_inputGrid( std::make_shared(deck, nullptr) ), - m_schedule( std::make_shared( m_parseContext, m_inputGrid, deck ) ), + m_transMult( m_inputGrid->getNX(), m_inputGrid->getNY(), m_inputGrid->getNZ()), + m_schedule( std::make_shared( m_parseContext, *m_inputGrid, deck ) ), m_eclipseProperties( deck, m_tables, *m_inputGrid ), - m_eclipseConfig( deck, m_eclipseProperties, m_inputGrid, *m_schedule), - m_inputNnc( deck, m_inputGrid ), + m_eclipseConfig( deck, m_eclipseProperties, m_gridDims, *m_schedule , parseContext), + m_inputNnc( deck, m_gridDims ), m_deckUnitSystem( deck.getActiveUnitSystem() ) { - if (m_inputGrid->hasCellInfo()) - m_inputGrid->resetACTNUM(m_eclipseProperties.getIntGridProperty("ACTNUM").getData().data()); + m_inputGrid->resetACTNUM(m_eclipseProperties.getIntGridProperty("ACTNUM").getData().data()); if (deck.hasKeyword( "TITLE" )) { const auto& titleKeyword = deck.getKeyword( "TITLE" ); @@ -76,7 +78,12 @@ namespace Opm { initTransMult(); initFaults(deck); - initMULTREGT(deck); + + std::vector< const DeckKeyword* > multregtKeywords; + if (deck.hasKeyword("MULTREGT")) + multregtKeywords = deck.getKeywordList("MULTREGT"); + m_transMult.createMultregtScanner(m_eclipseProperties, multregtKeywords); + m_messageContainer.appendMessages(m_tables.getMessageContainer()); m_messageContainer.appendMessages(m_schedule->getMessageContainer()); @@ -104,6 +111,14 @@ namespace Opm { return m_eclipseConfig.getSummaryConfig(); } + const RestartConfig& EclipseState::getRestartConfig() const { + return m_eclipseConfig.getRestartConfig(); + } + + RestartConfig& EclipseState::getRestartConfig() { + return const_cast< RestartConfig& >( m_eclipseConfig.getRestartConfig() ); + } + const Eclipse3DProperties& EclipseState::get3DProperties() const { return m_eclipseProperties; } @@ -130,19 +145,32 @@ namespace Opm { return m_schedule; } + /// [[deprecated]] --- use cfg().io() IOConfigConstPtr EclipseState::getIOConfigConst() const { return m_eclipseConfig.getIOConfigConst(); } + /// [[deprecated]] --- use cfg().io() IOConfigPtr EclipseState::getIOConfig() const { return m_eclipseConfig.getIOConfig(); } - InitConfigConstPtr EclipseState::getInitConfig() const { + /// [[deprecated]] --- use cfg().init() + const InitConfig& EclipseState::getInitConfig() const { return m_eclipseConfig.getInitConfig(); } - SimulationConfigConstPtr EclipseState::getSimulationConfig() const { + /// [[deprecated]] --- use cfg() + const EclipseConfig& EclipseState::getEclipseConfig() const { + return cfg(); + } + + const EclipseConfig& EclipseState::cfg() const { + return m_eclipseConfig; + } + + /// [[deprecated]] --- use cfg().simulation() + const SimulationConfig& EclipseState::getSimulationConfig() const { return m_eclipseConfig.getSimulationConfig(); } @@ -150,7 +178,7 @@ namespace Opm { return m_faults; } - std::shared_ptr EclipseState::getTransMult() const { + const TransMult& EclipseState::getTransMult() const { return m_transMult; } @@ -167,46 +195,41 @@ namespace Opm { } void EclipseState::initTransMult() { - EclipseGridConstPtr grid = getInputGrid(); - m_transMult = std::make_shared( grid->getNX() , grid->getNY() , grid->getNZ()); - const auto& p = m_eclipseProperties; if (m_eclipseProperties.hasDeckDoubleGridProperty("MULTX")) - m_transMult->applyMULT(p.getDoubleGridProperty("MULTX"), FaceDir::XPlus); + m_transMult.applyMULT(p.getDoubleGridProperty("MULTX"), FaceDir::XPlus); if (m_eclipseProperties.hasDeckDoubleGridProperty("MULTX-")) - m_transMult->applyMULT(p.getDoubleGridProperty("MULTX-"), FaceDir::XMinus); + m_transMult.applyMULT(p.getDoubleGridProperty("MULTX-"), FaceDir::XMinus); if (m_eclipseProperties.hasDeckDoubleGridProperty("MULTY")) - m_transMult->applyMULT(p.getDoubleGridProperty("MULTY"), FaceDir::YPlus); + m_transMult.applyMULT(p.getDoubleGridProperty("MULTY"), FaceDir::YPlus); if (m_eclipseProperties.hasDeckDoubleGridProperty("MULTY-")) - m_transMult->applyMULT(p.getDoubleGridProperty("MULTY-"), FaceDir::YMinus); + m_transMult.applyMULT(p.getDoubleGridProperty("MULTY-"), FaceDir::YMinus); if (m_eclipseProperties.hasDeckDoubleGridProperty("MULTZ")) - m_transMult->applyMULT(p.getDoubleGridProperty("MULTZ"), FaceDir::ZPlus); + m_transMult.applyMULT(p.getDoubleGridProperty("MULTZ"), FaceDir::ZPlus); if (m_eclipseProperties.hasDeckDoubleGridProperty("MULTZ-")) - m_transMult->applyMULT(p.getDoubleGridProperty("MULTZ-"), FaceDir::ZMinus); + m_transMult.applyMULT(p.getDoubleGridProperty("MULTZ-"), FaceDir::ZMinus); } void EclipseState::initFaults(const Deck& deck) { - EclipseGridConstPtr grid = getInputGrid(); - std::shared_ptr gridSection = std::make_shared( deck ); + const GRIDSection gridSection ( deck ); - m_faults = FaultCollection(gridSection, grid); + m_faults = FaultCollection(gridSection, *m_inputGrid); setMULTFLT(gridSection); if (Section::hasEDIT(deck)) { - std::shared_ptr editSection = std::make_shared( deck ); - setMULTFLT(editSection); + setMULTFLT(EDITSection ( deck )); } - m_transMult->applyMULTFLT( m_faults ); + m_transMult.applyMULTFLT( m_faults ); } - void EclipseState::setMULTFLT(std::shared_ptr section) { - for (size_t index=0; index < section->count("MULTFLT"); index++) { - const auto& faultsKeyword = section->getKeyword("MULTFLT" , index); + void EclipseState::setMULTFLT(const Section& section) { + for (size_t index=0; index < section.count("MULTFLT"); index++) { + const auto& faultsKeyword = section.getKeyword("MULTFLT" , index); for (auto iter = faultsKeyword.begin(); iter != faultsKeyword.end(); ++iter) { const auto& faultRecord = *iter; @@ -218,26 +241,6 @@ namespace Opm { } } - - - void EclipseState::initMULTREGT(const Deck& deck) { - EclipseGridConstPtr grid = getInputGrid(); - - std::vector< const DeckKeyword* > multregtKeywords; - if (deck.hasKeyword("MULTREGT")) - multregtKeywords = deck.getKeywordList("MULTREGT"); - - std::shared_ptr scanner = - std::make_shared( - m_eclipseProperties, - multregtKeywords , - m_eclipseProperties.getDefaultRegionKeyword()); - - m_transMult->setMultregtScanner( scanner ); - } - - - void EclipseState::complainAboutAmbiguousKeyword(const Deck& deck, const std::string& keywordName) { m_messageContainer.error("The " + keywordName + " keyword must be unique in the deck. Ignoring all!"); auto keywords = deck.getKeywordList(keywordName); @@ -247,10 +250,6 @@ namespace Opm { } } - void EclipseState::applyModifierDeck(std::shared_ptr deckptr) { - applyModifierDeck(*deckptr); - } - void EclipseState::applyModifierDeck(const Deck& deck) { using namespace ParserKeywords; for (const auto& keyword : deck) { @@ -284,7 +283,7 @@ namespace Opm { */ fault.setTransMult( tmpMultFlt ); - m_transMult->applyMULTFLT( fault ); + m_transMult.applyMULTFLT( fault ); fault.setTransMult( newMultFlt ); } } diff --git a/ThirdParty/custom-opm-parser/opm-parser/opm/parser/eclipse/EclipseState/EclipseState.hpp b/ThirdParty/custom-opm-parser/opm-parser/opm/parser/eclipse/EclipseState/EclipseState.hpp index 79c645e95c..3be3afa5c0 100644 --- a/ThirdParty/custom-opm-parser/opm-parser/opm/parser/eclipse/EclipseState/EclipseState.hpp +++ b/ThirdParty/custom-opm-parser/opm-parser/opm/parser/eclipse/EclipseState/EclipseState.hpp @@ -21,18 +21,13 @@ #define OPM_ECLIPSE_STATE_HPP #include -#include -#include #include #include #include #include -#include -#include #include -#include -#include +#include #include #include #include @@ -52,11 +47,11 @@ namespace Opm { class InitConfig; class IOConfig; class ParseContext; + class RestartConfig; class Schedule; class Section; class SimulationConfig; class TableManager; - class TransMult; class UnitSystem; class EclipseState { @@ -78,15 +73,18 @@ namespace Opm { std::shared_ptr< const Schedule > getSchedule() const; std::shared_ptr< const IOConfig > getIOConfigConst() const; std::shared_ptr< IOConfig > getIOConfig() const; - std::shared_ptr< const InitConfig > getInitConfig() const; - std::shared_ptr< const SimulationConfig > getSimulationConfig() const; + + const InitConfig& getInitConfig() const; + const SimulationConfig& getSimulationConfig() const; const SummaryConfig& getSummaryConfig() const; + const RestartConfig& getRestartConfig() const; + RestartConfig& getRestartConfig(); std::shared_ptr< const EclipseGrid > getInputGrid() const; std::shared_ptr< EclipseGrid > getInputGridCopy() const; const FaultCollection& getFaults() const; - std::shared_ptr getTransMult() const; + const TransMult& getTransMult() const; /// non-neighboring connections /// the non-standard adjacencies as specified in input deck @@ -96,6 +94,8 @@ namespace Opm { const Eclipse3DProperties& get3DProperties() const; const TableManager& getTableManager() const; + const EclipseConfig& getEclipseConfig() const; + const EclipseConfig& cfg() const; // the unit system used by the deck. note that it is rarely needed to convert // units because internally to opm-parser everything is represented by SI @@ -107,8 +107,6 @@ namespace Opm { MessageContainer& getMessageContainer(); std::string getTitle() const; - /// [deprecated] - void applyModifierDeck(std::shared_ptr); void applyModifierDeck(const Deck& deck); private: @@ -116,26 +114,26 @@ namespace Opm { void initTransMult(); void initFaults(const Deck& deck); - void setMULTFLT(std::shared_ptr section); - void initMULTREGT(const Deck& deck); + void setMULTFLT(const Opm::Section& section); void complainAboutAmbiguousKeyword(const Deck& deck, const std::string& keywordName); ParseContext m_parseContext; const TableManager m_tables; + const GridDims m_gridDims; std::shared_ptr m_inputGrid; + TransMult m_transMult; std::shared_ptr< const Schedule > m_schedule; Eclipse3DProperties m_eclipseProperties; EclipseConfig m_eclipseConfig; NNC m_inputNnc; UnitSystem m_deckUnitSystem; - MessageContainer m_messageContainer; - - std::shared_ptr m_transMult; FaultCollection m_faults; std::string m_title; + + MessageContainer m_messageContainer; }; typedef std::shared_ptr EclipseStatePtr; diff --git a/ThirdParty/custom-opm-parser/opm-parser/opm/parser/eclipse/EclipseState/Grid/EclipseGrid.cpp b/ThirdParty/custom-opm-parser/opm-parser/opm/parser/eclipse/EclipseState/Grid/EclipseGrid.cpp index c11fe70ae2..99a3e26a0b 100644 --- a/ThirdParty/custom-opm-parser/opm-parser/opm/parser/eclipse/EclipseState/Grid/EclipseGrid.cpp +++ b/ThirdParty/custom-opm-parser/opm-parser/opm/parser/eclipse/EclipseState/Grid/EclipseGrid.cpp @@ -29,6 +29,9 @@ #include #include #include + +#include + #include #include #include @@ -37,88 +40,96 @@ #include #include #include + #include #include namespace Opm { + + EclipseGrid::EclipseGrid(std::array& dims , + const std::vector& coord , + const std::vector& zcorn , + const int * actnum, + const double * mapaxes) + : m_minpvValue(0), + m_minpvMode(MinpvMode::ModeEnum::Inactive), + m_pinch("PINCH"), + m_pinchoutMode(PinchMode::ModeEnum::TOPBOT), + m_multzMode(PinchMode::ModeEnum::TOP) + { + initCornerPointGrid( dims, coord , zcorn , actnum , mapaxes ); + } + + + /** Will create an EclipseGrid instance based on an existing GRID/EGRID file. */ EclipseGrid::EclipseGrid(const std::string& filename ) - : m_minpvValue(0), + : GridDims(), + m_minpvValue(0), m_minpvMode(MinpvMode::ModeEnum::Inactive), m_pinch("PINCH"), m_pinchoutMode(PinchMode::ModeEnum::TOPBOT), m_multzMode(PinchMode::ModeEnum::TOP) { - ecl_grid_type * new_ptr = ecl_grid_load_case( filename.c_str() ); + ecl_grid_type * new_ptr = ecl_grid_load_case__( filename.c_str() , false ); if (new_ptr) m_grid.reset( new_ptr ); else throw std::invalid_argument("Could not load grid from binary file: " + filename); - m_nx = static_cast( ecl_grid_get_nx( c_ptr() )); - m_ny = static_cast( ecl_grid_get_ny( c_ptr() )); - m_nz = static_cast( ecl_grid_get_nz( c_ptr() )); + m_nx = ecl_grid_get_nx( c_ptr() ); + m_ny = ecl_grid_get_ny( c_ptr() ); + m_nz = ecl_grid_get_nz( c_ptr() ); } - /* Copy constructor */ - EclipseGrid::EclipseGrid(const EclipseGrid& src) - : m_minpvValue( src.m_minpvValue ), - m_minpvMode( src.m_minpvMode ), - m_pinch( src.m_pinch ), - m_pinchoutMode( src.m_pinchoutMode ), - m_multzMode( src.m_multzMode ), - m_nx( src.m_nx ), - m_ny( src.m_ny ), - m_nz( src.m_nz ), - m_messages( src.m_messages ) - { - if (src.hasCellInfo()) - m_grid.reset( ecl_grid_alloc_copy( src.c_ptr() ) ); - - } - - /* - This creates a grid which only has dimension, and no pointer to - a true grid structure. This grid will answer false to - hasCellInfo() - but can be used in all situations where the grid - dependency is really only on the dimensions. - */ EclipseGrid::EclipseGrid(size_t nx, size_t ny , size_t nz, double dx, double dy, double dz) - : m_minpvValue(0), + : GridDims(nx, ny, nz), + m_minpvValue(0), m_minpvMode(MinpvMode::ModeEnum::Inactive), m_pinch("PINCH"), m_pinchoutMode(PinchMode::ModeEnum::TOPBOT), - m_multzMode(PinchMode::ModeEnum::TOP) + m_multzMode(PinchMode::ModeEnum::TOP), + m_grid( ecl_grid_alloc_rectangular(nx, ny, nz, dx, dy, dz, NULL) ) { - m_nx = nx; - m_ny = ny; - m_nz = nz; - m_grid.reset(ecl_grid_alloc_rectangular(nx, ny, nz, dx, dy, dz, NULL)); - } - - - // keyword must be DIMENS or SPECGRID - static std::vector getDims( const DeckKeyword& keyword ) { - const auto& record = keyword.getRecord(0); - std::vector dims = {record.getItem("NX").get< int >(0) , - record.getItem("NY").get< int >(0) , - record.getItem("NZ").get< int >(0) }; - return dims; } EclipseGrid::EclipseGrid(const std::shared_ptr& deckptr, const int * actnum) - : - EclipseGrid(*deckptr, actnum) + : EclipseGrid(*deckptr, actnum) {} + EclipseGrid::EclipseGrid(const EclipseGrid& src, const double* zcorn , const std::vector& actnum) + : GridDims(src.getNX(), src.getNY(), src.getNZ()), + m_messages( src.m_messages ), + m_minpvValue( src.m_minpvValue ), + m_minpvMode( src.m_minpvMode ), + m_pinch( src.m_pinch ), + m_pinchoutMode( src.m_pinchoutMode ), + m_multzMode( src.m_multzMode ) + { + const int * actnum_data = (actnum.empty()) ? nullptr : actnum.data(); + m_grid.reset( ecl_grid_alloc_processed_copy( src.c_ptr(), zcorn , actnum_data )); + } + + + EclipseGrid::EclipseGrid(const EclipseGrid& src, const std::vector& zcorn , const std::vector& actnum) + : EclipseGrid( src , (zcorn.empty()) ? nullptr : zcorn.data(), actnum ) + { } + + + EclipseGrid::EclipseGrid(const EclipseGrid& src, const std::vector& actnum) + : EclipseGrid( src , nullptr , actnum ) + { } + + + /* This is the main EclipseGrid constructor, it will inspect the input Deck for grid keywords, either the corner point keywords @@ -149,54 +160,17 @@ namespace Opm { EclipseGrid::EclipseGrid(const Deck& deck, const int * actnum) - : m_minpvValue(0), + : GridDims(deck), + m_minpvValue(0), m_minpvMode(MinpvMode::ModeEnum::Inactive), m_pinch("PINCH"), m_pinchoutMode(PinchMode::ModeEnum::TOPBOT), m_multzMode(PinchMode::ModeEnum::TOP) { - const bool hasRUNSPEC = Section::hasRUNSPEC(deck); - const bool hasGRID = Section::hasGRID(deck); - if (hasRUNSPEC && hasGRID) { - // Equivalent to first constructor. - RUNSPECSection runspecSection( deck ); - if( runspecSection.hasKeyword() ) { - const auto& dimens = runspecSection.getKeyword(); - std::vector dims = getDims(dimens); - initGrid(dims, deck); - } else { - const std::string msg = "The RUNSPEC section must have the DIMENS keyword with logically Cartesian grid dimensions."; - m_messages.error(msg); - throw std::invalid_argument(msg); - } - } else if (hasGRID) { - // Look for SPECGRID instead of DIMENS. - if (deck.hasKeyword()) { - const auto& specgrid = deck.getKeyword(); - std::vector dims = getDims(specgrid); - initGrid(dims, deck); - } else { - const std::string msg = "With no RUNSPEC section, the GRID section must specify the grid dimensions using the SPECGRID keyword."; - m_messages.error(msg); - throw std::invalid_argument(msg); - } - } else { - // The deck contains no relevant section, so it is probably a sectionless GRDECL file. - // Either SPECGRID or DIMENS is OK. - if (deck.hasKeyword("SPECGRID")) { - const auto& specgrid = deck.getKeyword(); - std::vector dims = getDims(specgrid); - initGrid(dims, deck); - } else if (deck.hasKeyword()) { - const auto& dimens = deck.getKeyword(); - std::vector dims = getDims(dimens); - initGrid(dims, deck); - } else { - const std::string msg = "The deck must specify grid dimensions using either DIMENS or SPECGRID."; - m_messages.error(msg); - throw std::invalid_argument(msg); - } - } + + const std::array dims = getNXYZ(); + initGrid(dims, deck); + if (actnum != nullptr) resetACTNUM(actnum); else { @@ -213,15 +187,13 @@ namespace Opm { } - void EclipseGrid::initGrid( const std::vector& dims, const Deck& deck) { - m_nx = static_cast(dims[0]); - m_ny = static_cast(dims[1]); - m_nz = static_cast(dims[2]); - + void EclipseGrid::initGrid( const std::array& dims, const Deck& deck) { if (hasCornerPointKeywords(deck)) { initCornerPointGrid(dims , deck); } else if (hasCartesianKeywords(deck)) { initCartesianGrid(dims , deck); + } else { + throw std::invalid_argument("EclipseGrid needs cornerpoint or cartesian keywords."); } if (deck.hasKeyword()) { @@ -261,39 +233,26 @@ namespace Opm { return activeIndex( getGlobalIndex( i,j,k )); } - - size_t EclipseGrid::activeIndex(size_t globalIndex) const { - assertCellInfo(); - { - int active_index = ecl_grid_get_active_index1( m_grid.get() , globalIndex ); - if (active_index < 0) - throw std::invalid_argument("Input argument does not correspond to an active cell"); - return static_cast( active_index ); - } + int active_index = ecl_grid_get_active_index1( m_grid.get() , globalIndex ); + if (active_index < 0) + throw std::invalid_argument("Input argument does not correspond to an active cell"); + return static_cast( active_index ); } - - - size_t EclipseGrid::getNX( ) const { - return m_nx; + /** + Observe: the input argument is assumed to be in the space + [0,num_active). + */ + size_t EclipseGrid::getGlobalIndex(size_t active_index) const { + int global_index = ecl_grid_get_global_index1A( m_grid.get() , active_index ); + return static_cast(global_index); } - size_t EclipseGrid::getNY( ) const { - return m_ny; + size_t EclipseGrid::getGlobalIndex(size_t i, size_t j, size_t k) const { + return GridDims::getGlobalIndex(i,j,k); } - size_t EclipseGrid::getNZ( ) const { - return m_nz; - } - - std::array< int, 3 > EclipseGrid::getNXYZ() const { - return {{ int( m_nx ), int( m_ny ), int( m_nz ) }}; - } - - size_t EclipseGrid::getCartesianSize( ) const { - return m_nx * m_ny * m_nz; - } bool EclipseGrid::isPinchActive( ) const { return m_pinch.hasValue(); @@ -320,34 +279,7 @@ namespace Opm { } - size_t EclipseGrid::getGlobalIndex(size_t i, size_t j, size_t k) const { - return (i + j * getNX() + k * getNX() * getNY()); - } - - std::array EclipseGrid::getIJK(size_t globalIndex) const { - std::array r = {{ 0, 0, 0 }}; - int k = globalIndex / (getNX() * getNY()); globalIndex -= k * (getNX() * getNY()); - int j = globalIndex / getNX(); globalIndex -= j * getNX(); - int i = globalIndex; - r[0] = i; - r[1] = j; - r[2] = k; - return r; - } - - void EclipseGrid::assertGlobalIndex(size_t globalIndex) const { - if (globalIndex >= getCartesianSize()) - throw std::invalid_argument("input index above valid range"); - } - - void EclipseGrid::assertIJK(size_t i , size_t j , size_t k) const { - if (i >= getNX() || j >= getNY() || k >= getNZ()) - throw std::invalid_argument("input index above valid range"); - } - - - - void EclipseGrid::initCartesianGrid(const std::vector& dims , const Deck& deck) { + void EclipseGrid::initCartesianGrid(const std::array& dims , const Deck& deck) { if (hasDVDEPTHZKeywords( deck )) initDVDEPTHZGrid( dims , deck ); else if (hasDTOPSKeywords(deck)) @@ -357,7 +289,7 @@ namespace Opm { } - void EclipseGrid::initDVDEPTHZGrid(const std::vector& dims, const Deck& deck) { + void EclipseGrid::initDVDEPTHZGrid(const std::array& dims, const Deck& deck) { const std::vector& DXV = deck.getKeyword().getSIDoubleData(); const std::vector& DYV = deck.getKeyword().getSIDoubleData(); const std::vector& DZV = deck.getKeyword().getSIDoubleData(); @@ -372,7 +304,7 @@ namespace Opm { } - void EclipseGrid::initDTOPSGrid(const std::vector& dims , const Deck& deck) { + void EclipseGrid::initDTOPSGrid(const std::array& dims , const Deck& deck) { std::vector DX = createDVector( dims , 0 , "DX" , "DXV" , deck); std::vector DY = createDVector( dims , 1 , "DY" , "DYV" , deck); std::vector DZ = createDVector( dims , 2 , "DZ" , "DZV" , deck); @@ -380,14 +312,44 @@ namespace Opm { m_grid.reset( ecl_grid_alloc_dx_dy_dz_tops( dims[0] , dims[1] , dims[2] , DX.data() , DY.data() , DZ.data() , TOPS.data() , nullptr ) ); } - void EclipseGrid::initCornerPointGrid(const std::vector& dims, const Deck& deck) { + + + void EclipseGrid::initCornerPointGrid(const std::array& dims , + const std::vector& coord , + const std::vector& zcorn , + const int * actnum, + const double * mapaxes) + { + const std::vector zcorn_float( zcorn.begin() , zcorn.end() ); + const std::vector coord_float( coord.begin() , coord.end() ); + float * mapaxes_float = nullptr; + if (mapaxes) { + mapaxes_float = new float[6]; + for (size_t i=0; i < 6; i++) + mapaxes_float[i] = mapaxes[i]; + } + + m_grid.reset( ecl_grid_alloc_GRDECL_data(dims[0] , + dims[1] , + dims[2] , + zcorn_float.data() , + coord_float.data() , + actnum , + false, // We do not apply the MAPAXES transformations + mapaxes_float) ); + + if (mapaxes) + delete[] mapaxes_float; + } + + void EclipseGrid::initCornerPointGrid(const std::array& dims, const Deck& deck) { assertCornerPointKeywords( dims , deck); { const auto& ZCORNKeyWord = deck.getKeyword(); const auto& COORDKeyWord = deck.getKeyword(); const std::vector& zcorn = ZCORNKeyWord.getSIDoubleData(); const std::vector& coord = COORDKeyWord.getSIDoubleData(); - double * mapaxes = NULL; + double * mapaxes = nullptr; if (deck.hasKeyword()) { const auto& mapaxesKeyword = deck.getKeyword(); @@ -397,24 +359,9 @@ namespace Opm { mapaxes[i] = record.getItem( i ).getSIDouble( 0 ); } } - - - { - const std::vector zcorn_float( zcorn.begin() , zcorn.end() ); - const std::vector coord_float( coord.begin() , coord.end() ); - float * mapaxes_float = NULL; - if (mapaxes) { - mapaxes_float = new float[6]; - for (size_t i=0; i < 6; i++) - mapaxes_float[i] = mapaxes[i]; - } - m_grid.reset( ecl_grid_alloc_GRDECL_data(dims[0] , dims[1] , dims[2] , zcorn_float.data() , coord_float.data() , nullptr , mapaxes_float) ); - - if (mapaxes) { - delete[] mapaxes_float; - delete[] mapaxes; - } - } + initCornerPointGrid( dims, coord , zcorn , nullptr , mapaxes ); + if (mapaxes) + delete[] mapaxes; } } @@ -428,7 +375,7 @@ namespace Opm { } - void EclipseGrid::assertCornerPointKeywords( const std::vector& dims , const Deck& deck) + void EclipseGrid::assertCornerPointKeywords(const std::array& dims , const Deck& deck) { const int nx = dims[0]; const int ny = dims[1]; @@ -530,7 +477,7 @@ namespace Opm { retained. */ - std::vector EclipseGrid::createTOPSVector(const std::vector& dims, + std::vector EclipseGrid::createTOPSVector(const std::array& dims, const std::vector& DZ, const Deck& deck) { double z_tolerance = 1e-6; @@ -563,7 +510,7 @@ namespace Opm { return TOPS; } - std::vector EclipseGrid::createDVector(const std::vector& dims, size_t dim, const std::string& DKey, + std::vector EclipseGrid::createDVector(const std::array& dims, size_t dim, const std::string& DKey, const std::string& DVKey, const Deck& deck) { size_t volume = dims[0] * dims[1] * dims[2]; @@ -600,7 +547,7 @@ namespace Opm { } - void EclipseGrid::scatterDim(const std::vector& dims , size_t dim , const std::vector& DV , std::vector& D) { + void EclipseGrid::scatterDim(const std::array& dims , size_t dim , const std::vector& DV , std::vector& D) { int index[3]; for (index[2] = 0; index[2] < dims[2]; index[2]++) { for (index[1] = 0; index[1] < dims[1]; index[1]++) { @@ -612,26 +559,7 @@ namespace Opm { } } - - /* - This function checks if the grid has a pointer to an underlying - ecl_grid_type; which must be used to read cell info as - size/depth/active of individual cells. - */ - - bool EclipseGrid::hasCellInfo() const { - return static_cast( m_grid ); - } - - - void EclipseGrid::assertCellInfo() const { - if (!hasCellInfo()) - throw std::invalid_argument("Tried to access cell information in a grid with only dimensions"); - } - - const ecl_grid_type * EclipseGrid::c_ptr() const { - assertCellInfo(); return m_grid.get(); } @@ -651,7 +579,7 @@ namespace Opm { if(m_minpvMode!=MinpvMode::ModeEnum::Inactive){ status = status && (m_minpvValue == other.getMinpvValue()); } - return status; + return status; } @@ -659,6 +587,10 @@ namespace Opm { return static_cast(ecl_grid_get_nactive( c_ptr() )); } + bool EclipseGrid::allActive( ) const { + return (getNumActive() == getCartesianSize()); + } + bool EclipseGrid::cellActive( size_t globalIndex ) const { assertGlobalIndex( globalIndex ); return ecl_grid_cell_active1( c_ptr() , static_cast(globalIndex)); @@ -776,20 +708,69 @@ namespace Opm { ecl_grid_init_zcorn_data_double( c_ptr() , zcorn.data() ); } + const std::vector& EclipseGrid::getActiveMap() const { + if( !this->activeMap.empty() ) return this->activeMap; + this->activeMap.resize( this->getNumActive() ); + const auto size = int(this->getCartesianSize()); + + for( int global_index = 0; global_index < size; global_index++) { + // Using the low level C function to get the active index, because the C++ + // version will throw for inactive cells. + int active_index = ecl_grid_get_active_index1( m_grid.get() , global_index ); + if (active_index >= 0) + this->activeMap[ active_index ] = global_index; + } + + return this->activeMap; + } void EclipseGrid::resetACTNUM( const int * actnum) { - assertCellInfo(); ecl_grid_reset_actnum( m_grid.get() , actnum ); + /* re-build the active map cache */ + this->activeMap.clear(); + this->getActiveMap(); + } + + ZcornMapper EclipseGrid::zcornMapper() const { + return ZcornMapper( getNX() , getNY(), getNZ() ); + } + + ZcornMapper::ZcornMapper(size_t nx , size_t ny, size_t nz) + : dims( {nx,ny,nz} ), + stride( {2 , 4*nx, 8*nx*ny} ), + cell_shift( {0 , 1 , 2*nx , 2*nx + 1 , 4*nx*ny , 4*nx*ny + 1, 4*nx*ny + 2*nx , 4*nx*ny + 2*nx + 1 }) + { } - void EclipseGrid::fwriteEGRID( const std::string& filename, bool output_metric ) const { - assertCellInfo(); - ecl_grid_fwrite_EGRID( m_grid.get() , filename.c_str(), output_metric ); + /* lower layer: upper layer (higher value of z - i.e. lower down in resrvoir). + + 2---3 6---7 + | | | | + 0---1 4---5 + */ + + size_t ZcornMapper::index(size_t i, size_t j, size_t k, int c) const { + if ((i >= dims[0]) || (j >= dims[1]) || (k >= dims[2]) || (c < 0) || (c >= 8)) + throw std::invalid_argument("Invalid cell argument"); + + return i*stride[0] + j*stride[1] + k*stride[2] + cell_shift[c]; } + + size_t ZcornMapper::index(size_t g, int c) const { + int k = g / (dims[0] * dims[1]); + g -= k * dims[0] * dims[1]; + + int j = g / dims[0]; + g -= j * dims[0]; + + int i = g; + + return index(i,j,k,c); + } } diff --git a/ThirdParty/custom-opm-parser/opm-parser/opm/parser/eclipse/EclipseState/Grid/EclipseGrid.hpp b/ThirdParty/custom-opm-parser/opm-parser/opm/parser/eclipse/EclipseState/Grid/EclipseGrid.hpp index 8478ed19da..2b7540ab56 100644 --- a/ThirdParty/custom-opm-parser/opm-parser/opm/parser/eclipse/EclipseState/Grid/EclipseGrid.hpp +++ b/ThirdParty/custom-opm-parser/opm-parser/opm/parser/eclipse/EclipseState/Grid/EclipseGrid.hpp @@ -18,13 +18,15 @@ */ -#ifndef ECLIPSE_GRID_HPP_ -#define ECLIPSE_GRID_HPP_ +#ifndef OPM_PARSER_ECLIPSE_GRID_HPP +#define OPM_PARSER_ECLIPSE_GRID_HPP #include #include #include +#include + #include #include @@ -37,6 +39,7 @@ namespace Opm { class Deck; + class ZcornMapper; /** About cell information and dimension: The actual grid @@ -47,33 +50,29 @@ namespace Opm { - Size of cells - Real world position of cells - Active/inactive status of cells - - However in may cases the only required information is the - dimension of the grid. To facilitate simpler use, in particular - in testing, the grid dimensions are internalized separate from - the ecl_grid_type pointer. This means that in many cases a grid - without the underlying ecl_grid_type pointer is sufficient. To - create such a 'naked' grid you can parse a deck with only - DIMENS / SPECGRID and no further grid related keywords, or - alternatively use the: - - EclipseGrid::EclipseGrid(nx,ny,nz) - - constructor. - - To query a grid instance if it has proper underlying grid - support use the method: - - bool EclipseGrid::hasCellInfo(); - */ - class EclipseGrid { + class EclipseGrid : public GridDims { public: explicit EclipseGrid(const std::string& filename); - explicit EclipseGrid(const EclipseGrid& srcGrid); - explicit EclipseGrid(size_t nx, size_t ny, size_t nz, - double dx = 1.0, double dy = 1.0, double dz = 1.0); + + /* + These constructors will make a copy of the src grid, with + zcorn and or actnum have been adjustments. + */ + EclipseGrid(const EclipseGrid& src, const double* zcorn , const std::vector& actnum); + EclipseGrid(const EclipseGrid& src, const std::vector& zcorn , const std::vector& actnum); + EclipseGrid(const EclipseGrid& src, const std::vector& actnum); + + EclipseGrid(size_t nx, size_t ny, size_t nz, + double dx = 1.0, double dy = 1.0, double dz = 1.0); + + EclipseGrid(std::array& dims , + const std::vector& coord , + const std::vector& zcorn , + const int * actnum = nullptr, + const double * mapaxes = nullptr); + /// EclipseGrid ignores ACTNUM in Deck, and therefore needs ACTNUM /// explicitly. If a null pointer is passed, every cell is active. @@ -84,11 +83,20 @@ namespace Opm { static bool hasCornerPointKeywords(const Deck&); static bool hasCartesianKeywords(const Deck&); size_t getNumActive( ) const; - size_t getNX( ) const; - size_t getNY( ) const; - size_t getNZ( ) const; - std::array< int, 3 > getNXYZ() const; - size_t getCartesianSize( ) const; + bool allActive() const; + + size_t activeIndex(size_t i, size_t j, size_t k) const; + size_t activeIndex(size_t globalIndex) const; + + /* + Observe that the there is a getGlobalIndex(i,j,k) + implementation in the base class. This method - translating + from an active index to a global index must be implemented + in the current class. + */ + size_t getGlobalIndex(size_t active_index) const; + size_t getGlobalIndex(size_t i, size_t j, size_t k) const; + bool isPinchActive( ) const; double getPinchThresholdThickness( ) const; PinchMode::ModeEnum getPinchOption( ) const; @@ -97,22 +105,43 @@ namespace Opm { MinpvMode::ModeEnum getMinpvMode() const; double getMinpvValue( ) const; - bool hasCellInfo() const; - /// The activeIndex methods will return from (i,j,k) or g, - /// where g \in [0,nx*n*nz) to the corresponding active index - /// in the range [0,numActive). Observe that if the input - /// argument corresponds to a cell which is not active an - /// exception will be raised - check with cellActive() first - /// if that is a possibillity. - size_t activeIndex(size_t i, size_t j, size_t k) const; - size_t activeIndex(size_t globalIndex) const; + /* + Will return a vector of nactive elements. The method will + behave differently depending on the lenght of the + input_vector: + + nx*ny*nz: only the values corresponding to active cells + are copied out. + + nactive: The input vector is copied straight out again. + + ??? : Exception. + */ + template + std::vector compressedVector(const std::vector& input_vector) const { + if( input_vector.size() == this->getNumActive() ) { + return input_vector; + } + + if (input_vector.size() != getCartesianSize()) + throw std::invalid_argument("Input vector must have full size"); + + { + std::vector compressed_vector( this->getNumActive() ); + const auto& active_map = this->getActiveMap( ); + + for (size_t i = 0; i < this->getNumActive(); ++i) + compressed_vector[i] = input_vector[ active_map[i] ]; + + return compressed_vector; + } + } - size_t getGlobalIndex(size_t i, size_t j, size_t k) const; - std::array getIJK(size_t globalIndex) const; - void assertGlobalIndex(size_t globalIndex) const; - void assertIJK(size_t i , size_t j , size_t k) const; + /// Will return a vector a length num_active; where the value + /// of each element is the corresponding global index. + const std::vector& getActiveMap() const; std::array getCellCenter(size_t i,size_t j, size_t k) const; std::array getCellCenter(size_t globalIndex) const; double getCellVolume(size_t globalIndex) const; @@ -125,6 +154,7 @@ namespace Opm { bool cellActive( size_t i , size_t j, size_t k ) const; double getCellDepth(size_t i,size_t j, size_t k) const; double getCellDepth(size_t globalIndex) const; + ZcornMapper zcornMapper() const; void exportMAPAXES( std::vector& mapaxes) const; @@ -133,46 +163,76 @@ namespace Opm { void exportACTNUM( std::vector& actnum) const; void resetACTNUM( const int * actnum); bool equal(const EclipseGrid& other) const; - void fwriteEGRID( const std::string& filename, bool output_metric ) const; const ecl_grid_type * c_ptr() const; const MessageContainer& getMessageContainer() const; MessageContainer& getMessageContainer(); private: - ERT::ert_unique_ptr m_grid; + MessageContainer m_messages; + double m_minpvValue; MinpvMode::ModeEnum m_minpvMode; Value m_pinch; PinchMode::ModeEnum m_pinchoutMode; PinchMode::ModeEnum m_multzMode; - size_t m_nx; - size_t m_ny; - size_t m_nz; - MessageContainer m_messages; + mutable std::vector< int > activeMap; - void assertCellInfo() const; + /* + The internal class grid_ptr is a a std::unique_ptr with + special copy semantics. The purpose of implementing this is + that the EclipseGrid class can now use the default + implementation for the copy and move constructors. + */ + using ert_ptr = ERT::ert_unique_ptr; + class grid_ptr : public ert_ptr { + public: + using ert_ptr::unique_ptr; + grid_ptr() = default; + grid_ptr(grid_ptr&&) = default; + grid_ptr(const grid_ptr& src) : + ert_ptr( ecl_grid_alloc_copy( src.get() ) ) {} + }; + grid_ptr m_grid; - void initCartesianGrid(const std::vector& dims, const Deck&); - void initCornerPointGrid(const std::vector& dims, const Deck&); - void initDTOPSGrid(const std::vector& dims, const Deck&); - void initDVDEPTHZGrid(const std::vector& dims, const Deck& deck); - void initGrid(const std::vector& dims, const Deck&); + void initCornerPointGrid(const std::array& dims , + const std::vector& coord , + const std::vector& zcorn , + const int * actnum, + const double * mapaxes); + + void initCartesianGrid( const std::array&, const Deck&); + void initCornerPointGrid( const std::array&, const Deck&); + void initDTOPSGrid( const std::array&, const Deck&); + void initDVDEPTHZGrid( const std::array&, const Deck&); + void initGrid( const std::array&, const Deck&); + void assertCornerPointKeywords( const std::array&, const Deck&); - void assertCornerPointKeywords(const std::vector& dims, const Deck&); static bool hasDVDEPTHZKeywords(const Deck&); - static bool hasDTOPSKeywords(const Deck&); - static void assertVectorSize(const std::vector& vector, size_t expectedSize, const std::string& msg); - static std::vector createTOPSVector(const std::vector& dims, const std::vector& DZ, + static bool hasDTOPSKeywords( const Deck&); + static void assertVectorSize( const std::vector& vector, size_t expectedSize, const std::string& msg); + static std::vector createTOPSVector(const std::array& dims, const std::vector& DZ, const Deck&); - static std::vector createDVector(const std::vector& dims, size_t dim, const std::string& DKey, + static std::vector createDVector(const std::array& dims, size_t dim, const std::string& DKey, const std::string& DVKey, const Deck&); - static void scatterDim(const std::vector& dims , size_t dim , const std::vector& DV , std::vector& D); + static void scatterDim(const std::array& dims , size_t dim , const std::vector& DV , std::vector& D); }; typedef std::shared_ptr EclipseGridPtr; typedef std::shared_ptr EclipseGridConstPtr; + + class ZcornMapper { + public: + ZcornMapper(size_t nx, size_t ny, size_t nz); + size_t index(size_t i, size_t j, size_t k, int c) const; + size_t index(size_t g, int c) const; + + private: + std::array dims; + std::array stride; + std::array cell_shift; + }; } -#endif +#endif // OPM_PARSER_ECLIPSE_GRID_HPP diff --git a/ThirdParty/custom-opm-parser/opm-parser/opm/parser/eclipse/EclipseState/Grid/FaultCollection.cpp b/ThirdParty/custom-opm-parser/opm-parser/opm/parser/eclipse/EclipseState/Grid/FaultCollection.cpp index 5d6ecb7074..96c6c4d165 100644 --- a/ThirdParty/custom-opm-parser/opm-parser/opm/parser/eclipse/EclipseState/Grid/FaultCollection.cpp +++ b/ThirdParty/custom-opm-parser/opm-parser/opm/parser/eclipse/EclipseState/Grid/FaultCollection.cpp @@ -17,14 +17,18 @@ along with OPM. If not, see . */ -#include + +#include +#include +#include +#include #include #include #include #include #include -#include +#include #include #include #include @@ -33,42 +37,51 @@ namespace Opm { + FaultCollection::FaultCollection() {} - - FaultCollection::FaultCollection( std::shared_ptr deck, std::shared_ptr grid) { - const auto& faultKeywords = deck->getKeywordList(); + FaultCollection::FaultCollection(const GRIDSection& gridSection, + const GridDims& grid) { + const auto& faultKeywords = gridSection.getKeywordList(); for (auto keyword_iter = faultKeywords.begin(); keyword_iter != faultKeywords.end(); ++keyword_iter) { const auto& faultsKeyword = *keyword_iter; for (auto iter = faultsKeyword->begin(); iter != faultsKeyword->end(); ++iter) { const auto& faultRecord = *iter; const std::string& faultName = faultRecord.getItem(0).get< std::string >(0); - int I1 = faultRecord.getItem(1).get< int >(0) - 1; - int I2 = faultRecord.getItem(2).get< int >(0) - 1; - int J1 = faultRecord.getItem(3).get< int >(0) - 1; - int J2 = faultRecord.getItem(4).get< int >(0) - 1; - int K1 = faultRecord.getItem(5).get< int >(0) - 1; - int K2 = faultRecord.getItem(6).get< int >(0) - 1; - FaceDir::DirEnum faceDir = FaceDir::FromString( faultRecord.getItem(7).get< std::string >(0) ); - std::shared_ptr face = std::make_shared(grid->getNX() , grid->getNY() , grid->getNZ(), - static_cast(I1) , static_cast(I2) , - static_cast(J1) , static_cast(J2) , - static_cast(K1) , static_cast(K2) , - faceDir); - if (!hasFault(faultName)) { - addFault( faultName ); - } - { - Fault& fault = getFault( faultName ); - fault.addFace( face ); - } + addFaultFaces(grid, faultRecord, faultName); } } } + + void FaultCollection::addFaultFaces(const GridDims& grid, + const DeckRecord& faultRecord, + const std::string& faultName) + { + int I1 = faultRecord.getItem(1).get(0) - 1; + int I2 = faultRecord.getItem(2).get(0) - 1; + int J1 = faultRecord.getItem(3).get(0) - 1; + int J2 = faultRecord.getItem(4).get(0) - 1; + int K1 = faultRecord.getItem(5).get(0) - 1; + int K2 = faultRecord.getItem(6).get(0) - 1; + FaceDir::DirEnum faceDir = FaceDir::FromString(faultRecord.getItem(7).get(0)); + std::shared_ptr face = std::make_shared( + grid.getNX(), grid.getNY(), grid.getNZ(), + static_cast(I1), static_cast(I2), + static_cast(J1), static_cast(J2), + static_cast(K1), static_cast(K2), + faceDir); + + if (!hasFault(faultName)) + addFault(faultName); + + Fault& fault = getFault(faultName); + fault.addFace(face); + } + size_t FaultCollection::size() const { return m_faults.size(); } diff --git a/ThirdParty/custom-opm-parser/opm-parser/opm/parser/eclipse/EclipseState/Grid/FaultCollection.hpp b/ThirdParty/custom-opm-parser/opm-parser/opm/parser/eclipse/EclipseState/Grid/FaultCollection.hpp index fd4201d782..527812af71 100644 --- a/ThirdParty/custom-opm-parser/opm-parser/opm/parser/eclipse/EclipseState/Grid/FaultCollection.hpp +++ b/ThirdParty/custom-opm-parser/opm-parser/opm/parser/eclipse/EclipseState/Grid/FaultCollection.hpp @@ -16,29 +16,26 @@ You should have received a copy of the GNU General Public License along with OPM. If not, see . */ -#ifndef FAULT_COLLECTION_HPP_ -#define FAULT_COLLECTION_HPP_ +#ifndef OPM_PARSER_FAULT_COLLECTION_HPP +#define OPM_PARSER_FAULT_COLLECTION_HPP #include #include -#include #include #include - namespace Opm { - class Deck; - class GRIDSection; - class EclipseGrid; + class DeckRecord; + class GridDims; class GRIDSection; class FaultCollection { public: FaultCollection(); - FaultCollection( std::shared_ptr deck, std::shared_ptr grid); + FaultCollection(const GRIDSection& gridSection, const GridDims& grid); size_t size() const; bool hasFault(const std::string& faultName) const; @@ -52,9 +49,12 @@ public: void setTransMult(const std::string& faultName , double transMult); private: + void addFaultFaces(const GridDims& grid, + const DeckRecord& faultRecord, + const std::string& faultName); OrderedMap m_faults; + }; } - -#endif +#endif // OPM_PARSER_FAULT_COLLECTION_HPP diff --git a/ThirdParty/custom-opm-parser/opm-parser/opm/parser/eclipse/EclipseState/Grid/FaultFace.hpp b/ThirdParty/custom-opm-parser/opm-parser/opm/parser/eclipse/EclipseState/Grid/FaultFace.hpp index 570bd57b64..e268e75b02 100644 --- a/ThirdParty/custom-opm-parser/opm-parser/opm/parser/eclipse/EclipseState/Grid/FaultFace.hpp +++ b/ThirdParty/custom-opm-parser/opm-parser/opm/parser/eclipse/EclipseState/Grid/FaultFace.hpp @@ -16,8 +16,8 @@ You should have received a copy of the GNU General Public License along with OPM. If not, see . */ -#ifndef FAULT_FACE_HPP_ -#define FAULT_FACE_HPP_ +#ifndef OPM_PARSER_FAULT_FACE_HPP +#define OPM_PARSER_FAULT_FACE_HPP #include #include @@ -48,4 +48,4 @@ private: } -#endif +#endif // OPM_PARSER_FAULT_FACE_HPP diff --git a/ThirdParty/custom-opm-parser/opm-parser/opm/parser/eclipse/EclipseState/Grid/GridDims.cpp b/ThirdParty/custom-opm-parser/opm-parser/opm/parser/eclipse/EclipseState/Grid/GridDims.cpp new file mode 100644 index 0000000000..5a65c47b39 --- /dev/null +++ b/ThirdParty/custom-opm-parser/opm-parser/opm/parser/eclipse/EclipseState/Grid/GridDims.cpp @@ -0,0 +1,119 @@ +/* + Copyright 2016 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 + +#include +#include +#include + +#include + +#include // DIMENS +#include // SPECGRID + +namespace Opm { + GridDims::GridDims(std::array xyz) : + GridDims(xyz[0], xyz[1], xyz[2]) + { + } + + GridDims::GridDims(size_t nx, size_t ny, size_t nz) : + m_nx(nx), m_ny(ny), m_nz(nz) + { + } + + GridDims::GridDims(const Deck& deck) { + if (deck.hasKeyword("SPECGRID")) + init(deck.getKeyword("SPECGRID")); + else if (deck.hasKeyword("DIMENS")) + init(deck.getKeyword("DIMENS")); + else + throw std::invalid_argument("Must have either SPECGRID or DIMENS to indicate grid dimensions"); + } + + size_t GridDims::getNX() const { + return m_nx; + } + + size_t GridDims::getNY() const { + return m_ny; + } + + size_t GridDims::getNZ() const { + return m_nz; + } + + const std::array GridDims::getNXYZ() const { + return std::array {int( m_nx ), int( m_ny ), int( m_nz )}; + } + + size_t GridDims::getGlobalIndex(size_t i, size_t j, size_t k) const { + return (i + j * getNX() + k * getNX() * getNY()); + } + + const std::array GridDims::getIJK(size_t globalIndex) const { + std::array r = { { 0, 0, 0 } }; + int k = globalIndex / (getNX() * getNY()); + globalIndex -= k * (getNX() * getNY()); + int j = globalIndex / getNX(); + globalIndex -= j * getNX(); + int i = globalIndex; + r[0] = i; + r[1] = j; + r[2] = k; + return r; + } + + size_t GridDims::getCartesianSize() const { + return m_nx * m_ny * m_nz; + } + + void GridDims::assertGlobalIndex(size_t globalIndex) const { + if (globalIndex >= getCartesianSize()) + throw std::invalid_argument("input index above valid range"); + } + + void GridDims::assertIJK(size_t i, size_t j, size_t k) const { + if (i >= getNX() || j >= getNY() || k >= getNZ()) + throw std::invalid_argument("input index above valid range"); + } + + GridDims::GridDims() : + m_nx(0), m_ny(0), m_nz(0) + { + } + + // keyword must be DIMENS or SPECGRID + inline std::array< int, 3 > readDims(const DeckKeyword& keyword) { + const auto& record = keyword.getRecord(0); + return { { record.getItem("NX").get(0), + record.getItem("NY").get(0), + record.getItem("NZ").get(0) } }; + } + + void GridDims::init(const DeckKeyword& keyword) { + auto dims = readDims(keyword); + m_nx = dims[0]; + m_ny = dims[1]; + m_nz = dims[2]; + } +} diff --git a/ThirdParty/custom-opm-parser/opm-parser/opm/parser/eclipse/EclipseState/Grid/GridDims.hpp b/ThirdParty/custom-opm-parser/opm-parser/opm/parser/eclipse/EclipseState/Grid/GridDims.hpp new file mode 100644 index 0000000000..9815ccf8b6 --- /dev/null +++ b/ThirdParty/custom-opm-parser/opm-parser/opm/parser/eclipse/EclipseState/Grid/GridDims.hpp @@ -0,0 +1,70 @@ +/* + Copyright 2016 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_PARSER_GRIDDIMS_HPP +#define OPM_PARSER_GRIDDIMS_HPP + +#include +#include +#include + +#include +#include + +namespace Opm { + class GridDims + { + public: + + GridDims(std::array xyz); + + GridDims(size_t nx, size_t ny, size_t nz); + + GridDims(const Deck& deck); + + size_t getNX() const; + + size_t getNY() const; + size_t getNZ() const; + + const std::array getNXYZ() const; + + size_t getGlobalIndex(size_t i, size_t j, size_t k) const; + + const std::array getIJK(size_t globalIndex) const; + + size_t getCartesianSize() const; + + void assertGlobalIndex(size_t globalIndex) const; + + void assertIJK(size_t i, size_t j, size_t k) const; + + protected: + GridDims(); + + size_t m_nx; + size_t m_ny; + size_t m_nz; + + private: + void init(const DeckKeyword& keyword); + }; +} + +#endif /* OPM_PARSER_GRIDDIMS_HPP */ diff --git a/ThirdParty/custom-opm-parser/opm-parser/opm/parser/eclipse/EclipseState/Grid/GridProperties.cpp b/ThirdParty/custom-opm-parser/opm-parser/opm/parser/eclipse/EclipseState/Grid/GridProperties.cpp index adafc72d2c..9301ab5f29 100644 --- a/ThirdParty/custom-opm-parser/opm-parser/opm/parser/eclipse/EclipseState/Grid/GridProperties.cpp +++ b/ThirdParty/custom-opm-parser/opm-parser/opm/parser/eclipse/EclipseState/Grid/GridProperties.cpp @@ -17,12 +17,26 @@ along with OPM. If not, see . */ +#include + #include #include #include namespace Opm { + /* + Before lookup the keyword strings are uppercased and trailing + space is trimmed. + */ + + static std::string normalize(const std::string& keyword) { + std::string kw(keyword.begin() , std::find( keyword.begin() , keyword.end() , ' ')); + uppercase( kw , kw ); + return kw; + } + + template <> GridProperties::GridProperties(const EclipseGrid& eclipseGrid, const UnitSystem* deckUnitSystem, @@ -46,6 +60,7 @@ namespace Opm { + /* In the case of integer properties we never really do any transformation, but we have implemented this dummy int @@ -69,7 +84,7 @@ namespace Opm { template<> int GridProperties::convertInputValue(double doubleValue) const { - if (fabs( nearbyint( doubleValue ) - doubleValue ) < 1e-6) + if (std::fabs( std::nearbyint( doubleValue ) - doubleValue ) < 1e-6) return static_cast( doubleValue ); else throw std::invalid_argument("Expected integer argument - got: " + std::to_string( doubleValue )); @@ -136,17 +151,14 @@ namespace Opm { } - - template< typename T > bool GridProperties::supportsKeyword(const std::string& keyword) const { - return m_supportedKeywords.count( keyword ) > 0; + return m_supportedKeywords.count( normalize( keyword ) ) > 0; } - template< typename T > bool GridProperties::hasKeyword(const std::string& keyword) const { - const std::string kw = uppercase(keyword); + const std::string kw = normalize( keyword ); const auto cnt = m_properties.count( kw ); const bool positive = cnt > 0; @@ -154,20 +166,22 @@ namespace Opm { return positive && !isAutoGenerated_(kw); } + + template< typename T > size_t GridProperties::size() const { - return m_property_list.size(); + return m_properties.size(); } template< typename T > const GridProperty& GridProperties::getKeyword(const std::string& keyword) const { - const std::string kw = uppercase(keyword); + const std::string kw = normalize(keyword); if (!hasKeyword(kw)) addAutoGeneratedKeyword_(kw); - GridProperty& property = (*m_properties.at( kw )); + GridProperty& property = m_properties.at( kw ); property.runPostProcessor( ); return property; } @@ -176,9 +190,10 @@ namespace Opm { template< typename T > const GridProperty& GridProperties::getInitializedKeyword(const std::string& keyword) const { - const std::string kw = uppercase(keyword); + const std::string kw = normalize(keyword); + if (hasKeyword(kw)) - return *m_properties.at( kw ); + return m_properties.at( kw ); else { if (supportsKeyword(kw)) throw std::invalid_argument("Keyword: " + kw + " is supported - but not initialized."); @@ -188,16 +203,27 @@ namespace Opm { } + template< typename T > + void GridProperties::insertKeyword(const SupportedKeywordInfo& supportedKeyword) const { + int nx = m_eclipseGrid.getNX(); + int ny = m_eclipseGrid.getNY(); + int nz = m_eclipseGrid.getNZ(); + + m_properties.emplace( supportedKeyword.getKeywordName() , GridProperty( nx, ny , nz , supportedKeyword )); + } + + template< typename T > bool GridProperties::addKeyword(const std::string& keywordName) { - const std::string kw = uppercase(keywordName); - if (!supportsKeyword( kw )) - throw std::invalid_argument("The keyword: " + kw + " is not supported in this container"); + if (!supportsKeyword( keywordName )) + throw std::invalid_argument("The keyword: " + keywordName + " is not supported in this container"); - if (hasKeyword(kw)) + if (hasKeyword(keywordName)) return false; else { + const std::string kw = normalize(keywordName); + // if the property was already added auto generated, we just need to make it // non-auto generated if (m_autoGeneratedProperties.count(kw)) { @@ -209,14 +235,7 @@ namespace Opm { return true; } - auto supportedKeyword = m_supportedKeywords.at( kw ); - int nx = m_eclipseGrid.getNX(); - int ny = m_eclipseGrid.getNY(); - int nz = m_eclipseGrid.getNZ(); - std::shared_ptr > newProperty(new GridProperty(nx , ny , nz , supportedKeyword)); - - m_properties.insert( std::pair > > ( kw , newProperty )); - m_property_list.push_back( newProperty ); + insertKeyword( m_supportedKeywords.at( kw ) ); return true; } } @@ -236,12 +255,11 @@ namespace Opm { template< typename T > - GridProperty& GridProperties::getOrCreateProperty(const std::string name) { - const std::string kw = uppercase(name); - if (!hasKeyword(kw)) { - addKeyword(kw); - } - return getKeyword(kw); + GridProperty& GridProperties::getOrCreateProperty(const std::string& name) { + if (!hasKeyword(name)) + addKeyword(name); + + return getKeyword(name); } /** @@ -321,7 +339,7 @@ namespace Opm { regionProperty.initMask( regionValue , mask); targetProperty.maskedSet( targetValue , mask); } else - throw std::invalid_argument("Fatal error processing EQUALREG keyword - invalid/undefined keyword: " + targetArray); + throw std::invalid_argument("Fatal error processing EQUALREG record - invalid/undefined keyword: " + targetArray); } template< typename T > @@ -337,7 +355,7 @@ namespace Opm { regionProperty.initMask( regionValue , mask); targetProperty.maskedAdd( shiftValue , mask); } else - throw std::invalid_argument("Fatal error processing EQUALREG keyword - invalid/undefined keyword: " + targetArray); + throw std::invalid_argument("Fatal error processing ADDREG record - invalid/undefined keyword: " + targetArray); } template< typename T > @@ -353,7 +371,7 @@ namespace Opm { regionProperty.initMask( regionValue , mask); targetProperty.maskedMultiply( factor , mask); } else - throw std::invalid_argument("Fatal error processing EQUALREG keyword - invalid/undefined keyword: " + targetArray); + throw std::invalid_argument("Fatal error processing MULTIREG record - invalid/undefined keyword: " + targetArray); } template< typename T > @@ -362,10 +380,10 @@ namespace Opm { const std::string& targetArray = record.getItem("TARGET_ARRAY").get< std::string >(0); if (!supportsKeyword( targetArray)) - throw std::invalid_argument("Fatal error processing COPYREG keyword - invalid/undefined keyword: " + targetArray); + throw std::invalid_argument("Fatal error processing COPYREG record - invalid/undefined keyword: " + targetArray); if (!hasKeyword( srcArray )) - throw std::invalid_argument("Fatal error processing COPYREG keyword - invalid/undefined keyword: " + srcArray); + throw std::invalid_argument("Fatal error processing COPYREG record - invalid/undefined keyword: " + srcArray); { int regionValue = record.getItem("REGION_NUMBER").get< int >(0); @@ -393,14 +411,18 @@ namespace Opm { template< typename T > GridProperty& GridProperties::getKeyword(const std::string& keyword) { - const std::string kw = uppercase(keyword); + const std::string kw = normalize(keyword); if (!hasKeyword(kw)) addAutoGeneratedKeyword_(kw); - return *m_properties.at( kw ); + return m_properties.at( kw ); } + + /* + This is const because of the auto-generation of keywords on get(). + */ template< typename T > bool GridProperties::addAutoGeneratedKeyword_(const std::string& keywordName) const { if (!supportsKeyword( keywordName )) @@ -409,23 +431,15 @@ namespace Opm { if (m_properties.count( keywordName ) > 0) return false; // property already exists (if it is auto generated or not doesn't matter) else { - auto& supportedKeyword = m_supportedKeywords.at( keywordName ); - int nx = m_eclipseGrid.getNX(); - int ny = m_eclipseGrid.getNY(); - int nz = m_eclipseGrid.getNZ(); - std::shared_ptr > newProperty(new GridProperty(nx , ny , nz , supportedKeyword)); - m_autoGeneratedProperties.insert(keywordName); - - m_properties.insert( std::pair > > ( keywordName , newProperty )); - m_property_list.push_back( newProperty ); + insertKeyword( m_supportedKeywords.at( keywordName ) ); return true; } } template< typename T > bool GridProperties::isAutoGenerated_(const std::string& keyword) const { - return m_autoGeneratedProperties.count(keyword); + return m_autoGeneratedProperties.count(keyword) > 0; } } diff --git a/ThirdParty/custom-opm-parser/opm-parser/opm/parser/eclipse/EclipseState/Grid/GridProperties.hpp b/ThirdParty/custom-opm-parser/opm-parser/opm/parser/eclipse/EclipseState/Grid/GridProperties.hpp index 2b1ac7ac42..bc1e18d271 100644 --- a/ThirdParty/custom-opm-parser/opm-parser/opm/parser/eclipse/EclipseState/Grid/GridProperties.hpp +++ b/ThirdParty/custom-opm-parser/opm-parser/opm/parser/eclipse/EclipseState/Grid/GridProperties.hpp @@ -58,13 +58,15 @@ namespace Opm { void setKeywordBox( const DeckRecord& deckRecord, BoxManager& boxManager); - class Eclipse3DProperties; template class GridProperties { public: typedef typename GridProperty::SupportedKeywordInfo SupportedKeywordInfo; + + struct const_iterator; + GridProperties(const EclipseGrid& eclipseGrid, const UnitSystem* deckUnitSystem, std::vector< SupportedKeywordInfo >&& supportedKeywords); @@ -75,12 +77,13 @@ namespace Opm { T convertInputValue( const GridProperty& property , double doubleValue) const; T convertInputValue( double doubleValue ) const; - bool supportsKeyword(const std::string& keyword) const; bool hasKeyword(const std::string& keyword) const; size_t size() const; const GridProperty& getKeyword(const std::string& keyword) const; const GridProperty& getInitializedKeyword(const std::string& keyword) const; + + bool addKeyword(const std::string& keywordName); void copyKeyword(const std::string& srcField , const std::string& targetField , @@ -106,7 +109,7 @@ namespace Opm { return getInitializedKeyword( Keyword::keywordName ); } - GridProperty& getOrCreateProperty(const std::string name); + GridProperty& getOrCreateProperty(const std::string& name); /** The fine print of the manual says the ADD keyword should support @@ -124,6 +127,31 @@ namespace Opm { void handleMULTIREGRecord( const DeckRecord& record, const GridProperty& regionProperty ); void handleCOPYREGRecord( const DeckRecord& record, const GridProperty& regionProperty ); + /* + Iterators over initialized properties. The overloaded + operator*() opens the pair which comes natively from the + std::map iterator. + */ + const_iterator begin() const { + return const_iterator( m_properties.begin() ); + } + + const_iterator end() const { + return const_iterator( m_properties.end() ); + } + + typedef typename std::map > storage; + typedef typename storage::const_iterator storage_iterator; + + struct const_iterator : public storage_iterator { + const_iterator( storage_iterator iter ) : storage_iterator( iter ) { } + + const GridProperty& operator*( ) { + const auto& pair = storage_iterator::operator*( ); + return pair.second; + } + }; + private: /// this method exists for (friend) Eclipse3DProperties to be allowed initializing PORV and ACTNUM keyword @@ -133,6 +161,7 @@ namespace Opm { const std::string& dimString ); GridProperty& getKeyword(const std::string& keyword); bool addAutoGeneratedKeyword_(const std::string& keywordName) const; + void insertKeyword(const SupportedKeywordInfo& supportedKeyword) const; bool isAutoGenerated_(const std::string& keyword) const; friend class Eclipse3DProperties; // needed for PORV keyword entanglement @@ -140,10 +169,11 @@ namespace Opm { const UnitSystem * m_deckUnitSystem = nullptr; MessageContainer m_messages; std::unordered_map m_supportedKeywords; - mutable std::map > > m_properties; + + mutable storage m_properties; mutable std::set m_autoGeneratedProperties; - mutable std::vector > > m_property_list; }; + } #endif // ECLIPSE_GRIDPROPERTIES_HPP_ diff --git a/ThirdParty/custom-opm-parser/opm-parser/opm/parser/eclipse/EclipseState/Grid/GridProperty.cpp b/ThirdParty/custom-opm-parser/opm-parser/opm/parser/eclipse/EclipseState/Grid/GridProperty.cpp index cc8d139a3e..06203d93e3 100644 --- a/ThirdParty/custom-opm-parser/opm-parser/opm/parser/eclipse/EclipseState/Grid/GridProperty.cpp +++ b/ThirdParty/custom-opm-parser/opm-parser/opm/parser/eclipse/EclipseState/Grid/GridProperty.cpp @@ -36,32 +36,32 @@ namespace Opm { template< typename T > static std::function< std::vector< T >( size_t ) > constant( T val ) { return [=]( size_t size ) { return std::vector< T >( size, val ); }; - }; + } template< typename T > static std::function< void( std::vector< T >& ) > noop() { return []( std::vector< T >& ) { return; }; - }; + } template< typename T > GridPropertySupportedKeywordInfo< T >::GridPropertySupportedKeywordInfo( const std::string& name, - std::function< std::vector< T >( size_t ) > initializer, - std::function< void( std::vector< T >& ) > postProcessor, + std::function< std::vector< T >( size_t ) > init, + std::function< void( std::vector< T >& ) > post, const std::string& dimString ) : m_keywordName( name ), - m_initializer( initializer ), - m_postProcessor( postProcessor ), + m_initializer( init ), + m_postProcessor( post ), m_dimensionString( dimString ) {} template< typename T > GridPropertySupportedKeywordInfo< T >::GridPropertySupportedKeywordInfo( const std::string& name, - std::function< std::vector< T >( size_t ) > initializer, + std::function< std::vector< T >( size_t ) > init, const std::string& dimString ) : m_keywordName( name ), - m_initializer( initializer ), + m_initializer( init ), m_postProcessor( noop< T >() ), m_dimensionString( dimString ) {} @@ -81,11 +81,11 @@ namespace Opm { GridPropertySupportedKeywordInfo< T >::GridPropertySupportedKeywordInfo( const std::string& name, const T defaultValue, - std::function< void( std::vector< T >& ) > postProcessor, + std::function< void( std::vector< T >& ) > post, const std::string& dimString ) : m_keywordName( name ), m_initializer( constant( defaultValue ) ), - m_postProcessor( postProcessor ), + m_postProcessor( post ), m_dimensionString( dimString ) {} @@ -141,11 +141,7 @@ namespace Opm { template< typename T > T GridProperty< T >::iget( size_t index ) const { - if (index < m_data.size()) { - return m_data[index]; - } else { - throw std::invalid_argument("Index out of range \n"); - } + return this->m_data.at( index ); } template< typename T > @@ -156,10 +152,7 @@ namespace Opm { template< typename T > void GridProperty< T >::iset(size_t index, T value) { - if (index < m_data.size()) - m_data[index] = value; - else - throw std::invalid_argument("Index out of range \n"); + this->m_data.at( index ) = value; } template< typename T > @@ -413,6 +406,48 @@ const std::string& GridProperty::getDimensionString() const { } +template +std::vector GridProperty::compressedCopy(const EclipseGrid& grid) const { + if (grid.allActive()) + return m_data; + else { + return grid.compressedVector( m_data ); + } +} + + + +template +std::vector GridProperty::cellsEqual(T value, const std::vector& activeMap) const { + std::vector cells; + for (size_t active_index = 0; active_index < activeMap.size(); active_index++) { + size_t global_index = activeMap[ active_index ]; + if (m_data[global_index] == value) + cells.push_back( active_index ); + } + return cells; +} + + +template +std::vector GridProperty::indexEqual(T value) const { + std::vector index_list; + for (size_t index = 0; index < m_data.size(); index++) { + if (m_data[index] == value) + index_list.push_back( index ); + } + return index_list; +} + + +template +std::vector GridProperty::cellsEqual(T value, const EclipseGrid& grid, bool active) const { + if (active) + return cellsEqual( value , grid.getActiveMap()); + else + return indexEqual( value ); +} + std::vector< double > temperature_lookup( size_t size, const TableManager* tables, const EclipseGrid* grid, diff --git a/ThirdParty/custom-opm-parser/opm-parser/opm/parser/eclipse/EclipseState/Grid/GridProperty.hpp b/ThirdParty/custom-opm-parser/opm-parser/opm/parser/eclipse/EclipseState/Grid/GridProperty.hpp index 30fc2989c8..719d3d93f6 100644 --- a/ThirdParty/custom-opm-parser/opm-parser/opm/parser/eclipse/EclipseState/Grid/GridProperty.hpp +++ b/ThirdParty/custom-opm-parser/opm-parser/opm/parser/eclipse/EclipseState/Grid/GridProperty.hpp @@ -147,8 +147,33 @@ public: assembling the properties. */ void runPostProcessor(); + /* + Will scan through the roperty and return a vector of all the + indices where the property value agrees with the input value. + */ + std::vector indexEqual(T value) const; + /* + Will run through all the cells in the activeMap and return a + list of the elements where the property value agrees with the + input value. The values returned will be in the space + [0,nactive) - i.e. 'active' indices. + */ + std::vector cellsEqual(T value , const std::vector& activeMap) const; + + /* + If active == true the method will get the activeMap from the + grid and call the cellsEqual( T , std::vector&) overload, + otherwise it will return indexEqual( value ); + */ + std::vector cellsEqual(T value, const EclipseGrid& grid, bool active = true) const; + + /* + Will return a std::vector of the data in the active cells. + */ + std::vector compressedCopy( const EclipseGrid& grid) const; + private: const DeckItem& getDeckItem( const DeckKeyword& ); void setDataPoint(size_t sourceIdx, size_t targetIdx, const DeckItem& deckItem); diff --git a/ThirdParty/custom-opm-parser/opm-parser/opm/parser/eclipse/EclipseState/Grid/MULTREGTScanner.cpp b/ThirdParty/custom-opm-parser/opm-parser/opm/parser/eclipse/EclipseState/Grid/MULTREGTScanner.cpp index c27f62e1cd..eb954bdefa 100644 --- a/ThirdParty/custom-opm-parser/opm-parser/opm/parser/eclipse/EclipseState/Grid/MULTREGTScanner.cpp +++ b/ThirdParty/custom-opm-parser/opm-parser/opm/parser/eclipse/EclipseState/Grid/MULTREGTScanner.cpp @@ -127,17 +127,16 @@ namespace Opm { Then it will go through the different regions and looking for interface with the wanted region values. */ - MULTREGTScanner::MULTREGTScanner(const Eclipse3DProperties& cellRegionNumbers, - const std::vector< const DeckKeyword* >& keywords, - const std::string& defaultRegion ) : - m_cellRegionNumbers(cellRegionNumbers) { + MULTREGTScanner::MULTREGTScanner(const Eclipse3DProperties& e3DProps, + const std::vector< const DeckKeyword* >& keywords) : + m_e3DProps(e3DProps) { for (size_t idx = 0; idx < keywords.size(); idx++) - this->addKeyword(*keywords[idx] , defaultRegion); + this->addKeyword(*keywords[idx] , e3DProps.getDefaultRegionKeyword()); MULTREGTSearchMap searchPairs; for (std::vector::const_iterator record = m_records.begin(); record != m_records.end(); ++record) { - if (cellRegionNumbers.hasDeckIntGridProperty( record->m_region.getValue())) { + if (e3DProps.hasDeckIntGridProperty( record->m_region.getValue())) { if (record->m_srcRegion.hasValue() && record->m_targetRegion.hasValue()) { int srcRegion = record->m_srcRegion.getValue(); int targetRegion = record->m_targetRegion.getValue(); @@ -148,10 +147,12 @@ namespace Opm { } } else - throw std::logic_error("MULTREGT record is based on region: " + record->m_region.getValue() + " which is not in the deck"); + throw std::logic_error( + "MULTREGT record is based on region: " + + record->m_region.getValue() + + " which is not in the deck"); } - for (auto iter = searchPairs.begin(); iter != searchPairs.end(); ++iter) { const MULTREGTRecord * record = (*iter).second; std::pair pair = (*iter).first; @@ -161,8 +162,6 @@ namespace Opm { m_searchMap[keyword][pair] = record; } - - } @@ -235,7 +234,7 @@ namespace Opm { double MULTREGTScanner::getRegionMultiplier(size_t globalIndex1 , size_t globalIndex2, FaceDir::DirEnum faceDir) const { for (auto iter = m_searchMap.begin(); iter != m_searchMap.end(); iter++) { - const Opm::GridProperty& region = m_cellRegionNumbers.getIntGridProperty( (*iter).first ); + const Opm::GridProperty& region = m_e3DProps.getIntGridProperty( (*iter).first ); MULTREGTSearchMap map = (*iter).second; int regionId1 = region.iget(globalIndex1); diff --git a/ThirdParty/custom-opm-parser/opm-parser/opm/parser/eclipse/EclipseState/Grid/MULTREGTScanner.hpp b/ThirdParty/custom-opm-parser/opm-parser/opm/parser/eclipse/EclipseState/Grid/MULTREGTScanner.hpp index 87ec9364a9..74d12669f7 100644 --- a/ThirdParty/custom-opm-parser/opm-parser/opm/parser/eclipse/EclipseState/Grid/MULTREGTScanner.hpp +++ b/ThirdParty/custom-opm-parser/opm-parser/opm/parser/eclipse/EclipseState/Grid/MULTREGTScanner.hpp @@ -18,8 +18,8 @@ */ -#ifndef MULTREGTSCANNER_HPP -#define MULTREGTSCANNER_HPP +#ifndef OPM_PARSER_MULTREGTSCANNER_HPP +#define OPM_PARSER_MULTREGTSCANNER_HPP #include #include @@ -70,9 +70,8 @@ namespace Opm { class MULTREGTScanner { public: - MULTREGTScanner(const Eclipse3DProperties& cellRegionNumbers, - const std::vector< const DeckKeyword* >& keywords, - const std::string& defaultRegion); + MULTREGTScanner(const Eclipse3DProperties& e3DProps, + const std::vector< const DeckKeyword* >& keywords); double getRegionMultiplier(size_t globalCellIdx1, size_t globalCellIdx2, FaceDir::DirEnum faceDir) const; private: @@ -80,9 +79,9 @@ namespace Opm { void assertKeywordSupported(const DeckKeyword& deckKeyword, const std::string& defaultRegion); std::vector< MULTREGTRecord > m_records; std::map m_searchMap; - const Eclipse3DProperties& m_cellRegionNumbers; + const Eclipse3DProperties& m_e3DProps; }; } -#endif +#endif // OPM_PARSER_MULTREGTSCANNER_HPP diff --git a/ThirdParty/custom-opm-parser/opm-parser/opm/parser/eclipse/EclipseState/Grid/NNC.cpp b/ThirdParty/custom-opm-parser/opm-parser/opm/parser/eclipse/EclipseState/Grid/NNC.cpp index 2e15370c20..9faae2d409 100644 --- a/ThirdParty/custom-opm-parser/opm-parser/opm/parser/eclipse/EclipseState/Grid/NNC.cpp +++ b/ThirdParty/custom-opm-parser/opm-parser/opm/parser/eclipse/EclipseState/Grid/NNC.cpp @@ -23,6 +23,7 @@ #include #include #include +#include #include #include @@ -34,23 +35,27 @@ namespace Opm NNC(*deck, eclipseGrid) {} - NNC::NNC(const Deck& deck, EclipseGridConstPtr eclipseGrid) { + /// [[deprecated]] + NNC::NNC(const Deck& deck, EclipseGridConstPtr eclipseGrid) : + NNC(deck, *eclipseGrid) + {} + + NNC::NNC(const Deck& deck, const GridDims& gridDims) { const auto& nncs = deck.getKeywordList(); for (size_t idx_nnc = 0; idx_nnc ijk1; ijk1[0] = static_cast(nnc.getRecord(i).getItem(0).get< int >(0)-1); ijk1[1] = static_cast(nnc.getRecord(i).getItem(1).get< int >(0)-1); ijk1[2] = static_cast(nnc.getRecord(i).getItem(2).get< int >(0)-1); - size_t global_index1 = eclipseGrid->getGlobalIndex(ijk1[0],ijk1[1],ijk1[2]); + size_t global_index1 = gridDims.getGlobalIndex(ijk1[0],ijk1[1],ijk1[2]); std::array ijk2; ijk2[0] = static_cast(nnc.getRecord(i).getItem(3).get< int >(0)-1); ijk2[1] = static_cast(nnc.getRecord(i).getItem(4).get< int >(0)-1); ijk2[2] = static_cast(nnc.getRecord(i).getItem(5).get< int >(0)-1); - size_t global_index2 = eclipseGrid->getGlobalIndex(ijk2[0],ijk2[1],ijk2[2]); + size_t global_index2 = gridDims.getGlobalIndex(ijk2[0],ijk2[1],ijk2[2]); const double trans = nnc.getRecord(i).getItem(6).getSIDouble(0); @@ -65,11 +70,11 @@ namespace Opm void NNC::addNNC(const size_t cell1, const size_t cell2, const double trans) { - NNCdata nncdata; - nncdata.cell1 = cell1; - nncdata.cell2 = cell2; - nncdata.trans = trans; - m_nnc.push_back(nncdata); + NNCdata tmp; + tmp.cell1 = cell1; + tmp.cell2 = cell2; + tmp.trans = trans; + m_nnc.push_back(tmp); } size_t NNC::numNNC() const { diff --git a/ThirdParty/custom-opm-parser/opm-parser/opm/parser/eclipse/EclipseState/Grid/NNC.hpp b/ThirdParty/custom-opm-parser/opm-parser/opm/parser/eclipse/EclipseState/Grid/NNC.hpp index 783b186890..fb23ac73a7 100644 --- a/ThirdParty/custom-opm-parser/opm-parser/opm/parser/eclipse/EclipseState/Grid/NNC.hpp +++ b/ThirdParty/custom-opm-parser/opm-parser/opm/parser/eclipse/EclipseState/Grid/NNC.hpp @@ -22,6 +22,7 @@ #include #include +#include #include #include @@ -46,8 +47,11 @@ public: /// [[deprecated]] NNC(std::shared_ptr deck_ptr, std::shared_ptr< const EclipseGrid > eclipseGrid); - /// Construct from input deck. + /// [[deprecated]] NNC(const Deck& deck, std::shared_ptr< const EclipseGrid > eclipseGrid); + + /// Construct from input deck. + NNC(const Deck& deck, const GridDims& gridDims); void addNNC(const size_t cell1, const size_t cell2, const double trans); const std::vector& nncdata() const { return m_nnc; } size_t numNNC() const; diff --git a/ThirdParty/custom-opm-parser/opm-parser/opm/parser/eclipse/EclipseState/Grid/SatfuncPropertyInitializers.cpp b/ThirdParty/custom-opm-parser/opm-parser/opm/parser/eclipse/EclipseState/Grid/SatfuncPropertyInitializers.cpp index 073764d303..90e63440f1 100644 --- a/ThirdParty/custom-opm-parser/opm-parser/opm/parser/eclipse/EclipseState/Grid/SatfuncPropertyInitializers.cpp +++ b/ThirdParty/custom-opm-parser/opm-parser/opm/parser/eclipse/EclipseState/Grid/SatfuncPropertyInitializers.cpp @@ -707,10 +707,11 @@ namespace Opm { const bool useEnptvd = tableManager->useEnptvd(); const auto& enptvdTables = tableManager->getEnptvdTables(); - for( size_t cellIdx = 0; cellIdx < eclipseGrid->getCartesianSize(); cellIdx++ ) { + const auto gridsize = eclipseGrid->getCartesianSize(); + for( size_t cellIdx = 0; cellIdx < gridsize; cellIdx++ ) { int satTableIdx = satnum.iget( cellIdx ) - 1; int endNum = endnum.iget( cellIdx ) - 1; - double cellDepth = std::get< 2 >( eclipseGrid->getCellCenter( cellIdx ) ); + double cellDepth = eclipseGrid->getCellDepth( cellIdx ); values[cellIdx] = selectValue(enptvdTables, @@ -748,10 +749,11 @@ namespace Opm { // assign a NaN in this case... const bool useImptvd = tableManager->useImptvd(); const TableContainer& imptvdTables = tableManager->getImptvdTables(); - for( size_t cellIdx = 0; cellIdx < eclipseGrid->getCartesianSize(); cellIdx++ ) { + const auto gridsize = eclipseGrid->getCartesianSize(); + for( size_t cellIdx = 0; cellIdx < gridsize; cellIdx++ ) { int imbTableIdx = imbnum.iget( cellIdx ) - 1; int endNum = endnum.iget( cellIdx ) - 1; - double cellDepth = std::get< 2 >( eclipseGrid->getCellCenter( cellIdx ) ); + double cellDepth = eclipseGrid->getCellDepth( cellIdx ); values[cellIdx] = selectValue(imptvdTables, (useImptvd && endNum >= 0) ? endNum : -1, diff --git a/ThirdParty/custom-opm-parser/opm-parser/opm/parser/eclipse/EclipseState/Grid/TransMult.cpp b/ThirdParty/custom-opm-parser/opm-parser/opm/parser/eclipse/EclipseState/Grid/TransMult.cpp index 6de95074f8..ac1203c9d2 100644 --- a/ThirdParty/custom-opm-parser/opm-parser/opm/parser/eclipse/EclipseState/Grid/TransMult.cpp +++ b/ThirdParty/custom-opm-parser/opm-parser/opm/parser/eclipse/EclipseState/Grid/TransMult.cpp @@ -16,16 +16,17 @@ 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 + namespace Opm { TransMult::TransMult(size_t nx , size_t ny , size_t nz) : @@ -78,7 +79,9 @@ namespace Opm { } double TransMult::getRegionMultiplier(size_t globalCellIndex1, size_t globalCellIndex2, FaceDir::DirEnum faceDir) const { - return m_multregtScanner->getRegionMultiplier(globalCellIndex1, globalCellIndex2, faceDir); + if (m_multregtScanner == nullptr) + throw new std::logic_error("MULTREGTScanner has not been initialized."); + return m_multregtScanner->getRegionMultiplier(globalCellIndex1, globalCellIndex2, faceDir); } bool TransMult::hasDirectionProperty(FaceDir::DirEnum faceDir) const { @@ -134,7 +137,8 @@ namespace Opm { - void TransMult::setMultregtScanner( std::shared_ptr multregtScanner) { - m_multregtScanner = multregtScanner; + void TransMult::createMultregtScanner(const Eclipse3DProperties& e3DProps, + std::vector< const DeckKeyword* > multregtKeywords) { + m_multregtScanner = new MULTREGTScanner(e3DProps, multregtKeywords); } } diff --git a/ThirdParty/custom-opm-parser/opm-parser/opm/parser/eclipse/EclipseState/Grid/TransMult.hpp b/ThirdParty/custom-opm-parser/opm-parser/opm/parser/eclipse/EclipseState/Grid/TransMult.hpp index fa304bf4ab..d8c7a279e2 100644 --- a/ThirdParty/custom-opm-parser/opm-parser/opm/parser/eclipse/EclipseState/Grid/TransMult.hpp +++ b/ThirdParty/custom-opm-parser/opm-parser/opm/parser/eclipse/EclipseState/Grid/TransMult.hpp @@ -26,8 +26,8 @@ {MULTX , MULTX- , MULTY , MULTY- , MULTZ , MULTZ-, MULTFLT , MULTREGT} */ -#ifndef TRANSMULT_HPP -#define TRANSMULT_HPP +#ifndef OPM_PARSER_TRANSMULT_HPP +#define OPM_PARSER_TRANSMULT_HPP #include @@ -35,13 +35,12 @@ #include #include - +#include namespace Opm { template< typename > class GridProperty; class Fault; class FaultCollection; - class MULTREGTScanner; class TransMult { @@ -53,7 +52,8 @@ namespace Opm { void applyMULT(const GridProperty& srcMultProp, FaceDir::DirEnum faceDir); void applyMULTFLT(const FaultCollection& faults); void applyMULTFLT(const Fault& fault); - void setMultregtScanner(std::shared_ptr multregtScanner); + void createMultregtScanner(const Eclipse3DProperties& e3DProps, + std::vector multregtKeywords); private: size_t getGlobalIndex(size_t i , size_t j , size_t k) const; @@ -66,9 +66,9 @@ namespace Opm { size_t m_nx , m_ny , m_nz; std::map > m_trans; std::map m_names; - std::shared_ptr m_multregtScanner; + MULTREGTScanner* m_multregtScanner = nullptr; }; } -#endif +#endif // OPM_PARSER_TRANSMULT_HPP diff --git a/ThirdParty/custom-opm-parser/opm-parser/opm/parser/eclipse/EclipseState/Grid/tests/ADDREGTests.cpp b/ThirdParty/custom-opm-parser/opm-parser/opm/parser/eclipse/EclipseState/Grid/tests/ADDREGTests.cpp index ea980696d3..98876c354a 100644 --- a/ThirdParty/custom-opm-parser/opm-parser/opm/parser/eclipse/EclipseState/Grid/tests/ADDREGTests.cpp +++ b/ThirdParty/custom-opm-parser/opm-parser/opm/parser/eclipse/EclipseState/Grid/tests/ADDREGTests.cpp @@ -149,6 +149,14 @@ static Opm::DeckPtr createValidIntDeck() { "DIMENS\n" " 5 5 1 /\n" "GRID\n" + "DX\n" + "25*0.25 /\n" + "DY\n" + "25*0.25 /\n" + "DZ\n" + "25*0.25 /\n" + "TOPS\n" + "25*0.25 /\n" "MULTNUM \n" "1 1 2 2 2\n" "1 1 2 2 2\n" @@ -180,6 +188,14 @@ static Opm::DeckPtr createValidPERMXDeck() { "DIMENS\n" " 5 5 1 /\n" "GRID\n" + "DX\n" + "25*0.25 /\n" + "DY\n" + "25*0.25 /\n" + "DZ\n" + "25*0.25 /\n" + "TOPS\n" + "25*0.25 /\n" "MULTNUM \n" "1 1 2 2 2\n" "1 1 2 2 2\n" @@ -218,31 +234,31 @@ static Opm::DeckPtr createValidPERMXDeck() { BOOST_AUTO_TEST_CASE(InvalidArrayThrows) { Opm::DeckPtr deck = createDeckInvalidArray(); - BOOST_CHECK_THROW( new Opm::EclipseState( deck, Opm::ParseContext()) , std::invalid_argument ); + BOOST_CHECK_THROW( new Opm::EclipseState( *deck, Opm::ParseContext()) , std::invalid_argument ); } BOOST_AUTO_TEST_CASE(InvalidRegionThrows) { Opm::DeckPtr deck = createDeckInvalidRegion(); - BOOST_CHECK_THROW( new Opm::EclipseState( deck, Opm::ParseContext()) , std::invalid_argument ); + BOOST_CHECK_THROW( new Opm::EclipseState( *deck, Opm::ParseContext()) , std::invalid_argument ); } BOOST_AUTO_TEST_CASE(ExpectedIntThrows) { Opm::DeckPtr deck = createDeckInvalidValue(); - BOOST_CHECK_THROW( new Opm::EclipseState( deck, Opm::ParseContext()) , std::invalid_argument ); + BOOST_CHECK_THROW( new Opm::EclipseState( *deck, Opm::ParseContext()) , std::invalid_argument ); } BOOST_AUTO_TEST_CASE(UnInitializedRegionThrows) { Opm::DeckPtr deck = createDeckUnInitializedRegion(); - BOOST_CHECK_THROW( new Opm::EclipseState( deck, Opm::ParseContext()) , std::invalid_argument ); + BOOST_CHECK_THROW( new Opm::EclipseState( *deck, Opm::ParseContext()) , std::invalid_argument ); } BOOST_AUTO_TEST_CASE(UnInitializedVectorThrows) { Opm::DeckPtr deck = createDeckUnInitializedVector(); - BOOST_CHECK_THROW( new Opm::EclipseState( deck, Opm::ParseContext()) , std::invalid_argument ); + BOOST_CHECK_THROW( new Opm::EclipseState( *deck, Opm::ParseContext()) , std::invalid_argument ); } diff --git a/ThirdParty/custom-opm-parser/opm-parser/opm/parser/eclipse/EclipseState/Grid/tests/BoxTests.cpp b/ThirdParty/custom-opm-parser/opm-parser/opm/parser/eclipse/EclipseState/Grid/tests/BoxTests.cpp index e2400b2ffb..0e888cb517 100644 --- a/ThirdParty/custom-opm-parser/opm-parser/opm/parser/eclipse/EclipseState/Grid/tests/BoxTests.cpp +++ b/ThirdParty/custom-opm-parser/opm-parser/opm/parser/eclipse/EclipseState/Grid/tests/BoxTests.cpp @@ -23,11 +23,9 @@ #define BOOST_TEST_MODULE BoxManagereTests -#include #include #include #include -#include #include diff --git a/ThirdParty/custom-opm-parser/opm-parser/opm/parser/eclipse/EclipseState/Grid/tests/CopyRegTests.cpp b/ThirdParty/custom-opm-parser/opm-parser/opm/parser/eclipse/EclipseState/Grid/tests/CopyRegTests.cpp index a34b8cabbe..ba8cac39c6 100644 --- a/ThirdParty/custom-opm-parser/opm-parser/opm/parser/eclipse/EclipseState/Grid/tests/CopyRegTests.cpp +++ b/ThirdParty/custom-opm-parser/opm-parser/opm/parser/eclipse/EclipseState/Grid/tests/CopyRegTests.cpp @@ -149,6 +149,14 @@ static Opm::DeckPtr createValidIntDeck() { "DIMENS\n" " 5 5 1 /\n" "GRID\n" + "DX\n" + "25*0.25 /\n" + "DY\n" + "25*0.25 /\n" + "DZ\n" + "25*0.25 /\n" + "TOPS\n" + "25*0.25 /\n" "MULTNUM \n" "1 1 2 2 2\n" "1 1 2 2 2\n" @@ -175,19 +183,19 @@ static Opm::DeckPtr createValidIntDeck() { BOOST_AUTO_TEST_CASE(InvalidArrayThrows1) { Opm::DeckPtr deck = createDeckInvalidArray1(); - BOOST_CHECK_THROW( new Opm::EclipseState( deck, Opm::ParseContext()) , std::invalid_argument ); + BOOST_CHECK_THROW( new Opm::EclipseState( *deck, Opm::ParseContext()) , std::invalid_argument ); } BOOST_AUTO_TEST_CASE(InvalidArrayThrows2) { Opm::DeckPtr deck = createDeckInvalidArray2(); - BOOST_CHECK_THROW( new Opm::EclipseState( deck, Opm::ParseContext()) , std::invalid_argument ); + BOOST_CHECK_THROW( new Opm::EclipseState( *deck, Opm::ParseContext()) , std::invalid_argument ); } BOOST_AUTO_TEST_CASE(InvalidRegionThrows) { Opm::DeckPtr deck = createDeckInvalidRegion(); - BOOST_CHECK_THROW( new Opm::EclipseState( deck, Opm::ParseContext()) , std::invalid_argument ); + BOOST_CHECK_THROW( new Opm::EclipseState( *deck, Opm::ParseContext()) , std::invalid_argument ); } @@ -195,13 +203,13 @@ BOOST_AUTO_TEST_CASE(InvalidRegionThrows) { BOOST_AUTO_TEST_CASE(UnInitializedVectorThrows) { Opm::DeckPtr deck = createDeckUnInitialized(); - BOOST_CHECK_THROW( new Opm::EclipseState( deck, Opm::ParseContext()) , std::invalid_argument ); + BOOST_CHECK_THROW( new Opm::EclipseState( *deck, Opm::ParseContext()) , std::invalid_argument ); } BOOST_AUTO_TEST_CASE(TypeMismatchThrows) { Opm::DeckPtr deck = createDeckInvalidTypeMismatch(); - BOOST_CHECK_THROW( new Opm::EclipseState( deck, Opm::ParseContext()) , std::invalid_argument ); + BOOST_CHECK_THROW( new Opm::EclipseState( *deck, Opm::ParseContext()) , std::invalid_argument ); } diff --git a/ThirdParty/custom-opm-parser/opm-parser/opm/parser/eclipse/EclipseState/Grid/tests/EclipseGridTests.cpp b/ThirdParty/custom-opm-parser/opm-parser/opm/parser/eclipse/EclipseState/Grid/tests/EclipseGridTests.cpp index 96d51d9966..9755b43cd9 100644 --- a/ThirdParty/custom-opm-parser/opm-parser/opm/parser/eclipse/EclipseState/Grid/tests/EclipseGridTests.cpp +++ b/ThirdParty/custom-opm-parser/opm-parser/opm/parser/eclipse/EclipseState/Grid/tests/EclipseGridTests.cpp @@ -23,22 +23,21 @@ #include #define BOOST_TEST_MODULE EclipseGridTests - -#include #include #include -#include - -#include -#include - -#include #include #include +#include + +#include -#include #include +#include +#include + +#include +#include BOOST_AUTO_TEST_CASE(CreateMissingDIMENS_throws) { @@ -50,8 +49,6 @@ BOOST_AUTO_TEST_CASE(CreateMissingDIMENS_throws) { BOOST_CHECK_THROW(new Opm::EclipseGrid( deck ) , std::invalid_argument); } - - static Opm::DeckPtr createDeckHeaders() { const char *deckData = "RUNSPEC\n" @@ -66,6 +63,35 @@ static Opm::DeckPtr createDeckHeaders() { return parser->parseString(deckData, Opm::ParseContext()); } +static Opm::DeckPtr createDeckDIMENS() { + const char *deckData = + "RUNSPEC\n" + "\n" + "DIMENS\n" + " 13 17 19/\n" + "GRID\n" + "EDIT\n" + "\n"; + Opm::ParserPtr parser(new Opm::Parser()); + return parser->parseString(deckData, Opm::ParseContext()); +} + +static Opm::DeckPtr createDeckSPECGRID() { + const char *deckData = + "GRID\n" + "SPECGRID \n" + " 13 17 19 / \n" + "COORD\n" + " 726*1 / \n" + "ZCORN \n" + " 8000*1 / \n" + "ACTNUM \n" + " 1000*1 / \n" + "EDIT\n" + "\n"; + Opm::ParserPtr parser(new Opm::Parser()); + return parser->parseString(deckData, Opm::ParseContext()); +} static Opm::DeckPtr createDeckMissingDIMS() { const char *deckData = @@ -93,8 +119,14 @@ BOOST_AUTO_TEST_CASE(HasGridKeywords) { BOOST_AUTO_TEST_CASE(CreateGridNoCells) { - Opm::DeckPtr deck = createDeckHeaders(); - Opm::EclipseGrid grid( deck ); + Opm::DeckPtr deckptr = createDeckHeaders(); + const Opm::Deck& deck = *deckptr; + { + Opm::EclipseGrid* gridptr = nullptr; + BOOST_CHECK_THROW( gridptr = new Opm::EclipseGrid( deck ) , std::invalid_argument); + delete gridptr; + } + const Opm::GridDims grid(deck); BOOST_CHECK_EQUAL( 10 , grid.getNX()); BOOST_CHECK_EQUAL( 10 , grid.getNY()); BOOST_CHECK_EQUAL( 10 , grid.getNZ()); @@ -318,8 +350,6 @@ BOOST_AUTO_TEST_CASE(CREATE_SIMPLE) { BOOST_CHECK_EQUAL( grid.getNY() , 20 ); BOOST_CHECK_EQUAL( grid.getNZ() , 30 ); BOOST_CHECK_EQUAL( grid.getCartesianSize() , 6000 ); - BOOST_CHECK_EQUAL( true , grid.hasCellInfo() ); - } BOOST_AUTO_TEST_CASE(DEPTHZ_EQUAL_TOPS) { @@ -399,9 +429,13 @@ BOOST_AUTO_TEST_CASE(HasINVALIDCartKeywords) { BOOST_AUTO_TEST_CASE(CreateMissingGRID_throws) { - Opm::DeckPtr deck = createDeckHeaders(); - Opm::EclipseGrid grid( deck ); - BOOST_CHECK_EQUAL( false , grid.hasCellInfo() ); + auto deckptr = createDeckHeaders(); + const Opm::Deck& deck = *deckptr; + { + Opm::EclipseGrid* gridptr = nullptr; + BOOST_CHECK_THROW( gridptr = new Opm::EclipseGrid( deck ) , std::invalid_argument); + delete gridptr; + } } @@ -430,7 +464,8 @@ static Opm::DeckPtr createInvalidDXYZCARTDeck() { BOOST_AUTO_TEST_CASE(CreateCartesianGRID) { - Opm::DeckPtr deck = createInvalidDXYZCARTDeck(); + auto deckptr = createInvalidDXYZCARTDeck(); + const Opm::Deck& deck = *deckptr; BOOST_CHECK_THROW(new Opm::EclipseGrid( deck ) , std::invalid_argument); } @@ -460,9 +495,13 @@ static Opm::DeckPtr createInvalidDXYZCARTDeckDEPTHZ() { BOOST_AUTO_TEST_CASE(CreateCartesianGRIDDEPTHZ) { - Opm::DeckPtr deck = createInvalidDXYZCARTDeckDEPTHZ(); - Opm::EclipseGrid grid( deck ); - BOOST_CHECK_EQUAL( false , grid.hasCellInfo() ); + auto deckptr = createInvalidDXYZCARTDeckDEPTHZ(); + const Opm::Deck& deck = *deckptr; + { + Opm::EclipseGrid* gridptr = nullptr; + BOOST_CHECK_THROW( gridptr = new Opm::EclipseGrid( deck ) , std::invalid_argument); + delete gridptr; + } } @@ -513,8 +552,14 @@ static Opm::DeckPtr createInvalidDEPTHZDeck1 () { BOOST_AUTO_TEST_CASE(CreateCartesianGRIDInvalidDEPTHZ1) { - Opm::DeckPtr deck = createInvalidDEPTHZDeck1(); - BOOST_CHECK_THROW(new Opm::EclipseGrid( deck ) , std::invalid_argument); + auto deckptr = createInvalidDEPTHZDeck1(); + const Opm::Deck& deck = *deckptr; + { + Opm::EclipseGrid* gridptr = nullptr; + BOOST_CHECK_THROW( gridptr = new Opm::EclipseGrid( deck ) , std::invalid_argument); + delete gridptr; + } + } @@ -541,20 +586,26 @@ static Opm::DeckPtr createInvalidDEPTHZDeck2 () { } BOOST_AUTO_TEST_CASE(CreateCartesianGRIDInvalidDEPTHZ2) { - Opm::DeckPtr deck = createInvalidDEPTHZDeck2(); - BOOST_CHECK_THROW(new Opm::EclipseGrid( deck ) , std::invalid_argument); + auto deckptr = createInvalidDEPTHZDeck2(); + const Opm::Deck& deck = *deckptr; + { + Opm::EclipseGrid* gridptr = nullptr; + BOOST_CHECK_THROW( gridptr = new Opm::EclipseGrid( deck ) , std::invalid_argument); + delete gridptr; + } + } BOOST_AUTO_TEST_CASE(CreateCartesianGRIDOnlyTopLayerDZ) { Opm::DeckPtr deck = createOnlyTopDZCartGrid(); - std::shared_ptr grid(new Opm::EclipseGrid( deck )); + Opm::EclipseGrid grid( *deck ); - BOOST_CHECK_EQUAL( 10 , grid->getNX( )); - BOOST_CHECK_EQUAL( 5 , grid->getNY( )); - BOOST_CHECK_EQUAL( 20 , grid->getNZ( )); - BOOST_CHECK_EQUAL( 1000 , grid->getNumActive()); + BOOST_CHECK_EQUAL( 10 , grid.getNX( )); + BOOST_CHECK_EQUAL( 5 , grid.getNY( )); + BOOST_CHECK_EQUAL( 20 , grid.getNZ( )); + BOOST_CHECK_EQUAL( 1000 , grid.getNumActive()); } @@ -640,11 +691,42 @@ BOOST_AUTO_TEST_CASE(ResetACTNUM) { BOOST_CHECK_EQUAL( 1000U , grid.getNumActive()); std::vector actnum(1000); actnum[0] = 1; + actnum[2] = 1; + actnum[4] = 1; + actnum[6] = 1; grid.resetACTNUM( actnum.data() ); - BOOST_CHECK_EQUAL( 1U , grid.getNumActive() ); + BOOST_CHECK_EQUAL( 4U , grid.getNumActive() ); + { + std::vector full(grid.getCartesianSize()); + std::iota(full.begin(), full.end(), 0); + + auto compressed = grid.compressedVector( full ); + BOOST_CHECK_EQUAL( compressed.size() , 4U ); + BOOST_CHECK_EQUAL( compressed[0] , 0 ); + BOOST_CHECK_EQUAL( compressed[1] , 2 ); + BOOST_CHECK_EQUAL( compressed[2] , 4 ); + BOOST_CHECK_EQUAL( compressed[3] , 6 ); + } + { + const auto& activeMap = grid.getActiveMap( ); + BOOST_CHECK_EQUAL( 4U , activeMap.size() ); + BOOST_CHECK_EQUAL( 0 , activeMap[0] ); + BOOST_CHECK_EQUAL( 2 , activeMap[1] ); + BOOST_CHECK_EQUAL( 4 , activeMap[2] ); + BOOST_CHECK_EQUAL( 6 , activeMap[3] ); + } grid.resetACTNUM( NULL ); BOOST_CHECK_EQUAL( 1000U , grid.getNumActive() ); + + { + const auto& activeMap = grid.getActiveMap( ); + BOOST_CHECK_EQUAL( 1000U , activeMap.size() ); + BOOST_CHECK_EQUAL( 0 , activeMap[0] ); + BOOST_CHECK_EQUAL( 1 , activeMap[1] ); + BOOST_CHECK_EQUAL( 2 , activeMap[2] ); + BOOST_CHECK_EQUAL( 999 , activeMap[999] ); + } } @@ -699,32 +781,6 @@ BOOST_AUTO_TEST_CASE(LoadFromBinary) { -BOOST_AUTO_TEST_CASE(Fwrite) { - const char *deckData = - "RUNSPEC\n" - "\n" - "DIMENS\n" - " 10 10 10 /\n" - "GRID\n" - "COORD\n" - " 726*1 / \n" - "ZCORN \n" - " 8000*1 / \n" - "EDIT\n" - "\n"; - - Opm::ParserPtr parser(new Opm::Parser()); - Opm::DeckConstPtr deck = parser->parseString(deckData, Opm::ParseContext()) ; - Opm::EclipseGrid grid1(deck ); - - grid1.fwriteEGRID( "TEST.EGRID" , true); - - Opm::EclipseGrid grid2( "TEST.EGRID" ); - - BOOST_CHECK( grid1.equal( grid2 )); - remove("TEST.EGRID"); -} - @@ -884,7 +940,7 @@ static Opm::DeckPtr createActnumBoxDeck() { BOOST_AUTO_TEST_CASE(GridBoxActnum) { Opm::DeckConstPtr deck = createActnumBoxDeck(); - Opm::EclipseState es(deck, Opm::ParseContext()); + Opm::EclipseState es(*deck, Opm::ParseContext()); auto ep = es.get3DProperties(); auto grid = es.getInputGrid(); @@ -935,26 +991,111 @@ BOOST_AUTO_TEST_CASE(GridBoxActnum) { BOOST_AUTO_TEST_CASE(GridActnumVia3D) { Opm::DeckConstPtr deck = createActnumDeck(); - Opm::EclipseState es(deck, Opm::ParseContext()); + Opm::EclipseState es(*deck, Opm::ParseContext()); auto ep = es.get3DProperties(); auto grid = es.getInputGrid(); Opm::EclipseGrid grid2( *grid ); BOOST_CHECK_NO_THROW(ep.getIntGridProperty("ACTNUM")); BOOST_CHECK_NO_THROW(grid->getNumActive()); - BOOST_CHECK(grid->hasCellInfo()); BOOST_CHECK_EQUAL(grid->getNumActive(), 2 * 2 * 2 - 1); BOOST_CHECK_NO_THROW(grid2.getNumActive()); - BOOST_CHECK(grid2.hasCellInfo()); BOOST_CHECK_EQUAL(grid2.getNumActive(), 2 * 2 * 2 - 1); } BOOST_AUTO_TEST_CASE(GridActnumViaState) { Opm::DeckConstPtr deck = createActnumDeck(); - BOOST_CHECK_NO_THROW(Opm::EclipseState(deck, Opm::ParseContext())); - Opm::EclipseState es(deck, Opm::ParseContext()); - BOOST_CHECK(es.getInputGrid()->hasCellInfo()); + BOOST_CHECK_NO_THROW(Opm::EclipseState(*deck, Opm::ParseContext())); + Opm::EclipseState es(*deck, Opm::ParseContext()); BOOST_CHECK_EQUAL(es.getInputGrid()->getNumActive(), 2 * 2 * 2 - 1); } + + +BOOST_AUTO_TEST_CASE(GridDimsSPECGRID) { + auto deckptr = createDeckSPECGRID(); + auto gd = Opm::GridDims(*deckptr); + BOOST_CHECK_EQUAL(gd.getNX(), 13); + BOOST_CHECK_EQUAL(gd.getNY(), 17); + BOOST_CHECK_EQUAL(gd.getNZ(), 19); +} + +BOOST_AUTO_TEST_CASE(GridDimsDIMENS) { + auto deckptr = createDeckDIMENS(); + auto gd = Opm::GridDims(*deckptr); + BOOST_CHECK_EQUAL(gd.getNX(), 13); + BOOST_CHECK_EQUAL(gd.getNY(), 17); + BOOST_CHECK_EQUAL(gd.getNZ(), 19); +} + + +BOOST_AUTO_TEST_CASE(ProcessedCopy) { + Opm::EclipseGrid gd(10,10,10); + std::vector zcorn; + std::vector actnum; + + gd.exportZCORN( zcorn ); + gd.exportACTNUM( actnum ); + + { + Opm::EclipseGrid gd2(gd , zcorn , actnum ); + BOOST_CHECK( gd.equal( gd2 )); + } + + zcorn[0] -= 1; + { + Opm::EclipseGrid gd2(gd , zcorn , actnum ); + BOOST_CHECK( !gd.equal( gd2 )); + } + + { + Opm::EclipseGrid gd2(gd , actnum ); + BOOST_CHECK( gd.equal( gd2 )); + } + + actnum.assign( gd.getCartesianSize() , 1); + actnum[0] = 0; + { + Opm::EclipseGrid gd2(gd , actnum ); + BOOST_CHECK( !gd.equal( gd2 )); + BOOST_CHECK( !gd2.cellActive( 0 )); + } +} + + +BOOST_AUTO_TEST_CASE(ZcornMapper) { + int nx = 3; + int ny = 4; + int nz = 5; + Opm::EclipseGrid grid(nx,ny,nz); + Opm::ZcornMapper zmp = grid.zcornMapper( ); + const ecl_grid_type * ert_grid = grid.c_ptr(); + + + BOOST_CHECK_THROW(zmp.index(nx,1,1,0) , std::invalid_argument); + BOOST_CHECK_THROW(zmp.index(0,ny,1,0) , std::invalid_argument); + BOOST_CHECK_THROW(zmp.index(0,1,nz,0) , std::invalid_argument); + BOOST_CHECK_THROW(zmp.index(0,1,2,8) , std::invalid_argument); + + for (int k=0; k < nz; k++) + for (int j=0; j < ny; j++) + for (int i=0; i < nx; i++) + for (int c=0; c < 8; c++) { + size_t g = i + j*nx + k*nx*ny; + BOOST_CHECK_EQUAL( zmp.index(g , c) , zmp.index( i,j,k,c)); + BOOST_CHECK_EQUAL( zmp.index(i,j,k,c) , ecl_grid_zcorn_index( ert_grid, i , j , k, c)); + } +} + + + +BOOST_AUTO_TEST_CASE(MoveTest) { + int nx = 3; + int ny = 4; + int nz = 5; + Opm::EclipseGrid grid1(nx,ny,nz); + Opm::EclipseGrid grid2( std::move( grid1 )); // grid2 should be move constructed from grid1 + + BOOST_CHECK( !grid1.c_ptr() ); // We peek at some internal details ... +} diff --git a/ThirdParty/custom-opm-parser/opm-parser/opm/parser/eclipse/EclipseState/Grid/tests/EqualRegTests.cpp b/ThirdParty/custom-opm-parser/opm-parser/opm/parser/eclipse/EclipseState/Grid/tests/EqualRegTests.cpp index 0bd7ffba38..05cc65a91d 100644 --- a/ThirdParty/custom-opm-parser/opm-parser/opm/parser/eclipse/EclipseState/Grid/tests/EqualRegTests.cpp +++ b/ThirdParty/custom-opm-parser/opm-parser/opm/parser/eclipse/EclipseState/Grid/tests/EqualRegTests.cpp @@ -123,6 +123,14 @@ static Opm::DeckPtr createValidIntDeck() { "DIMENS\n" " 5 5 1 /\n" "GRID\n" + "DX\n" + "25*0.25 /\n" + "DY\n" + "25*0.25 /\n" + "DZ\n" + "25*0.25 /\n" + "TOPS\n" + "25*0.25 /\n" "FLUXNUM \n" "1 1 2 2 2\n" "1 1 2 2 2\n" @@ -158,6 +166,14 @@ static Opm::DeckPtr createValidPERMXDeck() { "DIMENS\n" " 5 5 1 /\n" "GRID\n" + "DX\n" + "25*0.25 /\n" + "DY\n" + "25*0.25 /\n" + "DZ\n" + "25*0.25 /\n" + "TOPS\n" + "25*0.25 /\n" "MULTNUM \n" "1 1 2 2 2\n" "1 1 2 2 2\n" @@ -195,23 +211,23 @@ static Opm::DeckPtr createValidPERMXDeck() { BOOST_AUTO_TEST_CASE(InvalidArrayThrows) { Opm::DeckPtr deck = createDeckInvalidArray(); - BOOST_CHECK_THROW( new Opm::EclipseState( deck, Opm::ParseContext()) , std::invalid_argument ); + BOOST_CHECK_THROW( new Opm::EclipseState( *deck, Opm::ParseContext()) , std::invalid_argument ); } BOOST_AUTO_TEST_CASE(InvalidRegionThrows) { Opm::DeckPtr deck = createDeckInvalidRegion(); - BOOST_CHECK_THROW( new Opm::EclipseState( deck, Opm::ParseContext()) , std::invalid_argument ); + BOOST_CHECK_THROW( new Opm::EclipseState( *deck, Opm::ParseContext()) , std::invalid_argument ); } BOOST_AUTO_TEST_CASE(ExpectedIntThrows) { Opm::DeckPtr deck = createDeckInvalidValue(); - BOOST_CHECK_THROW( new Opm::EclipseState( deck, Opm::ParseContext()) , std::invalid_argument ); + BOOST_CHECK_THROW( new Opm::EclipseState( *deck, Opm::ParseContext()) , std::invalid_argument ); } BOOST_AUTO_TEST_CASE(UnInitializedVectorThrows) { Opm::DeckPtr deck = createDeckUnInitialized(); - BOOST_CHECK_THROW( new Opm::EclipseState( deck, Opm::ParseContext()) , std::invalid_argument ); + BOOST_CHECK_THROW( new Opm::EclipseState( *deck, Opm::ParseContext()) , std::invalid_argument ); } BOOST_AUTO_TEST_CASE(IntSetCorrectly) { diff --git a/ThirdParty/custom-opm-parser/opm-parser/opm/parser/eclipse/EclipseState/Grid/tests/FaultTests.cpp b/ThirdParty/custom-opm-parser/opm-parser/opm/parser/eclipse/EclipseState/Grid/tests/FaultTests.cpp index f565825e73..3f1bf2208d 100644 --- a/ThirdParty/custom-opm-parser/opm-parser/opm/parser/eclipse/EclipseState/Grid/tests/FaultTests.cpp +++ b/ThirdParty/custom-opm-parser/opm-parser/opm/parser/eclipse/EclipseState/Grid/tests/FaultTests.cpp @@ -22,11 +22,9 @@ #define BOOST_TEST_MODULE FaultTests -#include #include #include #include -#include #include #include diff --git a/ThirdParty/custom-opm-parser/opm-parser/opm/parser/eclipse/EclipseState/Grid/tests/GridPropertiesTests.cpp b/ThirdParty/custom-opm-parser/opm-parser/opm/parser/eclipse/EclipseState/Grid/tests/GridPropertiesTests.cpp index a28be1102a..41bcff75c2 100644 --- a/ThirdParty/custom-opm-parser/opm-parser/opm/parser/eclipse/EclipseState/Grid/tests/GridPropertiesTests.cpp +++ b/ThirdParty/custom-opm-parser/opm-parser/opm/parser/eclipse/EclipseState/Grid/tests/GridPropertiesTests.cpp @@ -22,11 +22,9 @@ #define BOOST_TEST_MODULE EclipseGridTests -#include #include #include #include -#include #include diff --git a/ThirdParty/custom-opm-parser/opm-parser/opm/parser/eclipse/EclipseState/Grid/tests/GridPropertyTests.cpp b/ThirdParty/custom-opm-parser/opm-parser/opm/parser/eclipse/EclipseState/Grid/tests/GridPropertyTests.cpp index 88a9a88c72..236289f07a 100644 --- a/ThirdParty/custom-opm-parser/opm-parser/opm/parser/eclipse/EclipseState/Grid/tests/GridPropertyTests.cpp +++ b/ThirdParty/custom-opm-parser/opm-parser/opm/parser/eclipse/EclipseState/Grid/tests/GridPropertyTests.cpp @@ -23,11 +23,9 @@ #define BOOST_TEST_MODULE EclipseGridTests -#include #include #include #include -#include #include #include @@ -260,6 +258,8 @@ BOOST_AUTO_TEST_CASE(GridPropertyInitialization) { "\n" "GRID\n" "\n" + "ACTNUM\n" + " 0 8*1 0 8*1 0 8*1 /\n" "DXV\n" "1 1 1 /\n" "\n" @@ -382,10 +382,62 @@ BOOST_AUTO_TEST_CASE(GridPropertyInitialization) { BOOST_CHECK_EQUAL(sguPropData[0 * 3*3], 0.9); BOOST_CHECK_EQUAL(sguPropData[1 * 3*3], 0.85); BOOST_CHECK_EQUAL(sguPropData[2 * 3*3], 0.80); + + + const auto& satnum = props.getIntGridProperty("SATNUM"); + { + const auto& activeMap = eg.getActiveMap(); + const auto cells1 = satnum.cellsEqual(1 , activeMap); + const auto cells2 = satnum.cellsEqual(2 , activeMap); + const auto cells3 = satnum.cellsEqual(3 , activeMap); + + BOOST_CHECK_EQUAL( cells1.size() , 8 ); + BOOST_CHECK_EQUAL( cells2.size() , 8 ); + BOOST_CHECK_EQUAL( cells3.size() , 8 ); + + for (size_t i = 0; i < 8; i++) { + BOOST_CHECK_EQUAL( cells1[i] , i ); + BOOST_CHECK_EQUAL( cells2[i] , i + 8); + BOOST_CHECK_EQUAL( cells3[i] , i + 16); + } + } + { + const auto cells1 = satnum.indexEqual(1 ); + const auto cells2 = satnum.indexEqual(2 ); + const auto cells3 = satnum.indexEqual(3 ); + + BOOST_CHECK_EQUAL( cells1.size() , 9 ); + BOOST_CHECK_EQUAL( cells2.size() , 9 ); + BOOST_CHECK_EQUAL( cells3.size() , 9 ); + + for (size_t i = 0; i < 9; i++) { + BOOST_CHECK_EQUAL( cells1[i] , i ); + BOOST_CHECK_EQUAL( cells2[i] , i + 9); + BOOST_CHECK_EQUAL( cells3[i] , i + 18); + } + } + + { + const auto cells3_a = satnum.cellsEqual(3 , eg); + const auto cells3_g = satnum.cellsEqual(3 , eg , false); + + for (size_t i = 0; i < 8; i++) { + BOOST_CHECK_EQUAL( cells3_a[i] , i + 16); + BOOST_CHECK_EQUAL( cells3_g[i] , i + 18); + } + BOOST_CHECK_EQUAL( cells3_g[8] , 26); + } + + const auto compressedSatnum = satnum.compressedCopy( eg ); + BOOST_CHECK_EQUAL( compressedSatnum.size() , eg.getNumActive()); + for (size_t i=0; i < eg.getNumActive(); i++) { + size_t g = eg.getGlobalIndex( i ); + BOOST_CHECK_EQUAL( compressedSatnum[i] , satnum.getData()[g]); + } } -void TestPostProcessorMul(std::vector< double >& values, +inline void TestPostProcessorMul(std::vector< double >& values, const Opm::TableManager*, const Opm::EclipseGrid*, Opm::GridProperties*, diff --git a/ThirdParty/custom-opm-parser/opm-parser/opm/parser/eclipse/EclipseState/Grid/tests/MULTREGTScannerTests.cpp b/ThirdParty/custom-opm-parser/opm-parser/opm/parser/eclipse/EclipseState/Grid/tests/MULTREGTScannerTests.cpp index 77ddcf8e9e..59b2966bfd 100644 --- a/ThirdParty/custom-opm-parser/opm-parser/opm/parser/eclipse/EclipseState/Grid/tests/MULTREGTScannerTests.cpp +++ b/ThirdParty/custom-opm-parser/opm-parser/opm/parser/eclipse/EclipseState/Grid/tests/MULTREGTScannerTests.cpp @@ -73,6 +73,14 @@ static Opm::DeckPtr createInvalidMULTREGTDeck() { "DIMENS\n" " 3 3 2 /\n" "GRID\n" + "DX\n" + "18*0.25 /\n" + "DY\n" + "18*0.25 /\n" + "DZ\n" + "18*0.25 /\n" + "TOPS\n" + "9*0.25 /\n" "FLUXNUM\n" "1 1 2\n" "1 1 2\n" @@ -110,19 +118,19 @@ BOOST_AUTO_TEST_CASE(InvalidInput) { std::vector keywords0; const auto& multregtKeyword0 = deck->getKeyword( "MULTREGT", 0 ); keywords0.push_back( &multregtKeyword0 ); - BOOST_CHECK_THROW( Opm::MULTREGTScanner scanner( props, keywords0, "MULTNUM" ); , std::invalid_argument ); + BOOST_CHECK_THROW( Opm::MULTREGTScanner scanner( props, keywords0 ); , std::invalid_argument ); // Not supported region std::vector keywords1; const auto& multregtKeyword1 = deck->getKeyword( "MULTREGT", 1 ); keywords1.push_back( &multregtKeyword1 ); - BOOST_CHECK_THROW( Opm::MULTREGTScanner scanner( props, keywords1, "MULTNUM" ); , std::invalid_argument ); + BOOST_CHECK_THROW( Opm::MULTREGTScanner scanner( props, keywords1 ); , std::invalid_argument ); // The keyword is ok; but it refers to a region which is not in the deck. std::vector keywords2; const auto& multregtKeyword2 = deck->getKeyword( "MULTREGT", 2 ); keywords2.push_back( &multregtKeyword2 ); - BOOST_CHECK_THROW( Opm::MULTREGTScanner scanner( props, keywords2, "MULTNUM" ); , std::logic_error ); + BOOST_CHECK_THROW( Opm::MULTREGTScanner scanner( props, keywords2 ); , std::logic_error ); } @@ -133,6 +141,14 @@ static Opm::DeckPtr createNotSupportedMULTREGTDeck() { "DIMENS\n" " 3 3 2 /\n" "GRID\n" + "DX\n" + "18*0.25 /\n" + "DY\n" + "18*0.25 /\n" + "DZ\n" + "18*0.25 /\n" + "TOPS\n" + "9*0.25 /\n" "FLUXNUM\n" "1 1 2\n" "1 1 2\n" @@ -175,26 +191,26 @@ BOOST_AUTO_TEST_CASE(NotSupported) { std::vector keywords0; const auto& multregtKeyword0 = deck->getKeyword( "MULTREGT", 0 ); keywords0.push_back( &multregtKeyword0 ); - BOOST_CHECK_THROW( Opm::MULTREGTScanner scanner( props, keywords0, "MULTNUM" ); , std::invalid_argument ); + BOOST_CHECK_THROW( Opm::MULTREGTScanner scanner( props, keywords0 ); , std::invalid_argument ); // Defaulted from value - not supported std::vector keywords1; const auto& multregtKeyword1 = deck->getKeyword( "MULTREGT", 1 ); keywords1.push_back( &multregtKeyword1 ); - BOOST_CHECK_THROW( Opm::MULTREGTScanner scanner( props, keywords1, "MULTNUM" ); , std::invalid_argument ); + BOOST_CHECK_THROW( Opm::MULTREGTScanner scanner( props, keywords1 ); , std::invalid_argument ); // Defaulted to value - not supported std::vector keywords2; const auto& multregtKeyword2 = deck->getKeyword( "MULTREGT", 2 ); keywords2.push_back( &multregtKeyword2 ); - BOOST_CHECK_THROW( Opm::MULTREGTScanner scanner( props, keywords2, "MULTNUM" ); , std::invalid_argument ); + BOOST_CHECK_THROW( Opm::MULTREGTScanner scanner( props, keywords2 ); , std::invalid_argument ); // srcValue == targetValue - not supported std::vector keywords3; const Opm::DeckKeyword& multregtKeyword3 = deck->getKeyword( "MULTREGT", 3 ); keywords3.push_back( &multregtKeyword3 ); - BOOST_CHECK_THROW( Opm::MULTREGTScanner scanner( props, keywords3, "MULTNUM" ); , std::invalid_argument ); + BOOST_CHECK_THROW( Opm::MULTREGTScanner scanner( props, keywords3 ); , std::invalid_argument ); } static Opm::DeckPtr createCopyMULTNUMDeck() { @@ -204,6 +220,14 @@ static Opm::DeckPtr createCopyMULTNUMDeck() { "DIMENS\n" "2 2 2 /\n" "GRID\n" + "DX\n" + "8*0.25 /\n" + "DY\n" + "8*0.25 /\n" + "DZ\n" + "8*0.25 /\n" + "TOPS\n" + "4*0.25 /\n" "FLUXNUM\n" "1 2\n" "1 2\n" diff --git a/ThirdParty/custom-opm-parser/opm-parser/opm/parser/eclipse/EclipseState/Grid/tests/MultiRegTests.cpp b/ThirdParty/custom-opm-parser/opm-parser/opm/parser/eclipse/EclipseState/Grid/tests/MultiRegTests.cpp index 76c9505746..02a81952c7 100644 --- a/ThirdParty/custom-opm-parser/opm-parser/opm/parser/eclipse/EclipseState/Grid/tests/MultiRegTests.cpp +++ b/ThirdParty/custom-opm-parser/opm-parser/opm/parser/eclipse/EclipseState/Grid/tests/MultiRegTests.cpp @@ -146,6 +146,14 @@ static Opm::DeckPtr createValidIntDeck() { "DIMENS\n" " 5 5 1 /\n" "GRID\n" + "DX\n" + "25*0.25 /\n" + "DY\n" + "25*0.25 /\n" + "DZ\n" + "25*0.25 /\n" + "TOPS\n" + "25*0.25 /\n" "REGIONS\n" "SATNUM \n" "1 1 2 2 2\n" @@ -179,29 +187,29 @@ static Opm::DeckPtr createValidIntDeck() { BOOST_AUTO_TEST_CASE(InvalidArrayThrows) { Opm::DeckPtr deck = createDeckInvalidArray(); - BOOST_CHECK_THROW( new Opm::EclipseState( deck, Opm::ParseContext()) , std::invalid_argument ); + BOOST_CHECK_THROW( new Opm::EclipseState( *deck, Opm::ParseContext()) , std::invalid_argument ); } BOOST_AUTO_TEST_CASE(InvalidRegionThrows) { Opm::DeckPtr deck = createDeckInvalidRegion(); - BOOST_CHECK_THROW( new Opm::EclipseState( deck, Opm::ParseContext()) , std::invalid_argument ); + BOOST_CHECK_THROW( new Opm::EclipseState( *deck, Opm::ParseContext()) , std::invalid_argument ); } BOOST_AUTO_TEST_CASE(ExpectedIntThrows) { Opm::DeckPtr deck = createDeckInvalidValue(); - BOOST_CHECK_THROW( new Opm::EclipseState( deck, Opm::ParseContext()) , std::invalid_argument ); + BOOST_CHECK_THROW( new Opm::EclipseState( *deck, Opm::ParseContext()) , std::invalid_argument ); } BOOST_AUTO_TEST_CASE(MissingRegionVectorThrows) { Opm::DeckPtr deck = createDeckMissingVector(); - BOOST_CHECK_THROW( new Opm::EclipseState( deck, Opm::ParseContext()) , std::invalid_argument ); + BOOST_CHECK_THROW( new Opm::EclipseState( *deck, Opm::ParseContext()) , std::invalid_argument ); } BOOST_AUTO_TEST_CASE(UnInitializedVectorThrows) { Opm::DeckPtr deck = createDeckUnInitialized(); - BOOST_CHECK_THROW( new Opm::EclipseState( deck, Opm::ParseContext()) , std::invalid_argument ); + BOOST_CHECK_THROW( new Opm::EclipseState( *deck, Opm::ParseContext()) , std::invalid_argument ); } BOOST_AUTO_TEST_CASE(IntSetCorrectly) { diff --git a/ThirdParty/custom-opm-parser/opm-parser/opm/parser/eclipse/EclipseState/Grid/tests/PORVTests.cpp b/ThirdParty/custom-opm-parser/opm-parser/opm/parser/eclipse/EclipseState/Grid/tests/PORVTests.cpp index ab0145b8e0..06ff9e581c 100644 --- a/ThirdParty/custom-opm-parser/opm-parser/opm/parser/eclipse/EclipseState/Grid/tests/PORVTests.cpp +++ b/ThirdParty/custom-opm-parser/opm-parser/opm/parser/eclipse/EclipseState/Grid/tests/PORVTests.cpp @@ -228,6 +228,39 @@ static Opm::DeckPtr createDeckWithNTG() { return parser->parseString(deckData, Opm::ParseContext()) ; } +static Opm::DeckPtr createDeckWithMULTREGP() { + const char *deckData = + "RUNSPEC\n" + "\n" + "DIMENS\n" + " 10 10 10 /\n" + "GRID\n" + "DX\n" + "1000*0.25 /\n" + "DYV\n" + "10*0.25 /\n" + "DZ\n" + "1000*0.25 /\n" + "TOPS\n" + "100*0.25 /\n" + "PORV\n" + "1000*77 /\n" + "MULTNUM\n" + "100*1 700*2 200*3 / \n" + "FLUXNUM\n" + "200*1 700*2 100*3 / \n" + "MULTREGP\n" + "1 10.0 / \n" + "1 2.0 F/ \n" + "0 123.0 F/ \n" // ignored + "2 20.0 M / \n" + "/\n" + "\n"; + + Opm::ParserPtr parser(new Opm::Parser()); + return parser->parseString(deckData, Opm::ParseContext()) ; +} + BOOST_AUTO_TEST_CASE(PORV_cartesianDeck) { /* Check that an exception is raised if we try to create a PORV field without PORO. */ Opm::DeckPtr deck = createCARTDeck(); @@ -324,6 +357,29 @@ BOOST_AUTO_TEST_CASE(PORV_multpvAndNtg) { BOOST_CHECK_CLOSE( cell_volume * poro*multpv*NTG , porv.iget(9,9,9) , 0.001); } +BOOST_AUTO_TEST_CASE(PORV_multregp) { + Opm::DeckPtr deck = createDeckWithMULTREGP(); + const auto props = getProps(deck); + const auto& porv = props.getDoubleGridProperty("PORV"); + const auto& porvData = porv.getData(); + double basePorv = 77.0; + + // the cumlative effect of the base pore volume is multiplied 2 for the cells in + // region 1 of FLUXNUM and by 20 for region 2 of MULTNUM. This means that the first + // 100 cels are multiplied by 2, then follow 100 cells multiplied by 2*20, then + // 600 cells multiplied by 20 while the last 200 cells are not modified at all. + for (int i=0; i < 100; ++i) + BOOST_CHECK_CLOSE(porvData[i], basePorv*2, 1e-8); + + for (int i=100; i < 200; ++i) + BOOST_CHECK_CLOSE(porvData[i], basePorv*2*20, 1e-8); + + for (int i=200; i < 800; ++i) + BOOST_CHECK_CLOSE(porvData[i], basePorv*20, 1e-8); + + for (int i=800; i < 1000; ++i) + BOOST_CHECK_CLOSE(porvData[i], basePorv, 1e-8); +} static Opm::DeckPtr createDeckNakedGRID() { @@ -346,8 +402,7 @@ static Opm::DeckPtr createDeckNakedGRID() { BOOST_AUTO_TEST_CASE(NAKED_GRID_THROWS) { /* Check that MULTIPLE Boxed PORV and MULTPV statements work and NTG */ Opm::DeckPtr deck = createDeckNakedGRID(); - const auto props = getProps(deck); - BOOST_CHECK_THROW( props.getDoubleGridProperty("PORV") , std::invalid_argument ); + BOOST_CHECK_THROW( getProps(deck) , std::invalid_argument ); } static Opm::DeckPtr createDeckWithPOROZero() { @@ -386,7 +441,7 @@ static Opm::DeckPtr createDeckWithPOROZero() { BOOST_AUTO_TEST_CASE(PORO_ZERO_ACTNUM_CORRECT) { /* Check that MULTIPLE Boxed PORV and MULTPV statements work and NTG */ Opm::DeckPtr deck = createDeckWithPOROZero(); - Opm::EclipseState state( deck , Opm::ParseContext()); + Opm::EclipseState state( *deck , Opm::ParseContext()); auto grid = state.getInputGrid( ); /* Top layer is active */ diff --git a/ThirdParty/custom-opm-parser/opm-parser/opm/parser/eclipse/EclipseState/Grid/tests/SatfuncPropertyInitializersTests.cpp b/ThirdParty/custom-opm-parser/opm-parser/opm/parser/eclipse/EclipseState/Grid/tests/SatfuncPropertyInitializersTests.cpp index deaba369fe..d3c5a45729 100644 --- a/ThirdParty/custom-opm-parser/opm-parser/opm/parser/eclipse/EclipseState/Grid/tests/SatfuncPropertyInitializersTests.cpp +++ b/ThirdParty/custom-opm-parser/opm-parser/opm/parser/eclipse/EclipseState/Grid/tests/SatfuncPropertyInitializersTests.cpp @@ -34,14 +34,16 @@ using namespace Opm; -void check_property(const Eclipse3DProperties& props1, const Eclipse3DProperties& props2, const std::string& propertyName) { +inline void check_property(const Eclipse3DProperties& props1, + const Eclipse3DProperties& props2, + const std::string& propertyName) { auto& data1 = props1.getDoubleGridProperty(propertyName).getData(); auto& data2 = props2.getDoubleGridProperty(propertyName).getData(); BOOST_CHECK_CLOSE(data1[0], data2[0], 1e-12); } -static Opm::Eclipse3DProperties getProps(Opm::DeckPtr deck) { +inline Opm::Eclipse3DProperties getProps(Opm::DeckPtr deck) { return Opm::Eclipse3DProperties(*deck, *new Opm::TableManager(*deck), *new Opm::EclipseGrid(deck)); } diff --git a/ThirdParty/custom-opm-parser/opm-parser/opm/parser/eclipse/EclipseState/IOConfig/IOConfig.cpp b/ThirdParty/custom-opm-parser/opm-parser/opm/parser/eclipse/EclipseState/IOConfig/IOConfig.cpp index 3cfefc605c..5a66b4be1d 100644 --- a/ThirdParty/custom-opm-parser/opm-parser/opm/parser/eclipse/EclipseState/IOConfig/IOConfig.cpp +++ b/ThirdParty/custom-opm-parser/opm-parser/opm/parser/eclipse/EclipseState/IOConfig/IOConfig.cpp @@ -28,7 +28,6 @@ #include #include #include -#include #include #include #include @@ -54,182 +53,14 @@ namespace Opm { return dir; } - - inline bool is_int( const std::string& x ) { - auto is_digit = []( char c ) { return std::isdigit( c ); }; - - return !x.empty() - && ( x.front() == '-' || is_digit( x.front() ) ) - && std::all_of( x.begin() + 1, x.end(), is_digit ); - } } - IOConfig::restartConfig IOConfig::rptrst( const DeckKeyword& kw, size_t step ) { - - const auto& items = kw.getStringData(); - - /* if any of the values are pure integers we assume this is meant to be - * the slash-terminated list of integers way of configuring. If - * integers and non-integers are mixed, this is an error. - */ - const auto ints = std::any_of( items.begin(), items.end(), is_int ); - const auto strs = !std::all_of( items.begin(), items.end(), is_int ); - - if( ints && strs ) throw std::runtime_error( - "RPTRST does not support mixed mnemonics and integer list." - ); - - size_t basic = 1; - size_t freq = 0; - bool found_basic = false; - - for( const auto& mnemonic : items ) { - - const auto freq_pos = mnemonic.find( "FREQ=" ); - if( freq_pos != std::string::npos ) { - freq = std::stoul( mnemonic.substr( freq_pos + 5 ) ); - } - - const auto basic_pos = mnemonic.find( "BASIC=" ); - if( basic_pos != std::string::npos ) { - basic = std::stoul( mnemonic.substr( basic_pos + 6 ) ); - found_basic = true; - } - } - - if( found_basic ) return restartConfig( step, basic, freq ); - - /* If no BASIC mnemonic is found, either it is not present or we might - * have an old data set containing integer controls instead of mnemonics. - * BASIC integer switch is integer control nr 1, FREQUENCY is integer - * control nr 6. - */ - - /* mnemonics, but without basic and freq. Effectively ignored */ - if( !ints ) return {}; - - const int BASIC_index = 0; - const int FREQ_index = 5; - - if( items.size() > BASIC_index ) - basic = std::stoul( items[ BASIC_index ] ); - - // Peculiar special case in eclipse, - not documented - // This ignore of basic = 0 for the integer mnemonics case - // is done to make flow write restart file at the same intervals - // as eclipse for the Norne data set. There might be some rules - // we are missing here. - if( 0 == basic ) return {}; - - if( items.size() > FREQ_index ) // if frequency is set - freq = std::stoul( items[ FREQ_index ] ); - - return restartConfig( step, basic, freq ); - } - - IOConfig::restartConfig IOConfig::rptsched( const DeckKeyword& keyword ) { - size_t restart = 0; - bool restart_found = false; - - const auto& items = keyword.getStringData(); - const auto ints = std::any_of( items.begin(), items.end(), is_int ); - const auto strs = !std::all_of( items.begin(), items.end(), is_int ); - - if( ints && strs ) throw std::runtime_error( - "RPTSCHED does not support mixed mnemonics and integer list." - ); - - for( const auto& mnemonic : items ) { - const auto restart_pos = mnemonic.find( "RESTART=" ); - if( restart_pos != std::string::npos ) { - restart = std::stoul( mnemonic.substr( restart_pos + 8 ) ); - restart_found = true; - } - - const auto nothing_pos = mnemonic.find( "NOTHING" ); - if( nothing_pos != std::string::npos ) { - restart = 0; - restart_found = true; - } - } - - if( restart_found ) return restartConfig( restart ); - - - /* No RESTART or NOTHING found, but it is not an integer list */ - if( strs ) return {}; - - /* We might have an old data set containing integer controls instead of - * mnemonics. Restart integer switch is integer control nr 7 - */ - - const int RESTART_index = 6; - - if( items.size() <= RESTART_index ) return {}; - - return restartConfig( std::stoul( items[ RESTART_index ] ) ); - } - - DynamicState< IOConfig::restartConfig > IOConfig::rstconf( - const SCHEDULESection& schedule, - std::shared_ptr< const TimeMap > timemap ) { - - size_t current_step = 1; - bool ignore_RPTSCHED_restart = false; - restartConfig unset; - - DynamicState< IOConfig::restartConfig > - restart_config( timemap, restartConfig( 0, 0, 1 ) ); - - for( const auto& keyword : schedule ) { - const auto& name = keyword.name(); - - if( name == "DATES" ) { - current_step += keyword.size(); - continue; - } - - if( name == "TSTEP" ) { - current_step += keyword.getRecord( 0 ).getItem( 0 ).size(); - continue; - } - - if( !( name == "RPTRST" || name == "RPTSCHED" ) ) continue; - - if( timemap->size() <= current_step ) continue; - - const bool is_RPTRST = name == "RPTRST"; - - if( !is_RPTRST && ignore_RPTSCHED_restart ) continue; - - const auto rs = is_RPTRST - ? rptrst( keyword, current_step - 1 ) - : rptsched( keyword ); - - if( is_RPTRST ) ignore_RPTSCHED_restart = rs.basic > 2; - - /* we're using the default state of restartConfig to signal "no - * update". The default state is non-sensical - */ - if( rs == unset ) continue; - - if( 6 == rs.rptsched_restart || 6 == rs.basic ) - throw std::runtime_error( - "OPM does not support the RESTART=6 setting" - "(write restart file every timestep)" - ); - - restart_config.update( current_step, rs ); - } - - return restart_config; - } IOConfig::IOConfig( const Deck& deck ) : IOConfig( GRIDSection( deck ), RUNSPECSection( deck ), - SCHEDULESection( deck ), std::make_shared< const TimeMap >( deck ), + deck.hasKeyword("NOSIM"), deck.getDataFile() ) {} @@ -266,8 +97,8 @@ namespace Opm { IOConfig::IOConfig( const GRIDSection& grid, const RUNSPECSection& runspec, - const SCHEDULESection& schedule, std::shared_ptr< const TimeMap > timemap, + bool nosim, const std::string& input_path ) : m_timemap( timemap ), m_write_INIT_file( grid.hasKeyword( "INIT" ) ), @@ -279,10 +110,10 @@ namespace Opm { m_deck_filename( input_path ), m_output_dir( outputdir( input_path ) ), m_base_name( basename( input_path ) ), - m_restart_output_config( std::make_shared< DynamicState< restartConfig > >( - rstconf( schedule, timemap ) ) ) + m_nosim( nosim ) {} + bool IOConfig::getWriteEGRIDFile() const { return m_write_EGRID_file; } @@ -291,153 +122,34 @@ namespace Opm { return m_write_INIT_file; } - bool IOConfig::getWriteRestartFile(size_t timestep) const { - bool write_restart_ts = false; - - if (0 == timestep) { - write_restart_ts = m_write_initial_RST_file; - } else if (m_restart_output_config) { - restartConfig ts_restart_config = m_restart_output_config->get(timestep); - - //Look at rptsched restart setting - if (ts_restart_config.rptsched_restart_set) { - if (ts_restart_config.rptsched_restart > 0) { - write_restart_ts = true; - } - } else { //Look at rptrst basic setting - switch (ts_restart_config.basic) { - case 0: //Do not write restart files - write_restart_ts = false; - break; - case 1: //Write restart file every report time - write_restart_ts = true; - break; - case 2: //Write restart file every report time - write_restart_ts = true; - break; - case 3: //Every n'th report time - write_restart_ts = getWriteRestartFileFrequency(timestep, ts_restart_config.timestep, ts_restart_config.frequency); - break; - case 4: //First reportstep of every year, or if n > 1, n'th years - write_restart_ts = getWriteRestartFileFrequency(timestep, ts_restart_config.timestep, ts_restart_config.frequency, true); - break; - case 5: //First reportstep of every month, or if n > 1, n'th months - write_restart_ts = getWriteRestartFileFrequency(timestep, ts_restart_config.timestep, ts_restart_config.frequency, false, true); - break; - default: - // do nothing - break; - } - } - } - - return write_restart_ts; - } - - - bool IOConfig::getWriteRestartFileFrequency(size_t timestep, - size_t start_timestep, - size_t frequency, - bool years, - bool months) const { - bool write_restart_file = false; - if ((!years && !months) && (timestep >= start_timestep)) { - write_restart_file = ((timestep % frequency) == 0) ? true : false; - } else { - write_restart_file = m_timemap->isTimestepInFirstOfMonthsYearsSequence(timestep, years, start_timestep, frequency); - - } - return write_restart_file; - } - - void IOConfig::assertTimeMap(TimeMapConstPtr timemap) { - if (!m_timemap) { - restartConfig rs; - rs.timestep = 0; - rs.basic = 0; - rs.frequency = 1; - rs.rptsched_restart_set = false; - rs.rptsched_restart = 0; - - m_timemap = timemap; - m_restart_output_config = std::make_shared>(timemap, rs); - } - } - /* - Will initialize the two internal variables holding the first - report step when restart and rft output is queried. - - The reason we are interested in this report step is that when we - reach this step the output files should be opened with mode 'w' - - whereas for subsequent steps they should be opened with mode - 'a'. + Will initialize an internal variable holding the first report + step when rft output is queried. The reason we are interested in + this report step is that when we reach this step the output + files should be opened with mode 'w' - whereas for subsequent + steps it should be opened with mode 'a'. */ - void IOConfig::initFirstOutput(const Schedule& schedule) { - m_first_restart_step = -1; + void IOConfig::initFirstRFTOutput(const Schedule& schedule) { m_first_rft_step = -1; - assertTimeMap( this->m_timemap ); - { - size_t report_step = 0; - while (true) { - if (getWriteRestartFile(report_step)) { - m_first_restart_step = report_step; - break; - } - report_step++; - if (report_step == m_timemap->size()) - break; - } - } - { - for (const auto& well : schedule.getWells( )) { - int well_output = well->firstRFTOutput(); - if (well_output >= 0) { - if ((m_first_rft_step < 0) || (well_output < m_first_rft_step)) - m_first_rft_step = well_output; - } + + for (const auto& well : schedule.getWells( )) { + int well_output = well->firstRFTOutput(); + if (well_output >= 0) { + if ((m_first_rft_step < 0) || (well_output < m_first_rft_step)) + m_first_rft_step = well_output; } } } - void IOConfig::handleSolutionSection(TimeMapConstPtr timemap, std::shared_ptr solutionSection) { - if (solutionSection->hasKeyword("RPTRST")) { - const auto& rptrstkeyword = solutionSection->getKeyword("RPTRST"); - - auto rs = rptrst( rptrstkeyword, 0 ); - if( rs != restartConfig() ) - m_restart_output_config->updateInitial( rs ); - - setWriteInitialRestartFile(true); // Guessing on eclipse rules for write of initial RESTART file (at time 0): - // Write of initial restart file is (due to the eclipse reference manual) - // governed by RPTSOL RESTART in solution section, - // if RPTSOL RESTART > 1 initial restart file is written. - // but - due to initial restart file written from Eclipse - // for data where RPTSOL RESTART not set - guessing that - // when RPTRST is set in SOLUTION (no basic though...) -> write inital restart. - } //RPTRST - if (solutionSection->hasKeyword("RPTSOL") && (timemap->size() > 0)) { - handleRPTSOL(solutionSection->getKeyword("RPTSOL")); - } //RPTSOL + void IOConfig::overrideNOSIM(bool nosim) { + m_nosim = nosim; } - void IOConfig::overrideRestartWriteInterval(size_t interval) { - size_t step = 0; - /* write restart files if the interval is non-zero. The restart - * mnemonic (setting) that governs restart-on-interval is BASIC=3 - */ - size_t basic = interval > 0 ? 3 : 0; - - restartConfig rs( step, basic, interval ); - m_restart_output_config->globalReset( rs ); - - setWriteInitialRestartFile( interval > 0 ); - } bool IOConfig::getUNIFIN() const { return m_UNIFIN; @@ -455,57 +167,6 @@ namespace Opm { return m_FMTOUT; } - void IOConfig::setWriteInitialRestartFile(bool writeInitialRestartFile) { - m_write_initial_RST_file = writeInitialRestartFile; - } - - - void IOConfig::handleRPTSOL( const DeckKeyword& keyword) { - const auto& record = keyword.getRecord(0); - - size_t restart = 0; - size_t found_mnemonic_RESTART = 0; - bool handle_RPTSOL_RESTART = false; - - const auto& item = record.getItem(0); - - - for (size_t index = 0; index < item.size(); ++index) { - const std::string& mnemonic = item.get< std::string >(index); - - found_mnemonic_RESTART = mnemonic.find("RESTART="); - if (found_mnemonic_RESTART != std::string::npos) { - std::string restart_no = mnemonic.substr(found_mnemonic_RESTART+8, mnemonic.size()); - restart = boost::lexical_cast(restart_no); - handle_RPTSOL_RESTART = true; - } - } - - - /* If no RESTART mnemonic is found, either it is not present or we might - have an old data set containing integer controls instead of mnemonics. - Restart integer switch is integer control nr 7 */ - - if (found_mnemonic_RESTART == std::string::npos) { - if (item.size() >= 7) { - const std::string& integer_control = item.get< std::string >(6); - try { - restart = boost::lexical_cast(integer_control); - handle_RPTSOL_RESTART = true; - } catch (boost::bad_lexical_cast &) { - //do nothing - } - } - } - - if (handle_RPTSOL_RESTART) { - if (restart > 1) { - setWriteInitialRestartFile(true); - } else { - setWriteInitialRestartFile(false); - } - } - } boost::gregorian::date IOConfig::getTimestepDate(size_t reportStep) const { @@ -514,17 +175,6 @@ namespace Opm { } - void IOConfig::dumpRestartConfig() const { - for (size_t reportStep = 0; reportStep < m_timemap->size(); reportStep++) { - if (getWriteRestartFile(reportStep)) { - auto time = (*m_timemap)[reportStep]; - boost::gregorian::date date = time.date(); - printf("%04zu : %02hu/%02hu/%hu \n" , reportStep , - date.day().as_number() , date.month().as_number() , static_cast(date.year())); - } - } - } - std::string IOConfig::getRestartFileName(const std::string& restart_base, int report_step, bool output) const { bool unified = output ? getUNIFOUT() : getUNIFIN(); @@ -539,11 +189,6 @@ namespace Opm { } - int IOConfig::getFirstRestartStep() const { - return m_first_restart_step; - } - - int IOConfig::getFirstRFTStep() const { return m_first_rft_step; } @@ -556,7 +201,7 @@ namespace Opm { m_output_enabled = enabled; } - std::string IOConfig::getOutputDir() { + std::string IOConfig::getOutputDir() const { return m_output_dir; } @@ -572,4 +217,33 @@ namespace Opm { m_base_name = baseName; } + std::string IOConfig::fullBasePath( ) const { + namespace fs = boost::filesystem; + + fs::path dir( m_output_dir ); + fs::path base( m_base_name ); + fs::path full_path = dir.make_preferred() / base.make_preferred(); + + return full_path.string(); + } + + + bool IOConfig::initOnly( ) const { + return m_nosim; + } + + + /*****************************************************************/ + /* Here at the bottom are some forwarding proxy methods which just + forward to the appropriate RestartConfig method. They are + retained here as a temporary convenience method to prevent + downstream breakage. + + Currently the EclipseState object can return a mutable IOConfig + object, which application code can alter to override settings + from the deck - this is quite ugly. When the API is reworked to + remove the ability modify IOConfig objects we should also + remove these forwarding methods. + */ + } //namespace Opm diff --git a/ThirdParty/custom-opm-parser/opm-parser/opm/parser/eclipse/EclipseState/IOConfig/IOConfig.hpp b/ThirdParty/custom-opm-parser/opm-parser/opm/parser/eclipse/EclipseState/IOConfig/IOConfig.hpp index 9a5bf462f4..44c8d0d3d6 100644 --- a/ThirdParty/custom-opm-parser/opm-parser/opm/parser/eclipse/EclipseState/IOConfig/IOConfig.hpp +++ b/ThirdParty/custom-opm-parser/opm-parser/opm/parser/eclipse/EclipseState/IOConfig/IOConfig.hpp @@ -30,8 +30,6 @@ namespace Opm { class DeckKeyword; class GRIDSection; class RUNSPECSection; - class SCHEDULESection; - class SOLUTIONSection; class TimeMap; class Schedule; @@ -124,9 +122,8 @@ namespace Opm { explicit IOConfig( const Deck& ); explicit IOConfig( const std::string& input_path ); - int getFirstRestartStep() const; + int getFirstRFTStep() const; - bool getWriteRestartFile(size_t timestep) const; bool getWriteEGRIDFile() const; bool getWriteINITFile() const; bool getUNIFOUT() const; @@ -135,52 +132,40 @@ namespace Opm { bool getFMTOUT() const; const std::string& getEclipseInputPath() const; - void overrideRestartWriteInterval(size_t interval); + void overrideNOSIM(bool nosim); - void handleSolutionSection(std::shared_ptr< const TimeMap > timemap, std::shared_ptr solutionSection); - void setWriteInitialRestartFile(bool writeInitialRestartFile); - /// This method will internalize variables with information of - /// the first report step with restart and rft output - /// respectively. This information is important because right - /// at the first output step we must reset the files to size - /// zero, for subsequent output steps we should append. - void initFirstOutput(const Schedule& schedule); boost::gregorian::date getTimestepDate(size_t timestep) const; - void dumpRestartConfig() const; std::string getRestartFileName(const std::string& restart_base, int report_step, bool output) const; bool getOutputEnabled(); void setOutputEnabled(bool enabled); - std::string getOutputDir(); + std::string getOutputDir() const; void setOutputDir(const std::string& outputDir); const std::string& getBaseName() const; void setBaseName(std::string baseName); + /// Return a string consisting of outputpath and basename; + /// i.e. /path/to/sim/CASE + std::string fullBasePath( ) const; + + bool initOnly() const; + void initFirstRFTOutput(const Schedule& schedule); + + // Proxy methods forwarding directly to corresponding RestartConfig + bool getWriteRestartFile(size_t timestep) const; + int getFirstRestartStep() const; + void overrideRestartWriteInterval(size_t interval); + void setWriteInitialRestartFile(bool writeInitialRestartFile); + private: - - IOConfig( const GRIDSection&, - const RUNSPECSection&, - const SCHEDULESection&, - std::shared_ptr< const TimeMap >, - const std::string& input_path ); - - void assertTimeMap(std::shared_ptr< const TimeMap > timemap); - bool getWriteRestartFileFrequency(size_t timestep, - size_t start_timestep, - size_t frequency, - bool years = false, - bool months = false) const; - void handleRPTSOL( const DeckKeyword& keyword); - std::shared_ptr< const TimeMap > m_timemap; bool m_write_INIT_file = false; bool m_write_EGRID_file = true; - bool m_write_initial_RST_file = false; bool m_UNIFIN = false; bool m_UNIFOUT = false; bool m_FMTIN = false; @@ -191,57 +176,13 @@ namespace Opm { bool m_output_enabled = true; std::string m_output_dir; std::string m_base_name; + bool m_nosim; - struct restartConfig { - /* - The content of this struct is logically divided in two; either the - restart behaviour is governed by { timestep , basic , frequency }, or - alternatively by { rptshec_restart_set , rptsched_restart }. - - The former triplet is mainly governed by the RPTRST keyword and the - latter pair by the RPTSCHED keyword. - */ - size_t timestep = 0; - size_t basic = 0; - size_t frequency = 0; - bool rptsched_restart_set = false; - size_t rptsched_restart = 0; - - restartConfig() = default; - restartConfig( size_t sched_restart ) : - rptsched_restart_set( true ), - rptsched_restart( sched_restart ) - {} - - restartConfig( size_t step, size_t b, size_t freq ) : - timestep( step ), - basic( b ), - frequency( freq ) - {} - - bool operator!=(const restartConfig& rhs) const { - return !( *this == rhs ); - } - - bool operator==( const restartConfig& rhs ) const { - if( this->rptsched_restart_set ) { - return rhs.rptsched_restart_set - && this->rptsched_restart == rhs.rptsched_restart; - } - - return this->timestep == rhs.timestep && - this->basic == rhs.basic && - this->frequency == rhs.frequency; - } - }; - - static DynamicState< restartConfig > rstconf( const SCHEDULESection&, - std::shared_ptr< const TimeMap > ); - static restartConfig rptrst( const DeckKeyword&, size_t ); - static restartConfig rptsched( const DeckKeyword& ); - - std::shared_ptr> m_restart_output_config; - + IOConfig( const GRIDSection&, + const RUNSPECSection&, + std::shared_ptr< const TimeMap >, + bool nosim, + const std::string& input_path ); }; diff --git a/ThirdParty/custom-opm-parser/opm-parser/opm/parser/eclipse/EclipseState/IOConfig/RestartConfig.cpp b/ThirdParty/custom-opm-parser/opm-parser/opm/parser/eclipse/EclipseState/IOConfig/RestartConfig.cpp new file mode 100644 index 0000000000..4c034c8a5f --- /dev/null +++ b/ThirdParty/custom-opm-parser/opm-parser/opm/parser/eclipse/EclipseState/IOConfig/RestartConfig.cpp @@ -0,0 +1,650 @@ +/* + Copyright 2015 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 + +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + + + + +namespace Opm { + +namespace { + +inline bool is_int( const std::string& x ) { + auto is_digit = []( char c ) { return std::isdigit( c ); }; + + return !x.empty() + && ( x.front() == '-' || is_digit( x.front() ) ) + && std::all_of( x.begin() + 1, x.end(), is_digit ); +} + +constexpr const char* RSTIntegerKeywords[] = { "BASIC", // 1 + "FLOWS", // 2 + "FIP", // 3 + "POT", // 4 + "PBPD", // 5 + "FREQ", // 6 + "PRES", // 7 + "VISC", // 8 + "DEN", // 9 + "DRAIN", // 10 + "KRO", // 11 + "KRW", // 12 + "KRG", // 13 + "PORO", // 14 + "NOGRAD", // 15 + "NORST", // 16 NORST - not supported + "SAVE", // 17 + "SFREQ", // 18 SFREQ=?? - not supported + "ALLPROPS", // 19 + "ROCKC", // 20 + "SGTRAP", // 21 + "", // 22 - Blank - ignored. + "RSSAT", // 23 + "RVSAT", // 24 + "GIMULT", // 25 + "SURFBLK", // 26 + "", // 27 - PCOW, PCOG, special cased + "STREAM", // 28 STREAM=?? - not supported + "RK", // 29 + "VELOCITY", // 30 + "COMPRESS" }; // 31 + +constexpr const char* SCHEDIntegerKeywords[] = { "PRES", // 1 + "SOIL", // 2 + "SWAT", // 3 + "SGAS", // 4 + "RS", // 5 + "RV", // 6 + "RESTART", // 7 + "FIP", // 8 + "WELLS", // 9 + "VFPPROD", // 10 + "SUMMARY", // 11 + "CPU", // 12 + "AQUCT", // 13 + "WELSPECS",// 14 + "NEWTON", // 15 + "POILD", // 16 + "PWAT", // 17 + "PWATD", // 18 + "PGAS", // 19 + "PGASD", // 20 + "FIPVE", // 21 + "WOC", // 22 + "GOC", // 23 + "WOCDIFF", // 24 + "GOCDIFF", // 25 + "WOCGOC", // 26 + "ODGAS", // 27 + "ODWAT", // 28 + "GDOWAT", // 29 + "WDOGAS", // 30 + "OILAPI", // 31 + "FIPITR", // 32 + "TBLK", // 33 + "PBLK", // 34 + "SALT", // 35 + "PLYADS", // 36 + "RK", // 37 + "FIPSALT", // 38 + "TUNING", // 39 + "GI", // 40 + "ROCKC", // 41 + "SPENWAT", // 42 + "FIPSOL", // 43 + "SURFBLK", // 44 + "SURFADS", // 45 + "FIPSURF", // 46 + "TRADS", // 47 + "VOIL", // 48 + "VWAT", // 49 + "VGAS", // 50 + "DENO", // 51 + "DENW", // 52 + "DENG", // 53 + "GASCONC", // 54 + "PB", // 55 + "PD", // 56 + "KRW", // 57 + "KRO", // 58 + "KRG", // 59 + "MULT", // 60 + "UNKNOWN", // 61 61 and 62 are not listed in the manual + "UNKNOWN", // 62 + "FOAM", // 63 + "FIPFOAM", // 64 + "TEMP", // 65 + "FIPTEMP", // 66 + "POTC", // 67 + "FOAMADS", // 68 + "FOAMDCY", // 69 + "FOAMMOB", // 70 + "RECOV", // 71 + "FLOOIL", // 72 + "FLOWAT", // 73 + "FLOGAS", // 74 + "SGTRAP", // 75 + "FIPRESV", // 76 + "FLOSOL", // 77 + "KRN", // 78 + "GRAD", // 79 + }; + +bool is_RPTRST_mnemonic( const std::string& kw ) { + /* all eclipse 100 keywords we want to not simply ignore. The list is + * sorted, so we can use binary_search for log(n) lookup. It is important + * that the list is sorted, but these are all the keywords listed in the + * manual and unlikely to change at all + */ + static constexpr const char* valid[] = { + "ACIP", "ACIS", "ALLPROPS", "BASIC", "BG", "BO", + "BW", "CELLINDX", "COMPRESS", "CONV", "DEN", "DRAIN", + "DRAINAGE", "DYNREG", "FIP", "FLORES", "FLOWS", "FREQ", + "GIMULT", "HYDH", "HYDHFW", "KRG", "KRO", "KRW", + "NOGRAD", "NORST", "NPMREB", "PBPD", "PCOG", "PCOW", + "PERMREDN", "POIS", "PORO", "PORV", "POT", "PRES", + "RFIP", "RK", "ROCKC", "RPORV", "RSSAT", "RVSAT", + "SAVE", "SDENO", "SFIP", "SFREQ", "SGTRAP", "SIGM_MOD", + "STREAM", "SURFBLK", "TRAS", "VELGAS", "VELOCITY", "VELOIL", + "VELWAT", "VISC", + }; + + return std::binary_search( std::begin( valid ), std::end( valid ), kw ); +} + +bool is_RPTSCHED_mnemonic( const std::string& kw ) { + static constexpr const char* valid[] = { + "ALKALINE", "ANIONS", "AQUCT", "AQUFET", "AQUFETP", "BFORG", + "CATIONS", "CPU", "DENG", "DENO", "DENW", "ESALPLY", + "ESALSUR", "FFORG", "FIP", "FIPFOAM", "FIPHEAT", "FIPRESV", + "FIPSALT", "FIPSOL", "FIPSURF", "FIPTEMP", "FIPTR", "FIPVE", + "FLOGAS", "FLOOIL", "FLOSOL", "FLOWAT", "FMISC", "FOAM", + "FOAMADS", "FOAMCNM", "FOAMDCY", "FOAMMOB", "GASCONC", "GASSATC", + "GDOWAT", "GI", "GOC", "GOCDIFF", "GRAD", "KRG", + "KRN", "KRO", "KRW", "MULT", "NEWTON", "NOTHING", + "NPMREB", "ODGAS", "ODWAT", "OILAPI", "PB", "PBLK", + "PBU", "PD", "PDEW", "PGAS", "PGASD", "PLYADS", + "POIL", "POILD", "POLYMER", "POTC", "POTG", "POTO", + "POTW", "PRES", "PRESSURE", "PWAT", "PWATD", "RECOV", + "RESTART", "ROCKC", "RS", "RSSAT", "RV", "RVSAT", + "SALT", "SGAS", "SGTRAP", "SIGM_MOD", "SOIL", "SSOL", + "SUMMARY", "SURFADS", "SURFBLK", "SWAT", "TBLK", "TEMP", + "TRACER", "TRADS", "TRDCY", "TUNING", "VFPPROD", "VGAS", + "VOIL", "VWAT", "WDOGAS", "WELLS", "WELSPECL", "WELSPECS", + "WOC", "WOCDIFF", "WOCGOC", + }; + + return std::binary_search( std::begin( valid ), std::end( valid ), kw ); +} + +} + + RestartSchedule::RestartSchedule( size_t sched_restart) : + rptsched_restart_set( true ), + rptsched_restart( sched_restart ) + { + } + + RestartSchedule::RestartSchedule( size_t step, size_t b, size_t freq) : + timestep( step ), + basic( b ), + frequency( basic > 2 ? std::max( freq, size_t{ 1 } ) : freq ) + { + /* + * if basic > 2 and freq is default (zero) we're looking at an error + * (every Nth step where N = 0). Instead of throwing we default this to + * 1 so that basic > 2 and freq unset essentially is + * write-every-timestep. It could've just as easily been an exception, + * but to be more robust handling poorly written decks we instead set a + * reasonable default and carry on. + */ + } + + bool RestartSchedule::operator!=(const RestartSchedule & rhs) const { + return !( *this == rhs ); + } + + bool RestartSchedule::operator==( const RestartSchedule& rhs ) const { + if( this->rptsched_restart_set ) { + return rhs.rptsched_restart_set + && this->rptsched_restart == rhs.rptsched_restart; + } + + return this->timestep == rhs.timestep && + this->basic == rhs.basic && + this->frequency == rhs.frequency; + } + +inline std::map< std::string, int > +RPTRST_integer( const std::vector< int >& ints ) { + const size_t PCO_index = 26; + const size_t BASIC_index = 0; + + std::map< std::string, int > mnemonics; + const size_t size = std::min( ints.size(), sizeof( RSTIntegerKeywords ) ); + + /* fun with special cases. Eclipse seems to ignore the BASIC=0, + * interpreting it as sort-of "don't modify". Handle this by *not* + * adding/updating the integer list sourced BASIC mnemonic, should it be + * zero. I'm not sure if this applies to other mnemonics, but the eclipse + * manual indicates that any zero here should disable the output. + * + * See https://github.com/OPM/opm-parser/issues/886 for reference + */ + if( size > 0 && ints[ BASIC_index ] != 0 ) + mnemonics[ RSTIntegerKeywords[ BASIC_index ] ] = ints[ BASIC_index ]; + + for( size_t i = 1; i < std::min( size, PCO_index ); ++i ) + mnemonics[ RSTIntegerKeywords[ i ] ] = ints[ i ]; + + for( size_t i = PCO_index + 1; i < size; ++i ) + mnemonics[ RSTIntegerKeywords[ i ] ] = ints[ i ]; + + /* item 27 (index 26) sets both PCOW and PCOG, so we special case it */ + if( ints.size() >= PCO_index ) { + mnemonics[ "PCOW" ] = ints[ PCO_index ]; + mnemonics[ "PCOG" ] = ints[ PCO_index ]; + } + + return std::move( mnemonics ); +} + +inline std::map< std::string, int > +RPTSCHED_integer( const std::vector< int >& ints ) { + const size_t size = std::min( ints.size(), sizeof( SCHEDIntegerKeywords ) ); + + std::map< std::string, int > mnemonics; + for( size_t i = 0; i < size; ++i ) + mnemonics[ SCHEDIntegerKeywords[ i ] ] = ints[ i ]; + + return std::move( mnemonics ); +} + +template< typename F, typename G > +inline std::map< std::string, int > RPT( const DeckKeyword& keyword, + F is_mnemonic, + G integer_mnemonic ) { + + const auto& items = keyword.getStringData(); + const auto ints = std::any_of( items.begin(), items.end(), is_int ); + const auto strs = !std::all_of( items.begin(), items.end(), is_int ); + + /* if any of the values are pure integers we assume this is meant to be + * the slash-terminated list of integers way of configuring. If + * integers and non-integers are mixed, this is an error. + */ + if( ints && strs ) throw std::runtime_error( + "RPTRST does not support mixed mnemonics and integer list." + ); + + auto stoi = []( const std::string& str ) { return std::stoi( str ); }; + if( ints ) + return integer_mnemonic( fun::map( stoi, items ) ); + + std::map< std::string, int > mnemonics; + + for( const auto& mnemonic : items ) { + const auto pos = mnemonic.find( '=' ); + + std::string base = mnemonic.substr( 0, pos ); + if( !is_mnemonic( base ) ) continue; + + const int val = pos != std::string::npos + ? std::stoi( mnemonic.substr( pos + 1 ) ) + : 1; + + mnemonics.emplace( base, val ); + } + + return std::move( mnemonics ); +} + +void expand_RPTRST_mnemonics(std::map< std::string, int >& mnemonics) { + const auto allprops = mnemonics.find( "ALLPROPS"); + if (allprops != mnemonics.end()) { + const auto value = allprops->second; + mnemonics.erase( "ALLPROPS" ); + + for (const auto& kw : {"BG","BO","BW","KRG","KRO","KRW","VOIL","VGAS","VWAT","DEN"}) + mnemonics[kw] = value; + + } +} + + +inline std::pair< std::map< std::string, int >, RestartSchedule > +RPTRST( const DeckKeyword& keyword, RestartSchedule prev, size_t step ) { + auto mnemonics = RPT( keyword, is_RPTRST_mnemonic, RPTRST_integer ); + + const bool has_freq = mnemonics.find( "FREQ" ) != mnemonics.end(); + const bool has_basic = mnemonics.find( "BASIC" ) != mnemonics.end(); + + expand_RPTRST_mnemonics( mnemonics ); + + if( !has_freq && !has_basic ) return { std::move( mnemonics ), {} }; + + const auto basic = has_basic ? mnemonics.at( "BASIC" ) : prev.basic; + const auto freq = has_freq ? mnemonics.at( "FREQ" ) : prev.frequency; + + return { std::move( mnemonics ), { step, basic, freq } }; +} + +inline std::pair< std::map< std::string, int >, RestartSchedule > +RPTSCHED( const DeckKeyword& keyword ) { + auto mnemonics = RPT( keyword, is_RPTSCHED_mnemonic, RPTSCHED_integer ); + + if( mnemonics.count( "NOTHING" ) ) + return { std::move( mnemonics ), { 0 } }; + + if( mnemonics.count( "RESTART" ) ) + return { std::move( mnemonics ), size_t( mnemonics.at( "RESTART" ) ) }; + + return { std::move( mnemonics ), {} }; +} + + + +void RestartConfig::handleScheduleSection(const SCHEDULESection& schedule) { + size_t current_step = 1; + RestartSchedule unset; + + auto ignore_RPTSCHED_RESTART = []( decltype( restart_schedule )& x ) { + return x.back().basic > 2; + }; + + for( const auto& keyword : schedule ) { + const auto& name = keyword.name(); + + if( name == "DATES" ) { + current_step += keyword.size(); + continue; + } + + if( name == "TSTEP" ) { + current_step += keyword.getRecord( 0 ).getItem( 0 ).size(); + continue; + } + + if( !( name == "RPTRST" || name == "RPTSCHED" ) ) continue; + if( this->m_timemap->size() <= current_step ) continue; + + const bool is_RPTRST = name == "RPTRST"; + const auto& prev_sched = this->restart_schedule.back(); + + auto config = is_RPTRST + ? RPTRST( keyword, prev_sched, current_step ) + : RPTSCHED( keyword ); + + /* add the missing entries from the previous step */ + { + auto& mnemonics = config.first; + const auto& prev_mnemonics = this->restart_keywords.back(); + mnemonics.insert( prev_mnemonics.begin(), prev_mnemonics.end() ); + + if( mnemonics.find( "NOTHING" ) != mnemonics.end() ) + mnemonics.clear(); + + this->restart_keywords.update( current_step , mnemonics ); + } + const bool ignore_RESTART = + !is_RPTRST && ignore_RPTSCHED_RESTART( this->restart_schedule ); + + const auto& rs = config.second; + if( rs == unset || ignore_RESTART ) continue; + + if( 6 == rs.rptsched_restart || 6 == rs.basic ) + throw std::runtime_error( + "OPM does not support the RESTART=6 setting " + "(write restart file every timestep)" + ); + + this->restart_schedule.update( current_step, rs ); + } +} + + bool RestartSchedule::writeRestartFile( size_t input_timestep , const TimeMap& timemap) const { + if (this->rptsched_restart_set && (this->rptsched_restart > 0)) + return true; + + switch (basic) { + //Do not write restart files + case 0: return false; + + //Write restart file every report time + case 1: return true; + + //Write restart file every report time + case 2: return true; + + //Every n'th report time + case 3: return ((input_timestep % this->frequency) == 0) ? true : false; + + //First reportstep of every year, or if n > 1, n'th years + case 4: return timemap.isTimestepInFirstOfMonthsYearsSequence(input_timestep, true , this->timestep, this->frequency); + + //First reportstep of every month, or if n > 1, n'th months + case 5: return timemap.isTimestepInFirstOfMonthsYearsSequence(input_timestep, false , this->timestep, this->frequency); + + default: return false; + } + } + + + + RestartConfig::RestartConfig( const Deck& deck ) : + RestartConfig( SCHEDULESection( deck ), + SOLUTIONSection( deck ), + std::make_shared< const TimeMap >( deck )) + {} + + + RestartConfig::RestartConfig( const SCHEDULESection& schedule, + const SOLUTIONSection& solution, + std::shared_ptr< const TimeMap > timemap) : + m_timemap( timemap ), + m_first_restart_step( -1 ), + restart_schedule( timemap, { 0, 0, 1 } ), + restart_keywords( timemap, {} ) + { + handleSolutionSection( solution ); + handleScheduleSection( schedule ); + + initFirstOutput( ); + } + + + RestartSchedule RestartConfig::getNode( size_t timestep ) const{ + return restart_schedule.get(timestep); + } + + + bool RestartConfig::getWriteRestartFile(size_t timestep) const { + if (0 == timestep) + return m_write_initial_RST_file; + + { + RestartSchedule ts_restart_config = getNode( timestep ); + return ts_restart_config.writeRestartFile( timestep , *m_timemap ); + } + } + + + const std::map< std::string, int >& RestartConfig::getRestartKeywords( size_t timestep ) const { + return restart_keywords.at( timestep ); + } + + + int RestartConfig::getKeyword( const std::string& keyword, size_t timeStep) const { + const std::map< std::string, int >& keywords = this->getRestartKeywords( timeStep ); + const auto iter = keywords.find( keyword ); + if (iter == keywords.end()) { + if (is_RPTRST_mnemonic( keyword )) + return 0; + else + throw std::invalid_argument("The mnenomic " + keyword + " is not recognized"); + } else + return iter->second; + } + + /* + Will initialize the internal variable holding the first report + step when restart output is queried. + + The reason we are interested in this report step is that when we + reach this step the output files should be opened with mode 'w' + - whereas for subsequent steps they should be opened with mode + 'a'. + */ + + void RestartConfig::initFirstOutput( ) { + size_t report_step = 0; + while (true) { + if (getWriteRestartFile(report_step)) { + m_first_restart_step = report_step; + break; + } + report_step++; + if (report_step == m_timemap->size()) + break; + } + } + + + void RestartConfig::handleSolutionSection(const SOLUTIONSection& solutionSection) { + if (solutionSection.hasKeyword("RPTRST")) { + const auto& rptrstkeyword = solutionSection.getKeyword("RPTRST"); + + const auto rptrst = RPTRST( rptrstkeyword, {}, 0 ); + this->restart_keywords.updateInitial( rptrst.first ); + this->restart_schedule.updateInitial( rptrst.second ); + setWriteInitialRestartFile(true); // Guessing on eclipse rules for write of initial RESTART file (at time 0): + // Write of initial restart file is (due to the eclipse reference manual) + // governed by RPTSOL RESTART in solution section, + // if RPTSOL RESTART > 1 initial restart file is written. + // but - due to initial restart file written from Eclipse + // for data where RPTSOL RESTART not set - guessing that + // when RPTRST is set in SOLUTION (no basic though...) -> write inital restart. + } //RPTRST + + + if (solutionSection.hasKeyword("RPTSOL") && (m_timemap->size() > 0)) { + handleRPTSOL(solutionSection.getKeyword("RPTSOL")); + } //RPTSOL + } + + + void RestartConfig::overrideRestartWriteInterval(size_t interval) { + size_t step = 0; + /* write restart files if the interval is non-zero. The restart + * mnemonic (setting) that governs restart-on-interval is BASIC=3 + */ + size_t basic = interval > 0 ? 3 : 0; + + RestartSchedule rs( step, basic, interval ); + restart_schedule.globalReset( rs ); + + setWriteInitialRestartFile( interval > 0 ); + } + + + void RestartConfig::setWriteInitialRestartFile(bool writeInitialRestartFile) { + m_write_initial_RST_file = writeInitialRestartFile; + } + + + void RestartConfig::handleRPTSOL( const DeckKeyword& keyword) { + const auto& record = keyword.getRecord(0); + + size_t restart = 0; + size_t found_mnemonic_RESTART = 0; + bool handle_RPTSOL_RESTART = false; + + const auto& item = record.getItem(0); + + for (size_t index = 0; index < item.size(); ++index) { + const std::string& mnemonic = item.get< std::string >(index); + + found_mnemonic_RESTART = mnemonic.find("RESTART="); + if (found_mnemonic_RESTART != std::string::npos) { + std::string restart_no = mnemonic.substr(found_mnemonic_RESTART+8, mnemonic.size()); + restart = boost::lexical_cast(restart_no); + handle_RPTSOL_RESTART = true; + } + } + + + /* If no RESTART mnemonic is found, either it is not present or we might + have an old data set containing integer controls instead of mnemonics. + Restart integer switch is integer control nr 7 */ + + if (found_mnemonic_RESTART == std::string::npos) { + if (item.size() >= 7) { + const std::string& integer_control = item.get< std::string >(6); + try { + restart = boost::lexical_cast(integer_control); + handle_RPTSOL_RESTART = true; + } catch (boost::bad_lexical_cast &) { + //do nothing + } + } + } + + if (handle_RPTSOL_RESTART) { + if (restart > 1) { + setWriteInitialRestartFile(true); + } else { + setWriteInitialRestartFile(false); + } + } + } + + + + std::string RestartConfig::getRestartFileName(const std::string& restart_base, int report_step, bool unified , bool fmt_file) { + + ecl_file_enum file_type = (unified) ? ECL_UNIFIED_RESTART_FILE : ECL_RESTART_FILE; + char * c_str = ecl_util_alloc_filename( NULL , restart_base.c_str() , file_type, fmt_file , report_step); + std::string restart_filename = c_str; + free( c_str ); + + return restart_filename; + } + + + int RestartConfig::getFirstRestartStep() const { + return m_first_restart_step; + } + +} diff --git a/ThirdParty/custom-opm-parser/opm-parser/opm/parser/eclipse/EclipseState/IOConfig/RestartConfig.hpp b/ThirdParty/custom-opm-parser/opm-parser/opm/parser/eclipse/EclipseState/IOConfig/RestartConfig.hpp new file mode 100644 index 0000000000..83b015b187 --- /dev/null +++ b/ThirdParty/custom-opm-parser/opm-parser/opm/parser/eclipse/EclipseState/IOConfig/RestartConfig.hpp @@ -0,0 +1,375 @@ +/* + Copyright 2015 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_RESTART_CONFIG_HPP +#define OPM_RESTART_CONFIG_HPP + +#include +#include +#include +#include + +/* + The RestartConfig class internalizes information of when (at which + report steps) we should save restart files, and which properties + should be included in the restart files. The configuration of this + immensely complex, and this code is unfortunately also way too + complex. + + The most basic question to disentangle is the "When to write restart + files" versus "What data to store write in the restart file". As + expressed in the deck keywords this completely entangled, in this + implementation we have tried to disentangle it: + + Keywords involved + ----------------- + + RPTRST: This is the main keyword for configuring restart output; it + can be used to configure bothe when to write the files and which + properties should be included in the restart files. + + + RPTSCHED: The main purpose of the RPTSCHED keyword is to configure + output from the SCHEDULE section to the PRINT file. However the + mneomnic RESTART=n can be used to turn writing of restart files + on, and also for values > 2 to some configuration of what is + written to the restart file: + + RESTART=1 : As RPTRST,BASIC=1 + RESTART>1 : As RPTRST,BASIC=2 + RESTART>2 : Flow is added to restart file + RESTART>3 : Fluid in place is added to restart file + RESTART=6 : Restart file for every timestep. + + + + RPTSOL: The RPTSOL keyword is very similar to the RPTCHED keyword, + it configures output from the SOLUTION section to the PRINT file, + but just as the RPTSCHED keyword it accepts a RESTART=n mnenonic + which can be used similarly to the BASIC=n mnenonic of the RPTRST + keyword. In particular the writing of an initial restart files + with initial equilibrium solution is controlled by the RPTSOL + keyword. If the restart mneonic is greater than 2 that can be + used to configure FLOWS and FIP keywords in the restart file. + + RESTART=1 : As RPTRST,BASIC=1 + RESTART>1 : As RPTRST,BASIC=2 + RESTART>2 : Flow is added to restart file + RESTART>3 : Fluid in place is added to restart file + + + The basic rule in ECLIPSE is generally that the 'last keyword wins', + but for the RPTRST RPTSHCED combination a BASIC setting with n >= 3 + will override consecutive RESTART=n settings from RPTSCHED. + + + When to write restart files: + ---------------------------- + + When to write the restart file is governed by the BASIC=n setting in + the RPTRST keyword and the RESTART=n settings in the RPTSOL and + RPTSCHED keywords. The most common setting is 'ON' - i.e. BASIC=2 + which means write a restart file for every report step, that can be + turned off again with BASIC=0. For BASIC>2 there are varietes of + every n'th report step, and the first report step in every month and + every year. + + + Old style / new style + --------------------- + + All of the relevant keywords can be specified using a new style + based on string mneomnics and alternatively an old style represented + with a *strictly ordered* list of integers. For instance both of + these keywords request restart files written for every report step; + in addition to the fields required to actually restart the files + should contain the relative permeabilities KRO, KRW, KRG: + + RPTRST + BASIC=2 KRG KRW KRO / + + + RPTRST + 2 9*0 3*1 17*0 + + Integer controls and string mneomnics can not be mixed in the same + keyword, but they can be mixed in the same deck - and that is + actually quite common. + + + What is written to the restart file + ----------------------------------- + + The BASIC=n mneonics request the writing of a restart file which + should contain 'all properties required to restart', in addition you + can configure extra keywords to be added to the restart file. This + is configured by just adding a list as: + + RPTRST + BASIC=2 KRG KRW KRO / + + It is really *not clear* what is the correct persistence semantics + for these keywords, consider for insance the following series of keywords: + + -- Request restart file at every report step, the restart files + -- should contain additional properties KRO, KRG and KRW. + RPTRST + BASIC=2 KRG KRW KRO / + + -- Advance the simulator forward with TSTEP / DATES + TSTEP / DATES / WCONxxx + + -- Turn writing of restart files OFF using integer controls. + RPTRST + 0 / + + -- Advance the simulator forward with TSTEP / DATES + TSTEP / DATES / WCONxxx + + -- Turn writing of restart files ON using integer controls. + RPTRST + 2 / + + When writing of restart files is turned on again with the last + RPTRST keyword, should still the relative permeabilites KRO, KRW and + KRG be added to the restart files? The model we have implemented is: + + - The list of keywords written to the restart file is persisted + independtly of the BASIC=n setting. + + - Using string based mnonics you can *only add* kewyords to be + written to the files. To stop writing a keyword you must use an + integer control with value 0. + + Based on this best guess heuristic the final restart files will + still contain KRO, KRW and KRG. + + + + What is required to restart? + ---------------------------- + + A restart capable files is requested with the 'BASIC' mneomnic, but + exactly which properties the 'BASIC' keyword is expanded to is the + responsability of the simulator; i.e. for a black oil simulation you + will at the very least need the expansion: + + BASIC -> PRESSURE, SWAT, SGAS, RS, RV + + But this class just carries the boolean information: Yes - restart + is requested - expanding as illustrated is the responsability of the + simulator. + + + + + What is not supported? + ---------------------- + + The SAVE keyword is not supported in OPM at all, this implies that + the SAVE and SFREQ mneomics are not supported. +*/ + + + +namespace Opm { + + template< typename > class DynamicState; + + class Deck; + class DeckKeyword; + class GRIDSection; + class RUNSPECSection; + class SCHEDULESection; + class SOLUTIONSection; + class TimeMap; + class Schedule; + + + /*The IOConfig class holds data about input / ouput configurations + + Amongst these configuration settings, a IOConfig object knows if + a restart file should be written for a specific report step + + The write of restart files is governed by several eclipse keywords. + These keywords are all described in the eclipse manual, but some + of them are rather porly described there. + To have equal sets of restart files written from Eclipse and Flow for various + configurations, we have made a qualified guess on the behaviour + for some of the keywords (by running eclipse for different configurations, + and looked at which restart files that have been written). + + + ------ RPTSOL RESTART (solution section) ------ + If RPTSOL RESTART > 1 initial restart file is written. + + + ------ RPTRST (solution section) ------ + Eclipse manual states that the initial restart file is to be written + if RPTSOL RESTART > 1. But - due to that the initial restart file + is written from Eclipse for data where RPTSOL RESTART is not set, - we + have made a guess that when RPTRST is set in SOLUTION (no basic though...), + it means that the initial restart file should be written. + Running of eclipse with different settings have proven this to be a qualified guess. + + + ------ RPTRST BASIC=0 (solution or schedule section) ------ + No restart files are written + + + ------ RPTRST BASIC=1 or RPTRST BASIC=2 (solution or schedule section) ------ + Restart files are written for every timestep, from timestep 1 to number of timesteps. + (Write of inital timestep is governed by a separate setting) + + Notice! Eclipse simulator RPTRST BASIC=1 writes restart files for every + report step, but only keeps the last one written. This functionality is + not supported in Flow; so to compare Eclipse results with Flow results + for every report step, set RPTRST BASIC=2 for the eclipse run + + + ------ RPTRST BASIC=3 FREQ=n (solution or schedule section) ------ + Restart files are created every nth report time. Default frequency is 1 (every report step) + + If a frequency higher than 1 is given: + start_rs = report step the setting was given. + write report step rstep if (rstep >= start_rs) && ((rstep % frequency) == 0). + + + ------ RPTRST BASIC=4 FREQ=n or RPTRST BASIC=5 FREQ=n (solution or schedule section) ------ + For the settings BASIC 4 or BASIC 5, - first report step of every new year(4) or new month(5), + the first report step is compared with report step 0 (start), and then every report step is + compared with the previous one to see if year/month has changed. + + This leaves us with a set of timesteps. + All timesteps in the set that are higher or equal to the timestep the RPTRST keyword was set on is written. + + If in addition FREQUENCY is given (higher than 1), every n'the value of this set are to be written. + + If the setting BASIC=4 or BASIC=5 is set on a timestep that is a member of the set "first timestep of + each year" / "First timestep of each month", then the timestep that is freq-1 timesteps (within the set) from + this start timestep will be written, and then every n'the timestep (within the set) from this one will be written. + + If the setting BASIC=4 or BASIC=5 is set on a timestep that is not a member of the list "first timestep of + each year" / "First timestep of each month", then the list is searched for the closest timestep that are + larger than the timestep that introduced the setting, and then; same as above - the timestep that is freq-1 + timesteps from this one (within the set) will be written, and then every n'the timestep (within the set) from + this one will be written. + + + ------ RPTRST BASIC=6 (solution or schedule section) ------ + Not supported in Flow + + + ------ Default ------ + If no keywords for config of writing restart files have been handled; no restart files are written. + + */ + + //namespace { + + class RestartSchedule { + /* + The content of this struct is logically divided in two; either the + restart behaviour is governed by { timestep , basic , frequency }, or + alternatively by { rptshec_restart_set , rptsched_restart }. + + The former triplet is mainly governed by the RPTRST keyword and the + latter pair by the RPTSCHED keyword. + */ + public: + + RestartSchedule() = default; + RestartSchedule( size_t sched_restart); + RestartSchedule( size_t step, size_t b, size_t freq); + bool writeRestartFile( size_t timestep , const TimeMap& timemap) const; + bool operator!=(const RestartSchedule& rhs) const; + bool operator==( const RestartSchedule& rhs ) const; + + + + //private: + size_t timestep = 0; + size_t basic = 0; + size_t frequency = 0; + bool rptsched_restart_set = false; + size_t rptsched_restart = 0; + }; + // } + + class RestartConfig { + + public: + + RestartConfig(); + explicit RestartConfig( const Deck& ); + RestartConfig( const SCHEDULESection& schedule, + const SOLUTIONSection& solution, + std::shared_ptr< const TimeMap > timemap); + + + int getFirstRestartStep() const; + bool getWriteRestartFile(size_t timestep) const; + const std::map< std::string, int >& getRestartKeywords( size_t timestep ) const; + int getKeyword( const std::string& keyword, size_t timeStep) const; + + void overrideRestartWriteInterval(size_t interval); + void handleSolutionSection(const SOLUTIONSection& solutionSection); + void setWriteInitialRestartFile(bool writeInitialRestartFile); + + boost::gregorian::date getTimestepDate(size_t reportStep) const { + auto time = (*m_timemap)[reportStep]; + return time.date(); + } + + RestartSchedule getNode( size_t timestep ) const; + static std::string getRestartFileName(const std::string& restart_base, int report_step, bool unified, bool fmt_file); + private: + + + + /// This method will internalize variables with information of + /// the first report step with restart and rft output + /// respectively. This information is important because right + /// at the first output step we must reset the files to size + /// zero, for subsequent output steps we should append. + void initFirstOutput( ); + + bool getWriteRestartFileFrequency(size_t timestep, + size_t start_timestep, + size_t frequency, + bool years = false, + bool months = false) const; + void handleRPTSOL( const DeckKeyword& keyword); + + std::shared_ptr< const TimeMap > m_timemap; + int m_first_restart_step; + bool m_write_initial_RST_file = false; + + void handleScheduleSection( const SCHEDULESection& schedule); + void update( size_t step, const RestartSchedule& rs); + static RestartSchedule rptsched( const DeckKeyword& ); + + DynamicState< RestartSchedule > restart_schedule; + DynamicState< std::map< std::string, int > > restart_keywords; + }; +} //namespace Opm + + + +#endif diff --git a/ThirdParty/custom-opm-parser/opm-parser/opm/parser/eclipse/EclipseState/IOConfig/tests/CMakeLists.txt b/ThirdParty/custom-opm-parser/opm-parser/opm/parser/eclipse/EclipseState/IOConfig/tests/CMakeLists.txt index eb90f66c2b..f43bdb387d 100644 --- a/ThirdParty/custom-opm-parser/opm-parser/opm/parser/eclipse/EclipseState/IOConfig/tests/CMakeLists.txt +++ b/ThirdParty/custom-opm-parser/opm-parser/opm/parser/eclipse/EclipseState/IOConfig/tests/CMakeLists.txt @@ -1,2 +1,5 @@ opm_add_test(runIOConfigTests SOURCES IOConfigTest.cpp LIBRARIES opmparser ${Boost_LIBRARIES}) + +opm_add_test(runRestartConfigTests SOURCES RestartConfigTests.cpp + LIBRARIES opmparser ${Boost_LIBRARIES}) diff --git a/ThirdParty/custom-opm-parser/opm-parser/opm/parser/eclipse/EclipseState/IOConfig/tests/IOConfigTest.cpp b/ThirdParty/custom-opm-parser/opm-parser/opm/parser/eclipse/EclipseState/IOConfig/tests/IOConfigTest.cpp index 5d9237ff3f..0ca00560b3 100644 --- a/ThirdParty/custom-opm-parser/opm-parser/opm/parser/eclipse/EclipseState/IOConfig/tests/IOConfigTest.cpp +++ b/ThirdParty/custom-opm-parser/opm-parser/opm/parser/eclipse/EclipseState/IOConfig/tests/IOConfigTest.cpp @@ -162,638 +162,11 @@ static DeckPtr createDeck(const std::string& input) { BOOST_AUTO_TEST_CASE( RFT_TIME) { DeckPtr deck = createDeck(deckStr_RFT); - EclipseState state( deck , Opm::ParseContext() ); - std::shared_ptr ioConfig = state.getIOConfigConst(); + EclipseState state( *deck , Opm::ParseContext() ); + const IOConfig& ioConfig = state.cfg().io(); - BOOST_CHECK_EQUAL( ioConfig->getFirstRFTStep() , 2 ); -} - -BOOST_AUTO_TEST_CASE(RPTRST_mixed_mnemonics_int_list) { - const char* data = "RUNSPEC\n" - "DIMENS\n" - " 10 10 10 /\n" - "GRID\n" - "START -- 0 \n" - "19 JUN 2007 / \n" - "SCHEDULE\n" - "DATES -- 1\n" - " 10 OKT 2008 / \n" - "/\n" - "RPTRST\n" - "BASIC=3 0 1 2\n" - "/\n" - "DATES -- 2\n" - " 20 JAN 2010 / \n" - "/\n" - "DATES -- 3\n" - " 20 FEB 2010 / \n" - "/\n" - "RPTSCHED\n" - "BASIC=1\n" - "/\n"; - - auto deck = Parser().parseString( data, ParseContext() ); - BOOST_CHECK_THROW( IOConfig c( *deck ), std::runtime_error ); -} - -BOOST_AUTO_TEST_CASE(RPTRST) { - - const char *deckData1 = - "RUNSPEC\n" - "DIMENS\n" - " 10 10 10 /\n" - "GRID\n" - "START -- 0 \n" - "19 JUN 2007 / \n" - "SCHEDULE\n" - "DATES -- 1\n" - " 10 OKT 2008 / \n" - "/\n" - "RPTRST\n" - "BASIC=1\n" - "/\n" - "DATES -- 2\n" - " 20 JAN 2010 / \n" - "/\n"; - - const char *deckData2 = - "RUNSPEC\n" - "DIMENS\n" - " 10 10 10 /\n" - "GRID\n" - "START -- 0 \n" - "19 JUN 2007 / \n" - "SCHEDULE\n" - "DATES -- 1\n" - " 10 OKT 2008 / \n" - "/\n" - "RPTRST\n" - "BASIC=3 FREQ=2 RUBBISH=5\n" - "/\n" - "DATES -- 2\n" - " 20 JAN 2010 / \n" - "/\n" - "DATES -- 3\n" - " 20 JAN 2011 / \n" - "/\n"; - - const char *deckData3 = - "RUNSPEC\n" - "DIMENS\n" - " 10 10 10 /\n" - "GRID\n" - "START -- 0 \n" - "19 JUN 2007 / \n" - "SCHEDULE\n" - "DATES -- 1\n" - " 10 OKT 2008 / \n" - "/\n" - "RPTRST\n" - "3 0 0 0 0 2\n" - "/\n" - "DATES -- 2\n" - " 20 JAN 2010 / \n" - "/\n" - "DATES -- 3\n" - " 20 JAN 2011 / \n" - "/\n"; - - Opm::Parser parser; - ParseContext ctx; - - auto deck1 = parser.parseString( deckData1, ctx ); - IOConfig ioConfig1( *deck1 ); - - BOOST_CHECK( !ioConfig1.getWriteRestartFile( 0 ) ); - BOOST_CHECK( !ioConfig1.getWriteRestartFile( 1 ) ); - BOOST_CHECK( ioConfig1.getWriteRestartFile( 2 ) ); - - - auto deck2 = parser.parseString( deckData2, ctx ); - IOConfig ioConfig2( *deck2 ); - - BOOST_CHECK( !ioConfig2.getWriteRestartFile( 0 ) ); - BOOST_CHECK( !ioConfig2.getWriteRestartFile( 1 ) ); - BOOST_CHECK( ioConfig2.getWriteRestartFile( 2 ) ); - BOOST_CHECK( !ioConfig2.getWriteRestartFile( 3 ) ); - - auto deck3 = parser.parseString( deckData3, ctx ); - IOConfig ioConfig3( *deck3 ); - - BOOST_CHECK( !ioConfig3.getWriteRestartFile( 0 ) ); - BOOST_CHECK( !ioConfig3.getWriteRestartFile( 1 ) ); - BOOST_CHECK( ioConfig3.getWriteRestartFile( 2 ) ); - BOOST_CHECK( !ioConfig3.getWriteRestartFile( 3 ) ); -} - -BOOST_AUTO_TEST_CASE(RPTSCHED) { - - const char *deckData1 = - "RUNSPEC\n" - "DIMENS\n" - " 10 10 10 /\n" - "GRID\n" - "START -- 0 \n" - "19 JUN 2007 / \n" - "SCHEDULE\n" - "DATES -- 1\n" - " 10 OKT 2008 / \n" - "/\n" - "RPTSCHED\n" - "RESTART=1\n" - "/\n" - "DATES -- 2\n" - " 20 JAN 2010 / \n" - "/\n" - "DATES -- 3\n" - " 20 FEB 2010 / \n" - "/\n" - "RPTSCHED\n" - "RESTART=0\n" - "/\n"; - - - const char *deckData2 = - "RUNSPEC\n" - "DIMENS\n" - " 10 10 10 /\n" - "GRID\n" - "START -- 0 \n" - "19 JUN 2007 / \n" - "SCHEDULE\n" - "DATES -- 1\n" - " 10 OKT 2008 / \n" - "/\n" - "RPTSCHED\n" - "RESTART=1\n" - "/\n" - "DATES -- 2\n" - " 20 JAN 2010 / \n" - "/\n" - "DATES -- 3\n" - " 20 FEB 2010 / \n" - "/\n" - "RPTSCHED\n" - "NOTHING RUBBISH\n" - "/\n"; - - const char *deckData3 = - "RUNSPEC\n" - "DIMENS\n" - " 10 10 10 /\n" - "GRID\n" - "START -- 0 \n" - "19 JUN 2007 / \n" - "SCHEDULE\n" - "DATES -- 1\n" - " 10 OKT 2008 / \n" - "/\n" - "RPTRST\n" - "BASIC=3 FREQ=1 RUBBISH=5\n" - "/\n" - "DATES -- 2\n" - " 20 JAN 2010 / \n" - "/\n" - "DATES -- 3\n" - " 20 FEB 2010 / \n" - "/\n" - "RPTSCHED\n" - "0 0 0 0 0 0 0 0\n" - "/\n"; - - Parser parser; - ParseContext ctx; - - auto deck1 = parser.parseString( deckData1, ctx ); - IOConfig ioConfig1( *deck1 ); - - BOOST_CHECK( !ioConfig1.getWriteRestartFile( 0 ) ); - BOOST_CHECK( !ioConfig1.getWriteRestartFile( 1 ) ); - BOOST_CHECK( ioConfig1.getWriteRestartFile( 2 ) ); - BOOST_CHECK( ioConfig1.getWriteRestartFile( 3 ) ); - - - auto deck2 = parser.parseString( deckData2, ctx ); - IOConfig ioConfig2( *deck2 ); - - BOOST_CHECK( !ioConfig2.getWriteRestartFile( 0 ) ); - BOOST_CHECK( !ioConfig2.getWriteRestartFile( 1 ) ); - BOOST_CHECK( ioConfig2.getWriteRestartFile( 2 ) ); - BOOST_CHECK( ioConfig2.getWriteRestartFile( 3 ) ); - - - auto deck3 = parser.parseString( deckData3, ctx ); - IOConfig ioConfig3( *deck3 ); - //Older ECLIPSE 100 data set may use integer controls instead of mnemonics - BOOST_CHECK( !ioConfig3.getWriteRestartFile( 0 ) ); - BOOST_CHECK( !ioConfig3.getWriteRestartFile( 1 ) ); - BOOST_CHECK( ioConfig3.getWriteRestartFile( 2 ) ); - BOOST_CHECK( ioConfig3.getWriteRestartFile( 3 ) ); -} - -BOOST_AUTO_TEST_CASE(RPTSCHED_and_RPTRST) { - const char *deckData = - "RUNSPEC\n" - "DIMENS\n" - " 10 10 10 /\n" - "GRID\n" - "START -- 0 \n" - "19 JUN 2007 / \n" - "SCHEDULE\n" - "DATES -- 1\n" - " 10 OKT 2008 / \n" - "/\n" - "RPTRST\n" - "BASIC=3 FREQ=3\n" - "/\n" - "DATES -- 2\n" - " 20 JAN 2010 / \n" - "/\n" - "DATES -- 3\n" - " 20 FEB 2010 / \n" - "/\n" - "RPTSCHED\n" - "RESTART=1\n" - "/\n"; - - - Opm::Parser parser; - ParseContext ctx; - - auto deck = parser.parseString( deckData, ctx ); - IOConfig ioConfig( *deck ); - - BOOST_CHECK( !ioConfig.getWriteRestartFile( 0 ) ); - BOOST_CHECK( !ioConfig.getWriteRestartFile( 1 ) ); - BOOST_CHECK( !ioConfig.getWriteRestartFile( 2 ) ); - BOOST_CHECK( ioConfig.getWriteRestartFile( 3 ) ); -} - -BOOST_AUTO_TEST_CASE(NO_BASIC) { - const char* data = "RUNSPEC\n" - "DIMENS\n" - " 10 10 10 /\n" - "GRID\n" - "START -- 0 \n" - "19 JUN 2007 / \n" - "SCHEDULE\n" - "DATES -- 1\n" - " 10 OKT 2008 / \n" - "/\n" - "DATES -- 2\n" - " 20 JAN 2010 / \n" - "/\n" - "DATES -- 3\n" - " 20 FEB 2010 / \n" - "/\n" - "RPTSCHED\n" - "/\n"; - - auto deck = Parser().parseString( data, ParseContext() ); - IOConfig ioConfig( *deck ); - - for( size_t ts = 0; ts < 4; ++ts ) - BOOST_CHECK( !ioConfig.getWriteRestartFile( ts ) ); -} - -BOOST_AUTO_TEST_CASE(BASIC_EQ_1) { - const char* data = "RUNSPEC\n" - "DIMENS\n" - " 10 10 10 /\n" - "GRID\n" - "START -- 0 \n" - "19 JUN 2007 / \n" - "SCHEDULE\n" - "DATES -- 1\n" - " 10 OKT 2008 / \n" - "/\n" - "RPTRST\n" - "BASIC=3 FREQ=3\n" - "/\n" - "DATES -- 2\n" - " 20 JAN 2010 / \n" - "/\n" - "DATES -- 3\n" - " 20 FEB 2010 / \n" - "/\n" - "RPTSCHED\n" - "BASIC=1\n" - "/\n"; - - auto deck = Parser().parseString( data, ParseContext() ); - IOConfig ioConfig( *deck ); - - for( size_t ts = 0; ts < 3; ++ts ) - BOOST_CHECK( !ioConfig.getWriteRestartFile( ts ) ); - - BOOST_CHECK( ioConfig.getWriteRestartFile( 3 ) ); -} - -BOOST_AUTO_TEST_CASE(BASIC_EQ_3) { - const char* data = "RUNSPEC\n" - "DIMENS\n" - " 10 10 10 /\n" - "GRID\n" - "START\n" - " 21 MAY 1981 /\n" - "\n" - "SCHEDULE\n" - "RPTRST\n" - "BASIC=3 FREQ=3\n" - "/\n" - "DATES\n" - " 22 MAY 1981 /\n" // timestep 1 - " 23 MAY 1981 /\n" // timestep 2 - " 24 MAY 1981 /\n" // timestep 3 - " 25 MAY 1981 /\n" // timestep 4 - " 26 MAY 1981 /\n" // timestep 5 - " 1 JAN 1982 /\n" // timestep 6 - " 1 JAN 1982 13:55:44 /\n" // timestep 7 - " 3 JAN 1982 14:56:45.123 /\n" // timestep 8 - " 4 JAN 1982 14:56:45.123 /\n" // timestep 9 - " 5 JAN 1982 14:56:45.123 /\n" // timestep 10 - " 6 JAN 1982 14:56:45.123 /\n" // timestep 11 - "/\n"; - - auto deck = Parser().parseString( data, ParseContext() ); - IOConfig ioConfig( *deck ); - - const size_t freq = 3; - - /* BASIC=3, restart files are created every nth report time, n=3 */ - for( size_t ts = 1; ts < 12; ++ts ) - BOOST_CHECK_EQUAL( ts % freq == 0, ioConfig.getWriteRestartFile( ts ) ); -} - -BOOST_AUTO_TEST_CASE(BASIC_EQ_4) { - const char* data = "RUNSPEC\n" - "DIMENS\n" - " 10 10 10 /\n" - "GRID\n" - "START\n" - " 21 MAY 1981 /\n" - "\n" - "SCHEDULE\n" - "RPTRST\n" - "BASIC=4\n" - "/\n" - "DATES\n" - " 22 MAY 1981 /\n" // timestep 1 - " 23 MAY 1981 /\n" // timestep 2 - " 24 MAY 1981 /\n" // timestep 3 - " 25 MAY 1981 /\n" // timestep 4 - " 26 MAY 1981 /\n" // timestep 5 - " 1 JAN 1982 /\n" // timestep 6 - " 1 JAN 1982 13:55:44 /\n" // timestep 7 - " 3 JAN 1982 14:56:45.123 /\n" // timestep 8 - " 4 JAN 1982 14:56:45.123 /\n" // timestep 9 - " 5 JAN 1982 14:56:45.123 /\n" // timestep 10 - " 6 JAN 1982 14:56:45.123 /\n" // timestep 11 - " 6 JAN 1983 14:56:45.123 /\n" // timestep 12 - "/\n"; - - auto deck = Parser().parseString( data, ParseContext() ); - IOConfig ioConfig( *deck ); - - /* BASIC=4, restart file is written at the first report step of each year. - */ - for( size_t ts : { 1, 2, 3, 4, 5, 7, 8, 9, 10, 11 } ) - BOOST_CHECK( !ioConfig.getWriteRestartFile( ts ) ); - - for( size_t ts : { 6, 12 } ) - BOOST_CHECK( ioConfig.getWriteRestartFile( ts ) ); -} - -BOOST_AUTO_TEST_CASE(BASIC_EQ_4_FREQ_2) { - const char* data = "RUNSPEC\n" - "DIMENS\n" - " 10 10 10 /\n" - "GRID\n" - "START\n" - " 21 MAY 1981 /\n" - "\n" - "SCHEDULE\n" - "RPTRST\n" - "BASIC=4 FREQ=2\n" - "/\n" - "DATES\n" - " 22 MAY 1981 /\n" - " 23 MAY 1981 /\n" - " 24 MAY 1981 /\n" - " 23 MAY 1982 /\n" - " 24 MAY 1982 /\n" - " 24 MAY 1983 /\n" // write - " 25 MAY 1984 /\n" - " 26 MAY 1984 /\n" - " 26 MAY 1985 /\n" // write - " 27 MAY 1985 /\n" - " 1 JAN 1986 /\n" - "/\n"; - - auto deck = Parser().parseString( data, ParseContext() ); - IOConfig ioConfig( *deck ); - - /* BASIC=4, restart file is written at the first report step of each year. - * Optionally, if the mnemonic FREQ is set >1 the restart is written only - * every n'th year. - * - * FREQ=2 - */ - for( size_t ts : { 1, 2, 3, 4, 5, 7, 8, 10, 11 } ) - BOOST_CHECK( !ioConfig.getWriteRestartFile( ts ) ); - - for( size_t ts : { 6, 9 } ) - BOOST_CHECK( ioConfig.getWriteRestartFile( ts ) ); -} - -BOOST_AUTO_TEST_CASE(BASIC_EQ_5) { - const char* data = "RUNSPEC\n" - "DIMENS\n" - " 10 10 10 /\n" - "GRID\n" - "START\n" - " 21 MAY 1981 /\n" - "\n" - "SCHEDULE\n" - "RPTRST\n" - "BASIC=5 FREQ=2\n" - "/\n" - "DATES\n" - " 22 MAY 1981 /\n" - " 23 MAY 1981 /\n" - " 24 MAY 1981 /\n" - " 1 JUN 1981 /\n" - " 1 JUL 1981 /\n" // write - " 1 JAN 1982 /\n" - " 2 JAN 1982 /\n" - " 1 FEB 1982 /\n" // write - " 1 MAR 1982 /\n" - " 1 APR 1983 /\n" //write - " 2 JUN 1983 /\n" - "/\n"; - - auto deck = Parser().parseString( data, ParseContext() ); - IOConfig ioConfig( *deck ); - - /* BASIC=5, restart file is written at the first report step of each month. - */ - for( size_t ts : { 1, 2, 3, 4, 6, 7, 9, 11 } ) - BOOST_CHECK( !ioConfig.getWriteRestartFile( ts ) ); - - for( size_t ts : { 5, 8, 10 } ) - BOOST_CHECK( ioConfig.getWriteRestartFile( ts ) ); -} - -BOOST_AUTO_TEST_CASE(BASIC_EQ_0) { - const char* data = "RUNSPEC\n" - "DIMENS\n" - " 10 10 10 /\n" - "GRID\n" - "START\n" - " 21 MAY 1981 /\n" - "\n" - "SCHEDULE\n" - "RPTRST\n" - "BASIC=0 FREQ=2\n" - "/\n" - "DATES\n" - " 22 MAY 1981 /\n" - " 23 MAY 1981 /\n" - " 24 MAY 1981 /\n" - " 1 JUN 1981 /\n" - " 1 JUL 1981 /\n" - " 1 JAN 1982 /\n" - " 2 JAN 1982 /\n" - " 1 FEB 1982 /\n" - " 1 MAR 1982 /\n" - " 1 APR 1983 /\n" - " 2 JUN 1983 /\n" - "/\n"; - - auto deck = Parser().parseString( data, ParseContext() ); - IOConfig ioConfig( *deck ); - - /* RESTART=0, no restart file is written - */ - for( size_t ts = 0; ts < 11; ++ts ) - BOOST_CHECK( !ioConfig.getWriteRestartFile( ts ) ); -} - - -BOOST_AUTO_TEST_CASE(RESTART_EQ_0) { - const char* data = "RUNSPEC\n" - "DIMENS\n" - " 10 10 10 /\n" - "GRID\n" - "START\n" - " 21 MAY 1981 /\n" - "\n" - "SCHEDULE\n" - "RPTSCHED\n" - "RESTART=0\n" - "/\n" - "DATES\n" - " 22 MAY 1981 /\n" - " 23 MAY 1981 /\n" - " 24 MAY 1981 /\n" - " 1 JUN 1981 /\n" - " 1 JUL 1981 /\n" - " 1 JAN 1982 /\n" - " 2 JAN 1982 /\n" - " 1 FEB 1982 /\n" - " 1 MAR 1982 /\n" - " 1 APR 1983 /\n" - " 2 JUN 1983 /\n" - "/\n"; - - auto deck = Parser().parseString( data, ParseContext() ); - IOConfig ioConfig( *deck ); - - /* RESTART=0, no restart file is written - */ - for( size_t ts = 0; ts < 11; ++ts ) - BOOST_CHECK( !ioConfig.getWriteRestartFile( ts ) ); -} - -BOOST_AUTO_TEST_CASE(RESTART_BASIC_GT_2) { - const char* data = "RUNSPEC\n" - "DIMENS\n" - " 10 10 10 /\n" - "GRID\n" - "START\n" - " 21 MAY 1981 /\n" - "\n" - "SCHEDULE\n" - "RPTRST\n" - "BASIC=4 FREQ=2\n" - "/\n" - "DATES\n" - " 22 MAY 1981 /\n" - "/\n" - "RPTSCHED\n" // BASIC >2, ignore RPTSCHED RESTART - "RESTART=3, FREQ=1\n" - "/\n" - "DATES\n" - " 23 MAY 1981 /\n" - " 24 MAY 1981 /\n" - " 23 MAY 1982 /\n" - " 24 MAY 1982 /\n" - " 24 MAY 1983 /\n" // write - " 25 MAY 1984 /\n" - " 26 MAY 1984 /\n" - " 26 MAY 1985 /\n" // write - " 27 MAY 1985 /\n" - " 1 JAN 1986 /\n" - "/\n"; - - auto deck = Parser().parseString( data, ParseContext() ); - IOConfig ioConfig( *deck ); - - for( size_t ts : { 1, 2, 3, 4, 5, 7, 8, 10, 11 } ) - BOOST_CHECK( !ioConfig.getWriteRestartFile( ts ) ); - - for( size_t ts : { 6, 9 } ) - BOOST_CHECK( ioConfig.getWriteRestartFile( ts ) ); -} - -BOOST_AUTO_TEST_CASE(RESTART_BASIC_LEQ_2) { - const char* data = "RUNSPEC\n" - "DIMENS\n" - " 10 10 10 /\n" - "GRID\n" - "START\n" - " 21 MAY 1981 /\n" - "\n" - "SCHEDULE\n" - "RPTRST\n" - "BASIC=1" - "/\n" - "DATES\n" - " 22 MAY 1981 /\n" - "/\n" - "RPTSCHED\n" - "RESTART=0\n" - "/\n" - "DATES\n" - " 23 MAY 1981 /\n" - " 24 MAY 1981 /\n" - " 23 MAY 1982 /\n" - " 24 MAY 1982 /\n" - " 24 MAY 1983 /\n" - " 25 MAY 1984 /\n" - " 26 MAY 1984 /\n" - " 26 MAY 1985 /\n" - " 27 MAY 1985 /\n" - " 1 JAN 1986 /\n" - "/\n"; - - auto deck = Parser().parseString( data, ParseContext() ); - IOConfig ioConfig( *deck ); - - BOOST_CHECK( ioConfig.getWriteRestartFile( 1 ) ); - for( size_t ts = 2; ts < 11; ++ts ) - BOOST_CHECK( !ioConfig.getWriteRestartFile( ts ) ); + BOOST_CHECK_EQUAL( ioConfig.getFirstRFTStep() , 2 ); } BOOST_AUTO_TEST_CASE(DefaultProperties) { @@ -902,11 +275,15 @@ BOOST_AUTO_TEST_CASE(OutputPaths) { BOOST_CHECK_EQUAL( output_dir2, config2.getOutputDir() ); BOOST_CHECK_EQUAL( "testString", config2.getBaseName() ); + namespace fs = boost::filesystem; + Deck deck3; deck3.setDataFile( "/path/to/testString.DATA" ); IOConfig config3( deck3 ); std::string output_dir3 = "/path/to"; config3.setOutputDir( output_dir3 ); + auto testpath = fs::path( "/path/to/testString" ).make_preferred().string(); BOOST_CHECK_EQUAL( output_dir3, config3.getOutputDir() ); BOOST_CHECK_EQUAL( "testString", config3.getBaseName() ); + BOOST_CHECK_EQUAL( testpath, config3.fullBasePath() ); } diff --git a/ThirdParty/custom-opm-parser/opm-parser/opm/parser/eclipse/EclipseState/IOConfig/tests/RestartConfigTests.cpp b/ThirdParty/custom-opm-parser/opm-parser/opm/parser/eclipse/EclipseState/IOConfig/tests/RestartConfigTests.cpp new file mode 100644 index 0000000000..eddd264c9f --- /dev/null +++ b/ThirdParty/custom-opm-parser/opm-parser/opm/parser/eclipse/EclipseState/IOConfig/tests/RestartConfigTests.cpp @@ -0,0 +1,901 @@ +/* + Copyright 2016 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 . + */ + + + +#define BOOST_TEST_MODULE RestartConfigTests + +#include + + +#include +#include +#include +#include +#include + +inline std::string fst( const std::pair< std::string, int >& p ) { + return p.first; +} + +using namespace Opm; + + +BOOST_AUTO_TEST_CASE(RPTSCHED_INTEGER) { + + const char *deckData1 = + "RUNSPEC\n" + "DIMENS\n" + " 10 10 10 /\n" + "GRID\n" + "START -- 0 \n" + "19 JUN 2007 / \n" + "SOLUTION\n" + "RPTRST -- PRES,DEN,PCOW,PCOG,RK,VELOCITY,COMPRESS\n" + " 6*0 1 0 1 9*0 1 7*0 1 0 3*1 /\n" + "SCHEDULE\n" + "DATES -- 1\n" + " 10 OKT 2008 / \n" + "/\n" + "RPTSCHED\n" + "RESTART=1\n" + "/\n" + "DATES -- 2\n" + " 20 JAN 2010 / \n" + "/\n" + "RPTRST -- RK,VELOCITY,COMPRESS\n" + " 18*0 0 8*0 /\n" + "DATES -- 3\n" + " 20 FEB 2010 / \n" + "/\n" + "RPTSCHED\n" + "RESTART=0\n" + "/\n"; + + Parser parser; + ParseContext ctx; + + auto deck1 = parser.parseString( deckData1, ctx ); + RestartConfig rstConfig1( *deck1 ); + + BOOST_CHECK( rstConfig1.getWriteRestartFile( 0 ) ); + BOOST_CHECK( !rstConfig1.getWriteRestartFile( 1 ) ); + BOOST_CHECK( rstConfig1.getWriteRestartFile( 2 ) ); + BOOST_CHECK( !rstConfig1.getWriteRestartFile( 3 ) ); + + std::vector< std::string > kw_list1; + for( const auto& pair : rstConfig1.getRestartKeywords( 0 ) ) + if( pair.second != 0 ) kw_list1.push_back( pair.first ); + + const auto expected1 = {"BG","BO","BW","COMPRESS","DEN","KRG","KRO","KRW","PCOG","PCOW","PRES","RK","VELOCITY","VGAS","VOIL","VWAT"}; + BOOST_CHECK_EQUAL_COLLECTIONS( expected1.begin(), expected1.end(), + kw_list1.begin(), kw_list1.end() ); + + // ACIP is a valid mneonic - but not in this deck. + BOOST_CHECK_EQUAL( rstConfig1.getKeyword( "ACIP" , 0) , 0 ); + BOOST_CHECK_EQUAL( rstConfig1.getKeyword( "COMPRESS" , 0) , 1 ); + BOOST_CHECK_EQUAL( rstConfig1.getKeyword( "PCOG", 0) , 1 ); + BOOST_CHECK_THROW( rstConfig1.getKeyword( "UNKNOWN_KW", 0) , std::invalid_argument); + + std::vector< std::string > kw_list2; + for( const auto& pair : rstConfig1.getRestartKeywords( 3 ) ) + if( pair.second != 0 ) kw_list2.push_back( pair.first ); + + const auto expected2 = { "COMPRESS", "RESTART", "RK", "VELOCITY" }; + BOOST_CHECK_EQUAL_COLLECTIONS( expected2.begin(), expected2.end(), + kw_list2.begin(), kw_list2.end() ); + + BOOST_CHECK_EQUAL( rstConfig1.getKeyword( "ALLPROPS" , 0 ) , 0); + BOOST_CHECK_EQUAL( rstConfig1.getKeyword( "ALLPROPS" , 3 ) , 0); +} + + +const std::string& deckStr = "RUNSPEC\n" + "\n" + "DIMENS\n" + " 10 10 10 /\n" + "GRID\n" + "GRIDFILE\n" + " 0 1 /\n" + "\n" + "START\n" + " 21 MAY 1981 /\n" + "\n" + "SCHEDULE\n" + "DATES\n" + " 22 MAY 1981 /\n" // timestep 1 + " 23 MAY 1981 /\n" // timestep 2 + " 24 MAY 1981 /\n" // timestep 3 + " 25 MAY 1981 /\n" // timestep 4 + " 26 MAY 1981 /\n" // timestep 5 + " 1 JAN 1982 /\n" // timestep 6 + " 1 JAN 1982 13:55:44 /\n" // timestep 7 + " 3 JAN 1982 14:56:45.123 /\n" // timestep 8 + " 4 JAN 1982 14:56:45.123 /\n" // timestep 9 + " 5 JAN 1982 14:56:45.123 /\n" // timestep 10 + " 6 JAN 1982 14:56:45.123 /\n" // timestep 11 + " 7 JAN 1982 14:56:45.123 /\n" // timestep 12 + " 8 JAN 1982 14:56:45.123 /\n" // timestep 13 + " 9 JAN 1982 14:56:45.123 /\n" // timestep 14 + " 10 JAN 1982 14:56:45.123 /\n" // timestep 15 + " 11 JAN 1982 14:56:45.123 /\n" // timestep 16 + " 1 JAN 1983 /\n" // timestep 17 + " 2 JAN 1983 /\n" // timestep 18 + " 3 JAN 1983 /\n" // timestep 19 + " 1 JAN 1984 /\n" // timestep 20 + " 2 JAN 1984 /\n" // timestep 21 + " 1 JAN 1985 /\n" // timestep 22 + " 3 JAN 1986 14:56:45.123 /\n" // timestep 23 + " 4 JAN 1986 14:56:45.123 /\n" // timestep 24 + " 5 JAN 1986 14:56:45.123 /\n" // timestep 25 + " 1 JAN 1987 /\n" // timestep 26 + " 1 JAN 1988 /\n" // timestep 27 + " 2 JAN 1988 /\n" // timestep 28 + " 3 JAN 1988 /\n" // timestep 29 + " 1 JAN 1989 /\n" // timestep 30 + " 2 JAN 1989 /\n" // timestep 31 + " 2 JAN 1990 /\n" // timestep 32 + " 2 JAN 1991 /\n" // timestep 33 + " 3 JAN 1991 /\n" // timestep 34 + " 4 JAN 1991 /\n" // timestep 35 + " 1 JAN 1992 /\n" // timestep 36 + " 1 FEB 1992 /\n" // timestep 37 + " 1 MAR 1992 /\n" // timestep 38 + " 2 MAR 1992 /\n" // timestep 39 + " 3 MAR 1992 /\n" // timestep 40 + " 4 MAR 1992 /\n" // timestep 41 + " 1 APR 1992 /\n" // timestep 42 + " 2 APR 1992 /\n" // timestep 43 + " 1 MAY 1992 /\n" // timestep 44 + " 2 MAY 1992 /\n" // timestep 45 + " 3 MAY 1992 /\n" // timestep 46 + " 3 JUN 1992 /\n" // timestep 47 + " 3 JUL 1992 /\n" // timestep 48 + " 3 AUG 1992 /\n" // timestep 49 + " 4 AUG 1992 /\n" // timestep 50 + " 5 AUG 1992 /\n" // timestep 51 + " 6 AUG 1992 /\n" // timestep 52 + " 7 AUG 1992 /\n" // timestep 53 + " 8 AUG 1992 /\n" // timestep 54 + " 9 AUG 1992 /\n" // timestep 55 + " 10 AUG 1992 /\n" // timestep 56 + " 11 AUG 1992 /\n" // timestep 57 + " 12 AUG 1992 /\n" // timestep 58 + " 13 AUG 1992 /\n" // timestep 59 + " 14 AUG 1992 /\n" // timestep 60 + " 15 AUG 1992 /\n" // timestep 61 + "/\n" + "\n"; + +const std::string deckStr_RFT = "RUNSPEC\n" + "OIL\n" + "GAS\n" + "WATER\n" + "DIMENS\n" + " 10 10 10 /\n" + "GRID\n" + "DXV\n" + "10*0.25 /\n" + "DYV\n" + "10*0.25 /\n" + "DZV\n" + "10*0.25 /\n" + "TOPS\n" + "100*0.25 /\n" + "\n" + "START -- 0 \n" + "1 NOV 1979 / \n" + "SCHEDULE\n" + "DATES -- 1\n" + " 1 DES 1979/ \n" + "/\n" + "WELSPECS\n" + " 'OP_1' 'OP' 9 9 1* 'OIL' 1* 1* 1* 1* 1* 1* 1* / \n" + " 'OP_2' 'OP' 4 4 1* 'OIL' 1* 1* 1* 1* 1* 1* 1* / \n" + "/\n" + "COMPDAT\n" + " 'OP_1' 9 9 1 1 'OPEN' 1* 32.948 0.311 3047.839 1* 1* 'X' 22.100 / \n" + " 'OP_1' 9 9 2 2 'OPEN' 1* 46.825 0.311 4332.346 1* 1* 'X' 22.123 / \n" + " 'OP_1' 9 9 3 9 'OPEN' 1* 32.948 0.311 3047.839 1* 1* 'X' 22.100 / \n" + " 'OP_2' 4 4 4 9 'OPEN' 1* 32.948 0.311 3047.839 1* 1* 'X' 22.100 / \n" + "/\n" + "DATES -- 2\n" + " 10 OKT 2008 / \n" + "/\n" + "WRFT \n" + "/ \n" + "WELOPEN\n" + " 'OP_1' OPEN / \n" + " 'OP_2' OPEN / \n" + "/\n" + "DATES -- 3\n" + " 10 NOV 2008 / \n" + "/\n"; + + + +BOOST_AUTO_TEST_CASE(RPTRST_mixed_mnemonics_int_list) { + const char* data = "RUNSPEC\n" + "DIMENS\n" + " 10 10 10 /\n" + "GRID\n" + "START -- 0 \n" + "19 JUN 2007 / \n" + "SCHEDULE\n" + "DATES -- 1\n" + " 10 OKT 2008 / \n" + "/\n" + "RPTRST\n" + "BASIC=3 0 1 2\n" + "/\n" + "DATES -- 2\n" + " 20 JAN 2010 / \n" + "/\n" + "DATES -- 3\n" + " 20 FEB 2010 / \n" + "/\n" + "RPTSCHED\n" + "BASIC=1\n" + "/\n"; + + auto deck = Parser().parseString( data, ParseContext() ); + BOOST_CHECK_THROW( RestartConfig c( *deck ), std::runtime_error ); +} + +BOOST_AUTO_TEST_CASE(RPTRST) { + + const char *deckData1 = + "RUNSPEC\n" + "DIMENS\n" + " 10 10 10 /\n" + "GRID\n" + "START -- 0 \n" + "19 JUN 2007 / \n" + "SOLUTION\n" + "RPTRST\n" + " ACIP KRG KRO KRW NORST SFREQ=10 ALLPROPS/\n" + "SCHEDULE\n" + "DATES -- 1\n" + " 10 OKT 2008 / \n" + "/\n" + "RPTRST\n" + "BASIC=1\n" + "/\n" + "DATES -- 2\n" + " 20 JAN 2010 / \n" + "/\n"; + + const char *deckData2 = + "RUNSPEC\n" + "DIMENS\n" + " 10 10 10 /\n" + "GRID\n" + "START -- 0 \n" + "19 JUN 2007 / \n" + "SCHEDULE\n" + "DATES -- 1\n" + " 10 OKT 2008 / \n" + "/\n" + "RPTRST\n" + "BASIC=3 FREQ=2 FLOWS RUBBISH=5\n" + "/\n" + "DATES -- 2\n" + " 20 JAN 2010 / \n" + "/\n" + "DATES -- 3\n" + " 20 JAN 2011 / \n" + "/\n"; + + const char *deckData3 = + "RUNSPEC\n" + "DIMENS\n" + " 10 10 10 /\n" + "GRID\n" + "START -- 0 \n" + "19 JUN 2007 / \n" + "SCHEDULE\n" + "DATES -- 1\n" + " 10 OKT 2008 / \n" + "/\n" + "RPTRST\n" + "3 0 0 0 0 2\n" + "/\n" + "DATES -- 2\n" + " 20 JAN 2010 / \n" + "/\n" + "DATES -- 3\n" + " 20 JAN 2011 / \n" + "/\n"; + + Opm::Parser parser; + ParseContext ctx; + + auto deck1 = parser.parseString( deckData1, ctx ); + RestartConfig rstConfig1( *deck1 ); + + // Observe that this is true due to some undocumented guessing that + // the initial restart file should be written if a RPTRST keyword is + // found in the SOLUTION section, irrespective of the content of that + // keyword. + BOOST_CHECK( rstConfig1.getWriteRestartFile( 0 ) ); + BOOST_CHECK( !rstConfig1.getWriteRestartFile( 1 ) ); + BOOST_CHECK( rstConfig1.getWriteRestartFile( 2 ) ); + + + std::vector expected = { "ACIP","BASIC", "BG","BO","BW","DEN","KRG", "KRO", "KRW", "NORST", "SFREQ", "VGAS", "VOIL", "VWAT"}; + const auto kw_list = fun::map( fst, rstConfig1.getRestartKeywords(2) ); + + BOOST_CHECK_EQUAL_COLLECTIONS( expected.begin() ,expected.end(), + kw_list.begin() , kw_list.end() ); + + BOOST_CHECK_EQUAL( rstConfig1.getKeyword( "ALLPROPS" , 2 ) , 0); + + auto deck2 = parser.parseString( deckData2, ctx ); + RestartConfig rstConfig2( *deck2 ); + + const auto expected2 = { "BASIC", "FLOWS", "FREQ" }; + const auto kw_list2 = fun::map( fst, rstConfig2.getRestartKeywords( 2 ) ); + BOOST_CHECK_EQUAL_COLLECTIONS( expected2.begin(), expected2.end(), + kw_list2.begin(), kw_list2.end() ); + + BOOST_CHECK( !rstConfig2.getWriteRestartFile( 0 ) ); + BOOST_CHECK( !rstConfig2.getWriteRestartFile( 1 ) ); + BOOST_CHECK( rstConfig2.getWriteRestartFile( 2 ) ); + BOOST_CHECK( !rstConfig2.getWriteRestartFile( 3 ) ); + + auto deck3 = parser.parseString( deckData3, ctx ); + RestartConfig rstConfig3( *deck3 ); + + BOOST_CHECK( !rstConfig3.getWriteRestartFile( 0 ) ); + BOOST_CHECK( !rstConfig3.getWriteRestartFile( 1 ) ); + BOOST_CHECK( rstConfig3.getWriteRestartFile( 2 ) ); + BOOST_CHECK( !rstConfig3.getWriteRestartFile( 3 ) ); +} + + + + +BOOST_AUTO_TEST_CASE(RPTSCHED) { + + const char *deckData1 = + "RUNSPEC\n" + "DIMENS\n" + " 10 10 10 /\n" + "GRID\n" + "START -- 0 \n" + "19 JUN 2007 / \n" + "SCHEDULE\n" + "DATES -- 1\n" + " 10 OKT 2008 / \n" + "/\n" + "RPTSCHED\n" + "RESTART=1\n" + "/\n" + "DATES -- 2\n" + " 20 JAN 2010 / \n" + "/\n" + "DATES -- 3\n" + " 20 FEB 2010 / \n" + "/\n" + "RPTSCHED\n" + "RESTART=0\n" + "/\n"; + + + const char *deckData2 = + "RUNSPEC\n" + "DIMENS\n" + " 10 10 10 /\n" + "GRID\n" + "START -- 0 \n" + "19 JUN 2007 / \n" + "SCHEDULE\n" + "DATES -- 1\n" + " 10 OKT 2008 / \n" + "/\n" + "RPTSCHED\n" + "RESTART=3 FIP\n" + "/\n" + "DATES -- 2\n" + " 20 JAN 2010 / \n" + "/\n" + "RPTSCHED\n" + "RESTART=4\n" + "/\n" + "DATES -- 3\n" + " 20 FEB 2010 / \n" + "/\n" + "RPTSCHED\n" + "NOTHING RUBBISH\n" + "/\n"; + + const char *deckData3 = + "RUNSPEC\n" + "DIMENS\n" + " 10 10 10 /\n" + "GRID\n" + "START -- 0 \n" + "19 JUN 2007 / \n" + "SOLUTION\n" + "RPTSOL\n" + " RESTART=4 /\n" + "SCHEDULE\n" + "DATES -- 1\n" + " 10 OKT 2008 / \n" + "/\n" + "RPTRST\n" + "BASIC=3 FREQ=1 RUBBISH=5\n" + "/\n" + "DATES -- 2\n" + " 20 JAN 2010 / \n" + "/\n" + "DATES -- 3\n" + " 20 FEB 2010 / \n" + "/\n" + "RPTSCHED\n" + "0 0 0 0 0 0 0 0\n" + "/\n"; + + Parser parser; + ParseContext ctx; + + auto deck1 = parser.parseString( deckData1, ctx ); + RestartConfig rstConfig1( *deck1 ); + + BOOST_CHECK( !rstConfig1.getWriteRestartFile( 0 ) ); + BOOST_CHECK( !rstConfig1.getWriteRestartFile( 1 ) ); + BOOST_CHECK( rstConfig1.getWriteRestartFile( 2 ) ); + BOOST_CHECK( rstConfig1.getWriteRestartFile( 3 ) ); + + + auto deck2 = parser.parseString( deckData2, ctx ); + RestartConfig rstConfig2( *deck2 ); + + BOOST_CHECK( !rstConfig2.getWriteRestartFile( 0 ) ); + BOOST_CHECK( !rstConfig2.getWriteRestartFile( 1 ) ); + BOOST_CHECK( rstConfig2.getWriteRestartFile( 2 ) ); + BOOST_CHECK( rstConfig2.getWriteRestartFile( 3 ) ); + + const auto expected2 = { "FIP", "RESTART" }; + const auto kw_list2 = fun::map( fst, rstConfig2.getRestartKeywords( 2 ) ); + BOOST_CHECK_EQUAL_COLLECTIONS( expected2.begin(), expected2.end(), + kw_list2.begin(), kw_list2.end() ); + + + auto deck3 = parser.parseString( deckData3, ctx ); + RestartConfig rstConfig3( *deck3 ); + //Older ECLIPSE 100 data set may use integer controls instead of mnemonics + BOOST_CHECK( rstConfig3.getWriteRestartFile( 0 ) ); + BOOST_CHECK( !rstConfig3.getWriteRestartFile( 1 ) ); + BOOST_CHECK( rstConfig3.getWriteRestartFile( 2 ) ); + BOOST_CHECK( rstConfig3.getWriteRestartFile( 3 ) ); + + std::vector expected3 = { "BASIC", "FREQ" }; + const auto kw_list3 = fun::map( fst, rstConfig3.getRestartKeywords(2) ); + BOOST_CHECK_EQUAL_COLLECTIONS( expected3.begin() , expected3.end() , kw_list3.begin() , kw_list3.end() ); +} + + +BOOST_AUTO_TEST_CASE(RPTSCHED_and_RPTRST) { + const char *deckData = + "RUNSPEC\n" + "DIMENS\n" + " 10 10 10 /\n" + "GRID\n" + "START -- 0 \n" + "19 JUN 2007 / \n" + "SCHEDULE\n" + "DATES -- 1\n" + " 10 OKT 2008 / \n" + "/\n" + "RPTRST\n" + "BASIC=3 FREQ=3 BG BO\n" + "/\n" + "DATES -- 2\n" + " 20 JAN 2010 / \n" + "/\n" + "DATES -- 3\n" + " 20 FEB 2010 / \n" + "/\n" + "RPTSCHED\n" + "RESTART=1\n" + "/\n"; + + + Opm::Parser parser; + ParseContext ctx; + + auto deck = parser.parseString( deckData, ctx ); + RestartConfig rstConfig( *deck ); + + BOOST_CHECK( !rstConfig.getWriteRestartFile( 0 ) ); + BOOST_CHECK( !rstConfig.getWriteRestartFile( 1 ) ); + BOOST_CHECK( !rstConfig.getWriteRestartFile( 2 ) ); + BOOST_CHECK( rstConfig.getWriteRestartFile( 3 ) ); +} + + +BOOST_AUTO_TEST_CASE(NO_BASIC) { + const char* data = "RUNSPEC\n" + "DIMENS\n" + " 10 10 10 /\n" + "GRID\n" + "START -- 0 \n" + "19 JUN 2007 / \n" + "SCHEDULE\n" + "DATES -- 1\n" + " 10 OKT 2008 / \n" + "/\n" + "DATES -- 2\n" + " 20 JAN 2010 / \n" + "/\n" + "DATES -- 3\n" + " 20 FEB 2010 / \n" + "/\n" + "RPTSCHED\n" + "/\n"; + + auto deck = Parser().parseString( data, ParseContext() ); + RestartConfig ioConfig( *deck ); + + for( size_t ts = 0; ts < 4; ++ts ) + BOOST_CHECK( !ioConfig.getWriteRestartFile( ts ) ); +} + +BOOST_AUTO_TEST_CASE(BASIC_EQ_1) { + const char* data = "RUNSPEC\n" + "DIMENS\n" + " 10 10 10 /\n" + "GRID\n" + "START -- 0 \n" + "19 JUN 2007 / \n" + "SCHEDULE\n" + "DATES -- 1\n" + " 10 OKT 2008 / \n" + "/\n" + "RPTRST\n" + "BASIC=3 FREQ=3\n" + "/\n" + "DATES -- 2\n" + " 20 JAN 2010 / \n" + "/\n" + "DATES -- 3\n" + " 20 FEB 2010 / \n" + "/\n" + "RPTSCHED\n" + "BASIC=1\n" + "/\n"; + + auto deck = Parser().parseString( data, ParseContext() ); + RestartConfig ioConfig( *deck ); + + for( size_t ts = 0; ts < 3; ++ts ) + BOOST_CHECK( !ioConfig.getWriteRestartFile( ts ) ); + + BOOST_CHECK( ioConfig.getWriteRestartFile( 3 ) ); +} + +BOOST_AUTO_TEST_CASE(BASIC_EQ_3) { + const char* data = "RUNSPEC\n" + "DIMENS\n" + " 10 10 10 /\n" + "GRID\n" + "START\n" + " 21 MAY 1981 /\n" + "\n" + "SCHEDULE\n" + "RPTRST\n" + "BASIC=3 FREQ=3\n" + "/\n" + "DATES\n" + " 22 MAY 1981 /\n" // timestep 1 + " 23 MAY 1981 /\n" // timestep 2 + " 24 MAY 1981 /\n" // timestep 3 + " 25 MAY 1981 /\n" // timestep 4 + " 26 MAY 1981 /\n" // timestep 5 + " 1 JAN 1982 /\n" // timestep 6 + " 1 JAN 1982 13:55:44 /\n" // timestep 7 + " 3 JAN 1982 14:56:45.123 /\n" // timestep 8 + " 4 JAN 1982 14:56:45.123 /\n" // timestep 9 + " 5 JAN 1982 14:56:45.123 /\n" // timestep 10 + " 6 JAN 1982 14:56:45.123 /\n" // timestep 11 + "/\n"; + + auto deck = Parser().parseString( data, ParseContext() ); + RestartConfig ioConfig( *deck ); + + const size_t freq = 3; + + /* BASIC=3, restart files are created every nth report time, n=3 */ + for( size_t ts = 1; ts < 12; ++ts ) + BOOST_CHECK_EQUAL( ts % freq == 0, ioConfig.getWriteRestartFile( ts ) ); +} + +BOOST_AUTO_TEST_CASE(BASIC_EQ_4) { + const char* data = "RUNSPEC\n" + "DIMENS\n" + " 10 10 10 /\n" + "GRID\n" + "START\n" + " 21 MAY 1981 /\n" + "\n" + "SCHEDULE\n" + "RPTRST\n" + "BASIC=4\n" + "/\n" + "DATES\n" + " 22 MAY 1981 /\n" // timestep 1 + " 23 MAY 1981 /\n" // timestep 2 + " 24 MAY 1981 /\n" // timestep 3 + " 25 MAY 1981 /\n" // timestep 4 + " 26 MAY 1981 /\n" // timestep 5 + " 1 JAN 1982 /\n" // timestep 6 + " 1 JAN 1982 13:55:44 /\n" // timestep 7 + " 3 JAN 1982 14:56:45.123 /\n" // timestep 8 + " 4 JAN 1982 14:56:45.123 /\n" // timestep 9 + " 5 JAN 1982 14:56:45.123 /\n" // timestep 10 + " 6 JAN 1982 14:56:45.123 /\n" // timestep 11 + " 6 JAN 1983 14:56:45.123 /\n" // timestep 12 + "/\n"; + + auto deck = Parser().parseString( data, ParseContext() ); + RestartConfig ioConfig( *deck ); + + /* BASIC=4, restart file is written at the first report step of each year. + */ + for( size_t ts : { 1, 2, 3, 4, 5, 7, 8, 9, 10, 11 } ) + BOOST_CHECK( !ioConfig.getWriteRestartFile( ts ) ); + + for( size_t ts : { 6, 12 } ) + BOOST_CHECK( ioConfig.getWriteRestartFile( ts ) ); +} + +BOOST_AUTO_TEST_CASE(BASIC_EQ_4_FREQ_2) { + const char* data = "RUNSPEC\n" + "DIMENS\n" + " 10 10 10 /\n" + "GRID\n" + "START\n" + " 21 MAY 1981 /\n" + "\n" + "SCHEDULE\n" + "RPTRST\n" + "BASIC=4 FREQ=2\n" + "/\n" + "DATES\n" + " 22 MAY 1981 /\n" + " 23 MAY 1981 /\n" + " 24 MAY 1981 /\n" + " 23 MAY 1982 /\n" + " 24 MAY 1982 /\n" + " 24 MAY 1983 /\n" // write + " 25 MAY 1984 /\n" + " 26 MAY 1984 /\n" + " 26 MAY 1985 /\n" // write + " 27 MAY 1985 /\n" + " 1 JAN 1986 /\n" + "/\n"; + + auto deck = Parser().parseString( data, ParseContext() ); + RestartConfig ioConfig( *deck ); + + /* BASIC=4, restart file is written at the first report step of each year. + * Optionally, if the mnemonic FREQ is set >1 the restart is written only + * every n'th year. + * + * FREQ=2 + */ + for( size_t ts : { 1, 2, 3, 4, 5, 7, 8, 10, 11 } ) + BOOST_CHECK( !ioConfig.getWriteRestartFile( ts ) ); + + for( size_t ts : { 6, 9 } ) + BOOST_CHECK( ioConfig.getWriteRestartFile( ts ) ); +} + +BOOST_AUTO_TEST_CASE(BASIC_EQ_5) { + const char* data = "RUNSPEC\n" + "DIMENS\n" + " 10 10 10 /\n" + "GRID\n" + "START\n" + " 21 MAY 1981 /\n" + "\n" + "SCHEDULE\n" + "RPTRST\n" + "BASIC=5 FREQ=2\n" + "/\n" + "DATES\n" + " 22 MAY 1981 /\n" + " 23 MAY 1981 /\n" + " 24 MAY 1981 /\n" + " 1 JUN 1981 /\n" + " 1 JUL 1981 /\n" // write + " 1 JAN 1982 /\n" + " 2 JAN 1982 /\n" + " 1 FEB 1982 /\n" // write + " 1 MAR 1982 /\n" + " 1 APR 1983 /\n" //write + " 2 JUN 1983 /\n" + "/\n"; + + auto deck = Parser().parseString( data, ParseContext() ); + RestartConfig ioConfig( *deck ); + + /* BASIC=5, restart file is written at the first report step of each month. + */ + for( size_t ts : { 1, 2, 3, 4, 6, 7, 9, 11 } ) + BOOST_CHECK( !ioConfig.getWriteRestartFile( ts ) ); + + for( size_t ts : { 5, 8, 10 } ) + BOOST_CHECK( ioConfig.getWriteRestartFile( ts ) ); +} + +BOOST_AUTO_TEST_CASE(BASIC_EQ_0) { + const char* data = "RUNSPEC\n" + "DIMENS\n" + " 10 10 10 /\n" + "GRID\n" + "START\n" + " 21 MAY 1981 /\n" + "\n" + "SCHEDULE\n" + "RPTRST\n" + "BASIC=0 FREQ=2\n" + "/\n" + "DATES\n" + " 22 MAY 1981 /\n" + " 23 MAY 1981 /\n" + " 24 MAY 1981 /\n" + " 1 JUN 1981 /\n" + " 1 JUL 1981 /\n" + " 1 JAN 1982 /\n" + " 2 JAN 1982 /\n" + " 1 FEB 1982 /\n" + " 1 MAR 1982 /\n" + " 1 APR 1983 /\n" + " 2 JUN 1983 /\n" + "/\n"; + + auto deck = Parser().parseString( data, ParseContext() ); + RestartConfig ioConfig( *deck ); + + /* RESTART=0, no restart file is written + */ + for( size_t ts = 0; ts < 11; ++ts ) + BOOST_CHECK( !ioConfig.getWriteRestartFile( ts ) ); +} + + +BOOST_AUTO_TEST_CASE(RESTART_EQ_0) { + const char* data = "RUNSPEC\n" + "DIMENS\n" + " 10 10 10 /\n" + "GRID\n" + "START\n" + " 21 MAY 1981 /\n" + "\n" + "SCHEDULE\n" + "RPTSCHED\n" + "RESTART=0\n" + "/\n" + "DATES\n" + " 22 MAY 1981 /\n" + " 23 MAY 1981 /\n" + " 24 MAY 1981 /\n" + " 1 JUN 1981 /\n" + " 1 JUL 1981 /\n" + " 1 JAN 1982 /\n" + " 2 JAN 1982 /\n" + " 1 FEB 1982 /\n" + " 1 MAR 1982 /\n" + " 1 APR 1983 /\n" + " 2 JUN 1983 /\n" + "/\n"; + + auto deck = Parser().parseString( data, ParseContext() ); + RestartConfig ioConfig( *deck ); + + /* RESTART=0, no restart file is written + */ + for( size_t ts = 0; ts < 11; ++ts ) + BOOST_CHECK( !ioConfig.getWriteRestartFile( ts ) ); +} + +BOOST_AUTO_TEST_CASE(RESTART_BASIC_GT_2) { + const char* data = "RUNSPEC\n" + "DIMENS\n" + " 10 10 10 /\n" + "GRID\n" + "START\n" + " 21 MAY 1981 /\n" + "\n" + "SCHEDULE\n" + "RPTRST\n" + "BASIC=4 FREQ=2\n" + "/\n" + "DATES\n" + " 22 MAY 1981 /\n" + "/\n" + "RPTSCHED\n" // BASIC >2, ignore RPTSCHED RESTART + "RESTART=3, FREQ=1\n" + "/\n" + "DATES\n" + " 23 MAY 1981 /\n" + " 24 MAY 1981 /\n" + " 23 MAY 1982 /\n" + " 24 MAY 1982 /\n" + " 24 MAY 1983 /\n" // write + " 25 MAY 1984 /\n" + " 26 MAY 1984 /\n" + " 26 MAY 1985 /\n" // write + " 27 MAY 1985 /\n" + " 1 JAN 1986 /\n" + "/\n"; + + auto deck = Parser().parseString( data, ParseContext() ); + RestartConfig ioConfig( *deck ); + + for( size_t ts : { 1, 2, 3, 4, 5, 7, 8, 10, 11 } ) + BOOST_CHECK( !ioConfig.getWriteRestartFile( ts ) ); + + for( size_t ts : { 6, 9 } ) + BOOST_CHECK( ioConfig.getWriteRestartFile( ts ) ); +} + +BOOST_AUTO_TEST_CASE(RESTART_BASIC_LEQ_2) { + const char* data = "RUNSPEC\n" + "DIMENS\n" + " 10 10 10 /\n" + "GRID\n" + "START\n" + " 21 MAY 1981 /\n" + "\n" + "SCHEDULE\n" + "RPTRST\n" + "BASIC=1" + "/\n" + "DATES\n" + " 22 MAY 1981 /\n" + "/\n" + "RPTSCHED\n" + "RESTART=0\n" + "/\n" + "DATES\n" + " 23 MAY 1981 /\n" + " 24 MAY 1981 /\n" + " 23 MAY 1982 /\n" + " 24 MAY 1982 /\n" + " 24 MAY 1983 /\n" + " 25 MAY 1984 /\n" + " 26 MAY 1984 /\n" + " 26 MAY 1985 /\n" + " 27 MAY 1985 /\n" + " 1 JAN 1986 /\n" + "/\n"; + + auto deck = Parser().parseString( data, ParseContext() ); + RestartConfig ioConfig( *deck ); + + BOOST_CHECK( ioConfig.getWriteRestartFile( 1 ) ); + for( size_t ts = 2; ts < 11; ++ts ) + BOOST_CHECK( !ioConfig.getWriteRestartFile( ts ) ); +} + + + diff --git a/ThirdParty/custom-opm-parser/opm-parser/opm/parser/eclipse/EclipseState/Schedule/Completion.cpp b/ThirdParty/custom-opm-parser/opm-parser/opm/parser/eclipse/EclipseState/Schedule/Completion.cpp index 1d2ee2b9ad..fb083cbaa4 100644 --- a/ThirdParty/custom-opm-parser/opm-parser/opm/parser/eclipse/EclipseState/Schedule/Completion.cpp +++ b/ThirdParty/custom-opm-parser/opm-parser/opm/parser/eclipse/EclipseState/Schedule/Completion.cpp @@ -17,19 +17,24 @@ along with OPM. If not, see . */ +#include #include #include #include #include #include +#include #include #include +#include #include namespace Opm { - Completion::Completion(int i, int j , int k , WellCompletion::StateEnum state , + Completion::Completion(int i, int j , int k , + double depth, + WellCompletion::StateEnum state , const Value& connectionTransmissibilityFactor, const Value& diameter, const Value& skinFactor, @@ -42,7 +47,7 @@ namespace Opm { m_state(state), m_direction(direction), m_segment_number(-1), - m_center_depth(-1.e100) + m_center_depth( depth ) {} Completion::Completion(std::shared_ptr oldCompletion, WellCompletion::StateEnum newStatus) @@ -136,12 +141,22 @@ namespace Opm { disentangled, and each completion is returned separately. */ - std::pair > Completion::completionsFromCOMPDATRecord( const DeckRecord& compdatRecord ) { + inline std::vector< CompletionPtr > + fromCOMPDAT( const EclipseGrid& grid, const DeckRecord& compdatRecord, const Well& well ) { + std::vector completions; - std::string well = compdatRecord.getItem("WELL").getTrimmedString(0); + // We change from eclipse's 1 - n, to a 0 - n-1 solution - int I = compdatRecord.getItem("I").get< int >(0) - 1; - int J = compdatRecord.getItem("J").get< int >(0) - 1; + // I and J can be defaulted with 0 or *, in which case they are fetched + // from the well head + const auto& itemI = compdatRecord.getItem( "I" ); + const auto defaulted_I = itemI.defaultApplied( 0 ) || itemI.get< int >( 0 ) == 0; + const int I = !defaulted_I ? itemI.get< int >( 0 ) - 1 : well.getHeadI(); + + const auto& itemJ = compdatRecord.getItem( "J" ); + const auto defaulted_J = itemJ.defaultApplied( 0 ) || itemJ.get< int >( 0 ) == 0; + const int J = !defaulted_J ? itemJ.get< int >( 0 ) - 1 : well.getHeadJ(); + int K1 = compdatRecord.getItem("K1").get< int >(0) - 1; int K2 = compdatRecord.getItem("K2").get< int >(0) - 1; WellCompletion::StateEnum state = WellCompletion::StateEnumFromString( compdatRecord.getItem("STATE").getTrimmedString(0) ); @@ -167,11 +182,12 @@ namespace Opm { const WellCompletion::DirectionEnum direction = WellCompletion::DirectionEnumFromString(compdatRecord.getItem("DIR").getTrimmedString(0)); for (int k = K1; k <= K2; k++) { - CompletionPtr completion(new Completion(I , J , k , state , connectionTransmissibilityFactor, diameter, skinFactor, direction )); + double depth = grid.getCellDepth( I,J,k ); + CompletionPtr completion(new Completion(I , J , k , depth , state , connectionTransmissibilityFactor, diameter, skinFactor, direction )); completions.push_back( completion ); } - return std::pair >( well , completions ); + return completions; } /* @@ -184,25 +200,32 @@ namespace Opm { } */ + std::map< std::string, std::vector< CompletionPtr > > + Completion::fromCOMPDAT( const EclipseGrid& grid , + const DeckKeyword& compdatKeyword, + const std::vector< const Well* >& wells ) { - std::map > Completion::completionsFromCOMPDATKeyword( const DeckKeyword& compdatKeyword ) { - std::map > completionMapList; - for (size_t recordIndex = 0; recordIndex < compdatKeyword.size(); recordIndex++) { - std::pair > wellCompletionsPair = completionsFromCOMPDATRecord( compdatKeyword.getRecord( recordIndex )); - std::string well = wellCompletionsPair.first; - std::vector& newCompletions = wellCompletionsPair.second; + std::map< std::string, std::vector< CompletionPtr > > res; - if (completionMapList.find(well) == completionMapList.end()) - completionMapList[well] = std::vector(); + for( const auto& record : compdatKeyword ) { - { - std::vector& currentCompletions = completionMapList.find(well)->second; + const auto wellname = record.getItem( "WELL" ).getTrimmedString( 0 ); + const auto name_eq = [&]( const Well* w ) { + return w->name() == wellname; + }; - for (size_t ic = 0; ic < newCompletions.size(); ic++) - currentCompletions.push_back( newCompletions[ic] ); - } + auto well = std::find_if( wells.begin(), wells.end(), name_eq ); + + if( well == wells.end() ) continue; + + auto completions = Opm::fromCOMPDAT( grid, record, **well ); + + res[ wellname ].insert( res[ wellname ].end(), + completions.begin(), + completions.end() ); } - return completionMapList; + + return res; } void Completion::fixDefaultIJ(int wellHeadI , int wellHeadJ) { diff --git a/ThirdParty/custom-opm-parser/opm-parser/opm/parser/eclipse/EclipseState/Schedule/Completion.hpp b/ThirdParty/custom-opm-parser/opm-parser/opm/parser/eclipse/EclipseState/Schedule/Completion.hpp index 66bad5e36a..f5e3425eb4 100644 --- a/ThirdParty/custom-opm-parser/opm-parser/opm/parser/eclipse/EclipseState/Schedule/Completion.hpp +++ b/ThirdParty/custom-opm-parser/opm-parser/opm/parser/eclipse/EclipseState/Schedule/Completion.hpp @@ -34,10 +34,14 @@ namespace Opm { class DeckKeyword; class DeckRecord; + class Well; + class EclipseGrid; class Completion { public: - Completion(int i, int j , int k , WellCompletion::StateEnum state , + Completion(int i, int j , int k , + double depth, + WellCompletion::StateEnum state , const Value& connectionTransmissibilityFactor, const Value& diameter, const Value& skinFactor, @@ -67,8 +71,10 @@ namespace Opm { WellCompletion::DirectionEnum getDirection() const; - static std::map > > completionsFromCOMPDATKeyword( const DeckKeyword& compdatKeyword ); - static std::pair > > completionsFromCOMPDATRecord( const DeckRecord& compdatRecord ); + static std::map< std::string, std::vector< std::shared_ptr< Completion > > > + fromCOMPDAT( const EclipseGrid& grid, + const DeckKeyword& compdatKeyword, + const std::vector< const Well* >& ); private: int m_i, m_j, m_k; diff --git a/ThirdParty/custom-opm-parser/opm-parser/opm/parser/eclipse/EclipseState/Schedule/CompletionSet.cpp b/ThirdParty/custom-opm-parser/opm-parser/opm/parser/eclipse/EclipseState/Schedule/CompletionSet.cpp index a4bb1bacf1..9aa73129b4 100644 --- a/ThirdParty/custom-opm-parser/opm-parser/opm/parser/eclipse/EclipseState/Schedule/CompletionSet.cpp +++ b/ThirdParty/custom-opm-parser/opm-parser/opm/parser/eclipse/EclipseState/Schedule/CompletionSet.cpp @@ -94,7 +94,7 @@ namespace Opm { - void CompletionSet::orderCompletions(size_t well_i, size_t well_j, EclipseGridConstPtr grid) + void CompletionSet::orderCompletions(size_t well_i, size_t well_j) { if (m_completions.empty()) { return; @@ -102,42 +102,42 @@ namespace Opm { // Find the first completion and swap it into the 0-position. const double surface_z = 0.0; - size_t first_index = findClosestCompletion(well_i, well_j, grid, surface_z, 0); + size_t first_index = findClosestCompletion(well_i, well_j, surface_z, 0); std::swap(m_completions[first_index], m_completions[0]); // Repeat for remaining completions. - // Note that since findClosestCompletion() is O(n) if n is the number of completions, - // this is an O(n^2) algorithm. However, it should be acceptable since the expected - // number of completions is fairly low (< 100). + // + // Note that since findClosestCompletion() is O(n), this is an + // O(n^2) algorithm. However, it should be acceptable since + // the expected number of completions is fairly low (< 100). + for (size_t pos = 1; pos < m_completions.size() - 1; ++pos) { CompletionConstPtr prev = m_completions[pos - 1]; - const double prevz = grid->getCellDepth(prev->getI(), prev->getJ(), prev->getK()); - size_t next_index = findClosestCompletion(prev->getI(), prev->getJ(), grid, prevz, pos); + const double prevz = prev->getCenterDepth(); + size_t next_index = findClosestCompletion(prev->getI(), prev->getJ(), prevz, pos); std::swap(m_completions[next_index], m_completions[pos]); } } - size_t CompletionSet::findClosestCompletion(int oi, int oj, EclipseGridConstPtr grid, - double oz, size_t start_pos) + size_t CompletionSet::findClosestCompletion(int oi, int oj, double oz, size_t start_pos) { size_t closest = std::numeric_limits::max(); int min_ijdist2 = std::numeric_limits::max(); double min_zdiff = std::numeric_limits::max(); for (size_t pos = start_pos; pos < m_completions.size(); ++pos) { + const double depth = m_completions[pos]->getCenterDepth(); const int ci = m_completions[pos]->getI(); const int cj = m_completions[pos]->getJ(); // Using square of distance to avoid non-integer arithmetics. const int ijdist2 = (ci - oi) * (ci - oi) + (cj - oj) * (cj - oj); if (ijdist2 < min_ijdist2) { min_ijdist2 = ijdist2; - const int ck = m_completions[pos]->getK(); - min_zdiff = std::abs(grid->getCellDepth(ci, cj, ck) - oz); + min_zdiff = std::abs(depth - oz); closest = pos; } else if (ijdist2 == min_ijdist2) { - const int ck = m_completions[pos]->getK(); - const double zdiff = std::abs(grid->getCellDepth(ci, cj, ck) - oz); + const double zdiff = std::abs(depth - oz); if (zdiff < min_zdiff) { min_zdiff = zdiff; closest = pos; diff --git a/ThirdParty/custom-opm-parser/opm-parser/opm/parser/eclipse/EclipseState/Schedule/CompletionSet.hpp b/ThirdParty/custom-opm-parser/opm-parser/opm/parser/eclipse/EclipseState/Schedule/CompletionSet.hpp index da4dec348b..1361e0630b 100644 --- a/ThirdParty/custom-opm-parser/opm-parser/opm/parser/eclipse/EclipseState/Schedule/CompletionSet.hpp +++ b/ThirdParty/custom-opm-parser/opm-parser/opm/parser/eclipse/EclipseState/Schedule/CompletionSet.hpp @@ -27,8 +27,6 @@ namespace Opm { - class EclipseGrid; - class CompletionSet { public: using const_iterator = std::vector< std::shared_ptr< const Completion > >::const_iterator; @@ -56,11 +54,10 @@ namespace Opm { /// \param[in] well_i logical cartesian i-coordinate of well head /// \param[in] well_j logical cartesian j-coordinate of well head /// \param[in] grid EclipseGrid object, used for cell depths - void orderCompletions(size_t well_i, size_t well_j, std::shared_ptr< const EclipseGrid > grid); + void orderCompletions(size_t well_i, size_t well_j); private: std::vector> m_completions; - size_t findClosestCompletion(int oi, int oj, std::shared_ptr< const EclipseGrid > grid, - double oz, size_t start_pos); + size_t findClosestCompletion(int oi, int oj, double oz, size_t start_pos); }; typedef std::shared_ptr CompletionSetPtr; diff --git a/ThirdParty/custom-opm-parser/opm-parser/opm/parser/eclipse/EclipseState/Schedule/DynamicState.hpp b/ThirdParty/custom-opm-parser/opm-parser/opm/parser/eclipse/EclipseState/Schedule/DynamicState.hpp index bd94959a1d..f65b77779f 100644 --- a/ThirdParty/custom-opm-parser/opm-parser/opm/parser/eclipse/EclipseState/Schedule/DynamicState.hpp +++ b/ThirdParty/custom-opm-parser/opm-parser/opm/parser/eclipse/EclipseState/Schedule/DynamicState.hpp @@ -68,6 +68,12 @@ namespace Opm { } + const T& back() const { + if (m_data.size() > 0) + return m_data.back(); + else + return m_initialValue; + } const T& at(size_t index) const { if (index >= m_timeMap->size()) @@ -85,14 +91,8 @@ namespace Opm { } - T get(size_t index) const { - if (index >= m_timeMap->size()) - throw std::range_error("Index value is out range."); - - if (index >= m_data.size()) - return m_currentValue; - - return m_data[index]; + const T& get(size_t index) const { + return this->at( index ); } diff --git a/ThirdParty/custom-opm-parser/opm-parser/opm/parser/eclipse/EclipseState/Schedule/DynamicVector.hpp b/ThirdParty/custom-opm-parser/opm-parser/opm/parser/eclipse/EclipseState/Schedule/DynamicVector.hpp index fa6ed8a6cd..92b3d4fdda 100644 --- a/ThirdParty/custom-opm-parser/opm-parser/opm/parser/eclipse/EclipseState/Schedule/DynamicVector.hpp +++ b/ThirdParty/custom-opm-parser/opm-parser/opm/parser/eclipse/EclipseState/Schedule/DynamicVector.hpp @@ -24,8 +24,6 @@ #include -#include -#include #include diff --git a/ThirdParty/custom-opm-parser/opm-parser/opm/parser/eclipse/EclipseState/Schedule/Group.cpp b/ThirdParty/custom-opm-parser/opm-parser/opm/parser/eclipse/EclipseState/Schedule/Group.cpp index e6e42ca585..5a1c6e7553 100644 --- a/ThirdParty/custom-opm-parser/opm-parser/opm/parser/eclipse/EclipseState/Schedule/Group.cpp +++ b/ThirdParty/custom-opm-parser/opm-parser/opm/parser/eclipse/EclipseState/Schedule/Group.cpp @@ -40,7 +40,7 @@ namespace Opm { std::shared_ptr > liquidTarget; std::shared_ptr > reservoirVolumeTarget; std::shared_ptr > efficiencyFactor; - std::shared_ptr > transferEfficiencyFactor; + std::shared_ptr > transferEfficiencyFactor; }; @@ -53,7 +53,7 @@ namespace Opm { liquidTarget( new DynamicState(timeMap , INVALID_GROUP_RATE)), reservoirVolumeTarget( new DynamicState(timeMap , INVALID_GROUP_RATE)), efficiencyFactor( new DynamicState(timeMap, INVALID_EFFICIENCY_FACTOR)), - transferEfficiencyFactor( new DynamicState(timeMap, false)) + transferEfficiencyFactor( new DynamicState(timeMap, false)) { } @@ -96,8 +96,9 @@ namespace Opm { Group::Group(const std::string& name_, TimeMapConstPtr timeMap , size_t creationTimeStep) : m_injection( new GroupInjection::InjectionData(timeMap) ), m_production( new GroupProduction::ProductionData( timeMap )), - m_wells( new DynamicState(timeMap , WellSetConstPtr(new WellSet() ))), - m_isProductionGroup( new DynamicState(timeMap, true)) + m_wells( new DynamicState< std::shared_ptr< const WellSet > >( timeMap , std::make_shared< const WellSet >() ) ), + m_isProductionGroup( timeMap, false), + m_isInjectionGroup( timeMap, false) { m_name = name_; m_creationTimeStep = creationTimeStep; @@ -117,15 +118,19 @@ namespace Opm { } bool Group::isProductionGroup(size_t timeStep) const { - return m_isProductionGroup->get(timeStep); + return bool( m_isProductionGroup.get(timeStep) ); } bool Group::isInjectionGroup(size_t timeStep) const { - return !m_isProductionGroup->get(timeStep); + return bool( m_isInjectionGroup.get(timeStep) ); } void Group::setProductionGroup(size_t timeStep, bool isProductionGroup_) { - m_isProductionGroup->update(timeStep, isProductionGroup_); + m_isProductionGroup.update(timeStep, isProductionGroup_); + } + + void Group::setInjectionGroup(size_t timeStep, bool isInjectionGroup_) { + m_isInjectionGroup.update(timeStep, isInjectionGroup_); } @@ -302,20 +307,18 @@ namespace Opm { /*****************************************************************/ - WellSetConstPtr Group::wellMap(size_t time_step) const { + std::shared_ptr< const WellSet > Group::wellMap(size_t time_step) const { return m_wells->get(time_step); } bool Group::hasWell(const std::string& wellName , size_t time_step) const { - WellSetConstPtr wellSet = wellMap(time_step); - return wellSet->hasWell(wellName); + return this->wellMap(time_step)->hasWell( wellName ); } - WellConstPtr Group::getWell(const std::string& wellName , size_t time_step) const { - WellSetConstPtr wellSet = wellMap(time_step); - return wellSet->getWell(wellName); + const Well* Group::getWell(const std::string& wellName , size_t time_step) const { + return this->wellMap( time_step )->getWell( wellName ); } const WellSet& Group::getWells( size_t time_step ) const { @@ -323,13 +326,12 @@ namespace Opm { } size_t Group::numWells(size_t time_step) const { - WellSetConstPtr wellSet = wellMap(time_step); - return wellSet->size(); + return wellMap(time_step)->size(); } - void Group::addWell(size_t time_step , WellPtr well) { - WellSetConstPtr wellSet = wellMap(time_step); - WellSetPtr newWellSet = WellSetPtr( wellSet->shallowCopy() ); + void Group::addWell(size_t time_step, Well* well ) { + auto wellSet = wellMap(time_step); + std::shared_ptr< WellSet > newWellSet( wellSet->shallowCopy() ); newWellSet->addWell(well); m_wells->update(time_step , newWellSet); @@ -337,8 +339,8 @@ namespace Opm { void Group::delWell(size_t time_step, const std::string& wellName) { - WellSetConstPtr wellSet = wellMap(time_step); - WellSetPtr newWellSet = WellSetPtr( wellSet->shallowCopy() ); + auto wellSet = wellMap(time_step); + std::shared_ptr< WellSet > newWellSet( wellSet->shallowCopy() ); newWellSet->delWell(wellName); m_wells->update(time_step , newWellSet); diff --git a/ThirdParty/custom-opm-parser/opm-parser/opm/parser/eclipse/EclipseState/Schedule/Group.hpp b/ThirdParty/custom-opm-parser/opm-parser/opm/parser/eclipse/EclipseState/Schedule/Group.hpp index e8ff6ef067..e34785a606 100644 --- a/ThirdParty/custom-opm-parser/opm-parser/opm/parser/eclipse/EclipseState/Schedule/Group.hpp +++ b/ThirdParty/custom-opm-parser/opm-parser/opm/parser/eclipse/EclipseState/Schedule/Group.hpp @@ -22,13 +22,13 @@ #define GROUP_HPP_ #include +#include #include #include namespace Opm { - template< typename > class DynamicState; class TimeMap; class Well; @@ -51,6 +51,7 @@ namespace Opm { bool isProductionGroup(size_t timeStep) const; bool isInjectionGroup(size_t timeStep) const; void setProductionGroup(size_t timeStep, bool isProductionGroup); + void setInjectionGroup(size_t timeStep, bool isInjectionGroup_); /******************************************************************/ void setInjectionPhase(size_t time_step , Phase::PhaseEnum phase); @@ -100,10 +101,10 @@ namespace Opm { /*****************************************************************/ bool hasWell(const std::string& wellName , size_t time_step) const; - std::shared_ptr< const Well > getWell(const std::string& wellName , size_t time_step) const; + const Well* getWell(const std::string& wellName , size_t time_step) const; const WellSet& getWells( size_t time_step ) const; size_t numWells(size_t time_step) const; - void addWell(size_t time_step , std::shared_ptr< Well > well); + void addWell(size_t time_step , Well* well); void delWell(size_t time_step, const std::string& wellName ); private: std::shared_ptr< const WellSet > wellMap(size_t time_step) const; @@ -113,7 +114,8 @@ namespace Opm { std::shared_ptr m_injection; std::shared_ptr m_production; std::shared_ptr> > m_wells; - std::shared_ptr > m_isProductionGroup; + DynamicState m_isProductionGroup; + DynamicState m_isInjectionGroup; }; typedef std::shared_ptr GroupPtr; typedef std::shared_ptr GroupConstPtr; diff --git a/ThirdParty/custom-opm-parser/opm-parser/opm/parser/eclipse/EclipseState/Schedule/GroupTree.cpp b/ThirdParty/custom-opm-parser/opm-parser/opm/parser/eclipse/EclipseState/Schedule/GroupTree.cpp index 8b2c493a4c..116d517bd6 100644 --- a/ThirdParty/custom-opm-parser/opm-parser/opm/parser/eclipse/EclipseState/Schedule/GroupTree.cpp +++ b/ThirdParty/custom-opm-parser/opm-parser/opm/parser/eclipse/EclipseState/Schedule/GroupTree.cpp @@ -30,6 +30,11 @@ namespace Opm { m_root = GroupTreeNode::createFieldNode(); } + GroupTree::GroupTree( const GroupTree& x ) : + m_root( GroupTreeNode::createFieldNode() ) { + deepCopy( x.m_root, this->m_root ); + } + void GroupTree::updateTree(const std::string& childName) { updateTree(childName, m_root->name()); } diff --git a/ThirdParty/custom-opm-parser/opm-parser/opm/parser/eclipse/EclipseState/Schedule/GroupTree.hpp b/ThirdParty/custom-opm-parser/opm-parser/opm/parser/eclipse/EclipseState/Schedule/GroupTree.hpp index 7d952e968a..bcb16139b8 100644 --- a/ThirdParty/custom-opm-parser/opm-parser/opm/parser/eclipse/EclipseState/Schedule/GroupTree.hpp +++ b/ThirdParty/custom-opm-parser/opm-parser/opm/parser/eclipse/EclipseState/Schedule/GroupTree.hpp @@ -32,6 +32,7 @@ namespace Opm { class GroupTree { public: GroupTree(); + GroupTree( const GroupTree& ); void updateTree(const std::string& childName); void updateTree(const std::string& childName, const std::string& parentName); @@ -42,6 +43,14 @@ namespace Opm { std::shared_ptr deepCopy() const; void printTree(std::ostream &os) const; + bool operator==( const GroupTree& rhs ) { + return this->m_root == rhs.m_root; + } + + bool operator!=( const GroupTree& rhs ) { + return !(*this == rhs ); + } + private: GroupTreeNodePtr m_root; diff --git a/ThirdParty/custom-opm-parser/opm-parser/opm/parser/eclipse/EclipseState/Schedule/MSW/Compsegs.cpp b/ThirdParty/custom-opm-parser/opm-parser/opm/parser/eclipse/EclipseState/Schedule/MSW/Compsegs.cpp index 43ef9f97f6..56c9a37fb6 100644 --- a/ThirdParty/custom-opm-parser/opm-parser/opm/parser/eclipse/EclipseState/Schedule/MSW/Compsegs.cpp +++ b/ThirdParty/custom-opm-parser/opm-parser/opm/parser/eclipse/EclipseState/Schedule/MSW/Compsegs.cpp @@ -78,17 +78,23 @@ namespace Opm { throw std::runtime_error("this way to obtain DISTANCE_END not implemented yet!"); } - WellCompletion::DirectionEnum direction; - if (record.getItem().hasValue(0)) { - direction = WellCompletion::DirectionEnumFromString(record.getItem().get< std::string >(0)); - } else if (!record.getItem().hasValue(0)) { + if( !record.getItem< ParserKeywords::COMPSEGS::DIRECTION >().hasValue( 0 ) && + !record.getItem< ParserKeywords::COMPSEGS::DISTANCE_END >().hasValue( 0 ) ) { throw std::runtime_error("the direction has to be specified when DISTANCE_END in the record is not specified"); } - if (record.getItem().hasValue(0)) { - if (!record.getItem().hasValue(0)) { - throw std::runtime_error("the direction has to be specified when END_IJK in the record is specified"); - } + if( record.getItem< ParserKeywords::COMPSEGS::END_IJK >().hasValue( 0 ) && + !record.getItem< ParserKeywords::COMPSEGS::DIRECTION >().hasValue( 0 ) ) { + throw std::runtime_error("the direction has to be specified when END_IJK in the record is specified"); + } + + /* + * Defaulted well completion. Must be non-defaulted if DISTANCE_END + * is set or a range is specified. If not this is effectively ignored. + */ + WellCompletion::DirectionEnum direction = WellCompletion::X; + if( record.getItem< ParserKeywords::COMPSEGS::DIRECTION >().hasValue( 0 ) ) { + direction = WellCompletion::DirectionEnumFromString(record.getItem().get< std::string >(0)); } double center_depth; diff --git a/ThirdParty/custom-opm-parser/opm-parser/opm/parser/eclipse/EclipseState/Schedule/OilVaporizationProperties.cpp b/ThirdParty/custom-opm-parser/opm-parser/opm/parser/eclipse/EclipseState/Schedule/OilVaporizationProperties.cpp index e10a70adb6..3ed27ad47c 100644 --- a/ThirdParty/custom-opm-parser/opm-parser/opm/parser/eclipse/EclipseState/Schedule/OilVaporizationProperties.cpp +++ b/ThirdParty/custom-opm-parser/opm-parser/opm/parser/eclipse/EclipseState/Schedule/OilVaporizationProperties.cpp @@ -20,11 +20,6 @@ namespace Opm { - - OilVaporizationProperties::OilVaporizationProperties(){ - - } - double OilVaporizationProperties::getMaxDRVDT() const{ if (m_type == Opm::OilVaporizationEnum::DRVDT){ return m_maxDRVDT; @@ -69,35 +64,60 @@ namespace Opm { } } - OilVaporizationPropertiesPtr OilVaporizationProperties::createOilVaporizationPropertiesDRSDT(double maximum, std::string option){ - auto ovp = OilVaporizationPropertiesPtr(new OilVaporizationProperties()); - ovp->m_type = Opm::OilVaporizationEnum::DRSDT; - ovp->m_maxDRSDT = maximum; + OilVaporizationProperties OilVaporizationProperties::createDRSDT(double maximum, std::string option){ + OilVaporizationProperties ovp; + ovp.m_type = Opm::OilVaporizationEnum::DRSDT; + ovp.m_maxDRSDT = maximum; if (option == "ALL"){ - ovp->m_maxDRSDT_allCells = true; + ovp.m_maxDRSDT_allCells = true; }else if (option == "FREE") { - ovp->m_maxDRSDT_allCells = false; + ovp.m_maxDRSDT_allCells = false; }else{ throw std::invalid_argument("Only ALL or FREE is allowed as option string"); } return ovp; } - OilVaporizationPropertiesPtr OilVaporizationProperties::createOilVaporizationPropertiesDRVDT(double maximum){ - auto ovp = OilVaporizationPropertiesPtr(new OilVaporizationProperties()); - ovp->m_type = Opm::OilVaporizationEnum::DRVDT; - ovp->m_maxDRVDT = maximum; + OilVaporizationProperties OilVaporizationProperties::createDRVDT(double maximum){ + OilVaporizationProperties ovp; + ovp.m_type = Opm::OilVaporizationEnum::DRVDT; + ovp.m_maxDRVDT = maximum; return ovp; - } - OilVaporizationPropertiesPtr OilVaporizationProperties::createOilVaporizationPropertiesVAPPARS(double vap1, double vap2){ - auto ovp = OilVaporizationPropertiesPtr(new OilVaporizationProperties()); - ovp->m_type = Opm::OilVaporizationEnum::VAPPARS; - ovp->m_vap1 = vap1; - ovp->m_vap2 = vap2; + OilVaporizationProperties OilVaporizationProperties::createVAPPARS(double vap1, double vap2){ + OilVaporizationProperties ovp; + ovp.m_type = Opm::OilVaporizationEnum::VAPPARS; + ovp.m_vap1 = vap1; + ovp.m_vap2 = vap2; return ovp; - } + bool OilVaporizationProperties::operator==( const OilVaporizationProperties& rhs ) const { + if( this->m_type == OilVaporizationEnum::UNDEF + || rhs.m_type == OilVaporizationEnum::UNDEF + || this->m_type != rhs.m_type ) return false; + + switch( this->m_type ) { + case OilVaporizationEnum::DRSDT: + return this->m_maxDRSDT == rhs.m_maxDRSDT + && this->m_maxDRSDT_allCells == rhs.m_maxDRSDT_allCells; + + case OilVaporizationEnum::DRVDT: + return this->m_maxDRVDT == rhs.m_maxDRVDT; + + case OilVaporizationEnum::VAPPARS: + return this->m_vap1 == rhs.m_vap1 + && this->m_vap2 == rhs.m_vap2; + + default: + throw std::logic_error( "UNDEF Oil vaporization property; this should never happen" ); + } + } + + bool OilVaporizationProperties::operator!=( const OilVaporizationProperties& rhs ) const { + return this->m_type == OilVaporizationEnum::UNDEF + || rhs.m_type == OilVaporizationEnum::UNDEF + || this->m_type != rhs.m_type; + } } diff --git a/ThirdParty/custom-opm-parser/opm-parser/opm/parser/eclipse/EclipseState/Schedule/OilVaporizationProperties.hpp b/ThirdParty/custom-opm-parser/opm-parser/opm/parser/eclipse/EclipseState/Schedule/OilVaporizationProperties.hpp index cc6100f73b..c843f824cb 100644 --- a/ThirdParty/custom-opm-parser/opm-parser/opm/parser/eclipse/EclipseState/Schedule/OilVaporizationProperties.hpp +++ b/ThirdParty/custom-opm-parser/opm-parser/opm/parser/eclipse/EclipseState/Schedule/OilVaporizationProperties.hpp @@ -32,14 +32,12 @@ namespace Opm * Any one of the three keywords {VAPPARS, DRSDT, DRVDT} will cancel previous settings of the other keywords. * Ask for type first and the ask for the correct values for this type, asking for values not valid for the current type will throw a logic exception. */ - class OilVaporizationProperties - { + class OilVaporizationProperties { public: + static OilVaporizationProperties createDRSDT(double maxDRSDT, std::string option); + static OilVaporizationProperties createDRVDT(double maxDRVDT); + static OilVaporizationProperties createVAPPARS(double vap1, double vap2); - - static std::shared_ptr createOilVaporizationPropertiesDRSDT(double maxDRSDT, std::string option); - static std::shared_ptr createOilVaporizationPropertiesDRVDT(double maxDRVDT); - static std::shared_ptr createOilVaporizationPropertiesVAPPARS(double vap1, double vap2); Opm::OilVaporizationEnum getType() const; double getVap1() const; double getVap2() const; @@ -47,16 +45,20 @@ namespace Opm double getMaxDRVDT() const; bool getOption() const; + /* + * if either argument was default constructed == will always be false + * and != will always be true + */ + bool operator==( const OilVaporizationProperties& ) const; + bool operator!=( const OilVaporizationProperties& ) const; + private: - OilVaporizationProperties(); - Opm::OilVaporizationEnum m_type; + Opm::OilVaporizationEnum m_type = OilVaporizationEnum::UNDEF; double m_vap1; double m_vap2; double m_maxDRSDT; double m_maxDRVDT; bool m_maxDRSDT_allCells; }; - typedef std::shared_ptr OilVaporizationPropertiesPtr; - typedef std::shared_ptr OilVaporizationPropertiesConstPtr; } #endif // DRSDT_H diff --git a/ThirdParty/custom-opm-parser/opm-parser/opm/parser/eclipse/EclipseState/Schedule/Schedule.cpp b/ThirdParty/custom-opm-parser/opm-parser/opm/parser/eclipse/EclipseState/Schedule/Schedule.cpp index 83f8635c35..6b6a532ec9 100644 --- a/ThirdParty/custom-opm-parser/opm-parser/opm/parser/eclipse/EclipseState/Schedule/Schedule.cpp +++ b/ThirdParty/custom-opm-parser/opm-parser/opm/parser/eclipse/EclipseState/Schedule/Schedule.cpp @@ -27,9 +27,7 @@ #include #include #include -#include #include -#include #include #include #include @@ -43,6 +41,7 @@ #include #include #include + #include #include #include @@ -58,41 +57,39 @@ namespace Opm { - static inline std::shared_ptr< TimeMap > createTimeMap( const Deck& deck ) { - boost::gregorian::date defaultStartTime( 1983, 1, 1 ); - boost::posix_time::ptime startTime( defaultStartTime ); + namespace { - if (deck.hasKeyword("START")) { - const auto& startKeyword = deck.getKeyword("START"); - startTime = TimeMap::timeFromEclipse(startKeyword.getRecord(0)); + time_t posixTime( const boost::posix_time::ptime& t) { + boost::posix_time::ptime epoch( boost::gregorian::date( 1970, 1, 1 ) ); + return time_t( ( t - epoch ).total_seconds() ); } - return std::make_shared< TimeMap >( startTime ); } + Schedule::Schedule(const ParseContext& parseContext, - std::shared_ptr grid, + const EclipseGrid& grid, std::shared_ptr< const Deck > deckptr ) : Schedule(parseContext, grid, *deckptr ) {} Schedule::Schedule( const ParseContext& parseContext, - std::shared_ptr grid, + const EclipseGrid& grid, const Deck& deck ) : - m_timeMap( createTimeMap( deck ) ), - m_grid( grid ) + m_timeMap( std::make_shared< TimeMap>( deck )), + m_rootGroupTree( m_timeMap, GroupTree{} ), + m_oilvaporizationproperties( m_timeMap, OilVaporizationProperties{} ), + m_events( m_timeMap ), + m_modifierDeck( m_timeMap, nullptr ), + m_tuning( m_timeMap ) + { - initializeNOSIM(deck); - m_tuning.reset(new Tuning(m_timeMap)); - m_events.reset(new Events(m_timeMap)); - m_modifierDeck.reset( new DynamicVector >( m_timeMap , std::shared_ptr( 0 ) )); + m_controlModeWHISTCTL = WellProducer::CMODE_UNDEFINED; addGroup( "FIELD", 0 ); - initRootGroupTreeNode(getTimeMap()); - initOilVaporization(getTimeMap()); if (Section::hasSCHEDULE(deck)) { std::shared_ptr scheduleSection = std::make_shared(deck); - iterateScheduleSection(parseContext , *scheduleSection ); + iterateScheduleSection(parseContext , *scheduleSection , grid ); } } @@ -101,27 +98,14 @@ namespace Opm { } time_t Schedule::posixStartTime() const { - boost::posix_time::ptime epoch( boost::gregorian::date( 1970, 1, 1 ) ); - return time_t( ( this->getStartTime() - epoch ).total_seconds() ); + return posixTime(this->getStartTime()); } - void Schedule::initOilVaporization(TimeMapConstPtr timeMap) { - m_oilvaporizationproperties.reset(new DynamicState(timeMap, OilVaporizationPropertiesPtr())); + time_t Schedule::posixEndTime() const { + return posixTime( this->m_timeMap->getEndTime() ); } - void Schedule::initRootGroupTreeNode(TimeMapConstPtr timeMap) { - m_rootGroupTree.reset(new DynamicState(timeMap, GroupTreePtr(new GroupTree()))); - } - - void Schedule::initializeNOSIM(const Deck& deck) { - if (deck.hasKeyword("NOSIM")){ - nosim = true; - } else { - nosim = false; - } - } - - void Schedule::iterateScheduleSection(const ParseContext& parseContext , const SCHEDULESection& section ) { + void Schedule::iterateScheduleSection(const ParseContext& parseContext , const SCHEDULESection& section , const EclipseGrid& grid) { /* geoModifiers is a list of geo modifiers which can be found in the schedule section. This is only partly supported, support is indicated by the bool @@ -152,97 +136,94 @@ namespace Opm { for (size_t keywordIdx = 0; keywordIdx < section.size(); ++keywordIdx) { const auto& keyword = section.getKeyword(keywordIdx); - if (keyword.name() == "DATES") { - handleDATES(keyword); + if (keyword.name() == "DATES") currentStep += keyword.size(); - } - if (keyword.name() == "TSTEP") { - handleTSTEP(keyword); + else if (keyword.name() == "TSTEP") currentStep += keyword.getRecord(0).getItem(0).size(); // This is a bit weird API. - } - if (keyword.name() == "WELSPECS") { - handleWELSPECS(section, keyword, currentStep); - } + else if (keyword.name() == "WELSPECS") + handleWELSPECS( section, keywordIdx, currentStep ); - if (keyword.name() == "WCONHIST") + else if (keyword.name() == "WHISTCTL") + handleWHISTCTL(parseContext, keyword); + + else if (keyword.name() == "WCONHIST") handleWCONHIST(keyword, currentStep); - if (keyword.name() == "WCONPROD") + else if (keyword.name() == "WCONPROD") handleWCONPROD(keyword, currentStep); - if (keyword.name() == "WCONINJE") + else if (keyword.name() == "WCONINJE") handleWCONINJE(section, keyword, currentStep); - if (keyword.name() == "WPOLYMER") + else if (keyword.name() == "WPOLYMER") handleWPOLYMER(keyword, currentStep); - if (keyword.name() == "WSOLVENT") + else if (keyword.name() == "WSOLVENT") handleWSOLVENT(keyword, currentStep); - if (keyword.name() == "WCONINJH") + else if (keyword.name() == "WCONINJH") handleWCONINJH(section, keyword, currentStep); - if (keyword.name() == "WGRUPCON") + else if (keyword.name() == "WGRUPCON") handleWGRUPCON(keyword, currentStep); - if (keyword.name() == "COMPDAT") - handleCOMPDAT(keyword, currentStep); + else if (keyword.name() == "COMPDAT") + handleCOMPDAT(keyword, currentStep, grid); - if (keyword.name() == "WELSEGS") + else if (keyword.name() == "WELSEGS") handleWELSEGS(keyword, currentStep); - if (keyword.name() == "COMPSEGS") + else if (keyword.name() == "COMPSEGS") handleCOMPSEGS(keyword, currentStep); - if (keyword.name() == "WELOPEN") + else if (keyword.name() == "WELOPEN") handleWELOPEN(keyword, currentStep , section.hasKeyword("COMPLUMP")); - if (keyword.name() == "WELTARG") + else if (keyword.name() == "WELTARG") handleWELTARG(section, keyword, currentStep); - if (keyword.name() == "GRUPTREE") + else if (keyword.name() == "GRUPTREE") handleGRUPTREE(keyword, currentStep); - if (keyword.name() == "GCONINJE") + else if (keyword.name() == "GCONINJE") handleGCONINJE(section, keyword, currentStep); - if (keyword.name() == "GCONPROD") + else if (keyword.name() == "GCONPROD") handleGCONPROD(keyword, currentStep); - if (keyword.name() == "GEFAC") + else if (keyword.name() == "GEFAC") handleGEFAC(keyword, currentStep); - if (keyword.name() == "TUNING") + else if (keyword.name() == "TUNING") handleTUNING(keyword, currentStep); - if (keyword.name() == "NOSIM") - handleNOSIM(); - - if (keyword.name() == "WRFT") + else if (keyword.name() == "WRFT") rftProperties.push_back( std::make_pair( &keyword , currentStep )); - if (keyword.name() == "WRFTPLT") + else if (keyword.name() == "WRFTPLT") rftProperties.push_back( std::make_pair( &keyword , currentStep )); - if (keyword.name() == "WPIMULT") + else if (keyword.name() == "WPIMULT") handleWPIMULT(keyword, currentStep); - if (keyword.name() == "COMPORD") + else if (keyword.name() == "COMPORD") handleCOMPORD(parseContext , keyword, currentStep); - if (keyword.name() == "DRSDT") + else if (keyword.name() == "DRSDT") handleDRSDT(keyword, currentStep); - if (keyword.name() == "DRVDT") + else if (keyword.name() == "DRVDT") handleDRVDT(keyword, currentStep); - if (keyword.name() == "VAPPARS") + else if (keyword.name() == "VAPPARS") handleVAPPARS(keyword, currentStep); + else if (keyword.name() == "WECON") + handleWECON(keyword, currentStep); - if (geoModifiers.find( keyword.name() ) != geoModifiers.end()) { + else if (geoModifiers.find( keyword.name() ) != geoModifiers.end()) { bool supported = geoModifiers.at( keyword.name() ); if (supported) { /* @@ -251,11 +232,11 @@ namespace Opm { index currentstep; then we fetch the deck (newly created - or old) from the container and add the keyword. */ - if (!m_modifierDeck->iget(currentStep)) - m_modifierDeck->iset( currentStep , std::make_shared( )); + if (!m_modifierDeck.iget(currentStep)) + m_modifierDeck.iset( currentStep , std::make_shared( )); - m_modifierDeck->iget( currentStep )->addKeyword( keyword ); - m_events->addEvent( ScheduleEvents::GEO_MODIFIER , currentStep); + m_modifierDeck.iget( currentStep )->addKeyword( keyword ); + m_events.addEvent( ScheduleEvents::GEO_MODIFIER , currentStep); } else { std::string msg = "OPM does not support grid property modifier " + keyword.name() + " in the Schedule section. Error at report: " + std::to_string( currentStep ); @@ -264,9 +245,6 @@ namespace Opm { } } - m_timeMap->initFirstTimestepsYears(); - m_timeMap->initFirstTimestepsMonths(); - for (auto rftPair = rftProperties.begin(); rftPair != rftProperties.end(); ++rftPair) { const DeckKeyword& keyword = *rftPair->first; size_t timeStep = rftPair->second; @@ -287,23 +265,30 @@ namespace Opm { } - void Schedule::handleDATES( const DeckKeyword& keyword) { - m_timeMap->addFromDATESKeyword(keyword); - } - - void Schedule::handleTSTEP( const DeckKeyword& keyword) { - m_timeMap->addFromTSTEPKeyword(keyword); - } - - bool Schedule::handleGroupFromWELSPECS(const std::string& groupName, GroupTreePtr newTree) const { + bool Schedule::handleGroupFromWELSPECS(const std::string& groupName, GroupTree& newTree) const { bool treeUpdated = false; - if (!newTree->getNode(groupName)) { + if (!newTree.getNode(groupName)) { treeUpdated = true; - newTree->updateTree(groupName); + newTree.updateTree(groupName); } return treeUpdated; } + void Schedule::handleWHISTCTL(const ParseContext& parseContext, const DeckKeyword& keyword) { + for( const auto& record : keyword ) { + const std::string& cmodeString = record.getItem("CMODE").getTrimmedString(0); + WellProducer::ControlModeEnum controlMode = WellProducer::ControlModeFromString( cmodeString ); + m_controlModeWHISTCTL = controlMode; + const std::string bhp_terminate = record.getItem("BPH_TERMINATE").getTrimmedString(0); + if (bhp_terminate == "YES") { + std::string msg = "The WHISTCTL keyword does not handle 'YES'. i.e. to terminate the run"; + m_messages.error(msg); + parseContext.handleError( ParseContext::UNSUPPORTED_TERMINATE_IF_BHP , m_messages, msg ); + } + + } + } + void Schedule::handleCOMPORD(const ParseContext& parseContext, const DeckKeyword& compordKeyword, size_t /* currentStep */) { for (const auto& record : compordKeyword) { @@ -318,9 +303,24 @@ namespace Opm { - void Schedule::handleWELSPECS( const SCHEDULESection& section, const DeckKeyword& keyword, size_t currentStep) { + void Schedule::handleWELSPECS( const SCHEDULESection& section, + size_t index, + size_t currentStep ) { bool needNewTree = false; - GroupTreePtr newTree = m_rootGroupTree->get(currentStep)->deepCopy(); + auto newTree = m_rootGroupTree.get(currentStep); + + const auto COMPORD_in_timestep = [&]() -> const DeckKeyword* { + auto itr = section.begin() + index; + for( ; itr != section.end(); ++itr ) { + if( itr->name() == "DATES" ) return nullptr; + if( itr->name() == "TSTEP" ) return nullptr; + if( itr->name() == "COMPORD" ) return std::addressof( *itr ); + } + + return nullptr; + }; + + const auto& keyword = section.getKeyword( index ); for (size_t recordNr = 0; recordNr < keyword.size(); recordNr++) { const auto& record = keyword.getRecord(recordNr); @@ -333,9 +333,8 @@ namespace Opm { if (!hasWell(wellName)) { WellCompletion::CompletionOrderEnum wellCompletionOrder = WellCompletion::TRACK; - DeckTimeStepConstPtr deckTimeStep = section.getDeckTimeStep(currentStep); - if (deckTimeStep->hasKeyword("COMPORD")) { - const auto& compord = deckTimeStep->getKeyword("COMPORD"); + if( const auto* compordp = COMPORD_in_timestep() ) { + const auto& compord = *compordp; for (size_t compordRecordNr = 0; compordRecordNr < compord.size(); compordRecordNr++) { const auto& compordRecord = compord.getRecord(compordRecordNr); @@ -350,10 +349,10 @@ namespace Opm { addWell(wellName, record, currentStep, wellCompletionOrder); } - WellConstPtr currentWell = getWell(wellName); - checkWELSPECSConsistency(currentWell, keyword, recordNr); + const auto* currentWell = getWell(wellName); + checkWELSPECSConsistency( *currentWell, keyword, recordNr); - addWellToGroup( getGroup(groupName) , getWell(wellName) , currentStep); + addWellToGroup( this->m_groups.at( groupName ), *this->m_wells.get( wellName ), currentStep); if (handleGroupFromWELSPECS(groupName, newTree)) needNewTree = true; @@ -362,8 +361,8 @@ namespace Opm { } if (needNewTree) { - m_rootGroupTree->update(currentStep, newTree); - m_events->addEvent( ScheduleEvents::GROUP_CHANGE , currentStep); + m_rootGroupTree.update(currentStep, newTree); + m_events.addEvent( ScheduleEvents::GROUP_CHANGE , currentStep); } } @@ -371,8 +370,8 @@ namespace Opm { for( const auto& record : keyword ) { double vap = record.getItem("OIL_VAP_PROPENSITY").get< double >(0); double density = record.getItem("OIL_DENSITY_PROPENSITY").get< double >(0); - OilVaporizationPropertiesPtr vappars = OilVaporizationProperties::createOilVaporizationPropertiesVAPPARS(vap, density); - setOilVaporizationProperties(vappars, currentStep); + auto vappars = OilVaporizationProperties::createVAPPARS(vap, density); + this->m_oilvaporizationproperties.update( currentStep, vappars ); } } @@ -380,8 +379,8 @@ namespace Opm { void Schedule::handleDRVDT( const DeckKeyword& keyword, size_t currentStep){ for( const auto& record : keyword ) { double max = record.getItem("DRVDT_MAX").getSIDouble(0); - OilVaporizationPropertiesPtr drvdt = OilVaporizationProperties::createOilVaporizationPropertiesDRVDT(max); - setOilVaporizationProperties(drvdt, currentStep); + auto drvdt = OilVaporizationProperties::createDRVDT(max); + this->m_oilvaporizationproperties.update( currentStep, drvdt ); } } @@ -391,24 +390,24 @@ namespace Opm { for( const auto& record : keyword ) { double max = record.getItem("DRSDT_MAX").getSIDouble(0); std::string option = record.getItem("Option").get< std::string >(0); - OilVaporizationPropertiesPtr drsdt = OilVaporizationProperties::createOilVaporizationPropertiesDRSDT(max, option); - setOilVaporizationProperties(drsdt, currentStep); + auto drsdt = OilVaporizationProperties::createDRSDT(max, option); + this->m_oilvaporizationproperties.update( currentStep, drsdt ); } } - void Schedule::checkWELSPECSConsistency(WellConstPtr well, const DeckKeyword& keyword, size_t recordIdx) { + void Schedule::checkWELSPECSConsistency( const Well& well, const DeckKeyword& keyword, size_t recordIdx) { const auto& record = keyword.getRecord(recordIdx); - if (well->getHeadI() != record.getItem("HEAD_I").get< int >(0) - 1) { + if (well.getHeadI() != record.getItem("HEAD_I").get< int >(0) - 1) { std::string msg = - "Unable process WELSPECS for well " + well->name() + ", HEAD_I deviates from existing value"; + "Unable process WELSPECS for well " + well.name() + ", HEAD_I deviates from existing value"; m_messages.error(keyword.getFileName(), msg, keyword.getLineNumber()); throw std::invalid_argument(msg); } - if (well->getHeadJ() != record.getItem("HEAD_J").get< int >(0) - 1) { + if (well.getHeadJ() != record.getItem("HEAD_J").get< int >(0) - 1) { std::string msg = - "Unable process WELSPECS for well " + well->name() + ", HEAD_J deviates from existing value"; + "Unable process WELSPECS for well " + well.name() + ", HEAD_J deviates from existing value"; m_messages.error(keyword.getFileName(), msg, keyword.getLineNumber()); throw std::invalid_argument(msg); } @@ -422,10 +421,9 @@ namespace Opm { const WellCommon::StatusEnum status = WellCommon::StatusFromString(record.getItem("STATUS").getTrimmedString(0)); - const std::vector wells = getWells(wellNamePattern); + auto wells = getWells(wellNamePattern); - for (auto wellIter=wells.begin(); wellIter != wells.end(); ++wellIter) { - WellPtr well = *wellIter; + for( auto* well : getWells( wellNamePattern ) ) { WellProductionProperties properties; @@ -445,6 +443,11 @@ namespace Opm { WellProducer::ControlModeEnum control = WellProducer::ControlModeFromString(cmodeString); + if ( m_controlModeWHISTCTL != WellProducer::CMODE_UNDEFINED && + m_controlModeWHISTCTL != WellProducer::NONE) { + control = m_controlModeWHISTCTL; // overwrite given control + } + if (properties.hasProductionControl(control)) { properties.controlMode = control; } @@ -456,9 +459,9 @@ namespace Opm { throw std::invalid_argument(msg); } } - updateWellStatus( well , currentStep , status ); + updateWellStatus( *well , currentStep , status ); if (well->setProductionProperties(currentStep, properties)) - m_events->addEvent( ScheduleEvents::PRODUCTION_UPDATE , currentStep); + m_events.addEvent( ScheduleEvents::PRODUCTION_UPDATE , currentStep); if ( !well->getAllowCrossFlow() && !isPredictionMode && (properties.OilRate + properties.WaterRate + properties.GasRate) == 0 ) { @@ -466,15 +469,15 @@ namespace Opm { "Well " + well->name() + " is a history matched well with zero rate where crossflow is banned. " + "This well will be closed at " + std::to_string ( m_timeMap->getTimePassedUntil(currentStep) / (60*60*24) ) + " days"; m_messages.note(msg); - updateWellStatus(well, currentStep, WellCommon::StatusEnum::SHUT ); + updateWellStatus( *well, currentStep, WellCommon::StatusEnum::SHUT ); } } } } - void Schedule::updateWellStatus(std::shared_ptr well, size_t reportStep , WellCommon::StatusEnum status) { - if (well->setStatus( reportStep , status )) - m_events->addEvent( ScheduleEvents::WELL_STATUS_CHANGE , reportStep ); + void Schedule::updateWellStatus( Well& well, size_t reportStep , WellCommon::StatusEnum status) { + if( well.setStatus( reportStep, status ) ) + m_events.addEvent( ScheduleEvents::WELL_STATUS_CHANGE, reportStep ); } @@ -502,10 +505,8 @@ namespace Opm { for( const auto& record : keyword ) { const std::string& wellNamePattern = record.getItem("WELL").getTrimmedString(0); double wellPi = record.getItem("WELLPI").get< double >(0); - std::vector wells = getWells(wellNamePattern); - for (auto wellIter=wells.begin(); wellIter != wells.end(); ++wellIter) { - WellPtr well = *wellIter; + for( auto* well : getWells( wellNamePattern ) ) { CompletionSetConstPtr currentCompletionSet = well->getCompletions(currentStep); CompletionSetPtr newCompletionSet(new CompletionSet( )); @@ -569,21 +570,19 @@ namespace Opm { void Schedule::handleWCONINJE( const SCHEDULESection& section, const DeckKeyword& keyword, size_t currentStep) { for( const auto& record : keyword ) { const std::string& wellNamePattern = record.getItem("WELL").getTrimmedString(0); - std::vector wells = getWells(wellNamePattern); - for (auto wellIter=wells.begin(); wellIter != wells.end(); ++wellIter) { - WellPtr well = *wellIter; + for( auto* well : getWells( wellNamePattern ) ) { WellInjector::TypeEnum injectorType = WellInjector::TypeFromString( record.getItem("TYPE").getTrimmedString(0) ); WellCommon::StatusEnum status = WellCommon::StatusFromString( record.getItem("STATUS").getTrimmedString(0)); - updateWellStatus( well , currentStep , status ); + updateWellStatus( *well , currentStep , status ); WellInjectionProperties properties(well->getInjectionPropertiesCopy(currentStep)); properties.injectorType = injectorType; properties.predictionMode = true; if (!record.getItem("RATE").defaultApplied(0)) { - properties.surfaceInjectionRate = convertInjectionRateToSI(record.getItem("RATE").get< double >(0) , injectorType, section.getActiveUnitSystem()); + properties.surfaceInjectionRate = convertInjectionRateToSI(record.getItem("RATE").get< double >(0) , injectorType, section.unitSystem()); properties.addInjectionControl(WellInjector::RATE); } else properties.dropInjectionControl(WellInjector::RATE); @@ -631,14 +630,14 @@ namespace Opm { } if (well->setInjectionProperties(currentStep, properties)) - m_events->addEvent( ScheduleEvents::INJECTION_UPDATE , currentStep ); + m_events.addEvent( ScheduleEvents::INJECTION_UPDATE , currentStep ); if ( ! well->getAllowCrossFlow() && (properties.surfaceInjectionRate == 0) ) { std::string msg = "Well " + well->name() + " is an injector with zero rate where crossflow is banned. " + "This well will be closed at " + std::to_string ( m_timeMap->getTimePassedUntil(currentStep) / (60*60*24) ) + " days"; m_messages.note(msg); - updateWellStatus(well, currentStep, WellCommon::StatusEnum::SHUT ); + updateWellStatus( *well, currentStep, WellCommon::StatusEnum::SHUT ); } } } @@ -648,11 +647,8 @@ namespace Opm { void Schedule::handleWPOLYMER( const DeckKeyword& keyword, size_t currentStep) { for( const auto& record : keyword ) { const std::string& wellNamePattern = record.getItem("WELL").getTrimmedString(0); - std::vector wells = getWells(wellNamePattern); - - for (auto wellIter=wells.begin(); wellIter != wells.end(); ++wellIter) { - WellPtr well = *wellIter; + for( auto* well : getWells( wellNamePattern ) ) { WellPolymerProperties properties(well->getPolymerPropertiesCopy(currentStep)); properties.m_polymerConcentration = record.getItem("POLYMER_CONCENTRATION").getSIDouble(0); @@ -673,14 +669,26 @@ namespace Opm { } } + + + void Schedule::handleWECON( const DeckKeyword& keyword, size_t currentStep) { + for( const auto& record : keyword ) { + const std::string& wellNamePattern = record.getItem("WELL").getTrimmedString(0); + WellEconProductionLimits econ_production_limits(record); + + for( auto* well : getWells( wellNamePattern ) ) { + well->setEconProductionLimits(currentStep, econ_production_limits); + } + } + } + + void Schedule::handleWSOLVENT( const DeckKeyword& keyword, size_t currentStep) { for( const auto& record : keyword ) { const std::string& wellNamePattern = record.getItem("WELL").getTrimmedString(0); - std::vector wells = getWells(wellNamePattern); - for (auto wellIter=wells.begin(); wellIter != wells.end(); ++wellIter) { - WellPtr well = *wellIter; + for( auto* well : getWells( wellNamePattern ) ) { WellInjectionProperties injectionProperties = well->getInjectionProperties( currentStep ); if (well->isInjector( currentStep ) && injectionProperties.injectorType == WellInjector::GAS) { double fraction = record.getItem("SOLVENT_FRACTION").get< double >(0); @@ -695,17 +703,17 @@ namespace Opm { void Schedule::handleWCONINJH( const SCHEDULESection& section, const DeckKeyword& keyword, size_t currentStep) { for( const auto& record : keyword ) { const std::string& wellName = record.getItem("WELL").getTrimmedString(0); - WellPtr well = getWell(wellName); // convert injection rates to SI WellInjector::TypeEnum injectorType = WellInjector::TypeFromString( record.getItem("TYPE").getTrimmedString(0)); double injectionRate = record.getItem("RATE").get< double >(0); - injectionRate = convertInjectionRateToSI(injectionRate, injectorType, section.getActiveUnitSystem()); + injectionRate = convertInjectionRateToSI(injectionRate, injectorType, section.unitSystem()); WellCommon::StatusEnum status = WellCommon::StatusFromString( record.getItem("STATUS").getTrimmedString(0)); - updateWellStatus(well , currentStep , status ); - WellInjectionProperties properties(well->getInjectionPropertiesCopy(currentStep)); + auto& well = *this->m_wells.get( wellName ); + updateWellStatus( well, currentStep, status ); + WellInjectionProperties properties(well.getInjectionPropertiesCopy(currentStep)); properties.injectorType = injectorType; @@ -718,15 +726,15 @@ namespace Opm { } properties.predictionMode = false; - if (well->setInjectionProperties(currentStep, properties)) - m_events->addEvent( ScheduleEvents::INJECTION_UPDATE , currentStep ); + if (well.setInjectionProperties(currentStep, properties)) + m_events.addEvent( ScheduleEvents::INJECTION_UPDATE , currentStep ); - if ( ! well->getAllowCrossFlow() && (injectionRate == 0) ) { + if ( ! well.getAllowCrossFlow() && (injectionRate == 0) ) { std::string msg = - "Well " + well->name() + " is an injector with zero rate where crossflow is banned. " + + "Well " + well.name() + " is an injector with zero rate where crossflow is banned. " + "This well will be closed at " + std::to_string ( m_timeMap->getTimePassedUntil(currentStep) / (60*60*24) ) + " days"; m_messages.note(msg); - updateWellStatus(well, currentStep, WellCommon::StatusEnum::SHUT ); + updateWellStatus( well, currentStep, WellCommon::StatusEnum::SHUT ); } } } @@ -746,10 +754,8 @@ namespace Opm { } const std::string& wellNamePattern = record.getItem("WELL").getTrimmedString(0); - const std::vector& wells = getWells(wellNamePattern); - for (auto wellIter=wells.begin(); wellIter != wells.end(); ++wellIter) { - WellPtr well = *wellIter; + for( auto* well : getWells( wellNamePattern ) ) { if(haveCompletionData){ CompletionSetConstPtr currentCompletionSet = well->getCompletions(currentStep); @@ -810,9 +816,9 @@ namespace Opm { } well->addCompletionSet(currentStep, newCompletionSet); - m_events->addEvent(ScheduleEvents::COMPLETION_CHANGE, currentStep); + m_events.addEvent(ScheduleEvents::COMPLETION_CHANGE, currentStep); if (newCompletionSet->allCompletionsShut()) - updateWellStatus( well , currentStep , WellCommon::StatusEnum::SHUT); + updateWellStatus( *well, currentStep, WellCommon::StatusEnum::SHUT); } else if(!haveCompletionData) { @@ -824,7 +830,7 @@ namespace Opm { m_messages.note(msg); continue; } - updateWellStatus( well , currentStep , status ); + updateWellStatus( *well, currentStep, status ); } } } @@ -843,7 +849,7 @@ namespace Opm { */ void Schedule::handleWELTARG( const SCHEDULESection& section , const DeckKeyword& keyword, size_t currentStep) { - Opm::UnitSystem unitSystem = section.getActiveUnitSystem(); + Opm::UnitSystem unitSystem = section.unitSystem(); double siFactorL = unitSystem.parse("LiquidSurfaceVolume/Time")->getSIScaling(); double siFactorG = unitSystem.parse("GasSurfaceVolume/Time")->getSIScaling(); double siFactorP = unitSystem.parse("Pressure")->getSIScaling(); @@ -853,10 +859,15 @@ namespace Opm { const std::string& wellNamePattern = record.getItem("WELL").getTrimmedString(0); const std::string& cMode = record.getItem("CMODE").getTrimmedString(0); double newValue = record.getItem("NEW_VALUE").get< double >(0); - const std::vector& wells = getWells(wellNamePattern); - for (auto wellIter=wells.begin(); wellIter != wells.end(); ++wellIter) { - WellPtr well = *wellIter; + const auto wells = getWells( wellNamePattern ); + + if( wells.empty() ) + throw std::invalid_argument( + wellNamePattern + " does not match any wells. " + + "Specify wells with the WCONxxxx keywords." ); + + for( auto* well : wells ) { if(well->isProducer(currentStep)){ WellProductionProperties prop = well->getProductionPropertiesCopy(currentStep); @@ -959,52 +970,52 @@ namespace Opm { void Schedule::handleGCONINJE( const SCHEDULESection& section, const DeckKeyword& keyword, size_t currentStep) { for( const auto& record : keyword ) { const std::string& groupName = record.getItem("GROUP").getTrimmedString(0); - GroupPtr group = getGroup(groupName); + auto& group = this->m_groups.at( groupName ); { Phase::PhaseEnum phase = Phase::PhaseEnumFromString( record.getItem("PHASE").getTrimmedString(0) ); - group->setInjectionPhase( currentStep , phase ); + group.setInjectionPhase( currentStep , phase ); } { GroupInjection::ControlEnum controlMode = GroupInjection::ControlEnumFromString( record.getItem("CONTROL_MODE").getTrimmedString(0) ); - group->setInjectionControlMode( currentStep , controlMode ); + group.setInjectionControlMode( currentStep , controlMode ); } Phase::PhaseEnum wellPhase = Phase::PhaseEnumFromString( record.getItem("PHASE").getTrimmedString(0)); // calculate SI injection rates for the group double surfaceInjectionRate = record.getItem("SURFACE_TARGET").get< double >(0); - surfaceInjectionRate = convertInjectionRateToSI(surfaceInjectionRate, wellPhase, section.getActiveUnitSystem()); + surfaceInjectionRate = convertInjectionRateToSI(surfaceInjectionRate, wellPhase, section.unitSystem()); double reservoirInjectionRate = record.getItem("RESV_TARGET").getSIDouble(0); - group->setSurfaceMaxRate( currentStep , surfaceInjectionRate); - group->setReservoirMaxRate( currentStep , reservoirInjectionRate); - group->setTargetReinjectFraction( currentStep , record.getItem("REINJ_TARGET").getSIDouble(0)); - group->setTargetVoidReplacementFraction( currentStep , record.getItem("VOIDAGE_TARGET").getSIDouble(0)); + group.setSurfaceMaxRate( currentStep , surfaceInjectionRate); + group.setReservoirMaxRate( currentStep , reservoirInjectionRate); + group.setTargetReinjectFraction( currentStep , record.getItem("REINJ_TARGET").getSIDouble(0)); + group.setTargetVoidReplacementFraction( currentStep , record.getItem("VOIDAGE_TARGET").getSIDouble(0)); - group->setProductionGroup(currentStep, false); + group.setInjectionGroup(currentStep, true); } } void Schedule::handleGCONPROD( const DeckKeyword& keyword, size_t currentStep) { for( const auto& record : keyword ) { const std::string& groupName = record.getItem("GROUP").getTrimmedString(0); - GroupPtr group = getGroup(groupName); + auto& group = this->m_groups.at( groupName ); { GroupProduction::ControlEnum controlMode = GroupProduction::ControlEnumFromString( record.getItem("CONTROL_MODE").getTrimmedString(0) ); - group->setProductionControlMode( currentStep , controlMode ); + group.setProductionControlMode( currentStep , controlMode ); } - group->setOilTargetRate( currentStep , record.getItem("OIL_TARGET").getSIDouble(0)); - group->setGasTargetRate( currentStep , record.getItem("GAS_TARGET").getSIDouble(0)); - group->setWaterTargetRate( currentStep , record.getItem("WATER_TARGET").getSIDouble(0)); - group->setLiquidTargetRate( currentStep , record.getItem("LIQUID_TARGET").getSIDouble(0)); - group->setReservoirVolumeTargetRate( currentStep , record.getItem("RESERVOIR_FLUID_TARGET").getSIDouble(0)); + group.setOilTargetRate( currentStep , record.getItem("OIL_TARGET").getSIDouble(0)); + group.setGasTargetRate( currentStep , record.getItem("GAS_TARGET").getSIDouble(0)); + group.setWaterTargetRate( currentStep , record.getItem("WATER_TARGET").getSIDouble(0)); + group.setLiquidTargetRate( currentStep , record.getItem("LIQUID_TARGET").getSIDouble(0)); + group.setReservoirVolumeTargetRate( currentStep , record.getItem("RESERVOIR_FLUID_TARGET").getSIDouble(0)); { GroupProductionExceedLimit::ActionEnum exceedAction = GroupProductionExceedLimit::ActionEnumFromString(record.getItem("EXCEED_PROC").getTrimmedString(0) ); - group->setProductionExceedLimitAction( currentStep , exceedAction ); + group.setProductionExceedLimitAction( currentStep , exceedAction ); } - group->setProductionGroup(currentStep, true); + group.setProductionGroup(currentStep, true); } } @@ -1012,13 +1023,13 @@ namespace Opm { void Schedule::handleGEFAC( const DeckKeyword& keyword, size_t currentStep) { for( const auto& record : keyword ) { const std::string& groupName = record.getItem("GROUP").getTrimmedString(0); - GroupPtr group = getGroup(groupName); + auto& group = this->m_groups.at( groupName ); - group->setGroupEfficiencyFactor(currentStep, record.getItem("EFFICIENCY_FACTOR").get< double >(0)); + group.setGroupEfficiencyFactor(currentStep, record.getItem("EFFICIENCY_FACTOR").get< double >(0)); const std::string& transfer_str = record.getItem("TRANSFER_EXT_NET").getTrimmedString(0); bool transfer = (transfer_str == "YES") ? true : false; - group->setTransferGroupEfficiencyFactor(currentStep, transfer); + group.setTransferGroupEfficiencyFactor(currentStep, transfer); } } @@ -1031,36 +1042,36 @@ namespace Opm { const auto& record1 = keyword.getRecord(0); double TSINIT = record1.getItem("TSINIT").getSIDouble(0); - m_tuning->setTSINIT(currentStep, TSINIT); + this->m_tuning.setTSINIT(currentStep, TSINIT); double TSMAXZ = record1.getItem("TSMAXZ").getSIDouble(0); - m_tuning->setTSMAXZ(currentStep, TSMAXZ); + this->m_tuning.setTSMAXZ(currentStep, TSMAXZ); double TSMINZ = record1.getItem("TSMINZ").getSIDouble(0); - m_tuning->setTSMINZ(currentStep, TSMINZ); + this->m_tuning.setTSMINZ(currentStep, TSMINZ); double TSMCHP = record1.getItem("TSMCHP").getSIDouble(0); - m_tuning->setTSMCHP(currentStep, TSMCHP); + this->m_tuning.setTSMCHP(currentStep, TSMCHP); double TSFMAX = record1.getItem("TSFMAX").get< double >(0); - m_tuning->setTSFMAX(currentStep, TSFMAX); + this->m_tuning.setTSFMAX(currentStep, TSFMAX); double TSFMIN = record1.getItem("TSFMIN").get< double >(0); - m_tuning->setTSFMIN(currentStep, TSFMIN); + this->m_tuning.setTSFMIN(currentStep, TSFMIN); double TSFCNV = record1.getItem("TSFCNV").get< double >(0); - m_tuning->setTSFCNV(currentStep, TSFCNV); + this->m_tuning.setTSFCNV(currentStep, TSFCNV); double TFDIFF = record1.getItem("TFDIFF").get< double >(0); - m_tuning->setTFDIFF(currentStep, TFDIFF); + this->m_tuning.setTFDIFF(currentStep, TFDIFF); double THRUPT = record1.getItem("THRUPT").get< double >(0); - m_tuning->setTHRUPT(currentStep, THRUPT); + this->m_tuning.setTHRUPT(currentStep, THRUPT); const auto& TMAXWCdeckItem = record1.getItem("TMAXWC"); if (TMAXWCdeckItem.hasValue(0)) { double TMAXWC = TMAXWCdeckItem.getSIDouble(0); - m_tuning->setTMAXWC(currentStep, TMAXWC); + this->m_tuning.setTMAXWC(currentStep, TMAXWC); } } @@ -1069,46 +1080,46 @@ namespace Opm { const auto& record2 = keyword.getRecord(1); double TRGTTE = record2.getItem("TRGTTE").get< double >(0); - m_tuning->setTRGTTE(currentStep, TRGTTE); + this->m_tuning.setTRGTTE(currentStep, TRGTTE); double TRGCNV = record2.getItem("TRGCNV").get< double >(0); - m_tuning->setTRGCNV(currentStep, TRGCNV); + this->m_tuning.setTRGCNV(currentStep, TRGCNV); double TRGMBE = record2.getItem("TRGMBE").get< double >(0); - m_tuning->setTRGMBE(currentStep, TRGMBE); + this->m_tuning.setTRGMBE(currentStep, TRGMBE); double TRGLCV = record2.getItem("TRGLCV").get< double >(0); - m_tuning->setTRGLCV(currentStep, TRGLCV); + this->m_tuning.setTRGLCV(currentStep, TRGLCV); double XXXTTE = record2.getItem("XXXTTE").get< double >(0); - m_tuning->setXXXTTE(currentStep, XXXTTE); + this->m_tuning.setXXXTTE(currentStep, XXXTTE); double XXXCNV = record2.getItem("XXXCNV").get< double >(0); - m_tuning->setXXXCNV(currentStep, XXXCNV); + this->m_tuning.setXXXCNV(currentStep, XXXCNV); double XXXMBE = record2.getItem("XXXMBE").get< double >(0); - m_tuning->setXXXMBE(currentStep, XXXMBE); + this->m_tuning.setXXXMBE(currentStep, XXXMBE); double XXXLCV = record2.getItem("XXXLCV").get< double >(0); - m_tuning->setXXXLCV(currentStep, XXXLCV); + this->m_tuning.setXXXLCV(currentStep, XXXLCV); double XXXWFL = record2.getItem("XXXWFL").get< double >(0); - m_tuning->setXXXWFL(currentStep, XXXWFL); + this->m_tuning.setXXXWFL(currentStep, XXXWFL); double TRGFIP = record2.getItem("TRGFIP").get< double >(0); - m_tuning->setTRGFIP(currentStep, TRGFIP); + this->m_tuning.setTRGFIP(currentStep, TRGFIP); const auto& TRGSFTdeckItem = record2.getItem("TRGSFT"); if (TRGSFTdeckItem.hasValue(0)) { double TRGSFT = TRGSFTdeckItem.get< double >(0); - m_tuning->setTRGSFT(currentStep, TRGSFT); + this->m_tuning.setTRGSFT(currentStep, TRGSFT); } double THIONX = record2.getItem("THIONX").get< double >(0); - m_tuning->setTHIONX(currentStep, THIONX); + this->m_tuning.setTHIONX(currentStep, THIONX); int TRWGHT = record2.getItem("TRWGHT").get< int >(0); - m_tuning->setTRWGHT(currentStep, TRWGHT); + this->m_tuning.setTRWGHT(currentStep, TRWGHT); } @@ -1116,55 +1127,57 @@ namespace Opm { const auto& record3 = keyword.getRecord(2); int NEWTMX = record3.getItem("NEWTMX").get< int >(0); - m_tuning->setNEWTMX(currentStep, NEWTMX); + this->m_tuning.setNEWTMX(currentStep, NEWTMX); int NEWTMN = record3.getItem("NEWTMN").get< int >(0); - m_tuning->setNEWTMN(currentStep, NEWTMN); + this->m_tuning.setNEWTMN(currentStep, NEWTMN); int LITMAX = record3.getItem("LITMAX").get< int >(0); - m_tuning->setLITMAX(currentStep, LITMAX); + this->m_tuning.setLITMAX(currentStep, LITMAX); int LITMIN = record3.getItem("LITMIN").get< int >(0); - m_tuning->setLITMIN(currentStep, LITMIN); + this->m_tuning.setLITMIN(currentStep, LITMIN); int MXWSIT = record3.getItem("MXWSIT").get< int >(0); - m_tuning->setMXWSIT(currentStep, MXWSIT); + this->m_tuning.setMXWSIT(currentStep, MXWSIT); int MXWPIT = record3.getItem("MXWPIT").get< int >(0); - m_tuning->setMXWPIT(currentStep, MXWPIT); + this->m_tuning.setMXWPIT(currentStep, MXWPIT); double DDPLIM = record3.getItem("DDPLIM").getSIDouble(0); - m_tuning->setDDPLIM(currentStep, DDPLIM); + this->m_tuning.setDDPLIM(currentStep, DDPLIM); double DDSLIM = record3.getItem("DDSLIM").get< double >(0); - m_tuning->setDDSLIM(currentStep, DDSLIM); + this->m_tuning.setDDSLIM(currentStep, DDSLIM); double TRGDPR = record3.getItem("TRGDPR").getSIDouble(0); - m_tuning->setTRGDPR(currentStep, TRGDPR); + this->m_tuning.setTRGDPR(currentStep, TRGDPR); const auto& XXXDPRdeckItem = record3.getItem("XXXDPR"); if (XXXDPRdeckItem.hasValue(0)) { double XXXDPR = XXXDPRdeckItem.getSIDouble(0); - m_tuning->setXXXDPR(currentStep, XXXDPR); + this->m_tuning.setXXXDPR(currentStep, XXXDPR); } } } - void Schedule::handleNOSIM() { - nosim = true; - } + void Schedule::handleCOMPDAT( const DeckKeyword& keyword, size_t currentStep, const EclipseGrid& grid) { + const auto wells = this->getWells( currentStep ); + auto completions = Completion::fromCOMPDAT( grid, keyword, wells ); - void Schedule::handleCOMPDAT( const DeckKeyword& keyword, size_t currentStep) { - std::map > completionMapList = Completion::completionsFromCOMPDATKeyword( keyword ); - std::map >::iterator iter; - - for( iter= completionMapList.begin(); iter != completionMapList.end(); iter++) { - const std::string wellName = iter->first; - WellPtr well = getWell(wellName); - well->addCompletions(currentStep, iter->second); + for( const auto pair : completions ) { + auto& well = *this->m_wells.get( pair.first ); + well.addCompletions( currentStep, pair.second ); + if (well.getCompletions( currentStep )->allCompletionsShut()) { + std::string msg = + "All completions in well " + well.name() + " is shut at " + std::to_string ( m_timeMap->getTimePassedUntil(currentStep) / (60*60*24) ) + " days. \n" + + "The well is therefore also shut."; + m_messages.note(msg); + updateWellStatus( well, currentStep, WellCommon::StatusEnum::SHUT); + } } - m_events->addEvent(ScheduleEvents::COMPLETION_CHANGE, currentStep); + m_events.addEvent(ScheduleEvents::COMPLETION_CHANGE, currentStep); } void Schedule::handleWELSEGS( const DeckKeyword& keyword, size_t currentStep) { @@ -1172,7 +1185,7 @@ namespace Opm { newSegmentset->segmentsFromWELSEGSKeyword(keyword); const std::string& well_name = newSegmentset->wellName(); - WellPtr well = getWell(well_name); + auto well = this->m_wells.get( well_name ); // update multi-segment related information for the well well->addSegmentSet(currentStep, newSegmentset); @@ -1181,48 +1194,48 @@ namespace Opm { void Schedule::handleCOMPSEGS( const DeckKeyword& keyword, size_t currentStep) { const auto& record1 = keyword.getRecord(0); const std::string& well_name = record1.getItem("WELL").getTrimmedString(0); - WellPtr well = getWell(well_name); + auto& well = *this->m_wells.get( well_name ); std::vector compsegs_vector = Compsegs::compsegsFromCOMPSEGSKeyword( keyword ); - SegmentSetConstPtr current_segmentSet = well->getSegmentSet(currentStep); + SegmentSetConstPtr current_segmentSet = well.getSegmentSet(currentStep); Compsegs::processCOMPSEGS(compsegs_vector, current_segmentSet); - CompletionSetConstPtr current_completionSet = well->getCompletions(currentStep); + CompletionSetConstPtr current_completionSet = well.getCompletions(currentStep); // it is necessary to update the segment related information for some completions. CompletionSetPtr new_completionSet = CompletionSetPtr(current_completionSet->shallowCopy()); Compsegs::updateCompletionsWithSegment(compsegs_vector, new_completionSet); - well->addCompletionSet(currentStep, new_completionSet); + well.addCompletionSet(currentStep, new_completionSet); } void Schedule::handleWGRUPCON( const DeckKeyword& keyword, size_t currentStep) { for( const auto& record : keyword ) { const std::string& wellName = record.getItem("WELL").getTrimmedString(0); - WellPtr well = getWell(wellName); + auto& well = *this->m_wells.get( wellName ); bool availableForGroupControl = convertEclipseStringToBool(record.getItem("GROUP_CONTROLLED").getTrimmedString(0)); - well->setAvailableForGroupControl(currentStep, availableForGroupControl); + well.setAvailableForGroupControl(currentStep, availableForGroupControl); - well->setGuideRate(currentStep, record.getItem("GUIDE_RATE").get< double >(0)); + well.setGuideRate(currentStep, record.getItem("GUIDE_RATE").get< double >(0)); if (!record.getItem("PHASE").defaultApplied(0)) { std::string guideRatePhase = record.getItem("PHASE").getTrimmedString(0); - well->setGuideRatePhase(currentStep, GuideRate::GuideRatePhaseEnumFromString(guideRatePhase)); + well.setGuideRatePhase(currentStep, GuideRate::GuideRatePhaseEnumFromString(guideRatePhase)); } else - well->setGuideRatePhase(currentStep, GuideRate::UNDEFINED); + well.setGuideRatePhase(currentStep, GuideRate::UNDEFINED); - well->setGuideRateScalingFactor(currentStep, record.getItem("SCALING_FACTOR").get< double >(0)); + well.setGuideRateScalingFactor(currentStep, record.getItem("SCALING_FACTOR").get< double >(0)); } } void Schedule::handleGRUPTREE( const DeckKeyword& keyword, size_t currentStep) { - GroupTreePtr currentTree = m_rootGroupTree->get(currentStep); - GroupTreePtr newTree = currentTree->deepCopy(); + const auto& currentTree = m_rootGroupTree.get(currentStep); + auto newTree = currentTree; for( const auto& record : keyword ) { const std::string& childName = record.getItem("CHILD_GROUP").getTrimmedString(0); const std::string& parentName = record.getItem("PARENT_GROUP").getTrimmedString(0); - newTree->updateTree(childName, parentName); + newTree.updateTree(childName, parentName); if (!hasGroup(parentName)) addGroup( parentName , currentStep ); @@ -1230,7 +1243,7 @@ namespace Opm { if (!hasGroup(childName)) addGroup( childName , currentStep ); } - m_rootGroupTree->update(currentStep, newTree); + m_rootGroupTree.update(currentStep, newTree); } void Schedule::handleWRFT( const DeckKeyword& keyword, size_t currentStep) { @@ -1242,10 +1255,9 @@ namespace Opm { for( const auto& record : keyword ) { const std::string& wellNamePattern = record.getItem("WELL").getTrimmedString(0); - const std::vector wells = getWells(wellNamePattern); - for (auto wellIter=wells.begin(); wellIter != wells.end(); ++wellIter) { - WellPtr well = *wellIter; + for( auto* well : getWells( wellNamePattern ) ) { + well->setRFTActive(currentStep, true); size_t numStep = m_timeMap->numTimesteps(); if(currentStepsetRFTForWellWhenFirstOpen(m_timeMap->numTimesteps(), currentStep); } } @@ -1265,14 +1277,11 @@ namespace Opm { for( const auto& record : keyword ) { const std::string& wellNamePattern = record.getItem("WELL").getTrimmedString(0); - const std::vector wells = getWells(wellNamePattern); RFTConnections::RFTEnum RFTKey = RFTConnections::RFTEnumFromString(record.getItem("OUTPUT_RFT").getTrimmedString(0)); - PLTConnections::PLTEnum PLTKey = PLTConnections::PLTEnumFromString(record.getItem("OUTPUT_PLT").getTrimmedString(0)); - for (auto wellIter=wells.begin(); wellIter != wells.end(); ++wellIter) { - WellPtr well = *wellIter; + for( auto* well : getWells( wellNamePattern ) ) { switch(RFTKey){ case RFTConnections::RFTEnum::YES: well->setRFTActive(currentStep, true); @@ -1313,8 +1322,8 @@ namespace Opm { return m_timeMap; } - GroupTreePtr Schedule::getGroupTree(size_t timeStep) const { - return m_rootGroupTree->get(timeStep); + const GroupTree& Schedule::getGroupTree(size_t timeStep) const { + return m_rootGroupTree.get(timeStep); } void Schedule::addWell(const std::string& wellName, const DeckRecord& record, size_t timeStep, WellCompletion::CompletionOrderEnum wellCompletionOrder) { @@ -1323,7 +1332,6 @@ namespace Opm { int headJ = record.getItem("HEAD_J").get< int >(0) - 1; Phase::PhaseEnum preferredPhase = Phase::PhaseEnumFromString(record.getItem("PHASE").getTrimmedString(0)); Value refDepth("REF_DEPTH"); - WellPtr well; const auto& refDepthItem = record.getItem("REF_DEPTH"); if (refDepthItem.hasValue(0)) @@ -1334,9 +1342,16 @@ namespace Opm { if (allowCrossFlowStr == "NO") allowCrossFlow = false; - well = std::make_shared(wellName, m_grid , headI, headJ, refDepth, preferredPhase, m_timeMap , timeStep, wellCompletionOrder, allowCrossFlow); + bool automaticShutIn = true; + const std::string& automaticShutInStr = record.getItem().getTrimmedString(0); + if (automaticShutInStr == "STOP") { + automaticShutIn = false; + } + + auto well = std::make_shared(wellName, headI, headJ, refDepth, preferredPhase, m_timeMap , timeStep, + wellCompletionOrder, allowCrossFlow, automaticShutIn); m_wells.insert( wellName , well); - m_events->addEvent( ScheduleEvents::NEW_WELL , timeStep ); + m_events.addEvent( ScheduleEvents::NEW_WELL , timeStep ); } size_t Schedule::numWells() const { @@ -1344,39 +1359,37 @@ namespace Opm { } size_t Schedule::numWells(size_t timestep) const { - std::vector wells = getWells(timestep); - return wells.size(); + return this->getWells( timestep ).size(); } bool Schedule::hasWell(const std::string& wellName) const { return m_wells.hasKey( wellName ); } - std::vector Schedule::getWells() const { + std::vector< const Well* > Schedule::getWells() const { return getWells(m_timeMap->size()-1); } - std::vector Schedule::getWells(size_t timeStep) const { + std::vector< const Well* > Schedule::getWells(size_t timeStep) const { if (timeStep >= m_timeMap->size()) { throw std::invalid_argument("Timestep to large"); } - std::vector wells; - for (auto iter = m_wells.begin(); iter != m_wells.end(); ++iter) { - WellConstPtr well = *iter; - if (well->hasBeenDefined(timeStep)) { - wells.push_back(well); - } + auto defined = [=]( const Well* w ) { + return w->hasBeenDefined( timeStep ); + }; + + std::vector< const Well* > wells; + for( const auto well : m_wells ) { + if( !defined( well.get() ) ) continue; + wells.push_back( well.get() ); } + return wells; } - WellPtr Schedule::getWell(const std::string& wellName) { - return m_wells.get( wellName ); - } - - const Well& Schedule::getWell(const std::string& wellName) const { - return *m_wells.get( wellName ); + const Well* Schedule::getWell(const std::string& wellName) const { + return m_wells.get( wellName ).get(); } @@ -1386,31 +1399,42 @@ namespace Opm { been opened by the simulator. */ - std::vector Schedule::getOpenWells(size_t timeStep) { - std::vector wells; - for (auto well_iter = m_wells.begin(); well_iter != m_wells.end(); ++well_iter) { - auto well = *well_iter; - if (well->getStatus( timeStep ) == WellCommon::OPEN) - wells.push_back( well ); + std::vector< const Well* > Schedule::getOpenWells(size_t timeStep) const { + + auto open = [=]( const Well* w ) { + return w->getStatus( timeStep ) == WellCommon::OPEN; + }; + + std::vector< const Well* > wells; + for( const auto well : m_wells ) { + if( !open( well.get() ) ) continue; + wells.push_back( well.get() ); } + return wells; } + std::vector< const Well* > Schedule::getWellsMatching( const std::string& wellNamePattern ) const { + auto tmp = const_cast< Schedule* >( this )->getWells( wellNamePattern ); + return { tmp.begin(), tmp.end() }; + } - std::vector Schedule::getWells(const std::string& wellNamePattern) { - std::vector wells; + std::vector< Well* > Schedule::getWells(const std::string& wellNamePattern) { size_t wildcard_pos = wellNamePattern.find("*"); - if (wildcard_pos == wellNamePattern.length()-1) { - for (auto wellIter = m_wells.begin(); wellIter != m_wells.end(); ++wellIter) { - WellPtr well = *wellIter; - if (Well::wellNameInWellNamePattern(well->name(), wellNamePattern)) { - wells.push_back (well); - } + + if( wildcard_pos != wellNamePattern.length()-1 ) { + if( !m_wells.hasKey( wellNamePattern ) ) return {}; + return { m_wells.get( wellNamePattern ).get() }; + } + + std::vector< Well* > wells; + for (auto wellIter = m_wells.begin(); wellIter != m_wells.end(); ++wellIter) { + Well* well = wellIter->get(); + if (Well::wellNameInWellNamePattern(well->name(), wellNamePattern)) { + wells.push_back (well); } } - else { - wells.push_back(getWell(wellNamePattern)); - } + return wells; } @@ -1418,9 +1442,8 @@ namespace Opm { if (!m_timeMap) { throw std::invalid_argument("TimeMap is null, can't add group named: " + groupName); } - GroupPtr group(new Group(groupName, m_timeMap , timeStep)); - m_groups[ groupName ] = group; - m_events->addEvent( ScheduleEvents::NEW_GROUP , timeStep ); + m_groups.emplace( groupName, Group { groupName, m_timeMap, timeStep } ); + m_events.addEvent( ScheduleEvents::NEW_GROUP , timeStep ); } size_t Schedule::numGroups() const { @@ -1431,11 +1454,8 @@ namespace Opm { return m_groups.find(groupName) != m_groups.end(); } - bool Schedule::initOnly() const { - return nosim; - } - GroupPtr Schedule::getGroup(const std::string& groupName) const { + const Group& Schedule::getGroup(const std::string& groupName) const { if (hasGroup(groupName)) { return m_groups.at(groupName); } else @@ -1446,19 +1466,18 @@ namespace Opm { std::vector< const Group* > groups; for( const auto& itr : m_groups ) - groups.push_back( itr.second.get() ); + groups.push_back( &itr.second ); return groups; } - void Schedule::addWellToGroup( GroupPtr newGroup , WellPtr well , size_t timeStep) { - const std::string currentGroupName = well->getGroupName(timeStep); + void Schedule::addWellToGroup( Group& newGroup, Well& well , size_t timeStep) { + const std::string currentGroupName = well.getGroupName(timeStep); if (currentGroupName != "") { - GroupPtr currentGroup = getGroup( currentGroupName ); - currentGroup->delWell( timeStep , well->name()); + m_groups.at( currentGroupName ).delWell( timeStep, well.name() ); } - well->setGroupName(timeStep , newGroup->name()); - newGroup->addWell(timeStep , well); + well.setGroupName(timeStep , newGroup.name()); + newGroup.addWell(timeStep , &well); } @@ -1473,10 +1492,10 @@ namespace Opm { case WellInjector::OIL: case WellInjector::WATER: - return rawRate * unitSystem.parse("LiquidSurfaceVolume/Time")->getSIScaling(); + return unitSystem.to_si( UnitSystem::measure::liquid_surface_rate, rawRate ); case WellInjector::GAS: - return rawRate * unitSystem.parse("GasSurfaceVolume/Time")->getSIScaling(); + return unitSystem.to_si( UnitSystem::measure::gas_surface_rate, rawRate ); default: throw std::logic_error("Unknown injector type"); @@ -1487,10 +1506,10 @@ namespace Opm { switch (wellPhase) { case Phase::OIL: case Phase::WATER: - return rawRate * unitSystem.parse("LiquidSurfaceVolume/Time")->getSIScaling(); + return unitSystem.to_si( UnitSystem::measure::liquid_surface_rate, rawRate ); case Phase::GAS: - return rawRate * unitSystem.parse("GasSurfaceVolume/Time")->getSIScaling(); + return unitSystem.to_si( UnitSystem::measure::gas_surface_rate, rawRate ); default: throw std::logic_error("Unknown injection phase"); @@ -1512,9 +1531,7 @@ namespace Opm { size_t Schedule::getMaxNumCompletionsForWells(size_t timestep) const { size_t ncwmax = 0; - const std::vector& wells = getWells(); - for (auto wellIter=wells.begin(); wellIter != wells.end(); ++wellIter) { - WellConstPtr wellPtr = *wellIter; + for( const auto* wellPtr : getWells() ) { CompletionSetConstPtr completionsSetPtr = wellPtr->getCompletions(timestep); if (completionsSetPtr->size() > ncwmax ) @@ -1524,12 +1541,12 @@ namespace Opm { return ncwmax; } - TuningPtr Schedule::getTuning() const { - return m_tuning; + const Tuning& Schedule::getTuning() const { + return this->m_tuning; } std::shared_ptr Schedule::getModifierDeck(size_t timeStep) const { - return m_modifierDeck->iget( timeStep ); + return m_modifierDeck.iget( timeStep ); } @@ -1544,19 +1561,15 @@ namespace Opm { const Events& Schedule::getEvents() const { - return *m_events; + return this->m_events; } - OilVaporizationPropertiesConstPtr Schedule::getOilVaporizationProperties(size_t timestep){ - return m_oilvaporizationproperties->get(timestep); - } - - void Schedule::setOilVaporizationProperties(const OilVaporizationPropertiesPtr vapor, size_t timestep){ - m_oilvaporizationproperties->update(timestep, vapor); + const OilVaporizationProperties& Schedule::getOilVaporizationProperties(size_t timestep){ + return m_oilvaporizationproperties.get(timestep); } bool Schedule::hasOilVaporizationProperties(){ - return m_oilvaporizationproperties->size() > 0; + return m_oilvaporizationproperties.size() > 0; } } diff --git a/ThirdParty/custom-opm-parser/opm-parser/opm/parser/eclipse/EclipseState/Schedule/Schedule.hpp b/ThirdParty/custom-opm-parser/opm-parser/opm/parser/eclipse/EclipseState/Schedule/Schedule.hpp index d4043d2128..e18c2ba00e 100644 --- a/ThirdParty/custom-opm-parser/opm-parser/opm/parser/eclipse/EclipseState/Schedule/Schedule.hpp +++ b/ThirdParty/custom-opm-parser/opm-parser/opm/parser/eclipse/EclipseState/Schedule/Schedule.hpp @@ -24,37 +24,37 @@ #include +#include +#include +#include +#include +#include +#include #include +#include #include #include namespace Opm { - template< typename > class DynamicState; - template< typename > class DynamicVector; - class Deck; class DeckKeyword; class DeckRecord; class EclipseGrid; - class Events; - class Group; - class GroupTree; - class OilVaporizationProperties; class ParseContext; class SCHEDULESection; class TimeMap; - class Tuning; class UnitSystem; class Well; class Schedule { public: - Schedule(const ParseContext& parseContext, std::shared_ptr grid, + Schedule(const ParseContext& parseContext, const EclipseGrid& grid, const Deck& deck ); + /// [deprecated] - Schedule(const ParseContext& parseContext, std::shared_ptr grid, + Schedule(const ParseContext& parseContext, const EclipseGrid& grid, std::shared_ptr deck ); /* @@ -63,6 +63,8 @@ namespace Opm */ boost::posix_time::ptime getStartTime() const; time_t posixStartTime() const; + time_t posixEndTime() const; + std::shared_ptr< const TimeMap > getTimeMap() const; @@ -70,22 +72,20 @@ namespace Opm size_t numWells(size_t timestep) const; size_t getMaxNumCompletionsForWells(size_t timestep) const; bool hasWell(const std::string& wellName) const; - std::shared_ptr< Well > getWell(const std::string& wellName); - const Well& getWell(const std::string& wellName) const; - std::vector> getOpenWells(size_t timeStep); - std::vector> getWells() const; - std::vector> getWells(size_t timeStep) const; - std::vector> getWells(const std::string& wellNamePattern); - std::shared_ptr< const OilVaporizationProperties > getOilVaporizationProperties(size_t timestep); + const Well* getWell(const std::string& wellName) const; + std::vector< const Well* > getOpenWells(size_t timeStep) const; + std::vector< const Well* > getWells() const; + std::vector< const Well* > getWells(size_t timeStep) const; + std::vector< const Well* > getWellsMatching( const std::string& ) const; + const OilVaporizationProperties& getOilVaporizationProperties(size_t timestep); - std::shared_ptr< GroupTree > getGroupTree(size_t t) const; + const GroupTree& getGroupTree(size_t t) const; size_t numGroups() const; bool hasGroup(const std::string& groupName) const; - std::shared_ptr< Group > getGroup(const std::string& groupName) const; + const Group& getGroup(const std::string& groupName) const; std::vector< const Group* > getGroups() const; - std::shared_ptr< Tuning > getTuning() const; + const Tuning& getTuning() const; - bool initOnly() const; const Events& getEvents() const; bool hasOilVaporizationProperties(); std::shared_ptr getModifierDeck(size_t timeStep) const; @@ -96,34 +96,30 @@ namespace Opm private: std::shared_ptr< TimeMap > m_timeMap; OrderedMap> m_wells; - std::shared_ptr m_grid; - std::map> m_groups; - std::shared_ptr> > m_rootGroupTree; - std::shared_ptr > > m_oilvaporizationproperties; - std::shared_ptr m_events; - std::shared_ptr > > m_modifierDeck; - std::shared_ptr< Tuning > m_tuning; - bool nosim; + std::map m_groups; + DynamicState< GroupTree > m_rootGroupTree; + DynamicState< OilVaporizationProperties > m_oilvaporizationproperties; + Events m_events; + DynamicVector > m_modifierDeck; + Tuning m_tuning; MessageContainer m_messages; + WellProducer::ControlModeEnum m_controlModeWHISTCTL; - - void updateWellStatus(std::shared_ptr well, size_t reportStep , WellCommon::StatusEnum status); - void addWellToGroup( std::shared_ptr< Group > newGroup , std::shared_ptr< Well > well , size_t timeStep); - void initializeNOSIM(const Deck& deck); - void initRootGroupTreeNode(std::shared_ptr< const TimeMap > timeMap); - void initOilVaporization(std::shared_ptr< const TimeMap > timeMap); - void iterateScheduleSection(const ParseContext& parseContext , const SCHEDULESection& ); - bool handleGroupFromWELSPECS(const std::string& groupName, std::shared_ptr< GroupTree > newTree) const; + std::vector< Well* > getWells(const std::string& wellNamePattern); + void updateWellStatus( Well& well, size_t reportStep , WellCommon::StatusEnum status); + void addWellToGroup( Group& newGroup , Well& well , size_t timeStep); + void iterateScheduleSection(const ParseContext& parseContext , const SCHEDULESection& , const EclipseGrid& grid); + bool handleGroupFromWELSPECS(const std::string& groupName, GroupTree& newTree) const; void addGroup(const std::string& groupName , size_t timeStep); void addWell(const std::string& wellName, const DeckRecord& record, size_t timeStep, WellCompletion::CompletionOrderEnum wellCompletionOrder); void handleCOMPORD(const ParseContext& parseContext, const DeckKeyword& compordKeyword, size_t currentStep); - void checkWELSPECSConsistency(std::shared_ptr< const Well > well, const DeckKeyword& keyword, size_t recordIdx); - void handleWELSPECS( const SCHEDULESection&, const DeckKeyword& keyword, size_t currentStep); + void checkWELSPECSConsistency( const Well&, const DeckKeyword& keyword, size_t recordIdx); + void handleWELSPECS( const SCHEDULESection&, size_t, size_t ); void handleWCONProducer( const DeckKeyword& keyword, size_t currentStep, bool isPredictionMode); void handleWCONHIST( const DeckKeyword& keyword, size_t currentStep); void handleWCONPROD( const DeckKeyword& keyword, size_t currentStep); void handleWGRUPCON( const DeckKeyword& keyword, size_t currentStep); - void handleCOMPDAT( const DeckKeyword& keyword, size_t currentStep); + void handleCOMPDAT( const DeckKeyword& keyword, size_t currentStep, const EclipseGrid& grid); void handleWELSEGS( const DeckKeyword& keyword, size_t currentStep); void handleCOMPSEGS( const DeckKeyword& keyword, size_t currentStep); void handleWCONINJE( const SCHEDULESection&, const DeckKeyword& keyword, size_t currentStep); @@ -136,9 +132,6 @@ namespace Opm void handleGCONPROD( const DeckKeyword& keyword, size_t currentStep); void handleGEFAC( const DeckKeyword& keyword, size_t currentStep); void handleTUNING( const DeckKeyword& keyword, size_t currentStep); - void handleNOSIM(); - void handleDATES( const DeckKeyword& keyword ); - void handleTSTEP( const DeckKeyword& keyword ); void handleGRUPTREE( const DeckKeyword& keyword, size_t currentStep); void handleWRFT( const DeckKeyword& keyword, size_t currentStep); void handleWRFTPLT( const DeckKeyword& keyword, size_t currentStep); @@ -146,6 +139,8 @@ namespace Opm void handleDRSDT( const DeckKeyword& keyword, size_t currentStep); void handleDRVDT( const DeckKeyword& keyword, size_t currentStep); void handleVAPPARS( const DeckKeyword& keyword, size_t currentStep); + void handleWECON( const DeckKeyword& keyword, size_t currentStep); + void handleWHISTCTL(const ParseContext& parseContext, const DeckKeyword& keyword); void checkUnhandledKeywords( const SCHEDULESection& ) const; @@ -153,9 +148,6 @@ namespace Opm static double convertInjectionRateToSI(double rawRate, Phase::PhaseEnum wellPhase, const Opm::UnitSystem &unitSystem); static bool convertEclipseStringToBool(const std::string& eclipseString); - - void setOilVaporizationProperties(const std::shared_ptr< OilVaporizationProperties > vapor, size_t timestep); - }; typedef std::shared_ptr SchedulePtr; typedef std::shared_ptr ScheduleConstPtr; diff --git a/ThirdParty/custom-opm-parser/opm-parser/opm/parser/eclipse/EclipseState/Schedule/ScheduleEnums.cpp b/ThirdParty/custom-opm-parser/opm-parser/opm/parser/eclipse/EclipseState/Schedule/ScheduleEnums.cpp index 0abd67ef7a..927da84d7f 100644 --- a/ThirdParty/custom-opm-parser/opm-parser/opm/parser/eclipse/EclipseState/Schedule/ScheduleEnums.cpp +++ b/ThirdParty/custom-opm-parser/opm-parser/opm/parser/eclipse/EclipseState/Schedule/ScheduleEnums.cpp @@ -20,8 +20,6 @@ #include #include -#include - #include namespace Opm { @@ -51,11 +49,8 @@ namespace Opm { } DirectionEnum - DirectionEnumFromString(const std::string& stringValue) + DirectionEnumFromString(const std::string& s ) { - std::string s(stringValue); - boost::algorithm::trim(s); - DirectionEnum direction; if (s == "X") { direction = DirectionEnum::X; } @@ -84,9 +79,7 @@ namespace Opm { } - StateEnum StateEnumFromString( const std::string& origStringValue ) { - std::string stringValue(origStringValue); - boost::algorithm::trim(stringValue); + StateEnum StateEnumFromString( const std::string& stringValue ) { if (stringValue == "OPEN") return OPEN; else if (stringValue == "SHUT") @@ -114,9 +107,7 @@ namespace Opm { } - CompletionOrderEnum CompletionOrderEnumFromString(const std::string& comporderStringValue) { - std::string stringValue(comporderStringValue); - boost::algorithm::trim(stringValue); + CompletionOrderEnum CompletionOrderEnumFromString(const std::string& stringValue ) { if (stringValue == "DEPTH") return DEPTH; else if (stringValue == "INPUT") @@ -153,10 +144,7 @@ namespace Opm { } - ControlEnum ControlEnumFromString( const std::string& origStringValue ) { - std::string stringValue(origStringValue); - boost::algorithm::trim(stringValue); - + ControlEnum ControlEnumFromString( const std::string& stringValue ) { if (stringValue == "NONE") return NONE; else if (stringValue == "RATE") @@ -197,6 +185,8 @@ namespace Opm { return "RESV"; case PRBL: return "PRBL"; + case FLD: + return "FLD"; default: throw std::invalid_argument("Unhandled enum value"); } @@ -220,6 +210,8 @@ namespace Opm { return RESV; else if (stringValue == "PRBL") return PRBL; + else if (stringValue == "FLD") + return FLD; else throw std::invalid_argument("Unknown enum state string: " + stringValue ); } @@ -248,9 +240,7 @@ namespace Opm { } - ActionEnum ActionEnumFromString( const std::string& origStringValue ) { - std::string stringValue(origStringValue); - boost::algorithm::trim(stringValue); + ActionEnum ActionEnumFromString( const std::string& stringValue ) { if (stringValue == "NONE") return NONE; @@ -286,9 +276,7 @@ namespace Opm { } } - PhaseEnum PhaseEnumFromString( const std::string& origStringValue ) { - std::string stringValue(origStringValue); - boost::algorithm::trim(stringValue); + PhaseEnum PhaseEnumFromString( const std::string& stringValue ) { if (stringValue == "OIL") return OIL; @@ -332,10 +320,7 @@ namespace Opm { } } - ControlModeEnum ControlModeFromString( const std::string& origStringValue ) { - std::string stringValue(origStringValue); - boost::algorithm::trim(stringValue); - + ControlModeEnum ControlModeFromString( const std::string& stringValue ) { if (stringValue == "ORAT") return ORAT; else if (stringValue == "WRAT") @@ -354,6 +339,8 @@ namespace Opm { return THP; else if (stringValue == "GRUP") return GRUP; + else if (stringValue == "NONE") + return NONE; else throw std::invalid_argument("Unknown enum state string: " + stringValue ); } @@ -377,10 +364,7 @@ namespace Opm { } } - TypeEnum TypeFromString( const std::string& origStringValue ) { - std::string stringValue(origStringValue); - boost::algorithm::trim(stringValue); - + TypeEnum TypeFromString( const std::string& stringValue ) { if (stringValue == "OIL") return OIL; else if (stringValue == "WATER") @@ -414,10 +398,7 @@ namespace Opm { } } - ControlModeEnum ControlModeFromString( const std::string& origStringValue ) { - std::string stringValue(origStringValue); - boost::algorithm::trim(stringValue); - + ControlModeEnum ControlModeFromString( const std::string& stringValue ) { if (stringValue == "RATE") return RATE; else if (stringValue == "RESV") @@ -453,10 +434,7 @@ namespace Opm { } - StatusEnum StatusFromString(const std::string& origStringValue) { - std::string stringValue(origStringValue); - boost::algorithm::trim(stringValue); - + StatusEnum StatusFromString(const std::string& stringValue) { if (stringValue == "OPEN") return OPEN; else if (stringValue == "SHUT") @@ -500,9 +478,7 @@ namespace Opm { } } - GuideRatePhaseEnum GuideRatePhaseEnumFromString( const std::string& origStringValue ) { - std::string stringValue(origStringValue); - boost::algorithm::trim(stringValue); + GuideRatePhaseEnum GuideRatePhaseEnumFromString( const std::string& stringValue ) { if (stringValue == "OIL") return OIL; @@ -547,9 +523,7 @@ namespace Opm { } } - RFTEnum RFTEnumFromString(const std::string &origStringValue) { - std::string stringValue(origStringValue); - boost::algorithm::trim(stringValue); + RFTEnum RFTEnumFromString(const std::string& stringValue) { if (stringValue == "YES") return YES; @@ -582,10 +556,7 @@ namespace Opm { } } - PLTEnum PLTEnumFromString( const std::string& origStringValue){ - std::string stringValue(origStringValue); - boost::algorithm::trim(stringValue); - + PLTEnum PLTEnumFromString( const std::string& stringValue ){ if (stringValue == "YES") return YES; else if (stringValue == "REPT") @@ -612,17 +583,13 @@ namespace Opm { } } - LengthDepthEnum LengthDepthEnumFromString(const std::string& stringValue) { - - std::string trimmedString(stringValue); - boost::algorithm::trim(trimmedString); - - if (trimmedString == "INC") { + LengthDepthEnum LengthDepthEnumFromString(const std::string& string ) { + if (string == "INC") { return INC; - } else if (trimmedString == "ABS") { + } else if (string == "ABS") { return ABS; } else { - throw std::invalid_argument("Unknown enum string: " + trimmedString + " for LengthDepthEnum"); + throw std::invalid_argument("Unknown enum string: " + string + " for LengthDepthEnum"); } } @@ -639,19 +606,16 @@ namespace Opm { } } - CompPressureDropEnum CompPressureDropEnumFromString(const std::string& stringValue) { + CompPressureDropEnum CompPressureDropEnumFromString( const std::string& string ) { - std::string trimmedString(stringValue); - boost::algorithm::trim(trimmedString); - - if (trimmedString == "HFA") { + if (string == "HFA") { return HFA; - } else if (trimmedString == "HF-") { + } else if (string == "HF-") { return HF_; - } else if (trimmedString == "H--") { + } else if (string == "H--") { return H__; } else { - throw std::invalid_argument("Unknown enum string: " + trimmedString + " for CompPressureDropEnum"); + throw std::invalid_argument("Unknown enum string: " + string + " for CompPressureDropEnum"); } } @@ -666,17 +630,14 @@ namespace Opm { } } - MultiPhaseModelEnum MultiPhaseModelEnumFromString(const std::string& stringValue) { + MultiPhaseModelEnum MultiPhaseModelEnumFromString(const std::string& string ) { - std::string trimmedString(stringValue); - boost::algorithm::trim(trimmedString); - - if ((trimmedString == "HO") || (trimmedString == "H0")) { + if ((string == "HO") || (string == "H0")) { return HO; - } else if (trimmedString == "DF") { + } else if (string == "DF") { return DF; } else { - throw std::invalid_argument("Unknown enum string: " + trimmedString + " for MultiPhaseModelEnum"); + throw std::invalid_argument("Unknown enum string: " + string + " for MultiPhaseModelEnum"); } } @@ -684,4 +645,73 @@ namespace Opm { } + + namespace WellEcon { + const std::string WorkoverEnumToString(WorkoverEnum enumValue) { + switch(enumValue) { + case NONE: + return "NONE"; + case CON: + return "CON"; + case CONP: + return "+CON"; + case WELL: + return "WELL"; + case PLUG: + return "PLUG"; + case LAST: + return "LAST"; + case RED: + return "RED"; + default: + throw std::invalid_argument("unhandled WorkoverEnum value"); + } + } + + WorkoverEnum WorkoverEnumFromString( const std::string& string ) { + + if (string == "NONE") { + return NONE; + } else if (string == "CON") { + return CON; + } else if (string == "+CON") { + return CONP; + } else if (string == "WELL") { + return WELL; + } else if (string == "PLUG") { + return PLUG; + } else if (string == "LAST") { + return LAST; + } else if (string == "RED") { + return RED; + } else { + throw std::invalid_argument("Unknown enum string: " + string + " for WorkoverEnum"); + } + } + + const std::string QuantityLimitEnumToString(QuantityLimitEnum enumValue) { + switch(enumValue) { + case RATE: + return "RATE"; + case POTN: + return "POTN"; + default: + throw std::invalid_argument("unhandled QuantityLimitvalue"); + } + } + + QuantityLimitEnum QuantityLimitEnumFromString(const std::string& string ) { + if (string == "RATE") { + return RATE; + } else if (string == "POTN") { + return POTN; + } else { + throw std::invalid_argument("Unknown enum string: " + string + " for QuantityLimitEnum"); + } + } + + + } + + } diff --git a/ThirdParty/custom-opm-parser/opm-parser/opm/parser/eclipse/EclipseState/Schedule/ScheduleEnums.hpp b/ThirdParty/custom-opm-parser/opm-parser/opm/parser/eclipse/EclipseState/Schedule/ScheduleEnums.hpp index cfd47cf43e..583655bb27 100644 --- a/ThirdParty/custom-opm-parser/opm-parser/opm/parser/eclipse/EclipseState/Schedule/ScheduleEnums.hpp +++ b/ThirdParty/custom-opm-parser/opm-parser/opm/parser/eclipse/EclipseState/Schedule/ScheduleEnums.hpp @@ -119,6 +119,7 @@ namespace Opm { namespace WellProducer { enum ControlModeEnum { + NONE = 0, ORAT = 1, WRAT = 2, GRAT = 4, @@ -135,7 +136,8 @@ namespace Opm { The items BHP, THP and GRUP only apply in prediction mode: WCONPROD. The elements in this enum are used as bitmasks to keep track of which controls are present, i.e. the 2^n - structure must be intact. + structure must be intact.The NONE item is only used in WHISTCTL + to cancel its effect. The properties are initialized with the CMODE_UNDEFINED value, but the undefined value is never assigned apart from @@ -190,7 +192,8 @@ namespace Opm { LRAT = 4, CRAT = 5, RESV = 6, - PRBL = 7 + PRBL = 7, + FLD = 8 }; const std::string ControlEnum2String( GroupProduction::ControlEnum enumValue ); @@ -239,6 +242,7 @@ namespace Opm { } enum OilVaporizationEnum{ + UNDEF = 0, VAPPARS = 1, DRSDT = 2, DRVDT = 3 @@ -272,6 +276,30 @@ namespace Opm { } + namespace WellEcon { + enum WorkoverEnum { + NONE = 0, + CON = 1, // CON + CONP = 2, // +CON + WELL = 3, + PLUG = 4, + // the following two only related to workover action + // on exceeding secondary water cut limit + LAST = 5, + RED = 6 + }; + const std::string WorkoverEnumToString(WorkoverEnum enumValue); + WorkoverEnum WorkoverEnumFromString(const std::string& stringValue); + + enum QuantityLimitEnum { + RATE = 0, + POTN = 1 + }; + const std::string QuantityLimitEnumToString(QuantityLimitEnum enumValue); + QuantityLimitEnum QuantityLimitEnumFromString(const std::string& stringValue); + } + + } #endif diff --git a/ThirdParty/custom-opm-parser/opm-parser/opm/parser/eclipse/EclipseState/Schedule/TimeMap.cpp b/ThirdParty/custom-opm-parser/opm-parser/opm/parser/eclipse/EclipseState/Schedule/TimeMap.cpp index d6c24a9e7d..057b3bc008 100644 --- a/ThirdParty/custom-opm-parser/opm-parser/opm/parser/eclipse/EclipseState/Schedule/TimeMap.cpp +++ b/ThirdParty/custom-opm-parser/opm-parser/opm/parser/eclipse/EclipseState/Schedule/TimeMap.cpp @@ -47,7 +47,7 @@ namespace Opm { // keyword was specified) if (deck.hasKeyword("START")) { const auto& keyword = deck.getKeyword("START"); - startTime = timeFromEclipse(keyword.getRecord(/*index=*/0)); + startTime = timeFromEclipse(keyword.getRecord(0)); } m_timeList.push_back( startTime ); @@ -68,9 +68,6 @@ namespace Opm { else if (keyword.name() == "DATES") addFromDATESKeyword(keyword); } - - this->initFirstTimestepsYears(); - this->initFirstTimestepsMonths(); } size_t TimeMap::numTimesteps() const { @@ -82,6 +79,9 @@ namespace Opm { return m_timeList[tStepIdx]; } + boost::posix_time::ptime TimeMap::getEndTime() const { + return m_timeList.back(); + } double TimeMap::getTotalTime() const { @@ -91,21 +91,29 @@ namespace Opm { return static_cast(deltaT.total_milliseconds())/1000.0; } + void TimeMap::addTime(boost::posix_time::ptime newTime) { boost::posix_time::ptime lastTime = m_timeList.back(); - if (newTime > lastTime) + size_t step = m_timeList.size(); + if (newTime > lastTime) { + boost::gregorian::date new_date = newTime.date(); + boost::gregorian::date prev_date = lastTime.date(); + + if (new_date.month() != prev_date.month()) + m_first_timestep_months.push_back(step); + + if (new_date.year() != prev_date.year()) + m_first_timestep_years.push_back( step ); + m_timeList.push_back( newTime ); - else + } else throw std::invalid_argument("Times added must be in strictly increasing order."); } void TimeMap::addTStep(boost::posix_time::time_duration step) { - if (step.total_seconds() > 0) { - boost::posix_time::ptime newTime = m_timeList.back() + step; - m_timeList.push_back( newTime ); - } else - throw std::invalid_argument("Can only add positive steps"); + boost::posix_time::ptime newTime = m_timeList.back() + step; + addTime(newTime); } @@ -291,58 +299,14 @@ namespace Opm { - void TimeMap::initFirstTimestepsMonths() { - m_first_timestep_months.clear(); - - const boost::posix_time::ptime& ptime_prev = getStartTime(0); - boost::gregorian::date prev_date = ptime_prev.date(); - - for (size_t rstep = 0; rstep < m_timeList.size(); ++rstep) { - const boost::posix_time::ptime& ptime_cur = getStartTime(rstep); - boost::gregorian::date cur_date = ptime_cur.date(); - - if (cur_date.month() != prev_date.month()) { - m_first_timestep_months.push_back(rstep); - prev_date = cur_date; - } else if (cur_date.year() != prev_date.year()) { //Same month but different year - m_first_timestep_months.push_back(rstep); - prev_date = cur_date; - } - } - } - - - void TimeMap::initFirstTimestepsYears() { - - m_first_timestep_years.clear(); - - const boost::posix_time::ptime& ptime_prev = getStartTime(0); - boost::gregorian::date prev_date = ptime_prev.date(); - - for (size_t rstep = 0; rstep < m_timeList.size(); ++rstep) { - const boost::posix_time::ptime& ptime_cur = getStartTime(rstep); - boost::gregorian::date cur_date = ptime_cur.date(); - - if (cur_date.year() != prev_date.year()) { - m_first_timestep_years.push_back(rstep); - prev_date = cur_date; - } - } - } const std::vector& TimeMap::getFirstTimestepMonths() const { - if (m_first_timestep_months.size() == 0) { - throw std::runtime_error("TimeMap vector m_first_timestep_months not initialized"); - } return m_first_timestep_months; } const std::vector& TimeMap::getFirstTimestepYears() const { - if (m_first_timestep_years.size() == 0) { - throw std::runtime_error("TimeMap vector m_first_timestep_years not initialized"); - } return m_first_timestep_years; } diff --git a/ThirdParty/custom-opm-parser/opm-parser/opm/parser/eclipse/EclipseState/Schedule/TimeMap.hpp b/ThirdParty/custom-opm-parser/opm-parser/opm/parser/eclipse/EclipseState/Schedule/TimeMap.hpp index 65a65bc5f2..59a9f33b6f 100644 --- a/ThirdParty/custom-opm-parser/opm-parser/opm/parser/eclipse/EclipseState/Schedule/TimeMap.hpp +++ b/ThirdParty/custom-opm-parser/opm-parser/opm/parser/eclipse/EclipseState/Schedule/TimeMap.hpp @@ -33,15 +33,14 @@ namespace Opm { class TimeMap { public: - TimeMap(boost::posix_time::ptime startDate); - TimeMap(std::shared_ptr< const Deck > deck); - TimeMap( const Deck& deck); + explicit TimeMap(boost::posix_time::ptime startDate); + explicit TimeMap(std::shared_ptr< const Deck > deck); + explicit TimeMap( const Deck& deck); + void addTime(boost::posix_time::ptime newTime); void addTStep(boost::posix_time::time_duration step); void addFromDATESKeyword( const DeckKeyword& DATESKeyword ); void addFromTSTEPKeyword( const DeckKeyword& TSTEPKeyword ); - void initFirstTimestepsMonths(); - void initFirstTimestepsYears(); size_t size() const; size_t last() const; size_t numTimesteps() const; @@ -49,6 +48,7 @@ namespace Opm { const boost::posix_time::ptime& operator[] (size_t index) const; /// Return the date and time where a given time step starts. boost::posix_time::ptime getStartTime(size_t tStepIdx) const; + boost::posix_time::ptime getEndTime() const; /// Return the period of time in seconds which passed between the start of the simulation and a given point in time. double getTimePassedUntil(size_t tLevelIdx) const; /// Return the length of a given time step in seconds. diff --git a/ThirdParty/custom-opm-parser/opm-parser/opm/parser/eclipse/EclipseState/Schedule/Tuning.cpp b/ThirdParty/custom-opm-parser/opm-parser/opm/parser/eclipse/EclipseState/Schedule/Tuning.cpp index b2a2cee4b1..b2f2ba11a5 100644 --- a/ThirdParty/custom-opm-parser/opm-parser/opm/parser/eclipse/EclipseState/Schedule/Tuning.cpp +++ b/ThirdParty/custom-opm-parser/opm-parser/opm/parser/eclipse/EclipseState/Schedule/Tuning.cpp @@ -37,7 +37,7 @@ namespace Opm { m_TFDIFF( new DynamicState(timemap, 1.25)), m_THRUPT( new DynamicState(timemap, 1.0E20)), m_TMAXWC( new DynamicState(timemap, 0.0 * Metric::Time)), - m_TMAXWC_has_value( new DynamicState(timemap, false)), + m_TMAXWC_has_value( new DynamicState(timemap, false)), m_TRGTTE( new DynamicState(timemap, 0.1)), m_TRGCNV( new DynamicState(timemap, 0.001)), m_TRGMBE( new DynamicState(timemap, 1.0E-7)), @@ -49,7 +49,7 @@ namespace Opm { m_XXXWFL( new DynamicState(timemap, 0.001)), m_TRGFIP( new DynamicState(timemap, 0.025)), m_TRGSFT( new DynamicState(timemap, 0.0)), - m_TRGSFT_has_value( new DynamicState(timemap, false)), + m_TRGSFT_has_value( new DynamicState(timemap, false)), m_THIONX( new DynamicState(timemap, 0.01)), m_TRWGHT( new DynamicState(timemap, 1)), m_NEWTMX( new DynamicState(timemap, 12)), @@ -62,7 +62,7 @@ namespace Opm { m_DDSLIM( new DynamicState(timemap, 1.0E6)), m_TRGDPR( new DynamicState(timemap, 1.0E6 * Metric::Pressure)), m_XXXDPR( new DynamicState(timemap, 0.0 * Metric::Pressure)), - m_XXXDPR_has_value( new DynamicState(timemap, false)) + m_XXXDPR_has_value( new DynamicState(timemap, false)) { } @@ -196,11 +196,11 @@ namespace Opm { return values->get(timestep); } - bool Tuning::getBoolValue(const std::string tuningItem, std::shared_ptr> values, size_t timestep) const{ + bool Tuning::getBoolValue(const std::string tuningItem, std::shared_ptr> values, size_t timestep) const{ if(m_ResetValue.find(tuningItem)!= m_ResetValue.end()){ timestep = 0; } - return values->get(timestep); + return bool( values->get(timestep) ); } diff --git a/ThirdParty/custom-opm-parser/opm-parser/opm/parser/eclipse/EclipseState/Schedule/Tuning.hpp b/ThirdParty/custom-opm-parser/opm-parser/opm/parser/eclipse/EclipseState/Schedule/Tuning.hpp index 51ae91c6e6..6e162f0884 100644 --- a/ThirdParty/custom-opm-parser/opm-parser/opm/parser/eclipse/EclipseState/Schedule/Tuning.hpp +++ b/ThirdParty/custom-opm-parser/opm-parser/opm/parser/eclipse/EclipseState/Schedule/Tuning.hpp @@ -139,7 +139,7 @@ namespace Opm { std::shared_ptr> m_TFDIFF; std::shared_ptr> m_THRUPT; std::shared_ptr> m_TMAXWC; - std::shared_ptr> m_TMAXWC_has_value; + std::shared_ptr> m_TMAXWC_has_value; /* Record 2 */ std::shared_ptr> m_TRGTTE; std::shared_ptr> m_TRGCNV; @@ -152,7 +152,7 @@ namespace Opm { std::shared_ptr> m_XXXWFL; std::shared_ptr> m_TRGFIP; std::shared_ptr> m_TRGSFT; - std::shared_ptr> m_TRGSFT_has_value; + std::shared_ptr> m_TRGSFT_has_value; std::shared_ptr> m_THIONX; std::shared_ptr> m_TRWGHT; /* Record 3 */ @@ -166,12 +166,12 @@ namespace Opm { std::shared_ptr> m_DDSLIM; std::shared_ptr> m_TRGDPR; std::shared_ptr> m_XXXDPR; - std::shared_ptr> m_XXXDPR_has_value; + std::shared_ptr> m_XXXDPR_has_value; std::map m_ResetValue; double getDoubleValue(const std::string tuningItem, std::shared_ptr> values, size_t timestep) const; int getIntValue(const std::string tuningItem, std::shared_ptr> values, size_t timestep) const; - bool getBoolValue(const std::string tuningItem, std::shared_ptr> values, size_t timestep) const; + bool getBoolValue(const std::string tuningItem, std::shared_ptr> values, size_t timestep) const; }; diff --git a/ThirdParty/custom-opm-parser/opm-parser/opm/parser/eclipse/EclipseState/Schedule/Well.cpp b/ThirdParty/custom-opm-parser/opm-parser/opm/parser/eclipse/EclipseState/Schedule/Well.cpp index 52cc176212..9cad174478 100644 --- a/ThirdParty/custom-opm-parser/opm-parser/opm/parser/eclipse/EclipseState/Schedule/Well.cpp +++ b/ThirdParty/custom-opm-parser/opm-parser/opm/parser/eclipse/EclipseState/Schedule/Well.cpp @@ -20,7 +20,6 @@ #include #include -#include #include #include #include @@ -33,30 +32,34 @@ namespace Opm { - Well::Well(const std::string& name_, std::shared_ptr grid , int headI, int headJ, Value refDepth , Phase::PhaseEnum preferredPhase, - TimeMapConstPtr timeMap, size_t creationTimeStep, WellCompletion::CompletionOrderEnum completionOrdering, bool allowCrossFlow) + Well::Well(const std::string& name_, int headI, + int headJ, Value refDepth , Phase::PhaseEnum preferredPhase, + TimeMapConstPtr timeMap, size_t creationTimeStep, + WellCompletion::CompletionOrderEnum completionOrdering, + bool allowCrossFlow, bool automaticShutIn) : m_status(new DynamicState(timeMap, WellCommon::SHUT)), - m_isAvailableForGroupControl(new DynamicState(timeMap, true)), + m_isAvailableForGroupControl(new DynamicState(timeMap, true)), m_guideRate(new DynamicState(timeMap, -1.0)), m_guideRatePhase(new DynamicState(timeMap, GuideRate::UNDEFINED)), m_guideRateScalingFactor(new DynamicState(timeMap, 1.0)), - m_isProducer(new DynamicState(timeMap, true)) , + m_isProducer(new DynamicState(timeMap, true)) , m_completions( new DynamicState( timeMap , CompletionSetConstPtr( new CompletionSet()) )), m_productionProperties( new DynamicState(timeMap, WellProductionProperties() )), m_injectionProperties( new DynamicState(timeMap, WellInjectionProperties() )), m_polymerProperties( new DynamicState(timeMap, WellPolymerProperties() )), + m_econproductionlimits( new DynamicState(timeMap, WellEconProductionLimits()) ), m_solventFraction( new DynamicState(timeMap, 0.0 )), m_groupName( new DynamicState( timeMap , "" )), - m_rft( new DynamicState(timeMap,false)), - m_plt( new DynamicState(timeMap,false)), + m_rft( new DynamicState(timeMap,false)), + m_plt( new DynamicState(timeMap,false)), m_timeMap( timeMap ), m_headI(headI), m_headJ(headJ), m_refDepth(refDepth), m_preferredPhase(preferredPhase), - m_grid( grid ), m_comporder(completionOrdering), m_allowCrossFlow(allowCrossFlow), + m_automaticShutIn(automaticShutIn), m_segmentset(new DynamicState(timeMap, SegmentSetPtr(new SegmentSet()))) { m_name = name_; @@ -88,6 +91,33 @@ namespace Opm { } + double Well::production_rate( Phase::PhaseEnum phase, size_t timestep ) const { + if( !this->isProducer( timestep ) ) return 0.0; + + const auto& p = this->getProductionProperties( timestep ); + + switch( phase ) { + case Phase::WATER: return p.WaterRate; + case Phase::OIL: return p.OilRate; + case Phase::GAS: return p.GasRate; + } + + throw std::logic_error( "Unreachable state. Invalid PhaseEnum value. " + "This is likely a programming error." ); + } + + double Well::injection_rate( Phase::PhaseEnum phase, size_t timestep ) const { + if( !this->isInjector( timestep ) ) return 0.0; + + const auto& i = this->getInjectionProperties( timestep ); + const auto type = i.injectorType; + + if( phase == Phase::WATER && type != WellInjector::WATER ) return 0.0; + if( phase == Phase::OIL && type != WellInjector::OIL ) return 0.0; + if( phase == Phase::GAS && type != WellInjector::GAS ) return 0.0; + + return i.surfaceInjectionRate; + } bool Well::setProductionProperties(size_t timeStep , const WellProductionProperties newProperties) { if (isInjector(timeStep)) @@ -139,6 +169,16 @@ namespace Opm { return m_solventFraction->update(timeStep, fraction); } + bool Well::setEconProductionLimits(const size_t timeStep, const WellEconProductionLimits& productionlimits) { + // not sure if this keyword turning a well to be producer. + // not sure what will happen if we use this keyword to a injector. + return m_econproductionlimits->update(timeStep, productionlimits); + } + + const WellEconProductionLimits& Well::getEconProductionLimits(const size_t timeStep) const { + return m_econproductionlimits->at(timeStep); + } + const double& Well::getSolventFraction(size_t timeStep) const { return m_solventFraction->at(timeStep); } @@ -166,11 +206,11 @@ namespace Opm { return m_messages; } bool Well::isProducer(size_t timeStep) const { - return m_isProducer->get(timeStep); + return bool( m_isProducer->get(timeStep) ); } bool Well::isInjector(size_t timeStep) const { - return !isProducer(timeStep); + return !bool( isProducer(timeStep) ); } bool Well::isAvailableForGroupControl(size_t timeStep) const { @@ -232,8 +272,7 @@ namespace Opm { auto completions = getCompletions( timeStep ); if (completions->size() > 0) { auto firstCompletion = completions->get(0); - double depth = m_grid->getCellDepth( firstCompletion->getI() , firstCompletion->getJ() , firstCompletion->getK()); - m_refDepth.setValue( depth ); + m_refDepth.setValue( firstCompletion->getCenterDepth() ); break; } else { timeStep++; @@ -252,6 +291,10 @@ namespace Opm { return m_completions->get( timeStep ); } + CompletionSetConstPtr Well::getCompletions() const { + return m_completions->back(); + } + void Well::addCompletions(size_t time_step , const std::vector& newCompletions) { CompletionSetConstPtr currentCompletionSet = m_completions->get(time_step); CompletionSetPtr newCompletionSet = CompletionSetPtr( currentCompletionSet->shallowCopy() ); @@ -267,7 +310,7 @@ namespace Opm { void Well::addCompletionSet(size_t time_step, const CompletionSetConstPtr newCompletionSet){ CompletionSetPtr mutable_copy(newCompletionSet->shallowCopy()); if (getWellCompletionOrdering() == WellCompletion::TRACK) { - mutable_copy->orderCompletions(m_headI, m_headJ, m_grid); + mutable_copy->orderCompletions(m_headI, m_headJ); } m_completions->update(time_step, mutable_copy); } @@ -288,11 +331,11 @@ namespace Opm { } bool Well::getRFTActive(size_t time_step) const{ - return m_rft->get(time_step); + return bool( m_rft->get(time_step) ); } bool Well::getPLTActive(size_t time_step) const{ - return m_plt->get(time_step); + return bool( m_plt->get(time_step) ); } void Well::setPLTActive(size_t time_step, bool value){ m_plt->update(time_step, value); @@ -361,21 +404,18 @@ namespace Opm { return m_allowCrossFlow; } + bool Well::getAutomaticShutIn() const { + return m_automaticShutIn; + } + bool Well::canOpen(size_t currentStep) const { - bool canOpen = true; - if (!getAllowCrossFlow()) { - if ( isInjector(currentStep) ) { - if (getInjectionProperties(currentStep).surfaceInjectionRate == 0) {; - canOpen = false; - } - } else { - if ( (getProductionProperties(currentStep).WaterRate + getProductionProperties(currentStep).OilRate + - getProductionProperties(currentStep).GasRate) == 0) { - canOpen = false; - } - } - } - return canOpen; + if( getAllowCrossFlow() ) return true; + + if( isInjector( currentStep ) ) + return getInjectionProperties( currentStep ).surfaceInjectionRate != 0; + + const auto& prod = getProductionProperties( currentStep ); + return (prod.WaterRate + prod.OilRate + prod.GasRate) != 0; } diff --git a/ThirdParty/custom-opm-parser/opm-parser/opm/parser/eclipse/EclipseState/Schedule/Well.hpp b/ThirdParty/custom-opm-parser/opm-parser/opm/parser/eclipse/EclipseState/Schedule/Well.hpp index 3b89e39d75..ce700ca853 100644 --- a/ThirdParty/custom-opm-parser/opm-parser/opm/parser/eclipse/EclipseState/Schedule/Well.hpp +++ b/ThirdParty/custom-opm-parser/opm-parser/opm/parser/eclipse/EclipseState/Schedule/Well.hpp @@ -28,6 +28,7 @@ #include #include #include +#include #include #include @@ -37,15 +38,17 @@ namespace Opm { class Completion; class CompletionSet; - class EclipseGrid; class Segment; class SegmentSet; class TimeMap; class Well { public: - Well(const std::string& name, std::shared_ptr grid , int headI, int headJ, Value refDepth , Phase::PhaseEnum preferredPhase, - std::shared_ptr< const TimeMap > timeMap, size_t creationTimeStep, WellCompletion::CompletionOrderEnum completionOrdering = WellCompletion::TRACK, bool allowCrossFlow = true); + Well(const std::string& name, int headI, + int headJ, Value refDepth , Phase::PhaseEnum preferredPhase, + std::shared_ptr< const TimeMap > timeMap, size_t creationTimeStep, + WellCompletion::CompletionOrderEnum completionOrdering = WellCompletion::TRACK, + bool allowCrossFlow = true, bool automaticShutIn = true); const std::string& name() const; bool hasBeenDefined(size_t timeStep) const; @@ -78,6 +81,18 @@ namespace Opm { void addCompletions(size_t time_step , const std::vector>& newCompletions); void addCompletionSet(size_t time_step, const std::shared_ptr< const CompletionSet > newCompletionSet); std::shared_ptr< const CompletionSet > getCompletions(size_t timeStep) const; + std::shared_ptr< const CompletionSet > getCompletions( ) const; + + /* The rate of a given phase under the following assumptions: + * * Returns zero if production is requested for an injector (and vice + * versa) + * * If this is an injector and something else than the + * requested phase is injected, returns 0, i.e. + * water_injector.injection_rate( gas ) == 0 + * * Mixed injection is not supported and always returns 0. + */ + double production_rate( Phase::PhaseEnum phase, size_t timestep ) const; + double injection_rate( Phase::PhaseEnum phase, size_t timestep ) const; bool setProductionProperties(size_t timeStep , const WellProductionProperties properties); WellProductionProperties getProductionPropertiesCopy(size_t timeStep) const; @@ -94,6 +109,9 @@ namespace Opm { bool setSolventFraction(size_t timeStep , const double fraction); const double& getSolventFraction(size_t timeStep) const; + bool setEconProductionLimits(const size_t timeStep, const WellEconProductionLimits& productionlimits); + const WellEconProductionLimits& getEconProductionLimits(const size_t timeStep) const; + int firstRFTOutput( ) const; bool getRFTActive(size_t time_step) const; void setRFTActive(size_t time_step, bool value); @@ -107,6 +125,7 @@ namespace Opm { WellCompletion::CompletionOrderEnum getWellCompletionOrdering() const; bool getAllowCrossFlow() const; + bool getAutomaticShutIn() const; bool canOpen(size_t time_step) const; @@ -124,20 +143,21 @@ namespace Opm { std::shared_ptr > m_status; - std::shared_ptr > m_isAvailableForGroupControl; + std::shared_ptr > m_isAvailableForGroupControl; std::shared_ptr > m_guideRate; std::shared_ptr > m_guideRatePhase; std::shared_ptr > m_guideRateScalingFactor; - std::shared_ptr > m_isProducer; + std::shared_ptr > m_isProducer; std::shared_ptr> > m_completions; std::shared_ptr > m_productionProperties; std::shared_ptr > m_injectionProperties; std::shared_ptr > m_polymerProperties; + std::shared_ptr > m_econproductionlimits; std::shared_ptr > m_solventFraction; std::shared_ptr > m_groupName; - std::shared_ptr > m_rft; - std::shared_ptr > m_plt; + std::shared_ptr > m_rft; + std::shared_ptr > m_plt; // WELSPECS data - assumes this is not dynamic @@ -146,17 +166,15 @@ namespace Opm { int m_headJ; mutable Value m_refDepth; Phase::PhaseEnum m_preferredPhase; - std::shared_ptr m_grid; WellCompletion::CompletionOrderEnum m_comporder; bool m_allowCrossFlow; + bool m_automaticShutIn; MessageContainer m_messages; // WELSEGS DATA - for mutli-segment wells // flag indicating if the well is a multi-segment well std::shared_ptr>> m_segmentset; }; - typedef std::shared_ptr WellPtr; - typedef std::shared_ptr WellConstPtr; } diff --git a/ThirdParty/custom-opm-parser/opm-parser/opm/parser/eclipse/EclipseState/Schedule/WellEconProductionLimits.cpp b/ThirdParty/custom-opm-parser/opm-parser/opm/parser/eclipse/EclipseState/Schedule/WellEconProductionLimits.cpp new file mode 100644 index 0000000000..29c85be965 --- /dev/null +++ b/ThirdParty/custom-opm-parser/opm-parser/opm/parser/eclipse/EclipseState/Schedule/WellEconProductionLimits.cpp @@ -0,0 +1,122 @@ +/* + Copyright 2016 SINTEF ICT, Applied Mathematics. + + 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 { + + WellEconProductionLimits::WellEconProductionLimits() + : m_min_oil_rate(0.0) + , m_min_gas_rate(0.0) + , m_max_water_cut(0.0) + , m_max_gas_oil_ratio(0.0) + , m_max_water_gas_ratio(0.0) + , m_workover(WellEcon::NONE) + , m_end_run(false) + , m_followon_well("'") + , m_quantity_limit(WellEcon::RATE) + , m_secondary_max_water_cut(0.0) + , m_workover_secondary(m_workover) + , m_max_gas_liquid_ratio(0.0) + , m_min_liquid_rate(0.0) + , m_max_temperature(-1e8) + , m_min_reservoir_fluid_rate(0.0) + { + } + + + + WellEconProductionLimits::WellEconProductionLimits(const DeckRecord& record) + : m_min_oil_rate(record.getItem("MIN_OIL_PRODUCTION").getSIDouble(0)) + , m_min_gas_rate(record.getItem("MIN_GAS_PRODUCTION").getSIDouble(0)) + , m_max_water_cut(record.getItem("MAX_WATER_CUT").get(0)) + , m_max_gas_oil_ratio(record.getItem("MAX_GAS_OIL_RATIO").get(0)) + , m_max_water_gas_ratio(record.getItem("MAX_WATER_GAS_RATIO").get(0)) + , m_workover(WellEcon::WorkoverEnumFromString(record.getItem("WORKOVER_RATIO_LIMIT").getTrimmedString(0))) + , m_end_run(false) + , m_followon_well(record.getItem("FOLLOW_ON_WELL").getTrimmedString(0)) + , m_quantity_limit(WellEcon::QuantityLimitEnumFromString(record.getItem("LIMITED_QUANTITY").getTrimmedString(0))) + , m_secondary_max_water_cut(record.getItem("SECOND_MAX_WATER_CUT").get(0)) + , m_max_gas_liquid_ratio(record.getItem("MAX_GAS_LIQUID_RATIO").get(0)) + , m_min_liquid_rate(record.getItem("MIN_LIQUID_PRODCUTION_RATE").getSIDouble(0)) + , m_min_reservoir_fluid_rate(record.getItem("MIN_RES_FLUID_RATE").getSIDouble(0)) + { + assert(m_workover != WellEcon::LAST); + assert(m_workover != WellEcon::RED); + + if (record.getItem("MAX_TEMP").hasValue(0)) { + m_max_temperature = record.getItem("MAX_TEMP").getSIDouble(0); + } else { + // defaulted with one really non-physical value. + m_max_temperature = -1e8; + } + + if (record.getItem("WORKOVER_SECOND_WATER_CUT_LIMIT").hasValue(0)) { + const std::string string_workover = record.getItem("WORKOVER_SECOND_WATER_CUT_LIMIT").getTrimmedString(0); + m_workover_secondary = WellEcon::WorkoverEnumFromString(string_workover); + } else { + m_workover_secondary = m_workover; + } + + if (record.getItem("END_RUN_FLAG").hasValue(0)) { + std::string string_endrun = record.getItem("END_RUN_FLAG").getTrimmedString(0); + if (string_endrun == "YES") { + m_end_run = true; + } else if (string_endrun != "NO") { + throw std::invalid_argument("Unknown input: " + string_endrun + " for END_RUN_FLAG in WECON"); + } + } + } + + + bool WellEconProductionLimits::operator==(const WellEconProductionLimits& other) const { + if ((minOilRate() == other.minOilRate()) && + (minGasRate() == other.minGasRate()) && + (maxWaterCut() == other.maxWaterCut()) && + (maxGasOilRatio() == other.maxGasOilRatio()) && + (maxWaterGasRatio() == other.maxWaterGasRatio()) && + (workover() == other.workover()) && + (followonWell() == other.followonWell()) && + (quantityLimit() == other.quantityLimit()) && + (maxSecondaryMaxWaterCut() == other.maxSecondaryMaxWaterCut()) && + (workoverSecondary() == other.workoverSecondary()) && + (maxGasLiquidRatio() == other.maxGasLiquidRatio()) && + (minLiquidRate() == other.minLiquidRate()) && + (maxTemperature() == other.maxTemperature()) && + (minReservoirFluidRate() == other.minReservoirFluidRate())) + { + + return true; + } else { + return false; + } + } + + + bool WellEconProductionLimits::operator!=(const WellEconProductionLimits& other) const { + return (!(*this == other)); + } + +} // namespace Opm diff --git a/ThirdParty/custom-opm-parser/opm-parser/opm/parser/eclipse/EclipseState/Schedule/WellEconProductionLimits.hpp b/ThirdParty/custom-opm-parser/opm-parser/opm/parser/eclipse/EclipseState/Schedule/WellEconProductionLimits.hpp new file mode 100644 index 0000000000..2cd05e7efa --- /dev/null +++ b/ThirdParty/custom-opm-parser/opm-parser/opm/parser/eclipse/EclipseState/Schedule/WellEconProductionLimits.hpp @@ -0,0 +1,169 @@ +/* + Copyright 2016 SINTEF ICT, Applied Mathematics. + + 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 WELLECONPRODUCTIONLIMITS_HPP_HEADER_INCLUDED +#define WELLECONPRODUCTIONLIMITS_HPP_HEADER_INCLUDED + +#include + +#include + +namespace Opm { + + class DeckRecord; + + class WellEconProductionLimits{ + public: + WellEconProductionLimits(const DeckRecord& record); + WellEconProductionLimits(); + + // TODO: not handling things related to m_secondary_max_water_cut + // for the moment. + + // limit switch on? + bool onAnyEffectiveLimit() const { + return (onAnyRatioLimit() || + onAnyRateLimit()); + }; + + bool onAnyRatioLimit() const { + return (onMaxWaterCut() || + onMaxGasOilRatio() || + onMaxWaterGasRatio() || + onMaxGasLiquidRatio()); + }; + + + bool onAnyRateLimit() const { + return (onMinOilRate() || + onMinGasRate() || + onMinLiquidRate() || + onMinReservoirFluidRate()); + }; + + bool onMinOilRate() const { + return (m_min_oil_rate > 0.0); + }; + + bool onMinGasRate() const { + return (m_min_gas_rate > 0.0); + }; + + bool onMaxWaterCut() const { + return (m_max_water_cut > 0.0); + }; + + bool onMaxGasOilRatio() const { + return (m_max_gas_oil_ratio > 0.0); + }; + + bool onMaxWaterGasRatio() const { + return (m_max_water_gas_ratio > 0.0); + }; + + bool onSecondaryMaxWaterCut() const { + return (m_secondary_max_water_cut > 0.0); + }; + + bool onMaxGasLiquidRatio() const { + return (m_max_gas_oil_ratio > 0.0); + }; + + // assuming Celsius temperature is used internally + bool onMaxTemperature() const { + return (m_max_temperature > -273.15); + }; + + bool onMinLiquidRate() const { + return (m_min_liquid_rate > 0.0); + }; + + bool onMinReservoirFluidRate() const { + return (m_min_reservoir_fluid_rate > 0.0); + }; + + // not sure what will happen if the followon well is a well does not exist. + bool validFollowonWell() const { + return (m_followon_well != "'"); + }; + + bool requireWorkover() const { + return (m_workover != WellEcon::NONE); + }; + + bool requireSecondaryWorkover() const { + return (m_workover_secondary != WellEcon::NONE); + } + + bool endRun() const { + return m_end_run; + } + + double minOilRate() const { return m_min_oil_rate; }; + + double minGasRate() const { return m_min_gas_rate; }; + + double maxWaterCut() const { return m_max_water_cut; }; + + double maxGasOilRatio() const { return m_max_gas_oil_ratio; }; + + double maxWaterGasRatio() const { return m_max_water_gas_ratio; }; + + WellEcon::WorkoverEnum workover() const { return m_workover; }; + + const std::string& followonWell() const { return m_followon_well; }; + + WellEcon::QuantityLimitEnum quantityLimit() const {return m_quantity_limit; }; + + double maxSecondaryMaxWaterCut() const { return m_secondary_max_water_cut; }; + + WellEcon::WorkoverEnum workoverSecondary() const { return m_workover_secondary; }; + + double maxGasLiquidRatio() const { return m_max_gas_liquid_ratio; }; + + double minLiquidRate() const { return m_min_liquid_rate; }; + + double maxTemperature() const { return m_max_temperature; }; + + double minReservoirFluidRate() const { return m_min_reservoir_fluid_rate; }; + + bool operator==(const WellEconProductionLimits& other) const; + + bool operator!=(const WellEconProductionLimits& other) const; + + private: + double m_min_oil_rate; + double m_min_gas_rate; + double m_max_water_cut; + double m_max_gas_oil_ratio; + double m_max_water_gas_ratio; + WellEcon::WorkoverEnum m_workover; + bool m_end_run; + std::string m_followon_well; + WellEcon::QuantityLimitEnum m_quantity_limit; + double m_secondary_max_water_cut; + WellEcon::WorkoverEnum m_workover_secondary; + double m_max_gas_liquid_ratio; + double m_min_liquid_rate; + double m_max_temperature; + double m_min_reservoir_fluid_rate; + }; +} // namespace Opm + +#endif // WELLECONPRODUCTIONLIMITS_HPP_HEADER_INCLUDED diff --git a/ThirdParty/custom-opm-parser/opm-parser/opm/parser/eclipse/EclipseState/Schedule/WellProductionProperties.cpp b/ThirdParty/custom-opm-parser/opm-parser/opm/parser/eclipse/EclipseState/Schedule/WellProductionProperties.cpp index 7a6a88f5a0..1cf30438fd 100644 --- a/ThirdParty/custom-opm-parser/opm-parser/opm/parser/eclipse/EclipseState/Schedule/WellProductionProperties.cpp +++ b/ThirdParty/custom-opm-parser/opm-parser/opm/parser/eclipse/EclipseState/Schedule/WellProductionProperties.cpp @@ -49,8 +49,9 @@ namespace Opm { WellProductionProperties p(record); p.predictionMode = false; - for (auto const& modeKey : {"ORAT", "WRAT", "GRAT", "LRAT", "RESV", "GRUP"}) { - auto cmode = WellProducer::ControlModeFromString( modeKey ); + namespace wp = WellProducer; + for( auto cmode : { wp::ORAT, wp::WRAT, wp::GRAT, + wp::LRAT, wp::RESV, wp::GRUP } ) { p.addProductionControl( cmode ); } @@ -67,7 +68,7 @@ namespace Opm { const auto& cmodeItem = record.getItem("CMODE"); if (!cmodeItem.defaultApplied(0)) { - const WellProducer::ControlModeEnum cmode = WellProducer::ControlModeFromString( cmodeItem.get< std::string >(0) ); + const auto cmode = WellProducer::ControlModeFromString( cmodeItem.getTrimmedString( 0 ) ); if (p.hasProductionControl( cmode )) p.controlMode = cmode; @@ -92,11 +93,17 @@ namespace Opm { p.ALQValue = record.getItem("ALQ" ).get< double >(0); //NOTE: Unit of ALQ is never touched p.VFPTableNumber = record.getItem("VFP_TABLE").get< int >(0); - for (auto const& modeKey : {"ORAT", "WRAT", "GRAT", "LRAT","RESV", "BHP" , "THP"}) { - if (!record.getItem(modeKey).defaultApplied(0)) { - auto cmode = WellProducer::ControlModeFromString( modeKey ); - p.addProductionControl( cmode ); - } + namespace wp = WellProducer; + using mode = std::pair< const char*, wp::ControlModeEnum >; + static const mode modes[] = { + { "ORAT", wp::ORAT }, { "WRAT", wp::WRAT }, { "GRAT", wp::GRAT }, + { "LRAT", wp::LRAT }, { "RESV", wp::RESV }, { "BHP", wp::BHP }, + { "THP", wp::THP } + }; + + for( const auto& cmode : modes ) { + if( !record.getItem( cmode.first ).defaultApplied( 0 ) ) + p.addProductionControl( cmode.second ); } if (addGroupProductionControl) { @@ -107,7 +114,7 @@ namespace Opm { { const auto& cmodeItem = record.getItem("CMODE"); if (cmodeItem.hasValue(0)) { - const WellProducer::ControlModeEnum cmode = WellProducer::ControlModeFromString( cmodeItem.get< std::string >(0) ); + const WellProducer::ControlModeEnum cmode = WellProducer::ControlModeFromString( cmodeItem.getTrimmedString(0) ); if (p.hasProductionControl( cmode )) p.controlMode = cmode; diff --git a/ThirdParty/custom-opm-parser/opm-parser/opm/parser/eclipse/EclipseState/Schedule/WellSet.cpp b/ThirdParty/custom-opm-parser/opm-parser/opm/parser/eclipse/EclipseState/Schedule/WellSet.cpp index 4f902361b4..48d89de5d4 100644 --- a/ThirdParty/custom-opm-parser/opm-parser/opm/parser/eclipse/EclipseState/Schedule/WellSet.cpp +++ b/ThirdParty/custom-opm-parser/opm-parser/opm/parser/eclipse/EclipseState/Schedule/WellSet.cpp @@ -36,7 +36,7 @@ namespace Opm { } - std::shared_ptr< const Well > WellSet::getWell(const std::string& wellName) const { + const Well* WellSet::getWell(const std::string& wellName) const { if (hasWell(wellName)) return m_wells.find(wellName)->second; else @@ -44,7 +44,7 @@ namespace Opm { } - void WellSet::addWell(std::shared_ptr< Well > well) { + void WellSet::addWell( Well* well) { const std::string& wellName = well->name(); if (!hasWell(wellName)) m_wells[wellName] = well; @@ -62,12 +62,12 @@ namespace Opm { WellSet * WellSet::shallowCopy() const { - WellSet * copy = new WellSet(); + std::unique_ptr< WellSet > copy( new WellSet() ); - for (std::map>::const_iterator iter=m_wells.begin(); iter != m_wells.end(); ++iter) - copy->addWell( (*iter).second ); + for( auto pair : this->m_wells ) + copy->addWell( pair.second ); - return copy; + return copy.release(); } WellSet::const_iterator WellSet::begin() const { diff --git a/ThirdParty/custom-opm-parser/opm-parser/opm/parser/eclipse/EclipseState/Schedule/WellSet.hpp b/ThirdParty/custom-opm-parser/opm-parser/opm/parser/eclipse/EclipseState/Schedule/WellSet.hpp index 1bd22d6982..82897b25cc 100644 --- a/ThirdParty/custom-opm-parser/opm-parser/opm/parser/eclipse/EclipseState/Schedule/WellSet.hpp +++ b/ThirdParty/custom-opm-parser/opm-parser/opm/parser/eclipse/EclipseState/Schedule/WellSet.hpp @@ -23,19 +23,19 @@ #include #include -#include - namespace Opm { + class Well; + class WellSet { public: - using const_iterator = std::map< std::string, std::shared_ptr< Well > >::const_iterator; + using const_iterator = std::map< std::string, Well* >::const_iterator; WellSet(); size_t size() const; bool hasWell(const std::string& wellName) const; - std::shared_ptr< const Well > getWell(const std::string& wellName) const; - void addWell(std::shared_ptr< Well > well); + const Well* getWell(const std::string& wellName) const; + void addWell( Well* well); void delWell(const std::string& wellName); WellSet * shallowCopy() const; @@ -43,11 +43,8 @@ namespace Opm { const_iterator end() const; private: - std::map> m_wells; + std::map m_wells; }; - - typedef std::shared_ptr WellSetPtr; - typedef std::shared_ptr WellSetConstPtr; } #endif diff --git a/ThirdParty/custom-opm-parser/opm-parser/opm/parser/eclipse/EclipseState/Schedule/tests/CompletionSetTests.cpp b/ThirdParty/custom-opm-parser/opm-parser/opm/parser/eclipse/EclipseState/Schedule/tests/CompletionSetTests.cpp index c4db040614..a715fde9dd 100644 --- a/ThirdParty/custom-opm-parser/opm-parser/opm/parser/eclipse/EclipseState/Schedule/tests/CompletionSetTests.cpp +++ b/ThirdParty/custom-opm-parser/opm-parser/opm/parser/eclipse/EclipseState/Schedule/tests/CompletionSetTests.cpp @@ -47,8 +47,8 @@ BOOST_AUTO_TEST_CASE(CreateCompletionSetOK) { BOOST_AUTO_TEST_CASE(AddCompletionSizeCorrect) { Opm::CompletionSet completionSet; - Opm::CompletionConstPtr completion1(new Opm::Completion(10,10,10,Opm::WellCompletion::OPEN , Opm::Value("ConnectionTransmissibilityFactor",99.88), Opm::Value("D",22.33), Opm::Value("SKIN",33.22))); - Opm::CompletionConstPtr completion2(new Opm::Completion(11,10,10,Opm::WellCompletion::OPEN , Opm::Value("ConnectionTransmissibilityFactor",99.88), Opm::Value("D",22.33), Opm::Value("SKIN",33.22))); + Opm::CompletionConstPtr completion1(new Opm::Completion(10,10,10,0.0,Opm::WellCompletion::OPEN , Opm::Value("ConnectionTransmissibilityFactor",99.88), Opm::Value("D",22.33), Opm::Value("SKIN",33.22))); + Opm::CompletionConstPtr completion2(new Opm::Completion(11,10,10,0.0,Opm::WellCompletion::OPEN , Opm::Value("ConnectionTransmissibilityFactor",99.88), Opm::Value("D",22.33), Opm::Value("SKIN",33.22))); completionSet.add( completion1 ); BOOST_CHECK_EQUAL( 1U , completionSet.size() ); @@ -61,8 +61,8 @@ BOOST_AUTO_TEST_CASE(AddCompletionSizeCorrect) { BOOST_AUTO_TEST_CASE(CompletionSetGetOutOfRangeThrows) { Opm::CompletionSet completionSet; - Opm::CompletionConstPtr completion1(new Opm::Completion(10,10,10,Opm::WellCompletion::OPEN , Opm::Value("ConnectionTransmissibilityFactor",99.88), Opm::Value("D",22.33), Opm::Value("SKIN",33.22))); - Opm::CompletionConstPtr completion2(new Opm::Completion(11,10,10,Opm::WellCompletion::OPEN , Opm::Value("ConnectionTransmissibilityFactor",99.88), Opm::Value("D",22.33), Opm::Value("SKIN",33.22))); + Opm::CompletionConstPtr completion1(new Opm::Completion(10,10,10,0.0,Opm::WellCompletion::OPEN , Opm::Value("ConnectionTransmissibilityFactor",99.88), Opm::Value("D",22.33), Opm::Value("SKIN",33.22))); + Opm::CompletionConstPtr completion2(new Opm::Completion(11,10,10,0.0,Opm::WellCompletion::OPEN , Opm::Value("ConnectionTransmissibilityFactor",99.88), Opm::Value("D",22.33), Opm::Value("SKIN",33.22))); completionSet.add( completion1 ); BOOST_CHECK_EQUAL( 1U , completionSet.size() ); @@ -77,8 +77,8 @@ BOOST_AUTO_TEST_CASE(CompletionSetGetOutOfRangeThrows) { BOOST_AUTO_TEST_CASE(AddCompletionSameCellUpdates) { Opm::CompletionSet completionSet; - Opm::CompletionConstPtr completion1(new Opm::Completion(10,10,10,Opm::WellCompletion::OPEN , Opm::Value("ConnectionTransmissibilityFactor",99.88), Opm::Value("D",22.33), Opm::Value("SKIN",33.22))); - Opm::CompletionConstPtr completion2(new Opm::Completion(10,10,10,Opm::WellCompletion::SHUT , Opm::Value("ConnectionTransmissibilityFactor",99.88), Opm::Value("D",22.33), Opm::Value("SKIN",33.22))); + Opm::CompletionConstPtr completion1(new Opm::Completion(10,10,10,0.0, Opm::WellCompletion::OPEN , Opm::Value("ConnectionTransmissibilityFactor",99.88), Opm::Value("D",22.33), Opm::Value("SKIN",33.22))); + Opm::CompletionConstPtr completion2(new Opm::Completion(10,10,10,0.0,Opm::WellCompletion::SHUT , Opm::Value("ConnectionTransmissibilityFactor",99.88), Opm::Value("D",22.33), Opm::Value("SKIN",33.22))); completionSet.add( completion1 ); @@ -93,9 +93,9 @@ BOOST_AUTO_TEST_CASE(AddCompletionSameCellUpdates) { BOOST_AUTO_TEST_CASE(AddCompletionShallowCopy) { Opm::CompletionSet completionSet; - Opm::CompletionConstPtr completion1(new Opm::Completion(10,10,10,Opm::WellCompletion::OPEN , Opm::Value("ConnectionTransmissibilityFactor",99.88), Opm::Value("D",22.33), Opm::Value("SKIN",33.22))); - Opm::CompletionConstPtr completion2(new Opm::Completion(10,10,11,Opm::WellCompletion::SHUT , Opm::Value("ConnectionTransmissibilityFactor",99.88), Opm::Value("D",22.33), Opm::Value("SKIN",33.22))); - Opm::CompletionConstPtr completion3(new Opm::Completion(10,10,12,Opm::WellCompletion::SHUT , Opm::Value("ConnectionTransmissibilityFactor",99.88), Opm::Value("D",22.33), Opm::Value("SKIN",33.22))); + Opm::CompletionConstPtr completion1(new Opm::Completion(10,10,10,0.0, Opm::WellCompletion::OPEN , Opm::Value("ConnectionTransmissibilityFactor",99.88), Opm::Value("D",22.33), Opm::Value("SKIN",33.22))); + Opm::CompletionConstPtr completion2(new Opm::Completion(10,10,11,0.0, Opm::WellCompletion::SHUT , Opm::Value("ConnectionTransmissibilityFactor",99.88), Opm::Value("D",22.33), Opm::Value("SKIN",33.22))); + Opm::CompletionConstPtr completion3(new Opm::Completion(10,10,12,0.0, Opm::WellCompletion::SHUT , Opm::Value("ConnectionTransmissibilityFactor",99.88), Opm::Value("D",22.33), Opm::Value("SKIN",33.22))); completionSet.add( completion1 ); completionSet.add( completion2 ); diff --git a/ThirdParty/custom-opm-parser/opm-parser/opm/parser/eclipse/EclipseState/Schedule/tests/CompletionTests.cpp b/ThirdParty/custom-opm-parser/opm-parser/opm/parser/eclipse/EclipseState/Schedule/tests/CompletionTests.cpp index e61de7d51f..8f01961997 100644 --- a/ThirdParty/custom-opm-parser/opm-parser/opm/parser/eclipse/EclipseState/Schedule/tests/CompletionTests.cpp +++ b/ThirdParty/custom-opm-parser/opm-parser/opm/parser/eclipse/EclipseState/Schedule/tests/CompletionTests.cpp @@ -38,12 +38,12 @@ BOOST_AUTO_TEST_CASE(CreateCompletionOK) { - Opm::Completion completion(10,10,10,Opm::WellCompletion::OPEN,Opm::Value("ConnectionTransmissibilityFactor",99.88), Opm::Value("D",22.33), Opm::Value("SKIN",33.22)); + Opm::Completion completion(10,10,10,0.0,Opm::WellCompletion::OPEN,Opm::Value("ConnectionTransmissibilityFactor",99.88), Opm::Value("D",22.33), Opm::Value("SKIN",33.22)); } BOOST_AUTO_TEST_CASE(testGetFunctions) { - Opm::Completion completion(10,11,12,Opm::WellCompletion::OPEN,Opm::Value("ConnectionTransmissibilityFactor",99.88), Opm::Value("D",22.33), Opm::Value("SKIN",33.22)); + Opm::Completion completion(10,11,12,0.0, Opm::WellCompletion::OPEN,Opm::Value("ConnectionTransmissibilityFactor",99.88), Opm::Value("D",22.33), Opm::Value("SKIN",33.22)); BOOST_CHECK_EQUAL( 10 , completion.getI() ); BOOST_CHECK_EQUAL( 11 , completion.getJ() ); BOOST_CHECK_EQUAL( 12 , completion.getK() ); @@ -56,11 +56,11 @@ BOOST_AUTO_TEST_CASE(testGetFunctions) { BOOST_AUTO_TEST_CASE(CompletionTestssameCoordinate) { - Opm::Completion completion1(10,10,10,Opm::WellCompletion::OPEN, Opm::Value("ConnectionTransmissibilityFactor",99.88), Opm::Value("D",22.33), Opm::Value("SKIN",33.22)); - Opm::Completion completion2(10,10,10,Opm::WellCompletion::OPEN, Opm::Value("ConnectionTransmissibilityFactor",99.88), Opm::Value("D",22.33), Opm::Value("SKIN",33.22)); - Opm::Completion completion3(11,10,10,Opm::WellCompletion::OPEN, Opm::Value("ConnectionTransmissibilityFactor",99.88), Opm::Value("D",22.33), Opm::Value("SKIN",33.22)); - Opm::Completion completion4(10,11,10,Opm::WellCompletion::OPEN, Opm::Value("ConnectionTransmissibilityFactor",99.88), Opm::Value("D",22.33), Opm::Value("SKIN",33.22)); - Opm::Completion completion5(10,10,11,Opm::WellCompletion::OPEN, Opm::Value("ConnectionTransmissibilityFactor",99.88), Opm::Value("D",22.33), Opm::Value("SKIN",33.22)); + Opm::Completion completion1(10,10,10,0.0, Opm::WellCompletion::OPEN, Opm::Value("ConnectionTransmissibilityFactor",99.88), Opm::Value("D",22.33), Opm::Value("SKIN",33.22)); + Opm::Completion completion2(10,10,10,0.0, Opm::WellCompletion::OPEN, Opm::Value("ConnectionTransmissibilityFactor",99.88), Opm::Value("D",22.33), Opm::Value("SKIN",33.22)); + Opm::Completion completion3(11,10,10,0.0, Opm::WellCompletion::OPEN, Opm::Value("ConnectionTransmissibilityFactor",99.88), Opm::Value("D",22.33), Opm::Value("SKIN",33.22)); + Opm::Completion completion4(10,11,10,0.0, Opm::WellCompletion::OPEN, Opm::Value("ConnectionTransmissibilityFactor",99.88), Opm::Value("D",22.33), Opm::Value("SKIN",33.22)); + Opm::Completion completion5(10,10,11,0.0, Opm::WellCompletion::OPEN, Opm::Value("ConnectionTransmissibilityFactor",99.88), Opm::Value("D",22.33), Opm::Value("SKIN",33.22)); BOOST_CHECK( completion1.sameCoordinate( completion2 )); BOOST_CHECK_EQUAL( false , completion1.sameCoordinate( completion3 )); diff --git a/ThirdParty/custom-opm-parser/opm-parser/opm/parser/eclipse/EclipseState/Schedule/tests/DynamicStateTests.cpp b/ThirdParty/custom-opm-parser/opm-parser/opm/parser/eclipse/EclipseState/Schedule/tests/DynamicStateTests.cpp index 0ad78de9ed..8d3d7e0198 100644 --- a/ThirdParty/custom-opm-parser/opm-parser/opm/parser/eclipse/EclipseState/Schedule/tests/DynamicStateTests.cpp +++ b/ThirdParty/custom-opm-parser/opm-parser/opm/parser/eclipse/EclipseState/Schedule/tests/DynamicStateTests.cpp @@ -53,6 +53,7 @@ BOOST_AUTO_TEST_CASE(DynamicStateGetDefault) { Opm::TimeMapPtr timeMap(new Opm::TimeMap(boost::posix_time::ptime(startDate))); Opm::DynamicState state(timeMap , 137); BOOST_CHECK_EQUAL( 137 , state.get(0)); + BOOST_CHECK_EQUAL( 137 , state.back() ); } @@ -92,6 +93,7 @@ BOOST_AUTO_TEST_CASE(DynamicStateSetOK) { BOOST_CHECK_EQUAL( 60 , state.get(6)); BOOST_CHECK_EQUAL( 60 , state.get(8)); BOOST_CHECK_EQUAL( 60 , state.get(9)); + BOOST_CHECK_EQUAL( 60 , state.back()); } diff --git a/ThirdParty/custom-opm-parser/opm-parser/opm/parser/eclipse/EclipseState/Schedule/tests/GeomodifierTests.cpp b/ThirdParty/custom-opm-parser/opm-parser/opm/parser/eclipse/EclipseState/Schedule/tests/GeomodifierTests.cpp index 26ef2b1b7b..4e0fa5b1d2 100644 --- a/ThirdParty/custom-opm-parser/opm-parser/opm/parser/eclipse/EclipseState/Schedule/tests/GeomodifierTests.cpp +++ b/ThirdParty/custom-opm-parser/opm-parser/opm/parser/eclipse/EclipseState/Schedule/tests/GeomodifierTests.cpp @@ -47,6 +47,15 @@ BOOST_AUTO_TEST_CASE( CheckUnsoppertedInSCHEDULE ) { "RUNSPEC\n" "DIMENS\n" " 10 10 10 / \n" + "GRID\n" + "DX\n" + "1000*0.25 /\n" + "DY\n" + "1000*0.25 /\n" + "DZ\n" + "1000*0.25 /\n" + "TOPS\n" + "100*0.25 /\n" "SCHEDULE\n" "TSTEP -- 1,2\n" " 10 10/\n" @@ -64,7 +73,7 @@ BOOST_AUTO_TEST_CASE( CheckUnsoppertedInSCHEDULE ) { Parser parser(true); auto deck = parser.parseString( deckString , parseContext ); - std::shared_ptr grid = std::make_shared( deck ); + EclipseGrid grid( deck ); parseContext.update( ParseContext::UNSUPPORTED_SCHEDULE_GEO_MODIFIER , InputError::IGNORE ); { diff --git a/ThirdParty/custom-opm-parser/opm-parser/opm/parser/eclipse/EclipseState/Schedule/tests/GroupTests.cpp b/ThirdParty/custom-opm-parser/opm-parser/opm/parser/eclipse/EclipseState/Schedule/tests/GroupTests.cpp index f91704f1e7..e13cf543fb 100644 --- a/ThirdParty/custom-opm-parser/opm-parser/opm/parser/eclipse/EclipseState/Schedule/tests/GroupTests.cpp +++ b/ThirdParty/custom-opm-parser/opm-parser/opm/parser/eclipse/EclipseState/Schedule/tests/GroupTests.cpp @@ -25,8 +25,6 @@ #include #include - - #include #include #include @@ -38,6 +36,8 @@ #include #include +using namespace Opm; + static Opm::TimeMapPtr createXDaysTimeMap(size_t numDays) { boost::gregorian::date startDate( 2010 , boost::gregorian::Jan , 1); Opm::TimeMapPtr timeMap(new Opm::TimeMap(boost::posix_time::ptime(startDate))); @@ -75,14 +75,18 @@ BOOST_AUTO_TEST_CASE(CreateGroup_SetInjectorProducer_CorrectStatusSet) { BOOST_CHECK(!group1.isInjectionGroup(1)); group1.setProductionGroup(3, false); BOOST_CHECK(!group1.isProductionGroup(3)); - BOOST_CHECK(group1.isInjectionGroup(3)); + BOOST_CHECK(!group1.isInjectionGroup(3)); group2.setProductionGroup(0, false); BOOST_CHECK(!group2.isProductionGroup(1)); - BOOST_CHECK(group2.isInjectionGroup(1)); + BOOST_CHECK(!group2.isInjectionGroup(1)); group2.setProductionGroup(3, true); BOOST_CHECK(group2.isProductionGroup(4)); BOOST_CHECK(!group2.isInjectionGroup(4)); + group2.setInjectionGroup(4, true); + BOOST_CHECK(group2.isProductionGroup(5)); + BOOST_CHECK(group2.isInjectionGroup(5)); + } @@ -155,21 +159,20 @@ BOOST_AUTO_TEST_CASE(GroupAddWell) { Opm::TimeMapPtr timeMap = createXDaysTimeMap(10); Opm::Group group("G1" , timeMap , 0); - std::shared_ptr grid = std::make_shared(10,10,10); - Opm::WellPtr well1(new Opm::Well("WELL1" , grid , 0, 0, Opm::Value("REF_DEPTH"), Opm::Phase::OIL, timeMap, 0)); - Opm::WellPtr well2(new Opm::Well("WELL2" , grid , 0, 0, Opm::Value("REF_DEPTH"), Opm::Phase::OIL, timeMap, 0)); + auto well1 = std::make_shared< Well >("WELL1", 0, 0, Opm::Value("REF_DEPTH"), Opm::Phase::OIL, timeMap, 0); + auto well2 = std::make_shared< Well >("WELL2", 0, 0, Opm::Value("REF_DEPTH"), Opm::Phase::OIL, timeMap, 0); BOOST_CHECK_EQUAL(0U , group.numWells(2)); - group.addWell( 3 , well1 ); + group.addWell( 3 , well1.get() ); BOOST_CHECK_EQUAL( 1U , group.numWells(3)); BOOST_CHECK_EQUAL( 0U , group.numWells(1)); - group.addWell( 4 , well1 ); + group.addWell( 4 , well1.get() ); BOOST_CHECK_EQUAL( 1U , group.numWells(4)); BOOST_CHECK_EQUAL( 0U , group.numWells(1)); BOOST_CHECK_EQUAL( 1U , group.numWells(5)); - group.addWell( 6 , well2 ); + group.addWell( 6 , well2.get() ); BOOST_CHECK_EQUAL( 1U , group.numWells(4)); BOOST_CHECK_EQUAL( 0U , group.numWells(1)); BOOST_CHECK_EQUAL( 1U , group.numWells(5)); @@ -193,16 +196,15 @@ BOOST_AUTO_TEST_CASE(GroupAddAndDelWell) { Opm::TimeMapPtr timeMap = createXDaysTimeMap(10); Opm::Group group("G1" , timeMap , 0); - std::shared_ptr grid = std::make_shared(10,10,10); - Opm::WellPtr well1(new Opm::Well("WELL1" , grid , 0, 0, Opm::Value("REF_DEPTH"), Opm::Phase::OIL, timeMap, 0)); - Opm::WellPtr well2(new Opm::Well("WELL2" , grid , 0, 0, Opm::Value("REF_DEPTH"), Opm::Phase::OIL, timeMap, 0)); + auto well1 = std::make_shared< Well >("WELL1", 0, 0, Opm::Value("REF_DEPTH"), Opm::Phase::OIL, timeMap, 0); + auto well2 = std::make_shared< Well >("WELL2", 0, 0, Opm::Value("REF_DEPTH"), Opm::Phase::OIL, timeMap, 0); BOOST_CHECK_EQUAL(0U , group.numWells(2)); - group.addWell( 3 , well1 ); + group.addWell( 3 , well1.get() ); BOOST_CHECK_EQUAL( 1U , group.numWells(3)); BOOST_CHECK_EQUAL( 0U , group.numWells(1)); - group.addWell( 6 , well2 ); + group.addWell( 6 , well2.get() ); BOOST_CHECK_EQUAL( 1U , group.numWells(4)); BOOST_CHECK_EQUAL( 0U , group.numWells(1)); BOOST_CHECK_EQUAL( 1U , group.numWells(5)); @@ -230,14 +232,13 @@ BOOST_AUTO_TEST_CASE(GroupAddAndDelWell) { BOOST_AUTO_TEST_CASE(getWells) { Opm::TimeMapPtr timeMap = createXDaysTimeMap(10); Opm::Group group("G1" , timeMap , 0); - std::shared_ptr grid = std::make_shared(10,10,10); - Opm::WellPtr well1(new Opm::Well("WELL1" , grid , 0, 0, Opm::Value("REF_DEPTH"), Opm::Phase::OIL, timeMap, 0)); - Opm::WellPtr well2(new Opm::Well("WELL2" , grid , 0, 0, Opm::Value("REF_DEPTH"), Opm::Phase::OIL, timeMap, 0)); + auto well1 = std::make_shared< Well >("WELL1", 0, 0, Opm::Value("REF_DEPTH"), Opm::Phase::OIL, timeMap, 0); + auto well2 = std::make_shared< Well >("WELL2", 0, 0, Opm::Value("REF_DEPTH"), Opm::Phase::OIL, timeMap, 0); - group.addWell( 2 , well1 ); - group.addWell( 3 , well1 ); - group.addWell( 3 , well2 ); - group.addWell( 4 , well1 ); + group.addWell( 2 , well1.get() ); + group.addWell( 3 , well1.get() ); + group.addWell( 3 , well2.get() ); + group.addWell( 4 , well1.get() ); std::vector< std::string > names = { "WELL1", "WELL2" }; std::vector< std::string > wnames; @@ -285,12 +286,12 @@ BOOST_AUTO_TEST_CASE(createDeckWithGEFAC) { Opm::ParseContext parseContext; Opm::DeckPtr deck = parser.parseString(input, parseContext); - std::shared_ptr grid = std::make_shared(10, 10, 10); + EclipseGrid grid(10,10,10); Opm::Schedule schedule(parseContext , grid, deck ); - Opm::GroupConstPtr group1 = schedule.getGroup("PRODUC"); - BOOST_CHECK_EQUAL(group1->getGroupEfficiencyFactor(0), 0.85); - BOOST_CHECK_EQUAL(group1->getTransferGroupEfficiencyFactor(0), true); + const auto& group1 = schedule.getGroup("PRODUC"); + BOOST_CHECK_EQUAL(group1.getGroupEfficiencyFactor(0), 0.85); + BOOST_CHECK(group1.getTransferGroupEfficiencyFactor(0)); } @@ -332,9 +333,9 @@ BOOST_AUTO_TEST_CASE(createDeckWithWGRUPCONandWCONPROD) { Opm::ParseContext parseContext; Opm::DeckPtr deck = parser.parseString(input, parseContext); - std::shared_ptr grid = std::make_shared(10, 10, 10); + EclipseGrid grid(10,10,10); Opm::Schedule schedule(parseContext , grid, deck ); - Opm::WellConstPtr currentWell = schedule.getWell("B-37T2"); + const auto* currentWell = schedule.getWell("B-37T2"); const Opm::WellProductionProperties& wellProductionProperties = currentWell->getProductionProperties(0); BOOST_CHECK_EQUAL(wellProductionProperties.controlMode, Opm::WellProducer::ControlModeEnum::GRUP); diff --git a/ThirdParty/custom-opm-parser/opm-parser/opm/parser/eclipse/EclipseState/Schedule/tests/ScheduleTests.cpp b/ThirdParty/custom-opm-parser/opm-parser/opm/parser/eclipse/EclipseState/Schedule/tests/ScheduleTests.cpp index 4d474ab03c..231e4fe047 100644 --- a/ThirdParty/custom-opm-parser/opm-parser/opm/parser/eclipse/EclipseState/Schedule/tests/ScheduleTests.cpp +++ b/ThirdParty/custom-opm-parser/opm-parser/opm/parser/eclipse/EclipseState/Schedule/tests/ScheduleTests.cpp @@ -23,10 +23,8 @@ #define BOOST_TEST_MODULE ScheduleTests -#include #include #include -#include #include #include @@ -189,8 +187,8 @@ static DeckPtr createDeckWithWellsAndCompletionData() { " 10 JUL 2007 / \n" " 10 AUG 2007 / \n" "/\n" - "COMPDAT\n" - " 'OP_1' 9 9 3 9 'OPEN' 1* 32.948 0.311 3047.839 1* 1* 'X' 22.100 / \n" + "COMPDAT\n" // with defaulted I and J + " 'OP_1' 0 * 3 9 'OPEN' 1* 32.948 0.311 3047.839 1* 1* 'X' 22.100 / \n" "/\n"; return parser.parseString(input, ParseContext()); @@ -199,16 +197,16 @@ static DeckPtr createDeckWithWellsAndCompletionData() { BOOST_AUTO_TEST_CASE(CreateScheduleDeckMissingReturnsDefaults) { DeckPtr deck(new Deck()); deck->addKeyword( DeckKeyword( "SCHEDULE" ) ); - std::shared_ptr grid = std::make_shared(10,10,10); + EclipseGrid grid(10,10,10); Schedule schedule(ParseContext() , grid , deck ); BOOST_CHECK_EQUAL( schedule.getStartTime() , boost::posix_time::ptime(boost::gregorian::date( 1983 , boost::gregorian::Jan , 1))); } BOOST_AUTO_TEST_CASE(CreateScheduleDeckWellsOrdered) { DeckPtr deck = createDeckWithWellsOrdered(); - std::shared_ptr grid = std::make_shared(100,100,100); + EclipseGrid grid(100,100,100); Schedule schedule(ParseContext() , grid , deck ); - std::vector wells = schedule.getWells(); + auto wells = schedule.getWells(); BOOST_CHECK_EQUAL( "CW_1" , wells[0]->name()); BOOST_CHECK_EQUAL( "BW_2" , wells[1]->name()); @@ -217,21 +215,21 @@ BOOST_AUTO_TEST_CASE(CreateScheduleDeckWellsOrdered) { BOOST_AUTO_TEST_CASE(CreateScheduleDeckWithStart) { DeckPtr deck = createDeck(); - std::shared_ptr grid = std::make_shared(10,10,10); + EclipseGrid grid(10,10,10); Schedule schedule(ParseContext() , grid , deck ); BOOST_CHECK_EQUAL( schedule.getStartTime() , boost::posix_time::ptime(boost::gregorian::date( 1998 , boost::gregorian::Mar , 8))); } BOOST_AUTO_TEST_CASE(CreateScheduleDeckWithSCHEDULENoThrow) { DeckPtr deck(new Deck()); - std::shared_ptr grid = std::make_shared(10,10,10); + EclipseGrid grid(10,10,10); deck->addKeyword( DeckKeyword( "SCHEDULE" ) ); BOOST_CHECK_NO_THROW(Schedule schedule(ParseContext() , grid , deck )); } BOOST_AUTO_TEST_CASE(EmptyScheduleHasNoWells) { - std::shared_ptr grid = std::make_shared(10,10,10); + EclipseGrid grid(10,10,10); DeckPtr deck = createDeck(); Schedule schedule(ParseContext() , grid , deck ); BOOST_CHECK_EQUAL( 0U , schedule.numWells() ); @@ -240,10 +238,10 @@ BOOST_AUTO_TEST_CASE(EmptyScheduleHasNoWells) { } BOOST_AUTO_TEST_CASE(CreateSchedule_DeckWithoutGRUPTREE_HasRootGroupTreeNodeForTimeStepZero) { - std::shared_ptr grid = std::make_shared(10,10,10); + EclipseGrid grid(10,10,10); DeckPtr deck = createDeck(); Schedule schedule(ParseContext() , grid , deck ); - BOOST_CHECK_EQUAL("FIELD", schedule.getGroupTree(0)->getNode("FIELD")->name()); + BOOST_CHECK_EQUAL("FIELD", schedule.getGroupTree(0).getNode("FIELD")->name()); } static std::shared_ptr< Deck > deckWithGRUPTREE() { @@ -265,10 +263,10 @@ static std::shared_ptr< Deck > deckWithGRUPTREE() { } BOOST_AUTO_TEST_CASE(CreateSchedule_DeckWithGRUPTREE_HasRootGroupTreeNodeForTimeStepZero) { - auto grid = std::make_shared(10,10,10); + EclipseGrid grid(10,10,10); auto deck = deckWithGRUPTREE(); Schedule schedule(ParseContext() , grid , deck ); - GroupTreeNodePtr fieldNode = schedule.getGroupTree(0)->getNode("FIELD"); + GroupTreeNodePtr fieldNode = schedule.getGroupTree(0).getNode("FIELD"); BOOST_CHECK_EQUAL("FIELD", fieldNode->name()); GroupTreeNodePtr FAREN = fieldNode->getChildGroup("FAREN"); BOOST_CHECK(FAREN->hasChildGroup("BARNET")); @@ -276,7 +274,7 @@ BOOST_AUTO_TEST_CASE(CreateSchedule_DeckWithGRUPTREE_HasRootGroupTreeNodeForTime BOOST_AUTO_TEST_CASE(GetGroups) { auto deck = deckWithGRUPTREE(); - auto grid = std::make_shared(10,10,10); + EclipseGrid grid(10,10,10); Schedule schedule(ParseContext() , grid , deck ); auto groups = schedule.getGroups(); @@ -293,7 +291,7 @@ BOOST_AUTO_TEST_CASE(GetGroups) { } BOOST_AUTO_TEST_CASE(EmptyScheduleHasFIELDGroup) { - std::shared_ptr grid = std::make_shared(10,10,10); + EclipseGrid grid(10,10,10); DeckPtr deck = createDeck(); Schedule schedule(ParseContext() , grid , deck ); BOOST_CHECK_EQUAL( 1U , schedule.numGroups() ); @@ -303,54 +301,53 @@ BOOST_AUTO_TEST_CASE(EmptyScheduleHasFIELDGroup) { } BOOST_AUTO_TEST_CASE(WellsIterator_Empty_EmptyVectorReturned) { - std::shared_ptr grid = std::make_shared(10,10,10); + EclipseGrid grid(10,10,10); DeckPtr deck = createDeck(); Schedule schedule(ParseContext() , grid , deck ); size_t timeStep = 0; - std::vector wells_alltimesteps = schedule.getWells(); + const auto wells_alltimesteps = schedule.getWells(); BOOST_CHECK_EQUAL(0U, wells_alltimesteps.size()); - std::vector wells_t0 = schedule.getWells(timeStep); + const auto wells_t0 = schedule.getWells(timeStep); BOOST_CHECK_EQUAL(0U, wells_t0.size()); BOOST_CHECK_THROW(schedule.getWells(1), std::invalid_argument); } BOOST_AUTO_TEST_CASE(WellsIterator_HasWells_WellsReturned) { - std::shared_ptr grid = std::make_shared(10,10,10); + EclipseGrid grid(10,10,10); DeckPtr deck = createDeckWithWells(); Schedule schedule(ParseContext() , grid , deck ); size_t timeStep = 0; - std::vector wells_alltimesteps = schedule.getWells(); + const auto wells_alltimesteps = schedule.getWells(); BOOST_CHECK_EQUAL(3U, wells_alltimesteps.size()); - std::vector wells_t0 = schedule.getWells(timeStep); + const auto wells_t0 = schedule.getWells(timeStep); BOOST_CHECK_EQUAL(1U, wells_t0.size()); - std::vector wells_t3 = schedule.getWells(3); + const auto wells_t3 = schedule.getWells(3); BOOST_CHECK_EQUAL(3U, wells_t3.size()); } BOOST_AUTO_TEST_CASE(WellsIteratorWithRegex_HasWells_WellsReturned) { - std::shared_ptr grid = std::make_shared(10,10,10); + EclipseGrid grid(10,10,10); DeckPtr deck = createDeckWithWells(); Schedule schedule(ParseContext() , grid , deck ); std::string wellNamePattern; - std::vector wells; wellNamePattern = "*"; - wells = schedule.getWells(wellNamePattern); + auto wells = schedule.getWellsMatching(wellNamePattern); BOOST_CHECK_EQUAL(3U, wells.size()); wellNamePattern = "W_*"; - wells = schedule.getWells(wellNamePattern); + wells = schedule.getWellsMatching(wellNamePattern); BOOST_CHECK_EQUAL(2U, wells.size()); wellNamePattern = "W_3"; - wells = schedule.getWells(wellNamePattern); + wells = schedule.getWellsMatching(wellNamePattern); BOOST_CHECK_EQUAL(1U, wells.size()); } BOOST_AUTO_TEST_CASE(ReturnNumWellsTimestep) { - std::shared_ptr grid = std::make_shared(10,10,10); + EclipseGrid grid(10,10,10); DeckPtr deck = createDeckWithWells(); Schedule schedule(ParseContext() , grid , deck ); @@ -361,7 +358,7 @@ BOOST_AUTO_TEST_CASE(ReturnNumWellsTimestep) { } BOOST_AUTO_TEST_CASE(ReturnMaxNumCompletionsForWellsInTimestep) { - std::shared_ptr grid = std::make_shared(10,10,10); + EclipseGrid grid(10,10,10); DeckPtr deck = createDeckWithWellsAndCompletionData(); Schedule schedule(ParseContext() , grid , deck ); @@ -370,11 +367,11 @@ BOOST_AUTO_TEST_CASE(ReturnMaxNumCompletionsForWellsInTimestep) { } BOOST_AUTO_TEST_CASE(TestCrossFlowHandling) { - std::shared_ptr grid = std::make_shared(10,10,10); + EclipseGrid grid(10,10,10); DeckPtr deck = createDeckForTestingCrossFlow(); Schedule schedule(ParseContext() , grid , deck ); - WellPtr well_ban = schedule.getWell("BAN"); + auto well_ban = schedule.getWell("BAN"); BOOST_CHECK_EQUAL(well_ban->getAllowCrossFlow(), false); @@ -387,8 +384,8 @@ BOOST_AUTO_TEST_CASE(TestCrossFlowHandling) { { - WellPtr well_allow = schedule.getWell("ALLOW"); - WellPtr well_default = schedule.getWell("DEFAULT"); + auto well_allow = schedule.getWell("ALLOW"); + auto well_default = schedule.getWell("DEFAULT"); BOOST_CHECK_EQUAL(well_default->getAllowCrossFlow(), true); BOOST_CHECK_EQUAL(well_allow->getAllowCrossFlow(), true); @@ -450,11 +447,10 @@ static DeckPtr createDeckWithWellsAndCompletionDataWithWELOPEN() { } BOOST_AUTO_TEST_CASE(CreateScheduleDeckWellsAndCompletionDataWithWELOPEN) { - std::shared_ptr grid = std::make_shared(10,10,10); + EclipseGrid grid(10,10,10); DeckPtr deck = createDeckWithWellsAndCompletionDataWithWELOPEN(); Schedule schedule(ParseContext() , grid , deck ); - WellPtr well; - well = schedule.getWell("OP_1"); + auto* well = schedule.getWell("OP_1"); size_t currentStep = 0; BOOST_CHECK_EQUAL(WellCommon::StatusEnum::SHUT, well->getStatus(currentStep)); currentStep = 3; @@ -554,12 +550,11 @@ BOOST_AUTO_TEST_CASE(CreateScheduleDeckWithWELOPEN_TryToOpenWellWithShutCompleti " 'OP_1' OPEN / \n " "/\n"; - std::shared_ptr grid = std::make_shared(10,10,10); + EclipseGrid grid(10,10,10); ParseContext parseContext; DeckPtr deck = parser.parseString(input, parseContext); Schedule schedule(parseContext , grid , deck ); - WellPtr well; - well = schedule.getWell("OP_1"); + auto* well = schedule.getWell("OP_1"); size_t currentStep = 3; BOOST_CHECK_EQUAL(WellCommon::StatusEnum::SHUT, well->getStatus(currentStep)); currentStep = 4; @@ -598,7 +593,7 @@ BOOST_AUTO_TEST_CASE(CreateScheduleDeckWithCOMPLUMPwithC1_ThrowsExcpetion) { DeckPtr deck = parser.parseString(input, ParseContext()); - std::shared_ptr grid = std::make_shared( 10 , 10 , 10 ); + EclipseGrid grid(10,10,10); BOOST_CHECK_THROW(Schedule schedule(ParseContext() , grid , deck ), std::exception); } @@ -634,7 +629,7 @@ BOOST_AUTO_TEST_CASE(CreateScheduleDeckWithCOMPLUMPwithC1andC2_ThrowsExcpetion) DeckPtr deck = parser.parseString(input, ParseContext()); - std::shared_ptr grid = std::make_shared( 10 , 10 , 10 ); + EclipseGrid grid(10,10,10); BOOST_CHECK_THROW(Schedule schedule(ParseContext() , grid , deck ), std::exception); } @@ -670,7 +665,7 @@ BOOST_AUTO_TEST_CASE(CreateScheduleDeckWithCOMPLUMPwithC2_ThrowsExcpetion) { DeckPtr deck = parser.parseString(input, ParseContext()); - std::shared_ptr grid = std::make_shared( 10 , 10 , 10 ); + EclipseGrid grid(10,10,10); BOOST_CHECK_THROW(Schedule schedule(ParseContext() , grid , deck ), std::exception); } @@ -704,11 +699,10 @@ BOOST_AUTO_TEST_CASE(CreateScheduleDeckWithCOMPLUMPwithDefaultValuesInWELOPEN) { " 10 NOV 2008 / \n" "/\n"; - std::shared_ptr grid = std::make_shared( 10 , 10 , 10 ); + EclipseGrid grid(10,10,10); DeckPtr deck = parser.parseString(input, ParseContext()); Schedule schedule(ParseContext() , grid , deck ); - WellPtr well; - well = schedule.getWell("OP_1"); + auto* well = schedule.getWell("OP_1"); size_t currentStep = 3; BOOST_CHECK_EQUAL(WellCommon::StatusEnum::OPEN, well->getStatus(currentStep)); } @@ -751,21 +745,19 @@ BOOST_AUTO_TEST_CASE(CreateScheduleDeckWithWRFT) { "/\n"; - std::shared_ptr grid = std::make_shared( 10 , 10 , 10 ); + EclipseGrid grid(10,10,10); ParseContext parseContext; DeckPtr deck = parser.parseString(input, parseContext); Schedule schedule(parseContext , grid , deck ); { - WellPtr well; - well = schedule.getWell("OP_1"); + auto* well = schedule.getWell("OP_1"); BOOST_CHECK_EQUAL(well->getRFTActive(2),true); BOOST_CHECK_EQUAL(2 , well->firstRFTOutput( )); } { - WellPtr well; - well = schedule.getWell("OP_2"); + auto* well = schedule.getWell("OP_2"); BOOST_CHECK_EQUAL(well->getRFTActive(3),true); BOOST_CHECK_EQUAL(3 , well->firstRFTOutput( )); } @@ -819,11 +811,10 @@ BOOST_AUTO_TEST_CASE(CreateScheduleDeckWithWRFTPLT) { " 10 NOV 2008 / \n" "/\n"; ParseContext parseContext; - std::shared_ptr grid = std::make_shared( 10 , 10 , 10 ); + EclipseGrid grid(10,10,10); DeckPtr deck = parser.parseString(input, parseContext); Schedule schedule(parseContext , grid , deck ); - WellPtr well; - well = schedule.getWell("OP_1"); + auto* well = schedule.getWell("OP_1"); size_t currentStep = 3; BOOST_CHECK_EQUAL(well->getRFTActive(currentStep),false); @@ -868,9 +859,9 @@ BOOST_AUTO_TEST_CASE(createDeckWithWeltArg) { ParseContext parseContext; DeckPtr deck = parser.parseString(input, parseContext); - std::shared_ptr grid = std::make_shared( 10 , 10 , 10 ); + EclipseGrid grid(10,10,10); Schedule schedule(parseContext , grid , deck ); - WellPtr well = schedule.getWell("OP_1"); + auto* well = schedule.getWell("OP_1"); size_t currentStep = 1; WellProductionProperties wpp = well->getProductionProperties(currentStep); @@ -906,7 +897,7 @@ BOOST_AUTO_TEST_CASE(createDeckWithWeltArgException) { ParseContext parseContext; DeckPtr deck = parser.parseString(input, parseContext); - std::shared_ptr grid = std::make_shared( 10 , 10 , 10 ); + EclipseGrid grid(10,10,10); BOOST_CHECK_THROW(Schedule (parseContext , grid , deck ), std::invalid_argument); } @@ -922,7 +913,7 @@ BOOST_AUTO_TEST_CASE(createDeckWithWeltArgException2) { ParseContext parseContext; DeckPtr deck = parser.parseString(input, parseContext); - std::shared_ptr grid = std::make_shared( 10 , 10 , 10 ); + EclipseGrid grid(10,10,10); BOOST_CHECK_THROW(Schedule (parseContext , grid , deck ), std::out_of_range); } @@ -978,9 +969,9 @@ BOOST_AUTO_TEST_CASE(createDeckWithWPIMULT) { ParseContext parseContext; DeckPtr deck = parser.parseString(input, parseContext); - std::shared_ptr grid = std::make_shared(10, 10, 10); + EclipseGrid grid(10,10,10); Schedule schedule(parseContext , grid, deck ); - WellPtr well = schedule.getWell("OP_1"); + auto* well = schedule.getWell("OP_1"); size_t currentStep = 2; CompletionSetConstPtr currentCompletionSet = well->getCompletions(currentStep); @@ -1026,14 +1017,14 @@ BOOST_AUTO_TEST_CASE(createDeckWithDRSDT) { ParseContext parseContext; DeckPtr deck = parser.parseString(input, parseContext); - std::shared_ptr grid = std::make_shared(10, 10, 10); + EclipseGrid grid(10,10,10); Schedule schedule(parseContext , grid, deck ); size_t currentStep = 1; BOOST_CHECK_EQUAL(schedule.hasOilVaporizationProperties(), true); - OilVaporizationPropertiesConstPtr ovap = schedule.getOilVaporizationProperties(currentStep); + const auto& ovap = schedule.getOilVaporizationProperties(currentStep); - BOOST_CHECK_EQUAL(true, ovap->getOption()); - BOOST_CHECK_EQUAL(ovap->getType(), Opm::OilVaporizationEnum::DRSDT); + BOOST_CHECK_EQUAL(true, ovap.getOption()); + BOOST_CHECK_EQUAL(ovap.getType(), Opm::OilVaporizationEnum::DRSDT); } @@ -1058,14 +1049,14 @@ BOOST_AUTO_TEST_CASE(createDeckWithDRSDTthenDRVDT) { ParseContext parseContext; DeckPtr deck = parser.parseString(input, parseContext); - std::shared_ptr grid = std::make_shared(10, 10, 10); + EclipseGrid grid(10,10,10); Schedule schedule(parseContext , grid, deck ); size_t currentStep = 2; BOOST_CHECK_EQUAL(schedule.hasOilVaporizationProperties(), true); - OilVaporizationPropertiesConstPtr ovap = schedule.getOilVaporizationProperties(currentStep); - double value = ovap->getMaxDRVDT(); + const OilVaporizationProperties& ovap = schedule.getOilVaporizationProperties(currentStep); + double value = ovap.getMaxDRVDT(); BOOST_CHECK_EQUAL(1.1574074074074074e-06, value); - BOOST_CHECK_EQUAL(ovap->getType(), Opm::OilVaporizationEnum::DRVDT); + BOOST_CHECK_EQUAL(ovap.getType(), Opm::OilVaporizationEnum::DRVDT); } BOOST_AUTO_TEST_CASE(createDeckWithVAPPARS) { @@ -1083,15 +1074,15 @@ BOOST_AUTO_TEST_CASE(createDeckWithVAPPARS) { ParseContext parseContext; DeckPtr deck = parser.parseString(input, parseContext); - std::shared_ptr grid = std::make_shared(10, 10, 10); + EclipseGrid grid(10,10,10); Schedule schedule(parseContext , grid, deck ); size_t currentStep = 1; BOOST_CHECK_EQUAL(schedule.hasOilVaporizationProperties(), true); - OilVaporizationPropertiesConstPtr ovap = schedule.getOilVaporizationProperties(currentStep); - BOOST_CHECK_EQUAL(ovap->getType(), Opm::OilVaporizationEnum::VAPPARS); - double vap1 = ovap->getVap1(); + const OilVaporizationProperties& ovap = schedule.getOilVaporizationProperties(currentStep); + BOOST_CHECK_EQUAL(ovap.getType(), Opm::OilVaporizationEnum::VAPPARS); + double vap1 = ovap.getVap1(); BOOST_CHECK_EQUAL(2, vap1); - double vap2 = ovap->getVap2(); + double vap2 = ovap.getVap2(); BOOST_CHECK_EQUAL(0.100, vap2); } @@ -1110,7 +1101,7 @@ BOOST_AUTO_TEST_CASE(createDeckWithOutOilVaporizationProperties) { ParseContext parseContext; DeckPtr deck = parser.parseString(input, parseContext); - std::shared_ptr grid = std::make_shared(10, 10, 10); + EclipseGrid grid(10,10,10); Schedule schedule(parseContext , grid, deck ); BOOST_CHECK_EQUAL(schedule.hasOilVaporizationProperties(), false); @@ -1169,16 +1160,16 @@ BOOST_AUTO_TEST_CASE(changeBhpLimitInHistoryModeWithWeltarg) { ParseContext parseContext; DeckPtr deck = parser.parseString(input, parseContext); - std::shared_ptr grid = std::make_shared(10, 10, 10); + EclipseGrid grid(10,10,10); Schedule schedule(parseContext , grid, deck ); - WellPtr well_p = schedule.getWell("P"); + auto* well_p = schedule.getWell("P"); BOOST_CHECK_EQUAL(well_p->getProductionProperties(0).BHPLimit, 0); //start BOOST_CHECK_EQUAL(well_p->getProductionProperties(1).BHPLimit, 50 * 1e5); // 1 // The BHP limit should not be effected by WCONHIST BOOST_CHECK_EQUAL(well_p->getProductionProperties(2).BHPLimit, 50 * 1e5); // 2 - WellPtr well_i = schedule.getWell("I"); + auto* well_i = schedule.getWell("I"); BOOST_CHECK_EQUAL(well_i->getInjectionProperties(0).BHPLimit, 0); //start BOOST_CHECK_EQUAL(well_i->getInjectionProperties(1).BHPLimit, 600 * 1e5); // 1 @@ -1193,4 +1184,134 @@ BOOST_AUTO_TEST_CASE(changeBhpLimitInHistoryModeWithWeltarg) { BOOST_CHECK_EQUAL( false , well_i->getInjectionProperties(4).hasInjectionControl(Opm::WellInjector::BHP) ); } +BOOST_AUTO_TEST_CASE(changeModeWithWHISTCTL) { + Opm::Parser parser; + std::string input = + "START -- 0 \n" + "19 JUN 2007 / \n" + "SCHEDULE\n" + "DATES -- 1\n" + " 10 OKT 2008 / \n" + "/\n" + "WELSPECS\n" + " 'P1' 'OP' 9 9 1* 'OIL' 1* 1* 1* 1* 1* 1* 1* / \n" + " 'P2' 'OP' 5 5 1* 'OIL' 1* 1* 1* 1* 1* 1* 1* / \n" + " 'I' 'OP' 1 1 1* 'WATER' 1* 1* 1* 1* 1* 1* 1* / \n" + "/\n" + "COMPDAT\n" + " 'P1' 9 9 1 1 'OPEN' 1* 32.948 0.311 3047.839 1* 1* 'X' 22.100 / \n" + " 'P1' 9 9 2 2 'OPEN' 1* 46.825 0.311 4332.346 1* 1* 'X' 22.123 / \n" + " 'P2' 5 5 1 1 'OPEN' 1* 32.948 0.311 3047.839 1* 1* 'X' 22.100 / \n" + " 'P2' 5 5 2 2 'OPEN' 1* 46.825 0.311 4332.346 1* 1* 'X' 22.123 / \n" + " 'I' 1 1 1 1 'OPEN' 1* 32.948 0.311 3047.839 1* 1* 'X' 22.100 / \n" + "/\n" + "WCONHIST\n" + " 'P1' 'OPEN' 'ORAT' 5*/ \n" + " 'P2' 'OPEN' 'ORAT' 5*/ \n" + "/\n" + "DATES -- 2\n" + " 15 OKT 2008 / \n" + "/\n" + "WHISTCTL\n" + " RESV / \n" + "WCONHIST\n" + " 'P1' 'OPEN' 'ORAT' 5*/ \n" + " 'P2' 'OPEN' 'ORAT' 5*/ \n" + "/\n" + "DATES -- 3\n" + " 18 OKT 2008 / \n" + "/\n" + "WCONHIST\n" + " 'P1' 'OPEN' 'ORAT' 5*/ \n" + " 'P2' 'OPEN' 'ORAT' 5*/ \n" + "/\n" + "DATES -- 4\n" + " 20 OKT 2008 / \n" + "/\n" + "WHISTCTL\n" + " LRAT / \n" + "WCONHIST\n" + " 'P1' 'OPEN' 'ORAT' 5*/ \n" + " 'P2' 'OPEN' 'ORAT' 5*/ \n" + "/\n" + "DATES -- 5\n" + " 25 OKT 2008 / \n" + "/\n" + "WHISTCTL\n" + " NONE / \n" + "WCONHIST\n" + " 'P1' 'OPEN' 'ORAT' 5*/ \n" + " 'P2' 'OPEN' 'ORAT' 5*/ \n" + "/\n" + ; + + ParseContext parseContext; + DeckPtr deck = parser.parseString(input, parseContext); + EclipseGrid grid(10,10,10); + Schedule schedule(parseContext , grid, deck ); + auto* well_p1 = schedule.getWell("P1"); + auto* well_p2 = schedule.getWell("P2"); + + //Start + BOOST_CHECK_EQUAL(well_p1->getProductionProperties(0).controlMode, Opm::WellProducer::CMODE_UNDEFINED); + BOOST_CHECK_EQUAL(well_p2->getProductionProperties(0).controlMode, Opm::WellProducer::CMODE_UNDEFINED); + + //10 OKT 2008 + BOOST_CHECK_EQUAL(well_p1->getProductionProperties(1).controlMode, Opm::WellProducer::ORAT); + BOOST_CHECK_EQUAL(well_p2->getProductionProperties(1).controlMode, Opm::WellProducer::ORAT); + + //15 OKT 2008 + BOOST_CHECK_EQUAL(well_p1->getProductionProperties(2).controlMode, Opm::WellProducer::RESV); + BOOST_CHECK_EQUAL(well_p2->getProductionProperties(2).controlMode, Opm::WellProducer::RESV); + + //18 OKT 2008 + BOOST_CHECK_EQUAL(well_p1->getProductionProperties(3).controlMode, Opm::WellProducer::RESV); + BOOST_CHECK_EQUAL(well_p2->getProductionProperties(3).controlMode, Opm::WellProducer::RESV); + + // 20 OKT 2008 + BOOST_CHECK_EQUAL(well_p1->getProductionProperties(4).controlMode, Opm::WellProducer::LRAT); + BOOST_CHECK_EQUAL(well_p2->getProductionProperties(4).controlMode, Opm::WellProducer::LRAT); + + // 25 OKT 2008 + BOOST_CHECK_EQUAL(well_p1->getProductionProperties(5).controlMode, Opm::WellProducer::ORAT); + BOOST_CHECK_EQUAL(well_p2->getProductionProperties(5).controlMode, Opm::WellProducer::ORAT); +} + +BOOST_AUTO_TEST_CASE(unsupportedOptionWHISTCTL) { + Opm::Parser parser; + std::string input = + "START -- 0 \n" + "19 JUN 2007 / \n" + "SCHEDULE\n" + "DATES -- 1\n" + " 10 OKT 2008 / \n" + "/\n" + "WELSPECS\n" + " 'P1' 'OP' 9 9 1* 'OIL' 1* 1* 1* 1* 1* 1* 1* / \n" + " 'P2' 'OP' 5 5 1* 'OIL' 1* 1* 1* 1* 1* 1* 1* / \n" + " 'I' 'OP' 1 1 1* 'WATER' 1* 1* 1* 1* 1* 1* 1* / \n" + "/\n" + "COMPDAT\n" + " 'P1' 9 9 1 1 'OPEN' 1* 32.948 0.311 3047.839 1* 1* 'X' 22.100 / \n" + " 'P1' 9 9 2 2 'OPEN' 1* 46.825 0.311 4332.346 1* 1* 'X' 22.123 / \n" + " 'P2' 5 5 1 1 'OPEN' 1* 32.948 0.311 3047.839 1* 1* 'X' 22.100 / \n" + " 'P2' 5 5 2 2 'OPEN' 1* 46.825 0.311 4332.346 1* 1* 'X' 22.123 / \n" + " 'I' 1 1 1 1 'OPEN' 1* 32.948 0.311 3047.839 1* 1* 'X' 22.100 / \n" + "/\n" + "WCONHIST\n" + " 'P1' 'OPEN' 'ORAT' 5*/ \n" + " 'P2' 'OPEN' 'ORAT' 5*/ \n" + "/\n" + "DATES -- 2\n" + " 15 OKT 2008 / \n" + "/\n" + "WHISTCTL\n" + " * YES / \n" + ; + + ParseContext parseContext; + DeckPtr deck = parser.parseString(input, parseContext); + EclipseGrid grid(10,10,10); + BOOST_CHECK_THROW(Schedule schedule(parseContext , grid, deck ), std::invalid_argument); +} diff --git a/ThirdParty/custom-opm-parser/opm-parser/opm/parser/eclipse/EclipseState/Schedule/tests/TimeMapTest.cpp b/ThirdParty/custom-opm-parser/opm-parser/opm/parser/eclipse/EclipseState/Schedule/tests/TimeMapTest.cpp index b9f7c32933..49a7427a6c 100644 --- a/ThirdParty/custom-opm-parser/opm-parser/opm/parser/eclipse/EclipseState/Schedule/tests/TimeMapTest.cpp +++ b/ThirdParty/custom-opm-parser/opm-parser/opm/parser/eclipse/EclipseState/Schedule/tests/TimeMapTest.cpp @@ -23,10 +23,8 @@ #define BOOST_TEST_MODULE TimeMapTests -#include #include #include -#include @@ -308,10 +306,6 @@ BOOST_AUTO_TEST_CASE(initTimestepsYearsAndMonths) { Opm::DeckPtr deck = parser->parseString(deckData, Opm::ParseContext()); const Opm::TimeMap tmap(deck); - Opm::TimeMap* writableTimemap = const_cast(&tmap); - writableTimemap->initFirstTimestepsMonths(); - writableTimemap->initFirstTimestepsYears(); - /*deckData timesteps: 0 21 may 1981 START 1 22 may 1981 diff --git a/ThirdParty/custom-opm-parser/opm-parser/opm/parser/eclipse/EclipseState/Schedule/tests/TuningTests.cpp b/ThirdParty/custom-opm-parser/opm-parser/opm/parser/eclipse/EclipseState/Schedule/tests/TuningTests.cpp index 2360d4dde8..fcce67fb39 100644 --- a/ThirdParty/custom-opm-parser/opm-parser/opm/parser/eclipse/EclipseState/Schedule/tests/TuningTests.cpp +++ b/ThirdParty/custom-opm-parser/opm-parser/opm/parser/eclipse/EclipseState/Schedule/tests/TuningTests.cpp @@ -70,9 +70,9 @@ static DeckPtr createDeck(const std::string& input) { BOOST_AUTO_TEST_CASE(TuningTest) { DeckPtr deck = createDeck(deckStr); - std::shared_ptr grid = std::make_shared( 10 , 10 , 10 ); + EclipseGrid grid(10,10,10); Schedule schedule( ParseContext() , grid , deck ); - TuningPtr tuning = schedule.getTuning(); + auto tuning = schedule.getTuning(); const double diff = 1.0e-14; @@ -80,112 +80,112 @@ BOOST_AUTO_TEST_CASE(TuningTest) { /*** TIMESTEP 4***/ /********* Record 1 ***********/ size_t timestep = 4; - double TSINIT_default = tuning->getTSINIT(timestep); + double TSINIT_default = tuning.getTSINIT(timestep); BOOST_CHECK_CLOSE(TSINIT_default, 1 * Metric::Time, diff); - double TSMAXZ_default = tuning->getTSMAXZ(timestep); + double TSMAXZ_default = tuning.getTSMAXZ(timestep); BOOST_CHECK_CLOSE(TSMAXZ_default, 365 * Metric::Time, diff); - double TSMINZ_default = tuning->getTSMINZ(timestep); + double TSMINZ_default = tuning.getTSMINZ(timestep); BOOST_CHECK_CLOSE(TSMINZ_default, 0.1 * Metric::Time, diff); - double TSMCHP_default = tuning->getTSMCHP(timestep); + double TSMCHP_default = tuning.getTSMCHP(timestep); BOOST_CHECK_CLOSE(TSMCHP_default, 0.15 * Metric::Time, diff); - double TSFMAX_default = tuning->getTSFMAX(timestep); + double TSFMAX_default = tuning.getTSFMAX(timestep); BOOST_CHECK_CLOSE(TSFMAX_default, 3.0, diff); - double TSFMIN_default = tuning->getTSFMIN(timestep); + double TSFMIN_default = tuning.getTSFMIN(timestep); BOOST_CHECK_CLOSE(TSFMIN_default, 0.3, diff); - double TSFCNV_default = tuning->getTSFCNV(timestep); + double TSFCNV_default = tuning.getTSFCNV(timestep); BOOST_CHECK_CLOSE(TSFCNV_default, 0.1, diff); - double TFDIFF_default = tuning->getTFDIFF(timestep); + double TFDIFF_default = tuning.getTFDIFF(timestep); BOOST_CHECK_CLOSE(TFDIFF_default, 1.25, diff); - double THRUPT_default = tuning->getTHRUPT(timestep); + double THRUPT_default = tuning.getTHRUPT(timestep); BOOST_CHECK_CLOSE(THRUPT_default, 1E20, diff); - bool TMAXWC_has_value = tuning->getTMAXWChasValue(timestep); - double TMAXWC_default = tuning->getTMAXWC(timestep); + bool TMAXWC_has_value = tuning.getTMAXWChasValue(timestep); + double TMAXWC_default = tuning.getTMAXWC(timestep); BOOST_CHECK_EQUAL(false, TMAXWC_has_value); BOOST_CHECK_CLOSE(TMAXWC_default, 0.0 * Metric::Time, diff); /********* Record 2 ************/ - double TRGTTE_default = tuning->getTRGTTE(timestep); + double TRGTTE_default = tuning.getTRGTTE(timestep); BOOST_CHECK_CLOSE(TRGTTE_default, 0.1, diff); - double TRGCNV_default = tuning->getTRGCNV(timestep); + double TRGCNV_default = tuning.getTRGCNV(timestep); BOOST_CHECK_CLOSE(TRGCNV_default, 0.001, diff); - double TRGMBE_default = tuning->getTRGMBE(timestep); + double TRGMBE_default = tuning.getTRGMBE(timestep); BOOST_CHECK_CLOSE(TRGMBE_default, 1.0E-7, diff); - double TRGLCV_default = tuning->getTRGLCV(timestep); + double TRGLCV_default = tuning.getTRGLCV(timestep); BOOST_CHECK_CLOSE(TRGLCV_default, 0.0001, diff); - double XXXTTE_default = tuning->getXXXTTE(timestep); + double XXXTTE_default = tuning.getXXXTTE(timestep); BOOST_CHECK_CLOSE(XXXTTE_default, 10.0, diff); - double XXXCNV_default = tuning->getXXXCNV(timestep); + double XXXCNV_default = tuning.getXXXCNV(timestep); BOOST_CHECK_CLOSE(XXXCNV_default, 0.01, diff); - double XXXMBE_default = tuning->getXXXMBE(timestep); + double XXXMBE_default = tuning.getXXXMBE(timestep); BOOST_CHECK_CLOSE(XXXMBE_default, 1.0E-6, diff); - double XXXLCV_default = tuning->getXXXLCV(timestep); + double XXXLCV_default = tuning.getXXXLCV(timestep); BOOST_CHECK_CLOSE(XXXLCV_default, 0.001, diff); - double XXXWFL_default = tuning->getXXXWFL(timestep); + double XXXWFL_default = tuning.getXXXWFL(timestep); BOOST_CHECK_CLOSE(XXXWFL_default, 0.001, diff); - double TRGFIP_default = tuning->getTRGFIP(timestep); + double TRGFIP_default = tuning.getTRGFIP(timestep); BOOST_CHECK_CLOSE(TRGFIP_default, 0.025, diff); - bool TRGSFT_has_value = tuning->getTRGSFThasValue(timestep); - double TRGSFT_default = tuning->getTRGSFT(timestep); + bool TRGSFT_has_value = tuning.getTRGSFThasValue(timestep); + double TRGSFT_default = tuning.getTRGSFT(timestep); BOOST_CHECK_EQUAL(false, TRGSFT_has_value); BOOST_CHECK_CLOSE(TRGSFT_default, 0.0, diff); - double THIONX_default = tuning->getTHIONX(timestep); + double THIONX_default = tuning.getTHIONX(timestep); BOOST_CHECK_CLOSE(THIONX_default, 0.01, diff); - int TRWGHT_default = tuning->getTRWGHT(timestep); + int TRWGHT_default = tuning.getTRWGHT(timestep); BOOST_CHECK_EQUAL(TRWGHT_default, 1); /********* Record 3 ************/ - int NEWTMX_default = tuning->getNEWTMX(timestep); + int NEWTMX_default = tuning.getNEWTMX(timestep); BOOST_CHECK_EQUAL(NEWTMX_default, 12); - int NEWTMN_default = tuning->getNEWTMN(timestep); + int NEWTMN_default = tuning.getNEWTMN(timestep); BOOST_CHECK_EQUAL(NEWTMN_default, 1); - int LITMAX_default = tuning->getLITMAX(timestep); + int LITMAX_default = tuning.getLITMAX(timestep); BOOST_CHECK_EQUAL(LITMAX_default, 25); - int LITMIN_default = tuning->getLITMIN(timestep); + int LITMIN_default = tuning.getLITMIN(timestep); BOOST_CHECK_EQUAL(LITMIN_default, 1); - int MXWSIT_default = tuning->getMXWSIT(timestep); + int MXWSIT_default = tuning.getMXWSIT(timestep); BOOST_CHECK_EQUAL(MXWSIT_default, 8); - int MXWPIT_default = tuning->getMXWPIT(timestep); + int MXWPIT_default = tuning.getMXWPIT(timestep); BOOST_CHECK_EQUAL(MXWPIT_default, 8); - double DDPLIM_default = tuning->getDDPLIM(timestep); + double DDPLIM_default = tuning.getDDPLIM(timestep); BOOST_CHECK_CLOSE(DDPLIM_default, 1.0E6 * Metric::Pressure, diff); - double DDSLIM_default = tuning->getDDSLIM(timestep); + double DDSLIM_default = tuning.getDDSLIM(timestep); BOOST_CHECK_CLOSE(DDSLIM_default, 1.0E6, diff); - double TRGDPR_default = tuning->getTRGDPR(timestep); + double TRGDPR_default = tuning.getTRGDPR(timestep); BOOST_CHECK_CLOSE(TRGDPR_default, 1.0E6 * Metric::Pressure, diff); - bool XXXDPR_has_value = tuning->getXXXDPRhasValue(timestep); - double XXXDPR_default = tuning->getXXXDPR(timestep); + bool XXXDPR_has_value = tuning.getXXXDPRhasValue(timestep); + double XXXDPR_default = tuning.getXXXDPR(timestep); BOOST_CHECK_EQUAL(false, XXXDPR_has_value); BOOST_CHECK_CLOSE(XXXDPR_default, 0.0, diff); @@ -195,110 +195,110 @@ BOOST_AUTO_TEST_CASE(TuningTest) { /*** TIMESTEP 5***/ /********* Record 1 ***********/ timestep = 5; - double TSINIT = tuning->getTSINIT(timestep); + double TSINIT = tuning.getTSINIT(timestep); BOOST_CHECK_CLOSE(TSINIT, 2 * Metric::Time, diff); - double TSMAXZ = tuning->getTSMAXZ(timestep); + double TSMAXZ = tuning.getTSMAXZ(timestep); BOOST_CHECK_CLOSE(TSMAXZ, 300 * Metric::Time, diff); - double TSMINZ = tuning->getTSMINZ(timestep); + double TSMINZ = tuning.getTSMINZ(timestep); BOOST_CHECK_CLOSE(TSMINZ, 0.3 * Metric::Time, diff); - double TSMCHP = tuning->getTSMCHP(timestep); + double TSMCHP = tuning.getTSMCHP(timestep); BOOST_CHECK_CLOSE(TSMCHP, 0.30 * Metric::Time, diff); - double TSFMAX = tuning->getTSFMAX(timestep); + double TSFMAX = tuning.getTSFMAX(timestep); BOOST_CHECK_CLOSE(TSFMAX, 6.0, 1.0); - double TSFMIN = tuning->getTSFMIN(timestep); + double TSFMIN = tuning.getTSFMIN(timestep); BOOST_CHECK_CLOSE(TSFMIN, 0.6, 1.0); - double TSFCNV = tuning->getTSFCNV(timestep); + double TSFCNV = tuning.getTSFCNV(timestep); BOOST_CHECK_CLOSE(TSFCNV, 0.2, diff); - double TFDIFF = tuning->getTFDIFF(timestep); + double TFDIFF = tuning.getTFDIFF(timestep); BOOST_CHECK_CLOSE(TFDIFF, 2.25, diff); - double THRUPT = tuning->getTHRUPT(timestep); + double THRUPT = tuning.getTHRUPT(timestep); BOOST_CHECK_CLOSE(THRUPT, 2E20, diff); - TMAXWC_has_value = tuning->getTMAXWChasValue(timestep); - TMAXWC_default = tuning->getTMAXWC(timestep); + TMAXWC_has_value = tuning.getTMAXWChasValue(timestep); + TMAXWC_default = tuning.getTMAXWC(timestep); BOOST_CHECK_EQUAL(false, TMAXWC_has_value); BOOST_CHECK_CLOSE(TMAXWC_default, 0.0 * Metric::Time, diff); /********* Record 2 ***********/ - double TRGTTE = tuning->getTRGTTE(timestep); + double TRGTTE = tuning.getTRGTTE(timestep); BOOST_CHECK_CLOSE(TRGTTE, 0.2, diff); - double TRGCNV = tuning->getTRGCNV(timestep); + double TRGCNV = tuning.getTRGCNV(timestep); BOOST_CHECK_CLOSE(TRGCNV, 0.002, diff); - double TRGMBE = tuning->getTRGMBE(timestep); + double TRGMBE = tuning.getTRGMBE(timestep); BOOST_CHECK_CLOSE(TRGMBE, 2.0E-7, diff); - double TRGLCV = tuning->getTRGLCV(timestep); + double TRGLCV = tuning.getTRGLCV(timestep); BOOST_CHECK_CLOSE(TRGLCV, 0.0002, diff); - double XXXTTE = tuning->getXXXTTE(timestep); + double XXXTTE = tuning.getXXXTTE(timestep); BOOST_CHECK_CLOSE(XXXTTE, 11.0, diff); - double XXXCNV = tuning->getXXXCNV(timestep); + double XXXCNV = tuning.getXXXCNV(timestep); BOOST_CHECK_CLOSE(XXXCNV, 0.02, diff); - double XXXMBE = tuning->getXXXMBE(timestep); + double XXXMBE = tuning.getXXXMBE(timestep); BOOST_CHECK_CLOSE(XXXMBE, 2.0E-6, diff); - double XXXLCV = tuning->getXXXLCV(timestep); + double XXXLCV = tuning.getXXXLCV(timestep); BOOST_CHECK_CLOSE(XXXLCV, 0.002, diff); - double XXXWFL = tuning->getXXXWFL(timestep); + double XXXWFL = tuning.getXXXWFL(timestep); BOOST_CHECK_CLOSE(XXXWFL, 0.002, diff); - double TRGFIP = tuning->getTRGFIP(timestep); + double TRGFIP = tuning.getTRGFIP(timestep); BOOST_CHECK_CLOSE(TRGFIP, 0.035, diff); - TRGSFT_has_value = tuning->getTRGSFThasValue(timestep); - double TRGSFT = tuning->getTRGSFT(timestep); + TRGSFT_has_value = tuning.getTRGSFThasValue(timestep); + double TRGSFT = tuning.getTRGSFT(timestep); BOOST_CHECK_EQUAL(true, TRGSFT_has_value); BOOST_CHECK_CLOSE(TRGSFT, 66.0, diff); - double THIONX = tuning->getTHIONX(timestep); + double THIONX = tuning.getTHIONX(timestep); BOOST_CHECK_CLOSE(THIONX, 0.02, diff); - int TRWGHT = tuning->getTRWGHT(timestep); + int TRWGHT = tuning.getTRWGHT(timestep); BOOST_CHECK_EQUAL(TRWGHT, 2); /********* Record 3 ***********/ - int NEWTMX = tuning->getNEWTMX(timestep); + int NEWTMX = tuning.getNEWTMX(timestep); BOOST_CHECK_EQUAL(NEWTMX, 13); - int NEWTMN = tuning->getNEWTMN(timestep); + int NEWTMN = tuning.getNEWTMN(timestep); BOOST_CHECK_EQUAL(NEWTMN, 2); - int LITMAX = tuning->getLITMAX(timestep); + int LITMAX = tuning.getLITMAX(timestep); BOOST_CHECK_EQUAL(LITMAX, 26); - int LITMIN = tuning->getLITMIN(timestep); + int LITMIN = tuning.getLITMIN(timestep); BOOST_CHECK_EQUAL(LITMIN, 2); - int MXWSIT = tuning->getMXWSIT(timestep); + int MXWSIT = tuning.getMXWSIT(timestep); BOOST_CHECK_EQUAL(MXWSIT, 9); - int MXWPIT = tuning->getMXWPIT(timestep); + int MXWPIT = tuning.getMXWPIT(timestep); BOOST_CHECK_EQUAL(MXWPIT, 9); - double DDPLIM= tuning->getDDPLIM(timestep); + double DDPLIM= tuning.getDDPLIM(timestep); BOOST_CHECK_CLOSE(DDPLIM, 4.0E6 * Metric::Pressure, diff); - double DDSLIM= tuning->getDDSLIM(timestep); + double DDSLIM= tuning.getDDSLIM(timestep); BOOST_CHECK_CLOSE(DDSLIM, 4.0E6, diff); - double TRGDPR = tuning->getTRGDPR(timestep); + double TRGDPR = tuning.getTRGDPR(timestep); BOOST_CHECK_CLOSE(TRGDPR, 4.0E6 * Metric::Pressure, diff); - XXXDPR_has_value = tuning->getXXXDPRhasValue(timestep); - double XXXDPR = tuning->getXXXDPR(timestep); + XXXDPR_has_value = tuning.getXXXDPRhasValue(timestep); + double XXXDPR = tuning.getXXXDPR(timestep); BOOST_CHECK_EQUAL(true, XXXDPR_has_value); BOOST_CHECK_CLOSE(XXXDPR, 1.0 * Metric::Pressure, diff); @@ -308,8 +308,8 @@ BOOST_AUTO_TEST_CASE(TuningTest) { /*** TIMESTEP 10 ***/ /********* Record 1 ***********/ timestep = 10; - TMAXWC_has_value = tuning->getTMAXWChasValue(timestep); - TMAXWC_default = tuning->getTMAXWC(timestep); + TMAXWC_has_value = tuning.getTMAXWChasValue(timestep); + TMAXWC_default = tuning.getTMAXWC(timestep); BOOST_CHECK_EQUAL(true, TMAXWC_has_value); BOOST_CHECK_CLOSE(TMAXWC_default, 10.0 * Metric::Time, diff); @@ -321,9 +321,9 @@ BOOST_AUTO_TEST_CASE(TuningTest) { BOOST_AUTO_TEST_CASE(TuningInitTest) { DeckPtr deck = createDeck(deckStr); - std::shared_ptr grid = std::make_shared( 10 , 10 , 10 ); + EclipseGrid grid(10,10,10); Schedule schedule(ParseContext() , grid , deck); - TuningPtr tuning = schedule.getTuning(); + auto tuning = schedule.getTuning(); const double diff = 1.0e-14; @@ -332,26 +332,26 @@ BOOST_AUTO_TEST_CASE(TuningInitTest) { /********* Record 1 ***********/ size_t timestep = 0; double value = 100.00; - tuning->setTuningInitialValue("TSINIT",value, false); - double TSINIT_default = tuning->getTSINIT(timestep); + tuning.setTuningInitialValue("TSINIT",value, false); + double TSINIT_default = tuning.getTSINIT(timestep); BOOST_CHECK_CLOSE(TSINIT_default, 100.00, diff); timestep = 10; - bool TMAXWC_has_value = tuning->getTMAXWChasValue(timestep); - double TMAXWC_default = tuning->getTMAXWC(timestep); + bool TMAXWC_has_value = tuning.getTMAXWChasValue(timestep); + double TMAXWC_default = tuning.getTMAXWC(timestep); BOOST_CHECK_EQUAL(true, TMAXWC_has_value); BOOST_CHECK_CLOSE(TMAXWC_default, 10.0 * Metric::Time, diff); - + } BOOST_AUTO_TEST_CASE(TuningResetTest) { DeckPtr deck = createDeck(deckStr); - std::shared_ptr grid = std::make_shared( 10 , 10 , 10 ); + EclipseGrid grid(10,10,10); Schedule schedule(ParseContext() , grid , deck); - TuningPtr tuning = schedule.getTuning(); + auto tuning = schedule.getTuning(); const double diff = 1.0e-14; @@ -360,12 +360,12 @@ BOOST_AUTO_TEST_CASE(TuningResetTest) { /********* Record 1 ***********/ size_t timestep = 0; double value = 666.00; - tuning->setTuningInitialValue("TSINIT",value, true); - double TSINIT_default = tuning->getTSINIT(timestep); + tuning.setTuningInitialValue("TSINIT",value, true); + double TSINIT_default = tuning.getTSINIT(timestep); BOOST_CHECK_CLOSE(TSINIT_default, 666.00, diff); timestep = 10; - TSINIT_default = tuning->getTSINIT(timestep); + TSINIT_default = tuning.getTSINIT(timestep); BOOST_CHECK_CLOSE(TSINIT_default, 666.00, diff); diff --git a/ThirdParty/custom-opm-parser/opm-parser/opm/parser/eclipse/EclipseState/Schedule/tests/WellSetTests.cpp b/ThirdParty/custom-opm-parser/opm-parser/opm/parser/eclipse/EclipseState/Schedule/tests/WellSetTests.cpp index 27e3fca13d..44bc08e1ca 100644 --- a/ThirdParty/custom-opm-parser/opm-parser/opm/parser/eclipse/EclipseState/Schedule/tests/WellSetTests.cpp +++ b/ThirdParty/custom-opm-parser/opm-parser/opm/parser/eclipse/EclipseState/Schedule/tests/WellSetTests.cpp @@ -25,11 +25,11 @@ #include #include -#include #include #include #include +using namespace Opm; static Opm::TimeMapPtr createXDaysTimeMap(size_t numDays) { boost::gregorian::date startDate( 2010 , boost::gregorian::Jan , 1); @@ -54,25 +54,24 @@ BOOST_AUTO_TEST_CASE(AddAndDeleteWell) { Opm::WellSet wellSet; Opm::TimeMapPtr timeMap = createXDaysTimeMap(10); - std::shared_ptr grid = std::make_shared(10,10,10); - Opm::WellPtr well(new Opm::Well("WELL1" , grid , 0, 0, Opm::Value("REF_DEPTH") , Opm::Phase::OIL, timeMap , 0)); - Opm::WellPtr well2(new Opm::Well("WELL2" , grid , 0, 0, Opm::Value("REF_DEPTH") , Opm::Phase::OIL, timeMap , 0)); + auto well = std::make_shared< Well >("WELL1", 0, 0, Opm::Value("REF_DEPTH"), Opm::Phase::OIL, timeMap , 0); + auto well2 = std::make_shared< Well >("WELL2", 0, 0, Opm::Value("REF_DEPTH"), Opm::Phase::OIL, timeMap , 0); - wellSet.addWell( well ); + wellSet.addWell( well.get() ); BOOST_CHECK_EQUAL(true , wellSet.hasWell("WELL1")); BOOST_CHECK_EQUAL(1U , wellSet.size()); - BOOST_CHECK_EQUAL( well , wellSet.getWell("WELL1")); + BOOST_CHECK_EQUAL( well.get(), wellSet.getWell("WELL1")); - wellSet.addWell( well2 ); + wellSet.addWell( well2.get() ); BOOST_CHECK_EQUAL(true , wellSet.hasWell("WELL2")); BOOST_CHECK_EQUAL(2U , wellSet.size()); - BOOST_CHECK_EQUAL( well2 , wellSet.getWell("WELL2")); + BOOST_CHECK_EQUAL( well2.get(), wellSet.getWell("WELL2")); wellSet.delWell("WELL1"); BOOST_CHECK_EQUAL(false , wellSet.hasWell("WELL1")); BOOST_CHECK_EQUAL(1U , wellSet.size()); - BOOST_CHECK_EQUAL( well2 , wellSet.getWell("WELL2")); + BOOST_CHECK_EQUAL( well2.get(), wellSet.getWell("WELL2")); } @@ -80,24 +79,22 @@ BOOST_AUTO_TEST_CASE(AddWellSameName) { Opm::WellSet wellSet; Opm::TimeMapPtr timeMap = createXDaysTimeMap(10); - std::shared_ptr grid = std::make_shared(10,10,10); - Opm::WellPtr well1(new Opm::Well("WELL" , grid , 0, 0,Opm::Value("REF_DEPTH"), Opm::Phase::OIL, timeMap , 0)); - Opm::WellPtr well2(new Opm::Well("WELL" , grid , 0, 0, Opm::Value("REF_DEPTH"), Opm::Phase::OIL, timeMap , 0)); + auto well1 = std::make_shared< Well >("WELL", 0, 0, Opm::Value("REF_DEPTH"), Opm::Phase::OIL, timeMap, 0); + auto well2 = std::make_shared< Well >("WELL", 0, 0, Opm::Value("REF_DEPTH"), Opm::Phase::OIL, timeMap, 0); - wellSet.addWell( well1 ); + wellSet.addWell( well1.get() ); BOOST_CHECK_EQUAL(true , wellSet.hasWell("WELL")); - BOOST_CHECK_NO_THROW( wellSet.addWell( well1 )); - BOOST_CHECK_THROW( wellSet.addWell( well2 ) , std::invalid_argument ); + BOOST_CHECK_NO_THROW( wellSet.addWell( well1.get() )); + BOOST_CHECK_THROW( wellSet.addWell( well2.get() ) , std::invalid_argument ); } BOOST_AUTO_TEST_CASE(Iterator) { Opm::WellSet wellSet; Opm::TimeMapPtr timeMap = createXDaysTimeMap(10); - std::shared_ptr grid = std::make_shared(10,10,10); - Opm::WellPtr well1(new Opm::Well("WELL" , grid , 0, 0,Opm::Value("REF_DEPTH"), Opm::Phase::OIL, timeMap , 0)); - Opm::WellPtr well2(new Opm::Well("WELL" , grid , 0, 0, Opm::Value("REF_DEPTH"), Opm::Phase::OIL, timeMap , 0)); + auto well1 = std::make_shared< Well >("WELL", 0, 0, Opm::Value("REF_DEPTH"), Opm::Phase::OIL, timeMap , 0); + auto well2 = std::make_shared< Well >("WELL", 0, 0, Opm::Value("REF_DEPTH"), Opm::Phase::OIL, timeMap , 0); for( const auto& well : wellSet ) BOOST_CHECK( well.second->isProducer( 0 ) ); diff --git a/ThirdParty/custom-opm-parser/opm-parser/opm/parser/eclipse/EclipseState/Schedule/tests/WellSolventTests.cpp b/ThirdParty/custom-opm-parser/opm-parser/opm/parser/eclipse/EclipseState/Schedule/tests/WellSolventTests.cpp index 69b72da3a5..6973e0d79e 100644 --- a/ThirdParty/custom-opm-parser/opm-parser/opm/parser/eclipse/EclipseState/Schedule/tests/WellSolventTests.cpp +++ b/ThirdParty/custom-opm-parser/opm-parser/opm/parser/eclipse/EclipseState/Schedule/tests/WellSolventTests.cpp @@ -19,10 +19,8 @@ #define BOOST_TEST_MODULE WellSolventTests -#include #include #include -#include #include #include @@ -141,14 +139,14 @@ static DeckPtr createDeckWithWaterInjector() { } BOOST_AUTO_TEST_CASE(TestNoSolvent) { DeckPtr deck = createDeckWithOutSolvent(); - std::shared_ptr grid = std::make_shared(10,10,10); + EclipseGrid grid(10,10,10); Schedule schedule(ParseContext() , grid , deck ); BOOST_CHECK(!deck->hasKeyword("WSOLVENT")); } BOOST_AUTO_TEST_CASE(TestGasInjector) { DeckPtr deck = createDeckWithGasInjector(); - std::shared_ptr grid = std::make_shared(10,10,10); + EclipseGrid grid(10,10,10); Schedule schedule(ParseContext(), grid , deck ); BOOST_CHECK(deck->hasKeyword("WSOLVENT")); @@ -156,14 +154,14 @@ BOOST_AUTO_TEST_CASE(TestGasInjector) { BOOST_AUTO_TEST_CASE(TestDynamicWSOLVENT) { DeckPtr deck = createDeckWithDynamicWSOLVENT(); - std::shared_ptr grid = std::make_shared(10,10,10); + EclipseGrid grid(10,10,10); Schedule schedule(ParseContext() , grid , deck ); BOOST_CHECK(deck->hasKeyword("WSOLVENT")); const auto& keyword = deck->getKeyword("WSOLVENT"); BOOST_CHECK_EQUAL(keyword.size(),1); const auto& record = keyword.getRecord(0); const std::string& wellNamesPattern = record.getItem("WELL").getTrimmedString(0); - std::vector wells_solvent = schedule.getWells(wellNamesPattern); + auto wells_solvent = schedule.getWellsMatching(wellNamesPattern); BOOST_CHECK_EQUAL(wellNamesPattern, "W_1"); BOOST_CHECK_EQUAL(wells_solvent[0]->getSolventFraction(0),0); //default 0 BOOST_CHECK_EQUAL(wells_solvent[0]->getSolventFraction(1),1); @@ -173,12 +171,12 @@ BOOST_AUTO_TEST_CASE(TestDynamicWSOLVENT) { BOOST_AUTO_TEST_CASE(TestOilInjector) { DeckPtr deck = createDeckWithOilInjector(); - std::shared_ptr grid = std::make_shared(10,10,10); + EclipseGrid grid(10,10,10); BOOST_CHECK_THROW (Schedule(ParseContext() , grid , deck ), std::invalid_argument); } BOOST_AUTO_TEST_CASE(TestWaterInjector) { DeckPtr deck = createDeckWithWaterInjector(); - std::shared_ptr grid = std::make_shared(10,10,10); + EclipseGrid grid(10,10,10); BOOST_CHECK_THROW (Schedule(ParseContext(), grid , deck ), std::invalid_argument); } diff --git a/ThirdParty/custom-opm-parser/opm-parser/opm/parser/eclipse/EclipseState/Schedule/tests/WellTests.cpp b/ThirdParty/custom-opm-parser/opm-parser/opm/parser/eclipse/EclipseState/Schedule/tests/WellTests.cpp index b30c859165..c47d463b6d 100644 --- a/ThirdParty/custom-opm-parser/opm-parser/opm/parser/eclipse/EclipseState/Schedule/tests/WellTests.cpp +++ b/ThirdParty/custom-opm-parser/opm-parser/opm/parser/eclipse/EclipseState/Schedule/tests/WellTests.cpp @@ -51,16 +51,14 @@ static Opm::TimeMapPtr createXDaysTimeMap(size_t numDays) { BOOST_AUTO_TEST_CASE(CreateWell_CorrectNameAndDefaultValues) { Opm::TimeMapPtr timeMap = createXDaysTimeMap(10); - std::shared_ptr grid = std::make_shared(10,10,10); - Opm::Well well("WELL1" , grid , 0, 0, Opm::Value("REF_DEPTH"), Opm::Phase::OIL, timeMap , 0); + Opm::Well well("WELL1" , 0, 0, Opm::Value("REF_DEPTH"), Opm::Phase::OIL, timeMap , 0); BOOST_CHECK_EQUAL( "WELL1" , well.name() ); BOOST_CHECK_EQUAL(0.0 , well.getProductionPropertiesCopy(5).OilRate); } BOOST_AUTO_TEST_CASE(CreateWell_GetProductionPropertiesShouldReturnSameObject) { Opm::TimeMapPtr timeMap = createXDaysTimeMap(10); - std::shared_ptr grid = std::make_shared(10,10,10); - Opm::Well well("WELL1" , grid , 0, 0, Opm::Value("REF_DEPTH"), Opm::Phase::OIL, timeMap , 0); + Opm::Well well("WELL1" , 0, 0, Opm::Value("REF_DEPTH"), Opm::Phase::OIL, timeMap , 0); BOOST_CHECK_EQUAL(&(well.getProductionProperties(5)), &(well.getProductionProperties(5))); BOOST_CHECK_EQUAL(&(well.getProductionProperties(8)), &(well.getProductionProperties(8))); @@ -69,8 +67,7 @@ BOOST_AUTO_TEST_CASE(CreateWell_GetProductionPropertiesShouldReturnSameObject) { BOOST_AUTO_TEST_CASE(CreateWell_GetInjectionPropertiesShouldReturnSameObject) { Opm::TimeMapPtr timeMap = createXDaysTimeMap(10); - std::shared_ptr grid = std::make_shared(10,10,10); - Opm::Well well("WELL1" , grid , 0, 0, Opm::Value("REF_DEPTH"), Opm::Phase::WATER, timeMap , 0); + Opm::Well well("WELL1" , 0, 0, Opm::Value("REF_DEPTH"), Opm::Phase::WATER, timeMap , 0); BOOST_CHECK_EQUAL(&(well.getInjectionProperties(5)), &(well.getInjectionProperties(5))); BOOST_CHECK_EQUAL(&(well.getInjectionProperties(8)), &(well.getInjectionProperties(8))); @@ -79,8 +76,7 @@ BOOST_AUTO_TEST_CASE(CreateWell_GetInjectionPropertiesShouldReturnSameObject) { BOOST_AUTO_TEST_CASE(CreateWellCreateTimeStepOK) { Opm::TimeMapPtr timeMap = createXDaysTimeMap(10); - std::shared_ptr grid = std::make_shared(10,10,10); - Opm::Well well("WELL1" , grid , 0, 0, Opm::Value("REF_DEPTH"), Opm::Phase::OIL, timeMap , 5); + Opm::Well well("WELL1" , 0, 0, Opm::Value("REF_DEPTH"), Opm::Phase::OIL, timeMap , 5); BOOST_CHECK_EQUAL( false , well.hasBeenDefined(0) ); BOOST_CHECK_EQUAL( false , well.hasBeenDefined(4) ); BOOST_CHECK_EQUAL( true , well.hasBeenDefined(5) ); @@ -91,8 +87,7 @@ BOOST_AUTO_TEST_CASE(CreateWellCreateTimeStepOK) { BOOST_AUTO_TEST_CASE(setWellProductionProperties_PropertiesSetCorrect) { Opm::TimeMapPtr timeMap = createXDaysTimeMap(10); - std::shared_ptr grid = std::make_shared(10,10,10); - Opm::Well well("WELL1" , grid , 0, 0, Opm::Value("REF_DEPTH"), Opm::Phase::OIL, timeMap , 0); + Opm::Well well("WELL1" , 0, 0, Opm::Value("REF_DEPTH"), Opm::Phase::OIL, timeMap , 0); BOOST_CHECK_EQUAL(0.0 , well.getProductionPropertiesCopy( 5 ).OilRate); Opm::WellProductionProperties props; @@ -116,8 +111,7 @@ BOOST_AUTO_TEST_CASE(setWellProductionProperties_PropertiesSetCorrect) { BOOST_AUTO_TEST_CASE(setOilRate_RateSetCorrect) { Opm::TimeMapPtr timeMap = createXDaysTimeMap(10); - std::shared_ptr grid = std::make_shared(10,10,10); - Opm::Well well("WELL1" , grid , 0, 0, Opm::Value("REF_DEPTH"), Opm::Phase::OIL, timeMap , 0); + Opm::Well well("WELL1" , 0, 0, Opm::Value("REF_DEPTH"), Opm::Phase::OIL, timeMap , 0); BOOST_CHECK_EQUAL(0.0 , well.getProductionPropertiesCopy(5).OilRate); Opm::WellProductionProperties props; @@ -129,8 +123,7 @@ BOOST_AUTO_TEST_CASE(setOilRate_RateSetCorrect) { BOOST_AUTO_TEST_CASE(seLiquidRate_RateSetCorrect) { Opm::TimeMapPtr timeMap = createXDaysTimeMap(10); - std::shared_ptr grid = std::make_shared(10,10,10); - Opm::Well well("WELL1" , grid , 0, 0, Opm::Value("REF_DEPTH"), Opm::Phase::OIL, timeMap , 0); + Opm::Well well("WELL1" , 0, 0, Opm::Value("REF_DEPTH"), Opm::Phase::OIL, timeMap , 0); BOOST_CHECK_EQUAL(0.0 , well.getProductionPropertiesCopy(5).LiquidRate); Opm::WellProductionProperties props; @@ -143,8 +136,7 @@ BOOST_AUTO_TEST_CASE(seLiquidRate_RateSetCorrect) { BOOST_AUTO_TEST_CASE(setPredictionModeProduction_ModeSetCorrect) { Opm::TimeMapPtr timeMap = createXDaysTimeMap(10); - std::shared_ptr grid = std::make_shared(10,10,10); - Opm::Well well("WELL1" , grid , 0, 0, Opm::Value("REF_DEPTH"), Opm::Phase::OIL, timeMap , 0); + Opm::Well well("WELL1" , 0, 0, Opm::Value("REF_DEPTH"), Opm::Phase::OIL, timeMap , 0); BOOST_CHECK_EQUAL( true, well.getProductionPropertiesCopy(5).predictionMode); Opm::WellProductionProperties props; @@ -158,8 +150,7 @@ BOOST_AUTO_TEST_CASE(setPredictionModeProduction_ModeSetCorrect) { BOOST_AUTO_TEST_CASE(setpredictionModeInjection_ModeSetCorrect) { Opm::TimeMapPtr timeMap = createXDaysTimeMap(10); - std::shared_ptr grid = std::make_shared(10,10,10); - Opm::Well well("WELL1" , grid , 0, 0, Opm::Value("REF_DEPTH"), Opm::Phase::WATER, timeMap , 0); + Opm::Well well("WELL1" , 0, 0, Opm::Value("REF_DEPTH"), Opm::Phase::WATER, timeMap , 0); BOOST_CHECK_EQUAL( true, well.getInjectionPropertiesCopy(5).predictionMode); Opm::WellInjectionProperties props; @@ -197,9 +188,9 @@ BOOST_AUTO_TEST_CASE(WellCOMPDATtestTRACK) { Opm::ParseContext parseContext; Opm::DeckPtr deck = parser.parseString(input, parseContext); - std::shared_ptr grid = std::make_shared( 10 , 10 , 10 ); + Opm::EclipseGrid grid(10,10,10); Opm::Schedule schedule(Opm::ParseContext() , grid , deck ); - Opm::WellPtr op_1 = schedule.getWell("OP_1"); + auto* op_1 = schedule.getWell("OP_1"); size_t timestep = 2; Opm::CompletionSetConstPtr completions = op_1->getCompletions( timestep ); @@ -238,9 +229,9 @@ BOOST_AUTO_TEST_CASE(WellCOMPDATtestDefaultTRACK) { Opm::ParseContext parseContext; Opm::DeckPtr deck = parser.parseString(input, parseContext); - std::shared_ptr grid = std::make_shared( 10 , 10 , 10 ); + Opm::EclipseGrid grid(10,10,10); Opm::Schedule schedule(Opm::ParseContext() , grid , deck ); - Opm::WellPtr op_1 = schedule.getWell("OP_1"); + auto* op_1 = schedule.getWell("OP_1"); size_t timestep = 2; Opm::CompletionSetConstPtr completions = op_1->getCompletions( timestep ); @@ -281,9 +272,9 @@ BOOST_AUTO_TEST_CASE(WellCOMPDATtestINPUT) { Opm::ParseContext parseContext; Opm::DeckPtr deck = parser.parseString(input, parseContext); - std::shared_ptr grid = std::make_shared( 10 , 10 , 10 ); + Opm::EclipseGrid grid(10,10,10); Opm::Schedule schedule(Opm::ParseContext() , grid , deck ); - Opm::WellPtr op_1 = schedule.getWell("OP_1"); + auto* op_1 = schedule.getWell("OP_1"); size_t timestep = 2; Opm::CompletionSetConstPtr completions = op_1->getCompletions( timestep ); @@ -323,8 +314,7 @@ BOOST_AUTO_TEST_CASE(WellCOMPDATtestINPUT) { BOOST_AUTO_TEST_CASE(NewWellZeroCompletions) { Opm::TimeMapPtr timeMap = createXDaysTimeMap(10); - std::shared_ptr grid = std::make_shared(10,10,10); - Opm::Well well("WELL1" , grid , 0, 0, Opm::Value("REF_DEPTH"), Opm::Phase::OIL, timeMap , 0); + Opm::Well well("WELL1" , 0, 0, Opm::Value("REF_DEPTH"), Opm::Phase::OIL, timeMap , 0); Opm::CompletionSetConstPtr completions = well.getCompletions( 0 ); BOOST_CHECK_EQUAL( 0U , completions->size()); } @@ -332,19 +322,18 @@ BOOST_AUTO_TEST_CASE(NewWellZeroCompletions) { BOOST_AUTO_TEST_CASE(UpdateCompletions) { Opm::TimeMapPtr timeMap = createXDaysTimeMap(10); - Opm::EclipseGridConstPtr grid = std::make_shared(20, 20, 20); - Opm::Well well("WELL1" , grid , 0, 0, Opm::Value("REF_DEPTH"), Opm::Phase::OIL, timeMap , 0); + Opm::Well well("WELL1" , 0, 0, Opm::Value("REF_DEPTH"), Opm::Phase::OIL, timeMap , 0); Opm::CompletionSetConstPtr completions = well.getCompletions( 0 ); BOOST_CHECK_EQUAL( 0U , completions->size()); std::vector newCompletions; std::vector newCompletions2; - Opm::CompletionPtr comp1(new Opm::Completion( 10 , 10 , 10 , Opm::WellCompletion::AUTO , Opm::Value("ConnectionTransmissibilityFactor",99.88), Opm::Value("D",22.33), Opm::Value("SKIN",33.22))); - Opm::CompletionPtr comp2(new Opm::Completion( 10 , 10 , 11 , Opm::WellCompletion::SHUT , Opm::Value("ConnectionTransmissibilityFactor",99.88), Opm::Value("D",22.33), Opm::Value("SKIN",33.22))); - Opm::CompletionPtr comp3(new Opm::Completion( 10 , 10 , 12 , Opm::WellCompletion::OPEN , Opm::Value("ConnectionTransmissibilityFactor",99.88), Opm::Value("D",22.33), Opm::Value("SKIN",33.22))); - Opm::CompletionPtr comp4(new Opm::Completion( 10 , 10 , 12 , Opm::WellCompletion::SHUT , Opm::Value("ConnectionTransmissibilityFactor",99.88), Opm::Value("D",22.33), Opm::Value("SKIN",33.22))); - Opm::CompletionPtr comp5(new Opm::Completion( 10 , 10 , 13 , Opm::WellCompletion::OPEN , Opm::Value("ConnectionTransmissibilityFactor",99.88), Opm::Value("D",22.33), Opm::Value("SKIN",33.22))); + Opm::CompletionPtr comp1(new Opm::Completion( 10 , 10 , 10 , 10,Opm::WellCompletion::AUTO , Opm::Value("ConnectionTransmissibilityFactor",99.88), Opm::Value("D",22.33), Opm::Value("SKIN",33.22))); + Opm::CompletionPtr comp2(new Opm::Completion( 10 , 10 , 11 , 11,Opm::WellCompletion::SHUT , Opm::Value("ConnectionTransmissibilityFactor",99.88), Opm::Value("D",22.33), Opm::Value("SKIN",33.22))); + Opm::CompletionPtr comp3(new Opm::Completion( 10 , 10 , 12 , 12,Opm::WellCompletion::OPEN , Opm::Value("ConnectionTransmissibilityFactor",99.88), Opm::Value("D",22.33), Opm::Value("SKIN",33.22))); + Opm::CompletionPtr comp4(new Opm::Completion( 10 , 10 , 12 , 12,Opm::WellCompletion::SHUT , Opm::Value("ConnectionTransmissibilityFactor",99.88), Opm::Value("D",22.33), Opm::Value("SKIN",33.22))); + Opm::CompletionPtr comp5(new Opm::Completion( 10 , 10 , 13 , 13,Opm::WellCompletion::OPEN , Opm::Value("ConnectionTransmissibilityFactor",99.88), Opm::Value("D",22.33), Opm::Value("SKIN",33.22))); //std::vector newCompletions2{ comp4 , comp5}; Newer c++ @@ -375,6 +364,7 @@ Opm::CompletionPtr completion(const size_t i, const size_t j, const size_t k); Opm::CompletionPtr completion(const size_t i, const size_t j, const size_t k) { return std::make_shared(i, j, k, + k*1.0, Opm::WellCompletion::AUTO, Opm::Value("ConnectionTransmissibilityFactor",99.88), Opm::Value("D",22.33), @@ -386,11 +376,9 @@ Opm::CompletionPtr completion(const size_t i, const size_t j, const size_t k) BOOST_AUTO_TEST_CASE(CompletionOrder) { Opm::TimeMapPtr timeMap = createXDaysTimeMap(10); - Opm::EclipseGridConstPtr grid = std::make_shared(10, 10, 10); - { // Vertical well. - Opm::Well well("WELL1" , grid , 5, 5, Opm::Value("REF_DEPTH"), Opm::Phase::OIL, timeMap , 0); + Opm::Well well("WELL1" , 5, 5, Opm::Value("REF_DEPTH"), Opm::Phase::OIL, timeMap , 0); auto c1 = completion(5, 5, 8); auto c2 = completion(5, 5, 9); auto c3 = completion(5, 5, 1); @@ -406,7 +394,7 @@ BOOST_AUTO_TEST_CASE(CompletionOrder) { { // Horizontal well. - Opm::Well well("WELL1" , grid , 5, 5, Opm::Value("REF_DEPTH"), Opm::Phase::OIL, timeMap , 0); + Opm::Well well("WELL1" , 5, 5, Opm::Value("REF_DEPTH"), Opm::Phase::OIL, timeMap , 0); auto c1 = completion(6, 5, 8); auto c2 = completion(5, 6, 7); auto c3 = completion(7, 5, 8); @@ -445,8 +433,7 @@ BOOST_AUTO_TEST_CASE(CompletionOrder) { BOOST_AUTO_TEST_CASE(setGasRate_RateSetCorrect) { Opm::TimeMapPtr timeMap = createXDaysTimeMap(10); - std::shared_ptr grid = std::make_shared(10,10,10); - Opm::Well well("WELL1" , grid , 0, 0, Opm::Value("REF_DEPTH"), Opm::Phase::GAS, timeMap , 0); + Opm::Well well("WELL1" , 0, 0, Opm::Value("REF_DEPTH"), Opm::Phase::GAS, timeMap , 0); BOOST_CHECK_EQUAL(0.0 , well.getProductionPropertiesCopy(5).GasRate); Opm::WellProductionProperties properties; @@ -460,8 +447,7 @@ BOOST_AUTO_TEST_CASE(setGasRate_RateSetCorrect) { BOOST_AUTO_TEST_CASE(setWaterRate_RateSetCorrect) { Opm::TimeMapPtr timeMap = createXDaysTimeMap(10); - std::shared_ptr grid = std::make_shared(10,10,10); - Opm::Well well("WELL1" , grid , 0, 0, Opm::Value("REF_DEPTH"), Opm::Phase::WATER, timeMap , 0); + Opm::Well well("WELL1" , 0, 0, Opm::Value("REF_DEPTH"), Opm::Phase::WATER, timeMap , 0); BOOST_CHECK_EQUAL(0.0 , well.getProductionPropertiesCopy(5).WaterRate); Opm::WellProductionProperties properties; @@ -474,8 +460,7 @@ BOOST_AUTO_TEST_CASE(setWaterRate_RateSetCorrect) { BOOST_AUTO_TEST_CASE(setSurfaceInjectionRate_RateSetCorrect) { Opm::TimeMapPtr timeMap = createXDaysTimeMap(10); - std::shared_ptr grid = std::make_shared(10,10,10); - Opm::Well well("WELL1" , grid , 0, 0, Opm::Value("REF_DEPTH"), Opm::Phase::WATER, timeMap , 0); + Opm::Well well("WELL1" , 0, 0, Opm::Value("REF_DEPTH"), Opm::Phase::WATER, timeMap , 0); BOOST_CHECK_EQUAL(0.0 , well.getInjectionPropertiesCopy(5).surfaceInjectionRate); Opm::WellInjectionProperties props(well.getInjectionPropertiesCopy(5)); @@ -488,8 +473,7 @@ BOOST_AUTO_TEST_CASE(setSurfaceInjectionRate_RateSetCorrect) { BOOST_AUTO_TEST_CASE(setReservoirInjectionRate_RateSetCorrect) { Opm::TimeMapPtr timeMap = createXDaysTimeMap(10); - std::shared_ptr grid = std::make_shared(10,10,10); - Opm::Well well("WELL1" , grid , 0, 0, Opm::Value("REF_DEPTH"), Opm::Phase::WATER, timeMap , 0); + Opm::Well well("WELL1" , 0, 0, Opm::Value("REF_DEPTH"), Opm::Phase::WATER, timeMap , 0); BOOST_CHECK_EQUAL(0.0 , well.getInjectionPropertiesCopy(5).reservoirInjectionRate); Opm::WellInjectionProperties properties(well.getInjectionPropertiesCopy(5)); @@ -504,8 +488,7 @@ BOOST_AUTO_TEST_CASE(isProducerCorrectlySet) { // HACK: This test checks correctly setting of isProducer/isInjector. This property depends on which of // WellProductionProperties/WellInjectionProperties is set last, independent of actual values. Opm::TimeMapPtr timeMap = createXDaysTimeMap(10); - std::shared_ptr grid = std::make_shared(10,10,10); - Opm::Well well("WELL1" , grid , 0, 0, Opm::Value("REF_DEPTH"), Opm::Phase::OIL, timeMap ,0); + Opm::Well well("WELL1" , 0, 0, Opm::Value("REF_DEPTH"), Opm::Phase::OIL, timeMap ,0); /* 1: Well is created as producer */ BOOST_CHECK_EQUAL( false , well.isInjector(0)); @@ -561,8 +544,7 @@ BOOST_AUTO_TEST_CASE(isProducerCorrectlySet) { BOOST_AUTO_TEST_CASE(GroupnameCorretlySet) { Opm::TimeMapPtr timeMap = createXDaysTimeMap(10); - std::shared_ptr grid = std::make_shared(10,10,10); - Opm::Well well("WELL1" , grid , 0, 0, Opm::Value("REF_DEPTH"), Opm::Phase::WATER, timeMap ,0); + Opm::Well well("WELL1" , 0, 0, Opm::Value("REF_DEPTH"), Opm::Phase::WATER, timeMap ,0); BOOST_CHECK_EQUAL("" , well.getGroupName(2)); @@ -576,8 +558,7 @@ BOOST_AUTO_TEST_CASE(GroupnameCorretlySet) { BOOST_AUTO_TEST_CASE(addWELSPECS_setData_dataSet) { Opm::TimeMapPtr timeMap = createXDaysTimeMap(10); - std::shared_ptr grid = std::make_shared(10,10,10); - Opm::Well well("WELL1", grid , 23, 42, Opm::Value("REF_DEPTH" , 2334.32) , Opm::Phase::WATER, timeMap, 3); + Opm::Well well("WELL1", 23, 42, Opm::Value("REF_DEPTH" , 2334.32) , Opm::Phase::WATER, timeMap, 3); BOOST_CHECK(!well.hasBeenDefined(2)); BOOST_CHECK(well.hasBeenDefined(3)); @@ -590,8 +571,7 @@ BOOST_AUTO_TEST_CASE(addWELSPECS_setData_dataSet) { BOOST_AUTO_TEST_CASE(XHPLimitDefault) { Opm::TimeMapPtr timeMap = createXDaysTimeMap(10); - std::shared_ptr grid = std::make_shared(10,10,10); - Opm::Well well("WELL1", grid , 1, 2, Opm::Value("REF_DEPTH" , 2334.32), Opm::Phase::WATER, timeMap, 0); + Opm::Well well("WELL1", 1, 2, Opm::Value("REF_DEPTH" , 2334.32), Opm::Phase::WATER, timeMap, 0); Opm::WellProductionProperties productionProps(well.getProductionPropertiesCopy(1)); @@ -612,8 +592,7 @@ BOOST_AUTO_TEST_CASE(XHPLimitDefault) { BOOST_AUTO_TEST_CASE(InjectorType) { Opm::TimeMapPtr timeMap = createXDaysTimeMap(10); - std::shared_ptr grid = std::make_shared(10,10,10); - Opm::Well well("WELL1", grid , 1, 2, Opm::Value("REF_DEPTH" , 2334.32), Opm::Phase::WATER, timeMap, 0); + Opm::Well well("WELL1", 1, 2, Opm::Value("REF_DEPTH" , 2334.32), Opm::Phase::WATER, timeMap, 0); Opm::WellInjectionProperties injectionProps(well.getInjectionPropertiesCopy(1)); injectionProps.injectorType = Opm::WellInjector::WATER; @@ -628,12 +607,11 @@ BOOST_AUTO_TEST_CASE(InjectorType) { BOOST_AUTO_TEST_CASE(WellStatus) { Opm::TimeMapPtr timeMap = createXDaysTimeMap(10); - Opm::EclipseGridConstPtr grid = std::make_shared(20, 20, 20); - Opm::Well well("WELL1" , grid , 0, 0, Opm::Value("REF_DEPTH"), Opm::Phase::OIL, timeMap , 0); + Opm::Well well("WELL1" , 0, 0, Opm::Value("REF_DEPTH"), Opm::Phase::OIL, timeMap , 0); std::vector newCompletions; - Opm::CompletionPtr comp1(new Opm::Completion( 10 , 10 , 10 , Opm::WellCompletion::OPEN , Opm::Value("ConnectionTransmissibilityFactor",99.88), Opm::Value("D",22.33), Opm::Value("SKIN",33.22))); + Opm::CompletionPtr comp1(new Opm::Completion( 10 , 10 , 10 , 0.25 , Opm::WellCompletion::OPEN , Opm::Value("ConnectionTransmissibilityFactor",99.88), Opm::Value("D",22.33), Opm::Value("SKIN",33.22))); newCompletions.push_back( comp1 ); @@ -651,8 +629,7 @@ BOOST_AUTO_TEST_CASE(WellStatus) { BOOST_AUTO_TEST_CASE(WellHaveProductionControlLimit) { Opm::TimeMapPtr timeMap = createXDaysTimeMap(20); - std::shared_ptr grid = std::make_shared(10,10,10); - Opm::Well well("WELL1", grid , 1, 2, Opm::Value("REF_DEPTH" , 2334.32), Opm::Phase::OIL, timeMap, 0); + Opm::Well well("WELL1", 1, 2, Opm::Value("REF_DEPTH" , 2334.32), Opm::Phase::OIL, timeMap, 0); BOOST_CHECK( !well.getProductionPropertiesCopy(1).hasProductionControl( Opm::WellProducer::ORAT )); @@ -702,8 +679,7 @@ BOOST_AUTO_TEST_CASE(WellHaveProductionControlLimit) { BOOST_AUTO_TEST_CASE(WellHaveInjectionControlLimit) { Opm::TimeMapPtr timeMap = createXDaysTimeMap(20); - std::shared_ptr grid = std::make_shared(10,10,10); - Opm::Well well("WELL1", grid , 1, 2, Opm::Value("REF_DEPTH" , 2334.32), Opm::Phase::WATER, timeMap, 0); + Opm::Well well("WELL1", 1, 2, Opm::Value("REF_DEPTH" , 2334.32), Opm::Phase::WATER, timeMap, 0); BOOST_CHECK( !well.getInjectionPropertiesCopy(1).hasInjectionControl( Opm::WellInjector::RATE )); BOOST_CHECK( !well.getInjectionPropertiesCopy(1).hasInjectionControl( Opm::WellInjector::RESV )); @@ -747,8 +723,7 @@ BOOST_AUTO_TEST_CASE(WellHaveInjectionControlLimit) { BOOST_AUTO_TEST_CASE(WellSetAvailableForGroupControl_ControlSet) { Opm::TimeMapPtr timeMap = createXDaysTimeMap(20); - std::shared_ptr grid = std::make_shared(10,10,10); - Opm::Well well("WELL1", grid , 1, 2, Opm::Value("REF_DEPTH" , 2334.32), Opm::Phase::WATER, timeMap, 0); + Opm::Well well("WELL1", 1, 2, Opm::Value("REF_DEPTH" , 2334.32), Opm::Phase::WATER, timeMap, 0); BOOST_CHECK(well.isAvailableForGroupControl(10)); well.setAvailableForGroupControl(12, false); @@ -759,8 +734,7 @@ BOOST_AUTO_TEST_CASE(WellSetAvailableForGroupControl_ControlSet) { BOOST_AUTO_TEST_CASE(WellSetGuideRate_GuideRateSet) { Opm::TimeMapPtr timeMap = createXDaysTimeMap(20); - std::shared_ptr grid = std::make_shared(10,10,10); - Opm::Well well("WELL1", grid , 1, 2, Opm::Value("REF_DEPTH" , 2334.32), Opm::Phase::WATER, timeMap, 0); + Opm::Well well("WELL1", 1, 2, Opm::Value("REF_DEPTH" , 2334.32), Opm::Phase::WATER, timeMap, 0); BOOST_CHECK_LT(well.getGuideRate(0), 0); well.setGuideRate(1, 32.2); @@ -770,8 +744,7 @@ BOOST_AUTO_TEST_CASE(WellSetGuideRate_GuideRateSet) { BOOST_AUTO_TEST_CASE(WellGuideRatePhase_GuideRatePhaseSet) { Opm::TimeMapPtr timeMap = createXDaysTimeMap(20); - std::shared_ptr grid = std::make_shared(10,10,10); - Opm::Well well("WELL1", grid , 1, 2, Opm::Value("REF_DEPTH" , 2334.32), Opm::Phase::WATER, timeMap, 0); + Opm::Well well("WELL1", 1, 2, Opm::Value("REF_DEPTH" , 2334.32), Opm::Phase::WATER, timeMap, 0); BOOST_CHECK_EQUAL(Opm::GuideRate::UNDEFINED, well.getGuideRatePhase(0)); well.setGuideRatePhase(3, Opm::GuideRate::RAT); BOOST_CHECK_EQUAL(Opm::GuideRate::UNDEFINED, well.getGuideRatePhase(2)); @@ -781,8 +754,7 @@ BOOST_AUTO_TEST_CASE(WellGuideRatePhase_GuideRatePhaseSet) { BOOST_AUTO_TEST_CASE(WellSetScalingFactor_ScalingFactorSetSet) { Opm::TimeMapPtr timeMap = createXDaysTimeMap(20); - std::shared_ptr grid = std::make_shared(10,10,10); - Opm::Well well("WELL1", grid , 1, 2, Opm::Value("REF_DEPTH" , 2334.32), Opm::Phase::WATER, timeMap, 0); + Opm::Well well("WELL1", 1, 2, Opm::Value("REF_DEPTH" , 2334.32), Opm::Phase::WATER, timeMap, 0); BOOST_CHECK_EQUAL(1.0, well.getGuideRateScalingFactor(0)); well.setGuideRateScalingFactor(4, 0.6); BOOST_CHECK_EQUAL(1.0, well.getGuideRateScalingFactor(3)); diff --git a/ThirdParty/custom-opm-parser/opm-parser/opm/parser/eclipse/EclipseState/SimulationConfig/tests/SimulationConfigTest.cpp b/ThirdParty/custom-opm-parser/opm-parser/opm/parser/eclipse/EclipseState/SimulationConfig/tests/SimulationConfigTest.cpp index 9ad4434ed3..1de6f83051 100644 --- a/ThirdParty/custom-opm-parser/opm-parser/opm/parser/eclipse/EclipseState/SimulationConfig/tests/SimulationConfigTest.cpp +++ b/ThirdParty/custom-opm-parser/opm-parser/opm/parser/eclipse/EclipseState/SimulationConfig/tests/SimulationConfigTest.cpp @@ -21,10 +21,8 @@ #define BOOST_TEST_MODULE SimulationConfigTests -#include #include #include -#include #include #include diff --git a/ThirdParty/custom-opm-parser/opm-parser/opm/parser/eclipse/EclipseState/SimulationConfig/tests/ThresholdPressureTest.cpp b/ThirdParty/custom-opm-parser/opm-parser/opm/parser/eclipse/EclipseState/SimulationConfig/tests/ThresholdPressureTest.cpp index 488e2e15f0..b46fa9e472 100644 --- a/ThirdParty/custom-opm-parser/opm-parser/opm/parser/eclipse/EclipseState/SimulationConfig/tests/ThresholdPressureTest.cpp +++ b/ThirdParty/custom-opm-parser/opm-parser/opm/parser/eclipse/EclipseState/SimulationConfig/tests/ThresholdPressureTest.cpp @@ -23,10 +23,8 @@ #define BOOST_TEST_MODULE ThresholdPressureTests -#include #include #include -#include #include #include diff --git a/ThirdParty/custom-opm-parser/opm-parser/opm/parser/eclipse/EclipseState/SummaryConfig/SummaryConfig.cpp b/ThirdParty/custom-opm-parser/opm-parser/opm/parser/eclipse/EclipseState/SummaryConfig/SummaryConfig.cpp index 3384c46732..9d8e466618 100644 --- a/ThirdParty/custom-opm-parser/opm-parser/opm/parser/eclipse/EclipseState/SummaryConfig/SummaryConfig.cpp +++ b/ThirdParty/custom-opm-parser/opm-parser/opm/parser/eclipse/EclipseState/SummaryConfig/SummaryConfig.cpp @@ -18,6 +18,8 @@ */ +#include +#include #include #include #include @@ -33,242 +35,317 @@ #include #include #include -#include #include +#include #include #include -#include namespace Opm { - static std::string wellName( const std::shared_ptr< const Well >& well ) { - return well->name(); +namespace { + /* A dummy deck that holds a Summary section with the keyword list that ALL + * expands to, plus the SUMMARY header + */ + const Deck ALL_keywords = { + "SUMMARY", + "FAQR", "FAQRG", "FAQT", "FAQTG", "FGIP", "FGIPG", "FGIPL", + "FGIR", "FGIT", "FGOR", "FGPR", "FGPT", "FOIP", "FOIPG", + "FOIPL", "FOIR", "FOIT", "FOPR", "FOPT", "FPR", "FVIR", + "FVIT", "FVPR", "FVPT", "FWCT", "FWGR", "FWIP", "FWIR", + "FWIT", "FWPR", "FWPT", + "GGIR", "GGIT", "GGOR", "GGPR", "GGPT", "GOIR", "GOIT", + "GOPR", "GOPT", "GVIR", "GVIT", "GVPR", "GVPT", "GWCT", + "GWGR", "GWIR", "GWIT", "GWPR", "GWPT", + "WBHP", "WGIR", "WGIT", "WGOR", "WGPR", "WGPT", "WOIR", + "WOIT", "WOPR", "WOPT", "WPI", "WTHP", "WVIR", "WVIT", + "WVPR", "WVPT", "WWCT", "WWGR", "WWIR", "WWIT", "WWPR", + "WWPT", + // ALL will not expand to these keywords yet + "AAQR", "AAQRG", "AAQT", "AAQTG" + }; + +/* + When the error handling config says that the error should be + logged, the handleMissingWell and handleMissingGroup routines + cheat. Ideally we should have a MessageContainer instance around + and pass that to the parseContext::handlError() routine. Instead + we: + + 1. We instantiate new MessageContainer() which is just + immediately dropped to floor, leaving the messages behind. + + 2. Print a message on stderr. + + The case of incorrectly/missing well/group names in the SUMMARY + section did just not seem important enough to warrant the + refactoring required to pass a mutable proper MessageContainer + all the way down here. +*/ + +void handleMissingWell( const ParseContext& parseContext , const std::string& keyword, const std::string& well) { + std::string msg = std::string("Error in keyword:") + keyword + std::string(" No such well: ") + well; + MessageContainer msgContainer; + if (parseContext.get( ParseContext::SUMMARY_UNKNOWN_WELL) == InputError::WARN) + std::cerr << "ERROR: " << msg << std::endl; + + parseContext.handleError( ParseContext::SUMMARY_UNKNOWN_WELL , msgContainer , msg ); +} + + +void handleMissingGroup( const ParseContext& parseContext , const std::string& keyword, const std::string& group) { + std::string msg = std::string("Error in keyword:") + keyword + std::string(" No such group: ") + group; + MessageContainer msgContainer; + if (parseContext.get( ParseContext::SUMMARY_UNKNOWN_GROUP) == InputError::WARN) + std::cerr << "ERROR: " << msg << std::endl; + + parseContext.handleError( ParseContext::SUMMARY_UNKNOWN_GROUP , msgContainer , msg ); +} + +inline void keywordW( std::vector< ERT::smspec_node >& list, + const ParseContext& parseContext, + const DeckKeyword& keyword, + const Schedule& schedule ) { + + const auto type = ECL_SMSPEC_WELL_VAR; + static const std::vector< std::string > wildcard = { "*" }; + + const auto hasValue = []( const DeckKeyword& kw ) { + return kw.getDataRecord().getDataItem().hasValue( 0 ); + }; + + const auto& patterns = keyword.size() > 0 && hasValue( keyword ) + ? keyword.getStringData() + : wildcard; + + for( const std::string& pattern : patterns ) { + auto wells = schedule.getWellsMatching( pattern ); + + if( wells.empty() ) + handleMissingWell( parseContext, keyword.name(), pattern ); + + for( const auto* well : wells ) + list.emplace_back( type, well->name(), keyword.name() ); + } +} + +inline void keywordG( std::vector< ERT::smspec_node >& list, + const ParseContext& parseContext, + const DeckKeyword& keyword, + const Schedule& schedule ) { + + const auto type = ECL_SMSPEC_GROUP_VAR; + + if( keyword.size() == 0 || + !keyword.getDataRecord().getDataItem().hasValue( 0 ) ) { + + for( const auto& group : schedule.getGroups() ) + list.emplace_back( type, group->name(), keyword.name() ); + + return; } - static std::string groupName( const Group* group ) { - return group->name(); + const auto& item = keyword.getDataRecord().getDataItem(); + + for( const std::string& group : item.getData< std::string >() ) { + if( schedule.hasGroup( group ) ) + list.emplace_back( ECL_SMSPEC_GROUP_VAR, group, keyword.name() ); + else + handleMissingGroup( parseContext, keyword.name(), group ); } +} - static inline std::vector< ERT::smspec_node > keywordW( - const DeckKeyword& keyword, - const Schedule& schedule ) { +inline void keywordF( std::vector< ERT::smspec_node >& list, + const DeckKeyword& keyword ) { + list.emplace_back( keyword.name() ); +} - const auto mknode = [&keyword]( const std::string& name ) { - return ERT::smspec_node( ECL_SMSPEC_WELL_VAR, name, keyword.name() ); - }; +inline std::array< int, 3 > dimensions( const EclipseGrid& grid ) { + return {{ int( grid.getNX() ), int( grid.getNY() ), int( grid.getNZ() ) }}; +} - const auto missing = [&schedule]( const std::string& name ) { - return !schedule.hasWell( name ); - }; +inline std::array< int, 3 > getijk( const DeckRecord& record, + int offset = 0 ) { + return {{ + record.getItem( offset + 0 ).get< int >( 0 ) - 1, + record.getItem( offset + 1 ).get< int >( 0 ) - 1, + record.getItem( offset + 2 ).get< int >( 0 ) - 1 + }}; +} - const auto& item = keyword.getDataRecord().getDataItem(); - auto wnames = item.hasValue( 0 ) - ? item.getData< std::string >() - : fun::map( wellName, schedule.getWells() ); +inline std::array< int, 3 > getijk( const Completion& completion ) { + return {{ completion.getI(), completion.getJ(), completion.getK() }}; +} - /* filter all requested names that were not in the Deck */ - wnames.erase( - std::remove_if( wnames.begin(), wnames.end(), missing ), - wnames.end() ); - - return fun::map( mknode, wnames ); +inline void keywordB( std::vector< ERT::smspec_node >& list, + const DeckKeyword& keyword, + std::array< int, 3 > dims ) { + for( const auto& record : keyword ) { + auto ijk = getijk( record ); + list.emplace_back( keyword.name(), dims.data(), ijk.data() ); } +} - static inline std::vector< ERT::smspec_node > keywordG( - const DeckKeyword& keyword, - const Schedule& schedule ) { +inline void keywordR( std::vector< ERT::smspec_node >& list, + const DeckKeyword& keyword, + const Eclipse3DProperties& props, + std::array< int, 3 > dims ) { - const auto mknode = [&keyword]( const std::string& name ) { - return ERT::smspec_node( ECL_SMSPEC_GROUP_VAR, name, keyword.name() ); - }; + /* RUNSUM is not a region keyword but a directive for how to format and + * print output. Unfortunately its *recognised* as a region keyword + * because of its structure and position. Hence the special handling of ignoring it. + */ + if( keyword.name() == "RUNSUM" ) return; + if( keyword.name() == "RPTONLY" ) return; - const auto missing = [&schedule]( const std::string& name ) { - return !schedule.hasGroup( name ); - }; + const auto& item = keyword.getDataRecord().getDataItem(); + const auto regions = item.hasValue( 0 ) + ? item.getData< int >() + : props.getRegions( "FIPNUM" ); - const auto& item = keyword.getDataRecord().getDataItem(); - auto gnames = item.hasValue( 0 ) - ? item.getData< std::string >() - : fun::map( groupName, schedule.getGroups() ); + for( const int region : regions ) + list.emplace_back( keyword.name(), dims.data(), region ); +} - gnames.erase( - std::remove_if( gnames.begin(), gnames.end(), missing ), - gnames.end() ); +inline void keywordC( std::vector< ERT::smspec_node >& list, + const ParseContext& parseContext, + const DeckKeyword& keyword, + const Schedule& schedule, + std::array< int, 3 > dims ) { - return fun::map( mknode, gnames ); - } + const auto& keywordstring = keyword.name(); + const auto last_timestep = schedule.getTimeMap()->last(); - static inline std::vector< ERT::smspec_node > keywordF( - const DeckKeyword& keyword ) { + for( const auto& record : keyword ) { - std::vector< ERT::smspec_node > res; - res.push_back( ERT::smspec_node( keyword.name() ) ); - return res; - } + const auto& wellitem = record.getItem( 0 ); - static inline std::array< int, 3 > dimensions( const EclipseGrid& grid ) { - return {{ - int( grid.getNX() ), - int( grid.getNY() ), - int( grid.getNZ() ) - }}; - } + const auto wells = wellitem.defaultApplied( 0 ) + ? schedule.getWells() + : schedule.getWellsMatching( wellitem.getTrimmedString( 0 ) ); - static inline std::array< int, 3 > getijk( const DeckRecord& record, - int offset = 0 ) - { - return {{ - record.getItem( offset + 0 ).get< int >( 0 ) - 1, - record.getItem( offset + 1 ).get< int >( 0 ) - 1, - record.getItem( offset + 2 ).get< int >( 0 ) - 1 - }}; - } + if( wells.empty() ) + handleMissingWell( parseContext, keyword.name(), wellitem.getTrimmedString( 0 ) ); - static inline std::array< int, 3 > getijk( const Completion& completion ) { - return {{ completion.getI(), completion.getJ(), completion.getK() }}; - } + for( const auto* well : wells ) { + const auto& name = well->name(); - static inline std::vector< ERT::smspec_node > keywordB( - const DeckKeyword& keyword, - std::array< int, 3 > dims ) { + /* + * we don't want to add completions that don't exist, so we iterate + * over a well's completions regardless of the desired block is + * defaulted or not + */ + for( const auto& completion : *well->getCompletions( last_timestep ) ) { + /* block coordinates defaulted */ + auto cijk = getijk( *completion ); - const auto mkrecord = [dims,&keyword]( const DeckRecord& record ) { - auto ijk = getijk( record ); - return ERT::smspec_node( keyword.name(), dims.data(), ijk.data() ); - }; - - return fun::map( mkrecord, keyword ); - } - - static inline std::vector< ERT::smspec_node > keywordR( - const DeckKeyword& keyword, - const Eclipse3DProperties& props, - std::array< int, 3 > dims ) { - - /* RUNSUM is not a region keyword but a directive for how to format and - * print output. Unfortunately its *recognised* as a region keyword - * because of its structure and position. Hence the special handling of ignoring it. - */ - if( keyword.name() == "RUNSUM" ) return {}; - if( keyword.name() == "RPTONLY" ) return {}; - - const auto mknode = [dims,&keyword]( int region ) { - return ERT::smspec_node( keyword.name(), dims.data(), region ); - }; - - const auto& item = keyword.getDataRecord().getDataItem(); - const auto regions = item.size() > 0 && item.hasValue( 0 ) - ? item.getData< int >() - : props.getRegions( "FIPNUM" ); - - return fun::map( mknode, regions ); - } - - static inline std::vector< ERT::smspec_node > keywordC( - const DeckKeyword& keyword, - const Schedule& schedule, - std::array< int, 3 > dims ) { - - std::vector< ERT::smspec_node > nodes; - const auto& keywordstring = keyword.name(); - const auto last_timestep = schedule.getTimeMap()->last(); - - for( const auto& record : keyword ) { - - if( record.getItem( 0 ).defaultApplied( 0 ) ) { - for( const auto& well : schedule.getWells() ) { - - const auto& name = wellName( well ); - - for( const auto& completion : *well->getCompletions( last_timestep ) ) { - auto cijk = getijk( *completion ); - - /* well defaulted, block coordinates defaulted */ - if( record.getItem( 1 ).defaultApplied( 0 ) ) { - nodes.emplace_back( keywordstring, name, dims.data(), cijk.data() ); - } - /* well defaulted, block coordinates specified */ - else { - auto recijk = getijk( record, 1 ); - if( std::equal( recijk.begin(), recijk.end(), cijk.begin() ) ) - nodes.emplace_back( keywordstring, name, dims.data(), cijk.data() ); - } - } - } - - } else { - const auto& name = record.getItem( 0 ).get< std::string >( 0 ); - /* all specified */ - if( !record.getItem( 1 ).defaultApplied( 0 ) ) { - auto ijk = getijk( record, 1 ); - nodes.emplace_back( keywordstring, name, dims.data(), ijk.data() ); - } - else { - /* well specified, block coordinates defaulted */ - for( const auto& completion : *schedule.getWell( name ).getCompletions( last_timestep ) ) { - auto ijk = getijk( *completion ); - nodes.emplace_back( keywordstring, name, dims.data(), ijk.data() ); - } - } - } - } - - return nodes; - } - - std::vector< ERT::smspec_node > handleKW( const DeckKeyword& keyword, - const Schedule& schedule, - const Eclipse3DProperties& props, - std::array< int, 3 > n_xyz ) { - const auto var_type = ecl_smspec_identify_var_type( keyword.name().c_str() ); - - switch( var_type ) { - case ECL_SMSPEC_WELL_VAR: return keywordW( keyword, schedule ); - case ECL_SMSPEC_GROUP_VAR: return keywordG( keyword, schedule ); - case ECL_SMSPEC_FIELD_VAR: return keywordF( keyword ); - case ECL_SMSPEC_BLOCK_VAR: return keywordB( keyword, n_xyz ); - case ECL_SMSPEC_REGION_VAR: return keywordR( keyword, props, n_xyz ); - case ECL_SMSPEC_COMPLETION_VAR: return keywordC( keyword, schedule, n_xyz ); - - default: return {}; + if( record.getItem( 1 ).defaultApplied( 0 ) ) { + list.emplace_back( keywordstring, name, dims.data(), cijk.data() ); + } + else { + /* block coordinates specified */ + auto recijk = getijk( record, 1 ); + if( std::equal( recijk.begin(), recijk.end(), cijk.begin() ) ) + list.emplace_back( keywordstring, name, dims.data(), cijk.data() ); + } + } } } +} - SummaryConfig::SummaryConfig( const Deck& deck, const EclipseState& es ) - : SummaryConfig( deck, - *es.getSchedule(), - es.get3DProperties(), - dimensions( *es.getInputGrid() ) ) - {} +inline void handleKW( std::vector< ERT::smspec_node >& list, + const DeckKeyword& keyword, + const Schedule& schedule, + const Eclipse3DProperties& props, + const ParseContext& parseContext, + std::array< int, 3 > n_xyz ) { + const auto var_type = ecl_smspec_identify_var_type( keyword.name().c_str() ); - SummaryConfig::SummaryConfig( const Deck& deck, - const Schedule& schedule, - const Eclipse3DProperties& props, - std::array< int, 3 > n_xyz ) { + switch( var_type ) { + case ECL_SMSPEC_WELL_VAR: return keywordW( list, parseContext, keyword, schedule ); + case ECL_SMSPEC_GROUP_VAR: return keywordG( list, parseContext, keyword, schedule ); + case ECL_SMSPEC_FIELD_VAR: return keywordF( list, keyword ); + case ECL_SMSPEC_BLOCK_VAR: return keywordB( list, keyword, n_xyz ); + case ECL_SMSPEC_REGION_VAR: return keywordR( list, keyword, props, n_xyz ); + case ECL_SMSPEC_COMPLETION_VAR: return keywordC( list, parseContext, keyword, schedule, n_xyz ); - SUMMARYSection section( deck ); - - using namespace std::placeholders; - const auto handler = std::bind( handleKW, _1, schedule, props, n_xyz ); - - /* This line of code does not compile on VS2015 - * this->keywords = fun::concat( fun::map( handler, section ) ); - * The following code is a workaround for this compiler bug */ - for (auto& x : section) - { - for (auto& keyword : handler(x)) - this->keywords.push_back(keyword); - } + default: return; } +} - SummaryConfig::const_iterator SummaryConfig::begin() const { - return this->keywords.cbegin(); - } +inline void uniq( std::vector< ERT::smspec_node >& vec ) { + const auto lt = []( const ERT::smspec_node& lhs, + const ERT::smspec_node& rhs ) { + return std::strcmp( lhs.key1(), rhs.key1() ) < 0; + }; + const auto eq = []( const ERT::smspec_node& lhs, + const ERT::smspec_node& rhs ) { + return std::strcmp( lhs.key1(), rhs.key1() ) == 0; + }; - SummaryConfig::const_iterator SummaryConfig::end() const { - return this->keywords.cend(); - } + std::sort( vec.begin(), vec.end(), lt ); + auto logical_end = std::unique( vec.begin(), vec.end(), eq ); + vec.erase( logical_end, vec.end() ); +} + +} + +SummaryConfig::SummaryConfig( const Deck& deck, const EclipseState& es , const ParseContext& parseContext) + : SummaryConfig( deck, + *es.getSchedule(), + es.get3DProperties(), + parseContext, + dimensions( *es.getInputGrid() ) ) +{} + +SummaryConfig::SummaryConfig( const Deck& deck, + const Schedule& schedule, + const Eclipse3DProperties& props, + const ParseContext& parseContext, + std::array< int, 3 > n_xyz ) { + + SUMMARYSection section( deck ); + for( auto& x : section ) + handleKW( this->keywords, x, schedule, props, parseContext, n_xyz ); + + if( section.hasKeyword( "ALL" ) ) + this->merge( { ALL_keywords, schedule, props, parseContext, n_xyz } ); + + uniq( this->keywords ); + for (const auto& kw: this->keywords) + this->short_keywords.insert( kw.keyword() ); +} + +SummaryConfig::const_iterator SummaryConfig::begin() const { + return this->keywords.cbegin(); +} + +SummaryConfig::const_iterator SummaryConfig::end() const { + return this->keywords.cend(); +} + +SummaryConfig& SummaryConfig::merge( const SummaryConfig& other ) { + this->keywords.insert( this->keywords.end(), + other.keywords.begin(), + other.keywords.end() ); + + uniq( this->keywords ); + return *this; +} + +SummaryConfig& SummaryConfig::merge( SummaryConfig&& other ) { + auto fst = std::make_move_iterator( other.keywords.begin() ); + auto lst = std::make_move_iterator( other.keywords.end() ); + this->keywords.insert( this->keywords.end(), fst, lst ); + other.keywords.clear(); + + uniq( this->keywords ); + return *this; +} + +bool SummaryConfig::hasKeyword( const std::string& keyword ) const { + return (this->short_keywords.count( keyword ) == 1); +} } diff --git a/ThirdParty/custom-opm-parser/opm-parser/opm/parser/eclipse/EclipseState/SummaryConfig/SummaryConfig.hpp b/ThirdParty/custom-opm-parser/opm-parser/opm/parser/eclipse/EclipseState/SummaryConfig/SummaryConfig.hpp index 06ee4c5005..874924a34a 100644 --- a/ThirdParty/custom-opm-parser/opm-parser/opm/parser/eclipse/EclipseState/SummaryConfig/SummaryConfig.hpp +++ b/ThirdParty/custom-opm-parser/opm-parser/opm/parser/eclipse/EclipseState/SummaryConfig/SummaryConfig.hpp @@ -22,6 +22,7 @@ #include #include +#include #include @@ -32,22 +33,40 @@ namespace Opm { class EclipseState; class ParserKeyword; class Schedule; + class ParseContext; class SummaryConfig { public: typedef std::vector< ERT::smspec_node >::const_iterator const_iterator; - SummaryConfig( const Deck&, const EclipseState& ); + SummaryConfig( const Deck&, const EclipseState& , const ParseContext& ); SummaryConfig( const Deck&, const Schedule&, - const Eclipse3DProperties&, std::array< int, 3 > ); + const Eclipse3DProperties&, const ParseContext&, std::array< int, 3 > ); SummaryConfig( const Deck&, const Schedule&, - const Eclipse3DProperties&, int, int, int ); + const Eclipse3DProperties&, const ParseContext&, int, int, int ); const_iterator begin() const; const_iterator end() const; + SummaryConfig& merge( const SummaryConfig& ); + SummaryConfig& merge( SummaryConfig&& ); + + /* + The hasKeyword() method will consult the internal set + 'short_keywords', i.e. the query should be based on pure + keywords like 'WWCT' and 'BPR' - and *not* fully + identifiers like 'WWCT:OPX' and 'BPR:10,12,3'. + */ + bool hasKeyword( const std::string& keyword ) const; private: + + /* + The short_keywords set contains only the pure keyword + part, e.g. "WWCT", and not the qualification with + well/group name or a numerical value. + */ std::vector< ERT::smspec_node > keywords; + std::set short_keywords; }; } //namespace Opm diff --git a/ThirdParty/custom-opm-parser/opm-parser/opm/parser/eclipse/EclipseState/SummaryConfig/tests/SummaryConfigTests.cpp b/ThirdParty/custom-opm-parser/opm-parser/opm/parser/eclipse/EclipseState/SummaryConfig/tests/SummaryConfigTests.cpp index b7758d4589..ad1227d563 100644 --- a/ThirdParty/custom-opm-parser/opm-parser/opm/parser/eclipse/EclipseState/SummaryConfig/tests/SummaryConfigTests.cpp +++ b/ThirdParty/custom-opm-parser/opm-parser/opm/parser/eclipse/EclipseState/SummaryConfig/tests/SummaryConfigTests.cpp @@ -55,8 +55,9 @@ static DeckPtr createDeck( const std::string& summary ) { "/\n" "COMPDAT\n" "'PRODUCER' 5 5 1 1 'OPEN' 1* -1 0.5 / \n" - "'W_1' 3 7 1 3 'OPEN' 1* 32.948 0.311 3047.839 2* 'X' 22.100 / \n" "'W_1' 3 7 2 2 'OPEN' 1* * 0.311 4332.346 2* 'X' 22.123 / \n" + "'W_1' 2 2 1 1 /\n" + "'WX2' 2 2 1 1 /\n" "/\n" "SUMMARY\n" + summary; @@ -66,8 +67,11 @@ static DeckPtr createDeck( const std::string& summary ) { static std::vector< std::string > sorted_names( const SummaryConfig& summary ) { std::vector< std::string > ret; - for( const auto& x : summary ) - ret.push_back( x.wgname() ); + for( const auto& x : summary ) { + auto wgname = x.wgname(); + if(wgname) + ret.push_back( x.wgname() ); + } std::sort( ret.begin(), ret.end() ); return ret; @@ -82,10 +86,20 @@ static std::vector< std::string > sorted_keywords( const SummaryConfig& summary return ret; } -static SummaryConfig createSummary( std::string input ) { +static std::vector< std::string > sorted_key_names( const SummaryConfig& summary ) { + std::vector< std::string > ret; + for( const auto& x : summary ) { + ret.push_back( x.key1() ); + } + + std::sort( ret.begin(), ret.end() ); + return ret; +} + +static SummaryConfig createSummary( std::string input , const ParseContext& parseContext = ParseContext()) { auto deck = createDeck( input ); - EclipseState state( deck, ParseContext() ); - return SummaryConfig( *deck, state ); + EclipseState state( *deck, parseContext ); + return state.getEclipseConfig().getSummaryConfig(); } BOOST_AUTO_TEST_CASE(wells_all) { @@ -111,10 +125,10 @@ BOOST_AUTO_TEST_CASE(wells_select) { names.begin(), names.end() ); } -BOOST_AUTO_TEST_CASE(wells_select_unknown_well) { - const auto input = "WWCT\n'W_1' 'WX2' 'unknown'/\n"; +BOOST_AUTO_TEST_CASE(wells_pattern) { + const auto input = "WWCT\n'W*' /\n"; const auto summary = createSummary( input ); - const auto wells = { "WX2", "W_1" }; + const auto wells = { "WX2", "W_1", "W_3" }; const auto names = sorted_names( summary ); BOOST_CHECK_EQUAL_COLLECTIONS( @@ -167,21 +181,190 @@ BOOST_AUTO_TEST_CASE(regions) { } BOOST_AUTO_TEST_CASE(completions) { - const auto input = "CWIR\n" + const auto input = "CWIR\n" // all specified "'PRODUCER' /\n" "'WX2' 1 1 1 /\n" - "'WX2' 2 2 2 /\n" + "'WX2' 2 2 1 /\n" "/\n" - "CWIT\n" + "CWIT\n" // block defaulted "'W_1' /\n" + "/\n" + "CGIT\n" // well defaulted + "* 2 2 1 /\n" + "/\n" + "CGIR\n" // all defaulted + " '*' /\n" "/\n"; const auto summary = createSummary( input ); - const auto keywords = { "CWIR", "CWIR", "CWIR", - "CWIT", "CWIT", "CWIT" }; + const auto keywords = { "CGIR", "CGIR", "CGIR", "CGIR", + "CGIT", "CGIT", + "CWIR", "CWIR", + "CWIT", "CWIT" }; const auto names = sorted_keywords( summary ); BOOST_CHECK_EQUAL_COLLECTIONS( keywords.begin(), keywords.end(), names.begin(), names.end() ); + +} + +BOOST_AUTO_TEST_CASE( merge ) { + const auto input1 = "WWCT\n/\n"; + auto summary1 = createSummary( input1 ); + + const auto keywords = { "FOPT", "WWCT", "WWCT", "WWCT", "WWCT" }; + const auto wells = { "PRODUCER", "WX2", "W_1", "W_3" }; + + const auto input2 = "FOPT\n"; + const auto summary2 = createSummary( input2 ); + + summary1.merge( summary2 ); + const auto kw_names = sorted_keywords( summary1 ); + const auto well_names = sorted_names( summary1 ); + + BOOST_CHECK_EQUAL_COLLECTIONS( + keywords.begin(), keywords.end(), + kw_names.begin(), kw_names.end() ); + + BOOST_CHECK_EQUAL_COLLECTIONS( + wells.begin(), wells.end(), + well_names.begin(), well_names.end() ); +} + +BOOST_AUTO_TEST_CASE( merge_move ) { + const auto input = "WWCT\n/\n"; + auto summary = createSummary( input ); + + const auto keywords = { "FOPT", "WWCT", "WWCT", "WWCT", "WWCT" }; + const auto wells = { "PRODUCER", "WX2", "W_1", "W_3" }; + + summary.merge( createSummary( "FOPT\n" ) ); + + const auto kw_names = sorted_keywords( summary ); + const auto well_names = sorted_names( summary ); + + BOOST_CHECK_EQUAL_COLLECTIONS( + keywords.begin(), keywords.end(), + kw_names.begin(), kw_names.end() ); + + BOOST_CHECK_EQUAL_COLLECTIONS( + wells.begin(), wells.end(), + well_names.begin(), well_names.end() ); +} + +static const auto ALL_keywords = { + "FAQR", "FAQRG", "FAQT", "FAQTG", "FGIP", "FGIPG", "FGIPL", + "FGIR", "FGIT", "FGOR", "FGPR", "FGPT", "FOIP", "FOIPG", + "FOIPL", "FOIR", "FOIT", "FOPR", "FOPT", "FPR", "FVIR", + "FVIT", "FVPR", "FVPT", "FWCT", "FWGR", "FWIP", "FWIR", + "FWIT", "FWPR", "FWPT", + "GGIR", "GGIT", "GGOR", "GGPR", "GGPT", "GOIR", "GOIT", + "GOPR", "GOPT", "GVIR", "GVIT", "GVPR", "GVPT", "GWCT", + "GWGR", "GWIR", "GWIT", "GWPR", "GWPT", + "WBHP", "WGIR", "WGIT", "WGOR", "WGPR", "WGPT", "WOIR", + "WOIT", "WOPR", "WOPT", "WPI", "WTHP", "WVIR", "WVIT", + "WVPR", "WVPT", "WWCT", "WWGR", "WWIR", "WWIT", "WWPR", + "WWPT", + // ALL will not expand to these keywords yet + "AAQR", "AAQRG", "AAQT", "AAQTG" +}; + + +BOOST_AUTO_TEST_CASE(summary_ALL) { + + const auto input = "ALL\n"; + + const auto summary = createSummary( input ); + const auto key_names = sorted_key_names( summary ); + + std::vector all; + + for( std::string keyword: ALL_keywords ) { + if(keyword[0]=='F') { + all.push_back(keyword); + } + else if (keyword[0]=='G') { + auto kn = keyword + ":"; + all.push_back(kn + "G"); + all.push_back(kn + "OP"); + all.push_back(kn + "FIELD"); + } + else if (keyword[0]=='W') { + auto kn = keyword + ":"; + all.push_back(kn + "W_1"); + all.push_back(kn + "WX2"); + all.push_back(kn + "W_3"); + all.push_back(kn + "PRODUCER"); + } + } + + std::sort(all.begin(), all.end()); + + BOOST_CHECK_EQUAL_COLLECTIONS( + all.begin(), all.end(), + key_names.begin(), key_names.end()); + + BOOST_CHECK_EQUAL( true , summary.hasKeyword( "FOPT")); + BOOST_CHECK_EQUAL( true , summary.hasKeyword( "GGIT")); + BOOST_CHECK_EQUAL( true , summary.hasKeyword( "WWCT")); + + BOOST_CHECK_EQUAL( false , summary.hasKeyword("NO-NOT-THIS")); +} + + + +BOOST_AUTO_TEST_CASE(INVALID_WELL1) { + ParseContext parseContext; + const auto input = "CWIR\n" + "NEW-WELL /\n" + "/\n"; + parseContext.updateKey( ParseContext::SUMMARY_UNKNOWN_WELL , InputError::THROW_EXCEPTION ); + BOOST_CHECK_THROW( createSummary( input , parseContext ) , std::invalid_argument); + + parseContext.updateKey( ParseContext::SUMMARY_UNKNOWN_WELL , InputError::IGNORE ); + BOOST_CHECK_NO_THROW( createSummary( input , parseContext )); +} + + +BOOST_AUTO_TEST_CASE(INVALID_WELL2) { + ParseContext parseContext; + const auto input = "WWCT\n" + " NEW-WELL /\n"; + parseContext.updateKey( ParseContext::SUMMARY_UNKNOWN_WELL , InputError::THROW_EXCEPTION ); + BOOST_CHECK_THROW( createSummary( input , parseContext ) , std::invalid_argument); + + parseContext.updateKey( ParseContext::SUMMARY_UNKNOWN_WELL , InputError::IGNORE ); + BOOST_CHECK_NO_THROW( createSummary( input , parseContext )); +} + + +BOOST_AUTO_TEST_CASE(INVALID_GROUP) { + ParseContext parseContext; + const auto input = "GWCT\n" + " NEW-GR /\n"; + parseContext.updateKey( ParseContext::SUMMARY_UNKNOWN_GROUP , InputError::THROW_EXCEPTION ); + BOOST_CHECK_THROW( createSummary( input , parseContext ) , std::invalid_argument); + + parseContext.updateKey( ParseContext::SUMMARY_UNKNOWN_GROUP , InputError::IGNORE ); + BOOST_CHECK_NO_THROW( createSummary( input , parseContext )); +} + +BOOST_AUTO_TEST_CASE( REMOVE_DUPLICATED_ENTRIES ) { + ParseContext parseContext; + const auto input = "WGPR \n/\n" + "WGPR \n/\n" + "ALL\n"; + + const auto summary = createSummary( input ); + const auto keys = sorted_key_names( summary ); + auto uniq_keys = keys; + uniq_keys.erase( std::unique( uniq_keys.begin(), + uniq_keys.end(), + std::equal_to< std::string >() ), + uniq_keys.end() ); + + BOOST_CHECK_EQUAL_COLLECTIONS( + keys.begin(), keys.end(), + uniq_keys.begin(), uniq_keys.end() ); } diff --git a/ThirdParty/custom-opm-parser/opm-parser/opm/parser/eclipse/EclipseState/Tables/ColumnSchema.cpp b/ThirdParty/custom-opm-parser/opm-parser/opm/parser/eclipse/EclipseState/Tables/ColumnSchema.cpp index 180f6aec66..dae6e90d09 100644 --- a/ThirdParty/custom-opm-parser/opm-parser/opm/parser/eclipse/EclipseState/Tables/ColumnSchema.cpp +++ b/ThirdParty/custom-opm-parser/opm-parser/opm/parser/eclipse/EclipseState/Tables/ColumnSchema.cpp @@ -23,8 +23,8 @@ namespace Opm { - ColumnSchema::ColumnSchema(const std::string& name , Table::ColumnOrderEnum order , Table::DefaultAction defaultAction) : - m_name( name ), + ColumnSchema::ColumnSchema(const std::string& nm, Table::ColumnOrderEnum order, Table::DefaultAction defaultAction) : + m_name( nm ), m_order( order ), m_defaultAction( defaultAction ) { @@ -32,8 +32,8 @@ namespace Opm { } - ColumnSchema::ColumnSchema(const std::string& name , Table::ColumnOrderEnum order , double defaultValue ) : - m_name( name ), + ColumnSchema::ColumnSchema(const std::string& nm, Table::ColumnOrderEnum order, double defaultValue ) : + m_name( nm ), m_order( order ), m_defaultAction( Table::DEFAULT_CONST ), m_defaultValue( defaultValue ) diff --git a/ThirdParty/custom-opm-parser/opm-parser/opm/parser/eclipse/EclipseState/Tables/Tables.cpp b/ThirdParty/custom-opm-parser/opm-parser/opm/parser/eclipse/EclipseState/Tables/Tables.cpp index 206bf622e0..c91bacd79f 100644 --- a/ThirdParty/custom-opm-parser/opm-parser/opm/parser/eclipse/EclipseState/Tables/Tables.cpp +++ b/ThirdParty/custom-opm-parser/opm-parser/opm/parser/eclipse/EclipseState/Tables/Tables.cpp @@ -639,10 +639,10 @@ GasvisctTable::GasvisctTable( const Deck& deck, const DeckItem& deckItem ) { throw std::runtime_error("Number of columns in the data file is inconsistent " "with the expected number for keyword GASVISCT"); - size_t numRows = deckItem.size() / m_schema->size(); + size_t rows = deckItem.size() / m_schema->size(); for (size_t columnIndex=0; columnIndex < m_schema->size(); columnIndex++) { auto& column = getColumn( columnIndex ); - for (size_t rowIdx = 0; rowIdx < numRows; rowIdx++) { + for (size_t rowIdx = 0; rowIdx < rows; rowIdx++) { size_t deckIndex = rowIdx * m_schema->size() + columnIndex; if (deckItem.defaultApplied( deckIndex )) diff --git a/ThirdParty/custom-opm-parser/opm-parser/opm/parser/eclipse/EclipseState/Tables/VFPInjTable.hpp b/ThirdParty/custom-opm-parser/opm-parser/opm/parser/eclipse/EclipseState/Tables/VFPInjTable.hpp index be1e7eed44..e33628d430 100644 --- a/ThirdParty/custom-opm-parser/opm-parser/opm/parser/eclipse/EclipseState/Tables/VFPInjTable.hpp +++ b/ThirdParty/custom-opm-parser/opm-parser/opm/parser/eclipse/EclipseState/Tables/VFPInjTable.hpp @@ -23,11 +23,9 @@ #include -#include #include -#include namespace Opm { diff --git a/ThirdParty/custom-opm-parser/opm-parser/opm/parser/eclipse/EclipseState/Tables/VFPProdTable.cpp b/ThirdParty/custom-opm-parser/opm-parser/opm/parser/eclipse/EclipseState/Tables/VFPProdTable.cpp index 02cc91a78e..a6b75940c5 100644 --- a/ThirdParty/custom-opm-parser/opm-parser/opm/parser/eclipse/EclipseState/Tables/VFPProdTable.cpp +++ b/ThirdParty/custom-opm-parser/opm-parser/opm/parser/eclipse/EclipseState/Tables/VFPProdTable.cpp @@ -31,7 +31,9 @@ namespace Opm { -static VFPProdTable::FLO_TYPE getFloType( const DeckItem& item) { +namespace { + +VFPProdTable::FLO_TYPE getFloType( const DeckItem& item) { const std::string& flo_string = item.getTrimmedString(0); if (flo_string == "OIL") { return VFPProdTable::FLO_OIL; @@ -116,6 +118,9 @@ VFPProdTable::ALQ_TYPE getALQType( const DeckItem& item) { return VFPProdTable::ALQ_INVALID; } } + +} + void VFPProdTable::init(int table_num, double datum_depth, FLO_TYPE flo_type, diff --git a/ThirdParty/custom-opm-parser/opm-parser/opm/parser/eclipse/EclipseState/Tables/VFPProdTable.hpp b/ThirdParty/custom-opm-parser/opm-parser/opm/parser/eclipse/EclipseState/Tables/VFPProdTable.hpp index 0e1e17d309..cb45815e7f 100644 --- a/ThirdParty/custom-opm-parser/opm-parser/opm/parser/eclipse/EclipseState/Tables/VFPProdTable.hpp +++ b/ThirdParty/custom-opm-parser/opm-parser/opm/parser/eclipse/EclipseState/Tables/VFPProdTable.hpp @@ -20,11 +20,9 @@ #ifndef OPM_PARSER_ECLIPSE_ECLIPSESTATE_TABLES_VFPPRODTABLE_HPP_ #define OPM_PARSER_ECLIPSE_ECLIPSESTATE_TABLES_VFPPRODTABLE_HPP_ -#include #include -#include #include namespace Opm { diff --git a/ThirdParty/custom-opm-parser/opm-parser/opm/parser/eclipse/EclipseState/Tables/tests/ColumnSchemaTests.cpp b/ThirdParty/custom-opm-parser/opm-parser/opm/parser/eclipse/EclipseState/Tables/tests/ColumnSchemaTests.cpp index e0abc6359d..f3d7584204 100644 --- a/ThirdParty/custom-opm-parser/opm-parser/opm/parser/eclipse/EclipseState/Tables/tests/ColumnSchemaTests.cpp +++ b/ThirdParty/custom-opm-parser/opm-parser/opm/parser/eclipse/EclipseState/Tables/tests/ColumnSchemaTests.cpp @@ -19,9 +19,7 @@ #define BOOST_TEST_MODULE ColumnSchemaTests -#include #include -#include #include diff --git a/ThirdParty/custom-opm-parser/opm-parser/opm/parser/eclipse/EclipseState/Tables/tests/PvtxTableTests.cpp b/ThirdParty/custom-opm-parser/opm-parser/opm/parser/eclipse/EclipseState/Tables/tests/PvtxTableTests.cpp index 0e5cb43a8f..1431e594fe 100644 --- a/ThirdParty/custom-opm-parser/opm-parser/opm/parser/eclipse/EclipseState/Tables/tests/PvtxTableTests.cpp +++ b/ThirdParty/custom-opm-parser/opm-parser/opm/parser/eclipse/EclipseState/Tables/tests/PvtxTableTests.cpp @@ -19,9 +19,7 @@ #define BOOST_TEST_MODULE PvtxTableTests -#include #include -#include #include #include diff --git a/ThirdParty/custom-opm-parser/opm-parser/opm/parser/eclipse/EclipseState/Tables/tests/SimpleTableTests.cpp b/ThirdParty/custom-opm-parser/opm-parser/opm/parser/eclipse/EclipseState/Tables/tests/SimpleTableTests.cpp index 0479947597..9cc4f912ae 100644 --- a/ThirdParty/custom-opm-parser/opm-parser/opm/parser/eclipse/EclipseState/Tables/tests/SimpleTableTests.cpp +++ b/ThirdParty/custom-opm-parser/opm-parser/opm/parser/eclipse/EclipseState/Tables/tests/SimpleTableTests.cpp @@ -19,9 +19,7 @@ #define BOOST_TEST_MODULE SimpleTableTests -#include #include -#include #include diff --git a/ThirdParty/custom-opm-parser/opm-parser/opm/parser/eclipse/EclipseState/Tables/tests/TableColumnTests.cpp b/ThirdParty/custom-opm-parser/opm-parser/opm/parser/eclipse/EclipseState/Tables/tests/TableColumnTests.cpp index 17cb36d7b4..e37f74758f 100644 --- a/ThirdParty/custom-opm-parser/opm-parser/opm/parser/eclipse/EclipseState/Tables/tests/TableColumnTests.cpp +++ b/ThirdParty/custom-opm-parser/opm-parser/opm/parser/eclipse/EclipseState/Tables/tests/TableColumnTests.cpp @@ -19,9 +19,7 @@ #define BOOST_TEST_MODULE TableColumnTests -#include #include -#include #include diff --git a/ThirdParty/custom-opm-parser/opm-parser/opm/parser/eclipse/EclipseState/Tables/tests/TableContainerTests.cpp b/ThirdParty/custom-opm-parser/opm-parser/opm/parser/eclipse/EclipseState/Tables/tests/TableContainerTests.cpp index dfd17fe3b0..293940aca4 100644 --- a/ThirdParty/custom-opm-parser/opm-parser/opm/parser/eclipse/EclipseState/Tables/tests/TableContainerTests.cpp +++ b/ThirdParty/custom-opm-parser/opm-parser/opm/parser/eclipse/EclipseState/Tables/tests/TableContainerTests.cpp @@ -19,9 +19,7 @@ #define BOOST_TEST_MODULE TableContainerTests -#include #include -#include #include #include @@ -34,7 +32,7 @@ #include #include -std::shared_ptr createSWOFDeck() { +inline std::shared_ptr createSWOFDeck() { const char *deckData = "TABDIMS\n" " 2 /\n" diff --git a/ThirdParty/custom-opm-parser/opm-parser/opm/parser/eclipse/EclipseState/Tables/tests/TableManagerTests.cpp b/ThirdParty/custom-opm-parser/opm-parser/opm/parser/eclipse/EclipseState/Tables/tests/TableManagerTests.cpp index cb1ec006e9..330b7ce848 100644 --- a/ThirdParty/custom-opm-parser/opm-parser/opm/parser/eclipse/EclipseState/Tables/tests/TableManagerTests.cpp +++ b/ThirdParty/custom-opm-parser/opm-parser/opm/parser/eclipse/EclipseState/Tables/tests/TableManagerTests.cpp @@ -19,9 +19,7 @@ #define BOOST_TEST_MODULE SimpleTableTests -#include #include -#include #include #include @@ -47,6 +45,7 @@ #include #include +namespace { std::shared_ptr createSingleRecordDeck() { const char *deckData = @@ -93,6 +92,7 @@ std::shared_ptr createSingleRecordDeckWithVd() { return deck; } +} BOOST_AUTO_TEST_CASE( CreateTables ) { std::shared_ptr deck = createSingleRecordDeck(); diff --git a/ThirdParty/custom-opm-parser/opm-parser/opm/parser/eclipse/EclipseState/Tables/tests/TableSchemaTests.cpp b/ThirdParty/custom-opm-parser/opm-parser/opm/parser/eclipse/EclipseState/Tables/tests/TableSchemaTests.cpp index 4c8893018c..5e71a31e34 100644 --- a/ThirdParty/custom-opm-parser/opm-parser/opm/parser/eclipse/EclipseState/Tables/tests/TableSchemaTests.cpp +++ b/ThirdParty/custom-opm-parser/opm-parser/opm/parser/eclipse/EclipseState/Tables/tests/TableSchemaTests.cpp @@ -19,9 +19,7 @@ #define BOOST_TEST_MODULE TableSchemaTests -#include #include -#include #include diff --git a/ThirdParty/custom-opm-parser/opm-parser/opm/parser/eclipse/EclipseState/checkDeck.cpp b/ThirdParty/custom-opm-parser/opm-parser/opm/parser/eclipse/EclipseState/checkDeck.cpp index 79b3a19c8d..deefc86c49 100644 --- a/ThirdParty/custom-opm-parser/opm-parser/opm/parser/eclipse/EclipseState/checkDeck.cpp +++ b/ThirdParty/custom-opm-parser/opm-parser/opm/parser/eclipse/EclipseState/checkDeck.cpp @@ -33,7 +33,7 @@ bool checkDeck(DeckConstPtr deck, ParserConstPtr parser, size_t enabledChecks) { const auto& keyword = deck->getKeyword(keywordIdx); if (!parser->isRecognizedKeyword( keyword.name() ) ) { std::string msg("Keyword '" + keyword.name() + "' is unknown."); - deck->getMessageContainer().warning(keyword.getFileName(), msg,keyword.getLineNumber()); + deck->getMessageContainer().warning(msg, keyword.getFileName(), keyword.getLineNumber()); deckValid = false; } } diff --git a/ThirdParty/custom-opm-parser/opm-parser/opm/parser/eclipse/EclipseState/tests/Eclipse3DPropertiesTests.cpp b/ThirdParty/custom-opm-parser/opm-parser/opm/parser/eclipse/EclipseState/tests/Eclipse3DPropertiesTests.cpp index cd2b3aa554..95b1ba4312 100644 --- a/ThirdParty/custom-opm-parser/opm-parser/opm/parser/eclipse/EclipseState/tests/Eclipse3DPropertiesTests.cpp +++ b/ThirdParty/custom-opm-parser/opm-parser/opm/parser/eclipse/EclipseState/tests/Eclipse3DPropertiesTests.cpp @@ -23,10 +23,8 @@ #define BOOST_TEST_MODULE Eclipse3DPropertiesTests -#include #include #include -#include #include #include @@ -46,6 +44,14 @@ static Opm::DeckPtr createDeck() { "DIMENS\n" " 10 10 10 /\n" "GRID\n" + "DX\n" + "1000*0.25 /\n" + "DY\n" + "1000*0.25 /\n" + "DZ\n" + "1000*0.25 /\n" + "TOPS\n" + "100*0.25 /\n" "FAULTS \n" " 'F1' 1 1 1 4 1 4 'X' / \n" " 'F2' 5 5 1 4 1 4 'X-' / \n" @@ -74,6 +80,8 @@ static Opm::DeckPtr createDeck() { return parser->parseString(deckData, Opm::ParseContext()); } + + static Opm::DeckPtr createValidIntDeck() { const char *deckData = "RUNSPEC\n" "GRIDOPTS\n" @@ -82,6 +90,14 @@ static Opm::DeckPtr createValidIntDeck() { "DIMENS\n" " 5 5 1 /\n" "GRID\n" + "DX\n" + "25*0.25 /\n" + "DY\n" + "25*0.25 /\n" + "DZ\n" + "25*0.25 /\n" + "TOPS\n" + "25*0.25 /\n" "MULTNUM \n" "1 1 2 2 2\n" "1 1 2 2 2\n" @@ -111,6 +127,14 @@ static Opm::DeckPtr createValidPERMXDeck() { "DIMENS\n" " 5 5 1 /\n" "GRID\n" + "DX\n" + "25*0.25 /\n" + "DY\n" + "25*0.25 /\n" + "DZ\n" + "25*0.25 /\n" + "TOPS\n" + "25*0.25 /\n" "MULTNUM \n" "1 1 2 2 2\n" "1 1 2 2 2\n" @@ -131,8 +155,8 @@ static Opm::DeckPtr createValidPERMXDeck() { "PERMX\n" "25*1 /\n" "ADDREG\n" - " PERMX 1 1 / \n" - " PERMX 3 2 / \n" + "'PermX ' 1 1 / \n" + "PErmX 3 2 / \n" "/\n" "EDIT\n" "\n"; @@ -210,7 +234,6 @@ BOOST_AUTO_TEST_CASE(IntGridProperty) { BOOST_AUTO_TEST_CASE(AddregIntSetCorrectly) { Opm::DeckPtr deck = createValidIntDeck(); Setup s(deck); - const auto& property = s.props.getIntGridProperty("SATNUM"); for (size_t j = 0; j < 5; j++) for (size_t i = 0; i < 5; i++) { @@ -236,6 +259,33 @@ BOOST_AUTO_TEST_CASE(PermxUnitAppliedCorrectly) { } } +BOOST_AUTO_TEST_CASE(DoubleIterator) { + Opm::DeckPtr deck = createValidPERMXDeck(); + Setup s(deck); + const auto& doubleProperties = s.props.getDoubleProperties(); + std::vector kw_list; + for (const auto& prop : doubleProperties ) + kw_list.push_back( prop.getKeywordName() ); + + BOOST_CHECK_EQUAL( 2 , kw_list.size() ); + BOOST_CHECK( std::find( kw_list.begin() , kw_list.end() , "PERMX") != kw_list.end()); + BOOST_CHECK( std::find( kw_list.begin() , kw_list.end() , "PERMZ") != kw_list.end()); +} + + +BOOST_AUTO_TEST_CASE(IntIterator) { + Opm::DeckPtr deck = createValidPERMXDeck(); + Setup s(deck); + const auto& intProperties = s.props.getIntProperties(); + std::vector kw_list; + for (const auto& prop : intProperties ) + kw_list.push_back( prop.getKeywordName() ); + + BOOST_CHECK_EQUAL( 1 , kw_list.size() ); + BOOST_CHECK_EQUAL( kw_list[0] , "MULTNUM" ); +} + + BOOST_AUTO_TEST_CASE(getRegions) { const char* input = "START -- 0 \n" @@ -245,9 +295,14 @@ BOOST_AUTO_TEST_CASE(getRegions) { "DIMENS\n" " 2 2 1 /\n" "GRID\n" - "DXV \n 2*400 /\n" - "DYV \n 2*400 /\n" - "DZV \n 1*400 /\n" + "DX\n" + "4*0.25 /\n" + "DY\n" + "4*0.25 /\n" + "DZ\n" + "4*0.25 /\n" + "TOPS\n" + "4*0.25 /\n" "REGIONS\n" "FIPNUM\n" "1 1 2 3 /\n"; diff --git a/ThirdParty/custom-opm-parser/opm-parser/opm/parser/eclipse/EclipseState/tests/EclipseStateTests.cpp b/ThirdParty/custom-opm-parser/opm-parser/opm/parser/eclipse/EclipseState/tests/EclipseStateTests.cpp index d9bde9ac81..b81d92ca8e 100644 --- a/ThirdParty/custom-opm-parser/opm-parser/opm/parser/eclipse/EclipseState/tests/EclipseStateTests.cpp +++ b/ThirdParty/custom-opm-parser/opm-parser/opm/parser/eclipse/EclipseState/tests/EclipseStateTests.cpp @@ -23,10 +23,8 @@ along with OPM. If not, see . #define BOOST_TEST_MODULE EclipseStateTests -#include #include #include -#include #include #include @@ -97,7 +95,7 @@ return parser->parseString(deckData, ParseContext()) ; BOOST_AUTO_TEST_CASE(GetPOROTOPBased) { DeckPtr deck = createDeckTOP(); - EclipseState state(deck , ParseContext()); + EclipseState state(*deck , ParseContext()); const Eclipse3DProperties& props = state.get3DProperties(); const GridProperty& poro = props.getDoubleGridProperty( "PORO" ); @@ -118,6 +116,14 @@ const char *deckData = "DIMENS\n" " 10 10 10 /\n" "GRID\n" +"DX\n" +"1000*0.25 /\n" +"DY\n" +"1000*0.25 /\n" +"DZ\n" +"1000*0.25 /\n" +"TOPS\n" +"100*0.25 /\n" "FAULTS \n" " 'F1' 1 1 1 4 1 4 'X' / \n" " 'F2' 5 5 1 4 1 4 'X-' / \n" @@ -160,6 +166,14 @@ const char *deckData = "DIMENS\n" " 10 10 10 /\n" "GRID\n" +"DX\n" +"1000*0.25 /\n" +"DY\n" +"1000*0.25 /\n" +"DZ\n" +"1000*0.25 /\n" +"TOPS\n" +"100*0.25 /\n" "PROPS\n" "-- multiply one layer for each face\n" "MULTX\n" @@ -180,62 +194,67 @@ ParserPtr parser(new Parser()); return parser->parseString(deckData, ParseContext()) ; } - BOOST_AUTO_TEST_CASE(CreateSchedule) { -DeckPtr deck = createDeck(); -EclipseState state(deck , ParseContext()); -ScheduleConstPtr schedule = state.getSchedule(); -EclipseGridConstPtr eclipseGrid = state.getInputGrid(); + DeckPtr deck = createDeck(); + EclipseState state(*deck, ParseContext()); + ScheduleConstPtr schedule = state.getSchedule(); + EclipseGridConstPtr eclipseGrid = state.getInputGrid(); -BOOST_CHECK_EQUAL( schedule->getStartTime() , boost::posix_time::ptime(boost::gregorian::date(1998 , 3 , 8 ))); + BOOST_CHECK_EQUAL(schedule->getStartTime(), boost::posix_time::ptime(boost::gregorian::date(1998, 3, 8))); } static DeckPtr createDeckSimConfig() { const std::string& inputStr = "RUNSPEC\n" - "EQLOPTS\n" - "THPRES /\n " - "DIMENS\n" - "10 3 4 /\n" - "\n" - "GRID\n" - "REGIONS\n" - "EQLNUM\n" - "10*1 10*2 100*3 /\n " - "\n" - - "SOLUTION\n" - "THPRES\n" - "1 2 12.0/\n" - "1 3 5.0/\n" - "2 3 7.0/\n" - "/\n" - "\n"; + "EQLOPTS\n" + "THPRES /\n " + "DIMENS\n" + "10 3 4 /\n" + "\n" + "GRID\n" + "DX\n" + "120*0.25 /\n" + "DY\n" + "120*0.25 /\n" + "DZ\n" + "120*0.25 /\n" + "TOPS\n" + "30*0.25 /\n" + "REGIONS\n" + "EQLNUM\n" + "10*1 10*2 100*3 /\n " + "\n" + "SOLUTION\n" + "THPRES\n" + "1 2 12.0/\n" + "1 3 5.0/\n" + "2 3 7.0/\n" + "/\n" + "\n"; ParserPtr parser(new Parser()); return parser->parseString(inputStr, ParseContext()) ; } - BOOST_AUTO_TEST_CASE(CreateSimulationConfig) { -DeckPtr deck = createDeckSimConfig(); -EclipseState state(deck, ParseContext()); -SimulationConfigConstPtr simConf = state.getSimulationConfig(); + DeckPtr deck = createDeckSimConfig(); + EclipseState state(*deck, ParseContext()); + const auto& simConf = state.getSimulationConfig(); -BOOST_CHECK( simConf->hasThresholdPressure() ); + BOOST_CHECK(simConf.hasThresholdPressure()); -std::shared_ptr thresholdPressure = simConf->getThresholdPressure(); -BOOST_CHECK_EQUAL(thresholdPressure->size(), 3); + std::shared_ptr thresholdPressure = simConf.getThresholdPressure(); + BOOST_CHECK_EQUAL(thresholdPressure->size(), 3); } BOOST_AUTO_TEST_CASE(PhasesCorrect) { DeckPtr deck = createDeck(); - EclipseState state( deck, ParseContext() ); + EclipseState state( *deck, ParseContext() ); const auto& tm = state.getTableManager(); BOOST_CHECK( tm.hasPhase( Phase::PhaseEnum::OIL )); BOOST_CHECK( tm.hasPhase( Phase::PhaseEnum::GAS )); @@ -244,14 +263,14 @@ BOOST_AUTO_TEST_CASE(PhasesCorrect) { BOOST_AUTO_TEST_CASE(TitleCorrect) { DeckPtr deck = createDeck(); - EclipseState state( deck, ParseContext() ); + EclipseState state( *deck, ParseContext() ); BOOST_CHECK_EQUAL( state.getTitle(), "The title" ); } BOOST_AUTO_TEST_CASE(IntProperties) { DeckPtr deck = createDeck(); - EclipseState state( deck, ParseContext() ); + EclipseState state( *deck, ParseContext() ); BOOST_CHECK_EQUAL( false, state.get3DProperties().supportsGridProperty( "NONO" ) ); BOOST_CHECK_EQUAL( true, state.get3DProperties().supportsGridProperty( "SATNUM" ) ); @@ -261,7 +280,7 @@ BOOST_AUTO_TEST_CASE(IntProperties) { BOOST_AUTO_TEST_CASE(GetProperty) { DeckPtr deck = createDeck(); - EclipseState state(deck, ParseContext()); + EclipseState state(*deck, ParseContext()); const auto& satNUM = state.get3DProperties().getIntGridProperty( "SATNUM" ); @@ -269,21 +288,21 @@ BOOST_AUTO_TEST_CASE(GetProperty) { for (size_t i=0; i < satNUM.getCartesianSize(); i++) BOOST_CHECK_EQUAL( 2 , satNUM.iget(i) ); - BOOST_CHECK_THROW( satNUM.iget(100000) , std::invalid_argument); + BOOST_CHECK_THROW( satNUM.iget(100000) , std::out_of_range ); } BOOST_AUTO_TEST_CASE(GetTransMult) { DeckPtr deck = createDeck(); - EclipseState state( deck, ParseContext() ); - std::shared_ptr transMult = state.getTransMult(); + EclipseState state( *deck, ParseContext() ); + const auto& transMult = state.getTransMult(); - BOOST_CHECK_EQUAL( 1.0, transMult->getMultiplier( 1, 0, 0, FaceDir::XPlus ) ); - BOOST_CHECK_THROW( transMult->getMultiplier( 1000, FaceDir::XPlus ), std::invalid_argument ); + BOOST_CHECK_EQUAL( 1.0, transMult.getMultiplier( 1, 0, 0, FaceDir::XPlus ) ); + BOOST_CHECK_THROW( transMult.getMultiplier( 1000, FaceDir::XPlus ), std::invalid_argument ); } BOOST_AUTO_TEST_CASE(GetFaults) { DeckPtr deck = createDeck(); - EclipseState state( deck, ParseContext() ); + EclipseState state( *deck, ParseContext() ); const auto& faults = state.getFaults(); BOOST_CHECK( faults.hasFault( "F1" ) ); @@ -295,50 +314,50 @@ BOOST_AUTO_TEST_CASE(GetFaults) { BOOST_CHECK_EQUAL( 0.50, F1.getTransMult() ); BOOST_CHECK_EQUAL( 0.25, F2.getTransMult() ); - std::shared_ptr transMult = state.getTransMult(); - BOOST_CHECK_EQUAL( transMult->getMultiplier( 0, 0, 0, FaceDir::XPlus ), 0.50 ); - BOOST_CHECK_EQUAL( transMult->getMultiplier( 4, 3, 0, FaceDir::XMinus ), 0.25 ); - BOOST_CHECK_EQUAL( transMult->getMultiplier( 4, 3, 0, FaceDir::ZPlus ), 1.00 ); + const auto& transMult = state.getTransMult(); + BOOST_CHECK_EQUAL( transMult.getMultiplier( 0, 0, 0, FaceDir::XPlus ), 0.50 ); + BOOST_CHECK_EQUAL( transMult.getMultiplier( 4, 3, 0, FaceDir::XMinus ), 0.25 ); + BOOST_CHECK_EQUAL( transMult.getMultiplier( 4, 3, 0, FaceDir::ZPlus ), 1.00 ); } BOOST_AUTO_TEST_CASE(FaceTransMults) { DeckPtr deck = createDeckNoFaults(); - EclipseState state(deck, ParseContext()); - std::shared_ptr transMult = state.getTransMult(); + EclipseState state(*deck, ParseContext()); + const auto& transMult = state.getTransMult(); for (int i = 0; i < 10; ++ i) { for (int j = 0; j < 10; ++ j) { for (int k = 0; k < 10; ++ k) { if (k == 1) - BOOST_CHECK_EQUAL(transMult->getMultiplier(i, j, k, FaceDir::XPlus), 10.0); + BOOST_CHECK_EQUAL(transMult.getMultiplier(i, j, k, FaceDir::XPlus), 10.0); else - BOOST_CHECK_EQUAL(transMult->getMultiplier(i, j, k, FaceDir::XPlus), 1.0); + BOOST_CHECK_EQUAL(transMult.getMultiplier(i, j, k, FaceDir::XPlus), 1.0); if (k == 2) - BOOST_CHECK_EQUAL(transMult->getMultiplier(i, j, k, FaceDir::XMinus), 11.0); + BOOST_CHECK_EQUAL(transMult.getMultiplier(i, j, k, FaceDir::XMinus), 11.0); else - BOOST_CHECK_EQUAL(transMult->getMultiplier(i, j, k, FaceDir::XMinus), 1.0); + BOOST_CHECK_EQUAL(transMult.getMultiplier(i, j, k, FaceDir::XMinus), 1.0); if (k == 3) - BOOST_CHECK_EQUAL(transMult->getMultiplier(i, j, k, FaceDir::YPlus), 12.0); + BOOST_CHECK_EQUAL(transMult.getMultiplier(i, j, k, FaceDir::YPlus), 12.0); else - BOOST_CHECK_EQUAL(transMult->getMultiplier(i, j, k, FaceDir::YPlus), 1.0); + BOOST_CHECK_EQUAL(transMult.getMultiplier(i, j, k, FaceDir::YPlus), 1.0); if (k == 4) - BOOST_CHECK_EQUAL(transMult->getMultiplier(i, j, k, FaceDir::YMinus), 13.0); + BOOST_CHECK_EQUAL(transMult.getMultiplier(i, j, k, FaceDir::YMinus), 13.0); else - BOOST_CHECK_EQUAL(transMult->getMultiplier(i, j, k, FaceDir::YMinus), 1.0); + BOOST_CHECK_EQUAL(transMult.getMultiplier(i, j, k, FaceDir::YMinus), 1.0); if (k == 5) - BOOST_CHECK_EQUAL(transMult->getMultiplier(i, j, k, FaceDir::ZPlus), 14.0); + BOOST_CHECK_EQUAL(transMult.getMultiplier(i, j, k, FaceDir::ZPlus), 14.0); else - BOOST_CHECK_EQUAL(transMult->getMultiplier(i, j, k, FaceDir::ZPlus), 1.0); + BOOST_CHECK_EQUAL(transMult.getMultiplier(i, j, k, FaceDir::ZPlus), 1.0); if (k == 6) - BOOST_CHECK_EQUAL(transMult->getMultiplier(i, j, k, FaceDir::ZMinus), 15.0); + BOOST_CHECK_EQUAL(transMult.getMultiplier(i, j, k, FaceDir::ZMinus), 15.0); else - BOOST_CHECK_EQUAL(transMult->getMultiplier(i, j, k, FaceDir::ZMinus), 1.0); + BOOST_CHECK_EQUAL(transMult.getMultiplier(i, j, k, FaceDir::ZMinus), 1.0); } } } @@ -352,6 +371,14 @@ static DeckPtr createDeckNoGridOpts() { "DIMENS\n" " 10 10 10 /\n" "GRID\n" + "DX\n" + "1000*0.25 /\n" + "DY\n" + "1000*0.25 /\n" + "DZ\n" + "1000*0.25 /\n" + "TOPS\n" + "100*0.25 /\n" "FLUXNUM\n" " 1000*1 /\n" "MULTNUM\n" @@ -371,6 +398,14 @@ static DeckPtr createDeckWithGridOpts() { "DIMENS\n" " 10 10 10 /\n" "GRID\n" + "DX\n" + "1000*0.25 /\n" + "DY\n" + "1000*0.25 /\n" + "DZ\n" + "1000*0.25 /\n" + "TOPS\n" + "100*0.25 /\n" "FLUXNUM\n" " 1000*1 /\n" "MULTNUM\n" @@ -383,7 +418,7 @@ static DeckPtr createDeckWithGridOpts() { BOOST_AUTO_TEST_CASE(NoGridOptsDefaultRegion) { DeckPtr deck = createDeckNoGridOpts(); - EclipseState state(deck, ParseContext()); + EclipseState state(*deck, ParseContext()); const auto& props = state.get3DProperties(); const auto& multnum = props.getIntGridProperty("MULTNUM"); const auto& fluxnum = props.getIntGridProperty("FLUXNUM"); @@ -397,7 +432,7 @@ BOOST_AUTO_TEST_CASE(NoGridOptsDefaultRegion) { BOOST_AUTO_TEST_CASE(WithGridOptsDefaultRegion) { DeckPtr deck = createDeckWithGridOpts(); - EclipseState state(deck, ParseContext()); + EclipseState state(*deck, ParseContext()); const auto& props = state.get3DProperties(); const auto& multnum = props.getIntGridProperty("MULTNUM"); const auto& fluxnum = props.getIntGridProperty("FLUXNUM"); @@ -413,14 +448,16 @@ BOOST_AUTO_TEST_CASE(TestIOConfigBaseName) { ParserPtr parser(new Parser()); DeckConstPtr deck = parser->parseFile("testdata/integration_tests/IOConfig/SPE1CASE2.DATA", parseContext); EclipseState state(*deck, parseContext); - BOOST_CHECK_EQUAL(state.getIOConfig()->getBaseName(), "SPE1CASE2"); - BOOST_CHECK_EQUAL(state.getIOConfig()->getOutputDir(), "testdata/integration_tests/IOConfig"); + const auto& io = state.cfg().io(); + BOOST_CHECK_EQUAL(io.getBaseName(), "SPE1CASE2"); + BOOST_CHECK_EQUAL(io.getOutputDir(), "testdata/integration_tests/IOConfig"); ParserPtr parser2(new Parser()); DeckConstPtr deck2 = createDeckWithGridOpts(); EclipseState state2(*deck2, parseContext); - BOOST_CHECK_EQUAL(state2.getIOConfig()->getBaseName(), ""); - BOOST_CHECK_EQUAL(state2.getIOConfig()->getOutputDir(), "."); + const auto& io2 = state2.cfg().io(); + BOOST_CHECK_EQUAL(io2.getBaseName(), ""); + BOOST_CHECK_EQUAL(io2.getOutputDir(), "."); } BOOST_AUTO_TEST_CASE(TestIOConfigCreation) { @@ -432,6 +469,14 @@ BOOST_AUTO_TEST_CASE(TestIOConfigCreation) { "DIMENS\n" " 10 10 10 /\n" "GRID\n" + "DX\n" + "1000*0.25 /\n" + "DY\n" + "1000*0.25 /\n" + "DZ\n" + "1000*0.25 /\n" + "TOPS\n" + "100*0.25 /\n" "START -- 0 \n" "19 JUN 2007 / \n" "SCHEDULE\n" @@ -450,14 +495,14 @@ BOOST_AUTO_TEST_CASE(TestIOConfigCreation) { ParserPtr parser(new Parser()); DeckPtr deck = parser->parseString(deckData, ParseContext()) ; - EclipseState state(deck , ParseContext()); + EclipseState state(*deck , ParseContext()); - IOConfigConstPtr ioConfig = state.getIOConfigConst(); + const RestartConfig& rstConfig = state.cfg().restart(); - BOOST_CHECK_EQUAL(false, ioConfig->getWriteRestartFile(0)); - BOOST_CHECK_EQUAL(false, ioConfig->getWriteRestartFile(1)); - BOOST_CHECK_EQUAL(true, ioConfig->getWriteRestartFile(2)); - BOOST_CHECK_EQUAL(false, ioConfig->getWriteRestartFile(3)); + BOOST_CHECK_EQUAL(false, rstConfig.getWriteRestartFile(0)); + BOOST_CHECK_EQUAL(false, rstConfig.getWriteRestartFile(1)); + BOOST_CHECK_EQUAL(true, rstConfig.getWriteRestartFile(2)); + BOOST_CHECK_EQUAL(false, rstConfig.getWriteRestartFile(3)); } @@ -469,6 +514,14 @@ BOOST_AUTO_TEST_CASE(TestIOConfigCreationWithSolutionRPTRST) { "\n" "DIMENS\n" " 10 10 10 /\n" + "DX\n" + "1000*0.25 /\n" + "DY\n" + "1000*0.25 /\n" + "DZ\n" + "1000*0.25 /\n" + "TOPS\n" + "100*0.25 /\n" "SOLUTION\n" "RPTRST\n" "BASIC=1/\n" @@ -493,14 +546,14 @@ BOOST_AUTO_TEST_CASE(TestIOConfigCreationWithSolutionRPTRST) { ParseContext parseContext; ParserPtr parser(new Parser()); DeckPtr deck = parser->parseString(deckData, parseContext) ; - EclipseState state(deck, parseContext); + EclipseState state(*deck, parseContext); - IOConfigConstPtr ioConfig = state.getIOConfigConst(); + const RestartConfig& rstConfig = state.cfg().restart(); - BOOST_CHECK_EQUAL(true , ioConfig->getWriteRestartFile(0)); - BOOST_CHECK_EQUAL(false , ioConfig->getWriteRestartFile(1)); - BOOST_CHECK_EQUAL(false , ioConfig->getWriteRestartFile(2)); - BOOST_CHECK_EQUAL(false , ioConfig->getWriteRestartFile(3)); + BOOST_CHECK_EQUAL(true , rstConfig.getWriteRestartFile(0)); + BOOST_CHECK_EQUAL(false , rstConfig.getWriteRestartFile(1)); + BOOST_CHECK_EQUAL(false , rstConfig.getWriteRestartFile(2)); + BOOST_CHECK_EQUAL(false , rstConfig.getWriteRestartFile(3)); } @@ -511,6 +564,14 @@ BOOST_AUTO_TEST_CASE(TestIOConfigCreationWithSolutionRPTSOL) { "DIMENS\n" " 10 10 10 /\n" "GRID\n" + "DX\n" + "1000*0.25 /\n" + "DY\n" + "1000*0.25 /\n" + "DZ\n" + "1000*0.25 /\n" + "TOPS\n" + "100*0.25 /\n" "SOLUTION\n" "RPTSOL\n" "RESTART=2\n" @@ -539,6 +600,14 @@ BOOST_AUTO_TEST_CASE(TestIOConfigCreationWithSolutionRPTSOL) { "DIMENS\n" " 10 10 10 /\n" "GRID\n" + "DX\n" + "1000*0.25 /\n" + "DY\n" + "1000*0.25 /\n" + "DZ\n" + "1000*0.25 /\n" + "TOPS\n" + "100*0.25 /\n" "SOLUTION\n" "RPTSOL\n" "0 0 0 0 0 0 2\n" @@ -568,19 +637,19 @@ BOOST_AUTO_TEST_CASE(TestIOConfigCreationWithSolutionRPTSOL) { { //mnemnonics DeckPtr deck = parser->parseString(deckData, parseContext) ; - EclipseState state(deck, parseContext); + EclipseState state(*deck, parseContext); - IOConfigConstPtr ioConfig = state.getIOConfigConst(); + const RestartConfig& rstConfig = state.cfg().restart(); - BOOST_CHECK_EQUAL(true, ioConfig->getWriteRestartFile(0)); + BOOST_CHECK_EQUAL(true, rstConfig.getWriteRestartFile(0)); } { //old fashion integer mnemonics DeckPtr deck = parser->parseString(deckData2, parseContext) ; - EclipseState state(deck, parseContext); + EclipseState state(*deck, parseContext); - IOConfigConstPtr ioConfig = state.getIOConfigConst(); + const RestartConfig& rstConfig = state.cfg().restart(); - BOOST_CHECK_EQUAL(true, ioConfig->getWriteRestartFile(0)); + BOOST_CHECK_EQUAL(true, rstConfig.getWriteRestartFile(0)); } } diff --git a/ThirdParty/custom-opm-parser/opm-parser/opm/parser/eclipse/Generator/KeywordGenerator.cpp b/ThirdParty/custom-opm-parser/opm-parser/opm/parser/eclipse/Generator/KeywordGenerator.cpp index f52cf6d095..ebac3b1b9e 100644 --- a/ThirdParty/custom-opm-parser/opm-parser/opm/parser/eclipse/Generator/KeywordGenerator.cpp +++ b/ThirdParty/custom-opm-parser/opm-parser/opm/parser/eclipse/Generator/KeywordGenerator.cpp @@ -30,6 +30,40 @@ #include #include #include + + +namespace { + +const std::string testHeader = + "#define BOOST_TEST_MODULE ParserRecordTests\n" + "#include \n" + "#include \n" + "#include \n" + "#include \n" + "#include \n" + "#include \n" + "#include \n" + "#include \n" + "#include \n" + "#include \n" + "#include \n" + "#include \n" + "using namespace Opm;\n" + "std::shared_ptr unitSystem( UnitSystem::newMETRIC() );\n"; + +const std::string sourceHeader = + "#include \n" + "#include \n" + "#include \n" + "#include \n" + "#include \n" + "#include \n" + "#include \n" + "#include \n\n\n" + "namespace Opm {\n" + "namespace ParserKeywords {\n\n"; +} + namespace Opm { KeywordGenerator::KeywordGenerator(bool verbose) @@ -37,45 +71,6 @@ namespace Opm { { } - - - - std::string testHeader() { - std::string header = "#define BOOST_TEST_MODULE ParserRecordTests\n" - "#include \n" - "#include \n" - "#include \n" - "#include \n" - "#include \n" - "#include \n" - "#include \n" - "#include \n" - "#include \n" - "#include \n" - "#include \n" - "#include \n" - "using namespace Opm;\n" - "std::shared_ptr unitSystem( UnitSystem::newMETRIC() );\n"; - - return header; - } - - - std::string KeywordGenerator::sourceHeader() { - std::string header = "#include \n" - "#include \n" - "#include \n" - "#include \n" - "#include \n" - "#include \n" - "#include \n" - "#include \n\n\n" - "namespace Opm {\n" - "namespace ParserKeywords {\n\n"; - - return header; - } - std::string KeywordGenerator::headerHeader(const std::string& suffix) { std::string header = "#ifndef PARSER_KEYWORDS_" + suffix + "_HPP\n" "#define PARSER_KEYWORDS_" + suffix + "_HPP\n" @@ -136,7 +131,8 @@ namespace Opm { std::vector< std::stringstream > streams( blocks ); for( unsigned int i = 0; i < streams.size(); ++i ) - streams[ i ] << sourceHeader() << std::endl + streams[ i ] << sourceHeader << std::endl + << "void addDefaultKeywords" << i << "(Parser& p);" << std::endl << "void addDefaultKeywords" << i << "(Parser& p) {" << std::endl; int bi = 0; @@ -153,7 +149,7 @@ namespace Opm { updateFile( streams[i], srcfile.insert( srcfile.size() - 4, std::to_string( i ) ) ); } - newSource << sourceHeader(); + newSource << sourceHeader; for (auto iter = loader.keyword_begin(); iter != loader.keyword_end(); ++iter) { std::shared_ptr keyword = (*iter).second; newSource << keyword->createCode() << std::endl; @@ -226,7 +222,7 @@ namespace Opm { bool KeywordGenerator::updateTest(const KeywordLoader& loader , const std::string& testFile) const { std::stringstream stream; - stream << testHeader(); + stream << testHeader; for (auto iter = loader.keyword_begin(); iter != loader.keyword_end(); ++iter) { const std::string& keywordName = (*iter).first; std::shared_ptr keyword = (*iter).second; diff --git a/ThirdParty/custom-opm-parser/opm-parser/opm/parser/eclipse/Generator/KeywordGenerator.hpp b/ThirdParty/custom-opm-parser/opm-parser/opm/parser/eclipse/Generator/KeywordGenerator.hpp index db9491ba88..d265bd57a1 100644 --- a/ThirdParty/custom-opm-parser/opm-parser/opm/parser/eclipse/Generator/KeywordGenerator.hpp +++ b/ThirdParty/custom-opm-parser/opm-parser/opm/parser/eclipse/Generator/KeywordGenerator.hpp @@ -35,7 +35,6 @@ namespace Opm { static void ensurePath( const std::string& file_name); static std::string endTest(); static std::string startTest(const std::string& test_name); - static std::string sourceHeader(); static std::string headerHeader( const std::string& ); static bool updateFile(const std::stringstream& newContent, const std::string& filename); diff --git a/ThirdParty/custom-opm-parser/opm-parser/opm/parser/eclipse/Generator/tests/KeywordLoaderTests.cpp b/ThirdParty/custom-opm-parser/opm-parser/opm/parser/eclipse/Generator/tests/KeywordLoaderTests.cpp index 54dbc90ac5..bd3ee48cbc 100644 --- a/ThirdParty/custom-opm-parser/opm-parser/opm/parser/eclipse/Generator/tests/KeywordLoaderTests.cpp +++ b/ThirdParty/custom-opm-parser/opm-parser/opm/parser/eclipse/Generator/tests/KeywordLoaderTests.cpp @@ -23,11 +23,9 @@ #define BOOST_TEST_MODULE InputKeywordTests -#include #include #include #include -#include #include @@ -84,9 +82,11 @@ BOOST_AUTO_TEST_CASE(DirectorySort) { BOOST_CHECK_THROW( Opm::KeywordLoader::sortSubdirectories( "testdata/parser/keyword-generator/loader/ZCORN") , std::invalid_argument ); std::vector dir_list = Opm::KeywordLoader::sortSubdirectories( "testdata/parser/keyword-generator/loader"); + namespace fs = boost::filesystem; + BOOST_CHECK_EQUAL( 2U , dir_list.size()); - BOOST_CHECK_EQUAL( dir_list[0] , "testdata/parser/keyword-generator/loader/001_ECLIPSE100"); - BOOST_CHECK_EQUAL( dir_list[1] , "testdata/parser/keyword-generator/loader/002_ECLIPSE300"); + BOOST_CHECK_EQUAL( fs::path( dir_list[0] ), fs::path( "testdata/parser/keyword-generator/loader/001_ECLIPSE100" ) ); + BOOST_CHECK_EQUAL( fs::path( dir_list[1] ), fs::path( "testdata/parser/keyword-generator/loader/002_ECLIPSE300" ) ); } diff --git a/ThirdParty/custom-opm-parser/opm-parser/opm/parser/eclipse/IntegrationTests/BoxTest.cpp b/ThirdParty/custom-opm-parser/opm-parser/opm/parser/eclipse/IntegrationTests/BoxTest.cpp index 0561b5dfb6..603215c594 100644 --- a/ThirdParty/custom-opm-parser/opm-parser/opm/parser/eclipse/IntegrationTests/BoxTest.cpp +++ b/ThirdParty/custom-opm-parser/opm-parser/opm/parser/eclipse/IntegrationTests/BoxTest.cpp @@ -19,10 +19,8 @@ #define BOOST_TEST_MODULE BoxTest -#include #include #include -#include #include @@ -44,7 +42,7 @@ EclipseState makeState(const std::string& fileName) { ParserPtr parser(new Parser( )); boost::filesystem::path boxFile(fileName); DeckPtr deck = parser->parseFile(boxFile.string(), ParseContext()); - EclipseState state(deck , ParseContext()); + EclipseState state(*deck , ParseContext()); return state; } diff --git a/ThirdParty/custom-opm-parser/opm-parser/opm/parser/eclipse/IntegrationTests/CMakeLists.txt b/ThirdParty/custom-opm-parser/opm-parser/opm/parser/eclipse/IntegrationTests/CMakeLists.txt index 656dae270a..30d66accc1 100644 --- a/ThirdParty/custom-opm-parser/opm-parser/opm/parser/eclipse/IntegrationTests/CMakeLists.txt +++ b/ThirdParty/custom-opm-parser/opm-parser/opm/parser/eclipse/IntegrationTests/CMakeLists.txt @@ -29,7 +29,8 @@ if (HAVE_OPM_DATA) ${OPM_DATA_ROOT}/spe9/SPE9_CP_GROUP.DATA ${OPM_DATA_ROOT}/spe9/SPE9.DATA ${OPM_DATA_ROOT}/spe10model1/SPE10_MODEL1.DATA - ${OPM_DATA_ROOT}/spe10model2/SPE10_MODEL2.DATA ) + ${OPM_DATA_ROOT}/spe10model2/SPE10_MODEL2.DATA + ${OPM_DATA_ROOT}/wells_test_suite/MSW/2D_H__/2D_H__.DATA ) get_filename_component( test_name ${test_deck} NAME_WE ) add_test( NAME ${test_name} COMMAND opmi ${test_deck}) endforeach() diff --git a/ThirdParty/custom-opm-parser/opm-parser/opm/parser/eclipse/IntegrationTests/CompletionsFromDeck.cpp b/ThirdParty/custom-opm-parser/opm-parser/opm/parser/eclipse/IntegrationTests/CompletionsFromDeck.cpp index b3d240cbc9..f52b2a46b1 100644 --- a/ThirdParty/custom-opm-parser/opm-parser/opm/parser/eclipse/IntegrationTests/CompletionsFromDeck.cpp +++ b/ThirdParty/custom-opm-parser/opm-parser/opm/parser/eclipse/IntegrationTests/CompletionsFromDeck.cpp @@ -19,84 +19,32 @@ #define BOOST_TEST_MODULE CompletionIntegrationTests - -#include -#include - #include -#include -#include -#include #include #include -#include #include #include #include #include - +#include +#include using namespace Opm; - -BOOST_AUTO_TEST_CASE( CreateCompletionsFromRecord ) { - - ParserPtr parser(new Parser()); - boost::filesystem::path scheduleFile("testdata/integration_tests/SCHEDULE/SCHEDULE_COMPDAT1"); - DeckPtr deck = parser->parseFile(scheduleFile.string(), ParseContext()); - const auto& COMPDAT1 = deck->getKeyword("COMPDAT" , 0); - const auto& line0 = COMPDAT1.getRecord(0); - const auto& line1 = COMPDAT1.getRecord(1); - - std::pair< std::string , std::vector > completionsList = Completion::completionsFromCOMPDATRecord( line0 ); - BOOST_CHECK_EQUAL( "W_1" , completionsList.first ); - BOOST_CHECK_EQUAL( 3U , completionsList.second.size() ); - - { - CompletionPtr completion0 = completionsList.second[0]; - CompletionPtr completion2 = completionsList.second[2]; - - BOOST_CHECK_EQUAL( 29 , completion0->getI() ); - BOOST_CHECK_EQUAL( 36 , completion0->getJ() ); - BOOST_CHECK_EQUAL( 0 , completion0->getK() ); - BOOST_CHECK_EQUAL( WellCompletion::OPEN , completion0->getState() ); - BOOST_CHECK_EQUAL( 3.8134259259259256e-12 , completion0->getConnectionTransmissibilityFactor() ); - BOOST_CHECK_EQUAL( WellCompletion::DirectionEnum::X, completion0->getDirection() ); - - BOOST_CHECK_EQUAL( 29 , completion2->getI() ); - BOOST_CHECK_EQUAL( 36 , completion2->getJ() ); - BOOST_CHECK_EQUAL( 2 , completion2->getK() ); - BOOST_CHECK_EQUAL( WellCompletion::OPEN , completion2->getState() ); - BOOST_CHECK_EQUAL( 3.8134259259259256e-12 , completion2->getConnectionTransmissibilityFactor() ); - BOOST_CHECK_EQUAL( WellCompletion::DirectionEnum::X, completion2->getDirection() ); - } - - { - std::pair > pair = Completion::completionsFromCOMPDATRecord( line1 ); - - // We try to get the numerical value of a default CF: - CompletionPtr comp = pair.second[0]; - /* - This statement gives a compilation error: - BOOST_CHECK_THROW( comp->getConnectionTransmissibilityFactor() , std::logical_error ); - */ - } -} - - - BOOST_AUTO_TEST_CASE( CreateCompletionsFromKeyword ) { ParserPtr parser(new Parser()); - boost::filesystem::path scheduleFile("testdata/integration_tests/SCHEDULE/SCHEDULE_COMPDAT1"); - DeckPtr deck = parser->parseFile(scheduleFile.string(), ParseContext()); + const auto scheduleFile = "testdata/integration_tests/SCHEDULE/SCHEDULE_COMPDAT1"; + DeckPtr deck = parser->parseFile(scheduleFile, ParseContext()); + EclipseGrid grid(10,10,10); + const Schedule schedule( ParseContext(), grid, *deck ); const auto& COMPDAT1 = deck->getKeyword("COMPDAT" , 1); - std::map< std::string , std::vector > completions = Completion::completionsFromCOMPDATKeyword( COMPDAT1 ); + const auto wells = schedule.getWells( 0 ); + auto completions = Completion::fromCOMPDAT( grid, COMPDAT1, wells ); BOOST_CHECK_EQUAL( 3U , completions.size() ); - BOOST_CHECK( completions.find("W_1") != completions.end() ); BOOST_CHECK( completions.find("W_2") != completions.end() ); BOOST_CHECK( completions.find("W_3") != completions.end() ); @@ -110,19 +58,29 @@ BOOST_AUTO_TEST_CASE( CreateCompletionsFromKeyword ) { CompletionConstPtr completion0 = W_3Completions[0]; CompletionConstPtr completion4 = W_3Completions[4]; - BOOST_CHECK_EQUAL( 30 , completion0->getI() ); - BOOST_CHECK_EQUAL( 17 , completion0->getJ() ); - BOOST_CHECK_EQUAL( 0 , completion0->getK() ); + BOOST_CHECK_EQUAL( 2 , completion0->getI() ); + BOOST_CHECK_EQUAL( 7 , completion0->getJ() ); + BOOST_CHECK_EQUAL( 0 , completion0->getK() ); BOOST_CHECK_EQUAL( WellCompletion::OPEN , completion0->getState() ); BOOST_CHECK_EQUAL( 3.1726851851851847e-12 , completion0->getConnectionTransmissibilityFactor() ); BOOST_CHECK_EQUAL( WellCompletion::DirectionEnum::Y, completion0->getDirection() ); - BOOST_CHECK_EQUAL( 30 , completion4->getI() ); - BOOST_CHECK_EQUAL( 16 , completion4->getJ() ); - BOOST_CHECK_EQUAL( 3 , completion4->getK() ); + BOOST_CHECK_EQUAL( 2 , completion4->getI() ); + BOOST_CHECK_EQUAL( 6 , completion4->getJ() ); + BOOST_CHECK_EQUAL( 3 , completion4->getK() ); BOOST_CHECK_EQUAL( WellCompletion::OPEN , completion4->getState() ); BOOST_CHECK_EQUAL( 5.4722222222222212e-13 , completion4->getConnectionTransmissibilityFactor() ); BOOST_CHECK_EQUAL( WellCompletion::DirectionEnum::Y, completion4->getDirection() ); + + + // Check that wells with all completions shut is also itself shut + const Well* well1 = schedule.getWell("W_1"); + BOOST_CHECK (!well1->getCompletions(0)->allCompletionsShut()); + BOOST_CHECK_EQUAL (well1->getStatus(0) , WellCommon::StatusEnum::OPEN); + + const Well* well2 = schedule.getWell("W_2"); + BOOST_CHECK (well2->getCompletions(0)->allCompletionsShut()); + BOOST_CHECK_EQUAL (well2->getStatus(0) , WellCommon::StatusEnum::SHUT); + + } - - diff --git a/ThirdParty/custom-opm-parser/opm-parser/opm/parser/eclipse/IntegrationTests/EclipseGridCreateFromDeck.cpp b/ThirdParty/custom-opm-parser/opm-parser/opm/parser/eclipse/IntegrationTests/EclipseGridCreateFromDeck.cpp index a8f47cc3af..2598402ed0 100644 --- a/ThirdParty/custom-opm-parser/opm-parser/opm/parser/eclipse/IntegrationTests/EclipseGridCreateFromDeck.cpp +++ b/ThirdParty/custom-opm-parser/opm-parser/opm/parser/eclipse/IntegrationTests/EclipseGridCreateFromDeck.cpp @@ -40,7 +40,7 @@ BOOST_AUTO_TEST_CASE(CreateCPGrid) { ParserPtr parser(new Parser()); boost::filesystem::path scheduleFile("testdata/integration_tests/GRID/CORNERPOINT.DATA"); DeckPtr deck = parser->parseFile(scheduleFile.string(), ParseContext()); - EclipseState es(deck, ParseContext()); + EclipseState es(*deck, ParseContext()); auto grid = es.getInputGrid(); BOOST_CHECK_EQUAL( 10U , grid->getNX( )); @@ -54,7 +54,7 @@ BOOST_AUTO_TEST_CASE(CreateCPActnumGrid) { ParserPtr parser(new Parser()); boost::filesystem::path scheduleFile("testdata/integration_tests/GRID/CORNERPOINT_ACTNUM.DATA"); DeckPtr deck = parser->parseFile(scheduleFile.string(), ParseContext()); - EclipseState es(deck, ParseContext()); + EclipseState es(*deck, ParseContext()); auto grid = es.getInputGrid(); BOOST_CHECK_EQUAL( 10U , grid->getNX( )); @@ -68,7 +68,7 @@ BOOST_AUTO_TEST_CASE(ExportFromCPGridAllActive) { ParserPtr parser(new Parser()); boost::filesystem::path scheduleFile("testdata/integration_tests/GRID/CORNERPOINT.DATA"); DeckPtr deck = parser->parseFile(scheduleFile.string(), ParseContext()); - EclipseState es(deck, ParseContext()); + EclipseState es(*deck, ParseContext()); auto grid = es.getInputGrid(); std::vector actnum; @@ -85,7 +85,7 @@ BOOST_AUTO_TEST_CASE(ExportFromCPGridACTNUM) { ParserPtr parser(new Parser()); boost::filesystem::path scheduleFile("testdata/integration_tests/GRID/CORNERPOINT_ACTNUM.DATA"); DeckPtr deck = parser->parseFile(scheduleFile.string(), ParseContext()); - EclipseState es(deck, ParseContext()); + EclipseState es(*deck, ParseContext()); auto grid = es.getInputGrid(); std::vector coord; diff --git a/ThirdParty/custom-opm-parser/opm-parser/opm/parser/eclipse/IntegrationTests/IOConfigIntegrationTest.cpp b/ThirdParty/custom-opm-parser/opm-parser/opm/parser/eclipse/IntegrationTests/IOConfigIntegrationTest.cpp index 39f5c0dd6d..c327b9ec73 100644 --- a/ThirdParty/custom-opm-parser/opm-parser/opm/parser/eclipse/IntegrationTests/IOConfigIntegrationTest.cpp +++ b/ThirdParty/custom-opm-parser/opm-parser/opm/parser/eclipse/IntegrationTests/IOConfigIntegrationTest.cpp @@ -28,7 +28,7 @@ #include #include #include -#include +#include #include #include #include @@ -36,24 +36,21 @@ using namespace Opm; - -void verifyRestartConfig(IOConfigConstPtr ioconfig, std::vector>& rptConfig) { +inline void verifyRestartConfig( const RestartConfig& rst, std::vector>& rptConfig) { for (auto rptrst : rptConfig) { int report_step = std::get<0>(rptrst); bool save = std::get<1>(rptrst); boost::gregorian::date report_date = std::get<2>(rptrst); - BOOST_CHECK_EQUAL( save , ioconfig->getWriteRestartFile( report_step )); + BOOST_CHECK_EQUAL( save, rst.getWriteRestartFile( report_step ) ); if (save) { - BOOST_CHECK_EQUAL( report_date, ioconfig->getTimestepDate( report_step )); + BOOST_CHECK_EQUAL( report_date, rst.getTimestepDate( report_step )); } } } - - -BOOST_AUTO_TEST_CASE( NorneResttartConfig ) { +BOOST_AUTO_TEST_CASE( NorneRestartConfig ) { std::vector > rptConfig; rptConfig.push_back( std::make_tuple(0 , true , boost::gregorian::date( 1997,11,6)) ); rptConfig.push_back( std::make_tuple(1 , true , boost::gregorian::date( 1997,11,14)) ); @@ -300,7 +297,7 @@ BOOST_AUTO_TEST_CASE( NorneResttartConfig ) { auto state = Parser::parse("testdata/integration_tests/IOConfig/RPTRST_DECK.DATA"); - verifyRestartConfig(state.getIOConfigConst(), rptConfig); + verifyRestartConfig(state.cfg().restart(), rptConfig); } @@ -342,8 +339,17 @@ BOOST_AUTO_TEST_CASE( RestartConfig2 ) { ParserPtr parser(new Parser()); DeckConstPtr deck = parser->parseFile("testdata/integration_tests/IOConfig/RPT_TEST2.DATA", parseContext); EclipseState state( deck , parseContext ); - std::shared_ptr ioConfig = state.getIOConfigConst(); - verifyRestartConfig(ioConfig, rptConfig); + const auto& rstConfig = state.cfg().restart(); + verifyRestartConfig( rstConfig, rptConfig ); - BOOST_CHECK_EQUAL( ioConfig->getFirstRestartStep() , 0 ); + BOOST_CHECK_EQUAL( rstConfig.getFirstRestartStep() , 0 ); +} + + + +BOOST_AUTO_TEST_CASE( SPE9END ) { + ParseContext parseContext; + ParserPtr parser(new Parser()); + DeckConstPtr deck = parser->parseFile("testdata/integration_tests/IOConfig/SPE9_END.DATA", parseContext); + BOOST_CHECK_NO_THROW( EclipseState state( *deck , parseContext ) ); } diff --git a/ThirdParty/custom-opm-parser/opm-parser/opm/parser/eclipse/IntegrationTests/IncludeTest.cpp b/ThirdParty/custom-opm-parser/opm-parser/opm/parser/eclipse/IntegrationTests/IncludeTest.cpp index 21ed0da145..3efa318dd3 100644 --- a/ThirdParty/custom-opm-parser/opm-parser/opm/parser/eclipse/IntegrationTests/IncludeTest.cpp +++ b/ThirdParty/custom-opm-parser/opm-parser/opm/parser/eclipse/IntegrationTests/IncludeTest.cpp @@ -40,7 +40,8 @@ using namespace boost::filesystem; static void createDeckWithInclude(path& datafile, std::string addEndKeyword) { - path root = unique_path("/tmp/%%%%-%%%%"); + path tmpdir = temp_directory_path(); + path root = tmpdir / unique_path("%%%%-%%%%"); path absoluteInclude = root / "absolute.include"; path includePath1 = root / "include"; path includePath2 = root / "include2"; diff --git a/ThirdParty/custom-opm-parser/opm-parser/opm/parser/eclipse/IntegrationTests/IntegrationTests.cpp b/ThirdParty/custom-opm-parser/opm-parser/opm/parser/eclipse/IntegrationTests/IntegrationTests.cpp index 0971a9d1c2..e21f0b630b 100644 --- a/ThirdParty/custom-opm-parser/opm-parser/opm/parser/eclipse/IntegrationTests/IntegrationTests.cpp +++ b/ThirdParty/custom-opm-parser/opm-parser/opm/parser/eclipse/IntegrationTests/IntegrationTests.cpp @@ -37,6 +37,8 @@ using namespace Opm; +namespace { + std::unique_ptr< ParserKeyword > createFixedSized(const std::string& kw , size_t size) { std::unique_ptr< ParserKeyword > pkw( new ParserKeyword( kw ) ); pkw->setFixedSize( size ); @@ -49,7 +51,7 @@ std::unique_ptr< ParserKeyword > createDynamicSized(const std::string& kw) { return pkw; } -static ParserPtr createWWCTParser() { +ParserPtr createWWCTParser() { auto parserKeyword = createDynamicSized("WWCT"); { std::shared_ptr record = std::make_shared(); @@ -64,6 +66,8 @@ static ParserPtr createWWCTParser() { return parser; } +} + BOOST_AUTO_TEST_CASE(parse_fileWithWWCTKeyword_deckReturned) { boost::filesystem::path singleKeywordFile("testdata/integration_tests/wwct.data"); ParserPtr parser = createWWCTParser(); diff --git a/ThirdParty/custom-opm-parser/opm-parser/opm/parser/eclipse/IntegrationTests/NNCTests.cpp b/ThirdParty/custom-opm-parser/opm-parser/opm/parser/eclipse/IntegrationTests/NNCTests.cpp index 943ebee10f..faae9f277a 100644 --- a/ThirdParty/custom-opm-parser/opm-parser/opm/parser/eclipse/IntegrationTests/NNCTests.cpp +++ b/ThirdParty/custom-opm-parser/opm-parser/opm/parser/eclipse/IntegrationTests/NNCTests.cpp @@ -25,16 +25,9 @@ #include #include -#if HAVE_DYNAMIC_BOOST_TEST -#define BOOST_TEST_DYN_LINK -#endif -#define NVERBOSE // to suppress our messages when throwing - #define BOOST_TEST_MODULE NNCTests -#include #include -#include using namespace Opm; diff --git a/ThirdParty/custom-opm-parser/opm-parser/opm/parser/eclipse/IntegrationTests/ParseMULTREGT.cpp b/ThirdParty/custom-opm-parser/opm-parser/opm/parser/eclipse/IntegrationTests/ParseMULTREGT.cpp index 27bda51cf3..bb994031b4 100644 --- a/ThirdParty/custom-opm-parser/opm-parser/opm/parser/eclipse/IntegrationTests/ParseMULTREGT.cpp +++ b/ThirdParty/custom-opm-parser/opm-parser/opm/parser/eclipse/IntegrationTests/ParseMULTREGT.cpp @@ -51,50 +51,50 @@ BOOST_AUTO_TEST_CASE( MULTREGT_ECLIPSE_STATE ) { ParseContext parseContext; ParserPtr parser(new Parser()); DeckPtr deck = parser->parseFile("testdata/integration_tests/MULTREGT/MULTREGT.DATA", parseContext); - EclipseState state(deck , parseContext); + EclipseState state(*deck , parseContext); auto transMult = state.getTransMult(); // Test NONNC // cell 0 and 1 are neigbours - BOOST_CHECK_EQUAL( 0.10 , transMult->getRegionMultiplier( 0 , 1 , FaceDir::DirEnum::XPlus)); + BOOST_CHECK_EQUAL( 0.10 , transMult.getRegionMultiplier( 0 , 1 , FaceDir::DirEnum::XPlus)); // cell 0 and 3 are not neigbours ==> 1 - BOOST_CHECK_EQUAL( 1.00 , transMult->getRegionMultiplier( 0 , 3 , FaceDir::DirEnum::XPlus)); + BOOST_CHECK_EQUAL( 1.00 , transMult.getRegionMultiplier( 0 , 3 , FaceDir::DirEnum::XPlus)); // Test NNC // cell 4 and 5 are neigbours ==> 1 - BOOST_CHECK_EQUAL( 1.00 , transMult->getRegionMultiplier( 4 , 5 , FaceDir::DirEnum::XPlus)); + BOOST_CHECK_EQUAL( 1.00 , transMult.getRegionMultiplier( 4 , 5 , FaceDir::DirEnum::XPlus)); // cell 4 and 7 are not neigbours - BOOST_CHECK_EQUAL( 0.50 , transMult->getRegionMultiplier( 4 , 7 , FaceDir::DirEnum::XPlus)); + BOOST_CHECK_EQUAL( 0.50 , transMult.getRegionMultiplier( 4 , 7 , FaceDir::DirEnum::XPlus)); // Test direction X, returns 1 for directions other than +-X - BOOST_CHECK_EQUAL( 1.00 , transMult->getRegionMultiplier( 0 , 1 , FaceDir::DirEnum::YPlus)); - BOOST_CHECK_EQUAL( 1.00 , transMult->getRegionMultiplier( 0 , 1 , FaceDir::DirEnum::ZPlus)); - BOOST_CHECK_EQUAL( 0.10 , transMult->getRegionMultiplier( 0 , 1 , FaceDir::DirEnum::XMinus)); - BOOST_CHECK_EQUAL( 1.00 , transMult->getRegionMultiplier( 0 , 1 , FaceDir::DirEnum::YMinus)); - BOOST_CHECK_EQUAL( 1.00 , transMult->getRegionMultiplier( 0 , 1 , FaceDir::DirEnum::ZMinus)); - BOOST_CHECK_EQUAL( 0.20 , transMult->getRegionMultiplier( 1 , 0 , FaceDir::DirEnum::XPlus)); - BOOST_CHECK_EQUAL( 1.00 , transMult->getRegionMultiplier( 1 , 0 , FaceDir::DirEnum::YPlus)); - BOOST_CHECK_EQUAL( 1.00 , transMult->getRegionMultiplier( 1 , 0 , FaceDir::DirEnum::ZPlus)); - BOOST_CHECK_EQUAL( 0.20 , transMult->getRegionMultiplier( 1 , 0 , FaceDir::DirEnum::XMinus)); - BOOST_CHECK_EQUAL( 1.00 , transMult->getRegionMultiplier( 1 , 0 , FaceDir::DirEnum::YMinus)); - BOOST_CHECK_EQUAL( 1.00 , transMult->getRegionMultiplier( 1 , 0 , FaceDir::DirEnum::ZMinus)); + BOOST_CHECK_EQUAL( 1.00 , transMult.getRegionMultiplier( 0 , 1 , FaceDir::DirEnum::YPlus)); + BOOST_CHECK_EQUAL( 1.00 , transMult.getRegionMultiplier( 0 , 1 , FaceDir::DirEnum::ZPlus)); + BOOST_CHECK_EQUAL( 0.10 , transMult.getRegionMultiplier( 0 , 1 , FaceDir::DirEnum::XMinus)); + BOOST_CHECK_EQUAL( 1.00 , transMult.getRegionMultiplier( 0 , 1 , FaceDir::DirEnum::YMinus)); + BOOST_CHECK_EQUAL( 1.00 , transMult.getRegionMultiplier( 0 , 1 , FaceDir::DirEnum::ZMinus)); + BOOST_CHECK_EQUAL( 0.20 , transMult.getRegionMultiplier( 1 , 0 , FaceDir::DirEnum::XPlus)); + BOOST_CHECK_EQUAL( 1.00 , transMult.getRegionMultiplier( 1 , 0 , FaceDir::DirEnum::YPlus)); + BOOST_CHECK_EQUAL( 1.00 , transMult.getRegionMultiplier( 1 , 0 , FaceDir::DirEnum::ZPlus)); + BOOST_CHECK_EQUAL( 0.20 , transMult.getRegionMultiplier( 1 , 0 , FaceDir::DirEnum::XMinus)); + BOOST_CHECK_EQUAL( 1.00 , transMult.getRegionMultiplier( 1 , 0 , FaceDir::DirEnum::YMinus)); + BOOST_CHECK_EQUAL( 1.00 , transMult.getRegionMultiplier( 1 , 0 , FaceDir::DirEnum::ZMinus)); // Multipliers between cells of the same region should return 1 - BOOST_CHECK_EQUAL( 1.00 , transMult->getRegionMultiplier( 0 , 2 , FaceDir::DirEnum::XPlus)); - BOOST_CHECK_EQUAL( 1.00 , transMult->getRegionMultiplier( 2 , 0 , FaceDir::DirEnum::XPlus)); + BOOST_CHECK_EQUAL( 1.00 , transMult.getRegionMultiplier( 0 , 2 , FaceDir::DirEnum::XPlus)); + BOOST_CHECK_EQUAL( 1.00 , transMult.getRegionMultiplier( 2 , 0 , FaceDir::DirEnum::XPlus)); // Test direcion XYZ, returns values for all directions - BOOST_CHECK_EQUAL( 1.50 , transMult->getRegionMultiplier( 0 , 4 , FaceDir::DirEnum::XPlus)); - BOOST_CHECK_EQUAL( 1.50 , transMult->getRegionMultiplier( 0 , 4 , FaceDir::DirEnum::YPlus)); - BOOST_CHECK_EQUAL( 1.50 , transMult->getRegionMultiplier( 0 , 4 , FaceDir::DirEnum::ZPlus)); - BOOST_CHECK_EQUAL( 1.50 , transMult->getRegionMultiplier( 4 , 0 , FaceDir::DirEnum::XPlus)); + BOOST_CHECK_EQUAL( 1.50 , transMult.getRegionMultiplier( 0 , 4 , FaceDir::DirEnum::XPlus)); + BOOST_CHECK_EQUAL( 1.50 , transMult.getRegionMultiplier( 0 , 4 , FaceDir::DirEnum::YPlus)); + BOOST_CHECK_EQUAL( 1.50 , transMult.getRegionMultiplier( 0 , 4 , FaceDir::DirEnum::ZPlus)); + BOOST_CHECK_EQUAL( 1.50 , transMult.getRegionMultiplier( 4 , 0 , FaceDir::DirEnum::XPlus)); // The first record is overwritten by the second - BOOST_CHECK_EQUAL( 2.50 , transMult->getRegionMultiplier( 3 , 7 , FaceDir::DirEnum::XPlus)); - BOOST_CHECK_EQUAL( 2.50 , transMult->getRegionMultiplier( 3 , 7 , FaceDir::DirEnum::YPlus)); + BOOST_CHECK_EQUAL( 2.50 , transMult.getRegionMultiplier( 3 , 7 , FaceDir::DirEnum::XPlus)); + BOOST_CHECK_EQUAL( 2.50 , transMult.getRegionMultiplier( 3 , 7 , FaceDir::DirEnum::YPlus)); // The 2 4 0.75 Z input is overwritten by 2 4 2.5 XY, ==) that 2 4 Z returns the 4 2 value = 0.6 - BOOST_CHECK_EQUAL( 0.60 , transMult->getRegionMultiplier( 7 , 3 , FaceDir::DirEnum::XPlus)); - BOOST_CHECK_EQUAL( 0.60 , transMult->getRegionMultiplier( 3 , 7 , FaceDir::DirEnum::ZPlus)); + BOOST_CHECK_EQUAL( 0.60 , transMult.getRegionMultiplier( 7 , 3 , FaceDir::DirEnum::XPlus)); + BOOST_CHECK_EQUAL( 0.60 , transMult.getRegionMultiplier( 3 , 7 , FaceDir::DirEnum::ZPlus)); } diff --git a/ThirdParty/custom-opm-parser/opm-parser/opm/parser/eclipse/IntegrationTests/ParseMULTSEGWELL.cpp b/ThirdParty/custom-opm-parser/opm-parser/opm/parser/eclipse/IntegrationTests/ParseMULTSEGWELL.cpp index e4051d7759..54d2a1d6ee 100644 --- a/ThirdParty/custom-opm-parser/opm-parser/opm/parser/eclipse/IntegrationTests/ParseMULTSEGWELL.cpp +++ b/ThirdParty/custom-opm-parser/opm-parser/opm/parser/eclipse/IntegrationTests/ParseMULTSEGWELL.cpp @@ -20,10 +20,8 @@ #define BOOST_TEST_MODULE ParseMULTSEGWELL #include -#include #include #include -#include #include #include diff --git a/ThirdParty/custom-opm-parser/opm-parser/opm/parser/eclipse/IntegrationTests/ParseMiscible.cpp b/ThirdParty/custom-opm-parser/opm-parser/opm/parser/eclipse/IntegrationTests/ParseMiscible.cpp index cd97c139fc..b48e5778fe 100644 --- a/ThirdParty/custom-opm-parser/opm-parser/opm/parser/eclipse/IntegrationTests/ParseMiscible.cpp +++ b/ThirdParty/custom-opm-parser/opm-parser/opm/parser/eclipse/IntegrationTests/ParseMiscible.cpp @@ -19,10 +19,8 @@ #define BOOST_TEST_MODULE ParseMiscible #include -#include #include #include -#include #include #include diff --git a/ThirdParty/custom-opm-parser/opm-parser/opm/parser/eclipse/IntegrationTests/ParsePVTO.cpp b/ThirdParty/custom-opm-parser/opm-parser/opm/parser/eclipse/IntegrationTests/ParsePVTO.cpp index 4465dfdd78..12e0a6e93f 100644 --- a/ThirdParty/custom-opm-parser/opm-parser/opm/parser/eclipse/IntegrationTests/ParsePVTO.cpp +++ b/ThirdParty/custom-opm-parser/opm-parser/opm/parser/eclipse/IntegrationTests/ParsePVTO.cpp @@ -20,10 +20,8 @@ #define BOOST_TEST_MODULE ParserIntegrationTests #include -#include #include #include -#include #include #include diff --git a/ThirdParty/custom-opm-parser/opm-parser/opm/parser/eclipse/IntegrationTests/ParseSLGOF.cpp b/ThirdParty/custom-opm-parser/opm-parser/opm/parser/eclipse/IntegrationTests/ParseSLGOF.cpp index c4e171e4a3..db99e6c82a 100644 --- a/ThirdParty/custom-opm-parser/opm-parser/opm/parser/eclipse/IntegrationTests/ParseSLGOF.cpp +++ b/ThirdParty/custom-opm-parser/opm-parser/opm/parser/eclipse/IntegrationTests/ParseSLGOF.cpp @@ -19,10 +19,8 @@ #define BOOST_TEST_MODULE ParserIntegrationTests #include -#include #include #include -#include #include #include diff --git a/ThirdParty/custom-opm-parser/opm-parser/opm/parser/eclipse/IntegrationTests/ParseTOPS.cpp b/ThirdParty/custom-opm-parser/opm-parser/opm/parser/eclipse/IntegrationTests/ParseTOPS.cpp index 6409f2e114..3d9e58d1a2 100644 --- a/ThirdParty/custom-opm-parser/opm-parser/opm/parser/eclipse/IntegrationTests/ParseTOPS.cpp +++ b/ThirdParty/custom-opm-parser/opm-parser/opm/parser/eclipse/IntegrationTests/ParseTOPS.cpp @@ -20,10 +20,8 @@ #define BOOST_TEST_MODULE ParserIntegrationTests #include -#include #include #include -#include #include #include @@ -42,7 +40,7 @@ BOOST_AUTO_TEST_CASE( PARSE_TOPS_OK) { std::string deckFile("testdata/integration_tests/GRID/TOPS.DATA"); ParseContext parseContext; DeckPtr deck = parser->parseFile(deckFile, parseContext); - EclipseState state(deck , parseContext); + EclipseState state(*deck , parseContext); EclipseGridConstPtr grid = state.getInputGrid(); BOOST_CHECK_EQUAL( grid->getNX() , 9 ); diff --git a/ThirdParty/custom-opm-parser/opm-parser/opm/parser/eclipse/IntegrationTests/ParseVFPPROD.cpp b/ThirdParty/custom-opm-parser/opm-parser/opm/parser/eclipse/IntegrationTests/ParseVFPPROD.cpp index 72c4933463..227da0a248 100644 --- a/ThirdParty/custom-opm-parser/opm-parser/opm/parser/eclipse/IntegrationTests/ParseVFPPROD.cpp +++ b/ThirdParty/custom-opm-parser/opm-parser/opm/parser/eclipse/IntegrationTests/ParseVFPPROD.cpp @@ -20,10 +20,8 @@ #define BOOST_TEST_MODULE ParserIntegrationTests #include -#include #include #include -#include #include #include diff --git a/ThirdParty/custom-opm-parser/opm-parser/opm/parser/eclipse/IntegrationTests/ParseWellWithWildcards.cpp b/ThirdParty/custom-opm-parser/opm-parser/opm/parser/eclipse/IntegrationTests/ParseWellWithWildcards.cpp index 33f5b6fb77..75b1ef9bc2 100644 --- a/ThirdParty/custom-opm-parser/opm-parser/opm/parser/eclipse/IntegrationTests/ParseWellWithWildcards.cpp +++ b/ThirdParty/custom-opm-parser/opm-parser/opm/parser/eclipse/IntegrationTests/ParseWellWithWildcards.cpp @@ -42,7 +42,7 @@ BOOST_AUTO_TEST_CASE( parse_WCONPROD_OK ) { ParserPtr parser(new Parser()); std::string wconprodFile("testdata/integration_tests/WellWithWildcards/WCONPROD1"); DeckPtr deck = parser->parseFile(wconprodFile, ParseContext()); - std::shared_ptr grid = std::make_shared( 30,30,30); + EclipseGrid grid(30,30,30); SchedulePtr sched(new Schedule(ParseContext() , grid , deck )); BOOST_CHECK_EQUAL(5U, sched->numWells()); @@ -53,19 +53,19 @@ BOOST_AUTO_TEST_CASE( parse_WCONPROD_OK ) { BOOST_CHECK(sched->hasWell("PROX5")); { - WellPtr well = sched->getWell("PROD2"); + auto* well = sched->getWell("PROD2"); BOOST_CHECK_CLOSE(1000/Metric::Time, well->getProductionProperties(0).OilRate, 0.001); BOOST_CHECK_CLOSE(1500/Metric::Time, well->getProductionProperties(1).OilRate, 0.001); } { - WellPtr well = sched->getWell("PROD3"); + auto* well = sched->getWell("PROD3"); BOOST_CHECK_CLOSE(0/Metric::Time, well->getProductionProperties(0).OilRate, 0.001); BOOST_CHECK_CLOSE(1500/Metric::Time, well->getProductionProperties(1).OilRate, 0.001); } { - WellPtr well = sched->getWell("PROX5"); + auto* well = sched->getWell("PROX5"); BOOST_CHECK_CLOSE(2000/Metric::Time, well->getProductionProperties(0).OilRate, 0.001); BOOST_CHECK_CLOSE(2000/Metric::Time, well->getProductionProperties(1).OilRate, 0.001); } @@ -77,7 +77,7 @@ BOOST_AUTO_TEST_CASE( parse_WCONINJE_OK ) { ParserPtr parser(new Parser()); std::string wconprodFile("testdata/integration_tests/WellWithWildcards/WCONINJE1"); DeckPtr deck = parser->parseFile(wconprodFile, parseContext); - std::shared_ptr grid = std::make_shared( 30,30,30 ); + EclipseGrid grid(30,30,30); SchedulePtr sched(new Schedule(parseContext , grid , deck )); BOOST_CHECK_EQUAL(5U, sched->numWells()); @@ -88,19 +88,19 @@ BOOST_AUTO_TEST_CASE( parse_WCONINJE_OK ) { BOOST_CHECK(sched->hasWell("INJX5")); { - WellPtr well = sched->getWell("INJE2"); + auto* well = sched->getWell("INJE2"); BOOST_CHECK_CLOSE(1000/Metric::Time, well->getInjectionProperties(0).surfaceInjectionRate, 0.001); BOOST_CHECK_CLOSE(1500/Metric::Time, well->getInjectionProperties(1).surfaceInjectionRate, 0.001); } { - WellPtr well = sched->getWell("INJE3"); + auto* well = sched->getWell("INJE3"); BOOST_CHECK_CLOSE(0/Metric::Time, well->getInjectionProperties(0).surfaceInjectionRate, 0.001); BOOST_CHECK_CLOSE(1500/Metric::Time, well->getInjectionProperties(1).surfaceInjectionRate, 0.001); } { - WellPtr well = sched->getWell("INJX5"); + auto* well = sched->getWell("INJX5"); BOOST_CHECK_CLOSE(2000/Metric::Time, well->getInjectionProperties(0).surfaceInjectionRate, 0.001); BOOST_CHECK_CLOSE(2000/Metric::Time, well->getInjectionProperties(1).surfaceInjectionRate, 0.001); } diff --git a/ThirdParty/custom-opm-parser/opm-parser/opm/parser/eclipse/IntegrationTests/ResinsightTest.cpp b/ThirdParty/custom-opm-parser/opm-parser/opm/parser/eclipse/IntegrationTests/ResinsightTest.cpp index 3283c403ef..073044cbc9 100644 --- a/ThirdParty/custom-opm-parser/opm-parser/opm/parser/eclipse/IntegrationTests/ResinsightTest.cpp +++ b/ThirdParty/custom-opm-parser/opm-parser/opm/parser/eclipse/IntegrationTests/ResinsightTest.cpp @@ -17,7 +17,8 @@ along with OPM. If not, see . */ -#define BOOST_TEST_MODULE BoxTest +#define BOOST_TEST_MODULE ResinsightIntegrationTests + #include #include @@ -29,7 +30,7 @@ #include #include #include -#include +#include #include @@ -46,10 +47,18 @@ BOOST_AUTO_TEST_CASE( test_parse ) { parser.addKeyword(); parser.addKeyword(); - auto deck = parser.parseFile("testdata/integration_tests/Resinsight/DECK1.DATA" , parseContext); + auto deckptr = parser.parseFile("testdata/integration_tests/Resinsight/DECK1.DATA" , parseContext); + const Deck& deck = *deckptr; - BOOST_CHECK( deck->hasKeyword() ); - BOOST_CHECK( deck->hasKeyword() ); + BOOST_CHECK( deck.hasKeyword() ); + BOOST_CHECK( deck.hasKeyword() ); + + { + GridDims* grid = nullptr; + BOOST_CHECK_NO_THROW( grid = new GridDims(deck) ); + BOOST_CHECK_NO_THROW( grid->getCartesianSize() ); + delete grid; + } } @@ -64,9 +73,14 @@ BOOST_AUTO_TEST_CASE( test_state ) { parser.addKeyword(); parser.addKeyword(); parser.addKeyword(); - auto deck = parser.parseFile("testdata/integration_tests/Resinsight/DECK1.DATA" , parseContext); + auto deckptr = parser.parseFile("testdata/integration_tests/Resinsight/DECK1.DATA" , parseContext); + const Deck& deck = *deckptr; - auto grid = std::make_shared( deck ); - auto gsec = std::make_shared< GRIDSection >( *deck ); - auto faults = std::make_shared( gsec, grid ); + GridDims grid(deck); + GRIDSection gsec(deck); + FaultCollection faults(gsec, grid); + BOOST_CHECK_EQUAL( grid.getNX(), 20U); + BOOST_CHECK_EQUAL( grid.getNY(), 20U); + BOOST_CHECK_EQUAL( grid.getNZ(), 10U); + BOOST_CHECK_EQUAL( faults.size(), 2U); } diff --git a/ThirdParty/custom-opm-parser/opm-parser/opm/parser/eclipse/IntegrationTests/ScheduleCreateFromDeck.cpp b/ThirdParty/custom-opm-parser/opm-parser/opm/parser/eclipse/IntegrationTests/ScheduleCreateFromDeck.cpp index d3a1b321e8..5dfa640e7a 100644 --- a/ThirdParty/custom-opm-parser/opm-parser/opm/parser/eclipse/IntegrationTests/ScheduleCreateFromDeck.cpp +++ b/ThirdParty/custom-opm-parser/opm-parser/opm/parser/eclipse/IntegrationTests/ScheduleCreateFromDeck.cpp @@ -46,7 +46,7 @@ BOOST_AUTO_TEST_CASE(CreateSchedule) { ParserPtr parser(new Parser()); std::string scheduleFile("testdata/integration_tests/SCHEDULE/SCHEDULE1"); DeckPtr deck = parser->parseFile(scheduleFile, parseContext); - std::shared_ptr grid = std::make_shared(10,10,3); + EclipseGrid grid(10,10,10); SchedulePtr sched(new Schedule(parseContext , grid , deck )); TimeMapConstPtr timeMap = sched->getTimeMap(); BOOST_CHECK_EQUAL(boost::posix_time::ptime(boost::gregorian::date(2007, boost::gregorian::May, 10)), sched->getStartTime()); @@ -60,7 +60,7 @@ BOOST_AUTO_TEST_CASE(CreateSchedule_Comments_After_Keywords) { ParserPtr parser(new Parser()); std::string scheduleFile("testdata/integration_tests/SCHEDULE/SCHEDULE_COMMENTS_AFTER_KEYWORDS"); DeckPtr deck = parser->parseFile(scheduleFile, parseContext); - std::shared_ptr grid = std::make_shared(10,10,3); + EclipseGrid grid(10,10,10); SchedulePtr sched(new Schedule(parseContext , grid , deck )); TimeMapConstPtr timeMap = sched->getTimeMap(); BOOST_CHECK_EQUAL(boost::posix_time::ptime(boost::gregorian::date(2007, boost::gregorian::May, 10)), sched->getStartTime()); @@ -73,7 +73,7 @@ BOOST_AUTO_TEST_CASE(WCONPROD_MissingCmode) { ParserPtr parser(new Parser()); std::string scheduleFile("testdata/integration_tests/SCHEDULE/SCHEDULE_MISSING_CMODE"); DeckPtr deck = parser->parseFile(scheduleFile, parseContext); - std::shared_ptr grid = std::make_shared(10,10,3); + EclipseGrid grid(10,10,3); BOOST_CHECK_NO_THROW( new Schedule(parseContext , grid , deck ) ); } @@ -83,7 +83,8 @@ BOOST_AUTO_TEST_CASE(WCONPROD_Missing_DATA) { ParserPtr parser(new Parser()); std::string scheduleFile("testdata/integration_tests/SCHEDULE/SCHEDULE_CMODE_MISSING_DATA"); DeckPtr deck = parser->parseFile(scheduleFile, parseContext); - std::shared_ptr grid = std::make_shared(10,10,3); + EclipseGrid grid(10,10,3); + BOOST_CHECK_THROW( new Schedule(parseContext , grid , deck ) , std::invalid_argument ); } @@ -93,15 +94,15 @@ BOOST_AUTO_TEST_CASE(WellTestRefDepth) { ParserPtr parser(new Parser()); std::string scheduleFile("testdata/integration_tests/SCHEDULE/SCHEDULE_WELLS2"); DeckPtr deck = parser->parseFile(scheduleFile, parseContext); - std::shared_ptr grid = std::make_shared(40,60,30); + EclipseGrid grid(40,60,30); BOOST_CHECK_EQUAL(3, 3); SchedulePtr sched(new Schedule(parseContext , grid , deck )); BOOST_CHECK_EQUAL(4, 4); - WellPtr well1 = sched->getWell("W_1"); - WellPtr well2 = sched->getWell("W_2"); - WellPtr well4 = sched->getWell("W_4"); - BOOST_CHECK_EQUAL( well1->getRefDepth() , grid->getCellDepth( 29 , 36 , 0 )); + auto* well1 = sched->getWell("W_1"); + auto* well2 = sched->getWell("W_2"); + auto* well4 = sched->getWell("W_4"); + BOOST_CHECK_EQUAL( well1->getRefDepth() , grid.getCellDepth( 29 , 36 , 0 )); BOOST_CHECK_EQUAL( well2->getRefDepth() , 100 ); BOOST_CHECK_THROW( well4->getRefDepth() , std::invalid_argument ); } @@ -112,7 +113,7 @@ BOOST_AUTO_TEST_CASE(WellTestOpen) { ParserPtr parser(new Parser()); std::string scheduleFile("testdata/integration_tests/SCHEDULE/SCHEDULE_WELLS2"); DeckPtr deck = parser->parseFile(scheduleFile, parseContext); - std::shared_ptr grid = std::make_shared(40,60,30); + EclipseGrid grid(40,60,30); SchedulePtr sched(new Schedule(parseContext , grid , deck )); auto well1 = sched->getWell( "W_1" ); @@ -152,7 +153,7 @@ BOOST_AUTO_TEST_CASE(WellTesting) { ParserPtr parser(new Parser()); std::string scheduleFile("testdata/integration_tests/SCHEDULE/SCHEDULE_WELLS2"); DeckPtr deck = parser->parseFile(scheduleFile, parseContext); - std::shared_ptr grid = std::make_shared(40,60,30); + EclipseGrid grid(40,60,30); SchedulePtr sched(new Schedule(parseContext , grid , deck )); BOOST_CHECK_EQUAL(4U, sched->numWells()); @@ -161,7 +162,7 @@ BOOST_AUTO_TEST_CASE(WellTesting) { BOOST_CHECK(sched->hasWell("W_3")); { - WellPtr well2 = sched->getWell("W_2"); + auto* well2 = sched->getWell("W_2"); BOOST_CHECK_EQUAL( 0 , well2->getProductionPropertiesCopy(2).ResVRate); BOOST_CHECK_CLOSE( 777/Metric::Time , well2->getProductionPropertiesCopy(7).ResVRate , 0.0001); BOOST_CHECK_EQUAL( 0 , well2->getProductionPropertiesCopy(8).ResVRate); @@ -181,7 +182,7 @@ BOOST_AUTO_TEST_CASE(WellTesting) { { - WellPtr well3 = sched->getWell("W_3"); + auto* well3 = sched->getWell("W_3"); BOOST_CHECK_EQUAL( WellCommon::AUTO , well3->getStatus(3)); BOOST_CHECK_EQUAL( 0 , well3->getProductionPropertiesCopy(2).LiquidRate); @@ -195,7 +196,7 @@ BOOST_AUTO_TEST_CASE(WellTesting) { } { - WellPtr well1 = sched->getWell("W_1"); + auto* well1 = sched->getWell("W_1"); BOOST_CHECK(well1->getProductionPropertiesCopy(0).predictionMode); BOOST_CHECK_EQUAL(0, well1->getProductionPropertiesCopy(0).OilRate); @@ -268,7 +269,7 @@ BOOST_AUTO_TEST_CASE(WellTestCOMPDAT_DEFAULTED_ITEMS) { ParserPtr parser(new Parser()); std::string scheduleFile("testdata/integration_tests/SCHEDULE/SCHEDULE_COMPDAT1"); DeckPtr deck = parser->parseFile(scheduleFile, parseContext); - std::shared_ptr grid = std::make_shared(40,60,30); + EclipseGrid grid(40,60,30); SchedulePtr sched(new Schedule(parseContext , grid, deck)); } @@ -278,7 +279,7 @@ BOOST_AUTO_TEST_CASE(WellTestCOMPDAT) { ParserPtr parser(new Parser()); std::string scheduleFile("testdata/integration_tests/SCHEDULE/SCHEDULE_WELLS2"); DeckPtr deck = parser->parseFile(scheduleFile, parseContext); - std::shared_ptr grid = std::make_shared(40,60,30); + EclipseGrid grid(40,60,30); SchedulePtr sched(new Schedule(parseContext , grid , deck)); BOOST_CHECK_EQUAL(4U, sched->numWells()); @@ -286,7 +287,7 @@ BOOST_AUTO_TEST_CASE(WellTestCOMPDAT) { BOOST_CHECK(sched->hasWell("W_2")); BOOST_CHECK(sched->hasWell("W_3")); { - WellPtr well1 = sched->getWell("W_1"); + auto* well1 = sched->getWell("W_1"); BOOST_CHECK_CLOSE(13000/Metric::Time , well1->getProductionPropertiesCopy(8).OilRate , 0.0001); CompletionSetConstPtr completions = well1->getCompletions(0); BOOST_CHECK_EQUAL(0U, completions->size()); @@ -310,10 +311,10 @@ BOOST_AUTO_TEST_CASE(GroupTreeTest_GRUPTREE_with_explicit_L0_parenting) { ParserPtr parser(new Parser()); std::string scheduleFile("testdata/integration_tests/SCHEDULE/SCHEDULE_GRUPTREE_EXPLICIT_PARENTING"); DeckPtr deck = parser->parseFile(scheduleFile, parseContext); - std::shared_ptr grid = std::make_shared(10,10,3); + EclipseGrid grid(10,10,3); SchedulePtr sched(new Schedule(parseContext , grid , deck)); - GroupTreeNodePtr rootNode = sched->getGroupTree(0)->getNode("FIELD"); + GroupTreeNodePtr rootNode = sched->getGroupTree(0).getNode("FIELD"); BOOST_REQUIRE_EQUAL("FIELD", rootNode->name()); @@ -339,7 +340,7 @@ BOOST_AUTO_TEST_CASE(GroupTreeTest_GRUPTREE_correct) { ParserPtr parser(new Parser()); std::string scheduleFile("testdata/integration_tests/SCHEDULE/SCHEDULE_WELSPECS_GRUPTREE"); DeckPtr deck = parser->parseFile(scheduleFile, parseContext); - std::shared_ptr grid = std::make_shared(10,10,3); + EclipseGrid grid(10,10,3); SchedulePtr schedule(new Schedule(parseContext , grid , deck)); BOOST_CHECK( schedule->hasGroup( "FIELD" )); @@ -358,11 +359,11 @@ BOOST_AUTO_TEST_CASE(GroupTreeTest_WELSPECS_AND_GRUPTREE_correct_iter_function) ParserPtr parser(new Parser()); std::string scheduleFile("testdata/integration_tests/SCHEDULE/SCHEDULE_WELSPECS_GROUPS"); DeckPtr deck = parser->parseFile(scheduleFile, parseContext); - std::shared_ptr grid = std::make_shared(10,10,3); + EclipseGrid grid(10,10,3); SchedulePtr schedule(new Schedule(parseContext , grid , deck)); // Time 0, only from WELSPECS - GroupTreeNodeConstPtr root = schedule->getGroupTree(0)->getNode("FIELD"); + GroupTreeNodeConstPtr root = schedule->getGroupTree(0).getNode("FIELD"); int iter_counted = 0; @@ -373,7 +374,7 @@ BOOST_AUTO_TEST_CASE(GroupTreeTest_WELSPECS_AND_GRUPTREE_correct_iter_function) // Time 1, a new group added in tree iter_counted = 0; - root = schedule->getGroupTree(1)->getNode("FIELD"); + root = schedule->getGroupTree(1).getNode("FIELD"); for (auto iter=root->begin(); iter != root->end(); ++iter) { iter_counted++; } @@ -385,11 +386,11 @@ BOOST_AUTO_TEST_CASE(GroupTreeTest_WELSPECS_AND_GRUPTREE_correct_tree) { ParserPtr parser(new Parser()); std::string scheduleFile("testdata/integration_tests/SCHEDULE/SCHEDULE_WELSPECS_GROUPS"); DeckPtr deck = parser->parseFile(scheduleFile, parseContext); - std::shared_ptr grid = std::make_shared(10,10,3); + EclipseGrid grid(10,10,3); SchedulePtr schedule(new Schedule(parseContext , grid , deck)); // Time 0, only from WELSPECS - GroupTreeNodePtr root0 = schedule->getGroupTree(0)->getNode("FIELD"); + GroupTreeNodePtr root0 = schedule->getGroupTree(0).getNode("FIELD"); BOOST_REQUIRE_EQUAL("FIELD", root0->name()); BOOST_CHECK(root0->hasChildGroup("GROUP_BJARNE")); GroupTreeNodePtr GROUP_BJARNE = root0->getChildGroup("GROUP_BJARNE"); @@ -400,7 +401,7 @@ BOOST_AUTO_TEST_CASE(GroupTreeTest_WELSPECS_AND_GRUPTREE_correct_tree) { BOOST_CHECK_EQUAL("GROUP_ODD", GROUP_ODD->name()); // Time 1, now also from GRUPTREE - GroupTreeNodePtr root1 = schedule->getGroupTree(1)->getNode("FIELD"); + GroupTreeNodePtr root1 = schedule->getGroupTree(1).getNode("FIELD"); BOOST_REQUIRE_EQUAL("FIELD", root1->name()); BOOST_CHECK(root1->hasChildGroup("GROUP_BJARNE")); GroupTreeNodePtr GROUP_BJARNE1 = root1->getChildGroup("GROUP_BJARNE"); @@ -430,12 +431,12 @@ BOOST_AUTO_TEST_CASE(GroupTreeTest_GRUPTREE_WITH_REPARENT_correct_tree) { ParserPtr parser(new Parser()); std::string scheduleFile("testdata/integration_tests/SCHEDULE/SCHEDULE_GROUPS_REPARENT"); DeckPtr deck = parser->parseFile(scheduleFile, parseContext); - std::shared_ptr grid = std::make_shared(10,10,3); + EclipseGrid grid(10,10,3); SchedulePtr schedule(new Schedule(parseContext , grid , deck)); // Time , from first GRUPTREE - GroupTreeNodePtr root0 = schedule->getGroupTree(0)->getNode("FIELD"); + GroupTreeNodePtr root0 = schedule->getGroupTree(0).getNode("FIELD"); BOOST_REQUIRE_EQUAL("FIELD", root0->name()); BOOST_CHECK(root0->hasChildGroup("GROUP_BJARNE")); GroupTreeNodePtr GROUP_BJARNE0 = root0->getChildGroup("GROUP_BJARNE"); @@ -463,11 +464,11 @@ BOOST_AUTO_TEST_CASE(GroupTreeTest_PrintGrouptree) { ParserPtr parser(new Parser()); std::string scheduleFile("testdata/integration_tests/SCHEDULE/SCHEDULE_WELSPECS_GROUPS"); DeckPtr deck = parser->parseFile(scheduleFile, parseContext); - std::shared_ptr grid = std::make_shared(10,10,3); + EclipseGrid grid(10,10,3); SchedulePtr sched(new Schedule(parseContext , grid , deck)); - GroupTreePtr rootNode = sched->getGroupTree(0); - rootNode->printTree(std::cout); + const auto& rootNode = sched->getGroupTree(0); + rootNode.printTree(std::cout); } @@ -477,7 +478,7 @@ BOOST_AUTO_TEST_CASE( WellTestGroups ) { ParserPtr parser(new Parser()); std::string scheduleFile("testdata/integration_tests/SCHEDULE/SCHEDULE_GROUPS"); DeckPtr deck = parser->parseFile(scheduleFile, parseContext); - std::shared_ptr grid = std::make_shared(10,10,3); + EclipseGrid grid(10,10,3); SchedulePtr sched( new Schedule(parseContext , grid , deck)); BOOST_CHECK_EQUAL( 3U , sched->numGroups() ); @@ -485,30 +486,30 @@ BOOST_AUTO_TEST_CASE( WellTestGroups ) { BOOST_CHECK( sched->hasGroup( "OP" )); { - GroupPtr group = sched->getGroup("INJ"); - BOOST_CHECK_EQUAL( Phase::WATER , group->getInjectionPhase( 3 )); - BOOST_CHECK_EQUAL( GroupInjection::VREP , group->getInjectionControlMode( 3 )); - BOOST_CHECK_CLOSE( 10/Metric::Time , group->getSurfaceMaxRate( 3 ) , 0.001); - BOOST_CHECK_CLOSE( 20/Metric::Time , group->getReservoirMaxRate( 3 ) , 0.001); - BOOST_CHECK_EQUAL( 0.75 , group->getTargetReinjectFraction( 3 )); - BOOST_CHECK_EQUAL( 0.95 , group->getTargetVoidReplacementFraction( 3 )); + auto& group = sched->getGroup("INJ"); + BOOST_CHECK_EQUAL( Phase::WATER , group.getInjectionPhase( 3 )); + BOOST_CHECK_EQUAL( GroupInjection::VREP , group.getInjectionControlMode( 3 )); + BOOST_CHECK_CLOSE( 10/Metric::Time , group.getSurfaceMaxRate( 3 ) , 0.001); + BOOST_CHECK_CLOSE( 20/Metric::Time , group.getReservoirMaxRate( 3 ) , 0.001); + BOOST_CHECK_EQUAL( 0.75 , group.getTargetReinjectFraction( 3 )); + BOOST_CHECK_EQUAL( 0.95 , group.getTargetVoidReplacementFraction( 3 )); - BOOST_CHECK_EQUAL( Phase::OIL , group->getInjectionPhase( 6 )); - BOOST_CHECK_EQUAL( GroupInjection::RATE , group->getInjectionControlMode( 6 )); - BOOST_CHECK_CLOSE( 1000/Metric::Time , group->getSurfaceMaxRate( 6 ) , 0.0001); + BOOST_CHECK_EQUAL( Phase::OIL , group.getInjectionPhase( 6 )); + BOOST_CHECK_EQUAL( GroupInjection::RATE , group.getInjectionControlMode( 6 )); + BOOST_CHECK_CLOSE( 1000/Metric::Time , group.getSurfaceMaxRate( 6 ) , 0.0001); - BOOST_CHECK(group->isInjectionGroup(3)); + BOOST_CHECK(group.isInjectionGroup(3)); } { - GroupPtr group = sched->getGroup("OP"); - BOOST_CHECK_EQUAL( GroupProduction::ORAT , group->getProductionControlMode(3)); - BOOST_CHECK_CLOSE( 10/Metric::Time , group->getOilTargetRate(3) , 0.001); - BOOST_CHECK_CLOSE( 20/Metric::Time , group->getWaterTargetRate(3) , 0.001); - BOOST_CHECK_CLOSE( 30/Metric::Time , group->getGasTargetRate(3) , 0.001); - BOOST_CHECK_CLOSE( 40/Metric::Time , group->getLiquidTargetRate(3) , 0.001); + auto& group = sched->getGroup("OP"); + BOOST_CHECK_EQUAL( GroupProduction::ORAT , group.getProductionControlMode(3)); + BOOST_CHECK_CLOSE( 10/Metric::Time , group.getOilTargetRate(3) , 0.001); + BOOST_CHECK_CLOSE( 20/Metric::Time , group.getWaterTargetRate(3) , 0.001); + BOOST_CHECK_CLOSE( 30/Metric::Time , group.getGasTargetRate(3) , 0.001); + BOOST_CHECK_CLOSE( 40/Metric::Time , group.getLiquidTargetRate(3) , 0.001); - BOOST_CHECK(group->isProductionGroup(3)); + BOOST_CHECK(group.isProductionGroup(3)); } } @@ -519,27 +520,27 @@ BOOST_AUTO_TEST_CASE( WellTestGroupAndWellRelation ) { ParserPtr parser(new Parser()); std::string scheduleFile("testdata/integration_tests/SCHEDULE/SCHEDULE_WELLS_AND_GROUPS"); DeckPtr deck = parser->parseFile(scheduleFile, parseContext); - std::shared_ptr grid = std::make_shared(10,10,3); + EclipseGrid grid(10,10,3); SchedulePtr sched( new Schedule(parseContext , grid , deck)); - GroupPtr group1 = sched->getGroup("GROUP1"); - GroupPtr group2 = sched->getGroup("GROUP2"); + auto& group1 = sched->getGroup("GROUP1"); + auto& group2 = sched->getGroup("GROUP2"); - BOOST_CHECK( group1->hasBeenDefined(0) ); - BOOST_CHECK_EQUAL(false , group2->hasBeenDefined(0)); - BOOST_CHECK( group2->hasBeenDefined(1)); + BOOST_CHECK( group1.hasBeenDefined(0) ); + BOOST_CHECK_EQUAL(false , group2.hasBeenDefined(0)); + BOOST_CHECK( group2.hasBeenDefined(1)); - BOOST_CHECK_EQUAL( true , group1->hasWell("W_1" , 0)); - BOOST_CHECK_EQUAL( true , group1->hasWell("W_2" , 0)); - BOOST_CHECK_EQUAL( false, group2->hasWell("W_1" , 0)); - BOOST_CHECK_EQUAL( false, group2->hasWell("W_2" , 0)); + BOOST_CHECK_EQUAL( true , group1.hasWell("W_1" , 0)); + BOOST_CHECK_EQUAL( true , group1.hasWell("W_2" , 0)); + BOOST_CHECK_EQUAL( false, group2.hasWell("W_1" , 0)); + BOOST_CHECK_EQUAL( false, group2.hasWell("W_2" , 0)); - BOOST_CHECK_EQUAL( true , group1->hasWell("W_1" , 1)); - BOOST_CHECK_EQUAL( false , group1->hasWell("W_2" , 1)); - BOOST_CHECK_EQUAL( false , group2->hasWell("W_1" , 1)); - BOOST_CHECK_EQUAL( true , group2->hasWell("W_2" , 1)); + BOOST_CHECK_EQUAL( true , group1.hasWell("W_1" , 1)); + BOOST_CHECK_EQUAL( false , group1.hasWell("W_2" , 1)); + BOOST_CHECK_EQUAL( false , group2.hasWell("W_1" , 1)); + BOOST_CHECK_EQUAL( true , group2.hasWell("W_2" , 1)); } @@ -548,7 +549,7 @@ BOOST_AUTO_TEST_CASE(WellTestWELSPECSDataLoaded) { ParserPtr parser(new Parser()); std::string scheduleFile("testdata/integration_tests/SCHEDULE/SCHEDULE_WELLS2"); DeckPtr deck = parser->parseFile(scheduleFile, parseContext); - std::shared_ptr grid = std::make_shared(40,60,30); + EclipseGrid grid(40,60,30); SchedulePtr sched(new Schedule(parseContext , grid , deck)); BOOST_CHECK_EQUAL(4U, sched->numWells()); @@ -556,19 +557,19 @@ BOOST_AUTO_TEST_CASE(WellTestWELSPECSDataLoaded) { BOOST_CHECK(sched->hasWell("W_2")); BOOST_CHECK(sched->hasWell("W_3")); { - WellConstPtr well1 = sched->getWell("W_1"); + const auto* well1 = sched->getWell("W_1"); BOOST_CHECK(!well1->hasBeenDefined(2)); BOOST_CHECK(well1->hasBeenDefined(3)); BOOST_CHECK_EQUAL(29, well1->getHeadI()); BOOST_CHECK_EQUAL(36, well1->getHeadJ()); - WellConstPtr well2 = sched->getWell("W_2"); + const auto* well2 = sched->getWell("W_2"); BOOST_CHECK(!well2->hasBeenDefined(2)); BOOST_CHECK(well2->hasBeenDefined(3)); BOOST_CHECK_EQUAL(19, well2->getHeadI()); BOOST_CHECK_EQUAL(50, well2->getHeadJ()); - WellConstPtr well3 = sched->getWell("W_3"); + const auto* well3 = sched->getWell("W_3"); BOOST_CHECK(!well3->hasBeenDefined(2)); BOOST_CHECK(well3->hasBeenDefined(3)); BOOST_CHECK_EQUAL(30, well3->getHeadI()); @@ -581,7 +582,7 @@ BOOST_AUTO_TEST_CASE(WellTestWELSPECS_InvalidConfig_Throws) { ParserPtr parser(new Parser()); std::string scheduleFile("testdata/integration_tests/SCHEDULE/SCHEDULE_WELL_INVALID_WELSPECS"); DeckPtr deck = parser->parseFile(scheduleFile, parseContext); - std::shared_ptr grid = std::make_shared(10,10,3); + EclipseGrid grid(10,10,3); BOOST_CHECK_THROW(new Schedule(parseContext , grid , deck), std::invalid_argument); } @@ -603,7 +604,7 @@ BOOST_AUTO_TEST_CASE(WellTestWELOPENControlsSet) { std::shared_ptr grid = std::make_shared( 10,10,10 ); SchedulePtr sched(new Schedule(grid , deck)); - WellConstPtr well1 = sched->getWell("W_1"); + const auto* well1 = sched->getWell("W_1"); BOOST_CHECK_EQUAL(WellCommon::StatusEnum::OPEN, sched->getWell("W_1")->getStatus(0)); BOOST_CHECK_EQUAL(WellCommon::StatusEnum::SHUT, sched->getWell("W_1")->getStatus(1)); BOOST_CHECK_EQUAL(WellCommon::StatusEnum::OPEN, sched->getWell("W_1")->getStatus(2)); @@ -620,22 +621,22 @@ BOOST_AUTO_TEST_CASE(WellTestWGRUPCONWellPropertiesSet) { ParserPtr parser(new Parser()); std::string scheduleFile("testdata/integration_tests/SCHEDULE/SCHEDULE_WGRUPCON"); DeckPtr deck = parser->parseFile(scheduleFile, parseContext); - std::shared_ptr grid = std::make_shared( 10,10,10 ); + EclipseGrid grid(10,10,10); SchedulePtr sched(new Schedule(parseContext , grid , deck)); - WellConstPtr well1 = sched->getWell("W_1"); + const auto* well1 = sched->getWell("W_1"); BOOST_CHECK(well1->isAvailableForGroupControl(0)); BOOST_CHECK_EQUAL(-1, well1->getGuideRate(0)); BOOST_CHECK_EQUAL(GuideRate::OIL, well1->getGuideRatePhase(0)); BOOST_CHECK_EQUAL(1.0, well1->getGuideRateScalingFactor(0)); - WellConstPtr well2 = sched->getWell("W_2"); + const auto* well2 = sched->getWell("W_2"); BOOST_CHECK(!well2->isAvailableForGroupControl(0)); BOOST_CHECK_EQUAL(-1, well2->getGuideRate(0)); BOOST_CHECK_EQUAL(GuideRate::UNDEFINED, well2->getGuideRatePhase(0)); BOOST_CHECK_EQUAL(1.0, well2->getGuideRateScalingFactor(0)); - WellConstPtr well3 = sched->getWell("W_3"); + const auto* well3 = sched->getWell("W_3"); BOOST_CHECK(well3->isAvailableForGroupControl(0)); BOOST_CHECK_EQUAL(100, well3->getGuideRate(0)); BOOST_CHECK_EQUAL(GuideRate::RAT, well3->getGuideRatePhase(0)); @@ -659,9 +660,9 @@ COMPDAT \n\ 'W1' 2* 1 1 'OPEN' 1* 32.948 0.311 3047.839 2* 'X' 22.100 /\n\ /\n"; DeckPtr deck = parser->parseString(deckString, parseContext); - std::shared_ptr grid = std::make_shared( 30,30,10 ); + EclipseGrid grid(30,30,10); SchedulePtr sched(new Schedule(parseContext , grid , deck)); - WellConstPtr well = sched->getWell("W1"); + const auto* well = sched->getWell("W1"); CompletionSetConstPtr completions = well->getCompletions(0); BOOST_CHECK_EQUAL( 10 , completions->get(0)->getI() ); BOOST_CHECK_EQUAL( 20 , completions->get(0)->getJ() ); @@ -677,7 +678,7 @@ BOOST_AUTO_TEST_CASE(OpmCode) { ParserPtr parser(new Parser()); std::string scheduleFile("testdata/integration_tests/SCHEDULE/wells_group.data"); DeckPtr deck = parser->parseFile(scheduleFile, parseContext); - std::shared_ptr grid = std::make_shared(10,10,3); + EclipseGrid grid(10,10,3); BOOST_CHECK_NO_THROW( new Schedule(parseContext , grid , deck) ); } @@ -688,13 +689,13 @@ BOOST_AUTO_TEST_CASE(WELLS_SHUT) { ParserPtr parser(new Parser()); std::string scheduleFile("testdata/integration_tests/SCHEDULE/SCHEDULE_SHUT_WELL"); DeckPtr deck = parser->parseFile(scheduleFile, parseContext); - std::shared_ptr grid = std::make_shared( 20,40,1 ); + EclipseGrid grid(20,40,1); SchedulePtr sched(new Schedule(parseContext , grid , deck)); - WellConstPtr well1 = sched->getWell("W1"); - WellConstPtr well2 = sched->getWell("W2"); - WellConstPtr well3 = sched->getWell("W3"); + const auto* well1 = sched->getWell("W1"); + const auto* well2 = sched->getWell("W2"); + const auto* well3 = sched->getWell("W3"); BOOST_CHECK_EQUAL( WellCommon::StatusEnum::OPEN , well1->getStatus(1)); BOOST_CHECK_EQUAL( WellCommon::StatusEnum::OPEN , well2->getStatus(1)); @@ -712,7 +713,7 @@ BOOST_AUTO_TEST_CASE(WellTestWPOLYMER) { ParserPtr parser(new Parser()); std::string scheduleFile("testdata/integration_tests/SCHEDULE/SCHEDULE_POLYMER"); DeckPtr deck = parser->parseFile(scheduleFile, parseContext); - std::shared_ptr grid = std::make_shared( 30,30,30); + EclipseGrid grid(30,30,30); SchedulePtr sched(new Schedule(parseContext , grid , deck)); @@ -720,7 +721,7 @@ BOOST_AUTO_TEST_CASE(WellTestWPOLYMER) { BOOST_CHECK(sched->hasWell("INJE01")); BOOST_CHECK(sched->hasWell("PROD01")); - WellConstPtr well1 = sched->getWell("INJE01"); + const auto* well1 = sched->getWell("INJE01"); BOOST_CHECK( well1->isInjector(0)); { const WellPolymerProperties& props_well10 = well1->getPolymerProperties(0); @@ -731,7 +732,7 @@ BOOST_AUTO_TEST_CASE(WellTestWPOLYMER) { BOOST_CHECK_CLOSE(0.1*Metric::PolymerDensity, props_well12.m_polymerConcentration, 0.0001); } - WellConstPtr well2 = sched->getWell("INJE02"); + const auto* well2 = sched->getWell("INJE02"); BOOST_CHECK( well2->isInjector(0)); { const WellPolymerProperties& props_well20 = well2->getPolymerProperties(0); @@ -742,7 +743,7 @@ BOOST_AUTO_TEST_CASE(WellTestWPOLYMER) { BOOST_CHECK_CLOSE(0.2*Metric::PolymerDensity, props_well22.m_polymerConcentration, 0.0001); } - WellConstPtr well3 = sched->getWell("INJE03"); + const auto* well3 = sched->getWell("INJE03"); BOOST_CHECK( well3->isInjector(0)); { const WellPolymerProperties& props_well30 = well3->getPolymerProperties(0); @@ -755,13 +756,122 @@ BOOST_AUTO_TEST_CASE(WellTestWPOLYMER) { } +BOOST_AUTO_TEST_CASE(WellTestWECON) { + ParseContext parseContext; + ParserPtr parser(new Parser()); + std::string scheduleFile("testdata/integration_tests/SCHEDULE/SCHEDULE_WECON"); + DeckPtr deck = parser->parseFile(scheduleFile, parseContext); + EclipseGrid grid(30,30,30); + SchedulePtr sched(new Schedule(parseContext , grid , deck)); + + BOOST_CHECK_EQUAL(3U, sched->numWells()); + BOOST_CHECK(sched->hasWell("INJE01")); + BOOST_CHECK(sched->hasWell("PROD01")); + BOOST_CHECK(sched->hasWell("PROD02")); + + const auto* prod1 = sched->getWell("PROD01"); + { + const WellEconProductionLimits& econ_limit1 = prod1->getEconProductionLimits(0); + BOOST_CHECK(econ_limit1.onMinOilRate()); + BOOST_CHECK(econ_limit1.onMaxWaterCut()); + BOOST_CHECK(!(econ_limit1.onMinGasRate())); + BOOST_CHECK(!(econ_limit1.onMaxGasOilRatio())); + BOOST_CHECK_EQUAL(econ_limit1.maxWaterCut(), 0.95); + BOOST_CHECK_EQUAL(econ_limit1.minOilRate(), 50.0/86400.); + BOOST_CHECK_EQUAL(econ_limit1.minGasRate(), 0.0); + BOOST_CHECK_EQUAL(econ_limit1.maxGasOilRatio(), 0.0); + BOOST_CHECK_EQUAL(econ_limit1.endRun(), false); + BOOST_CHECK_EQUAL(econ_limit1.followonWell(), "'"); + BOOST_CHECK_EQUAL(econ_limit1.quantityLimit(), WellEcon::RATE); + BOOST_CHECK_EQUAL(econ_limit1.workover(), WellEcon::CON); + BOOST_CHECK_EQUAL(econ_limit1.workoverSecondary(), WellEcon::CON); + BOOST_CHECK(econ_limit1.requireWorkover()); + BOOST_CHECK(econ_limit1.requireSecondaryWorkover()); + BOOST_CHECK(!(econ_limit1.validFollowonWell())); + BOOST_CHECK(!(econ_limit1.endRun())); + BOOST_CHECK(econ_limit1.onAnyRatioLimit()); + BOOST_CHECK(econ_limit1.onAnyRateLimit()); + BOOST_CHECK(econ_limit1.onAnyEffectiveLimit()); + + const WellEconProductionLimits& econ_limit2 = prod1->getEconProductionLimits(1); + BOOST_CHECK(!(econ_limit2.onMinOilRate())); + BOOST_CHECK(econ_limit2.onMaxWaterCut()); + BOOST_CHECK(econ_limit2.onMinGasRate()); + BOOST_CHECK(!(econ_limit2.onMaxGasOilRatio())); + BOOST_CHECK_EQUAL(econ_limit2.maxWaterCut(), 0.95); + BOOST_CHECK_EQUAL(econ_limit2.minOilRate(), 0.0); + BOOST_CHECK_EQUAL(econ_limit2.minGasRate(), 1000./86400.); + BOOST_CHECK_EQUAL(econ_limit2.maxGasOilRatio(), 0.0); + BOOST_CHECK_EQUAL(econ_limit2.endRun(), false); + BOOST_CHECK_EQUAL(econ_limit2.followonWell(), "'"); + BOOST_CHECK_EQUAL(econ_limit2.quantityLimit(), WellEcon::RATE); + BOOST_CHECK_EQUAL(econ_limit2.workover(), WellEcon::CON); + BOOST_CHECK_EQUAL(econ_limit2.workoverSecondary(), WellEcon::CON); + BOOST_CHECK(econ_limit2.requireWorkover()); + BOOST_CHECK(econ_limit2.requireSecondaryWorkover()); + BOOST_CHECK(!(econ_limit2.validFollowonWell())); + BOOST_CHECK(!(econ_limit2.endRun())); + BOOST_CHECK(econ_limit2.onAnyRatioLimit()); + BOOST_CHECK(econ_limit2.onAnyRateLimit()); + BOOST_CHECK(econ_limit2.onAnyEffectiveLimit()); + } + + const auto* prod2 = sched->getWell("PROD02"); + { + const WellEconProductionLimits& econ_limit1 = prod2->getEconProductionLimits(0); + BOOST_CHECK(!(econ_limit1.onMinOilRate())); + BOOST_CHECK(!(econ_limit1.onMaxWaterCut())); + BOOST_CHECK(!(econ_limit1.onMinGasRate())); + BOOST_CHECK(!(econ_limit1.onMaxGasOilRatio())); + BOOST_CHECK_EQUAL(econ_limit1.maxWaterCut(), 0.0); + BOOST_CHECK_EQUAL(econ_limit1.minOilRate(), 0.0); + BOOST_CHECK_EQUAL(econ_limit1.minGasRate(), 0.0); + BOOST_CHECK_EQUAL(econ_limit1.maxGasOilRatio(), 0.0); + BOOST_CHECK_EQUAL(econ_limit1.endRun(), false); + BOOST_CHECK_EQUAL(econ_limit1.followonWell(), "'"); + BOOST_CHECK_EQUAL(econ_limit1.quantityLimit(), WellEcon::RATE); + BOOST_CHECK_EQUAL(econ_limit1.workover(), WellEcon::NONE); + BOOST_CHECK_EQUAL(econ_limit1.workoverSecondary(), WellEcon::NONE); + BOOST_CHECK(!(econ_limit1.requireWorkover())); + BOOST_CHECK(!(econ_limit1.requireSecondaryWorkover())); + BOOST_CHECK(!(econ_limit1.validFollowonWell())); + BOOST_CHECK(!(econ_limit1.endRun())); + BOOST_CHECK(!(econ_limit1.onAnyRatioLimit())); + BOOST_CHECK(!(econ_limit1.onAnyRateLimit())); + BOOST_CHECK(!(econ_limit1.onAnyEffectiveLimit())); + + const WellEconProductionLimits& econ_limit2 = prod2->getEconProductionLimits(1); + BOOST_CHECK(!(econ_limit2.onMinOilRate())); + BOOST_CHECK(econ_limit2.onMaxWaterCut()); + BOOST_CHECK(econ_limit2.onMinGasRate()); + BOOST_CHECK(!(econ_limit2.onMaxGasOilRatio())); + BOOST_CHECK_EQUAL(econ_limit2.maxWaterCut(), 0.95); + BOOST_CHECK_EQUAL(econ_limit2.minOilRate(), 0.0); + BOOST_CHECK_EQUAL(econ_limit2.minGasRate(), 1000.0/86400.); + BOOST_CHECK_EQUAL(econ_limit2.maxGasOilRatio(), 0.0); + BOOST_CHECK_EQUAL(econ_limit2.endRun(), false); + BOOST_CHECK_EQUAL(econ_limit2.followonWell(), "'"); + BOOST_CHECK_EQUAL(econ_limit2.quantityLimit(), WellEcon::RATE); + BOOST_CHECK_EQUAL(econ_limit2.workover(), WellEcon::CON); + BOOST_CHECK_EQUAL(econ_limit2.workoverSecondary(), WellEcon::CON); + BOOST_CHECK(econ_limit2.requireWorkover()); + BOOST_CHECK(econ_limit2.requireSecondaryWorkover()); + BOOST_CHECK(!(econ_limit2.validFollowonWell())); + BOOST_CHECK(!(econ_limit2.endRun())); + BOOST_CHECK(econ_limit2.onAnyRatioLimit()); + BOOST_CHECK(econ_limit2.onAnyRateLimit()); + BOOST_CHECK(econ_limit2.onAnyEffectiveLimit()); + } +} + + BOOST_AUTO_TEST_CASE(TestEvents) { ParseContext parseContext; ParserPtr parser(new Parser()); std::string scheduleFile("testdata/integration_tests/SCHEDULE/SCHEDULE_EVENTS"); DeckPtr deck = parser->parseFile(scheduleFile, parseContext); - std::shared_ptr grid = std::make_shared(40,40,30); + EclipseGrid grid(40,40,30); SchedulePtr sched(new Schedule(parseContext , grid , deck)); const Events& events = sched->getEvents(); diff --git a/ThirdParty/custom-opm-parser/opm-parser/opm/parser/eclipse/IntegrationTests/TransMultIntegrationTests.cpp b/ThirdParty/custom-opm-parser/opm-parser/opm/parser/eclipse/IntegrationTests/TransMultIntegrationTests.cpp index 9dcfdff1bd..6ffa19dddd 100644 --- a/ThirdParty/custom-opm-parser/opm-parser/opm/parser/eclipse/IntegrationTests/TransMultIntegrationTests.cpp +++ b/ThirdParty/custom-opm-parser/opm-parser/opm/parser/eclipse/IntegrationTests/TransMultIntegrationTests.cpp @@ -42,19 +42,19 @@ BOOST_AUTO_TEST_CASE(MULTFLT_IN_SCHEDULE) { ParserPtr parser(new Parser()); std::string scheduleFile("testdata/integration_tests/TRANS/Deck1"); ParseContext parseContext; - DeckPtr deck = parser->parseFile(scheduleFile, parseContext); - std::shared_ptr eclState = std::make_shared( deck , parseContext ); - std::shared_ptr trans = eclState->getTransMult(); - std::shared_ptr schedule = eclState->getSchedule(); + DeckPtr deck = parser->parseFile(scheduleFile, parseContext); + EclipseState state(*deck, parseContext); + const auto& trans = state.getTransMult(); + std::shared_ptr schedule = state.getSchedule(); const Events& events = schedule->getEvents(); - BOOST_CHECK_EQUAL( 0.10 , trans->getMultiplier( 3,2,0,FaceDir::XPlus )); - BOOST_CHECK_EQUAL( 0.10 , trans->getMultiplier( 2,2,0,FaceDir::XPlus )); + BOOST_CHECK_EQUAL( 0.10 , trans.getMultiplier( 3,2,0,FaceDir::XPlus )); + BOOST_CHECK_EQUAL( 0.10 , trans.getMultiplier( 2,2,0,FaceDir::XPlus )); BOOST_CHECK( events.hasEvent( ScheduleEvents::GEO_MODIFIER , 3 ) ); { std::shared_ptr mini_deck = schedule->getModifierDeck(3); - eclState->applyModifierDeck( *mini_deck ); + state.applyModifierDeck( *mini_deck ); } - BOOST_CHECK_EQUAL( 2.00 , trans->getMultiplier( 2,2,0,FaceDir::XPlus )); - BOOST_CHECK_EQUAL( 0.10 , trans->getMultiplier( 3,2,0,FaceDir::XPlus )); + BOOST_CHECK_EQUAL( 2.00 , trans.getMultiplier( 2,2,0,FaceDir::XPlus )); + BOOST_CHECK_EQUAL( 0.10 , trans.getMultiplier( 3,2,0,FaceDir::XPlus )); } diff --git a/ThirdParty/custom-opm-parser/opm-parser/opm/parser/eclipse/Parser/ParseContext.cpp b/ThirdParty/custom-opm-parser/opm-parser/opm/parser/eclipse/Parser/ParseContext.cpp index 83e0852528..d6eb8826c4 100644 --- a/ThirdParty/custom-opm-parser/opm-parser/opm/parser/eclipse/Parser/ParseContext.cpp +++ b/ThirdParty/custom-opm-parser/opm-parser/opm/parser/eclipse/Parser/ParseContext.cpp @@ -67,8 +67,12 @@ namespace Opm { addKey(UNSUPPORTED_SCHEDULE_GEO_MODIFIER); addKey(UNSUPPORTED_COMPORD_TYPE); addKey(UNSUPPORTED_INITIAL_THPRES); + addKey(UNSUPPORTED_TERMINATE_IF_BHP); addKey(INTERNAL_ERROR_UNINITIALIZED_THPRES); + + addKey(SUMMARY_UNKNOWN_WELL); + addKey(SUMMARY_UNKNOWN_GROUP); } void ParseContext::initEnv() { @@ -238,10 +242,14 @@ namespace Opm { const std::string ParseContext::UNSUPPORTED_SCHEDULE_GEO_MODIFIER = "UNSUPPORTED_SCHEDULE_GEO_MODIFIER"; const std::string ParseContext::UNSUPPORTED_COMPORD_TYPE = "UNSUPPORTED_COMPORD_TYPE"; const std::string ParseContext::UNSUPPORTED_INITIAL_THPRES = "UNSUPPORTED_INITIAL_THPRES"; + const std::string ParseContext::UNSUPPORTED_TERMINATE_IF_BHP = "UNSUPPORTED_TERMINATE_IF_BHP"; const std::string ParseContext::INTERNAL_ERROR_UNINITIALIZED_THPRES = "INTERNAL_ERROR_UNINITIALIZED_THPRES"; const std::string ParseContext::PARSE_MISSING_SECTIONS = "PARSE_MISSING_SECTIONS"; + + const std::string ParseContext::SUMMARY_UNKNOWN_WELL = "SUMMARY_UNKNOWN_WELL"; + const std::string ParseContext::SUMMARY_UNKNOWN_GROUP = "SUMMARY_UNKNOWN_GROUP"; } diff --git a/ThirdParty/custom-opm-parser/opm-parser/opm/parser/eclipse/Parser/ParseContext.hpp b/ThirdParty/custom-opm-parser/opm-parser/opm/parser/eclipse/Parser/ParseContext.hpp index 325b070b68..76e076d627 100644 --- a/ThirdParty/custom-opm-parser/opm-parser/opm/parser/eclipse/Parser/ParseContext.hpp +++ b/ThirdParty/custom-opm-parser/opm-parser/opm/parser/eclipse/Parser/ParseContext.hpp @@ -191,6 +191,13 @@ namespace Opm { */ const static std::string UNSUPPORTED_INITIAL_THPRES; + /* + If the second item in the WHISTCTL keyword is set to YES + The simulator is supposed to terminate if the well is + changed to BHP control. This feature is not yet supported. + */ + const static std::string UNSUPPORTED_TERMINATE_IF_BHP; + /* If the third item in the THPRES keyword is defaulted the @@ -207,6 +214,14 @@ namespace Opm { */ const static std::string PARSE_MISSING_SECTIONS; + + /* + If you have configured a specific well in the summary section, + which is not recognized - how to handle. + */ + const static std::string SUMMARY_UNKNOWN_WELL; + const static std::string SUMMARY_UNKNOWN_GROUP; + private: void initDefault(); void initEnv(); diff --git a/ThirdParty/custom-opm-parser/opm-parser/opm/parser/eclipse/Parser/Parser.cpp b/ThirdParty/custom-opm-parser/opm-parser/opm/parser/eclipse/Parser/Parser.cpp index 7cfa4211e4..3e253ba613 100644 --- a/ThirdParty/custom-opm-parser/opm-parser/opm/parser/eclipse/Parser/Parser.cpp +++ b/ThirdParty/custom-opm-parser/opm-parser/opm/parser/eclipse/Parser/Parser.cpp @@ -47,15 +47,21 @@ namespace Opm { namespace { -template< typename Itr > -inline Itr find_comment( Itr begin, Itr end ) { +struct find_comment { + /* + * A note on performance: using a function to plug functionality into + * find_terminator rather than plain functions because it almost ensures + * inlining, where the plain function can reduce to a function pointer. + */ + template< typename Itr > + Itr operator()( Itr begin, Itr end ) const { + auto itr = std::find( begin, end, '-' ); + for( ; itr != end; itr = std::find( itr + 1, end, '-' ) ) + if( (itr + 1) != end && *( itr + 1 ) == '-' ) return itr; - auto itr = std::find( begin, end, '-' ); - for( ; itr != end; itr = std::find( itr + 1, end, '-' ) ) - if( (itr + 1) != end && *( itr + 1 ) == '-' ) return itr; - - return end; -} + return end; + } +}; template< typename Itr, typename Term > inline Itr find_terminator( Itr begin, Itr end, Term terminator ) { @@ -64,7 +70,7 @@ inline Itr find_terminator( Itr begin, Itr end, Term terminator ) { if( pos == end ) return end; - auto qbegin = std::find_if( begin, end, RawConsts::is_quote ); + auto qbegin = std::find_if( begin, end, RawConsts::is_quote() ); if( qbegin == end || qbegin > pos ) return pos; @@ -88,14 +94,13 @@ inline Itr find_terminator( Itr begin, Itr end, Term terminator ) { ABC "-- Not balanced quote? => ABC "-- Not balanced quote? */ static inline string_view strip_comments( string_view str ) { - return { str.begin(), find_terminator( str.begin(), str.end(), - find_comment< string_view::const_iterator > ) }; + return { str.begin(), + find_terminator( str.begin(), str.end(), find_comment() ) }; } template< typename Itr > inline Itr trim_left( Itr begin, Itr end ) { - - return std::find_if_not( begin, end, RawConsts::is_separator ); + return std::find_if_not( begin, end, RawConsts::is_separator() ); } template< typename Itr > @@ -104,7 +109,7 @@ inline Itr trim_right( Itr begin, Itr end ) { std::reverse_iterator< Itr > rbegin( end ); std::reverse_iterator< Itr > rend( begin ); - return std::find_if_not( rbegin, rend, RawConsts::is_separator ).base(); + return std::find_if_not( rbegin, rend, RawConsts::is_separator() ).base(); } inline string_view trim( string_view str ) { @@ -147,45 +152,24 @@ inline bool getline( string_view& input, string_view& line ) { /* * Read the input file and remove everything that isn't interesting data, * including stripping comments, removing leading/trailing whitespaces and - * everything after (terminating) slashes + * everything after (terminating) slashes. Manually copying into the string for + * performance. */ inline std::string clean( const std::string& str ) { std::string dst; - dst.reserve( str.size() ); + dst.resize( str.size() ); string_view input( str ), line; + auto dsti = dst.begin(); while( getline( input, line ) ) { line = trim( strip_slash( strip_comments( line ) ) ); - //if( line.begin() == line.end() ) continue; - - dst.append( line.begin(), line.end() ); - dst.push_back( '\n' ); + std::copy( line.begin(), line.end(), dsti ); + dsti += std::distance( line.begin(), line.end() ); + *dsti++ = '\n'; } - struct f { - bool inside_quotes = false; - bool operator()( char c ) { - if( c == ',' ) return true; - if( RawConsts::is_quote( c ) ) inside_quotes = !inside_quotes; - return false; - } - }; - - /* some decks use commas for item separation in records, but commas add - * nothing over whitespace. run over the deck and replace all non-quoted - * commas with whitespace. commas withing quotes are read verbatim and not - * to be touched. - * - * There's a known defect: considering the record - * foo bar, , , baz, , / - * baz will silently interpreted as item #3 instead of item #5. As of - * writing we're not sure if this is even legal, nor have we seen it - * happen, but the effort needed to support it is tremendous and will - * require significant changes throughout. - */ - std::replace_if( dst.begin(), dst.end(), f(), ' ' ); - + dst.resize( std::distance( dst.begin(), dsti ) ); return dst; } @@ -267,12 +251,12 @@ bool ParserState::done() const { } string_view ParserState::getline() { - string_view line; + string_view ln; - Opm::getline( this->input_stack.top().input, line ); + Opm::getline( this->input_stack.top().input, ln ); this->input_stack.top().lineNR++; - return line; + return ln; } void ParserState::closeFile() { @@ -331,10 +315,10 @@ void ParserState::loadFile(const boost::filesystem::path& inputFile) { std::fseek( fp, 0, SEEK_END ); buffer.resize( std::ftell( fp ) + 1 ); std::rewind( fp ); - std::fread( &buffer[ 0 ], 1, buffer.size() - 1, fp ); + const auto readc = std::fread( &buffer[ 0 ], 1, buffer.size() - 1, fp ); buffer.back() = '\n'; - if( std::ferror( fp ) ) + if( std::ferror( fp ) || readc != buffer.size() - 1 ) throw std::runtime_error( "Error when reading input file '" + inputFileCanonical.string() + "'" ); @@ -581,8 +565,8 @@ bool parseState( ParserState& parserState, const Parser& parser ) { * strip_comment is the actual (internal) implementation */ std::string Parser::stripComments( const std::string& str ) { - return { str.begin(), find_terminator( str.begin(), str.end(), - find_comment< std::string::const_iterator > ) }; + return { str.begin(), + find_terminator( str.begin(), str.end(), find_comment() ) }; } Parser::Parser(bool addDefault) { @@ -617,7 +601,7 @@ bool parseState( ParserState& parserState, const Parser& parser ) { return parserState.deck; } - void assertFullDeck(const ParseContext& context) { + inline void assertFullDeck(const ParseContext& context) { if (context.hasKey(ParseContext::PARSE_MISSING_SECTIONS)) throw new std::logic_error("Cannot construct a state in partial deck context"); } @@ -625,8 +609,9 @@ bool parseState( ParserState& parserState, const Parser& parser ) { EclipseState Parser::parse(const std::string &filename, const ParseContext& context) { assertFullDeck(context); Parser p; - auto deck = p.parseFile(filename, context); - return EclipseState(deck, context); + DeckPtr deck = p.parseFile(filename, context); + EclipseState es(deck, context); + return es; } EclipseState Parser::parse(const Deck& deck, const ParseContext& context) { @@ -694,7 +679,7 @@ bool parseState( ParserState& parserState, const Parser& parser ) { if( m_deckParserKeywords.count( name ) ) return true; - return matchingKeyword( name ); + return bool( matchingKeyword( name ) ); } void Parser::addParserKeyword( std::unique_ptr< const ParserKeyword >&& parserKeyword) { @@ -852,7 +837,7 @@ std::vector Parser::getAllDeckNames () const { if( deck.getKeyword(0).name() != "RUNSPEC" ) { std::string msg = "The first keyword of a valid deck must be RUNSPEC\n"; auto curKeyword = deck.getKeyword(0); - deck.getMessageContainer().warning(curKeyword.getFileName(), msg, curKeyword.getLineNumber()); + deck.getMessageContainer().warning(msg, curKeyword.getFileName(), curKeyword.getLineNumber()); deckValid = false; } @@ -872,7 +857,7 @@ std::vector Parser::getAllDeckNames () const { std::string msg = "The keyword '"+curKeywordName+"' is located in the '"+curSectionName +"' section where it is invalid"; - deck.getMessageContainer().warning(curKeyword.getFileName(), msg, curKeyword.getLineNumber()); + deck.getMessageContainer().warning(msg, curKeyword.getFileName(), curKeyword.getLineNumber()); deckValid = false; } @@ -883,7 +868,7 @@ std::vector Parser::getAllDeckNames () const { if (curKeywordName != "GRID") { std::string msg = "The RUNSPEC section must be followed by GRID instead of "+curKeywordName; - deck.getMessageContainer().warning(curKeyword.getFileName(), msg, curKeyword.getLineNumber()); + deck.getMessageContainer().warning(msg, curKeyword.getFileName(), curKeyword.getLineNumber()); deckValid = false; } @@ -893,7 +878,7 @@ std::vector Parser::getAllDeckNames () const { if (curKeywordName != "EDIT" && curKeywordName != "PROPS") { std::string msg = "The GRID section must be followed by EDIT or PROPS instead of "+curKeywordName; - deck.getMessageContainer().warning(curKeyword.getFileName(), msg, curKeyword.getLineNumber()); + deck.getMessageContainer().warning(msg, curKeyword.getFileName(), curKeyword.getLineNumber()); deckValid = false; } @@ -903,7 +888,7 @@ std::vector Parser::getAllDeckNames () const { if (curKeywordName != "PROPS") { std::string msg = "The EDIT section must be followed by PROPS instead of "+curKeywordName; - deck.getMessageContainer().warning(curKeyword.getFileName(), msg, curKeyword.getLineNumber()); + deck.getMessageContainer().warning(msg, curKeyword.getFileName(), curKeyword.getLineNumber()); deckValid = false; } @@ -913,7 +898,7 @@ std::vector Parser::getAllDeckNames () const { if (curKeywordName != "REGIONS" && curKeywordName != "SOLUTION") { std::string msg = "The PROPS section must be followed by REGIONS or SOLUTION instead of "+curKeywordName; - deck.getMessageContainer().warning(curKeyword.getFileName(), msg, curKeyword.getLineNumber()); + deck.getMessageContainer().warning(msg, curKeyword.getFileName(), curKeyword.getLineNumber()); deckValid = false; } @@ -923,7 +908,7 @@ std::vector Parser::getAllDeckNames () const { if (curKeywordName != "SOLUTION") { std::string msg = "The REGIONS section must be followed by SOLUTION instead of "+curKeywordName; - deck.getMessageContainer().warning(curKeyword.getFileName(), msg, curKeyword.getLineNumber()); + deck.getMessageContainer().warning(msg, curKeyword.getFileName(), curKeyword.getLineNumber()); deckValid = false; } @@ -933,7 +918,7 @@ std::vector Parser::getAllDeckNames () const { if (curKeywordName != "SUMMARY" && curKeywordName != "SCHEDULE") { std::string msg = "The SOLUTION section must be followed by SUMMARY or SCHEDULE instead of "+curKeywordName; - deck.getMessageContainer().warning(curKeyword.getFileName(), msg, curKeyword.getLineNumber()); + deck.getMessageContainer().warning(msg, curKeyword.getFileName(), curKeyword.getLineNumber()); deckValid = false; } @@ -943,7 +928,7 @@ std::vector Parser::getAllDeckNames () const { if (curKeywordName != "SCHEDULE") { std::string msg = "The SUMMARY section must be followed by SCHEDULE instead of "+curKeywordName; - deck.getMessageContainer().warning(curKeyword.getFileName(), msg, curKeyword.getLineNumber()); + deck.getMessageContainer().warning(msg, curKeyword.getFileName(), curKeyword.getLineNumber()); deckValid = false; } @@ -954,7 +939,7 @@ std::vector Parser::getAllDeckNames () const { std::string msg = "The SCHEDULE section must be the last one (" +curKeywordName+" specified after SCHEDULE)"; - deck.getMessageContainer().warning(curKeyword.getFileName(), msg, curKeyword.getLineNumber()); + deck.getMessageContainer().warning(msg, curKeyword.getFileName(), curKeyword.getLineNumber()); deckValid = false; } } @@ -964,7 +949,7 @@ std::vector Parser::getAllDeckNames () const { const auto& curKeyword = deck.getKeyword(deck.size() - 1); std::string msg = "The last section of a valid deck must be SCHEDULE (is "+curSectionName+")"; - deck.getMessageContainer().warning(curKeyword.getFileName(), msg, curKeyword.getLineNumber()); + deck.getMessageContainer().warning(msg, curKeyword.getFileName(), curKeyword.getLineNumber()); deckValid = false; } diff --git a/ThirdParty/custom-opm-parser/opm-parser/opm/parser/eclipse/Parser/ParserItem.hpp b/ThirdParty/custom-opm-parser/opm-parser/opm/parser/eclipse/Parser/ParserItem.hpp index a8af51beb9..d2a5f094ef 100644 --- a/ThirdParty/custom-opm-parser/opm-parser/opm/parser/eclipse/Parser/ParserItem.hpp +++ b/ThirdParty/custom-opm-parser/opm-parser/opm/parser/eclipse/Parser/ParserItem.hpp @@ -199,17 +199,18 @@ namespace Opm { } else deckItem.push_back(readValueToken(st.valueString())); + const auto value_start = token.size() - valueString.size(); // replace the first occurence of "N*FOO" by a sequence of N-1 times - // "1*FOO". this is slightly hacky, but it makes it work if the + // "FOO". this is slightly hacky, but it makes it work if the // number of defaults pass item boundaries... - std::string singleRepetition; - if (st.hasValue()) - singleRepetition = st.valueString(); - else - singleRepetition = "1*"; + // We can safely make a string_view of one_star because it + // has static storage + static const char* one_star = "1*"; + string_view rep = !st.hasValue() + ? string_view{ one_star } + : string_view{ token.begin() + value_start, token.end() }; - for (size_t i=0; i < st.count() - 1; i++) - rawRecord.push_front(singleRepetition); + rawRecord.prepend( st.count() - 1, rep ); } else { deckItem.push_back( readValueToken( token ) ); } diff --git a/ThirdParty/custom-opm-parser/opm-parser/opm/parser/eclipse/Parser/ParserKeyword.cpp b/ThirdParty/custom-opm-parser/opm-parser/opm/parser/eclipse/Parser/ParserKeyword.cpp index 7545e45b5b..cfa07079d8 100644 --- a/ThirdParty/custom-opm-parser/opm-parser/opm/parser/eclipse/Parser/ParserKeyword.cpp +++ b/ThirdParty/custom-opm-parser/opm-parser/opm/parser/eclipse/Parser/ParserKeyword.cpp @@ -223,7 +223,7 @@ namespace Opm { string_view ParserKeyword::getDeckName( const string_view& str ) { - auto first_sep = std::find_if( str.begin(), str.end(), RawConsts::is_separator ); + auto first_sep = std::find_if( str.begin(), str.end(), RawConsts::is_separator() ); // only look at the first 8 characters (at most) if( std::distance( str.begin(), first_sep ) < 9 ) diff --git a/ThirdParty/custom-opm-parser/opm-parser/opm/parser/eclipse/Parser/ParserRecord.cpp b/ThirdParty/custom-opm-parser/opm-parser/opm/parser/eclipse/Parser/ParserRecord.cpp index 5056ac6c4f..1ae319a060 100644 --- a/ThirdParty/custom-opm-parser/opm-parser/opm/parser/eclipse/Parser/ParserRecord.cpp +++ b/ThirdParty/custom-opm-parser/opm-parser/opm/parser/eclipse/Parser/ParserRecord.cpp @@ -118,11 +118,10 @@ namespace Opm { } DeckRecord ParserRecord::parse(const ParseContext& parseContext , MessageContainer& msgContainer, RawRecord& rawRecord ) const { - DeckRecord deckRecord( size() + 20 ); - for (size_t i = 0; i < size(); i++) { - auto parserItem = get(i); - deckRecord.addItem( parserItem->scan( rawRecord ) ); - } + std::vector< DeckItem > items; + items.reserve( this->size() + 20 ); + for( const auto& parserItem : *this ) + items.emplace_back( parserItem->scan( rawRecord ) ); if (rawRecord.size() > 0) { std::string msg = "The RawRecord for keyword \"" + rawRecord.getKeywordName() + "\" in file\"" + rawRecord.getFileName() + "\" contained " + @@ -131,7 +130,7 @@ namespace Opm { parseContext.handleError(ParseContext::PARSE_EXTRA_DATA , msgContainer, msg); } - return deckRecord; + return { std::move( items ) }; } bool ParserRecord::equal(const ParserRecord& other) const { diff --git a/ThirdParty/custom-opm-parser/opm-parser/opm/parser/eclipse/Parser/UnitSystem.cpp b/ThirdParty/custom-opm-parser/opm-parser/opm/parser/eclipse/Parser/UnitSystem.cpp deleted file mode 100644 index dbeaeefb78..0000000000 --- a/ThirdParty/custom-opm-parser/opm-parser/opm/parser/eclipse/Parser/UnitSystem.cpp +++ /dev/null @@ -1,142 +0,0 @@ -/* - Copyright 2013 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 -#include -*/ - -#include -#include -#include - - -#include -#include - - -namespace Opm { - - UnitSystem::UnitSystem(const std::string& unitSystem) : - m_name( unitSystem ) - { - - } - - bool UnitSystem::hasDimension(const std::string& dimension) const { - return (m_dimensions.find( dimension ) != m_dimensions.end()); - } - - - const Dimension& UnitSystem::getDimension(const std::string& dimension) const { - if (hasDimension( dimension )) - return m_dimensions.at( dimension ); - else - throw std::invalid_argument("Dimension: " + dimension + " not recognized "); - } - - - void UnitSystem::addDimension(const std::string& dimension , double SI_factor) { - if (hasDimension(dimension)) - m_dimensions.erase( dimension ); - - m_dimensions.insert( std::make_pair(dimension , Dimension(dimension , SI_factor))); - } - - - const std::string& UnitSystem::getName() const { - return m_name; - } - - - std::shared_ptr UnitSystem::parseFactor(const std::string& dimension) const { - std::vector dimensionList; - boost::split(dimensionList , dimension , boost::is_any_of("*")); - double SIfactor = 1.0; - for (auto iter = dimensionList.begin(); iter != dimensionList.end(); ++iter) { - Dimension dim = getDimension( *iter ); - SIfactor *= dim.getSIScaling(); - } - return Dimension::newComposite( dimension , SIfactor ); - } - - - - std::shared_ptr UnitSystem::parse(const std::string& dimension) const { - bool haveDivisor; - { - size_t divCount = std::count( dimension.begin() , dimension.end() , '/' ); - if (divCount == 0) - haveDivisor = false; - else if (divCount == 1) - haveDivisor = true; - else - throw std::invalid_argument("Dimension string can only have one division sign /"); - } - - if (haveDivisor) { - std::vector parts; - boost::split(parts , dimension , boost::is_any_of("/")); - Dimension dividend = parseFactor( parts[0] ); - Dimension divisor = parseFactor( parts[1] ); - - return Dimension::newComposite( dimension , dividend.getSIScaling() / divisor.getSIScaling() ); - } else { - return parseFactor( dimension ); - } - } - - - UnitSystem * UnitSystem::newMETRIC() { - UnitSystem * system = new UnitSystem("Metric"); - - system->addDimension("1" , 1); - system->addDimension("Length" , 1); - system->addDimension("Time" , 86400 ); - system->addDimension("Mass" , 1 ); - system->addDimension("Pressure" , 100000 ); - system->addDimension("Permeability" , 9.869233e-10 ); - system->addDimension("Viscosity" , 0.001); // viscosity. ECLiPSE uses cP for metric units - system->addDimension("GasDissolutionFactor" , 1); // Gas dissolution factor. ECLiPSE uses m^3/m^3 for metric units - - return system; - } - - - - UnitSystem * UnitSystem::newFIELD() { - UnitSystem * system = new UnitSystem("Field"); - - system->addDimension("1" , 1); - system->addDimension("Length" , 0.3048); - system->addDimension("Time" , 86400 ); - system->addDimension("Mass" , 0.45359237 ); - system->addDimension("Pressure" , 6894.76 ); - system->addDimension("Permeability" , 9.869233e-10 ); - system->addDimension("Viscosity" , 0.001); // viscosity. ECLiPSE uses cP for field units - system->addDimension("GasDissolutionFactor" , 28.316847/0.15898729); // Gas dissolution factor. ECLiPSE uses Mscft/stb for field units - - return system; - } - -} - - - diff --git a/ThirdParty/custom-opm-parser/opm-parser/opm/parser/eclipse/Parser/tests/MessageContainerTest.cpp b/ThirdParty/custom-opm-parser/opm-parser/opm/parser/eclipse/Parser/tests/MessageContainerTest.cpp index 7720b26de9..6811f6bc2b 100644 --- a/ThirdParty/custom-opm-parser/opm-parser/opm/parser/eclipse/Parser/tests/MessageContainerTest.cpp +++ b/ThirdParty/custom-opm-parser/opm-parser/opm/parser/eclipse/Parser/tests/MessageContainerTest.cpp @@ -20,9 +20,7 @@ #define BOOST_TEST_MODULE MessageContainerTest -#include #include -#include #include diff --git a/ThirdParty/custom-opm-parser/opm-parser/opm/parser/eclipse/Parser/tests/ParseContextTests.cpp b/ThirdParty/custom-opm-parser/opm-parser/opm/parser/eclipse/Parser/tests/ParseContextTests.cpp index 53fad86db4..ee1eb72e5e 100644 --- a/ThirdParty/custom-opm-parser/opm-parser/opm/parser/eclipse/Parser/tests/ParseContextTests.cpp +++ b/ThirdParty/custom-opm-parser/opm-parser/opm/parser/eclipse/Parser/tests/ParseContextTests.cpp @@ -147,6 +147,15 @@ BOOST_AUTO_TEST_CASE( CheckUnsupportedInSCHEDULE ) { "RUNSPEC\n" "DIMENS\n" " 10 10 10 / \n" + "GRID\n" + "DX\n" + "1000*0.25 /\n" + "DY\n" + "1000*0.25 /\n" + "DZ\n" + "1000*0.25 /\n" + "TOPS\n" + "100*0.25 /\n" "SCHEDULE\n" "MULTZ\n" " 1000*0.10 /\n" @@ -158,6 +167,15 @@ BOOST_AUTO_TEST_CASE( CheckUnsupportedInSCHEDULE ) { "RUNSPEC\n" "DIMENS\n" " 10 10 10 / \n" + "GRID\n" + "DX\n" + "1000*0.25 /\n" + "DY\n" + "1000*0.25 /\n" + "DZ\n" + "1000*0.25 /\n" + "TOPS\n" + "100*0.25 /\n" "SCHEDULE\n" "MULTFLT\n" " 'F1' 0.10 /\n" @@ -170,7 +188,7 @@ BOOST_AUTO_TEST_CASE( CheckUnsupportedInSCHEDULE ) { auto deckSupported = parser.parseString( deckStringSupported , parseContext ); auto deckUnSupported = parser.parseString( deckStringUnSupported , parseContext ); - std::shared_ptr grid = std::make_shared( deckSupported ); + EclipseGrid grid( deckSupported ); parseContext.update( ParseContext::UNSUPPORTED_SCHEDULE_GEO_MODIFIER , InputError::IGNORE ); BOOST_CHECK_NO_THROW( Schedule( parseContext , grid , deckSupported )); @@ -226,6 +244,15 @@ BOOST_AUTO_TEST_CASE(TestCOMPORD) { "RUNSPEC\n" "DIMENS\n" " 10 10 10 / \n" + "GRID\n" + "DX\n" + "1000*0.25 /\n" + "DY\n" + "1000*0.25 /\n" + "DZ\n" + "1000*0.25 /\n" + "TOPS\n" + "100*0.25 /\n" "SCHEDULE\n" "COMPORD\n" " '*' 'DEPTH' /\n" @@ -235,7 +262,7 @@ BOOST_AUTO_TEST_CASE(TestCOMPORD) { Parser parser(true); auto deck = parser.parseString( deckString , parseContext ); - std::shared_ptr grid = std::make_shared( deck ); + EclipseGrid grid( deck ); parseContext.update( ParseContext::UNSUPPORTED_COMPORD_TYPE , InputError::IGNORE); BOOST_CHECK_NO_THROW( Schedule( parseContext , grid , deck )); diff --git a/ThirdParty/custom-opm-parser/opm-parser/opm/parser/eclipse/Parser/tests/ParserKeywordTests.cpp b/ThirdParty/custom-opm-parser/opm-parser/opm/parser/eclipse/Parser/tests/ParserKeywordTests.cpp index 360ac232c4..2ba100e9fb 100644 --- a/ThirdParty/custom-opm-parser/opm-parser/opm/parser/eclipse/Parser/tests/ParserKeywordTests.cpp +++ b/ThirdParty/custom-opm-parser/opm-parser/opm/parser/eclipse/Parser/tests/ParserKeywordTests.cpp @@ -20,9 +20,7 @@ #define BOOST_TEST_MODULE ParserTests -#include #include -#include #include @@ -40,6 +38,7 @@ using namespace Opm; +namespace { std::shared_ptr createFixedSized(const std::string& kw , size_t size) { std::shared_ptr pkw = std::make_shared(kw); @@ -64,6 +63,7 @@ std::shared_ptr createTable(const std::string& name, return pkw; } +} BOOST_AUTO_TEST_CASE(construct_withname_nameSet) { ParserKeywordConstPtr parserKeyword = createDynamicSized("BPR"); diff --git a/ThirdParty/custom-opm-parser/opm-parser/opm/parser/eclipse/Parser/tests/ParserTests.cpp b/ThirdParty/custom-opm-parser/opm-parser/opm/parser/eclipse/Parser/tests/ParserTests.cpp index 42b4ce6888..0dc24dd2c2 100644 --- a/ThirdParty/custom-opm-parser/opm-parser/opm/parser/eclipse/Parser/tests/ParserTests.cpp +++ b/ThirdParty/custom-opm-parser/opm-parser/opm/parser/eclipse/Parser/tests/ParserTests.cpp @@ -39,7 +39,7 @@ using namespace Opm; -std::unique_ptr< ParserKeyword > createDynamicSized(const std::string& kw) { +inline std::unique_ptr< ParserKeyword > createDynamicSized(const std::string& kw) { std::unique_ptr< ParserKeyword > pkw( new ParserKeyword( kw ) ); pkw->setSizeType(SLASH_TERMINATED); return pkw; @@ -331,7 +331,7 @@ SWOF 0.7500, 3.6350e-01, 4.4820e-04 0 0.8000, 4.7192e-01, 2.8000e-05 0 0.8500, 6.0000e-01, 0.0000e+00 0 - 0.9000, 7.4939e-01, 0.0000e+00 0 + 0.9000, 7.4939e-01, 0.0000e+00 0 / )"; @@ -339,13 +339,20 @@ SWOF } -BOOST_AUTO_TEST_CASE(BRILLIG_CASE) { - ParseContext parseContext; - parseContext.update(ParseContext::PARSE_RANDOM_SLASH, InputError::IGNORE); - parseContext.update(ParseContext::PARSE_RANDOM_TEXT, InputError::IGNORE); - parseContext.update(ParseContext::PARSE_UNKNOWN_KEYWORD, InputError::IGNORE); - Parser parser(true); - parser.newDeckFromFile("d:/Models/Statoil/Brillig/BRILLIG.DATA", parseContext); - //BOOST_CHECK_THROW(parser.newDeckFromFile("testdata/parser/PATHSInIncludeInvalid.data", ParseContext()), std::runtime_error); +BOOST_AUTO_TEST_CASE(ParseTNUM) { + const char * deck1 = + "REGIONS\n" + "TNUMFSGS\n" + " 100*1/\n" + "\n" + "TNUMFXXX\n" + " 100*1/\n" + "\n"; + + Opm::ParseContext parseContext; + Opm::Parser parser; + auto deck = parser.parseString( deck1 , parseContext ); + BOOST_CHECK( deck->hasKeyword("TNUMFSGS")); + BOOST_CHECK( deck->hasKeyword("TNUMFXXX")); } diff --git a/ThirdParty/custom-opm-parser/opm-parser/opm/parser/eclipse/RawDeck/RawConsts.hpp b/ThirdParty/custom-opm-parser/opm-parser/opm/parser/eclipse/RawDeck/RawConsts.hpp index a0595d9a57..16afc012d3 100644 --- a/ThirdParty/custom-opm-parser/opm-parser/opm/parser/eclipse/RawDeck/RawConsts.hpp +++ b/ThirdParty/custom-opm-parser/opm-parser/opm/parser/eclipse/RawDeck/RawConsts.hpp @@ -28,20 +28,60 @@ namespace Opm { namespace RawConsts { const char slash = '/'; const char quote = '\''; - const std::string separators = "\t "; const std::string include = "INCLUDE"; const std::string end = "END"; const std::string endinclude = "ENDINC"; const std::string paths = "PATHS"; const unsigned int maxKeywordLength = 8; - static inline bool is_separator( char ch ) { - return ' ' == ch || '\n' == ch || '\t' == ch || '\r' == ch; - } + constexpr bool sep_table[ 256 ] = { + 0, 0, 0, 0, 0, 0, 0, 0, 0, + 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, }; - static inline bool is_quote( char ch ) { - return ch == quote || ch == '"'; - } + struct is_separator { + /* + * ch is space, comma, \r, \n, \t, \v or \f => true + * else false + */ + bool operator()( char ch ) const { + return sep_table[ int( ch ) ]; + } + }; + + constexpr bool q_table[ 256 ] = { + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, }; + + struct is_quote { + /* + * ch is ' or " => true + * else false + */ + bool operator()( char ch ) const { + return q_table[ int( ch ) ]; + } + }; } } diff --git a/ThirdParty/custom-opm-parser/opm-parser/opm/parser/eclipse/RawDeck/RawRecord.cpp b/ThirdParty/custom-opm-parser/opm-parser/opm/parser/eclipse/RawDeck/RawRecord.cpp index 1568e9700e..192acd0220 100644 --- a/ThirdParty/custom-opm-parser/opm-parser/opm/parser/eclipse/RawDeck/RawRecord.cpp +++ b/ThirdParty/custom-opm-parser/opm-parser/opm/parser/eclipse/RawDeck/RawRecord.cpp @@ -33,48 +33,48 @@ using namespace std; namespace Opm { - template< typename Itr > - static inline Itr first_nonspace( Itr begin, Itr end ) { - return std::find_if_not( begin, end, RawConsts::is_separator ); - } +namespace { - static std::deque< string_view > splitSingleRecordString( const string_view& line ) { +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< string_view > dst; - string_view record( line ); - - for( auto current = first_nonspace( record.begin(), record.end() ); - current != record.end(); - current = first_nonspace( current, record.end() ) ) - { - if( *current == RawConsts::quote ) { - auto quote_end = std::find( current + 1, record.end(), RawConsts::quote ) + 1; - dst.push_back( { current, quote_end } ); - current = quote_end; - } else { - auto token_end = std::find_if( current, record.end(), RawConsts::is_separator ); - dst.push_back( { current, token_end } ); - current = token_end; - } + 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; + dst.push_back( { current, quote_end } ); + current = quote_end; + } else { + auto token_end = std::find_if( current, record.end(), RawConsts::is_separator() ); + dst.push_back( { current, token_end } ); + current = token_end; } - - return dst; } - /* - * It is assumed that after a record is terminated, there is no quote marks - * in the subsequent comment. This is in accordance with the Eclipse user - * manual. - * - * If a "non-complete" record string is supplied, an invalid_argument - * exception is thrown. - * - */ + return dst; +} - template< typename T > - static inline bool even_quotes( const T& str ) { - return std::count( str.begin(), str.end(), RawConsts::quote ) % 2 == 0; - } +/* + * It is assumed that after a record is terminated, there is no quote marks + * in the subsequent comment. This is in accordance with the Eclipse user + * manual. + * + * If a "non-complete" record string is supplied, an invalid_argument + * exception is thrown. + * + */ + +template< typename T > +inline bool even_quotes( const T& str ) { + return std::count( str.begin(), str.end(), RawConsts::quote ) % 2 == 0; +} + +} RawRecord::RawRecord(const string_view& singleRecordString, const std::string& fileName, @@ -100,9 +100,8 @@ namespace Opm { return m_keywordName; } - void RawRecord::push_front(std::string tok ) { - this->expanded_items.push_back( tok ); - this->m_recordItems.emplace_front( this->expanded_items.back() ); + void RawRecord::prepend( size_t count, string_view tok ) { + this->m_recordItems.insert( this->m_recordItems.begin(), count, tok ); } void RawRecord::dump() const { diff --git a/ThirdParty/custom-opm-parser/opm-parser/opm/parser/eclipse/RawDeck/RawRecord.hpp b/ThirdParty/custom-opm-parser/opm-parser/opm/parser/eclipse/RawDeck/RawRecord.hpp index 49a9814189..783f1618f7 100644 --- a/ThirdParty/custom-opm-parser/opm-parser/opm/parser/eclipse/RawDeck/RawRecord.hpp +++ b/ThirdParty/custom-opm-parser/opm-parser/opm/parser/eclipse/RawDeck/RawRecord.hpp @@ -38,7 +38,8 @@ namespace Opm { RawRecord( const string_view&, const std::string& fileName = "", const std::string& keywordName = ""); inline string_view pop_front(); - void push_front(std::string token); + void push_front( string_view token ); + void prepend( size_t count, string_view token ); inline size_t size() const; std::string getRecordString() const; @@ -53,7 +54,6 @@ namespace Opm { private: string_view m_sanitizedRecordString; std::deque< string_view > m_recordItems; - std::list< std::string > expanded_items; const std::string m_fileName; const std::string m_keywordName; diff --git a/ThirdParty/custom-opm-parser/opm-parser/opm/parser/eclipse/RawDeck/StarToken.cpp b/ThirdParty/custom-opm-parser/opm-parser/opm/parser/eclipse/RawDeck/StarToken.cpp index b82227f16a..e9edd2d331 100644 --- a/ThirdParty/custom-opm-parser/opm-parser/opm/parser/eclipse/RawDeck/StarToken.cpp +++ b/ThirdParty/custom-opm-parser/opm-parser/opm/parser/eclipse/RawDeck/StarToken.cpp @@ -24,10 +24,12 @@ #include #include +#include + #include #include - +namespace qi = boost::spirit::qi; namespace Opm { @@ -69,55 +71,38 @@ namespace Opm { template<> 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( view.empty() ) throw std::invalid_argument( "Empty input string" ); - - char* end; - auto value = std::strtol( view.begin(), &end, 10 ); - - if( std::distance( view.begin(), (const char*)end ) != int( view.size() ) ) - throw std::invalid_argument( "Expected integer, got '" + view + "'" ); - - return value; + if( ok && cursor == view.end() ) return n; + throw std::invalid_argument( "Malformed integer '" + view + "'" ); } - static inline bool fortran_float( char ch ) { - return ch == 'd' || ch == 'D' || ch == 'E'; - } + template< typename T > + struct fortran_double : qi::real_policies< T > { + // Eclipse supports Fortran syntax for specifying exponents of floating point + // numbers ('D' and 'E', e.g., 1.234d5) + template< typename It > + static bool parse_exp( It& first, const It& last ) { + if( first == last || + (*first != 'e' && *first != 'E' && + *first != 'd' && *first != 'D' ) ) + return false; + ++first; + return true; + } + }; template<> double readValueToken< double >( string_view view ) { - if( view.empty() ) throw std::invalid_argument( "Empty input string" ); + 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 ); - char* end; - auto value = std::strtod( view.begin(), &end ); - if( std::distance( view.begin(), (const char*) end ) == int( view.size() ) ) - return value; - - // Eclipse supports Fortran syntax for specifying exponents of floating point - // numbers ('D' and 'E', e.g., 1.234d5) while C++ only supports the 'e' (e.g., - // 1.234e5). the quick fix is to replace 'D' by 'E' and 'd' by 'e' before trying - // to convert the string into a floating point value. - - const auto width = 64; - - if( view.size() > width ) throw std::invalid_argument( - "Maximum 'double' length is " + std::to_string( width ) - ); - - std::array< char, width > buffer {}; - std::copy( view.begin(), view.end(), buffer.begin() ); - - - auto fortran = std::find_if( buffer.begin(), buffer.end(), fortran_float ); - if( fortran != buffer.end() ) - *fortran = 'e'; - - value = std::strtod( buffer.data(), &end ); - if( std::distance( buffer.data(), end ) == int( view.size() ) ) - return value; - - throw std::invalid_argument( "Expected double, got: '" + view + "'" ); + if( ok && cursor == view.end() ) return n; + throw std::invalid_argument( "Malformed floating point number '" + view + "'" ); } template <> diff --git a/ThirdParty/custom-opm-parser/opm-parser/opm/parser/eclipse/RawDeck/tests/RawRecordTests.cpp b/ThirdParty/custom-opm-parser/opm-parser/opm/parser/eclipse/RawDeck/tests/RawRecordTests.cpp index 913f30c7e3..b95e31f92b 100644 --- a/ThirdParty/custom-opm-parser/opm-parser/opm/parser/eclipse/RawDeck/tests/RawRecordTests.cpp +++ b/ThirdParty/custom-opm-parser/opm-parser/opm/parser/eclipse/RawDeck/tests/RawRecordTests.cpp @@ -60,8 +60,8 @@ BOOST_AUTO_TEST_CASE(Rawrecord_OperatorThis_OK) { BOOST_AUTO_TEST_CASE(Rawrecord_PushFront_OK) { Opm::RawRecordPtr record(new Opm::RawRecord(" 'NODIR ' 'REVERS' 1 20 ")); - record->push_front("String2"); - record->push_front("String1"); + record->prepend( 1, "String2" ); + record->prepend( 1, "String1" ); BOOST_CHECK_EQUAL("String1", record->getItem(0)); @@ -72,8 +72,8 @@ BOOST_AUTO_TEST_CASE(Rawrecord_size_OK) { Opm::RawRecordPtr record(new Opm::RawRecord(" 'NODIR ' 'REVERS' 1 20 ")); BOOST_CHECK_EQUAL(4U, record->size()); - record->push_front("String2"); - record->push_front("String1"); + record->prepend( 1, "String2"); + record->prepend( 1, "String1"); BOOST_CHECK_EQUAL(6U, record->size()); } diff --git a/ThirdParty/custom-opm-parser/opm-parser/opm/parser/eclipse/Units/ConversionFactors.hpp b/ThirdParty/custom-opm-parser/opm-parser/opm/parser/eclipse/Units/ConversionFactors.hpp index 03cd1babb6..46b78fc3b9 100644 --- a/ThirdParty/custom-opm-parser/opm-parser/opm/parser/eclipse/Units/ConversionFactors.hpp +++ b/ThirdParty/custom-opm-parser/opm-parser/opm/parser/eclipse/Units/ConversionFactors.hpp @@ -51,13 +51,13 @@ namespace Opm { namespace prefix /// Conversion prefix for units. { - const double micro = 1.0e-6; /**< Unit prefix [\f$\mu\f$] */ - const double milli = 1.0e-3; /**< Unit prefix [m] */ - const double centi = 1.0e-2; /**< Non-standard unit prefix [c] */ - const double deci = 1.0e-1; /**< Non-standard unit prefix [d] */ - const double kilo = 1.0e3; /**< Unit prefix [k] */ - const double mega = 1.0e6; /**< Unit prefix [M] */ - const double giga = 1.0e9; /**< Unit prefix [G] */ + constexpr const double micro = 1.0e-6; /**< Unit prefix [\f$\mu\f$] */ + constexpr const double milli = 1.0e-3; /**< Unit prefix [m] */ + constexpr const double centi = 1.0e-2; /**< Non-standard unit prefix [c] */ + constexpr const double deci = 1.0e-1; /**< Non-standard unit prefix [d] */ + constexpr const double kilo = 1.0e3; /**< Unit prefix [k] */ + constexpr const double mega = 1.0e6; /**< Unit prefix [M] */ + constexpr const double giga = 1.0e9; /**< Unit prefix [G] */ } // namespace prefix namespace unit @@ -78,8 +78,8 @@ namespace Opm { { ///\name Common powers /// @{ - inline double square(double v) { return v * v; } - inline double cubic (double v) { return v * v * v; } + constexpr double square(double v) { return v * v; } + constexpr double cubic (double v) { return v * v * v; } /// @} // -------------------------------------------------------------- @@ -88,32 +88,33 @@ namespace Opm { /// \name Length /// @{ - const double meter = 1; - const double inch = 2.54 * prefix::centi*meter; - const double feet = 12 * inch; + constexpr const double meter = 1; + constexpr const double inch = 2.54 * prefix::centi*meter; + constexpr const double feet = 12 * inch; /// @} /// \name Time /// @{ - const double second = 1; - const double minute = 60 * second; - const double hour = 60 * minute; - const double day = 24 * hour; - const double year = 365 * day; + constexpr const double second = 1; + constexpr const double minute = 60 * second; + constexpr const double hour = 60 * minute; + constexpr const double day = 24 * hour; + constexpr const double year = 365 * day; /// @} /// \name Volume /// @{ - const double gallon = 231 * cubic(inch); - const double stb = 42 * gallon; - const double liter = 1 * cubic(prefix::deci*meter); + constexpr const double gallon = 231 * cubic(inch); + constexpr const double stb = 42 * gallon; + constexpr const double _liter = 1 * cubic(prefix::deci*meter); /// @} /// \name Mass /// @{ - const double kilogram = 1; + constexpr const double kilogram = 1; + constexpr const double gram = 1.0e-3 * kilogram; // http://en.wikipedia.org/wiki/Pound_(mass)#Avoirdupois_pound - const double pound = 0.45359237 * kilogram; + constexpr const double pound = 0.45359237 * kilogram; /// @} // -------------------------------------------------------------- @@ -122,7 +123,7 @@ namespace Opm { /// \name Standardised constant /// @{ - const double gravity = 9.80665 * meter/square(second); + constexpr const double gravity = 9.80665 * meter/square(second); /// @} // -------------------------------------------------------------- @@ -131,16 +132,17 @@ namespace Opm { /// \name Force /// @{ - const double Newton = kilogram*meter / square(second); // == 1 - const double lbf = pound * gravity; // Pound-force + constexpr const double Newton = kilogram*meter / square(second); // == 1 + constexpr const double dyne = 1e-5*Newton; + constexpr const double lbf = pound * gravity; // Pound-force /// @} /// \name Pressure /// @{ - const double Pascal = Newton / square(meter); // == 1 - const double barsa = 100000 * Pascal; - const double atm = 101325 * Pascal; - const double psia = lbf / square(inch); + constexpr const double Pascal = Newton / square(meter); // == 1 + constexpr const double barsa = 100000 * Pascal; + constexpr const double atm = 101325 * Pascal; + constexpr const double psia = lbf / square(inch); /// @} /// \name Temperature. This one is more complicated @@ -149,26 +151,26 @@ namespace Opm { /// subtract an offset for the conversion between from/to /// Kelvin /// @{ - const double degCelsius = 1.0; // scaling factor °C -> K - const double degCelsiusOffset = 273.15; // offset for the °C -> K conversion + constexpr const double degCelsius = 1.0; // scaling factor °C -> K + constexpr const double degCelsiusOffset = 273.15; // offset for the °C -> K conversion - const double degFahrenheit = 5.0/9; // scaling factor °F -> K - const double degFahrenheitOffset = 255.37; // offset for the °C -> K conversion + constexpr const double degFahrenheit = 5.0/9; // scaling factor °F -> K + constexpr const double degFahrenheitOffset = 255.37; // offset for the °C -> K conversion /// @} /// \name Viscosity /// @{ - const double Pas = Pascal * second; // == 1 - const double Poise = prefix::deci*Pas; + constexpr const double Pas = Pascal * second; // == 1 + constexpr const double Poise = prefix::deci*Pas; /// @} namespace perm_details { - const double p_grad = atm / (prefix::centi*meter); - const double area = square(prefix::centi*meter); - const double flux = cubic (prefix::centi*meter) / second; - const double velocity = flux / area; - const double visc = prefix::centi*Poise; - const double darcy = (velocity * visc) / p_grad; + constexpr const double p_grad = atm / (prefix::centi*meter); + constexpr const double area = square(prefix::centi*meter); + constexpr const double flux = cubic (prefix::centi*meter) / second; + constexpr const double velocity = flux / area; + constexpr const double visc = prefix::centi*Poise; + constexpr const double darcy = (velocity * visc) / p_grad; // == 1e-7 [m^2] / 101325 // == 9.869232667160130e-13 [m^2] } @@ -181,7 +183,7 @@ namespace Opm { /// of \f$1\,\mathit{atm}/\mathit{cm}\f$ acting across an area of /// \f$1\,\mathit{cm}^2\f$. /// - const double darcy = perm_details::darcy; + constexpr const double darcy = perm_details::darcy; /// @} } @@ -191,50 +193,78 @@ namespace Opm { namespace Metric { using namespace details::prefix; using namespace details::unit; - const double Pressure = barsa; - const double Temperature = degCelsius; - const double TemperatureOffset = degCelsiusOffset; - const double AbsoluteTemperature = degCelsius; // actually [K], but the these two are identical - const double Length = meter; - const double Time = day; - const double Mass = kilogram; - const double Permeability = milli*darcy; - const double Transmissibility = centi*Poise*cubic(meter)/(day*barsa); - const double LiquidSurfaceVolume = cubic(meter); - const double GasSurfaceVolume = cubic(meter); - const double ReservoirVolume = cubic(meter); - const double GasDissolutionFactor = GasSurfaceVolume/LiquidSurfaceVolume; - const double OilDissolutionFactor = LiquidSurfaceVolume/GasSurfaceVolume; - const double Density = kilogram/cubic(meter); - const double PolymerDensity = kilogram/cubic(meter); - const double Salinity = kilogram/cubic(meter); - const double Viscosity = centi*Poise; - const double Timestep = day; + constexpr const double Pressure = barsa; + constexpr const double Temperature = degCelsius; + constexpr const double TemperatureOffset = degCelsiusOffset; + constexpr const double AbsoluteTemperature = degCelsius; // actually [K], but the these two are identical + constexpr const double Length = meter; + constexpr const double Time = day; + constexpr const double Mass = kilogram; + constexpr const double Permeability = milli*darcy; + constexpr const double Transmissibility = centi*Poise*cubic(meter)/(day*barsa); + constexpr const double LiquidSurfaceVolume = cubic(meter); + constexpr const double GasSurfaceVolume = cubic(meter); + constexpr const double ReservoirVolume = cubic(meter); + constexpr const double GasDissolutionFactor = GasSurfaceVolume/LiquidSurfaceVolume; + constexpr const double OilDissolutionFactor = LiquidSurfaceVolume/GasSurfaceVolume; + constexpr const double Density = kilogram/cubic(meter); + constexpr const double PolymerDensity = kilogram/cubic(meter); + constexpr const double Salinity = kilogram/cubic(meter); + constexpr const double Viscosity = centi*Poise; + constexpr const double Timestep = day; + constexpr const double SurfaceTension = dyne/(centi*meter); } namespace Field { using namespace details::prefix; using namespace details::unit; - const double Pressure = psia; - const double Temperature = degFahrenheit; - const double TemperatureOffset = degFahrenheitOffset; - const double AbsoluteTemperature = degFahrenheit; // actually [°R], but the these two are identical - const double Length = feet; - const double Time = day; - const double Mass = pound; - const double Permeability = milli*darcy; - const double Transmissibility = centi*Poise*stb/(day*psia); - const double LiquidSurfaceVolume = stb; - const double GasSurfaceVolume = 1000*cubic(feet); - const double ReservoirVolume = stb; - const double GasDissolutionFactor = GasSurfaceVolume/LiquidSurfaceVolume; - const double OilDissolutionFactor = LiquidSurfaceVolume/GasSurfaceVolume; - const double Density = pound/cubic(feet); - const double PolymerDensity = pound/stb; - const double Salinity = pound/stb; - const double Viscosity = centi*Poise; - const double Timestep = day; + constexpr const double Pressure = psia; + constexpr const double Temperature = degFahrenheit; + constexpr const double TemperatureOffset = degFahrenheitOffset; + constexpr const double AbsoluteTemperature = degFahrenheit; // actually [°R], but the these two are identical + constexpr const double Length = feet; + constexpr const double Time = day; + constexpr const double Mass = pound; + constexpr const double Permeability = milli*darcy; + constexpr const double Transmissibility = centi*Poise*stb/(day*psia); + constexpr const double LiquidSurfaceVolume = stb; + constexpr const double GasSurfaceVolume = 1000*cubic(feet); + constexpr const double ReservoirVolume = stb; + constexpr const double GasDissolutionFactor = GasSurfaceVolume/LiquidSurfaceVolume; + constexpr const double OilDissolutionFactor = LiquidSurfaceVolume/GasSurfaceVolume; + constexpr const double Density = pound/cubic(feet); + constexpr const double PolymerDensity = pound/stb; + constexpr const double Salinity = pound/stb; + constexpr const double Viscosity = centi*Poise; + constexpr const double Timestep = day; + constexpr const double SurfaceTension = dyne/(centi*meter); + } + + + namespace Lab { + using namespace details::prefix; + using namespace details::unit; + constexpr const double Pressure = atm; + constexpr const double Temperature = degCelsius; + constexpr const double TemperatureOffset = degCelsiusOffset; + constexpr const double AbsoluteTemperature = degCelsius; // actually [K], but the these two are identical + constexpr const double Length = centi*meter; + constexpr const double Time = hour; + constexpr const double Mass = gram; + constexpr const double Permeability = milli*darcy; + constexpr const double Transmissibility = centi*Poise*cubic(centi*meter)/(hour*atm); + constexpr const double LiquidSurfaceVolume = cubic(centi*meter); + constexpr const double GasSurfaceVolume = cubic(centi*meter); + constexpr const double ReservoirVolume = cubic(centi*meter); + constexpr const double GasDissolutionFactor = GasSurfaceVolume/LiquidSurfaceVolume; + constexpr const double OilDissolutionFactor = LiquidSurfaceVolume/GasSurfaceVolume; + constexpr const double Density = gram/cubic(centi*meter); + constexpr const double PolymerDensity = gram/cubic(centi*meter); + constexpr const double Salinity = gram/cubic(centi*meter); + constexpr const double Viscosity = centi*Poise; + constexpr const double Timestep = hour; + constexpr const double SurfaceTension = dyne/(centi*meter); } } diff --git a/ThirdParty/custom-opm-parser/opm-parser/opm/parser/eclipse/Units/UnitSystem.cpp b/ThirdParty/custom-opm-parser/opm-parser/opm/parser/eclipse/Units/UnitSystem.cpp index fe19b57be6..a2fa5790a1 100644 --- a/ThirdParty/custom-opm-parser/opm-parser/opm/parser/eclipse/Units/UnitSystem.cpp +++ b/ThirdParty/custom-opm-parser/opm-parser/opm/parser/eclipse/Units/UnitSystem.cpp @@ -40,6 +40,7 @@ namespace { */ static const double to_metric[] = { + 1, 1 / Metric::Length, 1 / Metric::Time, 1 / Metric::Density, @@ -56,9 +57,19 @@ namespace { 1 / ( Metric::ReservoirVolume / Metric::Time ), 1 / Metric::Transmissibility, 1 / Metric::Mass, + 1, /* gas-oil ratio */ + 1, /* oil-gas ratio */ + 1, /* water cut */ + 1, /* gas formation volume factor */ + 1, /* oil formation volume factor */ + 1, /* water formation volume factor */ + 1, /* gas inverse formation volume factor */ + 1, /* oil inverse formation volume factor */ + 1, /* water inverse formation volume factor */ }; static const double from_metric[] = { + 1, Metric::Length, Metric::Time, Metric::Density, @@ -75,9 +86,48 @@ namespace { Metric::ReservoirVolume / Metric::Time, Metric::Transmissibility, Metric::Mass, + 1, /* gas-oil ratio */ + 1, /* oil-gas ratio */ + 1, /* water cut */ + 1, /* gas formation volume factor */ + 1, /* oil formation volume factor */ + 1, /* water formation volume factor */ + 1, /* gas inverse formation volume factor */ + 1, /* oil inverse formation volume factor */ + 1, /* water inverse formation volume factor */ + }; + + static constexpr const char* metric_names[] = { + "", + "M", + "DAY", + "KG/M3", + "BARSA", + "K", + "C", + "CP", + "MD", + "SM3", + "SM3", + "RM3", + "SM3/DAY", + "SM3/DAY", + "RM3/DAY", + "CPR3/DAY/BARS", + "KG", + "SM3/SM3", + "SM3/SM3", + "SM3/SM3", + "RM3/SM3", /* gas formation volume factor */ + "RM3/SM3", /* oil formation volume factor */ + "RM3/SM3", /* water formation volume factor */ + "SM3/RM3", /* gas inverse formation volume factor */ + "SM3/RM3", /* oil inverse formation volume factor */ + "SM3/RM3", /* water inverse formation volume factor */ }; static const double to_field[] = { + 1, 1 / Field::Length, 1 / Field::Time, 1 / Field::Density, @@ -94,9 +144,19 @@ namespace { 1 / ( Field::ReservoirVolume / Field::Time ), 1 / Field::Transmissibility, 1 / Field::Mass, + 1, /* gas-oil ratio */ + 1, /* oil-gas ratio */ + 1, /* water cut */ + 1 / (Field::ReservoirVolume / Field::GasSurfaceVolume), /* gas formation volume factor */ + 1, /* oil formation volume factor */ + 1, /* water formation volume factor */ + 1 / (Field::GasSurfaceVolume / Field::ReservoirVolume), /* gas inverse formation volume factor */ + 1, /* oil inverse formation volume factor */ + 1, /* water inverse formation volume factor */ }; static const double from_field[] = { + 1, Field::Length, Field::Time, Field::Density, @@ -113,8 +173,132 @@ namespace { Field::ReservoirVolume / Field::Time, Field::Transmissibility, Field::Mass, + 1, /* gas-oil ratio */ + 1, /* oil-gas ratio */ + 1, /* water cut */ + Field::ReservoirVolume / Field::GasSurfaceVolume, /* gas formation volume factor */ + 1, /* oil formation volume factor */ + 1, /* water formation volume factor */ + Field::GasSurfaceVolume / Field::ReservoirVolume, /* gas inverse formation volume factor */ + 1, /* oil inverse formation volume factor */ + 1, /* water inverse formation volume factor */ }; + static constexpr const char* field_names[] = { + "", + "FT", + "DAY", + "LB/FT3", + "PSIA", + "R", + "F", + "CP", + "MD", + "STB", + "MSCF", + "RB", + "STB/DAY", + "MSCF/DAY", + "RB/DAY", + "CPRB/DAY/PSI", + "LB", + "MSCF/STB", + "STB/MSCF", + "STB/STB", + "RB/MSCF", /* gas formation volume factor */ + "RB/STB", /* oil formation volume factor */ + "RB/STB", /* water formation volume factor */ + "MSCF/RB", /* gas inverse formation volume factor */ + "STB/RB", /* oil inverse formation volume factor */ + "STB/RB", /* water inverse formation volume factor */ + }; + + static const double to_lab[] = { + 1, + 1 / Lab::Length, + 1 / Lab::Time, + 1 / Lab::Density, + 1 / Lab::Pressure, + 1 / Lab::AbsoluteTemperature, + 1 / Lab::Temperature, + 1 / Lab::Viscosity, + 1 / Lab::Permeability, + 1 / Lab::LiquidSurfaceVolume, + 1 / Lab::GasSurfaceVolume, + 1 / Lab::ReservoirVolume, + 1 / ( Lab::LiquidSurfaceVolume / Lab::Time ), + 1 / ( Lab::GasSurfaceVolume / Lab::Time ), + 1 / ( Lab::ReservoirVolume / Lab::Time ), + 1 / Lab::Transmissibility, + 1 / Lab::Mass, + 1 / Lab::GasDissolutionFactor, /* gas-oil ratio */ + 1 / Lab::OilDissolutionFactor, /* oil-gas ratio */ + 1, /* water cut */ + 1, /* gas formation volume factor */ + 1, /* oil formation volume factor */ + 1, /* water formation volume factor */ + 1, /* gas inverse formation volume factor */ + 1, /* oil inverse formation volume factor */ + 1, /* water inverse formation volume factor */ + }; + + static const double from_lab[] = { + 1, + Lab::Length, + Lab::Time, + Lab::Density, + Lab::Pressure, + Lab::AbsoluteTemperature, + Lab::Temperature, + Lab::Viscosity, + Lab::Permeability, + Lab::LiquidSurfaceVolume, + Lab::GasSurfaceVolume, + Lab::ReservoirVolume, + Lab::LiquidSurfaceVolume / Lab::Time, + Lab::GasSurfaceVolume / Lab::Time, + Lab::ReservoirVolume / Lab::Time, + Lab::Transmissibility, + Lab::Mass, + Lab::GasDissolutionFactor, /* gas-oil ratio */ + Lab::OilDissolutionFactor, /* oil-gas ratio */ + 1, /* water cut */ + 1, /* gas formation volume factor */ + 1, /* oil formation volume factor */ + 1, /* water formation volume factor */ + 1, /* gas inverse formation volume factor */ + 1, /* oil inverse formation volume factor */ + 1, /* water inverse formation volume factor */ + }; + + static constexpr const char* lab_names[] = { + "", + "CM", + "HR", + "G/CC", + "ATM", + "K", + "C", + "CP", + "MD", + "SCC", + "SCC", + "RCC", + "SCC/HR", + "SCC/HR", + "RCC/HR", + "CPRCC/HR/ATM", + "G", + "SCC/SCC", + "SCC/SCC", + "SCC/SCC", + "RCC/SCC", /* gas formation volume factor */ + "RCC/SCC", /* oil formation volume factor */ + "RCC/SCC", /* water formation volume factor */ + "SCC/RCC", /* gas formation volume factor */ + "SCC/RCC", /* oil inverse formation volume factor */ + "SCC/RCC", /* water inverse formation volume factor */ + }; } UnitSystem::UnitSystem(const UnitType unit) : @@ -125,15 +309,19 @@ namespace { m_name = "Metric"; this->measure_table_from_si = to_metric; this->measure_table_to_si = from_metric; + this->unit_name_table = metric_names; break; case(UNIT_TYPE_FIELD): m_name = "Field"; this->measure_table_from_si = to_field; this->measure_table_to_si = from_field; + this->unit_name_table = field_names; break; case(UNIT_TYPE_LAB): m_name = "Lab"; - throw std::runtime_error( "Lab unit system is not supported" ); + this->measure_table_from_si = to_lab; + this->measure_table_to_si = from_lab; + this->unit_name_table = lab_names; break; default: //do nothing @@ -259,6 +447,25 @@ namespace { return this->measure_table_to_si[ static_cast< int >( m ) ] * val; } + void UnitSystem::from_si( measure m, std::vector& data ) const { + double factor = this->measure_table_from_si[ static_cast< int >( m ) ]; + auto scale = [=](double x) { return x * factor; }; + std::transform( data.begin() , data.end() , data.begin() , scale); + } + + + void UnitSystem::to_si( measure m, std::vector& data) const { + double factor = this->measure_table_to_si[ static_cast< int >( m ) ]; + auto scale = [=](double x) { return x * factor; }; + std::transform( data.begin() , data.end() , data.begin() , scale); + } + + + + const char* UnitSystem::name( measure m ) const { + return this->unit_name_table[ static_cast< int >( m ) ]; + } + UnitSystem * UnitSystem::newMETRIC() { UnitSystem * system = new UnitSystem(UNIT_TYPE_METRIC); @@ -281,6 +488,7 @@ namespace { system->addDimension("Salinity", Metric::Salinity); system->addDimension("Viscosity" , Metric::Viscosity); system->addDimension("Timestep" , Metric::Timestep); + system->addDimension("SurfaceTension" , Metric::SurfaceTension); system->addDimension("ContextDependent", std::numeric_limits::quiet_NaN()); return system; } @@ -309,6 +517,36 @@ namespace { system->addDimension("Salinity", Field::Salinity); system->addDimension("Viscosity", Field::Viscosity); system->addDimension("Timestep", Field::Timestep); + system->addDimension("SurfaceTension" , Field::SurfaceTension); + system->addDimension("ContextDependent", std::numeric_limits::quiet_NaN()); + return system; + } + + + + UnitSystem * UnitSystem::newLAB() { + UnitSystem * system = new UnitSystem(UNIT_TYPE_LAB); + + system->addDimension("1" , 1.0); + system->addDimension("Pressure", Lab::Pressure ); + system->addDimension("Temperature", Lab::Temperature, Lab::TemperatureOffset); + system->addDimension("AbsoluteTemperature", Lab::AbsoluteTemperature); + system->addDimension("Length", Lab::Length); + system->addDimension("Time" , Lab::Time); + system->addDimension("Mass", Lab::Mass); + system->addDimension("Permeability", Lab::Permeability ); + system->addDimension("Transmissibility", Lab::Transmissibility ); + system->addDimension("GasDissolutionFactor" , Lab::GasDissolutionFactor); + system->addDimension("OilDissolutionFactor", Lab::OilDissolutionFactor); + system->addDimension("LiquidSurfaceVolume", Lab::LiquidSurfaceVolume ); + system->addDimension("GasSurfaceVolume", Lab::GasSurfaceVolume ); + system->addDimension("ReservoirVolume", Lab::ReservoirVolume ); + system->addDimension("Density", Lab::Density ); + system->addDimension("PolymerDensity", Lab::PolymerDensity); + system->addDimension("Salinity", Lab::Salinity); + system->addDimension("Viscosity", Lab::Viscosity); + system->addDimension("Timestep", Lab::Timestep); + system->addDimension("SurfaceTension" , Lab::SurfaceTension); system->addDimension("ContextDependent", std::numeric_limits::quiet_NaN()); return system; } diff --git a/ThirdParty/custom-opm-parser/opm-parser/opm/parser/eclipse/Units/UnitSystem.hpp b/ThirdParty/custom-opm-parser/opm-parser/opm/parser/eclipse/Units/UnitSystem.hpp index e160186fe5..d22e6f3be2 100644 --- a/ThirdParty/custom-opm-parser/opm-parser/opm/parser/eclipse/Units/UnitSystem.hpp +++ b/ThirdParty/custom-opm-parser/opm-parser/opm/parser/eclipse/Units/UnitSystem.hpp @@ -22,6 +22,7 @@ #include #include +#include #include namespace Opm { @@ -37,6 +38,7 @@ namespace Opm { }; enum class measure : int { + identity, length, time, density, @@ -53,6 +55,15 @@ namespace Opm { rate, transmissibility, mass, + gas_oil_ratio, + oil_gas_ratio, + water_cut, + gas_formation_volume_factor, + oil_formation_volume_factor, + water_formation_volume_factor, + gas_inverse_formation_volume_factor, + oil_inverse_formation_volume_factor, + water_inverse_formation_volume_factor, }; UnitSystem(UnitType unit); @@ -71,9 +82,13 @@ namespace Opm { double from_si( measure, double ) const; double to_si( measure, double ) const; + void from_si( measure, std::vector& ) const; + void to_si( measure, std::vector& ) const; + const char* name( measure ) const; static UnitSystem * newMETRIC(); static UnitSystem * newFIELD(); + static UnitSystem * newLAB(); private: std::shared_ptr parseFactor(const std::string& dimension) const; @@ -82,6 +97,7 @@ namespace Opm { std::map > m_dimensions; const double* measure_table_from_si; const double* measure_table_to_si; + const char* const* unit_name_table; }; } diff --git a/ThirdParty/custom-opm-parser/opm-parser/opm/parser/eclipse/Units/tests/COMPSEGUnits.cpp b/ThirdParty/custom-opm-parser/opm-parser/opm/parser/eclipse/Units/tests/COMPSEGUnits.cpp index 3d3ad5a36c..20c0fdb8bd 100644 --- a/ThirdParty/custom-opm-parser/opm-parser/opm/parser/eclipse/Units/tests/COMPSEGUnits.cpp +++ b/ThirdParty/custom-opm-parser/opm-parser/opm/parser/eclipse/Units/tests/COMPSEGUnits.cpp @@ -19,9 +19,7 @@ #define BOOST_TEST_MODULE COMPSEGUNITS -#include #include -#include #include #include @@ -33,7 +31,7 @@ using namespace Opm; -std::shared_ptr createCOMPSEGSDeck() { +inline std::shared_ptr createCOMPSEGSDeck() { const char *deckData = "COMPSEGS\n" " WELL /\n" diff --git a/ThirdParty/custom-opm-parser/opm-parser/opm/parser/eclipse/Units/tests/UnitTests.cpp b/ThirdParty/custom-opm-parser/opm-parser/opm/parser/eclipse/Units/tests/UnitTests.cpp index 2bc766bc0b..4cf311dd24 100644 --- a/ThirdParty/custom-opm-parser/opm-parser/opm/parser/eclipse/Units/tests/UnitTests.cpp +++ b/ThirdParty/custom-opm-parser/opm-parser/opm/parser/eclipse/Units/tests/UnitTests.cpp @@ -188,3 +188,41 @@ BOOST_AUTO_TEST_CASE(UnitSystemEqual) { +BOOST_AUTO_TEST_CASE(LabUnitConversions) { + using Meas = UnitSystem::measure; + + auto lab = std::unique_ptr( UnitSystem::newLAB() ); + + { + const auto furlong = 660*details::unit::feet; + BOOST_CHECK_CLOSE( 2.01168e4 , lab->from_si( Meas::length , furlong ) , 1.0e-10 ); + BOOST_CHECK_CLOSE( furlong , lab->to_si( Meas::length , 2.01168e4 ) , 1.0e-10 ); + } + + struct Factor { Meas m; double f; }; + + for (const auto& q : { Factor{ Meas::density , 1.0e3 } , + Factor{ Meas::pressure , 101325.0 } , + Factor{ Meas::viscosity , 1.0e-3 } , + Factor{ Meas::liquid_surface_volume , 1.0e-6 } , + Factor{ Meas::gas_surface_volume , 1.0e-6 } , + Factor{ Meas::time , 3600.0 } , + Factor{ Meas::mass , 1.0e-3 } }) + { + BOOST_CHECK_CLOSE( q.f , lab->to_si( q.m , 1.0 ) , 1.0e-10 ); + BOOST_CHECK_CLOSE( 1.0 , lab->from_si( q.m , q.f ) , 1.0e-10 ); + } +} + + +BOOST_AUTO_TEST_CASE( VectorConvert ) { + std::vector d0 = {1,2,3}; + std::vector d1 = {1,2,3}; + UnitSystem * units = UnitSystem::newLAB(); + + units->from_si( UnitSystem::measure::pressure , d0 ); + for (size_t i = 0; i < d1.size(); i++) + BOOST_CHECK_EQUAL( units->from_si( UnitSystem::measure::pressure , d1[i] ) , d0[i]); + + delete units; +} diff --git a/ThirdParty/custom-opm-parser/opm-parser/opm/parser/eclipse/Utility/Functional.cpp b/ThirdParty/custom-opm-parser/opm-parser/opm/parser/eclipse/Utility/Functional.cpp index 21efaa31e7..706715b760 100644 --- a/ThirdParty/custom-opm-parser/opm-parser/opm/parser/eclipse/Utility/Functional.cpp +++ b/ThirdParty/custom-opm-parser/opm-parser/opm/parser/eclipse/Utility/Functional.cpp @@ -21,9 +21,9 @@ namespace Opm { namespace fun { - iota::iota( int begin, int end ) : first( begin ), last( end ) {} + iota::iota( int fst, int lst ) : first( fst ), last( lst ) {} - iota::iota( int end ) : iota( 0, end ) {} + iota::iota( int lst ) : iota( 0, lst ) {} size_t iota::size() const { return this->last - this->first; diff --git a/ThirdParty/custom-opm-parser/opm-parser/opm/parser/eclipse/Utility/Stringview.hpp b/ThirdParty/custom-opm-parser/opm-parser/opm/parser/eclipse/Utility/Stringview.hpp index 5d2b70a3ad..bbd737c984 100644 --- a/ThirdParty/custom-opm-parser/opm-parser/opm/parser/eclipse/Utility/Stringview.hpp +++ b/ThirdParty/custom-opm-parser/opm-parser/opm/parser/eclipse/Utility/Stringview.hpp @@ -147,16 +147,16 @@ namespace Opm { // Member functions of string_view. - inline string_view::string_view( const_iterator begin, - const_iterator end ) : - fst( begin ), - lst( end ) + inline string_view::string_view( const_iterator first, + const_iterator last ) : + fst( first ), + lst( last ) {} - inline string_view::string_view( const_iterator begin, + inline string_view::string_view( const_iterator first , size_t count ) : - fst( begin ), - lst( begin + count ) + fst( first ), + lst( first + count ) {} inline string_view::string_view( const std::string& str ) : diff --git a/ThirdParty/custom-opm-parser/opm-parser/opm/parser/eclipse/Utility/tests/FunctionalTests.cpp b/ThirdParty/custom-opm-parser/opm-parser/opm/parser/eclipse/Utility/tests/FunctionalTests.cpp index 3b6c560a0f..3ec90dd592 100644 --- a/ThirdParty/custom-opm-parser/opm-parser/opm/parser/eclipse/Utility/tests/FunctionalTests.cpp +++ b/ThirdParty/custom-opm-parser/opm-parser/opm/parser/eclipse/Utility/tests/FunctionalTests.cpp @@ -22,9 +22,7 @@ #include #include -#include #include -#include #include diff --git a/ThirdParty/custom-opm-parser/opm-parser/opm/parser/eclipse/Utility/tests/StringTests.cpp b/ThirdParty/custom-opm-parser/opm-parser/opm/parser/eclipse/Utility/tests/StringTests.cpp index a58ea4a4a4..c2ea987384 100644 --- a/ThirdParty/custom-opm-parser/opm-parser/opm/parser/eclipse/Utility/tests/StringTests.cpp +++ b/ThirdParty/custom-opm-parser/opm-parser/opm/parser/eclipse/Utility/tests/StringTests.cpp @@ -1,8 +1,6 @@ #define BOOST_TEST_MODULE StringTests -#include #include -#include #include #include diff --git a/ThirdParty/custom-opm-parser/opm-parser/opm/parser/eclipse/Utility/tests/StringviewTests.cpp b/ThirdParty/custom-opm-parser/opm-parser/opm/parser/eclipse/Utility/tests/StringviewTests.cpp index 551916aa2d..0a57384a01 100644 --- a/ThirdParty/custom-opm-parser/opm-parser/opm/parser/eclipse/Utility/tests/StringviewTests.cpp +++ b/ThirdParty/custom-opm-parser/opm-parser/opm/parser/eclipse/Utility/tests/StringviewTests.cpp @@ -3,9 +3,7 @@ #include #include -#include #include -#include #include diff --git a/ThirdParty/custom-opm-parser/opm-parser/opm/parser/eclipse/python/CMakeLists.txt b/ThirdParty/custom-opm-parser/opm-parser/opm/parser/eclipse/python/CMakeLists.txt index 3d793d4318..9f02376fde 100644 --- a/ThirdParty/custom-opm-parser/opm-parser/opm/parser/eclipse/python/CMakeLists.txt +++ b/ThirdParty/custom-opm-parser/opm-parser/opm/parser/eclipse/python/CMakeLists.txt @@ -1,16 +1,20 @@ find_package (PythonInterp REQUIRED) -find_package (ERTPython REQUIRED) +find_package (Cwrap) -add_subdirectory( c_inter ) +if (CWRAP_PYTHON_PATH) + add_subdirectory( c_inter ) -if (EXISTS "/etc/debian_version") - set( PYTHON_PACKAGE_PATH "dist-packages") + if (EXISTS "/etc/debian_version") + set( PYTHON_PACKAGE_PATH "dist-packages") + else() + set( PYTHON_PACKAGE_PATH "site-packages") + endif() + set(PYTHON_INSTALL_PREFIX "lib/python${PYTHON_VERSION_MAJOR}.${PYTHON_VERSION_MINOR}/${PYTHON_PACKAGE_PATH}" CACHE STRING "Subdirectory to install Python modules in") + + + include(cmake/python.cmake) + add_subdirectory( python ) + add_subdirectory( tests ) else() - set( PYTHON_PACKAGE_PATH "site-packages") + message("Could not find cwrap - Python bindings to Ert skipped") endif() -set(PYTHON_INSTALL_PREFIX "lib/python${PYTHON_VERSION_MAJOR}.${PYTHON_VERSION_MINOR}/${PYTHON_PACKAGE_PATH}" CACHE STRING "Subdirectory to install Python modules in") - - -include(cmake/python.cmake) -add_subdirectory( python ) -add_subdirectory( tests ) diff --git a/ThirdParty/custom-opm-parser/opm-parser/opm/parser/eclipse/python/c_inter/CMakeLists.txt b/ThirdParty/custom-opm-parser/opm-parser/opm/parser/eclipse/python/c_inter/CMakeLists.txt index 9ef2285b35..b18fa63a2b 100644 --- a/ThirdParty/custom-opm-parser/opm-parser/opm/parser/eclipse/python/c_inter/CMakeLists.txt +++ b/ThirdParty/custom-opm-parser/opm-parser/opm/parser/eclipse/python/c_inter/CMakeLists.txt @@ -5,6 +5,8 @@ cparse_context.cc ctable_manager.cc ctable.cc ctable_index.cc +ceclipse_grid.cc +cschedule.cc ) target_link_libraries(copmparser opmparser) diff --git a/ThirdParty/custom-opm-parser/opm-parser/opm/parser/eclipse/python/c_inter/cdeck.cc b/ThirdParty/custom-opm-parser/opm-parser/opm/parser/eclipse/python/c_inter/cdeck.cc index 3224522f70..825b7edf38 100644 --- a/ThirdParty/custom-opm-parser/opm-parser/opm/parser/eclipse/python/c_inter/cdeck.cc +++ b/ThirdParty/custom-opm-parser/opm-parser/opm/parser/eclipse/python/c_inter/cdeck.cc @@ -3,6 +3,16 @@ extern "C" { + int deck_size( const Opm::Deck * deck ); + Opm::Deck * deck_alloc(); + void deck_free( Opm::Deck * deck ); + const Opm::DeckKeyword * deck_iget_keyword( const Opm::Deck * deck , int index); + const Opm::DeckKeyword * deck_iget_named_keyword( const Opm::Deck * deck , const char * keyword , int index); + bool deck_has_keyword( const Opm::Deck * deck , const char * keyword); + int deck_num_keywords( const Opm::Deck * deck , const char * keyword); + + /*-----------------------------------------------------------------*/ + int deck_size( const Opm::Deck * deck ) { return static_cast( deck->size() ); } diff --git a/ThirdParty/custom-opm-parser/opm-parser/opm/parser/eclipse/python/c_inter/cdeck_item.cc b/ThirdParty/custom-opm-parser/opm-parser/opm/parser/eclipse/python/c_inter/cdeck_item.cc index 2efd7f5c5a..94b5e024a6 100644 --- a/ThirdParty/custom-opm-parser/opm-parser/opm/parser/eclipse/python/c_inter/cdeck_item.cc +++ b/ThirdParty/custom-opm-parser/opm-parser/opm/parser/eclipse/python/c_inter/cdeck_item.cc @@ -2,6 +2,14 @@ extern "C" { + int deck_item_get_size( const Opm::DeckItem * item ); + int deck_item_get_type( const Opm::DeckItem * item ); + int deck_item_iget_int( const Opm::DeckItem * item , int index); + double deck_item_iget_double( const Opm::DeckItem * item , int index); + const char * deck_item_iget_string( const Opm::DeckItem * item , int index); + + /*-----------------------------------------------------------------*/ + int deck_item_get_size( const Opm::DeckItem * item ) { return static_cast(item->size()); } diff --git a/ThirdParty/custom-opm-parser/opm-parser/opm/parser/eclipse/python/c_inter/cdeck_keyword.cc b/ThirdParty/custom-opm-parser/opm-parser/opm/parser/eclipse/python/c_inter/cdeck_keyword.cc index af239187e1..a53e92af45 100644 --- a/ThirdParty/custom-opm-parser/opm-parser/opm/parser/eclipse/python/c_inter/cdeck_keyword.cc +++ b/ThirdParty/custom-opm-parser/opm-parser/opm/parser/eclipse/python/c_inter/cdeck_keyword.cc @@ -2,6 +2,13 @@ extern "C" { + Opm::DeckKeyword * deck_keyword_alloc( const char * name ); + void deck_keyword_free( Opm::DeckKeyword * keyword ); + const char * deck_keyword_get_name( const Opm::DeckKeyword * keyword ); + int deck_keyword_get_size( const Opm::DeckKeyword * keyword ); + const Opm::DeckRecord* deck_keyword_iget_record( const Opm::DeckKeyword * keyword , int index); + + /*-----------------------------------------------------------------*/ Opm::DeckKeyword * deck_keyword_alloc( const char * name ) { auto keyword = new Opm::DeckKeyword( name ); diff --git a/ThirdParty/custom-opm-parser/opm-parser/opm/parser/eclipse/python/c_inter/cdeck_record.cc b/ThirdParty/custom-opm-parser/opm-parser/opm/parser/eclipse/python/c_inter/cdeck_record.cc index 895b79bdf4..342431eeda 100644 --- a/ThirdParty/custom-opm-parser/opm-parser/opm/parser/eclipse/python/c_inter/cdeck_record.cc +++ b/ThirdParty/custom-opm-parser/opm-parser/opm/parser/eclipse/python/c_inter/cdeck_record.cc @@ -1,6 +1,12 @@ #include extern "C" { + int deck_record_get_size( const Opm::DeckRecord * record ); + bool deck_record_has_item(const Opm::DeckRecord * record , const char * item); + Opm::DeckItem * deck_record_iget_item( Opm::DeckRecord * record , int index); + Opm::DeckItem * deck_record_get_item( Opm::DeckRecord * record , const char * name); + + /*-----------------------------------------------------------------*/ int deck_record_get_size( const Opm::DeckRecord * record ) { return static_cast(record->size()); diff --git a/ThirdParty/custom-opm-parser/opm-parser/opm/parser/eclipse/python/c_inter/ceclipse_grid.cc b/ThirdParty/custom-opm-parser/opm-parser/opm/parser/eclipse/python/c_inter/ceclipse_grid.cc new file mode 100644 index 0000000000..569d412149 --- /dev/null +++ b/ThirdParty/custom-opm-parser/opm-parser/opm/parser/eclipse/python/c_inter/ceclipse_grid.cc @@ -0,0 +1,21 @@ +#include +#include + +extern "C" { + + Opm::EclipseGrid * eclipse_grid_alloc(Opm::Deck * deck); + void eclipse_grid_free( Opm::EclipseGrid * grid ); + + /*-----------------------------------------------------------------*/ + + Opm::EclipseGrid * eclipse_grid_alloc(Opm::Deck * deck) { + return new Opm::EclipseGrid( *deck, nullptr ); + } + + void eclipse_grid_free( Opm::EclipseGrid * grid ) { + delete grid; + } + +} + + diff --git a/ThirdParty/custom-opm-parser/opm-parser/opm/parser/eclipse/python/c_inter/cparse_context.cc b/ThirdParty/custom-opm-parser/opm-parser/opm/parser/eclipse/python/c_inter/cparse_context.cc index 02f446d599..d2194d5724 100644 --- a/ThirdParty/custom-opm-parser/opm-parser/opm/parser/eclipse/python/c_inter/cparse_context.cc +++ b/ThirdParty/custom-opm-parser/opm-parser/opm/parser/eclipse/python/c_inter/cparse_context.cc @@ -3,20 +3,25 @@ extern "C" { + Opm::ParseContext * parse_context_alloc(); + void parse_context_free( Opm::ParseContext * parse_context ) ; + void parse_context_update( Opm::ParseContext * parse_context , const char * var , Opm::InputError::Action action); - Opm::ParseContext * parse_mode_alloc() { - Opm::ParseContext * parse_mode = new Opm::ParseContext( ); - return parse_mode; + /*-----------------------------------------------------------------*/ + + Opm::ParseContext * parse_context_alloc() { + Opm::ParseContext * parse_context = new Opm::ParseContext( ); + return parse_context; } - void parse_mode_free( Opm::ParseContext * parse_mode ) { - delete parse_mode; + void parse_context_free( Opm::ParseContext * parse_context ) { + delete parse_context; } - void parse_mode_update( Opm::ParseContext * parse_mode , const char * var , Opm::InputError::Action action) { - parse_mode->update( var , action ); + void parse_context_update( Opm::ParseContext * parse_context , const char * var , Opm::InputError::Action action) { + parse_context->update( var , action ); } } diff --git a/ThirdParty/custom-opm-parser/opm-parser/opm/parser/eclipse/python/c_inter/cparser.cc b/ThirdParty/custom-opm-parser/opm-parser/opm/parser/eclipse/python/c_inter/cparser.cc index 94808d6770..30a2725a2a 100644 --- a/ThirdParty/custom-opm-parser/opm-parser/opm/parser/eclipse/python/c_inter/cparser.cc +++ b/ThirdParty/custom-opm-parser/opm-parser/opm/parser/eclipse/python/c_inter/cparser.cc @@ -7,6 +7,14 @@ extern "C" { + Opm::Deck * parser_parse_file(const Opm::Parser * parser , const char * file , const Opm::ParseContext * parse_mode); + void * parser_alloc(); + bool parser_has_keyword(const Opm::Parser * parser , const char * keyword); + void parser_free(Opm::Parser * parser); + void parser_add_json_keyword(Opm::Parser * parser, const char * json_string); + + /*-----------------------------------------------------------------*/ + Opm::Deck * parser_parse_file(const Opm::Parser * parser , const char * file , const Opm::ParseContext * parse_mode) { return parser->newDeckFromFile( file , *parse_mode ); } diff --git a/ThirdParty/custom-opm-parser/opm-parser/opm/parser/eclipse/python/c_inter/cschedule.cc b/ThirdParty/custom-opm-parser/opm-parser/opm/parser/eclipse/python/c_inter/cschedule.cc new file mode 100644 index 0000000000..eb9261459a --- /dev/null +++ b/ThirdParty/custom-opm-parser/opm-parser/opm/parser/eclipse/python/c_inter/cschedule.cc @@ -0,0 +1,34 @@ +#include +#include +#include +#include + +extern "C" { + + Opm::Schedule * schedule_alloc(Opm::ParseContext * context, Opm::EclipseGrid * grid, Opm::Deck * deck); + void schedule_free( Opm::Schedule * schedule ); + time_t schedule_end( const Opm::Schedule * schedule ); + time_t schedule_start( const Opm::Schedule * schedule ); + + /*-----------------------------------------------------------------*/ + + time_t schedule_end( const Opm::Schedule * schedule ) { + return schedule->posixEndTime(); + } + + time_t schedule_start( const Opm::Schedule * schedule ) { + return schedule->posixStartTime(); + } + + + Opm::Schedule * schedule_alloc(Opm::ParseContext * context, Opm::EclipseGrid * grid, Opm::Deck * deck) { + return new Opm::Schedule( *context , *grid, *deck ); + } + + void schedule_free( Opm::Schedule * schedule ) { + delete schedule; + } + +} + + diff --git a/ThirdParty/custom-opm-parser/opm-parser/opm/parser/eclipse/python/c_inter/ctable.cc b/ThirdParty/custom-opm-parser/opm-parser/opm/parser/eclipse/python/c_inter/ctable.cc index b400ee9957..567b5012bd 100644 --- a/ThirdParty/custom-opm-parser/opm-parser/opm/parser/eclipse/python/c_inter/ctable.cc +++ b/ThirdParty/custom-opm-parser/opm-parser/opm/parser/eclipse/python/c_inter/ctable.cc @@ -3,6 +3,15 @@ extern "C" { + bool table_has_column( const Opm::SimpleTable * table , const char * column ); + int table_get_num_rows( const Opm::SimpleTable * table ); + double table_get_value( const Opm::SimpleTable * table , const char * column , int row_index); + double table_evaluate( const Opm::SimpleTable * table , const char * column , int row_index); + double table_evaluate_from_index( const Opm::SimpleTable * table , const char * column , const Opm::TableIndex * eval_index); + Opm::TableIndex * table_lookup( const Opm::SimpleTable * table , double arg_value ); + + /*-----------------------------------------------------------------*/ + bool table_has_column( const Opm::SimpleTable * table , const char * column ) { return table->hasColumn( column ); } diff --git a/ThirdParty/custom-opm-parser/opm-parser/opm/parser/eclipse/python/c_inter/ctable_index.cc b/ThirdParty/custom-opm-parser/opm-parser/opm/parser/eclipse/python/c_inter/ctable_index.cc index da329ae692..c82b0739b4 100644 --- a/ThirdParty/custom-opm-parser/opm-parser/opm/parser/eclipse/python/c_inter/ctable_index.cc +++ b/ThirdParty/custom-opm-parser/opm-parser/opm/parser/eclipse/python/c_inter/ctable_index.cc @@ -2,6 +2,10 @@ extern "C" { + void table_index_free( Opm::TableIndex * table_index ); + + /*-----------------------------------------------------------------*/ + void table_index_free( Opm::TableIndex * table_index ) { delete table_index; } diff --git a/ThirdParty/custom-opm-parser/opm-parser/opm/parser/eclipse/python/c_inter/ctable_manager.cc b/ThirdParty/custom-opm-parser/opm-parser/opm/parser/eclipse/python/c_inter/ctable_manager.cc index 783f409775..ee85848ed7 100644 --- a/ThirdParty/custom-opm-parser/opm-parser/opm/parser/eclipse/python/c_inter/ctable_manager.cc +++ b/ThirdParty/custom-opm-parser/opm-parser/opm/parser/eclipse/python/c_inter/ctable_manager.cc @@ -4,6 +4,14 @@ extern "C" { + Opm::TableManager * table_manager_alloc( const Opm::Deck * deck ); + void table_manager_free( Opm::TableManager * table_manager ); + bool table_manager_has_table( const Opm::TableManager * table_manager , const char * table_name); + int table_manager_num_tables( const Opm::TableManager * table_manager, const char * table_name); + const Opm::SimpleTable* table_manager_get_table( const Opm::TableManager * table_manager, const char * table_name, int table_num); + + /*-----------------------------------------------------------------*/ + Opm::TableManager * table_manager_alloc( const Opm::Deck * deck ) { return new Opm::TableManager( *deck ); } diff --git a/ThirdParty/custom-opm-parser/opm-parser/opm/parser/eclipse/python/cmake/python.cmake b/ThirdParty/custom-opm-parser/opm-parser/opm/parser/eclipse/python/cmake/python.cmake index c64dbf0287..7927f6d836 100644 --- a/ThirdParty/custom-opm-parser/opm-parser/opm/parser/eclipse/python/cmake/python.cmake +++ b/ThirdParty/custom-opm-parser/opm-parser/opm/parser/eclipse/python/cmake/python.cmake @@ -31,6 +31,11 @@ function(add_python_package target package_path source_files install_package) endfunction() +function(add_python_module target package_path module_file install_package) + set (source_list ${module_file}) + add_python_package( ${target} ${package_path} ${source_list} ${install_package}) +endfunction() + #----------------------------------------------------------------- @@ -52,6 +57,5 @@ function (addPythonTest TEST_NAME TEST_CLASS) if(TEST_OPTIONS_ENVIRONMENT) set_property(TEST python.tests.${TEST_NAME} PROPERTY ENVIRONMENT ${TEST_OPTIONS_ENVIRONMENT}) endif() - set_property(TEST python.tests.${TEST_NAME} PROPERTY ENVIRONMENT "PYTHONPATH=${ERT_PYTHON_PATH}:${PYTHONPATH}") + set_property(TEST python.tests.${TEST_NAME} PROPERTY ENVIRONMENT "PYTHONPATH=${CWRAP_PYTHON_PATH}:${PYTHONPATH}") endfunction(addPythonTest) - diff --git a/ThirdParty/custom-opm-parser/opm-parser/opm/parser/eclipse/python/python/CMakeLists.txt b/ThirdParty/custom-opm-parser/opm-parser/opm/parser/eclipse/python/python/CMakeLists.txt index eb2f1bb659..7bf1345417 100644 --- a/ThirdParty/custom-opm-parser/opm-parser/opm/parser/eclipse/python/python/CMakeLists.txt +++ b/ThirdParty/custom-opm-parser/opm-parser/opm/parser/eclipse/python/python/CMakeLists.txt @@ -1 +1,4 @@ add_subdirectory( opm ) + +add_python_module("opm_test" "${PYTHON_INSTALL_PREFIX}" "opm_test.py" False) + diff --git a/ThirdParty/custom-opm-parser/opm-parser/opm/parser/eclipse/python/python/opm/__init__.py b/ThirdParty/custom-opm-parser/opm-parser/opm/parser/eclipse/python/python/opm/__init__.py index 44832253e8..8bdd616d23 100644 --- a/ThirdParty/custom-opm-parser/opm-parser/opm/parser/eclipse/python/python/opm/__init__.py +++ b/ThirdParty/custom-opm-parser/opm-parser/opm/parser/eclipse/python/python/opm/__init__.py @@ -1,8 +1,7 @@ import ctypes -from ert.cwrap.clib import lib_name -from ert.cwrap.metacwrap import Prototype +from cwrap import lib_name, Prototype + - lib_path = None so_version = "" @@ -24,7 +23,6 @@ except ImportError: class OPMPrototype(Prototype): lib_file = lib_name( "libcopmparser" , path = lib_path , so_version = so_version) lib = ctypes.CDLL( lib_file , ctypes.RTLD_GLOBAL ) - + def __init__(self , prototype , bind = True): super(OPMPrototype , self).__init__( OPMPrototype.lib , prototype , bind = bind) - diff --git a/ThirdParty/custom-opm-parser/opm-parser/opm/parser/eclipse/python/python/opm/deck/deck.py b/ThirdParty/custom-opm-parser/opm-parser/opm/parser/eclipse/python/python/opm/deck/deck.py index 2cf11f0860..afc3ffde74 100644 --- a/ThirdParty/custom-opm-parser/opm-parser/opm/parser/eclipse/python/python/opm/deck/deck.py +++ b/ThirdParty/custom-opm-parser/opm-parser/opm/parser/eclipse/python/python/opm/deck/deck.py @@ -1,4 +1,4 @@ -from ert.cwrap import BaseCClass +from cwrap import BaseCClass from opm import OPMPrototype class Deck(BaseCClass): @@ -116,7 +116,7 @@ class Deck(BaseCClass): def free(self): - self._free( self ) + self._free( ) diff --git a/ThirdParty/custom-opm-parser/opm-parser/opm/parser/eclipse/python/python/opm/deck/deck_item.py b/ThirdParty/custom-opm-parser/opm-parser/opm/parser/eclipse/python/python/opm/deck/deck_item.py index 848fd9c066..39af5360e8 100644 --- a/ThirdParty/custom-opm-parser/opm-parser/opm/parser/eclipse/python/python/opm/deck/deck_item.py +++ b/ThirdParty/custom-opm-parser/opm-parser/opm/parser/eclipse/python/python/opm/deck/deck_item.py @@ -1,4 +1,4 @@ -from ert.cwrap import BaseCClass +from cwrap import BaseCClass from opm import OPMPrototype from opm.deck import ItemType diff --git a/ThirdParty/custom-opm-parser/opm-parser/opm/parser/eclipse/python/python/opm/deck/deck_keyword.py b/ThirdParty/custom-opm-parser/opm-parser/opm/parser/eclipse/python/python/opm/deck/deck_keyword.py index 1056a5869b..6c1c8c894d 100644 --- a/ThirdParty/custom-opm-parser/opm-parser/opm/parser/eclipse/python/python/opm/deck/deck_keyword.py +++ b/ThirdParty/custom-opm-parser/opm-parser/opm/parser/eclipse/python/python/opm/deck/deck_keyword.py @@ -1,4 +1,4 @@ -from ert.cwrap import BaseCClass +from cwrap import BaseCClass from opm import OPMPrototype class DeckKeyword(BaseCClass): diff --git a/ThirdParty/custom-opm-parser/opm-parser/opm/parser/eclipse/python/python/opm/deck/deck_record.py b/ThirdParty/custom-opm-parser/opm-parser/opm/parser/eclipse/python/python/opm/deck/deck_record.py index 0bc55898f2..0252cf0f92 100644 --- a/ThirdParty/custom-opm-parser/opm-parser/opm/parser/eclipse/python/python/opm/deck/deck_record.py +++ b/ThirdParty/custom-opm-parser/opm-parser/opm/parser/eclipse/python/python/opm/deck/deck_record.py @@ -1,4 +1,4 @@ -from ert.cwrap import BaseCClass +from cwrap import BaseCClass from opm import OPMPrototype class DeckRecord(BaseCClass): diff --git a/ThirdParty/custom-opm-parser/opm-parser/opm/parser/eclipse/python/python/opm/deck/item_type_enum.py b/ThirdParty/custom-opm-parser/opm-parser/opm/parser/eclipse/python/python/opm/deck/item_type_enum.py index 0b717d1a1e..d8de296b77 100644 --- a/ThirdParty/custom-opm-parser/opm-parser/opm/parser/eclipse/python/python/opm/deck/item_type_enum.py +++ b/ThirdParty/custom-opm-parser/opm-parser/opm/parser/eclipse/python/python/opm/deck/item_type_enum.py @@ -1,4 +1,4 @@ -from ert.cwrap import BaseCEnum +from cwrap import BaseCEnum class ItemType(BaseCEnum): diff --git a/ThirdParty/custom-opm-parser/opm-parser/opm/parser/eclipse/python/python/opm/ecl_state/CMakeLists.txt b/ThirdParty/custom-opm-parser/opm-parser/opm/parser/eclipse/python/python/opm/ecl_state/CMakeLists.txt index 8ad399ae95..9b7da3406a 100644 --- a/ThirdParty/custom-opm-parser/opm-parser/opm/parser/eclipse/python/python/opm/ecl_state/CMakeLists.txt +++ b/ThirdParty/custom-opm-parser/opm-parser/opm/parser/eclipse/python/python/opm/ecl_state/CMakeLists.txt @@ -5,4 +5,5 @@ set(PYTHON_SOURCES add_python_package("opm.ecl_state" ${PYTHON_INSTALL_PREFIX}/opm/ecl_state "${PYTHON_SOURCES}" True) add_subdirectory( tables ) - +add_subdirectory( schedule ) +add_subdirectory( grid ) diff --git a/ThirdParty/custom-opm-parser/opm-parser/opm/parser/eclipse/python/python/opm/ecl_state/grid/CMakeLists.txt b/ThirdParty/custom-opm-parser/opm-parser/opm/parser/eclipse/python/python/opm/ecl_state/grid/CMakeLists.txt new file mode 100644 index 0000000000..662138905b --- /dev/null +++ b/ThirdParty/custom-opm-parser/opm-parser/opm/parser/eclipse/python/python/opm/ecl_state/grid/CMakeLists.txt @@ -0,0 +1,6 @@ +set(PYTHON_SOURCES + __init__.py + eclipse_grid.py +) + +add_python_package("opm.ecl_state.grid" ${PYTHON_INSTALL_PREFIX}/opm/ecl_state/grid "${PYTHON_SOURCES}" True) diff --git a/ThirdParty/custom-opm-parser/opm-parser/opm/parser/eclipse/python/python/opm/ecl_state/grid/__init__.py b/ThirdParty/custom-opm-parser/opm-parser/opm/parser/eclipse/python/python/opm/ecl_state/grid/__init__.py new file mode 100644 index 0000000000..8e1c4af961 --- /dev/null +++ b/ThirdParty/custom-opm-parser/opm-parser/opm/parser/eclipse/python/python/opm/ecl_state/grid/__init__.py @@ -0,0 +1 @@ +from .eclipse_grid import EclipseGrid diff --git a/ThirdParty/custom-opm-parser/opm-parser/opm/parser/eclipse/python/python/opm/ecl_state/grid/eclipse_grid.py b/ThirdParty/custom-opm-parser/opm-parser/opm/parser/eclipse/python/python/opm/ecl_state/grid/eclipse_grid.py new file mode 100644 index 0000000000..f12f9664d3 --- /dev/null +++ b/ThirdParty/custom-opm-parser/opm-parser/opm/parser/eclipse/python/python/opm/ecl_state/grid/eclipse_grid.py @@ -0,0 +1,18 @@ +from cwrap import BaseCClass + +from opm import OPMPrototype +from opm.deck import Deck + +class EclipseGrid(BaseCClass): + TYPE_NAME = "eclipse_grid" + _alloc = OPMPrototype("void* eclipse_grid_alloc( deck )" , bind = False) + _free = OPMPrototype("void eclipse_grid_free( eclipse_grid )") + + + def __init__(self , deck): + c_ptr = self._alloc( deck ) + super(EclipseGrid , self).__init__( c_ptr ) + + + def free(self): + self._free( ) diff --git a/ThirdParty/custom-opm-parser/opm-parser/opm/parser/eclipse/python/python/opm/ecl_state/schedule/CMakeLists.txt b/ThirdParty/custom-opm-parser/opm-parser/opm/parser/eclipse/python/python/opm/ecl_state/schedule/CMakeLists.txt new file mode 100644 index 0000000000..9ea2ead8f3 --- /dev/null +++ b/ThirdParty/custom-opm-parser/opm-parser/opm/parser/eclipse/python/python/opm/ecl_state/schedule/CMakeLists.txt @@ -0,0 +1,6 @@ +set(PYTHON_SOURCES + __init__.py + schedule.py +) + +add_python_package("opm.ecl_state.schedule" ${PYTHON_INSTALL_PREFIX}/opm/ecl_state/schedule "${PYTHON_SOURCES}" True) diff --git a/ThirdParty/custom-opm-parser/opm-parser/opm/parser/eclipse/python/python/opm/ecl_state/schedule/__init__.py b/ThirdParty/custom-opm-parser/opm-parser/opm/parser/eclipse/python/python/opm/ecl_state/schedule/__init__.py new file mode 100644 index 0000000000..7aef82b288 --- /dev/null +++ b/ThirdParty/custom-opm-parser/opm-parser/opm/parser/eclipse/python/python/opm/ecl_state/schedule/__init__.py @@ -0,0 +1 @@ +from .schedule import Schedule diff --git a/ThirdParty/custom-opm-parser/opm-parser/opm/parser/eclipse/python/python/opm/ecl_state/schedule/schedule.py b/ThirdParty/custom-opm-parser/opm-parser/opm/parser/eclipse/python/python/opm/ecl_state/schedule/schedule.py new file mode 100644 index 0000000000..6b39abf5b5 --- /dev/null +++ b/ThirdParty/custom-opm-parser/opm-parser/opm/parser/eclipse/python/python/opm/ecl_state/schedule/schedule.py @@ -0,0 +1,35 @@ +from cwrap import BaseCClass +from ert.util import CTime +from opm import OPMPrototype + +from opm.parser import ParseContext +from opm.ecl_state.grid import EclipseGrid + +class Schedule(BaseCClass): + TYPE_NAME = "schedule" + _alloc = OPMPrototype("void* schedule_alloc( parse_context , eclipse_grid , deck )" , bind = False) + _free = OPMPrototype("void schedule_free( schedule )") + _end_time = OPMPrototype("time_t schedule_end(schedule)") + _start_time = OPMPrototype("time_t schedule_start(schedule)") + + + def __init__(self , grid, deck , parse_context = None): + if parse_context is None: + parse_context = ParseContext( ) + c_ptr = self._alloc( parse_context , grid , deck ) + super(Schedule , self).__init__( c_ptr ) + + + def endTime(self): + ct = self._end_time( ) + return ct.datetime( ) + + + def startTime(self): + ct = self._start_time( ) + return ct.datetime( ) + + + def free(self): + self._free( ) + diff --git a/ThirdParty/custom-opm-parser/opm-parser/opm/parser/eclipse/python/python/opm/ecl_state/tables/table.py b/ThirdParty/custom-opm-parser/opm-parser/opm/parser/eclipse/python/python/opm/ecl_state/tables/table.py index 25ff6be06c..c64c4a0806 100644 --- a/ThirdParty/custom-opm-parser/opm-parser/opm/parser/eclipse/python/python/opm/ecl_state/tables/table.py +++ b/ThirdParty/custom-opm-parser/opm-parser/opm/parser/eclipse/python/python/opm/ecl_state/tables/table.py @@ -1,6 +1,6 @@ import os.path -from ert.cwrap import BaseCClass +from cwrap import BaseCClass from opm import OPMPrototype from .table_index import TableIndex diff --git a/ThirdParty/custom-opm-parser/opm-parser/opm/parser/eclipse/python/python/opm/ecl_state/tables/table_index.py b/ThirdParty/custom-opm-parser/opm-parser/opm/parser/eclipse/python/python/opm/ecl_state/tables/table_index.py index 6b512ccb5a..574417e220 100644 --- a/ThirdParty/custom-opm-parser/opm-parser/opm/parser/eclipse/python/python/opm/ecl_state/tables/table_index.py +++ b/ThirdParty/custom-opm-parser/opm-parser/opm/parser/eclipse/python/python/opm/ecl_state/tables/table_index.py @@ -1,6 +1,6 @@ import os.path -from ert.cwrap import BaseCClass +from cwrap import BaseCClass from opm import OPMPrototype diff --git a/ThirdParty/custom-opm-parser/opm-parser/opm/parser/eclipse/python/python/opm/ecl_state/tables/table_manager.py b/ThirdParty/custom-opm-parser/opm-parser/opm/parser/eclipse/python/python/opm/ecl_state/tables/table_manager.py index 04c3131b1b..f78888f1ce 100644 --- a/ThirdParty/custom-opm-parser/opm-parser/opm/parser/eclipse/python/python/opm/ecl_state/tables/table_manager.py +++ b/ThirdParty/custom-opm-parser/opm-parser/opm/parser/eclipse/python/python/opm/ecl_state/tables/table_manager.py @@ -1,6 +1,6 @@ import os.path -from ert.cwrap import BaseCClass +from cwrap import BaseCClass from opm import OPMPrototype @@ -23,7 +23,7 @@ class TableManager(BaseCClass): def free(self): - self._free( self ) + self._free( ) def hasTable(self, name ): diff --git a/ThirdParty/custom-opm-parser/opm-parser/opm/parser/eclipse/python/python/opm/parser/error_action.py b/ThirdParty/custom-opm-parser/opm-parser/opm/parser/eclipse/python/python/opm/parser/error_action.py index 83f3c1d72e..44d04dc6df 100644 --- a/ThirdParty/custom-opm-parser/opm-parser/opm/parser/eclipse/python/python/opm/parser/error_action.py +++ b/ThirdParty/custom-opm-parser/opm-parser/opm/parser/eclipse/python/python/opm/parser/error_action.py @@ -1,4 +1,4 @@ -from ert.cwrap import BaseCEnum +from cwrap import BaseCEnum class ErrorAction(BaseCEnum): diff --git a/ThirdParty/custom-opm-parser/opm-parser/opm/parser/eclipse/python/python/opm/parser/parse_context.py b/ThirdParty/custom-opm-parser/opm-parser/opm/parser/eclipse/python/python/opm/parser/parse_context.py index 0075134488..f93002ab84 100644 --- a/ThirdParty/custom-opm-parser/opm-parser/opm/parser/eclipse/python/python/opm/parser/parse_context.py +++ b/ThirdParty/custom-opm-parser/opm-parser/opm/parser/eclipse/python/python/opm/parser/parse_context.py @@ -1,11 +1,11 @@ -from ert.cwrap import BaseCClass, CWrapper +from cwrap import BaseCClass, CWrapper from opm import OPMPrototype class ParseContext(BaseCClass): - TYPE_NAME = "parse_mode" - _alloc = OPMPrototype("void* parse_mode_alloc()", bind = False) - _free = OPMPrototype("void parse_mode_free(parse_mode)") - _update = OPMPrototype("void parse_mode_update(parse_mode, char* , error_action_enum)") + TYPE_NAME = "parse_context" + _alloc = OPMPrototype("void* parse_context_alloc()", bind = False) + _free = OPMPrototype("void parse_context_free(parse_context)") + _update = OPMPrototype("void parse_context_update(parse_context, char* , error_action_enum)") def __init__(self): c_ptr = self._alloc() diff --git a/ThirdParty/custom-opm-parser/opm-parser/opm/parser/eclipse/python/python/opm/parser/parser.py b/ThirdParty/custom-opm-parser/opm-parser/opm/parser/eclipse/python/python/opm/parser/parser.py index 076d6a095a..592a975045 100644 --- a/ThirdParty/custom-opm-parser/opm-parser/opm/parser/eclipse/python/python/opm/parser/parser.py +++ b/ThirdParty/custom-opm-parser/opm-parser/opm/parser/eclipse/python/python/opm/parser/parser.py @@ -3,7 +3,7 @@ import json import inspect from functools import partial -from ert.cwrap import BaseCClass +from cwrap import BaseCClass from opm import OPMPrototype from opm.deck import Deck from opm.parser import ParseContext @@ -29,7 +29,7 @@ class Parser(BaseCClass): _alloc = OPMPrototype("void* parser_alloc()" , bind = False) _free = OPMPrototype("void parser_free(parser)") _has_keyword = OPMPrototype("bool parser_has_keyword(parser, char*)") - _parse_file = OPMPrototype("deck_obj parser_parse_file(parser, char*, parse_mode)") + _parse_file = OPMPrototype("deck_obj parser_parse_file(parser, char*, parse_context)") _add_json_keyword = OPMPrototype("void parser_add_json_keyword(parser, char*)") diff --git a/ThirdParty/custom-opm-parser/opm-parser/opm/parser/eclipse/python/python/opm_test.py b/ThirdParty/custom-opm-parser/opm-parser/opm/parser/eclipse/python/python/opm_test.py new file mode 100644 index 0000000000..d6063b0812 --- /dev/null +++ b/ThirdParty/custom-opm-parser/opm-parser/opm/parser/eclipse/python/python/opm_test.py @@ -0,0 +1,8 @@ +from unittest import TestCase +import os.path + + +class OpmTest(TestCase): + + def createPath(self, path): + return os.path.join( os.path.abspath( os.path.dirname(__file__ )) , "../../../bin/testdata" , path) diff --git a/ThirdParty/custom-opm-parser/opm-parser/opm/parser/eclipse/python/tests/ecl_state/CMakeLists.txt b/ThirdParty/custom-opm-parser/opm-parser/opm/parser/eclipse/python/tests/ecl_state/CMakeLists.txt index 1cc6066187..6fcc836257 100644 --- a/ThirdParty/custom-opm-parser/opm-parser/opm/parser/eclipse/python/tests/ecl_state/CMakeLists.txt +++ b/ThirdParty/custom-opm-parser/opm-parser/opm/parser/eclipse/python/tests/ecl_state/CMakeLists.txt @@ -1,7 +1,7 @@ -set (TEST_SOURCES - __init__.py - test_table_manager.py) +set (TEST_SOURCES __init__.py ) add_python_package("python.tests.ecl_state" "${PYTHON_INSTALL_PREFIX}/tests/ecl_state" "${TEST_SOURCES}" False) -addPythontest( python.test_table_manager tests.ecl_state.test_table_manager.TableManagerTest ) +add_subdirectory( table ) +add_subdirectory( grid ) +add_subdirectory( schedule ) diff --git a/ThirdParty/custom-opm-parser/opm-parser/opm/parser/eclipse/python/tests/ecl_state/grid/CMakeLists.txt b/ThirdParty/custom-opm-parser/opm-parser/opm/parser/eclipse/python/tests/ecl_state/grid/CMakeLists.txt new file mode 100644 index 0000000000..f102238482 --- /dev/null +++ b/ThirdParty/custom-opm-parser/opm-parser/opm/parser/eclipse/python/tests/ecl_state/grid/CMakeLists.txt @@ -0,0 +1,7 @@ +set (TEST_SOURCES + __init__.py + test_grid.py) + +add_python_package("python.tests.ecl_state.grid" "${PYTHON_INSTALL_PREFIX}/tests/ecl_state/grid" "${TEST_SOURCES}" False) + +addPythontest( python.test_grid tests.ecl_state.grid.test_grid.EclipseGridTest ) diff --git a/ThirdParty/Ert/devel/debian/docs b/ThirdParty/custom-opm-parser/opm-parser/opm/parser/eclipse/python/tests/ecl_state/grid/__init__.py similarity index 100% rename from ThirdParty/Ert/devel/debian/docs rename to ThirdParty/custom-opm-parser/opm-parser/opm/parser/eclipse/python/tests/ecl_state/grid/__init__.py diff --git a/ThirdParty/custom-opm-parser/opm-parser/opm/parser/eclipse/python/tests/ecl_state/grid/test_grid.py b/ThirdParty/custom-opm-parser/opm-parser/opm/parser/eclipse/python/tests/ecl_state/grid/test_grid.py new file mode 100644 index 0000000000..5678c5fbfc --- /dev/null +++ b/ThirdParty/custom-opm-parser/opm-parser/opm/parser/eclipse/python/tests/ecl_state/grid/test_grid.py @@ -0,0 +1,18 @@ +from unittest import TestCase +import os.path +from ert.test import TestAreaContext + +from opm.parser import Parser +from opm.ecl_state.grid import EclipseGrid +from opm_test import OpmTest + +class EclipseGridTest(OpmTest): + def setUp(self): + pass + + def test_parse(self): + p = Parser() + test_file = self.createPath( "integration_tests/GRID/CORNERPOINT_ACTNUM.DATA" ) + deck = p.parseFile( test_file ) + grid = EclipseGrid( deck ) + diff --git a/ThirdParty/custom-opm-parser/opm-parser/opm/parser/eclipse/python/tests/ecl_state/schedule/CMakeLists.txt b/ThirdParty/custom-opm-parser/opm-parser/opm/parser/eclipse/python/tests/ecl_state/schedule/CMakeLists.txt new file mode 100644 index 0000000000..2e5e847fd2 --- /dev/null +++ b/ThirdParty/custom-opm-parser/opm-parser/opm/parser/eclipse/python/tests/ecl_state/schedule/CMakeLists.txt @@ -0,0 +1,7 @@ +set (TEST_SOURCES + __init__.py + test_schedule.py) + +add_python_package("python.tests.ecl_state.schedule" "${PYTHON_INSTALL_PREFIX}/tests/ecl_state/schedule" "${TEST_SOURCES}" False) + +addPythontest( python.test_schedule tests.ecl_state.schedule.test_schedule.ScheduleTest ) diff --git a/ThirdParty/custom-opm-parser/opm-parser/opm/parser/eclipse/python/tests/ecl_state/schedule/__init__.py b/ThirdParty/custom-opm-parser/opm-parser/opm/parser/eclipse/python/tests/ecl_state/schedule/__init__.py new file mode 100644 index 0000000000..e69de29bb2 diff --git a/ThirdParty/custom-opm-parser/opm-parser/opm/parser/eclipse/python/tests/ecl_state/schedule/test_schedule.py b/ThirdParty/custom-opm-parser/opm-parser/opm/parser/eclipse/python/tests/ecl_state/schedule/test_schedule.py new file mode 100644 index 0000000000..7e0874979f --- /dev/null +++ b/ThirdParty/custom-opm-parser/opm-parser/opm/parser/eclipse/python/tests/ecl_state/schedule/test_schedule.py @@ -0,0 +1,37 @@ +import datetime +import os.path +from ert.test import TestAreaContext + +from opm_test import OpmTest +from opm.parser import Parser +from opm.ecl_state.schedule import Schedule +from opm.ecl_state.grid import EclipseGrid + + + +class ScheduleTest(OpmTest): + def setUp(self): + pass + + def test_parse(self): + p = Parser() + + # This is slightly awkward; since only the deck based + # constructor is wrapped in the grid case we need to different + # input files to instantiate the Schedule and EclipseGrid + # instances respectively. + grid_file = self.createPath( "integration_tests/GRID/CORNERPOINT_ACTNUM.DATA" ) + grid_deck = p.parseFile( grid_file ) + grid = EclipseGrid(grid_deck) + + sched_file = self.createPath("integration_tests/SCHEDULE/SCHEDULE1") + sched_deck = p.parseFile( sched_file ) + s = Schedule( grid , sched_deck ) + + end = s.endTime() + self.assertEqual( datetime.datetime( end.year , end.month , end.day) , datetime.datetime( 2008 , 8 , 10 )) + #self.assertEqual( s.endTime( ) , datetime.datetime( 2008 , 8 , 10 )) + + start = s.startTime() + self.assertEqual( datetime.datetime( start.year , start.month , start.day) , datetime.datetime( 2007 , 5 , 10 )) + diff --git a/ThirdParty/custom-opm-parser/opm-parser/opm/parser/eclipse/python/tests/ecl_state/table/CMakeLists.txt b/ThirdParty/custom-opm-parser/opm-parser/opm/parser/eclipse/python/tests/ecl_state/table/CMakeLists.txt new file mode 100644 index 0000000000..73c4959d95 --- /dev/null +++ b/ThirdParty/custom-opm-parser/opm-parser/opm/parser/eclipse/python/tests/ecl_state/table/CMakeLists.txt @@ -0,0 +1,7 @@ +set (TEST_SOURCES + __init__.py + test_table_manager.py) + +add_python_package("python.tests.ecl_state.table" "${PYTHON_INSTALL_PREFIX}/tests/ecl_state/table" "${TEST_SOURCES}" False) + +addPythontest( python.test_table_manager tests.ecl_state.table.test_table_manager.TableManagerTest ) diff --git a/ThirdParty/custom-opm-parser/opm-parser/opm/parser/eclipse/python/tests/ecl_state/table/__init__.py b/ThirdParty/custom-opm-parser/opm-parser/opm/parser/eclipse/python/tests/ecl_state/table/__init__.py new file mode 100644 index 0000000000..e69de29bb2 diff --git a/ThirdParty/custom-opm-parser/opm-parser/opm/parser/eclipse/python/tests/ecl_state/test_table_manager.py b/ThirdParty/custom-opm-parser/opm-parser/opm/parser/eclipse/python/tests/ecl_state/table/test_table_manager.py similarity index 100% rename from ThirdParty/custom-opm-parser/opm-parser/opm/parser/eclipse/python/tests/ecl_state/test_table_manager.py rename to ThirdParty/custom-opm-parser/opm-parser/opm/parser/eclipse/python/tests/ecl_state/table/test_table_manager.py diff --git a/ThirdParty/custom-opm-parser/opm-parser/opm/parser/share/keywords/000_Eclipse100/A/AQUANCON b/ThirdParty/custom-opm-parser/opm-parser/opm/parser/share/keywords/000_Eclipse100/A/AQUANCON new file mode 100644 index 0000000000..da6d1271a3 --- /dev/null +++ b/ThirdParty/custom-opm-parser/opm-parser/opm/parser/share/keywords/000_Eclipse100/A/AQUANCON @@ -0,0 +1,15 @@ +{"name" : "AQUANCON" , "sections" : ["GRID" , "SOLUTION"], + "items" : [ + {"name" : "AQUIFER_ID" , "value_type" : "INT"}, + {"name" : "I1" , "value_type" : "INT"}, + {"name" : "I2" , "value_type" : "INT"}, + {"name" : "J1" , "value_type" : "INT"}, + {"name" : "J2" , "value_type" : "INT"}, + {"name" : "K1" , "value_type" : "INT"}, + {"name" : "K2" , "value_type" : "INT"}, + {"name" : "FACE" , "value_type" : "STRING"}, + {"name" : "INFLUX_COEFF" , "value_type" : "DOUBLE" , "dimension" : "Length*Length"}, + {"name" : "INFLUX_MULT" , "value_type" : "DOUBLE" , "default_value" : 1.0}, + {"name" : "CONNECT_ADJOINING_ACTIVE_CELL" , "value_type" : "STRING" , "default_value" : "NO"}]} + + diff --git a/ThirdParty/custom-opm-parser/opm-parser/opm/parser/share/keywords/000_Eclipse100/A/AQUFETP b/ThirdParty/custom-opm-parser/opm-parser/opm/parser/share/keywords/000_Eclipse100/A/AQUFETP new file mode 100644 index 0000000000..f1b3d8bcb6 --- /dev/null +++ b/ThirdParty/custom-opm-parser/opm-parser/opm/parser/share/keywords/000_Eclipse100/A/AQUFETP @@ -0,0 +1,11 @@ +{"name" : "AQUFETP" , "sections" : ["SOLUTION" , "SCHEDULE"], "size" : {"keyword":"AQUDIMS" , "item":"NANAQU"}, + "items" : [ + {"name" : "ID" , "value_type" : "INT"}, + {"name" : "DATUM_DEPTH" , "value_type" : "DOUBLE" , "dimension" : "Length"}, + {"name" : "P0" , "value_type" : "DOUBLE" , "dimension" : "Pressure"}, + {"name" : "V0" , "value_type" : "DOUBLE" , "dimension" : "Length*Length*Length"}, + {"name" : "COMPRESSIBILITY" , "value_type" : "DOUBLE" , "dimension" : "1/Pressure"}, + {"name" : "PI" , "value_type" : "DOUBLE" , "dimension" : "ReservoirVolume/Pressure*Time"}, + {"name" : "WATER_TABLE" , "value_type" : "INT" , "default_value" : 1}, + {"name" : "SALINITY" , "value_type" : "DOUBLE" , "default_value" : 0 , "dimension" : "Salinity"}, + {"name" : "TEMP" , "value_type" : "DOUBLE" , " dimension" : "Temperature"}]} diff --git a/ThirdParty/custom-opm-parser/opm-parser/opm/parser/share/keywords/000_Eclipse100/A/AQUIFER_PROBE_ANALYTIC b/ThirdParty/custom-opm-parser/opm-parser/opm/parser/share/keywords/000_Eclipse100/A/AQUIFER_PROBE_ANALYTIC new file mode 100644 index 0000000000..375e3fba14 --- /dev/null +++ b/ThirdParty/custom-opm-parser/opm-parser/opm/parser/share/keywords/000_Eclipse100/A/AQUIFER_PROBE_ANALYTIC @@ -0,0 +1,8 @@ +{"name" : "AQUIFER_PROBE_ANALYTIC" , + "sections" : ["SUMMARY"], + "data" : {"value_type" : "INT"}, + "deck_name_regex" : "AA.+"} + + + + diff --git a/ThirdParty/custom-opm-parser/opm-parser/opm/parser/share/keywords/000_Eclipse100/D/DATUM b/ThirdParty/custom-opm-parser/opm-parser/opm/parser/share/keywords/000_Eclipse100/D/DATUM new file mode 100644 index 0000000000..0afc763a7f --- /dev/null +++ b/ThirdParty/custom-opm-parser/opm-parser/opm/parser/share/keywords/000_Eclipse100/D/DATUM @@ -0,0 +1,4 @@ +{"name" : "DATUM" , "sections" : ["SOLUTION"] , "size" : 1, +"items" : [ + {"name" : "DEPTH" , "value_type" : "DOUBLE" , "dimension" : "Length"}]} + \ No newline at end of file diff --git a/ThirdParty/custom-opm-parser/opm-parser/opm/parser/share/keywords/000_Eclipse100/D/DUMPFLUX b/ThirdParty/custom-opm-parser/opm-parser/opm/parser/share/keywords/000_Eclipse100/D/DUMPFLUX new file mode 100644 index 0000000000..592fec119f --- /dev/null +++ b/ThirdParty/custom-opm-parser/opm-parser/opm/parser/share/keywords/000_Eclipse100/D/DUMPFLUX @@ -0,0 +1 @@ +{"name" : "DUMPFLUX" , "sections" : ["GRID"]} diff --git a/ThirdParty/custom-opm-parser/opm-parser/opm/parser/share/keywords/000_Eclipse100/G/GRAVITY b/ThirdParty/custom-opm-parser/opm-parser/opm/parser/share/keywords/000_Eclipse100/G/GRAVITY new file mode 100644 index 0000000000..7fef5d613c --- /dev/null +++ b/ThirdParty/custom-opm-parser/opm-parser/opm/parser/share/keywords/000_Eclipse100/G/GRAVITY @@ -0,0 +1,5 @@ +{"name" : "GRAVITY" , "sections" : ["PROPS"] , "size" : {"keyword":"TABDIMS" , "item":"NTPVT"}, + "items" : [ + {"name" : "API_GRAVITY" , "value_type" : "DOUBLE" , "dimension" : "1" , "comment" : "Dimension should be API"}, + {"name" : "WATER_SP_GRAVITY" , "value_type" : "DOUBLE" , "default" : 1.0}, + {"name" : "GAS_SP_GRAVITY" , "value_type" : "DOUBLE" , "default" : 0.7773}]} diff --git a/ThirdParty/custom-opm-parser/opm-parser/opm/parser/share/keywords/000_Eclipse100/J/JFUNC b/ThirdParty/custom-opm-parser/opm-parser/opm/parser/share/keywords/000_Eclipse100/J/JFUNC new file mode 100644 index 0000000000..c0222b5571 --- /dev/null +++ b/ThirdParty/custom-opm-parser/opm-parser/opm/parser/share/keywords/000_Eclipse100/J/JFUNC @@ -0,0 +1,8 @@ +{"name" : "JFUNC" , "sections" : ["GRID"], "size" : 1 , "items" : [ + {"name" : "FLAG" , "value_type" : "STRING", "default": "BOTH"}, + {"name" : "OW_SURFACE_TENSION" , "value_type" : "DOUBLE", "dimension":"SurfaceTension", "default": -1.0}, + {"name" : "GO_SURFACE_TENSION" , "value_type" : "DOUBLE", "dimension":"SurfaceTension", "default": -1.0}, + {"name" : "ALPHA_FACTOR" , "value_type" : "DOUBLE", "default": 0.5}, + {"name" : "BETA_FACTOR" , "value_type" : "DOUBLE", "default": 0.5}, + {"name" : "DIRECTION" , "value_type" : "STRING", "default": "XY" } +]} diff --git a/ThirdParty/custom-opm-parser/opm-parser/opm/parser/share/keywords/000_Eclipse100/M/MULTREGP b/ThirdParty/custom-opm-parser/opm-parser/opm/parser/share/keywords/000_Eclipse100/M/MULTREGP new file mode 100644 index 0000000000..020f4386f6 --- /dev/null +++ b/ThirdParty/custom-opm-parser/opm-parser/opm/parser/share/keywords/000_Eclipse100/M/MULTREGP @@ -0,0 +1,8 @@ +{"name": "MULTREGP", + "sections": ["GRID", "EDIT"], + "items": [ + {"name": "REGION", "value_type": "INT"}, + {"name": "MULTIPLIER", "value_type": "DOUBLE"}, + {"name": "REGION_TYPE", "value_type": "STRING", "default": "M"} + ] +} diff --git a/ThirdParty/custom-opm-parser/opm-parser/opm/parser/share/keywords/000_Eclipse100/R/RPTREGS b/ThirdParty/custom-opm-parser/opm-parser/opm/parser/share/keywords/000_Eclipse100/R/RPTREGS new file mode 100644 index 0000000000..5b92715678 --- /dev/null +++ b/ThirdParty/custom-opm-parser/opm-parser/opm/parser/share/keywords/000_Eclipse100/R/RPTREGS @@ -0,0 +1,3 @@ +{"name" : "RPTREGS" , "sections" : ["REGIONS"], "size" : 1, "items" : [ + {"name" : "MNEMONIC_LIST" , "size_type" : "ALL" , "value_type" : "STRING"}]} + diff --git a/ThirdParty/custom-opm-parser/opm-parser/opm/parser/share/keywords/000_Eclipse100/T/TNUM b/ThirdParty/custom-opm-parser/opm-parser/opm/parser/share/keywords/000_Eclipse100/T/TNUM new file mode 100644 index 0000000000..c407456727 --- /dev/null +++ b/ThirdParty/custom-opm-parser/opm-parser/opm/parser/share/keywords/000_Eclipse100/T/TNUM @@ -0,0 +1,4 @@ +{"name" : "TNUM" , + "deck_name_regex":"TNUM(F|S).{1,3}", + "sections" : ["REGIONS"], + "data" : {"value_type" : "INT" }} diff --git a/ThirdParty/custom-opm-parser/opm-parser/opm/parser/share/keywords/000_Eclipse100/W/WDRILTIM b/ThirdParty/custom-opm-parser/opm-parser/opm/parser/share/keywords/000_Eclipse100/W/WDRILTIM new file mode 100644 index 0000000000..558ba5740c --- /dev/null +++ b/ThirdParty/custom-opm-parser/opm-parser/opm/parser/share/keywords/000_Eclipse100/W/WDRILTIM @@ -0,0 +1,5 @@ +{"name" : "WDRILTIM" , "sections" : ["SCHEDULE"], "items": + [{"name" : "WELL" , "value_type" : "STRING"}, + {"name" : "DRILL_TIME" , "value_type" : "DOUBLE" , "dimension" : "Time" , "default_value" : 0.0}, + {"name" : "WORKOVER_CLOSE" , "value_type" : "STRING" , "default_value" : "NO"}, + {"name" : "COMPARTMENT" , "value_type" : "INT" , "default_value" : 0}]} diff --git a/ThirdParty/custom-opm-parser/opm-parser/opm/parser/share/keywords/000_Eclipse100/W/WECON b/ThirdParty/custom-opm-parser/opm-parser/opm/parser/share/keywords/000_Eclipse100/W/WECON new file mode 100644 index 0000000000..61179fad5b --- /dev/null +++ b/ThirdParty/custom-opm-parser/opm-parser/opm/parser/share/keywords/000_Eclipse100/W/WECON @@ -0,0 +1,17 @@ +{"name" : "WECON" , "sections" : ["SCHEDULE"], "items" : + [{"name" : "WELL" , "value_type" : "STRING"}, + {"name" : "MIN_OIL_PRODUCTION", "value_type" : "DOUBLE", "default" : 0.0 , "dimension" : "LiquidSurfaceVolume/Time"}, + {"name" : "MIN_GAS_PRODUCTION", "value_type" : "DOUBLE", "default" : 0.0 , "dimension" : "GasSurfaceVolume/Time"}, + {"name" : "MAX_WATER_CUT", "value_type" : "DOUBLE", "default" : 0.0}, + {"name" : "MAX_GAS_OIL_RATIO", "value_type" : "DOUBLE", "default" : 0.0}, + {"name" : "MAX_WATER_GAS_RATIO", "value_type" : "DOUBLE", "default" : 0.0}, + {"name" : "WORKOVER_RATIO_LIMIT", "value_type" : "STRING", "default" : "NONE"}, + {"name" : "END_RUN_FLAG", "value_type" : "STRING", "default" : "NO"}, + {"name" : "FOLLOW_ON_WELL", "value_type" : "STRING", "default" : "'"}, + {"name" : "LIMITED_QUANTITY", "value_type" : "STRING", "default" : "RATE"}, + {"name" : "SECOND_MAX_WATER_CUT", "value_type" : "DOUBLE", "default" : 0.0}, + {"name" : "WORKOVER_SECOND_WATER_CUT_LIMIT", "value_type" : "STRING"}, + {"name" : "MAX_GAS_LIQUID_RATIO", "value_type" : "DOUBLE", "default" : 0.0}, + {"name" : "MIN_LIQUID_PRODCUTION_RATE", "value_type" : "DOUBLE", "default" : 0.0, "dimension" : "LiquidSurfaceVolume/Time"}, + {"name" : "MAX_TEMP", "value_type" : "DOUBLE", "dimension" : "Temperature"}, + {"name" : "MIN_RES_FLUID_RATE", "value_type" : "DOUBLE", "dimension" : "ReservoirVolume/Time", "default" : 0.0}]} diff --git a/ThirdParty/custom-opm-parser/opm-parser/opm/parser/share/keywords/000_Eclipse100/W/WLIFT b/ThirdParty/custom-opm-parser/opm-parser/opm/parser/share/keywords/000_Eclipse100/W/WLIFT new file mode 100644 index 0000000000..609e1a0a80 --- /dev/null +++ b/ThirdParty/custom-opm-parser/opm-parser/opm/parser/share/keywords/000_Eclipse100/W/WLIFT @@ -0,0 +1,14 @@ +{"name" : "WLIFT" , "sections" : ["SCHEDULE"], +"items" : +[{"name" : "WELL" , "value_type" : "STRING"}, + {"name" : "TRIGGER_LIMIT" , "value_type" : "DOUBLE" , "default_value" : 0.0, "comment" : "The dimension here depends on the phase - must be handled in the application"}, + {"name" : "TRIGGRE_PHASE" , "value_type" : "STRING" , "default_value" : "OIL"}, + {"name" : "NEW_VFP_TABLE" , "value_type" : "INT" , "default_value" : 0}, + {"name" : "NEW_ALQ_VALUE" , "value_type" : "DOUBLE" , "default_value" : 0.0 , "comment" : "The dimension here depends on the phase - must be handled in the application"}, + {"name" : "NEW_WEFAC" , "value_type" : "DOUBLE" , "default_value" : 0.0}, + {"name" : "WWCT_LIMIT" , "value_type" : "DOUBLE" , "default_value" : 0.0}, + {"name" : "NEW_THP_LIMIT" , "value_type" : "DOUBLE" , "default_value" : 0.0 , "dimension" : "Pressure"}, + {"name" : "WGOR_LIMIT" , "value_type" : "DOUBLE" , "default_value" : 0.0}, + {"name" : "ALQ_SHIFT" , "value_type" : "DOUBLE" , "default_value" : 1e20}, + {"name" : "THP_SHIFT" , "value_type" : "DOUBLE" , "default_value" : 1e20 , "dimension" : "Pressure"}]} + \ No newline at end of file diff --git a/ThirdParty/custom-opm-parser/opm-parser/redhat/opm-parser.spec b/ThirdParty/custom-opm-parser/opm-parser/redhat/opm-parser.spec index 4c40a2d309..7680ca4046 100644 --- a/ThirdParty/custom-opm-parser/opm-parser/redhat/opm-parser.spec +++ b/ThirdParty/custom-opm-parser/opm-parser/redhat/opm-parser.spec @@ -2,10 +2,10 @@ # spec file for package opm-parser # -%define tag rc4 +%define tag 0test0 Name: opm-parser -Version: 2015.04 +Version: 2016.10 Release: 0 Summary: Open Porous Media - parser library License: GPL-3.0 @@ -14,8 +14,8 @@ Url: http://www.opm-project.org/ Source0: https://github.com/OPM/%{name}/archive/release/%{version}/%{tag}.tar.gz#/%{name}-%{version}.tar.gz BuildRequires: blas-devel lapack-devel dune-common-devel BuildRequires: git suitesparse-devel doxygen bc opm-common-devel -%{?el6:BuildRequires: cmake28 devtoolset-2 boost148-devel} -%{?!el6:BuildRequires: cmake gcc gcc-gfortran gcc-c++ boost-devel} +%{?el6:BuildRequires: cmake28 devtoolset-3-toolchain boost148-devel} +%{?!el6:BuildRequires: cmake gcc gcc-gfortran gcc-c++ boost-devel python-ert.ecl python-cwrap} BuildRequires: tinyxml-devel ert.ecl-devel BuildRoot: %{_tmppath}/%{name}-%{version}-build Requires: libopm-parser1 = %{version} @@ -59,13 +59,40 @@ Requires: libopm-parser1 = %{version} %description bin This package contains the applications for opm-parser +%{?!el6: + +%package -n libopm-cparser1 +Summary: Open Porous Media - parser library +Group: System/Libraries + +%package -n libopm-cparser1-devel +Summary: Development and header files for opm-cparser +Group: Development/Libraries/C and C++ +Requires: %{name} = %{version} +Requires: libopm-cparser1 = %{version} + +%description -n libopm-cparser1-devel +This package contains the development and header files for opm-cparser + +%description -n libopm-cparser1 +The Open Porous Media (OPM) initiative provides a set of open-source tools centered around the simulation of flow and transport of fluids in porous media. The goal of the initiative is to establish a sustainable environment for the development of an efficient and well-maintained software suite. This package contains the c wrapping library for the parser. + +%package -n python-opm-parser +Summary: ERT - Ensemble based Reservoir Tool - Python bindings +Group: Python/Libraries +Requires: libomp-cparser1 python-cwrap + +%description -n python-opm-parser +OPM parser python bindings. +} + %prep %setup -q -n %{name}-release-%{version}-%{tag} # consider using -DUSE_VERSIONED_DIR=ON if backporting %build -%{?el6:scl enable devtoolset-2 bash} -%{?el6:cmake28} %{?!el6:cmake} -DBUILD_SHARED_LIBS=1 -DCMAKE_BUILD_TYPE=RelWithDebInfo -DSTRIP_DEBUGGING_SYMBOLS=ON -DCMAKE_INSTALL_PREFIX=%{_prefix} -DCMAKE_INSTALL_DOCDIR=share/doc/%{name}-%{version} -DUSE_RUNPATH=OFF %{?el6:-DCMAKE_CXX_COMPILER=/opt/rh/devtoolset-2/root/usr/bin/g++ -DCMAKE_C_COMPILER=/opt/rh/devtoolset-2/root/usr/bin/gcc -DCMAKE_Fortran_COMPILER=/opt/rh/devtoolset-2/root/usr/bin/gfortran -DBOOST_LIBRARYDIR=%{_libdir}/boost148 -DBOOST_INCLUDEDIR=%{_includedir}/boost148} +%{?el6:scl enable devtoolset-3 bash} +%{?el6:cmake28} %{?!el6:cmake} -DBUILD_SHARED_LIBS=1 -DCMAKE_BUILD_TYPE=RelWithDebInfo -DSTRIP_DEBUGGING_SYMBOLS=ON -DCMAKE_INSTALL_PREFIX=%{_prefix} -DCMAKE_INSTALL_DOCDIR=share/doc/%{name}-%{version} -DUSE_RUNPATH=OFF %{?el6:-DCMAKE_CXX_COMPILER=/opt/rh/devtoolset-3/root/usr/bin/g++ -DCMAKE_C_COMPILER=/opt/rh/devtoolset-3/root/usr/bin/gcc -DCMAKE_Fortran_COMPILER=/opt/rh/devtoolset-3/root/usr/bin/gfortran -DBOOST_LIBRARYDIR=%{_libdir}/boost148 -DBOOST_INCLUDEDIR=%{_includedir}/boost148} %{?!el6:-DENABLE_PYTHON=1} make %install @@ -86,11 +113,11 @@ rm -rf %{buildroot} %files -n libopm-parser1 %defattr(-,root,root,-) -%{_libdir}/*.so.* +%{_libdir}/libopm*.so.* %files devel %defattr(-,root,root,-) -%{_libdir}/*.so +%{_libdir}/libopm*.so %{_prefix}/lib/dunecontrol/* %{_libdir}/pkgconfig/* %{_includedir}/* @@ -99,3 +126,17 @@ rm -rf %{buildroot} %files bin %{_bindir}/* + +%{?!el6: +%files -n libopm-cparser1 +%defattr(-,root,root,-) +%{_libdir}/libcopm*.so.* + +%files -n libopm-cparser1-devel +%defattr(-,root,root,-) +%{_libdir}/libcopm*.so + +%files -n python-opm-parser +%defattr(-,root,root,-) +/usr/lib/python2.7/site-packages/opm/* +} diff --git a/ThirdParty/custom-opm-parser/opm-parser/testdata/integration_tests/BOX/BOXTEST1 b/ThirdParty/custom-opm-parser/opm-parser/testdata/integration_tests/BOX/BOXTEST1 index 0716ab73c4..5e9772add0 100644 --- a/ThirdParty/custom-opm-parser/opm-parser/testdata/integration_tests/BOX/BOXTEST1 +++ b/ThirdParty/custom-opm-parser/opm-parser/testdata/integration_tests/BOX/BOXTEST1 @@ -4,6 +4,14 @@ DIMENS 10 10 10 / GRID +DX +1000*1 / +DY +1000*1 / +DZ +1000*1 / +TOPS +100*1 / PERMX 1000*1 / diff --git a/ThirdParty/custom-opm-parser/opm-parser/testdata/integration_tests/IOConfig/RPTRST_DECK.DATA b/ThirdParty/custom-opm-parser/opm-parser/testdata/integration_tests/IOConfig/RPTRST_DECK.DATA index 0b02752c04..b3bcfe75a9 100644 --- a/ThirdParty/custom-opm-parser/opm-parser/testdata/integration_tests/IOConfig/RPTRST_DECK.DATA +++ b/ThirdParty/custom-opm-parser/opm-parser/testdata/integration_tests/IOConfig/RPTRST_DECK.DATA @@ -4,6 +4,14 @@ DIMENS START 06 'NOV' 1997 / GRID +DX +113344*1 / +DY +113344*1 / +DZ +113344*1 / +TOPS +5152*1 / SPECGRID 46 112 22 1 F / SOLUTION diff --git a/ThirdParty/custom-opm-parser/opm-parser/testdata/integration_tests/IOConfig/RPT_TEST2.DATA b/ThirdParty/custom-opm-parser/opm-parser/testdata/integration_tests/IOConfig/RPT_TEST2.DATA index 73a1035c0b..1ca81c6682 100644 --- a/ThirdParty/custom-opm-parser/opm-parser/testdata/integration_tests/IOConfig/RPT_TEST2.DATA +++ b/ThirdParty/custom-opm-parser/opm-parser/testdata/integration_tests/IOConfig/RPT_TEST2.DATA @@ -8,8 +8,14 @@ START 1 'JAN' 2000 / GRID -SPECGRID - 46 112 22 1 F / +DX +905296*1 / +DY +905296*1 / +DZ +905296*1 / +TOPS +32332*1 / SOLUTION diff --git a/ThirdParty/custom-opm-parser/opm-parser/testdata/integration_tests/IOConfig/SPE9_END.DATA b/ThirdParty/custom-opm-parser/opm-parser/testdata/integration_tests/IOConfig/SPE9_END.DATA new file mode 100644 index 0000000000..3534ea0e7a --- /dev/null +++ b/ThirdParty/custom-opm-parser/opm-parser/testdata/integration_tests/IOConfig/SPE9_END.DATA @@ -0,0 +1,174 @@ +-- This reservoir simulation deck is a simplified version of SPE1CASE2.DATA +-- found in opm-data: https://github.com/OPM/opm-data/blob/master/spe1/SPE1CASE2.DATA + + +-- This reservoir simulation deck is made available under the Open Database +-- License: http://opendatacommons.org/licenses/odbl/1.0/. Any rights in +-- individual contents of the database are licensed under the Database Contents +-- License: http://opendatacommons.org/licenses/dbcl/1.0/ + +-- Copyright (C) 2015 Statoil + +-- This simulation is based on the data given in +-- 'Comparison of Solutions to a Three-Dimensional +-- Black-Oil Reservoir Simulation Problem' by Aziz S. Odeh, +-- Journal of Petroleum Technology, January 1981 + +--------------------------------------------------------------------------- +------------------------ SPE1 - CASE 2 ------------------------------------ +--------------------------------------------------------------------------- + +RUNSPEC +-- ------------------------------------------------------------------------- + +TITLE + SPE1 - CASE 2 + +DIMENS + 10 10 3 / + +-- The number of equilibration regions is inferred from the EQLDIMS +-- keyword. +EQLDIMS +/ + +-- The number of PVTW tables is inferred from the TABDIMS keyword; +-- when no data is included in the keyword the default values are used. +TABDIMS +/ + + +OIL +GAS +WATER +DISGAS +-- As seen from figure 4 in Odeh, GOR is increasing with time, +-- which means that dissolved gas is present + + +FIELD + +START + 1 'JAN' 2015 / + +GRID +-- ------------------------------------------------------------------------- + + +DX +-- There are in total 300 cells with length 1000ft in x-direction + 300*1000 / +DY +-- There are in total 300 cells with length 1000ft in y-direction + 300*1000 / +DZ +-- The layers are 20, 30 and 50 ft thick, in each layer there are 100 cells + 100*20 100*30 100*50 / + +TOPS +-- The depth of the top of each grid block + 100*8325 / + +PORO +-- Constant porosity of 0.3 throughout all 300 grid cells + 300*0.3 / + +PERMX +-- The layers have perm. 500mD, 50mD and 200mD, respectively. + 100*500 100*50 100*200 / + +PERMY +-- Equal to PERMX + 100*500 100*50 100*200 / + +PERMZ +-- Cannot find perm. in z-direction in Odeh's paper +-- For the time being, we will assume PERMZ equal to PERMX and PERMY: + 100*500 100*50 100*200 / + + + +SCHEDULE + +RPTRST + 'BASIC=4' / +WELSPECS +-- Column 3: I-value of well head or heel +-- Column 4: J-value of well head or heel +-- - these coordinates are listed in Killough's dataset +-- Column 5: ref. depth of BHP (ft) +-- - stated to be 9110ft in Killough +-- Column 6: preferred phase for well +-- - should be water for injector and oil for producers +-- Column 7: drainage radius for calc. of productivity or +-- injectivity indices (ft) +-- - stated to be 60ft in Killough + +-- #: 1 2 3 4 5 6 7 + 'INJE1' 'G' 1 1 9110 'WATER' 60 / + 'PRODU2' 'G' 2 2 9110 'OIL' 60 / + / + +COMPDAT +-- Column 2: I-value of connecting grid block +-- Column 3: J-value of connecting grid block +-- Column 4: K-value of upper connecting grid block +-- Column 5: K-value of lower connecting grid block +-- - these coordinates are listed in Killough's dataset +-- Column 9: well bore diameter +-- - Killough says radius is 0.5ft + +-- #: 1 2 3 4 5 6 7 8 9 + 'INJE1' 1 1 1 1 'OPEN' 1* 1* 1 / + 'PRODU2' 2 2 2 2 'OPEN' 1* 1* 1 / +/ + +WCONINJE +-- Killough says the water injector is set to a max rate of +-- 5000 STBW per D with a max BHP of 4000psia at a reference +-- depth of 9110ft subsea: +-- #: 1 2 3 4 5 7 + 'INJE1' 'WATER' 'OPEN' 'RATE' 5000 1* 4000 / +/ + +WCONPROD +-- Killough says the max oil rate for all producers is set to +-- 1500 STBO per D at time zero and that the min flowing BHP +-- is set to 1000psia (with a ref. depth of 9110ft +-- for this pressure in all wells): +-- #: 1 2 3 4 9 + 'PRODU*' 'OPEN' 'ORAT' 1500 4* 1000 / +-- Here, the wildcard '*' has been used to indicate that this applies +-- to all producers; PRODU1-PRODU25. +/ + +TSTEP +30*10 / + +END + +-- At 300 days, the max oil rate for all producers is lowered +-- to 100 STBO per D: +WCONPROD +-- #: 1 2 3 4 9 + 'PRODU*' 'OPEN' 'ORAT' 100 4* 1000 / +/ + +TSTEP +6*10 / + +-- At 360 days, the max oil rate for all producers is changed +-- back to 1500 STBO per D: +WCONPROD +-- #: 1 2 3 4 9 + 'PRODU*' 'OPEN' 'ORAT' 1500 4* 1000 / +/ + +TSTEP +54*10 / +-- End of simulation at 900 days + +END + + + diff --git a/ThirdParty/custom-opm-parser/opm-parser/testdata/integration_tests/SCHEDULE/SCHEDULE_COMPDAT1 b/ThirdParty/custom-opm-parser/opm-parser/testdata/integration_tests/SCHEDULE/SCHEDULE_COMPDAT1 index 6bfb091154..814da630f4 100644 --- a/ThirdParty/custom-opm-parser/opm-parser/testdata/integration_tests/SCHEDULE/SCHEDULE_COMPDAT1 +++ b/ThirdParty/custom-opm-parser/opm-parser/testdata/integration_tests/SCHEDULE/SCHEDULE_COMPDAT1 @@ -1,67 +1,88 @@ +DIMENS + 10 10 10 / + +GRID + +DX + 1000*1 / +DY + 1000*1 / +DZ + 1000*1 / + +TOPS + 1000*1 / + +SCHEDULE WELSPECS - 'W_1' 'OP' 30 37 3.33 'OIL' 7* / - 'W_2' 'OP' 30 37 3.33 'OIL' 7* / - 'W_3' 'OP' 30 37 3.33 'OIL' 7* / + 'W_1' 'OP' 3 7 3.33 'OIL' 7* / + 'W_2' 'OP' 3 7 3.33 'OIL' 7* / + 'W_3' 'OP' 3 7 3.33 'OIL' 7* / / COMPDAT -- WELL I J K1 K2 Sat. CF DIAM KH SKIN ND DIR Ro - 'W_1' 30 37 1 3 'OPEN' 1* 32.948 0.311 3047.839 2* 'X' 22.100 / - 'W_1' 30 37 2 2 'OPEN' 1* * 0.311 4332.346 2* 'X' 22.123 / - 'W_1' 30 37 3 3 'OPEN' 1* 51.867 0.311 4799.764 2* 'X' 22.143 / - 'W_1' 30 37 4 4 'OPEN' 1* 34.243 0.311 3169.482 2* 'X' 22.166 / - 'W_1' 31 37 4 4 'OPEN' 1* 8.988 0.311 832.457 2* 'X' 22.236 / - 'W_1' 31 37 5 5 'OPEN' 1* 36.435 0.311 3375.309 2* 'X' 22.262 / - 'W_1' 31 37 6 6 'OPEN' 1* 39.630 0.311 3672.067 2* 'X' 22.283 / - 'W_1' 31 37 7 7 'OPEN' 1* 33.975 0.311 3148.671 2* 'X' 22.307 / - 'W_1' 31 37 8 8 'OPEN' 1* 24.869 0.311 2305.242 2* 'X' 22.329 / - 'W_1' 31 37 9 9 'OPEN' 1* 38.301 0.311 3551.043 2* 'X' 22.351 / - 'W_1' 31 37 10 10 'OPEN' 1* 6.642 0.311 615.914 2* 'X' 22.372 / - 'W_1' 31 37 11 11 'OPEN' 1* 1.322 0.311 122.614 2* 'X' 22.396 / - 'W_1' 31 37 12 12 'OPEN' 1* 3.797 0.311 352.293 2* 'X' 22.418 / - 'W_1' 31 37 13 13 'OPEN' 1* 14.742 0.311 1367.872 2* 'X' 22.439 / - 'W_1' 31 37 14 14 'OPEN' 1* 19.731 0.311 1831.202 2* 'X' 22.463 / - 'W_2' 20 51 1 1 'OPEN' 1* 1.168 0.311 107.872 2* 'Y' 21.925 / - 'W_2' 20 51 2 2 'OPEN' 1* 15.071 0.311 1391.859 2* 'Y' 21.920 / - 'W_2' 20 51 3 3 'OPEN' 1* 6.242 0.311 576.458 2* 'Y' 21.915 / - 'W_2' 20 51 4 4 'OPEN' 1* 16.493 0.311 1522.982 2* 'Y' 21.908 / - 'W_2' 20 51 5 5 'OPEN' 1* 7.359 0.311 679.489 2* 'Y' 21.903 / - 'W_3' 31 18 1 1 'OPEN' 1* 27.412 0.311 2445.337 2* 'Y' 18.521 / - 'W_3' 31 18 2 2 'OPEN' 1* 55.195 0.311 4923.842 2* 'Y' 18.524 / - 'W_3' 31 18 3 3 'OPEN' 1* 18.032 0.311 1608.615 2* 'Y' 18.526 / - 'W_3' 31 17 3 3 'OPEN' 1* 56.817 0.311 5047.177 2* 'Y' 18.155 / - 'W_3' 31 17 4 4 'OPEN' 1* 4.728 0.311 420.067 2* 'Y' 18.162 / + 'W_1' 3 3 1 3 'OPEN' 1* 32.948 0.311 3047.839 2* 'X' 22.100 / + 'W_1' 3 3 2 2 'OPEN' 1* * 0.311 4332.346 2* 'X' 22.123 / + 'W_1' 3 3 3 3 'OPEN' 1* 51.867 0.311 4799.764 2* 'X' 22.143 / + 'W_1' 3 3 4 4 'OPEN' 1* 34.243 0.311 3169.482 2* 'X' 22.166 / + 'W_1' 3 3 4 4 'OPEN' 1* 8.988 0.311 832.457 2* 'X' 22.236 / + 'W_1' 3 3 5 5 'OPEN' 1* 36.435 0.311 3375.309 2* 'X' 22.262 / + 'W_1' 3 3 6 6 'OPEN' 1* 39.630 0.311 3672.067 2* 'X' 22.283 / + 'W_1' 3 3 7 7 'OPEN' 1* 33.975 0.311 3148.671 2* 'X' 22.307 / + 'W_1' 3 3 8 8 'OPEN' 1* 24.869 0.311 2305.242 2* 'X' 22.329 / + 'W_1' 3 3 9 9 'OPEN' 1* 38.301 0.311 3551.043 2* 'X' 22.351 / + 'W_1' 3 3 1 1 'OPEN' 1* 6.642 0.311 615.914 2* 'X' 22.372 / + 'W_1' 3 3 1 1 'OPEN' 1* 1.322 0.311 122.614 2* 'X' 22.396 / + 'W_1' 3 3 1 1 'OPEN' 1* 3.797 0.311 352.293 2* 'X' 22.418 / + 'W_1' 3 3 1 1 'OPEN' 1* 14.742 0.311 1367.872 2* 'X' 22.439 / + 'W_1' 3 3 1 1 'OPEN' 1* 19.731 0.311 1831.202 2* 'X' 22.463 / + 'W_2' 2 5 1 1 'SHUT' 1* 1.168 0.311 107.872 2* 'Y' 21.925 / + 'W_2' 2 5 2 2 'SHUT' 1* 15.071 0.311 1391.859 2* 'Y' 21.920 / + 'W_2' 2 5 3 3 'SHUT' 1* 6.242 0.311 576.458 2* 'Y' 21.915 / + 'W_2' 2 5 4 4 'SHUT' 1* 16.493 0.311 1522.982 2* 'Y' 21.908 / + 'W_2' 2 5 5 5 'SHUT' 1* 7.359 0.311 679.489 2* 'Y' 21.903 / + 'W_3' 3 1 1 1 'OPEN' 1* 27.412 0.311 2445.337 2* 'Y' 18.521 / + 'W_3' 3 1 2 2 'OPEN' 1* 55.195 0.311 4923.842 2* 'Y' 18.524 / + 'W_3' 3 1 3 3 'OPEN' 1* 18.032 0.311 1608.615 2* 'Y' 18.526 / + 'W_3' 3 1 3 3 'OPEN' 1* 56.817 0.311 5047.177 2* 'Y' 18.155 / + 'W_3' 3 1 4 4 'OPEN' 1* 4.728 0.311 420.067 2* 'Y' 18.162 / / COMPDAT -- WELL I J K1 K2 Sat. CF DIAM KH SKIN ND DIR Ro - 'W_1' 30 37 1 3 'OPEN' 1* 32.948 0.311 3047.839 2* 'X' 22.100 / - 'W_1' 30 37 2 2 'OPEN' 1* 23487.0 0.311 4332.346 2* 'X' 22.123 / - 'W_1' 30 37 3 3 'OPEN' 1* 51.867 0.311 4799.764 2* 'X' 22.143 / - 'W_1' 30 37 4 4 'OPEN' 1* 34.243 0.311 3169.482 2* 'X' 22.166 / - 'W_1' 31 37 4 4 'OPEN' 1* 8.988 0.311 832.457 2* 'X' 22.236 / - 'W_1' 31 37 5 5 'OPEN' 1* 36.435 0.311 3375.309 2* 'X' 22.262 / - 'W_1' 31 37 6 6 'OPEN' 1* 39.630 0.311 3672.067 2* 'X' 22.283 / - 'W_1' 31 37 7 7 'OPEN' 1* 33.975 0.311 3148.671 2* 'X' 22.307 / - 'W_1' 31 37 8 8 'OPEN' 1* 24.869 0.311 2305.242 2* 'X' 22.329 / - 'W_1' 31 37 9 9 'OPEN' 1* 38.301 0.311 3551.043 2* 'X' 22.351 / - 'W_1' 31 37 10 10 'OPEN' 1* 6.642 0.311 615.914 2* 'X' 22.372 / - 'W_1' 31 37 11 11 'OPEN' 1* 1.322 0.311 122.614 2* 'X' 22.396 / - 'W_1' 31 37 12 12 'OPEN' 1* 3.797 0.311 352.293 2* 'X' 22.418 / - 'W_1' 31 37 13 13 'OPEN' 1* 14.742 0.311 1367.872 2* 'X' 22.439 / - 'W_1' 31 37 14 14 'OPEN' 1* 19.731 0.311 1831.202 2* 'X' 22.463 / - 'W_2' 20 51 1 1 'OPEN' 1* 1.168 0.311 107.872 2* 'Y' 21.925 / - 'W_2' 20 51 2 2 'OPEN' 1* 15.071 0.311 1391.859 2* 'Y' 21.920 / - 'W_2' 20 51 3 3 'OPEN' 1* 6.242 0.311 576.458 2* 'Y' 21.915 / - 'W_2' 20 51 4 4 'OPEN' 1* 16.493 0.311 1522.982 2* 'Y' 21.908 / - 'W_2' 20 51 5 5 'OPEN' 1* 7.359 0.311 679.489 2* 'Y' 21.903 / - 'W_3' 31 18 1 1 'OPEN' 1* 27.412 0.311 2445.337 2* 'Y' 18.521 / - 'W_3' 31 18 2 2 'OPEN' 1* 55.195 0.311 4923.842 2* 'Y' 18.524 / - 'W_3' 31 18 3 3 'OPEN' 1* 18.032 0.311 1608.615 2* 'Y' 18.526 / - 'W_3' 31 17 3 3 'OPEN' 1* 56.817 0.311 5047.177 2* 'Y' 18.155 / - 'W_3' 31 17 4 4 'OPEN' 1* 4.728 1* 420.067 2* 'Y' 18.162 / + 'W_1' 3 7 1 3 'OPEN' 1* 32.948 0.311 3047.839 2* 'X' 22.100 / + 'W_1' 3 7 2 2 'OPEN' 1* 23487.0 0.311 4332.346 2* 'X' 22.123 / + 'W_1' 3 7 3 3 'OPEN' 1* 51.867 0.311 4799.764 2* 'X' 22.143 / + 'W_1' 3 7 4 4 'OPEN' 1* 34.243 0.311 3169.482 2* 'X' 22.166 / + 'W_1' 3 7 4 4 'OPEN' 1* 8.988 0.311 832.457 2* 'X' 22.236 / + 'W_1' 3 7 5 5 'OPEN' 1* 36.435 0.311 3375.309 2* 'X' 22.262 / + 'W_1' 3 7 6 6 'OPEN' 1* 39.630 0.311 3672.067 2* 'X' 22.283 / + 'W_1' 3 7 7 7 'OPEN' 1* 33.975 0.311 3148.671 2* 'X' 22.307 / + 'W_1' 3 7 8 8 'OPEN' 1* 24.869 0.311 2305.242 2* 'X' 22.329 / + 'W_1' 3 7 9 9 'OPEN' 1* 38.301 0.311 3551.043 2* 'X' 22.351 / + 'W_1' 3 7 1 1 'OPEN' 1* 6.642 0.311 615.914 2* 'X' 22.372 / + 'W_1' 3 7 1 1 'OPEN' 1* 1.322 0.311 122.614 2* 'X' 22.396 / + 'W_1' 3 7 1 1 'OPEN' 1* 3.797 0.311 352.293 2* 'X' 22.418 / + 'W_1' 3 7 1 1 'OPEN' 1* 14.742 0.311 1367.872 2* 'X' 22.439 / + 'W_1' 3 7 1 1 'OPEN' 1* 19.731 0.311 1831.202 2* 'X' 22.463 / + 'W_2' 2 1 1 1 'SHUT' 1* 1.168 0.311 107.872 2* 'Y' 21.925 / + 'W_2' 2 1 2 2 'SHUT' 1* 15.071 0.311 1391.859 2* 'Y' 21.920 / + 'W_2' 2 1 3 3 'SHUT' 1* 6.242 0.311 576.458 2* 'Y' 21.915 / + 'W_2' 2 1 4 4 'SHUT' 1* 16.493 0.311 1522.982 2* 'Y' 21.908 / + 'W_2' 2 1 5 5 'SHUT' 1* 7.359 0.311 679.489 2* 'Y' 21.903 / + 'W_3' 3 8 1 1 'OPEN' 1* 27.412 0.311 2445.337 2* 'Y' 18.521 / + 'W_3' 3 8 2 2 'OPEN' 1* 55.195 0.311 4923.842 2* 'Y' 18.524 / + 'W_3' 3 8 3 3 'OPEN' 1* 18.032 0.311 1608.615 2* 'Y' 18.526 / + 'W_3' 3 7 3 3 'OPEN' 1* 56.817 0.311 5047.177 2* 'Y' 18.155 / + 'W_3' 3 7 4 4 'OPEN' 1* 4.728 1* 420.067 2* 'Y' 18.162 / / +WCONPROD + 'W_1' 'OPEN' 'ORAT' 20000 4* 1000 / + 'W_2' 'OPEN' 'ORAT' 20000 4* 1000 / + 'W_3' 'OPEN' 'ORAT' 20000 4* 1000 / +/ diff --git a/ThirdParty/custom-opm-parser/opm-parser/testdata/integration_tests/SCHEDULE/SCHEDULE_WECON b/ThirdParty/custom-opm-parser/opm-parser/testdata/integration_tests/SCHEDULE/SCHEDULE_WECON new file mode 100644 index 0000000000..93c19d9db1 --- /dev/null +++ b/ThirdParty/custom-opm-parser/opm-parser/testdata/integration_tests/SCHEDULE/SCHEDULE_WECON @@ -0,0 +1,44 @@ +START + 10 MAY 2007 / + + +SCHEDULE + + +WELSPECS + 'INJE01' 'I' 1 1 1* 'WATER' / + 'PROD01' 'P' 10 1 1* 'OIL' 7* / + 'PROD02' 'P' 20 1 1* 'OIL' 7* / +/ + +COMPDAT + 'INJE01' 1 1 2 2 'OPEN' 1* 200. 0.5 / + 'PROD01' 10 1 1 1 'OPEN' 1* 200. 0.5 / + 'PROD02' 20 1 1 1 'OPEN' 1* 200. 0.5 / +/ + +WCONINJE + 'INJE01' 'WATER' 'OPEN' 'RATE' 800.00 1* 1000 / +/ + +WCONPROD + 'PROD01' 'OPEN' 'BHP' 5* 200 / + 'PROD02' 'OPEN' 'BHP' 5* 200 / +/ + +WECON + 'PROD01' 50 1* 0.95 2* CON NO / +/ + +TSTEP +10 +/ + +WECON + 'PROD01' 1* 1000 0.95 2* CON NO / + 'PROD02' 1* 1000 0.95 2* CON NO / +/ + +TSTEP +10 +/ diff --git a/ThirdParty/custom-opm-parser/opm-parser/testdata/integration_tests/SCHEDULE/SCHEDULE_WELLS2 b/ThirdParty/custom-opm-parser/opm-parser/testdata/integration_tests/SCHEDULE/SCHEDULE_WELLS2 index 4906bc0d63..3e05fe6215 100644 --- a/ThirdParty/custom-opm-parser/opm-parser/testdata/integration_tests/SCHEDULE/SCHEDULE_WELLS2 +++ b/ThirdParty/custom-opm-parser/opm-parser/testdata/integration_tests/SCHEDULE/SCHEDULE_WELLS2 @@ -37,6 +37,8 @@ COMPDAT WCONHIST -- the spaces around the names indicator are intentional! +-- they test that even padded quoted literals as arguments to WCONHIST and +-- friends are stripped correctly ' W_1 ' ' OPEN ' ' ORAT ' 4000.000 4.000 12345 5* / 'W_2' 'SHUT' 'ORAT' 7998.000 2.000 1461075.000 5* / 'W_3' 'AUTO' 'ORAT' 7999.000 1.000 1471824.000 5* / diff --git a/ThirdParty/custom-opm-parser/opm-parser/testdata/integration_tests/TRANS/Deck1 b/ThirdParty/custom-opm-parser/opm-parser/testdata/integration_tests/TRANS/Deck1 index 04bdff60d2..f9e779d0b4 100644 --- a/ThirdParty/custom-opm-parser/opm-parser/testdata/integration_tests/TRANS/Deck1 +++ b/ThirdParty/custom-opm-parser/opm-parser/testdata/integration_tests/TRANS/Deck1 @@ -10,6 +10,14 @@ DIMENS 5 5 1 / GRID +DX +25*1 / +DY +25*1 / +DZ +25*1 / +TOPS +25*1 / FAULTS 'F1' 3 3 1 5 1 1 'X' /