Atom topic feed | site map | contact | login | Protection des données personnelles | Powered by FluxBB | réalisation artaban
You are not logged in.
Dear All,
After some years far from CA, I noticed some changes and I need more time as expected to perform FEA's .... :-)
For a modelling I need to write in a text file :
- the nodes numbers
- the coordinates coord_X / Y / Z for each node ....
So I used POST_RELEVE_T and I had the result herebellow that's not convenient for me .... is there a way the have only :
- the nodes numbers in double format i.e. without the N letter
- the 3 coordinates
-
and no comment if possible ?
Thanks for any advice
Paul
#
#--------------------------------------------------------------------------------
#
#ASTER 10.03.00 CONCEPT POST_R CALCULE LE 16/06/2011 A 23:33:55 DE TYPE
#TABLE_SDASTER
INTITULE NOEUD RESU NOM_CHAM NUME_ORDRE INST ABSC_CURV COOR_X COOR_Y COOR_Z DX DY
depl_noeuds N1 resol_nl DEPL 1 1.00000E+00 0.00000E+00 1.00000E+02 0.00000E+00 0.00000E+00 -7.31371E+01 9.35853E+04
depl_noeuds N4 resol_nl DEPL 1 1.00000E+00 1.00000E+04 1.00000E+02 1.00000E+04 0.00000E+00 -7.31373E+01 9.47918E+04
depl_noeuds N7 resol_nl DEPL 1 1.00000E+00 2.00005E+04 0.00000E+00 0.00000E+00 0.00000E+00 4.14393E-02 2.42675E-19
depl_noeuds N12 resol_nl DEPL 1 1.00000E+00 3.00005E+04 0.00000E+00 1.00000E+04 0.00000E+00 1.20618E-04 1.88381E+05
depl_noeuds N10011 resol_nl DEPL 1 1.00000E+00 3.01005E+04 1.00000E+02 9.99900E+03 0.00000E+00 -2.54518E+02 9.47649E+04
depl_noeuds N10012 resol_nl DEPL 1 1.00000E+00 3.01015E+04 1.00000E+02 9.99800E+03 0.00000E+00 -3.91341E+02 9.47400E+04
depl_noeuds N10013 resol_nl DEPL 1 1.00000E+00 3.01025E+04 1.00000E+02 9.99700E+03 0.00000E+00 -4.84321E+02 9.47186E+04
depl_noeuds N10014 resol_nl DEPL 1 1.00000E+00 3.01035E+04 1.00000E+02 9.99600E+03 0.00000E+00 -5.41178E+02 9.47003E+04
depl_noeuds N10015 resol_nl DEPL 1 1.00000E+00 3.01045E+04 1.00000E+02 9.99500E+03 0.00000E+00 -5.68289E+02 9.46851E+04
depl_noeuds N10016 resol_nl DEPL 1 1.00000E+00 3.01055E+04 1.00000E+02 9.99400E+03 0.00000E+00 -5.71648E+02 9.46726E+04
Offline
Dear All,
After some years far from CA, I noticed some changes and I need more time as expected to perform FEA's .... :-)
For a modelling I need to write in a text file :
- the nodes numbers
- the coordinates coord_X / Y / Z for each node ....So I used POST_RELEVE_T and I had the result herebellow that's not convenient for me .... is there a way the have only :
- the nodes numbers in double format i.e. without the N letter
- the 3 coordinates
- and no comment if possible ?Thanks for any advice
Paul
#
#--------------------------------------------------------------------------------
#
#ASTER 10.03.00 CONCEPT POST_R CALCULE LE 16/06/2011 A 23:33:55 DE TYPE
#TABLE_SDASTER
INTITULE NOEUD RESU NOM_CHAM NUME_ORDRE INST ABSC_CURV COOR_X COOR_Y COOR_Z DX DY
depl_noeuds N1 resol_nl DEPL 1 1.00000E+00 0.00000E+00 1.00000E+02 0.00000E+00 0.00000E+00 -7.31371E+01 9.35853E+04
depl_noeuds N4 resol_nl DEPL 1 1.00000E+00 1.00000E+04 1.00000E+02 1.00000E+04 0.00000E+00 -7.31373E+01 9.47918E+04
depl_noeuds N7 resol_nl DEPL 1 1.00000E+00 2.00005E+04 0.00000E+00 0.00000E+00 0.00000E+00 4.14393E-02 2.42675E-19
depl_noeuds N12 resol_nl DEPL 1 1.00000E+00 3.00005E+04 0.00000E+00 1.00000E+04 0.00000E+00 1.20618E-04 1.88381E+05
depl_noeuds N10011 resol_nl DEPL 1 1.00000E+00 3.01005E+04 1.00000E+02 9.99900E+03 0.00000E+00 -2.54518E+02 9.47649E+04
depl_noeuds N10012 resol_nl DEPL 1 1.00000E+00 3.01015E+04 1.00000E+02 9.99800E+03 0.00000E+00 -3.91341E+02 9.47400E+04
depl_noeuds N10013 resol_nl DEPL 1 1.00000E+00 3.01025E+04 1.00000E+02 9.99700E+03 0.00000E+00 -4.84321E+02 9.47186E+04
depl_noeuds N10014 resol_nl DEPL 1 1.00000E+00 3.01035E+04 1.00000E+02 9.99600E+03 0.00000E+00 -5.41178E+02 9.47003E+04
depl_noeuds N10015 resol_nl DEPL 1 1.00000E+00 3.01045E+04 1.00000E+02 9.99500E+03 0.00000E+00 -5.68289E+02 9.46851E+04
depl_noeuds N10016 resol_nl DEPL 1 1.00000E+00 3.01055E+04 1.00000E+02 9.99400E+03 0.00000E+00 -5.71648E+02 9.46726E+04
Hi,
did you try with CREA_TABLE?
Otherwise you can create a simple script to do the job; I would use python, but you can use your preferred language - also a bash script, using sed and similars.
Bye
Andrea
Offline
Dear Paul,
I think it will be difficult to obtain what you want without using an external post-processing tool, in particular for the nodes labels.
Anyway, if you copy-paste the result in a text file, then import it in Excel, you can have the format you need in a few research and replace:
1 1,00E+02 0,00E+00 0,00E+00
4 1,00E+02 1,00E+04 0,00E+00
7 0,00E+00 0,00E+00 0,00E+00
12 0,00E+00 1,00E+04 0,00E+00
10011 1,00E+02 1,00E+04 0,00E+00
10012 1,00E+02 1,00E+04 0,00E+00
10013 1,00E+02 1,00E+04 0,00E+00
10014 1,00E+02 1,00E+04 0,00E+00
10015 1,00E+02 1,00E+04 0,00E+00
10016 1,00E+02 9,99E+03 0,00E+00
A "better" option should be to extract what you need from the results concept by adding some Python code lines in your commands file.
I hope these advices will help you.
Kind regards,
Nicolas
Nicolas MERLETTE
Ubuntu 12.04 / Salome-Meca 2014.1
Offline
I see Andrea was thinking also to Python ;-))
Nicolas MERLETTE
Ubuntu 12.04 / Salome-Meca 2014.1
Offline
thanks you two ...
I can imagine it's possible to do it using python ... but to be honest I've never used it !
It is possible to use an external to (I've ever done it) but it's rather slow that's why I'm thinking in extracting results directly from the root (i.e CA) !
Nota : the extraction will be integrated in a loop ... then using Excel soft or something similar in not both convenient and possible !
Have a good WE
Paul
Offline
Concerning the extraction with Python, you can have a look to doc:
www.code-aster.org/V2/doc/default/fr/man_u/u1/u1.03.02.pdf
it is something as toto = RESU.LIST_VARI_ACCES() if RESU is your result concept
then toto.NOEUD[1] to have access to the first node label
etc
Nicolas
Nicolas MERLETTE
Ubuntu 12.04 / Salome-Meca 2014.1
Offline
thanks for the documentn link ! ... I'll have a look on it !
Paul
Offline
Using python is a must with Aster !
from Utilitai import partition
import string
MAIL=LIRE_MAILLAGE();
mesh = partition.MAIL_PY()
mesh.FromAster('MAIL')
# mesh.cn = coordonnees des noeuds (c'est un vecteur numeric N*3)
# mesh.tm = type de mailles
# mesh.co = connectivité des mailles
# mesh.gma = groupes de mailles
# mesh.gno = groupe de noeud
file=open('\chemin\vers\mon\fichier\mon_fichier.txt','w')
for ii in range(mesh.cn.shape[0]):
nodenum=int(mesh.correspondance_mailles[ii].strip(string.letters)) # POI01 -> int(01)
x,y,z = mesh.cn[ii,:]
file.write("%d %g %g %g\n" % (nodenum,x,y,z) )
file.close()
If you want to alter the nodes positions based on a calculation result then you can do it without any file: transfer the Aster concept into python space, modify there, overwrite the Aster concept.
Last edited by Ect (2011-06-17 19:57:35)
Offline
thanks you two ...
I can imagine it's possible to do it using python ... but to be honest I've never used it !
It is possible to use an external to (I've ever done it) but it's rather slow that's why I'm thinking in extracting results directly from the root (i.e CA) !
Nota : the extraction will be integrated in a loop ... then using Excel soft or something similar in not both convenient and possible !
Have a good WE
Paul
Hi,
quick&untested:
#!/usr/bin/python
import re
fdin=open('file_name', 'r')
fdout=open('out_file', 'w')
for l in fdin.readline():
l2 = re.match("depl_noeuds", l) # string to trigger the extraction of values
if l2 is not None:
values = l.split()
node = values[1][1:]
x = values[7]
y = values[8]
z = values[9]
fdout.write(node + "\t" + x + "\t" + y + "\t" + z + "\n")
fdin.close()
fdout.close()
this reads 'file_name', parses it and write the resuts in 'out_file'; it's rather rough, and I haven't tested it so it may be buggy too: take it as a base.
Bye
andrea
Offline
Hi,
quick&untested:
#!/usr/bin/python import re fdin=open('file_name', 'r') fdout=open('out_file', 'w') for l in fdin.readline(): l2 = re.match("depl_noeuds", l) # string to trigger the extraction of values if l2 is not None: values = l.split() node = values[1][1:] x = values[7] y = values[8] z = values[9] fdout.write(node + "\t" + x + "\t" + y + "\t" + z + "\n") fdin.close() fdout.close()
this reads 'file_name', parses it and write the resuts in 'out_file'; it's rather rough, and I haven't tested it so it may be buggy too: take it as a base.
Bye
andrea
Here is an alternative with a bit of explaination :
http://www.caelinux.org/wiki/index.php/ … tankar/HT1
You just need to add the fifth step in a for loop as explained by apalazzi which will run over all the nodes.
and in each step just use file.write() to export the values in a file.
So the whole code will be (inside the .comm file)
VAR = <table_name>.EXTR_TABLE();
fdout=open('out_file.txt', 'w')
for index in range(number_of_nodes):
node = (VAR.values().['NOEUD'])[index];
x = (VAR.values().['COOR_X'])[index];
y = (VAR.values().['COOR_Y'])[index];
z = (VAR.values().['COOR_Z'])[index];
fdout.write(node + "\t" + x + "\t" + y + "\t" + z + "\n")
fdout.close()
Offline
I agree with dbpatankar. I do something similar for extracting my Stress Result into a python data structure that meets my needs. I use the following code which extracts the Von Mises Stress and the Node it is associated with. Take note of the val['NOEUD'][1:] in my example or the values[1][1:] used by dbpatankar. This is removing the N from the node number.
Stress=POST_RELEVE_T(ACTION=_F(OPERATION='EXTRACTION',
INTITULE='',
RESULTAT=S[num],
NOM_CHAM='EQUI_NOEU_SIGM',
PRECISION=outputPrecision,
INST=calcTime,
GROUP_NO=( postRelieveT ),
NOM_CMP=('VMIS',),),);
StressT = Stress.EXTR_TABLE();
PyStress = {}
for val in StressT:
PyStress[int(val['NOEUD'][1:])] = [ float(val['VMIS']) ]
Offline
All
based on examples provided before, I understood :
- that python instruction must be placed between DEBUT and FIN otherwise they're ignored
- i tried some instruction from Ect example (even if I've not understood yet (see attachment)
Nevertheless in the example the word strip (used to remove the letter) leads to failure !!! ... if I remove nodenum the coordinates are well recorded :-(((
Tomorrow is another day ....
Paul
Offline
It fails because I forgot the indexing in:
nodenum=int(mesh.correspondance_mailles.strip(string.letters))
mesh.correspondance_mailles is an array so extracting the ith node number should have been:
nodenum=int(mesh.correspondance_mailles[ii].strip(string.letters))
my bad !
Offline
Thanks ....
I printed the partition.py where I think find a lot of information to well understand how to proceed ...
in any way thanks for your help ...
I agree combining Python and CA will lead to a usefull and powerfull way to perform FEA's !!!!!
Subsidiary question : my code uses informations from the gmsh mesh ... will the extractions and so on informations remain identical ?
Thanks to everybody
Paul
Offline
Ect,
The code you gave me failed for the provided example ... In my case using correspondance_mailles instead of correspondance_noeuds leaded to an error for nodenum (the last node of the list is the cause of the failure) !
Based on partition.py file I performed the following changes and now it works ... in any way thanks for the advices !
Now I would like to add the mesh informations like GMSH model ie. on a single line :
No_elem type_elem No_GM NOD1 NOD2 etc ... + (X,Y,Z)NOD1 (X,Y,Z)NOD2 ...
Where :
No_elem = element number
type_elem = type of element (quad / tria / hexa etc. ..)
No_GM = Physical group number
NODi = node number ...
(X,Y,Z)NOD_i = coordinates of the nodes that composed the element
What's the class where I can find the information on the elements ?
DEBUT(PAR_LOT='NON',);
from Utilitai import partition
import string
import numpy as N
PRE_GMSH();
MY_MAIL=LIRE_MAILLAGE();
mesh = partition.MAIL_PY()
mesh.FromAster('MY_MAIL')
file = open('/home/paul/ETUDE_ASTER/maillage.txt','w')
#file.write('$MeshFormat\n')
#file.write('2.2 0 8\n')
#file.write('$EndMeshFormat\n')
file.write('$Nodes\n')
file.write('%d\n' % mesh.dime_maillage[0]) # Nbre de noeuds
for ii in range(mesh.dime_maillage[0]):
nodenum=int(mesh.correspondance_noeuds[ii].strip(string.letters)) # strip = supprimer
x,y,z = mesh.cn[ii,:] # cn = coordonnees neouds
file.write("%d %g %g %g\n" % (nodenum,x,y,z) )
file.write('$EndNodes\n')
file.write('$Elements\n')
file.write('%d\n' % mesh.dime_maillage[2]) # Nbre de mailles
for ii in range(mesh.dime_maillage[2]):
maillenum = int(mesh.correspondance_mailles[ii].strip(string.letters))
connec_[] = mesh.co[ii,:] # co = connectivite => comment gerer le nbre d'argument ???? (tria3 = 3 / tria6 = 6 / quad4 = 4 etc. ...)
file.write('%d\n' % maillenum)
#file.write('Groupe de mailles\n')
#file.write('%s\n' % mesh.gma)
#file.write('Groupe de noeuds\n')
#file.write('%s\n' % mesh.gno)
#file.write('Table connectivite\n')
#file.write('%s\n' % mesh.co)
file.write('EndElements\n')
file.close()
FIN();
Paul
#####################################################
Last edited by Paul CARRICO (2011-06-19 11:21:04)
Offline
Dear All
Can somebody help me on the 2 following items :
1) lines 28-29 -> how can I wrote an element per line ?
2) from line 105 (I tested several syntaxes) : what is the good one ?
Thanks in advances
Paul
Offline
Dear All
Can somebody help me on the 2 following items :
1) lines 28-29 -> how can I wrote an element per line ?
I guess you want something like this:
for key in Res:
write(Res[key][0] + "\n" + Res[key][1] + "\n")
2) from line 105 (I tested several syntaxes) : what is the good one ?
It' a bit late and I don't remember exaclty how to extract data from table, however it may be something like:
x1 = depl_['COOR_X'][8][ii]
Hope it helps.
Bye
Andrea
Last edited by apalazzi (2011-06-23 23:19:41)
Offline