Salome HOME
Adding structure for parallelism parameters yan/parallel_mesh_cleanup
authorYoann Audouin <yoann.audouin@edf.fr>
Tue, 17 Jan 2023 09:41:00 +0000 (10:41 +0100)
committerYoann Audouin <yoann.audouin@edf.fr>
Tue, 17 Jan 2023 10:24:02 +0000 (11:24 +0100)
doc/examples/creating_parallel_mesh.py
doc/gui/input/parallel_compute.rst
idl/SMESH_Mesh.idl
src/SMESH_I/SMESH_Mesh_i.cxx
src/SMESH_I/SMESH_Mesh_i.hxx
src/SMESH_SWIG/smeshBuilder.py

index 9cfc0ee8000c872906f251625ccaccfb7bc5622a..ae7a22c0d1755ff2b62b3c9ce25441825dc014a8 100644 (file)
@@ -100,7 +100,10 @@ def run_test(nbox=2, boxsize=100):
 
     par_mesh = smesh.ParallelMesh(geom, name="par_mesh")
     par_mesh.AddGlobalHypothesis(netgen_parameters)
-    par_mesh.SetNbThreads(6)
+    param = par_mesh.GetParallelismSettings()
+    param.SetNbThreads(6)
+
+    assert param.GetNbThreads() == 6, param.GetNbThreads()
 
     start = time.monotonic()
     is_done = seq_mesh.Compute()
index 82d1abfb9a3c5eca5505c97730508bc4805e223a..fecbf2fea1b70be8ac688979df395ef0d277b563 100644 (file)
@@ -59,7 +59,8 @@ You follow the same principle as the creation of a sequential Mesh.
 #. Set the parameters for the parallelisation:
        .. code-block:: python
 
-               par_mesh.SetNbThreads()Compute()
+               param = par_mesh.GetParallelismSettings()
+               param.SetNbThreads(6)
 
 #. Compute the mesh:
        .. code-block:: python
index d4bc7fb5732eb7a9a1b0e39b2eaa4e7366fe3cd5..88152274ef2a4a354fd7b40a32ead57e0647d462 100644 (file)
@@ -904,6 +904,11 @@ module SMESH
      */
     void SetNbThreads(in long nbThreads);
     /*!
+    /*!
+     * \brief Get Number of Threads
+     */
+    long GetNbThreads();
+    /*!
 
     /*!
      * Get mesh description
index 7d4bcb4181a5d280d1b33c3853cb4d793aa6cc7a..d101f14dcd2a34feae7e61230b910071771eb45a 100644 (file)
@@ -7037,6 +7037,15 @@ void SMESH_Mesh_i::SetNbThreads(CORBA::Long nbThreads){
   _impl->SetNbThreads(nbThreads);
 }
 
+//=============================================================================
+/*!
+ * \brief Get the number of threads for a parallel computation
+ */
+//=============================================================================
+CORBA::Long SMESH_Mesh_i::GetNbThreads(){
+  return _impl->GetNbThreads();
+}
+
 
 //=============================================================================
 /*!
index 45928272db5698acf20ae64909c9e07f0617850d..d9a82e3c6f0ecd00c1acb528eb7e6024d04c97c6 100644 (file)
@@ -673,7 +673,11 @@ private:
                         SMESH::submesh_array_array& theSubMeshOrder,
                         const bool                  theIsDump);
 
+  /*!
+   * Parallelims informations
+   */
   void SetNbThreads(CORBA::Long nbThreads);
+  CORBA::Long GetNbThreads();
 
   /*!
    * \brief Finds concurrent sub-meshes
index f00c620839d463ff921f282f99bbe06edc04d4b7..8d0a81ac5693dab47b5ca5898b616a07c1cb8df8 100644 (file)
@@ -7583,12 +7583,41 @@ def _split_geom(geompyD, geom):
 
     return all_faces, solids
 
-class ParallelMesh(Mesh):
+class ParallelismSettings:
     """
-    Surcharge on Mesh for parallel computation of a mesh
+    Defines the parameters for the parallelism of ParallelMesh
     """
+    def __init__(self, mesh):
+        """
+        Construsctor
 
+        Parameters:
+        mesh: Instance of ParallelMesh
+        """
+        if not(isinstance(mesh, ParallelMesh)):
+            raise ValueError("mesh should be a ParallelMesh")
 
+        self._mesh = mesh
+
+    def SetNbThreads(self, nbThreads):
+        """
+        Set the number of threads for multithreading
+        """
+        if nbThreads < 1:
+            raise ValueError("Number of threads must be stricly greater than 1")
+
+        self._mesh.mesh.SetNbThreads(nbThreads)
+
+    def GetNbThreads(self):
+        """
+        Get Number of threads
+        """
+        return self._mesh.mesh.GetNbThreads()
+
+class ParallelMesh(Mesh):
+    """
+    Surcharge on Mesh for parallel computation of a mesh
+    """
     def __init__(self, smeshpyD, geompyD, geom, split_geom=True, name=0):
         """
         Create a parallel mesh.
@@ -7598,7 +7627,7 @@ class ParallelMesh(Mesh):
             geompyD: instance of geomBuilder
             geom: geometrical object for meshing
             split_geom: If true will divide geometry on solids and 1D/2D
-            coumpund and create the associated submeshes
+            coumpound and create the associated submeshes
             name: the name for the new mesh.
 
         Returns:
@@ -7628,10 +7657,20 @@ class ParallelMesh(Mesh):
                 algo3d = self.Tetrahedron(geom=solid, algo="NETGEN_3D_Remote")
                 self._algo3d.append(algo3d)
 
+        self._param = ParallelismSettings(self)
+
+
+    def GetParallelismSettings(self):
+        """
+        Return class to set parameters for the parallelism
+        """
+        return self._param
 
     def AddGlobalHypothesis(self, hyp):
         """
-        Assign a hypothesis
+        Split hypothesis to apply it to all the submeshes:
+        - the 1D+2D
+        - each of the 3D solids
 
         Parameters:
                 hyp: a hypothesis to assign
@@ -7648,18 +7687,6 @@ class ParallelMesh(Mesh):
             param3d = algo3d.Parameters()
             _copy_netgen_param(3, param3d, hyp)
 
-    def SetNbThreads(self, nbThreads):
-        """
-        Define the number of threads for meshing
-
-        Parameters:
-            nbThreads: Number of threads
-        """
-
-        if nbThreads < 1:
-            raise ValueError("Number of threads must be stricly greater than 1")
-
-        self.mesh.SetNbThreads(nbThreads)
 
     pass # End of ParallelMesh