# Solving PDE with Condition on Inside of Region

I'm trying to figure out how to use NDSolve to numerically solve PDEs where some internal values may be specified on the region of the solution. An example, which I picked from a textbook, is solving Laplace's equation $\nabla^2 f = 0$ on a region where we have Dirichlet boundary conditions on each edge, but we also have this set of points inside the region where $f = 0$. In this particular case, what I would try would be to solve over each of the two halves of the box (left and right), and ensure that $f$ and $\nabla f$ are continuous over the boundary between the halves, but as you can imagine, not every problem is so symmetrical. If I use DirichletCondition to try to specify values on the interior of the region, NDSolve ignores the interior condition. Does anybody know a better way to do this?

Edit: My first guess as to how I should code this is as follows:

f[x_, y_] = NDSolveValue[{Laplacian[u[x, y], {x, y}] == 0, u[x, 0] == 0,
u[x, 1] == 100, u[0, y] == 100 y, u[1, y] == 100 y,
DirichletCondition[u[x, y] == 0, x == 1/2 && y <= 2/5]},
u, {x, 0, 1}, {y, 0, 1}][x, y]


But the contour plot of this solution looks like this: So NDSolve is clearly ignoring the internal condition.

• Welcome to Mathematica.SE! I suggest that: 1) You take the introductory Tour now! 2) When you see good questions and answers, vote them up by clicking the gray triangles, because the credibility of the system is based on the reputation gained by users sharing their knowledge. Also, please remember to accept the answer, if any, that solves your problem, by clicking the checkmark sign! 3) As you receive help, try to give it too, by answering questions in your area of expertise. – bbgodfrey Feb 12 '15 at 18:46
• You mention, " If I use DirichletCondition to try to specify values on the interior of the region, NDSolve ignores the interior condition" which suggests that you have already done some coding. Can you share that so folks can provide concrete suggestions? – bobthechemist Feb 12 '15 at 18:49
• Sure! I added the code and a plot of the solution. – Michael Lee Feb 12 '15 at 19:01

I actually figured out how to do this myself from reading the answer to this question and then asking here how to construct the mesh I was looking for. I ran the following:

Needs["NDSolveFEM"]
bmesh = ToBoundaryMesh[
"Coordinates" -> {{0., 0.}, {1., 0.}, {1., 1.}, {0., 1.}, {.5, 0},
{.5,1}}, "BoundaryElements" -> {LineElement[{{1, 2}, {2, 3}, {3, 4},
{4, 1}, {5, 6}}]}]
mesh = ToElementMesh[bmesh, "MaxCellMeasure" -> 0.0005]
f[x_, y_] = NDSolveValue[{Laplacian[u[x, y], {x, y}] == 0, u[x, 1] == 100,
u[x, 0] == 0, u[1, y] == 100 y, u[0, y] == 100 y,
DirichletCondition[u[x, y] == 0, x == 1/2 && y <= 2/5]},
u, {x, y} \[Element] mesh][x, y]


...which gave me this solution: Credit goes to the original answerers of those questions for helping me figure this out. Thanks, guys!