If I solve Laplace's equation with Neumann boundary conditions then everything is defined via derivatives. Consequently one needs to fix a point with a specific value to get a solution. However if I fix my value with a Dirichlet condition the solution is distorted. Where am I going wrong?
Edit to question I think I have been asking Mathematica to solve an impossible problem. See my answer below.
Continue with original question
Here is an example
Needs["NDSolve`FEM`"];
x2 = 4; y2 = 1;
reg = ImplicitRegion[0 <= x <= x2 && 0 <= y <= y2, {x, y}];
mesh = ToElementMesh[reg,
"BoundaryMeshGenerator" -> {"Continuation"},
MaxCellMeasure -> .002,
"MaxBoundaryCellMeasure" -> 0.01];
Show[mesh["Wireframe"], Frame -> True, PlotRange -> All]
Here is a Laplacian with Neumann boundary conditions so that everything is defined through derivatives.
sol = NDSolveValue[{
Laplacian[u[x, y], {x, y}] ==
NeumannValue[1, 0 <= y <= y2 && x == 0] +
NeumannValue[Cos[2 \[Pi] x/x2], 0 <= x <= x2 && y == y2]
}, u, {x, y} \[Element] mesh];
This gives a message along the expected lines
NDSolveValue::femibcnd: No DirichletCondition or Robin-type NeumannValue was specified for {u}; the result is not unique up to a constant. >>
Now we repeat with a Dirichlet condition that gives a value in the corner
sol = NDSolveValue[{
Laplacian[u[x, y], {x, y}] ==
NeumannValue[1, 0 <= y <= y2 && x == 0] +
NeumannValue[Cos[2 \[Pi] x/x2], 0 <= x <= x2 && y == y2],
DirichletCondition[u[x, y] == 0, x == x2 && y == 0]
}, u, {x, y} \[Element] mesh];
Plot3D[sol[x, y], {x, y} \[Element] mesh, BoxRatios -> {x2, y2, 1}]
The value in the corner is as expected but the whole solution is distorted to reach the value.
If I change the location of the Dirichlet point then the location of the distortion changes as perhaps might be expected.
sol = NDSolveValue[{
Laplacian[u[x, y], {x, y}] ==
NeumannValue[1, 0 <= y <= y2 && x == 0] +
NeumannValue[Cos[2 \[Pi] x/x2], 0 <= x <= x2 && y == y2],
DirichletCondition[u[x, y] == 0, x == x2 && y == y2]
}, u, {x, y} \[Element] mesh];
Plot3D[sol[x, y], {x, y} \[Element] mesh, BoxRatios -> {x2, y2, 1}]
If I look at the Laplacian of the solution then the point continues to appear
ClearAll[f2];
f2[x_, y_] := Evaluate[Laplacian[sol[x, y], {x, y}]]
Plot3D[f2[x, y], {x, y} \[Element] mesh, BoxRatios -> {x2, y2, 1},
PlotRange -> All]
Plot3D[f2[x, y], {x, y} \[Element] mesh, BoxRatios -> {x2, y2, 1}]
The values in the above plots should be zero and they are small except where I have my Dirichlet point.
So what do I not understand? Is it something to do with Neumann values being associated with the normal to the boundary and this not being compatible with a defined point? Please enlighten me.