From 90a605444897c73c2479a6fe6555d6cf7d79592c Mon Sep 17 00:00:00 2001 From: Joakim Hove Date: Mon, 8 Feb 2021 09:34:26 +0100 Subject: [PATCH] Add method FieldConfig::data_size() --- python/res/enkf/config/field_config.py | 6 ++++++ tests/res/enkf/test_field_config.py | 14 ++++++++------ 2 files changed, 14 insertions(+), 6 deletions(-) diff --git a/python/res/enkf/config/field_config.py b/python/res/enkf/config/field_config.py index 469946e3ca..b5843e50a6 100644 --- a/python/res/enkf/config/field_config.py +++ b/python/res/enkf/config/field_config.py @@ -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, @@ -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() diff --git a/tests/res/enkf/test_field_config.py b/tests/res/enkf/test_field_config.py index a9bfc7da56..bac092d8b8 100644 --- a/tests/res/enkf/test_field_config.py +++ b/tests/res/enkf/test_field_config.py @@ -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") @@ -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())