# Fenics : boundary condition

I am working on a problem found here " http://www.caesarsystems.co.uk/NAFEMS_benchmarks/le10.html" ..I am really confused about the boundary conditions and tried my level best to compute it but result is totally different

here is my bcs

class Left(SubDomain): def inside(self, x, on_boundary):
return (between (x[1], (1.0,2.75)) and between (x[2], (0.0,0.600000000))

class Right(SubDomain):
def inside(self, x, on_boundary):
return (between(x[0], (2.0,3.25)) and between (x[2], (0.0,0.600000000)))

class Outerall(SubDomain):
def inside(self, x, on_boundary):
return (((x[0]/3.25)**2 + (x[1]/2.75)**2 ) -1.0 < tol) and abs(x[2]-0.600000000)

class Outermid(SubDomain):
def inside(self, x, on_boundary):
return  (((x[0]/3.25)**2 + (x[1]/2.75)**2 ) -1.0 < tol) and abs(x[2]-0.300000000) < tol

class Top(SubDomain):
def inside(self, x, on_boundary):
return abs(x[2]-0.600000000) < tol

• Nick, please, use the markdown options provided with the editor, as there is {} to format your code. Doing so, your post will become more readable.
– Jan
Commented May 21, 2013 at 14:09
• thanks Jan.. I have edited my post now you can read it properly Commented May 21, 2013 at 14:18
• Yes, now it looks good. One more thing: Can you provide information on what you are trying to do and what eventually goes wrong? E.g. by commenting your code. I prefer to look for implementation errors immediately rather than starting with interpreting the code.
– Jan
Commented May 21, 2013 at 14:37
• I get the results for this problem but it is absolutely incorrect so I think my bc is misinterpreted by fenics ..if you can check my class Outerall(SubDomain) and class Outermid(SubDomain) definition that would be great help..thnks Commented May 21, 2013 at 14:44
• Hi nickrocks and welcome to scicomp! I agree with @Jan on this. In order to help you, we really need more information about the results you get, what you expect to happen, and some sort of correspondence between the boundary conditions in your code and the problem you're solving. This will help all of us to understand and help you better.
– Paul
Commented May 22, 2013 at 0:22

## 1 Answer

The boundary conditions you posted look fine bar the indents which I assume is just because its on here. I would have a look at this http://fenicsproject.org/documentation/dolfin/1.0.0/python/demo/pde/subdomains-poisson/python/documentation.html and check that you are implementing the boundary conditions correctly later on. For example for your left boundary condition you will still need:

left = Left()
boundaries = FacetFunction("uint", mesh) ### size_t replaces uint from 1.1 on
boundaries.set_all(0)
left.mark(boundaries, 1)
bcs = [DirichletBC(V, 5.0, boundaries, 1)
ds = Measure("ds")[boundaries]