2
$\begingroup$

When solving the following PDE with a missing BC on the fourth edge ($y=1$):

sol = NDSolveValue[{D[u[x, y], {y, 2}] + D[u[x, y], {x, 2}] == (1-y), 
           DirichletCondition[u[x, y] == 0,(y==0||x==-1||x==1)]}, u, {x,y} \[Element] Rectangle[{-1,0},{1,1}]]

MMA returns an output. I would have expected an error such as missing BC. It seems that it implicitly considered a Neumann condition $\partial_n u = 0$ on $y=1$:

Plot[D[sol[x, y], y] /. y -> 1, {x, -1, 1}, PlotRange -> Full]

enter image description here

Plus, I get the same output when I specify NeumannValue:

sol = NDSolveValue[{D[u[x, y], {y, 2}] + D[u[x, y], {x, 2}] == 1-y + NeumannValue[0, y == 1], 
               DirichletCondition[u[x, y] == 0,(y==0||x==-1||x==1)]}, u, {x,y} \[Element] Rectangle[{-1,0},{1,1}]]

Is there a rational behind the apparent autocompletion of missing BCs with 0 Neumann conditions?

$\endgroup$
6
  • 2
    $\begingroup$ It seems that it implicitly considered a Neumann condition Yes. That is correct. When solving using FEM method that is the case. From help so not specifying a boundary condition at all is equivalent to specifying a Neumann 0 condition this means NDSolve also used FEM to solve your pde (because you used DirichletCondition . see NeumannValue.html $\endgroup$
    – Nasser
    Oct 21, 2023 at 7:47
  • $\begingroup$ @Nasser Where is this in the help? On the contrary, the doc for NDSolve (v13) states "The differential equations must contain enough initial or boundary conditions to determine the solutions for the yi completely." Edit In the NeumannValue doc, OK, thank you. $\endgroup$
    – anderstood
    Oct 21, 2023 at 7:49
  • $\begingroup$ @Nasser It seems FEM is used for some reasons other than DirichletCondition: NDSolveValue[{D[u[x, y], {y, 2}] + D[u[x, y], {x, 2}] == (1 - y), u[x, 0] == 0, u[-1, y] == 0, u[1, y] == 0}, u, {x, -1, 1}, {y, 0, 1}] returns the same output. Anyway, you answered my question. I don't know if I should close my question, as it can be found in the doc but not easily. $\endgroup$
    – anderstood
    Oct 21, 2023 at 8:23
  • 1
    $\begingroup$ It could be that FEM is selected even if you do not use DirichletCondition. It depends on the problem. I am not sure how it decides internally. But I think if you use DirichletCondition or explicit Neumann then it does select FEM in that case since these go with FEM method. You could leave the question open if you want, may be someone will have more official answer and more details. It is up to you. $\endgroup$
    – Nasser
    Oct 21, 2023 at 8:27
  • $\begingroup$ If you search "Neumann zero" in this site, you'll find quite a few related posts e.g. mathematica.stackexchange.com/a/222373/1871 mathematica.stackexchange.com/a/282379/1871 , but I cannot find a post focusing on this topic at least for now. $\endgroup$
    – xzczd
    Oct 21, 2023 at 11:57

1 Answer 1

3
$\begingroup$

What you call 'auto completion' of a Neumann value in the finite element method is in fact a necessity from the derivation of the finite element method. This is explained in the notes of NeumannValue. An explanation with more text is here.

To find out in what cases the FEM is chosen automatically, have a look in the documentation here. I have added a link to this from the NDSolve and the NDSolveValue ref pages under the 'Tech Notes' button.

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