Implementing Neumann boundary conditions for finite volume PDEs

467 Views Asked by At

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:

$u$ after a timestep of .01 with initial condition $u(x,0) = erfc(x)$

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?