|
EpetraExt
Development
|
00001 //@HEADER 00002 // *********************************************************************** 00003 // 00004 // EpetraExt: Epetra Extended - Linear Algebra Services Package 00005 // Copyright (2011) Sandia Corporation 00006 // 00007 // Under the terms of Contract DE-AC04-94AL85000 with Sandia Corporation, 00008 // the U.S. Government retains certain rights in this software. 00009 // 00010 // Redistribution and use in source and binary forms, with or without 00011 // modification, are permitted provided that the following conditions are 00012 // met: 00013 // 00014 // 1. Redistributions of source code must retain the above copyright 00015 // notice, this list of conditions and the following disclaimer. 00016 // 00017 // 2. Redistributions in binary form must reproduce the above copyright 00018 // notice, this list of conditions and the following disclaimer in the 00019 // documentation and/or other materials provided with the distribution. 00020 // 00021 // 3. Neither the name of the Corporation nor the names of the 00022 // contributors may be used to endorse or promote products derived from 00023 // this software without specific prior written permission. 00024 // 00025 // THIS SOFTWARE IS PROVIDED BY SANDIA CORPORATION "AS IS" AND ANY 00026 // EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 00027 // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 00028 // PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL SANDIA CORPORATION OR THE 00029 // CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 00030 // EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 00031 // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 00032 // PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 00033 // LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 00034 // NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 00035 // SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 00036 // 00037 // Questions? Contact Michael A. Heroux (maherou@sandia.gov) 00038 // 00039 // *********************************************************************** 00040 //@HEADER 00041 00042 /*############################################################################# 00043 # CVS File Information 00044 # Current revision: $Revision$ 00045 # Last modified: $Date$ 00046 # Modified by: $Author$ 00047 #############################################################################*/ 00048 00049 #ifndef _EPETRAEXT_PETSCAIJMATRIX_H_ 00050 #define _EPETRAEXT_PETSCAIJMATRIX_H_ 00051 00052 #include "Epetra_Object.h" 00053 #include "Epetra_CompObject.h" 00054 #include "Epetra_RowMatrix.h" 00055 #include "Epetra_Map.h" 00056 #ifdef HAVE_MPI 00057 #include "Epetra_MpiComm.h" 00058 #else 00059 #include "Epetra_SerialComm.h" 00060 #endif 00061 extern "C" { 00062 //Petsc headers. 00063 //Note: Petsc internally hard-codes paths to headers, relative to the PETSC home 00064 // directory. This means that --with-incdirs must contain the full path(s) 00065 // to the header below plus the PETSc home directory. 00066 #include "src/mat/impls/aij/mpi/mpiaij.h" 00067 } 00068 00069 class Epetra_Import; 00070 class Epetra_Export; 00071 class Epetra_Vector; 00072 class Epetra_MultiVector; 00073 00075 00083 class Epetra_PETScAIJMatrix: public Epetra_Object, public Epetra_CompObject, public virtual Epetra_RowMatrix { 00084 00085 public: 00086 00088 00089 00090 00095 Epetra_PETScAIJMatrix(Mat Amat); 00096 00098 virtual ~Epetra_PETScAIJMatrix(); 00100 00102 00103 00105 00119 int ExtractMyRowCopy(int MyRow, int Length, int & NumEntries, double *Values, int * Indices) const; 00120 00122 00128 int ExtractDiagonalCopy(Epetra_Vector & Diagonal) const; 00130 00132 00133 00135 00145 int Multiply(bool TransA, const Epetra_MultiVector& X, Epetra_MultiVector& Y) const; 00146 00148 00162 int Solve(bool Upper, bool Trans, bool UnitDiagonal, const Epetra_MultiVector& X, Epetra_MultiVector& Y) const; 00163 00165 00175 int InvRowSums(Epetra_Vector& x) const; 00176 00178 00185 int LeftScale(const Epetra_Vector& x); 00186 00188 00198 int InvColSums(Epetra_Vector& x) const; 00199 00201 00208 int RightScale(const Epetra_Vector& x); 00210 00212 00213 00214 00216 bool Filled() const {return(true);}; 00217 00219 bool LowerTriangular() const {return(false);}; 00220 00222 bool UpperTriangular() const {return(false);}; 00223 00225 00227 00228 00230 Mat Amat() const {return(Amat_);}; 00231 00233 /* Returns the quantity \f$ \| A \|_\infty\f$ such that 00234 \f[\| A \|_\infty = \max_{1\lei\lem} \sum_{j=1}^n |a_{ij}| \f]. 00235 */ 00236 double NormInf() const; 00237 00239 /* Returns the quantity \f$ \| A \|_1\f$ such that 00240 \f[\| A \|_1= \max_{1\lej\len} \sum_{i=1}^m |a_{ij}| \f]. 00241 */ 00242 double NormOne() const; 00243 00244 #ifndef EPETRA_NO_32BIT_GLOBAL_INDICES 00245 00246 int NumGlobalNonzeros() const {return(NumGlobalNonzeros_);}; 00247 00249 int NumGlobalRows() const {return(OperatorRangeMap().NumGlobalPoints());}; 00250 00252 int NumGlobalCols() const {return(OperatorDomainMap().NumGlobalPoints());}; 00253 00255 int NumGlobalDiagonals() const{return(OperatorDomainMap().NumGlobalPoints());}; 00256 #endif 00257 00258 long long NumGlobalNonzeros64() const {return(NumGlobalNonzeros_);}; 00259 00261 long long NumGlobalRows64() const {return(OperatorRangeMap().NumGlobalPoints64());}; 00262 00264 long long NumGlobalCols64() const {return(OperatorDomainMap().NumGlobalPoints64());}; 00265 00267 long long NumGlobalDiagonals64() const{return(OperatorDomainMap().NumGlobalPoints64());}; 00268 00270 int NumMyNonzeros() const {return(NumMyNonzeros_);}; 00271 00273 int NumMyRows() const {return(OperatorRangeMap().NumMyPoints());}; 00274 00276 int NumMyCols() const {return(RowMatrixColMap().NumMyPoints());}; 00277 00279 int NumMyDiagonals() const {return(OperatorRangeMap().NumMyPoints());}; 00280 00282 const Epetra_Map & OperatorDomainMap() const {return(*DomainMap_);}; 00283 00285 const Epetra_Map & OperatorRangeMap() const {return(*DomainMap_);}; 00286 00288 const Epetra_BlockMap& Map() const {return(RowMatrixRowMap());} 00289 00291 const Epetra_Map & RowMatrixRowMap() const {return(OperatorRangeMap());}; 00292 00294 const Epetra_Map & RowMatrixColMap() const {return(*ColMap_);}; 00295 00297 virtual const Epetra_Import * RowMatrixImporter() const {return(Importer_);}; 00298 00300 const Epetra_Comm & Comm() const {return(*Comm_);}; 00302 00303 00305 00306 00308 virtual void Print(std::ostream & os) const; 00310 00312 00313 00315 const char * Label() const {return(Epetra_Object::Label());}; 00316 00318 00327 int SetUseTranspose(bool UseTranspose) 00328 {(void)UseTranspose; return(-1);} 00329 00331 00339 int Apply(const Epetra_MultiVector& X, Epetra_MultiVector& Y) const { 00340 return(Epetra_PETScAIJMatrix::Multiply(Epetra_PETScAIJMatrix::UseTranspose(), X, Y));}; 00341 00343 00356 int ApplyInverse(const Epetra_MultiVector& X, 00357 Epetra_MultiVector& Y) const 00358 {(void)X; (void)Y; return(-1);} 00359 00361 virtual bool HasNormInf() const {return(true);} 00362 00364 virtual bool UseTranspose() const {return(false);} 00365 00367 00368 00369 00371 00380 int NumMyRowEntries(int MyRow, int & NumEntries) const; 00381 00383 int MaxNumEntries() const; 00385 00386 private: 00387 00388 int GetRow(int Row) const; 00389 Mat Amat_; //general PETSc matrix type 00390 mutable double * Values_; 00391 mutable int * Indices_; 00392 mutable int MaxNumEntries_; 00393 00394 #ifdef HAVE_MPI 00395 Epetra_MpiComm * Comm_; 00396 #else 00397 Epetra_SerialComm * Comm_; 00398 #endif 00399 Epetra_Map * DomainMap_; 00400 Epetra_Map * ColMap_; 00401 Epetra_Import * Importer_; 00402 mutable Epetra_MultiVector * ImportVector_; 00403 00404 double NumGlobalNonzeros_; 00405 int NumMyNonzeros_; 00406 int NumMyRows_; 00407 int NumGlobalRows_; 00408 int NumMyCols_; 00409 int PetscRowStart_; 00410 int PetscRowEnd_; 00411 enum petscMatrixType {PETSC_SEQ_AIJ, PETSC_MPI_AIJ}; 00412 const MatType MatType_; //really const char* 00413 mutable double NormInf_; 00414 mutable double NormOne_; 00415 00416 00418 //FIXME we need a copy ctor 00419 //Epetra_PETScAIJMatrix(const Epetra_PETScAIJMatrix & Matrix) {(void)Matrix;} 00420 }; 00421 #endif /* _EPETRAEXT_PETSCAIJMATRIX_H_ */
1.7.6.1