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 #if defined(Ifpack_SHOW_DEPRECATED_WARNINGS)
48 #ifdef __GNUC__
49 #warning "The Ifpack package is deprecated"
50 #endif
51 #endif
52 
53 #include "Ifpack_ConfigDefs.h"
54 #include "Epetra_RowMatrix.h"
55 #include "Epetra_CombineMode.h"
56 #include "Teuchos_RefCountPtr.hpp"
57 #include "Epetra_Import.h"
58 #include "Epetra_Map.h"
59 #ifdef HAVE_IFPACK_PARALLEL_SUBDOMAIN_SOLVERS
60 #include "Epetra_IntVector.h"
61 #else
62 # ifdef IFPACK_NODE_AWARE_CODE
63 # include "Epetra_IntVector.h"
64 # endif
65 #endif
66 
67 class Epetra_Map;
68 class Epetra_BlockMap;
69 class Epetra_CrsMatrix;
70 class Epetra_Comm;
71 
73 //
75 
76 public:
77 
79 #ifdef HAVE_IFPACK_PARALLEL_SUBDOMAIN_SOLVERS
80  Ifpack_OverlappingRowMatrix(const Teuchos::RefCountPtr<const Epetra_RowMatrix>& Matrix_in,
81  int OverlapLevel_in, int subdomainID);
82 #else
83 # ifdef IFPACK_NODE_AWARE_CODE
84  Ifpack_OverlappingRowMatrix(const Teuchos::RefCountPtr<const Epetra_RowMatrix>& Matrix_in,
85  int OverlapLevel_in, int myNodeID);
86 # endif
87 #endif
88  Ifpack_OverlappingRowMatrix(const Teuchos::RefCountPtr<const Epetra_RowMatrix>& Matrix_in,
89  int OverlapLevel_in);
90 
91 #ifdef HAVE_IFPACK_PARALLEL_SUBDOMAIN_SOLVERS
93 #else
94 # ifdef IFPACK_NODE_AWARE_CODE
96 # else
98 # endif
99 #endif
100 
101 
103 
105 
113  virtual int NumMyRowEntries(int MyRow, int & NumEntries) const;
114 
116  virtual int MaxNumEntries() const
117  {
118  return(MaxNumEntries_);
119  }
120 
122 
136  virtual int ExtractMyRowCopy(int MyRow, int Length, int & NumEntries, double *Values, int * Indices) const;
137 #ifdef HAVE_IFPACK_PARALLEL_SUBDOMAIN_SOLVERS
138  virtual int ExtractGlobalRowCopy(int MyRow, int Length, int & NumEntries, double* Values, int* Indices) const;
139 #else
140 # ifdef IFPACK_NODE_AWARE_CODE
141  virtual int ExtractGlobalRowCopy(int MyRow, int Length, int & NumEntries, double* Values, int* Indices) const;
142 # endif
143 #endif
144 
146 
152  virtual int ExtractDiagonalCopy(Epetra_Vector & Diagonal) const;
154 
156 
158 
168  virtual int Multiply(bool TransA, const Epetra_MultiVector& X, Epetra_MultiVector& Y) const;
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(A().NormInf());
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  return(A().NormOne());
233  }
234 
235 #ifndef EPETRA_NO_32BIT_GLOBAL_INDICES
236  virtual int NumGlobalNonzeros() const
238  {
239  if(A().RowMatrixRowMap().GlobalIndicesInt())
240  return (int) NumGlobalNonzeros_;
241  else
242  throw "Ifpack_OverlappingRowMatrix::NumGlobalNonzeros: Global indices not int";
243  }
244 
246  virtual int NumGlobalRows() const
247  {
248  return(A().NumGlobalRows());
249  }
250 
252  virtual int NumGlobalCols() const
253  {
254  return(A().NumGlobalCols());
255  }
256 
258  virtual int NumGlobalDiagonals() const
259  {
260  return(A().NumGlobalDiagonals());
261  }
262 #endif
263  virtual long long NumGlobalNonzeros64() const
265  {
266  return(NumGlobalNonzeros_);
267  }
268 
270  virtual long long NumGlobalRows64() const
271  {
272  return(A().NumGlobalRows64());
273  }
274 
276  virtual long long NumGlobalCols64() const
277  {
278  return(A().NumGlobalCols64());
279  }
280 
282  virtual long long NumGlobalDiagonals64() const
283  {
284  return(A().NumGlobalDiagonals64());
285  }
286 
288  virtual int NumMyNonzeros() const
289  {
290  return(NumMyNonzeros_);
291  }
292 
294  virtual int NumMyRows() const
295  {
296  return(NumMyRows_);
297  }
298 
300  virtual int NumMyCols() const
301  {
302  return(NumMyCols_);
303  }
304 
306  virtual int NumMyDiagonals() const
307  {
308  return(NumMyDiagonals_);
309  }
310 
312  virtual bool LowerTriangular() const
313  {
314  return(A().LowerTriangular());
315  }
316 
318  virtual bool UpperTriangular() const
319  {
320  return(A().UpperTriangular());
321  }
322 
324  virtual const Epetra_Map & RowMatrixRowMap() const
325  {
326  return(*Map_);
327  }
328 
330  virtual const Epetra_Map & RowMatrixColMap() const
331  {
332 #ifdef HAVE_IFPACK_PARALLEL_SUBDOMAIN_SOLVERS
333  return(*colMap_);
334 #else
335 # ifdef IFPACK_NODE_AWARE_CODE
336  return(*colMap_);
337 # else
338  return(*Map_);
339 # endif
340 #endif
341  }
342 
344  virtual const Epetra_Import * RowMatrixImporter() const
345  {
346  return(&*Importer_);
347  }
349 
350  // following functions are required to derive Epetra_RowMatrix objects.
351 
353  int SetOwnership(bool /* ownership */)
354  {
355  IFPACK_RETURN(-1);
356  }
357 
359  int SetUseTranspose(bool UseTranspose_in)
360  {
361  UseTranspose_ = UseTranspose_in;
362  return(0);
363  }
364 
366  bool UseTranspose() const
367  {
368  return(UseTranspose_);
369  }
370 
372  bool HasNormInf() const
373  {
374  return(A().HasNormInf());
375  }
376 
378  const Epetra_Comm & Comm() const
379  {
380  return(A().Comm());
381  }
382 
385  {
386  return(*Map_);
387  }
388 
390  const Epetra_Map & OperatorRangeMap() const
391  {
392  return(*Map_);
393  }
395 
396 const Epetra_BlockMap& Map() const;
397 
398 const char* Label() const{
399  return(Label_.c_str());
400 };
401 
402 int OverlapLevel() const
403 {
404  return(OverlapLevel_);
405 }
406 
408  Epetra_MultiVector& OvX,
409  Epetra_CombineMode CM = Insert);
410 
413  Epetra_CombineMode CM = Add);
414 #ifdef HAVE_IFPACK_PARALLEL_SUBDOMAIN_SOLVERS
415  inline const Epetra_RowMatrix& A() const
416  {
417  return(*Matrix_);
418  }
419 
420  inline Epetra_CrsMatrix& B() const
421  {
422  return(*ExtMatrix_);
423  }
424 #else
425 # ifdef IFPACK_NODE_AWARE_CODE
426  inline const Epetra_RowMatrix& A() const
427  {
428  return(*Matrix_);
429  }
430 
431  inline Epetra_CrsMatrix& B() const
432  {
433  return(*ExtMatrix_);
434  }
435 # endif
436 #endif
437 
438 private:
439 #ifndef HAVE_IFPACK_PARALLEL_SUBDOMAIN_SOLVERS
440 # ifndef IFPACK_NODE_AWARE_CODE
441  inline const Epetra_RowMatrix& A() const
442  {
443  return(*Matrix_);
444  }
445 
446  inline Epetra_RowMatrix& B() const;
447 # endif
448 #endif
449 
454 
457 
460 
462 
463  Teuchos::RefCountPtr<const Epetra_Map> Map_;
464 #ifdef HAVE_IFPACK_PARALLEL_SUBDOMAIN_SOLVERS
465  const Epetra_Map *colMap_;
466 #else
467 # ifdef IFPACK_NODE_AWARE_CODE
468  const Epetra_Map *colMap_;
469 # endif
470 #endif
471  Teuchos::RefCountPtr<const Epetra_Import> Importer_;
472 
473  Teuchos::RefCountPtr<const Epetra_RowMatrix> Matrix_;
474  Teuchos::RefCountPtr<Epetra_CrsMatrix> ExtMatrix_;
475  Teuchos::RefCountPtr<Epetra_Map> ExtMap_;
476  Teuchos::RefCountPtr<Epetra_Import> ExtImporter_;
477 
479  std::string Label_;
480 
481  template<typename int_type>
482  void BuildMap(int OverlapLevel_in);
483 
484 }; // class Ifpack_OverlappingRowMatrix
485 
486 #endif // IFPACK_OVERLAPPINGROWMATRIX_H
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...