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
60 idxtype *,
int *,
int *,
int *,
int *,
int *,
81 #ifdef HAVE_IFPACK_METIS
85 Teuchos::RefCountPtr<Epetra_CrsGraph> SymGraph ;
86 Teuchos::RefCountPtr<Epetra_Map> SymMap;
87 Teuchos::RefCountPtr<Ifpack_Graph_Epetra_CrsGraph> SymIFPACKGraph;
92 std::vector<int> Indices;
93 Indices.resize(Length);
98 std::vector<idxtype> wgtflag;
101 std::vector<int> options;
108 #if !defined(EPETRA_NO_32BIT_GLOBAL_INDICES) || !defined(EPETRA_NO_64BIT_GLOBAL_INDICES)
117 #ifndef EPETRA_NO_32BIT_GLOBAL_INDICES
118 if(SymGraph->RowMap().GlobalIndicesInt()) {
124 for (
int j = 0 ; j < NumIndices ; ++j) {
127 SymGraph->InsertGlobalIndices(i,1,&jj);
128 SymGraph->InsertGlobalIndices(jj,1,&i);
135 #ifndef EPETRA_NO_64BIT_GLOBAL_INDICES
136 if(SymGraph->RowMap().GlobalIndicesLongLong()) {
143 for (
int j = 0 ; j < NumIndices ; ++j) {
144 long long jj = Indices[j];
146 SymGraph->InsertGlobalIndices(i_LL,1,&jj);
147 SymGraph->InsertGlobalIndices(jj,1,&i_LL);
154 throw "Ifpack_METISPartitioner::ComputePartitions: GlobalIndices type unknown";
158 IFPACKGraph = SymIFPACKGraph;
170 std::vector<idxtype> xadj;
173 std::vector<idxtype> adjncy;
182 xadj[count2+1] = xadj[count2];
184 ierr = IFPACKGraph->ExtractMyRowCopy(i, Length, NumIndices, &Indices[0]);
187 for (
int j = 0 ; j < NumIndices ; ++j) {
190 adjncy[count++] = jj;
197 std::vector<idxtype> NodesInSubgraph;
226 #ifdef HAVE_IFPACK_METIS
232 METIS_PartGraphRecursive(&j, &xadj[0], &adjncy[0],
240 METIS_PartGraphKway (&j, &xadj[0], &adjncy[0],
242 NULL, &wgtflag[0], &numflag,
247 numflag = numflag * 2;
249 cerr <<
"METIS was not linked; now I put all" << endl;
250 cerr <<
"the local nodes in the same partition." << endl;
260 NodesInSubgraph[i] = 0;
262 for (
int i = 0 ; i <
NumMyRows() ; ++i) {
268 else NodesInSubgraph[j]++;
272 if( NodesInSubgraph[i] == 0 ) {
279 cerr <<
"Specified number of subgraphs ("
281 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.
int MaxNumEntries() const
Returns the max number of local entries in a row.
int NumMyNonzeros() const
Returns the number of local nonzero elements.
int NumMyRows() const
Returns the number of local rows.
std::vector< int > Partition_
Partition_[i] contains the ID of non-overlapping part it belongs to.
virtual int MyPID() const =0
TEUCHOS_DEPRECATED RCP< T > rcp(T *p, Dealloc_T dealloc, bool owns_mem)
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.
const Ifpack_Graph * Graph_
Reference to the graph to be partitioned.
int NumLocalParts_
Number of local subgraphs.
int NumLocalParts() const
Returns the number of computed local partitions.
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)