IFPACK  Development
 All Classes Files Functions Variables Enumerations Friends Pages
Ifpack_SubdomainFilter.h
1 //@HEADER
2 // ************************************************************************
3 //
4 // Ifpack_SubdomainFilter
5 // Author: Radu Popescu <radu.popescu@epfl.ch>
6 // Copyright 2011 EPFL - CMCS
7 //
8 // Redistribution and use in source and binary forms, with or without
9 // modification, are permitted provided that the following conditions are
10 // met:
11 //
12 // 1. Redistributions of source code must retain the above copyright
13 // notice, this list of conditions and the following disclaimer.
14 //
15 // 2. Redistributions in binary form must reproduce the above copyright
16 // notice, this list of conditions and the following disclaimer in the
17 // documentation and/or other materials provided with the distribution.
18 //
19 // 3. Neither the name of the copyright holder nor the names of the
20 // contributors may be used to endorse or promote products derived from
21 // this software without specific prior written permission.
22 //
23 // THIS SOFTWARE IS PROVIDED BY EPFL - CMCS "AS IS" AND ANY EXPRESS OR
24 // IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
25 // WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
26 // ARE DISCLAIMED. IN NO EVENT SHALL EPFL - CMCS OR THE CONTRIBUTORS
27 // BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
28 // OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
29 // OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
30 // BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
31 // WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
32 // OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
33 // EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34 //
35 // ************************************************************************
36 //@HEADER
37 
38 #ifndef IFPACK_SUBDOMAINFILTER_H
39 #define IFPACK_SUBDOMAINFILTER_H
40 
41 #ifdef IFPACK_SUBCOMM_CODE
42 
43 #include "Ifpack_ConfigDefs.h"
44 #ifdef HAVE_MPI
45 #include "Epetra_MpiComm.h"
46 #else
47 #include "Epetra_SerialComm.h"
48 #endif
49 #include "Epetra_RowMatrix.h"
50 #include "Epetra_CrsMatrix.h"
51 #include "Epetra_IntVector.h"
52 #include "Teuchos_RCP.hpp"
53 #include "Ifpack_OverlappingRowMatrix.h"
54 
55 class Epetra_Map;
56 class Epetra_MultiVector;
57 class Epetra_Vector;
58 class Epetra_Import;
59 class Epetra_BlockMap;
60 
62 
77 class Ifpack_SubdomainFilter : public virtual Epetra_RowMatrix {
78 
79 public:
81  Ifpack_SubdomainFilter(const Teuchos::RCP<const Epetra_RowMatrix>& Matrix, int subdomainId);
83 
85 
86  ~Ifpack_SubdomainFilter();
89 
91 
93 
101  virtual int NumMyRowEntries(int MyRow, int & NumEntries) const
102  {
103  NumEntries = NumEntries_[MyRow];
104  return(0);
105  }
106 
108  virtual int MaxNumEntries() const
109  {
110  return(MaxNumEntries_);
111  }
112 
114 
128  virtual inline int ExtractMyRowCopy(int MyRow, int Length, int & NumEntries, double *Values, int * Indices) const;
129 
131 
137  virtual int ExtractDiagonalCopy(Epetra_Vector & Diagonal) const;
139 
141 
143 
153  virtual int Multiply(bool TransA, const Epetra_MultiVector& X, Epetra_MultiVector& Y) const
154  {
155  if (TransA == true) {
156  IFPACK_CHK_ERR(-1);
157  }
158 
159  IFPACK_CHK_ERR(Apply(X,Y));
160  return(0);
161  }
162 
164  virtual int Solve(bool Upper, bool Trans, bool UnitDiagonal, const Epetra_MultiVector& X,
165  Epetra_MultiVector& Y) const
166  {
167  IFPACK_RETURN(-1); // not implemented
168  }
169 
170  virtual int Apply(const Epetra_MultiVector& X,
171  Epetra_MultiVector& Y) const;
172 
173  virtual int ApplyInverse(const Epetra_MultiVector& X,
174  Epetra_MultiVector& Y) const;
176  virtual int InvRowSums(Epetra_Vector& x) const
177  {
178  IFPACK_RETURN(-1); // not implemented
179  }
180 
182  virtual int LeftScale(const Epetra_Vector& x)
183  {
184  IFPACK_RETURN(-1); // not implemented
185  }
186 
188  virtual int InvColSums(Epetra_Vector& x) const
189  {
190  IFPACK_RETURN(-1); // not implemented
191  }
192 
193 
195  virtual int RightScale(const Epetra_Vector& x)
196  {
197  IFPACK_RETURN(-1); // not implemented
198  }
199 
201 
203 
205  virtual bool Filled() const
206  {
207  return true;
208  }
209 
211  /* Returns the quantity \f$ \| A \|_\infty\f$ such that
212  \f[\| A \|_\infty = \max_{1\lei\len} \sum_{i=1}^m |a_{ij}| \f].
213  */
214  virtual double NormInf() const
215  {
216  return(-1.0);
217  }
218 
220  /* Returns the quantity \f$ \| A \|_1\f$ such that
221  \f[\| A \|_1= \max_{1\lej\len} \sum_{j=1}^n |a_{ij}| \f].
222  */
223  virtual double NormOne() const
224  {
225  IFPACK_RETURN(-1.0);
226  }
227 
228 #ifndef EPETRA_NO_32BIT_GLOBAL_INDICES
229  virtual int NumGlobalNonzeros() const
231  {
232  return(NumGlobalNonzeros_);
233  }
234 
236  virtual int NumGlobalRows() const
237  {;
238 
239  return(NumGlobalRows_);
240  }
241 
243  virtual int NumGlobalCols() const
244  {
245  return(NumGlobalCols_);
246  }
247 
249  virtual int NumGlobalDiagonals() const
250  {
251  return(NumGlobalRows_);
252  }
253 #endif
254 
256  virtual long long NumGlobalNonzeros64() const
257  {
258  return(NumGlobalNonzeros_);
259  }
260 
262  virtual long long NumGlobalRows64() const
263  {
264  return(NumGlobalRows_);
265  }
266 
268  virtual long long NumGlobalCols64() const
269  {
270  return(NumGlobalRows_);
271  }
272 
274  virtual long long NumGlobalDiagonals64() const
275  {
276  return(NumGlobalRows_);
277  }
278 
280  virtual int NumMyNonzeros() const
281  {
282  return(NumMyNonzeros_);
283  }
284 
286  virtual int NumMyRows() const
287  {
288  return(NumMyRows_);
289  }
290 
292  virtual int NumMyCols() const
293  {
294  return(NumMyCols_);
295  }
296 
298  virtual int NumMyDiagonals() const
299  {
300  return(NumMyRows_);
301  }
302 
304  virtual bool LowerTriangular() const
305  {
306  return(Matrix_->LowerTriangular());
307  }
308 
310  virtual bool UpperTriangular() const
311  {
312  return(Matrix_->UpperTriangular());
313  }
314 
316  virtual const Epetra_Map & RowMatrixRowMap() const
317  {
318  return(*Map_);
319  }
320 
322  virtual const Epetra_Map & RowMatrixColMap() const
323  {
324  return(*colMap_);
325  }
326 
328  virtual const Epetra_Import * RowMatrixImporter() const
329  {
330  return(&*Importer_);
331  }
333 
334  virtual const Epetra_Import* Importer() const {return(&*Importer_);}
335 
336  virtual const Epetra_Export* Exporter() const {return(&*Exporter_);}
337 
338  // following functions are required to derive Epetra_RowMatrix objects.
339 
341  int SetOwnership(bool ownership)
342  {
343  IFPACK_RETURN(-1);
344  }
345 
347  int SetUseTranspose(bool UseTranspose_in)
348  {
349  UseTranspose_ = UseTranspose_in;
350  return(0);
351  }
352 
354  bool UseTranspose() const
355  {
356  return(UseTranspose_);
357  }
358 
360  bool HasNormInf() const
361  {
362  return(false);
363  }
364 
366  const Epetra_Comm & Comm() const
367  {
368  return(*SubComm_);
369  }
370 
372  const Epetra_Map & OperatorDomainMap() const
373  {
374  return(*Map_);
375  }
376 
378  const Epetra_Map & OperatorRangeMap() const
379  {
380  return(*Map_);
381  }
383 
384 const Epetra_BlockMap& Map() const;
385 
386 const char* Label() const{
387  return(Label_);
388 };
389 
390 private:
391  void UpdateImportVector(int NumVectors) const;
392  void UpdateExportVector(int NumVectors) const;
393 
395  Teuchos::RCP<const Epetra_RowMatrix> Matrix_;
396  const Ifpack_OverlappingRowMatrix* ovA_;
397 #ifdef HAVE_MPI
398  Teuchos::RCP<Epetra_MpiComm> SubComm_;
400  MPI_Comm subdomainMPIComm_;
401 #else
402  Teuchos::RCP<Epetra_SerialComm> SubComm_;
404 #endif
405  Teuchos::RCP<Epetra_Map> Map_;
408  Teuchos::RCP<Epetra_Map> colMap_;
410  int NumMyRows_;
412  int NumMyCols_;
414  int NumMyNonzeros_;
416  int NumGlobalRows_;
418  int NumGlobalCols_;
420  int NumGlobalNonzeros_;
422  int MaxNumEntries_;
424  int MaxNumEntriesA_;
426  std::vector<int> NumEntries_;
428  mutable std::vector<int> Indices_;
430  mutable std::vector<double> Values_;
432  bool UseTranspose_;
434  char Label_[80];
435  Teuchos::RCP<Epetra_Vector> Diagonal_;
436  double NormOne_;
437  double NormInf_;
438 
440  int* Ac_LIDMap_;
441  int* Bc_LIDMap_;
442  int* Ar_LIDMap_;
443  int* Br_LIDMap_;
444 
446  const Epetra_CrsMatrix* Acrs_;
447 
448  int NumMyRowsA_;
449  int NumMyColsA_;
450  int NumMyRowsB_;
451 
452  //mutable Teuchos::RCP<Epetra_MultiVector> ImportVector_;
453  //mutable Teuchos::RCP<Epetra_MultiVector> ExportVector_;
454  mutable Epetra_MultiVector* ExportVector_;
455  mutable Epetra_MultiVector* ImportVector_;
456  Teuchos::RCP<Epetra_Import> Importer_;
457  Teuchos::RCP<Epetra_Export> Exporter_;
458 
459 };
460 #endif //ifdef IFPACK_SUBCOMM_CODE
461 #endif /* IFPACK_SUBDOMAINFILTER_H */
Ifpack_OverlappingRowMatrix: matrix with ghost rows, based on Epetra_RowMatrix.