How to make a structured mesh with a hole and extrude it
Update: New version of FEMAddOns v1.4.2 includes ExtrudeMesh
@user21 updated FEMAddOns
and ExtrudeMesh
is included. Now, you only need to call FEMAddOns
and don't need to worry about namespace collisions with MeshTools
. For completeness, here is the updated workflow to get the latest version of FEMAddOns
and extend Alex's answer by two lines:
ResourceFunction["FEMAddOnsInstall"][]
Needs["FEMAddOns`"]
(* From Alex Trounev's Answer *)
Lx = 100;
Ly = 50; r[t_] :=
Piecewise[{{Lx/Cos[t], 0 <= t <= ArcTan[Ly/Lx]}, {Ly/Sin[t],
ArcTan[Ly/Lx] < t <= Pi - ArcTan[Ly/Lx]}, {-Lx/Cos[t],
Pi - ArcTan[Ly/Lx] < t <= Pi + ArcTan[Ly/Lx]}, {-Ly/Sin[t],
Pi + ArcTan[Ly/Lx] < t <= 2 Pi - ArcTan[Ly/Lx]}, {Lx/Cos[t],
2 Pi - ArcTan[Ly/Lx] < t <= 2 Pi}}]; pts1 =
Table[r[θ] {Cos[θ], Sin[θ]} // N, {θ, 0,
2 π, 2 Pi/360}]; pts2 =
Table[10. {Cos[θ], Sin[θ]} // N, {θ, 0, 2 π,
2 Pi/360}];
mesh2D = StructuredMesh[{pts1, pts2}, {96, 16}];
mesh2D["Wireframe"]
(* Extrude the mesh *)
mesh3D = ExtrudeMesh[mesh2D, 40, 6];
mesh3D["Wireframe"]
Original Answer
This is an extension of Alex Trounev's answer because I found a potential version problem with FEMAddOns
package. Perhaps someone can confirm.
If you download the latest version (v1.4.0) of FEMAddOns
, you will see that ExtrudeMesh
appears to be missing.
ResourceFunction["FEMAddOnsInstall"][]
Needs["FEMAddOns`"]
SystemOpen["paclet:FEMAddOns/guide/FEMAddOns"]
A potential workaround is to download MeshTools directly as shown in the following:
ClearAll["Global`*"]
ResourceFunction["GitHubInstall"]["c3m-labs", "MeshTools"]
Needs["MeshTools`"]
(* From Alex Trounev's Answer *)
Lx = 100;
Ly = 50; r[t_] :=
Piecewise[{{Lx/Cos[t], 0 <= t <= ArcTan[Ly/Lx]}, {Ly/Sin[t],
ArcTan[Ly/Lx] < t <= Pi - ArcTan[Ly/Lx]}, {-Lx/Cos[t],
Pi - ArcTan[Ly/Lx] < t <= Pi + ArcTan[Ly/Lx]}, {-Ly/Sin[t],
Pi + ArcTan[Ly/Lx] < t <= 2 Pi - ArcTan[Ly/Lx]}, {Lx/Cos[t],
2 Pi - ArcTan[Ly/Lx] < t <= 2 Pi}}]; pts1 =
Table[r[θ] {Cos[θ], Sin[θ]} // N, {θ, 0,
2 π, 2 Pi/360}]; pts2 =
Table[10. {Cos[θ], Sin[θ]} // N, {θ, 0, 2 π,
2 Pi/360}];
mesh2D = StructuredMesh[{pts1, pts2}, {96, 16}];
mesh2D["Wireframe"]
(* Extrude the mesh *)
mesh3D = ExtrudeMesh[mesh2D, 40, 6];
mesh3D["Wireframe"]
We can play with numbers to get an ideal mesh. As a stating point you could use this one:
Needs["MeshTools`"](*Needs["FEMAddOns`"]*)
Lx = 100;
Ly = 50; r[t_] :=
Piecewise[{{Lx/Cos[t], 0 <= t <= ArcTan[Ly/Lx]}, {Ly/Sin[t],
ArcTan[Ly/Lx] < t <= Pi - ArcTan[Ly/Lx]}, {-Lx/Cos[t],
Pi - ArcTan[Ly/Lx] < t <= Pi + ArcTan[Ly/Lx]}, {-Ly/Sin[t],
Pi + ArcTan[Ly/Lx] < t <= 2 Pi - ArcTan[Ly/Lx]}, {Lx/Cos[t],
2 Pi - ArcTan[Ly/Lx] < t <= 2 Pi}}]; pts1 =
Table[r[\[Theta]] {Cos[\[Theta]], Sin[\[Theta]]} // N, {\[Theta], 0,
2 \[Pi], 2 Pi/360}]; pts2 =
Table[10. {Cos[\[Theta]], Sin[\[Theta]]} // N, {\[Theta], 0, 2 \[Pi],
2 Pi/360}];
mesh = StructuredMesh[{pts1, pts2}, {96, 16}];
mesh["Wireframe"]
Thanks Tim Laska for explanation interface with MeshTools
. Since I have MeshTools
installed, I call directly
mesh3D = ExtrudeMesh[mesh, 42, 9];
mesh3D["Wireframe"["MeshElementStyle" -> EdgeForm[Gray]]]