]> SALOME platform Git repositories - plugins/gmshplugin.git/commitdiff
Salome HOME
Adds Hextrems HXT algorithm mab/gmsh_4.8.4
authorAfeef <afeef.badri@gmail.com>
Fri, 10 Sep 2021 14:18:33 +0000 (16:18 +0200)
committerAfeef <afeef.badri@gmail.com>
Fri, 10 Sep 2021 14:18:33 +0000 (16:18 +0200)
- Activates parallel meshing via HXT
  algorithm via the Gmsh interface

src/GMSHPlugin/GMSHPlugin_Hypothesis.hxx
src/GMSHPlugin/GMSHPlugin_Mesher.cxx
src/GMSHPlugin/GMSHPlugin_Mesher.hxx
src/GUI/GMSHPluginGUI_HypothesisCreator.cxx
src/GUI/GMSHPlugin_msg_en.ts
src/GUI/GMSHPlugin_msg_fr.ts

index cf413e0bbe17bc2d1ea069ff45d53b74337b95d5..0ab287d2159e8463cbad8783b9d273bb76f91996 100644 (file)
@@ -56,7 +56,8 @@ public:
    delaunay3,
    frontal3,
    mmg3d,
-   rtree
+   rtree,
+   hxt
   };
 
 
index e95b91c08bb4054b464f3dd922a482e66bf014de..af6b365229d6c2d168c886145aefb04703742f56 100644 (file)
 #include <Context.h>
 #endif
 
+#if GMSH_MAJOR_VERSION >=4 && GMSH_MINOR_VERSION >=8
+#include <omp.h>
+#endif
+
 using namespace std;
 
 namespace
@@ -206,6 +210,24 @@ void GMSHPlugin_Mesher::SetParameters(const GMSHPlugin_Hypothesis* hyp)
   }
 }
 
+
+//================================================================================
+/*!
+ * \brief Set maximum number of threads to be used by Gmsh
+ */
+//================================================================================
+
+#if GMSH_MAJOR_VERSION >=4 && GMSH_MINOR_VERSION >=8
+void GMSHPlugin_Mesher::SetMaxThreadsGmsh()
+{
+  MESSAGE("GMSHPlugin_Mesher::SetMaxThreadsGmsh");
+  if (_compounds.size() > 0)
+    _maxThreads = 1;
+  else
+    _maxThreads = omp_get_max_threads();
+}
+#endif
+
 //================================================================================
 /*!
  * \brief Set Gmsh Options
@@ -245,6 +267,7 @@ void GMSHPlugin_Mesher::SetGmshOptions()
   mapAlgo3d[1]=4; // Frontal
   mapAlgo3d[2]=7; // MMG3D
   mapAlgo3d[3]=9; // R-tree
+  mapAlgo3d[4]=10;// HXT
 
   int ok;
   ok = GmshSetOption("Mesh", "Algorithm"                , mapAlgo2d[_algo2d])    ;
@@ -288,6 +311,18 @@ void GMSHPlugin_Mesher::SetGmshOptions()
     ok = GmshSetOption("Mesh", "SecondOrderIncomplete"  ,(_useIncomplElem)?1.:0.);
     ASSERT(ok);
   }
+
+#if GMSH_MAJOR_VERSION >=4 && GMSH_MINOR_VERSION >=8
+/*ok = GmshSetOption("Mesh", "MaxNumThreads1D"          , 0. )  ; // Coarse-grain algo threads
+  ASSERT(ok);
+  ok = GmshSetOption("Mesh", "MaxNumThreads2D"          , 0. )  ; // Coarse-grain algo threads
+  ASSERT(ok);
+  ok = GmshSetOption("Mesh", "MaxNumThreads3D"          , 0. )  ; // Fine-grain algo threads HXT
+  ASSERT(ok);
+/**/
+  ok = GmshSetOption("General", "NumThreads"            , _maxThreads )  ; // system default i.e. OMP_NUM_THREADS
+  ASSERT(ok);
+#endif
 }
 
 //================================================================================
@@ -1013,6 +1048,9 @@ bool GMSHPlugin_Mesher::Compute()
 
   int err = 0;
 
+#if GMSH_MAJOR_VERSION >=4 && GMSH_MINOR_VERSION >=8
+  SetMaxThreadsGmsh();
+#endif
   GmshInitialize();
   SetGmshOptions();
   _gModel = new GModel();
