]> SALOME platform Git repositories - tools/eficas.git/blob - CarmelCND/acquiertGroupes.py
Salome HOME
travail sur monPlusieurs
[tools/eficas.git] / CarmelCND / acquiertGroupes.py
1 #! /usr/bin/env python
2 # -*- coding:utf-8 -*-
3 # /*  This file is part of MED.
4 #  *
5 #  *  COPYRIGHT (C) 1999 - 2013  EDF R&D, CEA/DEN
6 #  *  MED is free software: you can redistribute it and/or modify
7 #  *  it under the terms of the GNU Lesser General Public License as published by
8 #  *  the Free Software Foundation, either version 3 of the License, or
9 #  *  (at your option) any later version.
10 #  *
11 #  *  MED is distributed in the hope that it will be useful,
12 #  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
13 #  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14 #  *  GNU Lesser General Public License for more details.
15 #  *
16 #  *  You should have received a copy of the GNU Lesser General Public License
17 #  *  along with MED.  If not, see <http://www.gnu.org/licenses/>.
18 #  */
19
20
21 import sys
22 sys.path.append('/home/A96028/Salome/V7_main/tools/install/Medfichier-307-hdf51810/lib/python2.7/site-packages')
23
24 from med.medfile import *
25 from med.medmesh import *
26 from med.medfamily import *
27 from med.medfilter import *
28
29
30 def getGroupes(filename,debug=0) :
31     listeGroupes=[]
32     maa=""
33     
34     dicoNumFam={}
35
36     try :
37         fid = MEDfileOpen(filename,MED_ACC_RDONLY)
38     except :
39         return ("Pb a la lecture du fichier", listeGroupes,maa)
40
41    
42     # /* Lecture des infos concernant le premier maillage */
43     maa, sdim, mdim, type, desc, dtunit, sort, nstep, rep, nomcoo,unicoo = MEDmeshInfo(fid, 1)
44     if debug :
45         print "Maillage de nom : |%s| de dimension : %ld , et de type %s\n"%(maa,mdim,type)
46         print "Maillage de nom : |%s| , de dimension : %ld , et de type %s\n"%(maa,mdim,type)
47         print "\t -Dimension de l'espace : %ld\n"%(sdim)
48         print "\t -Description du maillage : %s\n"%(desc)
49         print "\t -Noms des axes : |%s|\n"%(nomcoo)
50         print "\t -Unités des axes : |%s|\n"%(unicoo)
51         print "\t -Type de repère : %s\n"%(rep)
52         print "\t -Nombre d'étape de calcul : %ld\n"%(nstep)
53         print "\t -Unité des dates : |%s|\n"%(dtunit)
54    
55     # /* Lecture du nombre de familles */
56     nfam = MEDnFamily(fid,maa)
57     if debug :
58         print "Nombre de familles : %d \n"%(nfam)
59    
60     # /* Lecture de chaque famille */
61     for i in xrange(0,nfam):
62    
63         # /* Lecture du nombre de groupe */
64         ngro = MEDnFamilyGroup(fid,maa,i+1)
65         if debug :
66             print "Famille %d a %d groupes \n"%(i+1,ngro)
67    
68         gro  = MEDCHAR(MED_LNAME_SIZE*ngro+1)
69          
70         nomfam,numfam,gro = MEDfamilyInfo(fid,maa,i+1,gro)
71         if debug :
72             print "Famille de nom %s et de numero %d : \n"%(nomfam,numfam)
73             print "Attributs : \n"
74     
75         for j in xrange(0,ngro):
76         # print "gro = %s\n"%(gro[j*MED_LNAME_SIZE:j*MED_LNAME_SIZE+MED_LNAME_SIZE])
77             groupSplit=gro[j*MED_LNAME_SIZE:j*MED_LNAME_SIZE+MED_LNAME_SIZE]
78             groupeName="".join(groupSplit).split("\x00")[0]
79             if groupeName[0:7]=="CENTRE_" : dicoNumFam[groupeName]=numfam
80             if groupeName not in listeGroupes : listeGroupes.append(groupeName) 
81
82
83     # /* Lecture des Numeros de Familles */ 
84     
85     nnoe, chgt, trsf = MEDmeshnEntity(fid,maa,MED_NO_DT,MED_NO_IT, MED_NODE,MED_NONE,MED_COORDINATE,MED_NO_CMODE)
86     nufano = MEDINT(nnoe)
87     MEDmeshEntityFamilyNumberRd(fid,maa, MED_NO_DT, MED_NO_IT, MED_NODE,MED_NONE,nufano)
88     dicoNumNode={}
89     for groupe in dicoNumFam.keys():
90         famille=dicoNumFam[groupe]
91         i=0
92         while i < nufano.size():
93            if nufano[i]==famille :
94               dicoNumNode[groupe]=i
95               break
96            i=i+1
97    
98    
99     print dicoNumNode
100     dicoCoord={}
101 #    for groupe in dicoNumNode.keys() :
102 #    for groupe in (1,) :
103 #        flt=MEDINT(1)
104 #        flt[0]=2
105 #        print flt
106 #        coo1=MEDFLOAT(4)
107 #        filter=med_filter()
108 #        print "kk"
109 #        err=MEDfilterEntityCr( fid, nnoe, 1, sdim, MED_ALL_CONSTITUENT, MED_FULL_INTERLACE, MED_COMPACT_PFLMODE, MED_NO_PROFILE,1 , flt, filter)
110 #        print err
111 #        print "kk"
112 #        MEDmeshNodeCoordinateAdvancedRd(fid, maa, MED_NO_DT, MED_NO_IT, filter, coo1)
113 #        print "kk"
114 #        MEDfilterClose(filter)
115 #        print "kk"
116 #        print coo1
117     dicoCoord['CENTRE_saxBas']=(0,0,28.5e-3)
118     dicoCoord['CENTRE_saxHaut']=(0,0,31.5e-3)
119
120     MEDfileClose(fid)
121     return ("",listeGroupes,maa,dicoCoord)
122
123 if __name__ == "__main__":
124     filename="/home/A96028/Carmel/Pascale/Domaine_Bidouille.med"
125     print getGroupes(filename)