pyvista / pyvista

3D plotting and mesh analysis through a streamlined interface for the Visualization Toolkit (VTK)

Home Page:https://docs.pyvista.org

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

why "max_angle" method from compute_cell_function of UnstructuredGrid is always -1.0

bladesaber opened this issue · comments

Describe the bug, what's wrong, and what you expected.

Hi. When I set the parameter "quality_measure" of the pyvista.UnstructuredGrid.compute_cell_function to "max_angle", it always returns -1.0. But the "min_angle" is correct. Is it a bug ??

Steps to reproduce the bug.

import numpy as np
import pyvista


xyzs = np.array([
    [0, 0, 0],  # 0
    [1, 0, 0],  # 1
    [0, 1, 0],  # 2
    [0, 0, 1],  # 3
    [1, 1, 1],  # 4
])
cells = np.array([
    [4, 0, 1, 2, 3],
    [4, 1, 2, 3, 4]
])
cell_types = np.array([
    10, 10
])

grid = pyvista.UnstructuredGrid(cells.reshape(-1), cell_types.reshape(-1), xyzs)
res = grid.compute_cell_quality(quality_measure='max_angle', progress_bar=False)['CellQuality']
print(res)

System Information

--------------------------------------------------------------------------------
  Date: Mon Mar 11 18:25:25 2024 CST

                OS : Linux
            CPU(s) : 20
           Machine : x86_64
      Architecture : 64bit
       Environment : Python
        GPU Vendor : Intel
      GPU Renderer : Mesa Intel(R) Graphics (ADL-S GT1)
       GPU Version : 4.6 (Core Profile) Mesa 21.2.6
  MathText Support : True

  Python 3.10.13 | packaged by conda-forge | (main, Dec 23 2023, 15:36:39)
  [GCC 12.3.0]

           pyvista : 0.43.3
               vtk : 9.2.6
             numpy : 1.26.3
        matplotlib : 3.8.2
            scooby : 0.9.2
             pooch : 1.8.0
            pillow : 10.2.0
             scipy : 1.12.0
              tqdm : 4.66.1
            meshio : 5.3.5
--------------------------------------------------------------------------------

Screenshots

No response

The documentation for compute_cell_quality states that "Cell types not supported by this filter or undefined quality of supported cell types will have an entry of -1."

So, the cell type of your grid (TETRA in this case) does not support the "max_angle" cell quality.

You can see the underlying vtk source code here:
https://github.com/Kitware/VTK/blob/b5723567a1978506df41061933f9ede83decab12/Filters/Verdict/vtkCellQuality.cxx#L260-L307

You can see from the source code that min angle is supported, but max angle is not.

Thank you very much