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)
Interpolate the vector field $(x^3 + y^2, x^5 + y^4)$, and store it either in a dolfinx function or a UFL expression.
square_tria_vector_field, square_tria_vector_field_ufl = common.prepare_vector_field_cases(
square_tria, lambda x: (x[0]**3 + x[1]**2, x[0]**5 + x[1]**4))
square_quad_vector_field, square_quad_vector_field_ufl = common.prepare_vector_field_cases(
square_quad, lambda x: (x[0]**3 + x[1]**2, x[0]**5 + x[1]**4))
Plot the vector field with a contour plot.
viskex.dolfinx.plot_vector_field(square_tria_vector_field, "vector")
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_vector_field(square_tria_vector_field_ufl, "vector")
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_vector_field(square_quad_vector_field, "vector")
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_vector_field(square_quad_vector_field_ufl, "vector")
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
Plot the vector field with a quiver plot.
viskex.dolfinx.plot_vector_field(square_tria_vector_field, "vector", glyph_factor=0.1)
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_vector_field(square_quad_vector_field, "vector", glyph_factor=0.1)
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
Apply the vector field as a deformation to the mesh.
viskex.dolfinx.plot_vector_field(square_tria_vector_field, "vector", warp_factor=0.1)
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_vector_field(square_quad_vector_field, "vector", warp_factor=0.1)
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