Salome HOME
proposal for plugin merge
[plugins/ghs3dplugin.git] / src / GHS3DPlugin / GHS3DPlugin_Hypothesis.hxx
index 77cde27eec240ce6973cf946183638ee6174d28b..97e0162e71ba4b6a2b45614e725358e956ea3559 100644 (file)
@@ -1,4 +1,4 @@
-// Copyright (C) 2004-2019  CEA/DEN, EDF R&D
+// Copyright (C) 2004-2022  CEA/DEN, EDF R&D
 //
 // This library is free software; you can redistribute it and/or
 // modify it under the terms of the GNU Lesser General Public
@@ -111,7 +111,7 @@ public:
 
   struct TIDMeshIDCompare {
     bool operator () (const SMDS_MeshElement* e1, const SMDS_MeshElement* e2) const
-    { return e1->GetMesh() == e2->GetMesh() ? e1->GetID() < e2->GetID() : e1->GetMesh() < e2->GetMesh() ; }
+    { return e1->GetMesh() == e2->GetMesh() ? e1->GetID() < e2->GetID() : e1->GetMesh() < e2->GetMesh(); }
   };
   
   typedef std::map<const SMDS_MeshElement*, std::string, TIDMeshIDCompare > TIDSortedElemGroupMap;
@@ -119,6 +119,19 @@ public:
   typedef std::set<std::string> TSetStrings;
 
   static const char* GetHypType() { return "MG-Tetra Parameters"; }
+
+  void SetMinSize(double theMinSize);
+  double GetMinSize() const { return myMinSize; }
+
+  void SetMaxSize(double theMaxSize);
+  double GetMaxSize() const { return myMaxSize; }
+
+  void SetUseVolumeProximity( bool toUse );
+  bool GetUseVolumeProximity() const { return myUseVolumeProximity; }
+
+  void SetNbVolumeProximityLayers( int nbLayers );
+  int GetNbVolumeProximityLayers() const { return myNbVolumeProximityLayers; }
+
   /*!
    * To mesh "holes" in a solid or not. Default is to mesh.
    */
@@ -170,6 +183,36 @@ public:
    */
   void SetVerboseLevel(short level);
   short GetVerboseLevel() const;
+  /*!
+   * Implemented algorithms to be executed [0,1]
+   *  0 - MGTetra-HPC
+   *  1 - MGTetra
+   */
+  enum ImplementedAlgorithms { MGTetraHPC = 0,  MGTetra };
+  void SetAlgorithm(ImplementedAlgorithms algoId);
+  ImplementedAlgorithms GetAlgorithm() const;
+  /*!
+   * Set Get for flag to use pthread parallel version of the algorithm
+   */
+  void SetUseNumOfThreads(bool setUseOfThreads);
+  bool GetUseNumOfThreads() const;
+   /*!
+   * Set Get num of threads to be used by MGTetra algorithms
+   */
+  void SetNumOfThreads(short numOfThreads);
+  short GetNumOfThreads() const;
+  /*!
+  * Set Get pthread mode used for MGTetra
+  */
+  enum PThreadMode { PThreadNone = 0, PThreadAggressive,  Safe };
+  void SetPthreadMode(PThreadMode pthreadMode );
+  PThreadMode GetPthreadMode() const;
+  /*!
+  * Set Get paralle mode used for MGTetra HPC
+  */
+  enum ParallelMode { ParallelNone = 0, ReproducibleGivenMaxNumThreads, Reproducible, ParallelAggressive };
+  void SetParallelMode(ParallelMode parallelMode );
+  ParallelMode GetParallelMode() const;
   /*!
    * To create new nodes
    */
@@ -203,27 +246,42 @@ public:
   * To define the volumic gradation
   */
   void SetGradation(double gradation);
-  double GetGradation() const ;
+  double GetGradation() const;
   /*!
   * Print log in standard output
   */
   void SetStandardOutputLog(bool logInStandardOutput);
-  bool GetStandardOutputLog() const ;
+  bool GetStandardOutputLog() const;
   /*!
   * Remove log file on success
   */
   void SetRemoveLogOnSuccess(bool removeLogOnSuccess);
-  bool GetRemoveLogOnSuccess() const ;
+  bool GetRemoveLogOnSuccess() const;
     
