From 5b1114ddf4c0693cbb56b9cbe1a503a21b82be33 Mon Sep 17 00:00:00 2001 From: Paul RASCLE Date: Sat, 29 Aug 2020 23:43:57 +0200 Subject: [PATCH] resource for tests on overlapping domains --- doc/salome/examples/CMakeLists.txt | 1 + .../examples/CTestTestfileInstall.cmake | 1 + doc/salome/examples/g027_domaineAmont.py | 4 +- .../examples/g028_domaineAmontChevauchant.py | 248 ++++++++++++++++++ doc/salome/examples/garonneAmont.shp | Bin 1084 -> 1212 bytes doc/salome/examples/garonneAmont.shx | Bin 108 -> 108 bytes 6 files changed, 252 insertions(+), 2 deletions(-) create mode 100644 doc/salome/examples/g028_domaineAmontChevauchant.py diff --git a/doc/salome/examples/CMakeLists.txt b/doc/salome/examples/CMakeLists.txt index 199cd08a..39413449 100644 --- a/doc/salome/examples/CMakeLists.txt +++ b/doc/salome/examples/CMakeLists.txt @@ -49,6 +49,7 @@ SET(EXAMPLES_TESTS h026_extensionSimpleRiveGauche.py g027_domaineAmont.py h027_regroupMeshes.py + g028_domaineAmontChevauchant.py ) SET(HYDRO_SAMPLES diff --git a/doc/salome/examples/CTestTestfileInstall.cmake b/doc/salome/examples/CTestTestfileInstall.cmake index 0593319e..6c6cff24 100644 --- a/doc/salome/examples/CTestTestfileInstall.cmake +++ b/doc/salome/examples/CTestTestfileInstall.cmake @@ -51,6 +51,7 @@ SET(EXAMPLES_TESTS h026_extensionSimpleRiveGauche g027_domaineAmont h027_regroupMeshes + g028_domaineAmontChevauchant ) FOREACH(tfile ${EXAMPLES_TESTS}) diff --git a/doc/salome/examples/g027_domaineAmont.py b/doc/salome/examples/g027_domaineAmont.py index 357dbbda..f473d80c 100644 --- a/doc/salome/examples/g027_domaineAmont.py +++ b/doc/salome/examples/g027_domaineAmont.py @@ -104,8 +104,8 @@ garonne_riveDroite = children["domaineAmont_RiveDroite"] #[garonne_riveGauche, garonne_litMineur, garonne_riveDroite] = geompy.SubShapeAll(HYDRO_domaineAmont, geompy.ShapeType["FACE"]) controlGeomProps(geompy, garonne_riveGauche, 23924.943383, 19616095.293123) -controlGeomProps(geompy, garonne_litMineur, 21161.868589, 2453082.699997) -controlGeomProps(geompy, garonne_riveDroite, 21871.837974, 25319246.863937) +controlGeomProps(geompy, garonne_litMineur, 21175.096223, 2462200.74836) +controlGeomProps(geompy, garonne_riveDroite, 21862.960741, 25310128.815573) # --- manual identification of all useful edge groups (boundary conditions) diff --git a/doc/salome/examples/g028_domaineAmontChevauchant.py b/doc/salome/examples/g028_domaineAmontChevauchant.py new file mode 100644 index 00000000..4dca291f --- /dev/null +++ b/doc/salome/examples/g028_domaineAmontChevauchant.py @@ -0,0 +1,248 @@ +# -*- coding: utf-8 -*- + +import os +HYDRO_SAMPLES = os.path.join( os.environ["HYDRO_ROOT_DIR"], "bin/salome/test/HYDRO") +HYDRO_TEST_RESOURCES = "/home/paul/testsHydro" #os.environ("HYDRO_TEST_RESOURCES") +if not os.path.isdir(HYDRO_TEST_RESOURCES): + os.mkdir(HYDRO_TEST_RESOURCES) + +import tempfile +tmpdir = tempfile.mkdtemp() +print("tmpdir=",tmpdir) + +import sys +import salome + +salome.salome_init() + +#---------------------- +# --- HYDRO +#---------------------- + +from HYDROPy import * +from PyQt5.QtCore import * +from PyQt5.QtGui import * + +from salome.hydrotools.hydroGeoMeshUtils import importPolylines, importBathymetry, createImmersibleZone, mergePolylines, getChildrenInStudy + +hydro_doc = HYDROData_Document.Document() + +offsetX = 430000. +offsetY = 6350000. +hydro_doc.SetLocalCS( offsetX, offsetY ) + +limites_amont = importPolylines(hydro_doc, os.path.join(HYDRO_SAMPLES, "domaineAmontChevauchant.shp"), "domaineAmontChevauchant_PolyXY", False, 4) +garonnes_amont = importPolylines(hydro_doc, os.path.join(HYDRO_SAMPLES, "garonneAmont.shp"), "garonneAmont_PolyXY", True, 3) + +Cloud_02 = importBathymetry(hydro_doc, "Cloud_02", HYDRO_SAMPLES) +garonne_point_L93 = importBathymetry(hydro_doc, "garonne_point_L93", HYDRO_SAMPLES) + +domaine_amont = createImmersibleZone(hydro_doc, "domaine_amont", limites_amont[0], Cloud_02, True, 0) +garonne_amont = createImmersibleZone(hydro_doc, "garonne_amont", garonnes_amont[0], garonne_point_L93, True, 0) + +# Calculation case +domaineAmontChevauchant = hydro_doc.CreateObject( KIND_CALCULATION ) +domaineAmontChevauchant.SetName( "domaineAmontChevauchant" ) + +domaineAmontChevauchant.SetAssignmentMode( HYDROData_CalculationCase.MANUAL ) +domaineAmontChevauchant.AddGeometryObject( domaine_amont ) +domaineAmontChevauchant.AddGeometryObject( garonne_amont ) + +case_geom_group = domaine_amont.GetGroup( 0 ) +domaineAmontChevauchant.AddGeometryGroup( case_geom_group ) +case_geom_group = garonne_amont.GetGroup( 0 ) +domaineAmontChevauchant.AddGeometryGroup( case_geom_group ) + +domaineAmontChevauchant.SetBoundaryPolyline( limites_amont[0] ) + +# Start the algorithm of the partition and assignment +domaineAmontChevauchant.Update() +domaineAmontChevauchant_RiveGauche = hydro_doc.FindObjectByName( "domaineAmontChevauchant_Reg_1" ) +domaineAmontChevauchant_Zone_1 = hydro_doc.FindObjectByName( "domaineAmontChevauchant_Zone_1" ) +domaineAmontChevauchant_Zone_1.SetColor( QColor( 28, 205, 228 )) +domaineAmontChevauchant_RiveGauche.AddZone( domaineAmontChevauchant_Zone_1 ) +domaineAmontChevauchant_LitMineur = hydro_doc.FindObjectByName( "domaineAmontChevauchant_Reg_2" ) +domaineAmontChevauchant_Zone_2 = hydro_doc.FindObjectByName( "domaineAmontChevauchant_Zone_2" ) +domaineAmontChevauchant_Zone_2.SetMergeType( HYDROData_Zone.Merge_ZMIN ) +domaineAmontChevauchant_Zone_2.SetColor( QColor( 228, 205, 28 )) +domaineAmontChevauchant_LitMineur.AddZone( domaineAmontChevauchant_Zone_2 ) +domaineAmontChevauchant_RiveDroite = hydro_doc.FindObjectByName( "domaineAmontChevauchant_Reg_3" ) +domaineAmontChevauchant_Zone_3 = hydro_doc.FindObjectByName( "domaineAmontChevauchant_Zone_3" ) +domaineAmontChevauchant_Zone_3.SetColor( QColor( 118, 228, 28 )) +domaineAmontChevauchant_RiveDroite.AddZone( domaineAmontChevauchant_Zone_3 ) +domaineAmontChevauchant_RiveGauche.SetName( "domaineAmontChevauchant_RiveGauche" ) +domaineAmontChevauchant_LitMineur.SetName( "domaineAmontChevauchant_LitMineur" ) +domaineAmontChevauchant_RiveDroite.SetName( "domaineAmontChevauchant_RiveDroite" ) + +# Export of the calculation case +domaineAmontChevauchant_entry = domaineAmontChevauchant.Export() + +#---------------------- +# --- Geometry +#---------------------- + +# Get geometry shape and print debug information +import GEOM +from salome.geom import geomBuilder +import math +import SALOMEDS +from salome.hydrotools.controls import controlGeomProps + +geompy = geomBuilder.New() + +print ("Entry:", domaineAmontChevauchant_entry) +HYDRO_domaineAmontChevauchant = salome.IDToObject( str( domaineAmontChevauchant_entry ) ) +print ("Geom shape:", HYDRO_domaineAmontChevauchant) +print ("Geom shape name:", HYDRO_domaineAmontChevauchant.GetName()) + +# --- manual definition: geometrical faces + +children = getChildrenInStudy(HYDRO_domaineAmontChevauchant) +garonne_riveGauche = children["domaineAmontChevauchant_RiveGauche"] +garonne_litMineur = children["domaineAmontChevauchant_LitMineur"] +garonne_riveDroite = children["domaineAmontChevauchant_RiveDroite"] +#[garonne_riveGauche, garonne_litMineur, garonne_riveDroite] = geompy.SubShapeAll(HYDRO_domaineAmontChevauchant, geompy.ShapeType["FACE"]) + +controlGeomProps(geompy, garonne_riveGauche, 24116.411482, 15853537.868346) +controlGeomProps(geompy, garonne_litMineur, 24157.055987, 2726363.217489) +controlGeomProps(geompy, garonne_riveDroite, 27118.637078, 32377028.446033) + +# --- manual identification of all useful edge groups (boundary conditions) + +allEdgesIds = geompy.SubShapeAllIDs(HYDRO_domaineAmontChevauchant, geompy.ShapeType["EDGE"]) +print("allEdgesIds", allEdgesIds) + +(isDone, ClosedFreeBoundary, OpenFreeBoundary) = geompy.GetFreeBoundary(HYDRO_domaineAmontChevauchant) +geompy.addToStudyInFather(HYDRO_domaineAmontChevauchant, ClosedFreeBoundary[0], "ClosedFreeBoundary") + +freeBoundary = geompy.ExtractShapes(ClosedFreeBoundary[0], geompy.ShapeType["EDGE"], True) +freeBoundaryIds = [ geompy.GetSubShapeID(HYDRO_domaineAmontChevauchant, 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_domaineAmontChevauchant, litMineur_droite, "litMineur_droite") +geompy.addToStudyInFather(HYDRO_domaineAmontChevauchant, litMineur_gauche, "litMineur_gauche") +rives = [litMineur_droite, litMineur_gauche] +rivesIds = [ geompy.GetSubShapeID(HYDRO_domaineAmontChevauchant, rives[i]) for i in range(len(rives)) ] +print("rivesIds", rivesIds) + +edges_litMineur = geompy.GetSharedShapesMulti([HYDRO_domaineAmontChevauchant, garonne_litMineur], geompy.ShapeType["EDGE"], True) +edges_riveGauche = geompy.GetSharedShapesMulti([HYDRO_domaineAmontChevauchant, garonne_riveGauche], geompy.ShapeType["EDGE"], True) +edges_riveDroite = geompy.GetSharedShapesMulti([HYDRO_domaineAmontChevauchant, garonne_riveDroite], geompy.ShapeType["EDGE"], True) +edges_litMineurIds = [ geompy.GetSubShapeID(HYDRO_domaineAmontChevauchant, edges_litMineur[i]) for i in range(len(edges_litMineur)) ] +edges_riveGaucheIds = [ geompy.GetSubShapeID(HYDRO_domaineAmontChevauchant, edges_riveGauche[i]) for i in range(len(edges_riveGauche)) ] +edges_riveDroiteIds = [ geompy.GetSubShapeID(HYDRO_domaineAmontChevauchant, 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_domaineAmontChevauchant, geompy.ShapeType["EDGE"]) +geompy.UnionIDs(SectionsGaronne, sectionsIds) +geompy.addToStudyInFather(HYDRO_domaineAmontChevauchant, 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_domaineAmontChevauchant, geompy.ShapeType["EDGE"]) +geompy.UnionIDs(bordGaucheDomaine, bordGaucheDomaineIds) +geompy.addToStudyInFather(HYDRO_domaineAmontChevauchant, bordGaucheDomaine, "bordGaucheDomaine") +bordDroiteDomaine = geompy.CreateGroup(HYDRO_domaineAmontChevauchant, geompy.ShapeType["EDGE"]) +geompy.UnionIDs(bordDroiteDomaine, bordDroiteDomaineIds) +geompy.addToStudyInFather(HYDRO_domaineAmontChevauchant, bordDroiteDomaine, "bordDroiteDomaine") + +amont = geompy.GetEdgeNearPoint(HYDRO_domaineAmontChevauchant, geompy.MakeVertex(54062.101935, 20486.776236, 0)) +aval = geompy.GetEdgeNearPoint(HYDRO_domaineAmontChevauchant, geompy.MakeVertex(47800.17745, 25211,491804, 0)) +geompy.addToStudyInFather(HYDRO_domaineAmontChevauchant, amont, "amont") +geompy.addToStudyInFather(HYDRO_domaineAmontChevauchant, aval, "aval") + +#---------------------- +# --- Meshing +#---------------------- + +import SMESH, SALOMEDS +from salome.smesh import smeshBuilder +from salome.hydrotools.controls import controlMeshStats, controlSubMeshStats +import tempfile + +smesh = smeshBuilder.New() + +# --- algorithms and hypothesis +garonneAmont = smesh.Mesh(HYDRO_domaineAmontChevauchant) + +NETGEN_2D = garonneAmont.Triangle(algo=smeshBuilder.NETGEN_1D2D) +NETGEN_2D_Parameters = NETGEN_2D.Parameters() +NETGEN_2D_Parameters.SetMaxSize( 200 ) +NETGEN_2D_Parameters.SetSecondOrder( 0 ) +NETGEN_2D_Parameters.SetOptimize( 1 ) +NETGEN_2D_Parameters.SetFineness( 4 ) +NETGEN_2D_Parameters.SetMinSize( 50 ) +NETGEN_2D_Parameters.SetUseSurfaceCurvature( 1 ) +NETGEN_2D_Parameters.SetFuseEdges( 1 ) +NETGEN_2D_Parameters.SetQuadAllowed( 0 ) + +algo2D_litMineur = garonneAmont.Quadrangle(algo=smeshBuilder.QUAD_MA_PROJ,geom=garonne_litMineur) +algo1D_litMineur = garonneAmont.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 = garonneAmont.Segment(geom=SectionsGaronne) +hypo1D_SectionsGaronne = algo1D_SectionsGaronne.NumberOfSegments(8) +hypo1D_SectionsGaronne.SetDistrType( 0 ) +subMesh_SectionsGaronne = algo1D_SectionsGaronne.GetSubMesh() +smesh.SetName(subMesh_SectionsGaronne, "SectionsGaronne") + +isDone = garonneAmont.SetMeshOrder( [ [ subMesh_SectionsGaronne, subMesh_litMineur ] ]) + +# --- compute mesh +isDone = garonneAmont.Compute() +isDone = garonneAmont.SplitQuadObject( garonneAmont, 1 ) +isDone = garonneAmont.ReorientObject( garonneAmont ) + +# --- geometrical groups of faces +riveGauche_1 = garonneAmont.GroupOnGeom(garonne_riveGauche,'riveGauche',SMESH.FACE) +litMineur_1 = garonneAmont.GroupOnGeom(garonne_litMineur,'litMineur',SMESH.FACE) +riveDroite_1 = garonneAmont.GroupOnGeom(garonne_riveDroite,'riveDroite',SMESH.FACE) + +# --- geometrical groups of edges + +ClosedFreeBoundary_1 = garonneAmont.GroupOnGeom(ClosedFreeBoundary[0],'ClosedFreeBoundary',SMESH.EDGE) +litMineur_droite_1 = garonneAmont.GroupOnGeom(litMineur_droite,'litMineur_droite',SMESH.EDGE) +litMineur_gauche_1 = garonneAmont.GroupOnGeom(litMineur_gauche,'litMineur_gauche',SMESH.EDGE) +SectionsgaronneAmont = garonneAmont.GroupOnGeom(SectionsGaronne,'SectionsGaronne',SMESH.EDGE) +bordGaucheDomaine_1 = garonneAmont.GroupOnGeom(bordGaucheDomaine,'bordGaucheDomaine',SMESH.EDGE) +bordDroiteDomaine_1 = garonneAmont.GroupOnGeom(bordDroiteDomaine,'bordDroiteDomaine',SMESH.EDGE) +amont_1 = garonneAmont.GroupOnGeom(amont,'amont',SMESH.EDGE) +aval_1 = garonneAmont.GroupOnGeom(aval,'aval',SMESH.EDGE) + +# --- geometrical groups of nodes + +garonneAmont_litMineur_2 = garonneAmont.GroupOnGeom(garonne_litMineur,'garonneAmont_litMineur',SMESH.NODE) +garonneAmont_riveDroite_2 = garonneAmont.GroupOnGeom(garonne_riveDroite,'garonneAmont_riveDroite',SMESH.NODE) +garonneAmont_riveGauche_2 = garonneAmont.GroupOnGeom(garonne_riveGauche,'garonneAmont_riveGauche',SMESH.NODE) +ClosedFreeBoundary_2 = garonneAmont.GroupOnGeom(ClosedFreeBoundary[0],'ClosedFreeBoundary',SMESH.NODE) +litMineur_droite_2 = garonneAmont.GroupOnGeom(litMineur_droite,'litMineur_droite',SMESH.NODE) +litMineur_gauche_2 = garonneAmont.GroupOnGeom(litMineur_gauche,'litMineur_gauche',SMESH.NODE) +SectionsgaronneAmont = garonneAmont.GroupOnGeom(SectionsGaronne,'SectionsGaronne',SMESH.NODE) +bordGaucheDomaine_2 = garonneAmont.GroupOnGeom(bordGaucheDomaine,'bordGaucheDomaine',SMESH.NODE) +bordDroiteDomaine_2 = garonneAmont.GroupOnGeom(bordDroiteDomaine,'bordDroiteDomaine',SMESH.NODE) +amont_2 = garonneAmont.GroupOnGeom(amont,'amont',SMESH.NODE) +aval_2 = garonneAmont.GroupOnGeom(aval,'aval',SMESH.NODE) + +garonneAmont.SetAutoColor( 1 ) +fichierMaillage = os.path.join(HYDRO_TEST_RESOURCES, 'garonneAmont.med') +garonneAmont.ExportMED(fichierMaillage, 0, SMESH.MED_V2_2, 1, None ,1) + +controlMeshStats(garonneAmont, 3056, 395, 5953) +controlSubMeshStats(litMineur_1, 1904) +controlSubMeshStats(riveDroite_1, 2518) +controlSubMeshStats(riveGauche_1, 1531) + +if salome.sg.hasDesktop(): + salome.sg.updateObjBrowser() + diff --git a/doc/salome/examples/garonneAmont.shp b/doc/salome/examples/garonneAmont.shp index 4486900cfa416df91e7eddc932f4ff1d21b398a2..ffb0d6d01dc659c4632d2f0ad451eba5a51cc41c 100644 GIT binary patch delta 342 zcmdnPv4?Ylv|8K?W(EdU1_p+eJ{Ny<@XI=yS{EOy@`-RXiGB6de4?!5BGE3j#)*!a z^-LNBl?6pOG6Icq0%8z&8^=FMRY=yc%#raxAy97pegF0Ak@$T4ccR>cWgV|ZM!YQo z${SwT(nNu?<#7p+uf%uV_lkt9qf^a~Cv^cp0iPVlIa_6+ZUXYnz2C4aD$6?R ztG)P{0ObG6*yg@hUDh#s%H&E7Ab*4K?_hmxS;w|F<~BD1BODucrmnHmm391nWXY?f zjXRB*17N;3j(4>S2I`P!XE53g3)Fc&vovHKvnJ~IDgfoImiV8M)dgD7(v%gu*^<$iIRIuW z*LK-I;XoxhHtL2afUda3x#w;kkbmkV$In