In the DiscretizeRegion documentation:
The region reg can be anything that is
ConstantRegionQandRegionEmbeddingDimensionless than or equal to 3.
With DiscretizeRegion there could be an easy way to check volume calculations. First, I do it with a test region:
reg3D = ImplicitRegion[x - 2 < y < x - 1 && 0 < z < (x + y)/(x - y),
{{x, 0, 2}, {y, -2, 0}, {z, 0, 3}}];
{RegionEmbeddingDimension @ reg3D, ConstantRegionQ @ reg3D}
{3, True}
{Volume @ reg3D // N, Volume @ DiscretizeRegion[reg3D]}
{0.375, 0.373509}
Now my problem region:
reg3D = ImplicitRegion[x - 2 < y < x - 1 && 0 < z < Exp[(x + y)/(x - y)],
{{x, 0, 2}, {y, -2, 0}, {z, 0, 3}}];
{RegionEmbeddingDimension @ reg3D, ConstantRegionQ @ reg3D}
{3, True}
{vol = Volume @ reg3D, vol // N}
{(3 (-1 + E^2))/(4 E), 1.7628}
Volume @ DiscretizeRegion[reg3D];
DiscretizeRegion::drf: DiscretizeRegion was unable to discretize the region ImplicitRegion[<<2>>]. >>
Error; yet another method:
g = RegionPlot3D[reg3D, PlotPoints -> 100]
discreteReg = DiscretizeGraphics[g // Normal] // Quiet;
{RegionDimension @ discreteReg, RegionEmbeddingDimension @ discreteReg}
{2, 3}
I am now able to obtain the area:
Area @ discreteReg
12.5795
but not the volume, it fails once again.
<< NDSolve`FEM`
ToElementMesh @ discreteReg
MeshRegion::dgcell: The cell Polygon[{41,11121,408,403}] is degenerate. >> ToBoundaryMesh::femtemnm: A mesh could not be generated. >>
I didn't get much further! What can I do?
Answer
Based on a discussion with the developers, the new default "MarchingCells" method (in version 10.2 or later) should be able to handle this, but is running into exception handling problems related to the singularity at x == y.
This may be improved in a future version, for now some possible workarounds are below. It is not necessary to fill the interior to compute the volume, so for a crude approximation we may use the "Legacy" method to get a boundary representation
reg0 = ImplicitRegion[x - 2 < y < x - 1 && 0 < z < Exp[(x + y)/(x - y)],
{{x, 0, 2}, {y, -2, 0}, {z, 0, 3}}];
{bmr0 = BoundaryDiscretizeRegion[reg0, Method -> "Legacy"], Volume[bmr0]}

which is not a great estimate.
This is an improvement, suggested by user21, which does fill the interior with 300000 or so tetrahedra.
em = NDSolve`FEM`ToElementMesh[reg0,
"BoundaryMeshGenerator" -> {"RegionPlot", "SamplePoints" -> 35}];
NIntegrate[1, {x, y, z} ∈ em]
(* 1.74563 *)
The following avoids the singularity and uses a finer mesh for a better estimate
ϵ = $MachineEpsilon/2;
reg = ImplicitRegion[x - 2 < y < x - 1 && 0 < z < Exp[(x + y)/(x - y)],
{{x, ϵ, 2}, {y, -2, ϵ}, {z, 0, 3}}];
{bmr = BoundaryDiscretizeRegion[reg, MaxCellMeasure -> 0.001], Volume[bmr]}


Comments
Post a Comment