Welcome to the forums. Please post in English or French.

You are not logged in.

#1 2019-04-15 15:30:03

sb1966
Member
Registered: 2015-03-16
Posts: 70

[SOLVED] Regarding "point_tags" in meshio

Dear All,

It might be a trivial question, but I could not figure it out myself and hence asking for help.

My questions are:
a) Are the  "point_tags" and "cells" from meshio.read are arbitrary?
b) Do they correspond to actual node ids or element ids some-how?

Let me explain with example:


1. I have a four noded mesh with two TRIA3 elements. The mesh in aster format is very simple and hand written as follows:

--------------------------------------------------------------------------------
 ASTER 13.06.00 CONCEPT reslin CALCULE LE 14/04/2019 A 02:05:49 DE TYPE EVOL_ELAS
 TITRE
MED FILE GENERATED BY HAND                                                     
 FINSF
 %
 COOR_3D
 N1        0.00000000000000E+00  0.00000000000000E+00  0.00000000000000E+00
 N2        1.00000000000000E+00  0.00000000000000E+00  0.00000000000000E+00
 N3        1.00000000000000E+00  1.00000000000000E+00  0.00000000000000E+00
 N4        0.00000000000000E+00  1.00000000000000E+00  0.00000000000000E+00
 FINSF
 %
 SEG2    
 M1       N1       N2      
 M2       N2       N3      
 M3       N3       N4      
 M4       N4       N1      
 FINSF
 %
 TRIA3   
 M5       N1       N2       N3      
 M6       N3       N4       N1      
 FINSF
 %
 GROUP_NO
 LEFT_SUPPORT            
 N1       N4      
 FINSF
 %
 ....
FIN

The mesh file is attached here inside the archive as testMail.dat

2. After a linear elastic static analysis, the SIEQ_NOEU fields are obtained as:

 
 ------>
 CHAMP AUX NOEUDS DE NOM SYMBOLIQUE  SIEQ_NOEU                                   
 NUMERO D'ORDRE: 1 INST:   0.00000000000000E+00                                  
 NOEUD                 VMIS                  TRESCA                PRIN_1                PRIN_2                PRIN_3                VMIS_SG 
                       VECT_1_X              VECT_1_Y              VECT_1_Z              VECT_2_X              VECT_2_Y              VECT_2_Z
                       VECT_3_X              VECT_3_Y              VECT_3_Z              TRSIG                 TRIAX   
 N1        8.05911726275959E+03  8.63773584905660E+03 -8.17500000000000E+03 -1.69669811320755E+03  4.62735849056603E+02 -8.05911726275959E+03
           3.53553390593274E-01  8.53553390593274E-01  0.00000000000000E+00  5.00000000000000E-01  0.00000000000000E+00  5.00000000000000E-01
           3.53553390593274E-01 -3.53553390593274E-01  5.00000000000000E-01 -9.40896226415094E+03 -3.63095238095238E-01
 N2        8.63773584905660E+03  8.63773584905660E+03 -1.20311320754717E+04 -3.39339622641509E+03 -3.39339622641509E+03 -8.63773584905660E+03
           0.00000000000000E+00  1.00000000000000E+00  0.00000000000000E+00  1.00000000000000E+00  0.00000000000000E+00  0.00000000000000E+00
           0.00000000000000E+00  0.00000000000000E+00  1.00000000000000E+00 -1.88179245283019E+04 -7.26190476190476E-01
 N3        8.05911726275959E+03  8.63773584905660E+03 -8.17500000000000E+03 -1.69669811320755E+03  4.62735849056603E+02 -8.05911726275959E+03
           3.53553390593274E-01  8.53553390593274E-01  0.00000000000000E+00  5.00000000000000E-01  0.00000000000000E+00  5.00000000000000E-01
           3.53553390593274E-01 -3.53553390593274E-01  5.00000000000000E-01 -9.40896226415094E+03 -3.63095238095238E-01
 N4        7.48049867646257E+03  8.63773584905660E+03 -4.31886792452830E+03 -2.23442133908020E-13  4.31886792452830E+03 -7.48049867646257E+03
           7.07106781186547E-01  7.07106781186548E-01  0.00000000000000E+00  0.00000000000000E+00  0.00000000000000E+00  1.00000000000000E+00
           7.07106781186548E-01 -7.07106781186547E-01  0.00000000000000E+00 -1.23908819712629E-12 -5.52141530806892E-17
 

The result files is attached here as stress.resu and testRes.rmed inside the archive

3. Then the result in rmed format is also read by meshio (v-2.3.7)

4. The meshio output of various _NOEU and _ELGA fields correspond well to the aster results. However, the point_tags and cell_tags of meshio are not conforming to node ids or element ids (of course python counter starts from zero!). For example:

In [67]: node_id=node_data["point_tags"]

In [68]: print(node_id)
Out[68]:[1 2 0 3]

Similarly the following gives node-connectivity matrix of elements, but not ele_ids

In [71]: mymesh.cells
Out[71]: 
{'line': array([[0, 1],
        [1, 2],
        [2, 3],
        [3, 0]], dtype=int32), 'triangle': array([[0, 1, 2],
        [2, 3, 0]], dtype=int32)}

On the other hand the "points" attribute correctly gives the nodal coordinates of the nodes serially.

