1 # -*- coding: utf-8 -*-
11 cpu_count = multiprocessing.cpu_count()
12 divider = min(4, cpu_count)/2.
14 print ("Running test on workstation with %d available cores" % cpu_count)
21 from salome.geom import geomBuilder
26 geompy = geomBuilder.New()
28 O = geompy.MakeVertex(0, 0, 0)
29 OX = geompy.MakeVectorDXDYDZ(1, 0, 0)
30 OY = geompy.MakeVectorDXDYDZ(0, 1, 0)
31 OZ = geompy.MakeVectorDXDYDZ(0, 0, 1)
32 flight_solid_brep_1 = geompy.ImportBREP(os.path.join(os.getenv("BLSURFPLUGIN_ROOT_DIR"),"share/salome/resources/blsurfplugin/flight_solid.brep"))
33 geompy.addToStudy( O, 'O' )
34 geompy.addToStudy( OX, 'OX' )
35 geompy.addToStudy( OY, 'OY' )
36 geompy.addToStudy( OZ, 'OZ' )
37 geompy.addToStudy( flight_solid_brep_1, 'flight_solid.brep_1' )
43 import SMESH, SALOMEDS
44 from salome.smesh import smeshBuilder
46 smesh = smeshBuilder.New()
48 Mesh_1 = smesh.Mesh(flight_solid_brep_1)
49 MG_CADSurf = Mesh_1.Triangle(algo=smeshBuilder.MG_CADSurf)
50 MG_CADSurf_Parameters_1 = MG_CADSurf.Parameters()
51 MG_CADSurf_Parameters_1.SetPhySize( 1 )
52 MG_CADSurf_Parameters_1.SetMaxSize( 1 )
53 MG_CADSurf_Parameters_1.SetGradation( 1.05 )
54 MG_CADSurf_Parameters_1.SetAngleMesh( 1 )
55 MG_CADSurf_Parameters_1.SetChordalError( 2.40018 )
56 # 4 procs are used by default
57 # => No need to set an option
60 isDone = Mesh_1.Compute()
63 time_multithread = time1-time0
65 print ("Time in multi thread (%d cores): %.3s"%(cpu_count, time_multithread))
67 Mesh_2 = smesh.Mesh(flight_solid_brep_1)
68 MG_CADSurf = Mesh_2.Triangle(algo=smeshBuilder.MG_CADSurf)
69 MG_CADSurf_Parameters_2 = MG_CADSurf.Parameters()
70 MG_CADSurf_Parameters_2.SetPhySize( 1 )
71 MG_CADSurf_Parameters_2.SetMaxSize( 1 )
72 MG_CADSurf_Parameters_2.SetGradation( 1.05 )
73 MG_CADSurf_Parameters_2.SetAngleMesh( 1 )
74 MG_CADSurf_Parameters_2.SetChordalError( 2.40018 )
76 MG_CADSurf_Parameters_2.SetMaxNumberOfThreads( 1 )
79 isDone = Mesh_2.Compute()
82 time_singlethread = time3-time2
83 print ("Time in single thread (1 proc): %.3s"%(time_singlethread))
86 print ("Warning: cannot validate test - only 1 cpu core is available")
88 assert time_multithread < time_singlethread/divider
90 if salome.sg.hasDesktop():
91 salome.sg.updateObjBrowser(True)