import dolfinx.mesh
import mpi4py.MPI
import viskex
import common_dolfinx as common # isort: skip
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)
Interpolate the vector field $(x^3 + y^2 + z^4, x^6 + y^5 + z^7, x^9 + y^8 + z^{10})$, and store it either in a dolfinx function or a UFL expression.
cube_tetra_vector_field, cube_tetra_vector_field_ufl = common.prepare_vector_field_cases(
cube_tetra, lambda x: (x[0]**3 + x[1]**2 + x[2]**4, x[0]**6 + x[1]**5 + x[2]**7, x[0]**9 + x[1]**8 + x[2]**10))
cube_hexa_vector_field, cube_hexa_vector_field_ufl = common.prepare_vector_field_cases(
cube_hexa, lambda x: (x[0]**3 + x[1]**2 + x[2]**4, x[0]**6 + x[1]**5 + x[2]**7, x[0]**9 + x[1]**8 + x[2]**10))
Plot the vector field with a contour plot.
viskex.dolfinx.plot_vector_field(cube_tetra_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(cube_tetra_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(cube_hexa_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(cube_hexa_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(cube_tetra_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(cube_hexa_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(cube_tetra_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(cube_hexa_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