2

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?

BRabbit27
  • 1,029
  • 2
  • 11
  • 20

1 Answers1

1

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.

gk1
  • 322
  • 2
  • 7
  • What does ${n-}$,${n+}$ in $F(u_{j+1/2}^{n-},u_{j+1/2}^{n+})$ mean? – BRabbit27 Nov 12 '14 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 '14 at 16:53
  • I am not following you, could you give a more detailed explanation please? – BRabbit27 Nov 12 '14 at 16:59
  • According to this document pp. 66 equation (4.6), my formulation seems right, isn't it? – BRabbit27 Nov 12 '14 at 17:41
  • 2
    @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 '14 at 18:39
  • The question of handling flux discontinuities on the boundary of cells is also known as the Riemann Problem. For more information about how to choose a numerical flux or Approximate Riemann Solver, see this post: http://scicomp.stackexchange.com/questions/36/how-can-i-choose-a-good-riemann-solver-when-numerically-solving-a-system-of-hype – Paul Nov 12 '14 at 18:47
  • Ok, I went through my books again and so what you are telling me is basically the iteration of the scheme is something like: 1) From initial conditions get cell boundaries and compute cell averages, 2) Advance solution to next time, 3) Reconstruct cell boundaries, 4) compute cell averages again and go to 2. Is this a right interpretation? – BRabbit27 Nov 13 '14 at 10:27
  • You compute cell averages by going to step 2 using the reconstructed cell boundary values from step 3. You don't compute them separately again. Remember, you are advancing the cell averages with every time step. – gk1 Nov 13 '14 at 10:46