UgGridHelpers::createEclipseGrid( )
- A new function createEclipsegrid has been added to the UgGridHelpers namespace. - The UnstructuredGrid C structure has been augmented with a new member: double * zcorn which can be used to hold a copy of the zcorn value *after* minpv induced modifications.
This commit is contained in:
@@ -242,6 +242,16 @@ struct UnstructuredGrid
|
|||||||
cornerpoint grids.
|
cornerpoint grids.
|
||||||
*/
|
*/
|
||||||
int *cell_facetag;
|
int *cell_facetag;
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
This vector is retained to be able to construct an
|
||||||
|
EclipseGrid representation of the Grid. If the grid
|
||||||
|
processor actually modifies the elements of the zcorn
|
||||||
|
vector from the input the modified version is stored here;
|
||||||
|
otherwise we just use the default.
|
||||||
|
*/
|
||||||
|
double * zcorn;
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -290,6 +300,15 @@ allocate_grid(size_t ndims ,
|
|||||||
size_t nnodes );
|
size_t nnodes );
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
Will allocate storage internally in the grid object to hold a copy
|
||||||
|
of the zcorn data supplied in the second argument.
|
||||||
|
*/
|
||||||
|
void
|
||||||
|
attach_zcorn_copy(struct UnstructuredGrid* G ,
|
||||||
|
const double * zcorn);
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Import a grid from a character representation stored in file.
|
* Import a grid from a character representation stored in file.
|
||||||
*
|
*
|
||||||
|
|||||||
@@ -149,5 +149,29 @@ FaceCellTraits<UnstructuredGrid>::Type faceCells(const UnstructuredGrid& grid)
|
|||||||
{
|
{
|
||||||
return FaceCellsProxy(grid);
|
return FaceCellsProxy(grid);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Opm::EclipseGrid createEclipseGrid(const UnstructuredGrid& grid, const Opm::EclipseGrid& inputGrid ) {
|
||||||
|
const int * dims = UgGridHelpers::cartDims( grid );
|
||||||
|
|
||||||
|
if ((inputGrid.getNX( ) == static_cast<size_t>(dims[0])) &&
|
||||||
|
(inputGrid.getNY( ) == static_cast<size_t>(dims[1])) &&
|
||||||
|
(inputGrid.getNZ( ) == static_cast<size_t>(dims[2]))) {
|
||||||
|
std::vector<int> updatedACTNUM;
|
||||||
|
const int* global_cell = UgGridHelpers::globalCell( grid );
|
||||||
|
|
||||||
|
if (global_cell) {
|
||||||
|
updatedACTNUM.assign( inputGrid.getCartesianSize( ) , 0 );
|
||||||
|
for (int c = 0; c < numCells( grid ); c++) {
|
||||||
|
updatedACTNUM[global_cell[c]] = 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return Opm::EclipseGrid( inputGrid, grid.zcorn, updatedACTNUM );
|
||||||
|
} else {
|
||||||
|
throw std::invalid_argument("Size mismatch - dimensions of inputGrid argument and current UnstructuredGrid instance disagree");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -22,6 +22,7 @@
|
|||||||
#define OPM_CORE_GRIDHELPERS_HEADER_INCLUDED
|
#define OPM_CORE_GRIDHELPERS_HEADER_INCLUDED
|
||||||
|
|
||||||
#include <opm/core/grid.h>
|
#include <opm/core/grid.h>
|
||||||
|
#include <opm/parser/eclipse/EclipseState/Grid/EclipseGrid.hpp>
|
||||||
|
|
||||||
#include <opm/common/utility/platform_dependent/disable_warnings.h>
|
#include <opm/common/utility/platform_dependent/disable_warnings.h>
|
||||||
#include <boost/range/iterator_range.hpp>
|
#include <boost/range/iterator_range.hpp>
|
||||||
@@ -184,6 +185,31 @@ struct CellVolumeIteratorTraits<UnstructuredGrid>
|
|||||||
typedef const double* IteratorType;
|
typedef const double* IteratorType;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
Will create an EclipseGrid representation (i.e. based on
|
||||||
|
ZCORN and COORD) of the current UnstructuredGrid
|
||||||
|
instance. When creating the UnstructuredGrid the detailed
|
||||||
|
cornerpoint information is discarded, and it is difficult
|
||||||
|
to go backwards to recreated ZCORN and COORD.
|
||||||
|
|
||||||
|
The current implementation is based on retaining a copy of the
|
||||||
|
zcorn keyword after the Minpvprocessor has modified it.
|
||||||
|
|
||||||
|
We then create a new EclipseGrid instance based on the original
|
||||||
|
input grid, but we "replace" the ZCORN and ACTNUM keywords with
|
||||||
|
the updated versions.
|
||||||
|
|
||||||
|
If the tolerance in the call to create_grid_cornerpoint( ) is
|
||||||
|
finite the grid processing code might collapse cells, the z
|
||||||
|
coordinate transformations from this process will *not* be
|
||||||
|
correctly represented in the EclipseGrid created by this
|
||||||
|
method.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/// \brief Construct an EclipseGrid instance based on the inputGrid, with modifications to
|
||||||
|
/// zcorn and actnum from the dune UnstructuredGrid.
|
||||||
|
Opm::EclipseGrid createEclipseGrid(const UnstructuredGrid& grid, const Opm::EclipseGrid& inputGrid );
|
||||||
|
|
||||||
/// \brief Get an iterator over the cell volumes of a grid positioned at the first cell.
|
/// \brief Get an iterator over the cell volumes of a grid positioned at the first cell.
|
||||||
const double* beginCellVolumes(const UnstructuredGrid& grid);
|
const double* beginCellVolumes(const UnstructuredGrid& grid);
|
||||||
|
|
||||||
|
|||||||
@@ -19,6 +19,7 @@
|
|||||||
|
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
|
|
||||||
|
#include <opm/core/grid/GridHelpers.hpp>
|
||||||
#include <opm/core/grid/GridManager.hpp>
|
#include <opm/core/grid/GridManager.hpp>
|
||||||
#include <opm/core/grid.h>
|
#include <opm/core/grid.h>
|
||||||
#include <opm/core/grid/cart_grid.h>
|
#include <opm/core/grid/cart_grid.h>
|
||||||
@@ -132,6 +133,7 @@ namespace Opm
|
|||||||
const std::vector<double>& poreVolumes)
|
const std::vector<double>& poreVolumes)
|
||||||
{
|
{
|
||||||
struct grdecl g;
|
struct grdecl g;
|
||||||
|
int cells_modified = 0;
|
||||||
std::vector<int> actnum;
|
std::vector<int> actnum;
|
||||||
std::vector<double> coord;
|
std::vector<double> coord;
|
||||||
std::vector<double> zcorn;
|
std::vector<double> zcorn;
|
||||||
@@ -157,7 +159,7 @@ namespace Opm
|
|||||||
// Currently the pinchProcessor is not used and only opmfil is supported
|
// Currently the pinchProcessor is not used and only opmfil is supported
|
||||||
//bool opmfil = inputGrid.getMinpvMode() == MinpvMode::OpmFIL;
|
//bool opmfil = inputGrid.getMinpvMode() == MinpvMode::OpmFIL;
|
||||||
bool opmfil = true;
|
bool opmfil = true;
|
||||||
mp.process(poreVolumes, minpv_value, actnum, opmfil, zcorn.data());
|
cells_modified = mp.process(poreVolumes, minpv_value, actnum, opmfil, zcorn.data());
|
||||||
}
|
}
|
||||||
|
|
||||||
const double z_tolerance = inputGrid.isPinchActive() ? inputGrid.getPinchThresholdThickness() : 0.0;
|
const double z_tolerance = inputGrid.isPinchActive() ? inputGrid.getPinchThresholdThickness() : 0.0;
|
||||||
@@ -165,11 +167,13 @@ namespace Opm
|
|||||||
if (!ug_) {
|
if (!ug_) {
|
||||||
OPM_THROW(std::runtime_error, "Failed to construct grid.");
|
OPM_THROW(std::runtime_error, "Failed to construct grid.");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (cells_modified > 0) {
|
||||||
|
attach_zcorn_copy( ug_ , zcorn.data() );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void GridManager::createGrdecl(Opm::DeckConstPtr deck, struct grdecl &grdecl)
|
void GridManager::createGrdecl(Opm::DeckConstPtr deck, struct grdecl &grdecl)
|
||||||
{
|
{
|
||||||
// Extract data from deck.
|
// Extract data from deck.
|
||||||
|
|||||||
@@ -48,11 +48,11 @@ namespace Opm
|
|||||||
/// will have the zcorn numbers changed so they are zero-thickness. Any
|
/// will have the zcorn numbers changed so they are zero-thickness. Any
|
||||||
/// cell below will be changed to include the deleted volume if mergeMinPCCells is true
|
/// cell below will be changed to include the deleted volume if mergeMinPCCells is true
|
||||||
/// els the volume will be lost
|
/// els the volume will be lost
|
||||||
void process(const std::vector<double>& pv,
|
int process(const std::vector<double>& pv,
|
||||||
const double minpv,
|
const double minpv,
|
||||||
const std::vector<int>& actnum,
|
const std::vector<int>& actnum,
|
||||||
const bool mergeMinPVCells,
|
const bool mergeMinPVCells,
|
||||||
double* zcorn) const;
|
double* zcorn) const;
|
||||||
private:
|
private:
|
||||||
std::array<int,8> cornerIndices(const int i, const int j, const int k) const;
|
std::array<int,8> cornerIndices(const int i, const int j, const int k) const;
|
||||||
std::array<double, 8> getCellZcorn(const int i, const int j, const int k, const double* z) const;
|
std::array<double, 8> getCellZcorn(const int i, const int j, const int k, const double* z) const;
|
||||||
@@ -68,7 +68,7 @@ namespace Opm
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
inline void MinpvProcessor::process(const std::vector<double>& pv,
|
inline int MinpvProcessor::process(const std::vector<double>& pv,
|
||||||
const double minpv,
|
const double minpv,
|
||||||
const std::vector<int>& actnum,
|
const std::vector<int>& actnum,
|
||||||
const bool mergeMinPVCells,
|
const bool mergeMinPVCells,
|
||||||
@@ -85,6 +85,8 @@ namespace Opm
|
|||||||
// is true, the higher four zcorn associated with the cell below
|
// is true, the higher four zcorn associated with the cell below
|
||||||
// is moved to these values (so it gains the deleted volume).
|
// is moved to these values (so it gains the deleted volume).
|
||||||
|
|
||||||
|
int cells_modified = 0;
|
||||||
|
|
||||||
// Check for sane input sizes.
|
// Check for sane input sizes.
|
||||||
const size_t log_size = dims_[0] * dims_[1] * dims_[2];
|
const size_t log_size = dims_[0] * dims_[1] * dims_[2];
|
||||||
if (pv.size() != log_size) {
|
if (pv.size() != log_size) {
|
||||||
@@ -107,6 +109,7 @@ namespace Opm
|
|||||||
}
|
}
|
||||||
setCellZcorn(ii, jj, kk, cz, zcorn);
|
setCellZcorn(ii, jj, kk, cz, zcorn);
|
||||||
|
|
||||||
|
|
||||||
// optionally add removed volume to the cell below.
|
// optionally add removed volume to the cell below.
|
||||||
if (mergeMinPVCells) {
|
if (mergeMinPVCells) {
|
||||||
// Check if there is a cell below.
|
// Check if there is a cell below.
|
||||||
@@ -119,10 +122,12 @@ namespace Opm
|
|||||||
setCellZcorn(ii, jj, kk + 1, cz_below, zcorn);
|
setCellZcorn(ii, jj, kk + 1, cz_below, zcorn);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
++cells_modified;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
return cells_modified;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -48,6 +48,8 @@ destroy_grid(struct UnstructuredGrid *g)
|
|||||||
|
|
||||||
free(g->global_cell);
|
free(g->global_cell);
|
||||||
free(g->cell_facetag);
|
free(g->cell_facetag);
|
||||||
|
|
||||||
|
free(g->zcorn);
|
||||||
}
|
}
|
||||||
|
|
||||||
free(g);
|
free(g);
|
||||||
@@ -69,6 +71,18 @@ create_grid_empty(void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void
|
||||||
|
attach_zcorn_copy(struct UnstructuredGrid* G , const double * zcorn)
|
||||||
|
{
|
||||||
|
size_t zcorn_elements = G->cartdims[0] * G->cartdims[1] * G->cartdims[2] * 8;
|
||||||
|
double * new_zcorn = realloc(G->zcorn , zcorn_elements * sizeof * G->zcorn );
|
||||||
|
if (new_zcorn) {
|
||||||
|
G->zcorn = new_zcorn;
|
||||||
|
memcpy(G->zcorn , zcorn , zcorn_elements * sizeof * G->zcorn );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
struct UnstructuredGrid *
|
struct UnstructuredGrid *
|
||||||
allocate_grid(size_t ndims ,
|
allocate_grid(size_t ndims ,
|
||||||
size_t ncells ,
|
size_t ncells ,
|
||||||
@@ -83,6 +97,9 @@ allocate_grid(size_t ndims ,
|
|||||||
G = create_grid_empty();
|
G = create_grid_empty();
|
||||||
|
|
||||||
if (G != NULL) {
|
if (G != NULL) {
|
||||||
|
/* zcorn cache - only for output. */
|
||||||
|
G->zcorn = NULL;
|
||||||
|
|
||||||
/* Grid fields ---------------------------------------- */
|
/* Grid fields ---------------------------------------- */
|
||||||
G->dimensions = ndims;
|
G->dimensions = ndims;
|
||||||
G->number_of_cells = ncells;
|
G->number_of_cells = ncells;
|
||||||
|
|||||||
@@ -21,6 +21,7 @@
|
|||||||
#include <opm/core/grid.h>
|
#include <opm/core/grid.h>
|
||||||
#include <opm/core/grid/cornerpoint_grid.h> /* compute_geometry */
|
#include <opm/core/grid/cornerpoint_grid.h> /* compute_geometry */
|
||||||
#include <opm/core/grid/GridManager.hpp> /* compute_geometry */
|
#include <opm/core/grid/GridManager.hpp> /* compute_geometry */
|
||||||
|
#include <opm/core/grid/GridHelpers.hpp>
|
||||||
#include <opm/core/grid/cpgpreprocess/preprocess.h>
|
#include <opm/core/grid/cpgpreprocess/preprocess.h>
|
||||||
#include <opm/parser/eclipse/Deck/Deck.hpp>
|
#include <opm/parser/eclipse/Deck/Deck.hpp>
|
||||||
#include <opm/parser/eclipse/Deck/DeckItem.hpp>
|
#include <opm/parser/eclipse/Deck/DeckItem.hpp>
|
||||||
@@ -172,5 +173,5 @@ BOOST_AUTO_TEST_CASE(TOPS_Fully_Specified) {
|
|||||||
|
|
||||||
BOOST_CHECK(grid_equal(cgrid1, cgrid2));
|
BOOST_CHECK(grid_equal(cgrid1, cgrid2));
|
||||||
|
|
||||||
Opm::EclipseGrid grid = gridM1.createEclipseGrid( *es1.getInputGrid( ) );
|
Opm::EclipseGrid grid = Opm::UgGridHelpers::createEclipseGrid( *cgrid1 , *es1.getInputGrid( ) );
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user