4

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

http://www.inf.ethz.ch/personal/tulink/FEM14/Ch1_ElmanSyvesterWathen_Ox05.pdf

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.

ccannon
  • 81
  • 5

2 Answers2

4

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]

Mathematica graphics

Michael E2
  • 235,386
  • 17
  • 334
  • 747
ccannon
  • 81
  • 5
  • 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 01:51
1

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]]
Ivan
  • 2,207
  • 15
  • 25