Merge pull request #353 from joakim-hove/EclipsestateNoGrid

Eclipsestate no grid
This commit is contained in:
Joakim Hove 2014-11-11 11:00:58 +01:00
commit bae5a0cb46
19 changed files with 376 additions and 296 deletions

View File

@ -1,4 +1,9 @@
;; <http://www.gnu.org/software/emacs/manual/html_node/emacs/Directory-Variables.html> ;; <http://www.gnu.org/software/emacs/manual/html_node/emacs/Directory-Variables.html>
((c-mode . ((c-basic-offset . 4) (( nil . ((eval . (progn
(tab-width . 8) (require 'projectile)
(indent-tabs-mode . nil)))) (puthash (projectile-project-root) "cd build; make -j 4" projectile-compilation-cmd-map)
(puthash (projectile-project-root) "cd build; ctest -j 4" projectile-test-cmd-map)))))
( c-mode . ((c-basic-offset . 4)
(tab-width . 8)
(indent-tabs-mode . nil))))

View File

@ -116,9 +116,11 @@ namespace Opm {
initPhases(deck, parserLog); initPhases(deck, parserLog);
initTables(deck, parserLog); initTables(deck, parserLog);
initEclipseGrid(deck, parserLog);
initSchedule(deck, parserLog); initSchedule(deck, parserLog);
initTitle(deck, parserLog); initTitle(deck, parserLog);
initEclipseGrid(deck, parserLog);
initProperties(deck, parserLog); initProperties(deck, parserLog);
initTransMult(parserLog); initTransMult(parserLog);
initFaults(deck, parserLog); initFaults(deck, parserLog);
@ -129,6 +131,7 @@ namespace Opm {
return m_deckUnitSystem; return m_deckUnitSystem;
} }
EclipseGridConstPtr EclipseState::getEclipseGrid() const { EclipseGridConstPtr EclipseState::getEclipseGrid() const {
return m_eclipseGrid; return m_eclipseGrid;
} }
@ -504,7 +507,6 @@ namespace Opm {
} }
void EclipseState::initProperties(DeckConstPtr deck, ParserLogPtr parserLog) { void EclipseState::initProperties(DeckConstPtr deck, ParserLogPtr parserLog) {
typedef GridProperties<int>::SupportedKeywordInfo SupportedIntKeywordInfo; typedef GridProperties<int>::SupportedKeywordInfo SupportedIntKeywordInfo;
std::shared_ptr<std::vector<SupportedIntKeywordInfo> > supportedIntKeywords(new std::vector<SupportedIntKeywordInfo>{ std::shared_ptr<std::vector<SupportedIntKeywordInfo> > supportedIntKeywords(new std::vector<SupportedIntKeywordInfo>{
@ -695,18 +697,14 @@ namespace Opm {
SupportedDoubleKeywordInfo( "SWATINIT" , 0.0, "1") SupportedDoubleKeywordInfo( "SWATINIT" , 0.0, "1")
}); });
// create the grid properties // register the grid properties
m_intGridProperties = std::make_shared<GridProperties<int> >(m_eclipseGrid->getNX(), m_intGridProperties = std::make_shared<GridProperties<int> >(m_eclipseGrid , supportedIntKeywords);
m_eclipseGrid->getNY(), m_doubleGridProperties = std::make_shared<GridProperties<double> >(m_eclipseGrid , supportedDoubleKeywords);
m_eclipseGrid->getNZ(),
supportedIntKeywords);
m_doubleGridProperties = std::make_shared<GridProperties<double> >(m_eclipseGrid->getNX(),
m_eclipseGrid->getNY(),
m_eclipseGrid->getNZ(),
supportedDoubleKeywords);
// first process all integer grid properties as these may be needed in order to // actually create the grid property objects. we need to first
// initialize the double properties // process all integer grid properties before the double ones
// as these may be needed in order to initialize the double
// properties
processGridProperties(deck, parserLog, /*enabledTypes=*/IntProperties); processGridProperties(deck, parserLog, /*enabledTypes=*/IntProperties);
processGridProperties(deck, parserLog, /*enabledTypes=*/DoubleProperties); processGridProperties(deck, parserLog, /*enabledTypes=*/DoubleProperties);
} }

View File

@ -43,6 +43,10 @@ namespace Opm {
m_grid.reset( new_ptr , ecl_grid_free ); m_grid.reset( new_ptr , ecl_grid_free );
else else
throw std::invalid_argument("Could not load grid from binary file: " + filename); throw std::invalid_argument("Could not load grid from binary file: " + filename);
m_nx = static_cast<size_t>( ecl_grid_get_nx( c_ptr() ));
m_ny = static_cast<size_t>( ecl_grid_get_ny( c_ptr() ));
m_nz = static_cast<size_t>( ecl_grid_get_nz( c_ptr() ));
} }
EclipseGrid::EclipseGrid(const ecl_grid_type * src_ptr) EclipseGrid::EclipseGrid(const ecl_grid_type * src_ptr)
@ -50,6 +54,26 @@ namespace Opm {
m_pinch("PINCH") m_pinch("PINCH")
{ {
m_grid.reset( ecl_grid_alloc_copy( src_ptr ) , ecl_grid_free ); m_grid.reset( ecl_grid_alloc_copy( src_ptr ) , ecl_grid_free );
m_nx = static_cast<size_t>( ecl_grid_get_nx( c_ptr() ));
m_ny = static_cast<size_t>( ecl_grid_get_ny( c_ptr() ));
m_nz = static_cast<size_t>( ecl_grid_get_nz( c_ptr() ));
}
/*
This creates a grid which only has dimension, and no pointer to
a true grid structure. This grid will answer false to
hasCellInfo() - but can be used in all situations where the grid
dependency is really only on the dimensions.
*/
EclipseGrid::EclipseGrid(size_t nx, size_t ny , size_t nz)
: m_minpv("MINPV"),
m_pinch("PINCH")
{
m_nx = nx;
m_ny = ny;
m_nz = nz;
} }
@ -116,16 +140,16 @@ namespace Opm {
void EclipseGrid::initGrid( const std::vector<int>& dims, DeckConstPtr deck, ParserLogPtr parserLog) { void EclipseGrid::initGrid( const std::vector<int>& dims, DeckConstPtr deck, ParserLogPtr parserLog) {
m_nx = static_cast<size_t>(dims[0]);
m_ny = static_cast<size_t>(dims[1]);
m_nz = static_cast<size_t>(dims[2]);
if (hasCornerPointKeywords(deck)) { if (hasCornerPointKeywords(deck)) {
initCornerPointGrid(dims , deck, parserLog); initCornerPointGrid(dims , deck, parserLog);
} else if (hasCartesianKeywords(deck)) { } else if (hasCartesianKeywords(deck)) {
initCartesianGrid(dims , deck); initCartesianGrid(dims , deck);
} else { }
const std::string msg = "The deck must have COORD / ZCORN or D?? + TOPS keywords";
parserLog->addError("", -1, msg);
throw std::invalid_argument(msg);
}
if (deck->hasKeyword("PINCH")) { if (deck->hasKeyword("PINCH")) {
m_pinch.setValue( deck->getKeyword("PINCH")->getRecord(0)->getItem("THRESHOLD_THICKNESS")->getSIDouble(0) ); m_pinch.setValue( deck->getKeyword("PINCH")->getRecord(0)->getItem("THRESHOLD_THICKNESS")->getSIDouble(0) );
} }
@ -137,33 +161,22 @@ namespace Opm {
bool EclipseGrid::equal(const EclipseGrid& other) const {
return (m_pinch.equal( other.m_pinch ) &&
m_minpv.equal( other.m_minpv ) &&
ecl_grid_compare( m_grid.get() , other.m_grid.get() , true , false , false ));
}
size_t EclipseGrid::getNumActive( ) const {
return static_cast<size_t>(ecl_grid_get_nactive( m_grid.get() ));
}
size_t EclipseGrid::getNX( ) const { size_t EclipseGrid::getNX( ) const {
return static_cast<size_t>(ecl_grid_get_nx( m_grid.get() )); return m_nx;
} }
size_t EclipseGrid::getNY( ) const { size_t EclipseGrid::getNY( ) const {
return static_cast<size_t>(ecl_grid_get_ny( m_grid.get() )); return m_ny;
} }
size_t EclipseGrid::getNZ( ) const { size_t EclipseGrid::getNZ( ) const {
return static_cast<size_t>(ecl_grid_get_nz( m_grid.get() )); return m_nz;
} }
size_t EclipseGrid::getCartesianSize( ) const { size_t EclipseGrid::getCartesianSize( ) const {
return static_cast<size_t>( ecl_grid_get_global_size( m_grid.get() )); return m_nx * m_ny * m_nz;
} }
bool EclipseGrid::isPinchActive( ) const { bool EclipseGrid::isPinchActive( ) const {
return m_pinch.hasValue(); return m_pinch.hasValue();
} }
@ -191,91 +204,43 @@ namespace Opm {
} }
double EclipseGrid::getCellVolume(size_t globalIndex) const {
assertGlobalIndex( globalIndex ); void EclipseGrid::initCartesianGrid(const std::vector<int>& dims , DeckConstPtr deck) {
return ecl_grid_get_cell_volume1( m_grid.get() , static_cast<int>(globalIndex)); if (hasDVDEPTHZKeywords( deck ))
initDVDEPTHZGrid( dims , deck );
else if (hasDTOPSKeywords(deck))
initDTOPSGrid( dims ,deck );
else
throw std::invalid_argument("Tried to initialize cartesian grid without all required keywords");
} }
void EclipseGrid::initDVDEPTHZGrid(const std::vector<int>& dims , DeckConstPtr deck) {
const std::vector<double>& DXV = deck->getKeyword("DXV")->getSIDoubleData();
const std::vector<double>& DYV = deck->getKeyword("DYV")->getSIDoubleData();
const std::vector<double>& DZV = deck->getKeyword("DZV")->getSIDoubleData();
const std::vector<double>& DEPTHZ = deck->getKeyword("DEPTHZ")->getSIDoubleData();
double EclipseGrid::getCellVolume(size_t i , size_t j , size_t k) const { assertVectorSize( DEPTHZ , static_cast<size_t>( (dims[0] + 1)*(dims[1] +1 )) , "DEPTHZ");
assertIJK(i,j,k); assertVectorSize( DXV , static_cast<size_t>( dims[0] ) , "DXV");
return ecl_grid_get_cell_volume3( m_grid.get() , static_cast<int>(i),static_cast<int>(j),static_cast<int>(k)); assertVectorSize( DYV , static_cast<size_t>( dims[1] ) , "DYV");
} assertVectorSize( DZV , static_cast<size_t>( dims[2] ) , "DZV");
std::tuple<double,double,double> EclipseGrid::getCellCenter(size_t globalIndex) const {
assertGlobalIndex( globalIndex );
{
double x,y,z;
ecl_grid_get_xyz1( m_grid.get() , static_cast<int>(globalIndex) , &x , &y , &z);
return std::tuple<double,double,double> {x,y,z};
}
}
std::tuple<double,double,double> EclipseGrid::getCellCenter(size_t i,size_t j, size_t k) const {
assertIJK(i,j,k);
{
double x,y,z;
ecl_grid_get_xyz3( m_grid.get() , static_cast<int>(i),static_cast<int>(j),static_cast<int>(k), &x , &y , &z);
return std::tuple<double,double,double> {x,y,z};
}
}
bool EclipseGrid::hasCornerPointKeywords(DeckConstPtr deck) {
if (deck->hasKeyword("ZCORN") && deck->hasKeyword("COORD"))
return true;
else
return false;
}
void EclipseGrid::assertCornerPointKeywords( const std::vector<int>& dims , DeckConstPtr deck, ParserLogPtr parserLog) const
{
const int nx = dims[0];
const int ny = dims[1];
const int nz = dims[2];
{
DeckKeywordConstPtr ZCORNKeyWord = deck->getKeyword("ZCORN");
if (ZCORNKeyWord->getDataSize() != static_cast<size_t>(8*nx*ny*nz)) {
const std::string msg =
"Wrong size of the ZCORN keyword: Expected 8*x*ny*nz = "
+ std::to_string(static_cast<long long>(8*nx*ny*nz)) + " is "
+ std::to_string(static_cast<long long>(ZCORNKeyWord->getDataSize()));
parserLog->addError("", -1, msg);
throw std::invalid_argument(msg);
}
}
{
DeckKeywordConstPtr COORDKeyWord = deck->getKeyword("COORD");
if (COORDKeyWord->getDataSize() != static_cast<size_t>(6*(nx + 1)*(ny + 1))) {
const std::string msg =
"Wrong size of the COORD keyword: Expected 8*(nx + 1)*(ny + 1) = "
+ std::to_string(static_cast<long long>(8*(nx + 1)*(ny + 1))) + " is "
+ std::to_string(static_cast<long long>(COORDKeyWord->getDataSize()));
parserLog->addError("", -1, msg);
throw std::invalid_argument(msg);
}
}
if (deck->hasKeyword("ACTNUM")) {
DeckKeywordConstPtr ACTNUMKeyWord = deck->getKeyword("ACTNUM");
if (ACTNUMKeyWord->getDataSize() != static_cast<size_t>(nx*ny*nz)) {
const std::string msg =
"Wrong size of the ACTNUM keyword: Expected nx*ny*nz = "
+ std::to_string(static_cast<long long>(nx*ny*nz)) + " is "
+ std::to_string(static_cast<long long>(ACTNUMKeyWord->getDataSize()));
parserLog->addError("", -1, msg);
throw std::invalid_argument(msg);
}
}
}
m_grid.reset( ecl_grid_alloc_dxv_dyv_dzv_depthz( dims[0] , dims[1] , dims[2] , DXV.data() , DYV.data() , DZV.data() , DEPTHZ.data() , NULL ) , ecl_grid_free);
}
void EclipseGrid::initDTOPSGrid(const std::vector<int>& dims , DeckConstPtr deck) {
std::vector<double> DX = createDVector( dims , 0 , "DX" , "DXV" , deck);
std::vector<double> DY = createDVector( dims , 1 , "DY" , "DYV" , deck);
std::vector<double> DZ = createDVector( dims , 2 , "DZ" , "DZV" , deck);
std::vector<double> TOPS = createTOPSVector( dims , DZ , deck );
m_grid.reset( ecl_grid_alloc_dx_dy_dz_tops( dims[0] , dims[1] , dims[2] , DX.data() , DY.data() , DZ.data() , TOPS.data() , NULL ) , ecl_grid_free);
}
void EclipseGrid::initCornerPointGrid(const std::vector<int>& dims , DeckConstPtr deck, ParserLogPtr parserLog) { void EclipseGrid::initCornerPointGrid(const std::vector<int>& dims , DeckConstPtr deck, ParserLogPtr parserLog) {
assertCornerPointKeywords( dims , deck, parserLog); assertCornerPointKeywords( dims , deck, parserLog);
{ {
@ -326,6 +291,61 @@ namespace Opm {
} }
bool EclipseGrid::hasCornerPointKeywords(DeckConstPtr deck) {
if (deck->hasKeyword("ZCORN") && deck->hasKeyword("COORD"))
return true;
else
return false;
}
void EclipseGrid::assertCornerPointKeywords( const std::vector<int>& dims , DeckConstPtr deck, ParserLogPtr parserLog)
{
const int nx = dims[0];
const int ny = dims[1];
const int nz = dims[2];
{
DeckKeywordConstPtr ZCORNKeyWord = deck->getKeyword("ZCORN");
if (ZCORNKeyWord->getDataSize() != static_cast<size_t>(8*nx*ny*nz)) {
const std::string msg =
"Wrong size of the ZCORN keyword: Expected 8*x*ny*nz = "
+ std::to_string(static_cast<long long>(8*nx*ny*nz)) + " is "
+ std::to_string(static_cast<long long>(ZCORNKeyWord->getDataSize()));
parserLog->addError("", -1, msg);
throw std::invalid_argument(msg);
}
}
{
DeckKeywordConstPtr COORDKeyWord = deck->getKeyword("COORD");
if (COORDKeyWord->getDataSize() != static_cast<size_t>(6*(nx + 1)*(ny + 1))) {
const std::string msg =
"Wrong size of the COORD keyword: Expected 8*(nx + 1)*(ny + 1) = "
+ std::to_string(static_cast<long long>(8*(nx + 1)*(ny + 1))) + " is "
+ std::to_string(static_cast<long long>(COORDKeyWord->getDataSize()));
parserLog->addError("", -1, msg);
throw std::invalid_argument(msg);
}
}
if (deck->hasKeyword("ACTNUM")) {
DeckKeywordConstPtr ACTNUMKeyWord = deck->getKeyword("ACTNUM");
if (ACTNUMKeyWord->getDataSize() != static_cast<size_t>(nx*ny*nz)) {
const std::string msg =
"Wrong size of the ACTNUM keyword: Expected nx*ny*nz = "
+ std::to_string(static_cast<long long>(nx*ny*nz)) + " is "
+ std::to_string(static_cast<long long>(ACTNUMKeyWord->getDataSize()));
parserLog->addError("", -1, msg);
throw std::invalid_argument(msg);
}
}
}
bool EclipseGrid::hasCartesianKeywords(DeckConstPtr deck) { bool EclipseGrid::hasCartesianKeywords(DeckConstPtr deck) {
if (hasDVDEPTHZKeywords( deck )) if (hasDVDEPTHZKeywords( deck ))
return true; return true;
@ -355,44 +375,13 @@ namespace Opm {
} }
void EclipseGrid::initCartesianGrid(const std::vector<int>& dims , DeckConstPtr deck) {
if (hasDVDEPTHZKeywords( deck ))
initDVDEPTHZGrid( dims , deck );
else if (hasDTOPSKeywords(deck))
initDTOPSGrid( dims ,deck );
else
throw std::invalid_argument("Tried to initialize cartesian grid without all required keywords");
}
void EclipseGrid::assertVectorSize(const std::vector<double>& vector , size_t expectedSize , const std::string& vectorName) { void EclipseGrid::assertVectorSize(const std::vector<double>& vector , size_t expectedSize , const std::string& vectorName) {
if (vector.size() != expectedSize) if (vector.size() != expectedSize)
throw std::invalid_argument("Wrong size for keyword: " + vectorName + ". Expected: " + boost::lexical_cast<std::string>(expectedSize) + " got: " + boost::lexical_cast<std::string>(vector.size())); throw std::invalid_argument("Wrong size for keyword: " + vectorName + ". Expected: " + boost::lexical_cast<std::string>(expectedSize) + " got: " + boost::lexical_cast<std::string>(vector.size()));
} }
void EclipseGrid::initDVDEPTHZGrid(const std::vector<int>& dims , DeckConstPtr deck) {
const std::vector<double>& DXV = deck->getKeyword("DXV")->getSIDoubleData();
const std::vector<double>& DYV = deck->getKeyword("DYV")->getSIDoubleData();
const std::vector<double>& DZV = deck->getKeyword("DZV")->getSIDoubleData();
const std::vector<double>& DEPTHZ = deck->getKeyword("DEPTHZ")->getSIDoubleData();
assertVectorSize( DEPTHZ , static_cast<size_t>( (dims[0] + 1)*(dims[1] +1 )) , "DEPTHZ");
assertVectorSize( DXV , static_cast<size_t>( dims[0] ) , "DXV");
assertVectorSize( DYV , static_cast<size_t>( dims[1] ) , "DYV");
assertVectorSize( DZV , static_cast<size_t>( dims[2] ) , "DZV");
m_grid.reset( ecl_grid_alloc_dxv_dyv_dzv_depthz( dims[0] , dims[1] , dims[2] , DXV.data() , DYV.data() , DZV.data() , DEPTHZ.data() , NULL ) , ecl_grid_free);
}
void EclipseGrid::initDTOPSGrid(const std::vector<int>& dims , DeckConstPtr deck) {
std::vector<double> DX = createDVector( dims , 0 , "DX" , "DXV" , deck);
std::vector<double> DY = createDVector( dims , 1 , "DY" , "DYV" , deck);
std::vector<double> DZ = createDVector( dims , 2 , "DZ" , "DZV" , deck);
std::vector<double> TOPS = createTOPSVector( dims , DZ , deck );
m_grid.reset( ecl_grid_alloc_dx_dy_dz_tops( dims[0] , dims[1] , dims[2] , DX.data() , DY.data() , DZ.data() , TOPS.data() , NULL ) , ecl_grid_free);
}
std::vector<double> EclipseGrid::createTOPSVector(const std::vector<int>& dims , const std::vector<double>& DZ , DeckConstPtr deck) { std::vector<double> EclipseGrid::createTOPSVector(const std::vector<int>& dims , const std::vector<double>& DZ , DeckConstPtr deck) {
@ -466,52 +455,117 @@ namespace Opm {
} }
} }
/*
This function checks if the grid has a pointer to an underlying
ecl_grid_type; which must be used to read cell info as
size/depth/active of individual cells.
*/
bool EclipseGrid::hasCellInfo() const {
return static_cast<bool>( m_grid );
}
void EclipseGrid::assertCellInfo() const {
if (!hasCellInfo())
throw std::invalid_argument("Tried to access cell information in a grid with only dimensions");
}
const ecl_grid_type * EclipseGrid::c_ptr() const {
assertCellInfo();
return m_grid.get();
}
bool EclipseGrid::equal(const EclipseGrid& other) const {
return (m_pinch.equal( other.m_pinch ) &&
m_minpv.equal( other.m_minpv ) &&
ecl_grid_compare( c_ptr() , other.c_ptr() , true , false , false ));
}
size_t EclipseGrid::getNumActive( ) const {
return static_cast<size_t>(ecl_grid_get_nactive( c_ptr() ));
}
double EclipseGrid::getCellVolume(size_t globalIndex) const {
assertGlobalIndex( globalIndex );
return ecl_grid_get_cell_volume1( c_ptr() , static_cast<int>(globalIndex));
}
double EclipseGrid::getCellVolume(size_t i , size_t j , size_t k) const {
assertIJK(i,j,k);
return ecl_grid_get_cell_volume3( c_ptr() , static_cast<int>(i),static_cast<int>(j),static_cast<int>(k));
}
std::tuple<double,double,double> EclipseGrid::getCellCenter(size_t globalIndex) const {
assertGlobalIndex( globalIndex );
{
double x,y,z;
ecl_grid_get_xyz1( c_ptr() , static_cast<int>(globalIndex) , &x , &y , &z);
return std::tuple<double,double,double> {x,y,z};
}
}
std::tuple<double,double,double> EclipseGrid::getCellCenter(size_t i,size_t j, size_t k) const {
assertIJK(i,j,k);
{
double x,y,z;
ecl_grid_get_xyz3( c_ptr() , static_cast<int>(i),static_cast<int>(j),static_cast<int>(k), &x , &y , &z);
return std::tuple<double,double,double> {x,y,z};
}
}
void EclipseGrid::exportACTNUM( std::vector<int>& actnum) const { void EclipseGrid::exportACTNUM( std::vector<int>& actnum) const {
size_t volume = getNX() * getNY() * getNZ(); size_t volume = getNX() * getNY() * getNZ();
if (getNumActive() == volume) if (getNumActive() == volume)
actnum.resize(0); actnum.resize(0);
else { else {
actnum.resize( volume ); actnum.resize( volume );
ecl_grid_init_actnum_data( m_grid.get() , actnum.data() ); ecl_grid_init_actnum_data( c_ptr() , actnum.data() );
} }
} }
void EclipseGrid::exportMAPAXES( std::vector<double>& mapaxes) const { void EclipseGrid::exportMAPAXES( std::vector<double>& mapaxes) const {
if (ecl_grid_use_mapaxes( m_grid.get())) { if (ecl_grid_use_mapaxes( c_ptr())) {
mapaxes.resize(6); mapaxes.resize(6);
ecl_grid_init_mapaxes_data_double( m_grid.get() , mapaxes.data() ); ecl_grid_init_mapaxes_data_double( c_ptr() , mapaxes.data() );
} else { } else {
mapaxes.resize(0); mapaxes.resize(0);
} }
} }
void EclipseGrid::exportCOORD( std::vector<double>& coord) const { void EclipseGrid::exportCOORD( std::vector<double>& coord) const {
coord.resize( ecl_grid_get_coord_size( m_grid.get() )); coord.resize( ecl_grid_get_coord_size( c_ptr() ));
ecl_grid_init_coord_data_double( m_grid.get() , coord.data() ); ecl_grid_init_coord_data_double( c_ptr() , coord.data() );
} }
void EclipseGrid::exportZCORN( std::vector<double>& zcorn) const { void EclipseGrid::exportZCORN( std::vector<double>& zcorn) const {
zcorn.resize( ecl_grid_get_zcorn_size( m_grid.get() )); zcorn.resize( ecl_grid_get_zcorn_size( c_ptr() ));
ecl_grid_init_zcorn_data_double( m_grid.get() , zcorn.data() ); ecl_grid_init_zcorn_data_double( c_ptr() , zcorn.data() );
} }
void EclipseGrid::resetACTNUM( const int * actnum) { void EclipseGrid::resetACTNUM( const int * actnum) {
assertCellInfo();
ecl_grid_reset_actnum( m_grid.get() , actnum ); ecl_grid_reset_actnum( m_grid.get() , actnum );
} }
void EclipseGrid::fwriteEGRID( const std::string& filename ) const { void EclipseGrid::fwriteEGRID( const std::string& filename ) const {
assertCellInfo();
ecl_grid_fwrite_EGRID( m_grid.get() , filename.c_str() ); ecl_grid_fwrite_EGRID( m_grid.get() , filename.c_str() );
} }
const ecl_grid_type * EclipseGrid::c_ptr() const {
return m_grid.get();
}
} }

View File

@ -33,10 +33,41 @@
namespace Opm { namespace Opm {
/**
About cell information and dimension: The actual grid
information is held in a pointer to an ERT ecl_grid_type
instance. This pointer must be used for access to all cell
related properties, including:
- Size of cells
- Real world position of cells
- Active/inactive status of cells
However in may cases the only required information is the
dimension of the grid. To facilitate simpler use, in particular
in testing, the grid dimensions are internalized separate from
the ecl_grid_type pointer. This means that in many cases a grid
without the underlying ecl_grid_type pointer is sufficient. To
create such a 'naked' grid you can parse a deck with only
DIMENS / SPECGRID and no further grid related keywords, or
alternatively use the:
EclipseGrid::EclipseGrid(nx,ny,nz)
constructor.
To query a grid instance if it has proper underlying grid
support use the method:
bool EclipseGrid::hasCellInfo();
*/
class EclipseGrid { class EclipseGrid {
public: public:
explicit EclipseGrid(const std::string& filename); explicit EclipseGrid(const std::string& filename);
explicit EclipseGrid(const ecl_grid_type * src_ptr); explicit EclipseGrid(const ecl_grid_type * src_ptr);
explicit EclipseGrid(size_t nx, size_t ny , size_t nz);
explicit EclipseGrid(std::shared_ptr<const Deck> deck, ParserLogPtr parserLog = std::make_shared<ParserLog>()); explicit EclipseGrid(std::shared_ptr<const Deck> deck, ParserLogPtr parserLog = std::make_shared<ParserLog>());
static bool hasCornerPointKeywords(std::shared_ptr<const Deck> deck); static bool hasCornerPointKeywords(std::shared_ptr<const Deck> deck);
@ -50,6 +81,7 @@ namespace Opm {
double getPinchThresholdThickness( ) const; double getPinchThresholdThickness( ) const;
bool isMinpvActive( ) const; bool isMinpvActive( ) const;
double getMinpvValue( ) const; double getMinpvValue( ) const;
bool hasCellInfo() const;
void assertGlobalIndex(size_t globalIndex) const; void assertGlobalIndex(size_t globalIndex) const;
void assertIJK(size_t i , size_t j , size_t k) const; void assertIJK(size_t i , size_t j , size_t k) const;
@ -70,19 +102,25 @@ namespace Opm {
std::shared_ptr<ecl_grid_type> m_grid; std::shared_ptr<ecl_grid_type> m_grid;
Value<double> m_minpv; Value<double> m_minpv;
Value<double> m_pinch; Value<double> m_pinch;
size_t m_nx;
size_t m_ny;
size_t m_nz;
void assertCellInfo() const;
void initCartesianGrid(const std::vector<int>& dims , DeckConstPtr deck); void initCartesianGrid(const std::vector<int>& dims , DeckConstPtr deck);
void initCornerPointGrid(const std::vector<int>& dims , DeckConstPtr deck, ParserLogPtr parserLog); void initCornerPointGrid(const std::vector<int>& dims , DeckConstPtr deck, ParserLogPtr parserLog);
void assertCornerPointKeywords(const std::vector<int>& dims, DeckConstPtr deck, ParserLogPtr parserLog) const ;
void initDTOPSGrid(const std::vector<int>& dims , DeckConstPtr deck); void initDTOPSGrid(const std::vector<int>& dims , DeckConstPtr deck);
void initDVDEPTHZGrid(const std::vector<int>& dims , DeckConstPtr deck); void initDVDEPTHZGrid(const std::vector<int>& dims , DeckConstPtr deck);
void initGrid(const std::vector<int>& dims, DeckConstPtr deck, ParserLogPtr parserLog); void initGrid(const std::vector<int>& dims, DeckConstPtr deck, ParserLogPtr parserLog);
static void assertCornerPointKeywords(const std::vector<int>& dims, DeckConstPtr deck, ParserLogPtr parserLog) ;
static bool hasDVDEPTHZKeywords(DeckConstPtr deck); static bool hasDVDEPTHZKeywords(DeckConstPtr deck);
static bool hasDTOPSKeywords(DeckConstPtr deck); static bool hasDTOPSKeywords(DeckConstPtr deck);
static void assertVectorSize(const std::vector<double>& vector , size_t expectedSize , const std::string& msg); static void assertVectorSize(const std::vector<double>& vector , size_t expectedSize , const std::string& msg);
std::vector<double> createTOPSVector(const std::vector<int>& dims , const std::vector<double>& DZ , DeckConstPtr deck); static std::vector<double> createTOPSVector(const std::vector<int>& dims , const std::vector<double>& DZ , DeckConstPtr deck);
std::vector<double> createDVector(const std::vector<int>& dims , size_t dim , const std::string& DKey , const std::string& DVKey, DeckConstPtr deck); static std::vector<double> createDVector(const std::vector<int>& dims , size_t dim , const std::string& DKey , const std::string& DVKey, DeckConstPtr deck);
void scatterDim(const std::vector<int>& dims , size_t dim , const std::vector<double>& DV , std::vector<double>& D); static void scatterDim(const std::vector<int>& dims , size_t dim , const std::vector<double>& DV , std::vector<double>& D);
}; };
typedef std::shared_ptr<EclipseGrid> EclipseGridPtr; typedef std::shared_ptr<EclipseGrid> EclipseGridPtr;

View File

@ -25,6 +25,7 @@
#include <tuple> #include <tuple>
#include <unordered_map> #include <unordered_map>
#include <opm/parser/eclipse/EclipseState/Grid/EclipseGrid.hpp>
#include <opm/parser/eclipse/EclipseState/Grid/GridProperty.hpp> #include <opm/parser/eclipse/EclipseState/Grid/GridProperty.hpp>
/* /*
@ -51,12 +52,9 @@ class GridProperties {
public: public:
typedef typename GridProperty<T>::SupportedKeywordInfo SupportedKeywordInfo; typedef typename GridProperty<T>::SupportedKeywordInfo SupportedKeywordInfo;
GridProperties(size_t nx , size_t ny , size_t nz , GridProperties(std::shared_ptr<const EclipseGrid> eclipseGrid , std::shared_ptr<const std::vector<SupportedKeywordInfo> > supportedKeywords) {
std::shared_ptr<const std::vector<SupportedKeywordInfo> > supportedKeywords) { m_eclipseGrid = eclipseGrid;
m_nx = nx;
m_ny = ny;
m_nz = nz;
for (auto iter = supportedKeywords->begin(); iter != supportedKeywords->end(); ++iter) for (auto iter = supportedKeywords->begin(); iter != supportedKeywords->end(); ++iter)
m_supportedKeywords[iter->getKeywordName()] = *iter; m_supportedKeywords[iter->getKeywordName()] = *iter;
} }
@ -78,7 +76,6 @@ public:
return m_properties.at( keyword ); return m_properties.at( keyword );
} }
bool addKeyword(const std::string& keywordName) { bool addKeyword(const std::string& keywordName) {
if (!supportsKeyword( keywordName )) if (!supportsKeyword( keywordName ))
throw std::invalid_argument("The keyword: " + keywordName + " is not supported in this container"); throw std::invalid_argument("The keyword: " + keywordName + " is not supported in this container");
@ -87,7 +84,10 @@ public:
return false; return false;
else { else {
auto supportedKeyword = m_supportedKeywords.at( keywordName ); auto supportedKeyword = m_supportedKeywords.at( keywordName );
std::shared_ptr<GridProperty<T> > newProperty(new GridProperty<T>(m_nx , m_ny , m_nz , supportedKeyword)); 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 )); m_properties.insert( std::pair<std::string , std::shared_ptr<GridProperty<T> > > ( keywordName , newProperty ));
return true; return true;
@ -96,7 +96,7 @@ public:
private: private:
size_t m_nx, m_ny, m_nz; std::shared_ptr<const EclipseGrid> m_eclipseGrid;
std::unordered_map<std::string, SupportedKeywordInfo> m_supportedKeywords; std::unordered_map<std::string, SupportedKeywordInfo> m_supportedKeywords;
std::map<std::string , std::shared_ptr<GridProperty<T> > > m_properties; std::map<std::string , std::shared_ptr<GridProperty<T> > > m_properties;
}; };

View File

@ -65,6 +65,23 @@ static Opm::DeckPtr createDeckHeaders() {
} }
static Opm::DeckPtr createDeckMissingDIMS() {
const char *deckData =
"RUNSPEC\n"
"\n"
"GRID\n"
"EDIT\n"
"\n";
Opm::ParserPtr parser(new Opm::Parser());
return parser->parseString(deckData) ;
}
BOOST_AUTO_TEST_CASE(MissingDimsThrows) {
Opm::DeckPtr deck = createDeckMissingDIMS();
BOOST_CHECK_THROW( new Opm::EclipseGrid( deck ) , std::invalid_argument);
}
BOOST_AUTO_TEST_CASE(HasGridKeywords) { BOOST_AUTO_TEST_CASE(HasGridKeywords) {
Opm::DeckPtr deck = createDeckHeaders(); Opm::DeckPtr deck = createDeckHeaders();
@ -72,6 +89,18 @@ BOOST_AUTO_TEST_CASE(HasGridKeywords) {
BOOST_CHECK( !Opm::EclipseGrid::hasCartesianKeywords( deck )); BOOST_CHECK( !Opm::EclipseGrid::hasCartesianKeywords( deck ));
} }
BOOST_AUTO_TEST_CASE(CreateGridNoCells) {
Opm::DeckPtr deck = createDeckHeaders();
Opm::EclipseGrid grid( deck );
BOOST_CHECK_EQUAL( 10 , grid.getNX());
BOOST_CHECK_EQUAL( 10 , grid.getNY());
BOOST_CHECK_EQUAL( 10 , grid.getNZ());
BOOST_CHECK_EQUAL( 1000 , grid.getCartesianSize());
}
static Opm::DeckPtr createCPDeck() { static Opm::DeckPtr createCPDeck() {
const char *deckData = const char *deckData =
"RUNSPEC\n" "RUNSPEC\n"
@ -228,6 +257,17 @@ static Opm::DeckPtr createCARTInvalidDeck() {
return parser->parseString(deckData) ; return parser->parseString(deckData) ;
} }
BOOST_AUTO_TEST_CASE(CREATE_SIMPLE) {
Opm::EclipseGrid grid(10,20,30);
BOOST_CHECK_EQUAL( grid.getNX() , 10 );
BOOST_CHECK_EQUAL( grid.getNY() , 20 );
BOOST_CHECK_EQUAL( grid.getNZ() , 30 );
BOOST_CHECK_EQUAL( grid.getCartesianSize() , 6000 );
BOOST_CHECK_EQUAL( false , grid.hasCellInfo() );
}
BOOST_AUTO_TEST_CASE(DEPTHZ_EQUAL_TOPS) { BOOST_AUTO_TEST_CASE(DEPTHZ_EQUAL_TOPS) {
Opm::DeckPtr deck1 = createCARTDeck(); Opm::DeckPtr deck1 = createCARTDeck();
Opm::DeckPtr deck2 = createCARTDeckDEPTHZ(); Opm::DeckPtr deck2 = createCARTDeckDEPTHZ();
@ -306,7 +346,8 @@ BOOST_AUTO_TEST_CASE(HasINVALIDCartKeywords) {
BOOST_AUTO_TEST_CASE(CreateMissingGRID_throws) { BOOST_AUTO_TEST_CASE(CreateMissingGRID_throws) {
Opm::DeckPtr deck = createDeckHeaders(); Opm::DeckPtr deck = createDeckHeaders();
BOOST_CHECK_THROW(new Opm::EclipseGrid( deck ) , std::invalid_argument); Opm::EclipseGrid grid( deck );
BOOST_CHECK_EQUAL( false , grid.hasCellInfo() );
} }
@ -366,7 +407,8 @@ static Opm::DeckPtr createInvalidDXYZCARTDeckDEPTHZ() {
BOOST_AUTO_TEST_CASE(CreateCartesianGRIDDEPTHZ) { BOOST_AUTO_TEST_CASE(CreateCartesianGRIDDEPTHZ) {
Opm::DeckPtr deck = createInvalidDXYZCARTDeckDEPTHZ(); Opm::DeckPtr deck = createInvalidDXYZCARTDeckDEPTHZ();
BOOST_CHECK_THROW(new Opm::EclipseGrid( deck ) , std::invalid_argument); Opm::EclipseGrid grid( deck );
BOOST_CHECK_EQUAL( false , grid.hasCellInfo() );
} }

View File

@ -41,7 +41,9 @@ BOOST_AUTO_TEST_CASE(Empty) {
SupportedKeywordInfo("SATNUM" , 0, "1"), SupportedKeywordInfo("SATNUM" , 0, "1"),
SupportedKeywordInfo("FIPNUM" , 2, "1") SupportedKeywordInfo("FIPNUM" , 2, "1")
}); });
Opm::GridProperties<int> gridProperties( 10, 10, 100 , supportedKeywords);
std::shared_ptr<const Opm::EclipseGrid> grid = std::make_shared<const Opm::EclipseGrid>(10,7,9);
Opm::GridProperties<int> gridProperties( grid , supportedKeywords);
BOOST_CHECK( gridProperties.supportsKeyword("SATNUM") ); BOOST_CHECK( gridProperties.supportsKeyword("SATNUM") );
BOOST_CHECK( gridProperties.supportsKeyword("FIPNUM") ); BOOST_CHECK( gridProperties.supportsKeyword("FIPNUM") );
@ -57,13 +59,13 @@ BOOST_AUTO_TEST_CASE(addKeyword) {
std::shared_ptr<std::vector<SupportedKeywordInfo> > supportedKeywords(new std::vector<SupportedKeywordInfo>{ std::shared_ptr<std::vector<SupportedKeywordInfo> > supportedKeywords(new std::vector<SupportedKeywordInfo>{
SupportedKeywordInfo("SATNUM" , 0, "1") SupportedKeywordInfo("SATNUM" , 0, "1")
}); });
Opm::GridProperties<int> gridProperties( 100, 10 , 10 , supportedKeywords); std::shared_ptr<const Opm::EclipseGrid> grid = std::make_shared<const Opm::EclipseGrid>(10,7,9);
Opm::GridProperties<int> gridProperties( grid , supportedKeywords);
BOOST_CHECK_THROW( gridProperties.addKeyword("NOT-SUPPORTED") , std::invalid_argument); BOOST_CHECK_THROW( gridProperties.addKeyword("NOT-SUPPORTED") , std::invalid_argument);
BOOST_CHECK( gridProperties.addKeyword("SATNUM")); BOOST_CHECK( gridProperties.addKeyword("SATNUM"));
BOOST_CHECK( !gridProperties.addKeyword("SATNUM")); BOOST_CHECK( !gridProperties.addKeyword("SATNUM"));
BOOST_CHECK( gridProperties.hasKeyword("SATNUM")); BOOST_CHECK( gridProperties.hasKeyword("SATNUM"));
} }
@ -74,7 +76,8 @@ BOOST_AUTO_TEST_CASE(getKeyword) {
std::shared_ptr<std::vector<SupportedKeywordInfo> > supportedKeywords(new std::vector<SupportedKeywordInfo>{ std::shared_ptr<std::vector<SupportedKeywordInfo> > supportedKeywords(new std::vector<SupportedKeywordInfo>{
SupportedKeywordInfo("SATNUM" , 0, "1") SupportedKeywordInfo("SATNUM" , 0, "1")
}); });
Opm::GridProperties<int> gridProperties( 100,25,4 , supportedKeywords); std::shared_ptr<const Opm::EclipseGrid> grid = std::make_shared<const Opm::EclipseGrid>(10,7,9);
Opm::GridProperties<int> gridProperties( grid , supportedKeywords);
std::shared_ptr<Opm::GridProperty<int> > satnum1 = gridProperties.getKeyword("SATNUM"); 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> > satnum2 = gridProperties.getKeyword("SATNUM");

View File

@ -427,9 +427,9 @@ BOOST_AUTO_TEST_CASE(GridPropertyPostProcessors) {
SupportedKeywordInfo kwInfo2("PORO" , 1.0 , testPostP , "1"); SupportedKeywordInfo kwInfo2("PORO" , 1.0 , testPostP , "1");
std::shared_ptr<std::vector<SupportedKeywordInfo> > supportedKeywords(new std::vector<SupportedKeywordInfo>{ std::shared_ptr<std::vector<SupportedKeywordInfo> > supportedKeywords(new std::vector<SupportedKeywordInfo>{
kwInfo1 , kwInfo2 }); kwInfo1 , kwInfo2 });
Opm::GridProperties<double> properties(10,10,10,supportedKeywords);
Opm::DeckPtr deck = createDeck(); Opm::DeckPtr deck = createDeck();
Opm::EclipseGrid grid(deck); std::shared_ptr<Opm::EclipseGrid> grid = std::make_shared<Opm::EclipseGrid>(deck);
Opm::GridProperties<double> properties(grid, supportedKeywords);
{ {
auto poro = properties.getKeyword("PORO"); auto poro = properties.getKeyword("PORO");

View File

@ -70,14 +70,6 @@ static Opm::DeckPtr createInvalidMULTREGTDeck() {
"DIMENS\n" "DIMENS\n"
" 3 3 2 /\n" " 3 3 2 /\n"
"GRID\n" "GRID\n"
"DX\n"
"18*0.25 /\n"
"DYV\n"
"3*0.25 /\n"
"DZ\n"
"18*0.25 /\n"
"TOPS\n"
"9*0.25 /\n"
"FLUXNUM\n" "FLUXNUM\n"
"1 1 2\n" "1 1 2\n"
"1 1 2\n" "1 1 2\n"
@ -114,8 +106,8 @@ BOOST_AUTO_TEST_CASE(InvalidInput) {
Opm::MULTREGTScanner scanner; Opm::MULTREGTScanner scanner;
Opm::DeckPtr deck = createInvalidMULTREGTDeck(); Opm::DeckPtr deck = createInvalidMULTREGTDeck();
Opm::EclipseGrid grid(deck); 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.getNX() , grid.getNY() , grid.getNZ() , supportedKeywords); std::shared_ptr<Opm::GridProperties<int> > gridProperties = std::make_shared<Opm::GridProperties<int> >(grid, supportedKeywords);
Opm::DeckKeywordConstPtr multregtKeyword0 = deck->getKeyword("MULTREGT",0); Opm::DeckKeywordConstPtr multregtKeyword0 = deck->getKeyword("MULTREGT",0);
Opm::DeckKeywordConstPtr multregtKeyword1 = deck->getKeyword("MULTREGT",1); Opm::DeckKeywordConstPtr multregtKeyword1 = deck->getKeyword("MULTREGT",1);
Opm::DeckKeywordConstPtr multregtKeyword2 = deck->getKeyword("MULTREGT",2); Opm::DeckKeywordConstPtr multregtKeyword2 = deck->getKeyword("MULTREGT",2);
@ -140,14 +132,6 @@ static Opm::DeckPtr createNotSupportedMULTREGTDeck() {
"DIMENS\n" "DIMENS\n"
" 3 3 2 /\n" " 3 3 2 /\n"
"GRID\n" "GRID\n"
"DX\n"
"18*0.25 /\n"
"DYV\n"
"3*0.25 /\n"
"DZ\n"
"18*0.25 /\n"
"TOPS\n"
"9*0.25 /\n"
"FLUXNUM\n" "FLUXNUM\n"
"1 1 2\n" "1 1 2\n"
"1 1 2\n" "1 1 2\n"
@ -209,14 +193,6 @@ static Opm::DeckPtr createSimpleMULTREGTDeck() {
"DIMENS\n" "DIMENS\n"
"2 2 2 /\n" "2 2 2 /\n"
"GRID\n" "GRID\n"
"DX\n"
"8*0.25 /\n"
"DYV\n"
"2*0.25 /\n"
"DZ\n"
"8*0.25 /\n"
"TOPS\n"
"4*0.25 /\n"
"FLUXNUM\n" "FLUXNUM\n"
"1 2\n" "1 2\n"
"1 2\n" "1 2\n"
@ -251,10 +227,10 @@ BOOST_AUTO_TEST_CASE(SimpleMULTREGT) {
SupportedKeywordInfo("MULTNUM" , 1 , "1") }); SupportedKeywordInfo("MULTNUM" , 1 , "1") });
Opm::DeckPtr deck = createSimpleMULTREGTDeck(); Opm::DeckPtr deck = createSimpleMULTREGTDeck();
Opm::EclipseGrid grid(deck); std::shared_ptr<Opm::EclipseGrid> grid = std::make_shared<Opm::EclipseGrid>( deck );
std::shared_ptr<const Opm::Box> inputBox = std::make_shared<const Opm::Box>( grid.getNX() , grid.getNY() , grid.getNZ() ); std::shared_ptr<const Opm::Box> inputBox = std::make_shared<const Opm::Box>( grid->getNX() , grid->getNY() , grid->getNZ() );
std::shared_ptr<Opm::GridProperties<int> > gridProperties = std::make_shared<Opm::GridProperties<int> >( grid.getNX() , grid.getNY() , grid.getNZ() , supportedKeywords); std::shared_ptr<Opm::GridProperties<int> > gridProperties = std::make_shared<Opm::GridProperties<int> >(grid, supportedKeywords);
std::shared_ptr<Opm::GridProperty<int> > fluxNum = gridProperties->getKeyword("FLUXNUM"); std::shared_ptr<Opm::GridProperty<int> > fluxNum = gridProperties->getKeyword("FLUXNUM");
std::shared_ptr<Opm::GridProperty<int> > multNum = gridProperties->getKeyword("MULTNUM"); std::shared_ptr<Opm::GridProperty<int> > multNum = gridProperties->getKeyword("MULTNUM");
Opm::DeckKeywordConstPtr fluxnumKeyword = deck->getKeyword("FLUXNUM",0); Opm::DeckKeywordConstPtr fluxnumKeyword = deck->getKeyword("FLUXNUM",0);
@ -316,14 +292,6 @@ static Opm::DeckPtr createCopyMULTNUMDeck() {
"DIMENS\n" "DIMENS\n"
"2 2 2 /\n" "2 2 2 /\n"
"GRID\n" "GRID\n"
"DX\n"
"8*0.25 /\n"
"DYV\n"
"2*0.25 /\n"
"DZ\n"
"8*0.25 /\n"
"TOPS\n"
"4*0.25 /\n"
"FLUXNUM\n" "FLUXNUM\n"
"1 2\n" "1 2\n"
"1 2\n" "1 2\n"

View File

@ -319,3 +319,29 @@ BOOST_AUTO_TEST_CASE(PORV_multpvAndNtg) {
BOOST_CHECK_CLOSE( PORV * multpv , porv->iget(0,0,0) , 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); BOOST_CHECK_CLOSE( cell_volume * poro*multpv*NTG , porv->iget(9,9,9) , 0.001);
} }
static Opm::DeckPtr createDeckNakedGRID() {
const char *deckData =
"RUNSPEC\n"
"\n"
"DIMENS\n"
" 10 10 10 /\n"
"GRID\n"
"PORO\n"
"100*0.10 100*0.20 100*0.30 100*0.40 100*0.50 100*0.60 100*0.70 100*0.80 100*0.90 100*1.0 /\n"
"EDIT\n"
"\n";
Opm::ParserPtr parser(new Opm::Parser());
return parser->parseString(deckData) ;
}
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);
BOOST_CHECK_THROW( state->getDoubleGridProperty("PORV") , std::invalid_argument );
}

View File

@ -113,6 +113,7 @@ BOOST_AUTO_TEST_CASE(GetPOROTOPBased) {
} }
static DeckPtr createDeck() { static DeckPtr createDeck() {
const char *deckData = const char *deckData =
"RUNSPEC\n" "RUNSPEC\n"
@ -120,14 +121,6 @@ static DeckPtr createDeck() {
"DIMENS\n" "DIMENS\n"
" 10 10 10 /\n" " 10 10 10 /\n"
"GRID\n" "GRID\n"
"DX\n"
"1000*0.25 /\n"
"DYV\n"
"10*0.25 /\n"
"DZ\n"
"1000*0.25 /\n"
"TOPS\n"
"1000*0.25 /\n"
"FAULTS \n" "FAULTS \n"
" 'F1' 1 1 1 4 1 4 'X' / \n" " 'F1' 1 1 1 4 1 4 'X' / \n"
" 'F2' 5 5 1 4 1 4 'X-' / \n" " 'F2' 5 5 1 4 1 4 'X-' / \n"
@ -169,14 +162,6 @@ static DeckPtr createDeckNoFaults() {
"DIMENS\n" "DIMENS\n"
" 10 10 10 /\n" " 10 10 10 /\n"
"GRID\n" "GRID\n"
"DX\n"
"1000*0.25 /\n"
"DYV\n"
"10*0.25 /\n"
"DZ\n"
"1000*0.25 /\n"
"TOPS\n"
"1000*0.25 /\n"
"PROPS\n" "PROPS\n"
"-- multiply one layer for each face\n" "-- multiply one layer for each face\n"
"MULTX\n" "MULTX\n"
@ -197,16 +182,7 @@ static DeckPtr createDeckNoFaults() {
return parser->parseString(deckData) ; return parser->parseString(deckData) ;
} }
BOOST_AUTO_TEST_CASE(StrictSemantics) { BOOST_AUTO_TEST_CASE(CreateSchedule) {
DeckPtr deck = createDeck();
EclipseState state(deck);
// the deck misses a few sections...
ParserLogPtr parserLog(new ParserLog());
BOOST_CHECK(!checkDeck(deck, parserLog));
}
BOOST_AUTO_TEST_CASE(CreatSchedule) {
DeckPtr deck = createDeck(); DeckPtr deck = createDeck();
EclipseState state(deck); EclipseState state(deck);
ScheduleConstPtr schedule = state.getSchedule(); ScheduleConstPtr schedule = state.getSchedule();

View File

@ -142,6 +142,7 @@ BOOST_AUTO_TEST_CASE( EQUAL ) {
EclipseState state = makeState("testdata/integration_tests/BOX/BOXTEST1", parserLog); EclipseState state = makeState("testdata/integration_tests/BOX/BOXTEST1", parserLog);
std::shared_ptr<GridProperty<int> > pvtnum = state.getIntGridProperty("PVTNUM"); std::shared_ptr<GridProperty<int> > pvtnum = state.getIntGridProperty("PVTNUM");
std::shared_ptr<GridProperty<int> > eqlnum = state.getIntGridProperty("EQLNUM"); std::shared_ptr<GridProperty<int> > eqlnum = state.getIntGridProperty("EQLNUM");
std::shared_ptr<GridProperty<double> > poro = state.getDoubleGridProperty("PORO");
size_t i,j,k; size_t i,j,k;
std::shared_ptr<const EclipseGrid> grid = state.getEclipseGrid(); std::shared_ptr<const EclipseGrid> grid = state.getEclipseGrid();
@ -151,6 +152,7 @@ BOOST_AUTO_TEST_CASE( EQUAL ) {
BOOST_CHECK_EQUAL( pvtnum->iget(i,j,k) , k ); BOOST_CHECK_EQUAL( pvtnum->iget(i,j,k) , k );
BOOST_CHECK_EQUAL( eqlnum->iget(i,j,k) , 77 + 2 * k ); BOOST_CHECK_EQUAL( eqlnum->iget(i,j,k) , 77 + 2 * k );
BOOST_CHECK_EQUAL( poro->iget(i,j,k) , 0.25 );
} }
} }

View File

@ -524,7 +524,7 @@ namespace Opm {
DeckKeywordPtr ParserKeyword::parse(RawKeywordConstPtr rawKeyword) const { DeckKeywordPtr ParserKeyword::parse(RawKeywordConstPtr rawKeyword) const {
if (rawKeyword->isFinished()) { if (rawKeyword->isFinished()) {
DeckKeywordPtr keyword(new DeckKeyword(rawKeyword->getKeywordName())); DeckKeywordPtr keyword(new DeckKeyword(rawKeyword->getKeywordName()));
keyword->setLocation(rawKeyword->getFilename(), rawKeyword->getLineNR()); keyword->setLocation(rawKeyword->getFilename(), rawKeyword->getLineNR());
for (size_t i = 0; i < rawKeyword->size(); i++) { for (size_t i = 0; i < rawKeyword->size(); i++) {
DeckRecordConstPtr deckRecord = m_record->parse(rawKeyword->getRecord(i)); DeckRecordConstPtr deckRecord = m_record->parse(rawKeyword->getRecord(i));
keyword->addRecord(deckRecord); keyword->addRecord(deckRecord);
@ -532,13 +532,12 @@ namespace Opm {
keyword->setDataKeyword( isDataKeyword() ); keyword->setDataKeyword( isDataKeyword() );
return keyword; return keyword;
} else } else
throw std::invalid_argument("Tried to create a deck keyword from an imcomplete rawkeyword: " + rawKeyword->getKeywordName()); throw std::invalid_argument("Tried to create a deck keyword from an incomplete raw keyword " + rawKeyword->getKeywordName());
} }
size_t ParserKeyword::getFixedSize() const { size_t ParserKeyword::getFixedSize() const {
if (!hasFixedSize()) { if (!hasFixedSize())
throw std::logic_error("This parser keyword does not have a fixed size!"); throw std::logic_error("The parser keyword "+getName()+" does not have a fixed size!");
}
return m_fixedSize; return m_fixedSize;
} }

View File

@ -1,10 +1,10 @@
{"name" : "ADD", "sections" : ["GRID", "EDIT", "PROPS", "REGIONS", "SOLUTION"], "items" : [ {"name" : "ADD", "sections" : ["GRID", "EDIT", "PROPS", "REGIONS", "SOLUTION"], "items" : [
{"name" : "field" , "value_type" : "STRING"}, {"name" : "field" , "value_type" : "STRING"},
{"name" : "shift" , "value_type" : "DOUBLE"}, {"name" : "shift" , "value_type" : "DOUBLE"},
{"name" : "I1" , "value_type" : "INT", "default" : 0}, {"name" : "I1" , "value_type" : "INT"},
{"name" : "I2" , "value_type" : "INT", "default" : 0}, {"name" : "I2" , "value_type" : "INT"},
{"name" : "J1" , "value_type" : "INT", "default" : 0}, {"name" : "J1" , "value_type" : "INT"},
{"name" : "J2" , "value_type" : "INT", "default" : 0}, {"name" : "J2" , "value_type" : "INT"},
{"name" : "K1" , "value_type" : "INT", "default" : 0}, {"name" : "K1" , "value_type" : "INT"},
{"name" : "K2" , "value_type" : "INT", "default" : 0}]} {"name" : "K2" , "value_type" : "INT"}]}

View File

@ -6,4 +6,4 @@
{"name" : "J1" , "value_type" : "INT"}, {"name" : "J1" , "value_type" : "INT"},
{"name" : "J2" , "value_type" : "INT"}, {"name" : "J2" , "value_type" : "INT"},
{"name" : "K1" , "value_type" : "INT"}, {"name" : "K1" , "value_type" : "INT"},
{"name" : "K2" , "value_type" : "INT"}]} {"name" : "K2" , "value_type" : "INT"}]}

View File

@ -1,9 +1,9 @@
{"name" : "MULTIPLY", "sections" : ["GRID", "EDIT", "PROPS", "REGIONS", "SOLUTION"], "items" : [ {"name" : "MULTIPLY", "sections" : ["GRID", "EDIT", "PROPS", "REGIONS", "SOLUTION"], "items" : [
{"name" : "field" , "value_type" : "STRING"}, {"name" : "field" , "value_type" : "STRING"},
{"name" : "factor" , "value_type" : "DOUBLE"}, {"name" : "factor" , "value_type" : "DOUBLE"},
{"name" : "I1" , "value_type" : "INT" , "default" : 0}, {"name" : "I1" , "value_type" : "INT" },
{"name" : "I2" , "value_type" : "INT" , "default" : 0}, {"name" : "I2" , "value_type" : "INT" },
{"name" : "J1" , "value_type" : "INT" , "default" : 0}, {"name" : "J1" , "value_type" : "INT" },
{"name" : "J2" , "value_type" : "INT" , "default" : 0}, {"name" : "J2" , "value_type" : "INT" },
{"name" : "K1" , "value_type" : "INT" , "default" : 0}, {"name" : "K1" , "value_type" : "INT" },
{"name" : "K2" , "value_type" : "INT" , "default" : 0}]} {"name" : "K2" , "value_type" : "INT" }]}

View File

@ -5,18 +5,6 @@ DIMENS
GRID GRID
DX
1000*0.25 /
DYV
10*0.25 /
DZ
1000*0.25 /
TOPS
1000*0.25 /
PERMX PERMX
1000*1 / 1000*1 /
@ -33,6 +21,10 @@ MULTIPLY
PERMZ 0.25 / PERMZ 0.25 /
/ /
EQUALS
PORO 0.25 /
/
EDIT EDIT
OIL OIL

View File

@ -5,17 +5,6 @@ DIMENS
GRID GRID
DX
1000*0.25 /
DYV
10*0.25 /
DZ
1000*0.25 /
TOPS
1000*0.25 /
EDIT EDIT

View File

@ -5,18 +5,6 @@ DIMENS
GRID GRID
DX
1000*0.25 /
DYV
10*0.25 /
DZ
1000*0.25 /
TOPS
1000*0.25 /
EDIT EDIT
OIL OIL