3
$\begingroup$

fixed in 10.1 (windows)


I'm trying to build an ElementMesh for a simple 1-D problem.

First, I build the boundary ElementMesh:

Needs["NDSolve`FEM`"]
bmesh = ToBoundaryMesh[
  "Coordinates" -> {{0}, {5}, {10}},
  "BoundaryElements" -> {PointElement[List /@ #, #] &@Range@3}
  ]
bmesh["Wireframe"["MeshElementMarkerStyle" -> Blue]]

and this apparently works as expected:

Mathematica graphics

Then I try to build the full ElementMesh:

mesh = ToElementMesh[bmesh,
  "RegionMarker" -> {{{2.5}, 1, 0.1}, {{7.5}, 2, 0.2}}
  ]

and this doesn't works:

Mathematica graphics

If I don't add markers in the first step:

bmesh = ToBoundaryMesh[
  "Coordinates" -> {{0}, {5}, {10}},
  "BoundaryElements" -> {PointElement[List /@ Range@3]}
  ]
mesh = ToElementMesh[bmesh,
  "RegionMarker" -> {{{2.5}, 1}, {{7.5}, 2}}
  ]

the full ElementMesh is built:

Mathematica graphics

but the region markers are not assigned:

Show[
 bmesh["Wireframe"],
 mesh["Wireframe"["MeshElementMarkerStyle" -> Blue]],
 mesh["Wireframe"["MeshElement" -> "BoundaryElements", 
   "MeshElementMarkerStyle" -> Red]]
 ]

Mathematica graphics

I also tried using "BoundaryMarkerFunction" option but I was unsuccessfull.

$\endgroup$
  • $\begingroup$ Don't forget to report it to WR (@user21 are from WR?) $\endgroup$ – P. Fonseca Jan 16 '15 at 12:24
  • 1
    $\begingroup$ OK, this is fixed in current sources and once a new version of Mathematica becomes available, then this will work as you'd expect. Sorry for the trouble. $\endgroup$ – user21 Jan 22 '15 at 18:20
5
$\begingroup$

That's an bug in the 1D case. A somewhat cumbersome way to work around that is to generate the mesh and then generate the mesh a second time where markers are computed and inserted into the mesh elements:

Needs["NDSolve`FEM`"]
bmesh = ToBoundaryMesh["Coordinates" -> {{0}, {5}, {10}}, 
   "BoundaryElements" -> {PointElement[List /@ Range@3]}];
mesh = ToElementMesh[bmesh];

mkMarker[c_, inci_] := Module[{pt1 = #[[1, 1]], pt2 = #[[2, 1]]},
    Which[
     pt2 <= 5, 1,
     pt1 >= 5, 2,
     True, 4 ]] & /@ (c[[#]] & /@ inci)

mkLineEle[c_, le_LineElement] := 
 LineElement[ElementIncidents[le], mkMarker[c, ElementIncidents[le]]]

coords = mesh["Coordinates"];
m2 = ToElementMesh["Coordinates" -> coords, 
   "MeshElements" -> (mkLineEle[coords, #] & /@ mesh["MeshElements"]),
   "BoundaryElements" -> {PointElement[
      Flatten[Position[coords, #]] & /@ bmesh["Coordinates"], {7, 5, 8}]}
   ];

Show[
 m2["Wireframe"["MeshElementMarkerStyle" -> Blue]], 
 m2["Wireframe"["MeshElement" -> "BoundaryElements", 
   "MeshElementMarkerStyle" -> Red]]]

enter image description here

Hope this helps.

$\endgroup$
  • $\begingroup$ Thanks for confirming the bug. Hope this will be solved soon, because refering to markers for i.e. physical properties of the medium is very useful provided it is simple to assign markers. $\endgroup$ – unlikely Jan 16 '15 at 10:46
2
$\begingroup$

This has been fixed in 10.1 (windows)

Mathematica graphics


Mathematica graphics

code

Needs["NDSolve`FEM`"]
bmesh = ToBoundaryMesh["Coordinates" -> {{0}, {5}, {10}}, 
"BoundaryElements" -> {PointElement[List /@ #, #] &@Range@3}]
bmesh["Wireframe"["MeshElementMarkerStyle" -> Blue]]

mesh = ToElementMesh[bmesh, 
  "RegionMarker" -> {{{2.5}, 1, 0.1}, {{7.5}, 2, 0.2}}]
Show[bmesh["Wireframe"], 
mesh["Wireframe"["MeshElementMarkerStyle" -> Blue]], 
mesh["Wireframe"["MeshElement" -> "BoundaryElements", "MeshElementMarkerStyle" -> Red]]]
$\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.