Following from my previous question I am trying to apply boundary conditions to this non-uniform finite volume mesh,
I would like to apply a Robin type boundary condition to the l.h.s. of the domain ($x=x_L)$, such that,
$$ \sigma_L = \left( d u_x + a u \right) \bigg|_{x=x_L} $$
where $\sigma_L$ is the boundary value; $a, d$ are coefficients defined on the boundary, advection and diffusion respectively; $u_x = \frac{\partial u}{\partial x}$, is the derivative of $u$ evaluated at the boundary and $u$ is the variable for which we are solving.
Possible approaches
I can think of two ways to implement this boundary condition on the above finite volume mesh:
A ghost cell approach.
Write $u_x$ as a finite difference including a ghost cell.$$ \sigma_L = d \frac{u_1 - u_0}{h_{-}} + a u(x_L)$$
A. Then use linear interpolation with points $x_0$ and $x_1$ to find the intermediate value, $u(x_L)$.
B. Alternatively find $u(x_L)$ by averaging over the cells, $u(x_L) = \frac{1}{2}(u_0 + u_1)$
In either case, the dependence on ghost cell can be eliminated in the usual way (via substitution into the finite volume equation).
An extrapolation approach.
Fit a linear (or quadratic) function to $u(x)$ by using the values at points $x_1, x_2$ ($x_3$). This will provide the value at $u(x_L)$. The linear (or quadratic) function can then be differentiated to find an expression for the value of the derivative, $u_x(x_L)$, at the boundary. This approach does not use a ghost cell.
Questions
- Which approach of the three, (1A, 1B or 2) is "standard" or you would recommend?
- Which approach introduces the smallest error or is the most stable?
- I think I can implement the ghost cell approach myself, however, how can the extrapolation approach be implemented, does this approach have a name?
- Are there any stability difference between fitting a linear function or a quadratic equation?
Specific equation
I wish to apply this boundary to the advection-diffusion equation (in conservation form) with non-linear source term,
$$ u_t = -au_x + du_{xx} + s(x,u,t) $$
Discretising this equation on the above mesh using the $\theta$-method gives,
$$ w_{j}^{n+1} - \theta r_a w_{j-1}^{n+1} - \theta r_b w_{j}^{n+1} - \theta r_c w_{j+1}^{n+1} = w_j^n + (1-\theta) r_a w_{j-1}^n + (1-\theta) r_b w_j^n + (1-\theta) r_c w_{j+1}^n + s(x_j,t_n) $$
However for the boundary point ($j=1$) I prefer to use a fully implicit scheme ($\theta=1$) to reduce the complexity,
$$ w_{1}^{n+1} - r_a w_{0}^{n+1} - r_b w_{1}^{n+1} - r_c w_{2}^{n+1} = w_1^n + s_1^n $$
Notice the ghost point $w_0^{n+1}$, this will be removed by applying the boundary condition.
The coefficients have the definitions,
$$ r_a = \frac{\Delta t}{h_j}\left( \frac{ah_j}{2h_{-}} + \frac{d}{h_{-}} \right) $$
$$ r_b = - \frac{\Delta t}{h_j}\left( \frac{a}{2}\left[ \frac{h_{j-1}}{h_{-}} - \frac{h_{j+1}}{h_{+}} \right] + d\left[-\frac{1}{h_{-}} - \frac{1}{h_{+}} \right]\right) $$
$$ r_c = \frac{\Delta t}{h_j}\left(- \frac{ah_j}{2h_{+}} + \frac{d}{h_{+}} \right) $$
All the "$h$" variables are defined as in the above diagram. Finally, $\Delta t$ which is the time step (N.B. this is a simplified case with constant $a$ and $d$ coefficients, in practice the "$r$" coefficients are slightly more complicated for this reason).