### Apply boundary condition Semi-circle

160

views

0

Hi, I am solving elastiicty problem for that I want to apply displacement on upper half of the semicircle. Figure attached

I am using this syntex to apply boundary condition but throws error: ValueError: math domain error, That is due to sqrt(-1), How to apply this boundary condition correctly.

```
class top(SubDomain):
def inside(self,x,on_boundary):
tol = 1e-1
return (x[1] - sqrt(r**2 - (x[0]-h)**2) - k ) < tol and on_boundary
#where r = radius
# (h,k) = center of the circle
```

FEniCS version 1.6.0

Thanks for the help.

HSK

Community: FEniCS Project

### 1 Answer

4

I assume it should be something like

```
R = 5.0
x0 = 20.
y0 = 10.
return (x[0]-x0)**2.+(x[1]-y0)**2. < (R+tol)**2. and on_boundary
```

Essentially your last bracket in the sqrt expression should be moved left. If you want to add the "upper circle" condition, you should add

`... and (x[1] >= y0) ...`

see update. Your full condition will be return (circle) and (half part) and on_boundary

written
4 months ago by
Corwinpro

Thanks for the help, it works

written
4 months ago by
hirshikesh

Please login to add an answer/comment or follow this question.

Thanks

HSK