This page was generated from docs\source\notebooks/grids.ipynb.

Grid Generation and Plotting with PyVista#

[1]:
import numpy as np
from sigmaepsilon.mesh import PolyData, CartesianFrame
from sigmaepsilon.mesh.grid import grid

size = Lx, Ly, Lz = 800, 600, 100
shape = nx, ny, nz = 8, 6, 2
xbins = np.linspace(0, Lx, nx + 1)
ybins = np.linspace(0, Ly, ny + 1)
zbins = np.linspace(0, Lz, nz + 1)
bins = xbins, ybins, zbins
frame = CartesianFrame(dim=3)

The PolyData class delegates plotting-related jobs to pyVista. Call your objects plot method the same way you’d call a pyVista object:

[2]:
from sigmaepsilon.mesh import PointData
from sigmaepsilon.mesh.cells import H8 as CellData

coords, topo = grid(bins=bins, eshape="H8")

pd = PointData(coords=coords, frame=frame)
cd = CellData(topo=topo, frames=frame)
mesh = PolyData(pd, cd)

mesh.plot(
    notebook=True, jupyter_backend="static", theme="document"
)
../_images/notebooks_grids_3_0.png
[3]:
from sigmaepsilon.mesh.cells import H27 as CellData

coords, topo = grid(bins=bins, eshape="H27")

pd = PointData(coords=coords, frame=frame)
cd = CellData(topo=topo, frames=frame)
mesh = PolyData(pd, cd)

mesh.plot(
    notebook=True, jupyter_backend="static", theme="document"
)
../_images/notebooks_grids_4_0.png
[3]:
from sigmaepsilon.mesh.cells import Q4 as CellData

coords, topo = grid(bins=(xbins, ybins), eshape="Q4")

pd = PointData(coords=coords, frame=frame)
cd = CellData(topo=topo, frames=frame)
mesh = PolyData(pd, cd)

mesh.plot(
    notebook=True, jupyter_backend="static", theme="document"
)
../_images/notebooks_grids_5_0.png
[5]:
from sigmaepsilon.mesh.cells import Q9 as CellData

coords, topo = grid(bins=(xbins, ybins), eshape="Q9")

pd = PointData(coords=coords, frame=frame)
cd = CellData(topo=topo, frames=frame)
mesh = PolyData(pd, cd)

mesh.plot(
    notebook=True, jupyter_backend="static", theme="document"
)
../_images/notebooks_grids_6_0.png