# How to extrude a planar mesh to a volume slice?

Is there an easy way to extrude a planar 2D-mesh to a volume slice?

ring = RegionDifference[Disk[{0, 0}, 1], Disk[{0, 0}, 1/2]];
DiscretizeRegion[ring]


The thickness of the slice is assumed to be small and should have only some element layers.

Thanks!

• does DiscretizeRegion@RegionProduct[Annulus[], Line[{{0},{1/10}}]] give what you need? – kglr Aug 23 '19 at 18:03
• @kglr Thanks, probably yes, but %["Wireframe"] didn't show the mesh. – Ulrich Neumann Aug 23 '19 at 18:14
• @kglr Sorry, just one remark. The planar mesh contains ~209 points, the volumemesh ~16814 . That means the mesh has changed significantly, the restriction "keep the planar meshing in some (3-4) layers" is lost. – Ulrich Neumann Aug 23 '19 at 18:25

If you want some control over the extruded mesh, under Applications in RegionProduct, there is a nice example.

ring = RegionDifference[Disk[{0, 0}, 1], Disk[{0, 0}, 1/2]];
dr = DiscretizeRegion[ring];
pointsToMesh[data_] :=
MeshRegion[Transpose[{data}],
Line@Table[{i, i + 1}, {i, Length[data] - 1}]];
data = Table[Exp[x], {x, 0., 0.5, 0.1}];
r1 = pointsToMesh[data];
rp = RegionProduct[dr, r1];
MeshRegion[rp, PlotTheme -> "Lines"]


You can use Subdivide in place of data if you just want a uniform mesh like so

rUniform = pointsToMesh[Subdivide[0, 0.1, 5]]
rpUniform = RegionProduct[dr, rUniform];
MeshRegion[rpUniform, PlotTheme -> "Lines"]

• Thanks, yes i want some control. Why Exp[x] is needed for data? – Ulrich Neumann Aug 23 '19 at 18:33
• It really is just an example of non-uniform grid control. For example, in a Computational Fluid Dynamics problem, you may want to have a boundary layer mesh at the wall that grows exponentially into the fluid domain. – Tim Laska Aug 23 '19 at 19:49
• @UlrichNeumann I added a simple uniform mesh extrusion using Subdivide to the answer to complement the non-uniform mesh. – Tim Laska Aug 23 '19 at 23:08
• That'it, thank you very much. – Ulrich Neumann Aug 24 '19 at 6:06
• You are welcome! – Tim Laska Aug 24 '19 at 11:22

I am developing MeshTools package, which contains a convenient function ExtrudeMesh just for this purpose.

First we create a quadrilateral mesh on annulus region. It can be structured or unstructured.

Needs["MeshTools"]

mesh2D = AnnulusMesh[{0, 0}, {1/2, 1}, {64, 4}]
mesh2D["Wireframe"]


Then we extrude 2D mesh to 3D with ExtrudeMesh. Position and orientation of resulting mesh can be further adjusted with TransformMesh.

mesh = ExtrudeMesh[mesh2D, 1, 4]
mesh["Wireframe"["MeshElementStyle" -> FaceForm@LightBlue]]


Structured (!) hexahedral meshes can be also transformed to tetrahedral meshes with HexToTetrahedronMesh.

HexToTetrahedronMesh[mesh]["Wireframe"["MeshElementStyle" ->FaceForm@LightBlue]]


• Thank you very much. That's what I needed to solve Poisson PDE in a predefined simple mesh. – Ulrich Neumann Aug 26 '19 at 8:12
• ...Unfortuantely it only works in v12 (my version is 11.0.1 ) – Ulrich Neumann Aug 26 '19 at 8:56
• Hm, I have tested it with 11.1 and it works. What does it complain about (I don't have 11.0 installed)? If you can fix this yourself I am happy to accept your pull request on GitHub. In general I think I could make the package compatible with 11.0, but I would not like to go back even further. – Pinti Aug 26 '19 at 9:11
• Now it works! Thank you for the very useful tool! – Ulrich Neumann Sep 9 '19 at 12:54
• Again thanks for your great tool. When I take a predefined mesh, created with MeshTools, inside NDSolve` I observed, that the mesh of the solution doesn't change. Is this a property of MeshTool meshes? – Ulrich Neumann Sep 26 '19 at 19:47