added: FIPConfig class

this parses FIP related flags from RPT(SCHED|SOL)
This commit is contained in:
Arne Morten Kvarving 2023-11-08 15:31:55 +01:00
parent 33c529652b
commit 3f08071eae
4 changed files with 456 additions and 0 deletions

View File

@ -142,6 +142,7 @@ if(ENABLE_ECL_INPUT)
src/opm/input/eclipse/EclipseState/InitConfig/Equil.cpp
src/opm/input/eclipse/EclipseState/InitConfig/FoamConfig.cpp
src/opm/input/eclipse/EclipseState/InitConfig/InitConfig.cpp
src/opm/input/eclipse/EclipseState/IOConfig/FIPConfig.cpp
src/opm/input/eclipse/EclipseState/IOConfig/IOConfig.cpp
src/opm/input/eclipse/EclipseState/Runspec.cpp
src/opm/input/eclipse/EclipseState/Phase.cpp
@ -503,6 +504,7 @@ if(ENABLE_ECL_INPUT)
tests/parser/FaceDirTests.cpp
tests/parser/FaultTests.cpp
tests/parser/FieldPropsTests.cpp
tests/parser/FIPConfigTests.cpp
tests/parser/FoamTests.cpp
tests/parser/FunctionalTests.cpp
tests/parser/GeomodifierTests.cpp
@ -1302,6 +1304,7 @@ if(ENABLE_ECL_INPUT)
opm/input/eclipse/EclipseState/SimulationConfig/RockConfig.hpp
opm/input/eclipse/EclipseState/SimulationConfig/SimulationConfig.hpp
opm/input/eclipse/Schedule/MSW/Valve.hpp
opm/input/eclipse/EclipseState/IOConfig/FIPConfig.hpp
opm/input/eclipse/EclipseState/IOConfig/IOConfig.hpp
opm/input/eclipse/EclipseState/checkDeck.hpp
opm/input/eclipse/EclipseState/Phase.hpp

View File

