IFPACK  Development
 All Classes Namespaces 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 #include "Ifpack_ConfigDefs.h"
42 
43 #ifdef HAVE_IFPACK_PARALLEL_SUBDOMAIN_SOLVERS
44 
45 #ifdef HAVE_MPI
46 #include "Epetra_MpiComm.h"
47 #else
48 #include "Epetra_SerialComm.h"
49 #endif
50 #include "Epetra_RowMatrix.h"
51 #include "Epetra_CrsMatrix.h"
52 #include "Epetra_IntVector.h"
53 #include "Teuchos_RCP.hpp"
54 #include "Ifpack_OverlappingRowMatrix.h"
55 
56 class Epetra_Map;
57 class Epetra_MultiVector;
58 class Epetra_Vector;
59 class Epetra_Import;
60 class Epetra_BlockMap;
61 
63 
78 class Ifpack_SubdomainFilter : public virtual Epetra_RowMatrix {
79 
80 public:
82  Ifpack_SubdomainFilter(const Teuchos::RCP<const Epetra_RowMatrix>& Matrix, int subdomainId);
84 
86 
87  ~Ifpack_SubdomainFilter();
90 
92 
94 
102  virtual int NumMyRowEntries(int MyRow, int & NumEntries) const
103  {
104  NumEntries = NumEntries_[MyRow];
105  return(0);
106  }
107 
109  virtual int MaxNumEntries() const
110  {
111  return(MaxNumEntries_);
112  }
113 
115 
129  virtual inline int ExtractMyRowCopy(int MyRow, int Length, int & NumEntries, double *Values, int * Indices) const;
130 
132 
138  virtual int ExtractDiagonalCopy(Epetra_Vector & Diagonal) const;
140 
142 
144 
154  virtual int Multiply(bool TransA, const Epetra_MultiVector& X, Epetra_MultiVector& Y) const
155  {
156  if (TransA == true) {
157  IFPACK_CHK_ERR(-1);
158  }
159 
160  IFPACK_CHK_ERR(Apply(X,Y));
161  return(0);
162  }
163 
165  virtual int Solve(bool Upper, bool Trans, bool UnitDiagonal, const Epetra_MultiVector& X,
166  Epetra_MultiVector& Y) const
167  {
168  IFPACK_RETURN(-1); // not implemented
169  }
170 
171  virtual int Apply(const Epetra_MultiVector& X,
172  Epetra_MultiVector& Y) const;
173 
174  virtual int ApplyInverse(const Epetra_MultiVector& X,
175  Epetra_MultiVector& Y) const;
177  virtual int InvRowSums(Epetra_Vector& x) const
178  {
179  IFPACK_RETURN(-1); // not implemented
180  }
181 
183  virtual int LeftScale(const Epetra_Vector& x)
184  {
185  IFPACK_RETURN(-1); // not implemented
186  }
187 
189  virtual int InvColSums(Epetra_Vector& x) const
190  {
191  IFPACK_RETURN(-1); // not implemented
192  }
193 
194 
196  virtual int RightScale(const Epetra_Vector& x)
197  {
198  IFPACK_RETURN(-1); // not implemented
199  }
200 
202 
204 
206  virtual bool Filled() const
207  {
208  return true;
209  }
210 
212  /* Returns the quantity \f$ \| A \|_\infty\f$ such that
213  \f[\| A \|_\infty = \max_{1\lei\len} \sum_{i=1}^m |a_{ij}| \f].
214  */
215  virtual double NormInf() const
216  {
217  return(-1.0);
218  }
219 
221  /* Returns the quantity \f$ \| A \|_1\f$ such that
222  \f[\| A \|_1= \max_{1\lej\len} \sum_{j=1}^n |a_{ij}| \f].
223  */
224  virtual double NormOne() const
225  {
226  IFPACK_RETURN(-1.0);
227  }
228 
229 #ifndef EPETRA_NO_32BIT_GLOBAL_INDICES
230  virtual int NumGlobalNonzeros() const
232  {
233  return(NumGlobalNonzeros_);
234  }
235 
237  virtual int NumGlobalRows() const
238  {;
239 
240  return(NumGlobalRows_);
241  }
242 
244  virtual int NumGlobalCols() const
245  {
246  return(NumGlobalCols_);
247  }
248 
250  virtual int NumGlobalDiagonals() const
251  {
252  return(NumGlobalRows_);
253  }
254 #endif
255 
257  virtual long long NumGlobalNonzeros64() const
258  {
259  return(NumGlobalNonzeros_);
260  }
261 
263  virtual long long NumGlobalRows64() const
264  {
265  return(NumGlobalRows_);
266  }
267 
269  virtual long long NumGlobalCols64() const
270  {
271  return(NumGlobalRows_);
272  }
273 
275  virtual long long NumGlobalDiagonals64() const
276  {
277  return(NumGlobalRows_);
278  }
279 
281  virtual int NumMyNonzeros() const
282  {
283  return(NumMyNonzeros_);
284  }
285 
287  virtual int NumMyRows() const
288  {
289  return(NumMyRows_);
290  }
291 
293  virtual int NumMyCols() const
294  {
295  return(NumMyCols_);
296  }
297 
299  virtual int NumMyDiagonals() const
300  {
301  return(NumMyRows_);
302  }
303 
305  virtual bool LowerTriangular() const
306  {
307  return(Matrix_->LowerTriangular());
308  }
309 
311  virtual bool UpperTriangular() const
312  {
313  return(Matrix_->UpperTriangular());
314  }
315 
317  virtual const Epetra_Map & RowMatrixRowMap() const
318  {
319  return(*Map_);
320  }
321 
323  virtual const Epetra_Map & RowMatrixColMap() const
324  {
325  return(*colMap_);
326  }
327 
329  virtual const Epetra_Import * RowMatrixImporter() const
330  {
331  return(&*Importer_);
332  }
334 
335  virtual const Epetra_Import* Importer() const {return(&*Importer_);}
336 
337  virtual const Epetra_Export* Exporter() const {return(&*Exporter_);}
338 
339  // following functions are required to derive Epetra_RowMatrix objects.
340 
342  int SetOwnership(bool ownership)
343  {
344  IFPACK_RETURN(-1);
345  }
346 
348  int SetUseTranspose(bool UseTranspose_in)
349  {
350  UseTranspose_ = UseTranspose_in;
351  return(0);
352  }
353 
355  bool UseTranspose() const
356  {
357  return(UseTranspose_);
358  }
359 
361  bool HasNormInf() const
362  {
363  return(false);
364  }
365 
367  const Epetra_Comm & Comm() const
368  {
369  return(*SubComm_);
370  }
371 
373  const Epetra_Map & OperatorDomainMap() const
374  {
375  return(*Map_);
376  }
377 
379  const Epetra_Map & OperatorRangeMap() const
380  {
381  return(*Map_);
382  }
384 
385 const Epetra_BlockMap& Map() const;
386 
387 const char* Label() const{
388  return(Label_);
389 };
390 
391 private:
392  void UpdateImportVector(int NumVectors) const;
393  void UpdateExportVector(int NumVectors) const;
394 
396  Teuchos::RCP<const Epetra_RowMatrix> Matrix_;
397  const Ifpack_OverlappingRowMatrix* ovA_;
398 #ifdef HAVE_MPI
399  Teuchos::RCP<Epetra_MpiComm> SubComm_;
401  MPI_Comm subdomainMPIComm_;
402 #else
403  Teuchos::RCP<Epetra_SerialComm> SubComm_;
405 #endif
406  Teuchos::RCP<Epetra_Map> Map_;
409  Teuchos::RCP<Epetra_Map> colMap_;
411  int NumMyRows_;
413  int NumMyCols_;
415  int NumMyNonzeros_;
417  int NumGlobalRows_;
419  int NumGlobalCols_;
421  int NumGlobalNonzeros_;
423  int MaxNumEntries_;
425  int MaxNumEntriesA_;
427  std::vector<int> NumEntries_;
429  mutable std::vector<int> Indices_;
431  mutable std::vector<double> Values_;
433  bool UseTranspose_;
435  char Label_[80];
436  Teuchos::RCP<Epetra_Vector> Diagonal_;
437  double NormOne_;
438  double NormInf_;
439 
441  int* Ac_LIDMap_;
442  int* Bc_LIDMap_;
443  int* Ar_LIDMap_;
444  int* Br_LIDMap_;
445 
447  const Epetra_CrsMatrix* Acrs_;
448 
449  int NumMyRowsA_;
450  int NumMyColsA_;
451  int NumMyRowsB_;
452 
453  //mutable Teuchos::RCP<Epetra_MultiVector> ImportVector_;
454  //mutable Teuchos::RCP<Epetra_MultiVector> ExportVector_;
455  mutable Epetra_MultiVector* ExportVector_;
456  mutable Epetra_MultiVector* ImportVector_;
457  Teuchos::RCP<Epetra_Import> Importer_;
458  Teuchos::RCP<Epetra_Export> Exporter_;
459 
460 };
461 #endif //ifdef HAVE_IFPACK_PARALLEL_SUBDOMAIN_SOLVERS
462 #endif /* IFPACK_SUBDOMAINFILTER_H */
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
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 int Multiply(bool TransA, const Epetra_MultiVector &X, Epetra_MultiVector &Y) const =0
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
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