How to get the volume of a geometry and/or a mesh?

More
5 years 2 months ago #1892 by MA
Attached is a simple example of a geometry object (sphere) and a surface mesh.
Can you please let me know if it's possible to get the volume of a geometry object or a 3D closed surface mesh?
As you can imagine, I need to calculate the volume of more complicated shapes.
Thanks for your help.
MA

import netgen.csg as csg
geo = csg.CSGeometry()
sphere = csg.Sphere(csg.Pnt(0, 0, 0), 3)
geo.Add(sphere)
mesh = geo.GenerateMesh(maxh=1.5)
More
5 years 2 months ago #1894 by hvwahl
Hi MA,

for the volume of the entire mesh, I would do
Code:
vol = Integrate(CoefficientFunction(1),mesh )
and if you need the volume element wise, see mesh element volume .

Best wishes,
Henry
More
5 years 1 month ago #1897 by MA
Thank you for the prompt answer. I really appreciate it.
The "Integrate" method is only available on "ngsolve" and requires a volume mesh. However, is their a way to get the volume of a closed surface (in stl format for instance) without building a volume mesh and using "netgen"?
Thanks.
MA
Time to create page: 0.107 seconds