1
$\begingroup$

For an examplary given surface mesh (example from documentation DiscretizeRegion )

sf=DiscretizeRegion[ParametricRegion[{Cos[u]/2, 3 Cos[v]/2 + Sin[u]/2, Sin[v]}, {{u, 0, 2 \[Pi]}, {v, 0, 2 \[Pi]}}]]

enter image description here

I would like to mesh the enclosed volume.

I know BoundaryMeshRegion evaluates the surface of a given volume, but couldn't find a "InverseFunction" which meshes the volume enclosed by a closed surface mesh!

Thanks

$\endgroup$
6
  • $\begingroup$ Assuming sf is a watertight and self-intersection free mesh, this should work: BoundaryMeshRegion[MeshCoordinates[sf], MeshCells[sf, 2]]. $\endgroup$
    – Greg Hurst
    Oct 11, 2022 at 14:01
  • $\begingroup$ @GregHurst Thanks, but BoundaryMeshRegion create a surface mesh again, or am I wrong? $\endgroup$ Oct 11, 2022 at 14:11
  • $\begingroup$ @GregHurst Thanks again, now I got it! $\endgroup$ Oct 11, 2022 at 14:16
  • $\begingroup$ It seems that there are two singular bands in this surfaces make the boundary discretize work fail. $\endgroup$
    – cvgmt
    Oct 11, 2022 at 14:22
  • $\begingroup$ @cvgmt Thanks, I tried MeshRepair[] but didn't succeed $\endgroup$ Oct 11, 2022 at 14:24

1 Answer 1

2
$\begingroup$

There are issues when converting that parametric object to a mesh. FindMeshDefects finds multiple defect.

Therefore, I created a different parametric object, two interlocked tori. If I needed your specific object, then I believe, with more effort, that I could created the original object correctly.

The illustrations are low-order. I was successful generating objects with more than 100,000 tetrahedrons.

steps = 4
unit = (2*Pi)/steps
p = ({0, Cos[#1], Sin[#1]} & ) /@ (unit*Range[0, steps]); 
t1 = TranslationTransform[{0, -3, 0}]
p1 = t1[p]; 
p2 = (RotationTransform[#1, {0, 0, 1}, {0, 0, 0}][p1] & ) /@ 
    (unit*Range[0, steps]); 
Dimensions[p2]
Graphics3D[{Point[Flatten[p2, 1]]}, Boxed -> True, 
  Axes -> True, AxesLabel -> 
   (Style[#1, Bold, Red, Large] & ) /@ {"X", "Y", "Z"}]
faces = Rationalize[
    N[Flatten[Table[{Triangle[{p2[[i,j]], p2[[i,j + 1]], 
          p2[[i + 1,j + 1]]}], Triangle[{p2[[i,j]], 
          p2[[i + 1,j + 1]], p2[[i + 1,j]]}]}, {i, steps}, 
       {j, steps}], 2]]]; 
coordinates = Sort[Union[Flatten[(#1[[1]] & ) /@ faces, 1]]]; 
sf1 = BoundaryMeshRegion[coordinates, 
   {Triangle[Table[Flatten[(Position[coordinates, #1] & ) /@ 
        triangle[[1]]], {triangle, faces}]]}, Boxed -> True, 
   Axes -> True, AxesLabel -> 
    (Style[#1, Bold, Red, Large] & ) /@ {"X", "Y", "Z"}, 
   AxesOrigin -> {0, 0, 0}]
FindMeshDefects[sf1]
sf2 = (TranslationTransform[{0, 3, 0}] @* 
    RotationTransform[Pi/2, {0, 1, 0}, {0, 0, 0}])[sf1]
sf = RegionUnion[sf1, sf2]
Head[sf]
Get["NDSolve`FEM`"]
mesh = ToElementMesh[sf, "NodeReordering" -> True, 
   MeshOrder -> 2]
mesh["Wireframe"["MeshElement" -> "MeshElements"]]

Mathematica graphics

Mathematica graphics

Mathematica graphics

At steps = 30, object looks quite reasonable. Unfortunately, at steps = 36, Mathematica breaks.

Mathematica graphics

By the way, BoundaryMeshRegion is defined by its faces and is filled (defines its volume). MeshRegion is defined by its objects and is not filled (defines its area).

Of course, I may have missed something.

$\endgroup$

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.