Salome HOME
Fixing issues pointed. Eliminate reference to MG_TetraHPC_API class since it is not...
[plugins/ghs3dplugin.git] / src / GHS3DPlugin / GHS3DPlugin_Hypothesis.cxx
index d8b3b0a8763c7c7c09aaa3665c266c3602c7385b..2f3b55e08e24675d0726579c4fdda024655c67c4 100644 (file)
@@ -1824,7 +1824,8 @@ std::string GHS3DPlugin_Hypothesis::CommandToRun(const GHS3DPlugin_Hypothesis* h
                                                  const bool                    hasShapeToMesh,
                                                  const bool                    forExecutable)
 {
-  std::string cmd = GetExeName();
+  GHS3DPlugin_Hypothesis::ImplementedAlgorithms algoId = (ImplementedAlgorithms) hyp->myAlgorithm;
+  std::string cmd = GetExeName( algoId );
   // check if any option is overridden by hyp->myTextOption
   bool max_memory     = hyp ? !hyp->HasOptionDefined("max_memory")               : true;
   bool auto_memory    = hyp ? !hyp->HasOptionDefined("automatic_memory")         : true;
@@ -1843,15 +1844,14 @@ std::string GHS3DPlugin_Hypothesis::CommandToRun(const GHS3DPlugin_Hypothesis* h
     useBndRecovery = hyp->myToUseBoundaryRecoveryVersion;
 
   // MG-Tetra needs to know amount of memory it may use (MB).
-  // Default memory is defined at MG-Tetra installation but it may be not enough,
-  // so allow to use about all available memory
-  if ( max_memory ) {
+  // Default memory is defined at MG-Tetra installation but it may be not enough,  // so allow to use about all available memory
+  if ( algoId == MGTetra && max_memory ) {
     float aMaximumMemory = hyp ? hyp->myMaximumMemory : -1;
     cmd += " --max_memory ";
     if ( aMaximumMemory < 0 ) cmd += SMESH_Comment( int( DefaultMaximumMemory() ));
     else                      cmd += SMESH_Comment( int( aMaximumMemory ));
   }
-  if ( auto_memory && !useBndRecovery ) {
+  if (  algoId == MGTetra && ( auto_memory && !useBndRecovery ) ) {
     float aInitialMemory = hyp ? hyp->myInitialMemory : -1;
     cmd += " --automatic_memory ";
     if ( aInitialMemory > 0 ) cmd += SMESH_Comment( int( aInitialMemory ));
@@ -1876,11 +1876,13 @@ std::string GHS3DPlugin_Hypothesis::CommandToRun(const GHS3DPlugin_Hypothesis* h
     cmd += " --optimisation_level none"; // issue 22608
   }
   else if ( optim_level && hyp && !useBndRecovery ) {
-    if ( hyp->myOptimizationLevel >= 0 && hyp->myOptimizationLevel < 5 ) {
-      const char* level[] = { "none" , "light" , "standard" , "standard+" , "strong" };
-      cmd += " --optimisation_level ";
-      cmd += level[ hyp->myOptimizationLevel ];
-    }
+    const char* level[] = { "none" , "light" , "standard" , "standard+" , "strong" };
+    const short myOpt = hyp->myOptimizationLevel;
+    
+    if ( myOpt >= 0 && myOpt < 5 && ( algoId == MGTetra || ( algoId == MGTetraHPC && myOpt != 3 ) ) ) {
+        cmd += " --optimisation_level ";
+        cmd += level[ myOpt ];
+    }    
   }
 
   // to create internal nodes
@@ -1917,13 +1919,20 @@ std::string GHS3DPlugin_Hypothesis::CommandToRun(const GHS3DPlugin_Hypothesis* h
       cmd += " --gradation " + SMESH_Comment( hyp->myGradation );
 
     if ( hyp->GetUseNumOfThreads() )
-    {
+    {      
       cmd += " --max_number_of_threads "  + SMESH_Comment( hyp->GetNumOfThreads() );
       const char* pthreadMode[] = { "none" , "aggressive" , "safe" };
-      if ( hyp->myPthreadModeMG >= 1 && hyp->myPthreadModeMG < 3 ) {
+      const char* parallelMode[] = { "none", "reproducible_given_max_number_of_threads", "reproducible", "aggressive"  };
+
+      if ( algoId == MGTetra && hyp->myPthreadModeMG >= 1 && hyp->myPthreadModeMG < 3 ) {
         cmd += " --pthreads_mode ";
         cmd += pthreadMode[ hyp->myPthreadModeMG ];
       }
+      else if ( algoId == MGTetraHPC && hyp->myPthreadModeMGHPC >= 1 && hyp->myPthreadModeMGHPC < 4 )
+      {
+        cmd += " --parallel_strategy ";
+        cmd += parallelMode[ hyp->myPthreadModeMGHPC ];
+      }
     }
 
     // proximity
@@ -2003,9 +2012,17 @@ std::string GHS3DPlugin_Hypothesis::GetFileNameHPC(const GHS3DPlugin_Hypothesis*
  */
 //================================================================================
 
-std::string GHS3DPlugin_Hypothesis::GetExeName()
+std::string GHS3DPlugin_Hypothesis::GetExeName( ImplementedAlgorithms algoId )
 {
-  return "mg-tetra.exe";
+  switch ( algoId )
+  {
+    case MGTetra:
+      return "mg-tetra.exe";
+    case MGTetraHPC:
+      return "mg-tetra_hpc.exe";
+    default:
+      throw( "Undefined algorithm id: ");
+  }
 }
 
 //================================================================================