index 1fdb36ccf3961fb2306f896ec349473f2389bcaf..a8b952ad1e49d82df1b9b244e050209dd6dbb5e2 100644 (file)
@@ -24,9 +24,9 @@
 
 #include <stdio.h>
 #include "GmshVersion.h"
-#if GMSH_MAJOR_VERSION >=4 
+#if GMSH_MAJOR_VERSION >=4
 #include "gmsh.h"
-#else 
+#else
 #include "Gmsh.h"
 #endif
 #include "GmshConfig.h"
@@ -34,7 +34,7 @@
 #include "GModelIO_GEO.h"
 #include "Geo.h"
 #if GMSH_MAJOR_VERSION >=4
-#include "GEdge.h" 
+#include "GEdge.h"
 #include "GFace.h"
 #else
 #include "GEdgeCompound.h"
@@ -66,7 +66,7 @@ class GMSHPlugin_Hypothesis;
  */
 //=============================================================================
 
-class GMSHPLUGIN_EXPORT GMSHPlugin_Mesher 
+class GMSHPLUGIN_EXPORT GMSHPlugin_Mesher
 {
  public:
   // ---------- PUBLIC METHODS ----------
@@ -78,7 +78,7 @@ class GMSHPLUGIN_EXPORT GMSHPlugin_Mesher
   bool Compute();
 
   bool Evaluate(MapShapeNbElems& aResMap);
-  
+
   static float DistBoundingBox(const SBoundingBox3d& bounds, const SPoint3& point);
 
  private:
@@ -97,14 +97,19 @@ class GMSHPLUGIN_EXPORT GMSHPlugin_Mesher
   bool                 _secondOrder, _useIncomplElem;
   bool                 _is2d;
   GModel*              _gModel;
-  
+#if GMSH_MAJOR_VERSION >=4 && GMSH_MINOR_VERSION >=3
+  double               _maxThreads;
+#endif
+
   std::set<std::string> _compounds;
-  
+
   void SetGmshOptions();
   void CreateGmshCompounds();
-  void SetCompoundMeshVisibility();
   void FillSMesh();
-
+#if GMSH_MAJOR_VERSION >=4 && GMSH_MINOR_VERSION >=3
+  void SetMaxThreadsGmsh();
+  void SetCompoundMeshVisibility();
+#endif
   class mymsg : public GmshMessage
   {
   private:
index 61f634dbdad9c926bf62f4e0a2dec3a73743cb95..bdc8a6463cf3c27c3cb80edb4ff162fe8c4dd7b5 100644 (file)
@@ -170,8 +170,8 @@ QFrame* GMSHPluginGUI_HypothesisCreator::buildFrame()
     aGroupLayout->addWidget( new QLabel( tr( "GMSH_3D_ALGO" ), GroupC1 ), row, 0 );
     my3DAlgo = new QComboBox( GroupC1 );
     QStringList types3DAlgo;
-    types3DAlgo << tr("GMSH_DELAUNAY3") << tr( "GMSH_FRONTAL_DELAUNAY" ) << tr( "GMSH_MMG3D" ) <<
-                  tr( "GMSH_R_TREE" );
+    types3DAlgo << tr( "GMSH_DELAUNAY3" ) << tr( "GMSH_FRONTAL_DELAUNAY" ) << tr( "GMSH_MMG3D" ) <<
+                  tr( "GMSH_R_TREE" ) << tr( "GMSH_HXT" );
     my3DAlgo->addItems( types3DAlgo );
     aGroupLayout->addWidget( my3DAlgo, row, 1 );
     row++;
index e8528856787b0792e842196433bc90e1b0b24184..d649a34dca2011730656d37c56ee3b5111d1a29e 100644 (file)
         <source>GMSH_R_TREE</source>
         <translation>R-tree</translation>
     </message>
+    <message>
+        <source>GMSH_HXT</source>
+        <translation>Parallel Delaunay (HXT)</translation>
+    </message>
     <message>
         <source>GMSH_2D_RECOMB_ALGO</source>
         <translation>2D recombination algorithm</translation>
index 00b0e94d66024aa1d94ba1b2ac34915a68679450..fc1376c833a1c8a16bc821006b531844dde2c339 100644 (file)
         <source>GMSH_R_TREE</source>
         <translation>R-tree</translation>
     </message>
+    <message>
+        <source>GMSH_HXT</source>
+        <translation>Delaunay Parallèle (HTX)</translation>
+    </message>
     <message>
         <source>GMSH_2D_RECOMB_ALGO</source>
         <translation>Algorithme de recombinaison 2D</translation>