Substantial edits to Eclipse3DProperties and ptr's

* moved region-property from EclipseState to Eclipse3DProperties
* moved initGridopts from EclipseState to Eclipse3DProperties
* made several Eclipse3DProperties methods private
* removed obsolete tests
* replaced log with throw internally in private method---is domain_error
* removed typedef in SatFuncPropertyInitializers
* postprocessors take raw pointers, not shared_ptr---these will be phased out
* fixed return reference instead of copy several places
** gridProperties<T> in Eclipse3DProperties are now references, not shared_ptr
** Eclipse3DProperties takes const Deck&, not shared_ptr
** EclipseGrid and Section are references
This commit is contained in:
Pål Grønås Drange
2016-03-29 17:19:51 +02:00
parent e48b64c41d
commit 3680dfcb97
23 changed files with 161 additions and 1190 deletions

View File

@@ -1,5 +1,5 @@
/*
Copyright 2016 Statoil ASA.
Copyright 2013 Statoil ASA.
This file is part of the Open Porous Media project (OPM).
@@ -311,20 +311,24 @@ namespace Opm {
Eclipse3DProperties::Eclipse3DProperties( const Deck& deck,
std::shared_ptr<const TableManager> tableManager,
const EclipseGrid& eclipseGrid)
std::shared_ptr<const TableManager> tableManager,
const EclipseGrid& eclipseGrid)
:
m_defaultRegion("FLUXNUM"),
m_deckUnitSystem(deck.getActiveUnitSystem()),
// Note that the variants of grid keywords for radial grids are not
// supported. (and hopefully never will be)
// register the grid properties
m_intGridProperties(eclipseGrid, makeSupportedIntKeywords()),
m_doubleGridProperties(eclipseGrid,
// Note that the variants of grid keywords for radial grids are not
// supported. (and hopefully never will be)
// register the grid properties
m_intGridProperties(eclipseGrid, makeSupportedIntKeywords()),
m_doubleGridProperties(eclipseGrid,
makeSupportedDoubleKeywords(tableManager.get(), &eclipseGrid, &m_intGridProperties))
{
/*
* The EQUALREG, MULTREG, COPYREG, ... keywords are used to manipulate
* vectors based on region values; for instance the statement

View File

@@ -1,894 +0,0 @@
/*
Copyright 2013 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/>.
*/
#include <boost/algorithm/string/join.hpp>
#include <opm/parser/eclipse/Deck/Deck.hpp>
#include <opm/parser/eclipse/Deck/Section.hpp>
#include <opm/parser/eclipse/EclipseState/EclipseState.hpp>
#include <opm/parser/eclipse/EclipseState/EclipseProperties.hpp>
#include <opm/parser/eclipse/EclipseState/Grid/Box.hpp>
#include <opm/parser/eclipse/EclipseState/Grid/BoxManager.hpp>
#include <opm/parser/eclipse/EclipseState/Grid/EclipseGrid.hpp>
#include <opm/parser/eclipse/EclipseState/Grid/GridProperties.hpp>
#include <opm/parser/eclipse/EclipseState/Grid/MULTREGTScanner.hpp>
#include <opm/parser/eclipse/EclipseState/Grid/SatfuncPropertyInitializers.hpp>
#include <opm/parser/eclipse/EclipseState/Grid/TransMult.hpp>
#include <opm/parser/eclipse/EclipseState/Tables/TableManager.hpp>
#include <opm/parser/eclipse/Units/Dimension.hpp>
#include <opm/parser/eclipse/Units/UnitSystem.hpp>
#include <opm/parser/eclipse/OpmLog/OpmLog.hpp>
namespace Opm {
namespace GridPropertyPostProcessor {
void distTopLayer( std::vector<double>& values,
const TableManager* tableManager,
const EclipseGrid* eclipseGrid,
GridProperties<int>* intGridProperties,
GridProperties<double>* doubleGridProperties)
{
size_t layerSize = eclipseGrid->getNX() * eclipseGrid->getNY();
size_t gridSize = eclipseGrid->getCartesianSize();
for( size_t globalIndex = layerSize; globalIndex < gridSize; globalIndex++ ) {
if( std::isnan( values[ globalIndex ] ) )
values[globalIndex] = values[globalIndex - layerSize];
}
}
/// initPORV uses doubleGridProperties: PORV, PORO, NTG, MULTPV
void initPORV( std::vector<double>& values,
const TableManager* tableManager,
const EclipseGrid* eclipseGrid,
GridProperties<int>* intGridProperties,
GridProperties<double>* doubleGridProperties)
{
/*
Observe that this apply method does not alter the values input
vector, instead it fetches the PORV property one more time, and
then manipulates that.
*/
const auto& porv = doubleGridProperties->getOrCreateProperty("PORV");
if (porv.containsNaN()) {
const auto& poro = doubleGridProperties->getOrCreateProperty("PORO");
const auto& ntg = doubleGridProperties->getOrCreateProperty("NTG");
if (poro.containsNaN())
throw std::logic_error("Do not have information for the PORV keyword - some defaulted values in PORO");
else {
const auto& poroData = poro.getData();
for (size_t globalIndex = 0; globalIndex < porv.getCartesianSize(); globalIndex++) {
if (std::isnan(values[globalIndex])) {
double cell_poro = poroData[globalIndex];
double cell_ntg = ntg.iget(globalIndex);
double cell_volume = eclipseGrid->getCellVolume(globalIndex);
values[globalIndex] = cell_poro * cell_volume * cell_ntg;
}
}
}
}
if (doubleGridProperties->hasKeyword("MULTPV")) {
const auto& multpvData = doubleGridProperties->getKeyword("MULTPV").getData();
for (size_t globalIndex = 0; globalIndex < porv.getCartesianSize(); globalIndex++) {
values[globalIndex] *= multpvData[globalIndex];
}
}
}
}
static std::vector< GridProperties< int >::SupportedKeywordInfo >
makeSupportedIntKeywords() {
return {GridProperties< int >::SupportedKeywordInfo( "SATNUM" , 1, "1" ),
GridProperties< int >::SupportedKeywordInfo( "IMBNUM" , 1, "1" ),
GridProperties< int >::SupportedKeywordInfo( "PVTNUM" , 1, "1" ),
GridProperties< int >::SupportedKeywordInfo( "EQLNUM" , 1, "1" ),
GridProperties< int >::SupportedKeywordInfo( "ENDNUM" , 1, "1" ),
GridProperties< int >::SupportedKeywordInfo( "FLUXNUM", 1, "1" ),
GridProperties< int >::SupportedKeywordInfo( "MULTNUM", 1, "1" ),
GridProperties< int >::SupportedKeywordInfo( "FIPNUM" , 1, "1" ),
GridProperties< int >::SupportedKeywordInfo( "MISCNUM", 1, "1" )
};
}
static std::vector< GridProperties< double >::SupportedKeywordInfo >
makeSupportedDoubleKeywords(const TableManager* tableManager,
const EclipseGrid* eclipseGrid,
GridProperties<int>* intGridProperties)
{
GridPropertyInitFunction< double > SGLLookup ( &SGLEndpoint, tableManager, eclipseGrid, intGridProperties, nullptr);
GridPropertyInitFunction< double > ISGLLookup ( &ISGLEndpoint, tableManager, eclipseGrid, intGridProperties, nullptr);
GridPropertyInitFunction< double > SWLLookup ( &SWLEndpoint, tableManager, eclipseGrid, intGridProperties, nullptr);
GridPropertyInitFunction< double > ISWLLookup ( &ISWLEndpoint, tableManager, eclipseGrid, intGridProperties, nullptr);
GridPropertyInitFunction< double > SGULookup ( &SGUEndpoint, tableManager, eclipseGrid, intGridProperties, nullptr);
GridPropertyInitFunction< double > ISGULookup ( &ISGUEndpoint, tableManager, eclipseGrid, intGridProperties, nullptr);
GridPropertyInitFunction< double > SWULookup ( &SWUEndpoint, tableManager, eclipseGrid, intGridProperties, nullptr);
GridPropertyInitFunction< double > ISWULookup ( &ISWUEndpoint, tableManager, eclipseGrid, intGridProperties, nullptr);
GridPropertyInitFunction< double > SGCRLookup ( &SGCREndpoint, tableManager, eclipseGrid, intGridProperties, nullptr);
GridPropertyInitFunction< double > ISGCRLookup ( &ISGCREndpoint, tableManager, eclipseGrid, intGridProperties, nullptr);
GridPropertyInitFunction< double > SOWCRLookup ( &SOWCREndpoint, tableManager, eclipseGrid, intGridProperties, nullptr);
GridPropertyInitFunction< double > ISOWCRLookup ( &ISOWCREndpoint, tableManager, eclipseGrid, intGridProperties, nullptr);
GridPropertyInitFunction< double > SOGCRLookup ( &SOGCREndpoint, tableManager, eclipseGrid, intGridProperties, nullptr);
GridPropertyInitFunction< double > ISOGCRLookup ( &ISOGCREndpoint, tableManager, eclipseGrid, intGridProperties, nullptr);
GridPropertyInitFunction< double > SWCRLookup ( &SWCREndpoint, tableManager, eclipseGrid, intGridProperties, nullptr);
GridPropertyInitFunction< double > ISWCRLookup ( &ISWCREndpoint, tableManager, eclipseGrid, intGridProperties, nullptr);
GridPropertyInitFunction< double > PCWLookup ( &PCWEndpoint, tableManager, eclipseGrid, intGridProperties, nullptr);
GridPropertyInitFunction< double > IPCWLookup ( &IPCWEndpoint, tableManager, eclipseGrid, intGridProperties, nullptr);
GridPropertyInitFunction< double > PCGLookup ( &PCGEndpoint, tableManager, eclipseGrid, intGridProperties, nullptr);
GridPropertyInitFunction< double > IPCGLookup ( &IPCGEndpoint, tableManager, eclipseGrid, intGridProperties, nullptr);
GridPropertyInitFunction< double > KRWLookup ( &KRWEndpoint, tableManager, eclipseGrid, intGridProperties, nullptr);
GridPropertyInitFunction< double > IKRWLookup ( &IKRWEndpoint, tableManager, eclipseGrid, intGridProperties, nullptr);
GridPropertyInitFunction< double > KRWRLookup ( &KRWREndpoint, tableManager, eclipseGrid, intGridProperties, nullptr);
GridPropertyInitFunction< double > IKRWRLookup ( &IKRWREndpoint, tableManager, eclipseGrid, intGridProperties, nullptr);
GridPropertyInitFunction< double > KROLookup ( &KROEndpoint, tableManager, eclipseGrid, intGridProperties, nullptr);
GridPropertyInitFunction< double > IKROLookup ( &IKROEndpoint, tableManager, eclipseGrid, intGridProperties, nullptr);
GridPropertyInitFunction< double > KRORWLookup ( &KRORWEndpoint, tableManager, eclipseGrid, intGridProperties, nullptr);
GridPropertyInitFunction< double > IKRORWLookup ( &IKRORWEndpoint, tableManager, eclipseGrid, intGridProperties, nullptr);
GridPropertyInitFunction< double > KRORGLookup ( &KRORGEndpoint, tableManager, eclipseGrid, intGridProperties, nullptr);
GridPropertyInitFunction< double > IKRORGLookup ( &IKRORGEndpoint, tableManager, eclipseGrid, intGridProperties, nullptr);
GridPropertyInitFunction< double > KRGLookup ( &KRGEndpoint, tableManager, eclipseGrid, intGridProperties, nullptr);
GridPropertyInitFunction< double > IKRGLookup ( &IKRGEndpoint, tableManager, eclipseGrid, intGridProperties, nullptr);
GridPropertyInitFunction< double > KRGRLookup ( &KRGREndpoint, tableManager, eclipseGrid, intGridProperties, nullptr);
GridPropertyInitFunction< double > IKRGRLookup ( &IKRGREndpoint, tableManager, eclipseGrid, intGridProperties, nullptr);
GridPropertyInitFunction< double > tempLookup ( &temperature_lookup,
tableManager, eclipseGrid, intGridProperties, nullptr );
GridPropertyPostFunction< double > distributeTopLayer( &GridPropertyPostProcessor::distTopLayer,
tableManager, eclipseGrid, intGridProperties, nullptr );
std::vector< GridProperties< double >::SupportedKeywordInfo > supportedDoubleKeywords;
// keywords to specify the scaled connate gas saturations.
for( const auto& kw : { "SGL", "SGLX", "SGLX-", "SGLY", "SGLY-", "SGLZ", "SGLZ-" } )
supportedDoubleKeywords.emplace_back( kw, SGLLookup, "1" );
for( const auto& kw : { "ISGL", "ISGLX", "ISGLX-", "ISGLY", "ISGLY-", "ISGLZ", "ISGLZ-" } )
supportedDoubleKeywords.emplace_back( kw, ISGLLookup, "1" );
// keywords to specify the connate water saturation.
for( const auto& kw : { "SWL", "SWLX", "SWLX-", "SWLY", "SWLY-", "SWLZ", "SWLZ-" } )
supportedDoubleKeywords.emplace_back( kw, SWLLookup, "1" );
for( const auto& kw : { "ISWL", "ISWLX", "ISWLX-", "ISWLY", "ISWLY-", "ISWLZ", "ISWLZ-" } )
supportedDoubleKeywords.emplace_back( kw, ISWLLookup, "1" );
// keywords to specify the maximum gas saturation.
for( const auto& kw : { "SGU", "SGUX", "SGUX-", "SGUY", "SGUY-", "SGUZ", "SGUZ-" } )
supportedDoubleKeywords.emplace_back( kw, SGULookup, "1" );
for( const auto& kw : { "ISGU", "ISGUX", "ISGUX-", "ISGUY", "ISGUY-", "ISGUZ", "ISGUZ-" } )
supportedDoubleKeywords.emplace_back( kw, ISGULookup, "1" );
// keywords to specify the maximum water saturation.
for( const auto& kw : { "SWU", "SWUX", "SWUX-", "SWUY", "SWUY-", "SWUZ", "SWUZ-" } )
supportedDoubleKeywords.emplace_back( kw, SWULookup, "1" );
for( const auto& kw : { "ISWU", "ISWUX", "ISWUX-", "ISWUY", "ISWUY-", "ISWUZ", "ISWUZ-" } )
supportedDoubleKeywords.emplace_back( kw, ISWULookup, "1" );
// keywords to specify the scaled critical gas saturation.
for( const auto& kw : { "SGCR", "SGCRX", "SGCRX-", "SGCRY", "SGCRY-", "SGCRZ", "SGCRZ-" } )
supportedDoubleKeywords.emplace_back( kw, SGCRLookup, "1" );
for( const auto& kw : { "ISGCR", "ISGCRX", "ISGCRX-", "ISGCRY", "ISGCRY-", "ISGCRZ", "ISGCRZ-" } )
supportedDoubleKeywords.emplace_back( kw, ISGCRLookup, "1" );
// keywords to specify the scaled critical oil-in-water saturation.
for( const auto& kw : { "SOWCR", "SOWCRX", "SOWCRX-", "SOWCRY", "SOWCRY-", "SOWCRZ", "SOWCRZ-" } )
supportedDoubleKeywords.emplace_back( kw, SOWCRLookup, "1" );
for( const auto& kw : { "ISOWCR", "ISOWCRX", "ISOWCRX-", "ISOWCRY", "ISOWCRY-", "ISOWCRZ", "ISOWCRZ-" } )
supportedDoubleKeywords.emplace_back( kw, ISOWCRLookup, "1" );
// keywords to specify the scaled critical oil-in-gas saturation.
for( const auto& kw : { "SOGCR", "SOGCRX", "SOGCRX-", "SOGCRY", "SOGCRY-", "SOGCRZ", "SOGCRZ-" } )
supportedDoubleKeywords.emplace_back( kw, SOGCRLookup, "1" );
for( const auto& kw : { "ISOGCR", "ISOGCRX", "ISOGCRX-", "ISOGCRY", "ISOGCRY-", "ISOGCRZ", "ISOGCRZ-" } )
supportedDoubleKeywords.emplace_back( kw, ISOGCRLookup, "1" );
// keywords to specify the scaled critical water saturation.
for( const auto& kw : { "SWCR", "SWCRX", "SWCRX-", "SWCRY", "SWCRY-", "SWCRZ", "SWCRZ-" } )
supportedDoubleKeywords.emplace_back( kw, SWCRLookup, "1" );
for( const auto& kw : { "ISWCR", "ISWCRX", "ISWCRX-", "ISWCRY", "ISWCRY-", "ISWCRZ", "ISWCRZ-" } )
supportedDoubleKeywords.emplace_back( kw, ISWCRLookup, "1" );
// keywords to specify the scaled oil-water capillary pressure
for( const auto& kw : { "PCW", "PCWX", "PCWX-", "PCWY", "PCWY-", "PCWZ", "PCWZ-" } )
supportedDoubleKeywords.emplace_back( kw, PCWLookup, "1" );
for( const auto& kw : { "IPCW", "IPCWX", "IPCWX-", "IPCWY", "IPCWY-", "IPCWZ", "IPCWZ-" } )
supportedDoubleKeywords.emplace_back( kw, IPCWLookup, "1" );
// keywords to specify the scaled gas-oil capillary pressure
for( const auto& kw : { "PCG", "PCGX", "PCGX-", "PCGY", "PCGY-", "PCGZ", "PCGZ-" } )
supportedDoubleKeywords.emplace_back( kw, PCGLookup, "1" );
for( const auto& kw : { "IPCG", "IPCGX", "IPCGX-", "IPCGY", "IPCGY-", "IPCGZ", "IPCGZ-" } )
supportedDoubleKeywords.emplace_back( kw, IPCGLookup, "1" );
// keywords to specify the scaled water relative permeability
for( const auto& kw : { "KRW", "KRWX", "KRWX-", "KRWY", "KRWY-", "KRWZ", "KRWZ-" } )
supportedDoubleKeywords.emplace_back( kw, KRWLookup, "1" );
for( const auto& kw : { "IKRW", "IKRWX", "IKRWX-", "IKRWY", "IKRWY-", "IKRWZ", "IKRWZ-" } )
supportedDoubleKeywords.emplace_back( kw, IKRWLookup, "1" );
// keywords to specify the scaled water relative permeability at the critical
// saturation
for( const auto& kw : { "KRWR" , "KRWRX" , "KRWRX-" , "KRWRY" , "KRWRY-" , "KRWRZ" , "KRWRZ-" } )
supportedDoubleKeywords.emplace_back( kw, KRWRLookup, "1" );
for( const auto& kw : { "IKRWR" , "IKRWRX" , "IKRWRX-" , "IKRWRY" , "IKRWRY-" , "IKRWRZ" , "IKRWRZ-" } )
supportedDoubleKeywords.emplace_back( kw, IKRWRLookup, "1" );
// keywords to specify the scaled oil relative permeability
for( const auto& kw : { "KRO", "KROX", "KROX-", "KROY", "KROY-", "KROZ", "KROZ-" } )
supportedDoubleKeywords.emplace_back( kw, KROLookup, "1" );
for( const auto& kw : { "IKRO", "IKROX", "IKROX-", "IKROY", "IKROY-", "IKROZ", "IKROZ-" } )
supportedDoubleKeywords.emplace_back( kw, IKROLookup, "1" );
// keywords to specify the scaled water relative permeability at the critical
// water saturation
for( const auto& kw : { "KRORW", "KRORWX", "KRORWX-", "KRORWY", "KRORWY-", "KRORWZ", "KRORWZ-" } )
supportedDoubleKeywords.emplace_back( kw, KRORWLookup, "1" );
for( const auto& kw : { "IKRORW", "IKRORWX", "IKRORWX-", "IKRORWY", "IKRORWY-", "IKRORWZ", "IKRORWZ-" } )
supportedDoubleKeywords.emplace_back( kw, IKRORWLookup, "1" );
// keywords to specify the scaled water relative permeability at the critical
// water saturation
for( const auto& kw : { "KRORG", "KRORGX", "KRORGX-", "KRORGY", "KRORGY-", "KRORGZ", "KRORGZ-" } )
supportedDoubleKeywords.emplace_back( kw, KRORGLookup, "1" );
for( const auto& kw : { "IKRORG", "IKRORGX", "IKRORGX-", "IKRORGY", "IKRORGY-", "IKRORGZ", "IKRORGZ-" } )
supportedDoubleKeywords.emplace_back( kw, IKRORGLookup, "1" );
// keywords to specify the scaled gas relative permeability
for( const auto& kw : { "KRG", "KRGX", "KRGX-", "KRGY", "KRGY-", "KRGZ", "KRGZ-" } )
supportedDoubleKeywords.emplace_back( kw, KRGLookup, "1" );
for( const auto& kw : { "IKRG", "IKRGX", "IKRGX-", "IKRGY", "IKRGY-", "IKRGZ", "IKRGZ-" } )
supportedDoubleKeywords.emplace_back( kw, IKRGLookup, "1" );
// keywords to specify the scaled gas relative permeability
for( const auto& kw : { "KRGR", "KRGRX", "KRGRX-", "KRGRY", "KRGRY-", "KRGRZ", "KRGRZ-" } )
supportedDoubleKeywords.emplace_back( kw, KRGRLookup, "1" );
for( const auto& kw : { "IKRGR", "IKRGRX", "IKRGRX-", "IKRGRY", "IKRGRY-", "IKRGRZ", "IKRGRZ-" } )
supportedDoubleKeywords.emplace_back( kw, IKRGRLookup, "1" );
// cell temperature (E300 only, but makes a lot of sense for E100, too)
supportedDoubleKeywords.emplace_back( "TEMPI", tempLookup, "Temperature" );
const double nan = std::numeric_limits<double>::quiet_NaN();
// porosity
supportedDoubleKeywords.emplace_back( "PORO", nan, distributeTopLayer, "1" );
// pore volume multipliers
supportedDoubleKeywords.emplace_back( "MULTPV", 1.0, "1" );
// the permeability keywords
for( const auto& kw : { "PERMX", "PERMY", "PERMZ" } )
supportedDoubleKeywords.emplace_back( kw, nan, distributeTopLayer, "Permeability" );
/* E300 only */
for( const auto& kw : { "PERMXY", "PERMYZ", "PERMZX" } )
supportedDoubleKeywords.emplace_back( kw, nan, distributeTopLayer, "Permeability" );
/* the transmissibility keywords for neighboring connections. note that
* these keywords don't seem to require a post-processor
*/
for( const auto& kw : { "TRANX", "TRANY", "TRANZ" } )
supportedDoubleKeywords.emplace_back( kw, nan, "Transmissibility" );
/* gross-to-net thickness (acts as a multiplier for PORO and the
* permeabilities in the X-Y plane as well as for the well rates.)
*/
supportedDoubleKeywords.emplace_back( "NTG", 1.0, "1" );
// transmissibility multipliers
for( const auto& kw : { "MULTX", "MULTY", "MULTZ", "MULTX-", "MULTY-", "MULTZ-" } )
supportedDoubleKeywords.emplace_back( kw, 1.0, "1" );
// initialisation
supportedDoubleKeywords.emplace_back( "SWATINIT", 0.0, "1");
supportedDoubleKeywords.emplace_back( "THCONR", 0.0, "1");
return supportedDoubleKeywords;
}
EclipseProperties::EclipseProperties( const Deck& deck,
std::shared_ptr<const TableManager> tableManager,
const EclipseGrid& eclipseGrid)
:
m_defaultRegion("FLUXNUM"),
m_deckUnitSystem(deck.getActiveUnitSystem()),
// Note that the variants of grid keywords for radial grids are not
// supported. (and hopefully never will be)
// register the grid properties
m_intGridProperties(eclipseGrid, makeSupportedIntKeywords()),
m_doubleGridProperties(eclipseGrid,
makeSupportedDoubleKeywords(tableManager.get(), &eclipseGrid, &m_intGridProperties))
{
GridPropertyPostFunction< double > initPORV(&GridPropertyPostProcessor::initPORV,
tableManager.get(),
&eclipseGrid,
&m_intGridProperties,
&m_doubleGridProperties);
// pore volume
m_doubleGridProperties.postAddKeyword( "PORV",
std::numeric_limits<double>::quiet_NaN(),
initPORV,
"Volume" );
// actually create the grid property objects. we need to first process
// all integer grid properties before the double ones as these may be
// needed in order to initialize the double properties
processGridProperties(deck, eclipseGrid, /*enabledTypes=*/IntProperties);
processGridProperties(deck, eclipseGrid, /*enabledTypes=*/DoubleProperties);
}
bool EclipseProperties::supportsGridProperty(const std::string& keyword,
int enabledTypes) const
{
bool result = false;
if (enabledTypes & IntProperties)
result = result ||
m_intGridProperties.supportsKeyword( keyword );
if (enabledTypes & DoubleProperties)
result = result ||
m_doubleGridProperties.supportsKeyword( keyword );
return result;
}
bool EclipseProperties::hasDeckIntGridProperty(const std::string& keyword) const {
if (!m_intGridProperties.supportsKeyword( keyword ))
throw std::logic_error("Integer grid property " + keyword + " is unsupported!");
return m_intGridProperties.hasKeyword( keyword );
}
bool EclipseProperties::hasDeckDoubleGridProperty(const std::string& keyword) const {
if (!m_doubleGridProperties.supportsKeyword( keyword ))
throw std::logic_error("Double grid property " + keyword + " is unsupported!");
return m_doubleGridProperties.hasKeyword( keyword );
}
GridProperties<int>& EclipseProperties::getIntGridProperties() {
return m_intGridProperties;
}
/// gets properties doubleGridProperties. This does not run any post processors
GridProperties<double>& EclipseProperties::getDoubleGridProperties() {
return m_doubleGridProperties;
}
/*
1. The public methods getIntGridProperty & getDoubleGridProperty will
invoke and run the property post processor (if any is registered); the
post processor will only run one time.
It is important that post processor is not run prematurely, internal
functions in EclipseState should therefore ask for properties by
invoking the getKeyword() method of the m_intGridProperties /
m_doubleGridProperties() directly and not through these methods.
2. Observe that this will autocreate a property if it has not been
explicitly added.
*/
const GridProperty<int>& EclipseProperties::getIntGridProperty( const std::string& keyword ) const {
return m_intGridProperties.getKeyword( keyword );
}
/// gets property from doubleGridProperty --- and calls the runPostProcessor
const GridProperty<double>& EclipseProperties::getDoubleGridProperty( const std::string& keyword ) const {
auto& gridProperty = const_cast< EclipseProperties* >( this )->m_doubleGridProperties.getKeyword( keyword );
gridProperty.runPostProcessor();
return gridProperty;
}
const GridProperty<int>& EclipseProperties::getDefaultRegion() const {
return m_intGridProperties.getKeyword( m_defaultRegion );
}
void EclipseProperties::setDefaultRegionKeyword(std::string defaultRegion) {
m_defaultRegion = defaultRegion;
}
std::string EclipseProperties::getDefaultRegionKeyword() const {
return m_defaultRegion;
}
const GridProperty<int>& EclipseProperties::getRegion( const DeckItem& regionItem ) const {
if (regionItem.defaultApplied(0))
return getDefaultRegion();
else {
const std::string regionArray = MULTREGT::RegionNameFromDeckValue( regionItem.get< std::string >(0) );
return m_intGridProperties.getInitializedKeyword( regionArray );
}
}
// this method is only used from EclipseStateTests, could make private?
/// Due to the post processor which might be applied to the GridProperty
/// objects it is essential that this method use the m_intGridProperties /
/// m_doubleGridProperties fields directly and *NOT* use the public methods
/// getIntGridProperty / getDoubleGridProperty.
void EclipseProperties::loadGridPropertyFromDeckKeyword(const Box& inputBox,
const DeckKeyword& deckKeyword,
int enabledTypes)
{
// FIXME PGDR TODO move logic to GridProperties?
const std::string& keyword = deckKeyword.name();
if (m_intGridProperties.supportsKeyword( keyword )) {
if (enabledTypes & IntProperties) {
GridProperty<int>& gridProperty = m_intGridProperties.getOrCreateProperty( keyword );
gridProperty.loadFromDeckKeyword( inputBox , deckKeyword );
}
} else if (m_doubleGridProperties.supportsKeyword( keyword )) {
if (enabledTypes & DoubleProperties) {
GridProperty<double>& gridProperty = m_doubleGridProperties.getOrCreateProperty( keyword );
gridProperty.loadFromDeckKeyword( inputBox , deckKeyword );
}
} else {
std::string msg = Log::fileMessage(deckKeyword.getFileName(),
deckKeyword.getLineNumber(),
"Tried to load unsupported grid property from keyword: "
+ deckKeyword.name());
OpmLog::addMessage(Log::MessageType::Error , msg);
}
}
static bool isInt(double value) {
return fabs(nearbyint(value) - value) < 1e-6;
}
void EclipseProperties::processGridProperties( const Deck& deck,
const EclipseGrid& eclipseGrid,
int enabledTypes) {
if (Section::hasGRID(deck)) {
scanSection(GRIDSection(deck), eclipseGrid, enabledTypes);
}
if (Section::hasEDIT(deck)) {
scanSection(EDITSection(deck), eclipseGrid, enabledTypes);
}
if (Section::hasPROPS(deck)) {
scanSection(PROPSSection(deck), eclipseGrid, enabledTypes);
}
if (Section::hasREGIONS(deck)) {
scanSection(REGIONSSection(deck), eclipseGrid, enabledTypes);
}
if (Section::hasSOLUTION(deck)) {
scanSection(SOLUTIONSection(deck), eclipseGrid, enabledTypes);
}
}
// private method
double EclipseProperties::getSIScaling(const std::string &dimensionString) const
{
return m_deckUnitSystem.getDimension(dimensionString)->getSIScaling();
}
void EclipseProperties::scanSection(const Section& section,
const EclipseGrid& eclipseGrid,
int enabledTypes) {
BoxManager boxManager(eclipseGrid.getNX(),
eclipseGrid.getNY(),
eclipseGrid.getNZ());
for( const auto& deckKeyword : section ) {
if (supportsGridProperty(deckKeyword.name(), enabledTypes) )
loadGridPropertyFromDeckKeyword( *boxManager.getActiveBox(),
deckKeyword,
enabledTypes);
else {
if (deckKeyword.name() == "ADD")
handleADDKeyword(deckKeyword, boxManager, enabledTypes);
if (deckKeyword.name() == "BOX")
handleBOXKeyword(deckKeyword, boxManager);
if (deckKeyword.name() == "COPY")
handleCOPYKeyword(deckKeyword, boxManager, enabledTypes);
if (deckKeyword.name() == "EQUALS")
handleEQUALSKeyword(deckKeyword, boxManager, enabledTypes);
if (deckKeyword.name() == "MULTIPLY")
handleMULTIPLYKeyword(deckKeyword, boxManager, enabledTypes);
if (deckKeyword.name() == "ENDBOX")
handleENDBOXKeyword(boxManager);
if (deckKeyword.name() == "EQUALREG")
handleEQUALREGKeyword(deckKeyword, enabledTypes);
if (deckKeyword.name() == "ADDREG")
handleADDREGKeyword(deckKeyword, enabledTypes);
if (deckKeyword.name() == "MULTIREG")
handleMULTIREGKeyword(deckKeyword, enabledTypes);
if (deckKeyword.name() == "COPYREG")
handleCOPYREGKeyword(deckKeyword, enabledTypes);
boxManager.endKeyword();
}
}
boxManager.endSection();
}
void EclipseProperties::handleBOXKeyword( const DeckKeyword& deckKeyword, BoxManager& boxManager) {
const auto& record = deckKeyword.getRecord(0);
int I1 = record.getItem("I1").get< int >(0) - 1;
int I2 = record.getItem("I2").get< int >(0) - 1;
int J1 = record.getItem("J1").get< int >(0) - 1;
int J2 = record.getItem("J2").get< int >(0) - 1;
int K1 = record.getItem("K1").get< int >(0) - 1;
int K2 = record.getItem("K2").get< int >(0) - 1;
boxManager.setInputBox( I1 , I2 , J1 , J2 , K1 , K2 );
}
void EclipseProperties::handleENDBOXKeyword(BoxManager& boxManager) {
boxManager.endInputBox();
}
void EclipseProperties::handleEQUALREGKeyword( const DeckKeyword& deckKeyword,
int enabledTypes)
{
for( const auto& record : deckKeyword ) {
const std::string& targetArray = record.getItem("ARRAY").get< std::string >(0);
if (!supportsGridProperty( targetArray , IntProperties + DoubleProperties))
throw std::invalid_argument("Fatal error processing EQUALREG keyword - invalid/undefined keyword: " + targetArray);
double doubleValue = record.getItem("VALUE").template get<double>(0);
int regionValue = record.getItem("REGION_NUMBER").template get<int>(0);
auto& regionProperty = getRegion( record.getItem("REGION_NAME") );
std::vector<bool> mask;
regionProperty.initMask( regionValue , mask);
if (m_intGridProperties.supportsKeyword( targetArray )) {
if (enabledTypes & IntProperties) {
if (isInt( doubleValue )) {
auto& targetProperty = m_intGridProperties.getOrCreateProperty( targetArray );
int intValue = static_cast<int>( doubleValue + 0.5 );
targetProperty.maskedSet( intValue , mask);
} else
throw std::invalid_argument("Fatal error processing EQUALREG keyword - expected integer value for: " + targetArray);
}
}
else if (m_doubleGridProperties.supportsKeyword( targetArray )) {
if (enabledTypes & DoubleProperties) {
auto& targetProperty = m_doubleGridProperties.getOrCreateProperty( targetArray );
const std::string& dimensionString = targetProperty.getDimensionString();
double SIValue = doubleValue * getSIScaling( dimensionString );
targetProperty.maskedSet( SIValue , mask);
}
}
else {
throw std::invalid_argument("Fatal error processing EQUALREG keyword - invalid/undefined keyword: " + targetArray);
}
}
}
void EclipseProperties::handleADDREGKeyword( const DeckKeyword& deckKeyword, int enabledTypes) {
for( const auto& record : deckKeyword ) {
const std::string& targetArray = record.getItem("ARRAY").get< std::string >(0);
if (!supportsGridProperty( targetArray , IntProperties + DoubleProperties))
throw std::invalid_argument("Fatal error processing ADDREG keyword - invalid/undefined keyword: " + targetArray);
if (supportsGridProperty( targetArray , enabledTypes)) {
double doubleValue = record.getItem("SHIFT").get< double >(0);
int regionValue = record.getItem("REGION_NUMBER").get< int >(0);
auto& regionProperty = getRegion( record.getItem("REGION_NAME") );
std::vector<bool> mask;
regionProperty.initMask( regionValue , mask);
if (m_intGridProperties.hasKeyword( targetArray )) {
if (enabledTypes & IntProperties) {
if (isInt( doubleValue )) {
GridProperty<int>& targetProperty = m_intGridProperties.getKeyword(targetArray);
int intValue = static_cast<int>( doubleValue + 0.5 );
targetProperty.maskedAdd( intValue , mask);
} else
throw std::invalid_argument("Fatal error processing ADDREG keyword - expected integer value for: " + targetArray);
}
}
else if (m_doubleGridProperties.hasKeyword( targetArray )) {
if (enabledTypes & DoubleProperties) {
GridProperty<double>& targetProperty = m_doubleGridProperties.getKeyword(targetArray);
const std::string& dimensionString = targetProperty.getDimensionString();
double SIValue = doubleValue * getSIScaling( dimensionString );
targetProperty.maskedAdd( SIValue , mask);
}
}
else {
throw std::invalid_argument("Fatal error processing ADDREG keyword - invalid/undefined keyword: " + targetArray);
}
}
}
}
void EclipseProperties::handleMULTIREGKeyword( const DeckKeyword& deckKeyword, int enabledTypes) {
for( const auto& record : deckKeyword ) {
const std::string& targetArray = record.getItem("ARRAY").get< std::string >(0);
if (!supportsGridProperty( targetArray , IntProperties + DoubleProperties))
throw std::invalid_argument("Fatal error processing MULTIREG keyword - invalid/undefined keyword: " + targetArray);
if (supportsGridProperty( targetArray , enabledTypes)) {
double doubleValue = record.getItem("FACTOR").get< double >(0);
int regionValue = record.getItem("REGION_NUMBER").get< int >(0);
auto& regionProperty = getRegion( record.getItem("REGION_NAME") );
std::vector<bool> mask;
regionProperty.initMask( regionValue , mask);
if (enabledTypes & IntProperties) {
if (isInt( doubleValue )) {
auto& targetProperty = m_intGridProperties.getOrCreateProperty( targetArray );
int intValue = static_cast<int>( doubleValue + 0.5 );
targetProperty.maskedMultiply( intValue , mask);
} else
throw std::invalid_argument(
"Fatal error processing MULTIREG keyword - expected"
" integer value for: " + targetArray);
}
if (enabledTypes & DoubleProperties) {
auto& targetProperty = m_doubleGridProperties.getOrCreateProperty(targetArray);
targetProperty.maskedMultiply( doubleValue , mask);
}
}
}
}
void EclipseProperties::handleCOPYREGKeyword( const DeckKeyword& deckKeyword, int enabledTypes) {
for( const auto& record : deckKeyword ) {
const std::string& srcArray = record.getItem("ARRAY").get< std::string >(0);
const std::string& targetArray = record.getItem("TARGET_ARRAY").get< std::string >(0);
if (!supportsGridProperty( targetArray , IntProperties + DoubleProperties))
throw std::invalid_argument("Fatal error processing MULTIREG keyword - invalid/undefined keyword: " + targetArray);
if (!supportsGridProperty( srcArray , IntProperties + DoubleProperties))
throw std::invalid_argument("Fatal error processing MULTIREG keyword - invalid/undefined keyword: " + srcArray);
if (supportsGridProperty( srcArray , enabledTypes))
{
int regionValue = record.getItem("REGION_NUMBER").get< int >(0);
auto& regionProperty = getRegion( record.getItem("REGION_NAME") );
std::vector<bool> mask;
regionProperty.initMask( regionValue , mask );
if (m_intGridProperties.hasKeyword( srcArray )) {
auto& srcProperty = m_intGridProperties.getInitializedKeyword( srcArray );
if (supportsGridProperty( targetArray , IntProperties)) {
GridProperty<int>& targetProperty = m_intGridProperties.getOrCreateProperty( targetArray );
targetProperty.maskedCopy( srcProperty , mask );
} else
throw std::invalid_argument("Fatal error processing COPYREG keyword.");
} else if (m_doubleGridProperties.hasKeyword( srcArray )) {
const GridProperty<double>& srcProperty = m_doubleGridProperties.getInitializedKeyword( srcArray );
if (supportsGridProperty( targetArray , DoubleProperties)) {
auto& targetProperty = m_doubleGridProperties.getOrCreateProperty( targetArray );
targetProperty.maskedCopy( srcProperty , mask );
}
}
else {
throw std::invalid_argument("Fatal error processing COPYREG keyword - invalid/undefined keyword: " + targetArray);
}
}
}
}
void EclipseProperties::handleMULTIPLYKeyword( const DeckKeyword& deckKeyword, BoxManager& boxManager, int enabledTypes) {
for( const auto& record : deckKeyword ) {
const std::string& field = record.getItem("field").get< std::string >(0);
double scaleFactor = record.getItem("factor").get< double >(0);
setKeywordBox(deckKeyword, record, boxManager);
if (m_intGridProperties.hasKeyword( field )) {
if (enabledTypes & IntProperties) {
int intFactor = static_cast<int>(scaleFactor);
GridProperty<int>& property = m_intGridProperties.getKeyword( field );
property.scale( intFactor , *boxManager.getActiveBox() );
}
} else if (m_doubleGridProperties.hasKeyword( field )) {
if (enabledTypes & DoubleProperties) {
GridProperty<double>& property = m_doubleGridProperties.getKeyword( field );
property.scale( scaleFactor , *boxManager.getActiveBox() );
}
} else if (!m_intGridProperties.supportsKeyword(field) &&
!m_doubleGridProperties.supportsKeyword(field))
throw std::invalid_argument("Fatal error processing MULTIPLY keyword. Tried to multiply not defined keyword " + field);
}
}
/**
The fine print of the manual says the ADD keyword should support
some state dependent semantics regarding endpoint scaling arrays
in the PROPS section. That is not supported.
*/
void EclipseProperties::handleADDKeyword( const DeckKeyword& deckKeyword, BoxManager& boxManager, int enabledTypes) {
for( const auto& record : deckKeyword ) {
const std::string& field = record.getItem("field").get< std::string >(0);
double shiftValue = record.getItem("shift").get< double >(0);
setKeywordBox(deckKeyword, record, boxManager);
if (m_intGridProperties.hasKeyword( field )) {
if (enabledTypes & IntProperties) {
int intShift = static_cast<int>(shiftValue);
GridProperty<int>& property = m_intGridProperties.getKeyword( field );
property.add( intShift , *boxManager.getActiveBox() );
}
} else if (m_doubleGridProperties.hasKeyword( field )) {
if (enabledTypes & DoubleProperties) {
GridProperty<double>& property = m_doubleGridProperties.getKeyword( field );
double siShiftValue = shiftValue * getSIScaling(property.getDimensionString());
property.add(siShiftValue , *boxManager.getActiveBox() );
}
} else if (!m_intGridProperties.supportsKeyword(field) &&
!m_doubleGridProperties.supportsKeyword(field))
throw std::invalid_argument("Fatal error processing ADD keyword. Tried to shift not defined keyword " + field);
}
}
void EclipseProperties::handleEQUALSKeyword( const DeckKeyword& deckKeyword, BoxManager& boxManager, int enabledTypes) {
for( const auto& record : deckKeyword ) {
const std::string& field = record.getItem("field").get< std::string >(0);
double value = record.getItem("value").get< double >(0);
setKeywordBox(deckKeyword, record, boxManager);
if (m_intGridProperties.supportsKeyword( field )) {
if (enabledTypes & IntProperties) {
int intValue = static_cast<int>(value);
GridProperty<int>& property = m_intGridProperties.getOrCreateProperty( field );
property.setScalar( intValue , *boxManager.getActiveBox() );
}
} else if (m_doubleGridProperties.supportsKeyword( field )) {
if (enabledTypes & DoubleProperties) {
GridProperty<double>& property = m_doubleGridProperties.getOrCreateProperty( field );
double siValue = value * getSIScaling(property.getKeywordInfo().getDimensionString());
property.setScalar( siValue , *boxManager.getActiveBox() );
}
} else
throw std::invalid_argument("Fatal error processing EQUALS keyword. Tried to set not defined keyword " + field);
}
}
void EclipseProperties::handleCOPYKeyword( const DeckKeyword& deckKeyword, BoxManager& boxManager, int enabledTypes) {
for( const auto& record : deckKeyword ) {
const std::string& srcField = record.getItem("src").get< std::string >(0);
const std::string& targetField = record.getItem("target").get< std::string >(0);
setKeywordBox(deckKeyword, record, boxManager);
if (m_intGridProperties.hasKeyword( srcField )) {
if (enabledTypes & IntProperties)
m_intGridProperties.copyKeyword( srcField , targetField , *boxManager.getActiveBox() );
}
else if (m_doubleGridProperties.hasKeyword( srcField )) {
if (enabledTypes & DoubleProperties)
m_doubleGridProperties.copyKeyword( srcField , targetField , *boxManager.getActiveBox() );
}
else
if (!m_intGridProperties.supportsKeyword(srcField) &&
!m_doubleGridProperties.supportsKeyword(srcField))
throw std::invalid_argument("Fatal error processing COPY keyword."
" Tried to copy from not defined keyword " + srcField);
}
}
// static member function
void EclipseProperties::setKeywordBox( const DeckKeyword& deckKeyword,
const DeckRecord& deckRecord,
BoxManager& boxManager) {
const auto& I1Item = deckRecord.getItem("I1");
const auto& I2Item = deckRecord.getItem("I2");
const auto& J1Item = deckRecord.getItem("J1");
const auto& J2Item = deckRecord.getItem("J2");
const auto& K1Item = deckRecord.getItem("K1");
const auto& K2Item = deckRecord.getItem("K2");
size_t setCount = 0;
if (!I1Item.defaultApplied(0))
setCount++;
if (!I2Item.defaultApplied(0))
setCount++;
if (!J1Item.defaultApplied(0))
setCount++;
if (!J2Item.defaultApplied(0))
setCount++;
if (!K1Item.defaultApplied(0))
setCount++;
if (!K2Item.defaultApplied(0))
setCount++;
if (setCount == 6) {
boxManager.setKeywordBox( I1Item.get< int >(0) - 1,
I2Item.get< int >(0) - 1,
J1Item.get< int >(0) - 1,
J2Item.get< int >(0) - 1,
K1Item.get< int >(0) - 1,
K2Item.get< int >(0) - 1);
} else if (setCount != 0) {
std::string msg = "BOX modifiers on keywords must be either "
"specified completely or not at all. Ignoring.";
OpmLog::addMessage(Log::MessageType::Error,
Log::fileMessage(deckKeyword.getFileName(),
deckKeyword.getLineNumber(),
msg));
}
}
}

