print "Geom shape:", HYDRO_garonne_1
print "Geom shape name:", HYDRO_garonne_1.GetName()
+
# --- 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, [7, 9, 14, 16, 18, 20, 22, 24, 27, 30, 32, 33])
-
-aval = geompy.CreateGroup(HYDRO_garonne_1, geompy.ShapeType["EDGE"])
-geompy.UnionIDs(aval, [7])
-amont = geompy.CreateGroup(HYDRO_garonne_1, geompy.ShapeType["EDGE"])
-geompy.UnionIDs(amont, [9])
+
+[garonne_litMineur,garonne_riveDroite,garonne_riveGauche] = geompy.SubShapeAll(HYDRO_garonne_1, geompy.ShapeType["FACE"])
+
+controlGeomProps(geompy, garonne_riveGauche, 29149.36918, 35948828.352061)
+controlGeomProps(geompy, garonne_litMineur, 30337.548492, 3488480.304388)
+controlGeomProps(geompy, garonne_riveDroite, 32012.343241, 25998769.23615)
+
+# --- manual identification of all useful edge groups (boundary conditions)
+
+allEdgesIds = geompy.SubShapeAllIDs(HYDRO_garonne_1, geompy.ShapeType["EDGE"])
+print "allEdgesIds", allEdgesIds
+
+(isDone, ClosedFreeBoundary, OpenFreeBoundary) = geompy.GetFreeBoundary(HYDRO_garonne_1)
+geompy.addToStudyInFather(HYDRO_garonne_1, ClosedFreeBoundary[0], "ClosedFreeBoundary")
+
+freeBoundary = geompy.ExtractShapes(ClosedFreeBoundary[0], geompy.ShapeType["EDGE"], True)
+freeBoundaryIds = [ geompy.GetSubShapeID(HYDRO_garonne_1, freeBoundary[i]) for i in range(len(freeBoundary)) ]
+print "freeBoundaryIds", freeBoundaryIds
+
+[litMineur_droite] = geompy.GetSharedShapesMulti([garonne_riveDroite, garonne_litMineur], geompy.ShapeType["EDGE"], True)
+[litMineur_gauche] = geompy.GetSharedShapesMulti([garonne_riveGauche, garonne_litMineur], geompy.ShapeType["EDGE"], True)
+geompy.addToStudyInFather(HYDRO_garonne_1, litMineur_droite, "litMineur_droite")
+geompy.addToStudyInFather(HYDRO_garonne_1, litMineur_gauche, "litMineur_gauche")
+rives = [litMineur_droite, litMineur_gauche]
+rivesIds = [ geompy.GetSubShapeID(HYDRO_garonne_1, rives[i]) for i in range(len(rives)) ]
+print "rivesIds", rivesIds
+
+edges_litMineur = geompy.GetSharedShapesMulti([HYDRO_garonne_1, garonne_litMineur], geompy.ShapeType["EDGE"], True)
+edges_riveGauche = geompy.GetSharedShapesMulti([HYDRO_garonne_1, garonne_riveGauche], geompy.ShapeType["EDGE"], True)
+edges_riveDroite = geompy.GetSharedShapesMulti([HYDRO_garonne_1, garonne_riveDroite], geompy.ShapeType["EDGE"], True)
+edges_litMineurIds = [ geompy.GetSubShapeID(HYDRO_garonne_1, edges_litMineur[i]) for i in range(len(edges_litMineur)) ]
+edges_riveGaucheIds = [ geompy.GetSubShapeID(HYDRO_garonne_1, edges_riveGauche[i]) for i in range(len(edges_riveGauche)) ]
+edges_riveDroiteIds = [ geompy.GetSubShapeID(HYDRO_garonne_1, edges_riveDroite[i]) for i in range(len(edges_riveDroite)) ]
+
+print "edges_litMineurIds", edges_litMineurIds
+print "edges_riveGaucheIds", edges_riveGaucheIds
+print "edges_riveDroiteIds", edges_riveDroiteIds
+
+sectionsIds = [Id for Id in edges_litMineurIds if Id not in rivesIds]
+print "sectionsIds", sectionsIds
SectionsGaronne = geompy.CreateGroup(HYDRO_garonne_1, geompy.ShapeType["EDGE"])
-geompy.UnionIDs(SectionsGaronne, [7, 9])
+geompy.UnionIDs(SectionsGaronne, sectionsIds)
+geompy.addToStudyInFather(HYDRO_garonne_1, SectionsGaronne, "SectionsGaronne")
+
+bordGaucheDomaineIds = [Id for Id in freeBoundaryIds if Id in edges_riveGaucheIds]
+bordDroiteDomaineIds = [Id for Id in freeBoundaryIds if Id in edges_riveDroiteIds]
+print "bordGaucheDomaineIds", bordGaucheDomaineIds
+print "bordDroiteDomaineIds", bordDroiteDomaineIds
bordGaucheDomaine = geompy.CreateGroup(HYDRO_garonne_1, geompy.ShapeType["EDGE"])
-geompy.UnionIDs(bordGaucheDomaine, [31, 34, 36, 38, 40, 41])
+geompy.UnionIDs(bordGaucheDomaine, bordGaucheDomaineIds)
+geompy.addToStudyInFather(HYDRO_garonne_1, bordGaucheDomaine, "bordGaucheDomaine")
bordDroiteDomaine = geompy.CreateGroup(HYDRO_garonne_1, geompy.ShapeType["EDGE"])
-geompy.UnionIDs(bordDroiteDomaine, [14, 17, 19, 21, 23, 25, 26, 28])
+geompy.UnionIDs(bordDroiteDomaine, bordDroiteDomaineIds)
+geompy.addToStudyInFather(HYDRO_garonne_1, bordDroiteDomaine, "bordDroiteDomaine")
-# --- publications dans l'étude
-geompy.addToStudyInFather( HYDRO_garonne_1, riveGauche, 'riveGauche' )
-geompy.addToStudyInFather( HYDRO_garonne_1, litMineur, 'litMineur' )
-geompy.addToStudyInFather( HYDRO_garonne_1, riveDroite, 'riveDroite' )
-geompy.addToStudyInFather( HYDRO_garonne_1, aval, 'aval' )
-geompy.addToStudyInFather( HYDRO_garonne_1, amont, 'amont' )
-geompy.addToStudyInFather( HYDRO_garonne_1, SectionsGaronne, 'SectionsGaronne' )
-geompy.addToStudyInFather( HYDRO_garonne_1, bordGaucheDomaine, 'bordGaucheDomaine' )
-geompy.addToStudyInFather( HYDRO_garonne_1, bordDroiteDomaine, 'bordDroiteDomaine' )
-
-# --- basic properties control: edges length, surfaces
-
-controlGeomProps(geompy, riveGauche, 29149.36918, 35948828.352061)
-controlGeomProps(geompy, litMineur, 30337.548492, 3488480.304388)
-controlGeomProps(geompy, riveDroite, 32012.343241, 25998769.23615)
+amont = geompy.GetEdgeNearPoint(HYDRO_garonne_1, geompy.MakeVertex(46757.861314, 25833.234752, 0))
+aval = geompy.GetEdgeNearPoint(HYDRO_garonne_1, geompy.MakeVertex(39078.979127, 32588.627279, 0))
+geompy.addToStudyInFather(HYDRO_garonne_1, amont, "amont")
+geompy.addToStudyInFather(HYDRO_garonne_1, aval, "aval")
#----------------------
# --- Meshing
#----------------------
-med_file = r'/tmp/garonne_1.med'
-try:
- os.remove(med_file)
-except OSError:
- pass
-
-
import SMESH, SALOMEDS
from salome.smesh import smeshBuilder
from salome.hydrotools.controls import controlMeshStats, controlSubMeshStats
+import tempfile
smesh = smeshBuilder.New(theStudy)
NETGEN_2D_Parameters.SetFuseEdges( 1 )
NETGEN_2D_Parameters.SetQuadAllowed( 0 )
-algo2D_litMineur = garonne_1.Quadrangle(algo=smeshBuilder.QUAD_MA_PROJ,geom=litMineur)
-algo1D_litMineur = garonne_1.Segment(geom=litMineur)
+algo2D_litMineur = garonne_1.Quadrangle(algo=smeshBuilder.QUAD_MA_PROJ,geom=garonne_litMineur)
+algo1D_litMineur = garonne_1.Segment(geom=garonne_litMineur)
hypo1D_litMineur = algo1D_litMineur.LocalLength(100,None,1e-07)
subMesh_litMineur = algo1D_litMineur.GetSubMesh()
smesh.SetName(subMesh_litMineur, "litMineur")
isDone = garonne_1.SplitQuadObject( garonne_1, 1 )
isDone = garonne_1.ReorientObject( garonne_1 )
+# --- geometrical groups of faces
+riveGauche_1 = garonne_1.GroupOnGeom(garonne_riveGauche,'riveGauche',SMESH.FACE)
+litMineur_1 = garonne_1.GroupOnGeom(garonne_litMineur,'litMineur',SMESH.FACE)
+riveDroite_1 = garonne_1.GroupOnGeom(garonne_riveDroite,'riveDroite',SMESH.FACE)
+
# --- geometrical groups of edges
-garonne_1_litMineur_Outer_1 = garonne_1.GroupOnGeom(garonne_1_litMineur_Outer,'garonne_1_litMineur_Outer',SMESH.EDGE)
-garonne_1_domaineEtendu_Outer_1 = garonne_1.GroupOnGeom(garonne_1_domaineEtendu_Outer,'garonne_1_domaineEtendu_Outer',SMESH.EDGE)
-aval_1 = garonne_1.GroupOnGeom(aval,'aval',SMESH.EDGE)
-amont_1 = garonne_1.GroupOnGeom(amont,'amont',SMESH.EDGE)
+
+ClosedFreeBoundary_1 = garonne_1.GroupOnGeom(ClosedFreeBoundary[0],'ClosedFreeBoundary',SMESH.EDGE)
+litMineur_droite_1 = garonne_1.GroupOnGeom(litMineur_droite,'litMineur_droite',SMESH.EDGE)
+litMineur_gauche_1 = garonne_1.GroupOnGeom(litMineur_gauche,'litMineur_gauche',SMESH.EDGE)
+SectionsGaronne_1 = garonne_1.GroupOnGeom(SectionsGaronne,'SectionsGaronne',SMESH.EDGE)
bordGaucheDomaine_1 = garonne_1.GroupOnGeom(bordGaucheDomaine,'bordGaucheDomaine',SMESH.EDGE)
bordDroiteDomaine_1 = garonne_1.GroupOnGeom(bordDroiteDomaine,'bordDroiteDomaine',SMESH.EDGE)
-SectionsGaronne_2 = garonne_1.GroupOnGeom(SectionsGaronne,'SectionsGaronne',SMESH.EDGE)
-
-# --- geometrical groups of faces
-riveGauche_1 = garonne_1.GroupOnGeom(riveGauche,'riveGauche',SMESH.FACE)
-litMineur_2 = garonne_1.GroupOnGeom(litMineur,'litMineur',SMESH.FACE)
-riveDroite_1 = garonne_1.GroupOnGeom(riveDroite,'riveDroite',SMESH.FACE)
+amont_1 = garonne_1.GroupOnGeom(amont,'amont',SMESH.EDGE)
+aval_1 = garonne_1.GroupOnGeom(aval,'aval',SMESH.EDGE)
# --- geometrical groups of nodes
-garonne_1_litMineur_Outer_2 = garonne_1.GroupOnGeom(garonne_1_litMineur_Outer,'garonne_1_litMineur_Outer',SMESH.NODE)
-garonne_1_domaineEtendu_Outer_2 = garonne_1.GroupOnGeom(garonne_1_domaineEtendu_Outer,'garonne_1_domaineEtendu_Outer',SMESH.NODE)
-riveGauche_2 = garonne_1.GroupOnGeom(riveGauche,'riveGauche',SMESH.NODE)
-litMineur_3 = garonne_1.GroupOnGeom(litMineur,'litMineur',SMESH.NODE)
-riveDroite_2 = garonne_1.GroupOnGeom(riveDroite,'riveDroite',SMESH.NODE)
-aval_2 = garonne_1.GroupOnGeom(aval,'aval',SMESH.NODE)
-amont_2 = garonne_1.GroupOnGeom(amont,'amont',SMESH.NODE)
+
+garonne_1_litMineur_2 = garonne_1.GroupOnGeom(garonne_litMineur,'garonne_1_litMineur',SMESH.NODE)
+garonne_1_riveDroite_2 = garonne_1.GroupOnGeom(garonne_riveDroite,'garonne_1_riveDroite',SMESH.NODE)
+garonne_1_riveGauche_2 = garonne_1.GroupOnGeom(garonne_riveGauche,'garonne_1_riveGauche',SMESH.NODE)
+ClosedFreeBoundary_2 = garonne_1.GroupOnGeom(ClosedFreeBoundary[0],'ClosedFreeBoundary',SMESH.NODE)
+litMineur_droite_2 = garonne_1.GroupOnGeom(litMineur_droite,'litMineur_droite',SMESH.NODE)
+litMineur_gauche_2 = garonne_1.GroupOnGeom(litMineur_gauche,'litMineur_gauche',SMESH.NODE)
+SectionsGaronne_2 = garonne_1.GroupOnGeom(SectionsGaronne,'SectionsGaronne',SMESH.NODE)
bordGaucheDomaine_2 = garonne_1.GroupOnGeom(bordGaucheDomaine,'bordGaucheDomaine',SMESH.NODE)
bordDroiteDomaine_2 = garonne_1.GroupOnGeom(bordDroiteDomaine,'bordDroiteDomaine',SMESH.NODE)
-SectionsGaronne_3 = garonne_1.GroupOnGeom(SectionsGaronne,'SectionsGaronne',SMESH.NODE)
+amont_2 = garonne_1.GroupOnGeom(amont,'amont',SMESH.NODE)
+aval_2 = garonne_1.GroupOnGeom(aval,'aval',SMESH.NODE)
garonne_1.SetAutoColor( 1 )
-garonne_1.ExportMED( med_file, 0, SMESH.MED_V2_2, 1, None ,1)
+tmpdir = tempfile.mkdtemp()
+print "tmpdir=",tmpdir
+fichierMaillage = os.path.join(tmpdir, 'garonne_1.med')
+garonne_1.ExportMED(fichierMaillage, 0, SMESH.MED_V2_2, 1, None ,1)
controlMeshStats(garonne_1, 3888, 475, 7597)
-controlSubMeshStats(litMineur_2, 2384)
+controlSubMeshStats(litMineur_1, 2384)
controlSubMeshStats(riveDroite_1, 2342)
controlSubMeshStats(riveGauche_1, 2871)
nomCas = 'garonne_1'
# --- med file 2D(x,y) of the case produced by SMESH
-fichierMaillage = med_file
# --- dictionary [med group name] = region name
dicoGroupeRegion= dict(litMineur = 'garonne_1_litMineur',
#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)}
+ '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"
-createZfield2(fichierMaillage)
-
-# --- create a field on nodes of type double with srtickler coefficient values, named "BOTTOM_FRICTION"
+#createZfield2(fichierMaillage)
+# --- create a field on nodes of type double with srtickler coefficient values, named "BOTTOM FRICTION"
from salome.hydrotools.interpolS import assignStrickler
-assignStrickler(nomCas, '/tmp/garonne_1F.med', '/tmp/garonne_1S.med')
+fichierFieldZ = os.path.join(tmpdir, 'garonne_1F.med')
+fichierFieldStrickler = os.path.join(tmpdir, 'garonne_1S.med')
+
+assignStrickler(nomCas, fichierFieldZ, fichierFieldStrickler)