12
$\begingroup$

Bug introduced in 10.2 or earlier, and fixed in 11.0.0


I am trying to change the element mesh for a FEA application I'm doing. I thought I understood it, when I did it in 2D. Here's my shape:

Needs["NDSolve`FEM`"];
myrect = Rectangle[{0, 0}, {5, 8}];
mydisk = Disk[{2, 4}, 1];
rectcirc = RegionDifference[myrect, mydisk];
rmesh = NDSolve`FEM`ToElementMesh[rectcirc, 
  MaxCellMeasure -> {"Length" -> .5}]
rmesh["Wireframe"]

enter image description here

If I set the MaxBoundaryCellMeasure to 0.1, it figures out that the boundary is around the inner edge of the rectangle, and outside of the circle, and the mesh is adjusted accordingly:

rmesh2 = NDSolve`FEM`ToElementMesh[rectcirc, 
  MaxCellMeasure -> {"Length" -> .5}, "MaxBoundaryCellMeasure" -> .1]
rmesh2["Wireframe"]

enter image description here

Now I am trying to do a very similar thing for a 3 dimensional setup:

mycub = Cuboid[{0, 0, 0}, {10, 10, 10}];
mysmallcube = Cuboid[{4, 4, 4}, {6, 6, 6}];
Graphics3D[{Opacity[.1], mycub, Opacity[.4], mysmallcube}]
myreg = RegionDifference[mycub, mysmallcube];
mcm = 1;
cubmesh = NDSolve`FEM`ToElementMesh[myreg, MaxCellMeasure -> mcm]
cubmesh2 = 
 NDSolve`FEM`ToElementMesh[myreg, "MaxBoundaryCellMeasure" -> .2, 
  MaxCellMeasure -> mcm]
Print@"only MCM:";
cubmesh["Wireframe"]
cubmesh["Wireframe"[PlotRange -> {All, {4, 6}, All}]]
cubmesh["Wireframe"["MeshElement" -> "MeshElements", 
  PlotRange -> {All, {4, 6}, All}]]
Print@"MCM and MBCM:";
cubmesh2["Wireframe"[PlotRange -> {All, {4, 6}, All}]]
cubmesh2["Wireframe"["MeshElement" -> "MeshElements", 
  PlotRange -> {All, {4, 6}, All}]]

Now, it seems like it should behave similarly to the 2D case. It seems like because cubmesh2 has a smaller MaxBoundaryCellMeasure, it should have a finer mesh along its boundaries (inner surface of big cuboid, outer surface of small one), but I'm not seeing that in the output. Both cubmesh and cubmesh2 look exactly the same, but you can tell that this isn't right for cubmesh2, because with its MaxBoundaryCellMeasure of 0.2 and cuboid wall size of 10, there should theoretically be $10/0.2=50$ cells, and there are obviously far fewer than that (I've taken a slice of the graphic and tilted it, to see it easier):

enter image description here

I've read this page but I feel like I'm missing something. I suspect it has something to do with using a BoundaryMesh instead, but I don't really know why. Why isn't this working?

$\endgroup$
  • 6
    $\begingroup$ This is a bug. I'll work on a fix and have that in one of the next releases. $\endgroup$ – user21 Jun 4 '16 at 1:35
  • $\begingroup$ @user21, whoa, are you a dev for the Mathematica FEM stuff? That would explain why you know so much about it. $\endgroup$ – YungHummmma Jun 4 '16 at 19:35
  • 2
    $\begingroup$ Yes I am one of the developers for the FEM stuff. $\endgroup$ – user21 Jun 4 '16 at 22:17
  • $\begingroup$ @user21 ah, cool. Well thank you for all the help recently, it's very appreciated. $\endgroup$ – YungHummmma Jun 4 '16 at 23:53
  • 1
    $\begingroup$ @user21 can you elaborate in what the bug is? I can make 3d regions with holes using implicit region but the resolution of the geometry is crap, worst than the 3d example in the documentation. $\endgroup$ – tsuresuregusa Jun 9 '16 at 20:26
7
$\begingroup$

This is fixed in V11.0:

mycub = Cuboid[{0, 0, 0}, {10, 10, 10}];
mysmallcube = Cuboid[{4, 4, 4}, {6, 6, 6}];
myreg = RegionDifference[mycub, mysmallcube];
mcm = 1;
cubmesh2 = 
  NDSolve`FEM`ToElementMesh[myreg, "MaxBoundaryCellMeasure" -> .2, 
   MaxCellMeasure -> mcm];
cubmesh2["Wireframe"[PlotRange -> {All, {4, 6}, All}]]
cubmesh2["Wireframe"["MeshElement" -> "MeshElements", 
  PlotRange -> {All, {4, 6}, All}]]

enter image description here enter image description here

$\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.