Salome HOME
New version of catalog for api runs
[modules/hydrosolver.git] / src / salome_hydro / telemac2d / eficas / telemac2d_V6_cata.py
1 # -*- coding: utf-8 -*-
2 #
3 #  Copyright (C) 2012-2013 EDF
4 #
5 #  This file is part of SALOME HYDRO module.
6 #
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.
11 #
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.
16 #
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/>.
19
20 import types
21 from Accas import *
22
23 def get_list_var_api(module):
24     """
25     Returns the list of variables avaialable throught the API for module
26
27     @param One of the modules of TELEMAC-MASCARET
28     """
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')
38     else:
39         return ['No variable available']
40
41     varnames, _ = model.list_variables()
42     return sorted(varnames)
43
44 class Tuple:
45   def __init__(self,ntuple):
46     self.ntuple=ntuple
47
48   def __convert__(self,valeur):
49     if type(valeur) == types.StringType:
50       return None
51     if len(valeur) != self.ntuple:
52       return None
53     return valeur
54
55   def info(self):
56     return "Tuple de %s elements" % self.ntuple
57
58   __repr__=info
59   __str__=info
60
61 JdC = JDC_CATA(regles = (UN_PARMI('TELEMAC2D',)),
62                         )
63
64
65
66 TELEMAC2D = PROC(
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",
73     ),
74     USER_FORTRAN = SIMP(statut = "f", typ = 'FichierOuRepertoire',
75                         fr = "Fichier Fortran utilisateur",
76                         ang = u"Fortran user file",
77     ),
78     WORKING_DIRECTORY = SIMP(statut = "o", typ = 'Repertoire',
79                              defaut = '/tmp',
80                              fr = "Repertoire de travail",
81                              ang = u"Working directory user file",
82     ),
83     RESULT_DIRECTORY = SIMP(statut = "f", typ = 'Repertoire',
84                             fr = "Repertoire de travail",
85                             ang = u"Working directory user file",
86     ),
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)"
90     ),
91     Consigne = SIMP(statut ="o", homo="information", typ="TXM",
92                     defaut = "All index are in Python numbering (Starting from 0)",
93     ),
94     INPUT_VARIABLE = FACT(statut = 'f', max = '**',
95                           fr = u"Variable d'entrée du calcul",
96                           ang = u"Computation input variable",
97
98         NAME = SIMP(statut = "o", typ = 'TXM',
99                     fr = u"Nom de la variable (format Python)",
100                     ang = u"Variable name (Python format)"
101         ),
102         VAR_INFO = FACT(statut = "o",
103                         fr = u'Variable du modèle Telemac2D',
104                         ang = u'Telemac2D model variable',
105
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")'
110             ),
111             DEFAULT_VALUE = SIMP(statut = "o", typ = 'TXM',
112                                  fr = u'Valeur par défaut',
113                                  ang = u'Default value',
114             ),
115             ZONE_DEF = FACT(statut = "o",
116                             ang = u'Variable definition area',
117                             fr = u'Zone de définition de la variable',
118
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',
123                 ),
124
125                 b_INDEX = BLOC(condition = "TYPE == 'INDEX'",
126                     INDEX = SIMP(statut = "o", typ = Tuple(3),
127                                  defaut = (0, 0, 0),
128                                  ang = "Index of the variable",
129                                  fr = u"Indice de la variable",
130                                  validators = VerifTypeTuple(('I', 'I', 'I')),
131                     ),
132                 ),
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]",
137                     ),
138                     Consigne = SIMP(statut ="o", homo="information", typ="TXM",
139                                     defaut = "Format [0,2:8,50:88,666]",
140                     ),
141                 ),
142                 b_POLYGON = BLOC(condition = "TYPE == 'POLYGON'",
143                     POLYGON = SIMP(statut = "o",
144                                    typ = Tuple(2),
145                                    max = '**',
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')),
151                     ),
152                 ),
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",
160                         ),
161                         SEPARATOR = SIMP(statut = "o", typ = 'TXM',
162                                          defaut = ',',
163                                          fr = u"Separateur pour le fichier de polygone",
164                                          ang = "Separator for the polygon file",
165                         ),
166                     ),
167                 ),
168             ),
169         ),
170     ),
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",
177         ),
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")',
185             ),
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')),
194                 ),
195             ),
196         ),
197     ),
198 )
199
200 TEXTE_NEW_JDC="TELEMAC2D()"