|
EpetraExt Development
|
00001 //@HEADER 00002 // *********************************************************************** 00003 // 00004 // EpetraExt: Epetra Extended - Linear Algebra Services Package 00005 // Copyright (2001) 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 # CVS File Information 00031 # Current revision: $Revision$ 00032 # Last modified: $Date$ 00033 # Modified by: $Author$ 00034 #############################################################################*/ 00035 00036 #ifndef _EPETRAEXT_PETSCAIJMATRIX_H_ 00037 #define _EPETRAEXT_PETSCAIJMATRIX_H_ 00038 00039 #include "Epetra_Object.h" 00040 #include "Epetra_CompObject.h" 00041 #include "Epetra_RowMatrix.h" 00042 #include "Epetra_Map.h" 00043 #ifdef HAVE_MPI 00044 #include "Epetra_MpiComm.h" 00045 #else 00046 #include "Epetra_SerialComm.h" 00047 #endif 00048 extern "C" { 00049 //Petsc headers. 00050 //Note: Petsc internally hard-codes paths to headers, relative to the PETSC home 00051 // directory. This means that --with-incdirs must contain the full path(s) 00052 // to the header below plus the PETSc home directory. 00053 #include "src/mat/impls/aij/mpi/mpiaij.h" 00054 } 00055 00056 class Epetra_Import; 00057 class Epetra_Export; 00058 class Epetra_Vector; 00059 class Epetra_MultiVector; 00060 00062 00070 class Epetra_PETScAIJMatrix: public Epetra_Object, public Epetra_CompObject, public virtual Epetra_RowMatrix { 00071 00072 public: 00073 00075 00076 00077 00082 Epetra_PETScAIJMatrix(Mat Amat); 00083 00085 virtual ~Epetra_PETScAIJMatrix(); 00087 00089 00090 00092 00106 int ExtractMyRowCopy(int MyRow, int Length, int & NumEntries, double *Values, int * Indices) const; 00107 00109 00115 int ExtractDiagonalCopy(Epetra_Vector & Diagonal) const; 00117 00119 00120 00122 00132 int Multiply(bool TransA, const Epetra_MultiVector& X, Epetra_MultiVector& Y) const; 00133 00135 00149 int Solve(bool Upper, bool Trans, bool UnitDiagonal, const Epetra_MultiVector& X, Epetra_MultiVector& Y) const; 00150 00152 00162 int InvRowSums(Epetra_Vector& x) const; 00163 00165 00172 int LeftScale(const Epetra_Vector& x); 00173 00175 00185 int InvColSums(Epetra_Vector& x) const; 00186 00188 00195 int RightScale(const Epetra_Vector& x); 00197 00199 00200 00201 00203 bool Filled() const {return(true);}; 00204 00206 bool LowerTriangular() const {return(false);}; 00207 00209 bool UpperTriangular() const {return(false);}; 00210 00212 00214 00215 00217 Mat Amat() const {return(Amat_);}; 00218 00220 /* Returns the quantity \f$ \| A \|_\infty\f$ such that 00221 \f[\| A \|_\infty = \max_{1\lei\lem} \sum_{j=1}^n |a_{ij}| \f]. 00222 */ 00223 double NormInf() const; 00224 00226 /* Returns the quantity \f$ \| A \|_1\f$ such that 00227 \f[\| A \|_1= \max_{1\lej\len} \sum_{i=1}^m |a_{ij}| \f]. 00228 */ 00229 double NormOne() const; 00230 00232 int NumGlobalNonzeros() const {return(NumGlobalNonzeros_);}; 00233 00235 int NumGlobalRows() const {return(OperatorRangeMap().NumGlobalPoints());}; 00236 00238 int NumGlobalCols() const {return(OperatorDomainMap().NumGlobalPoints());}; 00239 00241 int NumGlobalDiagonals() const{return(OperatorDomainMap().NumGlobalPoints());}; 00242 00244 int NumMyNonzeros() const {return(NumMyNonzeros_);}; 00245 00247 int NumMyRows() const {return(OperatorRangeMap().NumMyPoints());}; 00248 00250 int NumMyCols() const {return(RowMatrixColMap().NumMyPoints());}; 00251 00253 int NumMyDiagonals() const {return(OperatorRangeMap().NumMyPoints());}; 00254 00256 const Epetra_Map & OperatorDomainMap() const {return(*DomainMap_);}; 00257 00259 const Epetra_Map & OperatorRangeMap() const {return(*DomainMap_);}; 00260 00262 const Epetra_BlockMap& Map() const {return(RowMatrixRowMap());} 00263 00265 const Epetra_Map & RowMatrixRowMap() const {return(OperatorRangeMap());}; 00266 00268 const Epetra_Map & RowMatrixColMap() const {return(*ColMap_);}; 00269 00271 virtual const Epetra_Import * RowMatrixImporter() const {return(Importer_);}; 00272 00274 const Epetra_Comm & Comm() const {return(*Comm_);}; 00276 00277 00279 00280 00282 virtual void Print(ostream & os) const; 00284 00286 00287 00289 const char * Label() const {return(Epetra_Object::Label());}; 00290 00292 00301 int SetUseTranspose(bool UseTranspose) 00302 {(void)UseTranspose; return(-1);} 00303 00305 00313 int Apply(const Epetra_MultiVector& X, Epetra_MultiVector& Y) const { 00314 return(Epetra_PETScAIJMatrix::Multiply(Epetra_PETScAIJMatrix::UseTranspose(), X, Y));}; 00315 00317 00330 int ApplyInverse(const Epetra_MultiVector& X, 00331 Epetra_MultiVector& Y) const 00332 {(void)X; (void)Y; return(-1);} 00333 00335 virtual bool HasNormInf() const {return(true);} 00336 00338 virtual bool UseTranspose() const {return(false);} 00339 00341 00342 00343 00345 00354 int NumMyRowEntries(int MyRow, int & NumEntries) const; 00355 00357 int MaxNumEntries() const; 00359 00360 private: 00361 00362 int GetRow(int Row) const; 00363 Mat Amat_; //general PETSc matrix type 00364 mutable double * Values_; 00365 mutable int * Indices_; 00366 mutable int MaxNumEntries_; 00367 00368 #ifdef HAVE_MPI 00369 Epetra_MpiComm * Comm_; 00370 #else 00371 Epetra_SerialComm * Comm_; 00372 #endif 00373 Epetra_Map * DomainMap_; 00374 Epetra_Map * ColMap_; 00375 Epetra_Import * Importer_; 00376 mutable Epetra_MultiVector * ImportVector_; 00377 00378 double NumGlobalNonzeros_; 00379 int NumMyNonzeros_; 00380 int NumMyRows_; 00381 int NumGlobalRows_; 00382 int NumMyCols_; 00383 int PetscRowStart_; 00384 int PetscRowEnd_; 00385 enum petscMatrixType {PETSC_SEQ_AIJ, PETSC_MPI_AIJ}; 00386 const MatType MatType_; //really const char* 00387 mutable double NormInf_; 00388 mutable double NormOne_; 00389 00390 00392 //FIXME we need a copy ctor 00393 //Epetra_PETScAIJMatrix(const Epetra_PETScAIJMatrix & Matrix) {(void)Matrix;} 00394 }; 00395 #endif /* _EPETRAEXT_PETSCAIJMATRIX_H_ */
1.7.4