Salome HOME
Fix: getCellsContainingPoints() in case of polyhedron with a face containing colinear...
[tools/medcoupling.git] / src / MEDPartitioner / MEDPARTITIONER_MEDPartitioner.cxx
index c97c36b03407b7ca459677ef0ca055638c0047f5..cf75ce81232a743554006cc5107914e077e393dc 100644 (file)
@@ -1,4 +1,4 @@
-// Copyright (C) 2007-2015  CEA/DEN, EDF R&D
+// Copyright (C) 2007-2024  CEA, EDF
 //
 // This library is free software; you can redistribute it and/or
 // modify it under the terms of the GNU Lesser General Public
 #include "MEDPARTITIONER_ParallelTopology.hxx"
 #include "MEDPARTITIONER_Utils.hxx"
 #include "MEDPARTITIONER_Graph.hxx"
-#include "MEDPARTITIONER_MetisGraph.hxx"
-#include "MEDPARTITIONER_ScotchGraph.hxx"
+#ifdef MED_ENABLE_METIS
+#  include "MEDPARTITIONER_MetisGraph.hxx"
+#endif
+#ifdef MED_ENABLE_SCOTCH
+#  include "MEDPARTITIONER_ScotchGraph.hxx"
+#endif
+#ifdef MED_ENABLE_PTSCOTCH
+#  include "MEDPARTITIONER_PTScotchGraph.hxx"
+#endif
 #include "MEDPARTITIONER_MeshCollectionDriver.hxx"
 
 #include "MEDCouplingUMesh.hxx"
 #include <iostream>
 #include <vector>
 
