3
$\begingroup$

Context

I want to solve a PDE via FEM on a Disk.

If I use a Square I can write

reg = Rectangle[]; 
mesh =  ToElementMesh[reg, MaxCellMeasure -> 0.001];

Then I can for instance

Plot3D[x y, {x, y} ∈ reg]

Mathematica graphics

But, if I want to operate on a disc,

reg = Disk[]; 
mesh = ToElementMesh[reg, MaxCellMeasure -> 0.001];

I could for instance write

Plot3D[ r Exp[-r^2] Cos[2θ] /. θ -> ArcTan[x, y] /. 
   r -> Sqrt[x^2 + y^2] // Evaluate, {x, y} ∈ reg, 
 PlotRange -> All]

Mathematica graphics

But Ideally I would like to stick to Polar coordinates.

Question

How can I ask mathematica to sample polar points on my disc?

I.e. I would like to write

Plot3D[ r Exp[-r^2] Cos[2θ], {r, θ} ∈ reg, 
     PlotRange -> All]

Of course for this simple graphics the workaround is trivial. But what I want eventually is to solve

sol = NDSolveValue[{-Laplacian[u[r, θ], {r, θ}, 
       "Polar"] == 0 , DirichletCondition[u[r, θ] == 0, True]}, 
  u, {r, θ} ∈ mesh ]

I hope my question makes sense?

$\endgroup$
4
$\begingroup$

But what I want eventually is to solve

sol = NDSolveValue[{-Laplacian[u[r, θ], {r, θ}, 
       "Polar"] == 0 , DirichletCondition[u[r, θ] == 0, True]}, 
  u, {r, θ} ∈ mesh ]

You must made typo in above, as it is clear solution is zero without solving it. May be you meant to add a non-zero boundary condition or make the RHS of the PDF non-zero?

For example, if you want DirichletCondition[u[r, θ] == θ, you could write the same command as

<< NDSolve`FEM`
reg = Disk[];
mesh = ToElementMesh[reg, MaxCellMeasure -> 0.0001];
mesh["Wireframe"];
solFEM = NDSolveValue[{-Laplacian[u[x, y], {x, y}] == 0, 
       DirichletCondition[u[x, y] == ArcTan[x, y], True]}, 
        u[x, y], Element[{x, y}, mesh]]
Plot3D[solFEM, Element[{x, y}, mesh]]

Mathematica graphics

If you want to use polar coordinates explicitly, then you can use DSolve for this. But of course DSolve will not be able to some many problems that NDSolve can.

ClearAll[u, θ, r, a];
pde = -Laplacian[u[r, θ], {r,θ}, "Polar"] == 0;
bc = u[1,θ] ==θ;
sol = DSolve[{pde, bc}, u[r, θ], {r,θ}];
sol = sol /. {K[1] -> n, Infinity -> 100}

Mathematica graphics

sol = Activate[u[r,θ] /. First@sol];
RevolutionPlot3D[sol, {r, 0, 1}, {θ, 0, 2 Pi}]

Mathematica graphics

I do not think that Mathematica's Finite elements numerical solver supports non-cartesian coordinates as the default.

May be someone else knows more. But since it is a numerical solver, Why is it important to tell it to use different coordinates system?

Using different coordinate system is important in analytical solutions, since it can simplify the mathematics quit a bit when choosing the right coordinates based on geometry.

For your original plot question

I could for instance write

Plot3D[ r Exp[-r^2] Cos[2θ] /. θ -> ArcTan[x, y] /. 
   r -> Sqrt[x^2 + y^2] // Evaluate, {x, y} ∈ reg, 
 PlotRange -> All]

You can do the above much simpler like this

ParametricPlot3D[{r Cos[θ], r Sin[θ], r Exp[-r^2] Cos[2 θ]}, {r, 0, 1}, {θ, 0, 2 Pi}]

Mathematica graphics

$\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.