*/
MEDCouplingSkyLineArray *MEDCouplingUMesh::generateGraph() const
{
- MEDCouplingSkyLineArray* ret=new MEDCouplingSkyLineArray(_nodal_connec_index, _nodal_connec);
+ DataArrayInt* index=DataArrayInt::New();
+ index->alloc(_nodal_connec_index->getNbOfElems(),1);
+ int *indexCurPtr=index->getPointer();
+ int *indexPtr=_nodal_connec_index->getPointer();
+
+ for(int i=0;i<_nodal_connec_index->getNbOfElems();i++)
+ indexCurPtr[i]=indexPtr[i];
+
+ DataArrayInt* value=DataArrayInt::New();
+ value->alloc(_nodal_connec->getNbOfElems(),1);
+ int *valueCurPtr=value->getPointer();
+ int *valuePtr= _nodal_connec->getPointer();
+
+ for(int i=0;i<_nodal_connec->getNbOfElems();i++)
+ valueCurPtr[i]=valuePtr[i];
+
+ MEDCouplingSkyLineArray* ret=new MEDCouplingSkyLineArray(index, value);
return ret;
}
public:
typedef enum {METIS,SCOTCH} splitter_type;
- Graph() { }
+ Graph();
//creates a graph from a SKYLINEARRAY
Graph(ParaMEDMEM::MEDCouplingSkyLineArray* graph, int* edgeweight=0);
virtual ~Graph();
void setVerticesWeights(int *cellweight) { _cell_weight=cellweight; }
//computes partitioning of the graph
- virtual void partGraph(int ndomain, const std::string&, ParaDomainSelector *sel=0) = 0;
+ virtual void partGraph(int ndomain, const std::string& options_string="", ParaDomainSelector *sel=0) = 0;
//returns the partitioning
const int *getPart() const { return _partition->getValue(); }
(_input_collection->getMesh()).push_back(CreateEmptyMEDCouplingUMesh()); // or 0 if you want tests;
ParaMEDMEM::DataArrayInt* empty=ParaMEDMEM::DataArrayInt::New();
empty->alloc(0,1);
- (_input_collection->getCellFamilyIds()).push_back(empty);
+ (_input_collection->getCellFamilyIds()).push_back(empty);
}
try
{
MEDPARTITIONER::Graph* MEDPARTITIONER::MEDPartitioner::Graph(ParaMEDMEM::MEDCouplingSkyLineArray* graph, Graph::splitter_type split, int* edgeweight)
{
- // MEDPARTITIONER::SkyLineArray* r=0;
- // MEDPARTITIONER::Graph* cellGraph = 0;
- // switch (split)
- // {
- // case Graph::METIS:
- // if ( !cellGraph )
- // {
- // #ifdef MED_ENABLE_METIS
- // cellGraph=new METISGraph(r,edgeweight);
- // #endif
- // }
- // if ( !cellGraph )
- // throw INTERP_KERNEL::Exception("MeshCollection::createPartition : PARMETIS/METIS is not available. Check your products, please.");
- // break;
- // case Graph::SCOTCH:
- // #ifdef MED_ENABLE_SCOTCH
- // cellGraph=new SCOTCHGraph(r,edgeweight);
- // #else
- // throw INTERP_KERNEL::Exception("MeshCollection::createPartition : SCOTCH is not available. Check your products, please.");
- // #endif
- // break;
- // }
- // return cellGraph;
+ MEDPARTITIONER::SkyLineArray* arr=0;
+ MEDPARTITIONER::Graph* cellGraph=0;
+ std::vector<int> index,value;
+ int *arrIndex = (const_cast<ParaMEDMEM::DataArrayInt*>(graph->getIndex()))->getPointer();
+ int *arrValue = (const_cast<ParaMEDMEM::DataArrayInt*>(graph->getValue()))->getPointer();
+ for(int i=0;i<graph->getNumberOf();i++) {
+ index.push_back(arrIndex[i]);
+ }
+ for(int i=0;i<graph->getLength();i++) {
+ value.push_back(arrValue[i]);
+ }
+ arr = new SkyLineArray(index,value);
+ switch (split)
+ {
+ case Graph::METIS:
+ if ( !cellGraph )
+ {
+ #ifdef MED_ENABLE_METIS
+ cellGraph=new METISGraph(arr,edgeweight);
+ #endif
+ }
+ if ( !cellGraph )
+ throw INTERP_KERNEL::Exception("MEDPartitioner::Graph : PARMETIS/METIS is not available. Check your products, please.");
+ break;
+ case Graph::SCOTCH:
+ #ifdef MED_ENABLE_SCOTCH
+ cellGraph=new SCOTCHGraph(arr,edgeweight);
+ #else
+ throw INTERP_KERNEL::Exception("MEDPartitioner::Graph : SCOTCH is not available. Check your products, please.");
+ #endif
+ break;
+ }
+ return cellGraph;
}
namespace MEDPARTITIONER
{
- class Topology;
class MeshCollection;
class ParaDomainSelector;
class Graph;
-
+
class MEDPartitioner
{
public:
static MEDPartitioner *New(const ParaMEDMEM::MEDFileData* filedata, int ndomains=1, const std::string& library="metis",bool creates_boundary_faces=false, bool create_joints=false, bool mesure_memory=false);
void Write(const std::string& filename);
ParaMEDMEM::MEDFileData* getMEDFileData();
- MEDPARTITIONER::Graph* Graph(ParaMEDMEM::MEDCouplingSkyLineArray* graph, Graph::splitter_type split, int* edgeweight=0);
+ MEDPARTITIONER::Graph* Graph(ParaMEDMEM::MEDCouplingSkyLineArray* graph, Graph::splitter_type split=Graph::METIS, int* edgeweight=0);
private:
MEDPartitioner(const std::string& filename, int ndomains, const std::string& library,bool creates_boundary_faces, bool create_joints, bool mesure_memory);
MEDPartitioner(const ParaMEDMEM::MEDFileData* filedata, int ndomains, const std::string& library,bool creates_boundary_faces, bool create_joints, bool mesure_memory);
#include "MEDFileData.hxx"
#include "MEDPARTITIONER_MEDPartitioner.hxx"
-
+#include "MEDPARTITIONER.hxx"
+#include "MEDPARTITIONER_SkyLineArray.hxx"
#include "MEDPARTITIONER_Graph.hxx"
+#include "MEDPARTITIONER_MetisGraph.hxx"
+#include "MEDPARTITIONER_ScotchGraph.hxx"
using namespace ParaMEDMEM;
using namespace INTERP_KERNEL;
%nodefaultctor;
%newobject MEDPARTITIONER::MEDPartitioner::New;
+%newobject MEDPARTITIONER::MEDPartitioner::Graph;
%rename (InterpKernelException) INTERP_KERNEL::Exception;
static MEDPartitioner *New(const ParaMEDMEM::MEDFileData* filedata, int ndomains=1, const std::string& library="metis",bool creates_boundary_faces=false, bool create_joints=false, bool mesure_memory=false) throw(INTERP_KERNEL::Exception);
void Write(const std::string& filename) throw(INTERP_KERNEL::Exception);
ParaMEDMEM::MEDFileData* getMEDFileData() throw(INTERP_KERNEL::Exception);
- MEDPARTITIONER::Graph* Graph(ParaMEDMEM::MEDCouplingSkyLineArray* graph, Graph::splitter_type split, int* edgeweight=0) throw(INTERP_KERNEL::Exception);
+ MEDPARTITIONER::Graph* Graph(ParaMEDMEM::MEDCouplingSkyLineArray* graph, Graph::splitter_type split=Graph::METIS, int* edgeweight=0) throw(INTERP_KERNEL::Exception);
%extend
{
MEDPartitioner(const std::string& filename, int ndomains=1, const std::string& library="metis",bool creates_boundary_faces=false, bool create_joints=false, bool mesure_memory=false) throw(INTERP_KERNEL::Exception)
return MEDPartitioner::New(fileData,ndomains,library,creates_boundary_faces, create_joints, mesure_memory);
}
}
+};
+namespace MEDPARTITIONER
+{
+ class Graph
+ {
+ public:
+ virtual void partGraph(int ndomain, const std::string& options_string="", ParaDomainSelector *sel=0) throw(INTERP_KERNEL::Exception);
+ };
};
\ No newline at end of file
#mfd1 = MEDFileData.New()
p=MEDPartitioner.New(d,2);
#p=MEDPartitioner.New("/dn20/salome/imn/SALOME7YA/MED_BUILD/src/MEDLoader/Swig/splitted_blade1.med");
- #part=MEDPartitioner.Graph(m.generateGraph())
- #part.partGraph(2)
+ mm=m.generateGraph()
+ part=p.Graph(mm)
+ part.partGraph(2)
+ #part2.partGraph(2)
#a=part.getGraph()
#n2o,o2n=ren.renumber(a,b)
pass