From be90d11b3b205def08db904eaec6edbb13735f2e Mon Sep 17 00:00:00 2001 From: Arne Morten Kvarving Date: Wed, 23 Nov 2022 12:23:10 +0100 Subject: [PATCH 1/3] BCConfig: add missing include --- opm/input/eclipse/EclipseState/SimulationConfig/BCConfig.hpp | 1 + 1 file changed, 1 insertion(+) diff --git a/opm/input/eclipse/EclipseState/SimulationConfig/BCConfig.hpp b/opm/input/eclipse/EclipseState/SimulationConfig/BCConfig.hpp index 543508882..994a015e9 100644 --- a/opm/input/eclipse/EclipseState/SimulationConfig/BCConfig.hpp +++ b/opm/input/eclipse/EclipseState/SimulationConfig/BCConfig.hpp @@ -22,6 +22,7 @@ #include #include +#include #include #include From e23feb31f111d2ff8101f004142330da8a16a17f Mon Sep 17 00:00:00 2001 From: Arne Morten Kvarving Date: Wed, 23 Nov 2022 12:23:26 +0100 Subject: [PATCH 2/3] RockConfig: add missing include --- opm/input/eclipse/EclipseState/SimulationConfig/RockConfig.hpp | 1 + 1 file changed, 1 insertion(+) diff --git a/opm/input/eclipse/EclipseState/SimulationConfig/RockConfig.hpp b/opm/input/eclipse/EclipseState/SimulationConfig/RockConfig.hpp index 5fb9b623a..44565379e 100644 --- a/opm/input/eclipse/EclipseState/SimulationConfig/RockConfig.hpp +++ b/opm/input/eclipse/EclipseState/SimulationConfig/RockConfig.hpp @@ -21,6 +21,7 @@ #define OPM_ROCK_CONFIG_HPP #include +#include namespace Opm { From 8ea4d68e7a33f4298987acf3917a0cedc8ae564c Mon Sep 17 00:00:00 2001 From: Arne Morten Kvarving Date: Wed, 23 Nov 2022 12:23:41 +0100 Subject: [PATCH 3/3] ThresholdPressure: internalize THPRESFT keyword --- .../SimulationConfig/SimulationConfig.hpp | 1 + .../SimulationConfig/ThresholdPressure.hpp | 14 ++++++ .../eclipse/EclipseState/EclipseState.cpp | 1 + .../SimulationConfig/ThresholdPressure.cpp | 42 +++++++++++++++- tests/parser/ThresholdPressureTest.cpp | 49 ++++++++++++++++++- 5 files changed, 105 insertions(+), 2 deletions(-) diff --git a/opm/input/eclipse/EclipseState/SimulationConfig/SimulationConfig.hpp b/opm/input/eclipse/EclipseState/SimulationConfig/SimulationConfig.hpp index edc3b24d9..2cdba1b07 100644 --- a/opm/input/eclipse/EclipseState/SimulationConfig/SimulationConfig.hpp +++ b/opm/input/eclipse/EclipseState/SimulationConfig/SimulationConfig.hpp @@ -71,6 +71,7 @@ namespace Opm { } private: + friend class EclipseState; ThresholdPressure m_ThresholdPressure; BCConfig m_bcconfig; RockConfig m_rock_config; diff --git a/opm/input/eclipse/EclipseState/SimulationConfig/ThresholdPressure.hpp b/opm/input/eclipse/EclipseState/SimulationConfig/ThresholdPressure.hpp index 5fea71fb9..49de27f1d 100644 --- a/opm/input/eclipse/EclipseState/SimulationConfig/ThresholdPressure.hpp +++ b/opm/input/eclipse/EclipseState/SimulationConfig/ThresholdPressure.hpp @@ -20,6 +20,7 @@ #ifndef OPM_TRESHOLD_PRESSURES_HPP #define OPM_TRESHOLD_PRESSURES_HPP +#include #include #include @@ -27,6 +28,7 @@ namespace Opm { class Deck; + class FaultCollection; class FieldPropsManager; class ThresholdPressure { @@ -45,6 +47,11 @@ namespace Opm { , m_irreversible(false) {} + + //! \brief Reads the THPRESFT keyword if present. + void readFaults(const Deck& deck, + const FaultCollection& faults); + //! \brief Returns an instance for serialization tests. static ThresholdPressure serializationTestObject(); @@ -73,6 +80,11 @@ namespace Opm { hasThresholdPressure(r1,r2) first to be safe. */ double getThresholdPressure(int r1 , int r2) const; + + //! \brief Returns threshold pressure for a fault. + double getThresholdPressureFault(int idx) const; + + size_t ftSize() const; size_t size() const; bool active() const; bool restart() const; @@ -89,6 +101,7 @@ namespace Opm { serializer(m_irreversible); serializer(m_thresholdPressureTable); serializer(m_pressureTable); + serializer(m_thresholdFaultTable); } private: @@ -102,6 +115,7 @@ namespace Opm { std::vector> m_thresholdPressureTable; std::map , std::pair > m_pressureTable; + std::vector m_thresholdFaultTable; }; } //namespace Opm diff --git a/src/opm/input/eclipse/EclipseState/EclipseState.cpp b/src/opm/input/eclipse/EclipseState/EclipseState.cpp index 4901bef28..e337c9c12 100644 --- a/src/opm/input/eclipse/EclipseState/EclipseState.cpp +++ b/src/opm/input/eclipse/EclipseState/EclipseState.cpp @@ -143,6 +143,7 @@ namespace Opm { this->applyMULTXYZ(); this->initFaults(deck); + m_simulationConfig.m_ThresholdPressure.readFaults(deck,m_faults); if (this->getInitConfig().restartRequested()) { verify_consistent_restart_information(deck.get().back(), diff --git a/src/opm/input/eclipse/EclipseState/SimulationConfig/ThresholdPressure.cpp b/src/opm/input/eclipse/EclipseState/SimulationConfig/ThresholdPressure.cpp index 166555176..7f47e42ce 100644 --- a/src/opm/input/eclipse/EclipseState/SimulationConfig/ThresholdPressure.cpp +++ b/src/opm/input/eclipse/EclipseState/SimulationConfig/ThresholdPressure.cpp @@ -18,7 +18,9 @@ */ #include +#include #include +#include #include #include #include @@ -127,6 +129,38 @@ namespace Opm { } } + void ThresholdPressure::readFaults(const Deck& deck, + const FaultCollection& faults) + { + if (!DeckSection::hasGRID(deck) || !DeckSection::hasSOLUTION(deck)) + return; + + GRIDSection gridSection( deck ); + + const bool thpresftKeyword = gridSection.hasKeyword(); + if (!thpresftKeyword) + return; + + // extract the multipliers from the deck keyword + m_thresholdFaultTable.resize(faults.size(), -1.0); + for (const auto& thpresft : gridSection.get()) { + for (size_t recordIdx = 0; recordIdx < thpresft.size(); ++ recordIdx) { + const DeckRecord& record = thpresft.getRecord(recordIdx); + + const std::string& faultName = record.getItem("FAULT_NAME").getTrimmedString(0); + double thpresValue = record.getItem("VALUE").getSIDouble(0); + + for (size_t faultIdx = 0; faultIdx < faults.size(); faultIdx++) { + auto& fault = faults.getFault(faultIdx); + if (!shmatch(faultName, fault.getName())) + continue; + + m_thresholdFaultTable[faultIdx] = thpresValue; + } + } + } + } + ThresholdPressure ThresholdPressure::serializationTestObject() { ThresholdPressure result; @@ -166,9 +200,11 @@ namespace Opm { } } - } + double ThresholdPressure::getThresholdPressureFault(int idx) const { + return m_thresholdFaultTable[idx]; + } std::pair ThresholdPressure::makeIndex(int r1 , int r2) const { if (this->m_irreversible) @@ -199,6 +235,10 @@ namespace Opm { return m_pressureTable.size(); } + size_t ThresholdPressure::ftSize() const { + return m_thresholdFaultTable.size(); + } + bool ThresholdPressure::active() const { return m_active; } diff --git a/tests/parser/ThresholdPressureTest.cpp b/tests/parser/ThresholdPressureTest.cpp index b5333954c..d917a2bef 100644 --- a/tests/parser/ThresholdPressureTest.cpp +++ b/tests/parser/ThresholdPressureTest.cpp @@ -26,7 +26,9 @@ #include #include +#include #include +#include #include #include #include @@ -54,6 +56,39 @@ THPRES / )"; +const std::string& inputStrft = R"( +RUNSPEC +EQLOPTS +THPRES / +DIMENS +10 10 10 / + +REGIONS +EQLNUM + 120*3 / +SOLUTION +THPRES +1 2 12.0/ +1 3 5.0/ +2 3 33.0 / +2 3 7.0/ +/ + +GRID +DX +1000*0.25 / +DY +1000*0.25 / +DZ +1000*0.25 / +FAULTS + 'F1' 1 1 1 4 1 4 'X' / +/ +THPRESFT + 'F1' 1.0 / +/ +)"; + const std::string& inputStr_RESTART = R"( RUNSPEC EQLOPTS @@ -235,7 +270,7 @@ struct Setup InitConfig initConfig; ThresholdPressure threshPres; - explicit Setup(const std::string& input) : + explicit Setup(const std::string& input, bool ft = false) : deck(createDeck(ParseContext(), input)), tablemanager(deck), grid(10, 3, 4), @@ -243,6 +278,12 @@ struct Setup initConfig(deck), threshPres(initConfig.restartRequested(), deck, fp) { + if (ft) { + GRIDSection gridSection(deck); + GridDims dims(deck); + auto faults = FaultCollection(gridSection, dims); + threshPres.readFaults(deck, faults); + } } explicit Setup(const std::string& input, const ParseContext& parseContextArg) : @@ -341,3 +382,9 @@ BOOST_AUTO_TEST_CASE(Irreversible) { const auto& thp = s.threshPres; BOOST_CHECK(thp.getThresholdPressure(1,2) == -thp.getThresholdPressure(2,1)); } + +BOOST_AUTO_TEST_CASE(Faults) { + Setup s(inputStrft, true); + const auto& thp = s.threshPres; + BOOST_CHECK(thp.getThresholdPressureFault(0) == 100000.0); +}