# How I could calculate L2 norm of an unstructured grid?

I want to calculate L2 norm of a 3D unstructured grid to compare my simulation results in two different mesh sizes as coarse and fine. I read this answer and it seems in three-dimensional space, I should use this formula:

$$L^{2}-norm = \sqrt{\sum_{\Omega} (\phi_{coarse}-\phi_{fine})^{2} \Delta x^{3}}$$

My grid is a uniform grid with size $$\Delta x$$ but it is unstructured and as a result, $$\phi$$ is stored as a 1D vector based on ids of each point in unstructured grid instead of having $$\phi$$ as a three-dimensional matrix as: $$\phi(i,j,k)$$, which is common for structured grids. My question is: Should I use the above formula with power 3 of $$\Delta x$$ or cause I stored my results as 1D vectors, drop the power 3 and use this formula instead?

$$L^{2}-norm = \sqrt{\sum_{\Omega} (\phi_{coarse}-\phi_{fine})^{2} \Delta x}$$

I really appreciate any suggestion or answer.

• If your mesh is 3D, you should use "dV", which is the volume of each element. The $\Delta x$ would apply to a 1D mesh. – pmy Feb 2 at 18:15

How are you on a uniform unstructured grid? Are you in 1-D or 2-D? You're missing a lot of detail. This expression of the norm that you found is area weighted. If you're 1D then multiplying by $$\Delta x$$ makes sense, if you're 2D then it should be squared, etc, assuming you want to be area weighted. The dimension of the array doesn't matter, its the dimension of the domain that matters.
• It's obviously 3D mesh structure. Also, from "uniform", I mean there is no mesh refinement and we could assume the mesh size is constant among the computational domain. Also that expression is not necessarily area weighted cause in fact it is weighted by generalized volume of meshes and you could say the volume a 1D mesh (line) is its length, the volume a 2D mesh is its area, and 3D is its volume. $\Delta x^{3}$ also makes very sense for my case cause my meshes are cubic voxels. – Alone Programmer Feb 1 at 19:25
• Uniform means that the mesh size is contstant. You can have a uniform mesh that refines, provided that it refines uniformly. It's pretty clear that I meant weighted by the sizing, hence why I then clarified that you multiply by $\Delta x$ in 1D, $\Delta x ^2$ in 2D, etc. You have your answer, use the original formula. Also, you still haven't made clear how you are uniformly sized but unstructured. – EMP Feb 1 at 19:44