Ifpack Package Browser (Single Doxygen Collection)  Development
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Ifpack_SubdomainFilter.h
Go to the documentation of this file.
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 #if defined(Ifpack_SHOW_DEPRECATED_WARNINGS)
42 #ifdef __GNUC__
43 #warning "The Ifpack package is deprecated"
44 #endif
45 #endif
46 
47 #include "Ifpack_ConfigDefs.h"
48 
49 #ifdef HAVE_IFPACK_PARALLEL_SUBDOMAIN_SOLVERS
50 
51 #ifdef HAVE_MPI
52 #include "Epetra_MpiComm.h"
53 #else
54 #include "Epetra_SerialComm.h"
55 #endif
56 #include "Epetra_RowMatrix.h"
57 #include "Epetra_CrsMatrix.h"
58 #include "Epetra_IntVector.h"
59 #include "Teuchos_RCP.hpp"
61 
62 class Epetra_Map;
63 class Epetra_MultiVector;
64 class Epetra_Vector;
65 class Epetra_Import;
66 class Epetra_BlockMap;
67 
69 
84 class Ifpack_SubdomainFilter : public virtual Epetra_RowMatrix {
85 
86 public:
88  Ifpack_SubdomainFilter(const Teuchos::RCP<const Epetra_RowMatrix>& Matrix, int subdomainId);
90 
92 
93  ~Ifpack_SubdomainFilter();
96 
98 
100 
108  virtual int NumMyRowEntries(int MyRow, int & NumEntries) const
109  {
110  NumEntries = NumEntries_[MyRow];
111  return(0);
112  }
113 
115  virtual int MaxNumEntries() const
116  {
117  return(MaxNumEntries_);
118  }
119 
121 
135  virtual inline int ExtractMyRowCopy(int MyRow, int Length, int & NumEntries, double *Values, int * Indices) const;
136 
138 
144  virtual int ExtractDiagonalCopy(Epetra_Vector & Diagonal) const;
146 
148 
150 
160  virtual int Multiply(bool TransA, const Epetra_MultiVector& X, Epetra_MultiVector& Y) const
161  {
162  if (TransA == true) {
163  IFPACK_CHK_ERR(-1);
164  }
165 
166  IFPACK_CHK_ERR(Apply(X,Y));
167  return(0);
168  }
169 
171  virtual int Solve(bool Upper, bool Trans, bool UnitDiagonal, const Epetra_MultiVector& X,
172  Epetra_MultiVector& Y) const
173  {
174  IFPACK_RETURN(-1); // not implemented
175  }
176 
177  virtual int Apply(const Epetra_MultiVector& X,
178  Epetra_MultiVector& Y) const;
179 
180  virtual int ApplyInverse(const Epetra_MultiVector& X,
181  Epetra_MultiVector& Y) const;
183  virtual int InvRowSums(Epetra_Vector& x) const
184  {
185  IFPACK_RETURN(-1); // not implemented
186  }
187 
189  virtual int LeftScale(const Epetra_Vector& x)
190  {
191  IFPACK_RETURN(-1); // not implemented
192  }
193 
195  virtual int InvColSums(Epetra_Vector& x) const
196  {
197  IFPACK_RETURN(-1); // not implemented
198  }
199 
200 
202  virtual int RightScale(const Epetra_Vector& x)
203  {
204  IFPACK_RETURN(-1); // not implemented
205  }
206 
208 
210 
212  virtual bool Filled() const
213  {
214  return true;
215  }
216 
218  /* Returns the quantity \f$ \| A \|_\infty\f$ such that
219  \f[\| A \|_\infty = \max_{1\lei\len} \sum_{i=1}^m |a_{ij}| \f].
220  */
221  virtual double NormInf() const
222  {
223  return(-1.0);
224  }
225 
227  /* Returns the quantity \f$ \| A \|_1\f$ such that
228  \f[\| A \|_1= \max_{1\lej\len} \sum_{j=1}^n |a_{ij}| \f].
229  */
230  virtual double NormOne() const
231  {
232  IFPACK_RETURN(-1.0);
233  }
234 
235 #ifndef EPETRA_NO_32BIT_GLOBAL_INDICES
236  virtual int NumGlobalNonzeros() const
238  {
239  return(NumGlobalNonzeros_);
240  }
241 
243  virtual int NumGlobalRows() const
244  {;
245 
246  return(NumGlobalRows_);
247  }
248 
250  virtual int NumGlobalCols() const
251  {
252  return(NumGlobalCols_);
253  }
254 
256  virtual int NumGlobalDiagonals() const
257  {
258  return(NumGlobalRows_);
259  }
260 #endif
261 
263  virtual long long NumGlobalNonzeros64() const
264  {
265  return(NumGlobalNonzeros_);
266  }
267 
269  virtual long long NumGlobalRows64() const
270  {
271  return(NumGlobalRows_);
272  }
273 
275  virtual long long NumGlobalCols64() const
276  {
277  return(NumGlobalRows_);
278  }
279 
281  virtual long long NumGlobalDiagonals64() const
282  {
283  return(NumGlobalRows_);
284  }
285 
287  virtual int NumMyNonzeros() const
288  {
289  return(NumMyNonzeros_);
290  }
291 
293  virtual int NumMyRows() const
294  {
295  return(NumMyRows_);
296  }
297 
299  virtual int NumMyCols() const
300  {
301  return(NumMyCols_);
302  }
303 
305  virtual int NumMyDiagonals() const
306  {
307  return(NumMyRows_);
308  }
309 
311  virtual bool LowerTriangular() const
312  {
313  return(Matrix_->LowerTriangular());
314  }
315 
317  virtual bool UpperTriangular() const
318  {
319  return(Matrix_->UpperTriangular());
320  }
321 
323  virtual const Epetra_Map & RowMatrixRowMap() const
324  {
325  return(*Map_);
326  }
327 
329  virtual const Epetra_Map & RowMatrixColMap() const
330  {
331  return(*colMap_);
332  }
333 
335  virtual const Epetra_Import * RowMatrixImporter() const
336  {
337  return(&*Importer_);
338  }
340 
341  virtual const Epetra_Import* Importer() const {return(&*Importer_);}
342 
343  virtual const Epetra_Export* Exporter() const {return(&*Exporter_);}
344 
345  // following functions are required to derive Epetra_RowMatrix objects.
346 
348  int SetOwnership(bool ownership)
349  {
350  IFPACK_RETURN(-1);
351  }
352 
354  int SetUseTranspose(bool UseTranspose_in)
355  {
356  UseTranspose_ = UseTranspose_in;
357  return(0);
358  }
359 
361  bool UseTranspose() const
362  {
363  return(UseTranspose_);
364  }
365 
367  bool HasNormInf() const
368  {
369  return(false);
370  }
371 
373  const Epetra_Comm & Comm() const
374  {
375  return(*SubComm_);
376  }
377 
379  const Epetra_Map & OperatorDomainMap() const
380  {
381  return(*Map_);
382  }
383 
385  const Epetra_Map & OperatorRangeMap() const
386  {
387  return(*Map_);
388  }
390 
391 const Epetra_BlockMap& Map() const;
392 
393 const char* Label() const{
394  return(Label_);
395 };
396 
397 private:
398  void UpdateImportVector(int NumVectors) const;
399  void UpdateExportVector(int NumVectors) const;
400 
403  const Ifpack_OverlappingRowMatrix* ovA_;
404 #ifdef HAVE_MPI
407  MPI_Comm subdomainMPIComm_;
408 #else
411 #endif
415  Teuchos::RCP<Epetra_Map> colMap_;
417  int NumMyRows_;
419  int NumMyCols_;
421  int NumMyNonzeros_;
423  int NumGlobalRows_;
425  int NumGlobalCols_;
427  int NumGlobalNonzeros_;
429  int MaxNumEntries_;
431  int MaxNumEntriesA_;
433  std::vector<int> NumEntries_;
435  mutable std::vector<int> Indices_;
437  mutable std::vector<double> Values_;
439  bool UseTranspose_;
441  char Label_[80];
442  Teuchos::RCP<Epetra_Vector> Diagonal_;
443  double NormOne_;
444  double NormInf_;
445 
447  int* Ac_LIDMap_;
448  int* Bc_LIDMap_;
449  int* Ar_LIDMap_;
450  int* Br_LIDMap_;
451 
453  const Epetra_CrsMatrix* Acrs_;
454 
455  int NumMyRowsA_;
456  int NumMyColsA_;
457  int NumMyRowsB_;
458 
459  //mutable Teuchos::RCP<Epetra_MultiVector> ImportVector_;
460  //mutable Teuchos::RCP<Epetra_MultiVector> ExportVector_;
461  mutable Epetra_MultiVector* ExportVector_;
462  mutable Epetra_MultiVector* ImportVector_;
463  Teuchos::RCP<Epetra_Import> Importer_;
464  Teuchos::RCP<Epetra_Export> Exporter_;
465 
466 };
467 #endif //ifdef HAVE_IFPACK_PARALLEL_SUBDOMAIN_SOLVERS
468 #endif /* IFPACK_SUBDOMAINFILTER_H */
virtual long long NumGlobalDiagonals64() const =0
virtual int RightScale(const Epetra_Vector &x)=0
virtual const Epetra_Map & RowMatrixRowMap() const =0
virtual int SetUseTranspose(bool UseTranspose)=0
virtual double NormOne() const =0
virtual int ApplyInverse(const Epetra_MultiVector &X, Epetra_MultiVector &Y) const =0
const int NumVectors
Definition: performance.cpp:71
virtual const Epetra_Map & OperatorDomainMap() const =0
virtual int ExtractDiagonalCopy(Epetra_Vector &Diagonal) const =0
virtual const char * Label() const =0
virtual int LeftScale(const Epetra_Vector &x)=0
virtual int InvRowSums(Epetra_Vector &x) const =0
virtual int NumGlobalNonzeros() const =0
virtual bool LowerTriangular() const =0
virtual int NumMyCols() const =0
virtual int NumMyRowEntries(int MyRow, int &NumEntries) const =0
virtual int Apply(const Epetra_MultiVector &X, Epetra_MultiVector &Y) const =0
virtual int MaxNumEntries() const =0
virtual const Epetra_Map & OperatorRangeMap() const =0
virtual const Epetra_Comm & Comm() const =0
virtual const Epetra_Import * RowMatrixImporter() const =0
virtual bool UseTranspose() const =0
virtual const Epetra_BlockMap & Map() const =0
virtual double NormInf() const =0
virtual int NumMyRows() const =0
virtual bool Filled() const =0
Ifpack_OverlappingRowMatrix: matrix with ghost rows, based on Epetra_RowMatrix.
virtual int NumGlobalDiagonals() const =0
virtual int NumGlobalCols() const =0
virtual long long NumGlobalCols64() const =0
virtual long long NumGlobalNonzeros64() const =0
virtual int Multiply(bool TransA, const Epetra_MultiVector &X, Epetra_MultiVector &Y) const =0
#define IFPACK_RETURN(ifpack_err)
virtual int NumMyDiagonals() const =0
virtual bool HasNormInf() const =0
virtual bool UpperTriangular() const =0
virtual int ExtractMyRowCopy(int MyRow, int Length, int &NumEntries, double *Values, int *Indices) const =0
virtual const Epetra_Map & RowMatrixColMap() const =0
virtual int InvColSums(Epetra_Vector &x) const =0
#define IFPACK_CHK_ERR(ifpack_err)
virtual int Solve(bool Upper, bool Trans, bool UnitDiagonal, const Epetra_MultiVector &X, Epetra_MultiVector &Y) const =0
virtual int NumGlobalRows() const =0
virtual int NumMyNonzeros() const =0
virtual long long NumGlobalRows64() const =0