+
+  typedef std::map< std::string, std::string > TOptionValues;
+  typedef std::set< std::string >              TOptionNames;
+
+  void SetOptionValue(const std::string& optionName,
+                      const std::string& optionValue);
+  std::string GetOptionValue(const std::string& optionName,
+                             bool*              isDefault=0) const;
+  bool HasOptionDefined( const std::string& optionName ) const;
+  void ClearOption(const std::string& optionName);
+  TOptionValues        GetOptionValues()       const;
+  const TOptionValues& GetCustomOptionValues() const { return _customOption2value; }
+  /*!
+   * \brief To set the advanced options in the execution command line
+   */
+  void SetAdvancedOptionsInCommandLine( std::string & cmd, bool isMGTetra ) const;
   
+  //static inline const char* NoValue() { return "_"; }  
 //   struct TEnforcedEdge {
 //     long ID;
 //     long node1;
 //     long node2;
 //     std::string groupName;
 //   };
-  
-
   /*!
    * \brief Return command to run MG-Tetra mesher excluding file prefix (-f)
    */
@@ -234,6 +292,10 @@ public:
    * \brief Return a unique file name
    */
   static std::string GetFileName(const GHS3DPlugin_Hypothesis* hyp);
+  /*!
+   * \brief Return a unique file name for MGTetraHPC will have a GHS3D prefix
+   */
+  static std::string GetFileNameHPC(const GHS3DPlugin_Hypothesis* hyp);
   /*!
    * \brief Return the name of executable
    */
@@ -244,9 +306,9 @@ public:
    */
   bool SetEnforcedVertex(std::string aName, std::string anEntry, std::string aGroupName,
                          double size, double x=0.0, double y=0.0, double z=0.0, bool isCompound = false);
-  TGHS3DEnforcedVertex* GetEnforcedVertex(double x, double y, double z) throw (std::invalid_argument);
-  TGHS3DEnforcedVertex* GetEnforcedVertex(const std::string anEntry) throw (std::invalid_argument);
-  bool RemoveEnforcedVertex(double x=0.0, double y=0.0, double z=0.0, const std::string anEntry="" ) throw (std::invalid_argument);
+  TGHS3DEnforcedVertex* GetEnforcedVertex(double x, double y, double z);
+  TGHS3DEnforcedVertex* GetEnforcedVertex(const std::string anEntry);
+  bool RemoveEnforcedVertex(double x=0.0, double y=0.0, double z=0.0, const std::string anEntry="" );
   const TGHS3DEnforcedVertexCoordsValues& _GetEnforcedVerticesCoordsSize() const {return _enfVertexCoordsSizeList; }
   const TGHS3DEnforcedVertexEntryValues & _GetEnforcedVerticesEntrySize() const {return _enfVertexEntrySizeList; }
   const TGHS3DEnforcedVertexList        & _GetEnforcedVertices() const { return _enfVertexList; }
@@ -258,7 +320,7 @@ public:
    * To set enforced elements
    */
   bool SetEnforcedMesh(SMESH_Mesh& theMesh, SMESH::ElementType elementType, std::string name, std::string entry, std::string groupName = "");
-  bool SetEnforcedGroup(const SMESHDS_Mesh* theMeshDS, SMESH::long_array_var theIDs, SMESH::ElementType elementType, std::string name, std::string entry, std::string groupName = "");
+  bool SetEnforcedGroup(const SMESHDS_Mesh* theMeshDS, SMESH::smIdType_array_var theIDs, SMESH::ElementType elementType, std::string name, std::string entry, std::string groupName = "");
   bool SetEnforcedElements(TIDSortedElemSet theElemSet, SMESH::ElementType elementType, std::string groupName = "");
   const TGHS3DEnforcedMeshList _GetEnforcedMeshes() const { return _enfMeshList; }
   const TEntryGHS3DEnforcedMeshListMap _GetEnforcedMeshesByEntry() const { return _entryEnfMeshMap; }
@@ -302,24 +364,17 @@ public:
   static bool   DefaultToRemoveCentralPoint();
   static bool   DefaultStandardOutputLog();
   static bool   DefaultRemoveLogOnSuccess();
