[Gmsh] Area/Volume of physical groups
Christophe Geuzaine
cgeuzaine at uliege.be
Wed Mar 6 19:01:39 CET 2019
> On 6 Mar 2019, at 17:46, Max Orok <morok at mevex.com> wrote:
>
> Hello Johannes,
>
> Volume case:
> I think you can use the Plugin "MeshVolume" for this, calling it through the plugin API interface.
>
> Here is a link to the implementation:
> https://gitlab.onelab.info/gmsh/gmsh/blob/master/Plugin/MeshVolume.cpp <https://gitlab.onelab.info/gmsh/gmsh/blob/master/Plugin/MeshVolume.cpp>
>
Indeed; I've just modified the implementation a little bit so that it returns a post-processing view with the result (the version in Gmsh 4.2.0 only outputs a message). It will work for 1D, 2D and 3D. With the latest development snapshot, you can then just do something like this (here in Python):
import gmsh
gmsh.initialize()
gmsh.option.setNumber("General.Terminal", 1)
s = gmsh.model.occ.addRectangle(0,0,0, 3,2)
gmsh.model.occ.synchronize()
p = gmsh.model.addPhysicalGroup(2, [s])
gmsh.model.mesh.generate(2)
gmsh.plugin.setNumber("MeshVolume", "Dimension", 2)
gmsh.plugin.setNumber("MeshVolume", "Physical", p)
gmsh.plugin.run("MeshVolume")
_, _, data = gmsh.view.getListData(0)
print(data)
gmsh.finalize()
> Surface case:
> Perhaps you could use the Integrate Plugin? I think you would have to first have to make a physical group of just the 2D boundary elements and then use the integrate plugin with a value of 1 (see discussion in link for more info)
> https://gitlab.onelab.info/gmsh/gmsh/merge_requests/197 <https://gitlab.onelab.info/gmsh/gmsh/merge_requests/197>
>
Plugin(Integrate) is indeed also a possibility, that will also work in 1D, 2D and 3D. It's a bit more complicated, tough, as you need to create a post-processing view first (e.g. with "NewView"), then set the value to 1 (e.g. with "ModifyComponents"), then hide the parts of the mesh that you don't want consider, and finally call "Integrate". But it's of course more general, as you can integrate any function.
Cheers,
Christophe
> I hope this helps!
> Max
>
>
> On Wed, Mar 6, 2019 at 11:23 AM Johannes <joey5938 at protonmail.com <mailto:joey5938 at protonmail.com>> wrote:
> Hello,
>
> is there a way to get the surface area or volume of a physical group via the Gmsh API?
>
> Kind Regards
> Johannes
> _______________________________________________
> gmsh mailing list
> gmsh at onelab.info <mailto:gmsh at onelab.info>
> http://onelab.info/mailman/listinfo/gmsh <http://onelab.info/mailman/listinfo/gmsh>
>
>
> --
> Max Orok
> Contractor
> www.mevex.com <http://www.mevex.com/>
>
>
> _______________________________________________
> gmsh mailing list
> gmsh at onelab.info
> http://onelab.info/mailman/listinfo/gmsh
—
Prof. Christophe Geuzaine
University of Liege, Electrical Engineering and Computer Science
http://www.montefiore.ulg.ac.be/~geuzaine
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://onelab.info/pipermail/gmsh/attachments/20190306/7e4e7dc9/attachment-0001.html>
More information about the gmsh
mailing list