diff --git a/openmc/lib/filter.py b/openmc/lib/filter.py index 497d4592b9..5d2231cc2e 100644 --- a/openmc/lib/filter.py +++ b/openmc/lib/filter.py @@ -84,6 +84,12 @@ _dll.openmc_meshsurface_filter_get_mesh.errcheck = _error_handler _dll.openmc_meshsurface_filter_set_mesh.argtypes = [c_int32, c_int32] _dll.openmc_meshsurface_filter_set_mesh.restype = c_int _dll.openmc_meshsurface_filter_set_mesh.errcheck = _error_handler +_dll.openmc_mesh_filter_get_translation.argtypes = [c_int32, POINTER(c_double*3)] +_dll.openmc_mesh_filter_get_translation.restype = c_int +_dll.openmc_mesh_filter_get_translation.errcheck = _error_handler +_dll.openmc_mesh_filter_set_translation.argtypes = [c_int32, POINTER(c_double*3)] +_dll.openmc_mesh_filter_set_translation.restype = c_int +_dll.openmc_mesh_filter_set_translation.errcheck = _error_handler _dll.openmc_new_filter.argtypes = [c_char_p, POINTER(c_int32)] _dll.openmc_new_filter.restype = c_int _dll.openmc_new_filter.errcheck = _error_handler @@ -325,6 +331,16 @@ class MeshFilter(Filter): def mesh(self, mesh): _dll.openmc_mesh_filter_set_mesh(self._index, mesh._index) + @property + def translation(self): + translation = (c_double*3)() + _dll.openmc_mesh_filter_get_translation(self._index, translation) + return tuple(translation) + + @translation.setter + def translation(self, translation): + _dll.openmc_mesh_filter_set_translation(self._index, (c_double*3)(*translation)) + class MeshSurfaceFilter(Filter): filter_type = 'meshsurface' @@ -344,6 +360,16 @@ class MeshSurfaceFilter(Filter): def mesh(self, mesh): _dll.openmc_meshsurface_filter_set_mesh(self._index, mesh._index) + @property + def translation(self): + translation = (c_double*3)() + _dll.openmc_mesh_filter_get_translation(self._index, translation) + return tuple(translation) + + @translation.setter + def translation(self, translation): + _dll.openmc_mesh_filter_set_translation(self._index, (c_double*3)(*translation)) + class MuFilter(Filter): filter_type = 'mu' diff --git a/tests/unit_tests/test_lib.py b/tests/unit_tests/test_lib.py index 4a6d692555..6d8f567bc8 100644 --- a/tests/unit_tests/test_lib.py +++ b/tests/unit_tests/test_lib.py @@ -470,11 +470,17 @@ def test_regular_mesh(lib_init): assert isinstance(mesh, openmc.lib.RegularMesh) assert mesh_id == mesh.id + translation = (1.0, 2.0, 3.0) + mf = openmc.lib.MeshFilter(mesh) assert mf.mesh == mesh + mf.translation = translation + assert mf.translation == translation msf = openmc.lib.MeshSurfaceFilter(mesh) assert msf.mesh == mesh + msf.translation = translation + assert msf.translation == translation def test_rectilinear_mesh(lib_init):