I am trying to compute the volume of intersection of the following two regions:
a = 0.857597;
b = 1.653926;
hexagon = Polygon[{{0, (b - a)/2, 1/2}, {(b - a)/2, 0, 1/2},
{1/2, 0, (b - 1)/(2 a)}, {1/2, (b - 1)/2, 0}, {(b - 1)/2, 1/2, 0},
{0, 1/2, (b - 1)/(2 a)}}];
octahedron = ImplicitRegion[Abs[x] + Abs[y] + a Abs[z] <= b/2, {x, y, z}];
region2 = ImplicitRegion[1 >= RegionDistance[hexagon, {x, y, z}], {x, y, z}];
NIntegrate
directly doesn't work:
NIntegrate[1, {x, y, z} ∈ RegionIntersection[octahedron, region2]]
It results in a crash after using up the memory (32GB).
I tried to use DiscretizeRegion
first:
octd = DiscretizeRegion[octahedron, {{-1, 1}, {-1, 1}, {-1, 1}}];
regd = DiscretizeRegion[region2, {{-1, 2}, {-1, 2}, {-1, 2}}]; (* This takes 40 minutes *)
RegionIntersection[octd, regd]
This returns an error: “BoundaryMeshRegion: The boundary surface is not closed because the edges <<2>> only come from a single face.”
I also tried to discretize the regions using NDSolve`FEM`ToElementMesh
.
Needs["NDSolve`FEM`"];
ToElementMesh[region2, {{-1, 2}, {-1, 2}, {-1, 2}}]
This crashes without using significant memory. Computing finite element mesh on the first region does not crash, but intersecting it with the second region results in a crash without significant memory usage.
octf = ToElementMesh[octahedron, {{-1, 1}, {-1, 1}, {-1, 1}}];
RegionIntersection[octf, regd]
I have reported the issues with ToElementMesh
to Wolfram Support.
Is there any workaround?
$Version (* 12.1.0 for Mac OS X x86 (64-bit) (March 18, 2020) *)
region2
, a blob around the hexagon where all points in the region are within distance 1 from the hexagon. You can visualize it here:RegionPlot3D[ 1 >= RegionDistance[hexagon, {x, y, z}], {x, -2, 2}, {y, -2, 2}, {z, -2, 2}]
$\endgroup$ – flinty Jun 15 '20 at 16:19