# Can I select the boundary element according to regionmark?

The tutorial of Finite Element Generation gives a example on the useage of RegionMark

sh = 0.2;
sh2 = 0.02;
sw = 0.3;
bmesh = ToBoundaryMesh[
"Coordinates" -> {{0., 0.}, {1., 0.}, {1., sh}, {1., 1.}, {0.,
1.}, {0., sh + sh2}, {sw, sh + sh2}, {sw, sh}, {0., sh}},
"BoundaryElements" -> {LineElement[{{1, 2}, {2, 3}, {3, 4}, {4,
5}, {5, 6}, {6, 7}, {7, 8}, {8, 9}, {9, 1}, {3,
8}}]}];
bmesh["Wireframe"]

mesh = ToElementMesh[bmesh,
"RegionMarker" -> {{{0.1, sh/2}, 1, 0.001}, {{0.1, sh*2},
2}}];
mesh[
"Wireframe"[
"MeshElementStyle" -> {Directive[FaceForm[Green]],
Directive[FaceForm[Red]]}]]


which will produce

The boundary element of mesh can be obtained by using mesh["BoundaryElements"]. I want to know can I obtain the boundary element of the region with the prescribed RegionMark. For example, for the figure shown above, I want to only obtain the boundary element of the bottom green region.

• A question on this topic, How can I define Neumann boundary condition on the boundary between Green and Red regions? The boundary condition I want is that the electric displacement in y direction must follow εgreen . Eygreen = εred . Eyred – Navid Rajil Feb 2 '18 at 21:24
• @NavidRajil, ask a question with a specific example. I suspect you do not need that at all. Also, have a look at the Partial Differential Equations with Variable Coefficients section in the documentation. That shows a variable coefficient / multiple material domain solution. – user21 Feb 4 '18 at 8:41
• @user21, please refer to this. – Navid Rajil Feb 4 '18 at 18:24
• Is my answer of any use? – user21 Feb 8 '18 at 7:42

You can. You'd need to add element markers to the boundary mesh:

Needs["NDSolveFEM"]
sh = 0.2;
sh2 = 0.02;
sw = 0.3;
bmesh = ToBoundaryMesh[
"Coordinates" -> {{0., 0.}, {1., 0.}, {1., sh}, {1., 1.}, {0.,
1.}, {0., sh + sh2}, {sw, sh + sh2}, {sw, sh}, {0., sh}},
"BoundaryElements" -> {LineElement[{{1, 2}, {2, 3}, {3, 4}, {4,
5}, {5, 6}, {6, 7}, {7, 8}, {8, 9}, {9, 1}, {3, 8}}
, {1, 1, 2, 2, 2, 3, 3, 1, 1, 4}
]}];


Note the element markers in the boundary elements. I have added 4 markers:

bmesh["Wireframe"["MeshElement" -> "BoundaryElements",
"MeshElementStyle" -> {Green, Red, Blue, Orange}]]


Once you generate the mesh the boundary markers will be propagated to the new boundary elements in the full mesh:

mesh = ToElementMesh[bmesh,
"RegionMarker" -> {{{0.1, sh/2}, 1, 0.001}, {{0.1, sh*2}, 2}}];

Show[
mesh["Wireframe"[
"MeshElementStyle" -> {Directive[EdgeForm[LightGray],
FaceForm[]]}]],
mesh["Wireframe"["MeshElement" -> "BoundaryElements",
"MeshElementStyle" -> {Green, Red, Blue, Orange}]]]


You can inspect the generated markers:

Union[Join @@ ElementMarkers[mesh["BoundaryElements"]]]
{1, 2, 3, 4}


In addition to the ElementMesh generation tutorial you probably also want to look at the ElementMesh Visualization tutorial.