Skip to content
Snippets Groups Projects
Commit e9bb252f authored by Frederik Hennig's avatar Frederik Hennig
Browse files

fixed (most) boundary handling test cases

parent f0089541
No related branches found
No related tags found
No related merge requests found
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
......
......@@ -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,
......
......@@ -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
......
......@@ -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()
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment