Skip to content
Snippets Groups Projects
Commit dd542beb authored by Martin Bauer's avatar Martin Bauer
Browse files

walberla coupling modules are tested as well

parent 5fdda96c
No related merge requests found
...@@ -47,28 +47,24 @@ def _create_boundary_neighbor_index_list_python(flag_field_arr, nr_of_ghost_laye ...@@ -47,28 +47,24 @@ def _create_boundary_neighbor_index_list_python(flag_field_arr, nr_of_ghost_laye
return np.array(result, dtype=index_arr_dtype) return np.array(result, dtype=index_arr_dtype)
def _create_boundary_cell_index_list_python(flag_field_arr, nr_of_ghost_layers, boundary_mask, def _create_boundary_cell_index_list_python(flag_field_arr, boundary_mask,
fluid_mask, stencil, single_link): fluid_mask, stencil, single_link):
coordinate_names = boundary_index_array_coordinate_names[:len(flag_field_arr.shape)] coordinate_names = boundary_index_array_coordinate_names[:len(flag_field_arr.shape)]
index_arr_dtype = np.dtype([(name, np.int32) for name in coordinate_names] + [(direction_member_name, np.int32)]) index_arr_dtype = np.dtype([(name, np.int32) for name in coordinate_names] + [(direction_member_name, np.int32)])
result = [] result = []
gl = nr_of_ghost_layers for cell in itertools.product(*reversed([range(0, i) for i in flag_field_arr.shape])):
for cell in itertools.product(*reversed([range(gl, i - gl) for i in flag_field_arr.shape])):
cell = cell[::-1] cell = cell[::-1]
if not flag_field_arr[cell] & boundary_mask: if not flag_field_arr[cell] & boundary_mask:
continue continue
for dir_idx, direction in enumerate(stencil): for dir_idx, direction in enumerate(stencil):
neighbor_cell = tuple([cell_i + dir_i for cell_i, dir_i in zip(cell, direction)]) neighbor_cell = tuple([cell_i + dir_i for cell_i, dir_i in zip(cell, direction)])
neighbor_is_fluid = False if any(not 0 <= e < upper for e, upper in zip(neighbor_cell, flag_field_arr.shape)):
try: continue
neighbor_is_fluid = flag_field_arr[neighbor_cell] & fluid_mask if flag_field_arr[neighbor_cell] & fluid_mask:
except IndexError:
pass
if neighbor_is_fluid:
result.append(cell + (dir_idx,)) result.append(cell + (dir_idx,))
if single_link: if single_link:
continue break
return np.array(result, dtype=index_arr_dtype) return np.array(result, dtype=index_arr_dtype)
...@@ -95,18 +91,19 @@ def create_boundary_index_list(flag_field, stencil, boundary_mask, fluid_mask, ...@@ -95,18 +91,19 @@ def create_boundary_index_list(flag_field, stencil, boundary_mask, fluid_mask,
stencil = np.array(stencil, dtype=np.int32) stencil = np.array(stencil, dtype=np.int32)
args = (flag_field, nr_of_ghost_layers, boundary_mask, fluid_mask, stencil, single_link) 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)
if cython_funcs_available: if cython_funcs_available:
if dim == 2: if dim == 2:
if inner_or_boundary: if inner_or_boundary:
idx_list = create_boundary_neighbor_index_list_2d(*args) idx_list = create_boundary_neighbor_index_list_2d(*args)
else: else:
idx_list = create_boundary_cell_index_list_2d(*args) idx_list = create_boundary_cell_index_list_2d(*args_no_gl)
elif dim == 3: elif dim == 3:
if inner_or_boundary: if inner_or_boundary:
idx_list = create_boundary_neighbor_index_list_3d(*args) idx_list = create_boundary_neighbor_index_list_3d(*args)
else: else:
idx_list = create_boundary_cell_index_list_3d(*args) idx_list = create_boundary_cell_index_list_3d(*args_no_gl)
else: else:
raise ValueError("Flag field has to be a 2 or 3 dimensional numpy array") raise ValueError("Flag field has to be a 2 or 3 dimensional numpy array")
return np.array(idx_list, dtype=index_arr_dtype) return np.array(idx_list, dtype=index_arr_dtype)
...@@ -116,7 +113,7 @@ def create_boundary_index_list(flag_field, stencil, boundary_mask, fluid_mask, ...@@ -116,7 +113,7 @@ def create_boundary_index_list(flag_field, stencil, boundary_mask, fluid_mask,
if inner_or_boundary: if inner_or_boundary:
return _create_boundary_neighbor_index_list_python(*args) return _create_boundary_neighbor_index_list_python(*args)
else: else:
return _create_boundary_cell_index_list_python(*args) return _create_boundary_cell_index_list_python(*args_no_gl)
def create_boundary_index_array(flag_field, stencil, boundary_mask, fluid_mask, boundary_object, def create_boundary_index_array(flag_field, stencil, boundary_mask, fluid_mask, boundary_object,
......
...@@ -69,7 +69,7 @@ def create_boundary_neighbor_index_list_3d(object[IntegerType, ndim=3] flag_fiel ...@@ -69,7 +69,7 @@ def create_boundary_neighbor_index_list_3d(object[IntegerType, ndim=3] flag_fiel
@cython.boundscheck(False) # turn off bounds-checking for entire function @cython.boundscheck(False) # turn off bounds-checking for entire function
@cython.wraparound(False) # turn off negative index wrapping for entire function @cython.wraparound(False) # turn off negative index wrapping for entire function
def create_boundary_cell_index_list_2d(object[IntegerType, ndim=2] flag_field, def create_boundary_cell_index_list_2d(object[IntegerType, ndim=2] flag_field,
int nr_of_ghost_layers, IntegerType boundary_mask, IntegerType fluid_mask, IntegerType boundary_mask, IntegerType fluid_mask,
object[int, ndim=2] stencil, int single_link): object[int, ndim=2] stencil, int single_link):
cdef int xs, ys, x, y cdef int xs, ys, x, y
cdef int dirIdx, num_directions, dx, dy cdef int dirIdx, num_directions, dx, dy
...@@ -95,7 +95,7 @@ def create_boundary_cell_index_list_2d(object[IntegerType, ndim=2] flag_field, ...@@ -95,7 +95,7 @@ def create_boundary_cell_index_list_2d(object[IntegerType, ndim=2] flag_field,
@cython.boundscheck(False) # turn off bounds-checking for entire function @cython.boundscheck(False) # turn off bounds-checking for entire function
@cython.wraparound(False) # turn off negative index wrapping for entire function @cython.wraparound(False) # turn off negative index wrapping for entire function
def create_boundary_cell_index_list_3d(object[IntegerType, ndim=3] flag_field, def create_boundary_cell_index_list_3d(object[IntegerType, ndim=3] flag_field,
int nr_of_ghost_layers, IntegerType boundary_mask, IntegerType fluid_mask, IntegerType boundary_mask, IntegerType fluid_mask,
object[int, ndim=2] stencil, int single_link): object[int, ndim=2] stencil, int single_link):
cdef int xs, ys, zs, x, y, z cdef int xs, ys, zs, x, y, z
cdef int dirIdx, num_directions, dx, dy, dz cdef int dirIdx, num_directions, dx, dy, dz
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment