Ifpack_DiagonalFilter.h

Go to the documentation of this file.
00001 #ifndef IFPACK_DIAGONALFILTER_H
00002 #define IFPACK_DIAGONALFILTER_H
00003 
00004 #include "Ifpack_ConfigDefs.h"
00005 #include "Epetra_ConfigDefs.h"
00006 #include "Epetra_RowMatrix.h"
00007 class Epetra_Comm;
00008 class Epetra_Map;
00009 class Epetra_MultiVector;
00010 class Epetra_Import;
00011 class Epetra_BlockMap;
00012 #include "Epetra_Time.h"
00013 
00015 
00036 class Ifpack_DiagonalFilter : public virtual Epetra_RowMatrix {
00037 
00038 public:
00040   Ifpack_DiagonalFilter(Epetra_RowMatrix* Matrix,
00041                         double AbsoluteThreshold,
00042                         double RelativeThreshold) :
00043     A_(*Matrix),
00044     AbsoluteThreshold_(AbsoluteThreshold),
00045     RelativeThreshold_(RelativeThreshold)
00046   {
00047     Epetra_Time Time(Comm());
00048 
00049     pos_.resize(NumMyRows());
00050     val_.resize(NumMyRows());
00051 
00052     vector<int> Indices(MaxNumEntries());
00053     vector<double> Values(MaxNumEntries());
00054     int NumEntries;
00055 
00056     for (int MyRow = 0 ; MyRow < NumMyRows() ; ++MyRow) {
00057 
00058       pos_[MyRow] = -1;
00059       val_[MyRow] = 0.0;
00060       int ierr = A_.ExtractMyRowCopy(MyRow, MaxNumEntries(), NumEntries, 
00061                                      &Values[0], &Indices[0]);
00062       assert (ierr == 0);
00063 
00064       for (int i = 0 ; i < NumEntries ; ++i) {
00065         if (Indices[i] == MyRow) {
00066           pos_[MyRow] = i;
00067           val_[MyRow] = Values[i] * (RelativeThreshold_ - 1) +
00068             AbsoluteThreshold_ * EPETRA_SGN(Values[i]);
00069         }
00070         break;
00071       }
00072     }
00073     cout << "TIME = " << Time.ElapsedTime() << endl;
00074   }
00075   
00077   virtual ~Ifpack_DiagonalFilter() {};
00078 
00080   virtual int NumMyRowEntries(int MyRow, int& NumEntries) const
00081   {
00082     return(A_.NumMyRowEntries(MyRow, NumEntries));
00083   }
00084 
00086   virtual int MaxNumEntries() const
00087   {
00088     return(A_.MaxNumEntries());
00089   }
00090 
00091   inline virtual int ExtractMyRowCopy(int MyRow, int Length, int& NumEntries, 
00092                                double* Values, int* Indices) const;
00093 
00094   virtual int ExtractDiagonalCopy(Epetra_Vector & Diagonal) const
00095   {
00096     IFPACK_RETURN(A_.ExtractDiagonalCopy(Diagonal));
00097   }
00098 
00099   virtual int Multiply(bool TransA, const Epetra_MultiVector& X, 
00100            Epetra_MultiVector& Y) const;
00101 
00102   virtual int Solve(bool Upper, bool Trans, bool UnitDiagonal, 
00103         const Epetra_MultiVector& X,
00104         Epetra_MultiVector& Y) const
00105   {
00106     IFPACK_CHK_ERR(-1);
00107   }
00108 
00109   virtual int Apply(const Epetra_MultiVector& X,
00110         Epetra_MultiVector& Y) const
00111   {
00112     IFPACK_RETURN(Multiply(UseTranspose(),X,Y));
00113   }
00114 
00115   virtual int ApplyInverse(const Epetra_MultiVector& X,
00116          Epetra_MultiVector& Y) const
00117   {
00118     IFPACK_CHK_ERR(-1);
00119   }
00120 
00121   virtual int InvRowSums(Epetra_Vector& x) const
00122   {
00123     IFPACK_CHK_ERR(-1);
00124   }
00125 
00126   virtual int LeftScale(const Epetra_Vector& x)
00127   {
00128     return(A_.LeftScale(x));
00129   }
00130 
00131   virtual int InvColSums(Epetra_Vector& x) const
00132   {
00133     IFPACK_CHK_ERR(-1);;
00134   }
00135 
00136   virtual int RightScale(const Epetra_Vector& x) 
00137   {
00138     return(A_.RightScale(x));
00139   }
00140 
00141   virtual bool Filled() const
00142   {
00143     return(A_.Filled());
00144   }
00145 
00147   virtual double NormInf() const
00148   {
00149     return(-1.0);
00150   }
00151 
00153   virtual double NormOne() const
00154   {
00155     return(-1.0);
00156   }
00157 
00158   virtual int NumGlobalNonzeros() const
00159   {
00160     return(A_.NumGlobalNonzeros());
00161   }
00162 
00163   virtual int NumGlobalRows() const
00164   {
00165     return(A_.NumGlobalRows());
00166   }
00167 
00168   virtual int NumGlobalCols() const
00169   {
00170     return(A_.NumGlobalCols());
00171   }
00172 
00173   virtual int NumGlobalDiagonals() const
00174   {
00175     return(A_.NumGlobalDiagonals());
00176   }
00177 
00178   virtual int NumMyNonzeros() const
00179   {
00180     return(A_.NumMyNonzeros());
00181   }
00182 
00183   virtual int NumMyRows() const
00184   {
00185     return(A_.NumMyRows());
00186   }
00187 
00188   virtual int NumMyCols() const
00189   {
00190     return(A_.NumMyCols());
00191   }
00192 
00193   virtual int NumMyDiagonals() const
00194   {
00195     return(A_.NumMyDiagonals());
00196   }
00197 
00198   virtual bool LowerTriangular() const
00199   {
00200     return(A_.LowerTriangular());
00201   }
00202 
00203   virtual bool UpperTriangular() const
00204   {
00205     return(A_.UpperTriangular());
00206   }
00207 
00208   virtual const Epetra_Map& RowMatrixRowMap() const
00209   {
00210     return(A_.RowMatrixRowMap());
00211   }
00212 
00213   virtual const Epetra_Map& RowMatrixColMap() const
00214   {
00215     return(A_.RowMatrixColMap());
00216   }
00217 
00218   virtual const Epetra_Import* RowMatrixImporter() const
00219   {
00220     return(A_.RowMatrixImporter());
00221   }
00222 
00223   int SetUseTranspose(bool UseTranspose)
00224   {
00225     return(A_.SetUseTranspose(UseTranspose));
00226   }
00227 
00228   bool UseTranspose() const 
00229   {
00230     return(A_.UseTranspose());
00231   }
00232 
00234   bool HasNormInf() const
00235   {
00236     return(false);
00237   }
00238 
00239   const Epetra_Comm& Comm() const
00240   {
00241     return(A_.Comm());
00242   }
00243 
00244   const Epetra_Map& OperatorDomainMap() const 
00245   {
00246     return(A_.OperatorDomainMap());
00247   }
00248 
00249   const Epetra_Map& OperatorRangeMap() const 
00250   {
00251     return(A_.OperatorRangeMap());
00252   }
00253 
00254   const Epetra_BlockMap& Map() const 
00255   {
00256     return(A_.Map());
00257   }
00258 
00259   const char* Label() const{
00260     return(A_.Label());
00261   }
00262 
00263 private:
00264 
00266   Epetra_RowMatrix& A_;
00268   double AbsoluteThreshold_;
00270   double RelativeThreshold_;
00272   vector<int> pos_;
00274   vector<double> val_;
00275 
00276 };
00277 
00278 
00279 #endif /* IFPACK_DIAGONALFILTER_H */

Generated on Thu Sep 18 12:37:21 2008 for Ifpack Package Browser (Single Doxygen Collection) by doxygen 1.3.9.1