49 #include "Epetra_Comm.h" 50 #include "Epetra_CrsGraph.h" 51 #include "Epetra_Map.h" 52 #include "Teuchos_ParameterList.hpp" 53 #include "Teuchos_RefCountPtr.hpp" 57 #ifdef HAVE_IFPACK_METIS 59 void METIS_EstimateMemory(
int *,
idxtype *,
idxtype *,
int *,
int *,
int *);
61 idxtype *,
int *,
int *,
int *,
int *,
int *,
82 #ifdef HAVE_IFPACK_METIS 87 Teuchos::RefCountPtr<Epetra_CrsGraph> SymGraph ;
88 Teuchos::RefCountPtr<Epetra_Map> SymMap;
89 Teuchos::RefCountPtr<Ifpack_Graph_Epetra_CrsGraph> SymIFPACKGraph;
90 Teuchos::RefCountPtr<Ifpack_Graph> IFPACKGraph = Teuchos::rcp( (
Ifpack_Graph*)
Graph_,
false );
94 std::vector<int> Indices;
95 Indices.resize(Length);
100 std::vector<idxtype> wgtflag;
103 std::vector<int> options;
110 #if !defined(EPETRA_NO_32BIT_GLOBAL_INDICES) || !defined(EPETRA_NO_64BIT_GLOBAL_INDICES) 116 SymGraph = Teuchos::rcp(
new Epetra_CrsGraph(Copy,*SymMap,0) );
119 #ifndef EPETRA_NO_32BIT_GLOBAL_INDICES 120 if(SymGraph->RowMap().GlobalIndicesInt()) {
126 for (
int j = 0 ; j < NumIndices ; ++j) {
129 SymGraph->InsertGlobalIndices(i,1,&jj);
130 SymGraph->InsertGlobalIndices(jj,1,&i);
137 #ifndef EPETRA_NO_64BIT_GLOBAL_INDICES 138 if(SymGraph->RowMap().GlobalIndicesLongLong()) {
145 for (
int j = 0 ; j < NumIndices ; ++j) {
146 long long jj = Indices[j];
148 SymGraph->InsertGlobalIndices(i_LL,1,&jj);
149 SymGraph->InsertGlobalIndices(jj,1,&i_LL);
156 throw "Ifpack_METISPartitioner::ComputePartitions: GlobalIndices type unknown";
160 IFPACKGraph = SymIFPACKGraph;
172 std::vector<idxtype> xadj;
175 std::vector<idxtype> adjncy;
184 xadj[count2+1] = xadj[count2];
186 ierr = IFPACKGraph->ExtractMyRowCopy(i, Length, NumIndices, &Indices[0]);
189 for (
int j = 0 ; j < NumIndices ; ++j) {
192 adjncy[count++] = jj;
199 std::vector<idxtype> NodesInSubgraph;
228 #ifdef HAVE_IFPACK_METIS 234 METIS_EstimateMemory(&j, &xadj[0], &adjncy[0],
235 &numflag, &i, &nbytes );
237 METIS_PartGraphRecursive(&j, &xadj[0], &adjncy[0],
245 METIS_PartGraphKway (&j, &xadj[0], &adjncy[0],
247 NULL, &wgtflag[0], &numflag,
252 numflag = numflag * 2;
254 cerr <<
"METIS was not linked; now I put all" << endl;
255 cerr <<
"the local nodes in the same partition." << endl;
265 NodesInSubgraph[i] = 0;
267 for (
int i = 0 ; i <
NumMyRows() ; ++i) {
273 else NodesInSubgraph[j]++;
277 if( NodesInSubgraph[i] == 0 ) {
284 cerr <<
"Specified number of subgraphs (" 286 cerr <<
"Now I recall METIS with NumLocalParts_ = "
virtual int ExtractMyRowCopy(int MyRow, int LenOfIndices, int &NumIndices, int *Indices) const =0
Extracts a copy of input local row.
std::vector< int > Partition_
Partition_[i] contains the ID of non-overlapping part it belongs to.
Ifpack_Graph_Epetra_CrsGraph: a class to define Ifpack_Graph as a light-weight conversion of Epetra_C...
virtual const Epetra_Comm & Comm() const =0
Returns the communicator object of the graph.
int NumMyRows() const
Returns the number of local rows.
int NumLocalParts() const
Returns the number of computed local partitions.
const Ifpack_Graph * Graph_
Reference to the graph to be partitioned.
int NumLocalParts_
Number of local subgraphs.
Ifpack_Graph: a pure virtual class that defines graphs for IFPACK.
int ComputePartitions()
Computes the partitions. Returns 0 if successful.
#define IFPACK_CHK_ERR(ifpack_err)
int MaxNumEntries() const
Returns the max number of local entries in a row.
int NumMyNonzeros() const
Returns the number of local nonzero elements.