3
$\begingroup$

I am solving Laplace equation with particular geometry and boundary conditions:

L = 10; a = 1; k = 1/2; mesh = 0.06;

BoxL = x == L || x == -L || y == L || y == -L;

reg = ImplicitRegion[(-L <= x <= L && -L <= y <= L) && (x^2 + y^2 >=  
  a^2), {x, y}];
rp = RegionPlot[reg, AspectRatio -> Automatic, ImageSize -> Tiny]

enter image description here

Boundary condition for θ

bcθ = {DirichletCondition[u[x, y] == ArcTan[x, y] k, x^2 + y^2 == a^2],
   DirichletCondition[u[x, y] == 0, BoxL]};

Solving equation for θ

θ = NDSolveValue[{Laplacian[u[x, y], {x, y}] == 0, bcθ}, 
 u, {x, y} ∈ reg, Method -> {"FiniteElement", "MeshOptions" -> {MaxCellMeasure -> mesh}, 
"InterpolationOrder" -> {u -> 2}}];

And then plot:

enter image description here

Magnifying and showing the mesh:

enter image description here

There appears to be some small imperfections. Of course I have tuned the parameter mesh to minimize them, i.e., the mesh "scale" is the best I could find within this "shape".

Here comes my question: how do I define a mesh which is finer around the central circular hole (which is a boundary)? Is there a simple way without going down to draw it?

Thanks!

$\endgroup$

1 Answer 1

6
$\begingroup$

You can use "MaxBoundaryCellMeasure" for that:

L = 10; a = 1; k = 1/2; mesh = 0.06;
BoxL = x == L || x == -L || y == L || y == -L;
reg = ImplicitRegion[(-L <= x <= L && -L <= y <= L) && (x^2 + y^2 >= a^2), {x, y}];
bcθ = {DirichletCondition[u[x, y] == ArcTan[x, y] k, x^2 + y^2 == a^2], 
   DirichletCondition[u[x, y] == 0, BoxL]};

θ = NDSolveValue[{Laplacian[u[x, y], {x, y}] == 0, bcθ}, 
   u, {x, y} ∈ reg, 
   Method -> {"FiniteElement", "MeshOptions" -> {"MaxBoundaryCellMeasure" -> mesh}}];

Show[ContourPlot[θ[x, y], {x, y} ∈ θ["ElementMesh"], 
  PlotRange -> All], θ["ElementMesh"]["Wireframe"], PlotRange -> {{0, 2}, {-1, 1}}]

enter image description here

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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