7
$\begingroup$

I have been trying to mesh a cylindrical geometry with a notch. To generate the geometry i use the following command.

<< NDSolve`FEM`
 reg1 = Disk[{0, 0}, 0.25];
 Region[reg1];
 reg2 = RegionProduct[reg1, Line[{{0}, {2}}]];
 Region[reg2];
 reg3 = Cuboid[{-0.25, -0.1, 0.9}, {-0.15, 0.1, 1.1}];
 Region[reg3];
 reg4 = RegionDifference[reg2, reg3];
 RegionPlot3D[reg4, PlotPoints -> 100]

enter image description here
I am trying to mesh this geometry using linear Tetrahederal elements using the script

ToElementMesh[reg4, MaxCellMeasure -> {"Volume" -> 0.001},"MeshOrder" -> 1]

I get the following error

ToElementMesh::femtemnbb: The bounds for BooleanRegion[#1&&!#2&, 
{Cylinder[{{0,0,0},{0,0,2}},0.25],Cuboid[{-0.25,-0.1,0.9},{-0.15,0.1,1.1}]}] 
are {{-\[Infinity],\[Infinity]},{-\[Infinity],\[Infinity]},{-\[Infinity],\ 
[Infinity]}}. Unless finite numeric bounds are specified, the mesh generation 
will constrain the region to have finite bounds.

I will grateful if i could get any help on this issue or if there is a another way to do it? Thanks

$\endgroup$
7
$\begingroup$

Here is an alternative with exact numbers:

r = RegionDifference[Cylinder[{{0, 0, 0}, {0, 0, 2}}, 1/4], 
   Cuboid[{-1/4, -1/10, 9/10}, {-15/100, 1/10, 11/10}]];
m = ToElementMesh[r, MaxCellMeasure -> {"Volume" -> 0.001}, 
  "MeshOrder" -> 1]

But since you want a fist order mesh you could also discretize the regions first and then construct the region difference. This would allow for a good intersection of the regions:

r = RegionDifference[
   DiscretizeRegion@Cylinder[{{0, 0, 0}, {0, 0, 2}}, 1/4], 
   DiscretizeRegion@
    Cuboid[{-1/4, -1/10, 9/10}, {-15/100, 1/10, 11/10}]];
m = ToElementMesh[r, MaxCellMeasure -> {"Volume" -> 0.001}, 
  "MeshOrder" -> 1]

m["Wireframe"[PlotRange -> {8/10, 12/10}]]

enter image description here

This will requite a few more elements but it might be worth it.

$\endgroup$
  • $\begingroup$ @user21Thanks, this is a good alternative, especially that fine mesh is required at the intersecting regions. $\endgroup$ – KVK318 Apr 3 '18 at 21:34
8
$\begingroup$

The issue can be addressed by specifying explicit numerical bounds:

<< NDSolve`FEM`
reg=RegionDifference[
  Cylinder[{{0, 0, 0}, {0, 0, 2}}, 1/4],
  Cuboid[{-0.25, -0.1, 0.9}, {-0.15, 0.1, 1.1}]];
RegionPlot3D[reg,PlotPoints->100]
ToElementMesh[reg, {{-1/4,1/4}, {-1/4, 1/4},{0,2}}]
$\endgroup$
  • $\begingroup$ @YoungThanks, this works. $\endgroup$ – KVK318 Apr 3 '18 at 17:17
  • $\begingroup$ +1 for referencing a message page! $\endgroup$ – user21 Apr 3 '18 at 17:21
  • $\begingroup$ @user21Thanks, i forgot to do that last time. $\endgroup$ – KVK318 Apr 3 '18 at 17:24
  • $\begingroup$ @KVK318, thanks! $\endgroup$ – user21 Apr 3 '18 at 17:25

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.