X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=examples%2Fghs3dprh_multithread_cube_one_face.py;fp=examples%2Fghs3dprh_multithread_cube_one_face.py;h=27f72f8c0f2de159428d21ce7444acda947e437a;hb=ac107579219b08914567f79c6a27bc1efb05b264;hp=0000000000000000000000000000000000000000;hpb=f2dd979943d3ec1026c73a9927f2b429002de4fa;p=plugins%2Fghs3dprlplugin.git diff --git a/examples/ghs3dprh_multithread_cube_one_face.py b/examples/ghs3dprh_multithread_cube_one_face.py new file mode 100644 index 0000000..27f72f8 --- /dev/null +++ b/examples/ghs3dprh_multithread_cube_one_face.py @@ -0,0 +1,114 @@ +#!/usr/bin/env python + +""" +| usage: +| salome/File/Load_script ${GHS3DPRLPLUGIN_ROOT_DIR}/example +| +| result should be a tetrahedric meshed cube with one group of faces named Group_1 +| - with .SetMultithread(0) in 4 files med +| with mg-tetra_hpc.exe mpi results files are in /tmp/DOMAIN_*.med +| - with .SetMultithread(1) in 1 file med +| with mg-tetra_hpc.exe multithread result files are in /tmp/DOMAIN_1.med +""" + +### +### This file is generated automatically by SALOME v9.4.0 with dump python functionality +### + +import sys +import salome + +salome.salome_init() +# import salome_notebook +# notebook = salome_notebook.NoteBook() +# sys.path.insert(0, r'...') + + +### +### 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) +Box_1 = geompy.MakeBoxDXDYDZ(200, 200, 200) +Group_1 = geompy.CreateGroup(Box_1, geompy.ShapeType["FACE"]) +geompy.UnionIDs(Group_1, [13]) +[Group_1] = geompy.GetExistingSubObjects(Box_1, False) +geompy.addToStudy( O, 'O' ) +geompy.addToStudy( OX, 'OX' ) +geompy.addToStudy( OY, 'OY' ) +geompy.addToStudy( OZ, 'OZ' ) +geompy.addToStudy( Box_1, 'Box_1' ) +geompy.addToStudyInFather( Box_1, Group_1, 'Group_1' ) + +### +### 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) + +Mesh_1 = smesh.Mesh(Box_1) +NETGEN_1D_2D = Mesh_1.Triangle(algo=smeshBuilder.NETGEN_1D2D) +NETGEN_2D_Simple_Parameters_1 = NETGEN_1D_2D.Parameters(smeshBuilder.SIMPLE) +NETGEN_2D_Simple_Parameters_1.SetNumberOfSegments( 8 ) +NETGEN_2D_Simple_Parameters_1.SetMaxElementArea( 1200 ) +NETGEN_2D_Simple_Parameters_1.SetAllowQuadrangles( 0 ) +MG_Tetra_HPC = Mesh_1.Tetrahedron(algo=smeshBuilder.MG_Tetra_Parallel) +MG_Tetra_HPC_Parameters_1 = MG_Tetra_HPC.Parameters() +MG_Tetra_HPC_Parameters_1.SetMEDName( 'DOMAIN' ) +MG_Tetra_HPC_Parameters_1.SetNbPart( 4 ) # MPI: 4 files, Multithread: 4 threads +MG_Tetra_HPC_Parameters_1.SetKeepFiles( 1 ) +MG_Tetra_HPC_Parameters_1.SetBackground( 0 ) +# Multithread: have to load only one file DOMAIN_1.med +# MPI: have to load 4 file DOMAIN_1.med -> DOMAIN_4.med +MG_Tetra_HPC_Parameters_1.SetMultithread( 1 ) +MG_Tetra_HPC_Parameters_1.SetGradation( 1.05 ) +MG_Tetra_HPC_Parameters_1.SetMinSize( 0 ) +MG_Tetra_HPC_Parameters_1.SetMaxSize( 0 ) +Group_1_1 = Mesh_1.GroupOnGeom(Group_1,'Group_1',SMESH.FACE) +isDone = Mesh_1.Compute() +[ Group_1_1 ] = Mesh_1.GetGroups() +([SKIN_INITIAL], status) = smesh.CreateMeshesFromMED(r'/tmp/DOMAIN_skin.med') +[ Group_1_2, Group_Of_All_Faces, Group_Of_All_Edges, Group_Of_All_Nodes ] = SKIN_INITIAL.GetGroups() +([DOMAIN_1], status) = smesh.CreateMeshesFromMED(r'/tmp/DOMAIN_1.med') +[ All_Faces, Group_1_3, Skin_Group_Of_All_Faces, New_Tetrahedra, All_Nodes, New_Nodes ] = DOMAIN_1.GetGroups() + + +## Set names of Mesh objects +smesh.SetName(Group_Of_All_Edges, 'Group_Of_All_Edges') +smesh.SetName(All_Nodes, 'All_Nodes') +smesh.SetName(New_Nodes, 'New_Nodes') +smesh.SetName(NETGEN_1D_2D.GetAlgorithm(), 'NETGEN 1D-2D') +smesh.SetName(MG_Tetra_HPC.GetAlgorithm(), 'MG-Tetra_HPC') +smesh.SetName(Group_Of_All_Nodes, 'Group_Of_All_Nodes') +smesh.SetName(MG_Tetra_HPC_Parameters_1, 'MG-Tetra_HPC Parameters_1') +smesh.SetName(NETGEN_2D_Simple_Parameters_1, 'NETGEN 2D Simple Parameters_1') +smesh.SetName(Group_1_1, 'Group_1') +smesh.SetName(Mesh_1.GetMesh(), 'Mesh_1') +smesh.SetName(DOMAIN_1.GetMesh(), 'DOMAIN_1') +smesh.SetName(SKIN_INITIAL.GetMesh(), 'SKIN_INITIAL') +smesh.SetName(New_Tetrahedra, 'New_Tetrahedra') +smesh.SetName(Group_1_3, 'Group_1') +smesh.SetName(Skin_Group_Of_All_Faces, 'Skin_Group_Of_All_Faces') +smesh.SetName(All_Faces, 'All_Faces') +smesh.SetName(Group_Of_All_Faces, 'Group_Of_All_Faces') +smesh.SetName(Group_1_2, 'Group_1') + + +if salome.sg.hasDesktop(): + salome.sg.updateObjBrowser()