Eng-Tips is the largest engineering community on the Internet

Intelligent Work Forums for Engineering Professionals

  • Congratulations waross on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

sort the nodes in coherence with the mesh

Status
Not open for further replies.

Etienne17

Mechanical
Dec 4, 2020
6
0
0
DE
Hello everyone,

With a script I try to get the coordinates of the nodes of a particular surface.

The problem is that they are sorted according to their index and it gives this as a result for example:

Python:
coord = [G,E,K,
         L,J,B,
         N,K,M
         H,I,A,
         F,C,O ]

The following image illustrates the first points:
test2_tmdzaz.jpg


I would like to be able to sort them as follows:

Python:
coord = [A,F,K
         B,G,L
         C,H,M
         D,I,N
         E,J,O ]

test1_royneb.jpg


Do you think it's possible?

Here is the code I used:
Python:
n1=mdb.models['Model'].rootAssembly.sets['SURFACE'] 
xyz_coor = []    
for i in range(0,len(n1.nodes)): 
    xyz_coor.append([n1.nodes[i].coordinates[0],n1.nodes[i].coordinates[1],n1.nodes[i].coordinates[2],n1.nodes[i].label])
 
Replies continue below

Recommended for you

You can't change the node numbers or their order in the repository with Python.

What is the intent of this? Why do you want to do this?
 
This can’t be done with scripting but you can create so called unsorted node set (here unsorted means that it won’t be arranged according to node label). To do this click Sets —> Create and check the box "Make unsorted set". In the menu that appears you can pick nodes and set sorting expression.
 
Hello guies,

Thanks for your very quick answers.

Mustaine3 said:
What is the intent of this? Why do you want to do this?

I need it for several reasons. First of all, I would like to compute with a python script the normal vectors at each node so that I can apply normal forces to each node. The idea is to get the coordinates of each node sorted on the surface and then compute the normal vectors.

Then I get the results in Matlab and to manipulate them correctly, the nodes must be sorted so that the results are consistent.


FEA way said:
This can’t be done with scripting but you can create so called unsorted node set (here unsorted means that it won’t be arranged according to node label). To do this click Sets —> Create and check the box "Make unsorted set". In the menu that appears you can pick nodes and set sorting expression.

Thanks for the tip, but I don't know in advance what the mesh size is, so I can't sort the nodes manually and record them with the macro recorder.

Can't we use a connectivity table or something like that?

Have a nice evening [cheers]

 
When you submit the analysis A/CAE writes the information in the input file in the work directory. Or you can just generate that file without running it. There you can find the connectivity of each element and the position of each node. You could also change those data and then run the file via command line.

 
Status
Not open for further replies.
Back
Top