This is rather a general remark on FVM than an answer to the concrete questions. And the message is that there shouldn't be the need for such an adhoc discretization of the boundary conditions.
Unlike in FE- or FD-methods, where the starting point is a discrete ansatz for the solution, the FVM approach leaves the solution untouched (at first) but averages on a segmentation of the domain. The discretization of the solution comes into play only when the obtained system of balance equations is turned into an algebraic equation system by approximating the fluxes across the interfaces.
In this sense, in view of the boundary conditions, I advise to stick to the continuous form of the solution as long as possible and to introduce the discrete approximations only at the very end.
Say, the equation
ut=−aux+duxx+s(x,u,t)
holds on the entire domain. Then it holds on the subdomain
[0,h1), and an integration in space gives
∫h10utdx==∫h10∂x(−au+dux)dx(−au+dux)|x=h1−(−au+dux)|x=0++∫h10s(x,u,t)dx∫h10s(x,u,t)dx,
which is the contribution of the first cell to the equation system. Note that, apart from taking only averages, there has been no discretization of
u.
But now, to turn this into an algebraic equation, one typically assumes that on cell Ci the function u is constant in space, i.e. u(t,x)|Ci=ui(t). Thus, having associated u(xi)≈ui, one can express ux|hi at the cell boarders via the difference quotient in ui and ui+1. To express u at the cell boarders one can use interpolation (i.e. central differences or upwind schemes).
What to do at the boundary? In the example, it is all about approximating (−au+dux)|x=0, no matter what has been done to u so far.
Given u|x=0=gD one can introduce a ghost cell and the condition that an interpolant between u0 and u1 is equal to gD at the boarder.
Given ux|x=0=gN one can introduce a ghost cell and the condition that an approximation to the derivative between u0 and u1 matches gN at the boarder
If the flux itself is prescribed: (−au+dux)|x=0=gR, there is no need for a discretization.
However, I am not sure, what to do in the case that there are Robin type bc's that do not match the flux directly. This, will need some regularization because of the discontinuity of the advection and diffusion parameters.
===> Some personal thoughts on FVM <===
- FVM is not a scaled FDM, as examples of 1D Poisson's equations on a regular grid often suggest
- There shouldn't be a grid in FVM, there should be cells with interfaces and, if necessary, centers
- That's why I think that a stencil formulation of the discretization is not suitable
- Assembling of the equation system should be done according to the discretization approach, i.e. by iterating over the cells rather than defining an equation for every unknown. I mean to think of the i-th row of the coefficient matrix as the part of the problem posed on cell Ωi, rather than of the equation that is associated with ui.
- This is particularly important for 2D or 3D problems but may also help to have a clear notation in 1D: Make a difference between the volume (in 1D: length) of the cell, here hi, and the distance between the centers, maybe in 1D: di:=di,i+1=|xi−xi+1|.