Skip to content
GitLab
Projects Groups Snippets
  • /
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
    • Contribute to GitLab
  • Sign in / Register
  • ParaView ParaView
  • Project information
    • Project information
    • Activity
    • Labels
    • Members
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
  • Issues 1,961
    • Issues 1,961
    • List
    • Boards
    • Service Desk
    • Milestones
  • Merge requests 97
    • Merge requests 97
  • CI/CD
    • CI/CD
    • Pipelines
    • Jobs
    • Schedules
  • Deployments
    • Deployments
    • Environments
    • Releases
  • Monitor
    • Monitor
    • Incidents
  • Analytics
    • Analytics
    • Value stream
    • CI/CD
    • Repository
  • Wiki
    • Wiki
  • Snippets
    • Snippets
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
Collapse sidebar
  • ParaViewParaView
  • ParaViewParaView
  • Issues
  • #20974
Closed
Open
Issue created Sep 17, 2021 by Christopher M. Biwer@cmbiwer

Negative cell volumes for some hexahedrons

I am using the CellSize filter to compute cell volumes and it looks like for some cells its returning a negative volume.

I've reproduced this with the following ProgrammableSource that outputs a vtk.vtkUnstructureGrid:

# get output
uGrid = self.GetOutputDataObject(0)

# eight points for hexahedron
pointCoordinates = [
    [0.0, 0.0, -6.1],
    [0.604932, 0.0, -6.1],
    [0.604932, 0.0, -5.49507],
    [0, 0, -5.49507],
    [0, 0.604932, -6.1],
    [0.604932, 0.604932, -6.1],
    [0.604932, 0.604932, -5.49507],
    [0, 0.604932, -5.49507],
]

# create the points
points = vtk.vtkPoints()

# create a hexahedron from the points
hexahedron = vtk.vtkHexahedron()

for i, pt in enumerate(pointCoordinates):
    points.InsertNextPoint(pt)
    hexahedron.GetPointIds().SetId(i, i)

# add the hexahedron to a cell array
hexs = vtk.vtkCellArray()
hexs.InsertNextCell(hexahedron)

# add the points and hexahedron to an unstructured grid
uGrid.SetPoints(points)
uGrid.SetCells(hexahedron.GetCellType(), hexs)

Which returns a cell volume of -0.22137.

A screenshot in ParaView is below. cellsize

It seems the points should be in counter-clockwise order on the two opposite faces which they appear to be. I plot the points below.

import matplotlib.pyplot as plt
import numpy

fig = plt.figure()
ax = plt.axes(projection="3d")

pts = numpy.array([
    [0.0, 0.0, -6.1],
    [0.604932, 0.0, -6.1],
    [0.604932, 0.0, -5.49507],
    [0,0,-5.49507],
    [0,0.604932,-6.1],
    [0.604932,0.604932,-6.1],
    [0.604932,0.604932,-5.49507],
    [0,0.604932,-5.49507],
])

x = pts[:, 0]
y = pts[:, 1]
z = pts[:, 2]

ax.scatter(x[0], y[0], z[0], color="red")
ax.plot(x, y, z)
ax.scatter(x[-1], y[-1], z[-1], color="magenta")

ax.set_xlabel("x")
ax.set_ylabel("y")
ax.set_zlabel("z")

plt.show()

hex_path

I am wondering if these cells' points are in the order ParaView expects or if there is a different way I should be computing the cell volume? Thanks.

Its works as expected on other hexahedrons. For example:

pointCoordinates = list()
pointCoordinates.append([0.0, 0.0, 0.0])  # Face 1
pointCoordinates.append([1.0, 0.0, 0.0])
pointCoordinates.append([1.0, 1.0, 0.0])
pointCoordinates.append([0.0, 1.0, 0.0])
pointCoordinates.append([0.0, 0.0, 1.0])  # Face 2
pointCoordinates.append([1.0, 0.0, 1.0])
pointCoordinates.append([1.0, 1.0, 1.0])
pointCoordinates.append([0.0, 1.0, 1.0])

@patchett2002 @boonth @dhr @ethan.stam

To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information
Assignee
Assign to
Time tracking