Commit a9b4dd46 authored by Markus Holzer's avatar Markus Holzer
Browse files

Fixed Free Slip

parent 7b9b4e2d
Pipeline #38106 failed with stages
in 42 minutes and 35 seconds
......@@ -183,7 +183,12 @@ class FreeSlip(LbBoundary):
normal_direction[i] = direction[i]
ref_direction = MirroredStencilDirections.mirror_stencil(ref_direction, i)
ref_direction = inverse_direction(ref_direction)
# convex corner special case:
if all(n == 0 for n in normal_direction):
normal_direction = direction
else:
ref_direction = inverse_direction(ref_direction)
for i, cell_name in zip(range(dim), self.additional_data):
cell[cell_name[0]] = -normal_direction[i]
cell['ref_dir'] = self.stencil.index(ref_direction)
......
......@@ -297,6 +297,50 @@ def test_free_slip_index_list():
assert normal == normal_north_east
def test_free_slip_index_list_convex_corner():
stencil = LBStencil(Stencil.D2Q9)
dh = create_data_handling(domain_size=(4, 4))
src = dh.add_array('src', values_per_cell=len(stencil))
dh.fill('src', 0.0, ghost_layers=True)
lbm_config = LBMConfig(stencil=stencil, method=Method.SRT, relaxation_rate=1.8)
method = create_lb_method(lbm_config=lbm_config)
def bh_callback(x, y):
radius = 2
x_mid = 2
y_mid = 2
return (x - x_mid) ** 2 + (y - y_mid) ** 2 > radius ** 2
bh = LatticeBoltzmannBoundaryHandling(method, dh, 'src', name="bh")
free_slip = FreeSlip(stencil=stencil)
bh.set_boundary(free_slip, mask_callback=bh_callback)
bh.prepare()
for b in dh.iterate():
for b_obj, idx_arr in b[bh._index_array_name].boundary_object_to_index_list.items():
index_array = idx_arr
# correct index array for this case with convex corners
test = [(2, 1, 2, 0, 1, 2), (2, 1, 3, 1, 0, 3), (2, 1, 7, 1, 1, 7),
(2, 1, 8, 0, 1, 7), (3, 1, 2, 0, 1, 2), (3, 1, 4, -1, 0, 4),
(3, 1, 7, 0, 1, 8), (3, 1, 8, -1, 1, 8), (1, 2, 2, 0, 1, 2),
(1, 2, 3, 1, 0, 3), (1, 2, 5, 1, 0, 7), (1, 2, 7, 1, 1, 7),
(2, 2, 7, 1, 1, 7), (3, 2, 8, -1, 1, 8), (4, 2, 2, 0, 1, 2),
(4, 2, 4, -1, 0, 4), (4, 2, 6, -1, 0, 8), (4, 2, 8, -1, 1, 8),
(1, 3, 1, 0, -1, 1), (1, 3, 3, 1, 0, 3), (1, 3, 5, 1, -1, 5),
(1, 3, 7, 1, 0, 5), (2, 3, 5, 1, -1, 5), (3, 3, 6, -1, -1, 6),
(4, 3, 1, 0, -1, 1), (4, 3, 4, -1, 0, 4), (4, 3, 6, -1, -1, 6),
(4, 3, 8, -1, 0, 6), (2, 4, 1, 0, -1, 1), (2, 4, 3, 1, 0, 3),
(2, 4, 5, 1, -1, 5), (2, 4, 6, 0, -1, 5), (3, 4, 1, 0, -1, 1),
(3, 4, 4, -1, 0, 4), (3, 4, 5, 0, -1, 6), (3, 4, 6, -1, -1, 6)]
for i, cell in enumerate(index_array):
for j in range(len(cell)):
assert cell[j] == test[i][j]
def test_free_slip_equivalence():
# check if Free slip BC does the same if the normal direction is specified or not
......
Markdown is supported
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