# Negative cell volume

**URL:** https://discourse.paraview.org/t/negative-cell-volume/10995
**Category:** Development
**Created:** [December 15, 2022, 4:20pm UTC](https://discourse.paraview.org/t/negative-cell-volume/10995 "2022-12-15T16:20:41Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![hkjeldsberg](https://discourse.paraview.org/user_avatar/discourse.paraview.org/hkjeldsberg/32/10578_2.png) [@hkjeldsberg](https://discourse.paraview.org/u/hkjeldsberg)
#### Post date: [December 15, 2022, 4:20pm UTC](https://discourse.paraview.org/t/negative-cell-volume/10995/1 "2022-12-15T16:20:41Z")

</div>

I have created an unstructured grid consisting of one tetrahedral cell.

```bash
<?xml version="1.0"?>
<!DOCTYPE Xdmf SYSTEM "Xdmf.dtd" []>
<Xdmf Version="3.0" xmlns:xi="http://www.w3.org/2001/XInclude">
  <Domain>
    <Grid Name="mesh" GridType="Uniform">
      <Topology NumberOfElements="1" TopologyType="Tetrahedron" NodesPerElement="4">
        <DataItem Dimensions="6 4" NumberType="UInt" Format="XML">
0 1 2 3
</DataItem>
      </Topology>
      <Geometry GeometryType="XYZ">
        <DataItem Dimensions="8 3" Format="XML">
0 0 0
1 0 0
1 0 1
1 1 1
</DataItem>
      </Geometry>
    </Grid>
  </Domain>
</Xdmf>

```

I am using Paraview 5.10.0-RC1 and want to apply the `Cell Size` filter. This returns a negative value of -1/6 for the tetrahedral volume. Is there is a specific reason for this volume being negative?

 ![Screenshot 2022-12-15 at 17.20.06](https://discourse.paraview.org/uploads/default/original/2X/c/c620b25b4ec3b8afdbeb91d2379c59c66d79a3ae.png)

---

<div class="post-metadata">

### Author: ![hkjeldsberg](https://discourse.paraview.org/user_avatar/discourse.paraview.org/hkjeldsberg/32/10578_2.png) [@hkjeldsberg](https://discourse.paraview.org/u/hkjeldsberg)
#### Post date: [December 15, 2022, 4:38pm UTC](https://discourse.paraview.org/t/negative-cell-volume/10995/2 "2022-12-15T16:38:40Z")

</div>

With this minimal VTK 9.1.0 example I was able to reproduce the behaviour.

```python
import vtk

volume = vtk.vtkTetra.ComputeVolume([0, 0, 0], [1, 0, 0], [1, 0, 1], [1, 1, 1])
print(volume)

```

Output:

```bash
-0.16666666666666666

```

This is rectified if you change the order of the two last vertices:

```python
import vtk

volume = vtk.vtkTetra.ComputeVolume([0, 0, 0], [1, 0, 0], [1, 1, 1], [1, 0, 1])
print(volume)

```

Output:

```bash
0.16666666666666666

```

It seems like the volume computation is missing an absolute value of the determinant.

---

<div class="post-metadata">

### Author: ![Christos\_Tsolakis](https://discourse.paraview.org/user_avatar/discourse.paraview.org/christos_tsolakis/32/4450_2.png) [@Christos\_Tsolakis](https://discourse.paraview.org/u/Christos_Tsolakis)
#### Post date: [December 15, 2022, 7:46pm UTC](https://discourse.paraview.org/t/negative-cell-volume/10995/3 "2022-12-15T19:46:44Z")

</div>

Hi @hkjeldsberg and welcome to discourse !

> Is there is a specific reason for this volume being negative?

Yes ! the order of the vertices of the tetrahedra (and any other element) follow conventions to ensure consistency across calculations .  
See [figure 2](https://kitware.github.io/vtk-examples/site/VTKFileFormats/) in the documentation .

> volume = vtk.vtkTetra.ComputeVolume([0, 0, 0], [1, 0, 0], [1, 0, 1], [1, 1, 1])

in this case the normal vector of the face defined by the first three points using the right hand rule, points “outwards”, away from the fourth vertex and thus the volume is considered negative.

> This is rectified if you change the order of the two last vertices:

The first three vertices define now a normal that points on the same side of the face that `[1,0,1]` lies.
