4
$\begingroup$

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.

$\endgroup$
4
  • $\begingroup$ 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. $\endgroup$ – Timothy Wofford Dec 19 '14 at 16:46
  • $\begingroup$ 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. $\endgroup$ – ccannon Dec 19 '14 at 17:41
  • $\begingroup$ (1) DirichletCondition? (2) region = ImplicitRegion[<inequalities>]. $\endgroup$ – Michael E2 Dec 19 '14 at 18:34
  • $\begingroup$ tutorial/SolvingPDEwithFEM.html $\endgroup$ – Timothy Wofford Dec 19 '14 at 20:51
4
$\begingroup$

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

$\endgroup$
1
  • $\begingroup$ 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. $\endgroup$ – Michael E2 Dec 20 '14 at 1:51
1
$\begingroup$

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]]
$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.