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.
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.
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 # ======================================================================
23 def macr_cabri_mail_ops(self,EXEC_MAILLAGE,RAFF_MAILLAGE,VERI_MAIL,GEOM_BRID,
26 Ecriture de la macro MACR_CABRI_MAIL
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')
40 # La macro compte pour 1 dans la numerotation des commandes
43 # Le concept sortant (de type mail) est nommé 'nomres' dans
44 # le contexte de la macro
46 self.DeclareOut('nomres',self.sd)
50 loc_gibi=aster.repout()
51 gibi2000=loc_gibi+'gibi'
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']
58 niveau_gibi = EXEC_MAILLAGE['NIVE_GIBI']
61 ver_apla = VERI_MAIL['APLAT']
62 ver_veri = VERI_MAIL['VERIF']
65 if IMPRESSION['UNITE']!=None:
66 imp_unit = IMPRESSION['UNITE']
70 if IMPRESSION['FORMAT']!=None:
71 imp_form = IMPRESSION['FORMAT']
75 # if IMPRESSION['FICHIER']!=None:
76 # imp_fich = IMPRESSION['FICHIER']
82 nrad = RAFF_MAILLAGE['NB_RADIAL']
83 ncir = RAFF_MAILLAGE['NB_CIRCONF']
84 nver = RAFF_MAILLAGE['NB_VERTICAL']
85 nsect = RAFF_MAILLAGE['NB_ALESAGE']
88 maillage = {'nrad': nrad,
94 # Création du fichier datg
96 if GEOM_BRID['NORME'] == 'OUI':
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)
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)
126 fichier_datg = 'fort.'+str(unite_datg)
127 fichier_mgib = 'fort.'+str(unite_mgib)
132 ARGUMENT=(_F(NOM_PARA=fichier_datg),
133 _F(NOM_PARA=fichier_mgib),
136 # Lecture du maillage GIBI dans ASTER
138 UNITE_GIBI = unite_mgib,
141 nomres = LIRE_MAILLAGE(VERI_MAIL=_F(APLAT = ver_apla,
144 # if (imp_fichF == 1):
150 # Impression du fichier maillage
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 )
164 ##############################################################################################
165 # Liste des fonctions
166 ##############################################################################################
169 ## EXTERNES (appelables depuis l'extérieur)
172 ### Ecriture du fichier GIBI principal (dgib) - Bride STANDARD
173 # null = write_file_dgib_STD(unite_mgib,unite_datg,msh_bride,geo_bride)
175 ### Ecriture du fichier GIBI principal (dgib) - Bride QUELCONQUE
176 # null = write_file_dgib_QQE(unite_mgib,unite_datg,msh_bride,geo_bride)
178 ### Imprime tout le catalogue des brides standards disponibles dans un fichier texte
179 # null = print_bride_std(nom_fichier)
181 ### Catalogue complet des brides standards disponibles
185 ## INTERNES (réservées au travail interne)
188 ### Génération du nom du fichier pour le fichier maillage résultant (format GIBI)
189 # NomFichier(txt) = name_file_mgib(unite_mgib):
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):
194 ### Récupère un fichier texte DATG
195 # Txt = text_datg(fichier_datg):
197 ### Génération du texte pour les variables
198 # Txt = para_text(dico_var,var):
202 #=============================================================================================
203 # Importation des modules Python
204 #=============================================================================================
206 from Macro.macr_cabri_mail_dat import dico_var_geo,dico_var_msh,dico_bride_std
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):
214 # Nom du fichier maillage produit par GIBI
215 nomFichierMGIB = name_file_mgib(unite_mgib)
217 # Nom du fichier de commandes pour GIBI
218 nomFichierDATG = name_file_datg(unite_datg)
220 # Ouverture du fichier d'entrée de commandes
221 fdgib=open(nomFichierDATG,'w')
224 text = "**************************************************************\n"
225 text = text + "* Fichier GIBI pour le maillage d'une bride \n"
226 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"
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"
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"
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"
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()
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"
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)
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)
283 # Algorithme du maillage
284 text = "**************************************************************\n"
285 text = text + "* Algorithme de maillage \n"
286 text = text + "**************************************************************\n"
287 text = text + text_datg_std()
290 # Fermeture du fichier maillage
294 # Ecriture du fichier GIBI principal (dgib) - Bride QUELCONQUE
295 def write_file_dgib_QQE(unite_mgib,unite_datg,msh_bride,geo_bride):
297 # Nom du fichier maillage produit par GIBI
298 nomFichierMGIB = name_file_mgib(unite_mgib)
300 # Nom du fichier de commandes pour GIBI
301 nomFichierDATG = name_file_datg(unite_datg)
303 # Ouverture du fichier d'entree de commandes
304 fdgib=open(nomFichierDATG,'w')
307 text = "**************************************************************\n"
308 text = text + "* Fichier GIBI pour le maillage d'une bride \n"
309 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"
314 text = text + "**************************************************************\n"
315 text = text + "* Type bride: Bride quelconque\n"
316 text = text + "**************************************************************\n"
317 text = text + "titre '"+"Bride Quelconque"+"';\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"
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"
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()
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"
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)
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)
363 # Algorithme du maillage
364 text = "**************************************************************\n"
365 text = text + "* Algorithme de maillage \n"
366 text = text + "**************************************************************\n"
367 text = text + text_datg_qqe()
370 # Fermeture du fichier maillage
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)
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)
386 # Récupère un fichier texte DATG: texte GIBI pour procédures
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()
397 # Récupère un fichier texte DATG: texte GIBI pour bride quelconque
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()
408 # Récupère un fichier texte DATG: texte GIBI pour bride standard
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()
419 # Génération du texte pour les variables
420 def para_text(dico_var,var):
422 for nom_var in var.keys():
423 text = text+"* "+dico_var[nom_var]+"\n"
424 text = text+nom_var+" = "+`var[nom_var]`+";\n"
427 #=============================================================================================
428 # Accès au catalogue des brides standards
429 # (les brides standards sont décrites dans le fichier Data_Brides.py)
430 #=============================================================================================
434 # Imprime tout le catalogue des brides standards disponibles dans un fichier texte
435 def print_bride_std(nom_fichier):
437 # Ouverture du fichier
438 finfo=open(nom_fichier,'w')
441 # Fermeture du fichier
444 # Catalogue complet des brides standards disponibles
447 text = "Liste des brides standards avec leurs dimensions\n"
450 for nom_variable in dico_var_geo.keys():
451 text = text + nom_variable+"\t\t"
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"