5
$\begingroup$

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]

enter image description here

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

Thanks!

$\endgroup$
3
  • $\begingroup$ does DiscretizeRegion@RegionProduct[Annulus[], Line[{{0},{1/10}}]] give what you need? $\endgroup$
    – kglr
    Commented Aug 23, 2019 at 18:03
  • $\begingroup$ @kglr Thanks, probably yes, but %["Wireframe"] didn't show the mesh. $\endgroup$ Commented Aug 23, 2019 at 18:14
  • $\begingroup$ @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. $\endgroup$ Commented Aug 23, 2019 at 18:25

2 Answers 2

7
$\begingroup$

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"]

ExtrdueMesh

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"]
$\endgroup$
5
  • $\begingroup$ Thanks, yes i want some control. Why Exp[x] is needed for data? $\endgroup$ Commented Aug 23, 2019 at 18:33
  • $\begingroup$ 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. $\endgroup$
    – Tim Laska
    Commented Aug 23, 2019 at 19:49
  • $\begingroup$ @UlrichNeumann I added a simple uniform mesh extrusion using Subdivide to the answer to complement the non-uniform mesh. $\endgroup$
    – Tim Laska
    Commented Aug 23, 2019 at 23:08
  • $\begingroup$ That'it, thank you very much. $\endgroup$ Commented Aug 24, 2019 at 6:06
  • $\begingroup$ You are welcome! $\endgroup$
    – Tim Laska
    Commented Aug 24, 2019 at 11:22
7
$\begingroup$

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"]

AnnulusMesh

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]]

PipeMesh

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

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

PipeMesh_Tet

$\endgroup$
9
  • $\begingroup$ Thank you very much. That's what I needed to solve Poisson PDE in a predefined simple mesh. $\endgroup$ Commented Aug 26, 2019 at 8:12
  • $\begingroup$ ...Unfortuantely it only works in v12 (my version is 11.0.1 ) $\endgroup$ Commented Aug 26, 2019 at 8:56
  • $\begingroup$ 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. $\endgroup$
    – Pinti
    Commented Aug 26, 2019 at 9:11
  • 1
    $\begingroup$ Now it works! Thank you for the very useful tool! $\endgroup$ Commented Sep 9, 2019 at 12:54
  • 1
    $\begingroup$ 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? $\endgroup$ Commented Sep 26, 2019 at 19:47

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.