I'm trying to describe the intersection of two cylinders by an ImplicitRegion (in order to use it in NDSolve later).
ImplicitRegion[
-0.5 <= x <= 0.5 && -0.5 <= y <= 0.5 && -0.5 <= z <= 0.5 &&
(x^2 + z^2 <= 0.04 || y^2 + (0.3 + z)^2 <= 0.04),
{x, y,z}];
Region[%]
The result is missing the sharp edges. How can I improve the accuracy of the intersection?
Please note that I get a simliar result when doing this using RegionUnion
with Cylinder
.
cyl1 = Cylinder[{{-0.5, 0, 0}, {0.5, 0, 0}}, 0.2];
cyl2 = Cylinder[{{0, -0.5, -0.3}, {0, 0.5, -0.3}}, 0.2];
RegionUnion[cyl1, cyl2];
ToBoundaryMesh[%];
MeshRegion[%]
Using discretized regions works fine for two cylinders, but when I add a 3rd cylinder I receive the error message:
The boundary surface is not closed because the edges Line[{{2120, 2126}, {2018, 2032}, {1919, 2018}, {1622, 2120}}] only come from a single face
cyl1 = Cylinder[{{-0.5, 0, 0}, {0.5, 0, 0}}, 0.2];
cyl2 = Cylinder[{{0, -0.5, -0.3}, {0, 0.5, -0.3}}, 0.2];
cyl3 = Cylinder[{{0, -0.5, 0.3}, {0, 0.5, 0.3}}, 0.2];
BooleanRegion[#1 || #2 || #3 &,
{BoundaryDiscretizeRegion[cyl1],
BoundaryDiscretizeRegion[cyl2],
BoundaryDiscretizeRegion[cyl3]}]
EDIT: Here is another example:
If we just look at the surface mesh, we see, that the cylindrical faces are not connected, i.e. they do not form a connected region (even if I decrease the element size). So I cannot do an integral over that region.
ImplicitRegion[((x^2 + z^2 == 0.2^2)
|| ((y)^2 + (z + 0.3)^2 == 0.2^2)
|| ((y)^2 + (z - 0.3)^2 == 0.2^2))
&& ! (x^2 + z^2 < 0.2^2)
&& ! ((y)^2 + (z + 0.3)^2 < 0.2^2)
&& ! ((y)^2 + (z - 0.3)^2 < 0.2^2), {{x, -0.5, 0.5}, {y, -0.5,
0.5}, {z, -0.3, 0.3}}];
fluidSolidInterface =
ToBoundaryMesh[%, MaxCellMeasure -> {"Length" -> .1}]
%["Wireframe"]