# A Local Adaptive Mesh Refinement for JFO Cavitation Model on Cartesian Meshes
## 2 AMR Algorithm
### Neighbor Fixing
A matching method is applied to realize the periodic boundary condition. There are two steps to achieve the aim: (1) store the cell numbers of the west boundary and east boundary, respectively, and (2) conduct a pair matching operation according to the size of a cell. The matching method is illustrated in Figure 6 and Table 2. In the first step, the cells of the west boundary and east boundary are detected by the Neighbor finding (0 algorithm according to the returned number of neighbor cells be zero or not. Owing to the Z-order filling curve (see below), the cell number is naturally in descending order along the \(y\) coordinate. Otherwise, a sort of operation needs to be performed by comparing \(y\) coordinate. Secondly, a pair number is added at each cell starting from the first two cells. The pair number is self-added when the size of the west boundary cell is equal to the size of the east boundary cell. For example, the cell of 28,95,97 matches the cell of 86 with the pair number of 2. Moreover, due to the number of neighbor cells of 86 exceeding three, dissatisfying the 2:1 condition, a mesh refinement operation should be conducted to the cell of 86 in the next step. The Periodic matching () algorithm is shown in Algorithm 6. Figure 5: Two kinds of cases for hanging nodes (blank circle indicates ghost nodes). Figure 6: An example of periodic boundary condition. ### Z-Order Filling Curve

Z-order filling curve [39] is used to manage the solution order of the nonuniform mesh. A vector storing the ordered cell numbers is generated by the Z-ordering 0 algorithm, where the sequence of the cell numbers obeys the rule of the Z-order filling curve, as shown in Figure 7. The basic idea of the Z-ordering 0 algorithm is to travel the quadtree transversely under the sequence of NW\(\rightarrow\)NE\(\rightarrow\)SW\(\rightarrow\)SE layer by layer. The Z-ordering 0 algorithm is shown in Algorithm 7. ```
travel to the bottom NE cells as a start point; store the travel path layer by layer simultaneously; while the number of tagged cells is not equal to the total number of leaf cells travel the leaf cells on the same layer under the sequence of NW\(\rightarrow\)NE\(\rightarrow\)SW\(\rightarrow\)SE; store the travel path layer by layer simultaneously; go back to ancestor cell once the SE leaf cell is reached; end
```

**Algorithm 7** Z-ordering 0

## 3 Difference Schemes on Nonuniform Mesh

The universal Reynolds equation [18] governing both liquid and cavitation regions is expressed as

\[\frac{\partial}{\partial x}\left(h^{3}\frac{\partial p}{\partial x}\right)+ \frac{\partial}{\partial y}\left(h^{3}\frac{\partial p}{\partial y}\right)=6 \mu U\frac{\partial(h\theta)}{\partial x}, \tag{4}\]

where \(h\) is the film thickness, \(p\) is the liquid pressure, \(\mu\) is the dynamic viscosity, \(U\) is the sliding speed, and \(\theta\) is the density ratio. As mentioned above, AMR allows different numerical resolutions to exist in the computational domain; therefore, the regions have different sizes. As a result, the difference scheme for nonuniform mesh is different from that for uniform mesh. Figure 8 shows the parameter definition for the nonuniform difference scheme. \begin{table}
\begin{tabular}{c c c c} \hline \hline
**Cell Number of the** & \multirow{2}{*}{**Pair Number**} & **Cell Number of the** & \multirow{2}{*}{**Pair Number**} \\
**West Boundary** & & **East Boundary** & \\ \hline
22 & 1 & 24 & 1 \\
28 & 2 & 86 & 2 \\
95 & 2 & 15 & 3 \\
97 & 2 & & \\
120 & 3 & & \\
142 & 3 & & \\ \hline \hline \end{tabular}
\end{table} 
Table 2: Periodic pair number table. Figure 7: Z-order filling curve. The difference scheme of the pressure flow term is derived as

\[