Merge pull request #3573 from goncalvesmachadoc/collectCarfin

Store Multiple Lgrs
This commit is contained in:
Bård Skaflestad
2023-07-21 09:34:48 +02:00
committed by GitHub
8 changed files with 309 additions and 0 deletions

View File

@@ -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
@@ -503,6 +504,7 @@ if(ENABLE_ECL_INPUT)
tests/parser/ImportTests.cpp
tests/parser/InitConfigTest.cpp
tests/parser/IOConfigTests.cpp
tests/parser/LgrTests.cpp
tests/parser/MICPTests.cpp
tests/parser/MessageLimitTests.cpp
tests/parser/MultiRegTests.cpp
@@ -1084,6 +1086,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

View File

@@ -34,6 +34,7 @@
#include <opm/input/eclipse/EclipseState/Grid/FaultCollection.hpp>
#include <opm/input/eclipse/EclipseState/Grid/NNC.hpp>
#include <opm/input/eclipse/EclipseState/Grid/TransMult.hpp>
#include <opm/input/eclipse/EclipseState/Grid/LgrCollection.hpp>
#include <opm/input/eclipse/EclipseState/Runspec.hpp>
#include <opm/input/eclipse/EclipseState/Tables/TableManager.hpp>
#include <opm/input/eclipse/EclipseState/SimulationConfig/SimulationConfig.hpp>
@@ -95,6 +96,9 @@ namespace Opm {
const EclipseConfig& cfg() const;
const GridDims& gridDims() const;
const LgrCollection& getLgrs() 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.
@@ -131,6 +135,7 @@ namespace Opm {
serializer(m_deckUnitSystem);
serializer(m_inputNnc);
serializer(m_gridDims);
serializer(m_lgrs);
serializer(m_simulationConfig);
serializer(aquifer_config);
serializer(m_transMult);
@@ -148,6 +153,7 @@ namespace Opm {
void initIOConfigPostSchedule(const Deck& deck);
void assignRunTitle(const Deck& deck);
void reportNumberOfActivePhases() const;
void initLgrs(const Deck& deck);
void conveyNumericalAquiferEffects();
void applyMULTXYZ();
void initFaults(const Deck& deck);
@@ -167,6 +173,7 @@ namespace Opm {
NNC m_inputNnc;
GridDims m_gridDims;
FieldPropsManager field_props;
LgrCollection m_lgrs;
SimulationConfig m_simulationConfig;
AquiferConfig aquifer_config;
TransMult m_transMult;

View File

@@ -55,6 +55,7 @@ namespace Opm
{}
};
Carfin() = default;
explicit Carfin(const GridDims& gridDims,
IsActive isActive,
@@ -93,6 +94,15 @@ namespace Opm
int NY() const;
int NZ() const;
template<class Serializer>
void serializeOp(Serializer& serializer)
{
serializer(m_dims);
serializer(m_offset);
serializer(m_end_offset);
serializer(name_grid);
}
private:
GridDims m_globalGridDims_{};
IsActive m_globalIsActive_{};

View File

@@ -0,0 +1,65 @@
/*
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 <http://www.gnu.org/licenses/>.
*/
#ifndef OPM_PARSER_LGR_COLLECTION_HPP
#define OPM_PARSER_LGR_COLLECTION_HPP
#include <string>
#include <opm/input/eclipse/EclipseState/Util/OrderedMap.hpp>
#include <opm/input/eclipse/EclipseState/Grid/CarfinManager.hpp>
#include <opm/input/eclipse/EclipseState/Grid/Carfin.hpp>
#include <opm/input/eclipse/EclipseState/Grid/EclipseGrid.hpp>
namespace Opm {
class DeckRecord;
class GridDims;
class GRIDSection;
class LgrCollection {
public:
LgrCollection();
LgrCollection(const GRIDSection& gridSection, const EclipseGrid& grid);
static LgrCollection serializationTestObject();
explicit LgrCollection(const Deck& deck);
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 EclipseGrid& grid, const DeckRecord& lgrRecord);
bool operator==(const LgrCollection& data) const;
template<class Serializer>
void serializeOp(Serializer& serializer)
{
serializer(m_lgrs);
}
private:
OrderedMap<Carfin, 8> m_lgrs;
};
}
#endif // OPM_PARSER_LGR_COLLECTION_HPP

View File

@@ -140,6 +140,7 @@ namespace Opm {
this->conveyNumericalAquiferEffects();
this->m_inputGrid.resetACTNUM(this->field_props.actnum());
this->field_props.reset_actnum(this->getInputGrid().getACTNUM());
this->initLgrs(deck);
this->aquifer_config.load_connections(deck, this->getInputGrid());
this->applyMULTXYZ();
@@ -235,6 +236,10 @@ namespace Opm {
return m_faults;
}
const LgrCollection& EclipseState::getLgrs() const {
return m_lgrs;
}
const MICPpara& EclipseState::getMICPpara() const {
return m_micppara;
}
@@ -269,6 +274,17 @@ namespace Opm {
return !m_inputNnc.input().empty();
}
void EclipseState::initLgrs(const Deck& deck) {
if (!DeckSection::hasGRID(deck))
return;
const GRIDSection gridSection ( deck );
m_lgrs = LgrCollection(gridSection, m_inputGrid);
}
std::string EclipseState::getTitle() const {
return m_title;
}

View File

@@ -75,6 +75,7 @@ namespace {
namespace Opm
{
Carfin::Carfin(const GridDims& gridDims,
IsActive isActive,
ActiveIdx activeIdx)

View File

@@ -0,0 +1,92 @@
/*
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 <http://www.gnu.org/licenses/>.
*/
#include <opm/common/utility/OpmInputError.hpp>
#include <opm/common/OpmLog/OpmLog.hpp>
#include <opm/input/eclipse/Deck/DeckRecord.hpp>
#include <opm/input/eclipse/Deck/DeckSection.hpp>
#include <opm/input/eclipse/EclipseState/Grid/EclipseGrid.hpp>
#include <opm/input/eclipse/EclipseState/Grid/GridDims.hpp>
#include <opm/input/eclipse/EclipseState/Grid/LgrCollection.hpp>
#include <opm/input/eclipse/EclipseState/Grid/CarfinManager.hpp>
#include <opm/input/eclipse/EclipseState/Grid/Carfin.hpp>
#include <opm/input/eclipse/Parser/ParserKeywords/C.hpp>
namespace Opm {
LgrCollection::LgrCollection()
{}
/*
This class stores all LGR's. At this moment we only support lgr's input from CARFIN blocks
TODO: Collect also lgrs from RADFIN blocks...
*/
LgrCollection::LgrCollection(const GRIDSection& gridSection, const EclipseGrid& grid) {
const auto& lgrKeywords = gridSection.getKeywordList<ParserKeywords::CARFIN>();
for (const auto& lgrsKeyword : lgrKeywords) {
OpmLog::info(OpmInputError::format("\nLoading lgrs from {keyword} in {file} line {line}", lgrsKeyword->location()));
for (const auto& lgrRecord : *lgrsKeyword) {
addLgr(grid, lgrRecord);
}
}
}
size_t LgrCollection::size() const {
return m_lgrs.size();
}
bool LgrCollection::hasLgr(const std::string& lgrName) const {
return m_lgrs.count( lgrName ) > 0;
}
const Carfin& LgrCollection::getLgr(const std::string& lgrName) const {
return m_lgrs.get( lgrName );
}
Carfin& LgrCollection::getLgr(const std::string& lgrName) {
return m_lgrs.get( lgrName );
}
const Carfin& LgrCollection::getLgr(size_t lgrIndex) const {
return m_lgrs.iget( lgrIndex );
}
Carfin& LgrCollection::getLgr(size_t lgrIndex) {
return m_lgrs.iget( lgrIndex );
}
void LgrCollection::addLgr(const EclipseGrid& grid, const DeckRecord& lgrRecord) {
Carfin lgr(grid,
[&grid](const std::size_t global_index)
{
return grid.cellActive(global_index);
},
[&grid](const std::size_t global_index)
{
return grid.activeIndex(global_index);
});
lgr.update(lgrRecord);
m_lgrs.insert(std::make_pair(lgr.NAME(), lgr));
}
bool LgrCollection::operator==(const LgrCollection& data) const {
return this->m_lgrs == data.m_lgrs;
}
}

115
tests/parser/LgrTests.cpp Normal file
View File

@@ -0,0 +1,115 @@
/*
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 <http://www.gnu.org/licenses/>.
*/
#define BOOST_TEST_MODULE LgrTests
#include <boost/test/unit_test.hpp>
#include <boost/test/test_tools.hpp>
#include <opm/input/eclipse/Deck/Deck.hpp>
#include <opm/input/eclipse/Parser/Parser.hpp>
#include <opm/input/eclipse/EclipseState/EclipseState.hpp>
#include <opm/input/eclipse/EclipseState/Grid/LgrCollection.hpp>
#include <opm/input/eclipse/EclipseState/Grid/Carfin.hpp>
#include <opm/input/eclipse/EclipseState/EclipseState.hpp>
#include <filesystem>
using namespace Opm;
BOOST_AUTO_TEST_CASE(CreateLgrCollection) {
Opm::LgrCollection lgrs;
BOOST_CHECK_EQUAL( lgrs.size() , 0U );
BOOST_CHECK(! lgrs.hasLgr("NO-NotThisOne"));
BOOST_CHECK_THROW( lgrs.getLgr("NO") , std::invalid_argument );
}
BOOST_AUTO_TEST_CASE(ReadLgrCollection) {
const std::string deck_string = R"(
RUNSPEC
DIMENS
10 10 10 /
GRID
CARFIN
-- NAME I1-I2 J1-J2 K1-K2 NX NY NZ
'LGR1' 5 6 5 6 1 3 6 6 9 /
ENDFIN
CARFIN
-- NAME I1-I2 J1-J2 K1-K2 NX NY NZ
'LGR2' 7 8 7 8 1 3 8 8 9 /
ENDFIN
DX
1000*1 /
DY
1000*1 /
DZ
1000*1 /
TOPS
100*1 /
PORO
1000*0.15 /
PERMX
1000*1 /
COPY
PERMX PERMZ /
PERMX PERMY /
/
EDIT
OIL
GAS
TITLE
The title
START
16 JUN 1988 /
PROPS
REGIONS
SOLUTION
SCHEDULE
)";
Opm::Parser parser;
Opm::Deck deck = parser.parseString(deck_string);
Opm::EclipseState state(deck);
Opm::LgrCollection lgrs = state.getLgrs();
BOOST_CHECK_EQUAL( lgrs.size() , 2U );
BOOST_CHECK(lgrs.hasLgr("LGR1"));
BOOST_CHECK(lgrs.hasLgr("LGR2"));
const auto& lgr1 = state.getLgrs().getLgr("LGR1");
BOOST_CHECK_EQUAL(lgr1.NAME(), "LGR1");
const auto& lgr2 = lgrs.getLgr("LGR2");
BOOST_CHECK_EQUAL( lgr2.NAME() , "LGR2");
const auto& lgr3 = state.getLgrs().getLgr(0);
BOOST_CHECK_EQUAL( lgr1.NAME() , lgr3.NAME());
}