|
IFPACK Development
|
00001 //@HEADER 00002 // ************************************************************************ 00003 // 00004 // Ifpack_SubdomainFilter 00005 // Author: Radu Popescu <radu.popescu@epfl.ch> 00006 // Copyright 2011 EPFL - CMCS 00007 // 00008 // Redistribution and use in source and binary forms, with or without 00009 // modification, are permitted provided that the following conditions are 00010 // met: 00011 // 00012 // 1. Redistributions of source code must retain the above copyright 00013 // notice, this list of conditions and the following disclaimer. 00014 // 00015 // 2. Redistributions in binary form must reproduce the above copyright 00016 // notice, this list of conditions and the following disclaimer in the 00017 // documentation and/or other materials provided with the distribution. 00018 // 00019 // 3. Neither the name of the copyright holder nor the names of the 00020 // contributors may be used to endorse or promote products derived from 00021 // this software without specific prior written permission. 00022 // 00023 // THIS SOFTWARE IS PROVIDED BY EPFL - CMCS "AS IS" AND ANY EXPRESS OR 00024 // IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 00025 // WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 00026 // ARE DISCLAIMED. IN NO EVENT SHALL EPFL - CMCS OR THE CONTRIBUTORS 00027 // BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, 00028 // OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT 00029 // OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR 00030 // BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 00031 // WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE 00032 // OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, 00033 // EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 00034 // 00035 // ************************************************************************ 00036 //@HEADER 00037 00038 #ifndef IFPACK_SUBDOMAINFILTER_H 00039 #define IFPACK_SUBDOMAINFILTER_H 00040 00041 #ifdef IFPACK_SUBCOMM_CODE 00042 00043 #include "Ifpack_ConfigDefs.h" 00044 #ifdef HAVE_MPI 00045 #include "Epetra_MpiComm.h" 00046 #else 00047 #include "Epetra_SerialComm.h" 00048 #endif 00049 #include "Epetra_RowMatrix.h" 00050 #include "Epetra_CrsMatrix.h" 00051 #include "Epetra_IntVector.h" 00052 #include "Teuchos_RCP.hpp" 00053 #include "Ifpack_OverlappingRowMatrix.h" 00054 00055 class Epetra_Map; 00056 class Epetra_MultiVector; 00057 class Epetra_Vector; 00058 class Epetra_Import; 00059 class Epetra_BlockMap; 00060 00062 00077 class Ifpack_SubdomainFilter : public virtual Epetra_RowMatrix { 00078 00079 public: 00081 00082 Ifpack_SubdomainFilter(const Teuchos::RCP<const Epetra_RowMatrix>& Matrix, int subdomainId); 00083 00085 00086 00087 ~Ifpack_SubdomainFilter(); 00089 00091 00093 00101 virtual int NumMyRowEntries(int MyRow, int & NumEntries) const 00102 { 00103 NumEntries = NumEntries_[MyRow]; 00104 return(0); 00105 } 00106 00108 virtual int MaxNumEntries() const 00109 { 00110 return(MaxNumEntries_); 00111 } 00112 00114 00128 virtual inline int ExtractMyRowCopy(int MyRow, int Length, int & NumEntries, double *Values, int * Indices) const; 00129 00131 00137 virtual int ExtractDiagonalCopy(Epetra_Vector & Diagonal) const; 00139 00141 00143 00153 virtual int Multiply(bool TransA, const Epetra_MultiVector& X, Epetra_MultiVector& Y) const 00154 { 00155 if (TransA == true) { 00156 IFPACK_CHK_ERR(-1); 00157 } 00158 00159 IFPACK_CHK_ERR(Apply(X,Y)); 00160 return(0); 00161 } 00162 00164 virtual int Solve(bool Upper, bool Trans, bool UnitDiagonal, const Epetra_MultiVector& X, 00165 Epetra_MultiVector& Y) const 00166 { 00167 IFPACK_RETURN(-1); // not implemented 00168 } 00169 00170 virtual int Apply(const Epetra_MultiVector& X, 00171 Epetra_MultiVector& Y) const; 00172 00173 virtual int ApplyInverse(const Epetra_MultiVector& X, 00174 Epetra_MultiVector& Y) const; 00176 virtual int InvRowSums(Epetra_Vector& x) const 00177 { 00178 IFPACK_RETURN(-1); // not implemented 00179 } 00180 00182 virtual int LeftScale(const Epetra_Vector& x) 00183 { 00184 IFPACK_RETURN(-1); // not implemented 00185 } 00186 00188 virtual int InvColSums(Epetra_Vector& x) const 00189 { 00190 IFPACK_RETURN(-1); // not implemented 00191 } 00192 00193 00195 virtual int RightScale(const Epetra_Vector& x) 00196 { 00197 IFPACK_RETURN(-1); // not implemented 00198 } 00199 00201 00203 00205 virtual bool Filled() const 00206 { 00207 return true; 00208 } 00209 00211 /* Returns the quantity \f$ \| A \|_\infty\f$ such that 00212 \f[\| A \|_\infty = \max_{1\lei\len} \sum_{i=1}^m |a_{ij}| \f]. 00213 */ 00214 virtual double NormInf() const 00215 { 00216 return(-1.0); 00217 } 00218 00220 /* Returns the quantity \f$ \| A \|_1\f$ such that 00221 \f[\| A \|_1= \max_{1\lej\len} \sum_{j=1}^n |a_{ij}| \f]. 00222 */ 00223 virtual double NormOne() const 00224 { 00225 IFPACK_RETURN(-1.0); 00226 } 00227 00229 virtual int NumGlobalNonzeros() const 00230 { 00231 return(NumGlobalNonzeros_); 00232 } 00233 00235 virtual int NumGlobalRows() const 00236 {; 00237 00238 return(NumGlobalRows_); 00239 } 00240 00242 virtual int NumGlobalCols() const 00243 { 00244 return(NumGlobalCols_); 00245 } 00246 00248 virtual int NumGlobalDiagonals() const 00249 { 00250 return(NumGlobalRows_); 00251 } 00252 00254 virtual int NumMyNonzeros() const 00255 { 00256 return(NumMyNonzeros_); 00257 } 00258 00260 virtual int NumMyRows() const 00261 { 00262 return(NumMyRows_); 00263 } 00264 00266 virtual int NumMyCols() const 00267 { 00268 return(NumMyCols_); 00269 } 00270 00272 virtual int NumMyDiagonals() const 00273 { 00274 return(NumMyRows_); 00275 } 00276 00278 virtual bool LowerTriangular() const 00279 { 00280 return(Matrix_->LowerTriangular()); 00281 } 00282 00284 virtual bool UpperTriangular() const 00285 { 00286 return(Matrix_->UpperTriangular()); 00287 } 00288 00290 virtual const Epetra_Map & RowMatrixRowMap() const 00291 { 00292 return(*Map_); 00293 } 00294 00296 virtual const Epetra_Map & RowMatrixColMap() const 00297 { 00298 return(*colMap_); 00299 } 00300 00302 virtual const Epetra_Import * RowMatrixImporter() const 00303 { 00304 return(&*Importer_); 00305 } 00307 00308 virtual const Epetra_Import* Importer() const {return(&*Importer_);} 00309 00310 virtual const Epetra_Export* Exporter() const {return(&*Exporter_);} 00311 00312 // following functions are required to derive Epetra_RowMatrix objects. 00313 00315 int SetOwnership(bool ownership) 00316 { 00317 IFPACK_RETURN(-1); 00318 } 00319 00321 int SetUseTranspose(bool UseTranspose_in) 00322 { 00323 UseTranspose_ = UseTranspose_in; 00324 return(0); 00325 } 00326 00328 bool UseTranspose() const 00329 { 00330 return(UseTranspose_); 00331 } 00332 00334 bool HasNormInf() const 00335 { 00336 return(false); 00337 } 00338 00340 const Epetra_Comm & Comm() const 00341 { 00342 return(*SubComm_); 00343 } 00344 00346 const Epetra_Map & OperatorDomainMap() const 00347 { 00348 return(*Map_); 00349 } 00350 00352 const Epetra_Map & OperatorRangeMap() const 00353 { 00354 return(*Map_); 00355 } 00357 00358 const Epetra_BlockMap& Map() const; 00359 00360 const char* Label() const{ 00361 return(Label_); 00362 }; 00363 00364 private: 00365 void UpdateImportVector(int NumVectors) const; 00366 void UpdateExportVector(int NumVectors) const; 00367 00369 Teuchos::RCP<const Epetra_RowMatrix> Matrix_; 00370 const Ifpack_OverlappingRowMatrix* ovA_; 00371 #ifdef HAVE_MPI 00372 00373 Teuchos::RCP<Epetra_MpiComm> SubComm_; 00374 MPI_Comm subdomainMPIComm_; 00375 #else 00376 00377 Teuchos::RCP<Epetra_SerialComm> SubComm_; 00378 #endif 00379 00380 Teuchos::RCP<Epetra_Map> Map_; 00382 Teuchos::RCP<Epetra_Map> colMap_; 00384 int NumMyRows_; 00386 int NumMyCols_; 00388 int NumMyNonzeros_; 00390 int NumGlobalRows_; 00392 int NumGlobalCols_; 00394 int NumGlobalNonzeros_; 00396 int MaxNumEntries_; 00398 int MaxNumEntriesA_; 00400 std::vector<int> NumEntries_; 00402 mutable std::vector<int> Indices_; 00404 mutable std::vector<double> Values_; 00406 bool UseTranspose_; 00408 char Label_[80]; 00409 Teuchos::RCP<Epetra_Vector> Diagonal_; 00410 double NormOne_; 00411 double NormInf_; 00412 00414 int* Ac_LIDMap_; 00415 int* Bc_LIDMap_; 00416 int* Ar_LIDMap_; 00417 int* Br_LIDMap_; 00418 00420 const Epetra_CrsMatrix* Acrs_; 00421 00422 int NumMyRowsA_; 00423 int NumMyColsA_; 00424 int NumMyRowsB_; 00425 00426 //mutable Teuchos::RCP<Epetra_MultiVector> ImportVector_; 00427 //mutable Teuchos::RCP<Epetra_MultiVector> ExportVector_; 00428 mutable Epetra_MultiVector* ExportVector_; 00429 mutable Epetra_MultiVector* ImportVector_; 00430 Teuchos::RCP<Epetra_Import> Importer_; 00431 Teuchos::RCP<Epetra_Export> Exporter_; 00432 00433 }; 00434 #endif //ifdef IFPACK_SUBCOMM_CODE 00435 #endif /* IFPACK_SUBDOMAINFILTER_H */
1.7.4