X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FMEDPartitioner%2FMEDPARTITIONER_PTScotchGraph.cxx;h=0ca472e815cc9797e3975d27a712c38b90a40059;hb=662a2a2393a25baef77e42f74204b11b70a9646c;hp=056701fcd694df8dde4b8e89a37e7dc87bda8b49;hpb=b423460cb8f74693b6af405a65054e02af0e4ce4;p=tools%2Fmedcoupling.git diff --git a/src/MEDPartitioner/MEDPARTITIONER_PTScotchGraph.cxx b/src/MEDPartitioner/MEDPARTITIONER_PTScotchGraph.cxx index 056701fcd..0ca472e81 100644 --- a/src/MEDPartitioner/MEDPARTITIONER_PTScotchGraph.cxx +++ b/src/MEDPartitioner/MEDPARTITIONER_PTScotchGraph.cxx @@ -1,4 +1,4 @@ -// Copyright (C) 2017 CEA/DEN, EDF R&D +// Copyright (C) 2017-2023 CEA, EDF // // This library is free software; you can redistribute it and/or // modify it under the terms of the GNU Lesser General Public @@ -25,6 +25,7 @@ #include "MCType.hxx" #include +#include #include #ifdef MED_ENABLE_PTSCOTCH @@ -38,7 +39,7 @@ extern "C" using namespace MEDPARTITIONER; -PTSCOTCHGraph::PTSCOTCHGraph(MEDCoupling::MEDCouplingSkyLineArray *graph, int *edgeweight, DataArrayInt *vlbloctab):Graph(graph,edgeweight),_vlbloctab(vlbloctab) +PTSCOTCHGraph::PTSCOTCHGraph(MEDCoupling::MEDCouplingSkyLineArray *graph, int *edgeweight, DataArrayIdType *vlbloctab):Graph(graph,edgeweight),_vlbloctab(vlbloctab) { } @@ -52,10 +53,10 @@ void PTSCOTCHGraph::partGraph(int ndomain, const std::string& options_string, Pa std::cout << "proc " << MyGlobals::_Rank << " : PTSCOTCHGraph::partGraph" << std::endl; //number of graph vertices - int n = _graph->getNumberOf(); + int n = FromIdType(_graph->getNumberOf()); //graph - int * xadj=const_cast(_graph->getIndex()); - int * adjncy=const_cast(_graph->getValues()); + mcIdType * xadj=const_cast(_graph->getIndex()); + mcIdType * adjncy=const_cast(_graph->getValues()); //ndomain int nparts=ndomain; @@ -63,10 +64,30 @@ void PTSCOTCHGraph::partGraph(int ndomain, const std::string& options_string, Pa throw INTERP_KERNEL::Exception("PTSCOTCHGraph::partGraph : PTSCOTCH is not available. Check your products, please."); #else //output parameters - int* partition = new int[n+1]; - - int* vlbloctab = _vlbloctab?const_cast(_vlbloctab->begin()):0; + std::unique_ptr partition(new mcIdType[n+1]); +#ifdef MEDCOUPLING_USE_64BIT_IDS + mcIdType *cellWeightPtr(nullptr); + std::vector cellWeightVec; + if(_cell_weight) + { + cellWeightVec.insert(cellWeightVec.end(),_cell_weight,_cell_weight+_graph->getLength()); + cellWeightPtr = cellWeightVec.data(); + } + mcIdType *edgeWeightPtr(nullptr); + std::vector edgeWeightVec; + if(_edge_weight) + { + edgeWeightVec.insert(edgeWeightVec.end(),_edge_weight,_edge_weight+_graph->getLength()); + edgeWeightPtr = edgeWeightVec.data(); + } +#else + mcIdType *cellWeightPtr(_cell_weight); + mcIdType *edgeWeightPtr(_edge_weight); +#endif + mcIdType *vlbloctab = _vlbloctab?const_cast(_vlbloctab->begin()):nullptr; + + SCOTCH_randomReset(); SCOTCH_Dgraph scotch_graph; SCOTCH_dgraphInit(&scotch_graph, MPI_COMM_WORLD); SCOTCH_dgraphBuild(&scotch_graph, @@ -75,13 +96,13 @@ void PTSCOTCHGraph::partGraph(int ndomain, const std::string& options_string, Pa n, // vertlocmax , should be set to vertlocnbr for graphs without holes xadj, // vertloctab[vertnbr+1] , index vertex table 0, // vendloctab , index end vertex table if disjoint, set to zero - _cell_weight, // veloloctab , graph vertices loads, set to zero + cellWeightPtr, // veloloctab , graph vertices loads, set to zero vlbloctab, // vlblocltab , vertex label array : global vertex index xadj[n], // edgelocnbr , number of edges xadj[n], // edgelocsiz , same as edgelocnbr if edgeloctab is compact adjncy, // edgeloctab[edgelocnbr], global indexes of edges - 0, // edgegsttab , optionnal, should be computed internally, set to zero - _edge_weight); // edloloctab , graph edges loads, set to zero + 0, // edgegsttab , optional, should be computed internally, set to zero + edgeWeightPtr); // edloloctab , graph edges loads, set to zero SCOTCH_Strat scotch_strategy; SCOTCH_stratInit(&scotch_strategy); @@ -93,7 +114,7 @@ void PTSCOTCHGraph::partGraph(int ndomain, const std::string& options_string, Pa if (nparts>1) { if (MyGlobals::_Verbose>10) std::cout << "SCOTCHGraph::graphPart SCOTCH_graphPart" << std::endl; - SCOTCH_dgraphPart(&scotch_graph,nparts,&scotch_strategy,partition); + SCOTCH_dgraphPart(&scotch_graph,nparts,&scotch_strategy,partition.get()); } else //partition for 1 subdomain { @@ -104,15 +125,14 @@ void PTSCOTCHGraph::partGraph(int ndomain, const std::string& options_string, Pa SCOTCH_stratExit(&scotch_strategy); SCOTCH_dgraphExit(&scotch_graph); - std::vector index(n+1); - std::vector value(n); + std::vector index(n+1); + std::vector value(n); index[0]=0; for (int i=0; i