Having computed my solution u to the stokes equations, I plotted it on a courser mesh using
```python
# plotting
L = Constant(10)
mesh_plot = RectangleMesh(Point(0, 0), Point(1, L), 2, 5)
W2 = FunctionSpace(mesh_plot, V)
u_plot = interpolate(u, W2)
plot(u_plot)
However when I tried to extract the meshpoints and vector values to process in python the sizes of the
meshpoints array and the vector values don't align
ur=np.array(u_plot.sub(0,deepcopy=True))
uz= np.array(u_plot.sub(1,deepcopy=True))
coor = np.array(mesh_plot.coordinates() )
print(np.size(coor))
print(np.size(uz))
How can I get the vector values evaluated at each of the meshpoints in the plot.
Thanks
Full code to reproduce
from dolfin import *
import numpy as np
L = Constant(10)
# Define mesh and
mesh = RectangleMesh(Point(0, 0), Point(1, L), 100, 100)
boundaries = MeshFunction("size_t", mesh, mesh.topology().dim() - 1)
boundaries.set_all(0)
# Define Taylor--Hood function space W
V = VectorElement("CG", triangle, 2)
Q = FiniteElement("CG", triangle, 1)
W = FunctionSpace(mesh, MixedElement([V, Q]))
# Define Function and TestFunction(s)
w = Function(W)
(u, p) = split(w)
(v, q) = split(TestFunction(W))
# Boundary Conditions
u_out = Expression(('-x[0]*0.5*std::log(30)', '0'), degree=1)
# manually put in L
inl = 'near(x[1], 10)'
FB = 'near(x[0], 1.0)'
cent = 'near(x[0], 0.0)'
out = 'near(x[1], 0.0)'
bcu_inflow = DirichletBC(W.sub(0), (0.0,0.0), inl)
bcu_cent = DirichletBC(W.sub(0).sub(0), (0.0), cent)
bcu_outflow = DirichletBC(W.sub(0), u_out, out)
bcs = [bcu_inflow, bcu_cent, bcu_outflow]
# weak form
x = SpatialCoordinate(mesh)
def div_cyl(v):
return (1/x[0])*(x[0]*v[0]).dx(0) + v[1].dx(1)
a1 = (inner( grad(u), grad(v) ) - p*div_cyl(v) ) *dx
a2 = div_cyl(u)*q*dx
F = a1 + a2
# Solve problem
solve(F == 0, w, bcs)
(u, p) = w.split()
# plotting
L = Constant(10)
mesh_plot = RectangleMesh(Point(0, 0), Point(1, L), 2, 5)
W2 = FunctionSpace(mesh_plot, V)
u_plot = interpolate(u, W2)
plot(u_plot)
# mismatched sizes
ur=np.array(u_plot.sub(0,deepcopy=True))
uz= np.array(u_plot.sub(1,deepcopy=True))
coor = np.array(mesh_plot.coordinates() )
print(np.size(coor))
print(np.size(uz))