Salome HOME
[bos #38045] [EDF] (2023-T3) Stand alone version for Netgen meshers.
[plugins/netgenplugin.git] / src / NETGENPlugin / NETGENPlugin_DriverParam.cxx
index fedea933a748d4200e28720ab9a249c0a8383216..aa8502ac8f02bc8816a6630d3b98c28b0155212d 100644 (file)
  * @param aParams The object to display
  */
 void printNetgenParams(netgen_params& aParams){
-  std::cout << "has_netgen_param: " << aParams.has_netgen_param << std::endl;
-  std::cout << "maxh: " << aParams.maxh << std::endl;
-  std::cout << "minh: " << aParams.minh << std::endl;
-  std::cout << "segmentsperedge: " << aParams.segmentsperedge << std::endl;
-  std::cout << "grading: " << aParams.grading << std::endl;
-  std::cout << "curvaturesafety: " << aParams.curvaturesafety << std::endl;
-  std::cout << "secondorder: " << aParams.secondorder << std::endl;
-  std::cout << "quad: " << aParams.quad << std::endl;
-  std::cout << "optimize: " << aParams.optimize << std::endl;
-  std::cout << "fineness: " << aParams.fineness << std::endl;
-  std::cout << "uselocalh: " << aParams.uselocalh << std::endl;
-  std::cout << "merge_solids: " << aParams.merge_solids << std::endl;
-  std::cout << "chordalError: " << aParams.chordalError << std::endl;
-  std::cout << "optsteps2d: " << aParams.optsteps2d << std::endl;
-  std::cout << "optsteps3d: " << aParams.optsteps3d << std::endl;
-  std::cout << "elsizeweight: " << aParams.elsizeweight << std::endl;
-  std::cout << "opterrpow: " << aParams.opterrpow << std::endl;
-  std::cout << "delaunay: " << aParams.delaunay << std::endl;
-  std::cout << "checkoverlap: " << aParams.checkoverlap << std::endl;
-  std::cout << "checkchartboundary: " << aParams.checkchartboundary << std::endl;
-  std::cout << "closeedgefac: " << aParams.closeedgefac << std::endl;
-  std::cout << "nbThreadMesher: " << aParams.nbThreads << std::endl;
-  std::cout << "has_local_size: " << aParams.has_local_size << std::endl;
-  std::cout << "meshsizefilename: " << aParams.meshsizefilename << std::endl;
-  std::cout << "has_maxelementvolume_hyp: " << aParams.has_maxelementvolume_hyp << std::endl;
-  std::cout << "maxElementVolume: " << aParams.maxElementVolume << std::endl;
-  std::cout << "has_LengthFromEdges_hyp: " << aParams.has_LengthFromEdges_hyp << std::endl;
+  if ( aParams.myType == Hypo )
+  {
+    std::cout << "has_netgen_param: " << aParams.has_netgen_param << std::endl;
+    std::cout << "maxh: " << aParams.maxh << std::endl;
+    std::cout << "minh: " << aParams.minh << std::endl;
+    std::cout << "segmentsperedge: " << aParams.segmentsperedge << std::endl;
+    std::cout << "grading: " << aParams.grading << std::endl;
+    std::cout << "curvaturesafety: " << aParams.curvaturesafety << std::endl;
+    std::cout << "secondorder: " << aParams.secondorder << std::endl;
+    std::cout << "quad: " << aParams.quad << std::endl;
+    std::cout << "optimize: " << aParams.optimize << std::endl;
+    std::cout << "fineness: " << aParams.fineness << std::endl;
+    std::cout << "uselocalh: " << aParams.uselocalh << std::endl;
+    std::cout << "merge_solids: " << aParams.merge_solids << std::endl;
+    std::cout << "chordalError: " << aParams.chordalError << std::endl;
+    std::cout << "optsteps2d: " << aParams.optsteps2d << std::endl;
+    std::cout << "optsteps3d: " << aParams.optsteps3d << std::endl;
+    std::cout << "elsizeweight: " << aParams.elsizeweight << std::endl;
+    std::cout << "opterrpow: " << aParams.opterrpow << std::endl;
+    std::cout << "delaunay: " << aParams.delaunay << std::endl;
+    std::cout << "checkoverlap: " << aParams.checkoverlap << std::endl;
+    std::cout << "checkchartboundary: " << aParams.checkchartboundary << std::endl;
+    std::cout << "closeedgefac: " << aParams.closeedgefac << std::endl;
+    std::cout << "nbThreadMesher: " << aParams.nbThreads << std::endl;
+    std::cout << "has_local_size: " << aParams.has_local_size << std::endl;
+    std::cout << "meshsizefilename: " << aParams.meshsizefilename << std::endl;
+    std::cout << "has_maxelementvolume_hyp: " << aParams.has_maxelementvolume_hyp << std::endl;
+    std::cout << "maxElementVolume: " << aParams.maxElementVolume << std::endl;
+    std::cout << "has_LengthFromEdges_hyp: " << aParams.has_LengthFromEdges_hyp << std::endl;
+  }
 }
 
-/**
- * @brief Import a param_file into a netgen_params structure
- *
- * @param param_file Name of the file
- * @param aParams Structure to fill
- */
-void importNetgenParams(const std::string param_file, netgen_params& aParams){
+void importDefaultNetgenParams(const std::string param_file, netgen_params& aParams)
+{
   std::ifstream myfile(param_file);
   std::string line;
+  // set the default type!
+  aParams.myType = Hypo;
 
   std::getline(myfile, line);
   aParams.has_netgen_param = std::stoi(line);
@@ -131,7 +131,54 @@ void importNetgenParams(const std::string param_file, netgen_params& aParams){
   aParams.maxElementVolume = std::stod(line);
   std::getline(myfile, line);
   aParams.maxElementVolume = std::stoi(line);
+  myfile.close();
+}
+
+void importSimple2D3DNetgenParams(const std::string param_file, netgen_params& aParams, bool is3D )
+{
+  std::ifstream myfile(param_file);
+  std::string line;
+
+  aParams.myType = !is3D ? Simple2D : Simple3D;
+  std::getline(myfile, line);
+  aParams.has_netgen_param = std::stoi(line); // 1
+  std::getline(myfile, line);
+  aParams.numberOfSegments = std::stoi(line); // segments      (int)
+  std::getline(myfile, line);
+  aParams.localLength = std::stod(line);      // localLenght  (double)
+  std::getline(myfile, line);
+  aParams.maxElementArea = std::stod(line);   // max area     (double)
+  if ( is3D )
+  {
+    std::getline(myfile, line);
+    aParams.maxElementVol = std::stod(line); // max volume    (double)
+  }    
+  std::getline(myfile, line);
+  aParams.allowQuadrangles = std::stoi(line); // int
 
+  myfile.close();
+};
+
+/**
+ * @brief Import a param_file into a netgen_params structure
+ *
+ * @param param_file Name of the file
+ * @param aParams Structure to fill
+ */
+void importNetgenParams(const std::string param_file, netgen_params& aParams){
+  
+  if ( param_file.find("simple2D") != std::string::npos || param_file.find("simple3D") != std::string::npos /*support simple 2D && 3D*/ )
+  {
+    importSimple2D3DNetgenParams( param_file, aParams, bool(param_file.find("simple3D") != std::string::npos) );
+  }
+  else if ( param_file.find("maxarea") == std::string::npos && param_file.find("lenghtfromedge") == std::string::npos /*hypo file for 2D SA*/)
+  {
+    importDefaultNetgenParams( param_file, aParams );
+  }
+  else
+  {
+    aParams.has_netgen_param = false;
+  }
 };
 
 /**
@@ -141,32 +188,38 @@ void importNetgenParams(const std::string param_file, netgen_params& aParams){
  * @param aParams the object
  */
 void exportNetgenParams(const std::string param_file, netgen_params& aParams){
-  std::ofstream myfile(param_file);
-  myfile << aParams.has_netgen_param << std::endl;
-  myfile << aParams.maxh << std::endl;
-  myfile << aParams.minh << std::endl;
-  myfile << aParams.segmentsperedge << std::endl;
-  myfile << aParams.grading << std::endl;
-  myfile << aParams.curvaturesafety << std::endl;
-  myfile << aParams.secondorder << std::endl;
-  myfile << aParams.quad << std::endl;
-  myfile << aParams.optimize << std::endl;
-  myfile << aParams.fineness << std::endl;
-  myfile << aParams.uselocalh << std::endl;
-  myfile << aParams.merge_solids << std::endl;
-  myfile << aParams.chordalError << std::endl;
-  myfile << aParams.optsteps2d << std::endl;
-  myfile << aParams.optsteps3d << std::endl;
-  myfile << aParams.elsizeweight << std::endl;
-  myfile << aParams.opterrpow << std::endl;
-  myfile << aParams.delaunay << std::endl;
-  myfile << aParams.checkoverlap << std::endl;
-  myfile << aParams.checkchartboundary << std::endl;
-  myfile << aParams.closeedgefac << std::endl;
-  myfile << aParams.nbThreads << std::endl;
-  myfile << aParams.has_local_size << std::endl;
-  myfile << aParams.meshsizefilename << std::endl;
-  myfile << aParams.has_maxelementvolume_hyp << std::endl;
-  myfile << aParams.maxElementVolume << std::endl;
-  myfile << aParams.has_LengthFromEdges_hyp << std::endl;
+  if ( aParams.myType == Hypo ){
+    std::ofstream myfile(param_file);
+    myfile << aParams.has_netgen_param << std::endl;
+    myfile << aParams.maxh << std::endl;
+    myfile << aParams.minh << std::endl;
+    myfile << aParams.segmentsperedge << std::endl;
+    myfile << aParams.grading << std::endl;
+    myfile << aParams.curvaturesafety << std::endl;
+    myfile << aParams.secondorder << std::endl;
+    myfile << aParams.quad << std::endl;
+    myfile << aParams.optimize << std::endl;
+    myfile << aParams.fineness << std::endl;
+    myfile << aParams.uselocalh << std::endl;
+    myfile << aParams.merge_solids << std::endl;
+    myfile << aParams.chordalError << std::endl;
+    myfile << aParams.optsteps2d << std::endl;
+    myfile << aParams.optsteps3d << std::endl;
+    myfile << aParams.elsizeweight << std::endl;
+    myfile << aParams.opterrpow << std::endl;
+    myfile << aParams.delaunay << std::endl;
+    myfile << aParams.checkoverlap << std::endl;
+    myfile << aParams.checkchartboundary << std::endl;
+    myfile << aParams.closeedgefac << std::endl;
+    myfile << aParams.nbThreads << std::endl;
+    myfile << aParams.has_local_size << std::endl;
+    myfile << aParams.meshsizefilename << std::endl;
+    myfile << aParams.has_maxelementvolume_hyp << std::endl;
+    myfile << aParams.maxElementVolume << std::endl;
+    myfile << aParams.has_LengthFromEdges_hyp << std::endl;
+  }
+  else if ( aParams.myType == Simple2D )
+  {
+    // TODO: Export the 2D && 3D simple versions
+  }
 };