# How to create cylinder pie using ParametricRegion?

I'm wondering that this simple definition of a cylinder pie doesn't work

pie = ParametricRegion[ {r Cos[\[CurlyPhi]], r Sin[\[CurlyPhi]],z}, {{r, 5 , 10 }, { \[CurlyPhi], -\[Phi]/2, \[Phi]/2}, {z, 0 ,2 }}]


Evaluating Region needs around 28 seconds to complete (very slow )

Region[pie]


DiscretizeRegion fails after some time

DiscretizeRegion[pie] (*DiscretizeRegion::drf: DiscretizeRegion was unable to discretize the region ParametricRegion[<<2>>].*)


MeshRegion[pie] only shows the input.

What's wrong here? Is there a fast workaround? Thanks!

My goal is to combine several pies later (*Union)

• Region[pie] shows this. I am on v12.2.0 Win7-x64.
– Syed
Commented Mar 18, 2022 at 11:06
• pie = With[{\[Phi] = \[Pi]/2}, ParametricRegion[{r Cos[\[CurlyPhi]], r Sin[\[CurlyPhi]], z}, {{r, 5, 10}, {\[CurlyPhi], -\[Phi]/2, \[Phi]/2}, {z, 0, 2}}]]; pie // Region Commented Mar 18, 2022 at 11:22
• (assuming \[Phi] has a value assigned before pie is defined) is Region@RegionConvert[pie, "Implicit"] any faster?
– kglr
Commented Mar 18, 2022 at 11:29
• @kglr Thanks! I started with ImplicitRegion[] with polar parameters r,\[CurlyPhi],z but wasn't able to plot it, because RegionPlot3D expects cartesian coordinates. Commented Mar 18, 2022 at 12:18

A possible workaround:

apie = RegionProduct[Annulus[{0, 0}, {5, 10}, {0 Degree, 30 Degree}],
Line[{{0}, {2}}]];
bpie = RegionProduct[
Annulus[{0, 0}, {7, 12}, {15 Degree, 45 Degree}],
Line[{{0}, {1}}]];

Region[#, Boxed -> True] & /@ {apie, bpie, RegionUnion[apie, bpie]}


• Thanks, that's what I was looking for. Unfortunately MeshRegion[RegionUnion[apie, bpie]] still doesn't evaluate. Any idea why? Commented Mar 18, 2022 at 12:20
• MeshRegion[DiscretizeRegion[...] would work. You can also use mcells within DiscretizeRegion command. I tried: MeshRegion[ DiscretizeRegion[RegionUnion[apie, bpie], MaxCellMeasure -> {"Length" -> 0.1}, AccuracyGoal -> 2]] Anything more aggressive results in a memory allocation failure as I have 8GB only.
– Syed
Commented Mar 18, 2022 at 12:29

Here is an accurate workaround:

Needs["OpenCascadeLink"]
Polygon[{{0, 0, 0}, {1, 0, 0}, {1, 1, 0}, {0, 1, 0}}]];
sweep = OpenCascadeShapeRotationalSweep[face, {{2, 0, 0}, {2, 1, 0}},
N[30 Degree]];
Show[BoundaryMeshRegion[bmesh], bmesh["Wireframe"]]


To get a full element mesh:

Needs["NDSolveFEM"]
ToElementMesh[bmesh, "MaxCellMeasure" -> Infinity]


This returns a mesh with 139 elements. If you want a first order mesh use:

ToElementMesh[bmesh, "MaxCellMeasure" -> Infinity,"MeshOrder"->1]


Compare this with:

apie = RegionProduct[Annulus[{0, 0}, {5, 10}, {0 Degree, 30 Degree}],
Line[{{0}, {2}}]];
BoundaryDiscretizeRegion[apie]


Look at the accuracy of the corners.

• Thanks for your interesting answer. Didn't know this package. Is there also a command to mesh the complete volume? Commented Mar 18, 2022 at 13:14
• So, OpenCascadeLink ships with Mathematica. Search for it in the help system. What it returns in a boundary ElementMesh. This then can be meshed with ToElementMesh. Commented Mar 18, 2022 at 13:27
• @UlrichNeumann, OpenCascadeLink, or check out the OpenCascade tag on this site. Commented Mar 18, 2022 at 13:29
• Thank you, ToElementMesh[bmesh] works fine. But if I try ToElementMesh[bmesh[[1]]] to create a simple rough mesh , the result is wrong at the concave side of the volume. Any idea how to solve this? Commented Mar 18, 2022 at 13:59
• The result is not wrong, if you ask ToElementMesh to create a list from coordinates it computes a convex hull. To get a mesh use ToElementMesh[bmesh], perhaps with some max cell measure, or by specifying options to OpenCascadeShapeSurfaceMeshToBoundaryMesh Commented Mar 18, 2022 at 14:02