7 from salome.geom
import geomBuilder
8 geompy = geomBuilder.New(salome.myStudy)
10 import SMESH, SALOMEDS
11 from salome.smesh
import smeshBuilder
12 smesh = smeshBuilder.New(salome.myStudy)
16 box = geompy.MakeBoxDXDYDZ( 10, 10, 10 )
17 face = geompy.SubShapeAll( box, geompy.ShapeType[
"FACE"])[0]
20 mesh = smesh.Mesh( box )
21 mesh.AutomaticHexahedralization(0)
24 res = mesh.Add0DElementsToAllNodes( mesh )
28 res = mesh.Add0DElementsToAllNodes( mesh, groupName )
29 mesh.RemoveGroupWithContents( res )
32 groupName =
"0Dsubmesh"
33 submesh = mesh.GetSubMesh( face,
"faceSM")
34 res = mesh.Add0DElementsToAllNodes( submesh, groupName )
37 group = mesh.Group( face,
"faceGroup" )
38 res = mesh.Add0DElementsToAllNodes( group )
41 mesh.RemoveElements( mesh.GetIdsFromFilter( smesh.GetFilter( SMESH.ELEM0D,
42 SMESH.FT_ElemGeomType,
43 "=",SMESH.Geom_POINT )))
46 res = mesh.Add0DElementsToAllNodes( mesh.GetElementsId() )
48 mesh.RemoveElements( mesh.GetElementsByType( SMESH.ELEM0D ))
52 res = mesh.Add0DElementsToAllNodes( mesh.GetIDSource( nodes, SMESH.NODE ))
9 from salome.smesh
import smeshBuilder
10 smesh = smeshBuilder.New(salome.myStudy)
17 def MakePolygon (a_mesh, x0, y0, z0, radius, nb_vert):
18 al = 2.0 * math.pi / nb_vert
22 for ii
in range(nb_vert):
23 nid = mesh.AddNode(x0 + radius * math.cos(ii*al),
24 y0 + radius * math.sin(ii*al),
30 return mesh.AddPolygonalFace(node_ids)
33 f1 = MakePolygon(mesh, 0, 0, 0, 30, 13)
34 f2 = MakePolygon(mesh, 0, 0, 10, 21, 9)
35 f3 = MakePolygon(mesh, 0, 0, 20, 13, 6)
37 salome.sg.updateObjBrowser(
True)
7 from salome.smesh
import smeshBuilder
8 smesh = smeshBuilder.New(salome.myStudy)
16 al = 2 * math.pi / 5.0
19 rr = aa / (2.0 * math.sin(al/2.0))
22 dh = rr * math.sqrt(2.0 * (1.0 - cosal * (1.0 + 2.0 * cosal)))
23 hh = 2.0 * dh - dr * (rr*(cosal - 1) + (rr + dr)*(math.cos(al/2) - 1)) / dh
31 cos_bot = math.cos(i*al)
32 sin_bot = math.sin(i*al)
34 cos_top = math.cos(i*al + al/2.0)
35 sin_top = math.sin(i*al + al/2.0)
37 nd = mesh.AddNode(rr * cos_top, rr * sin_top, hh )
38 nc = mesh.AddNode(r1 * cos_top, r1 * sin_top, hh - dh)
39 nb = mesh.AddNode(r1 * cos_bot, r1 * sin_bot, dh)
40 na = mesh.AddNode(rr * cos_bot, rr * sin_bot, 0)
48 mesh.AddPolyhedralVolume([dd[0], dd[1], dd[2], dd[3], dd[4],
49 dd[0], cc[0], bb[1], cc[1], dd[1],
50 dd[1], cc[1], bb[2], cc[2], dd[2],
51 dd[2], cc[2], bb[3], cc[3], dd[3],
52 dd[3], cc[3], bb[4], cc[4], dd[4],
53 dd[4], cc[4], bb[0], cc[0], dd[0],
54 aa[4], bb[4], cc[4], bb[0], aa[0],
55 aa[3], bb[3], cc[3], bb[4], aa[4],
56 aa[2], bb[2], cc[2], bb[3], aa[3],
57 aa[1], bb[1], cc[1], bb[2], aa[2],
58 aa[0], bb[0], cc[0], bb[1], aa[1],
59 aa[0], aa[1], aa[2], aa[3], aa[4]],
60 [5,5,5,5,5,5,5,5,5,5,5,5])
62 if salome.sg.hasDesktop():
63 salome.sg.updateObjBrowser(
True)
7 from salome.geom
import geomBuilder
8 geompy = geomBuilder.New(salome.myStudy)
10 import SMESH, SALOMEDS
11 from salome.smesh
import smeshBuilder
12 smesh = smeshBuilder.New(salome.myStudy)
13 import salome_notebook
29 ff = [0, 0, 0, 0, 0, 0]
31 bb[0] = mesh.AddNode( 0., 0., 0.)
32 bb[1] = mesh.AddNode(10., 0., 0.)
33 bb[2] = mesh.AddNode(20., 0., 0.)
34 bb[3] = mesh.AddNode(30., 0., 0.)
36 tt[0] = mesh.AddNode( 0., 15., 0.)
37 tt[1] = mesh.AddNode(10., 15., 0.)
38 tt[2] = mesh.AddNode(20., 15., 0.)
39 tt[3] = mesh.AddNode(30., 15., 0.)
41 ff[0] = mesh.AddFace([bb[0], bb[1], tt[1]])
42 ff[1] = mesh.AddFace([bb[0], tt[1], tt[0]])
43 ff[2] = mesh.AddFace([bb[1], bb[2], tt[2]])
44 ff[3] = mesh.AddFace([bb[1], tt[2], tt[1]])
45 ff[4] = mesh.AddFace([bb[2], bb[3], tt[3]])
46 ff[5] = mesh.AddFace([bb[2], tt[3], tt[2]])
49 print "\nDiagonal inversion ... ",
50 res = mesh.InverseDiag(bb[1], tt[2])
51 if not res:
print "failed!"
54 salome.sg.updateObjBrowser(
True)
7 from salome.geom
import geomBuilder
8 geompy = geomBuilder.New(salome.myStudy)
10 import SMESH, SALOMEDS
11 from salome.smesh
import smeshBuilder
12 smesh = smeshBuilder.New(salome.myStudy)
13 import salome_notebook
29 ff = [0, 0, 0, 0, 0, 0]
31 bb[0] = mesh.AddNode( 0., 0., 0.)
32 bb[1] = mesh.AddNode(10., 0., 0.)
33 bb[2] = mesh.AddNode(20., 0., 0.)
34 bb[3] = mesh.AddNode(30., 0., 0.)
36 tt[0] = mesh.AddNode( 0., 15., 0.)
37 tt[1] = mesh.AddNode(10., 15., 0.)
38 tt[2] = mesh.AddNode(20., 15., 0.)
39 tt[3] = mesh.AddNode(30., 15., 0.)
41 ff[0] = mesh.AddFace([bb[0], bb[1], tt[1]])
42 ff[1] = mesh.AddFace([bb[0], tt[1], tt[0]])
43 ff[2] = mesh.AddFace([bb[1], bb[2], tt[2]])
44 ff[3] = mesh.AddFace([bb[1], tt[2], tt[1]])
45 ff[4] = mesh.AddFace([bb[2], bb[3], tt[3]])
46 ff[5] = mesh.AddFace([bb[2], tt[3], tt[2]])
49 print "\nUnite two triangles ... ",
50 res = mesh.DeleteDiag(bb[1], tt[2])
51 if not res:
print "failed!"
54 salome.sg.updateObjBrowser(
True)
7 from salome.geom
import geomBuilder
8 geompy = geomBuilder.New(salome.myStudy)
10 import SMESH, SALOMEDS
11 from salome.smesh
import smeshBuilder
12 smesh = smeshBuilder.New(salome.myStudy)
13 import salome_notebook
29 ff = [0, 0, 0, 0, 0, 0]
31 bb[0] = mesh.AddNode( 0., 0., 0.)
32 bb[1] = mesh.AddNode(10., 0., 0.)
33 bb[2] = mesh.AddNode(20., 0., 0.)
34 bb[3] = mesh.AddNode(30., 0., 0.)
36 tt[0] = mesh.AddNode( 0., 15., 0.)
37 tt[1] = mesh.AddNode(10., 15., 0.)
38 tt[2] = mesh.AddNode(20., 15., 0.)
39 tt[3] = mesh.AddNode(30., 15., 0.)
41 ff[0] = mesh.AddFace([bb[0], bb[1], tt[1]])
42 ff[1] = mesh.AddFace([bb[0], tt[1], tt[0]])
43 ff[2] = mesh.AddFace([bb[1], bb[2], tt[2]])
44 ff[3] = mesh.AddFace([bb[1], tt[2], tt[1]])
45 ff[4] = mesh.AddFace([bb[2], bb[3], tt[3]])
46 ff[5] = mesh.AddFace([bb[2], tt[3], tt[2]])
49 print "\nUnite a set of triangles ... ",
50 res = mesh.TriToQuad([ff[2], ff[3], ff[4], ff[5]], SMESH.FT_MinimumAngle, 60.)
51 if not res:
print "failed!"
54 salome.sg.updateObjBrowser(
True)
7 from salome.geom
import geomBuilder
8 geompy = geomBuilder.New(salome.myStudy)
10 import SMESH, SALOMEDS
11 from salome.smesh
import smeshBuilder
12 smesh = smeshBuilder.New(salome.myStudy)
13 import salome_notebook
23 n1 = mesh.AddNode(0.0 * dx, 0, 0)
24 n2 = mesh.AddNode(1.0 * dx, 0, 0)
25 n3 = mesh.AddNode(2.0 * dx, 0, 0)
26 n4 = mesh.AddNode(3.0 * dx, 0, 0)
27 n5 = mesh.AddNode(4.0 * dx, 0, 0)
28 n6 = mesh.AddNode(5.0 * dx, 0, 0)
29 n7 = mesh.AddNode(0.0 * dx, dy, 0)
30 n8 = mesh.AddNode(1.0 * dx, dy, 0)
31 n9 = mesh.AddNode(2.0 * dx, dy, 0)
32 n10 = mesh.AddNode(3.0 * dx, dy, 0)
33 n11 = mesh.AddNode(4.0 * dx, dy, 0)
34 n12 = mesh.AddNode(5.0 * dx, dy, 0)
36 f1 = mesh.AddFace([n1, n2, n8 , n7 ])
37 f2 = mesh.AddFace([n2, n3, n9 , n8 ])
38 f3 = mesh.AddFace([n3, n4, n10, n9 ])
39 f4 = mesh.AddFace([n4, n5, n11, n10])
40 f5 = mesh.AddFace([n5, n6, n12, n11])
45 salome.sg.updateObjBrowser(
True)
8 from salome.geom
import geomBuilder
9 geompy = geomBuilder.New(salome.myStudy)
11 import SMESH, SALOMEDS
12 from salome.smesh
import smeshBuilder
13 smesh = smeshBuilder.New(salome.myStudy)
16 points = [[0, 0], [50, 30], [50, 110], [0, 150], [-80, 150], [-130, 70], [-130, -20]]
21 vert = geompy.MakeVertex(point[0], point[1], 0)
22 geompy.addToStudy(vert,
"Vertex_" + `iv`)
28 Edge_straight = geompy.MakeEdge(vertices[0], vertices[4])
29 Edge_bezierrr = geompy.MakeBezier(vertices)
30 Wire_polyline = geompy.MakePolyline(vertices)
31 Edge_Circle = geompy.MakeCircleThreePnt(vertices[0], vertices[1], vertices[2])
33 geompy.addToStudy(Edge_straight,
"Edge_straight")
34 geompy.addToStudy(Edge_bezierrr,
"Edge_bezierrr")
35 geompy.addToStudy(Wire_polyline,
"Wire_polyline")
36 geompy.addToStudy(Edge_Circle ,
"Edge_Circle")
39 Wire_polyline_edges = geompy.SubShapeAll(Wire_polyline, geompy.ShapeType[
"EDGE"])
40 for ii
in range(len(Wire_polyline_edges)):
41 geompy.addToStudyInFather(Wire_polyline, Wire_polyline_edges[ii],
"Edge_" + `ii + 1`)
47 def Mesh1D(shape1d, nbSeg, name):
48 mesh1d_tool = smesh.Mesh(shape1d, name)
49 algo = mesh1d_tool.Segment()
50 hyp = algo.NumberOfSegments(nbSeg)
51 isDone = mesh1d_tool.Compute()
52 if not isDone:
print 'Mesh ', name,
': computation failed'
56 def MakeQuadMesh2(mesh_name):
57 quad_1 = smesh.Mesh(name = mesh_name)
60 n1 = quad_1.AddNode(0, 20, 10)
61 n2 = quad_1.AddNode(0, 40, 10)
62 n3 = quad_1.AddNode(0, 40, 30)
63 n4 = quad_1.AddNode(0, 20, 30)
64 n5 = quad_1.AddNode(0, 0, 30)
65 n6 = quad_1.AddNode(0, 0, 10)
68 quad_1.AddEdge([n1, n2])
69 quad_1.AddEdge([n2, n3])
70 quad_1.AddEdge([n3, n4])
71 quad_1.AddEdge([n4, n1])
72 quad_1.AddEdge([n4, n5])
73 quad_1.AddEdge([n5, n6])
74 quad_1.AddEdge([n6, n1])
77 quad_1.AddFace([n1, n2, n3, n4])
78 quad_1.AddFace([n1, n4, n5, n6])
79 return [quad_1, [1,2,3,4,5,6,7], [8,9]]
82 Edge_straight_mesh = Mesh1D(Edge_straight, 7,
"Edge_straight")
83 Edge_bezierrr_mesh = Mesh1D(Edge_bezierrr, 7,
"Edge_bezierrr")
84 Wire_polyline_mesh = Mesh1D(Wire_polyline, 3,
"Wire_polyline")
85 Edge_Circle_mesh = Mesh1D(Edge_Circle , 8,
"Edge_Circle")
88 [quad_1, ee_1, ff_1] = MakeQuadMesh2(
"quad_1")
89 [quad_2, ee_2, ff_2] = MakeQuadMesh2(
"quad_2")
90 [quad_3, ee_3, ff_3] = MakeQuadMesh2(
"quad_3")
91 [quad_4, ee_4, ff_4] = MakeQuadMesh2(
"quad_4")
92 [quad_5, ee_5, ff_5] = MakeQuadMesh2(
"quad_5")
93 [quad_6, ee_6, ff_6] = MakeQuadMesh2(
"quad_6")
94 [quad_7, ee_7, ff_7] = MakeQuadMesh2(
"quad_7")
99 refPoint = SMESH.PointStruct(0, 0, 0)
100 a10 = 10.0*math.pi/180.0
101 a45 = 45.0*math.pi/180.0
104 error = quad_1.ExtrusionAlongPath([1,2], Edge_straight_mesh, Edge_straight, 1,
108 error = quad_2.ExtrusionAlongPath([2], Edge_bezierrr_mesh, Edge_bezierrr, 1,
112 error = quad_3.ExtrusionAlongPath([2], Edge_bezierrr_mesh, Edge_bezierrr, 1,
113 1, [a45, a45, a45, 0, -a45, -a45, -a45], 0, refPoint)
116 error = quad_4.ExtrusionAlongPath([4], Wire_polyline_mesh, Wire_polyline_edges[0], 1,
117 1, [a10, a10, a10], 0, refPoint)
120 error = quad_5.ExtrusionAlongPath(ff_5 , Wire_polyline_mesh, Wire_polyline_edges[2], 4,
124 error = quad_6.ExtrusionAlongPath(ff_6 , Edge_Circle_mesh, Edge_Circle, 1,
128 error = quad_7.ExtrusionAlongPath(ff_7, Edge_Circle_mesh, Edge_Circle, 1,
129 1, [a45, -a45, a45, -a45, a45, -a45, a45, -a45], 0, refPoint)
131 salome.sg.updateObjBrowser(
True)
7 from salome.geom
import geomBuilder
8 geompy = geomBuilder.New(salome.myStudy)
10 import SMESH, SALOMEDS
11 from salome.smesh
import smeshBuilder
12 smesh = smeshBuilder.New(salome.myStudy)
15 Box_1 = geompy.MakeBoxDXDYDZ(200., 200., 200.)
16 geompy.addToStudy(Box_1,
"Box_1")
18 faces = geompy.SubShapeAll(Box_1, geompy.ShapeType[
"FACE"])
22 geompy.addToStudyInFather(Box_1, Face_1,
"Face_1")
23 geompy.addToStudyInFather(Box_1, Face_2,
"Face_2")
26 Mesh_1 = smesh.Mesh(Face_1)
27 algo1D = Mesh_1.Segment()
28 algo1D.NumberOfSegments(3)
31 isDone = Mesh_1.Compute()
32 if not isDone:
print 'Mesh Mesh_1 : computation failed'
35 Mesh_2 = smesh.Mesh(Face_2)
37 algo1D = Mesh_2.Segment()
38 algo1D.NumberOfSegments(1)
39 algo2D = Mesh_2.Triangle()
40 algo2D.MaxElementArea(240)
42 isDone = Mesh_2.Compute()
43 if not isDone:
print 'Mesh Mesh_2 : computation failed'
46 pattern = smesh.GetPattern()
48 isDone = pattern.LoadFromFace(Mesh_2.GetMesh(), Face_2, 0)
49 if (isDone != 1):
print 'LoadFromFace :', pattern.GetErrorCode()
52 facesToSplit = Mesh_1.GetElementsByType(SMESH.FACE)
53 print "Splitting %d rectangular face(s) to %d triangles..."%(len(facesToSplit), 2*len(facesToSplit))
54 pattern.ApplyToMeshFaces(Mesh_1.GetMesh(), facesToSplit, 0, 0)
55 isDone = pattern.MakeMesh(Mesh_1.GetMesh(), 0, 0)
56 if (isDone != 1):
print 'MakeMesh :', pattern.GetErrorCode()
59 Mesh_3 = smesh.Mesh(Box_1)
63 isDone = Mesh_3.Compute()
64 if not isDone:
print 'Mesh Mesh_3 : computation failed'
67 pattern_hexa = smesh.GetPattern()
69 smp_hexa =
"""!!! Nb of points:
86 !!! Indices of points of 4 elements:
92 pattern_hexa.LoadFromFile(smp_hexa)
95 volsToSplit = Mesh_3.GetElementsByType(SMESH.VOLUME)
96 print "Splitting %d hexa volume(s) to %d hexas..."%(len(volsToSplit), 4*len(volsToSplit))
97 pattern_hexa.ApplyToHexahedrons(Mesh_3.GetMesh(), volsToSplit,0,3)
98 isDone = pattern_hexa.MakeMesh(Mesh_3.GetMesh(),
True,
True)
99 if (isDone != 1):
print 'MakeMesh :', pattern_hexa.GetErrorCode()
102 Mesh_4 = smesh.Mesh(Box_1)
106 isDone = Mesh_4.Compute()
107 if not isDone:
print 'Mesh Mesh_4 : computation failed'
110 pattern_pyra = smesh.GetPattern()
112 smp_pyra =
"""!!! Nb of points:
123 !!! Indices of points of 6 elements:
131 pattern_pyra.LoadFromFile(smp_pyra)
134 volsToSplit = Mesh_4.GetElementsByType(SMESH.VOLUME)
135 print "Splitting %d hexa volume(s) to %d hexas..."%(len(volsToSplit), 6*len(volsToSplit))
136 pattern_pyra.ApplyToHexahedrons(Mesh_4.GetMesh(), volsToSplit,1,0)
137 isDone = pattern_pyra.MakeMesh(Mesh_4.GetMesh(),
True,
True)
138 if (isDone != 1):
print 'MakeMesh :', pattern_pyra.GetErrorCode()
6 from salome.geom
import geomBuilder
7 geompy = geomBuilder.New(salome.myStudy)
9 from salome.smesh
import smeshBuilder
10 smesh = smeshBuilder.New(salome.myStudy)
13 OY = geompy.MakeVectorDXDYDZ(0, 1, 0)
14 OY1 = geompy.MakeTranslation( OY, 1, 0, 0 )
15 OY2 = geompy.MakeTranslation( OY, 2, 0, 0 )
16 q1 = geompy.MakeQuad2Edges( OY, OY1 )
17 q2 = geompy.MakeQuad2Edges( OY1, OY2 )
19 shape = geompy.Partition( [q1,q2], theName=
'shape' )
20 ff = geompy.SubShapeAll( shape, geompy.ShapeType[
"FACE"], theName=
"quad" )
23 mesh = smesh.Mesh( shape )
26 mesh.Triangle( ff[1] )
30 quadGroup = mesh.Group( ff[0],
"quads")
31 mesh.ExtrusionSweepObject2D( quadGroup, [0,0,1], 1 )
34 mesh.ConvertToQuadratic( theToBiQuad=
True )
37 mesh.SplitBiQuadraticIntoLinear()