From af6f18b5aa2255ff924528b65d3edbfd8fc2888a Mon Sep 17 00:00:00 2001 From: Joakim Hove Date: Tue, 22 Apr 2014 00:20:03 +0200 Subject: [PATCH] Added methods to export the ZCORN, COORD and ACTNUM keywords from the EclipseGrid. --- .../eclipse/EclipseState/Grid/EclipseGrid.cpp | 24 +++++++- .../eclipse/EclipseState/Grid/EclipseGrid.hpp | 5 +- .../Grid/tests/EclipseGridTests.cpp | 18 +++++- .../EclipseGridCreateFromDeck.cpp | 55 +++++++++++++++++++ 4 files changed, 99 insertions(+), 3 deletions(-) diff --git a/opm/parser/eclipse/EclipseState/Grid/EclipseGrid.cpp b/opm/parser/eclipse/EclipseState/Grid/EclipseGrid.cpp index fc7ce0181..0bdb917a3 100644 --- a/opm/parser/eclipse/EclipseState/Grid/EclipseGrid.cpp +++ b/opm/parser/eclipse/EclipseState/Grid/EclipseGrid.cpp @@ -209,7 +209,29 @@ namespace Opm { } } } - + + void EclipseGrid::exportACTNUM( std::vector& actnum) const { + int volume = getNX() * getNY() * getNZ(); + if (getNumActive() == volume) + actnum.resize(0); + else { + actnum.resize( volume ); + ecl_grid_init_actnum_data( m_grid.get() , actnum.data() ); + } + } + + void EclipseGrid::exportCOORD( std::vector& coord) const { + coord.resize( ecl_grid_get_coord_size( m_grid.get() )); + ecl_grid_init_coord_data_double( m_grid.get() , coord.data() ); + } + + void EclipseGrid::exportZCORN( std::vector& zcorn) const { + zcorn.resize( ecl_grid_get_zcorn_size( m_grid.get() )); + ecl_grid_init_zcorn_data_double( m_grid.get() , zcorn.data() ); + } + + + } diff --git a/opm/parser/eclipse/EclipseState/Grid/EclipseGrid.hpp b/opm/parser/eclipse/EclipseState/Grid/EclipseGrid.hpp index 630a9116c..9d9e13072 100644 --- a/opm/parser/eclipse/EclipseState/Grid/EclipseGrid.hpp +++ b/opm/parser/eclipse/EclipseState/Grid/EclipseGrid.hpp @@ -41,7 +41,10 @@ namespace Opm { int getNX( ) const; int getNY( ) const; int getNZ( ) const; - + + void exportCOORD( std::vector& coord) const; + void exportZCORN( std::vector& zcorn) const; + void exportACTNUM( std::vector& actnum) const; private: std::shared_ptr m_grid; diff --git a/opm/parser/eclipse/EclipseState/Grid/tests/EclipseGridTests.cpp b/opm/parser/eclipse/EclipseState/Grid/tests/EclipseGridTests.cpp index 26ede8629..3a26070d0 100644 --- a/opm/parser/eclipse/EclipseState/Grid/tests/EclipseGridTests.cpp +++ b/opm/parser/eclipse/EclipseState/Grid/tests/EclipseGridTests.cpp @@ -235,5 +235,21 @@ BOOST_AUTO_TEST_CASE(CreateCartesianGRIDOnlyTopLayerDZ) { BOOST_CHECK_EQUAL( 10 , grid->getNX( )); BOOST_CHECK_EQUAL( 5 , grid->getNY( )); BOOST_CHECK_EQUAL( 20 , grid->getNZ( )); - //BOOST_CHECK_EQUAL( 1000 , grid->getNumActive()); + BOOST_CHECK_EQUAL( 1000 , grid->getNumActive()); +} + + + +BOOST_AUTO_TEST_CASE(AllActiveExportActnum) { + Opm::DeckPtr deck = createOnlyTopDZCartGrid(); + std::shared_ptr runspecSection(new Opm::RUNSPECSection(deck) ); + std::shared_ptr gridSection(new Opm::GRIDSection(deck) ); + std::shared_ptr grid(new Opm::EclipseGrid( runspecSection , gridSection )); + + std::vector actnum; + + actnum.push_back(100); + + grid->exportACTNUM( actnum ); + BOOST_CHECK_EQUAL( 0U , actnum.size()); } diff --git a/opm/parser/eclipse/IntegrationTests/EclipseGridCreateFromDeck.cpp b/opm/parser/eclipse/IntegrationTests/EclipseGridCreateFromDeck.cpp index c9321dd8f..77b0827c3 100644 --- a/opm/parser/eclipse/IntegrationTests/EclipseGridCreateFromDeck.cpp +++ b/opm/parser/eclipse/IntegrationTests/EclipseGridCreateFromDeck.cpp @@ -61,3 +61,58 @@ BOOST_AUTO_TEST_CASE(CreateCPActnumGrid) { BOOST_CHECK_EQUAL( 100 , grid->getNumActive() ); } + +BOOST_AUTO_TEST_CASE(ExportFromCPGridAllActive) { + ParserPtr parser(new Parser()); + boost::filesystem::path scheduleFile("testdata/integration_tests/GRID/CORNERPOINT.DATA"); + DeckPtr deck = parser->parseFile(scheduleFile.string()); + + std::shared_ptr runspecSection(new RUNSPECSection(deck) ); + std::shared_ptr gridSection(new GRIDSection(deck) ); + std::shared_ptr grid(new EclipseGrid( runspecSection , gridSection )); + + std::vector actnum; + + actnum.push_back(100); + grid->exportACTNUM( actnum ); + BOOST_CHECK_EQUAL( actnum.size() , 0U ); +} + + + + +BOOST_AUTO_TEST_CASE(ExportFromCPGridACTNUM) { + ParserPtr parser(new Parser()); + boost::filesystem::path scheduleFile("testdata/integration_tests/GRID/CORNERPOINT_ACTNUM.DATA"); + DeckPtr deck = parser->parseFile(scheduleFile.string()); + + std::shared_ptr runspecSection(new RUNSPECSection(deck) ); + std::shared_ptr gridSection(new GRIDSection(deck) ); + std::shared_ptr grid(new EclipseGrid( runspecSection , gridSection )); + + std::vector coord; + std::vector zcorn; + std::vector actnum; + size_t volume = grid->getNX()*grid->getNY()*grid->getNZ(); + + grid->exportCOORD( coord ); + BOOST_CHECK_EQUAL( coord.size() , (size_t) (grid->getNX() + 1) * (grid->getNY() + 1) * 6); + + grid->exportZCORN( zcorn ); + BOOST_CHECK_EQUAL( zcorn.size() , volume * 8); + + grid->exportACTNUM( actnum ); + BOOST_CHECK_EQUAL( actnum.size() , volume ); + + { + const std::vector& deckActnum = deck->getKeyword("ACTNUM")->getIntData(); + const std::vector& deckZCORN = deck->getKeyword("ZCORN")->getSIDoubleData(); + + for (size_t i = 0; i < volume; i++) { + BOOST_CHECK_EQUAL( deckActnum[i] , actnum[i]); + for (size_t j=0; j < 8; j++) + BOOST_CHECK_CLOSE( zcorn[i*8 + j] , deckZCORN[i*8 + j] , 0.0001); + } + } +} +