Extrude a 2D mesh to 3DΒΆ

This example shows how to extrude a 2D mesh to 3D. This can be helpful for closed laboratory geometries for example. If you are looking for more flexible ways to create 3D meshes, have a look at TetGen and Gmsh.

import numpy as np

import pygimli as pg
import pygimli.meshtools as mt

We start by generating a 2D mesh.

plc = mt.createCircle([-1, -4], radius=1.5, area=0.1, segments=25)
circle = mt.createMesh(plc)
for cell in circle.cells():
pg.show(circle, circle.cellMarkers(), label="Cell Markers")
plot extrude 2D to 3D


(<matplotlib.axes._subplots.AxesSubplot object at 0x7f8fbdbe7c50>, <matplotlib.colorbar.Colorbar object at 0x7f8fd897d668>)

We now extrude this mesh to 3D given a z vector.

z = np.geomspace(1, 5, 5)-1
cylinder = pg.meshtools.extrudeMesh(circle, a=z)
pg.show(cylinder, cylinder.cellMarkers(), label="Cell markers")
plot extrude 2D to 3D


<PIL.Image.Image image mode=RGB size=2048x1536 at 0x7F8FD8995FD0>

(<pyvista.plotting.plotting.Plotter object at 0x7f8fd8995320>, None)

Gallery generated by Sphinx-Gallery