From: Yoann AUDOUIN Date: Thu, 4 May 2017 07:55:08 +0000 (+0200) Subject: Modification for new interface of openturns + cleanup X-Git-Tag: Salome_8_3_Hydro_2_0rc1~14^2~13 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=45ed6248a534d447590c913f8b5668d2787a7a57;p=modules%2Fhydrosolver.git Modification for new interface of openturns + cleanup --- diff --git a/src/HYDRO/TELEMAC2D.py b/src/HYDRO/TELEMAC2D.py index beb9f4b..85f1f01 100644 --- a/src/HYDRO/TELEMAC2D.py +++ b/src/HYDRO/TELEMAC2D.py @@ -40,16 +40,16 @@ logger.setLevel(logging.DEBUG) from salome.kernel.parametric.compo_utils import \ create_input_dict, create_normal_parametric_output, create_error_parametric_output -from salome.hydro.telemac2d import Telemac2D -from salome.hydro.telemac2d.polygon import get_list_points_in_polygon +from TelApy.api.t2d import Telemac2D +from TelApy.tools.polygon import get_list_points_in_polygon from salome.hydro.study import jdc_to_dict, get_jdc_dict_var_as_tuple, HydroStudyEditor ################################################ class TELEMAC2D(HYDROSOLVER_ORB__POA.TELEMAC2D, dsccalcium.PyDSCComponent): - + lock = threading.Lock() - + """ Pour etre un composant SALOME cette classe Python doit avoir le nom du composant et heriter de la @@ -57,7 +57,7 @@ class TELEMAC2D(HYDROSOLVER_ORB__POA.TELEMAC2D, dsccalcium.PyDSCComponent): par omniidl et de la classe SALOME_ComponentPy_i qui porte les services generaux d'un composant SALOME """ - def __init__ ( self, orb, poa, contID, containerName, instanceName, + def __init__ ( self, orb, poa, contID, containerName, instanceName, interfaceName ): logger.info("__init__: " + containerName + ' ; ' + instanceName) dsccalcium.PyDSCComponent.__init__(self, orb, poa,contID, @@ -81,7 +81,7 @@ class TELEMAC2D(HYDROSOLVER_ORB__POA.TELEMAC2D, dsccalcium.PyDSCComponent): try: self.beginService("TELEMAC2D.Init") self.jdc_dict = self.get_jdc_dict_from_case(studyId, detCaseEntry) - + # Ugly hack to check if we are in OpenTURNS context or Mascaret coupling context if "VARIABLE_ENTREE" in self.jdc_dict: # Create variable mappings for OpenTURNS @@ -91,7 +91,7 @@ class TELEMAC2D(HYDROSOLVER_ORB__POA.TELEMAC2D, dsccalcium.PyDSCComponent): if not self.input_var_map.has_key(name): self.input_var_map[name] = [] self.input_var_map[name] += [Telemac2DInputVariable(input_var["VARIABLE_MODELE_T2D"])] - + self.output_var_map = {} for output_var in get_jdc_dict_var_as_tuple(self.jdc_dict, "VARIABLE_SORTIE"): t2d_output_var = Telemac2DOutputVariable(output_var["VARIABLE_T2D"]) @@ -109,7 +109,7 @@ class TELEMAC2D(HYDROSOLVER_ORB__POA.TELEMAC2D, dsccalcium.PyDSCComponent): TELEMAC2D.lock.acquire() salome.salome_init() TELEMAC2D.lock.release() - + # Get filenames from the case in Salome study ed = HydroStudyEditor(study_id) sobj = ed.editor.study.FindObjectID(case_entry) @@ -147,7 +147,7 @@ class TELEMAC2D(HYDROSOLVER_ORB__POA.TELEMAC2D, dsccalcium.PyDSCComponent): def Exec(self, paramInput): try: self.beginService("TELEMAC2D.Exec") - + # Save / restore state # Not used yet because time can not be reset #if self.saved_state is None: @@ -165,7 +165,7 @@ class TELEMAC2D(HYDROSOLVER_ORB__POA.TELEMAC2D, dsccalcium.PyDSCComponent): exec_mode = parameter.value logger.debug("ID: %s" % id) logger.debug("Execution mode: %s" % exec_mode) - + # Append id to result file name result_filename = self.jdc_dict.get("RESULTAT") or "r2d.slf" (result_filename_wo_ext, ext) = os.path.splitext(result_filename) @@ -296,7 +296,7 @@ class TELEMAC2D(HYDROSOLVER_ORB__POA.TELEMAC2D, dsccalcium.PyDSCComponent): z_min = sys.float_info.max (first, after_last) = border["points_id"] k = first - while k != after_last: + while k != after_last: nbor_k = self.t2d.get_integer('MODEL.NBOR', k) h_k = self.t2d.get_double('MODEL.WATERDEPTH', nbor_k) z_bottom_k = self.t2d.get_double('MODEL.BOTTOMELEVATION', nbor_k) @@ -319,7 +319,7 @@ class TELEMAC2D(HYDROSOLVER_ORB__POA.TELEMAC2D, dsccalcium.PyDSCComponent): zf_min = sys.float_info.max (first, after_last) = border["points_id"] k = first - while k != after_last: + while k != after_last: knext = self.t2d.get_integer('MODEL.KP1BOR', k) nbor_k = self.t2d.get_integer('MODEL.NBOR', k) nbor_knext = self.t2d.get_integer('MODEL.NBOR', knext) @@ -361,8 +361,8 @@ class TELEMAC2D(HYDROSOLVER_ORB__POA.TELEMAC2D, dsccalcium.PyDSCComponent): v_i = self.t2d.get_double('MODEL.VELOCITYV', idx) h_i = self.t2d.get_double('MODEL.WATERDEPTH', idx) v = math.sqrt(u_i**2 + v_i**2) - ##### TODO: Remove that and find the real error - if h_i <= 0.0: + ##### TODO: Remove that and find the real error + if h_i <= 0.0: print 'Error: water depth is negative or zero on point', idx #raise Exception('Null water depth value') h_i = 0.01 @@ -380,7 +380,7 @@ class TELEMAC2D(HYDROSOLVER_ORB__POA.TELEMAC2D, dsccalcium.PyDSCComponent): q = 0.0 (first, after_last) = border["points_id"] k = first - while k != after_last: + while k != after_last: knext = self.t2d.get_integer('MODEL.KP1BOR', k) nbor_k = self.t2d.get_integer('MODEL.NBOR', k) nbor_knext = self.t2d.get_integer('MODEL.NBOR', knext) @@ -412,7 +412,7 @@ class TELEMAC2D(HYDROSOLVER_ORB__POA.TELEMAC2D, dsccalcium.PyDSCComponent): q = 0.0 (first, after_last) = border["points_id"] k = first - while k != after_last: + while k != after_last: knext = self.t2d.get_integer('MODEL.KP1BOR', k) nbor_k = self.t2d.get_integer('MODEL.NBOR', k) nbor_knext = self.t2d.get_integer('MODEL.NBOR', knext) @@ -462,7 +462,7 @@ class TELEMAC2D(HYDROSOLVER_ORB__POA.TELEMAC2D, dsccalcium.PyDSCComponent): logger.debug("set z for border point %d, h:%f, zf:%f, z:%f" % (k, hbor_k, bottom_elevation, z)) k = self.t2d.get_integer('MODEL.KP1BOR', k) """ - + # Method 2: Just tell Telemac what is the imposed elevation for the border if z is not None: self.t2d.set_double('MODEL.COTE', z, border["border_id"]) diff --git a/src/salome_hydro/telemac2d/CMakeLists.txt b/src/salome_hydro/telemac2d/CMakeLists.txt index a4d3f5e..ffcf670 100644 --- a/src/salome_hydro/telemac2d/CMakeLists.txt +++ b/src/salome_hydro/telemac2d/CMakeLists.txt @@ -16,16 +16,3 @@ # along with SALOME HYDRO module. If not, see . ADD_SUBDIRECTORY(eficas) - -# --- Python files --- - -SET(PYFILES - __init__.py - polygon.py -) - -SET(INSTALL_DIR ${SALOME_INSTALL_PYTHON}/salome/hydro/telemac2d) - -# --- rules --- - -SALOME_INSTALL_SCRIPTS("${PYFILES}" ${INSTALL_DIR}) diff --git a/src/salome_hydro/telemac2d/__init__.py b/src/salome_hydro/telemac2d/__init__.py deleted file mode 100644 index e4b3bfd..0000000 --- a/src/salome_hydro/telemac2d/__init__.py +++ /dev/null @@ -1,16 +0,0 @@ -# Copyright (C) 2012-2013 EDF -# -# This file is part of SALOME HYDRO module. -# -# SALOME HYDRO module is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. -# -# SALOME HYDRO module is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with SALOME HYDRO module. If not, see .