What I frequently do is interpolate a 2D slice of the Function on a 2D mesh and plot that.
At least for debugging/understanding the solutions I find this much more convenient than using an additional software pipeline.
I wrote a helper function for this:
def plot_cross(u, mesh2D, title="", axis=1):
# create Expression to evaluate u on a hyperplane
ucross = uCross(u=u, axis=axis)
# interpolate u onto the 2D mesh
V = dolfin.FunctionSpace(mesh2D, "CG", 1)
u2D = dolfin.Function(V)
u2D.interpolate(ucross)
dolfin.plot(u2D, title=title)
class uCross(dolfin.Expression):
def __init__(self, u, axis=1):
self.u = u
self.i = axis
dolfin.Expression.__init__(self)
def eval(self, value, x):
y = list(x)
y.insert(self.i, 0.)
value[0] = self.u(y)
This code is limited in that it can only plot on crosssections which lie precisely on the x-y, x-z or y-z planes. (the "axis=1" default means that x-z is plotted by default, i.e. the direction with index 1, which is x1, is left out.)
But I'm sure it can give you a general idea how to implement more general crossectional plots.
Cheers, Gregor