Boundary question

Hi

I am new to fenics and just wants to make sure that I am implementing it correctly. I would like to have 0 on the left boundary as a dirichlet boundary condition , so I am doing the following:

u_L = Expression(“near(x[0], 0)”, degree=2)

def boundary_L(x, on_boundary):
return on_boundary
bc_L = DirichletBC(V, u_L, boundary_L)

Is this correct? and could someone maybe explain what “near(x[0], 0)” means exactly.

“near(x[0],0)” is a boolean evaluation, return one if x[0], the x-coordinate is close to 0, and zero otherwise.
I would suggest you having a look at https://fenicsproject.org/docs/dolfin/latest/python/demos/poisson/demo_poisson.py.html

Thank you, I will have a look at it