# Finite volume method implementation issues

I am trying to write a simple finite volume method code but there are some concepts I'm still not really getting right (perhaps I'm overcomplicating things)

Given a uniform grid, the idea is to approximate the solution by computing cell averages as

$$\bar u(x_j,t^n) = \bar u_j^n = \frac{1}{h}\int^{x_{j+1/2}}_{x_{j-1/2}} u(x,t^n)dx$$

When implementing the cell average computation in my code, I suppose I can use any quadrature, is this right?

Now, at $t=0$, I know the values for every $x_{j+1/2}$ and compute can compute $\bar u_j^0$, $\bar u_{j+1}^0$, $\bar u_{j-1}^0$ which in turn I can use to compute

$$\bar u_j^{n+1} = \bar u_j^{n} - \frac{\Delta t}{\Delta x}\Big[ F(\bar u_j^{n},\bar u_{j+1}^{n})-F(\bar u_{j-1}^{n},\bar u_j^{n}) \Big]$$

given the numerical flux $F(\cdot,\cdot )$If I understood correctly, everything should be fine up to this point.

Now, for the next iteration do I need to recompute the averages for each cell? If so I don't see where to get the values for each $x_{j+1/2}$. Or should I just use the new computed values, i.e. $\bar u_{j-1}^{n+1}$,$\bar u_j^{n+1}$,$\bar u_{j+1}^{n+1}$ , to iterate over the scheme?

I don't know if I missing something else in here, any thoughts?

There is a small mistake in your finite volume formulation:

It should be

$$\bar u_j^{n+1} = \bar u_j^{n} - \frac{\Delta t}{\Delta x}\Big[ F( u_{j+\frac{1}{2}}^{n-},u_{j+\frac{1}{2}}^{n+})-F( u_{j-\frac{1}{2}}^{n-},u_{j-\frac{1}{2}}^{n+}) \Big]$$

So you can evolve the cell averages using the above equations. But if you notice, the flux terms requires the values for the cell boundaries and for this you need to use a reconstruction procedure. So, in essence, you are recomputing the cell boundary values at every time step and not the cell averages. The cell averages are computed using the iteration procedure you just mentioned. The cell boundary values are usually computed using the averages of the cells and it's neighbors. Different reconstruction procedures result in different schemes.

• What does ${n-}$,${n+}$ in $F(u_{j+1/2}^{n-},u_{j+1/2}^{n+})$ mean? Nov 12, 2014 at 16:49
• $n-(n+)$ is the value of u to the left (right) of the boundary for cell $j$ at time step n.
– gk1
Nov 12, 2014 at 16:53
• I am not following you, could you give a more detailed explanation please? Nov 12, 2014 at 16:59
• According to this document pp. 66 equation (4.6), my formulation seems right, isn't it? Nov 12, 2014 at 17:41
• @BRabbit27: The flux function can be discontinuous on the boundary of the cells. In 1D, this means that at the boundary $x_{j+1/2}$, there are two (one-sided) limit values: from the left $n-$ and from the right $n+$. One way to deal with this situation is to replace the original (discontinuous) flux function at the boundary with a numerical flux function. This numerical flux is a function of the two limit values at the boundary: $u_{j+1/2}^{n+}$ and $u_{j+1/2}^{n-}$. How you choose this numerical flux is not unique and leads to different methods, as gauravk suggests.
– Paul
Nov 12, 2014 at 18:39