This is a read only copy of the old FEniCS QA forum. Please visit the new QA forum to ask questions

Plotting solution on refined mesh after automated goal oriented error control

0 votes

Please I need help with the following. I have solved the Stokes problem as shown below, using automated goal oriented error control control on an estimate of the drag as in the code. The python code runs well and from the output messages, the mesh is refined. However, when I do a plot of the pressure and velocity using "plot(p.leaf_node(), title="Pressure Solution on final mesh")" and "plot(u.leaf_node(), title="Velocity Solution on final mesh")" the plot is till on the original mesh. How doI go about seeing the solution for both variables on the refined mesh. My overall objective is to be able to pass the refined mesh and solutions as argument to another function.

Regards,

V = VectorFunctionSpace(mesh, "Lagrange", 2)
Q = FunctionSpace(mesh, "CG", 1)
W = V * Q
noslip = Constant((0, 0))
bc0 = DirichletBC(W.sub(0), noslip, boundary_parts, 3)
bc1 = DirichletBC(W.sub(0), noslip, boundary_parts, 0)
inflow = Expression(("sin(x[1]pi/w_x)", "0.0"),w_x=ly)
bc2 = DirichletBC(W.sub(0), inflow, boundary_parts, 2)
bcs = [bc0, bc1, bc2]
(v, q) = TestFunctions(W)
f = Constant((0, 0))
w = Function(W)
(u, p) = split(w)
F = (inner(grad(u), grad(v)) - div(v)
p - qdiv(u))dx-inner(f, v)*dx

Define goal functional

ds = Measure("ds")[boundary_parts]
M = p*ds(0)
tol = 1e-3
solve(F == 0, w, bcs, tol = tol, M = M)
# (needed for further computation on coefficient vector)
(u, p) = w.split(True)
print "Norm of velocity coefficient vector: %.15g" % u.vector().norm("l2")
print "Norm of pressure coefficient vector: %.15g" % p.vector().norm("l2")
(u, p) = w.split()
plot(p.root_node(), title="Solution on initial mesh")
plot(p.leaf_node(), title="Solution on final mesh")
return p, u

asked Feb 25, 2015 by chuckdii2002 FEniCS Novice (270 points)
...