]> SALOME platform Git repositories - modules/smesh.git/blob - doc/salome/examples/defining_hypotheses_ex16.py
Salome HOME
Fix for the '52701: SIGSEGV in Mesh creation dialog box after activating Viscous...
[modules/smesh.git] / doc / salome / examples / defining_hypotheses_ex16.py
1 # "Import 2D Elements from Another Mesh" example
2
3 import salome
4 salome.salome_init()
5 import GEOM
6 from salome.geom import geomBuilder
7 geompy = geomBuilder.New(salome.myStudy)
8
9 import SMESH, SALOMEDS
10 from salome.smesh import smeshBuilder
11 smesh =  smeshBuilder.New(salome.myStudy)
12
13 # Make a patritioned box
14
15 box = geompy.MakeBoxDXDYDZ(100,100,100)
16
17 N = geompy.MakeVectorDXDYDZ( 1,0,0 )
18 O = geompy.MakeVertex( 50,0,0 )
19 plane = geompy.MakePlane( O, N, 200 ) # plane YOZ
20
21 shape2boxes = geompy.MakeHalfPartition( box, plane )
22 boxes = geompy.SubShapeAllSorted(shape2boxes, geompy.ShapeType["SOLID"])
23
24 geompy.addToStudy( boxes[0], "boxes[0]")
25 geompy.addToStudy( boxes[1], "boxes[1]")
26 midFace0 = geompy.SubShapeAllSorted(boxes[0], geompy.ShapeType["FACE"])[5]
27 geompy.addToStudyInFather( boxes[0], midFace0, "middle Face")
28 midFace1 = geompy.SubShapeAllSorted(boxes[1], geompy.ShapeType["FACE"])[0]
29 geompy.addToStudyInFather( boxes[1], midFace1, "middle Face")
30
31 # Mesh one of boxes with quadrangles. It is a source mesh
32
33 srcMesh = smesh.Mesh(boxes[0], "source mesh") # box coloser to CS origin
34 nSeg1 = srcMesh.Segment().NumberOfSegments(4)
35 srcMesh.Quadrangle()
36 srcMesh.Compute()
37 srcFaceGroup = srcMesh.GroupOnGeom( midFace0, "src faces", SMESH.FACE )
38
39 # Import faces from midFace0 to the target mesh
40
41 tgtMesh = smesh.Mesh(boxes[1], "target mesh")
42 importAlgo = tgtMesh.UseExisting2DElements(midFace1)
43 import2hyp = importAlgo.SourceFaces( [srcFaceGroup] )
44 tgtMesh.Segment().NumberOfSegments(3)
45 tgtMesh.Quadrangle()
46 tgtMesh.Compute()
47
48 # Import the whole source mesh with groups
49 import2hyp.SetCopySourceMesh(True,True)
50 tgtMesh.Compute()