5
$\begingroup$

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"?

$\endgroup$
4
  • 6
    $\begingroup$ I might get a ban for this comment, but I cannot resist...size matters! $\endgroup$
    – bmf
    Feb 3, 2023 at 11:19
  • $\begingroup$ 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. $\endgroup$
    – user21
    Feb 3, 2023 at 13:08
  • $\begingroup$ @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. $\endgroup$
    – a019
    Feb 3, 2023 at 13:53
  • $\begingroup$ @MuhammadAli, I have tried to clarify that in my answer. $\endgroup$
    – user21
    Feb 3, 2023 at 14:09

1 Answer 1

4
$\begingroup$

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

$\endgroup$
3
  • $\begingroup$ Thanks! However, I am not able to change the cell sizes at boundaries, "MaxBoundaryCellMeasure" does nothing, I going through this example though, mathematica.stackexchange.com/questions/141386/…. $\endgroup$
    – a019
    Feb 3, 2023 at 12:40
  • 1
    $\begingroup$ @MuhammadAli, please see the second part of my answer. Also, note that in your post you do not make use of "MaxBoundaryCellMeasure" . $\endgroup$
    – user21
    Feb 3, 2023 at 12:41
  • $\begingroup$ Thanks! I just updated the output with the commands. $\endgroup$
    – a019
    Feb 3, 2023 at 12:58

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.