diff --git a/CMakeLists_files.cmake b/CMakeLists_files.cmake index c91c3cfac..dd5c8965b 100644 --- a/CMakeLists_files.cmake +++ b/CMakeLists_files.cmake @@ -119,6 +119,7 @@ if(ENABLE_ECL_INPUT) src/opm/input/eclipse/EclipseState/Grid/BoxManager.cpp src/opm/input/eclipse/EclipseState/Grid/Carfin.cpp src/opm/input/eclipse/EclipseState/Grid/CarfinManager.cpp + src/opm/input/eclipse/EclipseState/Grid/LgrCollection.cpp src/opm/input/eclipse/EclipseState/Grid/EclipseGrid.cpp src/opm/input/eclipse/EclipseState/Grid/FieldProps.cpp src/opm/input/eclipse/EclipseState/Grid/FieldPropsManager.cpp @@ -1084,6 +1085,7 @@ if(ENABLE_ECL_INPUT) opm/input/eclipse/EclipseState/Grid/Fault.hpp opm/input/eclipse/EclipseState/Grid/Box.hpp opm/input/eclipse/EclipseState/Grid/Carfin.hpp + opm/input/eclipse/EclipseState/Grid/LgrCollection.hpp opm/input/eclipse/EclipseState/Grid/FieldProps.hpp opm/input/eclipse/EclipseState/Grid/FieldPropsManager.hpp opm/input/eclipse/EclipseState/Grid/FaultFace.hpp diff --git a/opm/input/eclipse/EclipseState/EclipseState.hpp b/opm/input/eclipse/EclipseState/EclipseState.hpp index 9e90e89f5..bfcd0e1a3 100644 --- a/opm/input/eclipse/EclipseState/EclipseState.hpp +++ b/opm/input/eclipse/EclipseState/EclipseState.hpp @@ -34,6 +34,7 @@ #include #include #include +#include #include #include #include @@ -95,6 +96,9 @@ namespace Opm { const EclipseConfig& cfg() const; const GridDims& gridDims() const; + virtual const CarfinManager& getInputGLgr() const; + bool hasInputLGR() 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 units. @@ -166,6 +170,7 @@ namespace Opm { EclipseGrid m_inputGrid; NNC m_inputNnc; GridDims m_gridDims; + LgrCollection m_inputLgr; FieldPropsManager field_props; SimulationConfig m_simulationConfig; AquiferConfig aquifer_config; diff --git a/opm/input/eclipse/EclipseState/Grid/LgrCollection.hpp b/opm/input/eclipse/EclipseState/Grid/LgrCollection.hpp new file mode 100644 index 000000000..611123677 --- /dev/null +++ b/opm/input/eclipse/EclipseState/Grid/LgrCollection.hpp @@ -0,0 +1,64 @@ +/* + Copyright (C) 2023 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_PARSER_LGR_COLLECTION_HPP +#define OPM_PARSER_LGR_COLLECTION_HPP + +#include +#include + +#include +#include +#include + +namespace Opm { + + class DeckRecord; + class GridDims; + class GRIDSection; + + +class LgrCollection { +public: + LgrCollection(); + LgrCollection(const GRIDSection& gridSection, const GridDims& grid); + + static LgrCollection serializationTestObject(); + + size_t size() const; + bool hasLgr(const std::string& lgrName) const; + Carfin& getLgr(const std::string& lgrName); + const Carfin& getLgr(const std::string& lgrName) const; + Carfin& getLgr(size_t lgrIndex); + const Carfin& getLgr(size_t lgrIndex) const; + + + void addLgr(const std::string& lgrName); + + bool operator==(const LgrCollection& data) const; + + template + void serializeOp(Serializer& serializer) + { + serializer(m_lgrs); + } + +private: + +OrderedMap m_lgrs; +}; +} + +#endif // OPM_PARSER_LGR_COLLECTION_HPP diff --git a/src/opm/input/eclipse/EclipseState/EclipseState.cpp b/src/opm/input/eclipse/EclipseState/EclipseState.cpp index c65f013e7..05721b398 100644 --- a/src/opm/input/eclipse/EclipseState/EclipseState.cpp +++ b/src/opm/input/eclipse/EclipseState/EclipseState.cpp @@ -127,6 +127,7 @@ namespace Opm { , m_inputNnc( m_inputGrid, deck) , m_gridDims( deck ) , field_props( deck, m_runspec.phases(), m_inputGrid, m_tables) + , m_inputLgrs( deck) , m_simulationConfig( m_eclipseConfig.init().restartRequested(), deck, field_props) , aquifer_config( m_tables, m_inputGrid, deck, field_props) , m_transMult( GridDims(deck), deck, field_props) diff --git a/src/opm/input/eclipse/EclipseState/Grid/LgrCollection.cpp b/src/opm/input/eclipse/EclipseState/Grid/LgrCollection.cpp new file mode 100644 index 000000000..8b9dd5f48 --- /dev/null +++ b/src/opm/input/eclipse/EclipseState/Grid/LgrCollection.cpp @@ -0,0 +1,118 @@ +/* + Copyright (C) 2023 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 + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +namespace Opm { + + + LgrCollection::LgrCollection() + {} + + LgrCollection::LgrCollection(const GRIDSection& gridSection, + const GridDims& grid) { + const auto& lgrKeywords = gridSection.getKeywordList(); + + for (auto keyword_iter = lgrKeywords.begin(); keyword_iter != lgrKeywords.end(); ++keyword_iter) { + const auto& lgrsKeyword = *keyword_iter; + OpmLog::info(OpmInputError::format("\nLoading faults from {keyword} in {file} line {line}", lgrsKeyword->location())); + + for (auto iter = lgrsKeyword->begin(); iter != lgrsKeyword->end(); ++iter) { + const auto& lgrRecord = *iter; + const std::string& lgrName = lgrRecord.getItem(0).get< std::string >(0); + + addLgr(grid, lgrRecord, lgrName); + } + } + } + + LgrCollection LgrCollection::serializationTestObject() + { + LgrCollection result; + result.m_lgrs.insert({"test", Carfin::serializationTestObject()}); + + return result; + } + + void LgrCollection::addFaultFaces(const GridDims& grid, + const DeckRecord& lgrRecord, + const std::string& lgrName) + { + 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)); + FaultFace face { grid.getNX(), grid.getNY(), grid.getNZ(), + size_t(I1), size_t(I2), + size_t(J1), size_t(J2), + size_t(K1), size_t(K2), + faceDir }; + + if (!hasFault(faultName)) + addFault(faultName); + + getFault( faultName ).addFace( face ); + } + + size_t LgrCollection::size() const { + return m_lgrs.size(); + } + + bool LgrCollection::hasFault(const std::string& faultName) const { + return m_flgrs.count( faultName ) > 0; + } + + const Fault& FaultCollection::getFault(const std::string& faultName) const { + return m_lgrs.get( faultName ); + } + + Fault& LgrCollection::getFault(const std::string& faultName) { + return m_lgrs.get( faultName ); + } + + Fault& LgrCollection::getFault(size_t faultIndex) { + return m_lgrs.iget( faultIndex ); + } + + const Fault& LgrCollection::getFault(size_t faultIndex) const { + return m_lgrs.iget( faultIndex ); + } + + void LgrCollection::addLgr(const std::string& lgrName) { + Carfin lgr(lgrName); + m_lgrs.insert(std::make_pair(lgr.getName() , lgr)); + } + + bool LgrCollection::operator==(const LgrCollection& data) const { + return this->m_lgrs == data.m_lgrs; + } +}