# Compute accuracy order as mesh gets refined?

I have implemented a FVM code and now I need to plot the accuracy of the method as the mesh gets refined. Having a very fine mesh, my idea is to compare what is the error between the coarser and fine mesh in the L1-norm. My problem is that having a finer mesh the solution vector has more entries than the solution with the coarse grid, therefore, how to compare the two?

• If the meshes are nested, the easiest would be to represent the coarse solution on the fine mesh and use that to compare. – Jesse Chan Dec 14 '14 at 20:22
• No, they are not nested, I have the values of the solution of a finer mesh, say, 1000 grid points, and then I have another solution with 300 grid points. Since both solution vectors have different number of points, how to compare both? – BRabbit27 Dec 14 '14 at 20:24
• Have you tried using the method of manufactured solutions? – Paul Dec 15 '14 at 5:07
• If you were using finite elements I would suggest interpolation using your elements to project the values from one mesh onto the other. I'm not well versed in finite elements, but perhaps there is a similar approach that would be valid here. – Doug Lipinski Dec 15 '14 at 14:51
• The issue would be mostly expense and representation - FVM is akin to piecewise constant basis functions, so non-nested meshes implies that neither mesh can represent functions from the other mesh. Additionally, to find the pointwise difference between solutions on diff meshes would require searching for elements in one mesh containing elements in another. – Jesse Chan Dec 16 '14 at 21:15

## 3 Answers

If you interpret the $L^{1}$ norm as a function norm (i.e., an integral), then increasing the number of solution values will be offset by a decrease in the mesh width. The result should be comparable values in norm.

That is, if your solution is $f$, taking on values $f(x_{i})$ for $i = 1, \ldots, N$, then

\begin{align} \|f\|_{1} = \int_{0}^{L}|f(x)|\,\mathrm{d}x \approx h\sum_{i = 1}^{N}|f(x_{i})|, \end{align}

assuming:

• your mesh is uniform (otherwise, put $h$ inside the summation and replace it with $x_{i+1/2} - x_{i-1/2}$, assuming the discretization points are at cell centers)
• the domain of the PDE is $[0,L]$ (without loss of generality).
• Yes, but this doesn't tell him how to compute the norm of a difference of functions on two different meshes for a FVM problem. – Bill Barth Dec 15 '14 at 12:50
• To expand on what @BillBarth said, of course he can compute the norm of each solution. The difficulty is how to compute the difference between the solutions since they are on different meshes (and then compute the norm of that difference). – Doug Lipinski Dec 15 '14 at 14:40
• If it's a finite volume method, there's normally a polynomial reconstruction on each cell associated with the method (e.g., for Godunov's first-order method, constants; for Lax-Wendroff, linear). Cell averaging is used to go from the reconstruction to the discrete representation, so one way to project the function on the coarse mesh to a function on the fine mesh is to generate the polynomial reconstruction on the coarse mesh, repartition the mesh, and calculate cell averages on the finer mesh. – Geoff Oxberry Dec 15 '14 at 19:22
• I have usually tended to go the other way than suggested so far and average the finer grid to the coarser. This avoids the concern I usually have with interpolation adding information that really is not there in the coarser solution. – Kyle Mandli Dec 16 '14 at 0:21

If you believe that your mesh size is in the asymptotic regime, you might try Richardson error estimation.

Essentially, the idea is that you model your error as $O(h^p)$ for some unknown $p$ and assume that your other terms beyond that order are negligibly small. Then, for three different grid sizes you have the three approximations

$$f_{h}\approx f_* + ch^p$$ $$f_{2h}\approx f_* + c(2h)^p$$ $$f_{4h}\approx f_* + c(4h)^p$$

where here $f_h$ and $f_{2h}$ $f_{4h}$ are the solutions on the fine, medium, and coarser grids. With some algebra, you get $f_{h} - f_{2h} \approx c(h^p-(2h)^p)$ and similarly for the other difference so you can solve for $p$ and $c$.

To take the difference between functions of grids on difference sizes, just use restriction -- $f_h$ is sampled on $0,1,2,3,4,5,6$, $f_{2h}$ is sampled on $0,2,4,6$, so evaluate at every other point. Choose whatever norm you want to estimate the error for.

• Per the question, the meshes are not nested. Some sort of interpolation, at least, is required. – Bill Barth Dec 16 '14 at 19:10
• Ah thanks for the note, @Bill -- I missed that comment. So the problem is not that one mesh is more finely resolved than the other but rather that they are entirely different meshes? The original question talks about refining a coarser mesh to obtain a fine one, if that's not the case then something more complicated is needed as you said. – Victor Minden Dec 16 '14 at 19:21

Interpolate on the coarser grid, e.g., by tensor product splines of sufficient smoothness. Then, evaluate the interpolant over the finer grid. Now you have two same-length solution vectors: one sampled from the low resolution model, the other -- actual data solved on the higher resolution. Find their difference in a given norm.