2
$\begingroup$

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.

$\endgroup$
  • $\begingroup$ 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 $\endgroup$ – Navid Rajil Feb 2 '18 at 21:24
  • $\begingroup$ @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. $\endgroup$ – user21 Feb 4 '18 at 8:41
  • $\begingroup$ @user21, please refer to this. $\endgroup$ – Navid Rajil Feb 4 '18 at 18:24
  • $\begingroup$ Is my answer of any use? $\endgroup$ – user21 Feb 8 '18 at 7:42
2
$\begingroup$

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.

| improve this answer | |
$\endgroup$

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.