import dolfinx.mesh
import mpi4py.MPI
import viskex
Generate meshes of the unit square by dividing each edge of the square in 6 segments, using either a triangular or quadrangular mesh.
square_tria = dolfinx.mesh.create_unit_square(mpi4py.MPI.COMM_WORLD, 6, 6, dolfinx.mesh.CellType.triangle)
square_quad = dolfinx.mesh.create_unit_square(mpi4py.MPI.COMM_WORLD, 6, 6, dolfinx.mesh.CellType.quadrilateral)
Plot the meshes.
viskex.dolfinx.plot_mesh(square_tria)
viskex.dolfinx.plot_mesh(square_quad)
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=2
plots cells of the mesh (i.e., triangles or quadrilaterals), dim=1
plots facets of the mesh (i.e., segments), while dim=0
plots vertices of the mesh.
viskex.dolfinx.plot_mesh(square_tria, dim=2)
viskex.dolfinx.plot_mesh(square_quad, dim=2)
viskex.dolfinx.plot_mesh(square_tria, dim=1)
viskex.dolfinx.plot_mesh(square_quad, dim=1)
viskex.dolfinx.plot_mesh(square_tria, dim=0)
viskex.dolfinx.plot_mesh(square_quad, dim=0)