salome.salome_init()
theStudy = salome.myStudy
-
+
#----------------------
-# --- HYDRO
+# --- HYDRO
#----------------------
from HYDROPy import *
-from PyQt4.QtCore import *
-from PyQt4.QtGui import *
+from PyQt5.QtCore import *
+from PyQt5.QtGui import *
hydro_doc = HYDROData_Document.Document( theStudy._get_StudyId() )
Cloud_02.SetName( "Cloud_02" )
Cloud_02.SetAltitudesInverted( 0 )
-Cloud_02.ImportFromFile( os.path.join(HYDRO_SAMPLES, "Cloud_02.xyz" ))
+if not(Cloud_02.ImportFromFile( os.path.join(HYDRO_SAMPLES, "Cloud_02.xyz" ))):
+ raise ValueError('problem while loading bathymetry')
Cloud_02.Update()
garonne_point_L93.SetName( "garonne_point_L93" )
garonne_point_L93.SetAltitudesInverted( 0 )
-garonne_point_L93.ImportFromFile( os.path.join(HYDRO_SAMPLES, "garonne_point_L93.xyz" ))
+if not(garonne_point_L93.ImportFromFile( os.path.join(HYDRO_SAMPLES, "garonne_point_L93.xyz" ))):
+ raise ValueError('problem while loading bathymetry')
garonne_point_L93.Update()
garonne_1_litMineur = hydro_doc.FindObjectByName( "garonne_1_Reg_1" )
garonne_1_Zone_1 = hydro_doc.FindObjectByName( "garonne_1_Zone_1" )
garonne_1_Zone_1.SetMergeType( HYDROData_Zone.Merge_ZMIN )
+garonne_1_Zone_1.SetColor( QColor( 192, 113, 64 ))
garonne_1_litMineur.AddZone( garonne_1_Zone_1 )
+
garonne_1_riveDroite = hydro_doc.FindObjectByName( "garonne_1_Reg_2" )
garonne_1_Zone_2 = hydro_doc.FindObjectByName( "garonne_1_Zone_2" )
+garonne_1_Zone_2.SetColor( QColor( 141, 192, 64 ))
garonne_1_riveDroite.AddZone( garonne_1_Zone_2 )
+
garonne_1_Zone_3 = hydro_doc.FindObjectByName( "garonne_1_Zone_3" )
+garonne_1_Zone_3.SetMergeType( HYDROData_Zone.Merge_Object )
+Cloud_02 = hydro_doc.FindObjectByName( "Cloud_02" )
+garonne_1_Zone_3.SetMergeObject( Cloud_02 )
+garonne_1_Zone_3.SetColor( QColor( 64, 192, 77 ))
garonne_1_riveDroite.AddZone( garonne_1_Zone_3 )
+
garonne_1_riveGauche = hydro_doc.FindObjectByName( "garonne_1_Reg_3" )
garonne_1_Zone_4 = hydro_doc.FindObjectByName( "garonne_1_Zone_4" )
+garonne_1_Zone_4.SetMergeType( HYDROData_Zone.Merge_Object )
+Cloud_02 = hydro_doc.FindObjectByName( "Cloud_02" )
+garonne_1_Zone_4.SetMergeObject( Cloud_02 )
+garonne_1_Zone_4.SetColor( QColor( 64, 75, 192 ))
garonne_1_riveGauche.AddZone( garonne_1_Zone_4 )
+
garonne_1_Zone_5 = hydro_doc.FindObjectByName( "garonne_1_Zone_5" )
+garonne_1_Zone_5.SetColor( QColor( 64, 192, 77 ))
garonne_1_riveGauche.AddZone( garonne_1_Zone_5 )
garonne_1_litMineur.SetName("garonne_1_litMineur")
garonne_1_entry = garonne_1.Export( theStudy._get_StudyId() )
#----------------------
-# --- Geometry
+# --- Geometry
#----------------------
# Get geometry shape and print debug information
print "Geom shape:", HYDRO_garonne_1
print "Geom shape name:", HYDRO_garonne_1.GetName()
-# --- manual definition: geometrical faces
+# --- manual definition: geometrical faces
[riveGauche,litMineur,riveDroite] = geompy.ExtractShapes(HYDRO_garonne_1, geompy.ShapeType["FACE"], True)
# --- manual definition: useful groups of edges
garonne_1_litMineur_Outer = geompy.CreateGroup(HYDRO_garonne_1, geompy.ShapeType["EDGE"])
geompy.UnionIDs(garonne_1_litMineur_Outer, [7, 9])
garonne_1_domaineEtendu_Outer = geompy.CreateGroup(HYDRO_garonne_1, geompy.ShapeType["EDGE"])
-geompy.UnionIDs(garonne_1_domaineEtendu_Outer, [4, 11, 17, 24, 26, 28, 14, 19, 20, 22, 31, 39, 41, 33, 35, 37])
+geompy.UnionIDs(garonne_1_domaineEtendu_Outer, [7, 9, 14, 16, 18, 20, 22, 24, 27, 30, 32, 33])
aval = geompy.CreateGroup(HYDRO_garonne_1, geompy.ShapeType["EDGE"])
-geompy.UnionIDs(aval, [4])
+geompy.UnionIDs(aval, [7])
amont = geompy.CreateGroup(HYDRO_garonne_1, geompy.ShapeType["EDGE"])
-geompy.UnionIDs(amont, [11])
+geompy.UnionIDs(amont, [9])
SectionsGaronne = geompy.CreateGroup(HYDRO_garonne_1, geompy.ShapeType["EDGE"])
-geompy.UnionIDs(SectionsGaronne, [4, 11])
+geompy.UnionIDs(SectionsGaronne, [7, 9])
bordGaucheDomaine = geompy.CreateGroup(HYDRO_garonne_1, geompy.ShapeType["EDGE"])
-geompy.UnionIDs(bordGaucheDomaine, [14, 28, 20, 24, 19, 17, 26, 22])
+geompy.UnionIDs(bordGaucheDomaine, [27, 30, 32, 33])
bordDroiteDomaine = geompy.CreateGroup(HYDRO_garonne_1, geompy.ShapeType["EDGE"])
-geompy.UnionIDs(bordDroiteDomaine, [41, 35, 31, 33, 39, 37])
+geompy.UnionIDs(bordDroiteDomaine, [14, 16, 18, 20, 22, 24])
# --- publications dans l'étude
geompy.addToStudyInFather( HYDRO_garonne_1, riveGauche, 'riveGauche' )
geompy.addToStudyInFather( HYDRO_garonne_1, bordDroiteDomaine, 'bordDroiteDomaine' )
# --- basic properties control: edges length, surfaces
-controlGeomProps(geompy, riveGauche, 29149.36918, 35992556.454929)
-controlGeomProps(geompy, litMineur, 30337.548492, 3646827.749809)
-controlGeomProps(geompy, riveDroite, 32012.343241, 26177085.460092)
+controlGeomProps(geompy, riveGauche, 29149.36918, 35948828.352061)
+controlGeomProps(geompy, litMineur, 30337.548492, 3488480.304388)
+controlGeomProps(geompy, riveDroite, 32012.343241, 25998769.23615)
#----------------------
-# --- Meshing
+# --- Meshing
#----------------------
import SMESH, SALOMEDS
fichierMaillage = os.path.join(tmpdir, 'garonne_1.med')
garonne_1.ExportMED(fichierMaillage, 0, SMESH.MED_V2_2, 1, None ,1)
+mesures = garonne_1.GetMeshInfo()
+d= {}
+for key, value in mesures.iteritems():
+ d[str(key)] = value
+nbTriangles = d['Entity_Triangle']
+nbNodes = d['Entity_Node']
+
controlMeshStats(garonne_1, 3888, 475, 7597)
controlSubMeshStats(litMineur_2, 2384)
controlSubMeshStats(riveDroite_1, 2342)
salome.sg.updateObjBrowser(1)
#----------------------
-# --- Z interpolation with HYDRO
+# --- Z interpolation with HYDRO
#----------------------
from salome.hydrotools.interpolZ import interpolZ, createZfield2
riveDroite = 'garonne_1_riveDroite',
riveGauche = 'garonne_1_riveGauche',
)
-# --- value to use for Z when the node is not in a region (used to detect problems)
+# --- value to use for Z when the node is not in a region (used to detect problems)
zUndef = 80
# --- Z interpolation on the bathymety/altimetry on the mesh nodes
statz = interpolZ(nomCas, fichierMaillage, dicoGroupeRegion, zUndef)
-refstatz = {'riveDroite': (10.88, 32.47999954), 'riveGauche': (7.72, 71.38999939), 'litMineur': (2.06, 25.41)}
+#print statz
+refstatz = {'riveDroite': (10.88, 32.61, 24.17, 5.12, 17.57, 31.33, 0.25),
+ 'riveGauche': (7.72, 71.86, 24.51, 12.18, 12.90, 60.36, 0.25),
+ 'litMineur': (2.06, 25.41, 13.93, 4.33, 8.47, 21.78)}
controlStatZ(statz, refstatz)
# --- add a field on nodes of type double with z values, named "BOTTOM"
#----------------------
-# --- Telemac Calculation
+# --- Telemac Calculation
#----------------------
import shutil
PYTEL(CODE='telemac2d',
FICHIER_CAS='%s/init.cas',
REPERTOIRE_TRAVAIL='%s/work',
- ENTREE_MED=_F(FICHIER_MED='%s/garonne_1F.med',
+ ENTREE_MED=_F(FICHIER_MED='%s/garonne_1Z.med',
FICHIER_BCD='%s/condlim.bcd',),
- SORTIE_MED='%s/r2d_garonne_1F.med',);
+ SORTIE_MED='%s/r2d_garonne_1Z.med',);
""" % (tmpdir, tmpdir, tmpdir, tmpdir, tmpdir)
print jdc
from salome.hydro.study import jdc_to_dict
param_dict = jdc_to_dict(jdc, ["PYTEL", "_F"])
+# --- close xterm automatically after Telemac execution
+param_dict['batchExec'] = True
print param_dict
from salome.hydro.pytel.launcher import run_pytel
run_pytel(param_dict)
+
+from salome.hydrotools.controls import controlTelemacResult
+aMedResult = tmpdir + '/r2d_garonne_1Z.med'
+refstats = {'nbTriangles' : nbTriangles,
+ 'nbNodes' : nbNodes,
+ 'fieldNames':('DEBIT SCALAIRE', 'FOND', 'FROTTEMENT', "HAUTEUR D'EAU", 'NBRE DE COURANT', 'SURFACE LIBRE', 'VITESSE U', 'VITESSE V'),
+ 'iterations':[(0, -1), (1, -1), (2, -1), (3, -1), (4, -1), (5, -1)]
+ }
+controlTelemacResult(aMedResult, refstats)