<html><head><meta http-equiv="Content-Type" content="text/html; charset=utf-8"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; line-break: after-white-space;" class=""><br class=""><div><br class=""><blockquote type="cite" class=""><div class="">On 6 Mar 2019, at 17:46, Max Orok <<a href="mailto:morok@mevex.com" class="">morok@mevex.com</a>> wrote:</div><br class="Apple-interchange-newline"><div class=""><div dir="ltr" class=""><div dir="ltr" class=""><div dir="ltr" class=""><div class="">Hello Johannes, <br class=""></div><div class=""><br class=""></div><div class="">Volume case:</div><div class="">I think you can use the Plugin "MeshVolume" for this, calling it through the plugin API interface. <br class=""></div><div class=""><br class=""></div><div class="">Here is a link to the implementation: <br class=""></div><div class=""><a href="https://gitlab.onelab.info/gmsh/gmsh/blob/master/Plugin/MeshVolume.cpp" target="_blank" class="">https://gitlab.onelab.info/gmsh/gmsh/blob/master/Plugin/MeshVolume.cpp</a></div><div class=""><br class=""></div></div></div></div></div></blockquote><div><br class=""></div><div>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):</div><div><br class=""></div><div><div style="margin: 0px; font-stretch: normal; line-height: normal; font-family: Menlo;" class=""><span style="font-variant-ligatures: no-common-ligatures" class="">import gmsh</span></div><div style="margin: 0px; font-stretch: normal; line-height: normal; font-family: Menlo;" class=""><br class=""></div><div style="margin: 0px; font-stretch: normal; line-height: normal; font-family: Menlo;" class=""><span style="font-variant-ligatures: no-common-ligatures" class="">gmsh.initialize()</span></div><div style="margin: 0px; font-stretch: normal; line-height: normal; font-family: Menlo;" class=""><span style="font-variant-ligatures: no-common-ligatures" class=""><br class=""></span></div><div style="margin: 0px; font-stretch: normal; line-height: normal; font-family: Menlo;" class=""><span style="font-variant-ligatures: no-common-ligatures" class="">gmsh.option.setNumber("General.Terminal", 1)</span></div><div style="margin: 0px; font-stretch: normal; line-height: normal; font-family: Menlo; min-height: 14px;" class=""><span style="font-variant-ligatures: no-common-ligatures" class=""></span><br class=""></div><div style="margin: 0px; font-stretch: normal; line-height: normal; font-family: Menlo;" class=""><span style="font-variant-ligatures: no-common-ligatures" class="">s = gmsh.model.occ.addRectangle(0,0,0, 3,2)</span></div><div style="margin: 0px; font-stretch: normal; line-height: normal; font-family: Menlo;" class=""><span style="font-variant-ligatures: no-common-ligatures" class="">gmsh.model.occ.synchronize()</span></div><div style="margin: 0px; font-stretch: normal; line-height: normal; font-family: Menlo;" class=""><span style="font-variant-ligatures: no-common-ligatures" class="">p = gmsh.model.addPhysicalGroup(2, [s])</span></div><div style="margin: 0px; font-stretch: normal; line-height: normal; font-family: Menlo;" class=""><span style="font-variant-ligatures: no-common-ligatures" class="">gmsh.model.mesh.generate(2)</span></div><div style="margin: 0px; font-stretch: normal; line-height: normal; font-family: Menlo; min-height: 14px;" class=""><span style="font-variant-ligatures: no-common-ligatures" class=""></span><br class=""></div><div style="margin: 0px; font-stretch: normal; line-height: normal; font-family: Menlo;" class=""><span style="font-variant-ligatures: no-common-ligatures" class="">gmsh.plugin.setNumber("MeshVolume", "Dimension", 2)</span></div><div style="margin: 0px; font-stretch: normal; line-height: normal; font-family: Menlo;" class=""><span style="font-variant-ligatures: no-common-ligatures" class="">gmsh.plugin.setNumber("MeshVolume", "Physical", p)</span></div><div style="margin: 0px; font-stretch: normal; line-height: normal; font-family: Menlo;" class=""><span style="font-variant-ligatures: no-common-ligatures" class="">gmsh.plugin.run("MeshVolume")</span></div><div style="margin: 0px; font-stretch: normal; line-height: normal; font-family: Menlo; min-height: 14px;" class=""><span style="font-variant-ligatures: no-common-ligatures" class=""></span><br class=""></div><div style="margin: 0px; font-stretch: normal; line-height: normal; font-family: Menlo;" class=""><span style="font-variant-ligatures: no-common-ligatures" class="">_, _, data = gmsh.view.getListData(0)</span></div><div style="margin: 0px; font-stretch: normal; line-height: normal; font-family: Menlo;" class=""><span style="font-variant-ligatures: no-common-ligatures" class="">print(data)</span></div><div style="margin: 0px; font-stretch: normal; line-height: normal; font-family: Menlo; min-height: 14px;" class=""><span style="font-variant-ligatures: no-common-ligatures" class=""></span><br class=""></div><div style="margin: 0px; font-stretch: normal; line-height: normal; font-family: Menlo;" class=""><span style="font-variant-ligatures: no-common-ligatures" class="">gmsh.finalize()</span></div><div style="margin: 0px; font-stretch: normal; line-height: normal; font-family: Menlo;" class=""><span style="font-variant-ligatures: no-common-ligatures" class=""><br class=""></span></div></div><div><br class=""></div><blockquote type="cite" class=""><div class=""><div dir="ltr" class=""><div dir="ltr" class=""><div dir="ltr" class=""><div class="">Surface case: <br class=""></div><div class="">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)</div><div class=""><a href="https://gitlab.onelab.info/gmsh/gmsh/merge_requests/197" class="">https://gitlab.onelab.info/gmsh/gmsh/merge_requests/197</a></div><div class=""><br class=""></div></div></div></div></div></blockquote><div><br class=""></div><div>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.</div><div><br class=""></div><div>Cheers,</div><div><br class=""></div><div><div><div class="">Christophe</div></div></div><br class=""><blockquote type="cite" class=""><div class=""><div dir="ltr" class=""><div dir="ltr" class=""><div dir="ltr" class=""><div class="">I hope this helps!</div><div class="">Max <br class=""></div><div class=""><br class=""></div></div></div></div><br class=""><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Wed, Mar 6, 2019 at 11:23 AM Johannes <<a href="mailto:joey5938@protonmail.com" target="_blank" class="">joey5938@protonmail.com</a>> wrote:<br class=""></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div class="">Hello,<br class=""></div><div class=""><br class=""></div><div class="">is there a way to get the surface area or volume of a physical group via the Gmsh API?<br class=""></div><div class=""><br class=""></div><div class="">Kind Regards<br class=""></div><div class="">Johannes<br class=""></div>_______________________________________________<br class="">
gmsh mailing list<br class="">
<a href="mailto:gmsh@onelab.info" target="_blank" class="">gmsh@onelab.info</a><br class="">
<a href="http://onelab.info/mailman/listinfo/gmsh" rel="noreferrer" target="_blank" class="">http://onelab.info/mailman/listinfo/gmsh</a><br class="">
</blockquote></div><br clear="all" class=""><br class="">-- <br class=""><div dir="ltr" class="gmail-m_3587993506648668742gmail_signature"><div dir="ltr" class=""><div class=""><div dir="ltr" class=""><div class=""><div dir="ltr" class=""><div class="">Max Orok</div><div class="">Contractor<br class=""></div></div><div dir="ltr" class=""><a href="http://www.mevex.com/" target="_blank" class="">www.mevex.com</a><br class=""><br class=""><img src="https://docs.google.com/uc?export=download&id=1fHTIiW4OMUjQr1iOkspQ7wiEsxunoOs0&revid=0B6x5w-5zVaEjSkpwbm5oY29jbG1XMzJoYldXTmJpNGFtb3dVPQ" width="164" height="42" class=""><br class=""></div></div></div></div></div></div>
_______________________________________________<br class="">gmsh mailing list<br class=""><a href="mailto:gmsh@onelab.info" class="">gmsh@onelab.info</a><br class="">http://onelab.info/mailman/listinfo/gmsh<br class=""></div></blockquote></div><br class=""><div class="">
<div dir="auto" style="color: rgb(0, 0, 0); letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; word-wrap: break-word; -webkit-nbsp-mode: space; line-break: after-white-space;" class=""><div dir="auto" style="word-wrap: break-word; -webkit-nbsp-mode: space; line-break: after-white-space;" class=""><div style="color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px;">— </div><div style="color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px;">Prof. Christophe Geuzaine<br class="">University of Liege, Electrical Engineering and Computer Science <br class=""><a href="http://www.montefiore.ulg.ac.be/~geuzaine" class="">http://www.montefiore.ulg.ac.be/~geuzaine</a><br class=""></div><div style="color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px;"><br class=""></div></div></div><br class="Apple-interchange-newline">
</div>
<br class=""></body></html>