I want to solve the laplace equation on the disk using NDSolve. Particularly I want to solve the problem $$\frac{\partial^2 u }{\partial r^2 } +r^{-1}\frac{\partial u }{\partial r }+r^{-2}\frac{\partial^2 u }{\partial \theta^2 }=0$$ with $$u(a,\theta )=f(\theta )$$ and $0<\theta <2 \pi $.
Also set $a=3$ and $f(\theta )=\begin{cases} 1 & 0 \leq \theta \leq \pi \\ \sin^2 \theta & \pi < \theta < 2 \pi \end{cases}$.
So my attemped code is
Clear["Global`*"]
a = 3;
f[theta_] :=
Piecewise[{{1, 0 <= theta <= π}, {(Sin[theta])^2, π < theta < 2*π}}]
PDE = (D[u[r, theta], {r, 2}]) + r^-1*(D[u[r, theta], {r, 1}]) +
r^-2*(D[u[r, theta], {theta, 2}]) == 0;
BC = u[r, theta /. theta -> 0] == u[r, theta /. theta -> 2*π]
IC = u[r /. r -> a, theta] == f[theta];
sol = NDSolve[{PDE, BC, IC }, u, {r, theta} ∈ Disk[]];
Plot3D[u[r, theta], {r, 0, a}, {theta, 0, 2*π}]
However the code is not working, I can't figure out why. Can you explain my mistake?
ufun = NDSolveValue[{Laplacian[u[r, θ], {r, θ}, "Polar"] == 0, DirichletCondition[u[r, θ] == Piecewise[{{1, 0 < θ <= π}, {Sin[θ]^2, π < θ <= 2 π}}], r == 3 && 0 < θ < 2 π], PeriodicBoundaryCondition[u[r, θ], θ == 0, TranslationTransform[{0, 2 π}]]}, u, {r, 0, 3}, {θ, 0, 2 π}, Method -> {"FiniteElement", "MeshOptions" -> {"MaxCellMeasure" -> 0.0005}}]
? $\endgroup$