From d7abcc094576f2a893056acfcd7fe13cb421f8bb Mon Sep 17 00:00:00 2001 From: Paul RASCLE Date: Sun, 28 May 2017 14:59:20 +0200 Subject: [PATCH] scripts autotests plus robustes pour l'identification des shapes --- doc/salome/examples/h009_normalCaseManual.py | 63 +++- .../examples/h010_normalCaseManualMesh.py | 153 +++++---- .../h011_normalCaseManualInterpolZ.py | 157 +++++---- doc/salome/examples/h012_caseDigueManual.py | 186 +++++++---- .../examples/h013_caseDigueManualMesh.py | 289 ++++++++++------ .../examples/h014_caseDigueManualInterpolZ.py | 314 +++++++++++------- .../examples/h015_normalCaseManualTelemac.py | 144 ++++---- ...h019_normalCaseManualInterpolZStrickler.py | 164 +++++---- 8 files changed, 909 insertions(+), 561 deletions(-) diff --git a/doc/salome/examples/h009_normalCaseManual.py b/doc/salome/examples/h009_normalCaseManual.py index 3650dd8c..7a2ef88c 100644 --- a/doc/salome/examples/h009_normalCaseManual.py +++ b/doc/salome/examples/h009_normalCaseManual.py @@ -327,11 +327,64 @@ HYDRO_garonne_1 = salome.IDToObject( str( garonne_1_entry ) ) print "Geom shape:", HYDRO_garonne_1 print "Geom shape name:", HYDRO_garonne_1.GetName() -[riveGauche,litMineur,riveDroite] = geompy.ExtractShapes(HYDRO_garonne_1, geompy.ShapeType["FACE"], True) - -controlGeomProps(geompy, riveGauche, 29149.36918, 35948828.352061) -controlGeomProps(geompy, litMineur, 30337.548492, 3488480.304388) -controlGeomProps(geompy, riveDroite, 32012.343241, 25998769.23615) +[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, 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, bordGaucheDomaineIds) +geompy.addToStudyInFather(HYDRO_garonne_1, bordGaucheDomaine, "bordGaucheDomaine") +bordDroiteDomaine = geompy.CreateGroup(HYDRO_garonne_1, geompy.ShapeType["EDGE"]) +geompy.UnionIDs(bordDroiteDomaine, bordDroiteDomaineIds) +geompy.addToStudyInFather(HYDRO_garonne_1, bordDroiteDomaine, "bordDroiteDomaine") + +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") if salome.sg.hasDesktop(): salome.sg.updateObjBrowser(1) diff --git a/doc/salome/examples/h010_normalCaseManualMesh.py b/doc/salome/examples/h010_normalCaseManualMesh.py index ae8198a2..b0115191 100644 --- a/doc/salome/examples/h010_normalCaseManualMesh.py +++ b/doc/salome/examples/h010_normalCaseManualMesh.py @@ -327,56 +327,74 @@ 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]) - -# --- 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.5484919, 3263628.55399) -#controlGeomProps(geompy, riveDroite, 32012.3432411, 26177085.4601) -controlGeomProps(geompy, litMineur, 30337.548492, 3488480.304388) -controlGeomProps(geompy, riveDroite, 32012.343241, 25998769.23615) +geompy.UnionIDs(bordDroiteDomaine, bordDroiteDomaineIds) +geompy.addToStudyInFather(HYDRO_garonne_1, bordDroiteDomaine, "bordDroiteDomaine") + +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) @@ -394,8 +412,8 @@ NETGEN_2D_Parameters.SetUseSurfaceCurvature( 1 ) 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") @@ -413,41 +431,44 @@ isDone = garonne_1.Compute() 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, 1763, 180, 3360) -#controlSubMeshStats(litMineur_2, 48) -#controlSubMeshStats(riveDroite_1, 1360) -#controlSubMeshStats(riveGauche_1, 1952) controlMeshStats(garonne_1, 3888, 475, 7597) -controlSubMeshStats(litMineur_2, 2384) +controlSubMeshStats(litMineur_1, 2384) controlSubMeshStats(riveDroite_1, 2342) controlSubMeshStats(riveGauche_1, 2871) diff --git a/doc/salome/examples/h011_normalCaseManualInterpolZ.py b/doc/salome/examples/h011_normalCaseManualInterpolZ.py index 1e875129..6c80a663 100644 --- a/doc/salome/examples/h011_normalCaseManualInterpolZ.py +++ b/doc/salome/examples/h011_normalCaseManualInterpolZ.py @@ -327,55 +327,74 @@ 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]) - -# --- 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' ) +geompy.UnionIDs(bordDroiteDomaine, bordDroiteDomaineIds) +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) @@ -393,8 +412,8 @@ NETGEN_2D_Parameters.SetUseSurfaceCurvature( 1 ) 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") @@ -412,37 +431,44 @@ isDone = garonne_1.Compute() 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) @@ -460,12 +486,11 @@ from salome.hydrotools.controls import controlStatZ 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', - riveDroite = 'garonne_1_riveDroite', - riveGauche = 'garonne_1_riveGauche', +dicoGroupeRegion= dict(garonne_1_litMineur = 'garonne_1_litMineur', + garonne_1_riveDroite = 'garonne_1_riveDroite', + garonne_1_riveGauche = 'garonne_1_riveGauche', ) # --- value to use for Z when the node is not in a region (used to detect problems) zUndef = 90 @@ -473,9 +498,9 @@ zUndef = 90 # --- Z interpolation on the bathymety/altimetry on the mesh nodes statz = interpolZ(nomCas, fichierMaillage, dicoGroupeRegion, zUndef) #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)} +refstatz = {'garonne_1_riveDroite': (10.88, 32.61, 24.17, 5.12, 17.57, 31.33, 0.25), + 'garonne_1_riveGauche': (7.72, 71.86, 24.51, 12.18, 12.90, 60.36, 0.25), + 'garonne_1_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" diff --git a/doc/salome/examples/h012_caseDigueManual.py b/doc/salome/examples/h012_caseDigueManual.py index 5e184af7..611c48fe 100644 --- a/doc/salome/examples/h012_caseDigueManual.py +++ b/doc/salome/examples/h012_caseDigueManual.py @@ -317,77 +317,77 @@ digue.Update(); # Calculation case -garonne_2 = hydro_doc.CreateObject( KIND_CALCULATION ) -garonne_2.SetName( "garonne_2" ) +garonne_1 = hydro_doc.CreateObject( KIND_CALCULATION ) +garonne_1.SetName( "garonne_1" ) -garonne_2.SetAssignmentMode( HYDROData_CalculationCase.MANUAL ) -garonne_2.AddGeometryObject( litMineur ) -garonne_2.AddGeometryObject( domaineEtendu ) -garonne_2.AddGeometryObject( litMajeur ) -garonne_2.AddGeometryObject( digue ); +garonne_1.SetAssignmentMode( HYDROData_CalculationCase.MANUAL ) +garonne_1.AddGeometryObject( litMineur ) +garonne_1.AddGeometryObject( domaineEtendu ) +garonne_1.AddGeometryObject( litMajeur ) +garonne_1.AddGeometryObject( digue ); case_geom_group = domaineEtendu.GetGroup( 0 ); -garonne_2.AddGeometryGroup( case_geom_group ); +garonne_1.AddGeometryGroup( case_geom_group ); case_geom_group = litMineur.GetGroup( 0 ); -garonne_2.AddGeometryGroup( case_geom_group ); +garonne_1.AddGeometryGroup( case_geom_group ); case_geom_group = litMajeur.GetGroup( 0 ); -garonne_2.AddGeometryGroup( case_geom_group ); +garonne_1.AddGeometryGroup( case_geom_group ); case_geom_group = digue.GetGroup( 2 ); -garonne_2.AddGeometryGroup( case_geom_group ); +garonne_1.AddGeometryGroup( case_geom_group ); case_geom_group = digue.GetGroup( 0 ); -garonne_2.AddGeometryGroup( case_geom_group ); +garonne_1.AddGeometryGroup( case_geom_group ); case_geom_group = digue.GetGroup( 3 ); -garonne_2.AddGeometryGroup( case_geom_group ); +garonne_1.AddGeometryGroup( case_geom_group ); case_geom_group = digue.GetGroup( 1 ); -garonne_2.AddGeometryGroup( case_geom_group ); -garonne_2.SetBoundaryPolyline( domaine ); +garonne_1.AddGeometryGroup( case_geom_group ); +garonne_1.SetBoundaryPolyline( domaine ); # Start the algorithm of the partition and assignment -garonne_2.Update() +garonne_1.Update() -garonne_2_litMineur = hydro_doc.FindObjectByName( "garonne_2_Reg_1" ) -garonne_2_Zone_1 = hydro_doc.FindObjectByName( "garonne_2_Zone_1" ) -garonne_2_Zone_1.SetMergeType( HYDROData_Zone.Merge_ZMIN ) -garonne_2_Zone_1.SetColor( QColor( 192, 137, 64 )) -garonne_2_litMineur.AddZone( garonne_2_Zone_1 ) +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, 137, 64 )) +garonne_1_litMineur.AddZone( garonne_1_Zone_1 ) -garonne_2_riveDroite = hydro_doc.FindObjectByName( "garonne_2_Reg_2" ) -garonne_2_Zone_2 = hydro_doc.FindObjectByName( "garonne_2_Zone_2" ) -garonne_2_Zone_2.SetColor( QColor( 64, 192, 98 )) -garonne_2_riveDroite.AddZone( garonne_2_Zone_2 ) +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( 64, 192, 98 )) +garonne_1_riveDroite.AddZone( garonne_1_Zone_2 ) -garonne_2_Zone_3 = hydro_doc.FindObjectByName( "garonne_2_Zone_3" ) -garonne_2_Zone_3.SetMergeType( HYDROData_Zone.Merge_Object ) +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_2_Zone_3.SetMergeObject( Cloud_02 ) -garonne_2_Zone_3.SetColor( QColor( 64, 66, 192 )) -garonne_2_riveDroite.AddZone( garonne_2_Zone_3 ) +garonne_1_Zone_3.SetMergeObject( Cloud_02 ) +garonne_1_Zone_3.SetColor( QColor( 64, 66, 192 )) +garonne_1_riveDroite.AddZone( garonne_1_Zone_3 ) -garonne_2_riveGauche = hydro_doc.FindObjectByName( "garonne_2_Reg_3" ) -garonne_2_Zone_4 = hydro_doc.FindObjectByName( "garonne_2_Zone_4" ) -garonne_2_Zone_4.SetMergeType( HYDROData_Zone.Merge_Object ) +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_2_Zone_4.SetMergeObject( Cloud_02 ) -garonne_2_Zone_4.SetColor( QColor( 64, 192, 164 )) -garonne_2_riveGauche.AddZone( garonne_2_Zone_4 ) +garonne_1_Zone_4.SetMergeObject( Cloud_02 ) +garonne_1_Zone_4.SetColor( QColor( 64, 192, 164 )) +garonne_1_riveGauche.AddZone( garonne_1_Zone_4 ) -garonne_2_Zone_5 = hydro_doc.FindObjectByName( "garonne_2_Zone_5" ) -garonne_2_Zone_5.SetColor( QColor( 192, 149, 64 )) -garonne_2_riveGauche.AddZone( garonne_2_Zone_5 ) +garonne_1_Zone_5 = hydro_doc.FindObjectByName( "garonne_1_Zone_5" ) +garonne_1_Zone_5.SetColor( QColor( 192, 149, 64 )) +garonne_1_riveGauche.AddZone( garonne_1_Zone_5 ) -garonne_2_digue = hydro_doc.FindObjectByName( "garonne_2_Reg_4" ) -garonne_2_Zone_6 = hydro_doc.FindObjectByName( "garonne_2_Zone_6" ) -garonne_2_Zone_6.SetMergeType( HYDROData_Zone.Merge_ZMAX ) -garonne_2_Zone_6.SetColor( QColor( 64, 192, 177 )) -garonne_2_digue.AddZone( garonne_2_Zone_6 ) +garonne_1_digue = hydro_doc.FindObjectByName( "garonne_1_Reg_4" ) +garonne_1_Zone_6 = hydro_doc.FindObjectByName( "garonne_1_Zone_6" ) +garonne_1_Zone_6.SetMergeType( HYDROData_Zone.Merge_ZMAX ) +garonne_1_Zone_6.SetColor( QColor( 64, 192, 177 )) +garonne_1_digue.AddZone( garonne_1_Zone_6 ) -garonne_2_litMineur.SetName("garonne_2_litMineur") -garonne_2_riveDroite.SetName("garonne_2_riveDroite") -garonne_2_riveGauche.SetName("garonne_2_riveGauche") -garonne_2_digue.SetName("garonne_2_digue") +garonne_1_litMineur.SetName("garonne_1_litMineur") +garonne_1_riveDroite.SetName("garonne_1_riveDroite") +garonne_1_riveGauche.SetName("garonne_1_riveGauche") +garonne_1_digue.SetName("garonne_1_digue") # Export of the calculation case -garonne_2_entry = garonne_2.Export( theStudy._get_StudyId() ) +garonne_1_entry = garonne_1.Export( theStudy._get_StudyId() ) #---------------------- # --- Geometry @@ -402,21 +402,79 @@ from salome.hydrotools.controls import controlGeomProps geompy = geomBuilder.New(theStudy) -print "Entry:", garonne_2_entry -HYDRO_garonne_2 = salome.IDToObject( str( garonne_2_entry ) ) -print "Geom shape:", HYDRO_garonne_2 -print "Geom shape name:", HYDRO_garonne_2.GetName() - -[riveGauche,digue,litMineur,riveDroite] = geompy.ExtractShapes(HYDRO_garonne_2, geompy.ShapeType["FACE"], True) -geompy.addToStudyInFather( HYDRO_garonne_2, riveGauche, 'riveGauche' ) -geompy.addToStudyInFather( HYDRO_garonne_2, digue, 'digue' ) -geompy.addToStudyInFather( HYDRO_garonne_2, litMineur, 'litMineur' ) -geompy.addToStudyInFather( HYDRO_garonne_2, riveDroite, 'riveDroite' ) - -controlGeomProps(geompy, riveGauche, 39490.835288, 35845737.590926) -controlGeomProps(geompy, digue, 10341.466108, 103090.760662) -controlGeomProps(geompy, litMineur, 30337.548492, 3488480.304388) -controlGeomProps(geompy, riveDroite, 32012.343241, 25998769.23615) +print "Entry:", garonne_1_entry +HYDRO_garonne_1 = salome.IDToObject( str( garonne_1_entry ) ) +print "Geom shape:", HYDRO_garonne_1 +print "Geom shape name:", HYDRO_garonne_1.GetName() + +[garonne_riveGauche,garonne_digue,garonne_litMineur,garonne_riveDroite] = geompy.ExtractShapes(HYDRO_garonne_1, geompy.ShapeType["FACE"], True) + +controlGeomProps(geompy, garonne_riveGauche, 39490.835288, 35845737.590926) +controlGeomProps(geompy, garonne_digue, 10341.466108, 103090.760662) +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, 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, bordGaucheDomaineIds) +geompy.addToStudyInFather(HYDRO_garonne_1, bordGaucheDomaine, "bordGaucheDomaine") +bordDroiteDomaine = geompy.CreateGroup(HYDRO_garonne_1, geompy.ShapeType["EDGE"]) +geompy.UnionIDs(bordDroiteDomaine, bordDroiteDomaineIds) +geompy.addToStudyInFather(HYDRO_garonne_1, bordDroiteDomaine, "bordDroiteDomaine") + +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") + +amontDigue = geompy.GetEdgeNearPoint(HYDRO_garonne_1, geompy.MakeVertex(44736.43, 29847.52, 0)) +avalDigue = geompy.GetEdgeNearPoint(HYDRO_garonne_1, geompy.MakeVertex(40961.39, 31800.95, 0)) +geompy.addToStudyInFather(HYDRO_garonne_1, amontDigue, "amontDigue") +geompy.addToStudyInFather(HYDRO_garonne_1, avalDigue, "avalDigue") + +SectionsDigue = geompy.CreateGroup(HYDRO_garonne_1, geompy.ShapeType["EDGE"]) +geompy.UnionIDs(SectionsDigue, [geompy.GetSubShapeID(HYDRO_garonne_1, amontDigue), geompy.GetSubShapeID(HYDRO_garonne_1, avalDigue)]) +geompy.addToStudyInFather( HYDRO_garonne_1, SectionsDigue, 'SectionsDigue' ) if salome.sg.hasDesktop(): salome.sg.updateObjBrowser(1) diff --git a/doc/salome/examples/h013_caseDigueManualMesh.py b/doc/salome/examples/h013_caseDigueManualMesh.py index 5b222ab3..7a306f06 100644 --- a/doc/salome/examples/h013_caseDigueManualMesh.py +++ b/doc/salome/examples/h013_caseDigueManualMesh.py @@ -317,77 +317,77 @@ digue.Update(); # Calculation case -garonne_2 = hydro_doc.CreateObject( KIND_CALCULATION ) -garonne_2.SetName( "garonne_2" ) +garonne_1 = hydro_doc.CreateObject( KIND_CALCULATION ) +garonne_1.SetName( "garonne_1" ) -garonne_2.SetAssignmentMode( HYDROData_CalculationCase.MANUAL ) -garonne_2.AddGeometryObject( litMineur ) -garonne_2.AddGeometryObject( domaineEtendu ) -garonne_2.AddGeometryObject( litMajeur ) -garonne_2.AddGeometryObject( digue ); +garonne_1.SetAssignmentMode( HYDROData_CalculationCase.MANUAL ) +garonne_1.AddGeometryObject( litMineur ) +garonne_1.AddGeometryObject( domaineEtendu ) +garonne_1.AddGeometryObject( litMajeur ) +garonne_1.AddGeometryObject( digue ); case_geom_group = domaineEtendu.GetGroup( 0 ); -garonne_2.AddGeometryGroup( case_geom_group ); +garonne_1.AddGeometryGroup( case_geom_group ); case_geom_group = litMineur.GetGroup( 0 ); -garonne_2.AddGeometryGroup( case_geom_group ); +garonne_1.AddGeometryGroup( case_geom_group ); case_geom_group = litMajeur.GetGroup( 0 ); -garonne_2.AddGeometryGroup( case_geom_group ); +garonne_1.AddGeometryGroup( case_geom_group ); case_geom_group = digue.GetGroup( 2 ); -garonne_2.AddGeometryGroup( case_geom_group ); +garonne_1.AddGeometryGroup( case_geom_group ); case_geom_group = digue.GetGroup( 0 ); -garonne_2.AddGeometryGroup( case_geom_group ); +garonne_1.AddGeometryGroup( case_geom_group ); case_geom_group = digue.GetGroup( 3 ); -garonne_2.AddGeometryGroup( case_geom_group ); +garonne_1.AddGeometryGroup( case_geom_group ); case_geom_group = digue.GetGroup( 1 ); -garonne_2.AddGeometryGroup( case_geom_group ); -garonne_2.SetBoundaryPolyline( domaine ); +garonne_1.AddGeometryGroup( case_geom_group ); +garonne_1.SetBoundaryPolyline( domaine ); # Start the algorithm of the partition and assignment -garonne_2.Update(); +garonne_1.Update(); -garonne_2_litMineur = hydro_doc.FindObjectByName( "garonne_2_Reg_1" ) -garonne_2_Zone_1 = hydro_doc.FindObjectByName( "garonne_2_Zone_1" ) -garonne_2_Zone_1.SetMergeType( HYDROData_Zone.Merge_ZMIN ) -garonne_2_Zone_1.SetColor( QColor( 192, 137, 64 )) -garonne_2_litMineur.AddZone( garonne_2_Zone_1 ) +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, 137, 64 )) +garonne_1_litMineur.AddZone( garonne_1_Zone_1 ) -garonne_2_riveDroite = hydro_doc.FindObjectByName( "garonne_2_Reg_2" ) -garonne_2_Zone_2 = hydro_doc.FindObjectByName( "garonne_2_Zone_2" ) -garonne_2_Zone_2.SetColor( QColor( 64, 192, 98 )) -garonne_2_riveDroite.AddZone( garonne_2_Zone_2 ) +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( 64, 192, 98 )) +garonne_1_riveDroite.AddZone( garonne_1_Zone_2 ) -garonne_2_Zone_3 = hydro_doc.FindObjectByName( "garonne_2_Zone_3" ) -garonne_2_Zone_3.SetMergeType( HYDROData_Zone.Merge_Object ) +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_2_Zone_3.SetMergeObject( Cloud_02 ) -garonne_2_Zone_3.SetColor( QColor( 64, 66, 192 )) -garonne_2_riveDroite.AddZone( garonne_2_Zone_3 ) +garonne_1_Zone_3.SetMergeObject( Cloud_02 ) +garonne_1_Zone_3.SetColor( QColor( 64, 66, 192 )) +garonne_1_riveDroite.AddZone( garonne_1_Zone_3 ) -garonne_2_riveGauche = hydro_doc.FindObjectByName( "garonne_2_Reg_3" ) -garonne_2_Zone_4 = hydro_doc.FindObjectByName( "garonne_2_Zone_4" ) -garonne_2_Zone_4.SetMergeType( HYDROData_Zone.Merge_Object ) +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_2_Zone_4.SetMergeObject( Cloud_02 ) -garonne_2_Zone_4.SetColor( QColor( 64, 192, 164 )) -garonne_2_riveGauche.AddZone( garonne_2_Zone_4 ) +garonne_1_Zone_4.SetMergeObject( Cloud_02 ) +garonne_1_Zone_4.SetColor( QColor( 64, 192, 164 )) +garonne_1_riveGauche.AddZone( garonne_1_Zone_4 ) -garonne_2_Zone_5 = hydro_doc.FindObjectByName( "garonne_2_Zone_5" ) -garonne_2_Zone_5.SetColor( QColor( 192, 149, 64 )) -garonne_2_riveGauche.AddZone( garonne_2_Zone_5 ) +garonne_1_Zone_5 = hydro_doc.FindObjectByName( "garonne_1_Zone_5" ) +garonne_1_Zone_5.SetColor( QColor( 192, 149, 64 )) +garonne_1_riveGauche.AddZone( garonne_1_Zone_5 ) -garonne_2_digue = hydro_doc.FindObjectByName( "garonne_2_Reg_4" ) -garonne_2_Zone_6 = hydro_doc.FindObjectByName( "garonne_2_Zone_6" ) -garonne_2_Zone_6.SetMergeType( HYDROData_Zone.Merge_ZMAX ) -garonne_2_Zone_6.SetColor( QColor( 64, 192, 177 )) -garonne_2_digue.AddZone( garonne_2_Zone_6 ) +garonne_1_digue = hydro_doc.FindObjectByName( "garonne_1_Reg_4" ) +garonne_1_Zone_6 = hydro_doc.FindObjectByName( "garonne_1_Zone_6" ) +garonne_1_Zone_6.SetMergeType( HYDROData_Zone.Merge_ZMAX ) +garonne_1_Zone_6.SetColor( QColor( 64, 192, 177 )) +garonne_1_digue.AddZone( garonne_1_Zone_6 ) -garonne_2_litMineur.SetName("garonne_2_litMineur") -garonne_2_riveDroite.SetName("garonne_2_riveDroite") -garonne_2_riveGauche.SetName("garonne_2_riveGauche") -garonne_2_digue.SetName("garonne_2_digue") +garonne_1_litMineur.SetName("garonne_1_litMineur") +garonne_1_riveDroite.SetName("garonne_1_riveDroite") +garonne_1_riveGauche.SetName("garonne_1_riveGauche") +garonne_1_digue.SetName("garonne_1_digue") # Export of the calculation case -garonne_2_entry = garonne_2.Export( theStudy._get_StudyId() ) +garonne_1_entry = garonne_1.Export( theStudy._get_StudyId() ) #---------------------- # --- Geometry @@ -402,29 +402,80 @@ from salome.hydrotools.controls import controlGeomProps geompy = geomBuilder.New(theStudy) -print "Entry:", garonne_2_entry -HYDRO_garonne_2 = salome.IDToObject( str( garonne_2_entry ) ) -print "Geom shape:", HYDRO_garonne_2 -print "Geom shape name:", HYDRO_garonne_2.GetName() +print "Entry:", garonne_1_entry +HYDRO_garonne_1 = salome.IDToObject( str( garonne_1_entry ) ) +print "Geom shape:", HYDRO_garonne_1 +print "Geom shape name:", HYDRO_garonne_1.GetName() + +[garonne_riveGauche,garonne_digue,garonne_litMineur,garonne_riveDroite] = geompy.ExtractShapes(HYDRO_garonne_1, geompy.ShapeType["FACE"], True) + +controlGeomProps(geompy, garonne_riveGauche, 39490.835288, 35845737.590926) +controlGeomProps(geompy, garonne_digue, 10341.466108, 103090.760662) +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, 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, bordGaucheDomaineIds) +geompy.addToStudyInFather(HYDRO_garonne_1, bordGaucheDomaine, "bordGaucheDomaine") +bordDroiteDomaine = geompy.CreateGroup(HYDRO_garonne_1, geompy.ShapeType["EDGE"]) +geompy.UnionIDs(bordDroiteDomaine, bordDroiteDomaineIds) +geompy.addToStudyInFather(HYDRO_garonne_1, bordDroiteDomaine, "bordDroiteDomaine") + +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") + +amontDigue = geompy.GetEdgeNearPoint(HYDRO_garonne_1, geompy.MakeVertex(44736.43, 29847.52, 0)) +avalDigue = geompy.GetEdgeNearPoint(HYDRO_garonne_1, geompy.MakeVertex(40961.39, 31800.95, 0)) +geompy.addToStudyInFather(HYDRO_garonne_1, amontDigue, "amontDigue") +geompy.addToStudyInFather(HYDRO_garonne_1, avalDigue, "avalDigue") + +SectionsDigue = geompy.CreateGroup(HYDRO_garonne_1, geompy.ShapeType["EDGE"]) +geompy.UnionIDs(SectionsDigue, [geompy.GetSubShapeID(HYDRO_garonne_1, amontDigue), geompy.GetSubShapeID(HYDRO_garonne_1, avalDigue)]) +geompy.addToStudyInFather( HYDRO_garonne_1, SectionsDigue, 'SectionsDigue' ) -[riveGauche,digue,litMineur,riveDroite] = geompy.ExtractShapes(HYDRO_garonne_2, geompy.ShapeType["FACE"], True) -geompy.addToStudyInFather( HYDRO_garonne_2, riveGauche, 'riveGauche' ) -geompy.addToStudyInFather( HYDRO_garonne_2, digue, 'digue' ) -geompy.addToStudyInFather( HYDRO_garonne_2, litMineur, 'litMineur' ) -geompy.addToStudyInFather( HYDRO_garonne_2, riveDroite, 'riveDroite' ) - -SectionsGaronne = geompy.CreateGroup(HYDRO_garonne_2, geompy.ShapeType["EDGE"]) -geompy.UnionIDs(SectionsGaronne, [7, 9]) -geompy.addToStudyInFather( HYDRO_garonne_2, SectionsGaronne, 'SectionsGaronne' ) - -SectionsDigue = geompy.CreateGroup(HYDRO_garonne_2, geompy.ShapeType["EDGE"]) -geompy.UnionIDs(SectionsDigue, [43, 48]) -geompy.addToStudyInFather( HYDRO_garonne_2, SectionsDigue, 'SectionsDigue' ) - -controlGeomProps(geompy, riveGauche, 39490.835288, 35845737.590926) -controlGeomProps(geompy, digue, 10341.466108, 103090.760662) -controlGeomProps(geompy, litMineur, 30337.548492, 3488480.304388) -controlGeomProps(geompy, riveDroite, 32012.343241, 25998769.23615) #---------------------- # --- Meshing @@ -433,13 +484,14 @@ controlGeomProps(geompy, riveDroite, 32012.343241, 25998769.23615) import SMESH, SALOMEDS from salome.smesh import smeshBuilder from salome.hydrotools.controls import controlMeshStats, controlSubMeshStats +import tempfile smesh = smeshBuilder.New(theStudy) # --- algorithms and hypothesis -garonne_2 = smesh.Mesh(HYDRO_garonne_2) +garonne_1 = smesh.Mesh(HYDRO_garonne_1) -NETGEN_2D = garonne_2.Triangle(algo=smeshBuilder.NETGEN_1D2D) +NETGEN_2D = garonne_1.Triangle(algo=smeshBuilder.NETGEN_1D2D) NETGEN_2D_Parameters = NETGEN_2D.Parameters() NETGEN_2D_Parameters.SetMaxSize( 200 ) NETGEN_2D_Parameters.SetSecondOrder( 0 ) @@ -450,67 +502,84 @@ NETGEN_2D_Parameters.SetUseSurfaceCurvature( 1 ) NETGEN_2D_Parameters.SetFuseEdges( 1 ) NETGEN_2D_Parameters.SetQuadAllowed( 0 ) -algo2D_litMineur = garonne_2.Quadrangle(algo=smeshBuilder.QUAD_MA_PROJ,geom=litMineur) -algo1D_litMineur = garonne_2.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") -algo1D_SectionsGaronne = garonne_2.Segment(geom=SectionsGaronne) +algo1D_SectionsGaronne = garonne_1.Segment(geom=SectionsGaronne) hypo1D_SectionsGaronne = algo1D_SectionsGaronne.NumberOfSegments(8) hypo1D_SectionsGaronne.SetDistrType( 0 ) subMesh_SectionsGaronne = algo1D_SectionsGaronne.GetSubMesh() smesh.SetName(subMesh_SectionsGaronne, "SectionsGaronne") -algo2D_digue = garonne_2.Quadrangle(algo=smeshBuilder.QUAD_MA_PROJ,geom=digue) -algo1D_digue = garonne_2.Segment(geom=digue) +algo2D_digue = garonne_1.Quadrangle(algo=smeshBuilder.QUAD_MA_PROJ,geom=garonne_digue) +algo1D_digue = garonne_1.Segment(geom=garonne_digue) hypo1D_digue = algo1D_digue.LocalLength(50,None,1e-07) subMesh_digue = algo1D_digue.GetSubMesh() smesh.SetName(subMesh_digue, "digue") -algo1D_SectionsDigue = garonne_2.Segment(geom=SectionsDigue) +algo1D_SectionsDigue = garonne_1.Segment(geom=SectionsDigue) hypo1D_SectionsDigue = algo1D_SectionsDigue.NumberOfSegments(4) hypo1D_SectionsDigue.SetDistrType( 0 ) subMesh_SectionsDigue = algo1D_SectionsDigue.GetSubMesh() smesh.SetName(subMesh_SectionsDigue, "SectionsDigue") -isDone = garonne_2.SetMeshOrder( [ [ subMesh_SectionsGaronne, subMesh_litMineur ], [ subMesh_SectionsDigue, subMesh_digue ]]) +isDone = garonne_1.SetMeshOrder( [ [ subMesh_SectionsGaronne, subMesh_litMineur ], [ subMesh_SectionsDigue, subMesh_digue ]]) # --- compute mesh -isDone = garonne_2.Compute() -isDone = garonne_2.SplitQuadObject( garonne_2, 1 ) -isDone = garonne_2.ReorientObject( garonne_2 ) - -# --- geometrical groups of edges -SectionsGaronne_2 = garonne_2.GroupOnGeom(SectionsGaronne,'SectionsGaronne',SMESH.EDGE) -SectionsDigue_2 = garonne_2.GroupOnGeom(SectionsDigue,'SectionsDigue',SMESH.EDGE) +isDone = garonne_1.Compute() +isDone = garonne_1.SplitQuadObject( garonne_1, 1 ) +isDone = garonne_1.ReorientObject( garonne_1 ) # --- geometrical groups of faces -riveGauche_1 = garonne_2.GroupOnGeom(riveGauche,'riveGauche',SMESH.FACE) -litMineur_2 = garonne_2.GroupOnGeom(litMineur,'litMineur',SMESH.FACE) -riveDroite_1 = garonne_2.GroupOnGeom(riveDroite,'riveDroite',SMESH.FACE) -digue_1 = garonne_2.GroupOnGeom(digue,'digue',SMESH.FACE) - -# --- geometrical groups of nodes -riveGauche_2 = garonne_2.GroupOnGeom(riveGauche,'riveGauche',SMESH.NODE) -litMineur_3 = garonne_2.GroupOnGeom(litMineur,'litMineur',SMESH.NODE) -riveDroite_2 = garonne_2.GroupOnGeom(riveDroite,'riveDroite',SMESH.NODE) -digue_2 = garonne_2.GroupOnGeom(digue,'digue',SMESH.NODE) -SectionsGaronne_3 = garonne_2.GroupOnGeom(SectionsGaronne,'SectionsGaronne',SMESH.NODE) - - -med_file = r'/tmp/garonne_2.med' +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) +digue_1 = garonne_1.GroupOnGeom(garonne_digue,'digue',SMESH.FACE) -try: - os.remove(med_file) -except OSError: - pass - -garonne_2.SetAutoColor( 1 ) -garonne_2.ExportMED( med_file, 0, SMESH.MED_V2_2, 1, None ,1) +# --- geometrical groups of edges +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) +amont_1 = garonne_1.GroupOnGeom(amont,'amont',SMESH.EDGE) +aval_1 = garonne_1.GroupOnGeom(aval,'aval',SMESH.EDGE) +SectionsDigue_1 = garonne_1.GroupOnGeom(SectionsDigue,'SectionsDigue',SMESH.EDGE) -controlMeshStats(garonne_2, 6190, 691, 12201) -controlSubMeshStats(litMineur_2, 2384) +# --- geometrical groups of nodes +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) +garonne_1_digue_2 = garonne_1.GroupOnGeom(garonne_digue,'garonne_1_digue',SMESH.FACE) +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) +amont_2 = garonne_1.GroupOnGeom(amont,'amont',SMESH.NODE) +aval_2 = garonne_1.GroupOnGeom(aval,'aval',SMESH.NODE) +SectionsDigue_2 = garonne_1.GroupOnGeom(SectionsDigue,'SectionsDigue',SMESH.NODE) + +garonne_1.SetAutoColor( 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) + +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, 6190, 691, 12201) +controlSubMeshStats(litMineur_1, 2384) controlSubMeshStats(riveDroite_1, 2400) controlSubMeshStats(riveGauche_1, 6585) controlSubMeshStats(digue_1, 832) diff --git a/doc/salome/examples/h014_caseDigueManualInterpolZ.py b/doc/salome/examples/h014_caseDigueManualInterpolZ.py index b3780686..9980a29c 100644 --- a/doc/salome/examples/h014_caseDigueManualInterpolZ.py +++ b/doc/salome/examples/h014_caseDigueManualInterpolZ.py @@ -317,77 +317,77 @@ digue.Update(); # Calculation case -garonne_2 = hydro_doc.CreateObject( KIND_CALCULATION ) -garonne_2.SetName( "garonne_2" ) +garonne_1 = hydro_doc.CreateObject( KIND_CALCULATION ) +garonne_1.SetName( "garonne_1" ) -garonne_2.SetAssignmentMode( HYDROData_CalculationCase.MANUAL ) -garonne_2.AddGeometryObject( litMineur ) -garonne_2.AddGeometryObject( domaineEtendu ) -garonne_2.AddGeometryObject( litMajeur ) -garonne_2.AddGeometryObject( digue ); +garonne_1.SetAssignmentMode( HYDROData_CalculationCase.MANUAL ) +garonne_1.AddGeometryObject( litMineur ) +garonne_1.AddGeometryObject( domaineEtendu ) +garonne_1.AddGeometryObject( litMajeur ) +garonne_1.AddGeometryObject( digue ); case_geom_group = domaineEtendu.GetGroup( 0 ); -garonne_2.AddGeometryGroup( case_geom_group ); +garonne_1.AddGeometryGroup( case_geom_group ); case_geom_group = litMineur.GetGroup( 0 ); -garonne_2.AddGeometryGroup( case_geom_group ); +garonne_1.AddGeometryGroup( case_geom_group ); case_geom_group = litMajeur.GetGroup( 0 ); -garonne_2.AddGeometryGroup( case_geom_group ); +garonne_1.AddGeometryGroup( case_geom_group ); case_geom_group = digue.GetGroup( 2 ); -garonne_2.AddGeometryGroup( case_geom_group ); +garonne_1.AddGeometryGroup( case_geom_group ); case_geom_group = digue.GetGroup( 0 ); -garonne_2.AddGeometryGroup( case_geom_group ); +garonne_1.AddGeometryGroup( case_geom_group ); case_geom_group = digue.GetGroup( 3 ); -garonne_2.AddGeometryGroup( case_geom_group ); +garonne_1.AddGeometryGroup( case_geom_group ); case_geom_group = digue.GetGroup( 1 ); -garonne_2.AddGeometryGroup( case_geom_group ); -garonne_2.SetBoundaryPolyline( domaine ); +garonne_1.AddGeometryGroup( case_geom_group ); +garonne_1.SetBoundaryPolyline( domaine ); # Start the algorithm of the partition and assignment -garonne_2.Update(); +garonne_1.Update(); -garonne_2_litMineur = hydro_doc.FindObjectByName( "garonne_2_Reg_1" ) -garonne_2_Zone_1 = hydro_doc.FindObjectByName( "garonne_2_Zone_1" ) -garonne_2_Zone_1.SetMergeType( HYDROData_Zone.Merge_ZMIN ) -garonne_2_Zone_1.SetColor( QColor( 192, 137, 64 )) -garonne_2_litMineur.AddZone( garonne_2_Zone_1 ) +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, 137, 64 )) +garonne_1_litMineur.AddZone( garonne_1_Zone_1 ) -garonne_2_riveDroite = hydro_doc.FindObjectByName( "garonne_2_Reg_2" ) -garonne_2_Zone_2 = hydro_doc.FindObjectByName( "garonne_2_Zone_2" ) -garonne_2_Zone_2.SetColor( QColor( 64, 192, 98 )) -garonne_2_riveDroite.AddZone( garonne_2_Zone_2 ) +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( 64, 192, 98 )) +garonne_1_riveDroite.AddZone( garonne_1_Zone_2 ) -garonne_2_Zone_3 = hydro_doc.FindObjectByName( "garonne_2_Zone_3" ) -garonne_2_Zone_3.SetMergeType( HYDROData_Zone.Merge_Object ) +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_2_Zone_3.SetMergeObject( Cloud_02 ) -garonne_2_Zone_3.SetColor( QColor( 64, 66, 192 )) -garonne_2_riveDroite.AddZone( garonne_2_Zone_3 ) +garonne_1_Zone_3.SetMergeObject( Cloud_02 ) +garonne_1_Zone_3.SetColor( QColor( 64, 66, 192 )) +garonne_1_riveDroite.AddZone( garonne_1_Zone_3 ) -garonne_2_riveGauche = hydro_doc.FindObjectByName( "garonne_2_Reg_3" ) -garonne_2_Zone_4 = hydro_doc.FindObjectByName( "garonne_2_Zone_4" ) -garonne_2_Zone_4.SetMergeType( HYDROData_Zone.Merge_Object ) +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_2_Zone_4.SetMergeObject( Cloud_02 ) -garonne_2_Zone_4.SetColor( QColor( 64, 192, 164 )) -garonne_2_riveGauche.AddZone( garonne_2_Zone_4 ) +garonne_1_Zone_4.SetMergeObject( Cloud_02 ) +garonne_1_Zone_4.SetColor( QColor( 64, 192, 164 )) +garonne_1_riveGauche.AddZone( garonne_1_Zone_4 ) -garonne_2_Zone_5 = hydro_doc.FindObjectByName( "garonne_2_Zone_5" ) -garonne_2_Zone_5.SetColor( QColor( 192, 149, 64 )) -garonne_2_riveGauche.AddZone( garonne_2_Zone_5 ) +garonne_1_Zone_5 = hydro_doc.FindObjectByName( "garonne_1_Zone_5" ) +garonne_1_Zone_5.SetColor( QColor( 192, 149, 64 )) +garonne_1_riveGauche.AddZone( garonne_1_Zone_5 ) -garonne_2_digue = hydro_doc.FindObjectByName( "garonne_2_Reg_4" ) -garonne_2_Zone_6 = hydro_doc.FindObjectByName( "garonne_2_Zone_6" ) -garonne_2_Zone_6.SetMergeType( HYDROData_Zone.Merge_ZMAX ) -garonne_2_Zone_6.SetColor( QColor( 64, 192, 177 )) -garonne_2_digue.AddZone( garonne_2_Zone_6 ) +garonne_1_digue = hydro_doc.FindObjectByName( "garonne_1_Reg_4" ) +garonne_1_Zone_6 = hydro_doc.FindObjectByName( "garonne_1_Zone_6" ) +garonne_1_Zone_6.SetMergeType( HYDROData_Zone.Merge_ZMAX ) +garonne_1_Zone_6.SetColor( QColor( 64, 192, 177 )) +garonne_1_digue.AddZone( garonne_1_Zone_6 ) -garonne_2_litMineur.SetName("garonne_2_litMineur") -garonne_2_riveDroite.SetName("garonne_2_riveDroite") -garonne_2_riveGauche.SetName("garonne_2_riveGauche") -garonne_2_digue.SetName("garonne_2_digue") +garonne_1_litMineur.SetName("garonne_1_litMineur") +garonne_1_riveDroite.SetName("garonne_1_riveDroite") +garonne_1_riveGauche.SetName("garonne_1_riveGauche") +garonne_1_digue.SetName("garonne_1_digue") # Export of the calculation case -garonne_2_entry = garonne_2.Export( theStudy._get_StudyId() ) +garonne_1_entry = garonne_1.Export( theStudy._get_StudyId() ) #---------------------- # --- Geometry @@ -402,29 +402,80 @@ from salome.hydrotools.controls import controlGeomProps geompy = geomBuilder.New(theStudy) -print "Entry:", garonne_2_entry -HYDRO_garonne_2 = salome.IDToObject( str( garonne_2_entry ) ) -print "Geom shape:", HYDRO_garonne_2 -print "Geom shape name:", HYDRO_garonne_2.GetName() - -[riveGauche,digue,litMineur,riveDroite] = geompy.ExtractShapes(HYDRO_garonne_2, geompy.ShapeType["FACE"], True) -geompy.addToStudyInFather( HYDRO_garonne_2, riveGauche, 'riveGauche' ) -geompy.addToStudyInFather( HYDRO_garonne_2, digue, 'digue' ) -geompy.addToStudyInFather( HYDRO_garonne_2, litMineur, 'litMineur' ) -geompy.addToStudyInFather( HYDRO_garonne_2, riveDroite, 'riveDroite' ) - -SectionsGaronne = geompy.CreateGroup(HYDRO_garonne_2, geompy.ShapeType["EDGE"]) -geompy.UnionIDs(SectionsGaronne, [7, 9]) -geompy.addToStudyInFather( HYDRO_garonne_2, SectionsGaronne, 'SectionsGaronne' ) - -SectionsDigue = geompy.CreateGroup(HYDRO_garonne_2, geompy.ShapeType["EDGE"]) -geompy.UnionIDs(SectionsDigue, [43, 48]) -geompy.addToStudyInFather( HYDRO_garonne_2, SectionsDigue, 'SectionsDigue' ) - -controlGeomProps(geompy, riveGauche, 39490.835288, 35845737.590926) -controlGeomProps(geompy, digue, 10341.466108, 103090.760662) -controlGeomProps(geompy, litMineur, 30337.548492, 3488480.304388) -controlGeomProps(geompy, riveDroite, 32012.343241, 25998769.23615) +print "Entry:", garonne_1_entry +HYDRO_garonne_1 = salome.IDToObject( str( garonne_1_entry ) ) +print "Geom shape:", HYDRO_garonne_1 +print "Geom shape name:", HYDRO_garonne_1.GetName() + + +[garonne_riveGauche,garonne_digue,garonne_litMineur,garonne_riveDroite] = geompy.ExtractShapes(HYDRO_garonne_1, geompy.ShapeType["FACE"], True) + +controlGeomProps(geompy, garonne_riveGauche, 39490.835288, 35845737.590926) +controlGeomProps(geompy, garonne_digue, 10341.466108, 103090.760662) +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, 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, bordGaucheDomaineIds) +geompy.addToStudyInFather(HYDRO_garonne_1, bordGaucheDomaine, "bordGaucheDomaine") +bordDroiteDomaine = geompy.CreateGroup(HYDRO_garonne_1, geompy.ShapeType["EDGE"]) +geompy.UnionIDs(bordDroiteDomaine, bordDroiteDomaineIds) +geompy.addToStudyInFather(HYDRO_garonne_1, bordDroiteDomaine, "bordDroiteDomaine") + +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") + +amontDigue = geompy.GetEdgeNearPoint(HYDRO_garonne_1, geompy.MakeVertex(44736.43, 29847.52, 0)) +avalDigue = geompy.GetEdgeNearPoint(HYDRO_garonne_1, geompy.MakeVertex(40961.39, 31800.95, 0)) +geompy.addToStudyInFather(HYDRO_garonne_1, amontDigue, "amontDigue") +geompy.addToStudyInFather(HYDRO_garonne_1, avalDigue, "avalDigue") + +SectionsDigue = geompy.CreateGroup(HYDRO_garonne_1, geompy.ShapeType["EDGE"]) +geompy.UnionIDs(SectionsDigue, [geompy.GetSubShapeID(HYDRO_garonne_1, amontDigue), geompy.GetSubShapeID(HYDRO_garonne_1, avalDigue)]) +geompy.addToStudyInFather( HYDRO_garonne_1, SectionsDigue, 'SectionsDigue' ) #---------------------- # --- Meshing @@ -433,13 +484,14 @@ controlGeomProps(geompy, riveDroite, 32012.343241, 25998769.23615) import SMESH, SALOMEDS from salome.smesh import smeshBuilder from salome.hydrotools.controls import controlMeshStats, controlSubMeshStats +import tempfile smesh = smeshBuilder.New(theStudy) # --- algorithms and hypothesis -garonne_2 = smesh.Mesh(HYDRO_garonne_2) +garonne_1 = smesh.Mesh(HYDRO_garonne_1) -NETGEN_2D = garonne_2.Triangle(algo=smeshBuilder.NETGEN_1D2D) +NETGEN_2D = garonne_1.Triangle(algo=smeshBuilder.NETGEN_1D2D) NETGEN_2D_Parameters = NETGEN_2D.Parameters() NETGEN_2D_Parameters.SetMaxSize( 200 ) NETGEN_2D_Parameters.SetSecondOrder( 0 ) @@ -450,75 +502,90 @@ NETGEN_2D_Parameters.SetUseSurfaceCurvature( 1 ) NETGEN_2D_Parameters.SetFuseEdges( 1 ) NETGEN_2D_Parameters.SetQuadAllowed( 0 ) -algo2D_litMineur = garonne_2.Quadrangle(algo=smeshBuilder.QUAD_MA_PROJ,geom=litMineur) -algo1D_litMineur = garonne_2.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") -algo1D_SectionsGaronne = garonne_2.Segment(geom=SectionsGaronne) +algo1D_SectionsGaronne = garonne_1.Segment(geom=SectionsGaronne) hypo1D_SectionsGaronne = algo1D_SectionsGaronne.NumberOfSegments(8) hypo1D_SectionsGaronne.SetDistrType( 0 ) subMesh_SectionsGaronne = algo1D_SectionsGaronne.GetSubMesh() smesh.SetName(subMesh_SectionsGaronne, "SectionsGaronne") -algo2D_digue = garonne_2.Quadrangle(algo=smeshBuilder.QUAD_MA_PROJ,geom=digue) -algo1D_digue = garonne_2.Segment(geom=digue) +algo2D_digue = garonne_1.Quadrangle(algo=smeshBuilder.QUAD_MA_PROJ,geom=garonne_digue) +algo1D_digue = garonne_1.Segment(geom=garonne_digue) hypo1D_digue = algo1D_digue.LocalLength(50,None,1e-07) subMesh_digue = algo1D_digue.GetSubMesh() smesh.SetName(subMesh_digue, "digue") -algo1D_SectionsDigue = garonne_2.Segment(geom=SectionsDigue) +algo1D_SectionsDigue = garonne_1.Segment(geom=SectionsDigue) hypo1D_SectionsDigue = algo1D_SectionsDigue.NumberOfSegments(4) hypo1D_SectionsDigue.SetDistrType( 0 ) subMesh_SectionsDigue = algo1D_SectionsDigue.GetSubMesh() smesh.SetName(subMesh_SectionsDigue, "SectionsDigue") -isDone = garonne_2.SetMeshOrder( [ [ subMesh_SectionsGaronne, subMesh_litMineur ], [ subMesh_SectionsDigue, subMesh_digue ]]) +isDone = garonne_1.SetMeshOrder( [ [ subMesh_SectionsGaronne, subMesh_litMineur ], [ subMesh_SectionsDigue, subMesh_digue ]]) # --- compute mesh -isDone = garonne_2.Compute() -isDone = garonne_2.SplitQuadObject( garonne_2, 1 ) -isDone = garonne_2.ReorientObject( garonne_2 ) - -# --- geometrical groups of edges -SectionsGaronne_2 = garonne_2.GroupOnGeom(SectionsGaronne,'SectionsGaronne',SMESH.EDGE) -SectionsDigue_2 = garonne_2.GroupOnGeom(SectionsDigue,'SectionsDigue',SMESH.EDGE) +isDone = garonne_1.Compute() +isDone = garonne_1.SplitQuadObject( garonne_1, 1 ) +isDone = garonne_1.ReorientObject( garonne_1 ) # --- geometrical groups of faces -riveGauche_1 = garonne_2.GroupOnGeom(riveGauche,'riveGauche',SMESH.FACE) -litMineur_2 = garonne_2.GroupOnGeom(litMineur,'litMineur',SMESH.FACE) -riveDroite_1 = garonne_2.GroupOnGeom(riveDroite,'riveDroite',SMESH.FACE) -digue_1 = garonne_2.GroupOnGeom(digue,'digue',SMESH.FACE) - -# --- geometrical groups of nodes -riveGauche_2 = garonne_2.GroupOnGeom(riveGauche,'riveGauche',SMESH.NODE) -litMineur_3 = garonne_2.GroupOnGeom(litMineur,'litMineur',SMESH.NODE) -riveDroite_2 = garonne_2.GroupOnGeom(riveDroite,'riveDroite',SMESH.NODE) -digue_2 = garonne_2.GroupOnGeom(digue,'digue',SMESH.NODE) -SectionsGaronne_3 = garonne_2.GroupOnGeom(SectionsGaronne,'SectionsGaronne',SMESH.NODE) +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) +digue_1 = garonne_1.GroupOnGeom(garonne_digue,'digue',SMESH.FACE) +# --- geometrical groups of edges +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) +amont_1 = garonne_1.GroupOnGeom(amont,'amont',SMESH.EDGE) +aval_1 = garonne_1.GroupOnGeom(aval,'aval',SMESH.EDGE) +SectionsDigue_1 = garonne_1.GroupOnGeom(SectionsDigue,'SectionsDigue',SMESH.EDGE) -med_file = r'/tmp/garonne_2.med' - -try: - os.remove(med_file) -except OSError: - pass - - -garonne_2.SetAutoColor( 1 ) -garonne_2.ExportMED( med_file, 0, SMESH.MED_V2_2, 1, None ,1) - -controlMeshStats(garonne_2, 6190, 691, 12201) -controlSubMeshStats(litMineur_2, 2384) +# --- geometrical groups of nodes +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) +garonne_1_digue_2 = garonne_1.GroupOnGeom(garonne_digue,'garonne_1_digue',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) +amont_2 = garonne_1.GroupOnGeom(amont,'amont',SMESH.NODE) +aval_2 = garonne_1.GroupOnGeom(aval,'aval',SMESH.NODE) +SectionsDigue_2 = garonne_1.GroupOnGeom(SectionsDigue,'SectionsDigue',SMESH.NODE) + +garonne_1.SetAutoColor( 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) + +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, 6190, 691, 12201) +controlSubMeshStats(litMineur_1, 2384) controlSubMeshStats(riveDroite_1, 2400) controlSubMeshStats(riveGauche_1, 6585) controlSubMeshStats(digue_1, 832) if salome.sg.hasDesktop(): salome.sg.updateObjBrowser(1) - #---------------------- # --- Z interpolation with HYDRO #---------------------- @@ -527,16 +594,13 @@ from salome.hydrotools.interpolZ import interpolZ, createZfield2 from salome.hydrotools.controls import controlStatZ # --- case name in HYDRO -nomCas = 'garonne_2' - -# --- med file 2D(x,y) of the case produced by SMESH -fichierMaillage = med_file +nomCas = 'garonne_1' # --- dictionary [med group name] = region name -dicoGroupeRegion= dict(litMineur = 'garonne_2_litMineur', - riveDroite = 'garonne_2_riveDroite', - riveGauche = 'garonne_2_riveGauche', - digue = 'garonne_2_digue', +dicoGroupeRegion= dict(garonne_1_litMineur = 'garonne_1_litMineur', + garonne_1_riveDroite = 'garonne_1_riveDroite', + garonne_1_riveGauche = 'garonne_1_riveGauche', + garonne_1_digue = 'garonne_1_digue', ) # --- value to use for Z when the node is not in a region (used to detect problems) zUndef = 90 @@ -544,10 +608,10 @@ zUndef = 90 # --- Z interpolation on the bathymety/altimetry on the mesh nodes statz = interpolZ(nomCas, fichierMaillage, dicoGroupeRegion, zUndef) #print statz -refstatz = {'riveDroite': (10.88, 32.61, 24.09, 5.13, 17.57, 31.33, 0.2), - 'riveGauche': (7.72, 72.40, 21.59, 8.37, 16.71, 35.71, 0.2), - 'litMineur': (2.06, 25.41, 13.93, 4.33, 8.47, 21.78), - 'digue': (14.10, 27.09, 22.01, 2.56, 18.15, 25.02)} +refstatz = {'garonne_1_riveDroite': (10.88, 32.61, 24.09, 5.13, 17.57, 31.33, 0.2), + 'garonne_1_riveGauche': (7.72, 72.40, 21.59, 8.37, 16.71, 35.71, 0.2), + 'garonne_1_litMineur': (2.06, 25.41, 13.93, 4.33, 8.47, 21.78), + 'garonne_1_digue': (14.10, 27.09, 22.01, 2.56, 18.15, 25.02)} controlStatZ(statz, refstatz) # --- add a field on nodes of type double with z values, named "BOTTOM" diff --git a/doc/salome/examples/h015_normalCaseManualTelemac.py b/doc/salome/examples/h015_normalCaseManualTelemac.py index ff061d34..8c8977d2 100644 --- a/doc/salome/examples/h015_normalCaseManualTelemac.py +++ b/doc/salome/examples/h015_normalCaseManualTelemac.py @@ -327,39 +327,65 @@ 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, 17, 18, 20, 22, 24, 26, 28, 31, 33, 35, 37, 39, 41]) - -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, 33, 35, 37, 39, 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, 18, 20, 22, 24, 26, 28]) - -# --- 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) +geompy.UnionIDs(bordDroiteDomaine, bordDroiteDomaineIds) +geompy.addToStudyInFather(HYDRO_garonne_1, bordDroiteDomaine, "bordDroiteDomaine") + +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 @@ -386,8 +412,8 @@ NETGEN_2D_Parameters.SetUseSurfaceCurvature( 1 ) 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") @@ -405,31 +431,35 @@ isDone = garonne_1.Compute() 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 ) tmpdir = tempfile.mkdtemp() @@ -445,7 +475,7 @@ nbTriangles = d['Entity_Triangle'] nbNodes = d['Entity_Node'] controlMeshStats(garonne_1, 3888, 475, 7597) -controlSubMeshStats(litMineur_2, 2384) +controlSubMeshStats(litMineur_1, 2384) controlSubMeshStats(riveDroite_1, 2342) controlSubMeshStats(riveGauche_1, 2871) @@ -466,9 +496,9 @@ nomCas = 'garonne_1' print 'fichierMaillage=', fichierMaillage # --- dictionary [med group name] = region name -dicoGroupeRegion= dict(litMineur = 'garonne_1_litMineur', - riveDroite = 'garonne_1_riveDroite', - riveGauche = 'garonne_1_riveGauche', +dicoGroupeRegion= dict(garonne_1_litMineur = 'garonne_1_litMineur', + garonne_1_riveDroite = 'garonne_1_riveDroite', + garonne_1_riveGauche = 'garonne_1_riveGauche', ) # --- value to use for Z when the node is not in a region (used to detect problems) zUndef = 80 @@ -476,9 +506,9 @@ zUndef = 80 # --- Z interpolation on the bathymety/altimetry on the mesh nodes statz = interpolZ(nomCas, fichierMaillage, dicoGroupeRegion, zUndef) #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)} +refstatz = {'garonne_1_riveDroite': (10.88, 32.61, 24.17, 5.12, 17.57, 31.33, 0.25), + 'garonne_1_riveGauche': (7.72, 71.86, 24.51, 12.18, 12.90, 60.36, 0.25), + 'garonne_1_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" diff --git a/doc/salome/examples/h019_normalCaseManualInterpolZStrickler.py b/doc/salome/examples/h019_normalCaseManualInterpolZStrickler.py index 5af2c60e..e1fedc24 100644 --- a/doc/salome/examples/h019_normalCaseManualInterpolZStrickler.py +++ b/doc/salome/examples/h019_normalCaseManualInterpolZStrickler.py @@ -616,56 +616,76 @@ HYDRO_garonne_1 = salome.IDToObject( str( garonne_1_entry ) ) 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) @@ -683,8 +703,8 @@ NETGEN_2D_Parameters.SetUseSurfaceCurvature( 1 ) 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") @@ -702,37 +722,44 @@ isDone = garonne_1.Compute() 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) @@ -750,12 +777,11 @@ from salome.hydrotools.controls import controlStatZ 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', - riveDroite = 'garonne_1_riveDroite', - riveGauche = 'garonne_1_riveGauche', +dicoGroupeRegion= dict(garonne_1_litMineur = 'garonne_1_litMineur', + garonne_1_riveDroite = 'garonne_1_riveDroite', + garonne_1_riveGauche = 'garonne_1_riveGauche', ) # --- value to use for Z when the node is not in a region (used to detect problems) zUndef = 90 @@ -763,15 +789,17 @@ zUndef = 90 # --- Z interpolation on the bathymety/altimetry on the mesh nodes statz = interpolZ(nomCas, fichierMaillage, dicoGroupeRegion, zUndef) #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)} +refstatz = {'garonne_1_riveDroite': (10.88, 32.61, 24.17, 5.12, 17.57, 31.33, 0.25), + 'garonne_1_riveGauche': (7.72, 71.86, 24.51, 12.18, 12.90, 60.36, 0.25), + 'garonne_1_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" 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) -- 2.39.2