Hello
I am trying to apply Dirichlet BCs on the upper-right and lower-left 10% corner edges of a square domain, see the following sketch and example code. There was no error in running the code, but by printing the max and min of the solution u
, I expected min to be 0 and max be 1 but the code gave me both around 1. I might just not seeing my own bugs, could anyone help taking a look? Thank you!
from dolfin import *
class ExternalSurf(SubDomain):
def inside(self, x, on_boundary):
top = ( (x[0] > 4.5) and (x[1] >5.-DOLFIN_EPS) )
right = ( (x[1] > 4.5) and (x[0] > 5.-DOLFIN_EPS) )
return (top or right) and on_boundary
class InternalSurf(SubDomain):
def inside(self, x, on_boundary):
bottom = ( (x[0] < 0.5) and (x[1] <DOLFIN_EPS) )
left = ( (x[1] < 0.5) and (x[0] <DOLFIN_EPS) )
return (bottom or left) and on_boundary
mesh = RectangleMesh(Point(0., 0.), Point(5., 5.), 100, 100)
V = FunctionSpace(mesh, 'Lagrange', 2)
bc1 = DirichletBC(V, Constant(1.), InternalSurf())
bc2 = DirichletBC(V, Constant(0.), ExternalSurf())
bc = [ bc1, bc2 ]
u = Function(V)
v = TestFunction(V)
F = inner( grad(u), grad(v) )*dx
solve(F==0,u,bc)
print('min(u.vector()) ',min(u.vector()))
print('max(u.vector()) ',max(u.vector()))
the code does give the following warning though:
*** Warning: Found no facets matching domain for boundary condition.