View File

@@ -1,118 +0,0 @@
/*
Copyright 2013 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/>.
*/
#ifndef OPM_ECLIPSE_PROPERTIES_HPP
#define OPM_ECLIPSE_PROPERTIES_HPP
#include <utility>
#include <memory>
#include <set>
#include <opm/parser/eclipse/EclipseState/Grid/GridProperty.hpp>
#include <opm/parser/eclipse/EclipseState/Grid/GridProperties.hpp>
namespace Opm {
// template< typename > class GridProperty;
// template< typename > class GridProperties;
class Box;
class BoxManager;
class Deck;
class DeckItem;
class DeckKeyword;
class DeckRecord;
class EclipseGrid;
class EclipseState;
class InitConfig;
class IOConfig;
class ParseMode;
class Schedule;
class Section;
class TableManager;
class TransMult;
class UnitSystem;
class EclipseProperties
{
public:
enum EnabledTypes {
IntProperties = 0x01,
DoubleProperties = 0x02,
AllProperties = IntProperties | DoubleProperties
};
EclipseProperties( const Deck& deck,
std::shared_ptr<const TableManager> tableManager,
const EclipseGrid& eclipseGrid);
static void setKeywordBox( const DeckKeyword& deckKeyword, const DeckRecord&, BoxManager& boxManager);
const GridProperty<int>& getRegion( const DeckItem& regionItem ) const;
const GridProperty<int>& getDefaultRegion() const;
std::string getDefaultRegionKeyword() const;
void setDefaultRegionKeyword(std::string defaultRegionKeyword);
const GridProperty<int>& getIntGridProperty( const std::string& keyword ) const;
const GridProperty<double> & getDoubleGridProperty( const std::string& keyword ) const;
GridProperties<int>& getIntGridProperties();
GridProperties<double>& getDoubleGridProperties();
bool hasDeckIntGridProperty(const std::string& keyword) const;
bool hasDeckDoubleGridProperty(const std::string& keyword) const;
bool supportsGridProperty(const std::string& keyword, int enabledTypes=AllProperties) const;
private:
void processGridProperties( const Deck& deck,
const EclipseGrid& eclipseGrid,
int enabledTypes);
double getSIScaling(const std::string &dimensionString) const;
void scanSection(const Section& section,
const EclipseGrid& eclipseGrid,
int enabledTypes);
void handleADDKeyword( const DeckKeyword& deckKeyword, BoxManager& boxManager, int enabledTypes);
void handleBOXKeyword( const DeckKeyword& deckKeyword, BoxManager& boxManager);
void handleCOPYKeyword( const DeckKeyword& deckKeyword, BoxManager& boxManager, int enabledTypes);
void handleENDBOXKeyword( BoxManager& boxManager);
void handleEQUALSKeyword( const DeckKeyword& deckKeyword, BoxManager& boxManager, int enabledTypes);
void handleMULTIPLYKeyword(const DeckKeyword& deckKeyword, BoxManager& boxManager, int enabledTypes);
void handleADDREGKeyword( const DeckKeyword& deckKeyword, int enabledTypes);
void handleCOPYREGKeyword( const DeckKeyword& deckKeyword, int enabledTypes);
void handleEQUALREGKeyword(const DeckKeyword& deckKeyword, int enabledTypes);
void handleMULTIREGKeyword(const DeckKeyword& deckKeyword, int enabledTypes);
void loadGridPropertyFromDeckKeyword(const Box& inputBox,
const DeckKeyword& deckKeyword,
int enabledTypes = AllProperties);
void initProperties( const Deck& deck,
std::shared_ptr<const TableManager> tableManager,
const EclipseGrid& eclipseGrid );
std::string m_defaultRegion;
const UnitSystem& m_deckUnitSystem;
GridProperties<int> m_intGridProperties;
GridProperties<double> m_doubleGridProperties;
};
}
#endif // OPM_ECLIPSE_PROPERTIES_HPP

