Merge pull request #17 from pgdr/griddims

added griddims accessors
This commit is contained in:
Pål Grønås Drange
2017-01-11 19:05:40 +01:00
committed by GitHub
3 changed files with 43 additions and 3 deletions

View File

@@ -20,6 +20,24 @@ namespace state {
l.append( py::make_tuple( x.cell1, x.cell2, x.trans ) );
return l;
}
py::tuple getXYZ( const EclipseState& state ) {
return py::make_tuple( state.getInputGrid().getNX(),
state.getInputGrid().getNY(),
state.getInputGrid().getNZ());
}
int getNumActive( const EclipseState& state ) {
return state.getInputGrid().getNumActive();
}
int getCartesianSize( const EclipseState& state ) {
return state.getInputGrid().getCartesianSize();
}
int getGlobalIndex( const EclipseState& state, int i, int j, int k ) {
return state.getInputGrid().getGlobalIndex(i, j, k);
}
py::tuple getIJK( const EclipseState& state, int g ) {
const auto& ijk = state.getInputGrid().getIJK(g);
return py::make_tuple(ijk[0], ijk[1], ijk[2]);
}
}
namespace props {
@@ -146,10 +164,15 @@ py::def( "parse", parse );
py::class_< EclipseState >( "EclipseState", py::no_init )
.add_property( "title", &EclipseState::getTitle )
.def( "_schedule", &EclipseState::getSchedule, ref() )
.def( "_props", &EclipseState::get3DProperties, ref() )
.def( "has_input_nnc", &EclipseState::hasInputNNC )
.def( "_schedule", &EclipseState::getSchedule, ref() )
.def( "_props", &EclipseState::get3DProperties, ref() )
.def( "has_input_nnc", &EclipseState::hasInputNNC )
.def( "input_nnc", state::getNNC )
.def( "_getXYZ", state::getXYZ )
.def( "nactive", state::getNumActive )
.def( "cartesianSize", state::getCartesianSize )
.def( "globalIndex", state::getGlobalIndex )
.def( "getIJK", state::getIJK )
;
py::class_< Eclipse3DProperties >( "Eclipse3DProperties", py::no_init )

View File

@@ -72,6 +72,13 @@ class EclipseState(object):
def __repr__(self):
return 'EclipseState(title = "%s")' % self.title
def getNX(self):
return self._getXYZ()[0]
def getNY(self):
return self._getXYZ()[1]
def getNZ(self):
return self._getXYZ()[2]
@property
def schedule(self):
return Schedule(self._schedule())

View File

@@ -16,3 +16,13 @@ class TestState(unittest.TestCase):
def test_state_nnc(self):
self.assertFalse(self.state.has_input_nnc())
def test_grid(self):
self.assertEqual(9, self.state.getNX())
self.assertEqual(9, self.state.getNY())
self.assertEqual(4, self.state.getNZ())
self.assertEqual(9*9*4, self.state.nactive())
self.assertEqual(9*9*4, self.state.cartesianSize())
g,i,j,k = 295,7,5,3
self.assertEqual(g, self.state.globalIndex(i,j,k))
self.assertEqual((i,j,k), self.state.getIJK(g))