# A Novel Cell-Based Adaptive Cartesian Grid Approach for Complex Flow Simulations
## 3 Numerical Methods
### Hanging Grids Discretization  
In previous studies [25], Lagrange polynomials were utilized to extend the solution from a coarse to a fine grid level, demonstrating their suitability within the AMR framework. The solvers, which are based on grid-nodal points, essentially perform one-dimensional interpolation exclusively at the hanging nodes. The solver in this study is cell-centered, with center nodes of adjacent cells experiencing coordinate changes in all directions at hanging grids. This paper addresses the discretization challenges posed by hanging nodes through the use of the distance-weighted least squares (DWLS) interpolation method. This approach offers enhanced flexibility in stencil selection, while simultaneously ensuring interpolation accuracy through the development of basis functions. It utilizes adjacent mesh cells surrounding the hanging nodes to construct equidistant finite difference stencils. Following mesh smoothing, adjacent cells are maintained with a level difference not exceeding one. At this juncture, the hanging nodes can be categorized into two types, as depicted in Figure 6.  
For the first scenario, regardless of whether bilinear interpolation (or trilinear interpolation within a 3D context involving 8 sub-cells) or inverse distance weighting interpolation is employed, the final outcome can be simplified to:  
\[\phi_{B}=\frac{1}{4}\phi_{1}+\frac{1}{4}\phi_{2}+\frac{1}{4}\phi_{3}+\frac{1}{ 4}\phi_{4} \tag{15}\]  
This interpolated formula exhibits second-order accuracy, where \(\phi\) represents the solution variables required by the solver, such as the primitive variables \(\rho,\ u,\ v,\ T,\ p\), etc. The second type of hanging grid, taking discretization in the \(i\)+ direction as an example, has its interpolation stencil illustrated in Figure 7, where the required template  
Figure 6: Classification of hanging grids. (**a**) Type I hanging grid; (**b**) type II hanging grid. (The dashed red line represents the discretized template width in this paper, while the red circles denote the discrete nodes requiring interpolation construction). can be conveniently determined through the neighbors. Subsequently, the linear basis \(\mathrm{p}(\mathbf{x})=\left[1,x,y\right]^{\mathrm{T}}\) is employed to approximate the target function:  
\[\phi(\mathbf{x})=\mathrm{p}(\mathbf{x})^{\mathrm{T}}\mathbf{a} \tag{16}\]  
wherein \(\mathbf{x}\) denotes the position vector, and the corresponding coefficient vector \(\mathbf{a}\) is determined by minimizing the following objective function \(J\), expressed as:  
\[J=\sum_{i=1}^{n}w_{i}[\phi(\mathbf{x}_{i})-\phi_{i}]^{2}=(\mathbf{Pa}-\mathbf{ \phi})^{\mathrm{T}}\mathbf{W}(\mathbf{Pa}-\mathbf{\phi}),\;w_{i}=1/\left|\mathbf{x }_{i}-\mathbf{x}_{R}\right|^{2} \tag{17}\]  
In the equation, the subscript \(n\) represents the number of interpolation stencil cells, the subscript \(R\) refers to the corresponding target point, \(w_{i}\) represents weight functions indicating the importance of different stencil points, \(\mathbf{W}=\mathrm{diag}(w_{1}\;w_{2}\;\cdots w_{n})\) is the diagonal expansion matrix, \(\mathbf{\phi}=[\phi_{1}\;\phi_{2}\;\cdots\phi_{n}]^{\mathrm{T}}\) is the vector of flow field values from the selected interpolation stencil cells, and \(\mathbf{P}=\left[\mathrm{p}(\mathbf{x}_{1})\;\mathrm{p}(\mathbf{x}_{2})\; \cdots\;\mathrm{p}(\mathbf{x}_{n})\right]^{\mathrm{T}}\) is the position matrix of the selected stencil cells. When \(\partial J/\partial\mathbf{a}=0\), we have:  
\[\mathbf{P}^{\mathrm{T}}\mathbf{W}\mathbf{Pa}=\mathbf{P}^{\mathrm{T}}\mathbf{W} \mathbf{\phi} \tag{18}\]  
By solving this, the coefficient vector \(\mathbf{a}\) is obtained:  
\[\mathbf{a}=(\mathbf{P}^{\mathrm{T}}\mathbf{W}\mathbf{P})^{-1}\mathbf{P}^{ \mathrm{T}  
surface boundaries. As illustrated in Figure 8, fluid cells were classified and labeled, and local reconstructions were performed near the grid nodes close to the physical surface to enforce immersed boundary conditions (IBC).