1 # -*- coding: utf-8 -*-
2 # Copyright (C) 2017-2022 CEA/DEN, EDF R&D
4 # This library is free software; you can redistribute it and/or
5 # modify it under the terms of the GNU Lesser General Public
6 # License as published by the Free Software Foundation; either
7 # version 2.1 of the License, or (at your option) any later version.
9 # This library is distributed in the hope that it will be useful,
10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 # Lesser General Public License for more details.
14 # You should have received a copy of the GNU Lesser General Public
15 # License along with this library; if not, write to the Free Software
16 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18 # See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
25 import multiprocessing
29 cpu_count = multiprocessing.cpu_count()
32 print ("Running test on workstation with %d available cores" % cpu_count)
39 from salome.geom import geomBuilder
43 geompy = geomBuilder.New()
45 O = geompy.MakeVertex(0, 0, 0)
46 OX = geompy.MakeVectorDXDYDZ(1, 0, 0)
47 OY = geompy.MakeVectorDXDYDZ(0, 1, 0)
48 OZ = geompy.MakeVectorDXDYDZ(0, 0, 1)
49 flight_solid_brep_1 = geompy.ImportBREP(os.path.join(os.getenv("BLSURFPLUGIN_ROOT_DIR"),"share/salome/resources/blsurfplugin/flight_solid.brep"))
50 geompy.addToStudy( O, 'O' )
51 geompy.addToStudy( OX, 'OX' )
52 geompy.addToStudy( OY, 'OY' )
53 geompy.addToStudy( OZ, 'OZ' )
54 geompy.addToStudy( flight_solid_brep_1, 'flight_solid.brep_1' )
60 import SMESH, SALOMEDS
61 from salome.smesh import smeshBuilder
63 smesh = smeshBuilder.New()
65 Mesh_1 = smesh.Mesh(flight_solid_brep_1)
66 MG_CADSurf = Mesh_1.Triangle(algo=smeshBuilder.MG_CADSurf)
67 MG_CADSurf_Parameters_1 = MG_CADSurf.Parameters()
68 MG_CADSurf_Parameters_1.SetPhySize( 1 )
69 MG_CADSurf_Parameters_1.SetMaxSize( 1 )
70 MG_CADSurf_Parameters_1.SetGradation( 1.05 )
71 MG_CADSurf_Parameters_1.SetAngleMesh( 1 )
72 MG_CADSurf_Parameters_1.SetChordalError( 2.40018 )
73 # 4 procs are used by default
74 # => No need to set an option
77 isDone = Mesh_1.Compute()
80 time_multithread = time1-time0
82 print ("Time in multi thread (%d procs): %.3f s"%(cpu_count, time_multithread))
84 Mesh_2 = smesh.Mesh(flight_solid_brep_1)
85 MG_CADSurf = Mesh_2.Triangle(algo=smeshBuilder.MG_CADSurf)
86 MG_CADSurf_Parameters_2 = MG_CADSurf.Parameters()
87 MG_CADSurf_Parameters_2.SetPhySize( 1 )
88 MG_CADSurf_Parameters_2.SetMaxSize( 1 )
89 MG_CADSurf_Parameters_2.SetGradation( 1.05 )
90 MG_CADSurf_Parameters_2.SetAngleMesh( 1 )
91 MG_CADSurf_Parameters_2.SetChordalError( 2.40018 )
93 MG_CADSurf_Parameters_2.SetMaxNumberOfThreads( 1 )
96 isDone = Mesh_2.Compute()
99 time_singlethread = time3-time2
100 print ("Time in single thread (1 proc): %.3f s"%(time_singlethread))
102 assert time_multithread < time_singlethread
104 if salome.sg.hasDesktop():
105 salome.sg.updateObjBrowser()
107 print ("Warning: multithread test is disabled for %d cpu core(s)" % cpu_count)