diff --git a/src/pystencils/boundaries/boundaryhandling.py b/src/pystencils/boundaries/boundaryhandling.py index cfccdd0783b3ab678129cb44e7f2150ee5331b16..e7b44099dc3c38283f37bbf1f63478a2be6361e9 100644 --- a/src/pystencils/boundaries/boundaryhandling.py +++ b/src/pystencils/boundaries/boundaryhandling.py @@ -1,4 +1,3 @@ -from typing import Sequence from functools import lru_cache import numpy as np @@ -12,7 +11,7 @@ from pystencils.sympyextensions import TypedSymbol from pystencils.defaults import DEFAULTS from pystencils.types.quick import Arr, create_type from pystencils.gpu.gpu_array_handler import GPUArrayHandler -from pystencils.field import Field +from pystencils.field import Field, FieldType from pystencils.backend.kernelfunction import FieldPointerParam try: @@ -306,7 +305,8 @@ class BoundaryHandling: def _add_boundary(self, boundary_obj, flag=None): if boundary_obj not in self._boundary_object_to_boundary_info: sym_index_field = Field.create_generic('indexField', spatial_dimensions=1, - dtype=numpy_data_type_for_boundary_object(boundary_obj, self.dim)) + dtype=numpy_data_type_for_boundary_object(boundary_obj, self.dim), + field_type=FieldType.INDEXED) ast = self._create_boundary_kernel(self._data_handling.fields[self._field_name], sym_index_field, boundary_obj) if flag is None: @@ -317,7 +317,7 @@ class BoundaryHandling: def _create_boundary_kernel(self, symbolic_field, symbolic_index_field, boundary_obj): return create_boundary_kernel(symbolic_field, symbolic_index_field, self.stencil, boundary_obj, - target=self._target, cpu_openmp=self._openmp) + target=self._target,) # cpu_openmp=self._openmp) TODO: replace def _create_index_fields(self): dh = self._data_handling diff --git a/src/pystencils/boundaries/createindexlist.py b/src/pystencils/boundaries/createindexlist.py index d20e946fbc82d3cdceb81b3bdb084046d1af731b..34bd0766ec904d76d15915aac3e08400f7737683 100644 --- a/src/pystencils/boundaries/createindexlist.py +++ b/src/pystencils/boundaries/createindexlist.py @@ -57,8 +57,8 @@ def _create_index_list_python( : len(flag_field_arr.shape) ] index_arr_dtype = np.dtype( - [(name, default_index_array_dtype) for name in coordinate_names] - + [(direction_member_name, default_index_array_dtype)] + [(name, default_index_array_dtype.numpy_dtype) for name in coordinate_names] + + [(direction_member_name, default_index_array_dtype.numpy_dtype)] ) # boundary cells are extracted via np.where. To ensure continous memory access in the compute kernel these cells @@ -148,11 +148,11 @@ def create_boundary_index_list( dim = len(flag_field.shape) coordinate_names = boundary_index_array_coordinate_names[:dim] index_arr_dtype = np.dtype( - [(name, default_index_array_dtype) for name in coordinate_names] - + [(direction_member_name, default_index_array_dtype)] + [(name, default_index_array_dtype.numpy_dtype) for name in coordinate_names] + + [(direction_member_name, default_index_array_dtype.numpy_dtype)] ) - stencil = np.array(stencil, dtype=default_index_array_dtype) + stencil = np.array(stencil, dtype=default_index_array_dtype.numpy_dtype) args = ( flag_field, nr_of_ghost_layers, diff --git a/src/pystencils/datahandling/serial_datahandling.py b/src/pystencils/datahandling/serial_datahandling.py index e01db8dbb33cb32fe1bf3aa85baaaec22ddfa943..0f5ddb431a869f3326f25b46a4f276268d2afd44 100644 --- a/src/pystencils/datahandling/serial_datahandling.py +++ b/src/pystencils/datahandling/serial_datahandling.py @@ -9,8 +9,7 @@ from pystencils.datahandling.datahandling_interface import DataHandling from pystencils.enums import Target from pystencils.field import (Field, FieldType, create_numpy_array_with_layout, layout_string_to_tuple, spatial_layout_string_to_tuple) -# TODO replace with platform -# from pystencils.gpu.gpu_array_handler import GPUArrayHandler, GPUNotAvailableHandler +from pystencils.gpu.gpu_array_handler import GPUArrayHandler, GPUNotAvailableHandler from pystencils.slicing import normalize_slice, remove_ghost_layers from pystencils.utils import DotDict diff --git a/tests/test_boundary.py b/tests/test_boundary.py index a94d3782020cd494a4b01009f04016e889fca9c0..84c390221649bb96e8deeb567e3a66c67d8c3b13 100644 --- a/tests/test_boundary.py +++ b/tests/test_boundary.py @@ -244,3 +244,6 @@ def test_dirichlet(with_indices): assert all([np.allclose(a, np.array(value)) for a in dh.cpu_arrays.src[1:-2, -1]]) assert all([np.allclose(a, np.array(value)) for a in dh.cpu_arrays.src[0, 1:-2]]) assert all([np.allclose(a, np.array(value)) for a in dh.cpu_arrays.src[-1, 1:-2]]) + + +test_kernel_vs_copy_boundary()