Salome HOME
Yoann : Mise a jour Eficas V9_DEV
[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     del(model)
43     return sorted(varnames)
44
45 class Tuple:
46   def __init__(self,ntuple):
47     self.ntuple=ntuple
48
49   def __convert__(self,valeur):
50     if type(valeur) == types.StringType:
51       return None
52     if len(valeur) != self.ntuple:
53       return None
54     return valeur
55
56   def info(self):
57     return "Tuple de %s elements" % self.ntuple
58
59   __repr__=info
60   __str__=info
61
62 JdC = JDC_CATA(regles = (UN_PARMI('TELEMAC2D',)),
63                         )
64
65
66
67 TELEMAC2D = PROC(
68     nom = "TELEMAC2D", op = None,
69     fr = u"Définition d'un cas d'étude Telemac2D",
70     ang = u"Definition of a Telemac2D study case",
71     STEERING_FILE = SIMP(statut = "o", typ = 'Fichier',
72                        fr = u"Fichier de description du cas",
73                        ang = u"Case description file",
74     ),
75     USER_FORTRAN = SIMP(statut = "f", typ = 'FichierOuRepertoire',
76                         fr = "Fichier Fortran utilisateur",
77                         ang = u"Fortran user file",
78     ),
79     WORKING_DIRECTORY = SIMP(statut = "o", typ = 'Repertoire',
80                              defaut = '/tmp',
81                              fr = "Repertoire de travail",
82                              ang = u"Working directory user file",
83     ),
84     RESULT_DIRECTORY = SIMP(statut = "f", typ = 'Repertoire',
85                             fr = "Repertoire de travail",
86                             ang = u"Working directory user file",
87     ),
88     RESULTS_FILE_NAME = SIMP(statut = "f", typ = 'TXM',
89                              fr = u"Fichier des resultats (Ecrasera celui dans le fichier cas)",
90                              ang = u"Results file (Will replace the one in the steering file)"
91     ),
92     Consigne = SIMP(statut ="o", homo="information", typ="TXM",
93                     defaut = "All index are in Python numbering (Starting from 0)",
94     ),
95     INPUT_VARIABLE = FACT(statut = 'f', max = '**',
96                           fr = u"Variable d'entrée du calcul",
97                           ang = u"Computation input variable",
98
99         NAME = SIMP(statut = "o", typ = 'TXM',
100                     fr = u"Nom de la variable (format Python)",
101                     ang = u"Variable name (Python format)"
102         ),
103         VAR_INFO = FACT(statut = "o",
104                         fr = u'Variable du modèle Telemac2D',
105                         ang = u'Telemac2D model variable',
106
107             VAR_NAME = SIMP(statut = "o", typ = 'TXM',
108                             intoSug = get_list_var_api('TELEMAC2D'),
109                             fr = u'Nom de la variable du modèle (ex: "MODEL.DEBIT")',
110                             ang = u'Model variable name (ex: "MODEL.DEBIT")'
111             ),
112             DEFAULT_VALUE = SIMP(statut = "o", typ = 'TXM',
113                                  fr = u'Valeur par défaut',
114                                  ang = u'Default value',
115             ),
116             ZONE_DEF = FACT(statut = "o",
117                             ang = u'Variable definition area',
118                             fr = u'Zone de définition de la variable',
119
120                 TYPE = SIMP(statut = "o", typ = 'TXM',
121                             into = ['INDEX', 'RANGE', 'POLYGON', 'POLYGON_FILE'],
122                             fr = u'Type de definition de la variable',
123                             ang = u'Type of definition for the variable',
124                 ),
125
126                 b_INDEX = BLOC(condition = "TYPE == 'INDEX'",
127                     INDEX = SIMP(statut = "o", typ = Tuple(3),
128                                  defaut = (0, 0, 0),
129                                  ang = "Index of the variable",
130                                  fr = u"Indice de la variable",
131                                  validators = VerifTypeTuple(('I', 'I', 'I')),
132                     ),
133                 ),
134                 b_RANGE = BLOC(condition = "TYPE == 'RANGE'",
135                     RANGE = SIMP(statut = "o", typ = 'TXM',
136                                  fr = u"Liste d'index pour des tableaux à une dimension ex: [1,3:8,666]",
137                                  ang = "Range of index for one dimension arrays ex: [1,3:8,666]",
138                     ),
139                     Consigne = SIMP(statut ="o", homo="information", typ="TXM",
140                                     defaut = "Format [0,2:8,50:88,666]",
141                     ),
142                 ),
143                 b_POLYGON = BLOC(condition = "TYPE == 'POLYGON'",
144                     POLYGON = SIMP(statut = "o",
145                                    typ = Tuple(2),
146                                    max = '**',
147                                    fr = u"Liste des sommets (coordonnées X,Y) du "
148                                         u"polygone définissant le contour de la zone",
149                                    ang = "List of points (X,Y coordinates) of the "
150                                          "polygon defining the border of the area",
151                                    validators = VerifTypeTuple(('R', 'R')),
152                     ),
153                 ),
154                 b_POLYGON_FILE = BLOC(condition = "TYPE == 'POLYGON_FILE'",
155                     POLYGON_FILE = FACT(statut = "o",
156                                         fr = u"Polygon dans un fichier",
157                                         ang = "Polygone in a file",
158                         FILE_NAME = SIMP(statut = "o", typ = 'Fichier',
159                                          fr = u"Fichier contenant les info du polygone",
160                                          ang = "File containing the polygon info",
161                         ),
162                         SEPARATOR = SIMP(statut = "o", typ = 'TXM',
163                                          defaut = ',',
164                                          fr = u"Separateur pour le fichier de polygone",
165                                          ang = "Separator for the polygon file",
166                         ),
167                     ),
168                 ),
169             ),
170         ),
171     ),
172     OUTPUT_VARIABLE = FACT(statut = 'f', max = '**',
173                            fr = u"Variable de sortie du calcul",
174                            ang = u"Computation output variable",
175         NAME = SIMP(statut = "o", typ = 'TXM',
176                    fr = u"Nom de la variable",
177                    ang = u"Variable name",
178         ),
179         VAR_INFO = FACT(statut = "o",
180                         fr = u'Variable du modèle Telemac2D',
181                         ang = u'Telemac2D model variable',
182             VAR_NAME = SIMP(statut = "o", typ = 'TXM',
183                             intoSug = get_list_var_api('TELEMAC2D'),
184                             fr = u'Nom de la variable du modèle (ex: "MODEL.DEBIT")',
185                             ang = u'Model variable name (ex: "MODEL.DEBIT")',
186             ),
187             ZONE_DEF = FACT(statut = "o",
188                             ang = u'Variable definition area',
189                             fr = u'Zone de définition de la variable',
190                 INDEX = SIMP(statut = "o", typ = Tuple(3),
191                              defaut = (0, 0, 0, ),
192                              ang = "Index of the point / border",
193                              fr = u"Indice du point ou de la frontière",
194                              validators = VerifTypeTuple(('I', 'I', 'I')),
195                 ),
196             ),
197         ),
198     ),
199 )
200
201 TEXTE_NEW_JDC="TELEMAC2D()"