From a7e3d50e5342a802a6e9d2e3d435402a98af7d1d Mon Sep 17 00:00:00 2001 From: Joakim Hove Date: Thu, 16 Jun 2016 22:23:59 +0200 Subject: [PATCH] Cornerpoint based EclipseGrid constructor. --- .../eclipse/EclipseState/Grid/EclipseGrid.cpp | 67 ++++++++++++++----- .../eclipse/EclipseState/Grid/EclipseGrid.hpp | 22 ++++-- 2 files changed, 67 insertions(+), 22 deletions(-) diff --git a/opm/parser/eclipse/EclipseState/Grid/EclipseGrid.cpp b/opm/parser/eclipse/EclipseState/Grid/EclipseGrid.cpp index c11fe70ae..9831c9eb8 100644 --- a/opm/parser/eclipse/EclipseState/Grid/EclipseGrid.cpp +++ b/opm/parser/eclipse/EclipseState/Grid/EclipseGrid.cpp @@ -43,6 +43,23 @@ namespace Opm { + + EclipseGrid::EclipseGrid(const std::vector& dims , + const std::vector& coord , + const std::vector& zcorn , + const int * actnum, + const double * mapaxes) + : m_minpvValue(0), + m_minpvMode(MinpvMode::ModeEnum::Inactive), + m_pinch("PINCH"), + m_pinchoutMode(PinchMode::ModeEnum::TOPBOT), + m_multzMode(PinchMode::ModeEnum::TOP) + { + initCornerPointGrid( dims, coord , zcorn , actnum , mapaxes ); + } + + + /** Will create an EclipseGrid instance based on an existing GRID/EGRID file. @@ -380,6 +397,36 @@ namespace Opm { m_grid.reset( ecl_grid_alloc_dx_dy_dz_tops( dims[0] , dims[1] , dims[2] , DX.data() , DY.data() , DZ.data() , TOPS.data() , nullptr ) ); } + + void EclipseGrid::initCornerPointGrid(const std::vector& dims , + const std::vector& coord , + const std::vector& zcorn , + const int * actnum, + const double * mapaxes) + { + const std::vector zcorn_float( zcorn.begin() , zcorn.end() ); + const std::vector coord_float( coord.begin() , coord.end() ); + float * mapaxes_float = NULL; + if (mapaxes) { + mapaxes_float = new float[6]; + for (size_t i=0; i < 6; i++) + mapaxes_float[i] = mapaxes[i]; + } + + m_grid.reset( ecl_grid_alloc_GRDECL_data(dims[0] , + dims[1] , + dims[2] , + zcorn_float.data() , + coord_float.data() , + actnum , + mapaxes_float) ); + + if (mapaxes) + delete[] mapaxes_float; + } + + + void EclipseGrid::initCornerPointGrid(const std::vector& dims, const Deck& deck) { assertCornerPointKeywords( dims , deck); { @@ -397,24 +444,10 @@ namespace Opm { mapaxes[i] = record.getItem( i ).getSIDouble( 0 ); } } + initCornerPointGrid( dims, coord , zcorn , nullptr , mapaxes ); - - { - const std::vector zcorn_float( zcorn.begin() , zcorn.end() ); - const std::vector coord_float( coord.begin() , coord.end() ); - float * mapaxes_float = NULL; - if (mapaxes) { - mapaxes_float = new float[6]; - for (size_t i=0; i < 6; i++) - mapaxes_float[i] = mapaxes[i]; - } - m_grid.reset( ecl_grid_alloc_GRDECL_data(dims[0] , dims[1] , dims[2] , zcorn_float.data() , coord_float.data() , nullptr , mapaxes_float) ); - - if (mapaxes) { - delete[] mapaxes_float; - delete[] mapaxes; - } - } + if (mapaxes) + delete[] mapaxes; } } diff --git a/opm/parser/eclipse/EclipseState/Grid/EclipseGrid.hpp b/opm/parser/eclipse/EclipseState/Grid/EclipseGrid.hpp index 8478ed19d..75cc149d3 100644 --- a/opm/parser/eclipse/EclipseState/Grid/EclipseGrid.hpp +++ b/opm/parser/eclipse/EclipseState/Grid/EclipseGrid.hpp @@ -72,14 +72,21 @@ namespace Opm { public: explicit EclipseGrid(const std::string& filename); explicit EclipseGrid(const EclipseGrid& srcGrid); - explicit EclipseGrid(size_t nx, size_t ny, size_t nz, - double dx = 1.0, double dy = 1.0, double dz = 1.0); + EclipseGrid(size_t nx, size_t ny, size_t nz, + double dx = 1.0, double dy = 1.0, double dz = 1.0); + + EclipseGrid(const std::vector& dims , + const std::vector& coord , + const std::vector& zcorn , + const int * actnum = nullptr, + const double * mapaxes = nullptr); + /// EclipseGrid ignores ACTNUM in Deck, and therefore needs ACTNUM /// explicitly. If a null pointer is passed, every cell is active. - explicit EclipseGrid(const Deck& deck, const int * actnum = nullptr); + EclipseGrid(const Deck& deck, const int * actnum = nullptr); /// [deprecated] - explicit EclipseGrid(const std::shared_ptr& deck, const int * actnum = nullptr); + EclipseGrid(const std::shared_ptr& deck, const int * actnum = nullptr); static bool hasCornerPointKeywords(const Deck&); static bool hasCartesianKeywords(const Deck&); @@ -150,7 +157,12 @@ namespace Opm { MessageContainer m_messages; void assertCellInfo() const; - + + void initCornerPointGrid(const std::vector& dims , + const std::vector& coord , + const std::vector& zcorn , + const int * actnum, + const double * mapaxes); void initCartesianGrid(const std::vector& dims, const Deck&); void initCornerPointGrid(const std::vector& dims, const Deck&); void initDTOPSGrid(const std::vector& dims, const Deck&);