How can I mesh a solid cylinder with triangular or tetrahedral elements
I just followed examples in TetGenLink documentation:
Needs["TetGenLink`"]
data3D =
N@Flatten[Table[{r Cos[phi], r Sin[phi], z}, {phi, 0, 2 Pi, .5},
{z, -4, 4, .5}, {r, .2, 1, .4}], 2];
in = TetGenCreate[];
TetGenSetPoints[in, data3D];
out = TetGenTetrahedralize[in, ""];
coords = TetGenGetPoints[out];
meshElements = TetGenGetElements[out];
TetrahedraWireframe[i_] :=
Line[ Flatten[
i[[All, #]] & /@ {{1, 2}, {2, 3}, {3, 1}, {1, 4}, {2, 4}, {3, 4}}, 1]]
Graphics3D[GraphicsComplex[coords, TetrahedraWireframe[meshElements]],
Boxed -> False]
You could put caps on your cylinder and control the mesh with PlotPoints
and MaxRecursion
:
Show[
ParametricPlot3D[{r Cos[phi], r Sin[phi], 4}, {phi, 0, 2 Pi}, {r, 0, 1},
Mesh -> All, PlotPoints -> {25, 4}, MaxRecursion -> 0],
ParametricPlot3D[{r Cos[phi], r Sin[phi], -4}, {phi, 0, 2 Pi}, {r, 0, 1},
Mesh -> All, PlotPoints -> {25, 4}, MaxRecursion -> 0],
ParametricPlot3D[{Cos[phi], Sin[phi], z}, {phi, 0, 2 Pi}, {z, -4, 4},
Mesh -> All, PlotPoints -> {25, 13}, MaxRecursion -> 0],
PlotRange -> All, Boxed -> False, Axes -> False
]