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.
|
||||
*/
|
||||
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 );
|
||||
|
||||
|
||||
/**
|
||||
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.
|
||||
*
|
||||
|
||||
@@ -149,5 +149,29 @@ FaceCellTraits<UnstructuredGrid>::Type faceCells(const UnstructuredGrid& 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
|
||||
|
||||
#include <opm/core/grid.h>
|
||||
#include <opm/parser/eclipse/EclipseState/Grid/EclipseGrid.hpp>
|
||||
|
||||
#include <opm/common/utility/platform_dependent/disable_warnings.h>
|
||||
#include <boost/range/iterator_range.hpp>
|
||||
@@ -33,7 +34,7 @@ namespace Opm
|
||||
namespace UgGridHelpers
|
||||
{
|
||||
|
||||
/// \brief Allows viewing a sparse table consisting out of C-array
|
||||
/// \brief Allows viewing a sparse table consisting out of C-array
|
||||
///
|
||||
/// This class can be used to convert two int array (like they are
|
||||
/// in UnstructuredGrid for representing the cell to faces mapping
|
||||
@@ -47,7 +48,7 @@ public:
|
||||
typedef boost::iterator_range<const int*> BaseRowType;
|
||||
typedef BaseRowType::size_type size_type;
|
||||
typedef int value_type;
|
||||
|
||||
|
||||
IntRange(const int* start_arg, const int* end_arg)
|
||||
: BaseRowType(start_arg, end_arg)
|
||||
{}
|
||||
@@ -184,6 +185,31 @@ struct CellVolumeIteratorTraits<UnstructuredGrid>
|
||||
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.
|
||||
const double* beginCellVolumes(const UnstructuredGrid& grid);
|
||||
|
||||
|
||||
@@ -19,6 +19,7 @@
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#include <opm/core/grid/GridHelpers.hpp>
|
||||
#include <opm/core/grid/GridManager.hpp>
|
||||
#include <opm/core/grid.h>
|
||||
#include <opm/core/grid/cart_grid.h>
|
||||
@@ -132,6 +133,7 @@ namespace Opm
|
||||
const std::vector<double>& poreVolumes)
|
||||
{
|
||||
struct grdecl g;
|
||||
int cells_modified = 0;
|
||||
std::vector<int> actnum;
|
||||
std::vector<double> coord;
|
||||
std::vector<double> zcorn;
|
||||
@@ -157,7 +159,7 @@ namespace Opm
|
||||
// Currently the pinchProcessor is not used and only opmfil is supported
|
||||
//bool opmfil = inputGrid.getMinpvMode() == MinpvMode::OpmFIL;
|
||||
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;
|
||||
@@ -165,11 +167,13 @@ namespace Opm
|
||||
if (!ug_) {
|
||||
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)
|
||||
{
|
||||
// Extract data from deck.
|
||||
|
||||
@@ -48,11 +48,11 @@ namespace Opm
|
||||
/// 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
|
||||
/// els the volume will be lost
|
||||
void process(const std::vector<double>& pv,
|
||||
const double minpv,
|
||||
const std::vector<int>& actnum,
|
||||
const bool mergeMinPVCells,
|
||||
double* zcorn) const;
|
||||
int process(const std::vector<double>& pv,
|
||||
const double minpv,
|
||||
const std::vector<int>& actnum,
|
||||
const bool mergeMinPVCells,
|
||||
double* zcorn) const;
|
||||
private:
|
||||
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;
|
||||
@@ -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 std::vector<int>& actnum,
|
||||
const bool mergeMinPVCells,
|
||||
@@ -85,6 +85,8 @@ namespace Opm
|
||||
// is true, the higher four zcorn associated with the cell below
|
||||
// is moved to these values (so it gains the deleted volume).
|
||||
|
||||
int cells_modified = 0;
|
||||
|
||||
// Check for sane input sizes.
|
||||
const size_t log_size = dims_[0] * dims_[1] * dims_[2];
|
||||
if (pv.size() != log_size) {
|
||||
@@ -107,6 +109,7 @@ namespace Opm
|
||||
}
|
||||
setCellZcorn(ii, jj, kk, cz, zcorn);
|
||||
|
||||
|
||||
// optionally add removed volume to the cell below.
|
||||
if (mergeMinPVCells) {
|
||||
// Check if there is a cell below.
|
||||
@@ -119,10 +122,12 @@ namespace Opm
|
||||
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->cell_facetag);
|
||||
|
||||
free(g->zcorn);
|
||||
}
|
||||
|
||||
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 *
|
||||
allocate_grid(size_t ndims ,
|
||||
size_t ncells ,
|
||||
@@ -83,6 +97,9 @@ allocate_grid(size_t ndims ,
|
||||
G = create_grid_empty();
|
||||
|
||||
if (G != NULL) {
|
||||
/* zcorn cache - only for output. */
|
||||
G->zcorn = NULL;
|
||||
|
||||
/* Grid fields ---------------------------------------- */
|
||||
G->dimensions = ndims;
|
||||
G->number_of_cells = ncells;
|
||||
|
||||
Reference in New Issue
Block a user