Message Boards Message Boards

0
|
6493 Views
|
9 Replies
|
0 Total Likes
View groups...
Share
Share this post:
GROUPS:

Calculation of included Volume

POSTED BY: Henrik Schachner
9 Replies

Dear Anton, dear Udo,

thank you very much for your suggestions! Those are exactly the kind of solutions I was hoping to find!

Regards -- Henrik

POSTED BY: Henrik Schachner

This discussion might of interest : "Find the volume of Phobos and Deimos".

Here is an application of the prescribed solution in the answer by Bob Werner in that discussion:

coords = MeshCoordinates[sphereMesh];
cells = MeshCells[sphereMesh, 2];
Total[Abs[cells /. Polygon[x__] :> Det[coords[[x]]]]]/6

 (*  Out[10]= 4.15297 *)
POSTED BY: Anton Antonov

I just found a working "solution" which I would qualify as really dirty:

boundarySphereMesh = ToExpression @ StringReplace[ToString@InputForm[sphereMesh], "MeshRegion" -> "BoundaryMeshRegion"]

But basically my question remains: How can this be achieved in a clean way? I do not believe that this dirty method is always working.

POSTED BY: Henrik Schachner

If you can make the 2D mesh into a BoundaryMeshRegion then you can call its Volume.

POSTED BY: Udo Krause

Dear Udo,

thank you for your quick response! But your answer was exactly my question. I do no know how to convert this MeshRegion into a BoundaryMeshRegion:

BoundaryMesh[sphereMesh]

does not work. Inspecting the FullForm of sphereMesh gives the impression that one just has to replace the head of sphereMesh like so:

BoundaryMeshRegion @@ sphereMesh

but this is working neither because (for a reason I cannot understand) sphereMesh is an Atom.

Regards -- Henrik

POSTED BY: Henrik Schachner

I think BoundaryDiscretizeGraphics is what you're looking for.

POSTED BY: Jesse Friedman

Dear Jesse,

you are right! I first hesitated the detour going from mesh to graphics and back to mesh, but maybe this is the only way:

sphereMesh = DiscretizeGraphics[Sphere[]]; (* ... as an example *)
spherePrim = MeshPrimitives[sphereMesh, 2];
sphereBoundary = BoundaryDiscretizeGraphics[spherePrim];
Through[{Head, Volume, RegionDimension, RegionEmbeddingDimension}[sphereBoundary]]
(* Out:  {BoundaryMeshRegion,4.152965792075726`,3,3} *)

Thank you four your suggestion! Regards -- Henrik

POSTED BY: Henrik Schachner

But your answer was exactly my question.

Not at all, because one creates a BoundaryMeshRegion from the given data just by

In[121]:= BoundaryMeshRegion[MeshCoordinates[#], MeshCells[#, 2]] &[DiscretizeGraphics[Sphere[]]]
In[122]:= Volume[%]
Out[122]= 4.15297

enter image description here

POSTED BY: Udo Krause

Dear Udo,

thank you very much for taking the time looking into this problem! Meanwhile - as you can see in the response to Jesse - a solution was found. I used Sphere[] just as an example. My actual problem deals with a much more complicated mesh structure for which there is no analytical expression (therefore something like ImplicitRegion[] is not possible).

Regards -- Henrik

POSTED BY: Henrik Schachner
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard

Group Abstract Group Abstract