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
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,
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
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"])
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)
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:
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)
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)
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)
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
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)
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)
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"])