Personal tools
You are here: Home Forum Use Get polyhedron node order

Get polyhedron node order

Up to Use

Re: Get polyhedron node order

Posted by William Tougeron at August 15. 2019

(rewriting the precedent post with better layout - please delete it as well as this line).

Hi all,

I have some mesh with hexahedrons in it. They were created using faces, like this:

mesh.AddPolyhedralVolumeByFaces(face_list)

This is because I am importing a mesh in which cells are defined by faces.

Now, I would like to export the mesh to another format in which cells are defined by nodes. But, when I do: mesh.GetElemNodes(elem_id) it returns something like this:

[5, 5, 7, 3, 5, 2, 6, 5, 5, 6, 8, 7, 5, 7, 8, 4, 5, 4, 8, 6, 5, 3, 4, 2]

where nodes of all faces are (randomly?) mixed and repeated.

When I go to the GUI and go to Mesh > Mesh Information > Element Info, it shows something like this:

Volume: #740174
> &nbsp;&nbsp;&nbsp;&nbsp;Type: Polyhedron<br>     Quadratic: No
> &nbsp;&nbsp;&nbsp;&nbsp;Connectivity<br>         Face 1 / 6
> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Node 5 8: #5
> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Node 7 8: #7
> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Node 3 8: #3
> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Node 1 8: #1
> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Face 2 6
> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Node 2 8: #2
> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Node 6 8: #6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&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Node 4 8: #4
> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Node 8 8: #8
> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Node 6 8: #6
> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Node 2 8: #2
> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Face 6 6
> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Node 3 8: #3
> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Node 4 8: #4
> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Node 2 8: #2
> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Node 1 8: #1
> (...)<strong>

One can see "Node 5/8", "Node 7/8", etc. So, Salome knows the order of the 8 nodes in the element. But how to get it from within a script?

Enclosed is a test mesh in MED format with a single cell in it.

Thanks for help

All the best,

Attachments

Re: Get polyhedron node order

Posted by William Tougeron at August 15. 2019
ach... :) too bad there is no "edit" function on this forum... :) my html code was tested before posting but non-breaking spaces didn't work here... would be grateful if some administrator could fix it... thanks :)

Re: Get polyhedron node order

Posted by William Tougeron at August 15. 2019

Hi All,

Because of Python 2 (and other reasons) I am using an older version of Salome (7.7.1).

I made now the same test in Salome 9.3.0 and the issue is the same, but the worse thing is that node order ("Node 1/8", "Node 2/8", etc.) is not even more visible in the Mesh > Mesh Information > Element Info dialogue box...

Re: Get polyhedron node order

Posted by SMESH expert at August 15. 2019

Hello William

SELOME returns nodes exactly in the same order as you see them in the Mesh Information dialog but without breaking into faces. They are all nodes of all faces given at construction.

Mesh module can't recognize canonical elements  (like hexahedron) defined as polyhedra. If you know type of elements, probably you can pick up needed nodes of element from its polyhedral nodes.

Best regards

Edward

 

Re: Get polyhedron node order

Posted by William Tougeron at August 15. 2019

Hi,

Thanks for (ultra high) responsiveness.

Actually the output in the dialogue box and in the script differ. In my first post, from within the script the ID list begins with two "5", which is not possible... (a same face can't have two time the same node).

If you look at resting IDs you can see the order is different everywhere.

This is true also for the "one cell test mesh":

from the script: [5, 1, 2, 3, 5, 5, 6, 1, 5, 6, 7, 2, 5, 2, 7, 8, 5, 8, 7, 6, 5, 3, 8, 5]

from the GUI: [5, 6, 1, 4] [6, 7, 2, 1] [2, 7, 8, 3] [8, 7, 6, 5] [3, 8, 5, 4]

Re: Get polyhedron node order

Posted by SMESH expert at August 15. 2019

Actually, there is a bug :(  - GetElemNodes() works wrong for polyhedrons.

Another approach is to get nodes by specifying face index: mesh.GetElemFaceNodes( elem, faceIndex ). faceIndex counts from zero.

 

BR Edward

p, li { white-space: pre-wrap; }

 

Re: Get polyhedron node order

Posted by William Tougeron at August 15. 2019

Hi Edward, thanks

Unfortunately, using faces doesn't help as well... The ordering in the input mesh format is a bit random and there is no direct way to extract a correct node order for hexa in Salome...

Any idea how to reorder "random node cloud" into a hexa ordering ? (ordering rule for hexa are enclosed).

Have a nice afternoon,

Attachments

Re: Get polyhedron node order

Posted by SMESH expert at August 15. 2019

In Python you can do that as follows:

1) Find two faces having no common nodes. These are "top" and "bottom" nodes.

2) Set order of top nodes to correspond to that of bottom ones: 
- get direction from top gravity center (GC) to its 1st node (let's call such direction GCN)
- find 1st bottom node as one whose GCN has maximal dot product with GCN of 1st top node.

3) Orient faces normals according to the  ordering rule.

BR Edward

Re: Get polyhedron node order

Posted by Christophe Bourcier at August 20. 2019

Hi William,

Alternatively, you can use MEDCoupling to write your converter. Use getNodalConnectivity() and getNodalConnectivityIndex().

See this page to learn how to use these two arrays: https://docs.salome-platform.org/latest/dev/MEDCoupling/developer/MEDCouplingUMeshPage.html#MEDCouplingUMeshAdvBuild

Christophe

Re: Get polyhedron node order

Posted by Christophe Bourcier at August 20. 2019

You can also use unPolyze() to convert all polyhedra with 8 nodes to hexahedra.

See https://docs.salome-platform.org/latest/dev/MEDCoupling/developer/classMEDCoupling_1_1MEDCouplingUMesh.html#a6e7b373edb18486664a917946204fc8b

Christophe

Powered by Ploneboard
Document Actions