# -*- coding: utf-8 -*-
-###
-### This file is generated automatically by SALOME v7.8.0 with dump python functionality
-###
+import os
+HYDRO_SAMPLES = os.path.join( os.environ["HYDRO_ROOT_DIR"], "bin/salome/test/HYDRO")
import sys
import salome
salome.salome_init()
theStudy = salome.myStudy
-import salome_notebook
-notebook = salome_notebook.NoteBook(theStudy)
-#sys.path.insert( 0, r'/local00/home/B27118/projets/salome_hydro/bugs/V780H2016')
-
-###
-### HYDRO component
-###
+#----------------------
+# --- HYDRO
+#----------------------
from HYDROPy import *
from PyQt5.QtCore import *
for profil in seqProfs:
Stream_1.AddProfile(profil)
-Stream_1.SetDDZ( 0.200 )
+Stream_1.SetDDZ( 0.050 )
Stream_1.SetSpatialStep( 0.5 )
Stream_1.Update()
# Start the algorithm of the partition and assignment
Case_1.Update()
-riveGauche = hydro_doc.FindObjectByName( "Case_1_Reg_1" )
+Reg_riveGauche = hydro_doc.FindObjectByName( "Case_1_Reg_1" )
Case_1_Zone_1 = hydro_doc.FindObjectByName( "Case_1_Zone_1" )
Case_1_Zone_1.SetColor( QColor( 156, 192, 64 ))
-riveGauche.AddZone( Case_1_Zone_1 )
-litMineur = hydro_doc.FindObjectByName( "Case_1_Reg_2" )
+Reg_riveGauche.AddZone( Case_1_Zone_1 )
+Reg_litMineur = hydro_doc.FindObjectByName( "Case_1_Reg_2" )
Case_1_Zone_2 = hydro_doc.FindObjectByName( "Case_1_Zone_2" )
Case_1_Zone_2.SetMergeType( HYDROData_Zone.Merge_Object )
Stream_1_Altitude_1 = hydro_doc.FindObjectByName( "Stream_1_Altitude_1" )
Case_1_Zone_2.SetMergeObject( Stream_1_Altitude_1 )
Case_1_Zone_2.SetColor( QColor( 64, 75, 192 ))
-litMineur.AddZone( Case_1_Zone_2 )
-riveDroite = hydro_doc.FindObjectByName( "Case_1_Reg_3" )
+Reg_litMineur.AddZone( Case_1_Zone_2 )
+Reg_riveDroite = hydro_doc.FindObjectByName( "Case_1_Reg_3" )
Case_1_Zone_3 = hydro_doc.FindObjectByName( "Case_1_Zone_3" )
Case_1_Zone_3.SetColor( QColor( 192, 109, 64 ))
-riveDroite.AddZone( Case_1_Zone_3 )
-riveGauche.SetName( "riveGauche" )
-litMineur.SetName( "litMineur" )
-riveDroite.SetName( "riveDroite" )
+Reg_riveDroite.AddZone( Case_1_Zone_3 )
+Reg_riveGauche.SetName( "Reg_riveGauche" )
+Reg_litMineur.SetName( "Reg_litMineur" )
+Reg_riveDroite.SetName( "Reg_riveDroite" )
# Export of the calculation case
Case_1_entry = Case_1.Export( theStudy._get_StudyId() )
-# Get geometry shape and print debug information
-import GEOM
-print "Entry:", Case_1_entry
-HYDRO_Case_1 = salome.IDToObject( str( Case_1_entry ) )
-print "Geom shape:", HYDRO_Case_1
-print "Geom shape name:", HYDRO_Case_1.GetName()
-
-
-###
-### GEOM component
-###
+#----------------------
+# --- Geometry
+#----------------------
import GEOM
from salome.geom import geomBuilder
import math
import SALOMEDS
+from salome.hydrotools.controls import controlGeomProps
+# Get geometry shape and print debug information
+print "Entry:", Case_1_entry
+HYDRO_Case_1 = salome.IDToObject( str( Case_1_entry ) )
+print "Geom shape:", HYDRO_Case_1
+print "Geom shape name:", HYDRO_Case_1.GetName()
geompy = geomBuilder.New(theStudy)
-#geomObj_1 = geompy.RestoreShape("") # the shape string has not been dump for performance reason
-#[geomObj_2,geomObj_3,geomObj_4] = geompy.SubShapeAll(geomObj_1, geompy.ShapeType["FACE"])
-geomObj_5 = geompy.CreateGroup(geomObj_1, geompy.ShapeType["EDGE"])
-geompy.UnionIDs(geomObj_5, [4, 12, 19, 23, 25, 21, 14, 9])
-HYDRO_Case_1 = geompy.RestoreShape("") # the shape string has not been dump for performance reason
+# --- manual definition: geometrical faces
[riveGauche,litMineur,riveDroite] = geompy.SubShapeAll(HYDRO_Case_1, geompy.ShapeType["FACE"])
-#listSubShapeIDs = geompy.SubShapeAllIDs(HYDRO_Case_1, geompy.ShapeType["VERTEX"])
-#listSubShapeIDs = geompy.SubShapeAllIDs(HYDRO_Case_1, geompy.ShapeType["VERTEX"])
-#listSubShapeIDs = geompy.SubShapeAllIDs(HYDRO_Case_1, geompy.ShapeType["EDGE"])
-#listSubShapeIDs = geompy.SubShapeAllIDs(HYDRO_Case_1, geompy.ShapeType["EDGE"])
-#listSubShapeIDs = geompy.SubShapeAllIDs(HYDRO_Case_1, geompy.ShapeType["EDGE"])
-#listSubShapeIDs = geompy.SubShapeAllIDs(HYDRO_Case_1, geompy.ShapeType["EDGE"])
-#listSubShapeIDs = geompy.SubShapeAllIDs(HYDRO_Case_1, geompy.ShapeType["EDGE"])
-#listSubShapeIDs = geompy.SubShapeAllIDs(HYDRO_Case_1, geompy.ShapeType["EDGE"])
-#listSubShapeIDs = geompy.SubShapeAllIDs(HYDRO_Case_1, geompy.ShapeType["EDGE"])
-#listSubShapeIDs = geompy.SubShapeAllIDs(HYDRO_Case_1, geompy.ShapeType["EDGE"])
-#listSubShapeIDs = geompy.SubShapeAllIDs(HYDRO_Case_1, geompy.ShapeType["EDGE"])
-#listSubShapeIDs = geompy.SubShapeAllIDs(HYDRO_Case_1, geompy.ShapeType["EDGE"])
-#listSubShapeIDs = geompy.SubShapeAllIDs(HYDRO_Case_1, geompy.ShapeType["EDGE"])
-#listSubShapeIDs = geompy.SubShapeAllIDs(HYDRO_Case_1, geompy.ShapeType["EDGE"])
-#listSubShapeIDs = geompy.SubShapeAllIDs(HYDRO_Case_1, geompy.ShapeType["EDGE"])
+
+# --- manual definition: useful groups of edges
Case_1_plaine_Outer = geompy.CreateGroup(HYDRO_Case_1, geompy.ShapeType["EDGE"])
geompy.UnionIDs(Case_1_plaine_Outer, [4, 12, 19, 23, 25, 21, 14, 9])
sections = geompy.CreateGroup(HYDRO_Case_1, geompy.ShapeType["EDGE"])
geompy.UnionIDs(sections, [14, 12])
-geompy.addToStudy( HYDRO_Case_1, 'HYDRO_Case_1' )
+
+# --- publish in study
geompy.addToStudyInFather( HYDRO_Case_1, riveGauche, 'riveGauche' )
geompy.addToStudyInFather( HYDRO_Case_1, litMineur, 'litMineur' )
geompy.addToStudyInFather( HYDRO_Case_1, riveDroite, 'riveDroite' )
-geompy.addToStudyInFather( HYDRO_Case_1, Case_1_plaine_Outer, 'Case_1_plaine_Outer' )
geompy.addToStudyInFather( HYDRO_Case_1, sections, 'sections' )
-###
-### SMESH component
-###
+# --- basic properties control: edges length, surfaces
+
+controlGeomProps(geompy, riveGauche, 355.239855, 7755.628676)
+controlGeomProps(geompy, litMineur, 383.395884, 3432.296956)
+controlGeomProps(geompy, riveDroite, 419.214176, 2537.363869)
+
+#----------------------
+# --- Meshing
+#----------------------
+
+med_file = r'/tmp/plaine.med'
+try:
+ os.remove(med_file)
+except OSError:
+ pass
import SMESH, SALOMEDS
from salome.smesh import smeshBuilder
+from salome.hydrotools.controls import controlMeshStats, controlSubMeshStats
smesh = smeshBuilder.New(theStudy)
+
+# --- algorithms and hypothesis
plaine = smesh.Mesh(HYDRO_Case_1)
+
NETGEN_2D = plaine.Triangle(algo=smeshBuilder.NETGEN_1D2D)
NETGEN_2D_Parameters_1 = NETGEN_2D.Parameters()
NETGEN_2D_Parameters_1.SetMaxSize( 10 )
NETGEN_2D_Parameters_1.SetUseSurfaceCurvature( 1 )
NETGEN_2D_Parameters_1.SetFuseEdges( 1 )
NETGEN_2D_Parameters_1.SetQuadAllowed( 0 )
-Regular_1D = plaine.Segment(geom=litMineur)
-litMineur_1 = Regular_1D.GetSubMesh()
-Local_Length_1 = Regular_1D.LocalLength(3,None,1e-07)
-QuadFromMedialAxis_1D2D = plaine.Quadrangle(algo=smeshBuilder.QUAD_MA_PROJ,geom=litMineur)
-Regular_1D_1 = plaine.Segment(geom=sections)
-sections_1 = Regular_1D_1.GetSubMesh()
-Nb_Segments_1 = Regular_1D_1.NumberOfSegments(20)
-isDone = plaine.SetMeshOrder( [ [ sections_1, litMineur_1 ] ])
+algo2D_litMineur = plaine.Quadrangle(algo=smeshBuilder.QUADRANGLE,geom=litMineur)
+algo1D_litMineur = plaine.Segment(geom=litMineur)
+hypo1D_litMineur = algo1D_litMineur.NumberOfSegments(60)
+subMesh_litMineur = algo1D_litMineur.GetSubMesh()
+smesh.SetName(subMesh_litMineur, "litMineur")
+
+algo1D_sections = plaine.Segment(geom=sections)
+hypo1D_sections = algo1D_sections.NumberOfSegments(20)
+hypo1D_sections.SetDistrType( 0 )
+subMesh_sections = algo1D_sections.GetSubMesh()
+smesh.SetName(subMesh_sections, "sections")
+
+isDone = plaine.SetMeshOrder( [ [ subMesh_sections, subMesh_litMineur ] ])
+
+# --- compute mesh
isDone = plaine.Compute()
isDone = plaine.SplitQuadObject( plaine, 1 )
+isDone = plaine.ReorientObject( plaine )
+# --- geometrical groups of faces
riveGauche_1 = plaine.GroupOnGeom(riveGauche,'riveGauche',SMESH.FACE)
litMineur_2 = plaine.GroupOnGeom(litMineur,'litMineur',SMESH.FACE)
riveDroite_1 = plaine.GroupOnGeom(riveDroite,'riveDroite',SMESH.FACE)
+
+# --- geometrical groups of edges
Case_1_plaine_Outer_1 = plaine.GroupOnGeom(Case_1_plaine_Outer,'Case_1_plaine_Outer',SMESH.EDGE)
sections_2 = plaine.GroupOnGeom(sections,'sections',SMESH.EDGE)
+
+# --- geometrical groups of nodes
riveGauche_2 = plaine.GroupOnGeom(riveGauche,'riveGauche',SMESH.NODE)
litMineur_3 = plaine.GroupOnGeom(litMineur,'litMineur',SMESH.NODE)
riveDroite_2 = plaine.GroupOnGeom(riveDroite,'riveDroite',SMESH.NODE)
Case_1_plaine_Outer_2 = plaine.GroupOnGeom(Case_1_plaine_Outer,'Case_1_plaine_Outer',SMESH.NODE)
sections_3 = plaine.GroupOnGeom(sections,'sections',SMESH.NODE)
+
smesh.SetName(plaine, 'plaine')
+plaine.SetAutoColor( 1 )
try:
- plaine.ExportMED( r'plaine.med', 0, SMESH.MED_V2_2, 1, None ,1)
+ plaine.ExportMED( med_file, 0, SMESH.MED_V2_2, 1, None ,1)
except:
print 'ExportToMEDX() failed. Invalid file name?'
-#controlMeshStats(plaine, 6190, 691, 12201)
-#controlSubMeshStats(litMineur_2, 2384)
-#controlSubMeshStats(riveDroite_1, 2400)
-#controlSubMeshStats(riveGauche_1, 6585)
+controlMeshStats(plaine, 1680, 227, 3251)
+controlSubMeshStats(litMineur_2, 2400)
+controlSubMeshStats(riveDroite_1, 257)
+controlSubMeshStats(riveGauche_1, 580)
#----------------------
# --- Z interpolation with HYDRO
fichierMaillage = med_file
# --- dictionary [med group name] = region name
-dicoGroupeRegion= dict(litMineur = 'litMineur',
- riveDroite = 'riveDroite',
- riveGauche = 'riveGauche',
+dicoGroupeRegion= dict(litMineur = 'Reg_litMineur',
+ riveDroite = 'Reg_riveDroite',
+ riveGauche = 'Reg_riveGauche',
)
# --- value to use for Z when the node is not in a region (used to detect problems)
zUndef = 110
# --- 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': (100.0, 100.0, 100.0, 0.0, 100.0, 100.0),
+ 'riveGauche': (100.0, 100.0, 100.0, 0.0, 100.0, 100.0),
+ 'litMineur': (80.35, 100.0, 92.88, 4.82, 84.44, 100.0)}
controlStatZ(statz, refstatz)
# --- add a field on nodes of type double with z values, named "BOTTOM"