Substantial edits to Eclipse3DProperties

* Removed all references to state, need to fix initPORV
* Made TransMult return raw pointer const GridProperty over shared pointer.
* Moved getDirectionProperty and hasDirectionProperty out of API
** Removed tests as these methods are no longer public
* Moved grid properties stuff to new class
* Removed use of deck in SatfuncInitializers, moved to TableManager
* Removed shared_ptr for several members of EclipseState and 3DProperties
* Moved region-property from EclipseState to Eclipse3DProperties
* Moved initGridopts from EclipseState to Eclipse3DProperties
* Made several Eclipse3DProperties methods private
* 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
* Removed obsolete tests
This commit is contained in:
Pål Grønås Drange 2016-03-08 17:07:42 +01:00
parent 49a1c17eb8
commit e48b64c41d
41 changed files with 3611 additions and 1916 deletions

1
.gitignore vendored
View File

@ -9,3 +9,4 @@ install
.project
/testdata/statoil
.idea
/Debug/

View File

@ -70,6 +70,7 @@ ${generator_source}
set (state_source
EclipseState/EclipseState.cpp
EclipseState/Eclipse3DProperties.cpp
EclipseState/Messages.cpp
#
EclipseState/checkDeck.cpp
@ -169,6 +170,7 @@ Units/Dimension.hpp
Units/ConversionFactors.hpp
#
EclipseState/EclipseState.hpp
EclipseState/Eclipse3DProperties.hpp
EclipseState/Messages.hpp
#
EclipseState/checkDeck.hpp

View File

@ -0,0 +1,914 @@
/*
Copyright 2016 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/Eclipse3DProperties.hpp>
#include <opm/parser/eclipse/EclipseState/EclipseState.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>
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;
}
Eclipse3DProperties::Eclipse3DProperties( 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))
{
/*
* The EQUALREG, MULTREG, COPYREG, ... keywords are used to manipulate
* vectors based on region values; for instance the statement
*
* EQUALREG
* PORO 0.25 3 / -- Region array not specified
* PERMX 100 3 F /
* /
*
* will set the PORO field to 0.25 for all cells in region 3 and the PERMX
* value to 100 mD for the same cells. The fourth optional argument to the
* EQUALREG keyword is used to indicate which REGION array should be used
* for the selection.
*
* If the REGION array is not indicated (as in the PORO case) above, the
* default region to use in the xxxREG keywords depends on the GRIDOPTS
* keyword:
*
* 1. If GRIDOPTS is present, and the NRMULT item is greater than zero,
* the xxxREG keywords will default to use the MULTNUM region.
*
* 2. If the GRIDOPTS keyword is not present - or the NRMULT item equals
* zero, the xxxREG keywords will default to use the FLUXNUM keyword.
*
* This quite weird behaviour comes from reading the GRIDOPTS and MULTNUM
* documentation, and practical experience with ECLIPSE
* simulations. Ufortunately the documentation of the xxxREG keywords does
* not confirm this.
*/
if (deck.hasKeyword( "GRIDOPTS" )) {
const auto& gridOpts = deck.getKeyword( "GRIDOPTS" );
const auto& record = gridOpts.getRecord( 0 );
const auto& nrmult_item = record.getItem( "NRMULT" );
if (nrmult_item.get<int>( 0 ) > 0)
m_defaultRegion = "MULTNUM"; // GRIDOPTS and positive NRMULT
}
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 Eclipse3DProperties::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 Eclipse3DProperties::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 Eclipse3DProperties::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>& Eclipse3DProperties::getIntGridProperties() {
return m_intGridProperties;
}
/// gets properties doubleGridProperties. This does not run any post processors
GridProperties<double>& Eclipse3DProperties::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>& Eclipse3DProperties::getIntGridProperty( const std::string& keyword ) const {
return m_intGridProperties.getKeyword( keyword );
}
/// gets property from doubleGridProperty --- and calls the runPostProcessor
const GridProperty<double>& Eclipse3DProperties::getDoubleGridProperty( const std::string& keyword ) const {
auto& gridProperty = const_cast< Eclipse3DProperties* >( this )->m_doubleGridProperties.getKeyword( keyword );
gridProperty.runPostProcessor();
return gridProperty;
}
std::string Eclipse3DProperties::getDefaultRegionKeyword() const {
return m_defaultRegion;
}
const GridProperty<int>& Eclipse3DProperties::getRegion( const DeckItem& regionItem ) const {
if (regionItem.defaultApplied(0))
return m_intGridProperties.getKeyword( m_defaultRegion );
else {
const std::string regionArray = MULTREGT::RegionNameFromDeckValue( regionItem.get< std::string >(0) );
return m_intGridProperties.getInitializedKeyword( regionArray );
}
}
/// 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 Eclipse3DProperties::loadGridPropertyFromDeckKeyword(const Box& inputBox,
const DeckKeyword& deckKeyword,
int enabledTypes)
{
const std::string& keyword = deckKeyword.name();
if (m_intGridProperties.supportsKeyword( keyword )) {
if (enabledTypes & IntProperties) {
auto& gridProperty = m_intGridProperties.getOrCreateProperty( keyword );
gridProperty.loadFromDeckKeyword( inputBox, deckKeyword );
}
} else if (m_doubleGridProperties.supportsKeyword( keyword )) {
if (enabledTypes & DoubleProperties) {
auto& gridProperty = m_doubleGridProperties.getOrCreateProperty( keyword );
gridProperty.loadFromDeckKeyword( inputBox, deckKeyword );
}
} else {
throw std::logic_error( "Tried to load unsupported grid property from keyword: " + deckKeyword.name() );
}
}
static bool isInt(double value) {
return fabs( nearbyint( value ) - value ) < 1e-6;
}
void Eclipse3DProperties::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 Eclipse3DProperties::getSIScaling(const std::string &dimensionString) const
{
return m_deckUnitSystem.getDimension(dimensionString)->getSIScaling();
}
void Eclipse3DProperties::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 Eclipse3DProperties::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 Eclipse3DProperties::handleENDBOXKeyword(BoxManager& boxManager) {
boxManager.endInputBox();
}
void Eclipse3DProperties::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 Eclipse3DProperties::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 Eclipse3DProperties::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 Eclipse3DProperties::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 Eclipse3DProperties::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 Eclipse3DProperties::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 Eclipse3DProperties::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 Eclipse3DProperties::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 Eclipse3DProperties::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

