Merge pull request #698 from jokva/equil-keyword-lookup
Equil keyword lookup
This commit is contained in:
@@ -129,6 +129,7 @@ EclipseState/Grid/NNC.cpp
|
||||
EclipseState/Grid/PinchMode.cpp
|
||||
#
|
||||
EclipseState/InitConfig/InitConfig.cpp
|
||||
EclipseState/InitConfig/Equil.cpp
|
||||
EclipseState/SimulationConfig/SimulationConfig.cpp
|
||||
EclipseState/SimulationConfig/ThresholdPressure.cpp
|
||||
EclipseState/Summary/Summary.cpp
|
||||
@@ -229,6 +230,7 @@ EclipseState/Grid/FaultCollection.hpp
|
||||
EclipseState/Grid/NNC.hpp
|
||||
#
|
||||
EclipseState/InitConfig/InitConfig.hpp
|
||||
EclipseState/InitConfig/Equil.hpp
|
||||
EclipseState/SimulationConfig/SimulationConfig.hpp
|
||||
EclipseState/SimulationConfig/ThresholdPressure.hpp
|
||||
EclipseState/Summary/Summary.hpp
|
||||
@@ -284,9 +286,7 @@ EclipseState/Tables/ColumnSchema.hpp
|
||||
EclipseState/Tables/TableEnums.hpp
|
||||
EclipseState/Tables/TableSchema.hpp
|
||||
EclipseState/Tables/TableIndex.hpp
|
||||
#
|
||||
Utility/Functional.hpp
|
||||
Utility/EquilWrapper.hpp)
|
||||
Utility/Functional.hpp)
|
||||
|
||||
add_library(buildParser ${rawdeck_source} ${build_parser_source} ${deck_source} ${unit_source} ${generator_source})
|
||||
target_link_libraries(buildParser opmjson ${Boost_LIBRARIES} ${ERT_LIBRARIES})
|
||||
|
||||
81
opm/parser/eclipse/EclipseState/InitConfig/Equil.cpp
Normal file
81
opm/parser/eclipse/EclipseState/InitConfig/Equil.cpp
Normal file
@@ -0,0 +1,81 @@
|
||||
#include <opm/parser/eclipse/Deck/DeckItem.hpp>
|
||||
#include <opm/parser/eclipse/Deck/DeckKeyword.hpp>
|
||||
#include <opm/parser/eclipse/Deck/DeckRecord.hpp>
|
||||
#include <opm/parser/eclipse/EclipseState/InitConfig/Equil.hpp>
|
||||
|
||||
namespace Opm {
|
||||
|
||||
EquilRecord::EquilRecord( const DeckRecord& record ) :
|
||||
datum_depth( record.getItem( 0 ).getSIDouble( 0 ) ),
|
||||
datum_depth_ps( record.getItem( 1 ).getSIDouble( 0 ) ),
|
||||
water_oil_contact_depth( record.getItem( 2 ).getSIDouble( 0 ) ),
|
||||
water_oil_contact_capillary_pressure( record.getItem( 3 ).getSIDouble( 0 ) ),
|
||||
gas_oil_contact_depth( record.getItem( 4 ).getSIDouble( 0 ) ),
|
||||
gas_oil_contact_capillary_pressure( record.getItem( 5 ).getSIDouble( 0 ) ),
|
||||
live_oil_init_proc( record.getItem( 6 ).get< int >( 0 ) <= 0 ),
|
||||
wet_gas_init_proc( record.getItem( 7 ).get< int >( 0 ) <= 0 ),
|
||||
init_target_accuracy( record.getItem( 8 ).get< int >( 0 ) )
|
||||
{}
|
||||
|
||||
double EquilRecord::datumDepth() const {
|
||||
return this->datum_depth;
|
||||
}
|
||||
|
||||
double EquilRecord::datumDepthPressure() const {
|
||||
return this->datum_depth_ps;
|
||||
}
|
||||
|
||||
double EquilRecord::waterOilContactDepth() const {
|
||||
return this->water_oil_contact_depth;
|
||||
}
|
||||
|
||||
double EquilRecord::waterOilContactCapillaryPressure() const {
|
||||
return this->water_oil_contact_capillary_pressure;
|
||||
}
|
||||
|
||||
double EquilRecord::gasOilContactDepth() const {
|
||||
return this->gas_oil_contact_depth;
|
||||
}
|
||||
|
||||
double EquilRecord::gasOilContactCapillaryPressure() const {
|
||||
return this->gas_oil_contact_capillary_pressure;
|
||||
}
|
||||
|
||||
bool EquilRecord::liveOilInitConstantRs() const {
|
||||
return this->live_oil_init_proc;
|
||||
}
|
||||
|
||||
bool EquilRecord::wetGasInitConstantRv() const {
|
||||
return this->wet_gas_init_proc;
|
||||
}
|
||||
|
||||
int EquilRecord::initializationTargetAccuracy() const {
|
||||
return this->init_target_accuracy;
|
||||
}
|
||||
|
||||
/* */
|
||||
|
||||
Equil::Equil( const DeckKeyword& keyword ) :
|
||||
records( keyword.begin(), keyword.end() )
|
||||
{}
|
||||
|
||||
const EquilRecord& Equil::getRecord( size_t id ) const {
|
||||
return this->records.at( id );
|
||||
}
|
||||
|
||||
size_t Equil::size() const {
|
||||
return this->records.size();
|
||||
}
|
||||
|
||||
bool Equil::empty() const {
|
||||
return this->records.empty();
|
||||
}
|
||||
|
||||
Equil::const_iterator Equil::begin() const {
|
||||
return this->records.begin();
|
||||
}
|
||||
|
||||
Equil::const_iterator Equil::end() const {
|
||||
return this->records.end();
|
||||
}
|
||||
}
|
||||
58
opm/parser/eclipse/EclipseState/InitConfig/Equil.hpp
Normal file
58
opm/parser/eclipse/EclipseState/InitConfig/Equil.hpp
Normal file
@@ -0,0 +1,58 @@
|
||||
#ifndef OPM_EQUIL_HPP
|
||||
#define OPM_EQUIL_HPP
|
||||
|
||||
namespace Opm {
|
||||
|
||||
class DeckKeyword;
|
||||
class DeckRecord;
|
||||
|
||||
class EquilRecord {
|
||||
public:
|
||||
explicit EquilRecord( const DeckRecord& );
|
||||
|
||||
double datumDepth() const;
|
||||
double datumDepthPressure() const;
|
||||
double waterOilContactDepth() const;
|
||||
double waterOilContactCapillaryPressure() const;
|
||||
double gasOilContactDepth() const;
|
||||
double gasOilContactCapillaryPressure() const;
|
||||
|
||||
bool liveOilInitConstantRs() const;
|
||||
bool wetGasInitConstantRv() const;
|
||||
int initializationTargetAccuracy() const;
|
||||
|
||||
private:
|
||||
double datum_depth;
|
||||
double datum_depth_ps;
|
||||
double water_oil_contact_depth;
|
||||
double water_oil_contact_capillary_pressure;
|
||||
double gas_oil_contact_depth;
|
||||
double gas_oil_contact_capillary_pressure;
|
||||
|
||||
bool live_oil_init_proc;
|
||||
bool wet_gas_init_proc;
|
||||
int init_target_accuracy;
|
||||
};
|
||||
|
||||
class Equil {
|
||||
public:
|
||||
using const_iterator = std::vector< EquilRecord >::const_iterator;
|
||||
|
||||
Equil() = default;
|
||||
explicit Equil( const DeckKeyword& );
|
||||
|
||||
const EquilRecord& getRecord( size_t id ) const;
|
||||
|
||||
size_t size() const;
|
||||
bool empty() const;
|
||||
|
||||
const_iterator begin() const;
|
||||
const_iterator end() const;
|
||||
|
||||
private:
|
||||
std::vector< EquilRecord > records;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif //OPM_EQUIL_HPP
|
||||
@@ -22,12 +22,16 @@
|
||||
#include <opm/parser/eclipse/Deck/DeckKeyword.hpp>
|
||||
#include <opm/parser/eclipse/Deck/DeckRecord.hpp>
|
||||
#include <opm/parser/eclipse/EclipseState/InitConfig/InitConfig.hpp>
|
||||
|
||||
#include <iostream>
|
||||
#include <opm/parser/eclipse/EclipseState/InitConfig/Equil.hpp>
|
||||
|
||||
namespace Opm {
|
||||
|
||||
InitConfig::InitConfig(DeckConstPtr deck) {
|
||||
static inline Equil equils( const Deck& deck ) {
|
||||
if( !deck.hasKeyword( "EQUIL" ) ) return {};
|
||||
return Equil( deck.getKeyword( "EQUIL" ) );
|
||||
}
|
||||
|
||||
InitConfig::InitConfig(DeckConstPtr deck) : equil( equils( *deck ) ) {
|
||||
m_restartInitiated = false;
|
||||
m_restartStep = 0;
|
||||
m_restartRootName = "";
|
||||
@@ -69,4 +73,16 @@ namespace Opm {
|
||||
const std::string& InitConfig::getRestartRootName() const {
|
||||
return m_restartRootName;
|
||||
}
|
||||
|
||||
bool InitConfig::hasEquil() const {
|
||||
return !this->equil.empty();
|
||||
}
|
||||
|
||||
const Equil& InitConfig::getEquil() const {
|
||||
if( !this->hasEquil() )
|
||||
throw std::runtime_error( "Error: No 'EQUIL' present" );
|
||||
|
||||
return this->equil;
|
||||
}
|
||||
|
||||
} //namespace Opm
|
||||
|
||||
@@ -20,6 +20,8 @@
|
||||
#ifndef OPM_INIT_CONFIG_HPP
|
||||
#define OPM_INIT_CONFIG_HPP
|
||||
|
||||
#include <opm/parser/eclipse/EclipseState/InitConfig/Equil.hpp>
|
||||
|
||||
namespace Opm {
|
||||
|
||||
class Deck;
|
||||
@@ -33,12 +35,17 @@ namespace Opm {
|
||||
int getRestartStep() const;
|
||||
const std::string& getRestartRootName() const;
|
||||
|
||||
bool hasEquil() const;
|
||||
const Equil& getEquil() const;
|
||||
|
||||
private:
|
||||
void initRestartKW(std::shared_ptr< const Deck > deck);
|
||||
|
||||
bool m_restartInitiated;
|
||||
int m_restartStep;
|
||||
std::string m_restartRootName;
|
||||
|
||||
Equil equil;
|
||||
};
|
||||
|
||||
typedef std::shared_ptr<InitConfig> InitConfigPtr;
|
||||
|
||||
@@ -28,6 +28,7 @@
|
||||
#include <opm/parser/eclipse/Parser/Parser.hpp>
|
||||
#include <opm/parser/eclipse/EclipseState/EclipseState.hpp>
|
||||
#include <opm/parser/eclipse/EclipseState/InitConfig/InitConfig.hpp>
|
||||
#include <opm/parser/eclipse/Units/ConversionFactors.hpp>
|
||||
|
||||
|
||||
using namespace Opm;
|
||||
@@ -83,6 +84,24 @@ const std::string& deckStr4 =
|
||||
"19 JUN 2007 / \n"
|
||||
"SCHEDULE\n";
|
||||
|
||||
const std::string& deckWithEquil =
|
||||
"RUNSPEC\n"
|
||||
"DIMENS\n"
|
||||
" 10 10 10 /\n"
|
||||
"EQLDIMS\n"
|
||||
"1 100 20 1 1 /\n"
|
||||
"SOLUTION\n"
|
||||
"RESTART\n"
|
||||
"BASE 5\n"
|
||||
"/\n"
|
||||
"EQUIL\n"
|
||||
"2469 382.4 1705.0 0.0 500 0.0 1 1 20 /\n"
|
||||
"GRID\n"
|
||||
"START -- 0 \n"
|
||||
"19 JUN 2007 / \n"
|
||||
"SCHEDULE\n"
|
||||
"SKIPREST \n";
|
||||
|
||||
static DeckPtr createDeck(const std::string& input) {
|
||||
Opm::Parser parser;
|
||||
return parser.parseString(input, Opm::ParseMode());
|
||||
@@ -110,3 +129,43 @@ BOOST_AUTO_TEST_CASE(InitConfigTest) {
|
||||
DeckPtr deck4 = createDeck(deckStr4);
|
||||
BOOST_CHECK_THROW(std::make_shared<InitConfig>(deck4), std::runtime_error);
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_CASE( InitConfigWithoutEquil ) {
|
||||
auto deck = createDeck( deckStr );
|
||||
InitConfig config( deck );
|
||||
|
||||
BOOST_CHECK( !config.hasEquil() );
|
||||
BOOST_CHECK_THROW( config.getEquil(), std::runtime_error );
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_CASE( InitConfigWithEquil ) {
|
||||
auto deck = createDeck( deckWithEquil );
|
||||
InitConfig config( deck );
|
||||
|
||||
BOOST_CHECK( config.hasEquil() );
|
||||
BOOST_CHECK_NO_THROW( config.getEquil() );
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_CASE( EquilOperations ) {
|
||||
auto deck = createDeck( deckWithEquil );
|
||||
InitConfig config( deck );
|
||||
|
||||
const auto& equil = config.getEquil();
|
||||
|
||||
BOOST_CHECK( !equil.empty() );
|
||||
BOOST_CHECK_EQUAL( 1U, equil.size() );
|
||||
|
||||
BOOST_CHECK_NO_THROW( equil.getRecord( 0 ) );
|
||||
BOOST_CHECK_THROW( equil.getRecord( 1 ), std::out_of_range );
|
||||
|
||||
const auto& record = equil.getRecord( 0 );
|
||||
BOOST_CHECK_CLOSE( 2469, record.datumDepth(), 1e-12 );
|
||||
BOOST_CHECK_CLOSE( 382.4 * details::unit::barsa, record.datumDepthPressure(), 1e-12 );
|
||||
BOOST_CHECK_CLOSE( 1705.0, record.waterOilContactDepth(), 1e-12 );
|
||||
BOOST_CHECK_CLOSE( 0.0, record.waterOilContactCapillaryPressure(), 1e-12 );
|
||||
BOOST_CHECK_CLOSE( 500, record.gasOilContactDepth(), 1e-12 );
|
||||
BOOST_CHECK_CLOSE( 0.0, record.gasOilContactCapillaryPressure(), 1e-12 );
|
||||
BOOST_CHECK( !record.liveOilInitConstantRs() );
|
||||
BOOST_CHECK( !record.wetGasInitConstantRv() );
|
||||
BOOST_CHECK_EQUAL( 20, record.initializationTargetAccuracy() );
|
||||
}
|
||||
|
||||
@@ -1,125 +0,0 @@
|
||||
/*
|
||||
Copyright (C) 2014 by Andreas Lauser
|
||||
|
||||
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_EQUIL_WRAPPER_HPP
|
||||
#define OPM_PARSER_EQUIL_WRAPPER_HPP
|
||||
|
||||
#include <opm/parser/eclipse/Deck/Deck.hpp>
|
||||
#include <opm/parser/eclipse/Deck/DeckItem.hpp>
|
||||
#include <opm/parser/eclipse/Deck/DeckKeyword.hpp>
|
||||
#include <opm/parser/eclipse/Deck/DeckRecord.hpp>
|
||||
|
||||
namespace Opm {
|
||||
class EquilWrapper {
|
||||
public:
|
||||
/*!
|
||||
* \brief A wrapper class to provide convenient access to the
|
||||
* data of the 'EQUIL' keyword.
|
||||
*/
|
||||
EquilWrapper(const DeckKeyword& keyword)
|
||||
: m_keyword(keyword)
|
||||
{
|
||||
}
|
||||
|
||||
/*!
|
||||
* \brief Return the number of regions used for initialization
|
||||
*/
|
||||
int numRegions() const
|
||||
{ return m_keyword.size(); }
|
||||
|
||||
/*!
|
||||
* \brief The reference depth
|
||||
*/
|
||||
double datumDepth(int regionIdx) const
|
||||
{ return m_keyword.getRecord(regionIdx).getItem(0).getSIDouble(0); }
|
||||
|
||||
/*!
|
||||
* \brief The pressure at reference depth
|
||||
*/
|
||||
double datumDepthPressure(int regionIdx) const
|
||||
{ return m_keyword.getRecord(regionIdx).getItem(1).getSIDouble(0); }
|
||||
|
||||
/*!
|
||||
* \brief The depth of the water-oil contact
|
||||
*/
|
||||
double waterOilContactDepth(int regionIdx) const
|
||||
{ return m_keyword.getRecord(regionIdx).getItem(2).getSIDouble(0); }
|
||||
|
||||
/*!
|
||||
* \brief The capillary pressure at the water-oil contact
|
||||
*/
|
||||
double waterOilContactCapillaryPressure(int regionIdx) const
|
||||
{ return m_keyword.getRecord(regionIdx).getItem(3).getSIDouble(0); }
|
||||
|
||||
/*!
|
||||
* \brief The depth of the gas-oil contact
|
||||
*/
|
||||
double gasOilContactDepth(int regionIdx) const
|
||||
{ return m_keyword.getRecord(regionIdx).getItem(4).getSIDouble(0); }
|
||||
|
||||
/*!
|
||||
* \brief The capillary pressure at the gas-oil contact
|
||||
*/
|
||||
double gasOilContactCapillaryPressure(int regionIdx) const
|
||||
{ return m_keyword.getRecord(regionIdx).getItem(5).getSIDouble(0); }
|
||||
|
||||
/*!
|
||||
* \brief Integer number specifying the initialization proceedure for live oil
|
||||
*
|
||||
* Much fun with eclipse...
|
||||
*/
|
||||
int liveOilInitProceedure(int regionIdx) const
|
||||
{ return m_keyword.getRecord(regionIdx).getItem(6).get< int >(0); }
|
||||
|
||||
/*!
|
||||
* \brief Integer number specifying the initialization proceedure for wet gas
|
||||
*/
|
||||
int wetGasInitProceedure(int regionIdx) const
|
||||
{ return m_keyword.getRecord(regionIdx).getItem(7).get< int >(0); }
|
||||
|
||||
/*!
|
||||
* \brief Integer number specifying the desired accuracy of the initialization
|
||||
*/
|
||||
int initializationTargetAccuracy(int regionIdx) const
|
||||
{ return m_keyword.getRecord(regionIdx).getItem(8).get< int >(0); }
|
||||
|
||||
/*!
|
||||
* \brief Integer number specifying the type of the initialization
|
||||
*
|
||||
* This is only relevant for fully-compositional models
|
||||
*/
|
||||
int compositionalInitializationProceedure(int regionIdx) const
|
||||
{ return m_keyword.getRecord(regionIdx).getItem(9).get< int >(0); }
|
||||
|
||||
/*!
|
||||
* \brief Use the saturation pressure at the of the gas for
|
||||
* the gas-oil contact.
|
||||
*
|
||||
* This is only relevant for fully-compositional models and if
|
||||
* the initialization proceedure is either '2' or '3'.
|
||||
*/
|
||||
bool useSaturationPressure(int regionIdx) const
|
||||
{ return m_keyword.getRecord(regionIdx).getItem(10).get< int >(0) == 0; }
|
||||
|
||||
private:
|
||||
const DeckKeyword& m_keyword;
|
||||
};
|
||||
}
|
||||
|
||||
#endif // OPM_PARSER_EQUIL_WRAPPER_HPP
|
||||
|
||||
Reference in New Issue
Block a user