Nonsense XDMF output of a vector function of a 1d geometry
To parametrize the space dimension for a vector-valued unknown, it is useful to define always a VectorFunctionSpace
even in the 1d case, via the identification between Expression("x[0]")
and Expression(["x[0]"])
. Suppose that u
is such a Function
, its Numpy array is well defined (1-d array) and gives correct values.
However the XDMF output of such function produces nonsense values in ParaView, as can be seen via the following MWE.
from fenics import *
mesh = UnitIntervalMesh(10)
V = VectorFunctionSpace(mesh, "CG", 1)
u = Function(V)
u.interpolate(Expression(["x[0]"]))
# XDMF output does not produce any error
# Howver in ParaView nonsense values are affected to u
File("u.xdmf") << u
# PVD output produces an DOLFIN error
# "Don't know how to handle vector function with dimension other than 2 or 3."
File("u.pvd") << u
Comments (12)
-
reporter -
reporter - changed milestone to 1.7
-
I guess it should be treated as a scalar function in the xdmf file? Would you like to take a look at it? Search for the error message in the source code, it might be easy to fix.
-
Check first that DOLFIN supports XDMF output of scalar functions in 1D.
-
Scalars in 1D work, but there is a bit of a workaround, because XDMF does not support 1D geometry.
-
The problem is that XDMF does not support 1D geometry. At the moment, we supply dummy zero Y and Z components, so XDMF thinks it is getting a dataset in 3D. When it gets a VectorFunctionSpace, it expects it to have 3 components. I've pushed a fix to next.
-
reporter It works fine. Thank you very much.
-
reporter - changed status to resolved
Solved in a86a4d3
-
- changed status to open
Doesn't work for VectorElement with dim>1 in 1D. See comment on commit in next.
-
- changed status to resolved
Now fixed
-
- removed milestone
Removing milestone: 1.7 (automated comment)
-
What about for, say a mixed function space, say for Stokes with u,p = y \in V_mixed? Can the XMDF writing interface be written such that writing y to XDMF will make sense?
- Log in to comment