I've been playing around with the auto adaptive solver option, as explained in the demo Auto adaptive Poisson equation. I've been able to expand it to cases where there is a mixed function space, such as in the demo Poisson equation with pure Neumann boundary conditions, or when a vector function space is used. However, when I tried to use it for a problem that involved a mixed function space consisting of vector function spaces I get the error "Order "1" invalid for "Real" finite element." Here is the code:
# Create mesh
mesh = UnitSquareMesh(10, 10)
V = VectorFunctionSpace(mesh, "Lagrange", 1)
R = VectorFunctionSpace(mesh, "R", 0)
P = MixedFunctionSpace([V, R])
# define part of boundary
class BDY1(SubDomain):
def inside(self, x, on_boundary):
return near(x[1], 0)
bdy1 = BDY1()
boundaries = FacetFunction("size_t", mesh)
boundaries.set_all(0)
bdy1.mark(boundaries, 1)
ds = Measure("ds")[boundaries]
# Define functions
(u, c) = TrialFunctions(P)
(v, d) = TestFunctions(P)
t = Constant((1.0, 0.0)) # Traction force on the boundary
# Elasticity parameters
E, nu = 10.0, 0.3
mu, lmbda = Constant(E/(2*(1 + nu))), Constant(E*nu/((1 + nu)*(1 - 2*nu)))
# Set up linear problem
a = (inner(grad(u),grad(v)) + inner(c, v) + inner(u,d))*dx
L = dot(t, v)*ds(1)
# Solve variational problem
p = Function(P)
(u, c) = split(p)
M = u[i]*u[i]*dx
solve(a == L, p, tol=0.001, M=M)
# Plot and hold solution
plot(p.root_node().sub(0), mode = "displacement")
plot(p.leaf_node().sub(0), mode = "displacement")
interactive()
If anyone knows why this doesn't work and how to fix it, I would be grateful if they let me know.