@ -0,0 +1,114 @@
/*
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 {
class Box;
class BoxManager;
class Deck;
class DeckItem;
class DeckKeyword;
class DeckRecord;
class EclipseGrid;
class EclipseState;
class InitConfig;
class IOConfig;
class Schedule;
class Section;
class TableManager;
class TransMult;
class UnitSystem;
/// Class representing properties on 3D grid for use in EclipseState.
class Eclipse3DProperties
{
public:
enum EnabledTypes {
IntProperties = 0x01,
DoubleProperties = 0x02,
AllProperties = IntProperties | DoubleProperties
};
Eclipse3DProperties(const Deck& deck,
std::shared_ptr<const TableManager> tableManager,
const EclipseGrid& eclipseGrid);
const GridProperty<int>& getRegion(const DeckItem& regionItem) const;
std::string getDefaultRegionKeyword() const;
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);
static void setKeywordBox(const DeckKeyword& deckKeyword, const DeckRecord&, BoxManager& boxManager);
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

@ -0,0 +1,894 @@
/*
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

@ -0,0 +1,118 @@
/*
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

File diff suppressed because it is too large Load Diff

View File

@ -25,6 +25,7 @@
#include <set>
#include <opm/parser/eclipse/EclipseState/Schedule/ScheduleEnums.hpp>
#include <opm/parser/eclipse/EclipseState/Eclipse3DProperties.hpp>
#include <opm/parser/eclipse/Parser/MessageContainer.hpp>
namespace Opm {
@ -73,105 +74,57 @@ namespace Opm {
std::shared_ptr< EclipseGrid > getEclipseGridCopy() const;
const MessageContainer& getMessageContainer() const;
MessageContainer& getMessageContainer();
bool hasPhase(enum Phase::PhaseEnum phase) const;
std::string getTitle() const;
bool supportsGridProperty(const std::string& keyword, int enabledTypes=AllProperties) const;
std::shared_ptr<const GridProperty<int> > getRegion( const DeckItem& regionItem ) const;
std::shared_ptr<const GridProperty<int> > getDefaultRegion() const;
std::shared_ptr<const GridProperty<int> > getIntGridProperty( const std::string& keyword ) const;
std::shared_ptr<const GridProperty<double> > getDoubleGridProperty( const std::string& keyword ) const;
bool hasDeckIntGridProperty(const std::string& keyword) const;
bool hasDeckDoubleGridProperty(const std::string& keyword) const;
bool hasIntGridProperty(const std::string& keyword) const __attribute__((deprecated("use hasDeckIntGridProperty() instead")))
{ return hasDeckIntGridProperty(keyword); }
bool hasDoubleGridProperty(const std::string& keyword) const __attribute__((deprecated("use hasDeckDoubleGridProperty() instead")))
{ return hasDeckDoubleGridProperty(keyword); }
void loadGridPropertyFromDeckKeyword(std::shared_ptr<const Box> inputBox,
const DeckKeyword& deckKeyword,
int enabledTypes = AllProperties);
std::shared_ptr<const FaultCollection> getFaults() const;
std::shared_ptr<const TransMult> getTransMult() const;
std::shared_ptr<const NNC> getNNC() const;
bool hasNNC() const;
std::shared_ptr<const TableManager> getTableManager() const;
size_t getNumPhases() const;
const Eclipse3DProperties& getEclipseProperties() 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...
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...
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 initTables(std::shared_ptr< const Deck > deck);
void initIOConfig(std::shared_ptr< const Deck > deck);
void initSchedule(std::shared_ptr< const Deck > deck);
void initIOConfigPostSchedule(std::shared_ptr< const Deck > deck);
void initInitConfig(std::shared_ptr< const Deck > deck);
void initSimulationConfig(std::shared_ptr< const Deck > deck);
void initEclipseGrid(std::shared_ptr< const Deck > deck);
void initGridopts(std::shared_ptr< const Deck > deck);
void initPhases(std::shared_ptr< const Deck > deck);
void initTitle(std::shared_ptr< const Deck > deck);
void initProperties(std::shared_ptr< const Deck > deck);
void initTransMult();
void initFaults(std::shared_ptr< const Deck > deck);
void initNNC(std::shared_ptr< const Deck > deck);
void setMULTFLT(std::shared_ptr<const Opm::Section> section) const;
void initMULTREGT(std::shared_ptr< const Deck > deck);
double getSIScaling(const std::string &dimensionString) const;
void processGridProperties(std::shared_ptr< const Deck > deck, int enabledTypes);
void scanSection(std::shared_ptr<Opm::Section> section , 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 handleEQUALREGKeyword(const DeckKeyword& deckKeyword, int enabledTypes);
void handleMULTIREGKeyword(const DeckKeyword& deckKeyword, int enabledTypes);
void handleADDREGKeyword(const DeckKeyword& deckKeyword , int enabledTypes);
void handleCOPYREGKeyword(const DeckKeyword& deckKeyword , int enabledTypes);
void setKeywordBox( const DeckKeyword& deckKeyword, const DeckRecord&, BoxManager& boxManager);
void copyIntKeyword(const std::string& srcField , const std::string& targetField , std::shared_ptr<const Box> inputBox);
void copyDoubleKeyword(const std::string& srcField , const std::string& targetField , std::shared_ptr<const Box> inputBox);
void complainAboutAmbiguousKeyword(std::shared_ptr< const Deck > deck, const std::string& keywordName) const;
std::shared_ptr<GridProperty<int> > getOrCreateIntProperty_(const std::string name);
std::shared_ptr<GridProperty<double> > getOrCreateDoubleProperty_(const std::string name);
std::shared_ptr< const EclipseGrid > m_eclipseGrid;
std::shared_ptr< IOConfig > m_ioConfig;
std::shared_ptr< const InitConfig > m_initConfig;
std::shared_ptr< const Schedule > schedule;
std::shared_ptr< const Schedule > m_schedule;
std::shared_ptr< const SimulationConfig > m_simulationConfig;
std::shared_ptr<const TableManager> m_tables;
std::set<enum Phase::PhaseEnum> phases;
std::string m_title;
const UnitSystem& m_deckUnitSystem;
std::shared_ptr<GridProperties<int> > m_intGridProperties;
std::shared_ptr<GridProperties<double> > m_doubleGridProperties;
std::shared_ptr<TransMult> m_transMult;
std::shared_ptr<FaultCollection> m_faults;
std::shared_ptr<NNC> m_nnc;
std::string m_defaultRegion;
const UnitSystem& m_deckUnitSystem;
const ParseContext& m_parseContext;
std::shared_ptr<const TableManager> m_tables;
std::shared_ptr<const EclipseGrid> m_eclipseGrid;
Eclipse3DProperties m_eclipseProperties;
MessageContainer m_messageContainer;
};
@ -179,4 +132,4 @@ namespace Opm {
typedef std::shared_ptr<const EclipseState> EclipseStateConstPtr;
}
#endif
#endif // OPM_ECLIPSE_STATE_HPP

View File

@ -28,71 +28,87 @@
#include <opm/parser/eclipse/EclipseState/Grid/EclipseGrid.hpp>
#include <opm/parser/eclipse/EclipseState/Grid/GridProperty.hpp>
#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:
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.
*/
namespace Opm {
class EclipseGrid;
class Eclipse3DProperties;
template <typename T>
class GridProperties {
public:
typedef typename GridProperty<T>::SupportedKeywordInfo SupportedKeywordInfo;
GridProperties(std::shared_ptr<const EclipseGrid> eclipseGrid, std::vector< SupportedKeywordInfo >&& supportedKeywords) :
m_eclipseGrid( eclipseGrid ) {
GridProperties(const EclipseGrid& eclipseGrid,
std::vector< SupportedKeywordInfo >&& supportedKeywords) :
m_eclipseGrid( eclipseGrid )
{
for (auto iter = supportedKeywords.begin(); iter != supportedKeywords.end(); ++iter)
m_supportedKeywords.emplace( iter->getKeywordName(), std::move( *iter ) );
}
bool supportsKeyword(const std::string& keyword) const {
return m_supportedKeywords.count( keyword ) > 0;
}
bool hasKeyword(const std::string& keyword) const {
return m_properties.count( keyword ) > 0 && !isAutoGenerated_(keyword);
const auto cnt = m_properties.count( keyword );
const bool positive = cnt > 0;
return positive && !isAutoGenerated_(keyword);
}
size_t size() const {
return m_property_list.size();
}
std::shared_ptr<GridProperty<T> > getKeyword(const std::string& keyword) const {
const GridProperty<T>& getKeyword(const std::string& keyword) const {
if (!hasKeyword(keyword))
addAutoGeneratedKeyword_(keyword);
return m_properties.at( keyword );
return *m_properties.at( keyword );
}
std::shared_ptr<GridProperty<T> > getKeyword(size_t index) const {
GridProperty<T>& getKeyword(const std::string& keyword) {
if (!hasKeyword(keyword))
addAutoGeneratedKeyword_(keyword);
return *m_properties.at( keyword );
}
const GridProperty<T>& getKeyword(size_t index) const {
if (index < size())
return m_property_list[index];
return *m_property_list[index];
else
throw std::invalid_argument("Invalid index");
}
GridProperty<T>& getKeyword(size_t index) {
if (index < size())
return *m_property_list[index];
else
throw std::invalid_argument("Invalid index");
}
std::shared_ptr<GridProperty<T> > getInitializedKeyword(const std::string& keyword) const {
const GridProperty<T>& getInitializedKeyword(const std::string& keyword) const {
if (hasKeyword(keyword))
return m_properties.at( keyword );
return *m_properties.at( keyword );
else {
if (supportsKeyword(keyword))
throw std::invalid_argument("Keyword: " + keyword + " is supported - but not initialized.");
@ -101,7 +117,6 @@ public:
}
}
bool addKeyword(const std::string& keywordName) {
if (!supportsKeyword( keywordName ))
throw std::invalid_argument("The keyword: " + keywordName + " is not supported in this container");
@ -123,9 +138,9 @@ public:
}
auto supportedKeyword = m_supportedKeywords.at( keywordName );
int nx = m_eclipseGrid->getNX();
int ny = m_eclipseGrid->getNY();
int nz = m_eclipseGrid->getNZ();
int nx = m_eclipseGrid.getNX();
int ny = m_eclipseGrid.getNY();
int nz = m_eclipseGrid.getNZ();
std::shared_ptr<GridProperty<T> > newProperty(new GridProperty<T>(nx , ny , nz , supportedKeyword));
m_properties.insert( std::pair<std::string , std::shared_ptr<GridProperty<T> > > ( keywordName , newProperty ));
@ -134,6 +149,15 @@ public:
}
}
void copyKeyword(const std::string& srcField ,
const std::string& targetField ,
const Box& inputBox) {
const auto& src = this->getKeyword( srcField );
auto& target = this->getOrCreateProperty( targetField );
target.copyFrom( *src , inputBox );
}
template <class Keyword>
bool hasKeyword() const {
@ -141,18 +165,36 @@ public:
}
template <class Keyword>
std::shared_ptr<GridProperty<T> > getKeyword() const {
const GridProperty<T>& getKeyword() const {
return getKeyword( Keyword::keywordName );
}
template <class Keyword>
std::shared_ptr<GridProperty<T> > getInitializedKeyword() const {
const GridProperty<T>& getInitializedKeyword() const {
return getInitializedKeyword( Keyword::keywordName );
}
GridProperty<T>& getOrCreateProperty(const std::string name) {
if (!hasKeyword(name)) {
addKeyword(name);
}
return getKeyword(name);
}
private:
/// this method exists for (friend) Eclipse3DProperties to be allowed initializing PORV keyword
void postAddKeyword(const std::string& name,
const T defaultValue,
GridPropertyPostFunction< T >& postProcessor,
const std::string& dimString )
{
m_supportedKeywords.emplace(name,
SupportedKeywordInfo( name,
defaultValue,
postProcessor,
dimString ));
}
bool addAutoGeneratedKeyword_(const std::string& keywordName) const {
if (!supportsKeyword( keywordName ))
throw std::invalid_argument("The keyword: " + keywordName + " is not supported in this container");
@ -160,10 +202,10 @@ private:
if (m_properties.count( keywordName ) > 0)
return false; // property already exists (if it is auto generated or not doesn't matter)
else {
auto supportedKeyword = m_supportedKeywords.at( keywordName );
int nx = m_eclipseGrid->getNX();
int ny = m_eclipseGrid->getNY();
int nz = m_eclipseGrid->getNZ();
auto& supportedKeyword = m_supportedKeywords.at( keywordName );
int nx = m_eclipseGrid.getNX();
int ny = m_eclipseGrid.getNY();
int nz = m_eclipseGrid.getNZ();
std::shared_ptr<GridProperty<T> > newProperty(new GridProperty<T>(nx , ny , nz , supportedKeyword));
m_autoGeneratedProperties_.insert(keywordName);
@ -178,13 +220,13 @@ private:
return m_autoGeneratedProperties_.count(keyword);
}
std::shared_ptr<const EclipseGrid> m_eclipseGrid;
friend class Eclipse3DProperties; // needed for PORV keyword entanglement
const EclipseGrid& m_eclipseGrid;
std::unordered_map<std::string, SupportedKeywordInfo> m_supportedKeywords;
mutable std::map<std::string , std::shared_ptr<GridProperty<T> > > m_properties;
mutable std::set<std::string> m_autoGeneratedProperties_;
mutable std::vector<std::shared_ptr<GridProperty<T> > > m_property_list;
};
}
#endif
#endif // ECLIPSE_GRIDPROPERTIES_HPP_

View File

@ -219,7 +219,7 @@ namespace Opm {
template< typename T >
void GridProperty< T >::loadFromDeckKeyword( const DeckKeyword& deckKeyword ) {
const auto& deckItem = getDeckItem(deckKeyword);
const DeckItem& deckItem = getDeckItem(deckKeyword);
for (size_t dataPointIdx = 0; dataPointIdx < deckItem.size(); ++dataPointIdx) {
if (!deckItem.defaultApplied(dataPointIdx))
setDataPoint(dataPointIdx, dataPointIdx, deckItem);
@ -227,12 +227,12 @@ namespace Opm {
}
template< typename T >
void GridProperty< T >::loadFromDeckKeyword( std::shared_ptr<const Box> inputBox, const DeckKeyword& deckKeyword) {
if (inputBox->isGlobal())
void GridProperty< T >::loadFromDeckKeyword( const Box& inputBox, const DeckKeyword& deckKeyword) {
if (inputBox.isGlobal())
loadFromDeckKeyword( deckKeyword );
else {
const auto& deckItem = getDeckItem(deckKeyword);
const std::vector<size_t>& indexList = inputBox->getIndexList();
const std::vector<size_t>& indexList = inputBox.getIndexList();
if (indexList.size() == deckItem.size()) {
for (size_t sourceIdx = 0; sourceIdx < indexList.size(); sourceIdx++) {
size_t targetIdx = indexList[sourceIdx];
@ -252,12 +252,12 @@ namespace Opm {
}
template< typename T >
void GridProperty< T >::copyFrom( const GridProperty< T >& src, std::shared_ptr< const Box > inputBox ) {
if (inputBox->isGlobal()) {
void GridProperty< T >::copyFrom( const GridProperty< T >& src, const Box& inputBox ) {
if (inputBox.isGlobal()) {
for (size_t i = 0; i < src.getCartesianSize(); ++i)
m_data[i] = src.m_data[i];
} else {
const std::vector<size_t>& indexList = inputBox->getIndexList();
const std::vector<size_t>& indexList = inputBox.getIndexList();
for (size_t i = 0; i < indexList.size(); i++) {
size_t targetIndex = indexList[i];
m_data[targetIndex] = src.m_data[targetIndex];
@ -266,12 +266,12 @@ namespace Opm {
}
template< typename T >
void GridProperty< T >::scale( T scaleFactor, std::shared_ptr< const Box > inputBox ) {
if (inputBox->isGlobal()) {
void GridProperty< T >::scale( T scaleFactor, const Box& inputBox ) {
if (inputBox.isGlobal()) {
for (size_t i = 0; i < m_data.size(); ++i)
m_data[i] *= scaleFactor;
} else {
const std::vector<size_t>& indexList = inputBox->getIndexList();
const std::vector<size_t>& indexList = inputBox.getIndexList();
for (size_t i = 0; i < indexList.size(); i++) {
size_t targetIndex = indexList[i];
m_data[targetIndex] *= scaleFactor;
@ -280,12 +280,12 @@ namespace Opm {
}
template< typename T >
void GridProperty< T >::add( T shiftValue, std::shared_ptr<const Box> inputBox ) {
if (inputBox->isGlobal()) {
void GridProperty< T >::add( T shiftValue, const Box& inputBox ) {
if (inputBox.isGlobal()) {
for (size_t i = 0; i < m_data.size(); ++i)
m_data[i] += shiftValue;
} else {
const std::vector<size_t>& indexList = inputBox->getIndexList();
const std::vector<size_t>& indexList = inputBox.getIndexList();
for (size_t i = 0; i < indexList.size(); i++) {
size_t targetIndex = indexList[i];
m_data[targetIndex] += shiftValue;
@ -294,11 +294,11 @@ namespace Opm {
}
template< typename T >
void GridProperty< T >::setScalar( T value, std::shared_ptr< const Box > inputBox ) {
if (inputBox->isGlobal()) {
void GridProperty< T >::setScalar( T value, const Box& inputBox ) {
if (inputBox.isGlobal()) {
std::fill(m_data.begin(), m_data.end(), value);
} else {
const std::vector<size_t>& indexList = inputBox->getIndexList();
const std::vector<size_t>& indexList = inputBox.getIndexList();
for (size_t i = 0; i < indexList.size(); i++) {
size_t targetIndex = indexList[i];
m_data[targetIndex] = value;
@ -320,7 +320,6 @@ namespace Opm {
template< typename T >
void GridProperty< T >::runPostProcessor() {
if( this->m_hasRunPostProcessor ) return;
this->m_hasRunPostProcessor = true;
this->m_kwInfo.postProcessor()( m_data );
}
@ -333,11 +332,11 @@ namespace Opm {
}
template< typename T >
ERT::EclKW<T> GridProperty< T >::getEclKW( std::shared_ptr< const EclipseGrid > grid ) const {
ERT::EclKW<T> eclKW( getKeywordName(), grid->getNumActive() );
ERT::EclKW<T> GridProperty< T >::getEclKW( const EclipseGrid& grid ) const {
ERT::EclKW<T> eclKW( getKeywordName(), grid.getNumActive() );
size_t activeIndex = 0;
for (size_t g = 0; g < getCartesianSize(); g++) {
if (grid->cellActive( g )) {
if (grid.cellActive( g )) {
eclKW[activeIndex] = iget(g);
activeIndex++;
}

View File

@ -114,19 +114,19 @@ public:
void initMask( T value, std::vector<bool>& mask ) const;
/**
Due to the convention where it is only neceassary to supply the
Due to the convention where it is only necessary to supply the
top layer of the petrophysical properties we can unfortunately
not enforce that the number of elements elements in the
deckkeyword equals nx*ny*nz.
DeckKeyword equals nx*ny*nz.
*/
void loadFromDeckKeyword( const DeckKeyword& );
void loadFromDeckKeyword( std::shared_ptr<const Box>, const DeckKeyword& );
void loadFromDeckKeyword( const Box&, const DeckKeyword& );
void copyFrom( const GridProperty< T >&, std::shared_ptr< const Box > );
void scale( T scaleFactor, std::shared_ptr< const Box > );
void add( T shiftValue, std::shared_ptr< const Box > );
void setScalar( T value, std::shared_ptr< const Box > );
void copyFrom( const GridProperty< T >&, const Box& );
void scale( T scaleFactor, const Box& );
void add( T shiftValue, const Box& );
void setScalar( T value, const Box& );
const std::string& getKeywordName() const;
const SupportedKeywordInfo& getKeywordInfo() const;
@ -134,7 +134,7 @@ public:
void runPostProcessor();
ERT::EclKW<T> getEclKW() const;
ERT::EclKW<T> getEclKW( std::shared_ptr< const EclipseGrid > ) const;
ERT::EclKW<T> getEclKW( const EclipseGrid & ) const;
/**
Will check that all elements in the property are in the closed

View File

@ -1,9 +1,25 @@
/*
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 <algorithm>
#include <limits>
#include <vector>
#include <array>
#include <opm/parser/eclipse/Deck/Deck.hpp>
#include <opm/parser/eclipse/EclipseState/Eclipse3DProperties.hpp>
#include <opm/parser/eclipse/EclipseState/EclipseState.hpp>
#include <opm/parser/eclipse/EclipseState/Grid/EclipseGrid.hpp>
#include <opm/parser/eclipse/EclipseState/Grid/GridProperty.hpp>
@ -21,39 +37,54 @@ namespace Opm {
template< typename T >
GridPropertyInitFunction< T >::GridPropertyInitFunction(
signature fn,
const Deck& d,
const EclipseState& state ) :
f( fn ), deck( &d ), es( &state )
const TableManager* tables,
const EclipseGrid* grid,
GridProperties<int>* ig_props,
GridProperties<double>* dg_props)
:
f( fn ),
tm ( tables ),
eg ( grid ),
igp ( ig_props ),
dgp ( dg_props )
{}
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->deck, *this->es );
return (*this->f)( size, this->tm, this->eg, this->igp, this->dgp );
}
template< typename T >
GridPropertyPostFunction< T >::GridPropertyPostFunction(
signature fn,
const Deck& d,
const EclipseState& state ) :
f( fn ), deck( &d ), es( &state )
const TableManager* tables,
const EclipseGrid* grid,
GridProperties<int>* ig_props,
GridProperties<double>* dg_props)
:
f( fn ),
tm ( tables ),
eg ( grid ),
igp ( ig_props ),
dgp ( dg_props )
{}
template< typename T >
void GridPropertyPostFunction< T >::operator()( std::vector< T >& values ) const {
if( !this->f ) return;
return (*this->f)( values, *this->deck, *this->es );
if (!this->f)
return;
return (*this->f)( values, this->tm, this->eg, this->igp, this->dgp );
}
std::vector< double > temperature_lookup(
size_t size,
const Deck& deck,
const EclipseState& eclipseState ) {
const TableManager* tables,
const EclipseGrid* grid,
GridProperties<int>* ig_props,
GridProperties<double>* dg_props) {
if( !deck.hasKeyword("EQLNUM") ) {
if( !tables->useEqlnum() ) {
/* if values are defaulted in the TEMPI keyword, but no
* EQLNUM is specified, you will get NaNs
*/
@ -62,15 +93,13 @@ namespace Opm {
std::vector< double > values( size, 0 );
auto tables = eclipseState.getTableManager();
auto eclipseGrid = eclipseState.getEclipseGrid();
const auto& rtempvdTables = tables->getRtempvdTables();
const std::vector< int >& eqlNum = eclipseState.getIntGridProperty("EQLNUM")->getData();
const std::vector< int >& eqlNum = ig_props->getKeyword("EQLNUM").getData();
for (size_t cellIdx = 0; cellIdx < eqlNum.size(); ++ cellIdx) {
int cellEquilNum = eqlNum[cellIdx];
const RtempvdTable& rtempvdTable = rtempvdTables.getTable<RtempvdTable>(cellEquilNum);
double cellDepth = std::get<2>(eclipseGrid->getCellCenter(cellIdx));
double cellDepth = std::get<2>(grid->getCellCenter(cellIdx));
values[cellIdx] = rtempvdTable.evaluate("Temperature", cellDepth);
}

View File

@ -28,22 +28,29 @@
*/
namespace Opm {
class Deck;
class EclipseState;
class EclipseGrid;
class TableManager;
template <typename T> class GridProperties;
template< typename T >
class GridPropertyInitFunction {
public:
using signature = std::vector< T >(*)(
size_t,
const Deck&,
const EclipseState&
const TableManager*,
const EclipseGrid*,
GridProperties<int>* ig_props,
GridProperties<double>* dg_props
);
GridPropertyInitFunction(
signature,
const Deck&,
const EclipseState& );
const TableManager*,
const EclipseGrid*,
GridProperties<int>*,
GridProperties<double>*
);
GridPropertyInitFunction( T );
std::vector< T > operator()( size_t ) const;
@ -51,36 +58,50 @@ template< typename T >
private:
signature f = nullptr;
T constant;
const Deck* deck = nullptr;
const EclipseState* es = nullptr;
const TableManager* tm = nullptr;
const EclipseGrid* eg = nullptr;
GridProperties<int>* igp = nullptr;
GridProperties<double>* dgp = nullptr;
};
template< typename T >
class GridPropertyPostFunction {
public:
using signature = void(*)( std::vector< T >&,
const Deck&,
const EclipseState&
const TableManager*,
const EclipseGrid*,
GridProperties<int>*,
GridProperties<double>*
);
GridPropertyPostFunction() = default;
GridPropertyPostFunction(
signature,
const Deck&,
const EclipseState& );
const TableManager*,
const EclipseGrid*,
GridProperties<int>*,
GridProperties<double>*
);
void operator()( std::vector< T >& ) const;
private:
signature f = nullptr;
const Deck* deck = nullptr;
const EclipseState* es = nullptr;
const TableManager* tm = nullptr;
const EclipseGrid* eg = nullptr;
GridProperties<int>* igp = nullptr;
GridProperties<double>* dgp = nullptr;
};
// initialize the TEMPI grid property using the temperature vs depth
// table (stemming from the TEMPVD or the RTEMPVD keyword)
std::vector< double > temperature_lookup( size_t, const Deck&, const EclipseState& );
// std::vector< double > temperature_lookup( size_t, const EclipseState& );
std::vector< double > temperature_lookup( size_t,
const TableManager*,
const EclipseGrid*,
GridProperties<int>*,
GridProperties<double>*);
}
#endif
#endif // ECLIPSE_GRIDPROPERTY_INITIALIZERS_HPP

View File

@ -126,7 +126,9 @@ namespace Opm {
Then it will go through the different regions and looking for
interface with the wanted region values.
*/
MULTREGTScanner::MULTREGTScanner(std::shared_ptr<GridProperties<int> > cellRegionNumbers, const std::vector< const DeckKeyword* >& keywords , const std::string& defaultRegion ) :
MULTREGTScanner::MULTREGTScanner(const GridProperties<int>& cellRegionNumbers,
const std::vector< const DeckKeyword* >& keywords,
const std::string& defaultRegion ) :
m_cellRegionNumbers(cellRegionNumbers) {
for (size_t idx = 0; idx < keywords.size(); idx++)
@ -134,7 +136,7 @@ namespace Opm {
MULTREGTSearchMap searchPairs;
for (std::vector<MULTREGTRecord>::const_iterator record = m_records.begin(); record != m_records.end(); ++record) {
if (cellRegionNumbers->hasKeyword( record->m_region.getValue())) {
if (cellRegionNumbers.hasKeyword( record->m_region.getValue())) {
if (record->m_srcRegion.hasValue() && record->m_targetRegion.hasValue()) {
int srcRegion = record->m_srcRegion.getValue();
int targetRegion = record->m_targetRegion.getValue();
@ -232,11 +234,11 @@ namespace Opm {
double MULTREGTScanner::getRegionMultiplier(size_t globalIndex1 , size_t globalIndex2, FaceDir::DirEnum faceDir) const {
for (auto iter = m_searchMap.begin(); iter != m_searchMap.end(); iter++) {
std::shared_ptr<const Opm::GridProperty<int> > region = m_cellRegionNumbers->getKeyword( (*iter).first );
const Opm::GridProperty<int>& region = m_cellRegionNumbers.getKeyword( (*iter).first );
MULTREGTSearchMap map = (*iter).second;
int regionId1 = region->iget(globalIndex1);
int regionId2 = region->iget(globalIndex2);
int regionId1 = region.iget(globalIndex1);
int regionId2 = region.iget(globalIndex2);
std::pair<int,int> pair{regionId1 , regionId2};
@ -248,10 +250,10 @@ namespace Opm {
const MULTREGTRecord * record = map[pair];
bool applyMultiplier = true;
int i1 = globalIndex1%region->getNX();
int i2 = globalIndex2%region->getNX();
int j1 = globalIndex1/region->getNX()%region->getNY();
int j2 = globalIndex2/region->getNX()%region->getNY();
int i1 = globalIndex1 % region.getNX();
int i2 = globalIndex2 % region.getNX();
int j1 = globalIndex1 / region.getNX() % region.getNY();
int j2 = globalIndex2 / region.getNX() % region.getNY();
if (record->m_nncBehaviour == MULTREGT::NNC){
applyMultiplier = true;

View File

@ -69,7 +69,9 @@ namespace Opm {
class MULTREGTScanner {
public:
MULTREGTScanner(std::shared_ptr<GridProperties<int> > cellRegionNumbers, const std::vector< const DeckKeyword* >& keywords, const std::string& defaultRegion);
MULTREGTScanner(const GridProperties<int>& cellRegionNumbers,
const std::vector< const DeckKeyword* >& keywords,
const std::string& defaultRegion);
double getRegionMultiplier(size_t globalCellIdx1, size_t globalCellIdx2, FaceDir::DirEnum faceDir) const;
private:
@ -77,7 +79,7 @@ namespace Opm {
void assertKeywordSupported(const DeckKeyword& deckKeyword, const std::string& defaultRegion);
std::vector< MULTREGTRecord > m_records;
std::map<std::string , MULTREGTSearchMap> m_searchMap;
std::shared_ptr<GridProperties<int> > m_cellRegionNumbers;
const GridProperties<int>& m_cellRegionNumbers;
};
}

View File

@ -1,6 +1,23 @@
/*
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 <array>
#include <opm/parser/eclipse/Deck/Deck.hpp>
#include <opm/parser/eclipse/EclipseState/Eclipse3DProperties.hpp>
#include <opm/parser/eclipse/EclipseState/EclipseState.hpp>
#include <opm/parser/eclipse/EclipseState/Grid/EclipseGrid.hpp>
#include <opm/parser/eclipse/EclipseState/Grid/GridProperty.hpp>
@ -24,18 +41,18 @@ namespace Opm {
* can be used to enter relperm and capillary pressure tables.
*
* If SWOF and SGOF are specified in the deck it return I
* If SWFN, SGFN and SOF3 are specified in the deck it return I
* If SWFN, SGFN and SOF3 are specified in the deck it return II
* If keywords are missing or mixed, an error is given.
*/
enum class SatfuncFamily { none = 0, I = 1, II = 2 };
static SatfuncFamily getSaturationFunctionFamily( const TableManager& tm ) {
const TableContainer& swofTables = tm.getSwofTables();
const TableContainer& sgofTables = tm.getSgofTables();
const TableContainer& slgofTables = tm.getSlgofTables();
const TableContainer& sof3Tables = tm.getSof3Tables();
const TableContainer& swfnTables = tm.getSwfnTables();
const TableContainer& sgfnTables = tm.getSgfnTables();
static SatfuncFamily getSaturationFunctionFamily( const TableManager* tm ) {
const TableContainer& swofTables = tm->getSwofTables();
const TableContainer& sgofTables = tm->getSgofTables();
const TableContainer& slgofTables = tm->getSlgofTables();
const TableContainer& sof3Tables = tm->getSof3Tables();
const TableContainer& swfnTables = tm->getSwfnTables();
const TableContainer& sgfnTables = tm->getSgfnTables();
bool family1 = (!sgofTables.empty() || !slgofTables.empty()) && !swofTables.empty();
@ -59,10 +76,10 @@ namespace Opm {
enum class limit { min, max };
static std::vector< double > findMinWaterSaturation( const TableManager& tm ) {
const auto num_tables = tm.getTabdims()->getNumSatTables();
const auto& swofTables = tm.getSwofTables();
const auto& swfnTables = tm.getSwfnTables();
static std::vector< double > findMinWaterSaturation( const TableManager* tm ) {
const auto num_tables = tm->getTabdims()->getNumSatTables();
const auto& swofTables = tm->getSwofTables();
const auto& swfnTables = tm->getSwfnTables();
const auto famI = [&swofTables]( int i ) {
return swofTables.getTable< SwofTable >( i ).getSwColumn().front();
@ -80,10 +97,10 @@ namespace Opm {
}
}
static std::vector< double > findMaxWaterSaturation( const TableManager& tm ) {
const auto num_tables = tm.getTabdims()->getNumSatTables();
const auto& swofTables = tm.getSwofTables();
const auto& swfnTables = tm.getSwfnTables();
static std::vector< double > findMaxWaterSaturation( const TableManager* tm ) {
const auto num_tables = tm->getTabdims()->getNumSatTables();
const auto& swofTables = tm->getSwofTables();
const auto& swfnTables = tm->getSwfnTables();
const auto famI = [&swofTables]( int i ) {
return swofTables.getTable< SwofTable >( i ).getSwColumn().back();
@ -101,11 +118,11 @@ namespace Opm {
}
}
static std::vector< double > findMinGasSaturation( const TableManager& tm ) {
const auto num_tables = tm.getTabdims()->getNumSatTables();
const auto& sgofTables = tm.getSgofTables();
const auto& slgofTables = tm.getSlgofTables();
const auto& sgfnTables = tm.getSgfnTables();
static std::vector< double > findMinGasSaturation( const TableManager* tm ) {
const auto num_tables = tm->getTabdims()->getNumSatTables();
const auto& sgofTables = tm->getSgofTables();
const auto& slgofTables = tm->getSlgofTables();
const auto& sgfnTables = tm->getSgfnTables();
const auto famI_sgof = [&sgofTables]( int i ) {
return sgofTables.getTable< SgofTable >( i ).getSgColumn().front();
@ -141,11 +158,11 @@ namespace Opm {
}
static std::vector< double > findMaxGasSaturation( const TableManager& tm ) {
const auto num_tables = tm.getTabdims()->getNumSatTables();
const auto& sgofTables = tm.getSgofTables();
const auto& slgofTables = tm.getSlgofTables();
const auto& sgfnTables = tm.getSgfnTables();
static std::vector< double > findMaxGasSaturation( const TableManager* tm ) {
const auto num_tables = tm->getTabdims()->getNumSatTables();
const auto& sgofTables = tm->getSgofTables();
const auto& slgofTables = tm->getSlgofTables();
const auto& sgfnTables = tm->getSgfnTables();
const auto famI_sgof = [&sgofTables]( int i ) {
return sgofTables.getTable< SgofTable >( i ).getSgColumn().back();
@ -208,11 +225,11 @@ namespace Opm {
return table.getSwColumn()[ index - 1 ];
}
static std::vector< double > findCriticalWater( const TableManager& tm ) {
static std::vector< double > findCriticalWater( const TableManager* tm ) {
const auto num_tables = tm.getTabdims()->getNumSatTables();
const auto& swofTables = tm.getSwofTables();
const auto& swfnTables = tm.getSwfnTables();
const auto num_tables = tm->getTabdims()->getNumSatTables();
const auto& swofTables = tm->getSwofTables();
const auto& swfnTables = tm->getSwfnTables();
const auto famI = [&swofTables]( int i ) {
return critical_water( swofTables.getTable< SwofTable >( i ) );
@ -251,12 +268,12 @@ namespace Opm {
return slgofTable.getSlColumn()[ index - 1 ];
}
static std::vector< double > findCriticalGas( const TableManager& tm ) {
static std::vector< double > findCriticalGas( const TableManager* tm ) {
const auto num_tables = tm.getTabdims()->getNumSatTables();
const auto& sgfnTables = tm.getSgfnTables();
const auto& sgofTables = tm.getSgofTables();
const auto& slgofTables = tm.getSlgofTables();
const auto num_tables = tm->getTabdims()->getNumSatTables();
const auto& sgfnTables = tm->getSgfnTables();
const auto& sgofTables = tm->getSgofTables();
const auto& slgofTables = tm->getSlgofTables();
const auto famI_sgof = [&sgofTables]( int i ) {
return critical_gas( sgofTables.getTable< SgofTable >( i ) );
@ -311,10 +328,10 @@ namespace Opm {
return sof3Table.getSoColumn()[ index - 1 ];
}
static std::vector< double > findCriticalOilWater( const TableManager& tm ) {
const auto num_tables = tm.getTabdims()->getNumSatTables();
const auto& swofTables = tm.getSwofTables();
const auto& sof3Tables= tm.getSof3Tables();
static std::vector< double > findCriticalOilWater( const TableManager* tm ) {
const auto num_tables = tm->getTabdims()->getNumSatTables();
const auto& swofTables = tm->getSwofTables();
const auto& sof3Tables= tm->getSof3Tables();
const auto famI = [&swofTables]( int i ) {
return critical_oil_water( swofTables.getTable< SwofTable >( i ) );
@ -361,12 +378,12 @@ namespace Opm {
}
static std::vector< double > findCriticalOilGas( const TableManager& tm ) {
static std::vector< double > findCriticalOilGas( const TableManager* tm ) {
const auto num_tables = tm.getTabdims()->getNumSatTables();
const auto& sgofTables = tm.getSgofTables();
const auto& slgofTables = tm.getSlgofTables();
const auto& sof3Tables = tm.getSof3Tables();
const auto num_tables = tm->getTabdims()->getNumSatTables();
const auto& sgofTables = tm->getSgofTables();
const auto& slgofTables = tm->getSlgofTables();
const auto& sof3Tables = tm->getSof3Tables();
const auto famI_sgof = [&sgofTables]( int i ) {
return critical_oil_gas( sgofTables.getTable< SgofTable >( i ) );
@ -399,10 +416,10 @@ namespace Opm {
}
}
static std::vector< double > findMaxKrg( const TableManager& tm ) {
const auto num_tables = tm.getTabdims()->getNumSatTables();
const auto& sgofTables = tm.getSgofTables();
const auto& sgfnTables = tm.getSgfnTables();
static std::vector< double > findMaxKrg( const TableManager* tm ) {
const auto num_tables = tm->getTabdims()->getNumSatTables();
const auto& sgofTables = tm->getSgofTables();
const auto& sgfnTables = tm->getSgfnTables();
const auto& famI = [&sgofTables]( int i ) {
return sgofTables.getTable< SgofTable >( i ).getKrgColumn().back();
@ -422,10 +439,10 @@ namespace Opm {
}
}
static std::vector< double > findKrgr( const TableManager& tm ) {
const auto num_tables = tm.getTabdims()->getNumSatTables();
const auto& sgofTables = tm.getSgofTables();
const auto& sgfnTables = tm.getSgfnTables();
static std::vector< double > findKrgr( const TableManager* tm ) {
const auto num_tables = tm->getTabdims()->getNumSatTables();
const auto& sgofTables = tm->getSgofTables();
const auto& sgfnTables = tm->getSgfnTables();
const auto& famI = [&sgofTables]( int i ) {
return sgofTables.getTable< SgofTable >( i ).getKrgColumn().front();
@ -445,10 +462,10 @@ namespace Opm {
}
}
static std::vector< double > findKrwr( const TableManager& tm ) {
const auto num_tables = tm.getTabdims()->getNumSatTables();
const auto& swofTables = tm.getSwofTables();
const auto& swfnTables = tm.getSwfnTables();
static std::vector< double > findKrwr( const TableManager* tm ) {
const auto num_tables = tm->getTabdims()->getNumSatTables();
const auto& swofTables = tm->getSwofTables();
const auto& swfnTables = tm->getSwfnTables();
const auto& famI = [&swofTables]( int i ) {
return swofTables.getTable< SwofTable >( i ).getKrwColumn().front();
@ -468,10 +485,10 @@ namespace Opm {
}
}
static std::vector< double > findKrorw( const TableManager& tm ) {
const auto num_tables = tm.getTabdims()->getNumSatTables();
const auto& swofTables = tm.getSwofTables();
const auto& sof3Tables = tm.getSof3Tables();
static std::vector< double > findKrorw( const TableManager* tm ) {
const auto num_tables = tm->getTabdims()->getNumSatTables();
const auto& swofTables = tm->getSwofTables();
const auto& sof3Tables = tm->getSof3Tables();
const auto& famI = [&swofTables]( int i ) {
const auto& swofTable = swofTables.getTable< SwofTable >( i );
@ -502,10 +519,10 @@ namespace Opm {
}
}
static std::vector< double > findKrorg( const TableManager& tm ) {
const auto num_tables = tm.getTabdims()->getNumSatTables();
const auto& sgofTables = tm.getSgofTables();
const auto& sof3Tables = tm.getSof3Tables();
static std::vector< double > findKrorg( const TableManager* tm ) {
const auto num_tables = tm->getTabdims()->getNumSatTables();
const auto& sgofTables = tm->getSgofTables();
const auto& sof3Tables = tm->getSof3Tables();
const auto& famI = [&sgofTables]( int i ) {
const auto& sgofTable = sgofTables.getTable< SgofTable >( i );
@ -545,10 +562,10 @@ namespace Opm {
* is not taken into account which means that some twophase quantity must be
* scaled.
*/
static std::vector< double > findMaxPcog( const TableManager& tm ) {
const auto num_tables = tm.getTabdims()->getNumSatTables();
const auto& sgofTables = tm.getSgofTables();
const auto& sgfnTables = tm.getSgfnTables();
static std::vector< double > findMaxPcog( const TableManager* tm ) {
const auto num_tables = tm->getTabdims()->getNumSatTables();
const auto& sgofTables = tm->getSgofTables();
const auto& sgfnTables = tm->getSgfnTables();
const auto& famI = [&sgofTables]( int i ) {
return sgofTables.getTable< SgofTable >( i ).getPcogColumn().front();
@ -568,10 +585,10 @@ namespace Opm {
}
}
static std::vector< double > findMaxPcow( const TableManager& tm ) {
const auto num_tables = tm.getTabdims()->getNumSatTables();
const auto& swofTables = tm.getSwofTables();
const auto& swfnTables = tm.getSwfnTables();
static std::vector< double > findMaxPcow( const TableManager* tm ) {
const auto num_tables = tm->getTabdims()->getNumSatTables();
const auto& swofTables = tm->getSwofTables();
const auto& swfnTables = tm->getSwfnTables();
const auto& famI = [&swofTables]( int i ) {
return swofTables.getTable< SwofTable >( i ).getPcowColumn().front();
@ -591,10 +608,10 @@ namespace Opm {
}
}
static std::vector< double > findMaxKro( const TableManager& tm ) {
const auto num_tables = tm.getTabdims()->getNumSatTables();
const auto& swofTables = tm.getSwofTables();
const auto& sof3Tables = tm.getSof3Tables();
static std::vector< double > findMaxKro( const TableManager* tm ) {
const auto num_tables = tm->getTabdims()->getNumSatTables();
const auto& swofTables = tm->getSwofTables();
const auto& sof3Tables = tm->getSof3Tables();
const auto& famI = [&swofTables]( int i ) {
return swofTables.getTable< SwofTable >( i ).getKrowColumn().front();
@ -614,10 +631,10 @@ namespace Opm {
}
}
static std::vector< double > findMaxKrw( const TableManager& tm ) {
const auto num_tables = tm.getTabdims()->getNumSatTables();
const auto& swofTables = tm.getSwofTables();
const auto& swfnTables = tm.getSwfnTables();
static std::vector< double > findMaxKrw( const TableManager* tm ) {
const auto num_tables = tm->getTabdims()->getNumSatTables();
const auto& swofTables = tm->getSwofTables();
const auto& swfnTables = tm->getSwfnTables();
const auto& famI = [&swofTables]( int i ) {
return swofTables.getTable< SwofTable >( i ).getKrwColumn().back();
@ -664,35 +681,36 @@ namespace Opm {
static std::vector< double > satnumApply( size_t size,
const std::string& columnName,
const std::vector< double >& fallbackValues,
const Deck& m_deck,
const EclipseState& m_eclipseState,
const TableManager* tableManager,
const EclipseGrid* eclipseGrid,
GridProperties<int>* intGridProperties,
GridProperties<double>* doubleGridProperties,
bool useOneMinusTableValue ) {
std::vector< double > values( size, 0 );
auto eclipseGrid = m_eclipseState.getEclipseGrid();
auto tables = m_eclipseState.getTableManager();
auto tabdims = tables->getTabdims();
auto satnum = m_eclipseState.getIntGridProperty("SATNUM");
auto endnum = m_eclipseState.getIntGridProperty("ENDNUM");
std::vector< double > values( size, 0 );
auto tabdims = tableManager->getTabdims();
auto& satnum = intGridProperties->getKeyword("SATNUM");
auto& endnum = intGridProperties->getKeyword("ENDNUM");
int numSatTables = tabdims->getNumSatTables();
satnum->checkLimits( 1 , numSatTables );
satnum.checkLimits( 1 , numSatTables );
// All table lookup assumes three-phase model
assert( m_eclipseState.getNumPhases() == 3 );
assert( tableManager->getNumPhases() == 3 );
// acctually assign the defaults. if the ENPVD keyword was specified in the deck,
// this currently cannot be done because we would need the Z-coordinate of the
// cell and we would need to know how the simulator wants to interpolate between
// sampling points. Both of these are outside the scope of opm-parser, so we just
// assign a NaN in this case...
const bool useEnptvd = m_deck.hasKeyword("ENPTVD");
const auto& enptvdTables = tables->getEnptvdTables();
const bool useEnptvd = tableManager->useEnptvd();
const auto& enptvdTables = tableManager->getEnptvdTables();
for( size_t cellIdx = 0; cellIdx < eclipseGrid->getCartesianSize(); cellIdx++ ) {
int satTableIdx = satnum->iget( cellIdx ) - 1;
int endNum = endnum->iget( cellIdx ) - 1;
int satTableIdx = satnum.iget( cellIdx ) - 1;
int endNum = endnum.iget( cellIdx ) - 1;
double cellDepth = std::get< 2 >( eclipseGrid->getCellCenter( cellIdx ) );
@ -710,31 +728,31 @@ namespace Opm {
static std::vector< double > imbnumApply( size_t size,
const std::string& columnName,
const std::vector< double >& fallBackValues,
const Deck& m_deck,
const EclipseState& m_eclipseState,
const TableManager* tableManager,
const EclipseGrid* eclipseGrid,
GridProperties<int>* intGridProperties,
GridProperties<double>* doubleGridProperties,
bool useOneMinusTableValue ) {
std::vector< double > values( size, 0 );
auto eclipseGrid = m_eclipseState.getEclipseGrid();
auto tables = m_eclipseState.getTableManager();
auto imbnum = m_eclipseState.getIntGridProperty("IMBNUM");
auto endnum = m_eclipseState.getIntGridProperty("ENDNUM");
auto& imbnum = intGridProperties->getKeyword("IMBNUM");
auto& endnum = intGridProperties->getKeyword("ENDNUM");
auto tabdims = tables->getTabdims();
auto tabdims = tableManager->getTabdims();
const int numSatTables = tabdims->getNumSatTables();
imbnum->checkLimits( 1 , numSatTables );
imbnum.checkLimits( 1 , numSatTables );
// acctually assign the defaults. if the ENPVD keyword was specified in the deck,
// this currently cannot be done because we would need the Z-coordinate of the
// cell and we would need to know how the simulator wants to interpolate between
// sampling points. Both of these are outside the scope of opm-parser, so we just
// assign a NaN in this case...
const bool useImptvd = m_deck.hasKeyword("IMPTVD");
const TableContainer& imptvdTables = tables->getImptvdTables();
const bool useImptvd = tableManager->useImptvd();
const TableContainer& imptvdTables = tableManager->getImptvdTables();
for( size_t cellIdx = 0; cellIdx < eclipseGrid->getCartesianSize(); cellIdx++ ) {
int imbTableIdx = imbnum->iget( cellIdx ) - 1;
int endNum = endnum->iget( cellIdx ) - 1;
int imbTableIdx = imbnum.iget( cellIdx ) - 1;
int endNum = endnum.iget( cellIdx ) - 1;
double cellDepth = std::get< 2 >( eclipseGrid->getCellCenter( cellIdx ) );
values[cellIdx] = selectValue(imptvdTables,
@ -748,174 +766,378 @@ namespace Opm {
return values;
}
std::vector< double > SGLEndpoint( size_t size, const Deck& deck, const EclipseState& es ) {
const auto min_gas = findMinGasSaturation( *es.getTableManager() );
return satnumApply( size, "SGCO", min_gas, deck, es, false );
std::vector< double > SGLEndpoint( size_t size,
const TableManager * tableManager,
const EclipseGrid* eclipseGrid,
GridProperties<int>* intGridProperties,
GridProperties<double>* doubleGridProperties)
{
const auto min_gas = findMinGasSaturation( tableManager );
return satnumApply( size, "SGCO", min_gas, tableManager, eclipseGrid,
intGridProperties, doubleGridProperties, false );
}
std::vector< double > ISGLEndpoint( size_t size, const Deck& deck, const EclipseState& es ) {
const auto min_gas = findMinGasSaturation( *es.getTableManager() );
return imbnumApply( size, "SGCO", min_gas, deck, es, false );
std::vector< double > ISGLEndpoint( size_t size,
const TableManager * tableManager,
const EclipseGrid* eclipseGrid,
GridProperties<int>* intGridProperties,
GridProperties<double>* doubleGridProperties)
{
const auto min_gas = findMinGasSaturation( tableManager );
return imbnumApply( size, "SGCO", min_gas, tableManager, eclipseGrid,
intGridProperties, doubleGridProperties, false );
}
std::vector< double > SGUEndpoint( size_t size, const Deck& deck, const EclipseState& es ) {
const auto max_gas = findMaxGasSaturation( *es.getTableManager() );
return satnumApply( size, "SGMAX", max_gas, deck, es, false );
std::vector< double > SGUEndpoint( size_t size,
const TableManager * tableManager,
const EclipseGrid* eclipseGrid,
GridProperties<int>* intGridProperties,
GridProperties<double>* doubleGridProperties)
{
const auto max_gas = findMaxGasSaturation( tableManager );
return satnumApply( size, "SGMAX", max_gas, tableManager, eclipseGrid,
intGridProperties, doubleGridProperties, false );
}
std::vector< double > ISGUEndpoint( size_t size, const Deck& deck, const EclipseState& es ) {
const auto max_gas = findMaxGasSaturation( *es.getTableManager() );
return imbnumApply( size, "SGMAX", max_gas, deck, es, false );
std::vector< double > ISGUEndpoint( size_t size,
const TableManager * tableManager,
const EclipseGrid* eclipseGrid,
GridProperties<int>* intGridProperties,
GridProperties<double>* doubleGridProperties)
{
const auto max_gas = findMaxGasSaturation( tableManager );
return imbnumApply( size, "SGMAX", max_gas, tableManager, eclipseGrid,
intGridProperties, doubleGridProperties, false );
}
std::vector< double > SWLEndpoint( size_t size, const Deck& deck, const EclipseState& es ) {
const auto min_water = findMinWaterSaturation( *es.getTableManager() );
return satnumApply( size, "SWCO", min_water, deck, es, false );
std::vector< double > SWLEndpoint( size_t size,
const TableManager * tableManager,
const EclipseGrid* eclipseGrid,
GridProperties<int>* intGridProperties,
GridProperties<double>* doubleGridProperties)
{
const auto min_water = findMinWaterSaturation( tableManager );
return satnumApply( size, "SWCO", min_water, tableManager, eclipseGrid,
intGridProperties, doubleGridProperties, false );
}
std::vector< double > ISWLEndpoint( size_t size, const Deck& deck, const EclipseState& es ) {
const auto min_water = findMinWaterSaturation( *es.getTableManager() );
return imbnumApply( size, "SWCO", min_water, deck, es, false );
std::vector< double > ISWLEndpoint( size_t size,
const TableManager * tableManager,
const EclipseGrid * eclipseGrid,
GridProperties<int>* intGridProperties,
GridProperties<double>* doubleGridProperties)
{
const auto min_water = findMinWaterSaturation( tableManager );
return imbnumApply( size, "SWCO", min_water, tableManager, eclipseGrid,
intGridProperties, doubleGridProperties, false );
}
std::vector< double > SWUEndpoint( size_t size, const Deck& deck, const EclipseState& es ) {
const auto max_water = findMaxWaterSaturation( *es.getTableManager() );
return satnumApply( size, "SWMAX", max_water, deck, es, true );
std::vector< double > SWUEndpoint( size_t size,
const TableManager * tableManager,
const EclipseGrid * eclipseGrid,
GridProperties<int>* intGridProperties,
GridProperties<double>* doubleGridProperties)
{
const auto max_water = findMaxWaterSaturation( tableManager );
return satnumApply( size, "SWMAX", max_water, tableManager, eclipseGrid,
intGridProperties, doubleGridProperties, true );
}
std::vector< double > ISWUEndpoint( size_t size, const Deck& deck, const EclipseState& es ) {
const auto max_water = findMaxWaterSaturation( *es.getTableManager() );
return imbnumApply( size, "SWMAX", max_water, deck, es, true);
std::vector< double > ISWUEndpoint( size_t size,
const TableManager * tableManager,
const EclipseGrid * eclipseGrid,
GridProperties<int>* intGridProperties,
GridProperties<double>* doubleGridProperties)
{
const auto max_water = findMaxWaterSaturation( tableManager );
return imbnumApply( size, "SWMAX", max_water, tableManager, eclipseGrid,
intGridProperties, doubleGridProperties, true);
}
std::vector< double > SGCREndpoint( size_t size, const Deck& deck, const EclipseState& es ) {
const auto crit_gas = findCriticalGas( *es.getTableManager() );
return satnumApply( size, "SGCRIT", crit_gas, deck, es, false );
std::vector< double > SGCREndpoint( size_t size,
const TableManager * tableManager,
const EclipseGrid * eclipseGrid,
GridProperties<int>* intGridProperties,
GridProperties<double>* doubleGridProperties)
{
const auto crit_gas = findCriticalGas( tableManager );
return satnumApply( size, "SGCRIT", crit_gas, tableManager, eclipseGrid,
intGridProperties, doubleGridProperties, false );
}
std::vector< double > ISGCREndpoint( size_t size, const Deck& deck, const EclipseState& es ) {
const auto crit_gas = findCriticalGas( *es.getTableManager() );
return imbnumApply( size, "SGCRIT", crit_gas, deck, es, false );
std::vector< double > ISGCREndpoint( size_t size,
const TableManager * tableManager,
const EclipseGrid * eclipseGrid,
GridProperties<int>* intGridProperties,
GridProperties<double>* doubleGridProperties)
{
const auto crit_gas = findCriticalGas( tableManager );
return imbnumApply( size, "SGCRIT", crit_gas, tableManager, eclipseGrid,
intGridProperties, doubleGridProperties, false );
}
std::vector< double > SOWCREndpoint( size_t size, const Deck& deck, const EclipseState& es ) {
const auto oil_water = findCriticalOilWater( *es.getTableManager() );
return satnumApply( size, "SOWCRIT", oil_water, deck, es, false );
std::vector< double > SOWCREndpoint( size_t size,
const TableManager * tableManager,
const EclipseGrid * eclipseGrid,
GridProperties<int>* intGridProperties,
GridProperties<double>* doubleGridProperties)
{
const auto oil_water = findCriticalOilWater( tableManager );
return satnumApply( size, "SOWCRIT", oil_water, tableManager, eclipseGrid,
intGridProperties, doubleGridProperties, false );
}
std::vector< double > ISOWCREndpoint( size_t size, const Deck& deck, const EclipseState& es ) {
const auto oil_water = findCriticalOilWater( *es.getTableManager() );
return imbnumApply( size, "SOWCRIT", oil_water, deck, es, false );
std::vector< double > ISOWCREndpoint( size_t size,
const TableManager * tableManager,
const EclipseGrid * eclipseGrid,
GridProperties<int>* intGridProperties,
GridProperties<double>* doubleGridProperties
)
{
const auto oil_water = findCriticalOilWater( tableManager );
return imbnumApply( size, "SOWCRIT", oil_water, tableManager, eclipseGrid,
intGridProperties, doubleGridProperties, false );
}
std::vector< double > SOGCREndpoint( size_t size, const Deck& deck, const EclipseState& es ) {
const auto crit_oil_gas = findCriticalOilGas( *es.getTableManager() );
return satnumApply( size, "SOGCRIT", crit_oil_gas, deck, es, false );
std::vector< double > SOGCREndpoint( size_t size,
const TableManager * tableManager,
const EclipseGrid * eclipseGrid,
GridProperties<int>* intGridProperties,
GridProperties<double>* doubleGridProperties)
{
const auto crit_oil_gas = findCriticalOilGas( tableManager );
return satnumApply( size, "SOGCRIT", crit_oil_gas, tableManager, eclipseGrid,
intGridProperties, doubleGridProperties, false );
}
std::vector< double > ISOGCREndpoint( size_t size, const Deck& deck, const EclipseState& es ) {
const auto crit_oil_gas = findCriticalOilGas( *es.getTableManager() );
return imbnumApply( size, "SOGCRIT", crit_oil_gas, deck, es, false );
std::vector< double > ISOGCREndpoint( size_t size,
const TableManager * tableManager,
const EclipseGrid * eclipseGrid,
GridProperties<int>* intGridProperties,
GridProperties<double>* doubleGridProperties)
{
const auto crit_oil_gas = findCriticalOilGas( tableManager );
return imbnumApply( size, "SOGCRIT", crit_oil_gas, tableManager, eclipseGrid,
intGridProperties, doubleGridProperties, false );
}
std::vector< double > SWCREndpoint( size_t size, const Deck& deck, const EclipseState& es ) {
const auto crit_water = findCriticalWater( *es.getTableManager() );
return satnumApply( size, "SWCRIT", crit_water, deck, es, false );
std::vector< double > SWCREndpoint( size_t size,
const TableManager * tableManager,
const EclipseGrid * eclipseGrid,
GridProperties<int>* intGridProperties,
GridProperties<double>* doubleGridProperties)
{
const auto crit_water = findCriticalWater( tableManager );
return satnumApply( size, "SWCRIT", crit_water, tableManager, eclipseGrid,
intGridProperties, doubleGridProperties, false );
}
std::vector< double > ISWCREndpoint( size_t size, const Deck& deck, const EclipseState& es ) {
const auto crit_water = findCriticalWater( *es.getTableManager() );
return imbnumApply( size, "SWCRIT", crit_water, deck, es, false );
std::vector< double > ISWCREndpoint( size_t size,
const TableManager * tableManager,
const EclipseGrid * eclipseGrid,
GridProperties<int>* intGridProperties,
GridProperties<double>* doubleGridProperties)
{
const auto crit_water = findCriticalWater( tableManager );
return imbnumApply( size, "SWCRIT", crit_water, tableManager, eclipseGrid,
intGridProperties, doubleGridProperties, false );
}
std::vector< double > PCWEndpoint( size_t size, const Deck& deck, const EclipseState& es ) {
const auto max_pcow = findMaxPcow( *es.getTableManager() );
return satnumApply( size, "PCW", max_pcow, deck, es, false );
std::vector< double > PCWEndpoint( size_t size,
const TableManager * tableManager,
const EclipseGrid * eclipseGrid,
GridProperties<int>* intGridProperties,
GridProperties<double>* doubleGridProperties)
{
const auto max_pcow = findMaxPcow( tableManager );
return satnumApply( size, "PCW", max_pcow, tableManager, eclipseGrid,
intGridProperties, doubleGridProperties, false );
}
std::vector< double > IPCWEndpoint( size_t size, const Deck& deck, const EclipseState& es ) {
const auto max_pcow = findMaxPcow( *es.getTableManager() );
return imbnumApply( size, "IPCW", max_pcow, deck, es, false );
std::vector< double > IPCWEndpoint( size_t size,
const TableManager * tableManager,
const EclipseGrid * eclipseGrid,
GridProperties<int>* intGridProperties,
GridProperties<double>* doubleGridProperties)
{
const auto max_pcow = findMaxPcow( tableManager );
return imbnumApply( size, "IPCW", max_pcow, tableManager, eclipseGrid,
intGridProperties, doubleGridProperties, false );
}
std::vector< double > PCGEndpoint( size_t size, const Deck& deck, const EclipseState& es ) {
const auto max_pcog = findMaxPcog( *es.getTableManager() );
return satnumApply( size, "PCG", max_pcog, deck, es, false );
std::vector< double > PCGEndpoint( size_t size,
const TableManager * tableManager,
const EclipseGrid * eclipseGrid,
GridProperties<int>* intGridProperties,
GridProperties<double>* doubleGridProperties)
{
const auto max_pcog = findMaxPcog( tableManager );
return satnumApply( size, "PCG", max_pcog, tableManager, eclipseGrid,
intGridProperties, doubleGridProperties, false );
}
std::vector< double > IPCGEndpoint( size_t size, const Deck& deck, const EclipseState& es ) {
const auto max_pcog = findMaxPcog( *es.getTableManager() );
return imbnumApply( size, "IPCG", max_pcog, deck, es, false );
std::vector< double > IPCGEndpoint( size_t size,
const TableManager * tableManager,
const EclipseGrid * eclipseGrid,
GridProperties<int>* intGridProperties,
GridProperties<double>* doubleGridProperties)
{
const auto max_pcog = findMaxPcog( tableManager );
return imbnumApply( size, "IPCG", max_pcog, tableManager, eclipseGrid,
intGridProperties, doubleGridProperties, false );
}
std::vector< double > KRWEndpoint( size_t size, const Deck& deck, const EclipseState& es ) {
const auto max_krw = findMaxKrw( *es.getTableManager() );
return satnumApply( size, "KRW", max_krw, deck, es, false );
std::vector< double > KRWEndpoint( size_t size,
const TableManager * tableManager,
const EclipseGrid * eclipseGrid,
GridProperties<int>* intGridProperties,
GridProperties<double>* doubleGridProperties)
{
const auto max_krw = findMaxKrw( tableManager );
return satnumApply( size, "KRW", max_krw, tableManager, eclipseGrid,
intGridProperties, doubleGridProperties, false );
}
std::vector< double > IKRWEndpoint( size_t size, const Deck& deck, const EclipseState& es ) {
const auto krwr = findKrwr( *es.getTableManager() );
return imbnumApply( size, "IKRW", krwr, deck, es, false );
std::vector< double > IKRWEndpoint( size_t size,
const TableManager * tableManager,
const EclipseGrid * eclipseGrid,
GridProperties<int>* intGridProperties,
GridProperties<double>* doubleGridProperties)
{
const auto krwr = findKrwr( tableManager );
return imbnumApply( size, "IKRW", krwr, tableManager, eclipseGrid,
intGridProperties, doubleGridProperties, false );
}
std::vector< double > KRWREndpoint( size_t size, const Deck& deck, const EclipseState& es ) {
const auto krwr = findKrwr( *es.getTableManager() );
return satnumApply( size, "KRWR", krwr, deck, es, false );
std::vector< double > KRWREndpoint( size_t size,
const TableManager * tableManager,
const EclipseGrid * eclipseGrid,
GridProperties<int>* intGridProperties,
GridProperties<double>* doubleGridProperties)
{
const auto krwr = findKrwr( tableManager );
return satnumApply( size, "KRWR", krwr, tableManager, eclipseGrid,
intGridProperties, doubleGridProperties, false );
}
std::vector< double > IKRWREndpoint( size_t size, const Deck& deck, const EclipseState& es ) {
const auto krwr = findKrwr( *es.getTableManager() );
return imbnumApply( size, "IKRWR", krwr, deck, es, false );
std::vector< double > IKRWREndpoint( size_t size,
const TableManager * tableManager,
const EclipseGrid * eclipseGrid,
GridProperties<int>* intGridProperties,
GridProperties<double>* doubleGridProperties)
{
const auto krwr = findKrwr( tableManager );
return imbnumApply( size, "IKRWR", krwr, tableManager, eclipseGrid,
intGridProperties, doubleGridProperties, false );
}
std::vector< double > KROEndpoint( size_t size, const Deck& deck, const EclipseState& es ) {
const auto max_kro = findMaxKro( *es.getTableManager() );
return satnumApply( size, "KRO", max_kro, deck, es, false );
std::vector< double > KROEndpoint( size_t size,
const TableManager * tableManager,
const EclipseGrid * eclipseGrid,
GridProperties<int>* intGridProperties,
GridProperties<double>* doubleGridProperties)
{
const auto max_kro = findMaxKro( tableManager );
return satnumApply( size, "KRO", max_kro, tableManager, eclipseGrid,
intGridProperties, doubleGridProperties, false );
}
std::vector< double > IKROEndpoint( size_t size, const Deck& deck, const EclipseState& es ) {
const auto max_kro = findMaxKro( *es.getTableManager() );
return imbnumApply( size, "IKRO", max_kro, deck, es, false );
std::vector< double > IKROEndpoint( size_t size,
const TableManager * tableManager,
const EclipseGrid * eclipseGrid,
GridProperties<int>* intGridProperties,
GridProperties<double>* doubleGridProperties)
{
const auto max_kro = findMaxKro( tableManager );
return imbnumApply( size, "IKRO", max_kro, tableManager, eclipseGrid,
intGridProperties, doubleGridProperties, false );
}
std::vector< double > KRORWEndpoint( size_t size, const Deck& deck, const EclipseState& es ) {
const auto krorw = findKrorw( *es.getTableManager() );
return satnumApply( size, "KRORW", krorw, deck, es, false );
std::vector< double > KRORWEndpoint( size_t size,
const TableManager * tableManager,
const EclipseGrid * eclipseGrid,
GridProperties<int>* intGridProperties,
GridProperties<double>* doubleGridProperties)
{
const auto krorw = findKrorw( tableManager );
return satnumApply( size, "KRORW", krorw, tableManager, eclipseGrid,
intGridProperties, doubleGridProperties, false );
}
std::vector< double > IKRORWEndpoint( size_t size, const Deck& deck, const EclipseState& es ) {
const auto krorw = findKrorw( *es.getTableManager() );
return imbnumApply( size, "IKRORW", krorw, deck, es, false );
std::vector< double > IKRORWEndpoint( size_t size,
const TableManager * tableManager,
const EclipseGrid * eclipseGrid,
GridProperties<int>* intGridProperties,
GridProperties<double>* doubleGridProperties)
{
const auto krorw = findKrorw( tableManager );
return imbnumApply( size, "IKRORW", krorw, tableManager, eclipseGrid,
intGridProperties, doubleGridProperties, false );
}
std::vector< double > KRORGEndpoint( size_t size, const Deck& deck, const EclipseState& es ) {
const auto krorg = findKrorg( *es.getTableManager() );
return satnumApply( size, "KRORG", krorg, deck, es, false );
std::vector< double > KRORGEndpoint( size_t size,
const TableManager * tableManager,
const EclipseGrid * eclipseGrid,
GridProperties<int>* intGridProperties,
GridProperties<double>* doubleGridProperties)
{
const auto krorg = findKrorg( tableManager );
return satnumApply( size, "KRORG", krorg, tableManager, eclipseGrid,
intGridProperties, doubleGridProperties, false );
}
std::vector< double > IKRORGEndpoint( size_t size, const Deck& deck, const EclipseState& es ) {
const auto krorg = findKrorg( *es.getTableManager() );
return imbnumApply( size, "IKRORG", krorg, deck, es, false );
std::vector< double > IKRORGEndpoint( size_t size,
const TableManager * tableManager,
const EclipseGrid * eclipseGrid,
GridProperties<int>* intGridProperties,
GridProperties<double>* doubleGridProperties)
{
const auto krorg = findKrorg( tableManager );
return imbnumApply( size, "IKRORG", krorg, tableManager, eclipseGrid,
intGridProperties, doubleGridProperties, false );
}
std::vector< double > KRGEndpoint( size_t size, const Deck& deck, const EclipseState& es ) {
const auto max_krg = findMaxKrg( *es.getTableManager() );
return satnumApply( size, "KRG", max_krg, deck, es, false );
std::vector< double > KRGEndpoint( size_t size,
const TableManager * tableManager,
const EclipseGrid * eclipseGrid,
GridProperties<int>* intGridProperties,
GridProperties<double>* doubleGridProperties)
{
const auto max_krg = findMaxKrg( tableManager );
return satnumApply( size, "KRG", max_krg, tableManager, eclipseGrid,
intGridProperties, doubleGridProperties, false );
}
std::vector< double > IKRGEndpoint( size_t size, const Deck& deck, const EclipseState& es ) {
const auto max_krg = findMaxKrg( *es.getTableManager() );
return imbnumApply( size, "IKRG", max_krg, deck, es, false );
std::vector< double > IKRGEndpoint( size_t size,
const TableManager * tableManager,
const EclipseGrid * eclipseGrid,
GridProperties<int>* intGridProperties,
GridProperties<double>* doubleGridProperties)
{
const auto max_krg = findMaxKrg( tableManager );
return imbnumApply( size, "IKRG", max_krg, tableManager, eclipseGrid,
intGridProperties, doubleGridProperties, false );
}
std::vector< double > KRGREndpoint( size_t size, const Deck& deck, const EclipseState& es ) {
const auto krgr = findKrgr( *es.getTableManager() );
return satnumApply( size, "KRGR", krgr, deck, es, false );
std::vector< double > KRGREndpoint( size_t size,
const TableManager * tableManager,
const EclipseGrid * eclipseGrid,
GridProperties<int>* intGridProperties,
GridProperties<double>* doubleGridProperties)
{
const auto krgr = findKrgr( tableManager );
return satnumApply( size, "KRGR", krgr, tableManager, eclipseGrid,
intGridProperties, doubleGridProperties, false );
}
std::vector< double > IKRGREndpoint( size_t size, const Deck& deck, const EclipseState& es ) {
const auto krgr = findKrgr( *es.getTableManager() );
return imbnumApply( size, "IKRGR", krgr, deck, es, false );
std::vector< double > IKRGREndpoint( size_t size,
const TableManager * tableManager,
const EclipseGrid* eclipseGrid,
GridProperties<int>* intGridProperties,
GridProperties<double>* doubleGridProperties)
{
const auto krgr = findKrgr( tableManager );
return imbnumApply( size, "IKRGR", krgr, tableManager, eclipseGrid,
intGridProperties, doubleGridProperties, false );
}
}

View File

@ -22,46 +22,215 @@
#include <vector>
#include <string>
#include <opm/parser/eclipse/EclipseState/Grid/GridProperties.hpp>
namespace Opm {
class Deck;
class EclipseState;
class EclipseGrid;
class TableManager;
std::vector< double > SGLEndpoint( size_t, const Deck&, const EclipseState& );
std::vector< double > ISGLEndpoint( size_t, const Deck&, const EclipseState& );
std::vector< double > SGUEndpoint( size_t, const Deck&, const EclipseState& );
std::vector< double > ISGUEndpoint( size_t, const Deck&, const EclipseState& );
std::vector< double > SWLEndpoint( size_t, const Deck&, const EclipseState& );
std::vector< double > ISWLEndpoint( size_t, const Deck&, const EclipseState& );
std::vector< double > SWUEndpoint( size_t, const Deck&, const EclipseState& );
std::vector< double > ISWUEndpoint( size_t, const Deck&, const EclipseState& );
std::vector< double > SGCREndpoint( size_t, const Deck&, const EclipseState& );
std::vector< double > ISGCREndpoint( size_t, const Deck&, const EclipseState& );
std::vector< double > SOWCREndpoint( size_t, const Deck&, const EclipseState& );
std::vector< double > ISOWCREndpoint( size_t, const Deck&, const EclipseState& );
std::vector< double > SOGCREndpoint( size_t, const Deck&, const EclipseState& );
std::vector< double > ISOGCREndpoint( size_t, const Deck&, const EclipseState& );
std::vector< double > SWCREndpoint( size_t, const Deck&, const EclipseState& );
std::vector< double > ISWCREndpoint( size_t, const Deck&, const EclipseState& );
std::vector< double > PCWEndpoint( size_t, const Deck&, const EclipseState& );
std::vector< double > IPCWEndpoint( size_t, const Deck&, const EclipseState& );
std::vector< double > PCGEndpoint( size_t, const Deck&, const EclipseState& );
std::vector< double > IPCGEndpoint( size_t, const Deck&, const EclipseState& );
std::vector< double > KRWEndpoint( size_t, const Deck&, const EclipseState& );
std::vector< double > IKRWEndpoint( size_t, const Deck&, const EclipseState& );
std::vector< double > KRWREndpoint( size_t, const Deck&, const EclipseState& );
std::vector< double > IKRWREndpoint( size_t, const Deck&, const EclipseState& );
std::vector< double > KROEndpoint( size_t, const Deck&, const EclipseState& );
std::vector< double > IKROEndpoint( size_t, const Deck&, const EclipseState& );
std::vector< double > KRORWEndpoint( size_t, const Deck&, const EclipseState& );
std::vector< double > IKRORWEndpoint( size_t, const Deck&, const EclipseState& );
std::vector< double > KRORGEndpoint( size_t, const Deck&, const EclipseState& );
std::vector< double > IKRORGEndpoint( size_t, const Deck&, const EclipseState& );
std::vector< double > KRGEndpoint( size_t, const Deck&, const EclipseState& );
std::vector< double > IKRGEndpoint( size_t, const Deck&, const EclipseState& );
std::vector< double > KRGREndpoint( size_t, const Deck&, const EclipseState& );
std::vector< double > IKRGREndpoint( size_t, const Deck&, const EclipseState& );
std::vector<double> SGLEndpoint(size_t,
const TableManager*,
const EclipseGrid*,
GridProperties<int>*,
GridProperties<double>*);
std::vector<double> ISGLEndpoint(size_t,
const TableManager*,
const EclipseGrid*,
GridProperties<int>*,
GridProperties<double>*);
std::vector<double> SGUEndpoint(size_t,
const TableManager*,
const EclipseGrid*,
GridProperties<int>*,
GridProperties<double>*);
std::vector<double> ISGUEndpoint(size_t, const TableManager*,
const EclipseGrid*,
GridProperties<int>*,
GridProperties<double>*);
std::vector<double> SWLEndpoint(size_t,
const TableManager*,
const EclipseGrid*,
GridProperties<int>*,
GridProperties<double>*);
std::vector<double> ISWLEndpoint(size_t,
const TableManager*,
const EclipseGrid*,
GridProperties<int>*,
GridProperties<double>*);
std::vector<double> SWUEndpoint(size_t,
const TableManager*,
const EclipseGrid*,
GridProperties<int>*,
GridProperties<double>*);
std::vector<double> ISWUEndpoint(size_t,
const TableManager*,
const EclipseGrid*,
GridProperties<int>*,
GridProperties<double>*);
std::vector<double> SGCREndpoint(size_t,
const TableManager*,
const EclipseGrid*,
GridProperties<int>*,
GridProperties<double>*);
std::vector<double> ISGCREndpoint(size_t,
const TableManager*,
const EclipseGrid*,
GridProperties<int>*,
GridProperties<double>*);
std::vector<double> SOWCREndpoint(size_t,
const TableManager*,
const EclipseGrid*,
GridProperties<int>*,
GridProperties<double>*);
std::vector<double> ISOWCREndpoint(size_t,
const TableManager*,
const EclipseGrid*,
GridProperties<int>*,
GridProperties<double>*);
std::vector<double> SOGCREndpoint(size_t,
const TableManager*,
const EclipseGrid*,
GridProperties<int>*,
GridProperties<double>*);
std::vector<double> ISOGCREndpoint(size_t,
const TableManager*,
const EclipseGrid*,
GridProperties<int>*,
GridProperties<double>*);
std::vector<double> SWCREndpoint(size_t,
const TableManager*,
const EclipseGrid*,
GridProperties<int>*,
GridProperties<double>*);
std::vector<double> ISWCREndpoint(size_t,
const TableManager*,
const EclipseGrid*,
GridProperties<int>*,
GridProperties<double>*);
std::vector<double> PCWEndpoint(size_t,
const TableManager*,
const EclipseGrid*,
GridProperties<int>*,
GridProperties<double>*);
std::vector<double> IPCWEndpoint(size_t,
const TableManager*,
const EclipseGrid*,
GridProperties<int>*,
GridProperties<double>*);
std::vector<double> PCGEndpoint(size_t,
const TableManager*,
const EclipseGrid*,
GridProperties<int>*,
GridProperties<double>*);
std::vector<double> IPCGEndpoint(size_t,
const TableManager*,
const EclipseGrid*,
GridProperties<int>*,
GridProperties<double>*);
std::vector<double> KRWEndpoint(size_t,
const TableManager*,
const EclipseGrid*,
GridProperties<int>*,
GridProperties<double>*);
std::vector<double> IKRWEndpoint(size_t,
const TableManager*,
const EclipseGrid*,
GridProperties<int>*,
GridProperties<double>*);
std::vector<double> KRWREndpoint(size_t,
const TableManager*,
const EclipseGrid*,
GridProperties<int>*,
GridProperties<double>*);
std::vector<double> IKRWREndpoint(size_t,
const TableManager*,
const EclipseGrid*,
GridProperties<int>*,
GridProperties<double>*);
std::vector<double> KROEndpoint(size_t,
const TableManager*,
const EclipseGrid*,
GridProperties<int>*,
GridProperties<double>*);
std::vector<double> IKROEndpoint(size_t,
const TableManager*,
const EclipseGrid*,
GridProperties<int>*,
GridProperties<double>*);
std::vector<double> KRORWEndpoint(size_t,
const TableManager*,
const EclipseGrid*,
GridProperties<int>*,
GridProperties<double>*);
std::vector<double> IKRORWEndpoint(size_t,
const TableManager*,
const EclipseGrid*,
GridProperties<int>*,
GridProperties<double>*);
std::vector<double> KRORGEndpoint(size_t,
const TableManager*,
const EclipseGrid*,
GridProperties<int>*,
GridProperties<double>*);
std::vector<double> IKRORGEndpoint(size_t,
const TableManager*,
const EclipseGrid*,
GridProperties<int>*,
GridProperties<double>*);
std::vector<double> KRGEndpoint(size_t,
const TableManager*,
const EclipseGrid*,
GridProperties<int>*,
GridProperties<double>*);
std::vector<double> IKRGEndpoint(size_t,
const TableManager*,
const EclipseGrid*,
GridProperties<int>*,
GridProperties<double>*);
std::vector<double> KRGREndpoint(size_t,
const TableManager*,
const EclipseGrid*,
GridProperties<int>*,
GridProperties<double>*);
std::vector<double> IKRGREndpoint(size_t,
const TableManager*,
const EclipseGrid*,
GridProperties<int>*,
GridProperties<double>*);
}
#endif
#endif // ECLIPSE_SATFUNCPROPERTY_INITIALIZERS_HPP

View File

@ -64,8 +64,7 @@ namespace Opm {
double TransMult::getMultiplier__(size_t globalIndex, FaceDir::DirEnum faceDir) const {
if (hasDirectionProperty( faceDir )) {
std::shared_ptr<const GridProperty<double> > property = m_trans.at(faceDir);
return property->iget( globalIndex );
return m_trans.at(faceDir).iget( globalIndex );
} else
return 1.0;
}
@ -82,37 +81,31 @@ namespace Opm {
return m_multregtScanner->getRegionMultiplier(globalCellIndex1, globalCellIndex2, faceDir);
}
bool TransMult::hasDirectionProperty(FaceDir::DirEnum faceDir) const {
if (m_trans.count(faceDir) == 1)
return true;
else
return false;
return m_trans.count(faceDir) == 1;
}
void TransMult::insertNewProperty(FaceDir::DirEnum faceDir) {
GridPropertySupportedKeywordInfo<double> kwInfo(m_names[faceDir] , 1.0 , "1");
std::shared_ptr<GridProperty<double> > property = std::make_shared<GridProperty<double> >( m_nx , m_ny , m_nz , kwInfo );
std::pair<FaceDir::DirEnum , std::shared_ptr<GridProperty<double> > > pair(faceDir , property);
m_trans.insert( pair );
GridProperty< double > prop( m_nx, m_ny, m_nz, kwInfo );
m_trans.emplace( faceDir, std::move( prop ) );
}
std::shared_ptr<GridProperty<double> > TransMult::getDirectionProperty(FaceDir::DirEnum faceDir) {
GridProperty<double>& TransMult::getDirectionProperty(FaceDir::DirEnum faceDir) {
if (m_trans.count(faceDir) == 0)
insertNewProperty(faceDir);
return m_trans.at( faceDir );
}
void TransMult::applyMULT(std::shared_ptr<const GridProperty<double> > srcProp, FaceDir::DirEnum faceDir)
void TransMult::applyMULT(const GridProperty<double>& srcProp, FaceDir::DirEnum faceDir)
{
std::shared_ptr<GridProperty<double> > dstProp = getDirectionProperty(faceDir);
auto& dstProp = getDirectionProperty(faceDir);
const std::vector<double> &srcData = srcProp->getData();
const std::vector<double> &srcData = srcProp.getData();
for (size_t i = 0; i < srcData.size(); ++i)
dstProp->multiplyValueAtIndex(i, srcData[i]);
dstProp.multiplyValueAtIndex(i, srcData[i]);
}
@ -122,11 +115,11 @@ namespace Opm {
for (auto face_iter = fault->begin(); face_iter != fault->end(); ++face_iter) {
std::shared_ptr<const FaultFace> face = *face_iter;
FaceDir::DirEnum faceDir = face->getDir();
std::shared_ptr<GridProperty<double> > multProperty = getDirectionProperty(faceDir);
auto& multProperty = getDirectionProperty(faceDir);
for (auto cell_iter = face->begin(); cell_iter != face->end(); ++cell_iter) {
size_t globalIndex = *cell_iter;
multProperty->multiplyValueAtIndex( globalIndex , transMult);
multProperty.multiplyValueAtIndex( globalIndex , transMult);
}
}
}

View File

@ -50,9 +50,7 @@ namespace Opm {
double getMultiplier(size_t globalIndex, FaceDir::DirEnum faceDir) const;
double getMultiplier(size_t i , size_t j , size_t k, FaceDir::DirEnum faceDir) const;
double getRegionMultiplier( size_t globalCellIndex1, size_t globalCellIndex2, FaceDir::DirEnum faceDir) const;
bool hasDirectionProperty(FaceDir::DirEnum faceDir) const;
std::shared_ptr<GridProperty<double> > getDirectionProperty(FaceDir::DirEnum faceDir);
void applyMULT(std::shared_ptr<const GridProperty<double> > srcMultProp, FaceDir::DirEnum faceDir);
void applyMULT(const GridProperty<double>& srcMultProp, FaceDir::DirEnum faceDir);
void applyMULTFLT( std::shared_ptr<const FaultCollection> faults);
void applyMULTFLT( std::shared_ptr<const Fault> fault);
void setMultregtScanner(std::shared_ptr<const MULTREGTScanner> multregtScanner);
@ -62,9 +60,11 @@ namespace Opm {
void assertIJK(size_t i , size_t j , size_t k) const;
double getMultiplier__(size_t globalIndex , FaceDir::DirEnum faceDir) const;
void insertNewProperty(FaceDir::DirEnum faceDir);
bool hasDirectionProperty(FaceDir::DirEnum faceDir) const;
GridProperty<double>& getDirectionProperty(FaceDir::DirEnum faceDir);
size_t m_nx , m_ny , m_nz;
std::map<FaceDir::DirEnum , std::shared_ptr<GridProperty<double> > > m_trans;
std::map<FaceDir::DirEnum , GridProperty<double> > m_trans;
std::map<FaceDir::DirEnum , std::string> m_names;
std::shared_ptr<const MULTREGTScanner> m_multregtScanner;
};

View File

@ -35,9 +35,10 @@
#include <opm/parser/eclipse/Deck/Deck.hpp>
#include <opm/parser/eclipse/Deck/DeckKeyword.hpp>
#include <opm/parser/eclipse/EclipseState/Eclipse3DProperties.hpp>
#include <opm/parser/eclipse/EclipseState/EclipseState.hpp>
#include <opm/parser/eclipse/EclipseState/Grid/EclipseGrid.hpp>
#include <opm/parser/eclipse/EclipseState/Grid/GridProperty.hpp>
#include <opm/parser/eclipse/EclipseState/EclipseState.hpp>
static Opm::DeckPtr createDeckInvalidArray() {
@ -249,13 +250,13 @@ BOOST_AUTO_TEST_CASE(UnInitializedVectorThrows) {
BOOST_AUTO_TEST_CASE(IntSetCorrectly) {
Opm::DeckPtr deck = createValidIntDeck();
Opm::EclipseState state(deck , Opm::ParseContext());
std::shared_ptr<const Opm::GridProperty<int> > property = state.getIntGridProperty( "SATNUM");
const auto& property = state.getEclipseProperties().getIntGridProperty( "SATNUM");
for (size_t j=0; j< 5; j++)
for (size_t i = 0; i < 5; i++) {
if (i < 2)
BOOST_CHECK_EQUAL( 12 , property->iget(i,j,0));
BOOST_CHECK_EQUAL( 12 , property.iget(i,j,0));
else
BOOST_CHECK_EQUAL( 21 , property->iget(i,j,0));
BOOST_CHECK_EQUAL( 21 , property.iget(i,j,0));
}
}
@ -263,14 +264,15 @@ BOOST_AUTO_TEST_CASE(IntSetCorrectly) {
BOOST_AUTO_TEST_CASE(UnitAppliedCorrectly) {
Opm::DeckPtr deck = createValidPERMXDeck();
Opm::EclipseState state(deck , Opm::ParseContext());
std::shared_ptr<const Opm::GridProperty<double> > permx = state.getDoubleGridProperty( "PERMX");
const Opm::EclipseState state( deck, Opm::ParseContext() );
const auto& props = state.getEclipseProperties();
const auto& permx = props.getDoubleGridProperty( "PERMX");
for (size_t j=0; j< 5; j++)
for (size_t i = 0; i < 5; i++) {
if (i < 2)
BOOST_CHECK_EQUAL( 2 * Opm::Metric::Permeability , permx->iget(i,j,0));
BOOST_CHECK_CLOSE( 2 * Opm::Metric::Permeability , permx.iget(i,j,0), 0.0001);
else
BOOST_CHECK_EQUAL( 4 * Opm::Metric::Permeability , permx->iget(i,j,0));
BOOST_CHECK_CLOSE( 4 * Opm::Metric::Permeability , permx.iget(i,j,0), 0.0001);
}
}

View File

@ -34,9 +34,11 @@
#include <opm/parser/eclipse/Deck/Deck.hpp>
#include <opm/parser/eclipse/Deck/DeckKeyword.hpp>
#include <opm/parser/eclipse/EclipseState/Eclipse3DProperties.hpp>
#include <opm/parser/eclipse/EclipseState/EclipseState.hpp>
#include <opm/parser/eclipse/EclipseState/Grid/EclipseGrid.hpp>
#include <opm/parser/eclipse/EclipseState/Grid/GridProperty.hpp>
#include <opm/parser/eclipse/EclipseState/EclipseState.hpp>
static Opm::DeckPtr createDeckInvalidArray1() {
@ -196,26 +198,20 @@ 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() );
std::shared_ptr<const Opm::GridProperty<int> > property = state.getIntGridProperty( "FLUXNUM");
auto& property = state.getEclipseProperties().getIntGridProperty("FLUXNUM");
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

@ -34,9 +34,10 @@
#include <opm/parser/eclipse/Deck/Deck.hpp>
#include <opm/parser/eclipse/Deck/DeckKeyword.hpp>
#include <opm/parser/eclipse/EclipseState/Eclipse3DProperties.hpp>
#include <opm/parser/eclipse/EclipseState/EclipseState.hpp>
#include <opm/parser/eclipse/EclipseState/Grid/EclipseGrid.hpp>
#include <opm/parser/eclipse/EclipseState/Grid/GridProperty.hpp>
#include <opm/parser/eclipse/EclipseState/EclipseState.hpp>
static Opm::DeckPtr createDeckInvalidArray() {
@ -202,42 +203,40 @@ 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());
std::shared_ptr<const Opm::GridProperty<int> > property = state.getIntGridProperty( "SATNUM");
auto& property = state.getEclipseProperties().getIntGridProperty("SATNUM");
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));
}
}
BOOST_AUTO_TEST_CASE(UnitAppliedCorrectly) {
Opm::DeckPtr deck = createValidPERMXDeck();
Opm::EclipseState state(deck, Opm::ParseContext());
std::shared_ptr<const Opm::GridProperty<double> > permx = state.getDoubleGridProperty( "PERMX");
std::shared_ptr<const Opm::GridProperty<double> > permy = state.getDoubleGridProperty( "PERMY");
std::shared_ptr<const Opm::GridProperty<double> > permz = state.getDoubleGridProperty( "PERMZ");
const auto& props = state.getEclipseProperties();
const auto& permx = props.getDoubleGridProperty("PERMX");
const auto& permy = props.getDoubleGridProperty("PERMY");
const auto& permz = props.getDoubleGridProperty("PERMZ");
for (size_t g = 0; g < 25; g++) {
BOOST_CHECK_EQUAL( permz->iget(g), permx->iget(g));
BOOST_CHECK_EQUAL( permy->iget(g), permx->iget(g));
BOOST_CHECK_EQUAL(permz.iget(g), permx.iget(g));
BOOST_CHECK_EQUAL(permy.iget(g), permx.iget(g));
}
}

View File

@ -28,13 +28,14 @@
#include <boost/date_time/posix_time/posix_time.hpp>
#include <opm/common/utility/platform_dependent/reenable_warnings.h>
#include <opm/parser/eclipse/Parser/Parser.hpp>
#include <opm/parser/eclipse/Deck/Section.hpp>
#include <opm/parser/eclipse/Deck/Deck.hpp>
#include <opm/parser/eclipse/Deck/DeckKeyword.hpp>
#include <opm/parser/eclipse/EclipseState/Eclipse3DProperties.hpp>
#include <opm/parser/eclipse/EclipseState/EclipseState.hpp>
#include <opm/parser/eclipse/EclipseState/Grid/GridProperties.hpp>
@ -45,7 +46,7 @@ BOOST_AUTO_TEST_CASE(Empty) {
SupportedKeywordInfo("FIPNUM" , 2, "1")
};
std::shared_ptr<const Opm::EclipseGrid> grid = std::make_shared<const Opm::EclipseGrid>(10,7,9);
const Opm::EclipseGrid grid(10, 7, 9);
Opm::GridProperties<int> gridProperties(grid, std::move(supportedKeywords));
BOOST_CHECK( gridProperties.supportsKeyword("SATNUM") );
@ -65,7 +66,7 @@ BOOST_AUTO_TEST_CASE(addKeyword) {
std::vector<SupportedKeywordInfo> supportedKeywords = {
SupportedKeywordInfo("SATNUM" , 0, "1")
};
std::shared_ptr<const Opm::EclipseGrid> grid = std::make_shared<const Opm::EclipseGrid>(10,7,9);
Opm::EclipseGrid grid(10, 7, 9);
Opm::GridProperties<int> gridProperties(grid, std::move(supportedKeywords));
BOOST_CHECK_THROW(gridProperties.addKeyword("NOT-SUPPORTED"), std::invalid_argument);
@ -81,7 +82,7 @@ BOOST_AUTO_TEST_CASE(hasKeyword) {
std::vector<SupportedKeywordInfo> supportedKeywords = {
SupportedKeywordInfo("SATNUM" , 0, "1")
};
std::shared_ptr<const Opm::EclipseGrid> grid = std::make_shared<const Opm::EclipseGrid>(10,7,9);
const Opm::EclipseGrid grid(10, 7, 9);
Opm::GridProperties<int> gridProperties(grid, std::move(supportedKeywords));
// calling getKeyword() should not change the semantics of hasKeyword()!
@ -96,15 +97,16 @@ BOOST_AUTO_TEST_CASE(getKeyword) {
std::vector<SupportedKeywordInfo> supportedKeywords = {
SupportedKeywordInfo("SATNUM" , 0, "1")
};
std::shared_ptr<const Opm::EclipseGrid> grid = std::make_shared<const Opm::EclipseGrid>(10,7,9);
const Opm::EclipseGrid grid(10, 7, 9);
Opm::GridProperties<int> gridProperties( grid, std::move( supportedKeywords ) );
std::shared_ptr<Opm::GridProperty<int> > satnum1 = gridProperties.getKeyword("SATNUM");
std::shared_ptr<Opm::GridProperty<int> > satnum2 = gridProperties.getKeyword("SATNUM");
std::shared_ptr<Opm::GridProperty<int> > satnum3 = gridProperties.getKeyword(0);
const Opm::GridProperty<int>& satnum1 = gridProperties.getKeyword( "SATNUM" );
const Opm::GridProperty<int>& satnum2 = gridProperties.getKeyword( "SATNUM" );
const Opm::GridProperty<int>& satnum3 = gridProperties.getKeyword( size_t( 0 ) );
BOOST_CHECK_EQUAL( 1, gridProperties.size() );
BOOST_CHECK_EQUAL( satnum1.get() , satnum2.get());
BOOST_CHECK_EQUAL( satnum1.get() , satnum3.get());
BOOST_CHECK_EQUAL( &satnum1, &satnum2 );
BOOST_CHECK_EQUAL( &satnum1, &satnum3 );
BOOST_CHECK_THROW( gridProperties.getKeyword( "NOT-SUPPORTED" ), std::invalid_argument );
BOOST_CHECK_THROW( gridProperties.getKeyword( 3 ), std::invalid_argument );
}

View File

@ -37,9 +37,12 @@
#include <opm/parser/eclipse/Deck/Section.hpp>
#include <opm/parser/eclipse/Deck/Deck.hpp>
#include <opm/parser/eclipse/Deck/DeckKeyword.hpp>
#include <opm/parser/eclipse/EclipseState/Eclipse3DProperties.hpp>
#include <opm/parser/eclipse/EclipseState/EclipseState.hpp>
#include <opm/parser/eclipse/EclipseState/Grid/Box.hpp>
#include <opm/parser/eclipse/EclipseState/Grid/GridProperties.hpp>
#include <opm/parser/eclipse/EclipseState/Grid/GridProperty.hpp>
#include <opm/parser/eclipse/EclipseState/Tables/TableManager.hpp>
static const Opm::DeckKeyword createSATNUMKeyword( ) {
const char *deckData =
@ -154,7 +157,6 @@ BOOST_AUTO_TEST_CASE(SetFromDeckKeyword) {
}
}
BOOST_AUTO_TEST_CASE(copy) {
typedef Opm::GridProperty<int>::SupportedKeywordInfo SupportedKeywordInfo;
SupportedKeywordInfo keywordInfo1("P1", 0, "1");
@ -163,7 +165,7 @@ BOOST_AUTO_TEST_CASE(copy) {
Opm::GridProperty<int> prop2(4, 4, 2, keywordInfo2);
Opm::Box global(4, 4, 2);
std::shared_ptr<Opm::Box> layer0 = std::make_shared<Opm::Box>(global , 0,3,0,3,0,0);
Opm::Box layer0(global, 0, 3, 0, 3, 0, 0);
prop2.copyFrom(prop1, layer0);
@ -185,8 +187,8 @@ BOOST_AUTO_TEST_CASE(SCALE) {
Opm::GridProperty<int> prop1( 4, 4, 2, keywordInfo1 );
Opm::GridProperty<int> prop2( 4, 4, 2, keywordInfo2 );
std::shared_ptr<Opm::Box> global = std::make_shared<Opm::Box>(4,4,2);
std::shared_ptr<Opm::Box> layer0 = std::make_shared<Opm::Box>(*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.scale( 2, global );
@ -201,14 +203,13 @@ BOOST_AUTO_TEST_CASE(SCALE) {
}
}
BOOST_AUTO_TEST_CASE(SET) {
typedef Opm::GridProperty<int>::SupportedKeywordInfo SupportedKeywordInfo;
SupportedKeywordInfo keywordInfo( "P1", 1, "1" );
Opm::GridProperty<int> prop( 4, 4, 2, keywordInfo );
std::shared_ptr<Opm::Box> global = std::make_shared<Opm::Box>(4,4,2);
std::shared_ptr<Opm::Box> layer0 = std::make_shared<Opm::Box>(*global , 0,3,0,3,0,0);
Opm::Box global( 4, 4, 2 );
Opm::Box layer0( global, 0, 3, 0, 3, 0, 0 );
prop.setScalar( 2, global );
prop.setScalar( 4, layer0 );
@ -222,7 +223,6 @@ BOOST_AUTO_TEST_CASE(SET) {
}
}
BOOST_AUTO_TEST_CASE(ADD) {
typedef Opm::GridProperty<int>::SupportedKeywordInfo SupportedKeywordInfo;
SupportedKeywordInfo keywordInfo1( "P1", 1, "1" );
@ -230,8 +230,8 @@ BOOST_AUTO_TEST_CASE(ADD) {
Opm::GridProperty<int> prop1( 4, 4, 2, keywordInfo1 );
Opm::GridProperty<int> prop2( 4, 4, 2, keywordInfo2 );
std::shared_ptr<Opm::Box> global = std::make_shared<Opm::Box>(4,4,2);
std::shared_ptr<Opm::Box> layer0 = std::make_shared<Opm::Box>(*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.add( 2, global );
@ -353,38 +353,44 @@ BOOST_AUTO_TEST_CASE(GridPropertyInitialization) {
auto deck = parser->parseString(deckString, parseContext);
auto eclipseState = std::make_shared<Opm::EclipseState>(deck , parseContext);
Opm::EclipseState eclipseState(deck, parseContext);
const auto& props = eclipseState.getEclipseProperties();
// make sure that EclipseState throws if it is bugged about an _unsupported_ keyword
BOOST_CHECK_THROW(eclipseState->hasDeckIntGridProperty("ISWU"), std::logic_error);
BOOST_CHECK_THROW(eclipseState->hasDeckDoubleGridProperty("FLUXNUM"), std::logic_error);
BOOST_CHECK_THROW(props.hasDeckIntGridProperty("ISWU"), std::logic_error);
BOOST_CHECK_THROW(props.hasDeckDoubleGridProperty("FLUXNUM"), std::logic_error);
// make sure that EclipseState does not throw if it is asked for a supported grid
// property that is not contained in the deck
BOOST_CHECK(!eclipseState->hasDeckDoubleGridProperty("ISWU"));
BOOST_CHECK(!eclipseState->hasDeckIntGridProperty("FLUXNUM"));
// make sure that EclipseState does not throw if it is asked for a supported
// grid property that is not contained in the deck
BOOST_CHECK(!props.hasDeckDoubleGridProperty("ISWU"));
BOOST_CHECK(!props.hasDeckIntGridProperty("FLUXNUM"));
BOOST_CHECK(eclipseState->hasDeckIntGridProperty("SATNUM"));
BOOST_CHECK(eclipseState->hasDeckIntGridProperty("IMBNUM"));
BOOST_CHECK(props.hasDeckIntGridProperty("SATNUM"));
BOOST_CHECK(props.hasDeckIntGridProperty("IMBNUM"));
BOOST_CHECK(eclipseState->hasDeckDoubleGridProperty("SWU"));
BOOST_CHECK(eclipseState->hasDeckDoubleGridProperty("ISGU"));
BOOST_CHECK(eclipseState->hasDeckDoubleGridProperty("SGCR"));
BOOST_CHECK(eclipseState->hasDeckDoubleGridProperty("ISGCR"));
BOOST_CHECK(props.hasDeckDoubleGridProperty("SWU"));
BOOST_CHECK(props.hasDeckDoubleGridProperty("ISGU"));
BOOST_CHECK(props.hasDeckDoubleGridProperty("SGCR"));
BOOST_CHECK(props.hasDeckDoubleGridProperty("ISGCR"));
const auto& swuPropData = eclipseState->getDoubleGridProperty("SWU")->getData();
const auto& swuPropData = props.getDoubleGridProperty("SWU").getData();
BOOST_CHECK_EQUAL(swuPropData[0 * 3*3], 0.93);
BOOST_CHECK_EQUAL(swuPropData[1 * 3*3], 0.852);
BOOST_CHECK_EQUAL(swuPropData[2 * 3*3], 0.801);
const auto& sguPropData = eclipseState->getDoubleGridProperty("ISGU")->getData();
const auto& sguPropData = props.getDoubleGridProperty("ISGU").getData();
BOOST_CHECK_EQUAL(sguPropData[0 * 3*3], 0.9);
BOOST_CHECK_EQUAL(sguPropData[1 * 3*3], 0.85);
BOOST_CHECK_EQUAL(sguPropData[2 * 3*3], 0.80);
}
void TestPostProcessorMul(std::vector< double >& values, const Opm::Deck&, const Opm::EclipseState& ) {
void TestPostProcessorMul(std::vector< double >& values,
const Opm::TableManager*,
const Opm::EclipseGrid*,
Opm::GridProperties<int>*,
Opm::GridProperties<double>*)
{
for( size_t g = 0; g < values.size(); g++ )
values[g] *= 2.0;
}
@ -421,39 +427,44 @@ BOOST_AUTO_TEST_CASE(GridPropertyPostProcessors) {
typedef Opm::GridPropertySupportedKeywordInfo<double> SupportedKeywordInfo;
Opm::DeckPtr deck = createDeck();
Opm::EclipseState st( deck, Opm::ParseContext() ) ;
std::shared_ptr<Opm::EclipseGrid> grid = std::make_shared<Opm::EclipseGrid>(deck);
Opm::EclipseGrid grid(deck);
std::shared_ptr<Opm::TableManager> tm = std::make_shared<Opm::TableManager>(*deck);
Opm::Eclipse3DProperties props(*deck, tm, grid);
SupportedKeywordInfo kwInfo1("MULTPV" , 1.0 , "1");
Opm::GridPropertyPostFunction< double > gfunc( &TestPostProcessorMul, *deck, st );
Opm::GridPropertyPostFunction< double > gfunc( &TestPostProcessorMul,
tm.get(),
&grid,
&props.getIntGridProperties(),
&props.getDoubleGridProperties() );
SupportedKeywordInfo kwInfo2("PORO", 1.0, gfunc, "1");
std::vector<SupportedKeywordInfo > supportedKeywords = { kwInfo1, kwInfo2 };
Opm::GridProperties<double> properties(grid, std::move( supportedKeywords ) );
{
auto poro = properties.getKeyword("PORO");
auto multpv = properties.getKeyword("MULTPV");
auto& poro = properties.getKeyword("PORO");
auto& multpv = properties.getKeyword("MULTPV");
poro->loadFromDeckKeyword( deck->getKeyword("PORO" , 0));
multpv->loadFromDeckKeyword( deck->getKeyword("MULTPV" , 0));
poro.loadFromDeckKeyword( deck->getKeyword("PORO" , 0));
multpv.loadFromDeckKeyword( deck->getKeyword("MULTPV" , 0));
poro->runPostProcessor();
multpv->runPostProcessor();
poro.runPostProcessor();
multpv.runPostProcessor();
for (size_t g = 0; g < 1000; g++) {
BOOST_CHECK_EQUAL( multpv->iget(g) , 0.10 );
BOOST_CHECK_EQUAL( poro->iget(g) , 0.20 );
BOOST_CHECK_EQUAL( multpv.iget(g) , 0.10 );
BOOST_CHECK_EQUAL( poro.iget(g) , 0.20 );
}
poro->runPostProcessor();
multpv->runPostProcessor();
poro.runPostProcessor();
multpv.runPostProcessor();
for (size_t g = 0; g < 1000; g++) {
BOOST_CHECK_EQUAL( multpv->iget(g) , 0.10 );
BOOST_CHECK_EQUAL( poro->iget(g) , 0.20 );
BOOST_CHECK_EQUAL( multpv.iget(g) , 0.10 );
BOOST_CHECK_EQUAL( poro.iget(g) , 0.20 );
}
}
}

View File

@ -32,7 +32,9 @@
#include <opm/parser/eclipse/Deck/Deck.hpp>
#include <opm/parser/eclipse/Deck/DeckKeyword.hpp>
#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>
@ -109,8 +111,8 @@ BOOST_AUTO_TEST_CASE(InvalidInput) {
Opm::DeckPtr deck = createInvalidMULTREGTDeck();
std::shared_ptr<Opm::EclipseGrid> grid = std::make_shared<Opm::EclipseGrid>( deck );
std::shared_ptr<Opm::GridProperties<int> > gridProperties = std::make_shared<Opm::GridProperties<int> >(grid, std::move( supportedKeywords ) );
Opm::EclipseGrid grid( deck );
Opm::GridProperties<int> gridProperties( grid, std::move( supportedKeywords ) );
// Invalid direction
std::vector<const Opm::DeckKeyword*> keywords0;
@ -176,8 +178,8 @@ BOOST_AUTO_TEST_CASE(NotSupported) {
};
Opm::DeckPtr deck = createNotSupportedMULTREGTDeck();
std::shared_ptr<Opm::EclipseGrid> grid = std::make_shared<Opm::EclipseGrid>( deck );
std::shared_ptr<Opm::GridProperties<int> > gridProperties = std::make_shared<Opm::GridProperties<int> >(grid, std::move( supportedKeywords ) );
Opm::EclipseGrid grid( deck );
Opm::GridProperties<int> gridProperties( grid, std::move( supportedKeywords ) );
// Not support NOAQUNNC behaviour
std::vector<const Opm::DeckKeyword*> keywords0;
@ -197,13 +199,11 @@ BOOST_AUTO_TEST_CASE(NotSupported) {
keywords2.push_back( &multregtKeyword2 );
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 );
keywords3.push_back( &multregtKeyword3 );
BOOST_CHECK_THROW( Opm::MULTREGTScanner scanner( gridProperties, keywords3, "MULTNUM" ); , std::invalid_argument );
}
static Opm::DeckPtr createCopyMULTNUMDeck() {
@ -232,8 +232,6 @@ 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,18 +25,16 @@
#define BOOST_TEST_MODULE MultiRegTests
#include <boost/test/unit_test.hpp>
#include <boost/date_time/posix_time/posix_time.hpp>
#include <opm/parser/eclipse/Parser/Parser.hpp>
#include <opm/parser/eclipse/Parser/ParseContext.hpp>
#include <opm/parser/eclipse/Deck/Section.hpp>
#include <opm/parser/eclipse/Deck/Deck.hpp>
#include <opm/parser/eclipse/Deck/DeckKeyword.hpp>
#include <opm/parser/eclipse/EclipseState/Eclipse3DProperties.hpp>
#include <opm/parser/eclipse/EclipseState/EclipseState.hpp>
#include <opm/parser/eclipse/EclipseState/Grid/EclipseGrid.hpp>
#include <opm/parser/eclipse/EclipseState/Grid/GridProperty.hpp>
#include <opm/parser/eclipse/EclipseState/EclipseState.hpp>
static Opm::DeckPtr createDeckInvalidArray() {
@ -201,25 +199,20 @@ BOOST_AUTO_TEST_CASE(MissingRegionVectorThrows) {
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());
std::shared_ptr<const Opm::GridProperty<int> > property = state.getIntGridProperty( "SATNUM");
const auto& property = state.getEclipseProperties().getIntGridProperty("SATNUM");
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( 40 , property->iget(i,j,0));
BOOST_CHECK_EQUAL(40, property.iget(i, j, 0));
}
}

View File

@ -32,6 +32,7 @@
#include <opm/parser/eclipse/Deck/Section.hpp>
#include <opm/parser/eclipse/Deck/Deck.hpp>
#include <opm/parser/eclipse/Deck/DeckKeyword.hpp>
#include <opm/parser/eclipse/EclipseState/Eclipse3DProperties.hpp>
#include <opm/parser/eclipse/EclipseState/EclipseState.hpp>
#include <opm/parser/eclipse/EclipseState/Grid/GridProperty.hpp>
@ -228,97 +229,103 @@ static Opm::DeckPtr createDeckWithNTG() {
BOOST_AUTO_TEST_CASE(PORV_cartesianDeck) {
/* Check that an exception is raised if we try to create a PORV field without PORO. */
Opm::DeckPtr deck = createCARTDeck();
auto state = std::make_shared<Opm::EclipseState>(deck , Opm::ParseContext());
auto poro = state->getDoubleGridProperty("PORO");
BOOST_CHECK( poro->containsNaN() );
BOOST_CHECK_THROW( state->getDoubleGridProperty("PORV") , std::logic_error );
Opm::EclipseState state(deck, Opm::ParseContext());
const auto& props = state.getEclipseProperties();
const auto& poro = props.getDoubleGridProperty("PORO");
BOOST_CHECK(poro.containsNaN());
BOOST_CHECK_THROW(props.getDoubleGridProperty("PORV"), std::logic_error);
}
BOOST_AUTO_TEST_CASE(PORV_initFromPoro) {
/* Check that the PORV field is correctly calculated from PORO. */
Opm::DeckPtr deck = createDeckWithPORO();
auto state = std::make_shared<Opm::EclipseState>(deck , Opm::ParseContext());
auto poro = state->getDoubleGridProperty("PORO");
BOOST_CHECK( !poro->containsNaN() );
Opm::EclipseState state(deck, Opm::ParseContext());
const auto& props = state.getEclipseProperties();
const auto& poro = props.getDoubleGridProperty("PORO");
BOOST_CHECK( !poro.containsNaN() );
auto porv = state->getDoubleGridProperty("PORV");
const auto& porv = props.getDoubleGridProperty("PORV");
double cell_volume = 0.25 * 0.25 * 0.25;
BOOST_CHECK_CLOSE( cell_volume * 0.10 , porv->iget(0,0,0) , 0.001);
BOOST_CHECK_CLOSE( cell_volume * 0.10 , porv->iget(9,9,0) , 0.001);
BOOST_CHECK_CLOSE( cell_volume * 0.10 , porv.iget(0,0,0) , 0.001);
BOOST_CHECK_CLOSE( cell_volume * 0.10 , porv.iget(9,9,0) , 0.001);
BOOST_CHECK_CLOSE( cell_volume * 0.50 , porv->iget(0,0,4) , 0.001);
BOOST_CHECK_CLOSE( cell_volume * 0.50 , porv->iget(9,9,4) , 0.001);
BOOST_CHECK_CLOSE( cell_volume * 0.50 , porv.iget(0,0,4) , 0.001);
BOOST_CHECK_CLOSE( cell_volume * 0.50 , porv.iget(9,9,4) , 0.001);
BOOST_CHECK_CLOSE( cell_volume * 1.00 , porv->iget(0,0,9) , 0.001);
BOOST_CHECK_CLOSE( cell_volume * 1.00 , porv->iget(9,9,9) , 0.001);
BOOST_CHECK_CLOSE( cell_volume * 1.00 , porv.iget(0,0,9) , 0.001);
BOOST_CHECK_CLOSE( cell_volume * 1.00 , porv.iget(9,9,9) , 0.001);
}
BOOST_AUTO_TEST_CASE(PORV_initFromPoroWithCellVolume) {
/* Check that explicit PORV and CellVOlume * PORO can be combined. */
Opm::DeckPtr deck = createDeckWithPORVPORO();
auto state = std::make_shared<Opm::EclipseState>(deck, Opm::ParseContext());
auto porv = state->getDoubleGridProperty("PORV");
Opm::EclipseState state(deck, Opm::ParseContext());
const auto& props = state.getEclipseProperties();
const auto& porv = props.getDoubleGridProperty("PORV");
double cell_volume = 0.25 * 0.25 * 0.25;
BOOST_CHECK_CLOSE( 77.0 , porv->iget(0,0,0) , 0.001);
BOOST_CHECK_CLOSE( 77.0 , porv->iget(9,9,0) , 0.001);
BOOST_CHECK_CLOSE( 77.0 , porv.iget(0,0,0) , 0.001);
BOOST_CHECK_CLOSE( 77.0 , porv.iget(9,9,0) , 0.001);
BOOST_CHECK_CLOSE( cell_volume * 0.50 , porv->iget(0,0,4) , 0.001);
BOOST_CHECK_CLOSE( cell_volume * 0.50 , porv->iget(9,9,4) , 0.001);
BOOST_CHECK_CLOSE( cell_volume * 0.50 , porv.iget(0,0,4) , 0.001);
BOOST_CHECK_CLOSE( cell_volume * 0.50 , porv.iget(9,9,4) , 0.001);
BOOST_CHECK_CLOSE( cell_volume * 1.00 , porv->iget(0,0,9) , 0.001);
BOOST_CHECK_CLOSE( cell_volume * 1.00 , porv->iget(9,9,9) , 0.001);
BOOST_CHECK_CLOSE( cell_volume * 1.00 , porv.iget(0,0,9) , 0.001);
BOOST_CHECK_CLOSE( cell_volume * 1.00 , porv.iget(9,9,9) , 0.001);
}
BOOST_AUTO_TEST_CASE(PORV_multpv) {
/* Check that MULTPV is correctly accounted for. */
Opm::DeckPtr deck = createDeckWithMULTPV();
auto state = std::make_shared<Opm::EclipseState>(deck , Opm::ParseContext());
auto porv = state->getDoubleGridProperty("PORV");
Opm::EclipseState state(deck, Opm::ParseContext());
const auto& props = state.getEclipseProperties();
const auto& porv = props.getDoubleGridProperty("PORV");
double cell_volume = 0.25 * 0.25 * 0.25;
BOOST_CHECK_CLOSE( 770.0 , porv->iget(0,0,0) , 0.001);
BOOST_CHECK_CLOSE( 770.0 , porv->iget(4,4,0) , 0.001);
BOOST_CHECK_CLOSE( 77.0 , porv->iget(9,9,0) , 0.001);
BOOST_CHECK_CLOSE( 770.0 , porv.iget(0,0,0) , 0.001);
BOOST_CHECK_CLOSE( 770.0 , porv.iget(4,4,0) , 0.001);
BOOST_CHECK_CLOSE( 77.0 , porv.iget(9,9,0) , 0.001);
BOOST_CHECK_CLOSE( cell_volume * 0.50 , porv->iget(0,0,4) , 0.001);
BOOST_CHECK_CLOSE( cell_volume * 0.50 , porv->iget(9,9,4) , 0.001);
BOOST_CHECK_CLOSE( cell_volume * 0.50 , porv.iget(0,0,4) , 0.001);
BOOST_CHECK_CLOSE( cell_volume * 0.50 , porv.iget(9,9,4) , 0.001);
BOOST_CHECK_CLOSE( cell_volume * 0.90 , porv->iget(0,0,8) , 0.001);
BOOST_CHECK_CLOSE( cell_volume * 0.90 , porv->iget(9,9,8) , 0.001);
BOOST_CHECK_CLOSE( cell_volume * 0.90 , porv.iget(0,0,8) , 0.001);
BOOST_CHECK_CLOSE( cell_volume * 0.90 , porv.iget(9,9,8) , 0.001);
BOOST_CHECK_CLOSE( cell_volume * 10.00 , porv->iget(0,0,9) , 0.001);
BOOST_CHECK_CLOSE( cell_volume * 10.00 , porv->iget(9,9,9) , 0.001);
BOOST_CHECK_CLOSE( cell_volume * 10.00 , porv.iget(0,0,9) , 0.001);
BOOST_CHECK_CLOSE( cell_volume * 10.00 , porv.iget(9,9,9) , 0.001);
}
BOOST_AUTO_TEST_CASE(PORV_mutipleBoxAndMultpv) {
/* Check that MULTIPLE Boxed PORV and MULTPV statements work */
Opm::DeckPtr deck = createDeckWithBOXPORV();
auto state = std::make_shared<Opm::EclipseState>(deck , Opm::ParseContext());
auto porv = state->getDoubleGridProperty("PORV");
Opm::EclipseState state(deck, Opm::ParseContext());
const auto& props = state.getEclipseProperties();
const auto& porv = props.getDoubleGridProperty("PORV");
BOOST_CHECK_CLOSE( 1234.56 , porv->iget(0,0,0) , 0.001);
BOOST_CHECK_CLOSE( 1234.56 , porv->iget(9,9,9) , 0.001);
BOOST_CHECK_CLOSE( 1234.56 , porv.iget(0,0,0) , 0.001);
BOOST_CHECK_CLOSE( 1234.56 , porv.iget(9,9,9) , 0.001);
BOOST_CHECK_CLOSE( 7890.12 , porv->iget(1,1,1) , 0.001);
BOOST_CHECK_CLOSE( 7890.12 , porv->iget(2,2,2) , 0.001);
BOOST_CHECK_CLOSE( 7890.12 , porv.iget(1,1,1) , 0.001);
BOOST_CHECK_CLOSE( 7890.12 , porv.iget(2,2,2) , 0.001);
}
BOOST_AUTO_TEST_CASE(PORV_multpvAndNtg) {
/* Check that MULTIPLE Boxed PORV and MULTPV statements work and NTG */
Opm::DeckPtr deck = createDeckWithNTG();
auto state = std::make_shared<Opm::EclipseState>(deck , Opm::ParseContext());
auto porv = state->getDoubleGridProperty("PORV");
Opm::EclipseState state(deck, Opm::ParseContext());
const auto& props = state.getEclipseProperties();
const auto& porv = props.getDoubleGridProperty("PORV");
double cell_volume = 0.25 * 0.25 * 0.25;
double poro = 0.20;
double multpv = 10;
double NTG = 2;
double PORV = 10;
BOOST_CHECK_CLOSE( PORV * multpv , porv->iget(0,0,0) , 0.001);
BOOST_CHECK_CLOSE( cell_volume * poro*multpv*NTG , porv->iget(9,9,9) , 0.001);
BOOST_CHECK_CLOSE( PORV * multpv , porv.iget(0,0,0) , 0.001);
BOOST_CHECK_CLOSE( cell_volume * poro*multpv*NTG , porv.iget(9,9,9) , 0.001);
}
@ -343,6 +350,7 @@ static Opm::DeckPtr createDeckNakedGRID() {
BOOST_AUTO_TEST_CASE(NAKED_GRID_THROWS) {
/* Check that MULTIPLE Boxed PORV and MULTPV statements work and NTG */
Opm::DeckPtr deck = createDeckNakedGRID();
auto state = std::make_shared<Opm::EclipseState>(deck , Opm::ParseContext());
BOOST_CHECK_THROW( state->getDoubleGridProperty("PORV") , std::invalid_argument );
Opm::EclipseState state(deck, Opm::ParseContext());
const auto& props = state.getEclipseProperties();
BOOST_CHECK_THROW( props.getDoubleGridProperty("PORV") , std::invalid_argument );
}

View File

@ -26,6 +26,7 @@
#include <boost/test/unit_test.hpp>
#include <opm/parser/eclipse/Deck/Deck.hpp>
#include <opm/parser/eclipse/EclipseState/Eclipse3DProperties.hpp>
#include <opm/parser/eclipse/EclipseState/EclipseState.hpp>
#include <opm/parser/eclipse/EclipseState/Grid/GridProperty.hpp>
#include <opm/parser/eclipse/Parser/Parser.hpp>
@ -34,11 +35,10 @@
using namespace Opm;
void check_property(EclipseState eclState1, EclipseState eclState2, const std::string& propertyName) {
const std::vector<double> data1 = eclState1.getDoubleGridProperty(propertyName)->getData();
const std::vector<double> data2 = eclState2.getDoubleGridProperty(propertyName)->getData();
const std::vector<double> data1 = eclState1.getEclipseProperties().getDoubleGridProperty(propertyName).getData();
const std::vector<double> data2 = eclState2.getEclipseProperties().getDoubleGridProperty(propertyName).getData();
BOOST_CHECK_CLOSE(data1[0], data2[0],1e-12);
}
BOOST_AUTO_TEST_CASE(SaturationFunctionFamilyTests) {
@ -139,10 +139,8 @@ BOOST_AUTO_TEST_CASE(SaturationFunctionFamilyTests) {
strcat(familyMixDeck , deckdefault);
strcat(familyMixDeck , family1);
strcat(familyMixDeck , family2);
DeckPtr deckMix = parser->parseString(familyMixDeck, parseContext) ;
EclipseState stateMix(deckMix, parseContext);
BOOST_CHECK_THROW(stateMix.getDoubleGridProperty("SGCR") , std::invalid_argument);
BOOST_CHECK_THROW(stateMix.getEclipseProperties().getDoubleGridProperty("SGCR") , std::invalid_argument);
}

View File

@ -25,7 +25,7 @@
#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>
@ -40,11 +40,4 @@ BOOST_AUTO_TEST_CASE(Empty) {
BOOST_CHECK_EQUAL( transMult.getMultiplier(9,9,9, Opm::FaceDir::YMinus) , 1.0 );
BOOST_CHECK_EQUAL( transMult.getMultiplier(100 , Opm::FaceDir::ZMinus) , 1.0 );
BOOST_CHECK( !transMult.hasDirectionProperty( Opm::FaceDir::XPlus ));
BOOST_CHECK( !transMult.hasDirectionProperty( Opm::FaceDir::ZMinus ));
std::shared_ptr<Opm::GridProperty<double> > mult = transMult.getDirectionProperty( Opm::FaceDir::ZPlus );
BOOST_CHECK_EQUAL( mult->getKeywordName() , "MULTZ");
BOOST_CHECK( transMult.hasDirectionProperty( Opm::FaceDir::ZPlus ));
}

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;
int m_first_rft_step;
int m_first_restart_step = 0;
int m_first_rft_step = 0;
struct restartConfig {

View File

@ -45,7 +45,9 @@
namespace Opm {
SimulationConfig::SimulationConfig(const ParseContext& parseContext , DeckConstPtr deck, std::shared_ptr<GridProperties<int>> gridProperties) :
SimulationConfig::SimulationConfig(const ParseContext& parseContext,
DeckConstPtr deck,
GridProperties<int>& gridProperties) :
m_useCPR(false),
m_DISGAS(false),
m_VAPOIL(false)
@ -71,7 +73,9 @@ namespace Opm {
}
void SimulationConfig::initThresholdPressure(const ParseContext& parseContext, DeckConstPtr deck, std::shared_ptr<GridProperties<int>> gridProperties) {
void SimulationConfig::initThresholdPressure(const ParseContext& parseContext,
DeckConstPtr deck,
GridProperties<int>& gridProperties) {
m_ThresholdPressure = std::make_shared<const ThresholdPressure>(parseContext , deck, gridProperties);
}

View File

@ -33,7 +33,9 @@ namespace Opm {
public:
SimulationConfig(const ParseContext& parseContext , DeckConstPtr deck, std::shared_ptr<GridProperties<int>> gridProperties);
SimulationConfig(const ParseContext& parseContext,
DeckConstPtr deck,
GridProperties<int>& gridProperties);
std::shared_ptr<const ThresholdPressure> getThresholdPressure() const;
bool hasThresholdPressure() const;
@ -43,7 +45,9 @@ namespace Opm {
private:
void initThresholdPressure(const ParseContext& parseContext , DeckConstPtr deck, std::shared_ptr<GridProperties<int>> gridProperties);
void initThresholdPressure(const ParseContext& parseContext,
DeckConstPtr deck,
GridProperties<int>& gridProperties);
std::shared_ptr< const ThresholdPressure > m_ThresholdPressure;
bool m_useCPR;

View File

@ -29,8 +29,9 @@
namespace Opm {
ThresholdPressure::ThresholdPressure(const ParseContext& parseContext , DeckConstPtr deck, std::shared_ptr<GridProperties<int>> gridProperties)
: m_parseContext( parseContext )
ThresholdPressure::ThresholdPressure(const ParseContext& parseContext, DeckConstPtr deck,
GridProperties<int>& gridProperties) :
m_parseContext( parseContext )
{
if (Section::hasRUNSPEC( *deck ) && Section::hasSOLUTION( *deck )) {
@ -67,11 +68,11 @@ namespace Opm {
void ThresholdPressure::initThresholdPressure(const ParseContext& /* parseContext */,
std::shared_ptr<const RUNSPECSection> runspecSection,
std::shared_ptr<const SOLUTIONSection> solutionSection,
std::shared_ptr<GridProperties<int>> gridProperties) {
GridProperties<int>& gridProperties) {
bool thpresOption = false;
const bool thpresKeyword = solutionSection->hasKeyword<ParserKeywords::THPRES>( );
const bool hasEqlnumKeyword = gridProperties->hasKeyword<ParserKeywords::EQLNUM>( );
const bool hasEqlnumKeyword = gridProperties.hasKeyword<ParserKeywords::EQLNUM>( );
int maxEqlnum = 0;
//Is THPRES option set?
@ -95,8 +96,8 @@ namespace Opm {
{
//Find max of eqlnum
if (hasEqlnumKeyword) {
const auto& eqlnumKeyword = gridProperties->getKeyword<ParserKeywords::EQLNUM>( );
const auto& eqlnum = eqlnumKeyword->getData();
const auto& eqlnumKeyword = gridProperties.getKeyword<ParserKeywords::EQLNUM>( );
const auto& eqlnum = eqlnumKeyword.getData();
maxEqlnum = *std::max_element(eqlnum.begin(), eqlnum.end());
if (0 == maxEqlnum) {

View File

@ -36,7 +36,9 @@ namespace Opm {
public:
ThresholdPressure(const ParseContext& parseContext , std::shared_ptr< const Deck > deck, std::shared_ptr<GridProperties<int>> gridProperties);
ThresholdPressure(const ParseContext& parseContext,
std::shared_ptr< const Deck > deck,
GridProperties<int>& gridProperties);
/*
@ -69,7 +71,7 @@ namespace Opm {
void initThresholdPressure(const ParseContext& parseContext,
std::shared_ptr<const RUNSPECSection> runspecSection,
std::shared_ptr<const SOLUTIONSection> solutionSection,
std::shared_ptr<GridProperties<int>> gridProperties);
GridProperties<int>& gridProperties);
static std::pair<int,int> makeIndex(int r1 , int r2);
void addPair(int r1 , int r2 , const std::pair<bool , double>& valuePair);

View File

@ -110,45 +110,46 @@ static DeckPtr createDeck(const ParseContext& parseContext , const std::string&
return parser.parseString(input, parseContext);
}
static std::shared_ptr<GridProperties<int>> getGridProperties() {
static GridProperties<int> getGridProperties() {
GridPropertySupportedKeywordInfo<int> kwInfo = GridPropertySupportedKeywordInfo<int>("EQLNUM", 3, "");
std::vector<GridPropertySupportedKeywordInfo<int>> supportedKeywordsVec;
supportedKeywordsVec.push_back(kwInfo);
EclipseGridConstPtr eclipseGrid = std::make_shared<const EclipseGrid>(3, 3, 3);
std::shared_ptr<GridProperties<int>> gridProperties = std::make_shared<GridProperties<int>>(eclipseGrid, std::move(supportedKeywordsVec));
gridProperties->addKeyword("EQLNUM");
const EclipseGrid eclipseGrid(3, 3, 3);
GridProperties<int> gridProperties(eclipseGrid, std::move(supportedKeywordsVec));
gridProperties.addKeyword("EQLNUM");
return gridProperties;
}
BOOST_AUTO_TEST_CASE(SimulationConfigGetThresholdPressureTableTest) {
ParseContext parseContext;
auto gp = getGridProperties();
DeckPtr deck = createDeck(parseContext, inputStr);
SimulationConfigConstPtr simulationConfigPtr;
BOOST_CHECK_NO_THROW(simulationConfigPtr = std::make_shared<const SimulationConfig>(parseContext , deck, getGridProperties()));
BOOST_CHECK_NO_THROW( simulationConfigPtr = std::make_shared<const SimulationConfig>( parseContext, deck, gp ) );
}
BOOST_AUTO_TEST_CASE(SimulationConfigNOTHPRES) {
ParseContext parseContext;
auto gp = getGridProperties();
DeckPtr deck = createDeck(parseContext , inputStr_noTHPRES);
SimulationConfig simulationConfig(parseContext , deck, getGridProperties());
SimulationConfig simulationConfig(parseContext , deck, gp);
BOOST_CHECK_EQUAL( false , simulationConfig.hasThresholdPressure());
}
BOOST_AUTO_TEST_CASE(SimulationConfigCPRNotUsed) {
ParseContext parseContext;
auto gp = getGridProperties();
DeckPtr deck = createDeck(parseContext , inputStr_noTHPRES);
SimulationConfig simulationConfig(parseContext , deck, getGridProperties());
SimulationConfig simulationConfig(parseContext , deck, gp);
BOOST_CHECK_EQUAL( false , simulationConfig.useCPR());
}
BOOST_AUTO_TEST_CASE(SimulationConfigCPRUsed) {
ParseContext parseContext;
auto gp = getGridProperties();
DeckPtr deck = createDeck(parseContext , inputStr_cpr);
SUMMARYSection summary(*deck);
SimulationConfig simulationConfig(parseContext , deck, getGridProperties());
SimulationConfig simulationConfig(parseContext , deck, gp);
BOOST_CHECK_EQUAL( true , simulationConfig.useCPR());
BOOST_CHECK_EQUAL( false , summary.hasKeyword("CPR"));
}
@ -156,9 +157,10 @@ BOOST_AUTO_TEST_CASE(SimulationConfigCPRUsed) {
BOOST_AUTO_TEST_CASE(SimulationConfigCPRInSUMMARYSection) {
ParseContext parseContext;
auto gp = getGridProperties();
DeckPtr deck = createDeck(parseContext , inputStr_cpr_in_SUMMARY);
SUMMARYSection summary(*deck);
SimulationConfig simulationConfig(parseContext , deck, getGridProperties());
SimulationConfig simulationConfig(parseContext , deck, gp);
BOOST_CHECK_EQUAL( false , simulationConfig.useCPR());
BOOST_CHECK_EQUAL( true , summary.hasKeyword("CPR"));
}
@ -166,9 +168,10 @@ BOOST_AUTO_TEST_CASE(SimulationConfigCPRInSUMMARYSection) {
BOOST_AUTO_TEST_CASE(SimulationConfigCPRBoth) {
ParseContext parseContext;
auto gp = getGridProperties();
DeckPtr deck = createDeck(parseContext , inputStr_cpr_BOTH);
SUMMARYSection summary(*deck);
SimulationConfig simulationConfig(parseContext , deck, getGridProperties());
SimulationConfig simulationConfig(parseContext , deck, gp);
BOOST_CHECK_EQUAL( true , simulationConfig.useCPR());
BOOST_CHECK_EQUAL( true , summary.hasKeyword("CPR"));
@ -190,13 +193,15 @@ BOOST_AUTO_TEST_CASE(SimulationConfigCPRRUnspecWithData) {
BOOST_AUTO_TEST_CASE(SimulationConfig_VAPOIL_DISGAS) {
ParseContext parseContext;
auto gp1 = getGridProperties();
DeckPtr deck = createDeck(parseContext , inputStr);
SimulationConfig simulationConfig(parseContext , deck, getGridProperties());
SimulationConfig simulationConfig(parseContext , deck, gp1);
BOOST_CHECK_EQUAL( false , simulationConfig.hasDISGAS());
BOOST_CHECK_EQUAL( false , simulationConfig.hasVAPOIL());
auto gp2 = getGridProperties();
DeckPtr deck_vd = createDeck(parseContext, inputStr_vap_dis);
SimulationConfig simulationConfig_vd(parseContext , deck_vd, getGridProperties());
SimulationConfig simulationConfig_vd(parseContext , deck_vd, gp2);
BOOST_CHECK_EQUAL( true , simulationConfig_vd.hasDISGAS());
BOOST_CHECK_EQUAL( true , simulationConfig_vd.hasVAPOIL());
}

View File

@ -32,6 +32,7 @@
#include <opm/parser/eclipse/EclipseState/SimulationConfig/ThresholdPressure.hpp>
#include <opm/parser/eclipse/Parser/Parser.hpp>
#include <opm/parser/eclipse/Parser/ParseContext.hpp>
#include <opm/parser/eclipse/EclipseState/Grid/GridProperty.hpp>
#include <opm/parser/eclipse/EclipseState/Grid/GridProperties.hpp>
@ -139,23 +140,21 @@ static DeckPtr createDeck(const ParseContext& parseContext , const std::string&
return parser.parseString(input , parseContext);
}
static std::shared_ptr<GridProperties<int>> getGridProperties(int defaultEqlnum = 3, bool addKeyword = true) {
static GridProperties<int> getGridProperties(int defaultEqlnum = 3, bool addKeyword = true) {
GridPropertySupportedKeywordInfo<int> kwInfo = GridPropertySupportedKeywordInfo<int>( "EQLNUM", defaultEqlnum, "" );
std::vector<GridPropertySupportedKeywordInfo<int>> supportedKeywordsVec( 1, kwInfo );
EclipseGridConstPtr eclipseGrid = std::make_shared<const EclipseGrid>(3, 3, 3);
std::shared_ptr<GridProperties<int>> gridProperties = std::make_shared<GridProperties<int>>(eclipseGrid, std::move( supportedKeywordsVec ) );
const EclipseGrid eclipseGrid( 3, 3, 3 );
GridProperties<int> gridProperties( eclipseGrid, std::move( supportedKeywordsVec ) );
if (addKeyword) {
gridProperties->addKeyword("EQLNUM");
gridProperties.addKeyword( "EQLNUM" );
}
return gridProperties;
}
BOOST_AUTO_TEST_CASE(ThresholdPressureTest) {
ParseContext parseContext;
DeckPtr deck = createDeck(parseContext , inputStr);
static std::shared_ptr<GridProperties<int>> gridProperties = getGridProperties();
auto gridProperties = getGridProperties();
ThresholdPressureConstPtr thp = std::make_shared<ThresholdPressure>(parseContext , deck, gridProperties);
@ -172,7 +171,7 @@ BOOST_AUTO_TEST_CASE(ThresholdPressureTest) {
BOOST_AUTO_TEST_CASE(ThresholdPressureEmptyTest) {
ParseContext parseContext;
DeckPtr deck = createDeck(parseContext , inputStrNoSolutionSection);
static std::shared_ptr<GridProperties<int>> gridProperties = getGridProperties();
auto gridProperties = getGridProperties();
ThresholdPressureConstPtr thresholdPressurePtr = std::make_shared<ThresholdPressure>(parseContext , deck, gridProperties);
BOOST_CHECK_EQUAL(0, thresholdPressurePtr->size());
}
@ -182,7 +181,7 @@ BOOST_AUTO_TEST_CASE(ThresholdPressureNoTHPREStest) {
ParseContext parseContext;
DeckPtr deck_no_thpres = createDeck(parseContext , inputStrNoTHPRESinSolutionNorRUNSPEC);
DeckPtr deck_no_thpres2 = createDeck(parseContext , inputStrTHPRESinRUNSPECnotSoultion);
static std::shared_ptr<GridProperties<int>> gridProperties = getGridProperties();
auto gridProperties = getGridProperties();
ThresholdPressureConstPtr thresholdPressurePtr;
BOOST_CHECK_NO_THROW(thresholdPressurePtr = std::make_shared<ThresholdPressure>(parseContext , deck_no_thpres, gridProperties));
@ -202,7 +201,7 @@ BOOST_AUTO_TEST_CASE(ThresholdPressureThrowTest) {
DeckPtr deck_highRegNum = createDeck(parseContext , inputStrTooHighRegionNumbers);
DeckPtr deck_missingData = createDeck(parseContext , inputStrMissingData);
DeckPtr deck_missingPressure = createDeck(parseContext , inputStrMissingPressure);
static std::shared_ptr<GridProperties<int>> gridProperties = getGridProperties();
auto gridProperties = getGridProperties();
BOOST_CHECK_THROW(std::make_shared<ThresholdPressure>(parseContext,deck_irrevers, gridProperties), std::runtime_error);
BOOST_CHECK_THROW(std::make_shared<ThresholdPressure>(parseContext,deck_inconsistency, gridProperties), std::runtime_error);
@ -210,11 +209,11 @@ BOOST_AUTO_TEST_CASE(ThresholdPressureThrowTest) {
BOOST_CHECK_THROW(std::make_shared<ThresholdPressure>(parseContext,deck_missingData, gridProperties), std::runtime_error);
{
static std::shared_ptr<GridProperties<int>> gridPropertiesEQLNUMkeywordNotAdded = getGridProperties(3, false);
auto gridPropertiesEQLNUMkeywordNotAdded = getGridProperties(3, false);
BOOST_CHECK_THROW(std::make_shared<ThresholdPressure>(parseContext , deck, gridPropertiesEQLNUMkeywordNotAdded), std::runtime_error);
}
{
static std::shared_ptr<GridProperties<int>> gridPropertiesEQLNUMall0 = getGridProperties(0);
auto gridPropertiesEQLNUMall0 = getGridProperties(0);
BOOST_CHECK_THROW(std::make_shared<ThresholdPressure>(parseContext , deck, gridPropertiesEQLNUMall0), std::runtime_error);
}
@ -240,7 +239,7 @@ BOOST_AUTO_TEST_CASE(ThresholdPressureThrowTest) {
BOOST_AUTO_TEST_CASE(HasPair) {
ParseContext parseContext;
DeckPtr deck = createDeck(parseContext , inputStr);
static std::shared_ptr<GridProperties<int>> gridProperties = getGridProperties();
auto gridProperties = getGridProperties();
ThresholdPressure thp(parseContext , deck , gridProperties);
BOOST_CHECK_EQUAL( true , thp.hasRegionBarrier( 1 , 2 ));

View File

@ -30,6 +30,7 @@
#include <opm/parser/eclipse/Parser/ParserKeywords/T.hpp>
#include <opm/parser/eclipse/Parser/ParserKeywords/V.hpp>
#include <opm/parser/eclipse/EclipseState/Schedule/ScheduleEnums.hpp> // Phase::PhaseEnum
#include <opm/parser/eclipse/EclipseState/Tables/EnkrvdTable.hpp>
#include <opm/parser/eclipse/EclipseState/Tables/EnptvdTable.hpp>
#include <opm/parser/eclipse/EclipseState/Tables/GasvisctTable.hpp>
@ -73,7 +74,13 @@
namespace Opm {
TableManager::TableManager( const Deck& deck ) {
TableManager::TableManager( const Deck& deck )
:
hasImptvd (deck.hasKeyword("IMPTVD")),
hasEnptvd (deck.hasKeyword("ENPTVD")),
hasEqlnum (deck.hasKeyword("EQLNUM"))
{
initPhases( deck );
initDims( deck );
initSimpleTables( deck );
initFullTables(deck, "PVTG", m_pvtgTables);
@ -83,6 +90,28 @@ namespace Opm {
initVFPInjTables(deck, m_vfpinjTables);
}
void TableManager::initPhases(const Deck& deck) {
if (deck.hasKeyword("OIL"))
phases.insert(Phase::PhaseEnum::OIL);
if (deck.hasKeyword("GAS"))
phases.insert(Phase::PhaseEnum::GAS);
if (deck.hasKeyword("WATER"))
phases.insert(Phase::PhaseEnum::WATER);
if (phases.size() < 3)
OpmLog::addMessage(Log::MessageType::Info , "Only " + std::to_string(static_cast<long long>(phases.size())) + " fluid phases are enabled");
}
size_t TableManager::getNumPhases() const{
return phases.size();
}
bool TableManager::hasPhase(enum Phase::PhaseEnum phase) const {
return (phases.count(phase) == 1);
}
void TableManager::initDims(const Deck& deck) {
using namespace Opm::ParserKeywords;
@ -665,6 +694,18 @@ namespace Opm {
return m_vfpinjTables;
}
const bool TableManager::useImptvd() const {
return hasImptvd;
}
const bool TableManager::useEnptvd() const {
return hasEnptvd;
}
const bool TableManager::useEqlnum() const {
return hasEqlnum;
}
void TableManager::complainAboutAmbiguousKeyword(const Deck& deck, const std::string& keywordName) const {
OpmLog::addMessage(Log::MessageType::Error, "The " + keywordName + " keyword must be unique in the deck. Ignoring all!");
@ -675,5 +716,3 @@ namespace Opm {
}
}
}

View File

@ -20,10 +20,14 @@
#ifndef OPM_TABLE_MANAGER_HPP
#define OPM_TABLE_MANAGER_HPP
#include <set>
#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/Schedule/ScheduleEnums.hpp> // Phase::PhaseEnum
#include <opm/parser/eclipse/EclipseState/Tables/PvtgTable.hpp>
#include <opm/parser/eclipse/EclipseState/Tables/PvtoTable.hpp>
@ -101,6 +105,21 @@ namespace Opm {
const std::vector<PvtoTable>& getPvtoTables() const;
const std::map<int, VFPProdTable>& getVFPProdTables() const;
const std::map<int, VFPInjTable>& getVFPInjTables() const;
bool hasPhase(enum Phase::PhaseEnum phase) const;
/// number of phases, [gas, oil, water] = 3
size_t getNumPhases() const;
/// deck has keyword "IMPTVD" --- Imbition end-point versus depth tables
const bool useImptvd() const;
/// deck has keyword "ENPTVD" --- Saturation end-point versus depth tables
const bool useEnptvd() const;
/// deck has keyword "EQLNUM" --- Equilibriation region numbers
const bool useEqlnum() const;
private:
TableContainer& forceGetTables( const std::string& tableName , size_t numTables);
@ -109,6 +128,7 @@ namespace Opm {
void addTables( const std::string& tableName , size_t numTables);
void initSimpleTables(const Deck& deck);
void initRTempTables(const Deck& deck);
void initPhases(const Deck& deck);
void initDims(const Deck& deck);
void initRocktabTables(const Deck& deck);
void initGasvisctTables(const Deck& deck);
@ -119,7 +139,6 @@ 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);
@ -218,6 +237,12 @@ namespace Opm {
std::shared_ptr<Regdims> m_regdims;
std::shared_ptr<Tabdims> m_tabdims;
std::shared_ptr<Eqldims> m_eqldims;
std::set<enum Phase::PhaseEnum> phases;
const bool hasImptvd;// if deck has keyword IMPTVD
const bool hasEnptvd;// if deck has keyword ENPTVD
const bool hasEqlnum;// if deck has keyword EQLNUM
};
}

View File

@ -64,14 +64,86 @@ std::shared_ptr<const Opm::Deck> createSingleRecordDeck() {
}
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::ParseContext()));
return deck;
}
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);
auto tabdims = tables.getTabdims();
BOOST_CHECK_EQUAL( tabdims->getNumSatTables() , 2 );
BOOST_CHECK( !tables.useImptvd() );
BOOST_CHECK( !tables.useEnptvd() );
}
BOOST_AUTO_TEST_CASE( CreateTablesWithVd ) {
std::shared_ptr<const Opm::Deck> deck = createSingleRecordDeckWithVd();
Opm::TableManager tables(*deck);
auto tabdims = tables.getTabdims();
BOOST_CHECK_EQUAL( tabdims->getNumSatTables() , 2 );
BOOST_CHECK( tables.useImptvd() );
BOOST_CHECK( tables.useEnptvd() );
}
/*****************************************************************/

View File

@ -29,21 +29,23 @@
#include <opm/common/utility/platform_dependent/reenable_warnings.h>
#include <opm/common/OpmLog/OpmLog.hpp>
#include <opm/common/OpmLog/CounterLog.hpp>
#include <opm/parser/eclipse/EclipseState/Schedule/Schedule.hpp>
#include <opm/parser/eclipse/EclipseState/Schedule/ScheduleEnums.hpp>
#include <opm/parser/eclipse/EclipseState/SimulationConfig/ThresholdPressure.hpp>
#include <opm/parser/eclipse/EclipseState/SimulationConfig/SimulationConfig.hpp>
#include <opm/parser/eclipse/EclipseState/Eclipse3DProperties.hpp>
#include <opm/parser/eclipse/EclipseState/EclipseState.hpp>
#include <opm/parser/eclipse/EclipseState/checkDeck.hpp>
#include <opm/parser/eclipse/EclipseState/Grid/Box.hpp>
#include <opm/parser/eclipse/EclipseState/Grid/EclipseGrid.hpp>
#include <opm/parser/eclipse/EclipseState/Grid/GridProperty.hpp>
#include <opm/parser/eclipse/EclipseState/Grid/GridProperties.hpp>
#include <opm/parser/eclipse/EclipseState/Grid/Fault.hpp>
#include <opm/parser/eclipse/EclipseState/Grid/FaultCollection.hpp>
#include <opm/parser/eclipse/EclipseState/Grid/TransMult.hpp>
#include <opm/parser/eclipse/EclipseState/IOConfig/IOConfig.hpp>
#include <opm/parser/eclipse/EclipseState/Tables/TableManager.hpp>
#include <opm/parser/eclipse/Units/ConversionFactors.hpp>
#include <opm/parser/eclipse/Parser/Parser.hpp>
#include <opm/parser/eclipse/Parser/ParseContext.hpp>
@ -95,25 +97,22 @@ static DeckPtr createDeckTOP() {
return parser->parseString(deckData, ParseContext()) ;
}
BOOST_AUTO_TEST_CASE(GetPOROTOPBased) {
DeckPtr deck = createDeckTOP();
EclipseState state(deck , ParseContext());
auto& props = state.getEclipseProperties();
std::shared_ptr<const GridProperty<double> > poro = state.getDoubleGridProperty( "PORO" );
std::shared_ptr<const GridProperty<double> > permx = state.getDoubleGridProperty( "PERMX" );
const GridProperty<double>& poro = props.getDoubleGridProperty( "PORO" );
const GridProperty<double>& permx = props.getDoubleGridProperty( "PERMX" );
BOOST_CHECK_EQUAL(1000U , poro->getCartesianSize() );
BOOST_CHECK_EQUAL(1000U , permx->getCartesianSize() );
for (size_t i=0; i < poro->getCartesianSize(); i++) {
BOOST_CHECK_EQUAL( 0.10 , poro->iget(i) );
BOOST_CHECK_EQUAL( 0.25 * Metric::Permeability , permx->iget(i) );
BOOST_CHECK_EQUAL(1000U , poro.getCartesianSize() );
BOOST_CHECK_EQUAL(1000U , permx.getCartesianSize() );
for (size_t i=0; i < poro.getCartesianSize(); i++) {
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"
@ -183,6 +182,11 @@ 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();
@ -226,8 +230,11 @@ BOOST_AUTO_TEST_CASE(CreateSimulationConfig) {
DeckPtr deck = createDeckSimConfig();
EclipseState state(deck, ParseContext());
SimulationConfigConstPtr simulationConfig = state.getSimulationConfig();
std::shared_ptr<const ThresholdPressure> thresholdPressure = simulationConfig->getThresholdPressure();
SimulationConfigConstPtr simConf = state.getSimulationConfig();
BOOST_CHECK( simConf->hasThresholdPressure() );
std::shared_ptr<const ThresholdPressure> thresholdPressure = simConf->getThresholdPressure();
BOOST_CHECK_EQUAL(thresholdPressure->size(), 3);
}
@ -236,13 +243,12 @@ BOOST_AUTO_TEST_CASE(CreateSimulationConfig) {
BOOST_AUTO_TEST_CASE(PhasesCorrect) {
DeckPtr deck = createDeck();
EclipseState state( deck, ParseContext() );
BOOST_CHECK( state.hasPhase( Phase::PhaseEnum::OIL ));
BOOST_CHECK( state.hasPhase( Phase::PhaseEnum::GAS ));
BOOST_CHECK( !state.hasPhase( Phase::PhaseEnum::WATER ));
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 )));
}
BOOST_AUTO_TEST_CASE(TitleCorrect) {
DeckPtr deck = createDeck();
EclipseState state(deck, ParseContext());
@ -250,56 +256,43 @@ BOOST_AUTO_TEST_CASE(TitleCorrect) {
BOOST_CHECK_EQUAL( state.getTitle(), "The title" );
}
BOOST_AUTO_TEST_CASE(IntProperties) {
DeckPtr deck = createDeck();
EclipseState state(deck, ParseContext());
BOOST_CHECK_EQUAL( false , state.supportsGridProperty("NONO"));
BOOST_CHECK_EQUAL( true , state.supportsGridProperty("SATNUM"));
BOOST_CHECK_EQUAL( true , state.hasDeckIntGridProperty("SATNUM"));
BOOST_CHECK( ! state.getEclipseProperties().supportsGridProperty( "NONO" ) );
BOOST_CHECK( state.getEclipseProperties().supportsGridProperty( "SATNUM" ) );
BOOST_CHECK( state.getEclipseProperties().hasDeckIntGridProperty( "SATNUM" ) );
}
BOOST_AUTO_TEST_CASE(PropertiesNotSupportedThrows) {
std::shared_ptr<CounterLog> counter = std::make_shared<CounterLog>(Log::MessageType::Error);
OpmLog::addBackend("COUNTER" , counter);
BOOST_AUTO_TEST_CASE(PropertiesNotSupportsFalse) {
DeckPtr deck = createDeck();
EclipseState state( deck, ParseContext() );
const auto& swat = deck->getKeyword("SWAT");
BOOST_CHECK_EQUAL( false , state.supportsGridProperty("SWAT"));
state.loadGridPropertyFromDeckKeyword(std::make_shared<const Box>(10,10,10), swat);
BOOST_CHECK_EQUAL( 1 , counter->numMessages(Log::MessageType::Error) );
const auto& props = state.getEclipseProperties();
BOOST_CHECK( ! props.supportsGridProperty( "SWAT" ) );
}
BOOST_AUTO_TEST_CASE(GetProperty) {
DeckPtr deck = createDeck();
EclipseState state(deck, ParseContext());
std::shared_ptr<const GridProperty<int> > satNUM = state.getIntGridProperty( "SATNUM" );
const auto& satNUM = state.getEclipseProperties().getIntGridProperty( "SATNUM" );
BOOST_CHECK_EQUAL(1000U , satNUM->getCartesianSize() );
for (size_t i=0; i < satNUM->getCartesianSize(); i++)
BOOST_CHECK_EQUAL( 2 , satNUM->iget(i) );
BOOST_CHECK_EQUAL(1000U , satNUM.getCartesianSize() );
for (size_t i=0; i < satNUM.getCartesianSize(); i++)
BOOST_CHECK_EQUAL( 2 , satNUM.iget(i) );
BOOST_CHECK_THROW( satNUM->iget(100000) , std::invalid_argument);
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_AUTO_TEST_CASE(GetFaults) {
DeckPtr deck = createDeck();
EclipseState state(deck , ParseContext());
@ -403,22 +396,28 @@ static DeckPtr createDeckWithGridOpts() {
BOOST_AUTO_TEST_CASE(NoGridOptsDefaultRegion) {
DeckPtr deck = createDeckNoGridOpts();
EclipseState state(deck, ParseContext());
auto multnum = state.getIntGridProperty("MULTNUM");
auto fluxnum = state.getIntGridProperty("FLUXNUM");
auto def_property = state.getDefaultRegion();
const auto& props = state.getEclipseProperties();
const auto& multnum = props.getIntGridProperty("MULTNUM");
const auto& fluxnum = props.getIntGridProperty("FLUXNUM");
const auto default_kw = props.getDefaultRegionKeyword();
const auto& def_pro = props.getIntGridProperty(default_kw);
BOOST_CHECK_EQUAL( fluxnum , def_property );
BOOST_CHECK_EQUAL( &fluxnum , &def_pro );
BOOST_CHECK_NE( &fluxnum , &multnum );
}
BOOST_AUTO_TEST_CASE(WithGridOptsDefaultRegion) {
DeckPtr deck = createDeckWithGridOpts();
EclipseState state(deck, ParseContext());
auto multnum = state.getIntGridProperty("MULTNUM");
auto fluxnum = state.getIntGridProperty("FLUXNUM");
auto def_property = state.getDefaultRegion();
const auto& props = state.getEclipseProperties();
const auto& multnum = props.getIntGridProperty("MULTNUM");
const auto& fluxnum = props.getIntGridProperty("FLUXNUM");
const auto default_kw = props.getDefaultRegionKeyword();
const auto& def_pro = props.getIntGridProperty(default_kw);
BOOST_CHECK_EQUAL( multnum , def_property );
BOOST_CHECK_EQUAL( &multnum , &def_pro );
BOOST_CHECK_NE( &fluxnum , &multnum );
}

View File

@ -29,6 +29,7 @@
#include <opm/parser/eclipse/Deck/Deck.hpp>
#include <opm/parser/eclipse/Parser/Parser.hpp>
#include <opm/parser/eclipse/Parser/ParseContext.hpp>
#include <opm/parser/eclipse/EclipseState/Eclipse3DProperties.hpp>
#include <opm/parser/eclipse/EclipseState/EclipseState.hpp>
#include <opm/parser/eclipse/EclipseState/Grid/EclipseGrid.hpp>
#include <opm/parser/eclipse/EclipseState/Grid/GridProperty.hpp>
@ -51,9 +52,9 @@ EclipseState makeState(const std::string& fileName) {
BOOST_AUTO_TEST_CASE( PERMX ) {
EclipseState state = makeState( "testdata/integration_tests/BOX/BOXTEST1" );
std::shared_ptr<const GridProperty<double> > permx = state.getDoubleGridProperty("PERMX");
std::shared_ptr<const GridProperty<double> > permy = state.getDoubleGridProperty("PERMY");
std::shared_ptr<const GridProperty<double> > permz = state.getDoubleGridProperty("PERMZ");
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;
std::shared_ptr<const EclipseGrid> grid = state.getEclipseGrid();
@ -61,8 +62,8 @@ BOOST_AUTO_TEST_CASE( PERMX ) {
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,7 +74,7 @@ BOOST_AUTO_TEST_CASE( PERMX ) {
BOOST_AUTO_TEST_CASE( PARSE_BOX_OK ) {
EclipseState state = makeState( "testdata/integration_tests/BOX/BOXTEST1" );
std::shared_ptr<const GridProperty<int> > satnum = state.getIntGridProperty("SATNUM");
const auto& satnum = state.getEclipseProperties().getIntGridProperty( "SATNUM" );
{
size_t i, j, k;
std::shared_ptr<const EclipseGrid> grid = state.getEclipseGrid();
@ -83,9 +84,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 );
}
}
@ -93,12 +94,10 @@ BOOST_AUTO_TEST_CASE( PARSE_BOX_OK ) {
}
}
BOOST_AUTO_TEST_CASE( PARSE_MULTIPLY_COPY ) {
EclipseState state = makeState( "testdata/integration_tests/BOX/BOXTEST1" );
std::shared_ptr<const GridProperty<int> > satnum = state.getIntGridProperty("SATNUM");
std::shared_ptr<const GridProperty<int> > fipnum = state.getIntGridProperty("FIPNUM");
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();
@ -108,9 +107,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,13 +123,11 @@ BOOST_AUTO_TEST_CASE( KEYWORD_BOX_TOO_SMALL) {
BOOST_CHECK_THROW( makeState("testdata/integration_tests/BOX/BOXTEST3") , std::invalid_argument);
}
BOOST_AUTO_TEST_CASE( EQUAL ) {
EclipseState state = makeState( "testdata/integration_tests/BOX/BOXTEST1" );
std::shared_ptr<const GridProperty<int> > pvtnum = state.getIntGridProperty("PVTNUM");
std::shared_ptr<const GridProperty<int> > eqlnum = state.getIntGridProperty("EQLNUM");
std::shared_ptr<const GridProperty<double> > poro = state.getDoubleGridProperty("PORO");
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();
@ -138,14 +135,11 @@ BOOST_AUTO_TEST_CASE( EQUAL ) {
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 );
}
}
}
}