1 # -*- coding: utf-8 -*-
2 # Copyright (C) 2017-2019 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()
30 divider = min(4, cpu_count)/2.
32 print ("Running test on workstation with %d available cores" % cpu_count)
39 from salome.geom import geomBuilder
44 geompy = geomBuilder.New()
46 O = geompy.MakeVertex(0, 0, 0)
47 OX = geompy.MakeVectorDXDYDZ(1, 0, 0)
48 OY = geompy.MakeVectorDXDYDZ(0, 1, 0)
49 OZ = geompy.MakeVectorDXDYDZ(0, 0, 1)
50 flight_solid_brep_1 = geompy.ImportBREP(os.path.join(os.getenv("BLSURFPLUGIN_ROOT_DIR"),"share/salome/resources/blsurfplugin/flight_solid.brep"))
51 geompy.addToStudy( O, 'O' )
52 geompy.addToStudy( OX, 'OX' )
53 geompy.addToStudy( OY, 'OY' )
54 geompy.addToStudy( OZ, 'OZ' )
55 geompy.addToStudy( flight_solid_brep_1, 'flight_solid.brep_1' )
61 import SMESH, SALOMEDS
62 from salome.smesh import smeshBuilder
64 smesh = smeshBuilder.New()
66 Mesh_1 = smesh.Mesh(flight_solid_brep_1)
67 MG_CADSurf = Mesh_1.Triangle(algo=smeshBuilder.MG_CADSurf)
68 MG_CADSurf_Parameters_1 = MG_CADSurf.Parameters()
69 MG_CADSurf_Parameters_1.SetPhySize( 1 )
70 MG_CADSurf_Parameters_1.SetMaxSize( 1 )
71 MG_CADSurf_Parameters_1.SetGradation( 1.05 )
72 MG_CADSurf_Parameters_1.SetAngleMesh( 1 )
73 MG_CADSurf_Parameters_1.SetChordalError( 2.40018 )
74 # 4 procs are used by default
75 # => No need to set an option
78 isDone = Mesh_1.Compute()
81 time_multithread = time1-time0
83 print ("Time in multi thread (%d cores): %.3s"%(cpu_count, time_multithread))
85 Mesh_2 = smesh.Mesh(flight_solid_brep_1)
86 MG_CADSurf = Mesh_2.Triangle(algo=smeshBuilder.MG_CADSurf)
87 MG_CADSurf_Parameters_2 = MG_CADSurf.Parameters()
88 MG_CADSurf_Parameters_2.SetPhySize( 1 )
89 MG_CADSurf_Parameters_2.SetMaxSize( 1 )
90 MG_CADSurf_Parameters_2.SetGradation( 1.05 )
91 MG_CADSurf_Parameters_2.SetAngleMesh( 1 )
92 MG_CADSurf_Parameters_2.SetChordalError( 2.40018 )
94 MG_CADSurf_Parameters_2.SetMaxNumberOfThreads( 1 )
97 isDone = Mesh_2.Compute()
100 time_singlethread = time3-time2
101 print ("Time in single thread (1 proc): %.3s"%(time_singlethread))
104 print ("Warning: cannot validate test - only 1 cpu core is available")
106 assert time_multithread < time_singlethread/divider
108 if salome.sg.hasDesktop():
109 salome.sg.updateObjBrowser()