Hi there,
I’m a complete beginner in Fenics. I tried to solve a basic equation :
\Delta v(x,y) + \ell^2 v(x,y) = f(x) on a unit square, with v(0,y)=0 and v(x,0)=0
The f function has been implemented in Python and is quite complex.
This really seems like a dumm question, but how to implement f in Fenics ?
Here is the code I wrote :
mesh = UnitSquareMesh(16,16)
V = FunctionSpace(mesh, 'P', 1)
u_D = Expression('0', degree=0)
def boundary(x, on_boundary):
return on_boundary and x[0]<0.2 and x[1]<0.2
bc = DirichletBC(V, u_D, boundary)
v = TrialFunction(V)
s = TestFunction(V)
def aux(x):
return -l2*condY0(x[0])
f = interpolate(aux,V)
a = (-dot(grad(v), grad(s))+l2*v*s)*dx
L = f*s*dx
u = Function(V)
solve(a == L, u, bc)
However this doesn’t seem to work…
Thanks for your help !