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