Ifpack Package Browser (Single Doxygen Collection) Development
Ifpack_ReorderFilter.cpp
Go to the documentation of this file.
00001 /*@HEADER
00002 // ***********************************************************************
00003 //
00004 //       Ifpack: Object-Oriented Algebraic Preconditioner Package
00005 //                 Copyright (2002) Sandia Corporation
00006 //
00007 // Under terms of Contract DE-AC04-94AL85000, there is a non-exclusive
00008 // license for use of this work by or on behalf of the U.S. Government.
00009 //
00010 // This library is free software; you can redistribute it and/or modify
00011 // it under the terms of the GNU Lesser General Public License as
00012 // published by the Free Software Foundation; either version 2.1 of the
00013 // License, or (at your option) any later version.
00014 //
00015 // This library is distributed in the hope that it will be useful, but
00016 // WITHOUT ANY WARRANTY; without even the implied warranty of
00017 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00018 // Lesser General Public License for more details.
00019 //
00020 // You should have received a copy of the GNU Lesser General Public
00021 // License along with this library; if not, write to the Free Software
00022 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
00023 // USA
00024 // Questions? Contact Michael A. Heroux (maherou@sandia.gov)
00025 //
00026 // ***********************************************************************
00027 //@HEADER
00028 */
00029 
00030 #include "Ifpack_ConfigDefs.h"
00031 #include "Ifpack_ReorderFilter.h"
00032 #include "Ifpack_Reordering.h"
00033 #include "Epetra_ConfigDefs.h"
00034 #include "Epetra_RowMatrix.h"
00035 #include "Epetra_Comm.h"
00036 #include "Epetra_Map.h"
00037 #include "Epetra_MultiVector.h"
00038 #include "Epetra_Vector.h"
00039 
00040 //==============================================================================
00041 Ifpack_ReorderFilter::Ifpack_ReorderFilter(const Teuchos::RefCountPtr<Epetra_RowMatrix>& Matrix_in,
00042                                            const Teuchos::RefCountPtr<Ifpack_Reordering>& Reordering_in) :
00043   A_(Matrix_in),
00044   Reordering_(Reordering_in),
00045   NumMyRows_(Matrix_in->NumMyRows()),
00046   MaxNumEntries_(Matrix_in->MaxNumEntries())
00047 {
00048 }
00049 
00050 //==============================================================================
00051 Ifpack_ReorderFilter::Ifpack_ReorderFilter(const Ifpack_ReorderFilter& RHS) :
00052   A_(Matrix()),
00053   Reordering_(Reordering()),
00054   NumMyRows_(RHS.NumMyRows()),
00055   MaxNumEntries_(RHS.MaxNumEntries())
00056 {
00057   strcpy(Label_,RHS.Label());
00058 }
00059 
00060 //==============================================================================
00061 Ifpack_ReorderFilter& 
00062 Ifpack_ReorderFilter::operator=(const Ifpack_ReorderFilter& RHS)
00063 {
00064   if (this == &RHS)
00065     return (*this);
00066 
00067   A_ = RHS.Matrix();
00068 
00069   Reordering_ = RHS.Reordering();
00070   MaxNumEntries_ = RHS.MaxNumEntries();
00071   NumMyRows_ = RHS.NumMyRows();
00072 
00073   strcpy(Label_,RHS.Label());
00074   return(*this);
00075 }
00076 
00077 //==============================================================================
00078 int Ifpack_ReorderFilter::
00079 ExtractMyRowCopy(int MyRow, int Length, int & NumEntries, 
00080                  double *Values, int * Indices) const
00081 {
00082   int MyReorderdRow = Reordering_->InvReorder(MyRow);
00083 
00084   IFPACK_CHK_ERR(Matrix()->ExtractMyRowCopy(MyReorderdRow,MaxNumEntries_,
00085                                            NumEntries, Values,Indices));
00086 
00087   // suppose all elements are local. Note that now
00088   // Indices can have indices in non-increasing order.
00089   for (int i = 0 ; i < NumEntries ; ++i) {
00090     Indices[i] = Reordering_->Reorder(Indices[i]);
00091   }
00092 
00093   return(0);
00094 }
00095 
00096 //==============================================================================
00097 int Ifpack_ReorderFilter::
00098 ExtractDiagonalCopy(Epetra_Vector & Diagonal) const
00099 {
00100   Epetra_Vector DiagonalTilde(Diagonal.Map());
00101   IFPACK_CHK_ERR(Matrix()->ExtractDiagonalCopy(DiagonalTilde));
00102   IFPACK_CHK_ERR((Reordering_->P(DiagonalTilde,Diagonal)));
00103   return(0);
00104 }
00105 
00106 //==============================================================================
00107 int Ifpack_ReorderFilter::
00108 Multiply(bool TransA, const Epetra_MultiVector& X, 
00109          Epetra_MultiVector& Y) const
00110 {
00111   // need two additional vectors
00112   Epetra_MultiVector Xtilde(X.Map(),X.NumVectors());
00113   Epetra_MultiVector Ytilde(Y.Map(),Y.NumVectors());
00114   // bring X back to original ordering
00115   Reordering_->Pinv(X,Xtilde);
00116   // apply original matrix
00117   IFPACK_CHK_ERR(Matrix()->Multiply(TransA,Xtilde,Ytilde));
00118   // now reorder result
00119   Reordering_->P(Ytilde,Y);
00120 
00121 
00122   return(0);
00123 }
00124 
00125 //==============================================================================
00126 int Ifpack_ReorderFilter::
00127 Solve(bool Upper, bool Trans, bool UnitDiagonal, 
00128       const Epetra_MultiVector& X, Epetra_MultiVector& Y) const
00129 {
00130   IFPACK_CHK_ERR(-98);
00131 }
00132 
00133 //==============================================================================
00134 int Ifpack_ReorderFilter::
00135 Apply(const Epetra_MultiVector& X, Epetra_MultiVector& Y) const
00136 {
00137   IFPACK_RETURN(Multiply(UseTranspose(),X,Y));
00138 }
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines