From 3f46c2ca89cefb0a559acbc60b60da8b7a3f2d23 Mon Sep 17 00:00:00 2001 From: Pascale Noyret Date: Thu, 22 Apr 2010 14:31:29 +0000 Subject: [PATCH] *** empty log message *** --- Map/Map_Openturns.py | 20 +++++ Map/catalogues_Map.ini | 5 +- Map/schema-openturns-template.xml | 129 ++++++++++++++++++++++++++++++ generator/generator_map_OT.py | 112 ++++++++++++++++++++++++++ 4 files changed, 263 insertions(+), 3 deletions(-) create mode 100644 Map/Map_Openturns.py create mode 100644 Map/schema-openturns-template.xml create mode 100644 generator/generator_map_OT.py diff --git a/Map/Map_Openturns.py b/Map/Map_Openturns.py new file mode 100644 index 00000000..351aa74b --- /dev/null +++ b/Map/Map_Openturns.py @@ -0,0 +1,20 @@ +## -*- coding: utf-8 -*- +# +## -------------------------------------------------- +## debut entete +## -------------------------------------------------- +# +from Accas import * +# +#CONTEXT.debug = 1 +JdC = JDC_CATA ( code = 'OPENTURNS_GENERIC', + execmodul = None, + regles=(AU_MOINS_UN('CODE',)), + )# Fin JDC_CATA +# + +CODE= PROC(nom="CODE",op=None, + fr='solver', + NOMCODE = SIMP(statut = "o", typ='TXM',), + FICH_RESULTAT = SIMP(statut = "o", typ='Fichier',), +) diff --git a/Map/catalogues_Map.ini b/Map/catalogues_Map.ini index 96c94e37..f1702082 100644 --- a/Map/catalogues_Map.ini +++ b/Map/catalogues_Map.ini @@ -5,9 +5,8 @@ rep_cata=os.getcwd() catalogues = ( # (code,version,catalogue,formatIn) - #('Map','V0',os.path.join(rep_cata,'Map_Cata_V0.py'),'map'), - #('Map','V0',os.path.join(rep_cata,'Map1_Cata_V0.py'),'map'), - ('Map','V1',os.path.join(rep_cata,'Map1_Cata_V1.py'),'map'), +# ('Map','V1',os.path.join(rep_cata,'Map1_Cata_V1.py'),'map'), ('Map2','V0',os.path.join(rep_cata,'Map2_Cata_V0.py'),'map'), + ('Map','V0',os.path.join(rep_cata,'Map_Openturns.py'),'map_OT'), ) diff --git a/Map/schema-openturns-template.xml b/Map/schema-openturns-template.xml new file mode 100644 index 00000000..aea4d999 --- /dev/null +++ b/Map/schema-openturns-template.xml @@ -0,0 +1,129 @@ + + + + + + + + + + + + + + + + + + + + + + + + + %_CODE_NOMCODE% + + InitWithVarList + + + + + + + OpenTurnsLoop.InitNode + ExecWithVarList + + + + + + OpenTurnsLoop.InitNode + Finalize + + + + + + + + + + + OPENTURNS + + WrapperParser + + + + + + + + + + + + OpenTurnsLoop SaveResultsToFile + WrapperParser OpenTurnsLoop + InitDeterministicVars OpenTurnsLoop + + OpenTurnsLoop algoResults + SaveResultsToFile algoResults + + + OpenTurnsLoop evalSamples + OpenTurnsLoop.ExecNode inPoint + + + WrapperParser initOptLoop + OpenTurnsLoop algoInit + + + WrapperParser inputVarList + OpenTurnsLoop.InitNode inputVarList + + + WrapperParser outputVarList + OpenTurnsLoop.InitNode outputVarList + + + InitDeterministicVars detVars + OpenTurnsLoop.InitNode deterministicVars + + + OpenTurnsLoop.ExecNode outPoint + OpenTurnsLoop evalResults + + + OpenTurnsLoopnbBranches + 4 + + + SaveResultsToFilefileName + /tmp/savedResults.txt + + + WrapperParserwrapperFilePath + /local00/renaud/salome/test-OT-YACS/wrap.xml + + + WrapperParserstudyFilePath + /local00/renaud/salome/test-OT-YACS/openturns_study.py + + + + + + + + + + diff --git a/generator/generator_map_OT.py b/generator/generator_map_OT.py new file mode 100644 index 00000000..73b5fd02 --- /dev/null +++ b/generator/generator_map_OT.py @@ -0,0 +1,112 @@ +# -*- coding: utf-8 -*- +# CONFIGURATION MANAGEMENT OF EDF VERSION +# ====================================================================== +# COPYRIGHT (C) 1991 - 2002 EDF R&D WWW.CODE-ASTER.ORG +# THIS PROGRAM IS FREE SOFTWARE; YOU CAN REDISTRIBUTE IT AND/OR MODIFY +# IT UNDER THE TERMS OF THE GNU GENERAL PUBLIC LICENSE AS PUBLISHED BY +# THE FREE SOFTWARE FOUNDATION; EITHER VERSION 2 OF THE LICENSE, OR +# (AT YOUR OPTION) ANY LATER VERSION. +# +# THIS PROGRAM IS DISTRIBUTED IN THE HOPE THAT IT WILL BE USEFUL, BUT +# WITHOUT ANY WARRANTY; WITHOUT EVEN THE IMPLIED WARRANTY OF +# MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. SEE THE GNU +# GENERAL PUBLIC LICENSE FOR MORE DETAILS. +# +# YOU SHOULD HAVE RECEIVED A COPY OF THE GNU GENERAL PUBLIC LICENSE +# ALONG WITH THIS PROGRAM; IF NOT, WRITE TO EDF R&D CODE_ASTER, +# 1 AVENUE DU GENERAL DE GAULLE, 92141 CLAMART CEDEX, FRANCE. +# +# +# ====================================================================== +""" + Ce module contient le plugin generateur de fichier au format + SEP pour EFICAS. + +""" +import traceback +import types,string,re,os + +from generator_python import PythonGenerator + + +CONFIGliste=() +MOTCLEFListe=("_CODE_NOMCODE",) + +def entryPoint(): + """ + Retourne les informations necessaires pour le chargeur de plugins + + Ces informations sont retournees dans un dictionnaire + """ + return { + # Le nom du plugin + 'name' : 'map_OT', + # La factory pour creer une instance du plugin + 'factory' : MapGenerator, + } + + +class MapGenerator(PythonGenerator): + """ + Ce generateur parcourt un objet de type JDC et produit + un texte au format eficas et + un texte au format py + + """ + # Les extensions de fichier permis? + extensions=('.comm',) + + def gener(self,obj,format='brut',config=None): + self.config=config + self.dictMCVal={} + self.text=PythonGenerator.gener(self,obj,format) + self.generePythonOT() + return self.text + + + def generePythonOT(self) : + ''' + self.dictMCVal est un dictionnaire. + ce dictionnaire a pour clef la genealogie du MCSimp suivi de sa valeur + + ''' + f = file(self.config.repIni+"/schema-openturns-template.xml","r") + chaine = f.read() + f.close() + chaine2=self.remplaceCONFIG(chaine) + chaine=self.remplaceDICO(chaine2,MOTCLEFListe) + f=open("/tmp/nouveau_scema.xml",'wb') + f.write(chaine) + f.close() + + + def generMCSIMP(self,obj) : + """ + Convertit un objet MCSIMP en texte python + Remplit le dictionnaire des MCSIMP si nous ne sommes ni dans une loi, ni dans une variable + """ + s=PythonGenerator.generMCSIMP(self,obj) + clef="" + for i in obj.get_genealogie() : + clef=clef+"_"+i + self.dictMCVal[clef]=obj.valeur + return s + + + def remplaceCONFIG(self,chaine) : + for mot in CONFIGliste : + rplact="%_"+mot+"%" + result=chaine.replace(rplact,self.config.__dict__[mot]) + chaine=result + return chaine + + def remplaceDICO(self,chaine,dico) : + for mot in MOTCLEFListe : + rplact="%"+mot+"%" + try : + result=chaine.replace(rplact,str(self.dictMCVal[mot])) + except : + result=chaine + chaine=result + return chaine + -- 2.39.2