6
$\begingroup$

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] 

enter image description here

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`)

$\endgroup$
4
  • $\begingroup$ Region[pie] shows this. I am on v12.2.0 Win7-x64. $\endgroup$
    – Syed
    Commented Mar 18, 2022 at 11:06
  • $\begingroup$ 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 $\endgroup$
    – cvgmt
    Commented Mar 18, 2022 at 11:22
  • $\begingroup$ (assuming \[Phi] has a value assigned before pie is defined) is Region@RegionConvert[pie, "Implicit"] any faster? $\endgroup$
    – kglr
    Commented Mar 18, 2022 at 11:29
  • $\begingroup$ @kglr Thanks! I started with ImplicitRegion[] with polar parameters r,\[CurlyPhi],z but wasn't able to plot it, because RegionPlot3D expects cartesian coordinates. $\endgroup$ Commented Mar 18, 2022 at 12:18

2 Answers 2

8
$\begingroup$

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

enter image description here

$\endgroup$
2
  • $\begingroup$ Thanks, that's what I was looking for. Unfortunately MeshRegion[RegionUnion[apie, bpie]] still doesn't evaluate. Any idea why? $\endgroup$ Commented Mar 18, 2022 at 12:20
  • $\begingroup$ 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. $\endgroup$
    – Syed
    Commented Mar 18, 2022 at 12:29
7
$\begingroup$

Here is an accurate workaround:

Needs["OpenCascadeLink`"]
face = OpenCascadeShape[
   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]];
bmesh = OpenCascadeShapeSurfaceMeshToBoundaryMesh[sweep];
Show[BoundaryMeshRegion[bmesh], bmesh["Wireframe"]]

enter image description here

To get a full element mesh:

Needs["NDSolve`FEM`"]
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]

enter image description here

Look at the accuracy of the corners.

$\endgroup$
7
  • $\begingroup$ Thanks for your interesting answer. Didn't know this package. Is there also a command to mesh the complete volume? $\endgroup$ Commented Mar 18, 2022 at 13:14
  • $\begingroup$ 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. $\endgroup$
    – user21
    Commented Mar 18, 2022 at 13:27
  • $\begingroup$ @UlrichNeumann, OpenCascadeLink, or check out the OpenCascade tag on this site. $\endgroup$
    – user21
    Commented Mar 18, 2022 at 13:29
  • $\begingroup$ 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? $\endgroup$ Commented Mar 18, 2022 at 13:59
  • $\begingroup$ 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 $\endgroup$
    – user21
    Commented Mar 18, 2022 at 14:02

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.