Fenics does not detect boundary conditions [C++]

4 months ago by
I am trying to solve an elastic problem. The structure is constrained on two surface regions, and (changing the parameters) Fenics does not detect one or both regions. The domain is a box with dimensions: x=1, y=1, z=6.

The boundary condition is expressed using the class:
class wallConstrained : public SubDomain
  bool inside(const Array<double>& x, bool on_boundary) const
    return ((x[0]> -DOLFIN_EPS & x[0] < 0.1)*(x[1]>-DOLFIN_EPS & x[1] <0.1)*(x[2] <= DOLFIN_EPS) & on_boundary)|
           (((x[0]>0.9 & x[0] <1.0)*(x[1]>5.9 & x[1] <6.0)*(x[2] <= DOLFIN_EPS) ) & on_boundary )

I tried, for instance, to remove "& on_boundary", I tried to relax "x[2] <= -DOLFIN_EPS" with "x[2] <= 0.1" or even "x[2] <= 0.9", I tried to relax "x[0]>5.9 & x[0] <6.0" with "x[0]>5.9 & x[0] <6.1" even going out of the domain, and combination of these. I also checked the mesh, I always assured that the number of elements was enough for detection, without any results: it seems that Fenics can't see any facet on these regions, but actually the inside() function must return 1 on these regions. I even tried "geometric" and "pointwise" options for boundary condition definition, getting very strange results.
What do you suggest to check? Do you have some detailed reference on how boundary conditions work in Fenics?

Community: FEniCS Project

1 Answer

4 months ago by
The problem might be that you're using the bitwise AND operator (&) instead of the logical AND operator (&&).
Unfortunately, it didn't change anything.
written 4 months ago by Francesco Clerici  
Looking more closely, it is also somewhat strange to use the multiplication operator with Boolean values.  Assuming you want the boundary of the region \((0,1)\times(0,1)\times(0,6)\) to be detected, you might try something more like

(on_boundary && ((x[0] < DOLFIN_EPS) || (x[0] > (1.0-DOLFIN_EPS)) || (x[1] < DOLFIN_EPS) || (x[1] > (1.0-DOLFIN_EPS)) || (x[2] < DOLFIN_EPS) || (x[2] > (6.0-DOLFIN_EPS))) )​
written 4 months ago by David Kamensky  
I noticed a strange thing: even if the condition is fulfilled (I checked it with a cout), no facet is included into the boundary regions. At this point it could be helpful knowing how BC work in FEniCS.
written 4 months ago by Francesco Clerici  
Please login to add an answer/comment or follow this question.

Similar posts:
Search »