Question: I want to solve a PDE using NDEigensystem
. The region is a rectangle Rectangle[{0,-70}, {20, 70}]
. How can I make a mesh that satisfies the following two conditions?
(1) The mesh is finer near $ y \approx 0$ .
(2) The line $ y=0$ should be the boundary of the mesh.
Motivation: The PDE that I want to solve can be written in the following command: First, I set the mesh as below:
mesh = ToElementMesh[Rectangle[{0, -70}, {20, 70}], MeshRefinementFunction -> Function[{vertices, area}, Block[ {x, y}, {x, y} = Mean[vertices]; If[-10 < y < 10, area > 0.1, area > 10]]] ]
and then write down the PDE:
NDEigensystem[{{3*psi3[x, y] - 10*psi2[x, y]*Sign[y] - Derivative[0, 1][psi2][x, y] - I*Derivative[1, 0][psi2][x, y], 3*psi4[x, y] - 10*psi1[x, y]*Sign[y] + Derivative[0, 1][psi1][x, y] - I*Derivative[1, 0][psi1][x, y], 3*psi1[x, y] - 10*psi4[x, y]*Sign[y] - Derivative[0, 1][psi4][x, y] - I*Derivative[1, 0][psi4][x, y], 3*psi2[x, y] - 10*psi3[x, y]*Sign[y] + Derivative[0, 1][psi3][x, y] - I*Derivative[1, 0][psi3][x, y]}, PeriodicBoundaryCondition[psi1[x, y], x == 0, TransformationFunction[{{1, 0, 20}, {0, 1, 0}, {0, 0, 1}}]], PeriodicBoundaryCondition[psi2[x, y], x == 0, TransformationFunction[{{1, 0, 20}, {0, 1, 0}, {0, 0, 1}}]], PeriodicBoundaryCondition[psi3[x, y], x == 0, TransformationFunction[{{1, 0, 20}, {0, 1, 0}, {0, 0, 1}}]], PeriodicBoundaryCondition[psi4[x, y], x == 0, TransformationFunction[{{1, 0, 20}, {0, 1, 0}, {0, 0, 1}}]], DirichletCondition[psi1[x, y] == 0, 0 < x < 20 && (y == 70 || y == -70)], DirichletCondition[psi2[x, y] == 0, 0 < x < 20 && (y == 70 || y == -70)], DirichletCondition[psi3[x, y] == 0, 0 < x < 20 && (y == 70 || y == -70)], DirichletCondition[psi4[x, y] == 0, 0 < x < 20 && (y == 70 || y == -70)]}, {psi1, psi2, psi3, psi4}, Element[{x, y}, mesh], 10]
The single important fact about the PDE is that the differential operator contains $ \mathrm{sgn}(y)$ , hence it is not continuous at $ y=0$ . This is why I want the mesh boundary to include $ y=0$ . The mesh I created is visualized as follows:

As wanted, the mesh is finer. However, $ y=0$ is not the boundary of the mesh.
The result of one solution obtained by solving the PDE is plotted as below:

In the above plot, the horizontal direction is the $ x$ -direction. Note that the solution is localized near $ y\approx 0$ . This is why I want to make the mesh finer near $ y\approx 0$ . I don’t believe the result is the good representation of the solution, since the graph looks jagged, which I don’t expect since the differential operator has a translation symmetry in $ x$ -direction.