By default, 4 threads are used (same default as in CADSurf).
void SetMaxNumberOfPointsPerPatch( in long nb ) raises (SALOME::SALOME_Exception);
long GetMaxNumberOfPointsPerPatch();
+
+ /*!
+ * Set max_number_of_threads parameter
+ *
+ * Set the maximum of threads to use for multithreading mesh computation.
+ */
+ void SetMaxNumberOfThreads( in long nb ) raises (SALOME::SALOME_Exception);
+ long GetMaxNumberOfThreads();
+
/*!
* Set respect_geometry parameter
*
def SetMaxNumberOfPointsPerPatch( self, nb ):
self.Parameters().SetMaxNumberOfPointsPerPatch( nb )
+ ## Set max_number_of_threads parameter
+ #
+ # Set the maximum of threads to use for multithreading mesh computation
+ #
+ def SetMaxNumberOfThreads( self, nb ):
+ self.Parameters().SetMaxNumberOfThreads( nb )
+
## Set respect_geometry parameter
#
# This patch independent option can be deactivated to allow MeshGems-CADSurf
cad_t *c = cad_new(ctx);
dcad_t *dcad = dcad_new(c);
+ // To enable multithreading
+ cad_set_thread_safety(c, 1);
+
/* Now fill the CAD object with data from your CAD
* environement. This is the most complex part of a successfull
* integration.
};
const char* intOptionNames[] = { "max_number_of_points_per_patch", // default = 100000
+ "max_number_of_threads", // default = 4
"" // mark of end
};
const char* doubleOptionNames[] = { // "surface_intersections_processing_max_cost",// default = 15
_defaultOptionValues["enforce_cad_edge_sizes" ] = "no";
_defaultOptionValues["jacobian_rectification_respect_geometry"] = "yes";
_defaultOptionValues["max_number_of_points_per_patch" ] = "0";
+ _defaultOptionValues["max_number_of_threads" ] = "4";
_defaultOptionValues["rectify_jacobian" ] = "yes";
_defaultOptionValues["respect_geometry" ] = "yes";
_defaultOptionValues["tiny_edge_avoid_surface_intersections" ] = "yes";
}
//=============================================================================
+void BLSURFPlugin_Hypothesis::SetMaxNumberOfThreads( int nb )
+ throw (std::invalid_argument)
+{
+ if ( nb < 0 )
+ throw std::invalid_argument( SMESH_Comment("Invalid number of threads: ") << nb );
+
+ if ( GetMaxNumberOfThreads() != nb )
+ {
+ SetOptionValue("max_number_of_threads", SMESH_Comment( nb ));
+ NotifySubMeshesHypothesisModification();
+ }
+}
+//=============================================================================
+int BLSURFPlugin_Hypothesis::GetMaxNumberOfThreads()
+{
+ return ToInt( GetOptionValue("max_number_of_threads", GET_DEFAULT()));
+}
+//=============================================================================
+
void BLSURFPlugin_Hypothesis::SetRespectGeometry( bool toRespect )
{
if ( GetRespectGeometry() != toRespect )
void SetMaxNumberOfPointsPerPatch( int nb ) throw (std::invalid_argument);
int GetMaxNumberOfPointsPerPatch();
+ void SetMaxNumberOfThreads( int nb ) throw (std::invalid_argument);
+ int GetMaxNumberOfThreads();
+
void SetRespectGeometry( bool toRespect );
bool GetRespectGeometry();
}
//=============================================================================
+void BLSURFPlugin_Hypothesis_i::SetMaxNumberOfThreads( CORBA::Long nb ) throw (SALOME::SALOME_Exception)
+{
+ if ( GetMaxNumberOfThreads() != nb )
+ {
+ try {
+ this->GetImpl()->SetMaxNumberOfThreads(nb);
+
+ } catch (const std::invalid_argument& ex) {
+ THROW_SALOME_CORBA_EXCEPTION( ex.what() ,SALOME::BAD_PARAM );
+ } catch (SALOME_Exception& ex) {
+ THROW_SALOME_CORBA_EXCEPTION( ex.what() ,SALOME::BAD_PARAM );
+ }
+ SMESH::TPythonDump() << _this() << ".SetMaxNumberOfThreads( " << nb << " )";
+ }
+}
+//=============================================================================
+CORBA::Long BLSURFPlugin_Hypothesis_i::GetMaxNumberOfThreads()
+{
+ return this->GetImpl()->GetMaxNumberOfThreads();
+}
+//=============================================================================
+
void BLSURFPlugin_Hypothesis_i::SetRespectGeometry( CORBA::Boolean toRespect )
{
if ( GetRespectGeometry() != toRespect )
else if ( name == "max_number_of_points_per_patch" )
SetMaxNumberOfPointsPerPatch( GetImpl()->ToInt( optionValue ));
+ else if ( name == "max_number_of_threads" )
+ SetMaxNumberOfThreads( GetImpl()->ToInt( optionValue ));
+
else if ( name == "rectify_jacobian" )
SetJacobianRectification( GetImpl()->ToBool( optionValue ));
void SetMaxNumberOfPointsPerPatch( CORBA::Long nb ) throw (SALOME::SALOME_Exception);
CORBA::Long GetMaxNumberOfPointsPerPatch();
+ void SetMaxNumberOfThreads( CORBA::Long nb ) throw (SALOME::SALOME_Exception);
+ CORBA::Long GetMaxNumberOfThreads();
+
void SetRespectGeometry( CORBA::Boolean toRespect );
CORBA::Boolean GetRespectGeometry();
<source>max_number_of_points_per_patch</source>
<translation>Maximal number of points per patch</translation>
</message>
+ <message>
+ <source>max_number_of_threads</source>
+ <translation>Maximal number of threads</translation>
+ </message>
<message>
<source>rectify_jacobian</source>
<translation>Rectify Jacobian</translation>
<source>max_number_of_points_per_patch</source>
<translation>Nombre de points maximal par patch</translation>
</message>
+ <message>
+ <source>max_number_of_threads</source>
+ <translation>Nombre de threads maximal</translation>
+ </message>
<message>
<source>rectify_jacobian</source>
<translation>Ajustement du Jacobien</translation>
<source>max_number_of_points_per_patch</source>
<translation>1パッチの最大点数</translation>
</message>
+ <message>
+ <source>max_number_of_threads</source>
+ <translation type="unfinished">Maximal number of threads</translation>
+ </message>
<message>
<source>rectify_jacobian</source>
<translation>ヤコビアンの修正</translation>
#
SET(BLSURFPLUGIN_TEST_FILES
+ test_cadsurf_multithread.py
test_enforced_internal_vertex.py
test_enforced_vertex.py
test_periodicity_2D_precad.py
--- /dev/null
+# -*- coding: utf-8 -*-
+
+import os
+import sys
+import salome
+import time
+
+salome.salome_init()
+theStudy = salome.myStudy
+
+###
+### GEOM component
+###
+
+import GEOM
+from salome.geom import geomBuilder
+import math
+import SALOMEDS
+
+
+geompy = geomBuilder.New(theStudy)
+
+O = geompy.MakeVertex(0, 0, 0)
+OX = geompy.MakeVectorDXDYDZ(1, 0, 0)
+OY = geompy.MakeVectorDXDYDZ(0, 1, 0)
+OZ = geompy.MakeVectorDXDYDZ(0, 0, 1)
+flight_solid_brep_1 = geompy.ImportBREP(os.path.join(os.getenv("DATA_DIR"),"Shapes/Brep/flight_solid.brep" ))
+geompy.addToStudy( O, 'O' )
+geompy.addToStudy( OX, 'OX' )
+geompy.addToStudy( OY, 'OY' )
+geompy.addToStudy( OZ, 'OZ' )
+geompy.addToStudy( flight_solid_brep_1, 'flight_solid.brep_1' )
+
+###
+### SMESH component
+###
+
+import SMESH, SALOMEDS
+from salome.smesh import smeshBuilder
+
+smesh = smeshBuilder.New(theStudy)
+
+Mesh_1 = smesh.Mesh(flight_solid_brep_1)
+MG_CADSurf = Mesh_1.Triangle(algo=smeshBuilder.MG_CADSurf)
+MG_CADSurf_Parameters_1 = MG_CADSurf.Parameters()
+MG_CADSurf_Parameters_1.SetPhySize( 1 )
+MG_CADSurf_Parameters_1.SetMaxSize( 1 )
+MG_CADSurf_Parameters_1.SetGradation( 1.05 )
+MG_CADSurf_Parameters_1.SetAngleMesh( 1 )
+MG_CADSurf_Parameters_1.SetChordalError( 2.40018 )
+# 4 procs are used by default
+# => No need to set an option
+
+time0 = time.time()
+isDone = Mesh_1.Compute()
+time1 = time.time()
+
+time_multithread = time1-time0
+
+print "Time in 4 proc: %.3s"%(time_multithread)
+
+Mesh_2 = smesh.Mesh(flight_solid_brep_1)
+MG_CADSurf = Mesh_2.Triangle(algo=smeshBuilder.MG_CADSurf)
+MG_CADSurf_Parameters_2 = MG_CADSurf.Parameters()
+MG_CADSurf_Parameters_2.SetPhySize( 1 )
+MG_CADSurf_Parameters_2.SetMaxSize( 1 )
+MG_CADSurf_Parameters_2.SetGradation( 1.05 )
+MG_CADSurf_Parameters_2.SetAngleMesh( 1 )
+MG_CADSurf_Parameters_2.SetChordalError( 2.40018 )
+# Use only one thread
+MG_CADSurf_Parameters_2.SetMaxNumberOfThreads( 1 )
+
+time2 = time.time()
+isDone = Mesh_2.Compute()
+time3 = time.time()
+
+time_singlethread = time3-time2
+print "Time in 1 proc: %.3s"%(time_singlethread)
+
+assert time_multithread < time_singlethread/2.
+
+if salome.sg.hasDesktop():
+ salome.sg.updateObjBrowser(True)