I'm solving the laplace equation in a domain with holes, and I need to compute the integral of the gradient on the boundary of these holes.
For that I define a mesh and solve the laplace equation with fem. As I understand (I'm no fem expert, I'm more used to work with particle methods) the fem solution should approach the "correct" solution as the mesh elements become smaller. This is in fact the case and I can have a converging approximation as the number of points in the mesh increases.
However, the symmetry of the system is not recovered and needs a way smaller mesh to be better resolved. To put this in concrete terms I define a mesh with a hole:
mesh2 = ToElementMesh[
ImplicitRegion[And[( x)^2 + y^2 <= 100, x^2 + y^2 > 1], {x, y}],
"MaxBoundaryCellMeasure" -> .0025,
"ImproveBoundaryPosition" -> False, "MaxCellMeasure" -> 2.5]
I solve the laplace equation with a source term
sol := NDSolveValue[{Derivative[0, 2][u][x, y] + Derivative[2, 0][u][x, y] ==
NeumannValue[1,x^2 + y^2 == 1 ],
DirichletCondition[u[x, y] == 0, x^2 + y^2 >= 99]},
u, {x, y} ∈ mesh2, AccuracyGoal -> 30,
Method -> "FiniteElement", PrecisionGoal -> 50,
WorkingPrecision -> 35, MaxSteps -> Infinity,
InterpolationOrder -> All]
Depending on the MaxBoundaryCellMeasure I use, the solution I obtain are like this:
Show[ContourPlot[Evaluate[(sol[x, y])/4.], {x, y} ∈ mesh2,
Contours -> 20, PlotPoints -> 30, MaxRecursion -> 4,
PlotRange -> {{-2, 2}, {-2, 2}, {-.6, -.2}},
PlotLegends -> Automatic,
ColorFunction -> "Rainbow"],
Graphics[{Cyan, Disk[{-6.5, 0}], Disk[{6.5, 0}]}]]
However, if I decrease increase the MaxBoundaryCellMeasure->.05 I get the following solution:
You can see the errors along the x and y axis near the boundary. The problem is clearly symmetric, but the solution has some error at the axis. The mesh broke the symmetry in a very annoying way.
To look closer at what I mean, let's plot the value of the solution and its gradient at the boundary of the hole. First,
f[x_, y_] = sol[x, y];
f1[x_, y_] = D[f[x, y], {{x, y}}];
Then, we plot it as a function of the angle
x = Cos[ϕ]y = Sin[ϕ];
Plot[{Evaluate[Norm[f1[x, y]]], Evaluate[Norm[f[x, y]]]}, {ϕ, 0,
2 π}, PlotStyle -> {Red, Black}, PlotRange -> Full,
Frame -> True, FrameLabel -> {"ϕ", "sol"},
PlotLegends -> {"Norm[f']", "f"}]
That's for the coarse mesh, however, the fine mesh has also broken the symmetry in the same places:
Since I'm interested precisely in the gradient of the function at the boundary this makes it more problematic to compute. Is this a bug?
Is there a way to "filter" the solution so I can get rid of the spikes in the gradient? am I doing something wrong at solving the equations? The real problem I want to solve doesn't have just one hole, but several with different kind of symmetries, that's why I'm interested in recovering the right symmetry in the solution.







"ImproveBoundaryPosition" -> Falseand expecting a good boundary? Are you trying to understand what ImproveBoundaryPosition does? If you just want a better solution try removing this option. – user21 Jan 08 '16 at 16:34NDSolveare needed. The FEM in the current version (10.3.1) is in machine precision, so the options will not take any effect. – user21 Jan 08 '16 at 16:35