From: Paul RASCLE Date: Fri, 28 Aug 2020 17:03:00 +0000 (+0200) Subject: other tests on simple extension X-Git-Tag: SH_V2_2_0~65 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=a298425567e6e85967d3f10e290dd690263c1299;p=modules%2Fhydro.git other tests on simple extension --- diff --git a/doc/salome/examples/CMakeLists.txt b/doc/salome/examples/CMakeLists.txt index fb9d81d1..1161336c 100644 --- a/doc/salome/examples/CMakeLists.txt +++ b/doc/salome/examples/CMakeLists.txt @@ -44,6 +44,9 @@ SET(EXAMPLES_TESTS g022_extensionSimpleComplete.py h022_extensionSimpleComplete.py h023_extensionSimpleAmont.py + h024_extensionSimpleAval.py + h025_extensionSimpleRiveDroite.py + h026_extensionSimpleRiveGauche.py ) SET(HYDRO_SAMPLES diff --git a/doc/salome/examples/CTestTestfileInstall.cmake b/doc/salome/examples/CTestTestfileInstall.cmake index 2cf13a46..3ee6b4d8 100644 --- a/doc/salome/examples/CTestTestfileInstall.cmake +++ b/doc/salome/examples/CTestTestfileInstall.cmake @@ -46,6 +46,9 @@ SET(EXAMPLES_TESTS g022_extensionSimpleComplete h022_extensionSimpleComplete h023_extensionSimpleAmont + h024_extensionSimpleAval + h025_extensionSimpleRiveDroite + h026_extensionSimpleRiveGauche ) FOREACH(tfile ${EXAMPLES_TESTS}) diff --git a/doc/salome/examples/h024_extensionSimpleAval.py b/doc/salome/examples/h024_extensionSimpleAval.py new file mode 100644 index 00000000..6f3766fe --- /dev/null +++ b/doc/salome/examples/h024_extensionSimpleAval.py @@ -0,0 +1,150 @@ +# -*- 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. + +ficMeshOut = os.path.join(tmpdir, "garonne_2_brd.med") +fileMeshBrd = freeBordersGroup(origFileMesh, ficMeshOut) +exploreEdgeGroups(fileMeshBrd, "", offsetX, offsetY) + +fitShapePointsToMesh(os.path.join(tmpdir, "garonne_2_brd_FreeBorders.shp"), + os.path.join(HYDRO_SAMPLES, 'extension_1_3.shp'), + tmpdir, True, True) + +#---------------------- +# --- HYDRO +#---------------------- + +from HYDROPy import * +from PyQt5.QtCore import * +from PyQt5.QtGui import * + +from salome.hydrotools.hydroGeoMeshUtils import importPolylines, importBathymetry, createImmersibleZone, mergePolylines + +hydro_doc = HYDROData_Document.Document() +hydro_doc.SetLocalCS( offsetX, offsetY ) + +limites_original = importPolylines(hydro_doc, os.path.join(tmpdir, "garonne_2_brd_FreeBorders_split.shp"), 'garonne_2_brd_FreeBorders', True, 4) +limites_domaine = importPolylines(hydro_doc, os.path.join(tmpdir, "extension_1_3_adj.shp"), 'extension_1_3', False, 2) + +limite_extension = mergePolylines(hydro_doc, 'limite_extension', [limites_original[1], limites_domaine[1]]) + +Cloud_02 = importBathymetry(hydro_doc, "Cloud_02", HYDRO_SAMPLES) + +domaine_extension = createImmersibleZone(hydro_doc, "domaine_extension", limite_extension, Cloud_02, True, 0) + +# Calculation case +extension = hydro_doc.CreateObject( KIND_CALCULATION ) +extension.SetName( "extension" ) +extension.SetAssignmentMode( HYDROData_CalculationCase.AUTOMATIC ) +extension.AddGeometryObject( domaine_extension ) +extension.SetBoundaryPolyline( limite_extension ) +extension.Update() + +# # Calculation case +# extension = hydro_doc.CreateObject( KIND_CALCULATION ) +# extension.SetName( "extension" ) +# extension.SetAssignmentMode( HYDROData_CalculationCase.MANUAL ) +# extension.AddGeometryObject( domaine_extension ) +# case_geom_group = domaine_extension.GetGroup( 0 ) +# extension.AddGeometryGroup( case_geom_group ) +# extension.SetBoundaryPolyline( limite_extension ) +# extension.SetStricklerTable( Strickler_table_1 ) +# # Start the algorithm of the partition and assignment +# extension.Update() +# extension_Reg_1 = hydro_doc.FindObjectByName( "extension_Reg_1" ) +# extension_Zone_1 = hydro_doc.FindObjectByName( "extension_Zone_1" ) +# extension_Zone_1.SetColor( QColor( 105, 228, 28 )) +# extension_Reg_1.AddZone( extension_Zone_1 ) +# extension_Reg_1.SetName( "Case_1_Reg_1" ) + +# Export of the calculation case +extension_entry = extension.Export() + +##---------------------- +## --- Geometry +##---------------------- + +import GEOM +from salome.geom import geomBuilder +import math +import SALOMEDS + +from salome.hydrotools.hydroGeoMeshUtils import getChildrenInStudy + +geompy = geomBuilder.New() + +print ("Entry:", extension_entry) +HYDRO_extension = salome.IDToObject( str( extension_entry ) ) +print ("Geom shape:", HYDRO_extension) +print ("Geom shape name:", HYDRO_extension.GetName()) + +[reg_extension] = geompy.SubShapeAll(HYDRO_extension, geompy.ShapeType["FACE"]) +#children = getChildrenInStudy(HYDRO_extension) +#extension_domaine_original_Outer = children["extension_domaine_original_Outer"] +#TODO: better identification +extension_domaine_original_Outer = geompy.CreateGroup(HYDRO_extension, geompy.ShapeType["EDGE"]) +geompy.UnionIDs(extension_domaine_original_Outer, [3]) +geompy.addToStudyInFather( HYDRO_extension, extension_domaine_original_Outer, 'extension_domaine_original_Outer' ) + +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 +extensionEnglobante = smesh.Mesh(HYDRO_extension) + +NETGEN_2D = extensionEnglobante.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 ) + +([origMeshBrd], status) = smesh.CreateMeshesFromMED(fileMeshBrd) +FreeBorders = origMeshBrd.GetGroupByName("FreeBorders") + +Import_1D = extensionEnglobante.UseExisting1DElements(geom=extension_domaine_original_Outer) +Source_Edges_1 = Import_1D.SourceEdges( FreeBorders ,1,1) + +isDone = extensionEnglobante.Compute() + +controlMeshStats(extensionEnglobante, 4811, 599, 9368) + +if salome.sg.hasDesktop(): + salome.sg.updateObjBrowser() diff --git a/doc/salome/examples/h025_extensionSimpleRiveDroite.py b/doc/salome/examples/h025_extensionSimpleRiveDroite.py new file mode 100644 index 00000000..4f4372b2 --- /dev/null +++ b/doc/salome/examples/h025_extensionSimpleRiveDroite.py @@ -0,0 +1,150 @@ +# -*- 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. + +ficMeshOut = os.path.join(tmpdir, "garonne_2_brd.med") +fileMeshBrd = freeBordersGroup(origFileMesh, ficMeshOut) +exploreEdgeGroups(fileMeshBrd, "", offsetX, offsetY) + +fitShapePointsToMesh(os.path.join(tmpdir, "garonne_2_brd_FreeBorders.shp"), + os.path.join(HYDRO_SAMPLES, 'extension_3_1.shp'), + tmpdir, True, True) + +#---------------------- +# --- HYDRO +#---------------------- + +from HYDROPy import * +from PyQt5.QtCore import * +from PyQt5.QtGui import * + +from salome.hydrotools.hydroGeoMeshUtils import importPolylines, importBathymetry, createImmersibleZone, mergePolylines + +hydro_doc = HYDROData_Document.Document() +hydro_doc.SetLocalCS( offsetX, offsetY ) + +limites_original = importPolylines(hydro_doc, os.path.join(tmpdir, "garonne_2_brd_FreeBorders_split.shp"), 'garonne_2_brd_FreeBorders', True, 4) +limites_domaine = importPolylines(hydro_doc, os.path.join(tmpdir, "extension_3_1_adj.shp"), 'extension_3_1', False, 2) + +limite_extension = mergePolylines(hydro_doc, 'limite_extension', [limites_original[0], limites_domaine[0]]) + +Cloud_02 = importBathymetry(hydro_doc, "Cloud_02", HYDRO_SAMPLES) + +domaine_extension = createImmersibleZone(hydro_doc, "domaine_extension", limite_extension, Cloud_02, True, 0) + +# Calculation case +extension = hydro_doc.CreateObject( KIND_CALCULATION ) +extension.SetName( "extension" ) +extension.SetAssignmentMode( HYDROData_CalculationCase.AUTOMATIC ) +extension.AddGeometryObject( domaine_extension ) +extension.SetBoundaryPolyline( limite_extension ) +extension.Update() + +# # Calculation case +# extension = hydro_doc.CreateObject( KIND_CALCULATION ) +# extension.SetName( "extension" ) +# extension.SetAssignmentMode( HYDROData_CalculationCase.MANUAL ) +# extension.AddGeometryObject( domaine_extension ) +# case_geom_group = domaine_extension.GetGroup( 0 ) +# extension.AddGeometryGroup( case_geom_group ) +# extension.SetBoundaryPolyline( limite_extension ) +# extension.SetStricklerTable( Strickler_table_1 ) +# # Start the algorithm of the partition and assignment +# extension.Update() +# extension_Reg_1 = hydro_doc.FindObjectByName( "extension_Reg_1" ) +# extension_Zone_1 = hydro_doc.FindObjectByName( "extension_Zone_1" ) +# extension_Zone_1.SetColor( QColor( 105, 228, 28 )) +# extension_Reg_1.AddZone( extension_Zone_1 ) +# extension_Reg_1.SetName( "Case_1_Reg_1" ) + +# Export of the calculation case +extension_entry = extension.Export() + +##---------------------- +## --- Geometry +##---------------------- + +import GEOM +from salome.geom import geomBuilder +import math +import SALOMEDS + +from salome.hydrotools.hydroGeoMeshUtils import getChildrenInStudy + +geompy = geomBuilder.New() + +print ("Entry:", extension_entry) +HYDRO_extension = salome.IDToObject( str( extension_entry ) ) +print ("Geom shape:", HYDRO_extension) +print ("Geom shape name:", HYDRO_extension.GetName()) + +[reg_extension] = geompy.SubShapeAll(HYDRO_extension, geompy.ShapeType["FACE"]) +#children = getChildrenInStudy(HYDRO_extension) +#extension_domaine_original_Outer = children["extension_domaine_original_Outer"] +#TODO: better identification +extension_domaine_original_Outer = geompy.CreateGroup(HYDRO_extension, geompy.ShapeType["EDGE"]) +geompy.UnionIDs(extension_domaine_original_Outer, [3]) +geompy.addToStudyInFather( HYDRO_extension, extension_domaine_original_Outer, 'extension_domaine_original_Outer' ) + +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 +extensionEnglobante = smesh.Mesh(HYDRO_extension) + +NETGEN_2D = extensionEnglobante.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 ) + +([origMeshBrd], status) = smesh.CreateMeshesFromMED(fileMeshBrd) +FreeBorders = origMeshBrd.GetGroupByName("FreeBorders") + +Import_1D = extensionEnglobante.UseExisting1DElements(geom=extension_domaine_original_Outer) +Source_Edges_1 = Import_1D.SourceEdges( FreeBorders ,1,1) + +isDone = extensionEnglobante.Compute() + +controlMeshStats(extensionEnglobante, 4500, 614, 8747) + +if salome.sg.hasDesktop(): + salome.sg.updateObjBrowser() diff --git a/doc/salome/examples/h026_extensionSimpleRiveGauche.py b/doc/salome/examples/h026_extensionSimpleRiveGauche.py new file mode 100644 index 00000000..d70d8fe9 --- /dev/null +++ b/doc/salome/examples/h026_extensionSimpleRiveGauche.py @@ -0,0 +1,150 @@ +# -*- 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. + +ficMeshOut = os.path.join(tmpdir, "garonne_2_brd.med") +fileMeshBrd = freeBordersGroup(origFileMesh, ficMeshOut) +exploreEdgeGroups(fileMeshBrd, "", offsetX, offsetY) + +fitShapePointsToMesh(os.path.join(tmpdir, "garonne_2_brd_FreeBorders.shp"), + os.path.join(HYDRO_SAMPLES, 'extension_3_2.shp'), + tmpdir, True, True) + +#---------------------- +# --- HYDRO +#---------------------- + +from HYDROPy import * +from PyQt5.QtCore import * +from PyQt5.QtGui import * + +from salome.hydrotools.hydroGeoMeshUtils import importPolylines, importBathymetry, createImmersibleZone, mergePolylines + +hydro_doc = HYDROData_Document.Document() +hydro_doc.SetLocalCS( offsetX, offsetY ) + +limites_original = importPolylines(hydro_doc, os.path.join(tmpdir, "garonne_2_brd_FreeBorders_split.shp"), 'garonne_2_brd_FreeBorders', True, 4) +limites_domaine = importPolylines(hydro_doc, os.path.join(tmpdir, "extension_3_2_adj.shp"), 'extension_3_2', False, 2) + +limite_extension = mergePolylines(hydro_doc, 'limite_extension', [limites_original[0], limites_domaine[1]]) + +Cloud_02 = importBathymetry(hydro_doc, "Cloud_02", HYDRO_SAMPLES) + +domaine_extension = createImmersibleZone(hydro_doc, "domaine_extension", limite_extension, Cloud_02, True, 0) + +# Calculation case +extension = hydro_doc.CreateObject( KIND_CALCULATION ) +extension.SetName( "extension" ) +extension.SetAssignmentMode( HYDROData_CalculationCase.AUTOMATIC ) +extension.AddGeometryObject( domaine_extension ) +extension.SetBoundaryPolyline( limite_extension ) +extension.Update() + +# # Calculation case +# extension = hydro_doc.CreateObject( KIND_CALCULATION ) +# extension.SetName( "extension" ) +# extension.SetAssignmentMode( HYDROData_CalculationCase.MANUAL ) +# extension.AddGeometryObject( domaine_extension ) +# case_geom_group = domaine_extension.GetGroup( 0 ) +# extension.AddGeometryGroup( case_geom_group ) +# extension.SetBoundaryPolyline( limite_extension ) +# extension.SetStricklerTable( Strickler_table_1 ) +# # Start the algorithm of the partition and assignment +# extension.Update() +# extension_Reg_1 = hydro_doc.FindObjectByName( "extension_Reg_1" ) +# extension_Zone_1 = hydro_doc.FindObjectByName( "extension_Zone_1" ) +# extension_Zone_1.SetColor( QColor( 105, 228, 28 )) +# extension_Reg_1.AddZone( extension_Zone_1 ) +# extension_Reg_1.SetName( "Case_1_Reg_1" ) + +# Export of the calculation case +extension_entry = extension.Export() + +##---------------------- +## --- Geometry +##---------------------- + +import GEOM +from salome.geom import geomBuilder +import math +import SALOMEDS + +from salome.hydrotools.hydroGeoMeshUtils import getChildrenInStudy + +geompy = geomBuilder.New() + +print ("Entry:", extension_entry) +HYDRO_extension = salome.IDToObject( str( extension_entry ) ) +print ("Geom shape:", HYDRO_extension) +print ("Geom shape name:", HYDRO_extension.GetName()) + +[reg_extension] = geompy.SubShapeAll(HYDRO_extension, geompy.ShapeType["FACE"]) +#children = getChildrenInStudy(HYDRO_extension) +#extension_domaine_original_Outer = children["extension_domaine_original_Outer"] +#TODO: better identification +extension_domaine_original_Outer = geompy.CreateGroup(HYDRO_extension, geompy.ShapeType["EDGE"]) +geompy.UnionIDs(extension_domaine_original_Outer, [3]) +geompy.addToStudyInFather( HYDRO_extension, extension_domaine_original_Outer, 'extension_domaine_original_Outer' ) + +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 +extensionEnglobante = smesh.Mesh(HYDRO_extension) + +NETGEN_2D = extensionEnglobante.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 ) + +([origMeshBrd], status) = smesh.CreateMeshesFromMED(fileMeshBrd) +FreeBorders = origMeshBrd.GetGroupByName("FreeBorders") + +Import_1D = extensionEnglobante.UseExisting1DElements(geom=extension_domaine_original_Outer) +Source_Edges_1 = Import_1D.SourceEdges( FreeBorders ,1,1) + +isDone = extensionEnglobante.Compute() + +controlMeshStats(extensionEnglobante, 4303, 588, 8371) + +if salome.sg.hasDesktop(): + salome.sg.updateObjBrowser()