This page was generated from docs\source\examples/compound1.ipynb.

Building a compound mesh#

[4]:
from sigmaepsilon.mesh import PointData, PolyData, TriMesh
from sigmaepsilon.mesh import grid, triangulate
from sigmaepsilon.mesh.space import StandardFrame
from sigmaepsilon.mesh.cells import H8, Q4, T3
import numpy as np

A = StandardFrame(dim=3)

coords, topo, _ = triangulate(size=(100, 100), shape=(4, 4))
pd = PointData(coords=coords, frame=A)
cd = T3(topo=topo, frames=A)
tri = TriMesh(pd, cd)

coords, topo = grid(size=(100, 100), shape=(10, 10), eshape="Q4")
pd = PointData(coords, frame=A)
cd = Q4(topo=topo, frames=A)
grid2d = PolyData(pd, cd)

coords, topo = grid(size=(100, 100, 100), shape=(8, 6, 2), eshape="H8")
pd = PointData(coords, frame=A)
cd = H8(topo=topo, frames=A)
grid3d = PolyData(pd, cd)

mesh = PolyData(frame=A)
mesh["tri", "T3"] = tri.move(np.array([0.0, 0.0, -20]))
mesh["grids", "Q4"] = grid2d.move(np.array([0.0, 0.0, 120]))
mesh["grids", "H8"] = grid3d

mesh["tri", "T3"].pointdata["values"] = np.full(tri.coords().shape[0], 5.0)
mesh["grids", "Q4"].pointdata["values"] = np.full(grid2d.coords().shape[0], 10.0)
mesh["grids", "H8"].pointdata["values"] = np.full(grid3d.coords().shape[0], -5.0)

mesh.to_standard_form()
mesh.lock(create_mappers=True)

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