FreeSlip
4 unresolved threads
4 unresolved threads
This MR adds FreeSlip boundary conditions to lbmpy. Fixes #3 (closed)
Edited by Markus Holzer
Merge request reports
Activity
Filter activity
added feature proposal label
added waiting for review label
107 109 def __call__(self, f_out, f_in, dir_symbol, inv_dir, lb_method, index_field): 108 110 return Assignment(f_in(inv_dir[dir_symbol]), f_out(dir_symbol)) 109 111 112 110 113 # end class NoSlip 111 114 115 class FreeSlip(LbBoundary): 116 """ 117 Free-Slip boundary condition, which enforces a zero normal fluid velocity $u_n = 0$ but places no restrictions 118 on the tangential fluid velocity $u_t$. 119 120 Args: 121 stencil: LBM stencil which is used for the simulation 122 normal_direction: optional normal direction. If the Free slip boundary is applied to a certain side in the 123 domain it is not necassary to calculate the normal direction since it can be stated for all changed this line in version 6 of the diff
123 domain it is not necassary to calculate the normal direction since it can be stated for all 124 boundary cells. This reduces the memory space for the index array significantly. 125 name: optional name of the boundary. 126 """ 127 128 def __init__(self, stencil, normal_direction=None, name=None): 129 """Set an optional name here, to mark boundaries, for example for force evaluations""" 130 self.stencil = stencil 131 132 if normal_direction and len(normal_direction) - normal_direction.count(0) != 1: 133 raise ValueError("It is only possible to pre specify the normal direction for simple situations." 134 "This means if the free slip boundary is applied to a straight wall or side in the " 135 "simulation domain. A possible value for example would be (0, 1, 0) if the " 136 "free slip boundary is applied to the northern wall. For more complex situations " 137 "the normal direction has to be calculated for each cell. This is done when " 138 "the normal direction is not defined for this class") Is there actually a technical limitation that forbids non-axis aligned but straight walls, e.g. (1,1,0)? As long as all cells in this boundary have the same normal, we don't have to calculate the normal cellwise even if the wall is slant, do we?
We would only need to make sure that the user does not specify a slanted wall with an angle != 45 degrees in a plane, e.g. (2,1,1).
138 normal_south = (0, 1) 139 normal_north = (0, -1) 140 141 normal_south_west = (1, 1) 142 normal_north_west = (1, -1) 143 normal_south_east = (-1, 1) 144 normal_north_east = (-1, -1) 145 146 for cell in index_array: 147 direction = stencil[cell[2]] 148 inv_dir = inverse_direction(direction) 149 150 boundary_cell = (cell[0] + direction[0], cell[1] + direction[1]) 151 normal = (cell[3], cell[4]) 152 # the data is written on the inverse direction of the fluid cell near the boundary 153 # the data is read from the mirrored direction of the inverser direction where the mirror axis is the normal changed this line in version 6 of the diff
120 dh = create_data_handling(domain_size=(4, 4), periodicity=(False, False)) 121 src = dh.add_array('src', values_per_cell=len(stencil), alignment=True) 122 dh.fill('src', 0.0, ghost_layers=True) 123 method = create_lb_method(stencil='D2Q9', method='srt', relaxation_rate=1.8) 124 125 bh = LatticeBoltzmannBoundaryHandling(method, dh, 'src', name="bh") 126 127 free_slip = FreeSlip(stencil=stencil) 128 add_box_boundary(bh, free_slip) 129 130 bh.prepare() 131 for b in dh.iterate(): 132 for b_obj, idx_arr in b[bh._index_array_name].boundary_object_to_index_list.items(): 133 index_array = idx_arr 134 135 # normale directions changed this line in version 6 of the diff
added 12 commits
-
b693d0e7...69c89003 - 10 commits from branch
pycodegen:master
- b001d4ea - Merge branch 'master' of i10git.cs.fau.de:pycodegen/lbmpy into FreeSlip
- 10a5dab1 - Fix Typos
-
b693d0e7...69c89003 - 10 commits from branch
mentioned in commit 036fe134