Salome HOME
comment examples/ghs3dprh_multithread_cube_one_face.py
[plugins/ghs3dprlplugin.git] / examples / ghs3dprh_multithread_cube_one_face.py
1 #!/usr/bin/env python
2
3 """
4 | usage:
5 | salome/File/Load_script ${GHS3DPRLPLUGIN_ROOT_DIR}/example
6 |
7 | result should be a tetrahedric meshed cube with one group of faces named Group_1
8 | - with .SetMultithread(0) in 4 files med
9 |   with mg-tetra_hpc.exe mpi results files are in /tmp/DOMAIN_*.med
10 | - with .SetMultithread(1) in 1 file med
11 |   with mg-tetra_hpc.exe multithread result files are in /tmp/DOMAIN_1.med
12 """
13
14 ###
15 ### This file is generated automatically by SALOME v9.4.0 with dump python functionality
16 ###
17
18 import sys
19 import salome
20
21 salome.salome_init()
22 # import salome_notebook
23 # notebook = salome_notebook.NoteBook()
24 # sys.path.insert(0, r'...')
25
26
27 ###
28 ### GEOM component
29 ###
30
31 import GEOM
32 from salome.geom import geomBuilder
33 import math
34 import SALOMEDS
35
36
37 geompy = geomBuilder.New()
38
39 O = geompy.MakeVertex(0, 0, 0)
40 OX = geompy.MakeVectorDXDYDZ(1, 0, 0)
41 OY = geompy.MakeVectorDXDYDZ(0, 1, 0)
42 OZ = geompy.MakeVectorDXDYDZ(0, 0, 1)
43 Box_1 = geompy.MakeBoxDXDYDZ(200, 200, 200)
44 Group_1 = geompy.CreateGroup(Box_1, geompy.ShapeType["FACE"])
45 geompy.UnionIDs(Group_1, [13])
46 [Group_1] = geompy.GetExistingSubObjects(Box_1, False)
47 geompy.addToStudy( O, 'O' )
48 geompy.addToStudy( OX, 'OX' )
49 geompy.addToStudy( OY, 'OY' )
50 geompy.addToStudy( OZ, 'OZ' )
51 geompy.addToStudy( Box_1, 'Box_1' )
52 geompy.addToStudyInFather( Box_1, Group_1, 'Group_1' )
53
54 ###
55 ### SMESH component
56 ###
57
58 import  SMESH, SALOMEDS
59 from salome.smesh import smeshBuilder
60
61 smesh = smeshBuilder.New()
62 #smesh.SetEnablePublish( False ) # Set to False to avoid publish in study if not needed or in some particular situations:
63                                  # multiples meshes built in parallel, complex and numerous mesh edition (performance)
64
65 Mesh_1 = smesh.Mesh(Box_1)
66 NETGEN_1D_2D = Mesh_1.Triangle(algo=smeshBuilder.NETGEN_1D2D)
67 NETGEN_2D_Simple_Parameters_1 = NETGEN_1D_2D.Parameters(smeshBuilder.SIMPLE)
68 NETGEN_2D_Simple_Parameters_1.SetNumberOfSegments( 8 )
69 NETGEN_2D_Simple_Parameters_1.SetMaxElementArea( 1200 )
70 NETGEN_2D_Simple_Parameters_1.SetAllowQuadrangles( 0 )
71 MG_Tetra_HPC = Mesh_1.Tetrahedron(algo=smeshBuilder.MG_Tetra_Parallel)
72 MG_Tetra_HPC_Parameters_1 = MG_Tetra_HPC.Parameters()
73 MG_Tetra_HPC_Parameters_1.SetMEDName( 'DOMAIN' )
74 MG_Tetra_HPC_Parameters_1.SetNbPart( 4 ) # MPI: 4 files, Multithread: 4 threads
75 MG_Tetra_HPC_Parameters_1.SetKeepFiles( 1 )
76 MG_Tetra_HPC_Parameters_1.SetBackground( 0 )
77 # Multithread: have to load only one file DOMAIN_1.med
78 # MPI: have to load 4 file DOMAIN_1.med -> DOMAIN_4.med
79 MG_Tetra_HPC_Parameters_1.SetMultithread( 1 )
80 MG_Tetra_HPC_Parameters_1.SetGradation( 1.05 )
81 MG_Tetra_HPC_Parameters_1.SetMinSize( 0 )
82 MG_Tetra_HPC_Parameters_1.SetMaxSize( 0 )
83 Group_1_1 = Mesh_1.GroupOnGeom(Group_1,'Group_1',SMESH.FACE)
84 isDone = Mesh_1.Compute()
85 [ Group_1_1 ] = Mesh_1.GetGroups()
86 ([SKIN_INITIAL], status) = smesh.CreateMeshesFromMED(r'/tmp/DOMAIN_skin.med')
87 [ Group_1_2, Group_Of_All_Faces, Group_Of_All_Edges, Group_Of_All_Nodes ] = SKIN_INITIAL.GetGroups()
88 ([DOMAIN_1], status) = smesh.CreateMeshesFromMED(r'/tmp/DOMAIN_1.med')
89 [ All_Faces, Group_1_3, Skin_Group_Of_All_Faces, New_Tetrahedra, All_Nodes, New_Nodes ] = DOMAIN_1.GetGroups()
90
91
92 ## Set names of Mesh objects
93 smesh.SetName(Group_Of_All_Edges, 'Group_Of_All_Edges')
94 smesh.SetName(All_Nodes, 'All_Nodes')
95 smesh.SetName(New_Nodes, 'New_Nodes')
96 smesh.SetName(NETGEN_1D_2D.GetAlgorithm(), 'NETGEN 1D-2D')
97 smesh.SetName(MG_Tetra_HPC.GetAlgorithm(), 'MG-Tetra_HPC')
98 smesh.SetName(Group_Of_All_Nodes, 'Group_Of_All_Nodes')
99 smesh.SetName(MG_Tetra_HPC_Parameters_1, 'MG-Tetra_HPC Parameters_1')
100 smesh.SetName(NETGEN_2D_Simple_Parameters_1, 'NETGEN 2D Simple Parameters_1')
101 smesh.SetName(Group_1_1, 'Group_1')
102 smesh.SetName(Mesh_1.GetMesh(), 'Mesh_1')
103 smesh.SetName(DOMAIN_1.GetMesh(), 'DOMAIN_1')
104 smesh.SetName(SKIN_INITIAL.GetMesh(), 'SKIN_INITIAL')
105 smesh.SetName(New_Tetrahedra, 'New_Tetrahedra')
106 smesh.SetName(Group_1_3, 'Group_1')
107 smesh.SetName(Skin_Group_Of_All_Faces, 'Skin_Group_Of_All_Faces')
108 smesh.SetName(All_Faces, 'All_Faces')
109 smesh.SetName(Group_Of_All_Faces, 'Group_Of_All_Faces')
110 smesh.SetName(Group_1_2, 'Group_1')
111
112
113 if salome.sg.hasDesktop():
114   salome.sg.updateObjBrowser()