4
$\begingroup$

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]]

enter image description here

$\endgroup$
5
$\begingroup$

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["NDSolve`FEM`"]
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"]

enter image description here

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]

enter image description here

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

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

enter image description here 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]]

enter image description here

See that they are the same:

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

enter image description here

$\endgroup$
  • $\begingroup$ the values on the line are not smooth in MMA... P.S. it has to be .... $\endgroup$ – ABCDEMMM Jul 30 at 14:44
  • $\begingroup$ @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. $\endgroup$ – user21 Jul 30 at 14:51
  • $\begingroup$ if I use 1/1000 (global refinement mesh), it is also not smooth, a little better ... $\endgroup$ – ABCDEMMM Jul 30 at 14:53
  • $\begingroup$ @ABCDEMMM, the try to refine the plot. $\endgroup$ – user21 Jul 30 at 14:54
  • $\begingroup$ I have used both methods ... $\endgroup$ – ABCDEMMM Jul 30 at 14:54

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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