Add interior Point to Dirichlet Boundary

Hello,

I want to add an interior point (not a facet) to my boundary. For example, in the code below the boundary reads Gamma = ([0,1] x {0}) v ([0,1] x {1}) v ({0} x [0,1]) v ({1} x [0,1]) . However, I want the function to be zero at Gamma and the origin (0,0), that is, the Dirichlet Boundary should consist of Gamma v {(0,0)}. Can I add the point (0,0) to the boundary?

Best regards
Johannes

from dolfin import *
import matplotlib.pyplot as plt
mesh=UnitSquareMesh(4,4)
V = FunctionSpace(mesh, ‘P’ ,1)
bc = DirichletBC(V,Constant(0.0), “on_boundary” )
f = Constant(1.0)
u = TrialFunction(V)
v = TestFunction(V)
a = dot(grad(u), grad(v))dx
L = f
v*dx
u_h = Function(V)
solve(a == L, u_h, bc)
plot(u_h)
plot(mesh)
plt.show()

===================================================================

In this example, (0,0) is part of the boundary; did you perhaps mean (\frac{1}{2},\frac{1}{2})? You can do that as follows:

from dolfin import *
import matplotlib.pyplot as plt
mesh=UnitSquareMesh(4,4)
V = FunctionSpace(mesh, "P" ,1)
bc = DirichletBC(V,Constant(0.0), "on_boundary" )

# Add another BC, where the condition is checked "pointwise":
bc_pt = DirichletBC(V,Constant(0.0),
                    "near(x[0],0.5) && near(x[1],0.5)",
                    "pointwise")
bcs = [bc,bc_pt]

f = Constant(1.0)
u = TrialFunction(V)
v = TestFunction(V)
a = dot(grad(u), grad(v))*dx
L = f*v*dx
u_h = Function(V)
solve(a == L, u_h, bcs) # (Note: Changed argument from bc to bcs)
plot(u_h)
plot(mesh)
plt.show()

When applying BCs pointwise, there just needs to be a DoF at the corresponding point (so, (0.7,0.3) would not work in this example).

Great, this works perfect. Thanks a lot.

Is near(x[0], 0.5) && near(x[1], 0.5) true for the closest node to (\frac{1}{2}, \frac{1}{2}), or is near(x[0], 0.5) equivalent to abs(x[0] - 0.5) < SOME_EPSILON? I guess that by:

there just needs to be a DoF at the corresponding point

you meant the latter, but I want to be sure as I need to impose DirichletBC on a node closest to an arbitrary location.