10
$\begingroup$

When I try to mesh the following region it fails. Why? Is there a workaround?

Needs["NDSolve`FEM`"];
Len = 1;  (*length *)
ht = 0.125; (* height *)
wd = 0.5; (* width *)
hwd = 0.25; (* hole width *)
reg = RegionDifference[Cuboid[{0, -wd/2, 0}, {Len, wd/2, ht}], 
  Cuboid[{Len/2 - hwd/2, -hwd/2, 0}, {Len/2 + hwd/2, hwd/2, ht}]];
Region[reg]

Mathematica graphics

mesh = ToElementMesh[reg];

DiscretizeGraphics::rnimpl: The function DiscretizeGraphics is not implemented for Tetrahedron[<<1>>].

Version 11.3 for Windows.

$\endgroup$
1

2 Answers 2

7
$\begingroup$

I don't know why on earth a Tetrahedron-wrapped list of 3D-simplices is returned by RegionDifference, but this helps to circumvent it:

R1 = BoundaryDiscretizeRegion[
   Cuboid[{0, -wd/2, 0}, {Len, wd/2, ht}], 
   MaxCellMeasure -> ∞
   ];
R2 = BoundaryDiscretizeRegion[
   Cuboid[{Len/2 - hwd/2, -hwd/2, 0}, {Len/2 + hwd/2, hwd/2, ht}], 
   MaxCellMeasure -> ∞
   ];
reg = RegionDifference[R1, R2];
mesh = ToElementMesh[reg]

ElementMesh[{{0., 1.}, {-0.25, 0.25}, {0., 0.125}}, {TetrahedronElement["<" 13557 ">"]}]

$\endgroup$
2
  • $\begingroup$ This does the job. Thanks. $\endgroup$
    – Hugh
    Commented Mar 14, 2019 at 17:34
  • $\begingroup$ Hugh, you're welcome. $\endgroup$ Commented Mar 14, 2019 at 18:15
6
$\begingroup$

May I suggest using MeshTools package? It offers more flexibility and alternative solutions for generating meshes on simple geometries.

Needs["NDSolve`FEM`"];
Len = 1;(*length*)
ht = 0.125;(*height*)
wd = 0.5;(*width*)
hwd = 0.25;(*hole width*)

region2D = RegionDifference[
   Rectangle[{0, 0}, {Len, wd}],
   Rectangle[{(Len - hwd)/2, (wd - hwd)/2}, {(Len + hwd)/2, (wd + hwd)/2}]
];

Needs["MeshTools`"];
mesh2D = SmoothenMesh@TriangleToQuadMesh@ToElementMesh[
    region2D,
    "MeshOrder" -> 1,
    MaxCellMeasure -> {"Length" -> 0.1}
]

mesh2D["Wireframe"]

mesh2D

mesh3D = ExtrudeMesh[mesh2D, ht, 5]

mesh3D["Wireframe"["MeshElementStyle" -> FaceForm@LightBlue]]

mesh3D

$\endgroup$
2
  • $\begingroup$ Package looks excellent. I will look further. Are the elements produced capable of being used in NDSolve for finite element analysis? I think NDSolve can only use cuboid or tetrahedral elements. Am I correct? $\endgroup$
    – Hugh
    Commented Mar 14, 2019 at 17:34
  • $\begingroup$ @Hugh Thank you! I am constantly improving the package to make it of production quality. Yes, of course, you can use this mesh with HexahedronElements in NDSolve and related functions. You can also create a "structured" mesh on you simple shape and get very high quality mesh with lower number of DOF. $\endgroup$
    – Pinti
    Commented Mar 15, 2019 at 7:45

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.