# control FEM grid size for 1D regions

I need to manage the mesh size for finite element method solution to a differential equation, where properties change over two regions. This is for one dimension. I created a boundary mesh of three points to create two linear regions.

<< NDSolveFEM

bmesh = ToBoundaryMesh["Coordinates" -> {{0}, {2}, {4}},
"BoundaryElements" -> {PointElement[{{1}, {2}, {3}}, {1, 1, 3}]},
"PointElements" -> {PointElement[{{1}, {2}, {3}}, {1, 1, 3}]}];

m3 = ToElementMesh[bmesh, "RegionMarker" -> {{{1}, 1, 0.2}, {{2},
2, 0.05}}]

m3["MeshElements"]

m3["Coordinates"]


When I check the element coordinates, the second region does not seem to have the element spacing that I requested. I should be 0.05, but it seems to stay at 0.2.

Table[{m3["Coordinates"][[i]], i}, {i,1,Length[m3["Coordinates"]]}]

m3["Wireframe"["MeshElementIDStyle" -> Red]]


Can anyone help?

• When you define m3, use { {3}, 2, 0.05} }. That is, the marker should be 3 instead of 2. – LouisB Aug 20 '19 at 23:20

m3 = ToElementMesh[bmesh,