1 # -*- coding: utf-8 -*-
3 # Copyright (C) 2012-2013 EDF
5 # This file is part of SALOME HYDRO module.
7 # SALOME HYDRO module is free software: you can redistribute it and/or modify
8 # it under the terms of the GNU General Public License as published by
9 # the Free Software Foundation, either version 3 of the License, or
10 # (at your option) any later version.
12 # SALOME HYDRO module is distributed in the hope that it will be useful,
13 # but WITHOUT ANY WARRANTY; without even the implied warranty of
14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 # GNU General Public License for more details.
17 # You should have received a copy of the GNU General Public License
18 # along with SALOME HYDRO module. If not, see <http://www.gnu.org/licenses/>.
23 def get_list_var_api(module):
25 Returns the list of variables avaialable throught the API for module
27 @param One of the modules of TELEMAC-MASCARET
29 if module == 'TELEMAC2D':
30 from TelApy.api.t2d import Telemac2d
31 model = Telemac2d('dummy.cas')
32 elif module == 'TELEMAC3D':
33 from TelApy.api.t3d import Telemac3d
34 model = Telemac3d('dummy.cas')
35 elif module == 'SISYPHE':
36 from TelApy.api.sis import Sisyphe
37 model = Sisyphe('dummy.cas')
39 return ['No variable available']
41 varnames, _ = model.list_variables()
42 return sorted(varnames)
45 def __init__(self,ntuple):
48 def __convert__(self,valeur):
49 if type(valeur) == types.StringType:
51 if len(valeur) != self.ntuple:
56 return "Tuple de %s elements" % self.ntuple
61 JdC = JDC_CATA(regles = (UN_PARMI('TELEMAC2D',)),
67 nom = "TELEMAC2D", op = None,
68 fr = u"Définition d'un cas d'étude Telemac2D",
69 ang = u"Definition of a Telemac2D study case",
70 STEERING_FILE = SIMP(statut = "o", typ = 'Fichier',
71 fr = u"Fichier de description du cas",
72 ang = u"Case description file",
74 USER_FORTRAN = SIMP(statut = "f", typ = 'FichierOuRepertoire',
75 fr = "Fichier Fortran utilisateur",
76 ang = u"Fortran user file",
78 WORKING_DIRECTORY = SIMP(statut = "o", typ = 'Repertoire',
80 fr = "Repertoire de travail",
81 ang = u"Working directory user file",
83 RESULT_DIRECTORY = SIMP(statut = "f", typ = 'Repertoire',
84 fr = "Repertoire de travail",
85 ang = u"Working directory user file",
87 RESULTS_FILE_NAME = SIMP(statut = "f", typ = 'TXM',
88 fr = u"Fichier des resultats (Ecrasera celui dans le fichier cas)",
89 ang = u"Results file (Will replace the one in the steering file)"
91 Consigne = SIMP(statut ="o", homo="information", typ="TXM",
92 defaut = "All index are in Python numbering (Starting from 0)",
94 INPUT_VARIABLE = FACT(statut = 'f', max = '**',
95 fr = u"Variable d'entrée du calcul",
96 ang = u"Computation input variable",
98 NAME = SIMP(statut = "o", typ = 'TXM',
99 fr = u"Nom de la variable (format Python)",
100 ang = u"Variable name (Python format)"
102 VAR_INFO = FACT(statut = "o",
103 fr = u'Variable du modèle Telemac2D',
104 ang = u'Telemac2D model variable',
106 VAR_NAME = SIMP(statut = "o", typ = 'TXM',
107 intoSug = get_list_var_api('TELEMAC2D'),
108 fr = u'Nom de la variable du modèle (ex: "MODEL.DEBIT")',
109 ang = u'Model variable name (ex: "MODEL.DEBIT")'
111 DEFAULT_VALUE = SIMP(statut = "o", typ = 'TXM',
112 fr = u'Valeur par défaut',
113 ang = u'Default value',
115 ZONE_DEF = FACT(statut = "o",
116 ang = u'Variable definition area',
117 fr = u'Zone de définition de la variable',
119 TYPE = SIMP(statut = "o", typ = 'TXM',
120 into = ['INDEX', 'RANGE', 'POLYGON', 'POLYGON_FILE'],
121 fr = u'Type de definition de la variable',
122 ang = u'Type of definition for the variable',
125 b_INDEX = BLOC(condition = "TYPE == 'INDEX'",
126 INDEX = SIMP(statut = "o", typ = Tuple(3),
128 ang = "Index of the variable",
129 fr = u"Indice de la variable",
130 validators = VerifTypeTuple(('I', 'I', 'I')),
133 b_RANGE = BLOC(condition = "TYPE == 'RANGE'",
134 RANGE = SIMP(statut = "o", typ = 'TXM',
135 fr = u"Liste d'index pour des tableaux à une dimension ex: [1,3:8,666]",
136 ang = "Range of index for one dimension arrays ex: [1,3:8,666]",
138 Consigne = SIMP(statut ="o", homo="information", typ="TXM",
139 defaut = "Format [0,2:8,50:88,666]",
142 b_POLYGON = BLOC(condition = "TYPE == 'POLYGON'",
143 POLYGON = SIMP(statut = "o",
146 fr = u"Liste des sommets (coordonnées X,Y) du "
147 u"polygone définissant le contour de la zone",
148 ang = "List of points (X,Y coordinates) of the "
149 "polygon defining the border of the area",
150 validators = VerifTypeTuple(('R', 'R')),
153 b_POLYGON_FILE = BLOC(condition = "TYPE == 'POLYGON_FILE'",
154 POLYGON_FILE = FACT(statut = "o",
155 fr = u"Polygon dans un fichier",
156 ang = "Polygone in a file",
157 FILE_NAME = SIMP(statut = "o", typ = 'Fichier',
158 fr = u"Fichier contenant les info du polygone",
159 ang = "File containing the polygon info",
161 SEPARATOR = SIMP(statut = "o", typ = 'TXM',
163 fr = u"Separateur pour le fichier de polygone",
164 ang = "Separator for the polygon file",
171 OUTPUT_VARIABLE = FACT(statut = 'f', max = '**',
172 fr = u"Variable de sortie du calcul",
173 ang = u"Computation output variable",
174 NAME = SIMP(statut = "o", typ = 'TXM',
175 fr = u"Nom de la variable",
176 ang = u"Variable name",
178 VAR_INFO = FACT(statut = "o",
179 fr = u'Variable du modèle Telemac2D',
180 ang = u'Telemac2D model variable',
181 VAR_NAME = SIMP(statut = "o", typ = 'TXM',
182 into = get_list_var_api('TELEMAC2D'),
183 fr = u'Nom de la variable du modèle (ex: "MODEL.DEBIT")',
184 ang = u'Model variable name (ex: "MODEL.DEBIT")',
186 ZONE_DEF = FACT(statut = "o",
187 ang = u'Variable definition area',
188 fr = u'Zone de définition de la variable',
189 INDEX = SIMP(statut = "o", typ = Tuple(3),
190 defaut = (0, 0, 0, ),
191 ang = "Index of the point / border",
192 fr = u"Indice du point ou de la frontière",
193 validators = VerifTypeTuple(('I', 'I', 'I')),
200 TEXTE_NEW_JDC="TELEMAC2D()"