Hi all,
I want to visualize two functions on the same mesh in Paraview (5.8.0), see the following MWE:
#!/usr/bin/env python3
from dolfinx import BoxMesh, VectorFunctionSpace, Function, FunctionSpace
from dolfinx.io import XDMFFile
import dolfinx.cpp.mesh
from mpi4py import MPI
import numpy as np
comm = MPI.COMM_WORLD
mesh = BoxMesh(comm, [np.array([0.0, 0.0, 0.0]),np.array([2.0, 1.0, 1.0])], [5, 5, 5],
dolfinx.cpp.mesh.CellType.tetrahedron, dolfinx.cpp.mesh.GhostMode.none)
V1 = VectorFunctionSpace(mesh, ("CG", 1))
V2 = FunctionSpace(mesh, ("DG", 0))
u = Function(V1, name="displacement")
d = Function(V2, name="some_scalar")
u.vector.set(1.33)
d.vector.set(2.0)
# write mesh and function
with XDMFFile(comm,'tmp/viz.xdmf','w') as outfile:
#mesh.topology.create_connectivity_all()
outfile.write_mesh(mesh)
outfile.write_function(u)
outfile.write_function(d)
When looking at the XDMF in Paraview, I a) cannot visualize the function values in color on the geometry, and b) cannot visualize the scalar function “some_scalar” on a geometry that was warped by the function “displacement”.
Writing just “displacement”, however, works, and the colored values of this function can be visualized.
I remember that dolfin used to have the setting “functions_share_mesh” for the XDMF writer. This does not seem to exist anymore.
Does anybody have an idea how to set this properly so that both functions can be visualized on the same (warped) geometry?
Thanks!
Marc