From: Anthony Geay Date: Fri, 29 Dec 2017 14:11:18 +0000 (+0100) Subject: Management of PTScotch/Scotch separetely X-Git-Tag: V9_0_0~15 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=b0d60cde5dc9ace9e5b1a651e657d343dcb9208c;p=tools%2Fmedcoupling.git Management of PTScotch/Scotch separetely --- diff --git a/src/MEDPartitioner/MEDPARTITIONER_Graph.hxx b/src/MEDPartitioner/MEDPARTITIONER_Graph.hxx index abf927310..60a559538 100644 --- a/src/MEDPartitioner/MEDPARTITIONER_Graph.hxx +++ b/src/MEDPartitioner/MEDPARTITIONER_Graph.hxx @@ -38,7 +38,7 @@ namespace MEDPARTITIONER class MEDPARTITIONER_EXPORT Graph { public: - typedef enum {METIS,SCOTCH} splitter_type; + typedef enum {METIS,SCOTCH,PTSCOTCH} splitter_type; Graph(); //creates a graph from a SKYLINEARRAY- WARNING!! Graph takes ownership of the array. diff --git a/src/MEDPartitioner/MEDPARTITIONER_MEDPartitioner.cxx b/src/MEDPartitioner/MEDPARTITIONER_MEDPartitioner.cxx index 5677d56ab..359e9306f 100644 --- a/src/MEDPartitioner/MEDPARTITIONER_MEDPartitioner.cxx +++ b/src/MEDPartitioner/MEDPARTITIONER_MEDPartitioner.cxx @@ -148,14 +148,14 @@ MEDPARTITIONER::Graph* MEDPARTITIONER::MEDPartitioner::Graph(MEDCoupling::MEDCou { MEDPARTITIONER::Graph* cellGraph=0; // will be destroyed by XXXGraph class: - MEDCoupling::MEDCouplingSkyLineArray* arr = MEDCoupling::MEDCouplingSkyLineArray::New(graph->getIndexArray(), graph->getValuesArray()); + MEDCoupling::MCAuto 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 ) @@ -163,15 +163,22 @@ 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,edgeweight,vlbloctab); + cellGraph=new PTSCOTCHGraph(arr.retn(),edgeweight,vlbloctab); #else - throw INTERP_KERNEL::Exception("MEDPartitioner::Graph : PTSCOTCH/SCOTCH is not available. Check your products, please."); + throw INTERP_KERNEL::Exception("MEDPartitioner::Graph : PTSCOTCH is not available. Check your products, please."); #endif -#endif - break; + break; + } + default: + throw INTERP_KERNEL::Exception("MEDPartitioner::Graph : Not managed split type engine !"); } return cellGraph; } diff --git a/src/MEDPartitioner_Swig/MEDPartitionerCommon.i b/src/MEDPartitioner_Swig/MEDPartitionerCommon.i index aeb343a27..a876aeb70 100644 --- a/src/MEDPartitioner_Swig/MEDPartitionerCommon.i +++ b/src/MEDPartitioner_Swig/MEDPartitionerCommon.i @@ -38,7 +38,7 @@ namespace MEDPARTITIONER class Graph { public: - typedef enum {METIS,SCOTCH} splitter_type; + typedef enum {METIS,SCOTCH,PTSCOTCH} splitter_type; public: virtual void partGraph(int ndomain, const std::string& options_string="", ParaDomainSelector *sel=0) throw(INTERP_KERNEL::Exception); MEDCoupling::MEDCouplingSkyLineArray *getGraph() const diff --git a/src/PyWrapping/TestPyWrapGathered_medcoupling.py b/src/PyWrapping/TestPyWrapGathered_medcoupling.py index 14a268000..899823638 100644 --- a/src/PyWrapping/TestPyWrapGathered_medcoupling.py +++ b/src/PyWrapping/TestPyWrapGathered_medcoupling.py @@ -86,17 +86,16 @@ class medcouplingTest(unittest.TestCase): @unittest.skipUnless(HasPartitionerExt(),"Requires Partitioner activation") def test3(self): + algoSelected=eval("Graph.%s"%MEDPartitioner.AvailableAlgorithms()[0].upper()) arr=DataArrayDouble(10) ; arr.iota() m=MEDCouplingCMesh() ; m.setCoords(arr,arr) m=m.buildUnstructured() ; m.setName("mesh") - m.write("all.med") a,b=m.computeNeighborsOfCells() sk=MEDCouplingSkyLineArray(b,a) - g=MEDPartitioner.Graph(sk) + g=MEDPartitioner.Graph(sk,algoSelected) g.partGraph(4) procIdOnCells=g.getPartition().getValuesArray() m0=m[procIdOnCells.findIdsEqual(0)] ; m0.setName("m0") - m0.write("part0.med") pass @unittest.skipUnless(HasParallelInterpolatorExt(),"Requires // interpolator activated") @@ -107,4 +106,12 @@ class medcouplingTest(unittest.TestCase): pass if __name__ == "__main__": + if HasParallelInterpolatorExt(): + try: + from mpi4py import MPI # if not imported test3 may failed due to MPI call of partitioner algorithms. + except: + pass + pass unittest.main() + pass +