# A Scalable Moving Boundary Treatment in the Lattice Boltzmann Method
## 4 Mesh Generation for a Specific Model  
In Figure 3, a flow chart of the static boundary and the moving boundary of the LBM is presented simultaneously. For the stationary boundary problem, the calculation process is shown by the black arrow. For the moving boundary problem, in the judgment of the sixth step, turn to the process shown by the red arrow, and add the eighth and ninth steps. In the ninth step, use Formula (8) proposed to initialize the new fluid point. It should be noted that the new cycle starts before the second step in the moving boundary problem. This means that each cycle includes a grid generation process, which will increase the time overhead. Therefore, optimized mesh generation can significantly reduce the total calculation time for the parallel calculation of moving boundary problems. Figure 3: Flow chart of LBM stationary boundary and moving boundary. Figure 2: Pressure field distribution before and after boundary correction; (**a**) before boundary correction; (**b**) after boundary correction. In mesh generation, three kinds of information about the grid need to be obtained: one, the grid style: solid grid or fluid grid; two, the boundary style: grid is or is not near the solid boundary; three, the distance: the distance from the boundary grid point to the solid boundary. In serial calculations, the three types of grid information can be easily obtained through the internal point connection method. The line segment formed by the point to be judged and the known internal point has a certain number of intersections with the solid boundary. According to the parity of the intersection, the grid points are solid grid points, or fluid grid points can be judged. For all grids, as long as information one of the neighboring grid is different, it is considered a boundary grid point, and then information two can be gained. For boundary grid points, the distance from the point to the solid boundary can be calculated through analytical geometry. In two-dimensional calculations, the solid boundary is composed of polyline segments connected by adjacent scattered points. When obtaining information one and three, all solid polylines need to be judged for all grid points. In parallel computing, the grid points are evenly distributed to each core. The number of grid points is the total number of grids divided by cores for a single core. Thus for the mesh generation portion, the ideal speedup ratio is the linear speedup ratio, i.e., the number of cores. The boundary polyline is composed of scattered boundary points. In this paper, the scattered boundary points are evenly distributed on each core, and the boundary polyline is reconstructed for mesh generation. It can be divided into the following steps:  
1. Divide the overall mesh uniformly according to the number of cores, and determine the left and right boundary coordinates of a single core mapped on the overall grid;
2. For a single-core, expand two columns outside the core boundary as a buffer;
3. Transfer boundary scatters. For a single-core, add a solid scatter point on the new left and right boundaries, and then reorder them;
4. Determine the internal points through the newly added boundary scatter points, and generate the mesh through the internal point connection method;  
During mesh generation, for a single core, both buffers one and two can obtain information one, only buffer one can obtain information two and three. During flow field calculation, the calculation domain does not include a buffer for a single core, and then all required grid information is obtained. Due to solid division, thus, for the mesh generation portion, the ideal speedup ratio is the square speedup ratio, i.e., the square of the number of cores. This method can significantly reduce the grid generation time and improve the calculation speed of the overall program. At the same time, only a few scattered point coordinates need to be transmitted during mesh generation.