2017-08-31 13:49:09 +02:00
|
|
|
#include <opm/parser/eclipse/EclipseState/Grid/EclipseGrid.hpp>
|
|
|
|
|
#include <opm/parser/eclipse/EclipseState/Grid/FaultCollection.hpp>
|
|
|
|
|
#include <opm/parser/eclipse/EclipseState/Grid/FaultFace.hpp>
|
|
|
|
|
#include <opm/parser/eclipse/EclipseState/Grid/Fault.hpp>
|
|
|
|
|
#include <opm/parser/eclipse/EclipseState/Grid/FaceDir.hpp>
|
|
|
|
|
|
2020-01-05 18:10:09 +01:00
|
|
|
#include <pybind11/stl.h>
|
|
|
|
|
#include "converters.hpp"
|
2019-09-13 09:40:13 +02:00
|
|
|
#include "export.hpp"
|
2017-08-31 13:49:09 +02:00
|
|
|
|
|
|
|
|
|
2017-09-07 14:38:31 +02:00
|
|
|
namespace {
|
2017-08-31 13:49:09 +02:00
|
|
|
py::tuple getXYZ( const EclipseGrid& grid ) {
|
|
|
|
|
return py::make_tuple( grid.getNX(),
|
|
|
|
|
grid.getNY(),
|
|
|
|
|
grid.getNZ());
|
|
|
|
|
}
|
2018-01-30 07:46:03 +01:00
|
|
|
|
2017-08-31 13:49:09 +02:00
|
|
|
int getNumActive( const EclipseGrid& grid ) {
|
|
|
|
|
return grid.getNumActive();
|
|
|
|
|
}
|
2018-01-30 07:46:03 +01:00
|
|
|
|
2017-08-31 13:49:09 +02:00
|
|
|
int getCartesianSize( const EclipseGrid& grid ) {
|
|
|
|
|
return grid.getCartesianSize();
|
|
|
|
|
}
|
2018-01-30 07:46:03 +01:00
|
|
|
|
2017-08-31 13:49:09 +02:00
|
|
|
int getGlobalIndex( const EclipseGrid& grid, int i, int j, int k ) {
|
|
|
|
|
return grid.getGlobalIndex(i, j, k);
|
|
|
|
|
}
|
2018-01-30 07:46:03 +01:00
|
|
|
|
2017-08-31 13:49:09 +02:00
|
|
|
py::tuple getIJK( const EclipseGrid& grid, int g ) {
|
|
|
|
|
const auto& ijk = grid.getIJK(g);
|
|
|
|
|
return py::make_tuple(ijk[0], ijk[1], ijk[2]);
|
|
|
|
|
}
|
2018-01-30 07:46:03 +01:00
|
|
|
|
2017-08-31 13:49:09 +02:00
|
|
|
double cellVolume1G( const EclipseGrid& grid, size_t glob_idx) {
|
|
|
|
|
return grid.getCellVolume(glob_idx);
|
|
|
|
|
}
|
2018-01-30 07:46:03 +01:00
|
|
|
|
2017-08-31 13:49:09 +02:00
|
|
|
double cellVolume3( const EclipseGrid& grid, size_t i_idx, size_t j_idx, size_t k_idx) {
|
|
|
|
|
return grid.getCellVolume(i_idx, j_idx, k_idx);
|
|
|
|
|
}
|
|
|
|
|
|
2020-01-05 18:10:09 +01:00
|
|
|
py::array cellVolumeAll( const EclipseGrid& grid)
|
|
|
|
|
{
|
|
|
|
|
std::vector<double> cellVol;
|
|
|
|
|
std::array<int, 3> dims = grid.getNXYZ();
|
|
|
|
|
size_t nCells = dims[0]*dims[1]*dims[2];
|
|
|
|
|
cellVol.reserve(nCells);
|
|
|
|
|
|
|
|
|
|
for (size_t n = 0; n < nCells; n++)
|
|
|
|
|
cellVol.push_back(grid.getCellVolume(n));
|
|
|
|
|
|
|
|
|
|
return convert::numpy_array(cellVol);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
py::array cellVolumeMask( const EclipseGrid& grid, std::vector<int>& mask)
|
|
|
|
|
{
|
|
|
|
|
std::array<int, 3> dims = grid.getNXYZ();
|
|
|
|
|
size_t nCells = dims[0]*dims[1]*dims[2];
|
|
|
|
|
|
|
|
|
|
if (nCells != mask.size())
|
|
|
|
|
throw std::logic_error("size of input mask doesn't match size of grid");
|
|
|
|
|
|
|
|
|
|
std::vector<double> cellVol(nCells, 0.0);
|
|
|
|
|
|
|
|
|
|
for (size_t n = 0; n < nCells; n++)
|
|
|
|
|
if (mask[n]==1)
|
|
|
|
|
cellVol[n] = grid.getCellVolume(n);
|
|
|
|
|
|
|
|
|
|
return convert::numpy_array(cellVol);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
double cellDepth1G( const EclipseGrid& grid, size_t glob_idx) {
|
|
|
|
|
return grid.getCellDepth(glob_idx);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
double cellDepth3( const EclipseGrid& grid, size_t i_idx, size_t j_idx, size_t k_idx) {
|
|
|
|
|
return grid.getCellDepth(i_idx, j_idx, k_idx);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
py::array cellDepthAll( const EclipseGrid& grid)
|
|
|
|
|
{
|
|
|
|
|
std::vector<double> cellDepth;
|
|
|
|
|
std::array<int, 3> dims = grid.getNXYZ();
|
|
|
|
|
size_t nCells = dims[0]*dims[1]*dims[2];
|
|
|
|
|
cellDepth.reserve(nCells);
|
|
|
|
|
|
|
|
|
|
for (size_t n = 0; n < nCells; n++)
|
|
|
|
|
cellDepth.push_back(grid.getCellDepth(n));
|
|
|
|
|
|
|
|
|
|
return convert::numpy_array(cellDepth);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
py::array cellDepthMask( const EclipseGrid& grid, std::vector<int>& mask)
|
|
|
|
|
{
|
|
|
|
|
std::array<int, 3> dims = grid.getNXYZ();
|
|
|
|
|
size_t nCells = dims[0]*dims[1]*dims[2];
|
|
|
|
|
|
|
|
|
|
if (nCells != mask.size())
|
|
|
|
|
throw std::logic_error("size of input mask doesn't match size of grid");
|
|
|
|
|
|
|
|
|
|
std::vector<double> cellDepth(nCells, 0.0);
|
|
|
|
|
|
|
|
|
|
for (size_t n = 0; n < nCells; n++)
|
|
|
|
|
if (mask[n]==1)
|
|
|
|
|
cellDepth[n] = grid.getCellDepth(n);
|
|
|
|
|
|
|
|
|
|
return convert::numpy_array(cellDepth);
|
|
|
|
|
}
|
2017-09-07 14:38:31 +02:00
|
|
|
}
|
2017-08-31 13:49:09 +02:00
|
|
|
|
2019-09-13 09:22:49 +02:00
|
|
|
void python::common::export_EclipseGrid(py::module& module) {
|
2017-08-31 13:49:09 +02:00
|
|
|
|
2018-01-30 07:46:03 +01:00
|
|
|
py::class_< EclipseGrid >( module, "EclipseGrid")
|
2017-09-07 14:38:31 +02:00
|
|
|
.def( "_getXYZ", &getXYZ )
|
2019-09-13 13:18:20 +02:00
|
|
|
.def_property_readonly("nx", &EclipseGrid::getNX)
|
|
|
|
|
.def_property_readonly("ny", &EclipseGrid::getNY)
|
|
|
|
|
.def_property_readonly("nz", &EclipseGrid::getNZ)
|
2019-09-13 11:57:30 +02:00
|
|
|
.def_property_readonly( "nactive", &getNumActive )
|
|
|
|
|
.def_property_readonly( "cartesianSize", &getCartesianSize )
|
2017-09-07 14:38:31 +02:00
|
|
|
.def( "globalIndex", &getGlobalIndex )
|
|
|
|
|
.def( "getIJK", &getIJK )
|
2019-09-13 15:38:00 +02:00
|
|
|
.def( "getCellVolume", &cellVolume1G)
|
|
|
|
|
.def( "getCellVolume", &cellVolume3)
|
2020-01-05 18:10:09 +01:00
|
|
|
.def( "getCellVolume", &cellVolumeAll)
|
|
|
|
|
.def( "getCellVolume", &cellVolumeMask)
|
|
|
|
|
.def( "getCellDepth", &cellDepth1G)
|
|
|
|
|
.def( "getCellDepth", &cellDepth3)
|
|
|
|
|
.def( "getCellDepth", &cellDepthAll)
|
|
|
|
|
.def( "getCellDepth", &cellDepthMask)
|
2018-01-30 07:46:03 +01:00
|
|
|
;
|
2017-08-31 13:49:09 +02:00
|
|
|
|
|
|
|
|
}
|