]> SALOME platform Git repositories - tools/eficas.git/blob - generator/generator_s_polymers_st_1.py
Salome HOME
8b4bca8e751369ccdf5e77c522b93eff3a44eef5
[tools/eficas.git] / generator / generator_s_polymers_st_1.py
1 # -* coding: utf-8 -*-
2 #            CONFIGURATION MANAGEMENT OF EDF VERSION
3 # ======================================================================
4 # COPYRIGHT (C) 1991 - 2002  EDF R&D                  WWW.CODE-ASTER.ORG
5 # THIS PROGRAM IS FREE SOFTWARE; YOU CAN REDISTRIBUTE IT AND/OR MODIFY
6 # IT UNDER THE TERMS OF THE GNU GENERAL PUBLIC LICENSE AS PUBLISHED BY
7 # THE FREE SOFTWARE FOUNDATION; EITHER VERSION 2 OF THE LICENSE, OR
8 # (AT YOUR OPTION) ANY LATER VERSION.
9 #
10 # THIS PROGRAM IS DISTRIBUTED IN THE HOPE THAT IT WILL BE USEFUL, BUT
11 # WITHOUT ANY WARRANTY; WITHOUT EVEN THE IMPLIED WARRANTY OF
12 # MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. SEE THE GNU
13 # GENERAL PUBLIC LICENSE FOR MORE DETAILS.
14 #
15 # YOU SHOULD HAVE RECEIVED A COPY OF THE GNU GENERAL PUBLIC LICENSE
16 # ALONG WITH THIS PROGRAM; IF NOT, WRITE TO EDF R&D CODE_ASTER,
17 #    1 AVENUE DU GENERAL DE GAULLE, 92141 CLAMART CEDEX, FRANCE.
18 #
19 #
20 # ======================================================================
21 """
22    Ce module contient le plugin generateur de fichier au format
23    SEP pour EFICAS.
24
25 """
26 import traceback
27 import types,string,re,os
28
29 from generator_map import MapGenerator
30
31 #____________________________________________________________________________________
32 # PYGMEEDict contient une equivalence entre le catalogue Map et les lignes generees
33 # comme entete (commentaire ?) dans le fichier d'input de pygmee
34 #
35
36 CONFIGliste=('NAME_SCHEME', 'PATH_ASTER', 'PATH_BENHUR', 'PATH_MODULE', 'PATH_PYGMEE', 'PATH_STUDY', 'repIni')
37 PYGMEEDict={
38        "_PYGMEE_FUSEAU1_b_forme_FICHIER"  : "#fuseau 1 (entree de lecfus) format : diametre DCE croissant / fraction cumulee decroisant ",
39        "FUSEAU2" :  "#fuseau 2 (entree de lecfus) format : diametre DCE croissant / fraction cumulee decroisant",
40        "_PYGMEE_TAILLE" : "# taille du VER en microns ",
41        "_PYGMEE_DISTANCE" : "# distance de repulsion :",
42            }
43
44 #_______________________________________________________________________________________________________
45 # listeOrdonneeMCPygmee contient une liste (donc ordonnee) des mots clefs pour 
46 # imposer l'ordre des  lignes generees
47 listeOrdonneeMCPygmee =('_PYGMEE_FUSEAU1_b_forme_FICHIER', 'FUSEAU2', '_PYGMEE_TAILLE','_PYGMEE_DISTANCE')
48
49
50 BENHURDict={
51        "_BENHUR_FINESSE" : "discretisation des arretes du VER ",
52            }
53
54 ASTERDict={
55        "_ASTER_LANCEMENT" : "execution de Code_Aster",
56        "_ASTER_CONDUCTIVITE_I" : "conductivite des inclusions",
57        "_ASTER_CONDUCTIVITE_M" : "conductivite de la matrice",
58            }
59
60 GMSHDict={
61        "_GMSH_LANCEMENT" : "execution de GMSH",
62            }
63
64 def entryPoint():
65    """
66       Retourne les informations necessaires pour le chargeur de plugins
67
68       Ces informations sont retournees dans un dictionnaire
69    """
70    return {
71         # Le nom du plugin
72           'name' : 's_polymers_st_1',
73         # La factory pour creer une instance du plugin
74           'factory' : s_poly_st_1Generator,
75           }
76
77
78 class s_poly_st_1Generator(MapGenerator):
79    """
80       Ce generateur parcourt un objet de type JDC et produit
81       un texte au format eficas et
82       un texte au format py
83
84    """
85    
86    def verifie(self):
87        liste=[]
88        for i in self.listeCODE:
89            liste.append(i.keys()[0])
90        if len(liste) != len(set(liste)):
91            raise AsException("il n'est pas prevu d avoir deux fois le meme code dans ce schema")
92
93
94    def PYGMEE(self,execution) :
95        dicoPygmee=self.dictMCVal["PYGMEE"]
96        self.dictPYGMEE=dicoPygmee
97        monFichier=self.config.PATH_PYGMEE+"/pygmee_input.txt"
98
99        #Lecture du fichier a trous
100        f = file(self.config.repIni+"/pygmee_input.txt","r")
101        chaine = f.read()  
102        f.close()   
103        chaine2=self.remplaceCONFIG(chaine,CONFIGliste)
104        chaine=self.remplaceDICO(chaine2,dicoPygmee)
105
106        if  os.path.isfile(monFichier) :
107            print "je detruis pygmee_input.txt"
108            commande="rm -rf " + monFichier
109            os.system (commande)
110        f=open(monFichier,'wb')
111        f.write(chaine)
112        f.close()
113        if execution=="non" : return ""
114
115        if ('_PYGMEE_LANCEMENT' in dicoPygmee.keys()) and  dicoPygmee['_PYGMEE_LANCEMENT'] == 'oui':
116            commande="echo '__________________';\n"
117            commande=commande + "echo 'execution de PYGMEE';\n"
118            commande=commande + "cd "+self.config.PATH_PYGMEE+";\n"
119            commande=commande + "python "+self.config.PATH_PYGMEE+"/pygmee_v1.py;\n"
120            commande=commande + "echo 'fin execution de PYGMEE';\n"
121            commande=commande + "echo '_____________________';\n\n\n"
122            return commande
123        else:
124            return ""
125
126    def BENHUR(self,execution) :
127        dicoBenhur=self.dictMCVal["BENHUR"]
128        if hasattr(self,'dictPYGMEE') and '_PYGMEE_TAILLE' in self.dictMCVal['PYGMEE']:
129            dicoBenhur["_PYGMEE_TAILLE"]=self.dictPYGMEE['_PYGMEE_TAILLE']
130        else :
131            dicoBenhur["_PYGMEE_TAILLE"]=0
132            print "Attention la variable Taille_VER non definie"
133        
134        finesse=str(dicoBenhur["_BENHUR_FINESSE"])
135        nom_fichier_BHR=self.config.PATH_STUDY+"/"+self.config.NAME_SCHEME+"_benhur_"+finesse+".bhr"
136        nom_BHR_Files=self.config.PATH_BENHUR+"/BHR_files.txt"
137
138        #Lecture du fichier a trous
139        f = file(self.config.repIni+"/benhur_pygmee.txt","r")
140        chaine = f.read()  
141        f.close()   
142        chaine2=self.remplaceCONFIG(chaine,CONFIGliste)
143        chaine=self.remplaceDICO(chaine2,dicoBenhur)
144
145        try :
146           f=open(nom_fichier_BHR,'wb')
147        except :
148           print "Pb de Generation de BENHUR"
149           return ""
150        f.write(chaine)
151        f.close()
152
153        f=open(nom_BHR_Files,'wb')
154        f.write(nom_fichier_BHR)
155        f.write("\n\n\n")
156        f.close()
157
158        if execution=="non" : return ""
159        if ('_BENHUR_LANCEMENT' in dicoBenhur.keys()) and  dicoBenhur['_BENHUR_LANCEMENT'] == 'oui':
160            commande="echo '__________________';\n"
161            commande=commande + "echo 'execution de BENHUR';\n"
162            commande=commande + "cd "+self.config.PATH_BENHUR+";\n"
163            commande=commande + "./benhur;\n"
164            commande=commande + "echo 'fin execution de BENHUR';\n"
165            commande=commande + "echo '________________________';\n\n\n"
166            return commande
167        else:
168           return ""
169
170
171
172    def ASTER(self,execution) :
173       print "Generation de ASTER"
174       dicoAster=self.dictMCVal["ASTER"]
175       nom_racine=self.config.PATH_MODULE+"/"+self.config.NAME_SCHEME+"/"+self.config.NAME_SCHEME
176       nom_fichier_ASTER=nom_racine+"_aster.comm"
177
178       #Lecture du fichier a trous
179       f = file(self.config.repIni+"/s_poly_st_1_aster_template.comm","r")
180       chaine = f.read()  
181       f.close()   
182       chaine2=self.remplaceDICO(chaine,self.dictPYGMEE)
183       chaine=self.remplaceDICO(chaine2,dicoAster)
184
185       f=open(nom_fichier_ASTER,'wb')
186       f.write(chaine)
187       f.close()
188
189       if ('_ASTER_LANCEMENT' in dicoAster.keys()) and  dicoAster['_ASTER_LANCEMENT'] == 'oui':
190          commande="cd "+self.config.PATH_MODULE+";"
191          commande=commande + self.config.PATH_ASTER + "/as_run "+self.config.PATH_MODULE
192          commande=commande + "/"+self.config.NAME_SCHEME+"/"+self.config.NAME_SCHEME+"_aster.export"
193          os.system(commande)
194       else:
195          return ""
196
197    def GMSH(self,execution) :
198       dicoGmsh=self.dictMCVal["GMSH"]
199       if ('_GMSH_LANCEMENT' in dicoGmsh.keys()) and  dicoGmsh['_GMSH_LANCEMENT'] == 'oui':
200          commande="cd "+self.config.PATH_MODULE+";"
201          commande=commande + "gmsh "+self.config.PATH_MODULE+"/"+self.config.NAME_SCHEME+"/"+self.config.NAME_SCHEME+"_aster.resu.msh"
202          print commande
203          os.system(commande)
204       else:
205          return ""
206
207    def METHODE(self,execution) :
208       print "METHODE"
209       return ""
210
211    def MATERIAUX(self,execution) :
212       print "MATERIAUX"
213       return ""
214
215    def DISCRETISATION(self,execution) :
216       print "DISCRETISATION"
217       return ""