5

I have the following mesh

Needs["NDSolve`FEM`"]

bmesh = ToBoundaryMesh[ "Coordinates" -> {{15, 10}, {5, 10}, {5, 0}, {0, 0}, {0, 1200}, {5, 1200}, {5, 1190}, {15, 1190}, {15, 10}, {1485, 10}, {1485, 1190}, {15, 1190}, {1485, 10}, {1495, 10}, {1495, 0}, {1500, 0}, {1500, 1200}, {1495, 1200}, {1495, 1190}, {1485, 1190}, {1496, 1170}, {1499, 1170}, {1499, 1180}, {1496, 1180}, {1, 20}, {4, 20}, {4, 30}, {1, 30}}, "BoundaryElements" -> {LineElement[{{1, 2}, {2, 3}, {3, 4}, {4, 5}, {5, 6}, {6, 7}, {7, 8}, {9, 10}, {10, 11}, {11, 12}, {12, 9}, {13, 14}, {14, 15}, {15, 16}, {16, 17}, {17, 18}, {18, 19}, {19, 20}, {21, 22}, {22, 23}, {23, 24}, {24, 21}, {25, 26}, {26, 27}, {27, 28}, {28, 25}}, {1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5}]}, "RegionHoles" -> {{1498, 1175}, {2, 25}},"MaxBoundaryCellMeasure" -> 200];

mesh = ToElementMesh[bmesh]; mesh["Wireframe"] (This works)

However, when I try to change the mesh cell size I cannot, Kernel quits itself: such as

   mesh = ToElementMesh[bmesh, MaxCellMeasure -> .02];
mesh["Wireframe"]

I want to set maximum cell measure on the boundaries: is there something I am missing?

so, it works, if I divide every length by 1000, why it is not working the way it is? However, at the boundaries, I still can not change the cell size?

=================================================================

With ToBoundaryMesh[region, "MaxBoundaryCellMeasure" -> 200]

and

mesh = ToElementMesh[bmesh, MaxCellMeasure -> 3000];
mesh["Wireframe"]

I get,

enter image description here

Why does it look uneven at the boundaries (I mean at the two standing sides where the cells are finer but in the middle, they seem less fine "marked regions"), "is there a way to check if it is fine or not"?

a019
  • 867
  • 4
  • 8
  • 6
    I might get a ban for this comment, but I cannot resist...size matters! – bmf Feb 03 '23 at 11:19
  • Not sure if you have already seen the tutorial on ElementMesh generation. This provides a good introduction to finite element mesh generation in the WL. – user21 Feb 03 '23 at 13:08
  • @user21 I am dealing with the linear boundary representation and I have been following the ElementMesh generation, so I am not sure if "MaxBoundaryCellMeasure" is still being ignore or not, because I am not able to find any example. – a019 Feb 03 '23 at 13:53
  • @MuhammadAli, I have tried to clarify that in my answer. – user21 Feb 03 '23 at 14:09

1 Answers1

4

With MaxCellMeasure -> 0.02 you are producing an extremely fine mesh. Here is a MaxCellMeasure -> 100

mesh = ToElementMesh[bmesh, MaxCellMeasure -> 100];
mesh["Wireframe"]

enter image description here

You'd probably want to do something like this:

ToBoundaryMesh[region, "MaxBoundaryCellMeasure" -> xzy]

but for this to work, you'd need a symbolic region description or a manual boundary mesh that resolves the boundary to the size you want. I guess a symbolic region is a bit easier.

Note that "MaxBoundaryCellMeasure" works for symbolic regions, like

bmesh = ToBoundaryMesh[Disk[], "MaxBoundaryCellMeasure" -> 0.025];
ToElementMesh[bmesh]["Wireframe"]

enter image description here

but not for manual boundary meshes like:

bmesh = ToBoundaryMesh[
   "Coordinates" -> {{0., 0.}, {1., 0.}, {1., 0.2}, {1., 1.}, {0., 
      1.}, {0., 0.22}, {0.3, 0.22}, {0.3, 0.2}, {0., 0.2}},
   "BoundaryElements" -> {LineElement[{{1, 2}, {2, 3}, {3, 4}, {4, 
        5}, {5, 6}, {6, 7}, {7, 8}, {8, 9}, {9, 1}, {3, 8}}]}
   , "MaxBoundaryCellMeasure" -> 0.001];
ToElementMesh[bmesh]["Wireframe"]

enter image description here

user21
  • 39,710
  • 8
  • 110
  • 167
  • Thanks! However, I am not able to change the cell sizes at boundaries, "MaxBoundaryCellMeasure" does nothing, I going through this example though, https://mathematica.stackexchange.com/questions/141386/making-good-meshes. – a019 Feb 03 '23 at 12:40
  • 1
    @MuhammadAli, please see the second part of my answer. Also, note that in your post you do not make use of "MaxBoundaryCellMeasure" . – user21 Feb 03 '23 at 12:41
  • Thanks! I just updated the output with the commands. – a019 Feb 03 '23 at 12:58