-  static double DefaultGradation();
-  
-  static TGHS3DEnforcedVertex DefaultGHS3DEnforcedVertex() {return TGHS3DEnforcedVertex();}
-  static TGHS3DEnforcedVertexList DefaultGHS3DEnforcedVertexList() {return TGHS3DEnforcedVertexList();}
-  static TGHS3DEnforcedVertexCoordsValues DefaultGHS3DEnforcedVertexCoordsValues() {return TGHS3DEnforcedVertexCoordsValues();}
-  static TGHS3DEnforcedVertexEntryValues DefaultGHS3DEnforcedVertexEntryValues() {return TGHS3DEnforcedVertexEntryValues();}
-  static TCoordsGHS3DEnforcedVertexMap DefaultCoordsGHS3DEnforcedVertexMap() {return TCoordsGHS3DEnforcedVertexMap();}
-  static TGeomEntryGHS3DEnforcedVertexMap DefaultGeomEntryGHS3DEnforcedVertexMap() {return TGeomEntryGHS3DEnforcedVertexMap();}
-  static TGroupNameGHS3DEnforcedVertexMap DefaultGroupNameGHS3DEnforcedVertexMap() {return TGroupNameGHS3DEnforcedVertexMap();}
-  
-  static TGHS3DEnforcedMesh         DefaultGHS3DEnforcedMesh() {return TGHS3DEnforcedMesh();}
-  static TGHS3DEnforcedMeshList     DefaultGHS3DEnforcedMeshList() {return TGHS3DEnforcedMeshList();}
-  static TEntryGHS3DEnforcedMeshListMap DefaultEntryGHS3DEnforcedMeshListMap() {return TEntryGHS3DEnforcedMeshListMap();}
-  static TIDSortedNodeGroupMap      DefaultIDSortedNodeGroupMap() {return TIDSortedNodeGroupMap();}
-  static TIDSortedElemGroupMap      DefaultIDSortedElemGroupMap() {return TIDSortedElemGroupMap();}
-  static TID2SizeMap                DefaultID2SizeMap() {return TID2SizeMap();}
-  static TSetStrings                DefaultGroupsToRemove() {return TSetStrings();}
-  
+  static inline double DefaultGradation() { return 1.05; }
+  static bool   DefaultUseVolumeProximity() { return false; }
+  static int    DefaultNbVolumeProximityLayers() { return 2; }
+  static short  DefaultAlgorithm() { return MGTetra; }
+  static short  DefaultNumOfThreads() { return 4; }
+   
+  void SetMinMaxSizeDefault( double theMinSize, double theMaxSize )
+  { myMinSizeDefault = theMinSize; myMaxSizeDefault = theMaxSize; }
+  double GetMinSizeDefault() const { return myMinSizeDefault; }
+  double GetMaxSizeDefault() const { return myMaxSizeDefault; }
+
   // Persistence
   virtual std::ostream & SaveTo(std::ostream & save);
   virtual std::istream & LoadFrom(std::istream & load);
@@ -334,6 +389,10 @@ public:
    */
   virtual bool SetParametersByDefaults(const TDefaults& dflts, const SMESH_Mesh* theMesh=0);
 
+  static bool  ToBool(const std::string& str, bool* isOk=0);
+  static double ToDbl(const std::string& str, bool* isOk=0);
+  static int    ToInt(const std::string& str, bool* isOk=0);
+
 protected:
 
   bool        myToMeshHoles;
@@ -350,9 +409,23 @@ protected:
   bool        myToRemoveCentralPoint;
   bool        myLogInStandardOutput;
   bool        myRemoveLogOnSuccess;
-  std::string myTextOption;
   double      myGradation;
+  bool        myUseVolumeProximity;
+  int         myNbVolumeProximityLayers;
+  double      myMinSize, myMinSizeDefault;
+  double      myMaxSize, myMaxSizeDefault;
+  //std::string myTextOption;
+  short       myAlgorithm;  //member used to pivot between MG-Tetra and MG-Tetra
+  bool        myUseNumOfThreads;
+  short       myNumOfThreads;
+  short       myPthreadModeMG;
+  short       myPthreadModeMGHPC;
   
+  TOptionValues _option2value, _customOption2value;         // user defined values
+  TOptionValues _defaultOptionValues;                       // default values
+  TOptionNames  _doubleOptions, _charOptions, _boolOptions; // to find a type of option  
+  std::vector<std::string>  _commonMGTetraAdvancedOptions;  // common advanced options for MGTetra and MGTetraHPC
+
   TGHS3DEnforcedVertexList         _enfVertexList;
   TGHS3DEnforcedVertexCoordsValues _enfVertexCoordsSizeList;
   TGHS3DEnforcedVertexEntryValues  _enfVertexEntrySizeList;