Skip to content
This repository has been archived by the owner on Jul 19, 2021. It is now read-only.

Commit

Permalink
Add method FieldConfig::data_size()
Browse files Browse the repository at this point in the history
  • Loading branch information
joakim-hove authored and ManInFez committed Feb 10, 2021
1 parent e242346 commit 90a6054
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 6 deletions.
6 changes: 6 additions & 0 deletions python/res/enkf/config/field_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,9 @@ class FieldConfig(BaseCClass):
_get_ny = ResPrototype("int field_config_get_ny(field_config)")
_get_nz = ResPrototype("int field_config_get_nz(field_config)")
_get_grid = ResPrototype("ecl_grid_ref field_config_get_grid(field_config)")
_get_data_size = ResPrototype(
"int field_config_get_data_size_from_grid(field_config)"
)
_export_format = ResPrototype(
"enkf_field_file_format_enum field_config_default_export_format(char*)",
bind=False,
Expand Down Expand Up @@ -107,6 +110,9 @@ def get_ny(self):
def get_nz(self):
return self._get_nz()

def get_data_size(self):
return self._get_data_size()

def get_grid(self):
return self._get_grid()

Expand Down
14 changes: 8 additions & 6 deletions tests/res/enkf/test_field_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ class FieldConfigTest(ResTest):
def test_field_guess_filetype(self):
with TestAreaContext("field_config") as test_context:
fname = abspath("test.kw.grdecl")
print(fname)
with open(fname, "w") as f:
f.write("-- my comment\n")
f.write("-- more comments\n")
Expand Down Expand Up @@ -71,16 +70,19 @@ def test_export_format(self):
FieldConfig.exportFormat("file.xyz")

def test_basics(self):
grid = EclGridGenerator.create_rectangular((17, 13, 11), (1, 1, 1))
nx = 17
ny = 13
nz = 11
actnum = [1] * nx * ny * nz
actnum[0] = 0
grid = EclGridGenerator.create_rectangular((nx, ny, nz), (1, 1, 1), actnum)
fc = FieldConfig("PORO", grid)
print(fc)
print(str(fc))
print(repr(fc))
pfx = "FieldConfig(type"
rep = repr(fc)
self.assertEqual(pfx, rep[: len(pfx)])
fc_xyz = fc.get_nx(), fc.get_ny(), fc.get_nz()
ex_xyz = 17, 13, 11
ex_xyz = nx, ny, nz
self.assertEqual(ex_xyz, fc_xyz)
self.assertEqual(0, fc.get_truncation_mode())
self.assertEqual(ex_xyz, (grid.getNX(), grid.getNY(), grid.getNZ()))
self.assertEqual(fc.get_data_size(), grid.get_num_active())

0 comments on commit 90a6054

Please sign in to comment.