43 #include "Ifpack_ConfigDefs.h" 44 #include "Teuchos_ParameterList.hpp" 45 #include "Teuchos_RefCountPtr.hpp" 46 #include "Epetra_MultiVector.h" 47 #include "Ifpack_Graph.h" 48 #include "Epetra_RowMatrix.h" 49 #include "Ifpack_Graph_Epetra_RowMatrix.h" 50 #include "Ifpack_RCMReordering.h" 91 for (
int i = 0 ; i < NumMyRows_ ; ++i) {
103 if (Name ==
"reorder: root node")
119 RootNode_ = List.get(
"reorder: root node", RootNode_);
128 IFPACK_CHK_ERR(
Compute(Graph));
139 if ((RootNode_ < 0) || (RootNode_ >= NumMyRows_))
142 Reorder_.resize(NumMyRows_);
146 InvReorder_.resize(NumMyRows_);
151 for (
int i = 0 ; i < NumMyRows_ ; ++i)
155 tmp.push_back(RootNode_);
157 int count = NumMyRows_ - 1;
159 vector<int> Indices(Length);
161 Reorder_[RootNode_] = count;
172 for (
int i = 0 ; i < (int)tmp.size() ; ++i) {
175 NumEntries, &Indices[0]));
178 sort(Indices.begin(), Indices.begin() + Length);
180 for (
int j = 0 ; j < NumEntries ; ++j) {
181 int col = Indices[j];
182 if (col >= NumMyRows_)
185 if (Reorder_[col] == -1) {
186 Reorder_[col] = count;
199 if ((tmp2.size() == 0) && (count != -1)) {
200 for (
int i = 0 ; i < NumMyRows_ ; ++i)
201 if (Reorder_[i] == -1) {
203 Reorder_[i] = count--;
213 for (
int i = 0 ; i < NumMyRows_ ; ++i) {
214 if (Reorder_[i] == -1)
219 InvReorder_.resize(NumMyRows_);
221 for (
int i = 0 ; i < NumMyRows_ ; ++i)
224 for (
int i = 0 ; i < NumMyRows_ ; ++i)
225 InvReorder_[Reorder_[i]] = i;
227 for (
int i = 0 ; i < NumMyRows_ ; ++i) {
228 if (InvReorder_[i] == -1)
242 if ((i < 0) || (i >= NumMyRows_))
255 if ((i < 0) || (i >= NumMyRows_))
259 return(InvReorder_[i]);
263 Epetra_MultiVector& X)
const 265 int NumVectors = X.NumVectors();
267 for (
int j = 0 ; j < NumVectors ; ++j) {
268 for (
int i = 0 ; i < NumMyRows_ ; ++i) {
269 int np = Reorder_[i];
270 X[j][np] = Xorig[j][i];
279 Epetra_MultiVector& X)
const 281 int NumVectors = X.NumVectors();
283 for (
int j = 0 ; j < NumVectors ; ++j) {
284 for (
int i = 0 ; i < NumMyRows_ ; ++i) {
285 int np = Reorder_[i];
286 X[j][i] = Xorig[j][np];
296 os <<
"*** Ifpack_RCMReordering" << endl << endl;
298 os <<
"*** Reordering not yet computed." << endl;
300 os <<
"*** Number of local rows = " << NumMyRows_ << endl;
301 os <<
"*** Root node = " << RootNode_ << endl;
303 os <<
"Local Row\tReorder[i]\tInvReorder[i]" << endl;
304 for (
int i = 0 ; i < NumMyRows_ ; ++i) {
305 os <<
'\t' << i <<
"\t\t" << Reorder_[i] <<
"\t\t" << InvReorder_[i] << endl;
virtual bool IsComputed() const
Returns true is the reordering object has been successfully initialized, false otherwise.
virtual int SetParameter(const string Name, const int Value)
Sets integer parameters `Name'.
virtual int Pinv(const Epetra_MultiVector &Xorig, Epetra_MultiVector &Xinvreord) const
Applies inverse reordering to multivector X, whose local length equals the number of local rows...
virtual int Compute(const Ifpack_Graph &Graph)
Computes all it is necessary to initialize the reordering object.
virtual int NumMyRows() const
Returns the number of local rows.
virtual int InvReorder(const int i) const
Returns the inverse reordered index of row i.
virtual ostream & Print(std::ostream &os) const
Prints basic information on iostream. This function is used by operator<<.
virtual int ExtractMyRowCopy(int MyRow, int LenOfIndices, int &NumIndices, int *Indices) const =0
Extracts a copy of input local row.
virtual int NumMyRows() const =0
Returns the number of local rows.
virtual int RootNode() const
Returns the root node.
Ifpack_RCMReordering: reverse Cuthill-McKee reordering.
Ifpack_Graph_Epetra_RowMatrix: a class to define Ifpack_Graph as a light-weight conversion of Epetra_...
Ifpack_Graph: a pure virtual class that defines graphs for IFPACK.
virtual int SetParameters(Teuchos::ParameterList &List)
Sets all parameters.
virtual int Reorder(const int i) const
Returns the reordered index of row i.
virtual int MaxMyNumEntries() const =0
Returns the maximun number of entries for row.
Ifpack_RCMReordering & operator=(const Ifpack_RCMReordering &RHS)
Assignment operator.
virtual int P(const Epetra_MultiVector &Xorig, Epetra_MultiVector &Xreord) const
Applies reordering to multivector X, whose local length equals the number of local rows...
Ifpack_RCMReordering()
Constructor for Ifpack_Graph's.