I know that there are some difficulties interpolating from Enriched function spaces to non-enriched spaces.
The attached script here used to work, but now the "stabilized" solution is not correct. Is there a way to fix this with dolfin 1.6?
Thanks again,
Evan
from fenics import *
mesh = IntervalMesh(10,0,1)
Q = FunctionSpace(mesh, 'CG', 1)
B = FunctionSpace(mesh, 'B', 2)
M = Q + B
def left(x, on_boundary):
return on_boundary and x[0] == 0
leftBC = DirichletBC(Q, 1.0, left)
kappa = 1.0/500.0
s = 1.0
f = Constant(0.0)
#==============================================================================
# unstabilized :
u = TrialFunction(Q)
v = TestFunction(Q)
us = Function(Q)
uf1 = Function(Q)
a = + kappa * u.dx(0) * v.dx(0) * dx \
+ s * u * v * dx
L = f * v * dx
solve(a == L, us, leftBC)
uf1.interpolate(us)
#==============================================================================
# stabilized :
u = TrialFunction(M)
v = TestFunction(M)
us = Function(M)
uf2 = Function(Q)
a = + kappa * u.dx(0) * v.dx(0) * dx \
+ s * u * v * dx
L = f * v * dx
solve(a == L, us, leftBC)
uf2.interpolate(us)
#==============================================================================
# plotting :
from pylab import *
t = mesh.coordinates()[:,0][::-1]
uf1 = uf1.vector().array()
uf2 = uf2.vector().array()
x = linspace(0, 1, 1000)
ue = (exp(-10*sqrt(5)*(x-2)) + exp(10*sqrt(5)*x))/(1 + exp(20*sqrt(5)))
plot(t, uf1, 'r', lw=2.0, label=r"$u_1$")
plot(t, uf2, 'k', lw=2.0, label=r"$u_2$")
plot(x, ue, 'k--', lw=2.0, label=r"$u_a$")
xlabel(r'$x$')
ylabel(r'$u$')
legend()
xlim([0,0.3])
grid()
show()