# How to impose Neumann boundary conditions in finite volume problems?

I'm trying to better understand finite volume methods and have started coding up a basic script to solve the diffusion equation $$u_t = u_{xx}$$ which has the finite volume form: $$\frac{\bar{u}^{n+1}_i\ - \bar{u}^n_i }{\Delta t} = \hat{F}_{i+\frac{1}{2}}^n - \hat{F}_{i-\frac{1}{2}}^n$$ where $\bar{u_i}$ is the average value of $u$ over cell $i$ and $\hat{F}$ is the numerical approximation to the flux at a cell interface.

I am using an ENO approximation in order to reproduce the point values $u$ and the derivative values $u_x$ as well. I'm aware of the ENO method to reproduce the numerical flux at each cell, however, I'm confused on how I can implement no flux boundary conditions using this method. Instead, here's what I've tried:

Using my array of known averages, $\bar{u}_i^n$, construct two coefficient matrices. One that approximates the value of the flux, $u_x$, at the left cell interface (which I'll call $L$) and one approximates it at the right cell interface (which I'll call $R$), giving me an equation that looks like $$\bar{u}^{n+1}_i = \bar{u}^n_i - \frac{\Delta t}{\Delta x}(R-L)\bar{u}^n_i$$. This allows me to just make the coefficients of the first row of $L$ and the last row of $R$ all zeros in order to implement no flux boundary conditions. However, when doing it this way, I seem to get something that is obviously non-conservative after I advance one time step:

This is clearly due to my implementation of the flux conditions, as the interior nodes all give correct values within the prescribed error.

Does anyone know how to solve this problem?

• Can you define explicitly what you mean by "flux"? How does it relate to $u$? – nukeguy Mar 9 '17 at 21:58
• We call $\hat{F}$ the flux because 1. it has the units of $\frac{concentration}{area * time}$ and 2. because that's what we refer to as the quantity $F$ such that $u_t = F(u)_x$. Thus, in this case $F(u)$ takes the form of $u_x$. Starting from the original form of the equation, $u_t = u_{xx}$ we can try and solve this equation in a cell $(x_{i+\frac{1}{2}},{x_{i-\frac{1}{2}})$. If we integrate this equation over the cell, we get $\bar{u}_t = \hat{F}_{i+\frac{1}{2}} - \hat{F}_{i-\frac{1}{2}}.$ – hijasonno Mar 9 '17 at 22:25
• So $\hat{F}$ is an approximation of $u_x$ in your method? Forgive my ignorance, I'm not very experienced with finite volume methods and their terminology. Could you provide more details on how you came up with the equation with $R$ and $L$? It seems to me that the units don't quite work out there. – nukeguy Mar 9 '17 at 22:53
• No worries. Are you familiar with ENO methods of reconstruction? If not, you can find more here: [link]mat.univie.ac.at/~obertsch/literatur/eno.pdff. It's essentially a way of interpolating given averages over a couple of cells. I put these coefficients in the matrices for $L$ and $R$ and then multiply them at each time step by $\bar{u}$ in order to get approximations to $u_x$ (and hence the flux) at each timestep. – hijasonno Mar 9 '17 at 23:05
• Well, $(R-L)\bar{u}$ is supposed to approximate $u_x$ which would give it the right units I believe. – hijasonno Mar 10 '17 at 1:29