import dolfinx.mesh
import mpi4py.MPI
import viskex
Generate meshes of the unit cube by dividing each edge of the cube in 6 segments, using either a tetrahedral or hexahedral mesh.
cube_tetra = dolfinx.mesh.create_unit_cube(mpi4py.MPI.COMM_WORLD, 6, 6, 6, dolfinx.mesh.CellType.tetrahedron)
cube_hexa = dolfinx.mesh.create_unit_cube(mpi4py.MPI.COMM_WORLD, 6, 6, 6, dolfinx.mesh.CellType.hexahedron)
Plot the meshes.
viskex.dolfinx.plot_mesh(cube_tetra)
viskex.dolfinx.plot_mesh(cube_hexa)
An optional argument dim
argument controls the dimension of the entities to plotted. By default, it is equal to the topological dimension. In this example, dim=3
plots cells of the mesh (i.e., tetrahedra or hexahedra), dim=2
plots facets of the mesh (i.e., triangles or quadrilaterals), dim=1
plots the edges of the mesh, while dim=0
plots vertices of the mesh.
viskex.dolfinx.plot_mesh(cube_tetra, dim=3)
viskex.dolfinx.plot_mesh(cube_hexa, dim=3)
viskex.dolfinx.plot_mesh(cube_tetra, dim=2)
viskex.dolfinx.plot_mesh(cube_hexa, dim=2)
viskex.dolfinx.plot_mesh(cube_tetra, dim=1)
viskex.dolfinx.plot_mesh(cube_hexa, dim=1)
viskex.dolfinx.plot_mesh(cube_tetra, dim=0)
viskex.dolfinx.plot_mesh(cube_hexa, dim=0)