import dolfinx.mesh
import mpi4py.MPI
import viskex
import common_dolfinx as common # isort: skip
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)
Mark boundaries according to the $(x, y)$ position of the vertices of the mesh:
square_tria_subdomains = common.mark_subdomains(square_tria)
square_quad_subdomains = common.mark_subdomains(square_quad)
square_tria_boundaries = common.mark_boundaries(square_tria, square_tria_subdomains)
square_quad_boundaries = common.mark_boundaries(square_quad, square_quad_subdomains)
We plot the resulting boundaries.
viskex.dolfinx.plot_mesh_tags(square_tria, square_tria_boundaries, "boundaries")
error: XDG_RUNTIME_DIR is invalid or not set in the environment. MESA: error: ZINK: failed to choose pdev glx: failed to create drisw screen
viskex.dolfinx.plot_mesh_tags(square_quad, square_quad_boundaries, "boundaries")
error: XDG_RUNTIME_DIR is invalid or not set in the environment. MESA: error: ZINK: failed to choose pdev glx: failed to create drisw screen
We can also plot all boundaries with tag equal to $4$ (first and second plot), $2$ (third and fourth plot) or both (fifth and sixth plot), which will be displayed with colors. The rest of the mesh facets are still included in the plot, but are colored in gray.
viskex.dolfinx.plot_mesh_tags(
square_tria, square_tria_boundaries, "boundaries_4", viskex.utils.values_in([4]))
error: XDG_RUNTIME_DIR is invalid or not set in the environment. MESA: error: ZINK: failed to choose pdev glx: failed to create drisw screen
viskex.dolfinx.plot_mesh_tags(
square_quad, square_quad_boundaries, "boundaries_4", viskex.utils.values_in([4]))
error: XDG_RUNTIME_DIR is invalid or not set in the environment. MESA: error: ZINK: failed to choose pdev glx: failed to create drisw screen
viskex.dolfinx.plot_mesh_tags(
square_tria, square_tria_boundaries, "boundaries_2", viskex.utils.values_in([2]))
error: XDG_RUNTIME_DIR is invalid or not set in the environment. MESA: error: ZINK: failed to choose pdev glx: failed to create drisw screen
viskex.dolfinx.plot_mesh_tags(
square_quad, square_quad_boundaries, "boundaries_2", viskex.utils.values_in([2]))
error: XDG_RUNTIME_DIR is invalid or not set in the environment. MESA: error: ZINK: failed to choose pdev glx: failed to create drisw screen
viskex.dolfinx.plot_mesh_tags(
square_tria, square_tria_boundaries, "boundaries_24", viskex.utils.values_in([2, 4]))
error: XDG_RUNTIME_DIR is invalid or not set in the environment. MESA: error: ZINK: failed to choose pdev glx: failed to create drisw screen
viskex.dolfinx.plot_mesh_tags(
square_quad, square_quad_boundaries, "boundaries_24", viskex.utils.values_in([2, 4]))
error: XDG_RUNTIME_DIR is invalid or not set in the environment. MESA: error: ZINK: failed to choose pdev glx: failed to create drisw screen