@ -0,0 +1,93 @@
/*
Copyright 2023 SINTEF Digital
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_FIP_CONFIG_HPP
#define OPM_FIP_CONFIG_HPP
#include <bitset>
namespace Opm {
class Deck;
class DeckKeyword;
class RPTConfig;
//! \brief Class holding FIP configuration from RPTSOL/RPTSCHED keyword.
class FIPConfig {
public:
//! \brief Enumeration of FIP report outputs.
enum FIPOutputField {
FIELD = 0, //!< Whole field
FIPNUM = 1, //!< FIPNUM regions
FIP = 2, //!< FIP defined regions
FOAM_FIELD = 3, //!< Foam field report
FOAM_REGION = 4, //!< Foam region report
POLYMER_FIELD = 5, //!< Polymer field report
POLYMER_REGION = 6, //!< Polymer region report
RESV = 7, //!< RESV report
SOLVENT_FIELD = 8, //!< Solvent field report
SOLVENT_REGION = 9, //!< Solvent region report
TEMPERATURE_FIELD = 10, //!< Temperature field report
TEMPERATURE_REGION = 11, //!< Temperature region report
SURF_FIELD = 12, //!< Surfacant field report
SURF_REGION = 13, //!< Surfacant region report
TRACER_FIELD = 14, //!< Tracer field report
TRACER_REGION = 15, //!< Tracer region report
VE = 16, //!< VE (oil, water, gas) zone report
NUM_FIP_REPORT = 17, //!< Number of configuration flags
};
//! \brief Default constructor.
FIPConfig() = default;
//! \brief Construct from RPTSOL keyword if deck holds one.
explicit FIPConfig(const Deck& deck);
//! \brief Construct from given keyword (RPTSOL or RPTSCHED).
explicit FIPConfig(const DeckKeyword& keyword);
//! \brief Construct from given RTPConfig.
explicit FIPConfig(const RPTConfig& rptConfig);
//! \brief Returns a test object used for serialization tests.
static FIPConfig serializationTestObject();
//! \brief (De-)serialization handler.
template<class Serializer>
void serializeOp(Serializer& serializer)
{
serializer(m_flags);
}
//! \brief Query if FIP output is enabled for a given field.
bool output(FIPOutputField field) const;
//! \brief Comparison operator.
bool operator==(const FIPConfig& rhs) const;
private:
//! \brief Initialize flags based on mnemonics in a RPTConfig instance.
void parseRPT(const RPTConfig& rptConfig);
std::bitset<NUM_FIP_REPORT> m_flags = {}; //!< Bitset holding enable status for fields
};
} //namespace Opm
#endif

View File

@ -0,0 +1,105 @@
/*
Copyright 2023 SINTEF Digital
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/input/eclipse/EclipseState/IOConfig/FIPConfig.hpp>
#include <opm/input/eclipse/Deck/DeckSection.hpp>
#include <opm/input/eclipse/Parser/ParserKeywords/R.hpp>
#include <opm/input/eclipse/Schedule/RPTConfig.hpp>
#include <vector>
namespace Opm {
FIPConfig::FIPConfig(const Deck& deck)
{
SOLUTIONSection solution_section(deck);
if (solution_section.hasKeyword<ParserKeywords::RPTSOL>()) {
this->parseRPT(solution_section.get<ParserKeywords::RPTSOL>().back());
}
}
FIPConfig::FIPConfig(const DeckKeyword& keyword)
: FIPConfig(RPTConfig(keyword))
{
}
FIPConfig::FIPConfig(const RPTConfig& rptConfig)
{
this->parseRPT(rptConfig);
}
void FIPConfig::parseRPT(const RPTConfig& rptConfig)
{
auto parseFlags = [this](const std::vector<int>& flags,
const unsigned value)
{
for (size_t i = 0; i < flags.size(); ++i) {
if (value > i) {
m_flags.set(flags[i]);
}
}
};
for (const auto& mnemonic : rptConfig) {
if (mnemonic.first == "FIP") {
parseFlags({FIELD, FIPNUM, FIP}, mnemonic.second);
} else if (mnemonic.first == "FIPFOAM") {
parseFlags({FOAM_FIELD, FOAM_REGION}, mnemonic.second);
} else if (mnemonic.first == "FIPPLY") {
parseFlags({POLYMER_FIELD, POLYMER_REGION}, mnemonic.second);
} else if (mnemonic.first == "FIPSOL") {
parseFlags({SOLVENT_FIELD, SOLVENT_REGION}, mnemonic.second);
} else if (mnemonic.first == "FIPSURF") {
parseFlags({SURF_FIELD, SURF_REGION}, mnemonic.second);
} else if (mnemonic.first == "FIPHEAT" || mnemonic.first == "FIPTEMP") {
parseFlags({TEMPERATURE_FIELD, TEMPERATURE_REGION}, mnemonic.second);
} else if (mnemonic.first == "FIPTR") {
parseFlags({TRACER_FIELD, TRACER_REGION}, mnemonic.second);
} else if (mnemonic.first == "FIPRESV") {
m_flags.set(RESV);
} else if (mnemonic.first == "FIPVE") {
m_flags.set(VE);
}
}
}
FIPConfig FIPConfig::serializationTestObject()
{
FIPConfig result;
result.m_flags.set(FIELD);
result.m_flags.set(FIP);
result.m_flags.set(RESV);
return result;
}
bool FIPConfig::output(FIPOutputField field) const
{
return m_flags.test(field);
}
bool FIPConfig::operator==(const FIPConfig& rhs) const
{
return this->m_flags == rhs.m_flags;
}
} //namespace Opm

View File

@ -0,0 +1,255 @@
/*
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 <http://www.gnu.org/licenses/>.
*/
#define BOOST_TEST_MODULE FIPConfigTests
#include <boost/test/unit_test.hpp>
#include <opm/input/eclipse/Deck/Deck.hpp>
#include <opm/input/eclipse/Deck/DeckSection.hpp>
#include <opm/input/eclipse/EclipseState/IOConfig/FIPConfig.hpp>
#include <opm/input/eclipse/Parser/Parser.hpp>
#include <opm/input/eclipse/Parser/ParserKeywords/R.hpp>
using namespace Opm;
BOOST_AUTO_TEST_CASE(FieldFoamFieldResv)
{
const std::string data = R"(
SOLUTION
RPTSOL
'FIP=1' 'FIPFOAM=1' 'FIPRESV' /
)";
auto deck = Parser().parseString( data );
const auto& keyword = SOLUTIONSection(deck).get<ParserKeywords::RPTSOL>().back();
FIPConfig fipConfig(keyword);
BOOST_CHECK( fipConfig.output(FIPConfig::FIELD));
BOOST_CHECK(!fipConfig.output(FIPConfig::FIPNUM));
BOOST_CHECK(!fipConfig.output(FIPConfig::FIP));
BOOST_CHECK( fipConfig.output(FIPConfig::FOAM_FIELD));
BOOST_CHECK(!fipConfig.output(FIPConfig::FOAM_REGION));
BOOST_CHECK(!fipConfig.output(FIPConfig::POLYMER_FIELD));
BOOST_CHECK(!fipConfig.output(FIPConfig::POLYMER_REGION));
BOOST_CHECK( fipConfig.output(FIPConfig::RESV));
BOOST_CHECK(!fipConfig.output(FIPConfig::SOLVENT_FIELD));
BOOST_CHECK(!fipConfig.output(FIPConfig::SOLVENT_REGION));
BOOST_CHECK(!fipConfig.output(FIPConfig::SURF_FIELD));
BOOST_CHECK(!fipConfig.output(FIPConfig::SURF_REGION));
BOOST_CHECK(!fipConfig.output(FIPConfig::TEMPERATURE_FIELD));
BOOST_CHECK(!fipConfig.output(FIPConfig::TEMPERATURE_REGION));
BOOST_CHECK(!fipConfig.output(FIPConfig::TRACER_FIELD));
BOOST_CHECK(!fipConfig.output(FIPConfig::TRACER_REGION));
BOOST_CHECK(!fipConfig.output(FIPConfig::VE));
}
BOOST_AUTO_TEST_CASE(FieldFipnumFipFoamFieldFoamRegionResv)
{
const std::string data = R"(
SOLUTION
RPTSOL
'FIP=3' 'FIPFOAM=2' 'FIPVE' /
)";
auto deck = Parser().parseString( data );
const auto& keyword = SOLUTIONSection(deck).get<ParserKeywords::RPTSOL>().back();
FIPConfig fipConfig(keyword);
BOOST_CHECK( fipConfig.output(FIPConfig::FIELD));
BOOST_CHECK( fipConfig.output(FIPConfig::FIPNUM));
BOOST_CHECK( fipConfig.output(FIPConfig::FIP));
BOOST_CHECK( fipConfig.output(FIPConfig::FOAM_FIELD));
BOOST_CHECK( fipConfig.output(FIPConfig::FOAM_REGION));
BOOST_CHECK(!fipConfig.output(FIPConfig::POLYMER_FIELD));
BOOST_CHECK(!fipConfig.output(FIPConfig::POLYMER_REGION));
BOOST_CHECK(!fipConfig.output(FIPConfig::RESV));
BOOST_CHECK(!fipConfig.output(FIPConfig::SOLVENT_FIELD));
BOOST_CHECK(!fipConfig.output(FIPConfig::SOLVENT_REGION));
BOOST_CHECK(!fipConfig.output(FIPConfig::SURF_FIELD));
BOOST_CHECK(!fipConfig.output(FIPConfig::SURF_REGION));
BOOST_CHECK(!fipConfig.output(FIPConfig::TEMPERATURE_FIELD));
BOOST_CHECK(!fipConfig.output(FIPConfig::TEMPERATURE_REGION));
BOOST_CHECK(!fipConfig.output(FIPConfig::TRACER_FIELD));
BOOST_CHECK(!fipConfig.output(FIPConfig::TRACER_REGION));
BOOST_CHECK( fipConfig.output(FIPConfig::VE));
}
BOOST_AUTO_TEST_CASE(PolymerFieldPolymerRegion)
{
const std::string data = R"(
SOLUTION
RPTSOL
'FIPPLY=2' /
)";
auto deck = Parser().parseString( data );
const auto& keyword = SOLUTIONSection(deck).get<ParserKeywords::RPTSOL>().back();
FIPConfig fipConfig(keyword);
BOOST_CHECK(!fipConfig.output(FIPConfig::FIELD));
BOOST_CHECK(!fipConfig.output(FIPConfig::FIPNUM));
BOOST_CHECK(!fipConfig.output(FIPConfig::FIP));
BOOST_CHECK(!fipConfig.output(FIPConfig::FOAM_FIELD));
BOOST_CHECK(!fipConfig.output(FIPConfig::FOAM_REGION));
BOOST_CHECK( fipConfig.output(FIPConfig::POLYMER_FIELD));
BOOST_CHECK( fipConfig.output(FIPConfig::POLYMER_REGION));
BOOST_CHECK(!fipConfig.output(FIPConfig::RESV));
BOOST_CHECK(!fipConfig.output(FIPConfig::SOLVENT_FIELD));
BOOST_CHECK(!fipConfig.output(FIPConfig::SOLVENT_REGION));
BOOST_CHECK(!fipConfig.output(FIPConfig::SURF_FIELD));
BOOST_CHECK(!fipConfig.output(FIPConfig::SURF_REGION));
BOOST_CHECK(!fipConfig.output(FIPConfig::TEMPERATURE_FIELD));
BOOST_CHECK(!fipConfig.output(FIPConfig::TEMPERATURE_REGION));
BOOST_CHECK(!fipConfig.output(FIPConfig::TRACER_FIELD));
BOOST_CHECK(!fipConfig.output(FIPConfig::TRACER_REGION));
BOOST_CHECK(!fipConfig.output(FIPConfig::VE));
}
BOOST_AUTO_TEST_CASE(SurfFieldSurfRegion)
{
const std::string data = R"(
SOLUTION
RPTSOL
'FIPSURF=2' /
)";
auto deck = Parser().parseString( data );
const auto& keyword = SOLUTIONSection(deck).get<ParserKeywords::RPTSOL>().back();
FIPConfig fipConfig(keyword);
BOOST_CHECK(!fipConfig.output(FIPConfig::FIELD));
BOOST_CHECK(!fipConfig.output(FIPConfig::FIPNUM));
BOOST_CHECK(!fipConfig.output(FIPConfig::FIP));
BOOST_CHECK(!fipConfig.output(FIPConfig::FOAM_FIELD));
BOOST_CHECK(!fipConfig.output(FIPConfig::FOAM_REGION));
BOOST_CHECK(!fipConfig.output(FIPConfig::POLYMER_FIELD));
BOOST_CHECK(!fipConfig.output(FIPConfig::POLYMER_REGION));
BOOST_CHECK(!fipConfig.output(FIPConfig::RESV));
BOOST_CHECK(!fipConfig.output(FIPConfig::SOLVENT_FIELD));
BOOST_CHECK(!fipConfig.output(FIPConfig::SOLVENT_REGION));
BOOST_CHECK( fipConfig.output(FIPConfig::SURF_FIELD));
BOOST_CHECK( fipConfig.output(FIPConfig::SURF_REGION));
BOOST_CHECK(!fipConfig.output(FIPConfig::TEMPERATURE_FIELD));
BOOST_CHECK(!fipConfig.output(FIPConfig::TEMPERATURE_REGION));
BOOST_CHECK(!fipConfig.output(FIPConfig::TRACER_FIELD));
BOOST_CHECK(!fipConfig.output(FIPConfig::TRACER_REGION));
BOOST_CHECK(!fipConfig.output(FIPConfig::VE));
}
BOOST_AUTO_TEST_CASE(HeatFieldHeatRegion)
{
const std::string data = R"(
SOLUTION
RPTSOL
'FIPHEAT=2' /
)";
auto deck = Parser().parseString( data );
const auto& keyword = SOLUTIONSection(deck).get<ParserKeywords::RPTSOL>().back();
FIPConfig fipConfig(keyword);
BOOST_CHECK(!fipConfig.output(FIPConfig::FIELD));
BOOST_CHECK(!fipConfig.output(FIPConfig::FIPNUM));
BOOST_CHECK(!fipConfig.output(FIPConfig::FIP));
BOOST_CHECK(!fipConfig.output(FIPConfig::FOAM_FIELD));
BOOST_CHECK(!fipConfig.output(FIPConfig::FOAM_REGION));
BOOST_CHECK(!fipConfig.output(FIPConfig::POLYMER_FIELD));
BOOST_CHECK(!fipConfig.output(FIPConfig::POLYMER_REGION));
BOOST_CHECK(!fipConfig.output(FIPConfig::RESV));
BOOST_CHECK(!fipConfig.output(FIPConfig::SOLVENT_FIELD));
BOOST_CHECK(!fipConfig.output(FIPConfig::SOLVENT_REGION));
BOOST_CHECK(!fipConfig.output(FIPConfig::SURF_FIELD));
BOOST_CHECK(!fipConfig.output(FIPConfig::SURF_REGION));
BOOST_CHECK( fipConfig.output(FIPConfig::TEMPERATURE_FIELD));
BOOST_CHECK( fipConfig.output(FIPConfig::TEMPERATURE_REGION));
BOOST_CHECK(!fipConfig.output(FIPConfig::TRACER_FIELD));
BOOST_CHECK(!fipConfig.output(FIPConfig::TRACER_REGION));
BOOST_CHECK(!fipConfig.output(FIPConfig::VE));
}
BOOST_AUTO_TEST_CASE(TemperatureFieldTemperatureRegion)
{
const std::string data = R"(
SOLUTION
RPTSOL
'FIPTEMP=2' /
)";
auto deck = Parser().parseString( data );
const auto& keyword = SOLUTIONSection(deck).get<ParserKeywords::RPTSOL>().back();
FIPConfig fipConfig(keyword);
BOOST_CHECK(!fipConfig.output(FIPConfig::FIELD));
BOOST_CHECK(!fipConfig.output(FIPConfig::FIPNUM));
BOOST_CHECK(!fipConfig.output(FIPConfig::FIP));
BOOST_CHECK(!fipConfig.output(FIPConfig::FOAM_FIELD));
BOOST_CHECK(!fipConfig.output(FIPConfig::FOAM_REGION));
BOOST_CHECK(!fipConfig.output(FIPConfig::POLYMER_FIELD));
BOOST_CHECK(!fipConfig.output(FIPConfig::POLYMER_REGION));
BOOST_CHECK(!fipConfig.output(FIPConfig::RESV));
BOOST_CHECK(!fipConfig.output(FIPConfig::SOLVENT_FIELD));
BOOST_CHECK(!fipConfig.output(FIPConfig::SOLVENT_REGION));
BOOST_CHECK(!fipConfig.output(FIPConfig::SURF_FIELD));
BOOST_CHECK(!fipConfig.output(FIPConfig::SURF_REGION));
BOOST_CHECK( fipConfig.output(FIPConfig::TEMPERATURE_FIELD));
BOOST_CHECK( fipConfig.output(FIPConfig::TEMPERATURE_REGION));
BOOST_CHECK(!fipConfig.output(FIPConfig::TRACER_FIELD));
BOOST_CHECK(!fipConfig.output(FIPConfig::TRACER_REGION));
BOOST_CHECK(!fipConfig.output(FIPConfig::VE));
}
BOOST_AUTO_TEST_CASE(TracerFieldTracerRegion)
{
const std::string data = R"(
SOLUTION
RPTSOL
'FIPTR=2' /
)";
auto deck = Parser().parseString( data );
const auto& keyword = SOLUTIONSection(deck).get<ParserKeywords::RPTSOL>().back();
FIPConfig fipConfig(keyword);
BOOST_CHECK(!fipConfig.output(FIPConfig::FIELD));
BOOST_CHECK(!fipConfig.output(FIPConfig::FIPNUM));
BOOST_CHECK(!fipConfig.output(FIPConfig::FIP));
BOOST_CHECK(!fipConfig.output(FIPConfig::FOAM_FIELD));
BOOST_CHECK(!fipConfig.output(FIPConfig::FOAM_REGION));
BOOST_CHECK(!fipConfig.output(FIPConfig::POLYMER_FIELD));
BOOST_CHECK(!fipConfig.output(FIPConfig::POLYMER_REGION));
BOOST_CHECK(!fipConfig.output(FIPConfig::RESV));
BOOST_CHECK(!fipConfig.output(FIPConfig::SOLVENT_FIELD));
BOOST_CHECK(!fipConfig.output(FIPConfig::SOLVENT_REGION));
BOOST_CHECK(!fipConfig.output(FIPConfig::SURF_FIELD));
BOOST_CHECK(!fipConfig.output(FIPConfig::SURF_REGION));
BOOST_CHECK(!fipConfig.output(FIPConfig::TEMPERATURE_FIELD));
BOOST_CHECK(!fipConfig.output(FIPConfig::TEMPERATURE_REGION));
BOOST_CHECK( fipConfig.output(FIPConfig::TRACER_FIELD));
BOOST_CHECK( fipConfig.output(FIPConfig::TRACER_REGION));
BOOST_CHECK(!fipConfig.output(FIPConfig::VE));
}