Ifpack Package Browser (Single Doxygen Collection)  Development
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Ifpack_OverlappingRowMatrix.h
Go to the documentation of this file.
1 
2 /*@HEADER
3 // ***********************************************************************
4 //
5 // Ifpack: Object-Oriented Algebraic Preconditioner Package
6 // Copyright (2002) Sandia Corporation
7 //
8 // Under terms of Contract DE-AC04-94AL85000, there is a non-exclusive
9 // license for use of this work by or on behalf of the U.S. Government.
10 //
11 // Redistribution and use in source and binary forms, with or without
12 // modification, are permitted provided that the following conditions are
13 // met:
14 //
15 // 1. Redistributions of source code must retain the above copyright
16 // notice, this list of conditions and the following disclaimer.
17 //
18 // 2. Redistributions in binary form must reproduce the above copyright
19 // notice, this list of conditions and the following disclaimer in the
20 // documentation and/or other materials provided with the distribution.
21 //
22 // 3. Neither the name of the Corporation nor the names of the
23 // contributors may be used to endorse or promote products derived from
24 // this software without specific prior written permission.
25 //
26 // THIS SOFTWARE IS PROVIDED BY SANDIA CORPORATION "AS IS" AND ANY
27 // EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
28 // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
29 // PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL SANDIA CORPORATION OR THE
30 // CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
31 // EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
32 // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
33 // PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
34 // LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
35 // NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
36 // SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
37 //
38 // Questions? Contact Michael A. Heroux (maherou@sandia.gov)
39 //
40 // ***********************************************************************
41 //@HEADER
42 */
43 
44 #ifndef IFPACK_OVERLAPPINGROWMATRIX_H
45 #define IFPACK_OVERLAPPINGROWMATRIX_H
46 
47 #include "Ifpack_ConfigDefs.h"
48 #include "Epetra_RowMatrix.h"
49 #include "Epetra_CombineMode.h"
50 #include "Teuchos_RefCountPtr.hpp"
51 #include "Epetra_Import.h"
52 #include "Epetra_Map.h"
53 #ifdef HAVE_IFPACK_PARALLEL_SUBDOMAIN_SOLVERS
54 #include "Epetra_IntVector.h"
55 #else
56 # ifdef IFPACK_NODE_AWARE_CODE
57 # include "Epetra_IntVector.h"
58 # endif
59 #endif
60 
61 class Epetra_Map;
62 class Epetra_BlockMap;
63 class Epetra_CrsMatrix;
64 class Epetra_Comm;
65 
67 //
69 
70 public:
71 
73 #ifdef HAVE_IFPACK_PARALLEL_SUBDOMAIN_SOLVERS
74  Ifpack_OverlappingRowMatrix(const Teuchos::RefCountPtr<const Epetra_RowMatrix>& Matrix_in,
75  int OverlapLevel_in, int subdomainID);
76 #else
77 # ifdef IFPACK_NODE_AWARE_CODE
78  Ifpack_OverlappingRowMatrix(const Teuchos::RefCountPtr<const Epetra_RowMatrix>& Matrix_in,
79  int OverlapLevel_in, int myNodeID);
80 # endif
81 #endif
82  Ifpack_OverlappingRowMatrix(const Teuchos::RefCountPtr<const Epetra_RowMatrix>& Matrix_in,
83  int OverlapLevel_in);
84 
85 #ifdef HAVE_IFPACK_PARALLEL_SUBDOMAIN_SOLVERS
87 #else
88 # ifdef IFPACK_NODE_AWARE_CODE
90 # else
92 # endif
93 #endif
94 
95 
97 
99 
107  virtual int NumMyRowEntries(int MyRow, int & NumEntries) const;
108 
110  virtual int MaxNumEntries() const
111  {
112  return(MaxNumEntries_);
113  }
114 
116 
130  virtual int ExtractMyRowCopy(int MyRow, int Length, int & NumEntries, double *Values, int * Indices) const;
131 #ifdef HAVE_IFPACK_PARALLEL_SUBDOMAIN_SOLVERS
132  virtual int ExtractGlobalRowCopy(int MyRow, int Length, int & NumEntries, double* Values, int* Indices) const;
133 #else
134 # ifdef IFPACK_NODE_AWARE_CODE
135  virtual int ExtractGlobalRowCopy(int MyRow, int Length, int & NumEntries, double* Values, int* Indices) const;
136 # endif
137 #endif
138 
140 
146  virtual int ExtractDiagonalCopy(Epetra_Vector & Diagonal) const;
148 
150 
152 
162  virtual int Multiply(bool TransA, const Epetra_MultiVector& X, Epetra_MultiVector& Y) const;
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(A().NormInf());
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  return(A().NormOne());
227  }
228 
229 #ifndef EPETRA_NO_32BIT_GLOBAL_INDICES
230  virtual int NumGlobalNonzeros() const
232  {
233  if(A().RowMatrixRowMap().GlobalIndicesInt())
234  return (int) NumGlobalNonzeros_;
235  else
236  throw "Ifpack_OverlappingRowMatrix::NumGlobalNonzeros: Global indices not int";
237  }
238 
240  virtual int NumGlobalRows() const
241  {
242  return(A().NumGlobalRows());
243  }
244 
246  virtual int NumGlobalCols() const
247  {
248  return(A().NumGlobalCols());
249  }
250 
252  virtual int NumGlobalDiagonals() const
253  {
254  return(A().NumGlobalDiagonals());
255  }
256 #endif
257  virtual long long NumGlobalNonzeros64() const
259  {
260  return(NumGlobalNonzeros_);
261  }
262 
264  virtual long long NumGlobalRows64() const
265  {
266  return(A().NumGlobalRows64());
267  }
268 
270  virtual long long NumGlobalCols64() const
271  {
272  return(A().NumGlobalCols64());
273  }
274 
276  virtual long long NumGlobalDiagonals64() const
277  {
278  return(A().NumGlobalDiagonals64());
279  }
280 
282  virtual int NumMyNonzeros() const
283  {
284  return(NumMyNonzeros_);
285  }
286 
288  virtual int NumMyRows() const
289  {
290  return(NumMyRows_);
291  }
292 
294  virtual int NumMyCols() const
295  {
296  return(NumMyCols_);
297  }
298 
300  virtual int NumMyDiagonals() const
301  {
302  return(NumMyDiagonals_);
303  }
304 
306  virtual bool LowerTriangular() const
307  {
308  return(A().LowerTriangular());
309  }
310 
312  virtual bool UpperTriangular() const
313  {
314  return(A().UpperTriangular());
315  }
316 
318  virtual const Epetra_Map & RowMatrixRowMap() const
319  {
320  return(*Map_);
321  }
322 
324  virtual const Epetra_Map & RowMatrixColMap() const
325  {
326 #ifdef HAVE_IFPACK_PARALLEL_SUBDOMAIN_SOLVERS
327  return(*colMap_);
328 #else
329 # ifdef IFPACK_NODE_AWARE_CODE
330  return(*colMap_);
331 # else
332  return(*Map_);
333 # endif
334 #endif
335  }
336 
338  virtual const Epetra_Import * RowMatrixImporter() const
339  {
340  return(&*Importer_);
341  }
343 
344  // following functions are required to derive Epetra_RowMatrix objects.
345 
347  int SetOwnership(bool /* ownership */)
348  {
349  IFPACK_RETURN(-1);
350  }
351 
353  int SetUseTranspose(bool UseTranspose_in)
354  {
355  UseTranspose_ = UseTranspose_in;
356  return(0);
357  }
358 
360  bool UseTranspose() const
361  {
362  return(UseTranspose_);
363  }
364 
366  bool HasNormInf() const
367  {
368  return(A().HasNormInf());
369  }
370 
372  const Epetra_Comm & Comm() const
373  {
374  return(A().Comm());
375  }
376 
379  {
380  return(*Map_);
381  }
382 
384  const Epetra_Map & OperatorRangeMap() const
385  {
386  return(*Map_);
387  }
389 
390 const Epetra_BlockMap& Map() const;
391 
392 const char* Label() const{
393  return(Label_.c_str());
394 };
395 
396 int OverlapLevel() const
397 {
398  return(OverlapLevel_);
399 }
400 
402  Epetra_MultiVector& OvX,
403  Epetra_CombineMode CM = Insert);
404 
407  Epetra_CombineMode CM = Add);
408 #ifdef HAVE_IFPACK_PARALLEL_SUBDOMAIN_SOLVERS
409  inline const Epetra_RowMatrix& A() const
410  {
411  return(*Matrix_);
412  }
413 
414  inline Epetra_CrsMatrix& B() const
415  {
416  return(*ExtMatrix_);
417  }
418 #else
419 # ifdef IFPACK_NODE_AWARE_CODE
420  inline const Epetra_RowMatrix& A() const
421  {
422  return(*Matrix_);
423  }
424 
425  inline Epetra_CrsMatrix& B() const
426  {
427  return(*ExtMatrix_);
428  }
429 # endif
430 #endif
431 
432 private:
433 #ifndef HAVE_IFPACK_PARALLEL_SUBDOMAIN_SOLVERS
434 # ifndef IFPACK_NODE_AWARE_CODE
435  inline const Epetra_RowMatrix& A() const
436  {
437  return(*Matrix_);
438  }
439 
440  inline Epetra_RowMatrix& B() const;
441 # endif
442 #endif
443 
448 
451 
454 
456 
457  Teuchos::RefCountPtr<const Epetra_Map> Map_;
458 #ifdef HAVE_IFPACK_PARALLEL_SUBDOMAIN_SOLVERS
459  const Epetra_Map *colMap_;
460 #else
461 # ifdef IFPACK_NODE_AWARE_CODE
462  const Epetra_Map *colMap_;
463 # endif
464 #endif
465  Teuchos::RefCountPtr<const Epetra_Import> Importer_;
466 
467  Teuchos::RefCountPtr<const Epetra_RowMatrix> Matrix_;
468  Teuchos::RefCountPtr<Epetra_CrsMatrix> ExtMatrix_;
469  Teuchos::RefCountPtr<Epetra_Map> ExtMap_;
470  Teuchos::RefCountPtr<Epetra_Import> ExtImporter_;
471 
473  std::string Label_;
474 
475  template<typename int_type>
476  void BuildMap(int OverlapLevel_in);
477 
478 }; // class Ifpack_OverlappingRowMatrix
479 
480 #endif // IFPACK_OVERLAPPINGROWMATRIX_H
481 
482 #if defined(Ifpack_SHOW_DEPRECATED_WARNINGS)
483 #ifdef __GNUC__
484 #warning "The Ifpack package is deprecated"
485 #endif
486 #endif
487 
virtual int InvRowSums(Epetra_Vector &) const
Computes the sum of absolute values of the rows of the Epetra_RowMatrix, results returned in x (NOT I...
virtual int NumMyRows() const
Returns the number of matrix rows owned by the calling processor.
const Epetra_BlockMap & Map() const
virtual int NumMyRowEntries(int MyRow, int &NumEntries) const
Returns the number of nonzero entries in MyRow.
Teuchos::RefCountPtr< Epetra_CrsMatrix > ExtMatrix_
virtual int MaxNumEntries() const
Returns the maximum of NumMyRowEntries() over all rows.
virtual int Apply(const Epetra_MultiVector &X, Epetra_MultiVector &Y) const
virtual long long NumGlobalNonzeros64() const
Returns the number of nonzero entries in the global matrix.
virtual double NormOne() const
Returns the one norm of the global matrix.
const Epetra_RowMatrix & A() const
Teuchos::RefCountPtr< const Epetra_Map > Map_
virtual int NumGlobalDiagonals() const
Returns the number of global nonzero diagonal entries, based on global row/column index comparisons...
virtual int ExtractDiagonalCopy(Epetra_Vector &Diagonal) const
Returns a copy of the main diagonal in a user-provided vector.
virtual int Solve(bool, bool, bool, const Epetra_MultiVector &, Epetra_MultiVector &) const
Returns result of a local-only solve using a triangular Epetra_RowMatrix with Epetra_MultiVectors X a...
virtual int ApplyInverse(const Epetra_MultiVector &X, Epetra_MultiVector &Y) const
Teuchos::RefCountPtr< Epetra_Import > ExtImporter_
virtual bool Filled() const
If FillComplete() has been called, this query returns true, otherwise it returns false.
virtual int ExtractMyRowCopy(int MyRow, int Length, int &NumEntries, double *Values, int *Indices) const
Returns a copy of the specified local row in user-provided arrays.
virtual int InvColSums(Epetra_Vector &) const
Computes the sum of absolute values of the columns of the Epetra_RowMatrix, results returned in x (NO...
virtual int NumMyCols() const
Returns the number of matrix columns owned by the calling processor.
virtual int Multiply(bool TransA, const Epetra_MultiVector &X, Epetra_MultiVector &Y) const
Returns the result of a Epetra_RowMatrix multiplied by a Epetra_MultiVector X in Y.
virtual long long NumGlobalDiagonals64() const
Returns the number of global nonzero diagonal entries, based on global row/column index comparisons...
Ifpack_OverlappingRowMatrix: matrix with ghost rows, based on Epetra_RowMatrix.
virtual long long NumGlobalRows64() const
Returns the number of global matrix rows.
int SetUseTranspose(bool UseTranspose_in)
Sets use transpose (not implemented).
virtual long long NumGlobalCols64() const
Returns the number of global matrix columns.
virtual bool UpperTriangular() const
If matrix is upper triangular in local index space, this query returns true, otherwise it returns fal...
#define IFPACK_RETURN(ifpack_err)
virtual bool LowerTriangular() const
If matrix is lower triangular in local index space, this query returns true, otherwise it returns fal...
Teuchos::RefCountPtr< Epetra_Map > ExtMap_
virtual const Epetra_Map & RowMatrixRowMap() const
Returns the Epetra_Map object associated with the rows of this matrix.
Teuchos::RefCountPtr< const Epetra_RowMatrix > Matrix_
virtual int LeftScale(const Epetra_Vector &)
Scales the Epetra_RowMatrix on the left with a Epetra_Vector x (NOT IMPLEMENTED). ...
int ImportMultiVector(const Epetra_MultiVector &X, Epetra_MultiVector &OvX, Epetra_CombineMode CM=Insert)
const Epetra_Map & OperatorRangeMap() const
Returns the Epetra_Map object associated with the range of this operator.
Epetra_CombineMode
virtual const Epetra_Map & RowMatrixColMap() const
Returns the Epetra_Map object associated with the columns of this matrix.
int SetOwnership(bool)
Sets ownership.
const Epetra_Map & OperatorDomainMap() const
Returns the Epetra_Map object associated with the domain of this operator.
virtual int NumGlobalRows() const
Returns the number of global matrix rows.
virtual int NumGlobalNonzeros() const
Returns the number of nonzero entries in the global matrix.
virtual double NormInf() const
Returns the infinity norm of the global matrix.
int ExportMultiVector(const Epetra_MultiVector &OvX, Epetra_MultiVector &X, Epetra_CombineMode CM=Add)
bool UseTranspose() const
Returns the current UseTranspose setting.
virtual int NumMyNonzeros() const
Returns the number of nonzero entries in the calling processor&#39;s portion of the matrix.
virtual int NumMyDiagonals() const
Returns the number of local nonzero diagonal entries, based on global row/column index comparisons...
Ifpack_OverlappingRowMatrix(const Teuchos::RefCountPtr< const Epetra_RowMatrix > &Matrix_in, int OverlapLevel_in)
virtual int RightScale(const Epetra_Vector &)
Scales the Epetra_RowMatrix on the right with a Epetra_Vector x (NOT IMPLEMENTED).
Teuchos::RefCountPtr< const Epetra_Import > Importer_
bool HasNormInf() const
Returns true if the this object can provide an approximate Inf-norm, false otherwise.
const Epetra_Comm & Comm() const
Returns a pointer to the Epetra_Comm communicator associated with this operator.
virtual int NumGlobalCols() const
Returns the number of global matrix columns.
virtual const Epetra_Import * RowMatrixImporter() const
Returns the Epetra_Import object that contains the import operations for distributed operations...