Interpolation at user-defined locations

All the quantities deals with in SWAN are located at the vertices. Hence, due to the user-defined locations of the wave parameters, interpolations are required. Let parameter $\varphi_j = \varphi(\vec{x}_j)$ and Cartesian coordinates $\vec{x}_j = (x_j, y_j)$, with $j \in \{1,2,3\}$ indicating the vertices of cell $i$, be given. The vertices 1, 2 and 3 are ordered in a counterclockwise direction, see Figure 8.2. The associated 3 edges are denoted as 12, 23 and 31.


Linear interpolation, with $\vec{x}_0$ inside cell $i$ and $\varphi_0 = \varphi(\vec{x}_0)$, is given by


  $\displaystyle \varphi(\vec{x}) = \varphi_0 + \nabla \varphi \cdot (\vec{x} - \vec{x}_0)
$ (8.17)



where $\nabla \varphi$ is a constant vector inside cell $i$. We apply Green-Gauss reconstruction, i.e.,


  $\displaystyle \nabla \varphi \approx \frac{1}{A_i} \int_{\triangle i} \nabla \v...
...e i}
\varphi \vec{n} d\Gamma \approx \frac{1}{A_i} \sum_e \varphi_e \vec{n}_e
$ (8.18)



where $A_i$ is the area of cell $i$ and the summation runs over the 3 edges $e \in \{12,23,31\}$ of cell $i$. The values $\varphi_e$ at edges are taken as averages:


  $\displaystyle \varphi_{12} = \frac{1}{2} (\varphi_1+\varphi_2)\, , \quad
\varp...
...phi_2+\varphi_3)\, , \quad
\varphi_{31} = \frac{1}{2} (\varphi_3+\varphi_1)\
$ (8.19)



Furthermore, $\vec{n}_e$ is the outward pointing normal at edge $e$ and is obtained by rotating the edge over 90$^o$ in the clockwise direction. Hence,


  $\displaystyle \vec{n}_{12} = R\vec{t}_{12}\, , \quad R = \left( \begin{array}{l...
... \\ -1 & 0 \end{array} \right) \, , \quad \vec{t}_{12} = \vec{x}_2 - \vec{x}_1
$ (8.20)



We also need the following identity


  $\displaystyle \vec{n}_{12} + \vec{n}_{23} + \vec{n}_{31} = 0
$ (8.21)



It is not difficult to show that



$\displaystyle \nabla \varphi$ $\textstyle =$ $\displaystyle \frac{1}{2A_i} \left [ \vec{n}_{12} (\varphi_1 - \varphi_3) + \vec{n}_{31} (\varphi_1 - \varphi_2) \right ]$  
  $\textstyle =$ $\displaystyle -\frac{1}{2A_i} \left [ \varphi_1 \vec{n}_{23} + \varphi_2 \vec{n}_{31} + \varphi_3 \vec{n}_{12} \right ]$ (8.22)
or


  $\displaystyle \frac{\partial \varphi}{\partial x} = \frac{1}{2A_i} \left [ \varphi_1 (y_2 - y_3) + \varphi_2 (y_3 - y_1) + \varphi_3 (y_1 - y_2) \right]
$ (8.23)



and


  $\displaystyle \frac{\partial \varphi}{\partial y} = \frac{1}{2A_i} \left [ \varphi_1 (x_3 - x_2) + \varphi_2 (x_1 - x_3) + \varphi_3 (x_2 - x_1) \right]
$ (8.24)



The area $A_i$ of cell $i$ is given by $\vert\vec{t}_{12} \cdot \vec{n}_{13}\vert/2$. Hence, with


  $\displaystyle \vec{n}_{13} = R\vec{t}_{13} = \left( \begin{array}{l} y_3 - y_1 \\ x_1 - x_3 \end{array} \right)
$ (8.25)



we have


  $\displaystyle A_i = \frac{1}{2} \vert (x_2 - x_1)(y_3 - y_1) - (x_3 - x_1)(y_2 - y_1) \vert
$ (8.26)






Alternatively, we may interpolate using the following relation


  $\displaystyle \varphi(\vec{x}) = \sum_k \varphi_k \lambda_k(\vec{x}) = \varphi_1 \lambda_1 + \varphi_2 \lambda_2 +\varphi_3 \lambda_3
$ (8.27)



where $\lambda_k$ is a linear shape function with the following properties:
  1. $\lambda_k$ is linear per cell and
  2. $\lambda_k(\vec{x}_j) = \delta_{kj}$ with $\delta_{kj}$ is the Kronecker delta.
We choose the following shape function


  $\displaystyle \lambda_k(\vec{x}) = a_0^k + a_x^k x + a_y^k y
$ (8.28)



and the coefficients $a$ follow from solving


  $\displaystyle \left(
\begin{array}{lll}
1 & x_1 & y_1 \\
1 & x_2 & y_2 \\
...
...egin{array}{lll}
1 & 0 & 0 \\
0 & 1 & 0 \\
0 & 0 & 1
\end{array} \right)
$ (8.29)



The SWAN team 2024-09-09