Salome HOME
Fix 32bits config bug
[tools/medcoupling.git] / src / MEDPartitioner / MEDPARTITIONER_ScotchGraph.cxx
index 90c0403048039109f8e809b7a437764a42c14d3e..1cd742b6d0de100a0f2060fe3a55f1a48a4cd0a2 100644 (file)
@@ -1,4 +1,4 @@
-// Copyright (C) 2007-2014  CEA/DEN, EDF R&D
+// Copyright (C) 2007-2020  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
@@ -21,6 +21,8 @@
 #include "MEDPARTITIONER_ScotchGraph.hxx"
 #include "MEDPARTITIONER_Utils.hxx"
 
+#include "MEDCouplingSkyLineArray.hxx"
+
 #include <cstdio>
 
 #ifdef MED_ENABLE_SCOTCH
@@ -37,7 +39,7 @@ SCOTCHGraph::SCOTCHGraph():Graph()
 {
 }
 
-SCOTCHGraph::SCOTCHGraph(MEDPARTITIONER::SkyLineArray* graph, int* edgeweight):Graph(graph,edgeweight)
+SCOTCHGraph::SCOTCHGraph(MEDCoupling::MEDCouplingSkyLineArray* graph, int* edgeweight):Graph(graph,edgeweight)
 {
 }
 
@@ -51,10 +53,17 @@ void SCOTCHGraph::partGraph(int ndomain, const std::string& options_string, Para
     std::cout << "proc " << MyGlobals::_Rank << " : SCOTCHGraph::partGraph" << std::endl;
   
   //number of graph vertices
-  int n = _graph->getNumberOf();
+  int n = FromIdType<int>(_graph->getNumberOf());
   //graph
+#ifdef MEDCOUPLING_USE_64BIT_IDS
+  std::vector<int> indexVec( _graph->getIndex(), _graph->getIndexArray()->end() );
+  std::vector<int> valueVec( _graph->getValues(), _graph->getValuesArray()->end() );
+  int * xadj=indexVec.data();
+  int * adjncy=valueVec.data();
+#else
   int * xadj=const_cast<int*>(_graph->getIndex());
-  int * adjncy=const_cast<int*>(_graph->getValue());
+  int * adjncy=const_cast<int*>(_graph->getValues());
+#endif
   //ndomain
   int nparts=ndomain;
 
@@ -97,19 +106,19 @@ void SCOTCHGraph::partGraph(int ndomain, const std::string& options_string, Para
   SCOTCH_stratExit(&scotch_strategy);
   SCOTCH_graphExit(&scotch_graph);
 
-  std::vector<int> index(n+1);
-  std::vector<int> value(n);
+  std::vector<mcIdType> index(n+1);
+  std::vector<mcIdType> value(n);
   index[0]=0;
   for (int i=0; i<n; i++)
     {
       index[i+1]=index[i]+1;
-      value[i]=partition[i];
+      value[i]=ToIdType(partition[i]);
     }
   delete [] partition;
   
   //creating a skylinearray with no copy of the index and partition array
   //the fifth argument true specifies that only the pointers are passed 
   //to the object
-  _partition = new MEDPARTITIONER::SkyLineArray(index,value);
+  _partition = MEDCoupling::MEDCouplingSkyLineArray::New(index,value);
 #endif
 }