IFPACK Development
Loading...
Searching...
No Matches
Ifpack_LocalFilter.h
1/*@HEADER
2// ***********************************************************************
3//
4// Ifpack: Object-Oriented Algebraic Preconditioner Package
5// Copyright (2002) Sandia Corporation
6//
7// Under terms of Contract DE-AC04-94AL85000, there is a non-exclusive
8// license for use of this work by or on behalf of the U.S. Government.
9//
10// Redistribution and use in source and binary forms, with or without
11// modification, are permitted provided that the following conditions are
12// met:
13//
14// 1. Redistributions of source code must retain the above copyright
15// notice, this list of conditions and the following disclaimer.
16//
17// 2. Redistributions in binary form must reproduce the above copyright
18// notice, this list of conditions and the following disclaimer in the
19// documentation and/or other materials provided with the distribution.
20//
21// 3. Neither the name of the Corporation nor the names of the
22// contributors may be used to endorse or promote products derived from
23// this software without specific prior written permission.
24//
25// THIS SOFTWARE IS PROVIDED BY SANDIA CORPORATION "AS IS" AND ANY
26// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
27// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
28// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL SANDIA CORPORATION OR THE
29// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
30// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
31// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
32// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
33// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
34// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
35// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
36//
37// Questions? Contact Michael A. Heroux (maherou@sandia.gov)
38//
39// ***********************************************************************
40//@HEADER
41*/
42
43#ifndef IFPACK_LOCALFILTER_H
44#define IFPACK_LOCALFILTER_H
45
46#if defined(Ifpack_SHOW_DEPRECATED_WARNINGS)
47#ifdef __GNUC__
48#warning "The Ifpack package is deprecated"
49#endif
50#endif
51
52#include "Ifpack_ConfigDefs.h"
53#ifdef HAVE_MPI
54#include "Epetra_MpiComm.h"
55#else
56#include "Epetra_SerialComm.h"
57#endif
58#include "Epetra_RowMatrix.h"
59#include "Teuchos_RefCountPtr.hpp"
60
61class Epetra_Map;
63class Epetra_Vector;
64class Epetra_Import;
65class Epetra_BlockMap;
66
68
104class Ifpack_LocalFilter : public virtual Epetra_RowMatrix {
105
106public:
108
109 Ifpack_LocalFilter(const Teuchos::RefCountPtr<const Epetra_RowMatrix>& Matrix);
110
112
113
115
117
119
121
129 virtual int NumMyRowEntries(int MyRow, int & NumEntries) const
130 {
131 NumEntries = NumEntries_[MyRow];
132 return(0);
133 }
134
136 virtual int MaxNumEntries() const
137 {
138 return(MaxNumEntries_);
139 }
140
142
156 virtual int ExtractMyRowCopy(int MyRow, int Length, int & NumEntries, double *Values, int * Indices) const;
157
159
165 virtual int ExtractDiagonalCopy(Epetra_Vector & Diagonal) const;
167
169
171
181 virtual int Multiply(bool TransA, const Epetra_MultiVector& X, Epetra_MultiVector& Y) const
182 {
183 if (TransA == true) {
184 IFPACK_CHK_ERR(-1);
185 }
186
187 IFPACK_CHK_ERR(Apply(X,Y));
188 return(0);
189 }
190
192 virtual int Solve(bool /* Upper */, bool /* Trans */, bool /* UnitDiagonal */, const Epetra_MultiVector& /* X */,
193 Epetra_MultiVector& /* Y */) const
194 {
195 IFPACK_RETURN(-1); // not implemented
196 }
197
198 virtual int Apply(const Epetra_MultiVector& X,
199 Epetra_MultiVector& Y) const;
200
201 virtual int ApplyInverse(const Epetra_MultiVector& X,
202 Epetra_MultiVector& Y) const;
204 virtual int InvRowSums(Epetra_Vector& /* x */) const
205 {
206 IFPACK_RETURN(-1); // not implemented
207 }
208
210 virtual int LeftScale(const Epetra_Vector& /* x */)
211 {
212 IFPACK_RETURN(-1); // not implemented
213 }
214
216 virtual int InvColSums(Epetra_Vector& /* x */) const
217 {
218 IFPACK_RETURN(-1); // not implemented
219 }
220
221
223 virtual int RightScale(const Epetra_Vector& /* x */)
224 {
225 IFPACK_RETURN(-1); // not implemented
226 }
227
229
231
233 virtual bool Filled() const
234 {
235 return true;
236 }
237
239 /* Returns the quantity \f$ \| A \|_\infty\f$ such that
240 \f[\| A \|_\infty = \max_{1\lei\len} \sum_{i=1}^m |a_{ij}| \f].
241 */
242 virtual double NormInf() const
243 {
244 return(-1.0);
245 }
246
248 /* Returns the quantity \f$ \| A \|_1\f$ such that
249 \f[\| A \|_1= \max_{1\lej\len} \sum_{j=1}^n |a_{ij}| \f].
250 */
251 virtual double NormOne() const
252 {
253 IFPACK_RETURN(-1.0);
254 }
255
256#ifndef EPETRA_NO_32BIT_GLOBAL_INDICES
258 virtual int NumGlobalNonzeros() const
259 {
260 return(NumNonzeros_);
261 }
262
264 virtual int NumGlobalRows() const
265 {
266 return(NumRows_);
267 }
268
270 virtual int NumGlobalCols() const
271 {
272 return(NumRows_);
273 }
274
276 virtual int NumGlobalDiagonals() const
277 {
278 return(NumRows_);
279 }
280#endif
281
283 virtual long long NumGlobalNonzeros64() const
284 {
285 return(NumNonzeros_);
286 }
287
289 virtual long long NumGlobalRows64() const
290 {
291 return(NumRows_);
292 }
293
295 virtual long long NumGlobalCols64() const
296 {
297 return(NumRows_);
298 }
299
301 virtual long long NumGlobalDiagonals64() const
302 {
303 return(NumRows_);
304 }
305
307 virtual int NumMyNonzeros() const
308 {
309 return(NumNonzeros_);
310 }
311
313 virtual int NumMyRows() const
314 {
315 return(NumRows_);
316 }
317
319 virtual int NumMyCols() const
320 {
321 return(NumRows_);
322 }
323
325 virtual int NumMyDiagonals() const
326 {
327 return(NumRows_);
328 }
329
331 virtual bool LowerTriangular() const
332 {
333 return(Matrix_->LowerTriangular());
334 }
335
337 virtual bool UpperTriangular() const
338 {
339 return(Matrix_->UpperTriangular());
340 }
341
343 virtual const Epetra_Map & RowMatrixRowMap() const
344 {
345 return(*Map_);
346 }
347
349 virtual const Epetra_Map & RowMatrixColMap() const
350 {
351 return(*Map_);
352 }
353
355 virtual const Epetra_Import * RowMatrixImporter() const
356 {
357 return(0);
358 }
360
361 // following functions are required to derive Epetra_RowMatrix objects.
362
364 int SetOwnership(bool /* ownership */)
365 {
366 IFPACK_RETURN(-1);
367 }
368
370 int SetUseTranspose(bool UseTranspose_in)
371 {
372 UseTranspose_ = UseTranspose_in;
373 return(0);
374 }
375
377 bool UseTranspose() const
378 {
379 return(UseTranspose_);
380 }
381
383 bool HasNormInf() const
384 {
385 return(false);
386 }
387
389 const Epetra_Comm & Comm() const
390 {
391 return(*SerialComm_);
392 }
393
396 {
397 return(*Map_);
398 }
399
402 {
403 return(*Map_);
404 }
406
407const Epetra_BlockMap& Map() const;
408
409const char* Label() const{
410 return(Label_);
411};
412
413private:
414
416 Teuchos::RefCountPtr<const Epetra_RowMatrix> Matrix_;
417#ifdef HAVE_MPI
419 Teuchos::RefCountPtr<Epetra_MpiComm> SerialComm_;
420#else
422 Teuchos::RefCountPtr<Epetra_SerialComm> SerialComm_;
423#endif
425 Teuchos::RefCountPtr<Epetra_Map> Map_;
427 int NumRows_;
429 int NumNonzeros_;
431 int MaxNumEntries_;
433 int MaxNumEntriesA_;
435 std::vector<int> NumEntries_;
437 mutable std::vector<int> Indices_;
439 mutable std::vector<double> Values_;
441 bool UseTranspose_;
443 char Label_[80];
444 Teuchos::RefCountPtr<Epetra_Vector> Diagonal_;
445 /* unused (comment out to avoid build warnings)
446 double NormOne_;
447 double NormInf_;
448 */
449};
450
451#endif /* IFPACK_LOCALFILTER_H */
Ifpack_LocalFilter a class for light-weight extraction of the submatrix corresponding to local rows a...
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 double NormInf() const
Returns the infinity norm of the global matrix.
virtual int NumGlobalCols() const
Returns the number of global matrix columns.
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 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 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 double NormOne() const
Returns the one norm of the global matrix.
virtual bool LowerTriangular() const
If matrix is lower triangular in local index space, this query returns true, otherwise it returns fal...
virtual int LeftScale(const Epetra_Vector &)
Scales the Epetra_RowMatrix on the left with a Epetra_Vector x (NOT IMPLEMENTED).
int SetOwnership(bool)
Sets ownership.
virtual const Epetra_Map & RowMatrixColMap() const
Returns the Epetra_Map object associated with the columns of this matrix.
virtual long long NumGlobalNonzeros64() const
Returns the number of nonzero entries in the global matrix.
virtual int NumMyRows() const
Returns the number of matrix rows owned by the calling processor.
virtual int NumGlobalRows() 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 int NumMyCols() const
Returns the number of matrix columns owned by the calling processor.
const Epetra_Map & OperatorRangeMap() const
Returns the Epetra_Map object associated with the range of this operator.
bool UseTranspose() const
Returns the current UseTranspose setting.
virtual int NumMyRowEntries(int MyRow, int &NumEntries) const
Returns the number of nonzero entries in MyRow.
virtual int NumGlobalDiagonals() const
Returns the number of global nonzero diagonal entries, based on global row/column index comparisons.
virtual const Epetra_Import * RowMatrixImporter() const
Returns the Epetra_Import object that contains the import operations for distributed operations.
bool HasNormInf() const
Returns true if the this object can provide an approximate Inf-norm, false otherwise.
virtual int ExtractDiagonalCopy(Epetra_Vector &Diagonal) const
Returns a copy of the main diagonal in a user-provided vector.
const Epetra_Map & OperatorDomainMap() const
Returns the Epetra_Map object associated with the domain of this operator.
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 NumMyDiagonals() const
Returns the number of local nonzero diagonal entries, based on global row/column index comparisons.
virtual bool UpperTriangular() const
If matrix is upper triangular in local index space, this query returns true, otherwise it returns fal...
const Epetra_Comm & Comm() const
Returns a pointer to the Epetra_Comm communicator associated with this operator.
virtual int NumMyNonzeros() const
Returns the number of nonzero entries in the calling processor's portion of the matrix.
virtual long long NumGlobalDiagonals64() const
Returns the number of global nonzero diagonal entries, based on global row/column index comparisons.
virtual ~Ifpack_LocalFilter()
Destructor.
virtual int NumGlobalNonzeros() const
Returns the number of nonzero entries in the global matrix.
virtual int RightScale(const Epetra_Vector &)
Scales the Epetra_RowMatrix on the right with a Epetra_Vector x (NOT IMPLEMENTED).
virtual bool Filled() const
If FillComplete() has been called, this query returns true, otherwise it returns false.
virtual const Epetra_Map & RowMatrixRowMap() const
Returns the Epetra_Map object associated with the rows of this matrix.
virtual int MaxNumEntries() const
Returns the maximum of NumMyRowEntries() over all rows.
virtual long long NumGlobalRows64() const
Returns the number of global matrix rows.