1 # -*- coding: utf-8 -*-
3 # This test is a known failure for MeshGems <= 2.4-5 (but must not crash Salome)
9 theStudy = salome.myStudy
16 from salome.geom import geomBuilder
21 geompy = geomBuilder.New(theStudy)
33 O = geompy.MakeVertex(0, 0, 0)
34 OX = geompy.MakeVectorDXDYDZ(1, 0, 0)
35 OY = geompy.MakeVectorDXDYDZ(0, 1, 0)
36 OZ = geompy.MakeVectorDXDYDZ(0, 0, 1)
37 geompy.addToStudy( O, 'O' )
38 geompy.addToStudy( OX, 'OX' )
39 geompy.addToStudy( OY, 'OY' )
40 geompy.addToStudy( OZ, 'OZ' )
42 Cylinder_1 = geompy.MakeCylinderRH(r1, h1)
43 Cylinder_2 = geompy.MakeCylinderRH(r2, h2)
44 Rotation_1 = geompy.MakeRotation(Cylinder_2, OY, -90*math.pi/180.0)
45 Translation_1 = geompy.MakeTranslation(Rotation_1, 0, 0, length_piquage)
47 piquage = geompy.MakeFuseList([Cylinder_1, Translation_1], True, True)
48 geompy.addToStudy( piquage, 'piquage' )
50 Inlet_z = geompy.GetFaceNearPoint(piquage, O)
51 geompy.addToStudyInFather( piquage, Inlet_z, 'Inlet_z' )
53 p_inlet_x = geompy.MakeVertex(-h2, 0, length_piquage)
54 Inlet_x = geompy.GetFaceNearPoint(piquage, p_inlet_x)
55 geompy.addToStudyInFather( piquage, Inlet_x, 'Inlet_x' )
57 p_outlet = geompy.MakeVertex(0, 0, h1)
58 Outlet = geompy.GetFaceNearPoint(piquage, p_outlet)
59 geompy.addToStudyInFather( piquage, Outlet, 'Outlet' )
61 Wall = geompy.CreateGroup(piquage, geompy.ShapeType["FACE"])
62 faces = geompy.SubShapeAll(piquage, geompy.ShapeType["FACE"])
63 geompy.UnionList(Wall, faces)
64 geompy.DifferenceList(Wall, [Inlet_x, Inlet_z, Outlet])
65 geompy.addToStudyInFather( piquage, Wall, 'Wall' )
67 p_corner = geompy.MakeVertex(-r2, 0, length_piquage+r2)
68 corner = geompy.GetVertexNearPoint(piquage, p_corner)
69 geompy.addToStudyInFather( piquage, corner, 'corner' )
71 geom_groups = [Inlet_x, Inlet_z, Outlet, Wall]
78 import SMESH, SALOMEDS
79 from salome.smesh import smeshBuilder
81 from salome.StdMeshers import StdMeshersBuilder
82 from salome.HYBRIDPlugin import HYBRIDPluginBuilder
84 smesh = smeshBuilder.New(theStudy)
86 # Viscous layers with imprinting (hexa core)
87 # ==========================================
89 Mesh_4 = smesh.Mesh(piquage, "Mesh_with_imprinting_hexa_core")
91 NETGEN_2D_1_1 = Mesh_4.Triangle(algo=smeshBuilder.NETGEN_1D2D)
92 NETGEN_2D_Parameters = NETGEN_2D_1_1.Parameters()
94 NETGEN_2D_Parameters.SetMinSize( 0.01 )
95 NETGEN_2D_Parameters.SetLocalSizeOnShape(corner, 0.01)
96 NETGEN_2D_Parameters.SetFineness( 5 )
97 NETGEN_2D_Parameters.SetGrowthRate( 0.1 )
98 NETGEN_2D_Parameters.SetNbSegPerEdge( 2 )
99 NETGEN_2D_Parameters.SetNbSegPerRadius( 3 )
101 wall_faces = geompy.SubShapeAll(Wall, geompy.ShapeType["FACE"])
102 wall_ids = geompy.GetSubShapesIDs(piquage, wall_faces)
103 Inlet_x_id, Inlet_z_id, Outlet_id = geompy.GetSubShapesIDs(piquage, [Inlet_x, Inlet_z, Outlet])
105 MG_Hybrid_4 = Mesh_4.Tetrahedron(algo=smeshBuilder.HYBRID)
106 MG_Hybrid_Parameters_4 = MG_Hybrid_4.Parameters()
107 MG_Hybrid_Parameters_4.SetLayersOnAllWrap( 0 )
108 MG_Hybrid_Parameters_4.SetElementGeneration( HYBRIDPluginBuilder.Generation_Hexa_Dominant )
109 MG_Hybrid_Parameters_4.SetHeightFirstLayer( 0.01 )
110 MG_Hybrid_Parameters_4.SetBoundaryLayersProgression( 1.1 )
111 MG_Hybrid_Parameters_4.SetNbOfBoundaryLayers( 3 )
112 MG_Hybrid_Parameters_4.SetFacesWithLayers( wall_ids )
113 MG_Hybrid_Parameters_4.SetFacesWithImprinting( [ Inlet_x_id, Inlet_z_id, Outlet_id ] )
115 isDone = Mesh_4.Compute()
118 raise Exception("Error when computing Mesh_with_imprinting_hexa_core")
120 assert Mesh_4.NbQuadrangles() > 0
125 for geom_group in geom_groups:
126 name = geom_group.GetName()
127 gr = Mesh_4.Group(geom_group)
128 d_groups_4[name] = gr
129 d_geom_groups[name] = geom_group
131 # Compare whole mesh volume
132 mesh_4_volume = Mesh_4.GetVolume()
133 shape_volume = geompy.BasicProperties(piquage)[2]
134 volume_error_4 = abs(shape_volume-mesh_4_volume)/shape_volume
136 assert volume_error_4 < 0.02
138 # Check viscous layers with imprinting
139 faces_imprinted = ["Inlet_x", "Inlet_z", "Outlet"]
141 for name in faces_imprinted:
142 gr_4 = d_groups_4[name]
143 #assert gr_1.Size() > 0
144 assert gr_4.Size() > 0
145 # Nb of quadrangles is in 7th index of mesh info
146 assert gr_4.GetMeshInfo()[7] > 0
148 # Compare mesh group and geom group
149 geom_area = geompy.BasicProperties(d_geom_groups[name])[1]
150 area_error_1 = abs(geom_area-smesh.GetArea(gr_4))/geom_area
151 assert area_error_1 < 0.025
154 if salome.sg.hasDesktop():
155 salome.sg.updateObjBrowser(1)