import firedrake
import viskex
import common_firedrake 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 = firedrake.UnitCubeMesh(6, 6, 6, hexahedral=False)
cube_hexa = firedrake.UnitCubeMesh(6, 6, 6, hexahedral=True)
Interpolate the scalar field $x^3 + y^2 + z^4$, and store it either in a firedrake function or a UFL expression.
cube_tetra_scalar_field, cube_tetra_scalar_field_ufl = common.prepare_scalar_field_cases(
cube_tetra, lambda x: x[0]**3 + x[1]**2 + x[2]**4)
cube_hexa_scalar_field, cube_hexa_scalar_field_ufl = common.prepare_scalar_field_cases(
cube_hexa, lambda x: x[0]**3 + x[1]**2 + x[2]**4)
Plot the scalar field with a contour plot.
viskex.firedrake.plot_scalar_field(cube_tetra_scalar_field, "scalar")
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.firedrake.plot_scalar_field(cube_tetra_scalar_field_ufl, "scalar")
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
# PYTEST_XFAIL: Temporarily broken due to firedrake#3315
"""Expect this cell to fail.
viskex.firedrake.plot_scalar_field(cube_hexa_scalar_field, "scalar")
"""
'Expect this cell to fail.\n\nviskex.firedrake.plot_scalar_field(cube_hexa_scalar_field, "scalar")\n'
# PYTEST_XFAIL: Temporarily broken due to firedrake#3315
"""Expect this cell to fail.
viskex.firedrake.plot_scalar_field(cube_hexa_scalar_field_ufl, "scalar")
"""
'Expect this cell to fail.\n\nviskex.firedrake.plot_scalar_field(cube_hexa_scalar_field_ufl, "scalar")\n'
Warp mesh according to scalar field.
viskex.firedrake.plot_scalar_field(cube_tetra_scalar_field, "scalar", 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
# PYTEST_XFAIL: Temporarily broken due to firedrake#3315
"""Expect this cell to fail.
viskex.firedrake.plot_scalar_field(cube_hexa_scalar_field, "scalar", warp_factor=0.1)
"""
'Expect this cell to fail.\n\nviskex.firedrake.plot_scalar_field(cube_hexa_scalar_field, "scalar", warp_factor=0.1)\n'