2

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

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.

Ice0cean
  • 813
  • 4
  • 11

1 Answers1

2

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

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

enter image description here

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

enter image description here

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.

user21
  • 39,710
  • 8
  • 110
  • 167