计算单元的网格质量#
计算 vtk.Unstructured.Grid
、 pyvista.UnstructuredGrid
或 pyvista.StructuredGrid
的最小缩放雅可比系数。
绘图单元质量#
这个内置示例显示了四面体梁中每个单元的最小缩放雅可比系数:
from pyansys import examples
examples.show_cell_qual()
这是示例的源代码:
import pyansys
# 加载存档文件并进行解析,以便后续的 FEM 查询
from pyansys import examples
# archive = pyansys.Archive(examples.hexarchivefile)
archive = pyansys.Archive(examples.tetarchivefile)
# 创建 vtk 对象
grid = archive.parse_vtk(force_linear=True)
# 获取单元网格质量
qual = grid.quality
# plot cell quality
grid.plot(scalars=qual, stitle='Cell Minimum Scaled\nJacobian', rng=[0, 1])
pyansys.quality#
- ansys.mapdl.reader.quality(grid)#
Compute the minimum scaled Jacobian cell quality of an UnstructuredGrid.
Negative values indicate invalid cells while positive values indicate valid cells. Varies between -1 and 1.
- Parameters:
grid (pyvista.UnstructuredGrid or pyvista.StructuredGrid) – Structured or Unstructured Grid from
pyvista
.
Examples
>>> from ansys.mapdl import reader as pymapdl_reader >>> import pyvista as pv >>> x = np.arange(-10, 10, 5) >>> y = np.arange(-10, 10, 5) >>> z = np.arange(-10, 10, 5) >>> x, y, z = np.meshgrid(x, y, z) >>> grid = pv.StructuredGrid(x, y, z) >>> pymapdl_reader.quality(grid) array([1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1.])