1 #@ MODIF macr_cabri_mail_ops Macro DATE 29/08/2006 AUTEUR MCOURTOI M.COURTOIS
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=(fichier_datg, fichier_mgib),
134 # Lecture du maillage GIBI dans ASTER
136 UNITE_GIBI = unite_mgib,
139 nomres = LIRE_MAILLAGE(VERI_MAIL=_F(APLAT = ver_apla,
142 # if (imp_fichF == 1):
148 # Impression du fichier maillage
150 if (imp_form == 'CASTEM'):
151 imp_ngib = IMPRESSION['NIVE_GIBI']
152 IMPR_RESU( RESU = _F(MAILLAGE=nomres, ),
153 FORMAT = 'CASTEM', NIVE_GIBI = imp_ngib )
154 if (imp_form == 'IDEAS'):
155 imp_nver = IMPRESSION['VERSION']
156 IMPR_RESU(RESU = _F(MAILLAGE=nomres,),
157 FORMAT = 'IDEAS', VERSION = imp_nver )
162 ##############################################################################################
163 # Liste des fonctions
164 ##############################################################################################
167 ## EXTERNES (appelables depuis l'extérieur)
170 ### Ecriture du fichier GIBI principal (dgib) - Bride STANDARD
171 # null = write_file_dgib_STD(unite_mgib,unite_datg,msh_bride,geo_bride)
173 ### Ecriture du fichier GIBI principal (dgib) - Bride QUELCONQUE
174 # null = write_file_dgib_QQE(unite_mgib,unite_datg,msh_bride,geo_bride)
176 ### Imprime tout le catalogue des brides standards disponibles dans un fichier texte
177 # null = print_bride_std(nom_fichier)
179 ### Catalogue complet des brides standards disponibles
183 ## INTERNES (réservées au travail interne)
186 ### Génération du nom du fichier pour le fichier maillage résultant (format GIBI)
187 # NomFichier(txt) = name_file_mgib(unite_mgib):
189 ### Génération du nom du fichier pour le fichier générant le maillage (commandes GIBI)
190 # NomFichier(txt) = name_file_datg(unite_datg):
192 ### Récupère un fichier texte DATG
193 # Txt = text_datg(fichier_datg):
195 ### Génération du texte pour les variables
196 # Txt = para_text(dico_var,var):
200 #=============================================================================================
201 # Importation des modules Python
202 #=============================================================================================
204 from Macro.macr_cabri_mail_dat import dico_var_geo,dico_var_msh,dico_bride_std
206 #=============================================================================================
207 # Fonctions principales
208 #=============================================================================================
209 # Ecriture du fichier GIBI principal (dgib) - Bride STANDARD
210 def write_file_dgib_STD(unite_mgib,unite_datg,msh_bride,geo_bride):
212 # Nom du fichier maillage produit par GIBI
213 nomFichierMGIB = name_file_mgib(unite_mgib)
215 # Nom du fichier de commandes pour GIBI
216 nomFichierDATG = name_file_datg(unite_datg)
218 # Ouverture du fichier d'entrée de commandes
219 fdgib=open(nomFichierDATG,'w')
222 text = "**************************************************************\n"
223 text = text + "* Fichier GIBI pour le maillage d'une bride \n"
224 text = text + "**************************************************************\n"
226 text = text + "* Ce fichier a été généré automatiquement par la macro ASTER MACR_CABRI_MAIL \n"
227 text = text + "* Ne pas modifier\n"
229 text = text + "**************************************************************\n"
230 text = text + "* Type bride: Bride standard \n"
231 text = text + "**************************************************************\n"
232 text = text + "titre '"+"Bride standard"+"';\n"
233 text = text + "** Type bride standard: "+geo_bride+"\n"
236 text = text + "nomfich = CHAINE \n"
237 if len(nomFichierMGIB)>72:
238 raise Exception, 'Nom de fichier trop long (limité à 72 caractères ' \
239 'pour GIBI) :\n',nomFichierMGIB
240 elif len(nomFichierMGIB)<=69:
241 text = text + "'"+nomFichierMGIB+"';\n"
243 text = text + "'"+nomFichierMGIB[:69]+"'\n" \
244 + "'"+nomFichierMGIB[69:]+"';\n"
245 text = text + "opti dime 3 elem cub8 SAUV FORM nomfich;\n"
246 text = text + "dens 1;\n"
250 # Procédures internes supplémentaires
251 text = "**************************************************************\n"
252 text = text + "* Procédures supplémentaires \n"
253 text = text + "**************************************************************\n"
254 text = text + text_datg_pro()
257 # Début de procédure de création du maillage
258 text = "**************************************************************\n"
259 text = text + "**************************************************************\n"
260 text = text + "********* Début de procédure de création du maillage *********\n"
261 text = text + "**************************************************************\n"
262 text = text + "**************************************************************\n"
263 text = text + "\n debproc constru;\n"
266 # Paramètres géométriques
267 car_bride = dico_bride_std[geo_bride]
268 text = "**************************************************************\n"
269 text = text + "* Paramètres géométriques \n"
270 text = text + "**************************************************************\n"
271 text = text + para_text(dico_var_geo,car_bride)
274 # Paramètres du maillage
275 text = "**************************************************************\n"
276 text = text + "* Paramètres physiques \n"
277 text = text + "**************************************************************\n"
278 text = text + para_text(dico_var_msh,msh_bride)
281 # Algorithme du maillage
282 text = "**************************************************************\n"
283 text = text + "* Algorithme de maillage \n"
284 text = text + "**************************************************************\n"
285 text = text + text_datg_std()
288 # Fermeture du fichier maillage
292 # Ecriture du fichier GIBI principal (dgib) - Bride QUELCONQUE
293 def write_file_dgib_QQE(unite_mgib,unite_datg,msh_bride,geo_bride):
295 # Nom du fichier maillage produit par GIBI
296 nomFichierMGIB = name_file_mgib(unite_mgib)
298 # Nom du fichier de commandes pour GIBI
299 nomFichierDATG = name_file_datg(unite_datg)
301 # Ouverture du fichier d'entree de commandes
302 fdgib=open(nomFichierDATG,'w')
305 text = "**************************************************************\n"
306 text = text + "* Fichier GIBI pour le maillage d'une bride \n"
307 text = text + "**************************************************************\n"
309 text = text + "* Ce fichier a été généré automatiquement par la macro ASTER MACR_CABRI_MAIL \n"
310 text = text + "* Ne pas modifier\n"
312 text = text + "**************************************************************\n"
313 text = text + "* Type bride: Bride quelconque\n"
314 text = text + "**************************************************************\n"
315 text = text + "titre '"+"Bride Quelconque"+"';\n"
317 text = text + "nomfich = CHAINE \n"
318 if len(nomFichierMGIB)>72:
319 raise Exception, 'Nom de fichier trop long (limité à 72 caractères ' \
320 'pour GIBI) :\n',nomFichierMGIB
321 elif len(nomFichierMGIB)<=69:
322 text = text + "'"+nomFichierMGIB+"';\n"
324 text = text + "'"+nomFichierMGIB[:69]+"'\n" \
325 + "'"+nomFichierMGIB[69:]+"';\n"
326 text = text + "opti dime 3 elem cub8 SAUV FORM nomfich;\n"
327 text = text + "dens 1;\n"
331 # Procédures internes supplémentaires
332 text = "**************************************************************\n"
333 text = text + "* Procédures supplémentaires \n"
334 text = text + "**************************************************************\n"
335 text = text + text_datg_pro()
338 # Début de procédure de création du maillage
339 text = "**************************************************************\n"
340 text = text + "**************************************************************\n"
341 text = text + "********* Début de procédure de création du maillage *********\n"
342 text = text + "**************************************************************\n"
343 text = text + "**************************************************************\n"
344 text = text + "\n debproc constru;\n"
347 # Paramètres géométriques
348 text = "**************************************************************\n"
349 text = text + "* Paramètres géométriques \n"
350 text = text + "**************************************************************\n"
351 text = text + para_text(dico_var_geo,geo_bride)
354 # Paramètres du maillage
355 text = "**************************************************************\n"
356 text = text + "* Paramètres physiques \n"
357 text = text + "**************************************************************\n"
358 text = text + para_text(dico_var_msh,msh_bride)
361 # Algorithme du maillage
362 text = "**************************************************************\n"
363 text = text + "* Algorithme de maillage \n"
364 text = text + "**************************************************************\n"
365 text = text + text_datg_qqe()
368 # Fermeture du fichier maillage
371 # Génération du nom du fichier pour le fichier maillage résultant (format GIBI)
372 def name_file_mgib(unite_mgib):
373 cur_dir = os.getcwd()
374 nomFichier = cur_dir+'/fort.'+str(unite_mgib)
378 # Génération du nom du fichier pour le fichier générant le maillage (commandes GIBI)
379 def name_file_datg(unite_datg):
380 cur_dir = os.getcwd()
381 nomFichier = cur_dir+'/fort.'+str(unite_datg)
384 # Récupère un fichier texte DATG: texte GIBI pour procédures
387 loc_datg = aster.repdex()
388 datg_bridePro = loc_datg+"macr_cabri_mail_proc.datg"
389 fproc=open(datg_bridePro,'r')
390 procText = fproc.read()
395 # Récupère un fichier texte DATG: texte GIBI pour bride quelconque
398 loc_datg = aster.repdex()
399 datg_brideQqe = loc_datg+"macr_cabri_mail_qqe.datg"
400 fproc=open(datg_brideQqe,'r')
401 procText = fproc.read()
406 # Récupère un fichier texte DATG: texte GIBI pour bride standard
409 loc_datg = aster.repdex()
410 datg_brideStd = loc_datg+"macr_cabri_mail_std.datg"
411 fproc=open(datg_brideStd,'r')
412 procText = fproc.read()
417 # Génération du texte pour les variables
418 def para_text(dico_var,var):
420 for nom_var in var.keys():
421 text = text+"* "+dico_var[nom_var]+"\n"
422 text = text+nom_var+" = "+`var[nom_var]`+";\n"
425 #=============================================================================================
426 # Accès au catalogue des brides standards
427 # (les brides standards sont décrites dans le fichier Data_Brides.py)
428 #=============================================================================================
432 # Imprime tout le catalogue des brides standards disponibles dans un fichier texte
433 def print_bride_std(nom_fichier):
435 # Ouverture du fichier
436 finfo=open(nom_fichier,'w')
439 # Fermeture du fichier
442 # Catalogue complet des brides standards disponibles
445 text = "Liste des brides standards avec leurs dimensions\n"
448 for nom_variable in dico_var_geo.keys():
449 text = text + nom_variable+"\t\t"
452 for nom_bride in dico_bride_std.keys():
453 bride = dico_bride_std[nom_bride]
454 text = text + nom_bride + '\t'
455 for nom_var in dico_var_geo.keys():
456 chaine = "%f" % (bride[nom_var])
457 text = text+chaine+"\t"