diff --git a/pystencils/boundaries/boundaryhandling.py b/pystencils/boundaries/boundaryhandling.py index 7af729ace1d95ceeba8df9c02e0e908c13aa7189..a1d23a372d1a623d8b78a5972cc7a8457fb84063 100644 --- a/pystencils/boundaries/boundaryhandling.py +++ b/pystencils/boundaries/boundaryhandling.py @@ -22,7 +22,7 @@ try: except ImportError: ParallelDataHandling = None -DEFAULT_FLAG_TYPE = np.uint64 +DEFAULT_FLAG_TYPE = np.uint32 class FlagInterface: diff --git a/pystencils/boundaries/createindexlist.py b/pystencils/boundaries/createindexlist.py index 0e23b93ee6646c4aa1519df31923dbef97b8cecc..42a9079c29d49cccdfbbccc97a890b44dbf78dfb 100644 --- a/pystencils/boundaries/createindexlist.py +++ b/pystencils/boundaries/createindexlist.py @@ -28,17 +28,17 @@ boundary_index_array_coordinate_names = ["x", "y", "z"] direction_member_name = "dir" -def numpy_data_type_for_boundary_object(boundary_object, dim): +def numpy_data_type_for_boundary_object(boundary_object, dim, data_type=np.int64): coordinate_names = boundary_index_array_coordinate_names[:dim] - return np.dtype([(name, np.int64) for name in coordinate_names] - + [(direction_member_name, np.int64)] + return np.dtype([(name, data_type) for name in coordinate_names] + + [(direction_member_name, data_type)] + [(i[0], i[1].numpy_dtype) for i in boundary_object.additional_data], align=True) def _create_boundary_neighbor_index_list_python(flag_field_arr, nr_of_ghost_layers, boundary_mask, - fluid_mask, stencil, single_link): + fluid_mask, stencil, single_link, data_type=np.int64): coordinate_names = boundary_index_array_coordinate_names[:len(flag_field_arr.shape)] - index_arr_dtype = np.dtype([(name, np.int64) for name in coordinate_names] + [(direction_member_name, np.int64)]) + index_arr_dtype = np.dtype([(name, data_type) for name in coordinate_names] + [(direction_member_name, data_type)]) result = [] gl = nr_of_ghost_layers @@ -57,9 +57,9 @@ def _create_boundary_neighbor_index_list_python(flag_field_arr, nr_of_ghost_laye def _create_boundary_cell_index_list_python(flag_field_arr, boundary_mask, - fluid_mask, stencil, single_link): + fluid_mask, stencil, single_link, data_type=np.int64): coordinate_names = boundary_index_array_coordinate_names[:len(flag_field_arr.shape)] - index_arr_dtype = np.dtype([(name, np.int64) for name in coordinate_names] + [(direction_member_name, np.int64)]) + index_arr_dtype = np.dtype([(name, data_type) for name in coordinate_names] + [(direction_member_name, data_type)]) result = [] for cell in itertools.product(*reversed([range(0, i) for i in flag_field_arr.shape])): @@ -96,9 +96,9 @@ def create_boundary_index_list(flag_field, stencil, boundary_mask, fluid_mask, """ dim = len(flag_field.shape) coordinate_names = boundary_index_array_coordinate_names[:dim] - index_arr_dtype = np.dtype([(name, np.int64) for name in coordinate_names] + [(direction_member_name, np.int64)]) + index_arr_dtype = np.dtype([(name, np.int32) for name in coordinate_names] + [(direction_member_name, np.int32)]) - stencil = np.array(stencil, dtype=np.int64) + stencil = np.array(stencil, dtype=np.int32) args = (flag_field, nr_of_ghost_layers, boundary_mask, fluid_mask, stencil, single_link) args_no_gl = (flag_field, boundary_mask, fluid_mask, stencil, single_link) diff --git a/pystencils/boundaries/createindexlistcython.pyx b/pystencils/boundaries/createindexlistcython.pyx index bf8bc7e4332b9e548f671aa3b4f77a4def8719e9..0931fdc7fe1038a7445f4e97a65ea24074e684fe 100644 --- a/pystencils/boundaries/createindexlistcython.pyx +++ b/pystencils/boundaries/createindexlistcython.pyx @@ -19,8 +19,8 @@ ctypedef fused IntegerType: def create_boundary_neighbor_index_list_2d(object[IntegerType, ndim=2] flag_field, int nr_of_ghost_layers, IntegerType boundary_mask, IntegerType fluid_mask, object[int, ndim=2] stencil, int single_link): - cdef long long xs, ys, x, y - cdef long long dirIdx, num_directions, dx, dy + cdef int xs, ys, x, y + cdef int dirIdx, num_directions, dx, dy xs, ys = flag_field.shape boundary_index_list = [] @@ -44,8 +44,8 @@ def create_boundary_neighbor_index_list_2d(object[IntegerType, ndim=2] flag_fiel def create_boundary_neighbor_index_list_3d(object[IntegerType, ndim=3] flag_field, int nr_of_ghost_layers, IntegerType boundary_mask, IntegerType fluid_mask, object[int, ndim=2] stencil, int single_link): - cdef long long xs, ys, zs, x, y, z - cdef long long dirIdx, num_directions, dx, dy, dz + cdef int xs, ys, zs, x, y, z + cdef int dirIdx, num_directions, dx, dy, dz xs, ys, zs = flag_field.shape boundary_index_list = [] @@ -72,8 +72,8 @@ def create_boundary_neighbor_index_list_3d(object[IntegerType, ndim=3] flag_fiel def create_boundary_cell_index_list_2d(object[IntegerType, ndim=2] flag_field, IntegerType boundary_mask, IntegerType fluid_mask, object[int, ndim=2] stencil, int single_link): - cdef long long xs, ys, x, y - cdef long long dirIdx, num_directions, dx, dy + cdef int xs, ys, x, y + cdef int dirIdx, num_directions, dx, dy xs, ys = flag_field.shape boundary_index_list = [] @@ -98,8 +98,8 @@ def create_boundary_cell_index_list_2d(object[IntegerType, ndim=2] flag_field, def create_boundary_cell_index_list_3d(object[IntegerType, ndim=3] flag_field, IntegerType boundary_mask, IntegerType fluid_mask, object[int, ndim=2] stencil, int single_link): - cdef long long xs, ys, zs, x, y, z - cdef long long dirIdx, num_directions, dx, dy, dz + cdef int xs, ys, zs, x, y, z + cdef int dirIdx, num_directions, dx, dy, dz xs, ys, zs = flag_field.shape boundary_index_list = []