Added methods to export the ZCORN, COORD and ACTNUM keywords from the EclipseGrid.

This commit is contained in:
Joakim Hove
2014-04-22 00:20:03 +02:00
parent 7428e7862f
commit af6f18b5aa
4 changed files with 99 additions and 3 deletions

View File

@@ -209,7 +209,29 @@ namespace Opm {
}
}
}
void EclipseGrid::exportACTNUM( std::vector<int>& 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<double>& 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<double>& zcorn) const {
zcorn.resize( ecl_grid_get_zcorn_size( m_grid.get() ));
ecl_grid_init_zcorn_data_double( m_grid.get() , zcorn.data() );
}
}

View File

@@ -41,7 +41,10 @@ namespace Opm {
int getNX( ) const;
int getNY( ) const;
int getNZ( ) const;
void exportCOORD( std::vector<double>& coord) const;
void exportZCORN( std::vector<double>& zcorn) const;
void exportACTNUM( std::vector<int>& actnum) const;
private:
std::shared_ptr<ecl_grid_type> m_grid;

View File

@@ -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<Opm::RUNSPECSection> runspecSection(new Opm::RUNSPECSection(deck) );
std::shared_ptr<Opm::GRIDSection> gridSection(new Opm::GRIDSection(deck) );
std::shared_ptr<Opm::EclipseGrid> grid(new Opm::EclipseGrid( runspecSection , gridSection ));
std::vector<int> actnum;
actnum.push_back(100);
grid->exportACTNUM( actnum );
BOOST_CHECK_EQUAL( 0U , actnum.size());
}

View File

@@ -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> runspecSection(new RUNSPECSection(deck) );
std::shared_ptr<GRIDSection> gridSection(new GRIDSection(deck) );
std::shared_ptr<EclipseGrid> grid(new EclipseGrid( runspecSection , gridSection ));
std::vector<int> 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> runspecSection(new RUNSPECSection(deck) );
std::shared_ptr<GRIDSection> gridSection(new GRIDSection(deck) );
std::shared_ptr<EclipseGrid> grid(new EclipseGrid( runspecSection , gridSection ));
std::vector<double> coord;
std::vector<double> zcorn;
std::vector<int> 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<int>& deckActnum = deck->getKeyword("ACTNUM")->getIntData();
const std::vector<double>& 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);
}
}
}