## 4 Local Refinement Near Immersed Boundaries Using Algebraic Level Sets
### Mesh Refinement Algorithms Based on Algebraic Level Sets  
The classical mesh refinement schemes are based on a posteriori error estimators [47; 48], which require a trial solution before adaptive refinement of the mesh is carried out. In the context of immersed boundary problems, it is expected that the behavioral fields will vary greatly near the boundaries. Therefore, in light of the position of immersed bound  
Figure 12: Algebraic level sets from an open quadratic NURBS curve. The generated algebraic level sets ensure the smoothness of the field.  
Figure 13: Algebraic level sets from a closed quadratic NURBS curve.  
aries, a priori mesh refinement is possible. Two adaptive refinement algorithms based on signed [35] and unsigned [34] distance fields are proposed here, as follows:  
1. _Sign-based Refinement Algorithm_ (SRA): The cut cells and their neighbors are recursively subdivided until the maximum level is reached. The cut cells are identified by checking the signed distance of the cell vertices to the immersed boundaries. As illustrated in Figure 14, a cell is marked as a cut cell if its vertices have opposite signs. To minimize the number of sign checkings, the vertex signs of the cut cells (ones not circled in Figure 13(a)) are stored in memory. As the subdivision continues, the cut cells in the next level can be determined by an additional check of the signs of the edge, face, and cell centers (circled in Figure 13(a)). A first-in-first-out (FIFO) stack queue (Figure 13(b)) is utilized to keep track of the cells. The cut cells in the current level are first popped out from the front of the stack. After sign checking, the cut cells in the next level are generated and then pushed to the back of the stack. The checking of signed distance and new cell generation each stop when the maximum chosen level of refinement is reached. 2. _Distance-based Refinement Algorithm_ (DRA): This algorithm is similar to the SRA except that the cut cells are determined by checking the magnitude of the distance of the cell vertices instead of the sign. This is particularly useful when the feature size \(d_{\text{feature}}\) of the immersed boundaries is smaller than the cell size \(d_{\text{cell}}\), in which case the sign-based algorithm may fail to detect a cut cell (see Figure 14(a)). In distance-based refinement, a cell is marked as a cut cell if \[\max_{i}|d_{i}|<\sqrt{k}d_{\text{cell}}\] (21) where \(k\) is the dimension of the domain and \(d_{i}\) is the distance of the \(i\)th vertex of the cell to the closest boundary. As shown in Figure 14(b), cells that would be missed by SRA can be identified by DRA. In general, the DRA criterion is stricter than that of the SRA, and can therefore cause relatively more cells to be subdivided.  
Figure 14: Illustration of the sign-based refinement algorithm: (**a**) the cut cells in level \(l\) are subdivided into appropriate sub-cells. The new cut cells in level \(l+1\) are identified by the newly calculated (circled) signs and the previously obtained (not circled) signs, and then (**b**) pushed to the back of the stack to wait for the next level subdivision.  
One possible strategy combining the above two algorithms is to dynamically switch between the two based on \(d_{\text{cell}}\). The distance-based criterion is chosen if \(d_{\text{cell}}>d_{\text{feature}}\); otherwise, the sign-based criterion is preferred. The inset magnified picture of Figure 15b shows a sign-based subdivision in the cut cell detected by the distance-based algorithm.