Salome HOME
[bos #38052][EDF](2023-T3) Option to replace polyhedrons by hexahedrons in the body...
[modules/smesh.git] / test / body_fitting_viscous_layer_tpipe.py
1 #!/usr/bin/env python
2
3 import sys
4 import salome
5
6 salome.salome_init()
7
8 ###
9 ### SHAPER component
10 ###
11
12 from salome.shaper import model
13
14 model.begin()
15 partSet = model.moduleDocument()
16
17 ### Create Part
18 Part_1 = model.addPart(partSet)
19 Part_1_doc = Part_1.document()
20
21 ### Create Cylinder
22 Cylinder_1 = model.addCylinder(Part_1_doc, model.selection("VERTEX", "PartSet/Origin"), model.selection("EDGE", "PartSet/OZ"), 0.5, 5)
23
24 ### Create Point
25 Point_2 = model.addPoint(Part_1_doc, -3, 0, 1.5)
26
27 ### Create Cylinder
28 Cylinder_2 = model.addCylinder(Part_1_doc, model.selection("VERTEX", "Point_1"), model.selection("EDGE", "PartSet/OX"), 0.3, 3)
29
30 ### Create Fuse
31 Fuse_1 = model.addFuse(Part_1_doc, [model.selection("SOLID", "Cylinder_1_1"), model.selection("SOLID", "Cylinder_2_1")], keepSubResults = True)
32
33 ### Create Group
34 Group_1 = model.addGroup(Part_1_doc, "Faces", [model.selection("FACE", "Cylinder_2_1/Face_3")])
35 Group_1.setName("Inlet_x")
36 Group_1.result().setName("Inlet_x")
37 Group_1.result().setColor(0, 85, 255)
38
39 ### Create Group
40 Group_2 = model.addGroup(Part_1_doc, "Faces", [model.selection("FACE", "Cylinder_1_1/Face_3")])
41 Group_2.setName("Inlet_z")
42 Group_2.result().setName("Inlet_z")
43 Group_2.result().setColor(170, 0, 0)
44
45 ### Create Group
46 Group_3 = model.addGroup(Part_1_doc, "Faces", [model.selection("FACE", "Cylinder_1_1/Face_2")])
47 Group_3.setName("Outlet")
48 Group_3.result().setName("Outlet")
49 Group_3.result().setColor(255, 170, 0)
50
51 ### Create Group
52 Group_4 = model.addGroup(Part_1_doc, "Faces", [model.selection("FACE", "Fuse_1_1/Modified_Face&Cylinder_1_1/Face_1"), model.selection("FACE", "Fuse_1_1/Modified_Face&Cylinder_2_1/Face_1")])
53 Group_4.setName("Wall")
54 Group_4.result().setName("Wall")
55 Group_4.result().setColor(85, 255, 0)
56
57 ### Create Group
58 Group_5 = model.addGroup(Part_1_doc, "Vertices", [model.selection("VERTEX", "Fuse_1_1/Generated_Vertex&Cylinder_1_1/Face_1")])
59 Group_5.setName("corner")
60 Group_5.result().setName("corner")
61
62 model.end()
63
64 ###
65 ### SHAPERSTUDY component
66 ###
67
68 model.publishToShaperStudy()
69 import SHAPERSTUDY
70 Fuse_1_1, Inlet_x, Inlet_z, Outlet, Wall, corner, = SHAPERSTUDY.shape(model.featureStringId(Fuse_1))
71
72 ###
73 ### SMESH component
74 ###
75
76 import  SMESH, SALOMEDS
77 from salome.smesh import smeshBuilder
78
79 smesh = smeshBuilder.New()
80
81 Mesh_1 = smesh.Mesh(Fuse_1_1,'Mesh_1')
82 Cartesian_3D_1 = Mesh_1.BodyFitted()
83 CartesianParameters3D = Cartesian_3D_1.SetGrid([ [ '0.05' ], [ 0, 1 ]],[ [ '0.05' ], [ 0, 1 ]],[ [ '0.05' ], [ 0, 1 ]],5e+07,1)
84 CartesianParameters3D.SetToCreateFaces( 1 )
85 ViscousLayers_0_05_3 = Cartesian_3D_1.ViscousLayers(0.05,3,1.1,[ Inlet_x, Inlet_z, Outlet ],1,smeshBuilder.SURF_OFFSET_SMOOTH,'Viscous_Layers')
86
87 isDone = Mesh_1.Compute()
88
89 if not isDone:
90   raise Exception("Mesh_1 not computed")
91
92 # Check volume of mesh
93 volume_mesh = Mesh_1.GetVolume()
94 volume_geom = 4.640535669879
95
96 assert abs(volume_mesh-volume_geom)/volume_geom < 0.005
97
98 # Check volume of Viscous layer
99 gr_Viscous_Layers = Mesh_1.GetGroupByName("Viscous_Layers")[0]
100
101 volume_mesh_VL = smesh.GetVolume(gr_Viscous_Layers)
102 volume_geom_reduced = 3.685108989376
103 volume_geom_VL = volume_geom - volume_geom_reduced
104
105 assert abs(volume_mesh_VL-volume_geom_VL)/volume_geom_VL < 0.005
106
107
108
109 if salome.sg.hasDesktop():
110   salome.sg.updateObjBrowser()