From: Christophe Bourcier Date: Thu, 15 Feb 2018 14:21:05 +0000 (+0100) Subject: Rename tests without test_ prefix X-Git-Tag: V8_5_0a1~2 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=d797fa4d76751c59832d908640eea64483d0bacd;p=plugins%2Fhybridplugin.git Rename tests without test_ prefix --- diff --git a/tests/advanced_text_option.py b/tests/advanced_text_option.py new file mode 100644 index 0000000..f4f7687 --- /dev/null +++ b/tests/advanced_text_option.py @@ -0,0 +1,126 @@ +# -*- coding: utf-8 -*- + +import sys +import salome + +salome.salome_init() +theStudy = salome.myStudy + +### +### GEOM component +### + +import GEOM +from salome.geom import geomBuilder +import math +import SALOMEDS + + +geompy = geomBuilder.New(theStudy) + +O = geompy.MakeVertex(0, 0, 0) +OX = geompy.MakeVectorDXDYDZ(1, 0, 0) +OY = geompy.MakeVectorDXDYDZ(0, 1, 0) +OZ = geompy.MakeVectorDXDYDZ(0, 0, 1) +O_1 = geompy.MakeVertex(0, 0, 0) +OX_1 = geompy.MakeVectorDXDYDZ(1, 0, 0) +OY_1 = geompy.MakeVectorDXDYDZ(0, 1, 0) +OZ_1 = geompy.MakeVectorDXDYDZ(0, 0, 1) +Cylinder_1 = geompy.MakeCylinderRH(0.5, 5) +Cylinder_2 = geompy.MakeCylinderRH(0.3, 3) +Rotation_1 = geompy.MakeRotation(Cylinder_2, OY_1, -90*math.pi/180.0) +Translation_1 = geompy.MakeTranslation(Rotation_1, 0, 0, 1.5) +piquage = geompy.MakeFuseList([Cylinder_1, Translation_1], True, True) +[Outlet] = geompy.SubShapes(piquage, [15]) +[Inlet_z,Inlet_x] = geompy.SubShapes(piquage, [3, 22]) +[corner] = geompy.SubShapes(piquage, [14]) +[geomObj_1] = geompy.SubShapeAll(Outlet, geompy.ShapeType["FACE"]) +[geomObj_2] = geompy.SubShapeAll(Inlet_z, geompy.ShapeType["FACE"]) +[geomObj_3] = geompy.SubShapeAll(Inlet_x, geompy.ShapeType["FACE"]) +geomObj_4 = geompy.MakeVertex(0, 0, 0) +geomObj_5 = geompy.MakeVectorDXDYDZ(1, 0, 0) +geomObj_6 = geompy.MakeVectorDXDYDZ(0, 1, 0) +geomObj_7 = geompy.MakeVectorDXDYDZ(0, 0, 1) +Wall = geompy.CreateGroup(piquage, geompy.ShapeType["FACE"]) +geompy.UnionIDs(Wall, [7, 17]) +[geomObj_8,geomObj_9] = geompy.SubShapeAll(Wall, geompy.ShapeType["SHAPE"]) +[geomObj_10,geomObj_11] = geompy.SubShapeAll(Wall, geompy.ShapeType["SHAPE"]) +[geomObj_12,geomObj_13] = geompy.SubShapeAll(Wall, geompy.ShapeType["FACE"]) +[geomObj_14,geomObj_15] = geompy.SubShapeAll(Wall, geompy.ShapeType["SHAPE"]) +geompy.addToStudy( O, 'O' ) +geompy.addToStudy( OX, 'OX' ) +geompy.addToStudy( OY, 'OY' ) +geompy.addToStudy( OZ, 'OZ' ) +geompy.addToStudy( O_1, 'O' ) +geompy.addToStudy( OX_1, 'OX' ) +geompy.addToStudy( OY_1, 'OY' ) +geompy.addToStudy( OZ_1, 'OZ' ) +geompy.addToStudy( Cylinder_1, 'Cylinder_1' ) +geompy.addToStudy( Cylinder_2, 'Cylinder_2' ) +geompy.addToStudy( Rotation_1, 'Rotation_1' ) +geompy.addToStudy( Translation_1, 'Translation_1' ) +geompy.addToStudy( piquage, 'piquage' ) +geompy.addToStudyInFather( piquage, Outlet, 'Outlet' ) +geompy.addToStudyInFather( piquage, Inlet_z, 'Inlet_z' ) +geompy.addToStudyInFather( piquage, Inlet_x, 'Inlet_x' ) +geompy.addToStudyInFather( piquage, corner, 'corner' ) +geompy.addToStudyInFather( piquage, Wall, 'Wall' ) + +### +### SMESH component +### + +import SMESH, SALOMEDS +from salome.smesh import smeshBuilder + +smesh = smeshBuilder.New(theStudy) + +Mesh_with_imprinting_set_by_groups = smesh.Mesh(piquage) +NETGEN_2D_1 = Mesh_with_imprinting_set_by_groups.Triangle(algo=smeshBuilder.NETGEN_1D2D) +NETGEN_Parameters_2D = NETGEN_2D_1.Parameters() +NETGEN_Parameters_2D.SetMinSize( 0.01 ) +NETGEN_Parameters_2D.SetLocalSizeOnShape(corner, 0.01) +NETGEN_Parameters_2D.SetFineness( 5 ) +NETGEN_Parameters_2D.SetGrowthRate( 0.1 ) +NETGEN_Parameters_2D.SetNbSegPerEdge( 2 ) +NETGEN_Parameters_2D.SetNbSegPerRadius( 3 ) +#Mesh_with_imprinting_set_by_groups.Triangle(algo=smeshBuilder.MG_CADSurf) +HYBRID_3D_2_2 = Mesh_with_imprinting_set_by_groups.Tetrahedron(algo=smeshBuilder.HYBRID) +HYBRID_Parameters_2 = HYBRID_3D_2_2.Parameters() +HYBRID_Parameters_2.SetElementGeneration( 0 ) +HYBRID_Parameters_2.SetHeightFirstLayer( 0.01 ) +HYBRID_Parameters_2.SetBoundaryLayersProgression( 1.1 ) +HYBRID_Parameters_2.SetNbOfBoundaryLayers( 3 ) +HYBRID_Parameters_2.SetFacesWithLayers( [ 7, 17 ] ) +HYBRID_Parameters_2.SetFacesWithImprinting( [ 22, 3, 15 ] ) +HYBRID_Parameters_2.SetLayersOnAllWrap( 0 ) +isDone = Mesh_with_imprinting_set_by_groups.Compute() + +if not isDone: + raise Exception("Problem in mesh generation") + +Nb_elems_0 = Mesh_with_imprinting_set_by_groups.NbVolumes() + +print "Nb_elems_0: ", Nb_elems_0 + +Inlet_x_3 = Mesh_with_imprinting_set_by_groups.GroupOnGeom(Inlet_x,'Inlet_x',SMESH.FACE) +Inlet_z_3 = Mesh_with_imprinting_set_by_groups.GroupOnGeom(Inlet_z,'Inlet_z',SMESH.FACE) +Outlet_3 = Mesh_with_imprinting_set_by_groups.GroupOnGeom(Outlet,'Outlet',SMESH.FACE) +Wall_3 = Mesh_with_imprinting_set_by_groups.GroupOnGeom(Wall,'Wall',SMESH.FACE) + +# Add an advanced option as text +HYBRID_Parameters_2.SetAdvancedOption( '--boundary_layer_height_relative_to_local_surface_size yes' ) +isDone = Mesh_with_imprinting_set_by_groups.Compute() + +if not isDone: + raise Exception("Problem in mesh generation") + +Nb_elems_1 = Mesh_with_imprinting_set_by_groups.NbVolumes() + +print "Nb_elems_1: ", Nb_elems_1 + +# Check that the number of elements is changed by the option +assert Nb_elems_1> 1.5*Nb_elems_0, "Advanced option as text does not work" + +if salome.sg.hasDesktop(): + salome.sg.updateObjBrowser(True) diff --git a/tests/cartesian_core_size.py b/tests/cartesian_core_size.py new file mode 100644 index 0000000..c767dd7 --- /dev/null +++ b/tests/cartesian_core_size.py @@ -0,0 +1,107 @@ +# -*- coding: utf-8 -*- + + +import sys +import salome + +salome.salome_init() +theStudy = salome.myStudy + +### +### GEOM component +### + +import GEOM +from salome.geom import geomBuilder +import math +import SALOMEDS + + +geompy = geomBuilder.New(theStudy) + +O = geompy.MakeVertex(0, 0, 0) +OX = geompy.MakeVectorDXDYDZ(1, 0, 0) +OY = geompy.MakeVectorDXDYDZ(0, 1, 0) +OZ = geompy.MakeVectorDXDYDZ(0, 0, 1) +Cylinder_1 = geompy.MakeCylinderRH(100, 300) +geompy.addToStudy( O, 'O' ) +geompy.addToStudy( OX, 'OX' ) +geompy.addToStudy( OY, 'OY' ) +geompy.addToStudy( OZ, 'OZ' ) +geompy.addToStudy( Cylinder_1, 'Cylinder_1' ) + +### +### SMESH component +### + +import SMESH, SALOMEDS +from salome.smesh import smeshBuilder + +from salome.HYBRIDPlugin import HYBRIDPluginBuilder + +smesh = smeshBuilder.New(theStudy) + +# Hybrid mesh with hexa dominant core +# =================================== + +Mesh_1 = smesh.Mesh(Cylinder_1) + +MG_CADSurf = Mesh_1.Triangle(algo=smeshBuilder.MG_CADSurf) + +MG_Hybrid = Mesh_1.Tetrahedron(algo=smeshBuilder.HYBRID) +MG_Hybrid_Parameters_1 = MG_Hybrid.Parameters() +MG_Hybrid_Parameters_1.SetElementGeneration( HYBRIDPluginBuilder.Generation_Hexa_Dominant ) +MG_Hybrid_Parameters_1.SetHeightFirstLayer( 1 ) +MG_Hybrid_Parameters_1.SetNbOfBoundaryLayers( 3 ) + +isDone = Mesh_1.Compute() + +nb_hexas_1 = Mesh_1.NbHexas() + +# check that hexaedra have been genereted +assert nb_hexas_1 > 0 + +# Hybrid mesh with cartesian core +# =============================== + +Mesh_2 = smesh.Mesh(Cylinder_1) + +MG_CADSurf_1 = Mesh_2.Triangle(algo=smeshBuilder.MG_CADSurf) + +MG_Hybrid_1 = Mesh_2.Tetrahedron(algo=smeshBuilder.HYBRID) +MG_Hybrid_Parameters_2 = MG_Hybrid_1.Parameters() +MG_Hybrid_Parameters_2.SetElementGeneration( HYBRIDPluginBuilder.Generation_Cartesian_Core ) +MG_Hybrid_Parameters_2.SetHeightFirstLayer( 1 ) +MG_Hybrid_Parameters_2.SetNbOfBoundaryLayers( 3 ) + +isDone = Mesh_2.Compute() + +nb_hexas_2 = Mesh_2.NbHexas() + +# check that hexaedra have been genereted +assert nb_hexas_2 > 0 + + +# Hybrid mesh with cartesian core with fine core elements size +# ============================================================ + +Mesh_3 = smesh.Mesh(Cylinder_1) + +MG_CADSurf_1 = Mesh_3.Triangle(algo=smeshBuilder.MG_CADSurf) + +MG_Hybrid_1 = Mesh_3.Tetrahedron(algo=smeshBuilder.HYBRID) +MG_Hybrid_Parameters_3 = MG_Hybrid_1.Parameters() +MG_Hybrid_Parameters_3.SetElementGeneration( HYBRIDPluginBuilder.Generation_Cartesian_Core ) +MG_Hybrid_Parameters_3.SetHeightFirstLayer( 1 ) +MG_Hybrid_Parameters_3.SetNbOfBoundaryLayers( 3 ) +MG_Hybrid_Parameters_3.SetCoreSize( 10 ) + +isDone = Mesh_3.Compute() + +nb_hexas_3 = Mesh_3.NbHexas() + +# check that more hexaedra have been genereted +assert nb_hexas_3 > nb_hexas_2 + +if salome.sg.hasDesktop(): + salome.sg.updateObjBrowser(True) diff --git a/tests/enforced_mesh.py b/tests/enforced_mesh.py new file mode 100644 index 0000000..d2675f2 --- /dev/null +++ b/tests/enforced_mesh.py @@ -0,0 +1,168 @@ +# -*- coding: utf-8 -*- + +import sys +import salome + +salome.salome_init() +theStudy = salome.myStudy + +### +### GEOM component +### + +import GEOM +from salome.geom import geomBuilder +import math +import SALOMEDS + + +geompy = geomBuilder.New(theStudy) + +O = geompy.MakeVertex(0, 0, 0) +OX = geompy.MakeVectorDXDYDZ(1, 0, 0) +OY = geompy.MakeVectorDXDYDZ(0, 1, 0) +OZ = geompy.MakeVectorDXDYDZ(0, 0, 1) +Cylinder_1 = geompy.MakeCylinderRH(0.5, 5) +Cylinder_2 = geompy.MakeCylinderRH(0.3, 3) +Rotation_1 = geompy.MakeRotation(Cylinder_2, OY, -90*math.pi/180.0) +Translation_1 = geompy.MakeTranslation(Rotation_1, 0, 0, 1.5) +piquage = geompy.MakeFuseList([Cylinder_1, Translation_1], True, True) +[Outlet] = geompy.SubShapes(piquage, [15]) +[Inlet_z,Inlet_x] = geompy.SubShapes(piquage, [3, 22]) +[corner] = geompy.SubShapes(piquage, [14]) +geomObj_1 = geompy.MakeVertex(0, 0, 0) +geomObj_2 = geompy.MakeVectorDXDYDZ(1, 0, 0) +geomObj_3 = geompy.MakeVectorDXDYDZ(0, 1, 0) +geomObj_4 = geompy.MakeVectorDXDYDZ(0, 0, 1) +Wall = geompy.CreateGroup(piquage, geompy.ShapeType["FACE"]) +geompy.UnionIDs(Wall, [7, 17]) +geompy.addToStudy( O, 'O' ) +geompy.addToStudy( OX, 'OX' ) +geompy.addToStudy( OY, 'OY' ) +geompy.addToStudy( OZ, 'OZ' ) +geompy.addToStudy( Cylinder_1, 'Cylinder_1' ) +geompy.addToStudy( Cylinder_2, 'Cylinder_2' ) +geompy.addToStudy( Rotation_1, 'Rotation_1' ) +geompy.addToStudy( Translation_1, 'Translation_1' ) +geompy.addToStudy( piquage, 'piquage' ) +geompy.addToStudyInFather( piquage, Inlet_x, 'Inlet_x' ) +geompy.addToStudyInFather( piquage, Outlet, 'Outlet' ) +geompy.addToStudyInFather( piquage, Wall, 'Wall' ) +geompy.addToStudyInFather( piquage, Inlet_z, 'Inlet_z' ) +geompy.addToStudyInFather( piquage, corner, 'corner' ) + +p1 = geompy.MakeVertex(0, -0.25, 1) +p2 = geompy.MakeVertex(0, 0.25, 1) +p3 = geompy.MakeVertex(0, 0.25, 3) +p4 = geompy.MakeVertex(0, -0.25, 3) + +wire = geompy.MakePolyline([p1, p2, p3, p4, p1]) +face = geompy.MakeFace(wire, 1, theName="face") + +### +### SMESH component +### + +import SMESH, SALOMEDS +from salome.smesh import smeshBuilder + +from salome.StdMeshers import StdMeshersBuilder + +smesh = smeshBuilder.New(theStudy) + +Mesh_faces = smesh.Mesh(face) +Mesh_faces.Triangle(algo=smeshBuilder.MG_CADSurf) +Mesh_faces.Compute() + + +# Viscous layers with Netgen additional hypothesis +# ================================================ + +Mesh_1 = smesh.Mesh(piquage) +NETGEN_2D = Mesh_1.Triangle(algo=smeshBuilder.NETGEN_1D2D) +NETGEN_2D_Parameters = NETGEN_2D.Parameters() + +NETGEN_2D_Parameters.SetMinSize( 0.01 ) +NETGEN_2D_Parameters.SetLocalSizeOnShape(corner, 0.01) +NETGEN_2D_Parameters.SetFineness( 5 ) +NETGEN_2D_Parameters.SetGrowthRate( 0.1 ) +NETGEN_2D_Parameters.SetNbSegPerEdge( 2 ) +NETGEN_2D_Parameters.SetNbSegPerRadius( 3 ) + +NETGEN_3D = Mesh_1.Tetrahedron() +Viscous_Layers_1 = NETGEN_3D.ViscousLayers(0.05,3,1.1,[],1,StdMeshersBuilder.SURF_OFFSET_SMOOTH) +Viscous_Layers_1.SetTotalThickness( 0.05 ) +Viscous_Layers_1.SetNumberLayers( 3 ) +Viscous_Layers_1.SetStretchFactor( 1.1 ) +Viscous_Layers_1.SetMethod( StdMeshersBuilder.SURF_OFFSET_SMOOTH ) +Viscous_Layers_1.SetFaces( [ 7, 17 ], 0 ) + + +#isDone = Mesh_1.Compute() +#Mesh_1.SplitVolumesIntoTetra( Mesh_1, 1 ) + +Outlet_1 = Mesh_1.GroupOnGeom(Outlet,'Outlet',SMESH.FACE) +Wall_1 = Mesh_1.GroupOnGeom(Wall,'Wall',SMESH.FACE) +Inlet_z_1 = Mesh_1.GroupOnGeom(Inlet_z,'Inlet_z',SMESH.FACE) +Inlet_x_1 = Mesh_1.GroupOnGeom(Inlet_x,'Inlet_x',SMESH.FACE) + +# Enforced mesh without layer +# =========================== + +Mesh_2 = smesh.Mesh(piquage, "Mesh_without_layer") + +NETGEN_2D_1_1 = Mesh_2.Triangle(algo=smeshBuilder.NETGEN_1D2D) +status = Mesh_2.AddHypothesis(NETGEN_2D_Parameters) + +MG_Hybrid_2 = Mesh_2.Tetrahedron(algo=smeshBuilder.HYBRID) +MG_Hybrid_Parameters_2 = MG_Hybrid_2.Parameters() +MG_Hybrid_Parameters_2.SetLayersOnAllWrap( 0 ) +MG_Hybrid_Parameters_2.SetElementGeneration( 0 ) +#MG_Hybrid_Parameters_2.SetHeightFirstLayer( 0.01 ) +#MG_Hybrid_Parameters_2.SetBoundaryLayersProgression( 1.1 ) +#MG_Hybrid_Parameters_2.SetNbOfBoundaryLayers( 3 ) +MG_Hybrid_Parameters_2.SetEnforcedMeshWithGroup( Mesh_faces.GetMesh(), SMESH.FACE, "LayersGroup" ) +MG_Hybrid_Parameters_2.SetKeepFiles(1) + +isDone = Mesh_2.Compute() + +if not isDone: + raise Exception("Error when computing Mesh_without_layer") + +# Check that a group has been created with the enforced mesh +assert len(Mesh_2.GetGroups()) == 1 +assert Mesh_2.GetGroups()[0].GetName() == 'LayersGroup' +assert Mesh_2.GetGroups()[0].Size() > 0 + +# Enforced mesh with layers +# ========================= + +Mesh_3 = smesh.Mesh(piquage, "Mesh_with_layer") + +NETGEN_2D_1_1 = Mesh_3.Triangle(algo=smeshBuilder.NETGEN_1D2D) +status = Mesh_3.AddHypothesis(NETGEN_2D_Parameters) + +MG_Hybrid_3 = Mesh_3.Tetrahedron(algo=smeshBuilder.HYBRID) +MG_Hybrid_Parameters_3 = MG_Hybrid_3.Parameters() +MG_Hybrid_Parameters_3.SetLayersOnAllWrap( 0 ) +MG_Hybrid_Parameters_3.SetElementGeneration( 0 ) +MG_Hybrid_Parameters_3.SetHeightFirstLayer( 0.01 ) +MG_Hybrid_Parameters_3.SetBoundaryLayersProgression( 1.1 ) +MG_Hybrid_Parameters_3.SetNbOfBoundaryLayers( 3 ) +MG_Hybrid_Parameters_3.SetEnforcedMeshWithGroup( Mesh_faces.GetMesh(), SMESH.FACE, "LayersGroup" ) +MG_Hybrid_Parameters_3.SetKeepFiles(1) +MG_Hybrid_3.SetFacesWithLayers( Wall ) + + +isDone = Mesh_3.Compute() + +if not isDone: + raise Exception("Error when computing Mesh_with_layer") + +# Check that a group has been created with the enforced mesh +assert len(Mesh_3.GetGroups()) == 1 +assert Mesh_3.GetGroups()[0].GetName() == 'LayersGroup' +assert Mesh_3.GetGroups()[0].Size() > 0 + +if salome.sg.hasDesktop(): + salome.sg.updateObjBrowser(1) diff --git a/tests/layers_imprinting.py b/tests/layers_imprinting.py new file mode 100644 index 0000000..d95d23f --- /dev/null +++ b/tests/layers_imprinting.py @@ -0,0 +1,222 @@ +# -*- coding: utf-8 -*- + +import sys +import salome + +salome.salome_init() +theStudy = salome.myStudy + +### +### GEOM component +### + +import GEOM +from salome.geom import geomBuilder +import math +import SALOMEDS + + +geompy = geomBuilder.New(theStudy) + +O = geompy.MakeVertex(0, 0, 0) +OX = geompy.MakeVectorDXDYDZ(1, 0, 0) +OY = geompy.MakeVectorDXDYDZ(0, 1, 0) +OZ = geompy.MakeVectorDXDYDZ(0, 0, 1) +Cylinder_1 = geompy.MakeCylinderRH(0.5, 5) +Cylinder_2 = geompy.MakeCylinderRH(0.3, 3) +Rotation_1 = geompy.MakeRotation(Cylinder_2, OY, -90*math.pi/180.0) +Translation_1 = geompy.MakeTranslation(Rotation_1, 0, 0, 1.5) +piquage = geompy.MakeFuseList([Cylinder_1, Translation_1], True, True) +[Outlet] = geompy.SubShapes(piquage, [15]) +[Inlet_z,Inlet_x] = geompy.SubShapes(piquage, [3, 22]) +[corner] = geompy.SubShapes(piquage, [14]) +geomObj_1 = geompy.MakeVertex(0, 0, 0) +geomObj_2 = geompy.MakeVectorDXDYDZ(1, 0, 0) +geomObj_3 = geompy.MakeVectorDXDYDZ(0, 1, 0) +geomObj_4 = geompy.MakeVectorDXDYDZ(0, 0, 1) +Wall = geompy.CreateGroup(piquage, geompy.ShapeType["FACE"]) +geompy.UnionIDs(Wall, [7, 17]) +geompy.addToStudy( O, 'O' ) +geompy.addToStudy( OX, 'OX' ) +geompy.addToStudy( OY, 'OY' ) +geompy.addToStudy( OZ, 'OZ' ) +geompy.addToStudy( Cylinder_1, 'Cylinder_1' ) +geompy.addToStudy( Cylinder_2, 'Cylinder_2' ) +geompy.addToStudy( Rotation_1, 'Rotation_1' ) +geompy.addToStudy( Translation_1, 'Translation_1' ) +geompy.addToStudy( piquage, 'piquage' ) +geompy.addToStudyInFather( piquage, Inlet_x, 'Inlet_x' ) +geompy.addToStudyInFather( piquage, Outlet, 'Outlet' ) +geompy.addToStudyInFather( piquage, Wall, 'Wall' ) +geompy.addToStudyInFather( piquage, Inlet_z, 'Inlet_z' ) +geompy.addToStudyInFather( piquage, corner, 'corner' ) + +geom_groups = [Inlet_x, Inlet_z, Outlet, Wall] +d_geom_groups = {} + +### +### SMESH component +### + +import SMESH, SALOMEDS +from salome.smesh import smeshBuilder + +from salome.StdMeshers import StdMeshersBuilder +from salome.HYBRIDPlugin import HYBRIDPluginBuilder + +smesh = smeshBuilder.New(theStudy) + + +# Viscous layers without imprinting +# ================================= + +Mesh_1 = smesh.Mesh(piquage, "Mesh_without_imprinting") +NETGEN_2D = Mesh_1.Triangle(algo=smeshBuilder.NETGEN_1D2D) +NETGEN_2D_Parameters = NETGEN_2D.Parameters() + +NETGEN_2D_Parameters.SetMinSize( 0.01 ) +NETGEN_2D_Parameters.SetLocalSizeOnShape(corner, 0.01) +NETGEN_2D_Parameters.SetFineness( 5 ) +NETGEN_2D_Parameters.SetGrowthRate( 0.1 ) +NETGEN_2D_Parameters.SetNbSegPerEdge( 2 ) +NETGEN_2D_Parameters.SetNbSegPerRadius( 3 ) + +MG_Hybrid = Mesh_1.Tetrahedron(algo=smeshBuilder.HYBRID) +MG_Hybrid_Parameters_1 = MG_Hybrid.Parameters() +MG_Hybrid_Parameters_1.SetLayersOnAllWrap( 0 ) +MG_Hybrid_Parameters_1.SetElementGeneration( HYBRIDPluginBuilder.Generation_Tetra_Dominant ) +MG_Hybrid_Parameters_1.SetHeightFirstLayer( 0.01 ) +MG_Hybrid_Parameters_1.SetBoundaryLayersProgression( 1.1 ) +MG_Hybrid_Parameters_1.SetNbOfBoundaryLayers( 3 ) +MG_Hybrid_Parameters_1.SetFacesWithLayers( [ 7, 17 ] ) + + +isDone = Mesh_1.Compute() + +if not isDone: + raise Exception("Error when computing Mesh_without_imprinting") + +d_groups_1 = {} + +for geom_group in geom_groups: + name = geom_group.GetName() + gr = Mesh_1.Group(geom_group) + d_groups_1[name] = gr + d_geom_groups[name] = geom_group + +assert Mesh_1.NbQuadrangles() == 0 + +shape_volume = geompy.BasicProperties(piquage)[2] + +# Compare whole mesh volume +volume_error_1 = abs(shape_volume-Mesh_1.GetVolume())/shape_volume + +assert volume_error_1 < 0.015 + +# Viscous layers with imprinting +# ============================== + +Mesh_2 = smesh.Mesh(piquage, "Mesh_with_imprinting") + +NETGEN_2D_1_1 = Mesh_2.Triangle(algo=smeshBuilder.NETGEN_1D2D) +status = Mesh_2.AddHypothesis(NETGEN_2D_Parameters) + +MG_Hybrid_2 = Mesh_2.Tetrahedron(algo=smeshBuilder.HYBRID) +MG_Hybrid_Parameters_2 = MG_Hybrid_2.Parameters() +MG_Hybrid_Parameters_2.SetLayersOnAllWrap( 0 ) +MG_Hybrid_Parameters_2.SetElementGeneration( HYBRIDPluginBuilder.Generation_Tetra_Dominant ) +MG_Hybrid_Parameters_2.SetHeightFirstLayer( 0.01 ) +MG_Hybrid_Parameters_2.SetBoundaryLayersProgression( 1.1 ) +MG_Hybrid_Parameters_2.SetNbOfBoundaryLayers( 3 ) +MG_Hybrid_Parameters_2.SetFacesWithLayers( [ 7, 17 ] ) +MG_Hybrid_Parameters_2.SetFacesWithImprinting( [ 22, 15, 3 ] ) + +isDone = Mesh_2.Compute() + +if not isDone: + raise Exception("Error when computing Mesh_with_imprinting") + +assert Mesh_2.NbQuadrangles() > 0 + +d_groups_2 = {} + +for geom_group in geom_groups: + name = geom_group.GetName() + gr = Mesh_2.Group(geom_group) + d_groups_2[name] = gr + +faces_imprinted = ["Inlet_x", "Inlet_z", "Outlet"] + +# Check viscous layers with imprinting +for name in faces_imprinted: + geom_area = geompy.BasicProperties(d_geom_groups[name])[1] + gr_1 = d_groups_1[name] + gr_2 = d_groups_2[name] + #assert gr_1.Size() > 0 + assert gr_2.Size() > 0 + # Nb of quadrangles is in 7th index of mesh info + assert gr_2.GetMeshInfo()[7] > 0 + + # Compare mesh group and geom group + area_error_1 = abs(geom_area-smesh.GetArea(gr_2))/geom_area + assert area_error_1 < 0.025 + # Compare mesh group with imprinting and mesh group without imprinting + area_error_2 = abs(smesh.GetArea(gr_1)-smesh.GetArea(gr_2))/smesh.GetArea(gr_1) + assert area_error_2 < 1e-10 + +# Compare whole mesh volume +mesh_2_volume = Mesh_2.GetVolume() +volume_error_2 = abs(shape_volume-mesh_2_volume)/shape_volume + +assert volume_error_2 < 0.015 + +# Viscous layers with imprinting set by groups +# ============================================ + +Mesh_3 = smesh.Mesh(piquage, "Mesh_with_imprinting_set_by_groups") + +NETGEN_2D_1_1 = Mesh_3.Triangle(algo=smeshBuilder.NETGEN_1D2D) +status = Mesh_3.AddHypothesis(NETGEN_2D_Parameters) + +MG_Hybrid_3 = Mesh_3.Tetrahedron(algo=smeshBuilder.HYBRID) +MG_Hybrid_Parameters_3 = MG_Hybrid_3.Parameters() +MG_Hybrid_Parameters_3.SetLayersOnAllWrap( 0 ) +MG_Hybrid_Parameters_3.SetElementGeneration( HYBRIDPluginBuilder.Generation_Tetra_Dominant ) +MG_Hybrid_Parameters_3.SetHeightFirstLayer( 0.01 ) +MG_Hybrid_Parameters_3.SetBoundaryLayersProgression( 1.1 ) +MG_Hybrid_Parameters_3.SetNbOfBoundaryLayers( 3 ) +MG_Hybrid_3.SetFacesWithLayers( Wall ) +MG_Hybrid_3.SetFacesWithImprinting( [ Inlet_x, Inlet_z, Outlet ] ) + +isDone = Mesh_3.Compute() + +if not isDone: + raise Exception("Error when computing Mesh_with_imprinting_set_by_groups") + +d_groups_3 = {} + +for geom_group in geom_groups: + name = geom_group.GetName() + gr = Mesh_3.Group(geom_group) + d_groups_3[name] = gr + +# Compare whole mesh volume +mesh_3_volume = Mesh_3.GetVolume() +volume_error_3 = abs(mesh_2_volume-mesh_3_volume)/mesh_2_volume + +assert abs(mesh_3_volume-mesh_2_volume)/mesh_2_volume < 1e-10 + +# Check viscous layers with imprinting +for name in faces_imprinted: + gr_2 = d_groups_2[name] + gr_3 = d_groups_3[name] + assert gr_3.Size() > 0 + # Nb of quadrangles is in 7th index of mesh info + assert gr_2.GetMeshInfo()[7] == gr_3.GetMeshInfo()[7] + + # Compare mesh group with imprinting set by ids and mesh group with imprinting set by geom group + area_error_3 = abs(smesh.GetArea(gr_2)-smesh.GetArea(gr_3))/smesh.GetArea(gr_2) + assert area_error_3 < 1e-10 + +if salome.sg.hasDesktop(): + salome.sg.updateObjBrowser(1) diff --git a/tests/layers_imprinting_hexa_core.py b/tests/layers_imprinting_hexa_core.py new file mode 100644 index 0000000..e494785 --- /dev/null +++ b/tests/layers_imprinting_hexa_core.py @@ -0,0 +1,136 @@ +# -*- coding: utf-8 -*- + +# This test is a known failure for MeshGems <= 2.4-5 (but must not crash Salome) + +import sys +import salome + +salome.salome_init() +theStudy = salome.myStudy + +### +### GEOM component +### + +import GEOM +from salome.geom import geomBuilder +import math +import SALOMEDS + + +geompy = geomBuilder.New(theStudy) + +O = geompy.MakeVertex(0, 0, 0) +OX = geompy.MakeVectorDXDYDZ(1, 0, 0) +OY = geompy.MakeVectorDXDYDZ(0, 1, 0) +OZ = geompy.MakeVectorDXDYDZ(0, 0, 1) +Cylinder_1 = geompy.MakeCylinderRH(0.5, 5) +Cylinder_2 = geompy.MakeCylinderRH(0.3, 3) +Rotation_1 = geompy.MakeRotation(Cylinder_2, OY, -90*math.pi/180.0) +Translation_1 = geompy.MakeTranslation(Rotation_1, 0, 0, 1.5) +piquage = geompy.MakeFuseList([Cylinder_1, Translation_1], True, True) +[Outlet] = geompy.SubShapes(piquage, [15]) +[Inlet_z,Inlet_x] = geompy.SubShapes(piquage, [3, 22]) +[corner] = geompy.SubShapes(piquage, [14]) +geomObj_1 = geompy.MakeVertex(0, 0, 0) +geomObj_2 = geompy.MakeVectorDXDYDZ(1, 0, 0) +geomObj_3 = geompy.MakeVectorDXDYDZ(0, 1, 0) +geomObj_4 = geompy.MakeVectorDXDYDZ(0, 0, 1) +Wall = geompy.CreateGroup(piquage, geompy.ShapeType["FACE"]) +geompy.UnionIDs(Wall, [7, 17]) +geompy.addToStudy( O, 'O' ) +geompy.addToStudy( OX, 'OX' ) +geompy.addToStudy( OY, 'OY' ) +geompy.addToStudy( OZ, 'OZ' ) +geompy.addToStudy( Cylinder_1, 'Cylinder_1' ) +geompy.addToStudy( Cylinder_2, 'Cylinder_2' ) +geompy.addToStudy( Rotation_1, 'Rotation_1' ) +geompy.addToStudy( Translation_1, 'Translation_1' ) +geompy.addToStudy( piquage, 'piquage' ) +geompy.addToStudyInFather( piquage, Inlet_x, 'Inlet_x' ) +geompy.addToStudyInFather( piquage, Outlet, 'Outlet' ) +geompy.addToStudyInFather( piquage, Wall, 'Wall' ) +geompy.addToStudyInFather( piquage, Inlet_z, 'Inlet_z' ) +geompy.addToStudyInFather( piquage, corner, 'corner' ) + +geom_groups = [Inlet_x, Inlet_z, Outlet, Wall] +d_geom_groups = {} + +### +### SMESH component +### + +import SMESH, SALOMEDS +from salome.smesh import smeshBuilder + +from salome.StdMeshers import StdMeshersBuilder +from salome.HYBRIDPlugin import HYBRIDPluginBuilder + +smesh = smeshBuilder.New(theStudy) + +# Viscous layers with imprinting (hexa core) +# ========================================== + +Mesh_4 = smesh.Mesh(piquage, "Mesh_with_imprinting_hexa_core") + +NETGEN_2D_1_1 = Mesh_4.Triangle(algo=smeshBuilder.NETGEN_1D2D) +NETGEN_2D_Parameters = NETGEN_2D_1_1.Parameters() + +NETGEN_2D_Parameters.SetMinSize( 0.01 ) +NETGEN_2D_Parameters.SetLocalSizeOnShape(corner, 0.01) +NETGEN_2D_Parameters.SetFineness( 5 ) +NETGEN_2D_Parameters.SetGrowthRate( 0.1 ) +NETGEN_2D_Parameters.SetNbSegPerEdge( 2 ) +NETGEN_2D_Parameters.SetNbSegPerRadius( 3 ) + +MG_Hybrid_4 = Mesh_4.Tetrahedron(algo=smeshBuilder.HYBRID) +MG_Hybrid_Parameters_4 = MG_Hybrid_4.Parameters() +MG_Hybrid_Parameters_4.SetLayersOnAllWrap( 0 ) +MG_Hybrid_Parameters_4.SetElementGeneration( HYBRIDPluginBuilder.Generation_Hexa_Dominant ) +MG_Hybrid_Parameters_4.SetHeightFirstLayer( 0.01 ) +MG_Hybrid_Parameters_4.SetBoundaryLayersProgression( 1.1 ) +MG_Hybrid_Parameters_4.SetNbOfBoundaryLayers( 3 ) +MG_Hybrid_Parameters_4.SetFacesWithLayers( [ 7, 17 ] ) +MG_Hybrid_Parameters_4.SetFacesWithImprinting( [ 22, 15, 3 ] ) + +isDone = Mesh_4.Compute() + +if not isDone: + raise Exception("Error when computing Mesh_with_imprinting_hexa_core") + +assert Mesh_4.NbQuadrangles() > 0 + +d_groups_4 = {} +d_geom_groups = {} + +for geom_group in geom_groups: + name = geom_group.GetName() + gr = Mesh_4.Group(geom_group) + d_groups_4[name] = gr + d_geom_groups[name] = geom_group + +# Compare whole mesh volume +mesh_4_volume = Mesh_4.GetVolume() +shape_volume = geompy.BasicProperties(piquage)[2] +volume_error_4 = abs(shape_volume-mesh_4_volume)/shape_volume + +assert volume_error_4 < 0.015 + +# Check viscous layers with imprinting +faces_imprinted = ["Inlet_x", "Inlet_z", "Outlet"] + +for name in faces_imprinted: + gr_4 = d_groups_4[name] + #assert gr_1.Size() > 0 + assert gr_4.Size() > 0 + # Nb of quadrangles is in 7th index of mesh info + assert gr_4.GetMeshInfo()[7] > 0 + + # Compare mesh group and geom group + geom_area = geompy.BasicProperties(d_geom_groups[name])[1] + area_error_1 = abs(geom_area-smesh.GetArea(gr_4))/geom_area + assert area_error_1 < 0.025 + + +if salome.sg.hasDesktop(): + salome.sg.updateObjBrowser(1) diff --git a/tests/mg_hybrid_pyramids.py b/tests/mg_hybrid_pyramids.py new file mode 100644 index 0000000..f546b5b --- /dev/null +++ b/tests/mg_hybrid_pyramids.py @@ -0,0 +1,92 @@ +# -*- coding: utf-8 -*- + + +import sys +import salome + +salome.salome_init() +theStudy = salome.myStudy + +### +### GEOM component +### + +import GEOM +from salome.geom import geomBuilder +import math +import SALOMEDS + + +geompy = geomBuilder.New(theStudy) + +box_side = 200 + +O = geompy.MakeVertex(0, 0, 0) +OX = geompy.MakeVectorDXDYDZ(1, 0, 0) +OY = geompy.MakeVectorDXDYDZ(0, 1, 0) +OZ = geompy.MakeVectorDXDYDZ(0, 0, 1) +Box_1 = geompy.MakeBoxDXDYDZ(box_side, box_side, box_side) +geompy.addToStudy( O, 'O' ) +geompy.addToStudy( OX, 'OX' ) +geompy.addToStudy( OY, 'OY' ) +geompy.addToStudy( OZ, 'OZ' ) +geompy.addToStudy( Box_1, 'Box_1' ) + +### +### SMESH component +### + +import SMESH, SALOMEDS +from salome.smesh import smeshBuilder + +smesh = smeshBuilder.New(theStudy) +Mesh_1 = smesh.Mesh(Box_1) +MG_CADSurf = Mesh_1.Triangle(algo=smeshBuilder.MG_CADSurf) +MG_CADSurf_Parameters_1 = MG_CADSurf.Parameters() +MG_CADSurf_Parameters_1.SetPhySize( 10 ) +MG_CADSurf_Parameters_1.SetMinSize( 0.34641 ) +MG_CADSurf_Parameters_1.SetMaxSize( 69.282 ) + +isDone = Mesh_1.Compute() + +# Copy the skin mesh +Mesh_2 = smesh.CopyMesh( Mesh_1, 'Mesh_2', 0, 0) + +# Add hybrid +HYBRID_3D = Mesh_1.Tetrahedron(algo=smeshBuilder.HYBRID) +MG_Hybrid_Parameters_1 = HYBRID_3D.Parameters() +MG_Hybrid_Parameters_1.SetElementGeneration( 1 ) +MG_Hybrid_Parameters_1.SetHeightFirstLayer( 1 ) +MG_Hybrid_Parameters_1.SetNbOfBoundaryLayers( 3 ) + +# Compute mesh on CAD +# =================== +isDone = Mesh_1.Compute() + +# Check volume +vol_mesh_1 = smesh.GetVolume(Mesh_1) +vol_box = box_side**3 +assert abs(vol_mesh_1-vol_box)/vol_box < 1e-4 + +# Check number of pyramids +assert Mesh_1.NbPyramids() > 1000 + +# Add hybrid to skin mesh +HYBRID_3D_1 = Mesh_2.Tetrahedron(algo=smeshBuilder.HYBRID,geom=None) +status = Mesh_2.AddHypothesis(MG_Hybrid_Parameters_1,None) + +# Compute mesh without CAD +# ======================== +isDone = Mesh_2.Compute() + +# Check volume +vol_mesh_2 = smesh.GetVolume(Mesh_2) +vol_box = box_side**3 +assert abs(vol_mesh_2-vol_box)/vol_box < 1e-4 + +# Check number of pyramids +assert Mesh_2.NbPyramids() > 1000 + + +if salome.sg.hasDesktop(): + salome.sg.updateObjBrowser(True) diff --git a/tests/test_advanced_text_option.py b/tests/test_advanced_text_option.py deleted file mode 100644 index f4f7687..0000000 --- a/tests/test_advanced_text_option.py +++ /dev/null @@ -1,126 +0,0 @@ -# -*- coding: utf-8 -*- - -import sys -import salome - -salome.salome_init() -theStudy = salome.myStudy - -### -### GEOM component -### - -import GEOM -from salome.geom import geomBuilder -import math -import SALOMEDS - - -geompy = geomBuilder.New(theStudy) - -O = geompy.MakeVertex(0, 0, 0) -OX = geompy.MakeVectorDXDYDZ(1, 0, 0) -OY = geompy.MakeVectorDXDYDZ(0, 1, 0) -OZ = geompy.MakeVectorDXDYDZ(0, 0, 1) -O_1 = geompy.MakeVertex(0, 0, 0) -OX_1 = geompy.MakeVectorDXDYDZ(1, 0, 0) -OY_1 = geompy.MakeVectorDXDYDZ(0, 1, 0) -OZ_1 = geompy.MakeVectorDXDYDZ(0, 0, 1) -Cylinder_1 = geompy.MakeCylinderRH(0.5, 5) -Cylinder_2 = geompy.MakeCylinderRH(0.3, 3) -Rotation_1 = geompy.MakeRotation(Cylinder_2, OY_1, -90*math.pi/180.0) -Translation_1 = geompy.MakeTranslation(Rotation_1, 0, 0, 1.5) -piquage = geompy.MakeFuseList([Cylinder_1, Translation_1], True, True) -[Outlet] = geompy.SubShapes(piquage, [15]) -[Inlet_z,Inlet_x] = geompy.SubShapes(piquage, [3, 22]) -[corner] = geompy.SubShapes(piquage, [14]) -[geomObj_1] = geompy.SubShapeAll(Outlet, geompy.ShapeType["FACE"]) -[geomObj_2] = geompy.SubShapeAll(Inlet_z, geompy.ShapeType["FACE"]) -[geomObj_3] = geompy.SubShapeAll(Inlet_x, geompy.ShapeType["FACE"]) -geomObj_4 = geompy.MakeVertex(0, 0, 0) -geomObj_5 = geompy.MakeVectorDXDYDZ(1, 0, 0) -geomObj_6 = geompy.MakeVectorDXDYDZ(0, 1, 0) -geomObj_7 = geompy.MakeVectorDXDYDZ(0, 0, 1) -Wall = geompy.CreateGroup(piquage, geompy.ShapeType["FACE"]) -geompy.UnionIDs(Wall, [7, 17]) -[geomObj_8,geomObj_9] = geompy.SubShapeAll(Wall, geompy.ShapeType["SHAPE"]) -[geomObj_10,geomObj_11] = geompy.SubShapeAll(Wall, geompy.ShapeType["SHAPE"]) -[geomObj_12,geomObj_13] = geompy.SubShapeAll(Wall, geompy.ShapeType["FACE"]) -[geomObj_14,geomObj_15] = geompy.SubShapeAll(Wall, geompy.ShapeType["SHAPE"]) -geompy.addToStudy( O, 'O' ) -geompy.addToStudy( OX, 'OX' ) -geompy.addToStudy( OY, 'OY' ) -geompy.addToStudy( OZ, 'OZ' ) -geompy.addToStudy( O_1, 'O' ) -geompy.addToStudy( OX_1, 'OX' ) -geompy.addToStudy( OY_1, 'OY' ) -geompy.addToStudy( OZ_1, 'OZ' ) -geompy.addToStudy( Cylinder_1, 'Cylinder_1' ) -geompy.addToStudy( Cylinder_2, 'Cylinder_2' ) -geompy.addToStudy( Rotation_1, 'Rotation_1' ) -geompy.addToStudy( Translation_1, 'Translation_1' ) -geompy.addToStudy( piquage, 'piquage' ) -geompy.addToStudyInFather( piquage, Outlet, 'Outlet' ) -geompy.addToStudyInFather( piquage, Inlet_z, 'Inlet_z' ) -geompy.addToStudyInFather( piquage, Inlet_x, 'Inlet_x' ) -geompy.addToStudyInFather( piquage, corner, 'corner' ) -geompy.addToStudyInFather( piquage, Wall, 'Wall' ) - -### -### SMESH component -### - -import SMESH, SALOMEDS -from salome.smesh import smeshBuilder - -smesh = smeshBuilder.New(theStudy) - -Mesh_with_imprinting_set_by_groups = smesh.Mesh(piquage) -NETGEN_2D_1 = Mesh_with_imprinting_set_by_groups.Triangle(algo=smeshBuilder.NETGEN_1D2D) -NETGEN_Parameters_2D = NETGEN_2D_1.Parameters() -NETGEN_Parameters_2D.SetMinSize( 0.01 ) -NETGEN_Parameters_2D.SetLocalSizeOnShape(corner, 0.01) -NETGEN_Parameters_2D.SetFineness( 5 ) -NETGEN_Parameters_2D.SetGrowthRate( 0.1 ) -NETGEN_Parameters_2D.SetNbSegPerEdge( 2 ) -NETGEN_Parameters_2D.SetNbSegPerRadius( 3 ) -#Mesh_with_imprinting_set_by_groups.Triangle(algo=smeshBuilder.MG_CADSurf) -HYBRID_3D_2_2 = Mesh_with_imprinting_set_by_groups.Tetrahedron(algo=smeshBuilder.HYBRID) -HYBRID_Parameters_2 = HYBRID_3D_2_2.Parameters() -HYBRID_Parameters_2.SetElementGeneration( 0 ) -HYBRID_Parameters_2.SetHeightFirstLayer( 0.01 ) -HYBRID_Parameters_2.SetBoundaryLayersProgression( 1.1 ) -HYBRID_Parameters_2.SetNbOfBoundaryLayers( 3 ) -HYBRID_Parameters_2.SetFacesWithLayers( [ 7, 17 ] ) -HYBRID_Parameters_2.SetFacesWithImprinting( [ 22, 3, 15 ] ) -HYBRID_Parameters_2.SetLayersOnAllWrap( 0 ) -isDone = Mesh_with_imprinting_set_by_groups.Compute() - -if not isDone: - raise Exception("Problem in mesh generation") - -Nb_elems_0 = Mesh_with_imprinting_set_by_groups.NbVolumes() - -print "Nb_elems_0: ", Nb_elems_0 - -Inlet_x_3 = Mesh_with_imprinting_set_by_groups.GroupOnGeom(Inlet_x,'Inlet_x',SMESH.FACE) -Inlet_z_3 = Mesh_with_imprinting_set_by_groups.GroupOnGeom(Inlet_z,'Inlet_z',SMESH.FACE) -Outlet_3 = Mesh_with_imprinting_set_by_groups.GroupOnGeom(Outlet,'Outlet',SMESH.FACE) -Wall_3 = Mesh_with_imprinting_set_by_groups.GroupOnGeom(Wall,'Wall',SMESH.FACE) - -# Add an advanced option as text -HYBRID_Parameters_2.SetAdvancedOption( '--boundary_layer_height_relative_to_local_surface_size yes' ) -isDone = Mesh_with_imprinting_set_by_groups.Compute() - -if not isDone: - raise Exception("Problem in mesh generation") - -Nb_elems_1 = Mesh_with_imprinting_set_by_groups.NbVolumes() - -print "Nb_elems_1: ", Nb_elems_1 - -# Check that the number of elements is changed by the option -assert Nb_elems_1> 1.5*Nb_elems_0, "Advanced option as text does not work" - -if salome.sg.hasDesktop(): - salome.sg.updateObjBrowser(True) diff --git a/tests/test_cartesian_core_size.py b/tests/test_cartesian_core_size.py deleted file mode 100644 index c767dd7..0000000 --- a/tests/test_cartesian_core_size.py +++ /dev/null @@ -1,107 +0,0 @@ -# -*- coding: utf-8 -*- - - -import sys -import salome - -salome.salome_init() -theStudy = salome.myStudy - -### -### GEOM component -### - -import GEOM -from salome.geom import geomBuilder -import math -import SALOMEDS - - -geompy = geomBuilder.New(theStudy) - -O = geompy.MakeVertex(0, 0, 0) -OX = geompy.MakeVectorDXDYDZ(1, 0, 0) -OY = geompy.MakeVectorDXDYDZ(0, 1, 0) -OZ = geompy.MakeVectorDXDYDZ(0, 0, 1) -Cylinder_1 = geompy.MakeCylinderRH(100, 300) -geompy.addToStudy( O, 'O' ) -geompy.addToStudy( OX, 'OX' ) -geompy.addToStudy( OY, 'OY' ) -geompy.addToStudy( OZ, 'OZ' ) -geompy.addToStudy( Cylinder_1, 'Cylinder_1' ) - -### -### SMESH component -### - -import SMESH, SALOMEDS -from salome.smesh import smeshBuilder - -from salome.HYBRIDPlugin import HYBRIDPluginBuilder - -smesh = smeshBuilder.New(theStudy) - -# Hybrid mesh with hexa dominant core -# =================================== - -Mesh_1 = smesh.Mesh(Cylinder_1) - -MG_CADSurf = Mesh_1.Triangle(algo=smeshBuilder.MG_CADSurf) - -MG_Hybrid = Mesh_1.Tetrahedron(algo=smeshBuilder.HYBRID) -MG_Hybrid_Parameters_1 = MG_Hybrid.Parameters() -MG_Hybrid_Parameters_1.SetElementGeneration( HYBRIDPluginBuilder.Generation_Hexa_Dominant ) -MG_Hybrid_Parameters_1.SetHeightFirstLayer( 1 ) -MG_Hybrid_Parameters_1.SetNbOfBoundaryLayers( 3 ) - -isDone = Mesh_1.Compute() - -nb_hexas_1 = Mesh_1.NbHexas() - -# check that hexaedra have been genereted -assert nb_hexas_1 > 0 - -# Hybrid mesh with cartesian core -# =============================== - -Mesh_2 = smesh.Mesh(Cylinder_1) - -MG_CADSurf_1 = Mesh_2.Triangle(algo=smeshBuilder.MG_CADSurf) - -MG_Hybrid_1 = Mesh_2.Tetrahedron(algo=smeshBuilder.HYBRID) -MG_Hybrid_Parameters_2 = MG_Hybrid_1.Parameters() -MG_Hybrid_Parameters_2.SetElementGeneration( HYBRIDPluginBuilder.Generation_Cartesian_Core ) -MG_Hybrid_Parameters_2.SetHeightFirstLayer( 1 ) -MG_Hybrid_Parameters_2.SetNbOfBoundaryLayers( 3 ) - -isDone = Mesh_2.Compute() - -nb_hexas_2 = Mesh_2.NbHexas() - -# check that hexaedra have been genereted -assert nb_hexas_2 > 0 - - -# Hybrid mesh with cartesian core with fine core elements size -# ============================================================ - -Mesh_3 = smesh.Mesh(Cylinder_1) - -MG_CADSurf_1 = Mesh_3.Triangle(algo=smeshBuilder.MG_CADSurf) - -MG_Hybrid_1 = Mesh_3.Tetrahedron(algo=smeshBuilder.HYBRID) -MG_Hybrid_Parameters_3 = MG_Hybrid_1.Parameters() -MG_Hybrid_Parameters_3.SetElementGeneration( HYBRIDPluginBuilder.Generation_Cartesian_Core ) -MG_Hybrid_Parameters_3.SetHeightFirstLayer( 1 ) -MG_Hybrid_Parameters_3.SetNbOfBoundaryLayers( 3 ) -MG_Hybrid_Parameters_3.SetCoreSize( 10 ) - -isDone = Mesh_3.Compute() - -nb_hexas_3 = Mesh_3.NbHexas() - -# check that more hexaedra have been genereted -assert nb_hexas_3 > nb_hexas_2 - -if salome.sg.hasDesktop(): - salome.sg.updateObjBrowser(True) diff --git a/tests/test_enforced_mesh.py b/tests/test_enforced_mesh.py deleted file mode 100644 index d2675f2..0000000 --- a/tests/test_enforced_mesh.py +++ /dev/null @@ -1,168 +0,0 @@ -# -*- coding: utf-8 -*- - -import sys -import salome - -salome.salome_init() -theStudy = salome.myStudy - -### -### GEOM component -### - -import GEOM -from salome.geom import geomBuilder -import math -import SALOMEDS - - -geompy = geomBuilder.New(theStudy) - -O = geompy.MakeVertex(0, 0, 0) -OX = geompy.MakeVectorDXDYDZ(1, 0, 0) -OY = geompy.MakeVectorDXDYDZ(0, 1, 0) -OZ = geompy.MakeVectorDXDYDZ(0, 0, 1) -Cylinder_1 = geompy.MakeCylinderRH(0.5, 5) -Cylinder_2 = geompy.MakeCylinderRH(0.3, 3) -Rotation_1 = geompy.MakeRotation(Cylinder_2, OY, -90*math.pi/180.0) -Translation_1 = geompy.MakeTranslation(Rotation_1, 0, 0, 1.5) -piquage = geompy.MakeFuseList([Cylinder_1, Translation_1], True, True) -[Outlet] = geompy.SubShapes(piquage, [15]) -[Inlet_z,Inlet_x] = geompy.SubShapes(piquage, [3, 22]) -[corner] = geompy.SubShapes(piquage, [14]) -geomObj_1 = geompy.MakeVertex(0, 0, 0) -geomObj_2 = geompy.MakeVectorDXDYDZ(1, 0, 0) -geomObj_3 = geompy.MakeVectorDXDYDZ(0, 1, 0) -geomObj_4 = geompy.MakeVectorDXDYDZ(0, 0, 1) -Wall = geompy.CreateGroup(piquage, geompy.ShapeType["FACE"]) -geompy.UnionIDs(Wall, [7, 17]) -geompy.addToStudy( O, 'O' ) -geompy.addToStudy( OX, 'OX' ) -geompy.addToStudy( OY, 'OY' ) -geompy.addToStudy( OZ, 'OZ' ) -geompy.addToStudy( Cylinder_1, 'Cylinder_1' ) -geompy.addToStudy( Cylinder_2, 'Cylinder_2' ) -geompy.addToStudy( Rotation_1, 'Rotation_1' ) -geompy.addToStudy( Translation_1, 'Translation_1' ) -geompy.addToStudy( piquage, 'piquage' ) -geompy.addToStudyInFather( piquage, Inlet_x, 'Inlet_x' ) -geompy.addToStudyInFather( piquage, Outlet, 'Outlet' ) -geompy.addToStudyInFather( piquage, Wall, 'Wall' ) -geompy.addToStudyInFather( piquage, Inlet_z, 'Inlet_z' ) -geompy.addToStudyInFather( piquage, corner, 'corner' ) - -p1 = geompy.MakeVertex(0, -0.25, 1) -p2 = geompy.MakeVertex(0, 0.25, 1) -p3 = geompy.MakeVertex(0, 0.25, 3) -p4 = geompy.MakeVertex(0, -0.25, 3) - -wire = geompy.MakePolyline([p1, p2, p3, p4, p1]) -face = geompy.MakeFace(wire, 1, theName="face") - -### -### SMESH component -### - -import SMESH, SALOMEDS -from salome.smesh import smeshBuilder - -from salome.StdMeshers import StdMeshersBuilder - -smesh = smeshBuilder.New(theStudy) - -Mesh_faces = smesh.Mesh(face) -Mesh_faces.Triangle(algo=smeshBuilder.MG_CADSurf) -Mesh_faces.Compute() - - -# Viscous layers with Netgen additional hypothesis -# ================================================ - -Mesh_1 = smesh.Mesh(piquage) -NETGEN_2D = Mesh_1.Triangle(algo=smeshBuilder.NETGEN_1D2D) -NETGEN_2D_Parameters = NETGEN_2D.Parameters() - -NETGEN_2D_Parameters.SetMinSize( 0.01 ) -NETGEN_2D_Parameters.SetLocalSizeOnShape(corner, 0.01) -NETGEN_2D_Parameters.SetFineness( 5 ) -NETGEN_2D_Parameters.SetGrowthRate( 0.1 ) -NETGEN_2D_Parameters.SetNbSegPerEdge( 2 ) -NETGEN_2D_Parameters.SetNbSegPerRadius( 3 ) - -NETGEN_3D = Mesh_1.Tetrahedron() -Viscous_Layers_1 = NETGEN_3D.ViscousLayers(0.05,3,1.1,[],1,StdMeshersBuilder.SURF_OFFSET_SMOOTH) -Viscous_Layers_1.SetTotalThickness( 0.05 ) -Viscous_Layers_1.SetNumberLayers( 3 ) -Viscous_Layers_1.SetStretchFactor( 1.1 ) -Viscous_Layers_1.SetMethod( StdMeshersBuilder.SURF_OFFSET_SMOOTH ) -Viscous_Layers_1.SetFaces( [ 7, 17 ], 0 ) - - -#isDone = Mesh_1.Compute() -#Mesh_1.SplitVolumesIntoTetra( Mesh_1, 1 ) - -Outlet_1 = Mesh_1.GroupOnGeom(Outlet,'Outlet',SMESH.FACE) -Wall_1 = Mesh_1.GroupOnGeom(Wall,'Wall',SMESH.FACE) -Inlet_z_1 = Mesh_1.GroupOnGeom(Inlet_z,'Inlet_z',SMESH.FACE) -Inlet_x_1 = Mesh_1.GroupOnGeom(Inlet_x,'Inlet_x',SMESH.FACE) - -# Enforced mesh without layer -# =========================== - -Mesh_2 = smesh.Mesh(piquage, "Mesh_without_layer") - -NETGEN_2D_1_1 = Mesh_2.Triangle(algo=smeshBuilder.NETGEN_1D2D) -status = Mesh_2.AddHypothesis(NETGEN_2D_Parameters) - -MG_Hybrid_2 = Mesh_2.Tetrahedron(algo=smeshBuilder.HYBRID) -MG_Hybrid_Parameters_2 = MG_Hybrid_2.Parameters() -MG_Hybrid_Parameters_2.SetLayersOnAllWrap( 0 ) -MG_Hybrid_Parameters_2.SetElementGeneration( 0 ) -#MG_Hybrid_Parameters_2.SetHeightFirstLayer( 0.01 ) -#MG_Hybrid_Parameters_2.SetBoundaryLayersProgression( 1.1 ) -#MG_Hybrid_Parameters_2.SetNbOfBoundaryLayers( 3 ) -MG_Hybrid_Parameters_2.SetEnforcedMeshWithGroup( Mesh_faces.GetMesh(), SMESH.FACE, "LayersGroup" ) -MG_Hybrid_Parameters_2.SetKeepFiles(1) - -isDone = Mesh_2.Compute() - -if not isDone: - raise Exception("Error when computing Mesh_without_layer") - -# Check that a group has been created with the enforced mesh -assert len(Mesh_2.GetGroups()) == 1 -assert Mesh_2.GetGroups()[0].GetName() == 'LayersGroup' -assert Mesh_2.GetGroups()[0].Size() > 0 - -# Enforced mesh with layers -# ========================= - -Mesh_3 = smesh.Mesh(piquage, "Mesh_with_layer") - -NETGEN_2D_1_1 = Mesh_3.Triangle(algo=smeshBuilder.NETGEN_1D2D) -status = Mesh_3.AddHypothesis(NETGEN_2D_Parameters) - -MG_Hybrid_3 = Mesh_3.Tetrahedron(algo=smeshBuilder.HYBRID) -MG_Hybrid_Parameters_3 = MG_Hybrid_3.Parameters() -MG_Hybrid_Parameters_3.SetLayersOnAllWrap( 0 ) -MG_Hybrid_Parameters_3.SetElementGeneration( 0 ) -MG_Hybrid_Parameters_3.SetHeightFirstLayer( 0.01 ) -MG_Hybrid_Parameters_3.SetBoundaryLayersProgression( 1.1 ) -MG_Hybrid_Parameters_3.SetNbOfBoundaryLayers( 3 ) -MG_Hybrid_Parameters_3.SetEnforcedMeshWithGroup( Mesh_faces.GetMesh(), SMESH.FACE, "LayersGroup" ) -MG_Hybrid_Parameters_3.SetKeepFiles(1) -MG_Hybrid_3.SetFacesWithLayers( Wall ) - - -isDone = Mesh_3.Compute() - -if not isDone: - raise Exception("Error when computing Mesh_with_layer") - -# Check that a group has been created with the enforced mesh -assert len(Mesh_3.GetGroups()) == 1 -assert Mesh_3.GetGroups()[0].GetName() == 'LayersGroup' -assert Mesh_3.GetGroups()[0].Size() > 0 - -if salome.sg.hasDesktop(): - salome.sg.updateObjBrowser(1) diff --git a/tests/test_layers_imprinting.py b/tests/test_layers_imprinting.py deleted file mode 100644 index d95d23f..0000000 --- a/tests/test_layers_imprinting.py +++ /dev/null @@ -1,222 +0,0 @@ -# -*- coding: utf-8 -*- - -import sys -import salome - -salome.salome_init() -theStudy = salome.myStudy - -### -### GEOM component -### - -import GEOM -from salome.geom import geomBuilder -import math -import SALOMEDS - - -geompy = geomBuilder.New(theStudy) - -O = geompy.MakeVertex(0, 0, 0) -OX = geompy.MakeVectorDXDYDZ(1, 0, 0) -OY = geompy.MakeVectorDXDYDZ(0, 1, 0) -OZ = geompy.MakeVectorDXDYDZ(0, 0, 1) -Cylinder_1 = geompy.MakeCylinderRH(0.5, 5) -Cylinder_2 = geompy.MakeCylinderRH(0.3, 3) -Rotation_1 = geompy.MakeRotation(Cylinder_2, OY, -90*math.pi/180.0) -Translation_1 = geompy.MakeTranslation(Rotation_1, 0, 0, 1.5) -piquage = geompy.MakeFuseList([Cylinder_1, Translation_1], True, True) -[Outlet] = geompy.SubShapes(piquage, [15]) -[Inlet_z,Inlet_x] = geompy.SubShapes(piquage, [3, 22]) -[corner] = geompy.SubShapes(piquage, [14]) -geomObj_1 = geompy.MakeVertex(0, 0, 0) -geomObj_2 = geompy.MakeVectorDXDYDZ(1, 0, 0) -geomObj_3 = geompy.MakeVectorDXDYDZ(0, 1, 0) -geomObj_4 = geompy.MakeVectorDXDYDZ(0, 0, 1) -Wall = geompy.CreateGroup(piquage, geompy.ShapeType["FACE"]) -geompy.UnionIDs(Wall, [7, 17]) -geompy.addToStudy( O, 'O' ) -geompy.addToStudy( OX, 'OX' ) -geompy.addToStudy( OY, 'OY' ) -geompy.addToStudy( OZ, 'OZ' ) -geompy.addToStudy( Cylinder_1, 'Cylinder_1' ) -geompy.addToStudy( Cylinder_2, 'Cylinder_2' ) -geompy.addToStudy( Rotation_1, 'Rotation_1' ) -geompy.addToStudy( Translation_1, 'Translation_1' ) -geompy.addToStudy( piquage, 'piquage' ) -geompy.addToStudyInFather( piquage, Inlet_x, 'Inlet_x' ) -geompy.addToStudyInFather( piquage, Outlet, 'Outlet' ) -geompy.addToStudyInFather( piquage, Wall, 'Wall' ) -geompy.addToStudyInFather( piquage, Inlet_z, 'Inlet_z' ) -geompy.addToStudyInFather( piquage, corner, 'corner' ) - -geom_groups = [Inlet_x, Inlet_z, Outlet, Wall] -d_geom_groups = {} - -### -### SMESH component -### - -import SMESH, SALOMEDS -from salome.smesh import smeshBuilder - -from salome.StdMeshers import StdMeshersBuilder -from salome.HYBRIDPlugin import HYBRIDPluginBuilder - -smesh = smeshBuilder.New(theStudy) - - -# Viscous layers without imprinting -# ================================= - -Mesh_1 = smesh.Mesh(piquage, "Mesh_without_imprinting") -NETGEN_2D = Mesh_1.Triangle(algo=smeshBuilder.NETGEN_1D2D) -NETGEN_2D_Parameters = NETGEN_2D.Parameters() - -NETGEN_2D_Parameters.SetMinSize( 0.01 ) -NETGEN_2D_Parameters.SetLocalSizeOnShape(corner, 0.01) -NETGEN_2D_Parameters.SetFineness( 5 ) -NETGEN_2D_Parameters.SetGrowthRate( 0.1 ) -NETGEN_2D_Parameters.SetNbSegPerEdge( 2 ) -NETGEN_2D_Parameters.SetNbSegPerRadius( 3 ) - -MG_Hybrid = Mesh_1.Tetrahedron(algo=smeshBuilder.HYBRID) -MG_Hybrid_Parameters_1 = MG_Hybrid.Parameters() -MG_Hybrid_Parameters_1.SetLayersOnAllWrap( 0 ) -MG_Hybrid_Parameters_1.SetElementGeneration( HYBRIDPluginBuilder.Generation_Tetra_Dominant ) -MG_Hybrid_Parameters_1.SetHeightFirstLayer( 0.01 ) -MG_Hybrid_Parameters_1.SetBoundaryLayersProgression( 1.1 ) -MG_Hybrid_Parameters_1.SetNbOfBoundaryLayers( 3 ) -MG_Hybrid_Parameters_1.SetFacesWithLayers( [ 7, 17 ] ) - - -isDone = Mesh_1.Compute() - -if not isDone: - raise Exception("Error when computing Mesh_without_imprinting") - -d_groups_1 = {} - -for geom_group in geom_groups: - name = geom_group.GetName() - gr = Mesh_1.Group(geom_group) - d_groups_1[name] = gr - d_geom_groups[name] = geom_group - -assert Mesh_1.NbQuadrangles() == 0 - -shape_volume = geompy.BasicProperties(piquage)[2] - -# Compare whole mesh volume -volume_error_1 = abs(shape_volume-Mesh_1.GetVolume())/shape_volume - -assert volume_error_1 < 0.015 - -# Viscous layers with imprinting -# ============================== - -Mesh_2 = smesh.Mesh(piquage, "Mesh_with_imprinting") - -NETGEN_2D_1_1 = Mesh_2.Triangle(algo=smeshBuilder.NETGEN_1D2D) -status = Mesh_2.AddHypothesis(NETGEN_2D_Parameters) - -MG_Hybrid_2 = Mesh_2.Tetrahedron(algo=smeshBuilder.HYBRID) -MG_Hybrid_Parameters_2 = MG_Hybrid_2.Parameters() -MG_Hybrid_Parameters_2.SetLayersOnAllWrap( 0 ) -MG_Hybrid_Parameters_2.SetElementGeneration( HYBRIDPluginBuilder.Generation_Tetra_Dominant ) -MG_Hybrid_Parameters_2.SetHeightFirstLayer( 0.01 ) -MG_Hybrid_Parameters_2.SetBoundaryLayersProgression( 1.1 ) -MG_Hybrid_Parameters_2.SetNbOfBoundaryLayers( 3 ) -MG_Hybrid_Parameters_2.SetFacesWithLayers( [ 7, 17 ] ) -MG_Hybrid_Parameters_2.SetFacesWithImprinting( [ 22, 15, 3 ] ) - -isDone = Mesh_2.Compute() - -if not isDone: - raise Exception("Error when computing Mesh_with_imprinting") - -assert Mesh_2.NbQuadrangles() > 0 - -d_groups_2 = {} - -for geom_group in geom_groups: - name = geom_group.GetName() - gr = Mesh_2.Group(geom_group) - d_groups_2[name] = gr - -faces_imprinted = ["Inlet_x", "Inlet_z", "Outlet"] - -# Check viscous layers with imprinting -for name in faces_imprinted: - geom_area = geompy.BasicProperties(d_geom_groups[name])[1] - gr_1 = d_groups_1[name] - gr_2 = d_groups_2[name] - #assert gr_1.Size() > 0 - assert gr_2.Size() > 0 - # Nb of quadrangles is in 7th index of mesh info - assert gr_2.GetMeshInfo()[7] > 0 - - # Compare mesh group and geom group - area_error_1 = abs(geom_area-smesh.GetArea(gr_2))/geom_area - assert area_error_1 < 0.025 - # Compare mesh group with imprinting and mesh group without imprinting - area_error_2 = abs(smesh.GetArea(gr_1)-smesh.GetArea(gr_2))/smesh.GetArea(gr_1) - assert area_error_2 < 1e-10 - -# Compare whole mesh volume -mesh_2_volume = Mesh_2.GetVolume() -volume_error_2 = abs(shape_volume-mesh_2_volume)/shape_volume - -assert volume_error_2 < 0.015 - -# Viscous layers with imprinting set by groups -# ============================================ - -Mesh_3 = smesh.Mesh(piquage, "Mesh_with_imprinting_set_by_groups") - -NETGEN_2D_1_1 = Mesh_3.Triangle(algo=smeshBuilder.NETGEN_1D2D) -status = Mesh_3.AddHypothesis(NETGEN_2D_Parameters) - -MG_Hybrid_3 = Mesh_3.Tetrahedron(algo=smeshBuilder.HYBRID) -MG_Hybrid_Parameters_3 = MG_Hybrid_3.Parameters() -MG_Hybrid_Parameters_3.SetLayersOnAllWrap( 0 ) -MG_Hybrid_Parameters_3.SetElementGeneration( HYBRIDPluginBuilder.Generation_Tetra_Dominant ) -MG_Hybrid_Parameters_3.SetHeightFirstLayer( 0.01 ) -MG_Hybrid_Parameters_3.SetBoundaryLayersProgression( 1.1 ) -MG_Hybrid_Parameters_3.SetNbOfBoundaryLayers( 3 ) -MG_Hybrid_3.SetFacesWithLayers( Wall ) -MG_Hybrid_3.SetFacesWithImprinting( [ Inlet_x, Inlet_z, Outlet ] ) - -isDone = Mesh_3.Compute() - -if not isDone: - raise Exception("Error when computing Mesh_with_imprinting_set_by_groups") - -d_groups_3 = {} - -for geom_group in geom_groups: - name = geom_group.GetName() - gr = Mesh_3.Group(geom_group) - d_groups_3[name] = gr - -# Compare whole mesh volume -mesh_3_volume = Mesh_3.GetVolume() -volume_error_3 = abs(mesh_2_volume-mesh_3_volume)/mesh_2_volume - -assert abs(mesh_3_volume-mesh_2_volume)/mesh_2_volume < 1e-10 - -# Check viscous layers with imprinting -for name in faces_imprinted: - gr_2 = d_groups_2[name] - gr_3 = d_groups_3[name] - assert gr_3.Size() > 0 - # Nb of quadrangles is in 7th index of mesh info - assert gr_2.GetMeshInfo()[7] == gr_3.GetMeshInfo()[7] - - # Compare mesh group with imprinting set by ids and mesh group with imprinting set by geom group - area_error_3 = abs(smesh.GetArea(gr_2)-smesh.GetArea(gr_3))/smesh.GetArea(gr_2) - assert area_error_3 < 1e-10 - -if salome.sg.hasDesktop(): - salome.sg.updateObjBrowser(1) diff --git a/tests/test_layers_imprinting_hexa_core.py b/tests/test_layers_imprinting_hexa_core.py deleted file mode 100644 index e494785..0000000 --- a/tests/test_layers_imprinting_hexa_core.py +++ /dev/null @@ -1,136 +0,0 @@ -# -*- coding: utf-8 -*- - -# This test is a known failure for MeshGems <= 2.4-5 (but must not crash Salome) - -import sys -import salome - -salome.salome_init() -theStudy = salome.myStudy - -### -### GEOM component -### - -import GEOM -from salome.geom import geomBuilder -import math -import SALOMEDS - - -geompy = geomBuilder.New(theStudy) - -O = geompy.MakeVertex(0, 0, 0) -OX = geompy.MakeVectorDXDYDZ(1, 0, 0) -OY = geompy.MakeVectorDXDYDZ(0, 1, 0) -OZ = geompy.MakeVectorDXDYDZ(0, 0, 1) -Cylinder_1 = geompy.MakeCylinderRH(0.5, 5) -Cylinder_2 = geompy.MakeCylinderRH(0.3, 3) -Rotation_1 = geompy.MakeRotation(Cylinder_2, OY, -90*math.pi/180.0) -Translation_1 = geompy.MakeTranslation(Rotation_1, 0, 0, 1.5) -piquage = geompy.MakeFuseList([Cylinder_1, Translation_1], True, True) -[Outlet] = geompy.SubShapes(piquage, [15]) -[Inlet_z,Inlet_x] = geompy.SubShapes(piquage, [3, 22]) -[corner] = geompy.SubShapes(piquage, [14]) -geomObj_1 = geompy.MakeVertex(0, 0, 0) -geomObj_2 = geompy.MakeVectorDXDYDZ(1, 0, 0) -geomObj_3 = geompy.MakeVectorDXDYDZ(0, 1, 0) -geomObj_4 = geompy.MakeVectorDXDYDZ(0, 0, 1) -Wall = geompy.CreateGroup(piquage, geompy.ShapeType["FACE"]) -geompy.UnionIDs(Wall, [7, 17]) -geompy.addToStudy( O, 'O' ) -geompy.addToStudy( OX, 'OX' ) -geompy.addToStudy( OY, 'OY' ) -geompy.addToStudy( OZ, 'OZ' ) -geompy.addToStudy( Cylinder_1, 'Cylinder_1' ) -geompy.addToStudy( Cylinder_2, 'Cylinder_2' ) -geompy.addToStudy( Rotation_1, 'Rotation_1' ) -geompy.addToStudy( Translation_1, 'Translation_1' ) -geompy.addToStudy( piquage, 'piquage' ) -geompy.addToStudyInFather( piquage, Inlet_x, 'Inlet_x' ) -geompy.addToStudyInFather( piquage, Outlet, 'Outlet' ) -geompy.addToStudyInFather( piquage, Wall, 'Wall' ) -geompy.addToStudyInFather( piquage, Inlet_z, 'Inlet_z' ) -geompy.addToStudyInFather( piquage, corner, 'corner' ) - -geom_groups = [Inlet_x, Inlet_z, Outlet, Wall] -d_geom_groups = {} - -### -### SMESH component -### - -import SMESH, SALOMEDS -from salome.smesh import smeshBuilder - -from salome.StdMeshers import StdMeshersBuilder -from salome.HYBRIDPlugin import HYBRIDPluginBuilder - -smesh = smeshBuilder.New(theStudy) - -# Viscous layers with imprinting (hexa core) -# ========================================== - -Mesh_4 = smesh.Mesh(piquage, "Mesh_with_imprinting_hexa_core") - -NETGEN_2D_1_1 = Mesh_4.Triangle(algo=smeshBuilder.NETGEN_1D2D) -NETGEN_2D_Parameters = NETGEN_2D_1_1.Parameters() - -NETGEN_2D_Parameters.SetMinSize( 0.01 ) -NETGEN_2D_Parameters.SetLocalSizeOnShape(corner, 0.01) -NETGEN_2D_Parameters.SetFineness( 5 ) -NETGEN_2D_Parameters.SetGrowthRate( 0.1 ) -NETGEN_2D_Parameters.SetNbSegPerEdge( 2 ) -NETGEN_2D_Parameters.SetNbSegPerRadius( 3 ) - -MG_Hybrid_4 = Mesh_4.Tetrahedron(algo=smeshBuilder.HYBRID) -MG_Hybrid_Parameters_4 = MG_Hybrid_4.Parameters() -MG_Hybrid_Parameters_4.SetLayersOnAllWrap( 0 ) -MG_Hybrid_Parameters_4.SetElementGeneration( HYBRIDPluginBuilder.Generation_Hexa_Dominant ) -MG_Hybrid_Parameters_4.SetHeightFirstLayer( 0.01 ) -MG_Hybrid_Parameters_4.SetBoundaryLayersProgression( 1.1 ) -MG_Hybrid_Parameters_4.SetNbOfBoundaryLayers( 3 ) -MG_Hybrid_Parameters_4.SetFacesWithLayers( [ 7, 17 ] ) -MG_Hybrid_Parameters_4.SetFacesWithImprinting( [ 22, 15, 3 ] ) - -isDone = Mesh_4.Compute() - -if not isDone: - raise Exception("Error when computing Mesh_with_imprinting_hexa_core") - -assert Mesh_4.NbQuadrangles() > 0 - -d_groups_4 = {} -d_geom_groups = {} - -for geom_group in geom_groups: - name = geom_group.GetName() - gr = Mesh_4.Group(geom_group) - d_groups_4[name] = gr - d_geom_groups[name] = geom_group - -# Compare whole mesh volume -mesh_4_volume = Mesh_4.GetVolume() -shape_volume = geompy.BasicProperties(piquage)[2] -volume_error_4 = abs(shape_volume-mesh_4_volume)/shape_volume - -assert volume_error_4 < 0.015 - -# Check viscous layers with imprinting -faces_imprinted = ["Inlet_x", "Inlet_z", "Outlet"] - -for name in faces_imprinted: - gr_4 = d_groups_4[name] - #assert gr_1.Size() > 0 - assert gr_4.Size() > 0 - # Nb of quadrangles is in 7th index of mesh info - assert gr_4.GetMeshInfo()[7] > 0 - - # Compare mesh group and geom group - geom_area = geompy.BasicProperties(d_geom_groups[name])[1] - area_error_1 = abs(geom_area-smesh.GetArea(gr_4))/geom_area - assert area_error_1 < 0.025 - - -if salome.sg.hasDesktop(): - salome.sg.updateObjBrowser(1) diff --git a/tests/test_mg_hybrid_pyramids.py b/tests/test_mg_hybrid_pyramids.py deleted file mode 100644 index f546b5b..0000000 --- a/tests/test_mg_hybrid_pyramids.py +++ /dev/null @@ -1,92 +0,0 @@ -# -*- coding: utf-8 -*- - - -import sys -import salome - -salome.salome_init() -theStudy = salome.myStudy - -### -### GEOM component -### - -import GEOM -from salome.geom import geomBuilder -import math -import SALOMEDS - - -geompy = geomBuilder.New(theStudy) - -box_side = 200 - -O = geompy.MakeVertex(0, 0, 0) -OX = geompy.MakeVectorDXDYDZ(1, 0, 0) -OY = geompy.MakeVectorDXDYDZ(0, 1, 0) -OZ = geompy.MakeVectorDXDYDZ(0, 0, 1) -Box_1 = geompy.MakeBoxDXDYDZ(box_side, box_side, box_side) -geompy.addToStudy( O, 'O' ) -geompy.addToStudy( OX, 'OX' ) -geompy.addToStudy( OY, 'OY' ) -geompy.addToStudy( OZ, 'OZ' ) -geompy.addToStudy( Box_1, 'Box_1' ) - -### -### SMESH component -### - -import SMESH, SALOMEDS -from salome.smesh import smeshBuilder - -smesh = smeshBuilder.New(theStudy) -Mesh_1 = smesh.Mesh(Box_1) -MG_CADSurf = Mesh_1.Triangle(algo=smeshBuilder.MG_CADSurf) -MG_CADSurf_Parameters_1 = MG_CADSurf.Parameters() -MG_CADSurf_Parameters_1.SetPhySize( 10 ) -MG_CADSurf_Parameters_1.SetMinSize( 0.34641 ) -MG_CADSurf_Parameters_1.SetMaxSize( 69.282 ) - -isDone = Mesh_1.Compute() - -# Copy the skin mesh -Mesh_2 = smesh.CopyMesh( Mesh_1, 'Mesh_2', 0, 0) - -# Add hybrid -HYBRID_3D = Mesh_1.Tetrahedron(algo=smeshBuilder.HYBRID) -MG_Hybrid_Parameters_1 = HYBRID_3D.Parameters() -MG_Hybrid_Parameters_1.SetElementGeneration( 1 ) -MG_Hybrid_Parameters_1.SetHeightFirstLayer( 1 ) -MG_Hybrid_Parameters_1.SetNbOfBoundaryLayers( 3 ) - -# Compute mesh on CAD -# =================== -isDone = Mesh_1.Compute() - -# Check volume -vol_mesh_1 = smesh.GetVolume(Mesh_1) -vol_box = box_side**3 -assert abs(vol_mesh_1-vol_box)/vol_box < 1e-4 - -# Check number of pyramids -assert Mesh_1.NbPyramids() > 1000 - -# Add hybrid to skin mesh -HYBRID_3D_1 = Mesh_2.Tetrahedron(algo=smeshBuilder.HYBRID,geom=None) -status = Mesh_2.AddHypothesis(MG_Hybrid_Parameters_1,None) - -# Compute mesh without CAD -# ======================== -isDone = Mesh_2.Compute() - -# Check volume -vol_mesh_2 = smesh.GetVolume(Mesh_2) -vol_box = box_side**3 -assert abs(vol_mesh_2-vol_box)/vol_box < 1e-4 - -# Check number of pyramids -assert Mesh_2.NbPyramids() > 1000 - - -if salome.sg.hasDesktop(): - salome.sg.updateObjBrowser(True) diff --git a/tests/tests.set b/tests/tests.set index 9fb237c..5ecb682 100644 --- a/tests/tests.set +++ b/tests/tests.set @@ -18,10 +18,10 @@ # SET(TEST_NAMES - test_cartesian_core_size - test_enforced_mesh - test_layers_imprinting - test_layers_imprinting_hexa_core - test_mg_hybrid_pyramids - test_advanced_text_option + cartesian_core_size + enforced_mesh + layers_imprinting + layers_imprinting_hexa_core + mg_hybrid_pyramids + advanced_text_option )