• Main Page
  • Related Pages
  • Namespaces
  • Classes
  • Files
  • File List
  • File Members

ml_Epetra_wrap_CrsGraph_as_RowMatrix.H

Go to the documentation of this file.
00001 
00011 /* ******************************************************************** */
00012 /* See the file COPYRIGHT for a complete copyright notice, contact      */
00013 /* person and disclaimer.                                               */
00014 /* ******************************************************************** */
00015 #if defined(HAVE_ML_EPETRA)
00016 
00017 #ifndef ML_EPETRA_CRSGRAPHWRAP_H
00018 #define ML_EPETRA_CRSGRAPHWRAP_H
00019 
00020 #include "Epetra_Import.h"
00021 #include "Epetra_Comm.h"
00022 #include "Epetra_SerialComm.h"
00023 #ifdef ML_MPI
00024 #include "Epetra_MpiComm.h"
00025 #endif
00026 #include "Epetra_Map.h"
00027 #include "Epetra_BlockMap.h"
00028 #include "Epetra_MultiVector.h"
00029 #include "Epetra_Operator.h"
00030 #include "Epetra_SrcDistObject.h"
00031 #include "Epetra_RowMatrix.h"
00032 class Epetra_Map;
00033 class Epetra_Comm;
00034 class Epetra_Import;
00035 class Epetra_Export;
00036 class Epetra_Vector;
00037 class Epetra_MultiVector;
00038 class Epetra_SrcDistObject;
00039 
00040 namespace ML_Epetra 
00041 {
00042 
00062 class CrsGraphWrapper: public virtual Epetra_RowMatrix 
00063 {
00064       
00065  public:
00067 
00068 
00079     CrsGraphWrapper(const Epetra_CrsGraph& graph, const Epetra_Map& dm,const Epetra_Map& rm,const Epetra_Comm& comm) : 
00080     graph_(graph),
00081     DomainMap_(dm),
00082     RangeMap_(rm),
00083     comm_(comm)
00084     {
00085       name_  = "ML_Epetra::CrsGraphWrapper";
00086       return;
00087     }
00088 
00090 
00091     virtual ~CrsGraphWrapper() {};
00092 
00094   
00096 
00098 
00106     int NumMyRowEntries(int MyRow, int & NumEntries) const
00107     {
00108       NumEntries = graph_.NumMyIndices(MyRow);
00109       return(0);
00110     }
00111 
00112 
00114     int MaxNumEntries() const
00115     {
00116       return(graph_.MaxNumIndices());
00117     }
00118 
00120 
00135     int ExtractMyRowCopy(int MyRow, int Length, int& NumEntries, double *Values, int * Indices) const
00136     {
00137       int err = graph_.ExtractMyRowCopy(MyRow,Length,NumEntries,Indices);
00138       if (!err)
00139       {
00140         int i,min;
00141         if (NumEntries<Length) min = NumEntries;
00142         else                   min = Length;
00143         for (i=0; i<min; i++) 
00144           Values[i] = 1.0;
00145       }
00146       return (err);
00147     }
00148 
00150     int ExtractDiagonalCopy(Epetra_Vector & Diagonal) const
00151     {
00152        cout << "**ERR** ML_Epetra::CrsGraphWrapper.ExtractDiagonalCopy(...) is not impl!\n";
00153        throw -1;
00154        return(-1);
00155     }
00157   
00159 
00161     int Multiply(bool TransA, const Epetra_MultiVector& X, Epetra_MultiVector& Y) const
00162     {
00163        cout << "**ERR** ML_Epetra::CrsGraphWrapper.Multiply(...) is not impl!\n";
00164        throw -1;
00165        return(-1);
00166     }
00167 
00169     int Solve(bool Upper, bool Trans, bool UnitDiagonal, const Epetra_MultiVector& X, 
00170         Epetra_MultiVector& Y) const
00171     {
00172        cout << "**ERR** ML_Epetra::CrsGraphWrapper.Solve(...) is not impl!\n";
00173        throw -1;
00174        return(-1);
00175     }
00176 
00178     int InvRowSums(Epetra_Vector& x) const
00179     {
00180        cout << "**ERR** ML_Epetra::CrsGraphWrapper.InvRowSums(...) is not impl!\n";
00181        throw -1;
00182        return(-1);
00183     }
00184 
00186     int LeftScale(const Epetra_Vector& x) 
00187     {
00188        cout << "**ERR** ML_Epetra::CrsGraphWrapper.LeftScale(...) is not impl!\n";
00189        throw -1;
00190        return(-1);
00191     }
00192 
00194     int InvColSums(Epetra_Vector& x) const
00195     {
00196        cout << "**ERR** ML_Epetra::CrsGraphWrapper.InvColSums(...) is not impl!\n";
00197        throw -1;
00198        return(-1);
00199     }
00200 
00202     int RightScale(const Epetra_Vector& x) 
00203     {
00204        cout << "**ERR** ML_Epetra::CrsGraphWrapper.RightScale(...) is not impl!\n";
00205        throw -1;
00206        return(-1);
00207     }
00209   
00211 
00213     bool Filled() const 
00214     {
00215        return(graph_.Filled());
00216     }
00217 
00219     double NormInf() const
00220     {
00221        cout << "**ERR** ML_Epetra::CrsGraphWrapper.NormInf(...) is not impl!\n";
00222        throw -1;
00223        return(-1.0);
00224     }
00225 
00227     double NormOne() const
00228     {
00229        cout << "**ERR** ML_Epetra::CrsGraphWrapper.NormOne(...) is not impl!\n";
00230        throw -1;
00231        return(-1.0);
00232     }
00233 
00235     int NumGlobalNonzeros() const {return(graph_.NumGlobalNonzeros()); }
00236 
00238     int NumGlobalRows() const {return(graph_.NumGlobalRows()); }
00239 
00241     int NumGlobalCols() const {return(graph_.NumGlobalCols()); }
00242 
00244     int NumGlobalDiagonals() const {return(graph_.NumGlobalDiagonals()); }
00245     
00247     int NumMyNonzeros() const {return(graph_.NumMyNonzeros()); }
00248 
00250     int NumMyRows() const {return(graph_.NumMyRows()); }
00251 
00253     int NumMyCols() const {return(graph_.NumMyCols()); }
00254 
00256     int NumMyDiagonals() const {return(graph_.NumMyDiagonals()); }
00257 
00259     bool LowerTriangular() const {return(graph_.LowerTriangular()); }
00260 
00262     bool UpperTriangular() const {return(graph_.UpperTriangular()); }
00263 
00265     const Epetra_Map & RowMatrixRowMap() const
00266     {
00267       return(dynamic_cast<const Epetra_Map&>(graph_.RowMap()));
00268     }
00269 
00271     const Epetra_Map & RowMatrixColMap() const 
00272     {
00273       return(dynamic_cast<const Epetra_Map &>(graph_.ColMap()));
00274     }
00275 
00277     const Epetra_Import * RowMatrixImporter() const 
00278     {
00279       return(graph_.Importer());
00280     }
00281     
00283     const Epetra_BlockMap& Map() const
00284     {
00285       return(graph_.RowMap());
00286     }
00287     
00289     int SetUseTranspose(bool UseTranspose)
00290     {
00291       usetranspose_ = UseTranspose;
00292       return(-1); //  the implementation does not support use of transpose
00293     }
00294     
00296     int Apply(const Epetra_MultiVector& X, Epetra_MultiVector& Y) const 
00297     { 
00298        cout << "ML_Epetra::CrsGraphWrapper::Apply() is not implemented\n"; throw -1;
00299        return(-1);
00300     }
00301     
00303     int ApplyInverse(const Epetra_MultiVector& X, Epetra_MultiVector& Y) const
00304     {
00305        cout << "**ERR** ML_Epetra::CrsGraphWrapper.ApplyInverse(...) is not impl!\n";
00306        throw -1;
00307        return(-1);
00308     }
00309 
00311     const char * Label() const                   {return(name_);}
00312 
00314     bool UseTranspose() const                    {return(usetranspose_);}
00315 
00317     bool HasNormInf() const                      {return(false);}
00318 
00320     const Epetra_Comm & Comm() const             {return(comm_);}
00321 
00323     const Epetra_Map & OperatorDomainMap() const {return(DomainMap_);}
00324 
00326     const Epetra_Map & OperatorRangeMap() const  {return(RangeMap_);}
00327     
00329  private:
00330     
00331     const Epetra_CrsGraph& graph_;
00332     bool                   usetranspose_;
00333     const char*            name_;
00334     Epetra_Map             DomainMap_;
00335     Epetra_Map             RangeMap_;
00336     const Epetra_Comm&     comm_;
00337 };
00338 
00339 } // namespace ML_Epetra
00340 
00341 #endif // defined(HAVE_ML_EPETRA)
00342 #endif // ML_EPETRA_CRSGRAPHWRAP_H