1 # -*- coding: iso-8859-1 -*-
2 # Copyright (C) 2007-2013 EDF R&D
4 # This library is free software; you can redistribute it and/or
5 # modify it under the terms of the GNU Lesser General Public
6 # License as published by the Free Software Foundation; either
7 # version 2.1 of the License.
9 # This library is distributed in the hope that it will be useful,
10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 # Lesser General Public License for more details.
14 # You should have received a copy of the GNU Lesser General Public
15 # License along with this library; if not, write to the Free Software
16 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18 # See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
22 Ce module contient la partie commune
23 aux generateurs XML et Etude d Openturns
32 pathDef=path+"DefautOpenturns"
34 sys.path.append(pathDef)
37 #=============================================
39 #=============================================
44 Classe generale du generateur
45 DictMCVal : dictionnaire des mots-cles
46 ListeVariables : chaque variable est decrite par un dictionnaire ; cette liste les regroupe
47 DictLois : dictionnaires des lois
49 def __init__ (self, appli, DictMCVal = {}, ListeVariables = [], DictLois = {}, DictVariables = {} ) :
50 #---------------------------------------------------------#
51 self.ListeVariables = ListeVariables
52 self.ListeVariablesIn = []
53 self.ListeVariablesOut = []
54 self.DictLois = DictLois
55 self.DictVariables = DictVariables
56 self.DictMCVal = DictMCVal
63 # On charge eventuellement le Solver par defaut
64 # et les valeurs par defaut du Solver (dans l init)
68 Solver = self.DictMCVal["PhysicalSolver"]
69 import_name = "Defaut"+Solver
70 self.module = __import__( import_name, globals(), locals() )
71 monDefaut = self.module.Defaut( self )
77 def getSTDGenerateur(self) :
78 #--------------------------#
80 gener = self.module.__dict__["MonSTDGenerateur"]
81 monSTDGenerateur=gener( self.DictMCVal, self.ListeVariablesIn, self.ListeVariablesOut, self.DictLois )
83 from OpenturnsSTD import STDGenerateur
84 monSTDGenerateur = STDGenerateur( self.appli, self.DictMCVal, self.ListeVariablesIn, self.ListeVariablesOut, self.DictLois )
85 return monSTDGenerateur
87 def getXMLGenerateur(self) :
88 #--------------------------#
90 gener = self.module.__dict__["MonXMLGenerateur"]
91 monXMLGenerateur=gener( self.DictMCVal, self.ListeVariables, self.DictLois )
93 from OpenturnsXML import XMLGenerateur
94 monXMLGenerateur = XMLGenerateur( self.appli, self.DictMCVal, self.DictVariables )
95 return monXMLGenerateur
97 def creeInfoVar (self) :
98 #----------------------#
100 On repere les variables in/out et on les numerote.
104 for DictVariable in self.ListeVariables :
105 if not DictVariable.has_key("Type") : DictVariable["Type"] = "in"
106 self.DictTypeVar[num] = DictVariable["Type"]
107 if DictVariable["Type"] == "in" :
108 self.nbVarIn = self.nbVarIn + 1
109 self.ListeVariablesIn.append( DictVariable )
110 print "OpenturnsBase.py: new input variable = ", DictVariable
112 self.nbVarOut = self.nbVarOut + 1
113 self.ListeVariablesOut.append( DictVariable )
114 print "OpenturnsBase.py: new output variable = ", DictVariable
115 liste.append( DictVariable )
117 self.ListeVariables = liste
120 def ajouteDictMCVal(self, dicoPlus) :
121 #-----------------------------------#
122 # Appele par le classe Defaut du python specifique au code (exple DefautASTER.py)
123 # enrichit self.DictMCVal avec les valeurs donnees dans dicoPlus
124 # si elles ne sont pas deja dans le dictionnaire
126 for clef in dicoPlus.keys():
127 if not self.DictMCVal.has_key(clef) :
128 self.DictMCVal[clef] = dicoPlus[clef]
130 def ajouteInfoVariables (self, dicoVariablesIn, dicoVariablesOut) :
131 #-----------------------------------------------------------------#
132 # Appele par le classe Defaut du python specifique au code (exple DefautASTER.py)
133 # met a jour les dictionnaires qui decrivent les variables (regexp par exemple)
136 for dictVariable in self.ListeVariables:
137 if self.DictTypeVar[num] == "in" :
138 dico = dicoVariablesIn
140 dico = dicoVariablesOut
141 for nouvelleVariable in dico.keys() :
142 if not dictVariable.has_key(nouvelleVariable):
143 dictVariable[nouvelleVariable] = dico[nouvelleVariable]
144 liste.append( dictVariable )