From 9d9d6e7c4ac60adf2fd8a8d1487311486d2bcb29 Mon Sep 17 00:00:00 2001 From: Pascale Noyret Date: Fri, 3 Dec 2010 16:53:28 +0000 Subject: [PATCH] fonctionne pour pygmee --- generator/generator_map.py | 25 ++++--- generator/generator_s_polymers_st_1.py | 98 ++++++++------------------ generator/monCreateYacs.py | 20 +----- 3 files changed, 45 insertions(+), 98 deletions(-) diff --git a/generator/generator_map.py b/generator/generator_map.py index c04eb173..0e72d01a 100644 --- a/generator/generator_map.py +++ b/generator/generator_map.py @@ -68,36 +68,39 @@ class MapGenerator(PythonGenerator): os.makedirs(self.nom_racine) self.listeCODE=[] self.text="" - self.textCode="" - self.texteExecution="" - self.ssCode=self.config.appli.ssCode - def verifie(self): - print 'verification generique' + self.ssCode=self.config.appli.ssCode + self.INSTALLDIR=self.config.appli.INSTALLDIR + self.ssCodeDir=os.path.join(self.INSTALLDIR,'MAP/Templates',self.ssCode) + print self.ssCodeDir + self.texteExecution="import os,sys\n" + self.texteExecution+="sys.path.append('"+self.ssCodeDir+"')\n" + self.texteExecution+="from s_polymers_st_1_YACS_nodes import *\n" def gener(self,obj,format='brut',config=None): - print 'generation dans generator_map' self.initialise(config) text=PythonGenerator.gener(self,obj,format) - self.verifie() - self.generePythonMap("non") return text def generRUN(self,obj,format='brut',config=None,): print 'generRUN dans generator_map' self.initialise(config) text=PythonGenerator.gener(self,obj,format) - self.verifie() - self.generePythonMap("oui") + for elt in self.listeCODE: + code=elt.keys()[0] + if code in self.__class__.__dict__.keys(): + texteCode=apply(self.__class__.__dict__[code],(self,)) + self.texteExecution += texteCode return self.texteExecution def generRUNYACS(self,obj,format='brut',config=None,nomFichier=None): self.initialise(config) text=PythonGenerator.gener(self,obj,format) + #self.generePythonMap("non") + import sys sys.path.append(os.path.join(os.getenv("YACS_ROOT_DIR"),"lib/python2.4/site-packages/salome/")) - self.verifie() import monCreateYacs self.monSchema=monCreateYacs.getSchema(config) self.proc=self.monSchema.createProc(self) diff --git a/generator/generator_s_polymers_st_1.py b/generator/generator_s_polymers_st_1.py index d1610702..0d7afbb7 100644 --- a/generator/generator_s_polymers_st_1.py +++ b/generator/generator_s_polymers_st_1.py @@ -60,14 +60,11 @@ class s_poly_st_1Generator(MapGenerator): """ - def verifie(self): - liste=[] - for i in self.listeCODE: - liste.append(i.keys()[0]) - if len(liste) != len(set(liste)): - raise AsException("il n'est pas prevu d avoir deux fois le meme code dans ce schema") -# I - YACS functions +#_________________________________ +# - YACS functions +#_________________________________ + def PYGMEEYACS(self, SchemaYacs, proc): monFichierInput=self.config.PATH_STUDY+"/"+self.config.NAME_SCHEME+"/pygmee_input.txt" factoryNode = SchemaYacs.monCata._nodeMap["pygmee_v2"] @@ -173,78 +170,42 @@ class s_poly_st_1Generator(MapGenerator): self.ASTERYACS(SchemaYacs,proc) self.GMSHYACS(SchemaYacs,proc) -# II - shell functions - def ETUDE(self,execution) : - self.dicoETUDE=self.dictMCVal["ETUDE"] - print "_____________________" - print self.dicoETUDE - print "ETUDE Ok" - print "_____________________\n" - return "" - - def MATERIAUX(self,execution) : - self.dicoMATERIAUX=self.dictMCVal["MATERIAUX"] - print "_____________________" - print self.dicoMATERIAUX - print "MATERIAUX Ok" - print "_____________________\n" - return "" - - def DISCRETISATION(self,execution) : - self.dicoDISCRETISATION=self.dictMCVal["DISCRETISATION"] - print "_____________________" - print self.dicoDISCRETISATION - print "DISCRETISATION Ok" - print "_____________________\n" - return "" - - def METHODE(self,execution) : - self.dicoMETHODE=self.dictMCVal["METHODE"] - print "_____________________" - print self.dicoMETHODE - print "METHODE Ok" - print "_____________________\n" - - if (self.LANCEMENT =='oui') : - pass - if (self.LANCEMENT =='non') : - return "" +#_________________________________ +# - shell functions +#_________________________________ + def METHODE(self) : commande=self.PYGMEE() - if (self.CHOIX=="FD+grid") : - print "option fdvgrid" - commande+= self.FDVGRID() - return commande - elif (self.CHOIX=="FEM+mesh") : - print "option Code_Aster" - commande+= self.BENHUR() - commande+= self.ASTER_s_polymers_st_1() - commande+= self.GMSH() - return commande + #if (self.CHOIX=="FD+grid") : + # print "option fdvgrid" + # commande+= self.FDVGRID() + #elif (self.CHOIX=="FEM+mesh") : + # print "option Code_Aster" + # commande+= self.BENHUR() + # commande+= self.ASTER_s_polymers_st_1() + # commande+= self.GMSH() + return commande + +#_________________________________ +# - code and component functions +#_________________________________ -# III - code and component functions def PYGMEE(self) : - commande_python="import os,sys;\n" - commande_python+="sys.path.append(os.path.join(os.getenv('EFICAS_ROOT'), 'MAP/Templates/s_polymers_st_1/'));\n" - commande_python+="from s_polymers_st_1_YACS_nodes import *;\n" - commande_python+="volume_fraction=component_pygmee_v2("+str(self.rve_size)+",1,"+str(self.sieve_curve_in)+","+str(self.sieve_curve_out)+","+str(self.repulsion_distance)+","+str(self.study_name)+","+str(self.study_path)+","+str(self.inclusion_name)+","+str(self.rve_name)+");\n" - return 'python -c "'+commande_python+'"\n' + commande="volume_fraction=component_pygmee_v2("+str(self.rve_size)+",1,'"+str(self.sieve_curve_in)+"','"+str(self.sieve_curve_out)+"',"+str(self.repulsion_distance)+",'"+str(self.study_name)+"','"+str(self.study_path)+"','"+str(self.inclusion_name)+"','"+str(self.rve_name)+"')\n" + return commande def FDVGRID(self): - commande_python="import os,sys;\n" - commande_python+="sys.path.append(os.path.join(os.getenv('EFICAS_ROOT'), 'MAP/Templates/s_polymers_st_1/'));\n" - commande_python+="from s_polymers_st_1_YACS_nodes import *;\n" - commande_python+="lambda_x=component_fdvgrid("+str(self.lambda_I)+","+str(self.lambda_M)+","+str(self.rve_size)+",'"+str(self.inclusion_name)+"',"+str(self.finesse)+");\n" + return " " + commande_python+="lambda_x=component_fdvgrid("+str(self.lambda_I)+","+str(self.lambda_M)+","+str(self.rve_size)+",'"+str(self.inclusion_name)+"',"+str(self.finesse)+")\n" return 'python -c "'+commande_python+'"\n' def BENHUR(self): - commande_python="import os,sys;\n" - commande_python+="sys.path.append(os.path.join(os.getenv('EFICAS_ROOT'), 'MAP/Templates/s_polymers_st_1/'));\n" - commande_python+="from s_polymers_st_1_YACS_nodes import *;\n" + return " " commande_python+="component_benhur("+str(self.finesse)+","+str(self.rve_size)+",'"+str(self.inclusion_name)+"','"+str(self.study_name)+"','"+str(self.study_path)+"');\n" return 'python -c "'+commande_python+'"\n' def ASTER_s_polymers_st_1(self) : + return " " commande_python="import os,sys;\n" commande_python+="sys.path.append(os.path.join(os.getenv('EFICAS_ROOT'), 'MAP/Templates/s_polymers_st_1/'));\n" commande_python+="from s_polymers_st_1_YACS_nodes import *;\n" @@ -252,13 +213,10 @@ class s_poly_st_1Generator(MapGenerator): return 'python -c "'+commande_python+'"\n' def GMSH(self) : + return " " commande_python="import os,sys;\n" commande_python+="sys.path.append(os.path.join(os.getenv('EFICAS_ROOT'), 'MAP/Templates/s_polymers_st_1/'));\n" commande_python+="from s_polymers_st_1_YACS_nodes import *;\n" commande_python+="component_gmsh_post('"+str(self.study_path+"/s_polymers_st_1_aster.resu.msh")+"');\n" return 'python -c "'+commande_python+'"\n' -## commande="echo 'execution de GMSH';\n" -## commande+= "gmsh "+self.config.PATH_STUDY+"/s_polymers_st_1_aster.resu.msh;\n" -## commande+= "echo 'fin execution de GMSH';\n" -## return commande diff --git a/generator/monCreateYacs.py b/generator/monCreateYacs.py index 03a9dbed..368e416c 100755 --- a/generator/monCreateYacs.py +++ b/generator/monCreateYacs.py @@ -49,24 +49,10 @@ class CreeSchemaYacs : def write_yacs_proc(self,proc, yacs_schema_filename): proc.saveSchema(yacs_schema_filename) +# pour l instant on garde cette classe +# pour pouvoir specialiser si necessaire +# pour d autres schema class s_polymers_st_1(CreeSchemaYacs) : - # CTL 20101121 : obsolete, has been transfered to genarator_s_polymers_st_1 - # for better genericity -## def ASTERYACS(self,proc,dico): -## factoryNode = self.monCata._nodeMap["asterRun"] -## self.asterNode = factoryNode.cloneNode("asterRun") -## nom_racine=self.config.PATH_STUDY+"/"+self.config.NAME_SCHEME+"/" -## monFichierExport=nom_racine+"s_poly_st_1_aster.export" -## monFichierMed=nom_racine+"s_poly_st_1_aster.resu.med" -## self.asterNode.getInputPort("pathAster").edInitPy(self.config.PATH_ASTER+"/bin") -## self.asterNode.getInputPort("fileExport").edInitPy(monFichierExport) -## self.asterNode.getInputPort("fileMed").edInitPy(monFichierMed) - -## proc.edAddChild(self.asterNode) -## if self.nodeAvant != None : -## proc.edAddCFLink(self.nodeAvant,self.asterNode) -## self.nodeAvant=self.asterNode - def METHODEYACS(self,proc,dico): self.generator.METHODEYACS(self,proc) -- 2.39.2