Specifying and solving a PDE on an L-shaped domain

I wish to solve Laplace's equation with Dirchlet boundary conditions on an L-shaped domain as described here

I know how to do this on a square domain (-1,1) x (-1,1).

eqn = D[u[x, y], {x, 2}] + D[u[x, y], {y, 2}] == -1;
bcs = {u[x, 1] == 0, u[1, y] == 0, u[x, -1] == 0, u[-1, y] == 0 };
sol = First[NDSolve[{eqn, bcs}, u, {x, -1, 1}, {y, -1, 1}]];
Plot3D[Evaluate[u[x, y] /. sol], {x, -1, 1}, {y, -1, 1}]


I wish to modify the second line so that it also specifies that u[x,0]==0 when y<0 and u[x,0]==0 when x<0. Then, I'd like to solve this on the L-shaped region and plot it on the L-shaped region.

• This is straight forward in v10 using Element[{x,y},region]. If you you don't have the new hotness, then maybe the advice I gave here will be of use. – Timothy Wofford Dec 19 '14 at 16:46
• Could you tell me specifically how to use Element? How do I specify that u[x,y]==0 if Element[{x,y},region]. How would I define region? I do have version 10. – ccannon Dec 19 '14 at 17:41
• (1) DirichletCondition? (2) region = ImplicitRegion[<inequalities>]. – Michael E2 Dec 19 '14 at 18:34
• tutorial/SolvingPDEwithFEM.html – Timothy Wofford Dec 19 '14 at 20:51

Thanks. I ended up using

region = ImplicitRegion[
Or[0 < x < 1 && -1 < y < 1, -1 < x < 1 && 0 < y < 1], {x, y}]
NDSolveValue[{Laplacian[u[x, y], {x, y}] == -1,
DirichletCondition[u[x, y] == 0, True]}, u, {x, y} ∈ region]

Plot3D[%[x, y], {x, y} ∈ region]


• I fixed the formatting, I hope. What you had posted could not be copied and pasted into Mathematica. Please check that I haven't misinterpreted anything. – Michael E2 Dec 20 '14 at 1:51

In Mathematica 10:

domain= ImplicitRegion[0 <= x <= 1 && -1 <= y <= 1 || -1 <= x <= 1 && 0 <= y <= 1, {x,y}];
sol = NDSolveValue[{D[u[x, y], {x, 2}] + D[u[x, y], {y, 2}] == -1,
DirichletCondition[u[x, y] == 0, True]},
u, Element[{x, y}, domain]];

Plot3D[sol[x, y], Element[{x, y}, domain]]