]> SALOME platform Git repositories - tools/eficas.git/blob - Aster/Cata/cataSTA7/Macro/macr_cabri_mail_ops.py
Salome HOME
Modif V6_4_°
[tools/eficas.git] / Aster / Cata / cataSTA7 / Macro / macr_cabri_mail_ops.py
1 #@ MODIF macr_cabri_mail_ops Macro  DATE 01/03/2005   AUTEUR MABBAS M.ABBAS 
2 # -*- coding: iso-8859-1 -*-
3 #            CONFIGURATION MANAGEMENT OF EDF VERSION
4 # ======================================================================
5 # COPYRIGHT (C) 1991 - 2003  EDF R&D                  WWW.CODE-ASTER.ORG
6 # THIS PROGRAM IS FREE SOFTWARE; YOU CAN REDISTRIBUTE IT AND/OR MODIFY  
7 # IT UNDER THE TERMS OF THE GNU GENERAL PUBLIC LICENSE AS PUBLISHED BY  
8 # THE FREE SOFTWARE FOUNDATION; EITHER VERSION 2 OF THE LICENSE, OR     
9 # (AT YOUR OPTION) ANY LATER VERSION.                                                  
10 #                                                                       
11 # THIS PROGRAM IS DISTRIBUTED IN THE HOPE THAT IT WILL BE USEFUL, BUT   
12 # WITHOUT ANY WARRANTY; WITHOUT EVEN THE IMPLIED WARRANTY OF            
13 # MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. SEE THE GNU      
14 # GENERAL PUBLIC LICENSE FOR MORE DETAILS.                              
15 #                                                                       
16 # YOU SHOULD HAVE RECEIVED A COPY OF THE GNU GENERAL PUBLIC LICENSE     
17 # ALONG WITH THIS PROGRAM; IF NOT, WRITE TO EDF R&D CODE_ASTER,         
18 #    1 AVENUE DU GENERAL DE GAULLE, 92141 CLAMART CEDEX, FRANCE.        
19 # ======================================================================
20
21 import os
22
23 def macr_cabri_mail_ops(self,EXEC_MAILLAGE,RAFF_MAILLAGE,VERI_MAIL,GEOM_BRID,
24                         IMPRESSION,**args):
25   """
26      Ecriture de la macro MACR_CABRI_MAIL
27   """
28   import types
29   from Accas import _F
30
31   ier=0
32
33   # On importe les definitions des commandes a utiliser dans la macro
34   # Le nom de la variable doit etre obligatoirement le nom de la commande
35   EXEC_LOGICIEL = self.get_cmd('EXEC_LOGICIEL')
36   LIRE_MAILLAGE = self.get_cmd('LIRE_MAILLAGE')
37   PRE_GIBI      = self.get_cmd('PRE_GIBI')
38   IMPR_RESU     = self.get_cmd('IMPR_RESU')
39
40   # La macro compte pour 1 dans la numerotation des commandes
41   self.set_icmd(1)
42
43   # Le concept sortant (de type mail) est nommé 'nomres' dans 
44   # le contexte de la macro
45   
46   self.DeclareOut('nomres',self.sd)
47   
48   # Chemin de Gibi
49   import aster
50   loc_gibi=aster.repout()
51   gibi2000=loc_gibi+'gibi'
52   
53   # Unité pour le fichier maillage produit (format GIBI)
54   unite_mgib = EXEC_MAILLAGE['UNITE_MGIB']
55   # Unité pour le fichier de commandes GIBI
56   unite_datg = EXEC_MAILLAGE['UNITE_DATG']
57   # Niveau gibi
58   niveau_gibi = EXEC_MAILLAGE['NIVE_GIBI']
59  
60   # Verif mail
61   ver_apla = VERI_MAIL['APLAT']
62   ver_veri = VERI_MAIL['VERIF']
63   
64   # Impression
65   if IMPRESSION['UNITE']!=None:
66    imp_unit = IMPRESSION['UNITE']
67    imp_unitF = 1
68   else:
69    imp_unitF = 0  
70   if IMPRESSION['FORMAT']!=None:
71    imp_form = IMPRESSION['FORMAT']
72    imp_formF = 1
73   else:
74    imp_formF = 0 
75 #  if IMPRESSION['FICHIER']!=None:
76 #   imp_fich = IMPRESSION['FICHIER']
77 #   imp_fichF = 1
78 #  else:
79 #   imp_fichF = 0 
80  
81   # Maillage  
82   nrad = RAFF_MAILLAGE['NB_RADIAL']
83   ncir = RAFF_MAILLAGE['NB_CIRCONF']
84   nver = RAFF_MAILLAGE['NB_VERTICAL']
85   nsect = RAFF_MAILLAGE['NB_ALESAGE']
86   temps = 5.
87     
88   maillage = {'nrad': nrad,
89               'ncir': ncir,
90               'nver': nver,
91               'nsect': nsect,
92               'temps' : temps,}
93
94   # Création du fichier datg
95   
96   if GEOM_BRID['NORME'] == 'OUI':
97     # Bride standard
98     type_bride = GEOM_BRID['TYPE']
99     ### Ecriture du fichier GIBI principal (dgib) - Bride STANDARD
100     write_file_dgib_STD(unite_mgib,unite_datg,maillage,type_bride) 
101   else:
102     # Bride quelconque
103     geo_bride_qqe = {'nbgouj': GEOM_BRID['GOUJ_N_GOUJON'],
104                 'dint':   GEOM_BRID['BRID_D_INT'],
105                 'dex1':   GEOM_BRID['TUBU_D_EXT'],
106                 'dex2':   GEOM_BRID['BRID_D_CONGE'],
107                 'dex3':   GEOM_BRID['BRID_D_EPAUL'],
108                 'dtrou':  GEOM_BRID['BRID_P_ALESAG'],
109                 'dext':   GEOM_BRID['BRID_D_EXT'],
110                 'dt':     GEOM_BRID['BRID_D_ALESAG'],
111                 'drd':    GEOM_BRID['GOUJ_D_RONDEL'],
112                 'dg':     GEOM_BRID['GOUJ_D_GOUJON'],
113                 'dec':    GEOM_BRID['GOUJ_D_ECROU'],
114                 'rcong':  GEOM_BRID['BRID_R_CONGE'],
115                 'he':     GEOM_BRID['GOUJ_E_ECROU'],
116                 'e':      GEOM_BRID['GOUJ_E_RONDEL'],
117                 'hc1':    GEOM_BRID['BRID_H'],
118                 'hcg1':   GEOM_BRID['TUBU_H'],
119                 'hb':     GEOM_BRID['BRID_H_EPAUL'],
120                 'htrou':  GEOM_BRID['BRID_H_ALESAG'],
121                 'pf':     GEOM_BRID['GOUJ_E_FILET'],
122                 'j':      GEOM_BRID['ETAN_E_JOINT']}  
123     ### Ecriture du fichier GIBI principal (dgib) - Bride QUELCONQUE
124     write_file_dgib_QQE(unite_mgib,unite_datg,maillage,geo_bride_qqe)  
125
126   fichier_datg = 'fort.'+str(unite_datg)
127   fichier_mgib = 'fort.'+str(unite_mgib)
128   
129   # Lancement de GIBI
130   EXEC_LOGICIEL(
131                LOGICIEL=gibi2000,
132                ARGUMENT=(_F(NOM_PARA=fichier_datg),
133                          _F(NOM_PARA=fichier_mgib),
134                          )
135                )
136   # Lecture du maillage GIBI dans ASTER
137   PRE_GIBI(
138           UNITE_GIBI = unite_mgib,
139           )
140   
141   nomres = LIRE_MAILLAGE(VERI_MAIL=_F(APLAT = ver_apla,
142                                       VERIF = ver_veri ),)
143                                       
144 #  if (imp_fichF == 1):  
145 #   print imp_fich
146   if (imp_formF == 1):  
147    print imp_form
148   if (imp_unitF == 1):  
149    print imp_unit    
150   # Impression du fichier maillage
151   if (imp_formF == 1):
152     if (imp_form == 'CASTEM'):
153       imp_ngib = IMPRESSION['NIVE_GIBI']
154       IMPR_RESU( RESU = _F(MAILLAGE=nomres, ),
155                  FORMAT = 'CASTEM', NIVE_GIBI = imp_ngib )
156     if (imp_form == 'IDEAS'):
157       imp_nver = IMPRESSION['VERSION']
158       IMPR_RESU(RESU = _F(MAILLAGE=nomres,),
159                 FORMAT = 'IDEAS', VERSION = imp_nver )
160                                 
161   return ier
162
163
164 ##############################################################################################
165 # Liste des fonctions
166 ##############################################################################################
167
168 #############
169 ## EXTERNES (appelables depuis l'extérieur)
170 #############
171
172 ### Ecriture du fichier GIBI principal (dgib) - Bride STANDARD
173 # null = write_file_dgib_STD(unite_mgib,unite_datg,msh_bride,geo_bride)
174
175 ### Ecriture du fichier GIBI principal (dgib) - Bride QUELCONQUE
176 # null = write_file_dgib_QQE(unite_mgib,unite_datg,msh_bride,geo_bride)
177
178 ### Imprime tout le catalogue des brides standards disponibles dans un fichier texte
179 # null = print_bride_std(nom_fichier)
180  
181 ### Catalogue complet des brides standards disponibles
182 # txt = bride_std()
183
184 #############
185 ## INTERNES (réservées au travail interne)
186 #############
187
188 ### Génération du nom du fichier pour le fichier maillage résultant (format GIBI)
189 # NomFichier(txt) = name_file_mgib(unite_mgib):
190
191 ### Génération du nom du fichier pour le fichier générant le maillage (commandes GIBI)
192 # NomFichier(txt) = name_file_datg(unite_datg):
193
194 ### Récupère un fichier texte DATG
195 # Txt = text_datg(fichier_datg):
196
197 ### Génération du texte pour les variables
198 # Txt = para_text(dico_var,var): 
199
200
201
202 #=============================================================================================
203 # Importation des modules Python
204 #=============================================================================================
205
206 from Macro.macr_cabri_mail_dat import dico_var_geo,dico_var_msh,dico_bride_std
207
208 #=============================================================================================
209 # Fonctions principales
210 #=============================================================================================
211 # Ecriture du fichier GIBI principal (dgib) - Bride STANDARD
212 def write_file_dgib_STD(unite_mgib,unite_datg,msh_bride,geo_bride):
213
214     # Nom du fichier maillage produit par GIBI
215     nomFichierMGIB = name_file_mgib(unite_mgib)
216  
217     # Nom du fichier de commandes pour GIBI
218     nomFichierDATG = name_file_datg(unite_datg)
219         
220     # Ouverture du fichier d'entrée de commandes
221     fdgib=open(nomFichierDATG,'w')
222     
223     # En-tete
224     text =        "**************************************************************\n"
225     text = text + "* Fichier GIBI pour le maillage d'une bride \n"
226     text = text + "**************************************************************\n"
227     text = text + "\n"
228     text = text + "* Ce fichier a été généré automatiquement par la macro ASTER MACR_CABRI_MAIL \n"
229     text = text + "* Ne pas modifier\n"
230     text = text + "\n"    
231     text = text + "**************************************************************\n"
232     text = text + "* Type bride: Bride standard \n"
233     text = text + "**************************************************************\n"
234     text = text + "titre '"+"Bride standard"+"';\n"
235     text = text + "** Type bride standard: "+geo_bride+"\n"
236    
237     text = text + "\n"
238     text = text + "nomfich = CHAINE \n"
239     if len(nomFichierMGIB)>72:
240       raise Exception, 'Nom de fichier trop long (limité à 72 caractères ' \
241          'pour GIBI) :\n',nomFichierMGIB
242     elif len(nomFichierMGIB)<=69:
243       text = text + "'"+nomFichierMGIB+"';\n"
244     else:
245       text = text + "'"+nomFichierMGIB[:69]+"'\n" \
246                   + "'"+nomFichierMGIB[69:]+"';\n"
247     text = text + "opti dime 3 elem cub8 SAUV FORM nomfich;\n"
248     text = text + "dens 1;\n"
249     text = text + "\n"
250     fdgib.write(text)
251     
252     # Procédures internes supplémentaires
253     text =        "**************************************************************\n"
254     text = text + "* Procédures supplémentaires \n"
255     text = text + "**************************************************************\n"
256     text = text + text_datg_pro()
257     fdgib.write(text)
258     
259     # Début de procédure de création du maillage
260     text =        "**************************************************************\n"
261     text = text + "**************************************************************\n"
262     text = text + "********* Début de procédure de création du maillage *********\n"
263     text = text + "**************************************************************\n"
264     text = text + "**************************************************************\n"
265     text = text + "\n debproc constru;\n"
266     fdgib.write(text)
267
268     # Paramètres géométriques
269     car_bride = dico_bride_std[geo_bride]
270     text =        "**************************************************************\n"
271     text = text + "* Paramètres géométriques \n"
272     text = text + "**************************************************************\n"
273     text = text + para_text(dico_var_geo,car_bride)
274     fdgib.write(text) 
275
276     # Paramètres du maillage
277     text =        "**************************************************************\n"
278     text = text + "* Paramètres physiques \n"
279     text = text + "**************************************************************\n"
280     text = text + para_text(dico_var_msh,msh_bride)
281     fdgib.write(text) 
282
283     # Algorithme du maillage
284     text =        "**************************************************************\n"
285     text = text + "* Algorithme de maillage \n"
286     text = text + "**************************************************************\n"
287     text = text + text_datg_std()
288     fdgib.write(text)
289     
290     # Fermeture du fichier maillage
291     fdgib.close()
292     
293     
294 # Ecriture du fichier GIBI principal (dgib) - Bride QUELCONQUE
295 def write_file_dgib_QQE(unite_mgib,unite_datg,msh_bride,geo_bride):
296         
297     # Nom du fichier maillage produit par GIBI
298     nomFichierMGIB = name_file_mgib(unite_mgib)
299  
300     # Nom du fichier de commandes pour GIBI
301     nomFichierDATG = name_file_datg(unite_datg)
302       
303     # Ouverture du fichier d'entree de commandes
304     fdgib=open(nomFichierDATG,'w')
305     
306     # En-tete
307     text =        "**************************************************************\n"
308     text = text + "* Fichier GIBI pour le maillage d'une bride \n"
309     text = text + "**************************************************************\n"
310     text = text + "\n"
311     text = text + "* Ce fichier a été généré automatiquement par la macro ASTER MACR_CABRI_MAIL \n"
312     text = text + "* Ne pas modifier\n"
313     text = text + "\n"    
314     text = text + "**************************************************************\n"
315     text = text + "* Type bride: Bride quelconque\n"
316     text = text + "**************************************************************\n"
317     text = text + "titre '"+"Bride Quelconque"+"';\n"
318     text = text + "\n"
319     text = text + "nomfich = CHAINE \n"
320     if len(nomFichierMGIB)>72:
321       raise Exception, 'Nom de fichier trop long (limité à 72 caractères ' \
322          'pour GIBI) :\n',nomFichierMGIB
323     elif len(nomFichierMGIB)<=69:
324       text = text + "'"+nomFichierMGIB+"';\n"
325     else:
326       text = text + "'"+nomFichierMGIB[:69]+"'\n" \
327                   + "'"+nomFichierMGIB[69:]+"';\n"
328     text = text + "opti dime 3 elem cub8 SAUV FORM nomfich;\n"
329     text = text + "dens 1;\n"
330     text = text + "\n"
331     fdgib.write(text)
332     
333     # Procédures internes supplémentaires
334     text =        "**************************************************************\n"
335     text = text + "* Procédures supplémentaires \n"
336     text = text + "**************************************************************\n"
337     text = text + text_datg_pro()
338     fdgib.write(text)
339     
340     # Début de procédure de création du maillage
341     text =        "**************************************************************\n"
342     text = text + "**************************************************************\n"
343     text = text + "********* Début de procédure de création du maillage *********\n"
344     text = text + "**************************************************************\n"
345     text = text + "**************************************************************\n"
346     text = text + "\n debproc constru;\n"
347     fdgib.write(text)
348
349     # Paramètres géométriques
350     text =        "**************************************************************\n"
351     text = text + "* Paramètres géométriques \n"
352     text = text + "**************************************************************\n"
353     text = text + para_text(dico_var_geo,geo_bride)
354     fdgib.write(text) 
355
356     # Paramètres du maillage
357     text =        "**************************************************************\n"
358     text = text + "* Paramètres physiques \n"
359     text = text + "**************************************************************\n"
360     text = text + para_text(dico_var_msh,msh_bride)
361     fdgib.write(text) 
362
363     # Algorithme du maillage
364     text =        "**************************************************************\n"
365     text = text + "* Algorithme de maillage \n"
366     text = text + "**************************************************************\n"
367     text = text + text_datg_qqe()
368     fdgib.write(text)
369     
370     # Fermeture du fichier maillage
371     fdgib.close()
372
373 # Génération du nom du fichier pour le fichier maillage résultant (format GIBI)
374 def name_file_mgib(unite_mgib):
375     cur_dir = os.getcwd()
376     nomFichier = cur_dir+'/fort.'+str(unite_mgib)
377     return nomFichier
378
379
380 # Génération du nom du fichier pour le fichier générant le maillage (commandes GIBI)
381 def name_file_datg(unite_datg):
382     cur_dir = os.getcwd()
383     nomFichier = cur_dir+'/fort.'+str(unite_datg)
384     return nomFichier
385
386 # Récupère un fichier texte DATG: texte GIBI pour procédures
387 def text_datg_pro():
388    import aster
389    loc_datg = aster.repdex()
390    datg_bridePro  = loc_datg+"macr_cabri_mail_proc.datg"
391    fproc=open(datg_bridePro,'r')
392    procText = fproc.read()
393    fproc.close()
394
395    return procText
396
397 # Récupère un fichier texte DATG: texte GIBI pour bride quelconque
398 def text_datg_qqe():
399    import aster
400    loc_datg = aster.repdex()
401    datg_brideQqe  = loc_datg+"macr_cabri_mail_qqe.datg"      
402    fproc=open(datg_brideQqe,'r')
403    procText = fproc.read()
404    fproc.close()
405
406    return procText
407
408 # Récupère un fichier texte DATG: texte GIBI pour bride standard
409 def text_datg_std():
410    import aster
411    loc_datg = aster.repdex()
412    datg_brideStd  = loc_datg+"macr_cabri_mail_std.datg"      
413    fproc=open(datg_brideStd,'r')
414    procText = fproc.read()
415    fproc.close()
416
417    return procText
418
419 # Génération du texte pour les variables
420 def para_text(dico_var,var):
421     text = '\n'
422     for nom_var in var.keys():
423         text = text+"* "+dico_var[nom_var]+"\n"
424         text = text+nom_var+" = "+`var[nom_var]`+";\n"
425     return text
426
427 #=============================================================================================
428 # Accès au catalogue des brides standards
429 # (les brides standards sont décrites dans le fichier Data_Brides.py)
430 #=============================================================================================
431
432
433
434 # Imprime tout le catalogue des brides standards disponibles dans un fichier texte
435 def print_bride_std(nom_fichier):
436     text = bride_std()
437     # Ouverture du fichier
438     finfo=open(nom_fichier,'w')
439     # Ecriture des infos
440     finfo.write(text)
441     # Fermeture du fichier
442     finfo.close()
443
444 # Catalogue complet des brides standards disponibles
445 def bride_std():
446     # Ligne d'info
447     text = "Liste des brides standards avec leurs dimensions\n"
448     # Première ligne
449     text = text+"\t"
450     for nom_variable in dico_var_geo.keys():      
451         text = text + nom_variable+"\t\t"
452     text = text + "\n"
453     # Lignes suivantes
454     for nom_bride in dico_bride_std.keys():
455         bride = dico_bride_std[nom_bride]    
456         text = text + nom_bride + '\t'
457         for nom_var in dico_var_geo.keys():
458             chaine = "%f" % (bride[nom_var])
459             text = text+chaine+"\t"               
460         text = text + "\n"
461     return text