View File

@@ -76,14 +76,12 @@ namespace Opm {
return m_deckUnitSystem;
}
EclipseGridConstPtr EclipseState::getEclipseGrid() const {
return m_eclipseProperties->getEclipseGrid();
return m_eclipseGrid;
}
// is only used in EclipseWriter
EclipseGridPtr EclipseState::getEclipseGridCopy() const {
return m_eclipseProperties->getEclipseGridCopy();
return std::make_shared<EclipseGrid>( m_eclipseGrid->c_ptr() );
}
const Eclipse3DProperties& EclipseState::getEclipseProperties() const {
@@ -171,7 +169,7 @@ namespace Opm {
void EclipseState::initTransMult() {
EclipseGridConstPtr grid = m_eclipseProperties->getEclipseGrid();
EclipseGridConstPtr grid = getEclipseGrid();
m_transMult = std::make_shared<TransMult>( grid->getNX() , grid->getNY() , grid->getNZ());
// by obtaining doubleGridProperties we're circumventing the runpostprocessor which is called on state.getkeyword
auto& doubleGp = m_eclipseProperties.getDoubleGridProperties();
@@ -192,7 +190,7 @@ namespace Opm {
}
void EclipseState::initFaults(DeckConstPtr deck) {
EclipseGridConstPtr grid = m_eclipseProperties->getEclipseGrid();
EclipseGridConstPtr grid = getEclipseGrid();
std::shared_ptr<GRIDSection> gridSection = std::make_shared<GRIDSection>( *deck );
m_faults = std::make_shared<FaultCollection>(gridSection , grid);
@@ -225,7 +223,7 @@ namespace Opm {
void EclipseState::initMULTREGT(DeckConstPtr deck) {
EclipseGridConstPtr grid = m_eclipseProperties->getEclipseGrid();
EclipseGridConstPtr grid = getEclipseGrid();
std::vector< const DeckKeyword* > multregtKeywords;
if (deck->hasKeyword("MULTREGT"))

View File

@@ -82,25 +82,19 @@ namespace Opm {
bool hasNNC() const;
const Eclipse3DProperties& getEclipseProperties() const;
std::shared_ptr<const TableManager> getTableManager() 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...
// 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...
const UnitSystem& getDeckUnitSystem() const;
void applyModifierDeck( std::shared_ptr<const Deck> deck);
// TODO this used to be private but since eclipseProperties needs to
// know SIScaling, we need access to either this or to the UnitSystem.
double getSIScaling(const std::string &dimensionString) const;
private:
void initTabdims(std::shared_ptr< const Deck > deck);
void initIOConfig(std::shared_ptr< const Deck > deck);
void initIOConfigPostSchedule(std::shared_ptr< const Deck > deck);
void initTitle(std::shared_ptr< const Deck > deck);
void initTransMult();
void initFaults(std::shared_ptr< const Deck > deck);
@@ -116,11 +110,10 @@ namespace Opm {
std::set<enum Phase::PhaseEnum> phases;
std::string m_title;
const UnitSystem& m_deckUnitSystem;
std::shared_ptr<TransMult> m_transMult;
std::shared_ptr<FaultCollection> m_faults;
std::shared_ptr<NNC> m_nnc;
const UnitSystem& m_deckUnitSystem;
const ParseContext& m_parseContext;
std::shared_ptr<const TableManager> m_tables;
std::shared_ptr<const EclipseGrid> m_eclipseGrid;

View File

@@ -31,17 +31,19 @@
#include <opm/parser/eclipse/EclipseState/Grid/GridProperties.hpp>
/**
This class implements a container (std::unordered_map<std::string ,
Gridproperty<T>>) of Gridproperties. Usage is as follows:
This class implements a container (std::unordered_map<std::string ,
Gridproperty<T>>) of Gridproperties. Usage is as follows:
1. Instantiate the class; passing the number of grid cells and the supported
keywords as a list of strings to the constructor.
1. Instantiate the class; passing the number of grid cells and the
supported keywords as a list of strings to the constructor.
2. Query the container with the supportsKeyword() and hasKeyword() methods.
2. Query the container with the supportsKeyword() and hasKeyword()
methods.
3. When you ask the container to get a keyword with the getKeyword() method
it will automatically create a new GridProperty object if the container
does not have this property.
3. When you ask the container to get a keyword with the
getKeyword() method it will automatically create a new
GridProperty object if the container does not have this
property.
*/
@@ -152,10 +154,10 @@ namespace Opm {
void copyKeyword(const std::string& srcField ,
const std::string& targetField ,
const Box& inputBox) {
const auto& src = this->getKeyword( srcField );
auto& target = this->getOrCreateProperty( targetField );
auto& src = getKeyword( srcField );
auto& target = getOrCreateProperty( targetField );
target.copyFrom( *src , inputBox );
target.copyFrom( src , inputBox );
}

View File

@@ -219,7 +219,7 @@ namespace Opm {
template< typename T >
void GridProperty< T >::loadFromDeckKeyword( const DeckKeyword& deckKeyword ) {
const DeckItem& deckItem = getDeckItem(deckKeyword);
const auto& deckItem = getDeckItem(deckKeyword);
for (size_t dataPointIdx = 0; dataPointIdx < deckItem.size(); ++dataPointIdx) {
if (!deckItem.defaultApplied(dataPointIdx))
setDataPoint(dataPointIdx, dataPointIdx, deckItem);

View File

@@ -27,6 +27,7 @@
#include <opm/parser/eclipse/EclipseState/Tables/RtempvdTable.hpp>
#include <opm/parser/eclipse/EclipseState/Tables/TableManager.hpp>
namespace Opm {
template< typename T >
@@ -52,6 +53,7 @@ namespace Opm {
template< typename T >
std::vector< T > GridPropertyInitFunction< T >::operator()( size_t size ) const {
if( !this->f ) return std::vector< T >( size, this->constant );
return (*this->f)( size, this->tm, this->eg, this->igp, this->dgp );
}
@@ -72,8 +74,8 @@ namespace Opm {
template< typename T >
void GridPropertyPostFunction< T >::operator()( std::vector< T >& values ) const {
if (!this->f)
return;
if (!this->f) return;
return (*this->f)( values, this->tm, this->eg, this->igp, this->dgp );
}

View File

@@ -198,11 +198,14 @@ BOOST_AUTO_TEST_CASE(UnInitializedVectorThrows) {
BOOST_CHECK_THROW( new Opm::EclipseState( deck, Opm::ParseContext()) , std::invalid_argument );
}
BOOST_AUTO_TEST_CASE(TypeMismatchThrows) {
Opm::DeckPtr deck = createDeckInvalidTypeMismatch();
BOOST_CHECK_THROW( new Opm::EclipseState( deck, Opm::ParseContext()) , std::invalid_argument );
}
BOOST_AUTO_TEST_CASE(IntSetCorrectly) {
Opm::DeckPtr deck = createValidIntDeck();
Opm::EclipseState state(deck , Opm::ParseContext() );
@@ -210,8 +213,8 @@ BOOST_AUTO_TEST_CASE(IntSetCorrectly) {
for (size_t j = 0; j < 5; j++)
for (size_t i = 0; i < 5; i++) {
if (i < 2)
BOOST_CHECK_EQUAL(10, property.iget(i, j, 0));
BOOST_CHECK_EQUAL( 10 , property.iget(i,j,0));
else
BOOST_CHECK_EQUAL(3 , property.iget(i, j, 0));
BOOST_CHECK_EQUAL( 3 , property.iget(i,j,0));
}
}

View File

@@ -203,16 +203,19 @@ BOOST_AUTO_TEST_CASE(InvalidRegionThrows) {
BOOST_CHECK_THROW( new Opm::EclipseState( deck, Opm::ParseContext()) , std::invalid_argument );
}
BOOST_AUTO_TEST_CASE(ExpectedIntThrows) {
Opm::DeckPtr deck = createDeckInvalidValue();
BOOST_CHECK_THROW( new Opm::EclipseState( deck, Opm::ParseContext()) , std::invalid_argument );
}
BOOST_AUTO_TEST_CASE(UnInitializedVectorThrows) {
Opm::DeckPtr deck = createDeckUnInitialized();
BOOST_CHECK_THROW( new Opm::EclipseState( deck, Opm::ParseContext()) , std::invalid_argument );
}
BOOST_AUTO_TEST_CASE(IntSetCorrectly) {
Opm::DeckPtr deck = createValidIntDeck();
Opm::EclipseState state(deck , Opm::ParseContext());
@@ -220,9 +223,9 @@ BOOST_AUTO_TEST_CASE(IntSetCorrectly) {
for (size_t j = 0; j < 5; j++)
for (size_t i = 0; i < 5; i++) {
if (i < 2)
BOOST_CHECK_EQUAL(11, property.iget(i, j, 0));
BOOST_CHECK_EQUAL( 11, property.iget(i,j,0));
else
BOOST_CHECK_EQUAL(20, property.iget(i, j, 0));
BOOST_CHECK_EQUAL( 20, property.iget(i,j,0));
}
}
@@ -231,7 +234,6 @@ BOOST_AUTO_TEST_CASE(UnitAppliedCorrectly) {
Opm::DeckPtr deck = createValidPERMXDeck();
Opm::EclipseState state(deck, Opm::ParseContext());
const auto& props = state.getEclipseProperties();
const auto& permx = props.getDoubleGridProperty("PERMX");
const auto& permy = props.getDoubleGridProperty("PERMY");
const auto& permz = props.getDoubleGridProperty("PERMZ");

View File

@@ -66,10 +66,10 @@ BOOST_AUTO_TEST_CASE(addKeyword) {
std::vector<SupportedKeywordInfo> supportedKeywords = {
SupportedKeywordInfo("SATNUM" , 0, "1")
};
Opm::EclipseGrid grid(10, 7, 9);
Opm::GridProperties<int> gridProperties(grid, std::move(supportedKeywords));
Opm::EclipseGrid grid(10,7,9);
Opm::GridProperties<int> gridProperties(grid, std::move( supportedKeywords ));
BOOST_CHECK_THROW(gridProperties.addKeyword("NOT-SUPPORTED"), std::invalid_argument);
BOOST_CHECK_THROW( gridProperties.addKeyword("NOT-SUPPORTED"), std::invalid_argument);
BOOST_CHECK( gridProperties.addKeyword("SATNUM"));
BOOST_CHECK( !gridProperties.addKeyword("SATNUM"));
@@ -83,7 +83,7 @@ BOOST_AUTO_TEST_CASE(hasKeyword) {
SupportedKeywordInfo("SATNUM" , 0, "1")
};
const Opm::EclipseGrid grid(10, 7, 9);
Opm::GridProperties<int> gridProperties(grid, std::move(supportedKeywords));
Opm::GridProperties<int> gridProperties( grid, std::move( supportedKeywords ) );
// calling getKeyword() should not change the semantics of hasKeyword()!
BOOST_CHECK(!gridProperties.hasKeyword("SATNUM"));
@@ -97,7 +97,7 @@ BOOST_AUTO_TEST_CASE(getKeyword) {
std::vector<SupportedKeywordInfo> supportedKeywords = {
SupportedKeywordInfo("SATNUM" , 0, "1")
};
const Opm::EclipseGrid grid(10, 7, 9);
const Opm::EclipseGrid grid(10,7,9);
Opm::GridProperties<int> gridProperties( grid, std::move( supportedKeywords ) );
const Opm::GridProperty<int>& satnum1 = gridProperties.getKeyword( "SATNUM" );
const Opm::GridProperty<int>& satnum2 = gridProperties.getKeyword( "SATNUM" );

View File

@@ -157,23 +157,24 @@ BOOST_AUTO_TEST_CASE(SetFromDeckKeyword) {
}
}
BOOST_AUTO_TEST_CASE(copy) {
typedef Opm::GridProperty<int>::SupportedKeywordInfo SupportedKeywordInfo;
SupportedKeywordInfo keywordInfo1("P1", 0, "1");
SupportedKeywordInfo keywordInfo2("P2", 9, "1");
Opm::GridProperty<int> prop1(4, 4, 2, keywordInfo1);
Opm::GridProperty<int> prop2(4, 4, 2, keywordInfo2);
SupportedKeywordInfo keywordInfo1("P1" , 0, "1");
SupportedKeywordInfo keywordInfo2("P2" , 9, "1");
Opm::GridProperty<int> prop1( 4 , 4 , 2 , keywordInfo1);
Opm::GridProperty<int> prop2( 4 , 4 , 2 , keywordInfo2);
Opm::Box global(4, 4, 2);
Opm::Box layer0(global, 0, 3, 0, 3, 0, 0);
Opm::Box global(4,4,2);
Opm::Box layer0(global , 0,3,0,3,0,0);
prop2.copyFrom(prop1, layer0);
prop2.copyFrom(prop1 , layer0);
for (size_t j = 0; j < 4; j++) {
for (size_t i = 0; i < 4; i++) {
for (size_t j=0; j < 4; j++) {
for (size_t i=0; i < 4; i++) {
BOOST_CHECK_EQUAL(prop2.iget(i, j, 0), 0);
BOOST_CHECK_EQUAL(prop2.iget(i, j, 1), 9);
BOOST_CHECK_EQUAL( prop2.iget(i,j,0), 0 );
BOOST_CHECK_EQUAL( prop2.iget(i,j,1), 9 );
}
}
}

View File

@@ -34,7 +34,6 @@
#include <opm/parser/eclipse/EclipseState/Eclipse3DProperties.hpp>
#include <opm/parser/eclipse/EclipseState/EclipseState.hpp>
#include <opm/parser/eclipse/EclipseState/EclipseProperties.hpp>
#include <opm/parser/eclipse/EclipseState/Grid/MULTREGTScanner.hpp>
#include <opm/parser/eclipse/EclipseState/Grid/EclipseGrid.hpp>
#include <opm/parser/eclipse/EclipseState/Grid/GridProperties.hpp>
@@ -115,10 +114,10 @@ BOOST_AUTO_TEST_CASE(InvalidInput) {
Opm::GridProperties<int> gridProperties( grid, std::move( supportedKeywords ) );
// Invalid direction
std::vector<const Opm::DeckKeyword*> keywords0;
const auto& multregtKeyword0 = deck->getKeyword( "MULTREGT", 0 );
std::vector< const Opm::DeckKeyword* > keywords0;
const auto& multregtKeyword0 = deck->getKeyword("MULTREGT",0);
keywords0.push_back( &multregtKeyword0 );
BOOST_CHECK_THROW( Opm::MULTREGTScanner scanner( gridProperties, keywords0, "MULTNUM" ); , std::invalid_argument );
BOOST_CHECK_THROW( Opm::MULTREGTScanner scanner(gridProperties, keywords0, "MULTNUM"); , std::invalid_argument);
// Not supported region
std::vector<const Opm::DeckKeyword*> keywords1;
@@ -127,10 +126,10 @@ BOOST_AUTO_TEST_CASE(InvalidInput) {
BOOST_CHECK_THROW( Opm::MULTREGTScanner scanner( gridProperties, keywords1, "MULTNUM" ); , std::invalid_argument );
// The keyword is ok; but it refers to a region which is not in the deck.
std::vector<const Opm::DeckKeyword*> keywords2;
const auto& multregtKeyword2 = deck->getKeyword( "MULTREGT", 2 );
std::vector< const Opm::DeckKeyword* > keywords2;
const auto& multregtKeyword2 = deck->getKeyword( "MULTREGT",2);
keywords2.push_back( &multregtKeyword2 );
BOOST_CHECK_THROW( Opm::MULTREGTScanner scanner( gridProperties, keywords2, "MULTNUM" ); , std::logic_error );
BOOST_CHECK_THROW( Opm::MULTREGTScanner scanner(gridProperties,keywords2,"MULTNUM"); , std::logic_error);
}
@@ -182,28 +181,28 @@ BOOST_AUTO_TEST_CASE(NotSupported) {
Opm::GridProperties<int> gridProperties( grid, std::move( supportedKeywords ) );
// Not support NOAQUNNC behaviour
std::vector<const Opm::DeckKeyword*> keywords0;
const auto& multregtKeyword0 = deck->getKeyword( "MULTREGT", 0 );
std::vector< const Opm::DeckKeyword* > keywords0;
const auto& multregtKeyword0 = deck->getKeyword("MULTREGT",0);
keywords0.push_back( &multregtKeyword0 );
BOOST_CHECK_THROW( Opm::MULTREGTScanner scanner( gridProperties, keywords0, "MULTNUM" ); , std::invalid_argument );
BOOST_CHECK_THROW( Opm::MULTREGTScanner scanner(gridProperties,keywords0,"MULTNUM"); , std::invalid_argument);
// Defaulted from value - not supported
std::vector<const Opm::DeckKeyword*> keywords1;
const auto& multregtKeyword1 = deck->getKeyword( "MULTREGT", 1 );
std::vector< const Opm::DeckKeyword* > keywords1;
const auto& multregtKeyword1 = deck->getKeyword("MULTREGT",1);
keywords1.push_back( &multregtKeyword1 );
BOOST_CHECK_THROW( Opm::MULTREGTScanner scanner( gridProperties, keywords1, "MULTNUM" ); , std::invalid_argument );
BOOST_CHECK_THROW( Opm::MULTREGTScanner scanner(gridProperties,keywords1,"MULTNUM"); , std::invalid_argument);
// Defaulted to value - not supported
std::vector<const Opm::DeckKeyword*> keywords2;
const auto& multregtKeyword2 = deck->getKeyword( "MULTREGT", 2 );
std::vector< const Opm::DeckKeyword* > keywords2;
const auto& multregtKeyword2 = deck->getKeyword("MULTREGT",2);
keywords2.push_back( &multregtKeyword2 );
BOOST_CHECK_THROW( Opm::MULTREGTScanner scanner( gridProperties, keywords2, "MULTNUM" ); , std::invalid_argument );
BOOST_CHECK_THROW( Opm::MULTREGTScanner scanner(gridProperties,keywords2,"MULTNUM"); , std::invalid_argument);
// srcValue == targetValue - not supported
std::vector<const Opm::DeckKeyword*> keywords3;
const Opm::DeckKeyword& multregtKeyword3 = deck->getKeyword( "MULTREGT", 3 );
std::vector< const Opm::DeckKeyword* > keywords3;
const Opm::DeckKeyword& multregtKeyword3 = deck->getKeyword("MULTREGT",3);
keywords3.push_back( &multregtKeyword3 );
BOOST_CHECK_THROW( Opm::MULTREGTScanner scanner( gridProperties, keywords3, "MULTNUM" ); , std::invalid_argument );
BOOST_CHECK_THROW( Opm::MULTREGTScanner scanner(gridProperties,keywords3 , "MULTNUM"); , std::invalid_argument);
}
static Opm::DeckPtr createCopyMULTNUMDeck() {
@@ -232,6 +231,8 @@ static Opm::DeckPtr createCopyMULTNUMDeck() {
return parser->parseString(deckData, Opm::ParseContext()) ;
}
BOOST_AUTO_TEST_CASE(MULTREGT_COPY_MULTNUM) {
Opm::DeckPtr deck = createCopyMULTNUMDeck();
Opm::EclipseState state(deck , Opm::ParseContext());

View File

@@ -25,7 +25,6 @@
#include <boost/test/unit_test.hpp>
#include <boost/date_time/posix_time/posix_time.hpp>
#include <opm/parser/eclipse/EclipseState/EclipseProperties.hpp>
#include <opm/parser/eclipse/EclipseState/Grid/TransMult.hpp>
#include <opm/parser/eclipse/EclipseState/Grid/GridProperty.hpp>

View File

@@ -180,8 +180,8 @@ namespace Opm {
bool m_FMTOUT;
std::string m_eclipse_input_path;
bool m_ignore_RPTSCHED_RESTART;
int m_first_restart_step = 0;
int m_first_rft_step = 0;
int m_first_restart_step;
int m_first_rft_step;
struct restartConfig {

View File

@@ -30,14 +30,14 @@
namespace Opm {
ThresholdPressure::ThresholdPressure(const ParseContext& parseContext, DeckConstPtr deck,
GridProperties<int>& gridProperties) :
m_parseContext( parseContext )
GridProperties<int>& gridProperties)
: m_parseContext( parseContext )
{
if (Section::hasRUNSPEC( *deck ) && Section::hasSOLUTION( *deck )) {
std::shared_ptr<const RUNSPECSection> runspecSection = std::make_shared<const RUNSPECSection>( *deck );
std::shared_ptr<const SOLUTIONSection> solutionSection = std::make_shared<const SOLUTIONSection>( *deck );
initThresholdPressure( parseContext, runspecSection, solutionSection, gridProperties );
if (Section::hasRUNSPEC(*deck) && Section::hasSOLUTION(*deck)) {
std::shared_ptr<const RUNSPECSection> runspecSection = std::make_shared<const RUNSPECSection>(*deck);
std::shared_ptr<const SOLUTIONSection> solutionSection = std::make_shared<const SOLUTIONSection>(*deck);
initThresholdPressure(parseContext, runspecSection, solutionSection, gridProperties);
}
}

View File

@@ -105,7 +105,7 @@ const std::string& inputStr_vap_dis = "RUNSPEC\n"
"REGIONS\n"
"\n";
static DeckPtr createDeck(const ParseContext& parseContext, const std::string& input) {
static DeckPtr createDeck(const ParseContext& parseContext , const std::string& input) {
Opm::Parser parser;
return parser.parseString(input, parseContext);
}

View File

@@ -146,7 +146,7 @@ static GridProperties<int> getGridProperties(int defaultEqlnum = 3, bool addKeyw
const EclipseGrid eclipseGrid( 3, 3, 3 );
GridProperties<int> gridProperties( eclipseGrid, std::move( supportedKeywordsVec ) );
if (addKeyword) {
gridProperties.addKeyword( "EQLNUM" );
gridProperties.addKeyword("EQLNUM");
}
return gridProperties;
}

View File

@@ -716,3 +716,5 @@ namespace Opm {
}
}
}

View File

@@ -27,7 +27,6 @@
#include <opm/parser/eclipse/Deck/DeckRecord.hpp>
#include <opm/parser/eclipse/EclipseState/Schedule/ScheduleEnums.hpp> // Phase::PhaseEnum
#include <opm/parser/eclipse/EclipseState/Tables/PvtgTable.hpp>
#include <opm/parser/eclipse/EclipseState/Tables/PvtoTable.hpp>
@@ -139,6 +138,7 @@ namespace Opm {
void initVFPInjTables(const Deck& deck,
std::map<int, VFPInjTable>& tableMap);
void initPlymaxTables(const Deck& deck);
void initPlyrockTables(const Deck& deck);
void initPlyshlogTables(const Deck& deck);

View File

@@ -94,37 +94,6 @@ std::shared_ptr<const Opm::Deck> createSingleRecordDeckWithVd() {
}
std::shared_ptr<const Opm::Deck> createSingleRecordDeckWithVd() {
const char *deckData =
"RUNSPEC\n"
"ENDSCALE\n"
"2* 1 2 /\n"
"PROPS\n"
"TABDIMS\n"
" 2 /\n"
"\n"
"SWFN\n"
"0.22 .0 7.0 \n"
"0.3 .0 4.0 \n"
"0.5 .24 2.5 \n"
"0.8 .65 1.0 \n"
"0.9 .83 .5 \n"
"1.0 1.00 .0 /\n"
"/\n"
"IMPTVD\n"
"3000.0 6*0.1 0.31 1*0.1\n"
"9000.0 6*0.1 0.32 1*0.1/\n"
"ENPTVD\n"
"3000.0 0.20 0.20 1.0 0.0 0.04 1.0 0.18 0.22\n"
"9000.0 0.22 0.22 1.0 0.0 0.04 1.0 0.18 0.22 /";
Opm::ParserPtr parser(new Opm::Parser);
Opm::DeckConstPtr deck(parser->parseString(deckData, Opm::ParseMode()));
return deck;
}
BOOST_AUTO_TEST_CASE( CreateTables ) {
std::shared_ptr<const Opm::Deck> deck = createSingleRecordDeck();
Opm::TableManager tables(*deck);

View File

@@ -97,6 +97,8 @@ static DeckPtr createDeckTOP() {
return parser->parseString(deckData, ParseContext()) ;
}
BOOST_AUTO_TEST_CASE(GetPOROTOPBased) {
DeckPtr deck = createDeckTOP();
EclipseState state(deck , ParseContext());
@@ -111,8 +113,10 @@ BOOST_AUTO_TEST_CASE(GetPOROTOPBased) {
BOOST_CHECK_EQUAL( 0.10 , poro.iget(i) );
BOOST_CHECK_EQUAL( 0.25 * Metric::Permeability , permx.iget(i) );
}
}
static DeckPtr createDeck() {
const char *deckData =
"RUNSPEC\n"
@@ -182,11 +186,6 @@ static DeckPtr createDeckNoFaults() {
return parser->parseString(deckData, ParseContext()) ;
}
BOOST_AUTO_TEST_CASE(GetProperties) {
DeckPtr deck = createDeck();
EclipseState state(deck , ParseContext());
BOOST_CHECK(state.getEclipseProperties());
}
BOOST_AUTO_TEST_CASE(CreateSchedule) {
DeckPtr deck = createDeck();
@@ -230,11 +229,9 @@ BOOST_AUTO_TEST_CASE(CreateSimulationConfig) {
DeckPtr deck = createDeckSimConfig();
EclipseState state(deck, ParseContext());
SimulationConfigConstPtr simConf = state.getSimulationConfig();
BOOST_CHECK( simConf->hasThresholdPressure() );
std::shared_ptr<const ThresholdPressure> thresholdPressure = simConf->getThresholdPressure();
SimulationConfigConstPtr simulationConfig = state.getSimulationConfig();
BOOST_CHECK(simulationConfig->hasThresholdPressure());
std::shared_ptr<const ThresholdPressure> thresholdPressure = simulationConfig->getThresholdPressure();
BOOST_CHECK_EQUAL(thresholdPressure->size(), 3);
}
@@ -242,26 +239,29 @@ BOOST_AUTO_TEST_CASE(CreateSimulationConfig) {
BOOST_AUTO_TEST_CASE(PhasesCorrect) {
DeckPtr deck = createDeck();
EclipseState state( deck, ParseContext() );
const TableManager& tm = *state.getTableManager();
BOOST_CHECK( tm.hasPhase( Phase::PhaseEnum::OIL ));
BOOST_CHECK( tm.hasPhase( Phase::PhaseEnum::GAS ));
BOOST_CHECK( !(tm.hasPhase( Phase::PhaseEnum::WATER )));
EclipseState state(deck, ParseContext());
const auto& tm = *state.getTableManager();
BOOST_CHECK( tm.hasPhase( Phase::PhaseEnum::OIL ));
BOOST_CHECK( tm.hasPhase( Phase::PhaseEnum::GAS ));
BOOST_CHECK( !tm.hasPhase( Phase::PhaseEnum::WATER ));
}
BOOST_AUTO_TEST_CASE(TitleCorrect) {
DeckPtr deck = createDeck();
EclipseState state(deck, ParseContext());
BOOST_CHECK_EQUAL( state.getTitle(), "The title" );
BOOST_CHECK_EQUAL( state.getTitle(), "The title");
}
BOOST_AUTO_TEST_CASE(IntProperties) {
DeckPtr deck = createDeck();
EclipseState state(deck, ParseContext());
BOOST_CHECK( ! state.getEclipseProperties().supportsGridProperty( "NONO" ) );
BOOST_CHECK( state.getEclipseProperties().supportsGridProperty( "SATNUM" ) );
BOOST_CHECK( state.getEclipseProperties().hasDeckIntGridProperty( "SATNUM" ) );
BOOST_CHECK( ! state.getEclipseProperties().supportsGridProperty("NONO"));
BOOST_CHECK( state.getEclipseProperties().supportsGridProperty("SATNUM"));
BOOST_CHECK( state.getEclipseProperties().hasDeckIntGridProperty("SATNUM"));
}
BOOST_AUTO_TEST_CASE(PropertiesNotSupportsFalse) {
@@ -284,33 +284,37 @@ BOOST_AUTO_TEST_CASE(GetProperty) {
BOOST_CHECK_THROW( satNUM.iget(100000) , std::invalid_argument);
}
BOOST_AUTO_TEST_CASE(GetTransMult) {
DeckPtr deck = createDeck();
EclipseState state(deck, ParseContext());
std::shared_ptr<const TransMult> transMult = state.getTransMult();
BOOST_CHECK_EQUAL( 1.0, transMult->getMultiplier( 1, 0, 0, FaceDir::XPlus ) );
BOOST_CHECK_THROW( transMult->getMultiplier( 1000, FaceDir::XPlus ), std::invalid_argument );
BOOST_CHECK_EQUAL( 1.0 , transMult->getMultiplier(1,0,0,FaceDir::XPlus));
BOOST_CHECK_THROW(transMult->getMultiplier(1000 , FaceDir::XPlus) , std::invalid_argument);
}
BOOST_AUTO_TEST_CASE(GetFaults) {
DeckPtr deck = createDeck();
EclipseState state(deck , ParseContext());
std::shared_ptr<const FaultCollection> faults = state.getFaults();
BOOST_CHECK( faults->hasFault( "F1" ) );
BOOST_CHECK( faults->hasFault( "F2" ) );
BOOST_CHECK( faults->hasFault("F1") );
BOOST_CHECK( faults->hasFault("F2") );
std::shared_ptr<const Fault> F1 = faults->getFault( "F1" );
std::shared_ptr<const Fault> F2 = faults->getFault( "F2" );
std::shared_ptr<const Fault> F1 = faults->getFault("F1");
std::shared_ptr<const Fault> F2 = faults->getFault("F2");
BOOST_CHECK_EQUAL( 0.50, F1->getTransMult() );
BOOST_CHECK_EQUAL( 0.25, F2->getTransMult() );
BOOST_CHECK_EQUAL( 0.50 , F1->getTransMult());
BOOST_CHECK_EQUAL( 0.25 , F2->getTransMult());
std::shared_ptr<const TransMult> transMult = state.getTransMult();
BOOST_CHECK_EQUAL( transMult->getMultiplier( 0, 0, 0, FaceDir::XPlus ), 0.50 );
BOOST_CHECK_EQUAL( transMult->getMultiplier( 4, 3, 0, FaceDir::XMinus ), 0.25 );
BOOST_CHECK_EQUAL( transMult->getMultiplier( 4, 3, 0, FaceDir::ZPlus ), 1.00 );
BOOST_CHECK_EQUAL( transMult->getMultiplier(0 , 0 , 0 , FaceDir::XPlus) , 0.50 );
BOOST_CHECK_EQUAL( transMult->getMultiplier(4 , 3 , 0 , FaceDir::XMinus) , 0.25 );
BOOST_CHECK_EQUAL( transMult->getMultiplier(4 , 3 , 0 , FaceDir::ZPlus) , 1.00 );
}

View File

@@ -52,18 +52,19 @@ EclipseState makeState(const std::string& fileName) {
BOOST_AUTO_TEST_CASE( PERMX ) {
EclipseState state = makeState( "testdata/integration_tests/BOX/BOXTEST1" );
const auto& permx = state.getEclipseProperties().getDoubleGridProperty( "PERMX" );
const auto& permy = state.getEclipseProperties().getDoubleGridProperty( "PERMY" );
const auto& permz = state.getEclipseProperties().getDoubleGridProperty( "PERMZ" );
size_t i, j, k;
const auto& props = state.getEclipseProperties();
const auto& permx = props.getDoubleGridProperty("PERMX");
const auto& permy = props.getDoubleGridProperty("PERMY");
const auto& permz = props.getDoubleGridProperty("PERMZ");
size_t i,j,k;
std::shared_ptr<const EclipseGrid> grid = state.getEclipseGrid();
for (k = 0; k < grid->getNZ(); k++) {
for (j = 0; j < grid->getNY(); j++) {
for (i = 0; i < grid->getNX(); i++) {
BOOST_CHECK_CLOSE( permx.iget( i, j, k ) * 0.25, permz.iget( i, j, k ), 0.001 );
BOOST_CHECK_EQUAL( permx.iget( i, j, k ) * 2, permy.iget( i, j, k ) );
BOOST_CHECK_CLOSE( permx.iget(i,j,k) * 0.25 , permz.iget(i,j,k) , 0.001);
BOOST_CHECK_EQUAL( permx.iget(i,j,k) * 2 , permy.iget(i,j,k));
}
}
@@ -73,10 +74,10 @@ BOOST_AUTO_TEST_CASE( PERMX ) {
BOOST_AUTO_TEST_CASE( PARSE_BOX_OK ) {
EclipseState state = makeState( "testdata/integration_tests/BOX/BOXTEST1" );
const auto& satnum = state.getEclipseProperties().getIntGridProperty( "SATNUM" );
EclipseState state = makeState("testdata/integration_tests/BOX/BOXTEST1");
const auto& satnum = state.getEclipseProperties().getIntGridProperty("SATNUM");
{
size_t i, j, k;
size_t i,j,k;
std::shared_ptr<const EclipseGrid> grid = state.getEclipseGrid();
for (k = 0; k < grid->getNZ(); k++) {
for (j = 0; j < grid->getNY(); j++) {
@@ -84,9 +85,9 @@ BOOST_AUTO_TEST_CASE( PARSE_BOX_OK ) {
size_t g = i + j * grid->getNX() + k * grid->getNX() * grid->getNY();
if (i <= 1 && j <= 1 && k <= 1)
BOOST_CHECK_EQUAL( satnum.iget( g ), 10 );
BOOST_CHECK_EQUAL(satnum.iget(g) , 10);
else
BOOST_CHECK_EQUAL( satnum.iget( g ), 2 );
BOOST_CHECK_EQUAL(satnum.iget(g) , 2);
}
}
@@ -94,11 +95,13 @@ BOOST_AUTO_TEST_CASE( PARSE_BOX_OK ) {
}
}
BOOST_AUTO_TEST_CASE( PARSE_MULTIPLY_COPY ) {
EclipseState state = makeState( "testdata/integration_tests/BOX/BOXTEST1" );
const auto& satnum = state.getEclipseProperties().getIntGridProperty( "SATNUM" );
const auto& fipnum = state.getEclipseProperties().getIntGridProperty( "FIPNUM" );
size_t i, j, k;
EclipseState state = makeState("testdata/integration_tests/BOX/BOXTEST1");
const auto& satnum = state.getEclipseProperties().getIntGridProperty("SATNUM");
const auto& fipnum = state.getEclipseProperties().getIntGridProperty("FIPNUM");
size_t i,j,k;
std::shared_ptr<const EclipseGrid> grid = state.getEclipseGrid();
for (k = 0; k < grid->getNZ(); k++) {
@@ -107,9 +110,9 @@ BOOST_AUTO_TEST_CASE( PARSE_MULTIPLY_COPY ) {
size_t g = i + j * grid->getNX() + k * grid->getNX() * grid->getNY();
if (i <= 1 && j <= 1 && k <= 1)
BOOST_CHECK_EQUAL( 4 * satnum.iget( g ), fipnum.iget( g ) );
BOOST_CHECK_EQUAL(4*satnum.iget(g) , fipnum.iget(g));
else
BOOST_CHECK_EQUAL( 2 * satnum.iget( i, j, k ), fipnum.iget( i, j, k ) );
BOOST_CHECK_EQUAL(2*satnum.iget(i,j,k) , fipnum.iget(i,j,k));
}
}
@@ -124,20 +127,20 @@ BOOST_AUTO_TEST_CASE( KEYWORD_BOX_TOO_SMALL) {
}
BOOST_AUTO_TEST_CASE( EQUAL ) {
EclipseState state = makeState( "testdata/integration_tests/BOX/BOXTEST1" );
const auto& pvtnum = state.getEclipseProperties().getIntGridProperty( "PVTNUM" );
const auto& eqlnum = state.getEclipseProperties().getIntGridProperty( "EQLNUM" );
const auto& poro = state.getEclipseProperties().getDoubleGridProperty( "PORO" );
size_t i, j, k;
EclipseState state = makeState("testdata/integration_tests/BOX/BOXTEST1");
const auto& pvtnum = state.getEclipseProperties().getIntGridProperty("PVTNUM");
const auto& eqlnum = state.getEclipseProperties().getIntGridProperty("EQLNUM");
const auto& poro = state.getEclipseProperties().getDoubleGridProperty("PORO");
size_t i,j,k;
std::shared_ptr<const EclipseGrid> grid = state.getEclipseGrid();
for (k = 0; k < grid->getNZ(); k++) {
for (j = 0; j < grid->getNY(); j++) {
for (i = 0; i < grid->getNX(); i++) {
BOOST_CHECK_EQUAL( pvtnum.iget( i, j, k ), k );
BOOST_CHECK_EQUAL( eqlnum.iget( i, j, k ), 77 + 2 * k );
BOOST_CHECK_EQUAL( poro.iget( i, j, k ), 0.25 );
BOOST_CHECK_EQUAL( pvtnum.iget(i,j,k) , k );
BOOST_CHECK_EQUAL( eqlnum.iget(i,j,k) , 77 + 2 * k );
BOOST_CHECK_EQUAL( poro.iget(i,j,k) , 0.25 );
}
}