# structured to unstructured grid - calculating volume of cell

I have a 3-D structured grid that I am trying to convert over to an unstructured grid.

Here is a picture of the 2-D structured grid with the nodes shown. It is axisymmetric about the x axis (y = 0). I will rotate this to make it 3-D.

My main concern in this conversion is that I need to output the volume of every cell from the structured grid. But as you can see, my cells are irregular hexa/penta-hedras, with non-parallel opposing faces (correct me if I'm wrong and I really hope I'm wrong, but I don't think I am). Does anyone have any suggestions on how to compute the volume of each cell? I have some ideas, but am open to other ideas. A colleague of mine mentioned that I could break up the volumes into tetrahedras and compute the volume that way. That is my #1 option so far.

My ideas are not so simple and the algorithm can get pretty involved. Does any one have a suggestion on how to compute the volume?

• ErrorNoPictureAttached. – Wolfgang Bangerth Jul 9 '15 at 12:29
• I think this would be extremely involved for a 3-D grid. I am coding in MATLAB, and I realized there's a function called "convhulln(X)" where X is a matrix of the indices of a volume, that calculates the volume of a convex hull given it's indices. Anyone familiar with this? If so, I think this function is suitable for my purpose? – user16891 Jul 9 '15 at 17:25

Note that for any element shape, you can write (here dimension dim = 2, but 3D is similar) $$V = \frac{1}{dim}\int\limits_K \nabla \cdot (x,y)^T\,dx = \frac{1}{2}\int\limits_{\partial K} (x,y)^T \cdot \mathbf{n}\,ds$$ Using the second integral, you can loop over the faces of each element and integrate on its boundary to obtain volume $V$.
If you have a list of (unique) mesh faces, you can iterate over all faces and contribute to the volume of left/right element adjacent to each face with a $\pm$ sign depending on the orientation of the normal with respect to the element.