In [70]: mymesh.points
Out[70]: 
array([[0., 0., 0.],
       [1., 0., 0.],
       [1., 1., 0.],
       [0., 1., 0.]])

So, My questions are:

a) Are the  "point_tags" and "cells" from meshio.read are arbitrary?
b) Do they conform to actual node ids or element ids some-how?

I request the learned forum members, (in particular, the developer of meshio) to kindly comment and help me.

Thanks and warm Regards.

(Sukumar)

Last edited by sb1966 (2019-04-15 22:51:13)


Attachments:
Files_for_meshio.zip, Size: 5.38 KiB, Downloads: 5

Offline

#2 2019-04-15 19:54:58

tianyikillua
Member
From: Paris
Registered: 2017-11-06
Posts: 53

Re: [SOLVED] Regarding "point_tags" in meshio

Hello!

I introduced the notion of `point_tags` and `cell_tags` in meshio (yes very recently). Didn't expect to see people actually using this library here since I haven't yet advertised here...However I consider this library to be very useful since meshio is pure Python and can be installed with `pip3 install meshio`. You can also read a (R)MED file and then convert it to XDMF / VTU so that you can read the mesh/result file directly under ParaView, without opening salome(_meca) à l'Obélix.

The design of these tags I proposed can be found here: https hmm/ github.com/nschloe/meshio/pull/352

1. The cells correspond well to your mesh, knowing that in Python indices begin with 0. "line" is the SEG2 element, while "triangle" is your TRIA3 element.

{'line': array([[0, 1],
        [1, 2],
        [2, 3],
        [3, 0]], dtype=int32), 'triangle': array([[0, 1, 2],
        [2, 3, 0]], dtype=int32)}

2. `point_tags` should indicate the node set that each node belongs to. `point_tags=[1 2 0 3]` says you have 3 node sets defined in your mesh:

You can see the set names corresponding to 1, 2 and 3 in `mesh.point_tags`.

mesh.point_tags =                                                         
{1: ['LEFT_SUPPORT',
  'H_SUPPORT'],
 2: ['H_SUPPORT'],
 3: ['LEFT_SUPPORT']}

the first node (0, 0, 0) belongs to node set 1: so it belongs both to 'LEFT_SUPPORT' and 'H_SUPPORT'
the 2nd node (1, 0, 0) belongs to node set 2: it belongs to 'H_SUPPORT'
the 4th node (0, 1, 0) belongs to node set 3: 'LEFT_SUPPORT'

Please also contact me at tianyikillua (at) gmail.com if you need further information.

Tianyi Li

Last edited by tianyikillua (2019-04-15 20:19:41)

Offline

#3 2019-04-15 21:34:26

sb1966
Member
Registered: 2015-03-16
Posts: 70

Re: [SOLVED] Regarding "point_tags" in meshio

Dear Tianyi Li,

Thanks a lot for your quick reply. I will go through the GiT pull you have mentioned and contact you if needed.

I think, meshio is a very useful program, especially for those who like to use FLOSS.

Also thank you for your suggestions to convert to XDMF/VTU format etc. and use paraview directly.

However, in my case, I need to modify the mesh by selecting those nodes that fulfill some failure criteria. I had posted my target in an earlier post in this forum -
(https://///www.code-aster.org/forum2/viewtopic.php?id=24034). Unfortunately it did not attract any response. Possibly my question was not comprehensive enough. :-) And meshio can certainly be of great help, I believe.

BTW, my subsequent questions would be:
1) is there any way to get directly the node ids  and element ids of the original mesh through meshio?
2)

>>> mymesh.cell_tags
{-2: ['SURFACE  '], -1: ['TOP_LINE  ']}

The above shows that there are two element groups, the keys being -1 and -2.

On the other hand

>>> mymesh.cell_data
{'line': {'cell_tags': array([ 0,  0, -1,  0], dtype=int32)}, 'triangle': {u'reslin__SIEQ_ELGA': array([[  8.63773585e+03,   8.63773585e+03,  -1.20311321e+04,
....

Here the cell_tags do not include the key -2. Would you please explain the difference?

Thank you once again for your support.

Have great time..

(Sukumar)

Offline

#4 2019-04-15 21:52:14

tianyikillua
Member
From: Paris
Registered: 2017-11-06
Posts: 53

Re: [SOLVED] Regarding "point_tags" in meshio

In [7]: mesh.cell_data["triangle"]["cell_tags"]                                 
Out[7]: array([-2, -2], dtype=int32)

What do you mean by original node id / element id ?

For node id (N1, N2...), simply add 1.

mesh.points[3] correspond to N4

For element id, the ordering is preserved within each cell_type

So for your triangle elements, the first element  M5       N1       N2       N3 is represented by the first line of mesh.cells["triangle"][0]

If you want to retrieve M_ind from mesh.cells, you need to order cell types using the MED/aster rule: first 1d element ,then 2d , then 3d, then you can find M_ind.

Offline

#5 2019-04-15 22:44:52

sb1966
Member
Registered: 2015-03-16
Posts: 70

Re: [SOLVED] Regarding "point_tags" in meshio

Dear Tianyi Li,

Thanks a lot for your kind explanation. I am marking this post as "SOLVED"

Regards.

(Sukumar)

Last edited by sb1966 (2019-04-15 22:50:31)

Offline

Board footer