diff --git a/CMakeLists_files.cmake b/CMakeLists_files.cmake index b98d23efc..e11d89721 100644 --- a/CMakeLists_files.cmake +++ b/CMakeLists_files.cmake @@ -51,6 +51,7 @@ if(ENABLE_ECL_INPUT) src/opm/parser/eclipse/Deck/DeckSection.cpp src/opm/parser/eclipse/Deck/UDAValue.cpp src/opm/parser/eclipse/Python/Python.cpp + src/opm/parser/eclipse/EclipseState/AquiferConfig.cpp src/opm/parser/eclipse/EclipseState/AquiferCT.cpp src/opm/parser/eclipse/EclipseState/Aquifetp.cpp src/opm/parser/eclipse/EclipseState/Aquancon.cpp @@ -608,6 +609,7 @@ if(ENABLE_ECL_INPUT) opm/parser/eclipse/EclipseState/EclipseState.hpp opm/parser/eclipse/EclipseState/EclipseConfig.hpp opm/parser/eclipse/EclipseState/Aquancon.hpp + opm/parser/eclipse/EclipseState/AquiferConfig.hpp opm/parser/eclipse/EclipseState/AquiferCT.hpp opm/parser/eclipse/EclipseState/Aquifetp.hpp opm/parser/eclipse/EclipseState/Schedule/Action/ActionAST.hpp diff --git a/opm/parser/eclipse/EclipseState/AquiferConfig.hpp b/opm/parser/eclipse/EclipseState/AquiferConfig.hpp new file mode 100644 index 000000000..d88a29fa3 --- /dev/null +++ b/opm/parser/eclipse/EclipseState/AquiferConfig.hpp @@ -0,0 +1,52 @@ +/* + Copyright (C) 2020 Equinor + + 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_AUQIFER_CONFIG_HPP +#define OPM_AUQIFER_CONFIG_HPP + +#include +#include +#include + +namespace Opm { + +class TableManager; +class EclipseGrid; +class Deck; + +class AquiferConfig { +public: + AquiferConfig() = default; + AquiferConfig(const TableManager& tables, const EclipseGrid& grid, const Deck& deck); + AquiferConfig(const Aquifetp& fetp, const AquiferCT& ct, const Aquancon& conn); + + bool active() const; + const AquiferCT& ct() const; + const Aquifetp& fetp() const; + const Aquancon& connections() const; + bool operator==(const AquiferConfig& other); +private: + Aquifetp aquifetp; + AquiferCT aquiferct; + Aquancon aqconn; +}; + +} + +#endif diff --git a/opm/parser/eclipse/EclipseState/EclipseState.hpp b/opm/parser/eclipse/EclipseState/EclipseState.hpp index 842e24f6e..abd74fc75 100644 --- a/opm/parser/eclipse/EclipseState/EclipseState.hpp +++ b/opm/parser/eclipse/EclipseState/EclipseState.hpp @@ -24,6 +24,7 @@ #include #include +#include #include #include #include @@ -57,6 +58,7 @@ namespace Opm { class TableManager; class UnitSystem; + class EclipseState { public: enum EnabledTypes { @@ -104,7 +106,7 @@ namespace Opm { void applyModifierDeck(const Deck& deck); const Runspec& runspec() const; - + const AquiferConfig& aquifer() const; private: void initIOConfigPostSchedule(const Deck& deck); void initTransMult(); @@ -128,7 +130,7 @@ namespace Opm { FaultCollection m_faults; std::string m_title; - + AquiferConfig aquifer_config; }; } diff --git a/src/opm/parser/eclipse/EclipseState/AquiferConfig.cpp b/src/opm/parser/eclipse/EclipseState/AquiferConfig.cpp new file mode 100644 index 000000000..f8ee06b14 --- /dev/null +++ b/src/opm/parser/eclipse/EclipseState/AquiferConfig.cpp @@ -0,0 +1,65 @@ +/* + Copyright (C) 2020 Equinor + + 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 { + +AquiferConfig::AquiferConfig(const TableManager& tables, const EclipseGrid& grid, const Deck& deck): + aquifetp(deck), + aquiferct(tables, deck), + aqconn(grid,deck) +{} + + +AquiferConfig::AquiferConfig(const Aquifetp& fetp, const AquiferCT& ct, const Aquancon& conn) : + aquifetp(fetp), + aquiferct(ct), + aqconn(conn) +{} + + +bool AquiferConfig::active() const { + return this->aqconn.active(); +} + +bool AquiferConfig::operator==(const AquiferConfig& other) { + return this->aquifetp == other.aquifetp && + this->aquiferct == other.aquiferct && + this->aqconn == other.aqconn; +} + +const AquiferCT& AquiferConfig::ct() const { + return this->aquiferct; +} + +const Aquifetp& AquiferConfig::fetp() const { + return this->aquifetp; +} + +const Aquancon& AquiferConfig::connections() const { + return this->aqconn; +} + +} diff --git a/src/opm/parser/eclipse/EclipseState/EclipseState.cpp b/src/opm/parser/eclipse/EclipseState/EclipseState.cpp index 6b09b93e8..1a2d1cd7a 100644 --- a/src/opm/parser/eclipse/EclipseState/EclipseState.cpp +++ b/src/opm/parser/eclipse/EclipseState/EclipseState.cpp @@ -63,6 +63,7 @@ namespace Opm { if( this->runspec().phases().size() < 3 ) OpmLog::info("Only " + std::to_string( this->runspec().phases().size() ) + " fluid phases are enabled" ); + this->aquifer_config = AquiferConfig(this->m_tables, this->m_inputGrid, deck); if (deck.hasKeyword( "TITLE" )) { const auto& titleKeyword = deck.getKeyword( "TITLE" ); @@ -162,6 +163,10 @@ namespace Opm { return m_title; } + const AquiferConfig& EclipseState::aquifer() const { + return this->aquifer_config; + } + void EclipseState::initTransMult() { const auto& fp = this->field_props; if (fp.has_double("MULTX")) this->m_transMult.applyMULT(fp.get_global_double("MULTX") , FaceDir::XPlus); diff --git a/tests/parser/AquiferTests.cpp b/tests/parser/AquiferTests.cpp index f19d8413c..7fda19612 100644 --- a/tests/parser/AquiferTests.cpp +++ b/tests/parser/AquiferTests.cpp @@ -22,9 +22,23 @@ along with OPM. If not, see . #include #include #include +#include using namespace Opm; + +EclipseGrid makeGrid() { + EclipseGrid grid(3,3,3); + std::vector actnum(27,1); + actnum[0] = 0; + actnum[9] = 0; + actnum[18] = 0; + grid.resetACTNUM(actnum); + return grid; +} + + + inline Deck createAquiferCTDeck() { const char *deckData = "DIMENS\n" @@ -286,8 +300,8 @@ inline Deck createAQUANCONDeck() { BOOST_AUTO_TEST_CASE(AquanconTest_DEFAULT_INFLUX) { auto deck1 = createAQUANCONDeck_DEFAULT_INFLUX1(); - EclipseState eclState1( deck1 ); - Aquancon aqcon(eclState1.getInputGrid(), deck1); + const auto& grid = makeGrid(); + Aquancon aqcon(grid, deck1); const auto& cells_aq1 = aqcon[1]; /* @@ -301,13 +315,11 @@ BOOST_AUTO_TEST_CASE(AquanconTest_DEFAULT_INFLUX) { BOOST_CHECK(aqcon.active()); auto deck2 = createAQUANCONDeck_DEFAULT_INFLUX2(); - EclipseState eclState2( deck2 ); - BOOST_CHECK_THROW(Aquancon( eclState2.getInputGrid(), deck2), std::invalid_argument); + BOOST_CHECK_THROW(Aquancon( grid, deck2), std::invalid_argument); // The cell (2,1,1) is attached to both aquifer 1 and aquifer 2 - that is illegal. auto deck3 = createAQUANCONDeck_DEFAULT_ILLEGAL(); - EclipseState eclState3( deck3 ); - BOOST_CHECK_THROW(Aquancon( eclState3.getInputGrid(), deck3), std::invalid_argument); + BOOST_CHECK_THROW(Aquancon( grid, deck3), std::invalid_argument); } @@ -507,6 +519,7 @@ BOOST_AUTO_TEST_CASE(AquifetpTest){ BOOST_CHECK_EQUAL(it.J, 500/86400e5); BOOST_CHECK( !it.p0.first ); } + } BOOST_AUTO_TEST_CASE(TEST_CREATE) { @@ -521,3 +534,23 @@ BOOST_AUTO_TEST_CASE(TEST_CREATE) { BOOST_CHECK_EQUAL( aqudims.getNumAquiferLists() , 0 ); BOOST_CHECK_EQUAL( aqudims.getNumAnalyticAquifersSingleList() , 0 ); } + +BOOST_AUTO_TEST_CASE(Test_Aquifer_Config) { + const std::string deck_string = R"( +DIMENS + 3 3 3 / +)"; + Opm::Parser parser; + Opm::Deck deck = parser.parseString(deck_string); + Opm::TableManager tables; + Opm::EclipseGrid grid(10,10,10); + Opm::AquiferConfig conf(tables, grid, deck); + BOOST_CHECK(!conf.active()); + + + const auto& fetp = conf.fetp(); + const auto& ct = conf.ct(); + const auto& conn = conf.connections(); + Opm::AquiferConfig conf2(fetp, ct, conn); + BOOST_CHECK( conf == conf2 ); +}