Hi,
I’m experimenting on stablization techniques of the advection-diffusion-reaction equation, on which I found some code by Evan Michael Cummings. He uses a Bubble Enriched method for stabilization:
from fenics import *
mesh = IntervalMesh(50 , 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
uD = project ( Constant(0.0), M)
leftBC = DirichletBC(Q, 0.0, left )
leftBC_b = DirichletBC(Q, uD , left )
kappa = Constant(1.0/100.0)
s = Constant(5.0)
d = Constant(10.0)
f = Function(Q)
f.vector()[25] = 1000 # this is about the middle for a 50 element mesh
# bubble - enriched solution :
u = TrialFunction(M)
v = TestFunction(M)
us = Function(M)
uf2 = Function(Q)
a = + kappa * u.dx(0) * v.dx(0) * dx \
+ d * u.dx(0) * v * dx \
+ s * u * v * dx
L = f * v * dx
solve(a == L, us , leftBC_b )
uf2.interpolate (us)
However, this formulation doesn’t seem to work (anymore) in FEniCS, because I get the following error:
TypeError: unsupported operand type(s) for +: ‘FunctionSpace’ and ‘FunctionSpace’
Does anyone know how to adapt the formulation to obtain the Bubble Enriched functionspace? I found some info on NodalEnrichedElements here, but I can’t figure out how to implement this in this case because they do not apply it to a FunctionSpace in the example.
Thanks in advance!