# Line-Dirichlet Boundary NDSolve

I have defined such a Dirichlet boundary conditions which fixes the nodes in a line, however, the results show that only two nodes are fixed, not the nodes in a line,

Code:

\[CapitalOmega] = Rectangle[{0, 0}, {1, 1}];
sol = NDSolveValue[{D[u[x, y], x, x] + D[u[x, y], y, y] - u[x, y] ==
0, u[0.5, y] == 1.0}, u, {x, y} \[Element] \[CapitalOmega]]

DensityPlot[sol[x, y], {x, y} \[Element] \[CapitalOmega],
Mesh -> None, ColorFunction -> "Rainbow", PlotRange -> All,
PlotLegends -> Automatic]

Plot3D[sol[x, y], {x, y} \[Element] \[CapitalOmega]]


These are boundary conditions and thus the seen behavior is as expected and correct. Now, you can have DirichletConditions inside the domain: For this you need to generate a mesh with an internal boundary (see documentation here)

Needs["NDSolveFEM"]
bmesh = ToBoundaryMesh[
"Coordinates" -> {{0, 0}, {1/2, 0}, {1, 0}, {1, 1}, {1/2, 1}, {0,
1}}, "BoundaryElements" -> {LineElement[{{1, 2}, {2, 3}, {3,
4}, {4, 5}, {5, 6}, {6, 1}}], LineElement[{{2, 5}}]}];


Look the boundary mesh, which now has an internal boundary:

bmesh["Wireframe"]


mesh = ToElementMesh[bmesh];
sol = NDSolveValue[{D[u[x, y], x, x] + D[u[x, y], y, y] - u[x, y] ==
0, u[0.5, y] == 1.0}, u, {x, y} \[Element] mesh]
Plot3D[sol[x, y], {x, y} \[Element] mesh]


You can refine the plot to get a better quality plot like so:

Plot3D[sol[x, y], {x, y} \[Element] mesh, PlotPoints -> 100]


However, it is better to just restrict the domain and have the boundary conditions at the boundary like so:

\[CapitalOmega] = Rectangle[{0, 0}, {1/2, 1}];
sol = NDSolveValue[{D[u[x, y], x, x] + D[u[x, y], y, y] - u[x, y] ==
0, u[0.5, y] == 1.0}, u, {x, y} \[Element] \[CapitalOmega]];
Plot3D[sol[x, y], {x, y} \[Element] \[CapitalOmega]]


See that they are the same:

Plot3D[sol[x, y] - sol2[x, y], {x, y} \[Element] \[CapitalOmega],
PlotRange -> All]


• the values on the line are not smooth in MMA... P.S. it has to be .... Jul 30, 2019 at 14:44
• @ABCDEMMM, refine the boundary mesh or the mesh. Could also me a plotting issue. Fact is that the difference between the two plots is small compared to the domain size. Jul 30, 2019 at 14:51
• if I use 1/1000 (global refinement mesh), it is also not smooth, a little better ... Jul 30, 2019 at 14:53
• @ABCDEMMM, the try to refine the plot. Jul 30, 2019 at 14:54
• I have used both methods ... Jul 30, 2019 at 14:54