Hello,
I am new to Fenics and I’m currently trying to use it to solve a 2-dimensionnal PDE, where the function to compute is the concentration C(z,t).
I want to solve it, knowing that C(z,0) = 0 and that C(0,t) is a piecewise linear function and I already have it stored in an array.
Exemple of C(0,t) :

Here is my naive implementation of C(0,t) (which is u_V here) :
from fenics import *
N = 10
C0 = [0,1,2,5,10,5,2,1,0,0,] #C(0,t) values at each time step
mesh = UnitSquareMesh(N,N)
V = FunctionSpace(mesh, "CG", 1)
#implementation of C(z,0) = 0
u_H = Constant(0)
#implementation of C(0,t) = C0
u_V = Function(V)
L=[0 for i in range((N+1)**2)]
for i in range(N):
L[(N+1)*i] = C0[i]
u_V.vector()[:]=L
When I use this to solve the PDE, I have some results, but I have no idea if it’s the right way to do it.
Is it the correct way to implement a piecewise linear function ?
Thanks.