I have reviewed the relevant posts and summarized the following code. Could someone please help verify the correctness of my code? Thank you very much!
# heat flux
Q = functionspace(mesh, ("DG", 0, (mesh.geometry.dim,)))
q = Function(Q)
q_expr = Expression(materials.kappa_m * grad(Tm), Q.element.interpolation_points())
q.interpolate(q_expr)
vtkFile = io.VTKFile(MPI.COMM_WORLD, "results/flux/q_m.pvd", "w")
vtkFile.write_function(q)
vtkFile.close()