------------------------------------ Tests - Creating Geometry and Mesh ------------------------------------ .. code-block:: bash #!/usr/bin/env python ### ### This file is generated automatically by SALOME v9.3.0 with dump python functionality ### import sys import salome salome.salome_init() import salome_notebook notebook = salome_notebook.NoteBook() sys.path.insert(0, r'/home/hgasca/Desktop/valvula') ### ### GEOM component ### import GEOM from salome.geom import geomBuilder import math import SALOMEDS geompy = geomBuilder.New() O = geompy.MakeVertex(0, 0, 0) OX = geompy.MakeVectorDXDYDZ(1, 0, 0) OY = geompy.MakeVectorDXDYDZ(0, 1, 0) OZ = geompy.MakeVectorDXDYDZ(0, 0, 1) D1 = 0.02365 D2 = 0.022 D3 = 0.003 D4 = 0.0099 D5 = 0.017 D6 = 0.024 D7 = D5 D8 = 0.038 D9 = 0.014 D10 = 0.021 D11 = 0.022 D12 = D7 + 0.001 L1 = 0.070 L2 = 0.001 L3 = 0.00633 L4 = 0.040 L5 = 0.003 L6 = 0.030 L7 = 0.08233 L8 = 0.002 L9 = 0.01 L10 = 0.05 L11 = 0.080 L12 = 0.005 L13 = 0.010 L14 = 0.035 L16 = 0.006 L15 = L14-L16 L17 = 0.010 Ax = 0 Bx = L1 Cx = L1 + L2 Dx = Cx + L3 Ex = Dx + L4 Fx = Ex + L5 Gx = Fx + L6 Hx = Dx + L7 Ix = Hx + L8 Jx = Hx + L17 Kx = Hx + L9 Lx = Jx + L16 Mx = Jx + L14 Nx = Kx + L10 Ox = Nx + L11 Px = Ox + L12 Qx = Px + L13 ay = 0 by = D3/2 cy = D2/2 dy = D1/2 ey = D4/2 fy = D5/2 gy = D6/2 hy = D11/2 iy = D7/2 + 0.0015 jy = D8/2 ky = D9/2 ly = D9/2 + 0.001 my = D10/2 sy = D12/2 # Horizontales P_1 = geompy.MakeVertex(Ax, ay, 0) P_2 = geompy.MakeVertex(Qx, ay, 0) P_3 = geompy.MakeVertex(Ax, by, 0) P_4 = geompy.MakeVertex(Qx, by, 0) P_5 = geompy.MakeVertex(Ax, cy, 0) P_6 = geompy.MakeVertex(Bx, cy, 0) P_7 = geompy.MakeVertex(Ix, ey, 0) P_8 = geompy.MakeVertex(Qx, ey, 0) P_9 = geompy.MakeVertex(Ix, fy, 0) P_10 = geompy.MakeVertex(Nx, fy, 0) P_11 = geompy.MakeVertex(Hx, sy, 0) P_12 = geompy.MakeVertex(Nx, sy, 0) P_13 = geompy.MakeVertex(Mx, hy, 0) P_14 = geompy.MakeVertex(Nx, hy, 0) P_15 = geompy.MakeVertex(Hx, ky, 0) P_16 = geompy.MakeVertex(Qx, ky, 0) # Verticales P_17 = geompy.MakeVertex(Bx, ay, 0) P_18 = geompy.MakeVertex(Bx, cy, 0) P_19 = geompy.MakeVertex(Ex, ay, 0) P_20 = geompy.MakeVertex(Ex, gy, 0) P_21 = geompy.MakeVertex(Fx, ay, 0) P_22 = geompy.MakeVertex(Fx, gy, 0) P_23 = geompy.MakeVertex(Ix, ay, 0) P_24 = geompy.MakeVertex(Ix, jy, 0) P_25 = geompy.MakeVertex(Jx, ay, 0) P_26 = geompy.MakeVertex(Jx, jy, 0) P_27 = geompy.MakeVertex(Kx, ay, 0) P_28 = geompy.MakeVertex(Kx, jy, 0) P_29 = geompy.MakeVertex(Mx, ay, 0) P_30 = geompy.MakeVertex(Mx, jy, 0) P_31 = geompy.MakeVertex(Nx, ay, 0) P_32 = geompy.MakeVertex(Nx, ky, 0) P_33 = geompy.MakeVertex(Ox, ay, 0) P_34 = geompy.MakeVertex(Ox, ky, 0) P_35 = geompy.MakeVertex(Px, ay, 0) P_36 = geompy.MakeVertex(Px, my, 0) # Horizontales Edge_1 = geompy.MakeEdge(P_1, P_2) Edge_2 = geompy.MakeEdge(P_3, P_4) Edge_3 = geompy.MakeEdge(P_5, P_6) Edge_4 = geompy.MakeEdge(P_7, P_8) Edge_5 = geompy.MakeEdge(P_9, P_10) Edge_6 = geompy.MakeEdge(P_11, P_12) Edge_7 = geompy.MakeEdge(P_13, P_14) Edge_8 = geompy.MakeEdge(P_15, P_16) # Verticales Edge_9 = geompy.MakeEdge(P_17, P_18) Edge_10 = geompy.MakeEdge(P_19, P_20) Edge_11 = geompy.MakeEdge(P_21, P_22) Edge_12 = geompy.MakeEdge(P_23, P_24) Edge_13 = geompy.MakeEdge(P_25, P_26) Edge_14 = geompy.MakeEdge(P_27, P_28) Edge_15 = geompy.MakeEdge(P_29, P_30) Edge_16 = geompy.MakeEdge(P_31, P_32) Edge_17 = geompy.MakeEdge(P_33, P_34) Edge_18 = geompy.MakeEdge(P_35, P_36) # Sketch 2D O = geompy.MakeVertex(0, 0, 0) OX = geompy.MakeVectorDXDYDZ(1, 0, 0) OY = geompy.MakeVectorDXDYDZ(0, 1, 0) OZ = geompy.MakeVectorDXDYDZ(0, 0, 1) geomObj_1 = geompy.MakeMarker(0, 0, 0, 1, 0, 0, 0, 1, 0) sk = geompy.Sketcher2D() sk.addPoint(0.000000, 0.000000) sk.addSegmentAbsolute(0.000000, dy) sk.addSegmentAbsolute(Bx , dy) sk.addSegmentAbsolute(Bx , cy) sk.addSegmentAbsolute(Cx , cy) sk.addSegmentAbsolute(Cx , by) sk.addSegmentAbsolute(Dx , by) sk.addSegmentAbsolute(Dx , ey) sk.addSegmentAbsolute(Ex , ey) sk.addSegmentAbsolute(Ex , fy) sk.addSegmentAbsolute(Dx , fy) sk.addSegmentAbsolute(Dx , gy) sk.addSegmentAbsolute(Gx , gy) sk.addSegmentAbsolute(Gx , fy) sk.addSegmentAbsolute(Fx , fy) sk.addSegmentAbsolute(Fx , ey) sk.addSegmentAbsolute(Ix , ey) sk.addSegmentAbsolute(Ix , fy) sk.addSegmentAbsolute(Hx , fy) sk.addSegmentAbsolute(Hx , iy) sk.addSegmentAbsolute(Kx , jy) sk.addSegmentAbsolute(Nx , jy) sk.addSegmentAbsolute(Nx , ky) sk.addSegmentAbsolute(Ox , ky) sk.addSegmentAbsolute(Ox , ly) sk.addSegmentAbsolute(Px , my) sk.addSegmentAbsolute(Qx , my) sk.addSegmentAbsolute(Qx , 0) sk.close() Sketch_1 = sk.wire(geomObj_1) body1 = geompy.MakeFaceWires([Sketch_1], 1) geomObj_2 = geompy.MakeMarker(0, 0, 0, 1, 0, 0, 0, 1, 0) sk = geompy.Sketcher2D() sk.addPoint(Lx, 0.000000) sk.addSegmentAbsolute(Lx , sy) sk.addSegmentAbsolute(Jx , sy) sk.addSegmentAbsolute(Jx , hy) sk.addSegmentAbsolute(Mx , hy) sk.addSegmentAbsolute(Mx , 0) sk.close() Sketch_2 = sk.wire(geomObj_2) body2 = geompy.MakeFaceWires([Sketch_2], 1) body = geompy.MakeCutList(body1, [body2], True) Partition_1 = geompy.MakePartition([body], [Edge_1, Edge_2, Edge_3, Edge_4, Edge_5, Edge_6, Edge_7, Edge_8, Edge_9, Edge_10, Edge_11, Edge_12, Edge_13, Edge_14, Edge_15, Edge_16, Edge_17, Edge_18], [], [], geompy.ShapeType["FACE"], 0, [], 0) Rotation_1 = geompy.MakeRotation(Partition_1, OX, -2.5*math.pi/180.0) #Boundaries inlet = geompy.CreateGroup(Rotation_1, geompy.ShapeType["EDGE"]) geompy.UnionIDs(inlet, [163, 128, 109]) wall = geompy.CreateGroup(Rotation_1, geompy.ShapeType["EDGE"]) geompy.UnionIDs(wall, [150, 4, 252, 210, 203, 220, 234, 250, 185, 21, 161, 196, 199, 194, 182, 145, 206, 154, 175, 40, 102, 231, 213, 100, 173, 178, 279, 189, 64]) positive_pres = geompy.CreateGroup(Rotation_1, geompy.ShapeType["EDGE"]) geompy.UnionIDs(positive_pres, [131, 133, 159]) negative_pres = geompy.CreateGroup(Rotation_1, geompy.ShapeType["EDGE"]) geompy.UnionIDs(negative_pres, [168, 116, 97, 61]) moving_wall = geompy.CreateGroup(Rotation_1, geompy.ShapeType["EDGE"]) geompy.UnionIDs(moving_wall, [90, 54, 166, 82, 147, 114, 136, 170, 140, 73]) Axis = geompy.CreateGroup(Rotation_1, geompy.ShapeType["EDGE"]) geompy.UnionIDs(Axis, [11, 51, 111, 32, 236, 18, 260, 79]) outlet = geompy.CreateGroup(Rotation_1, geompy.ShapeType["EDGE"]) geompy.UnionIDs(outlet, [294, 289, 272, 277]) geompy.DifferenceIDs(moving_wall, [90, 54, 166, 82, 147, 114, 136, 170, 140, 73]) geompy.UnionIDs(moving_wall, [90, 54, 166, 82, 147, 114, 136, 170, 140, 73, 86]) geompy.DifferenceIDs(wall, [150, 4, 252, 210, 203, 220, 234, 250, 185, 21, 161, 196, 199, 194, 182, 145, 206, 154, 175, 40, 102, 231, 213, 100, 173, 178, 279, 189, 64]) geompy.UnionIDs(wall, [150, 4, 252, 210, 203, 220, 234, 250, 185, 21, 161, 196, 199, 194, 182, 145, 206, 154, 175, 40, 102, 231, 213, 100, 173, 178, 279, 189, 64, 138]) geompy.DifferenceIDs(Axis, [11, 51, 111, 32, 236, 18, 260, 79]) geompy.UnionIDs(Axis, [11, 51, 111, 32, 236, 18, 260, 79, 292, 282]) frontAndBack = geompy.CreateGroup(Rotation_1, geompy.ShapeType["FACE"]) geompy.UnionIDs(frontAndBack, [112, 218, 52, 122, 290, 141, 232, 134, 148, 57, 176, 80, 268, 2, 98, 157, 275, 117, 69, 19, 183, 225, 239, 258, 285, 192, 280, 129, 26, 12, 45, 62, 197, 38, 164, 253, 105, 211, 33, 263, 93, 244, 171, 204]) geompy.addToStudy( P_1, 'P_1' ) geompy.addToStudy( P_2, 'P_2' ) geompy.addToStudy( P_3, 'P_3' ) geompy.addToStudy( P_4, 'P_4' ) geompy.addToStudy( P_5, 'P_5' ) geompy.addToStudy( P_6, 'P_6' ) geompy.addToStudy( P_7, 'P_7' ) geompy.addToStudy( P_8, 'P_8' ) geompy.addToStudy( P_9, 'P_9' ) geompy.addToStudy( P_10, 'P_10' ) geompy.addToStudy( P_11, 'P_11' ) geompy.addToStudy( P_12, 'P_12' ) geompy.addToStudy( P_13, 'P_13' ) geompy.addToStudy( P_14, 'P_14' ) geompy.addToStudy( P_15, 'P_15' ) geompy.addToStudy( P_16, 'P_16' ) geompy.addToStudy( P_17, 'P_17' ) geompy.addToStudy( P_18, 'P_18' ) geompy.addToStudy( P_19, 'P_19' ) geompy.addToStudy( P_20, 'P_20' ) geompy.addToStudy( P_21, 'P_21' ) geompy.addToStudy( P_22, 'P_22' ) geompy.addToStudy( P_23, 'P_23' ) geompy.addToStudy( P_24, 'P_24' ) geompy.addToStudy( P_25, 'P_25' ) geompy.addToStudy( P_26, 'P_26' ) geompy.addToStudy( P_27, 'P_27' ) geompy.addToStudy( P_28, 'P_28' ) geompy.addToStudy( P_29, 'P_29' ) geompy.addToStudy( P_30, 'P_30' ) geompy.addToStudy( P_31, 'P_31' ) geompy.addToStudy( P_32, 'P_32' ) geompy.addToStudy( P_33, 'P_33' ) geompy.addToStudy( P_34, 'P_34' ) geompy.addToStudy( P_35, 'P_35' ) geompy.addToStudy( P_36, 'P_36' ) geompy.addToStudy( Edge_1, 'Edge_1' ) geompy.addToStudy( Edge_2, 'Edge_2' ) geompy.addToStudy( Edge_3, 'Edge_3' ) geompy.addToStudy( Edge_4, 'Edge_4' ) geompy.addToStudy( Edge_5, 'Edge_5' ) geompy.addToStudy( Edge_6, 'Edge_6' ) geompy.addToStudy( Edge_7, 'Edge_7' ) geompy.addToStudy( Edge_8, 'Edge_8' ) geompy.addToStudy( Edge_9, 'Edge_9' ) geompy.addToStudy( Edge_10, 'Edge_10' ) geompy.addToStudy( Edge_11, 'Edge_11' ) geompy.addToStudy( Edge_12, 'Edge_12' ) geompy.addToStudy( Edge_13, 'Edge_13' ) geompy.addToStudy( Edge_14, 'Edge_14' ) geompy.addToStudy( Edge_15, 'Edge_15' ) geompy.addToStudy( Edge_16, 'Edge_16' ) geompy.addToStudy( Edge_17, 'Edge_17' ) geompy.addToStudy( Edge_18, 'Edge_18' ) geompy.addToStudy( O, 'O' ) geompy.addToStudy( OX, 'OX' ) geompy.addToStudy( OY, 'OY' ) geompy.addToStudy( OZ, 'OZ' ) geompy.addToStudy( Sketch_1, 'Sketch_1' ) geompy.addToStudy( Sketch_2, 'Sketch_2' ) geompy.addToStudy( body1, 'body1' ) geompy.addToStudy( body2, 'body2' ) geompy.addToStudy( body, 'body' ) geompy.addToStudy( Partition_1, 'Partition_1' ) geompy.addToStudy( Rotation_1, 'Rotation_1' ) geompy.addToStudyInFather( Rotation_1, inlet, 'inlet' ) geompy.addToStudyInFather( Rotation_1, wall, 'wall' ) geompy.addToStudyInFather( Rotation_1, positive_pres, 'positive_pres' ) geompy.addToStudyInFather( Rotation_1, negative_pres, 'negative_pres' ) geompy.addToStudyInFather( Rotation_1, moving_wall, 'moving_wall' ) geompy.addToStudyInFather( Rotation_1, Axis, 'Axis' ) geompy.addToStudyInFather( Rotation_1, outlet, 'outlet' ) geompy.addToStudyInFather( Rotation_1, frontAndBack, 'frontAndBack' ) ### ### SMESH component ### import SMESH, SALOMEDS from salome.smesh import smeshBuilder smesh = smeshBuilder.New() #smesh.SetEnablePublish( False ) # Set to False to avoid publish in study if not needed or in some particular situations: # multiples meshes built in parallel, complex and numerous mesh edition (performance) Rotation_1_1 = smesh.Mesh(Rotation_1) Regular_1D = Rotation_1_1.Segment() Local_Length_1 = Regular_1D.LocalLength(0.0002,None,1e-07) Quadrangle_2D = Rotation_1_1.Quadrangle(algo=smeshBuilder.QUADRANGLE) isDone = Rotation_1_1.Compute() inlet_1 = Rotation_1_1.GroupOnGeom(inlet,'inlet',SMESH.EDGE) wall_1 = Rotation_1_1.GroupOnGeom(wall,'wall',SMESH.EDGE) positive_pres_1 = Rotation_1_1.GroupOnGeom(positive_pres,'positive_pres',SMESH.EDGE) negative_pres_1 = Rotation_1_1.GroupOnGeom(negative_pres,'negative_pres',SMESH.EDGE) moving_wall_1 = Rotation_1_1.GroupOnGeom(moving_wall,'moving_wall',SMESH.EDGE) Axis_1 = Rotation_1_1.GroupOnGeom(Axis,'Axis',SMESH.EDGE) outlet_1 = Rotation_1_1.GroupOnGeom(outlet,'outlet',SMESH.EDGE) frontAndBack_1 = Rotation_1_1.GroupOnGeom(frontAndBack,'frontAndBack',SMESH.FACE) [ inlet_rotated, wall_rotated, positive_pres_rotated, negative_pres_rotated, moving_wall_rotated, Axis_rotated, outlet_rotated, frontAndBack_rotated, inlet_top, wall_top, positive_pres_top, negative_pres_top, moving_wall_top, Axis_top, outlet_top, frontAndBack_top ] = Rotation_1_1.RotationSweepObjects( [ Rotation_1_1 ], [ Rotation_1_1 ], [ Rotation_1_1 ], SMESH.AxisStruct( 0, 0, 1e-10, 10, 0, 0 ), 0.0872665, 1, 1e-11, 1 ) # The first parameter in SMESH.AxisStruct 1e-10 is the thicness of the exis face that after will be collapsed by openFoam. # The second 1e-11 allows to join points and elements under the value of the line before. ## Set names of Mesh objects smesh.SetName(Regular_1D.GetAlgorithm(), 'Regular_1D') smesh.SetName(outlet_rotated, 'outlet_rotated') smesh.SetName(frontAndBack_top, 'frontAndBack_top') smesh.SetName(Quadrangle_2D.GetAlgorithm(), 'Quadrangle_2D') smesh.SetName(Local_Length_1, 'Local Length_1') smesh.SetName(frontAndBack_1, 'frontAndBack') smesh.SetName(inlet_rotated, 'inlet_rotated') smesh.SetName(wall_rotated, 'wall_rotated') smesh.SetName(positive_pres_rotated, 'positive_pres_rotated') smesh.SetName(negative_pres_rotated, 'negative_pres_rotated') smesh.SetName(moving_wall_rotated, 'moving_wall_rotated') smesh.SetName(Axis_rotated, 'Axis_rotated') smesh.SetName(positive_pres_top, 'positive_pres_top') smesh.SetName(negative_pres_top, 'negative_pres_top') smesh.SetName(moving_wall_top, 'moving_wall_top') smesh.SetName(Axis_top, 'Axis_top') smesh.SetName(outlet_top, 'outlet_top') smesh.SetName(Rotation_1_1.GetMesh(), 'Rotation_1') smesh.SetName(frontAndBack_rotated, 'frontAndBack_rotated') smesh.SetName(wall_top, 'wall_top') smesh.SetName(inlet_top, 'inlet_top') smesh.SetName(inlet_1, 'inlet') smesh.SetName(positive_pres_1, 'positive_pres') smesh.SetName(wall_1, 'wall') smesh.SetName(moving_wall_1, 'moving_wall') smesh.SetName(negative_pres_1, 'negative_pres') smesh.SetName(outlet_1, 'outlet') smesh.SetName(Axis_1, 'Axis') if salome.sg.hasDesktop(): salome.sg.updateObjBrowser() Before exporting to an unv file review that there is an face in the axis and delete groups on edges.