-MEDPARTITIONER::MEDPartitioner::MEDPartitioner(const std::string& filename, int ndomains, const std::string& library,bool creates_boundary_faces, bool create_joints, bool mesure_memory):
+const char MEDPARTITIONER::MEDPartitioner::METIS_PART_ALG[]="Metis";
+const char MEDPARTITIONER::MEDPartitioner::SCOTCH_PART_ALG[]="Scotch";
+const char MEDPARTITIONER::MEDPartitioner::PTSCOTCH_PART_ALG[]="PTScotch";
+
+MEDPARTITIONER::MEDPartitioner::MEDPartitioner(const std::string& filename, int ndomains, const std::string& library,bool create_boundary_faces, bool create_joints, bool mesure_memory):
   _input_collection( 0 ), _output_collection( 0 ), _new_topology( 0 )
 {
   MyGlobals::_World_Size = 1;
   MyGlobals::_Rank = 0;
-  MyGlobals::_Creates_Boundary_Faces = creates_boundary_faces;
+  MyGlobals::_Create_Boundary_Faces = create_boundary_faces;
   MyGlobals::_Create_Joints = create_joints;
 
   ParaDomainSelector parallelizer(mesure_memory);
@@ -50,17 +61,17 @@ MEDPARTITIONER::MEDPartitioner::MEDPartitioner(const std::string& filename, int
     (MEDPARTITIONER::ParallelTopology*) _input_collection->getTopology();
   aPT->setGlobalNumerotationDefault( _input_collection->getParaDomainSelector() );
   _input_collection->prepareFieldDescriptions();
-  createPartitionCollection(ndomains, library, creates_boundary_faces, create_joints, mesure_memory);
+  createPartitionCollection(ndomains, library, create_boundary_faces, create_joints, mesure_memory);
 
   parallelizer.evaluateMemory();
 }
 
-MEDPARTITIONER::MEDPartitioner::MEDPartitioner(const MEDCoupling::MEDFileData* filedata, int ndomains, const std::string& library,bool creates_boundary_faces, bool create_joints, bool mesure_memory):
+MEDPARTITIONER::MEDPartitioner::MEDPartitioner(const MEDCoupling::MEDFileData* filedata, int ndomains, const std::string& library,bool create_boundary_faces, bool create_joints, bool mesure_memory):
   _input_collection( 0 ), _output_collection( 0 ), _new_topology( 0 )
 {
   MyGlobals::_World_Size = 1;
   MyGlobals::_Rank = 0;
-  MyGlobals::_Creates_Boundary_Faces = creates_boundary_faces;
+  MyGlobals::_Create_Boundary_Faces = create_boundary_faces;
   MyGlobals::_Create_Joints = create_joints;
 
   ParaDomainSelector parallelizer(mesure_memory);
@@ -72,17 +83,17 @@ MEDPARTITIONER::MEDPartitioner::MEDPartitioner(const MEDCoupling::MEDFileData* f
     (MEDPARTITIONER::ParallelTopology*) _input_collection->getTopology();
   aPT->setGlobalNumerotationDefault( _input_collection->getParaDomainSelector() );
   _input_collection->prepareFieldDescriptions();
-  createPartitionCollection(ndomains, library, creates_boundary_faces, create_joints, mesure_memory);
+  createPartitionCollection(ndomains, library, create_boundary_faces, create_joints, mesure_memory);
 
   parallelizer.evaluateMemory();
 }
 
-MEDPARTITIONER::MEDPartitioner::MEDPartitioner(const MEDCoupling::MEDFileData* filedata, MEDPARTITIONER ::Graph* graph, bool creates_boundary_faces, bool create_joints, bool mesure_memory):
+MEDPARTITIONER::MEDPartitioner::MEDPartitioner(const MEDCoupling::MEDFileData* filedata, MEDPARTITIONER ::Graph* graph, bool create_boundary_faces, bool create_joints, bool mesure_memory):
   _input_collection( 0 ), _output_collection( 0 ), _new_topology( 0 )
 {
   MyGlobals::_World_Size = 1;
   MyGlobals::_Rank = 0;
-  MyGlobals::_Creates_Boundary_Faces = creates_boundary_faces;
+  MyGlobals::_Create_Boundary_Faces = create_boundary_faces;
   MyGlobals::_Create_Joints = create_joints;
 
   ParaDomainSelector parallelizer(mesure_memory);
@@ -109,7 +120,7 @@ MEDPARTITIONER::MEDPartitioner::~MEDPartitioner()
   delete _new_topology; _new_topology = 0;
 }
 
-void MEDPARTITIONER::MEDPartitioner::createPartitionCollection(int ndomains, const std::string& library,bool creates_boundary_faces, bool create_joints, bool mesure_memory)
+void MEDPARTITIONER::MEDPartitioner::createPartitionCollection(int ndomains, const std::string& library,bool create_boundary_faces, bool create_joints, bool mesure_memory)
 {
   //ParallelTopology* aPT = (ParallelTopology*) _input_collection->getTopology();
   if (library == "metis")
@@ -133,17 +144,18 @@ MEDCoupling::MEDFileData* MEDPARTITIONER::MEDPartitioner::getMEDFileData()
   return _output_collection->retrieveDriver()->getMEDFileData();
 }
 
-MEDPARTITIONER::Graph* MEDPARTITIONER::MEDPartitioner::Graph(MEDCoupling::MEDCouplingSkyLineArray* graph, Graph::splitter_type split, int* edgeweight)
+MEDPARTITIONER::Graph* MEDPARTITIONER::MEDPartitioner::Graph(MEDCoupling::MEDCouplingSkyLineArray* graph, Graph::splitter_type split, int* edgeweight, DataArrayIdType *vlbloctab)
 {
   MEDPARTITIONER::Graph* cellGraph=0;
-  MEDCoupling::MEDCouplingSkyLineArray* arr = new MEDCoupling::MEDCouplingSkyLineArray(graph->getIndexArray(), graph->getValueArray());
+  // will be destroyed by XXXGraph class:
+  MEDCoupling::MCAuto<MEDCoupling::MEDCouplingSkyLineArray> arr(MEDCoupling::MEDCouplingSkyLineArray::New(graph->getIndexArray(), graph->getValuesArray()));
   switch (split)
     {
     case Graph::METIS:
       if ( !cellGraph )
         {
 #ifdef MED_ENABLE_METIS
-          cellGraph=new METISGraph(arr,edgeweight);
+          cellGraph=new METISGraph(arr.retn(),edgeweight);
 #endif
         }
       if ( !cellGraph )
@@ -151,11 +163,73 @@ MEDPARTITIONER::Graph* MEDPARTITIONER::MEDPartitioner::Graph(MEDCoupling::MEDCou
       break;
     case Graph::SCOTCH:
 #ifdef MED_ENABLE_SCOTCH
-      cellGraph=new SCOTCHGraph(arr,edgeweight);
+      cellGraph=new SCOTCHGraph(arr.retn(),edgeweight);
 #else
       throw INTERP_KERNEL::Exception("MEDPartitioner::Graph : SCOTCH is not available. Check your products, please.");
 #endif
       break;
+    case Graph::PTSCOTCH:
+      {
+#ifdef MED_ENABLE_PTSCOTCH
+        cellGraph=new PTSCOTCHGraph(arr.retn(),edgeweight,vlbloctab);
+#else
+        throw INTERP_KERNEL::Exception("MEDPartitioner::Graph : PTSCOTCH is not available. Check your products, please.");
+#endif
+        break;
+      }
+    default:
+      throw INTERP_KERNEL::Exception("MEDPartitioner::Graph : Not managed split type engine !");
     }
   return cellGraph;
 }
+
+std::vector<std::string> MEDPARTITIONER::MEDPartitioner::AvailableAlgorithms()
+{
+  std::vector<std::string> ret;
+#ifdef MED_ENABLE_METIS
+  ret.push_back(std::string(METIS_PART_ALG));
+#endif
+#ifdef MED_ENABLE_SCOTCH
+  ret.push_back(std::string(SCOTCH_PART_ALG));
+#endif
+#ifdef MED_ENABLE_PTSCOTCH
+  ret.push_back(std::string(PTSCOTCH_PART_ALG));
+#endif
+  return ret;
+}
+
+bool MEDPARTITIONER::MEDPartitioner::HasMetisAlg()
+{
+#ifdef MED_ENABLE_METIS
+  return true;
+#else
+  return false;
+#endif
+}
+
+bool MEDPARTITIONER::MEDPartitioner::HasScotchAlg()
+{
+#ifdef MED_ENABLE_SCOTCH
+  return true;
+#else
+  return false;
+#endif
+}
+
+bool MEDPARTITIONER::MEDPartitioner::HasPTScotchAlg()
+{
+#ifdef MED_ENABLE_PTSCOTCH
+  return true;
+#else
+  return false;
+#endif
+}
+
+std::vector<std::string> MEDPARTITIONER::MEDPartitioner::AllAlgorithms()
+{
+  std::vector<std::string> ret;
+  ret.push_back(std::string(METIS_PART_ALG));
+  ret.push_back(std::string(SCOTCH_PART_ALG));
+  ret.push_back(std::string(PTSCOTCH_PART_ALG));
+  return ret;
+}