Wall Distance Calculation
_Originally discussed in https://github.com/CEED/libCEED/issues/1081_ For RANS models (and other uses), we need some calculation of distance to the nearest wall. The simplest implementation of that is recommended in _Computations of Wall Distances Based on Differential Equations_ Tucket _et al_ 2005, which is a Poisson solve. ## Poisson Method The problem is $$ \begin{align*} \phi_{,kk} &= -1 \quad x \in \Omega\\ \phi &= 0 \quad x \in \Gamma_{\mathrm{wall}} \\ \phi_{,j} \hat n_j &= 0 \quad x \in \partial \Omega \setminus \Gamma_{\mathrm{wall}} \end{align*} $$ The distance-to-the wall $d$ is then computed from the solution $\phi$ of the above problem: $$d = -|\phi_{,i}| + \sqrt{|\phi_{,i}|^2 + 2 \phi}$$ where $| \cdot|$ is the Euclidean metric. ## Implementation I'd think this implementation should be similar to how the `GridAnisotropyTensor*` is setup; have a function that will return a `CeedVector` which stores $d$ evaluated at quadrature points. Equivalently, we could simply have $d$ be calculated on-the-fly form $\phi$ inside whatever QFunction needs it. _For post-processing/visualization purposes, we may also want to do an $L^2$ projection of $d$ onto the finite element space._ Input to this function should be a `dm` and a list of face IDs that should represent the walls of the problem. --- ## Optional Improvements ### Better Correction _A hyperbolic Poisson solver for wall distance computation on irregular triangular grids_ mentions an improvement to the above $d$ calculation introduced in _Distance approximations for rasterizing implicit curves_ (equation 5.3). It uses a normalization based on the Hessian of $\phi$: $$ d = -\frac{|\phi_{,i}|}{\Vert H\Vert} + \sqrt{\frac{|\phi_{,i}|^2}{\Vert H \Vert} + \frac{2 \phi}{\Vert H \Vert}}$$ where $H_{ij} = \phi_{,ij}$. This would require a projection operation ala divergence of diffusive flux, to obtain $\phi_{,ij}$, but the theory presented in _Distance approximations for rasterizing implicit curves_ shows this should still improve things quite a bit, which is based on a truncated Taylors series. ### $p$-Laplacian [_On Variational and PDE-Based Distance Function Approximations_](https://onlinelibrary-wiley-com.colorado.idm.oclc.org/doi/10.1111/cgf.12611) gives a formulation for a $p$-Laplacian form of the equations, along with a correction factor specifically for it: $$ \begin{align*} \partial_k (|\phi_{,k}|^{p-2}\phi_{,k}) &= -1 \quad x \in \Omega\\ \phi &= 0 \quad x \in \Gamma_{\mathrm{wall}} \\ \phi_{,j} \hat n_j &= 0 \quad x \in \partial \Omega \setminus \Gamma_{\mathrm{wall}} \end{align*} $$ and $$d = -|\phi_{,i}|^{p-1} + \left[ |\phi_{,i}|^p + \frac{p}{p-1} \phi \right]^{\frac{p-1}{p}}$$ (equation 36) This results in better results than the normal Poisson solve and correction.
task