added getCellVolume on sunbeam.grid

This commit is contained in:
Pål Grønås Drange
2017-03-31 12:19:39 +02:00
parent 68a3df64c2
commit dd56505825
3 changed files with 36 additions and 3 deletions

View File

@@ -81,6 +81,18 @@ class EclipseGrid(object):
def getNZ(self):
return self._getXYZ()[2]
def getCellVolume(self, global_idx=None, i_idx=None, j_idx=None, k_idx=None):
if global_idx is not None:
if set([i_idx, j_idx, k_idx]) != set([None]):
raise ValueError('Specify exactly one of global and all three i,j,k.')
return self._cellVolume1G(global_idx)
if None in [i_idx, j_idx, k_idx]:
raise ValueError('If not global_idx, need all three of i_idx, j_idx, and k_idx.')
return self._cellVolume3(i_idx, j_idx, k_idx)
def eclGrid(self):
return self._ecl_grid_ptr()
def __repr__(self):
x,y,z = self._getXYZ()
g = self.cartesianSize()

View File

@@ -122,6 +122,12 @@ py::tuple getIJK( const EclipseGrid& grid, int g ) {
const auto& ijk = grid.getIJK(g);
return py::make_tuple(ijk[0], ijk[1], ijk[2]);
}
double cellVolume1G( const EclipseGrid& grid, size_t glob_idx) {
return grid.getCellVolume(glob_idx);
}
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);
}
}
namespace props {
@@ -287,6 +293,8 @@ py::class_< EclipseGrid >( "EclipseGrid", py::no_init )
.def( "cartesianSize", grid::getCartesianSize )
.def( "globalIndex", grid::getGlobalIndex )
.def( "getIJK", grid::getIJK )
.def( "_cellVolume1G", grid::cellVolume1G)
.def( "_cellVolume3", grid::cellVolume3)
;
py::class_< Eclipse3DProperties >( "Eclipse3DProperties", py::no_init )