Forum Message

 

 

We have moved the forum to https://forum.ngsolve.org . This is an archived version of the topics until 05/05/23. All the topics were moved to the new forum and conversations can be continued there. This forum is just kept as legacy to not invalidate old links. If you want to continue a conversation just look for the topic in the new forum.

Notice

The forum is in read only mode.

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

More
4 years 7 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
4 years 7 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
4 years 7 months 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.101 seconds