From 500061ed328803e6883130dc858eca3f665a9ac8 Mon Sep 17 00:00:00 2001 From: Paul RASCLE Date: Mon, 31 Aug 2020 23:18:43 +0200 Subject: [PATCH] test modification of mesh not generated with HYDRO --- doc/salome/examples/CMakeLists.txt | 5 + .../examples/CTestTestfileInstall.cmake | 1 + doc/salome/examples/h030_editNonHydroMesh.py | 221 ++++++++++++++++++ doc/salome/examples/nouvelleDigue.shp | Bin 0 -> 300 bytes doc/salome/examples/nouvelleDigue.shx | Bin 0 -> 108 bytes doc/salome/examples/zoneNouvelleDigue.shp | Bin 0 -> 412 bytes doc/salome/examples/zoneNouvelleDigue.shx | Bin 0 -> 108 bytes 7 files changed, 227 insertions(+) create mode 100644 doc/salome/examples/h030_editNonHydroMesh.py create mode 100644 doc/salome/examples/nouvelleDigue.shp create mode 100644 doc/salome/examples/nouvelleDigue.shx create mode 100644 doc/salome/examples/zoneNouvelleDigue.shp create mode 100644 doc/salome/examples/zoneNouvelleDigue.shx diff --git a/doc/salome/examples/CMakeLists.txt b/doc/salome/examples/CMakeLists.txt index 04abe148..12ea1741 100644 --- a/doc/salome/examples/CMakeLists.txt +++ b/doc/salome/examples/CMakeLists.txt @@ -52,6 +52,7 @@ SET(EXAMPLES_TESTS g028_domaineAmontChevauchant.py h028_regroupOverlappingMeshes.py h029_regroupMeshesNonEnglobant.py + h030_editNonHydroMesh.py ) SET(HYDRO_SAMPLES @@ -89,10 +90,14 @@ SET(HYDRO_SAMPLES jonction_5_2.shx lit_majeur.shp lit_majeur.shx + nouvelleDigue.shp + nouvelleDigue.shx raccord_4_1.shp raccord_4_1.shx raccord_4_2.shp raccord_4_2.shx + zoneNouvelleDigue.shp + zoneNouvelleDigue.shx condlim.bcd init.cas init.lqd diff --git a/doc/salome/examples/CTestTestfileInstall.cmake b/doc/salome/examples/CTestTestfileInstall.cmake index 6017acdf..db8b9460 100644 --- a/doc/salome/examples/CTestTestfileInstall.cmake +++ b/doc/salome/examples/CTestTestfileInstall.cmake @@ -54,6 +54,7 @@ SET(EXAMPLES_TESTS g028_domaineAmontChevauchant h028_regroupOverlappingMeshes h029_regroupMeshesNonEnglobant + h030_editNonHydroMesh ) FOREACH(tfile ${EXAMPLES_TESTS}) diff --git a/doc/salome/examples/h030_editNonHydroMesh.py b/doc/salome/examples/h030_editNonHydroMesh.py new file mode 100644 index 00000000..3d611e7e --- /dev/null +++ b/doc/salome/examples/h030_editNonHydroMesh.py @@ -0,0 +1,221 @@ +# -*- 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") + +import tempfile +tmpdir = tempfile.mkdtemp() +print("tmpdir=",tmpdir) + +# --- generated resources + +origFileMesh = os.path.join(HYDRO_TEST_RESOURCES, 'garonne_2.med') + +# ---------------------------------------------------------------------------------- +# --- domain extension + +import sys +import salome + +salome.salome_init() + +from salome.hydrotools.shapesGroups import freeBordersGroup, exploreEdgeGroups, fitShapePointsToMesh + +offsetX = 430000. +offsetY = 6350000. + +from salome.hydrotools.changeCoords import changeCoords + +origFileMeshTrans = os.path.join(tmpdir, 'garonne_2_trs.med') +changeCoords(origFileMesh, origFileMeshTrans, 2154, 2154, offsetX, offsetY, 0, 0) + +from salome.hydrotools.cutMesh import cutMesh + +cutFileMesh = os.path.join(tmpdir, 'garonne_2_cut.med') +meshFile = cutMesh(origFileMeshTrans, + os.path.join(HYDRO_SAMPLES, 'zoneNouvelleDigue.shp'), + cutFileMesh, offsetX, offsetY) + +ficMeshOut = os.path.join(tmpdir, "garonne_2_cut_brd.med") +fileMeshBrd = freeBordersGroup(cutFileMesh, ficMeshOut) +exploreEdgeGroups(fileMeshBrd, "", offsetX, offsetY) + +#---------------------- +# --- 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() +hydro_doc.SetLocalCS( offsetX, offsetY ) + +limites_original = importPolylines(hydro_doc, os.path.join(tmpdir, "garonne_2_cut_brd_FreeBorders.shp"), 'garonne_2_cut_brd_FreeBorders', False, 4) +[nouvelle_digue] = importPolylines(hydro_doc, os.path.join(HYDRO_SAMPLES, "nouvelleDigue.shp"), 'nouvelleDigue_PolyXY', True, 4) + +Cloud_02 = importBathymetry(hydro_doc, "Cloud_02", HYDRO_SAMPLES) + +domaine_nouveau = createImmersibleZone(hydro_doc, "domaine_nouveau", limites_original[2], Cloud_02, True, 0) + +Profile_1 = hydro_doc.CreateObject( KIND_PROFILE ) +Profile_1.SetName( "Profile_1" ) +profile_points = [ gp_XY( -30, -10 ), + gp_XY( -15, 5 ), + gp_XY( 0, 6 ), + gp_XY( 15, 5 ), + gp_XY( 30, -10 ) ]; +Profile_1.SetParametricPoints( profile_points ) +Profile_1.Update() + +Polyline3D_1_Profile_1 = hydro_doc.CreateObject( KIND_PROFILE ) +Polyline3D_1_Profile_1.SetName( "Polyline3D_1_Profile_1" ) +profile_points = [ gp_XY( 0, 19.63 ), + gp_XY( 495.678, 20.18 ), + gp_XY( 1116.92, 20.39 ), + gp_XY( 1635.79, 19.66 ), + gp_XY( 2040.12, 20.1 ), + gp_XY( 2719.6, 20.76 ), + gp_XY( 3184.38, 21.1 ), + gp_XY( 4149.72, 21.47 ), + gp_XY( 4546.55, 26.79 ) ]; +Polyline3D_1_Profile_1.SetParametricPoints( profile_points ) +Polyline3D_1_Profile_1.Update() + +Polyline3D_1 = hydro_doc.CreateObject( KIND_POLYLINE ) +Polyline3D_1.SetName( "Polyline3D_1" ) +Polyline3D_1.SetPolylineXY( nouvelle_digue ) +Polyline3D_1.SetChildProfileUZ( Polyline3D_1_Profile_1.GetProfileUZ() ) +Polyline3D_1.SetAltitudeObject( Cloud_02 ) +Polyline3D_1.Update() + +Digue_1 = hydro_doc.CreateObject( KIND_DIGUE ) +Digue_1.SetName( "Digue_1" ) +Digue_1.SetZLevel( 5 ) +Digue_1.SetGuideLine( Polyline3D_1 ) +Digue_1.SetProfileMode( True ) +Digue_1.SetProfile( Profile_1 ) +Digue_1.SetEquiDistance( 30 ) +Digue_1.Update() + +# Calculation case +domaineNouveau = hydro_doc.CreateObject( KIND_CALCULATION ) +domaineNouveau.SetName( "domaineNouveau" ) + +domaineNouveau.SetAssignmentMode( HYDROData_CalculationCase.MANUAL ) +domaineNouveau.AddGeometryObject( Digue_1 ) +domaineNouveau.AddGeometryObject( domaine_nouveau ) + +case_geom_group = Digue_1.GetGroup( 2 ) +domaineNouveau.AddGeometryGroup( case_geom_group ) +case_geom_group = Digue_1.GetGroup( 0 ) +domaineNouveau.AddGeometryGroup( case_geom_group ) +case_geom_group = Digue_1.GetGroup( 3 ) +domaineNouveau.AddGeometryGroup( case_geom_group ) +case_geom_group = Digue_1.GetGroup( 1 ) +domaineNouveau.AddGeometryGroup( case_geom_group ) +case_geom_group = domaine_nouveau.GetGroup( 0 ) +domaineNouveau.AddGeometryGroup( case_geom_group ) + +domaineNouveau.SetBoundaryPolyline( limites_original[2] ) + +# Start the algorithm of the partition and assignment +domaineNouveau.Update() +domaineNouveau_Reg_1 = hydro_doc.FindObjectByName( "domaineNouveau_Reg_1" ) +domaineNouveau_Zone_1 = hydro_doc.FindObjectByName( "domaineNouveau_Zone_1" ) +domaineNouveau_Zone_1.SetMergeType( HYDROData_Zone.Merge_ZMAX ) +domaineNouveau_Zone_1.SetColor( QColor( 28, 168, 228 )) +domaineNouveau_Reg_1.AddZone( domaineNouveau_Zone_1 ) +domaineNouveau_Reg_2 = hydro_doc.FindObjectByName( "domaineNouveau_Reg_2" ) +domaineNouveau_Zone_2 = hydro_doc.FindObjectByName( "domaineNouveau_Zone_2" ) +domaineNouveau_Zone_2.SetColor( QColor( 28, 51, 228 )) +domaineNouveau_Reg_2.AddZone( domaineNouveau_Zone_2 ) +domaineNouveau_Reg_1.SetName( "domaineNouveau_Reg_1" ) +domaineNouveau_Reg_2.SetName( "domaineNouveau_Reg_2" ) + +# Export of the calculation case +domaineNouveau_entry = domaineNouveau.Export() + +##---------------------- +## --- Geometry +##---------------------- + +import GEOM +from salome.geom import geomBuilder +import math +import SALOMEDS + +from salome.hydrotools.hydroGeoMeshUtils import getChildrenInStudy + +geompy = geomBuilder.New() + +print ("Entry:", domaineNouveau_entry) +HYDRO_domaineNouveau = salome.IDToObject( str( domaineNouveau_entry ) ) +print ("Geom shape:", HYDRO_domaineNouveau) +print ("Geom shape name:", HYDRO_domaineNouveau.GetName()) + +#[reg_new] = geompy.SubShapeAll(HYDRO_domaineNouveau, geompy.ShapeType["FACE"]) +children = getChildrenInStudy(HYDRO_domaineNouveau) +sub_digue = children['domaineNouveau_Reg_1'] +sub_Reg_2 = children['domaineNouveau_Reg_2'] +sub_Digue_1_Left_Bank = children['domaineNouveau_Digue_1_Left_Bank'] +sub_Digue_1_Outlet = children['domaineNouveau_Digue_1_Outlet'] +sub_Digue_1_Right_Bank = children['domaineNouveau_Digue_1_Right_Bank'] +sub_domaine_nouveau_Outer = children['domaineNouveau_domaine_nouveau_Outer'] +sub_Digue_1_Inlet = children['domaineNouveau_Digue_1_Inlet'] + +if salome.sg.hasDesktop(): + salome.sg.updateObjBrowser() + +#---------------------- +#--- Meshing +#---------------------- + +import SMESH, SALOMEDS +from salome.smesh import smeshBuilder +from salome.hydrotools.controls import controlMeshStats, controlSubMeshStats + +smesh = smeshBuilder.New() + +#--- algorithms and hypothesis +domaineRemaille = smesh.Mesh(HYDRO_domaineNouveau) + +NETGEN_2D = domaineRemaille.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( 5 ) +NETGEN_2D_Parameters.SetUseSurfaceCurvature( 1 ) +NETGEN_2D_Parameters.SetFuseEdges( 1 ) +NETGEN_2D_Parameters.SetQuadAllowed( 0 ) + +Regular_1D = domaineRemaille.Segment(geom=sub_Digue_1_Outlet) +Number_of_Segments_1 = Regular_1D.NumberOfSegments(4) +Regular_1D_1 = domaineRemaille.Segment(geom=sub_Digue_1_Inlet) +status = domaineRemaille.AddHypothesis(Number_of_Segments_1,sub_Digue_1_Inlet) + +Regular_1D_2 = domaineRemaille.Segment(geom=sub_Digue_1_Left_Bank) +Local_Length_1 = Regular_1D_2.LocalLength(50,None,1e-07) +Regular_1D_3 = domaineRemaille.Segment(geom=sub_Digue_1_Right_Bank) +status = domaineRemaille.AddHypothesis(Local_Length_1,sub_Digue_1_Right_Bank) +# Regular_1D_4 = domaineRemaille.Segment(geom=sub_digue) +# status = domaineRemaille.AddHypothesis(Local_Length_1,sub_digue) +QuadFromMedialAxis_1D2D = domaineRemaille.Quadrangle(algo=smeshBuilder.QUAD_MA_PROJ,geom=sub_digue) + +([origMeshBrd], status) = smesh.CreateMeshesFromMED(fileMeshBrd) +FreeBorders = origMeshBrd.GetGroupByName("FreeBorders") +Import_1D = domaineRemaille.UseExisting1DElements(geom=sub_domaine_nouveau_Outer) +Source_Edges_1 = Import_1D.SourceEdges( FreeBorders ,1,1) + +isDone = domaineRemaille.Compute() +isDone = domaineRemaille.SplitQuadObject( domaineRemaille, 1 ) + +controlMeshStats(domaineRemaille, 5179, 769, 10144) + +if salome.sg.hasDesktop(): + salome.sg.updateObjBrowser() diff --git a/doc/salome/examples/nouvelleDigue.shp b/doc/salome/examples/nouvelleDigue.shp new file mode 100644 index 0000000000000000000000000000000000000000..4436a42f87dc809377def21b276902e68e025960 GIT binary patch literal 300 zcmZQzQ0HR64yL_eW?%p!hCi3nd~V;9aZG7WNPiU+;V3TEl)CV}jN_WbZ`<#MML1&D zjv~qk;c4x!WE@$TiX26N{AQuQ z4mLo(h0CkH$)ORBd=cl^xqy7X^F1>9Kt9afPm^}uUKkSLSlSh%aq^9fV?)pX%@#m@ e_@C{ntgmGpFHcKU@d^g|>w@n4X+ZfDsJ{WqdtZzI literal 0 HcmV?d00001 diff --git a/doc/salome/examples/nouvelleDigue.shx b/doc/salome/examples/nouvelleDigue.shx new file mode 100644 index 0000000000000000000000000000000000000000..217f9ed58b9c986ce232ec970a77a195b04abb3b GIT binary patch literal 108 zcmZQzQ0HR64$NLKGcW)V!=KA(KDY15IHoiwq`wM^a1@tnN?rI~#&J#Jx9#`BA{?=6 KM-epw@)7{;n-Pux literal 0 HcmV?d00001 diff --git a/doc/salome/examples/zoneNouvelleDigue.shp b/doc/salome/examples/zoneNouvelleDigue.shp new file mode 100644 index 0000000000000000000000000000000000000000..9effc148b3c2fc63f71ef753e4ba0c1a2df1494c GIT binary patch literal 412 zcmZQzQ0HR64$i$`W?*0i%E@W`;H%_F62*;_@QvPIpm2q6Ua?6d_@CZlj z+EGLqfxH>Sm<3WO0M(jt=AnAoO&LeKL(hEOfcBiMytw4m1BAWOihIrZp2#>dr}`V} z0_E@QdF9dZUdA!MKJux5ScK!Mq|k-aKgu|!o>TZcF%;o$)%3cO-jE2#q*~b=?k_Tq zwd}wC9tw_dyl(EZ)E3CE`1@|+b)Y|=?0>U&15iKA-)l1`6tg^&aTMR{*E|U*pUn0( zXVya*M_u^?!F)jTMDFIS4tXl$IIVl~l-WRj!`0_)@9)bvzREe`-V3z9amvj6xW_V% Y=Em2wp91-?aP1OdzkdzrUUdHg0PeAt%m4rY literal 0 HcmV?d00001 diff --git a/doc/salome/examples/zoneNouvelleDigue.shx b/doc/salome/examples/zoneNouvelleDigue.shx new file mode 100644 index 0000000000000000000000000000000000000000..f1e3aa8066424d7620c42084305c136d90c42be8 GIT binary patch literal 108 zcmZQzQ0HR64$NLKGcd3M<>WMea8}=tar}7Gbz)jjgyYm{DSxuQ$~Z1vx#dP|c!VQ% L?I@x~K;8@h%}fz^ literal 0 HcmV?d00001 -- 2.39.2