Ifpack Package Browser (Single Doxygen Collection)  Development
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Ifpack_SparsityFilter.h
Go to the documentation of this file.
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_SPARSITYFILTER_H
44 #define IFPACK_SPARSITYFILTER_H
45 
46 #include "Ifpack_ConfigDefs.h"
47 #include "Epetra_RowMatrix.h"
48 #include "Teuchos_RefCountPtr.hpp"
49 
50 class Epetra_Comm;
51 class Epetra_Map;
52 class Epetra_MultiVector;
53 class Epetra_Import;
54 class Epetra_BlockMap;
55 
57 
58 class Ifpack_SparsityFilter : public virtual Epetra_RowMatrix {
59 
60 public:
61  Ifpack_SparsityFilter(const Teuchos::RefCountPtr<Epetra_RowMatrix>& Matrix,
62  int AllowedNumEntries,
63  int AllowedBandwidth = -1);
64 
65  virtual ~Ifpack_SparsityFilter() {};
66 
67  virtual inline int NumMyRowEntries(int MyRow, int & NumEntries) const
68  {
69  NumEntries = NumEntries_[MyRow];
70  return(0);
71  }
72 
73  virtual int MaxNumEntries() const
74  {
75  return(MaxNumEntries_);
76  }
77 
78  virtual int ExtractMyRowCopy(int MyRow, int Length, int & NumEntries, double *Values, int * Indices) const;
79 
80  virtual int ExtractDiagonalCopy(Epetra_Vector & Diagonal) const;
81 
82  virtual int Multiply(bool TransA, const Epetra_MultiVector& X,
83  Epetra_MultiVector& Y) const;
84 
85  virtual int Solve(bool Upper, bool Trans, bool UnitDiagonal,
86  const Epetra_MultiVector& X,
87  Epetra_MultiVector& Y) const;
88 
89  virtual int Apply(const Epetra_MultiVector& X,
90  Epetra_MultiVector& Y) const;
91 
92  virtual int ApplyInverse(const Epetra_MultiVector& X,
93  Epetra_MultiVector& Y) const;
94 
95  virtual int InvRowSums(Epetra_Vector& /* x */) const
96  {
97  return(-98);
98  }
99 
100  virtual int LeftScale(const Epetra_Vector& /* x */)
101  {
102  return(-98);
103  }
104 
105  virtual int InvColSums(Epetra_Vector& /* x */) const
106  {
107  return(-98);
108  }
109 
110  virtual int RightScale(const Epetra_Vector& x)
111  {
112  return(A_->RightScale(x));
113  }
114 
115  virtual bool Filled() const
116  {
117  return(A_->Filled());
118  }
119 
120  virtual double NormInf() const
121  {
122  return(-1.0);
123  }
124 
125  virtual double NormOne() const
126  {
127  return(-1.0);
128  }
129 
130 #ifndef EPETRA_NO_32BIT_GLOBAL_INDICES
131  virtual int NumGlobalNonzeros() const
132  {
133  return(NumNonzeros_);
134  }
135 
136  virtual int NumGlobalRows() const
137  {
138  return(NumRows_);
139  }
140 
141  virtual int NumGlobalCols() const
142  {
143  return(NumRows_);
144  }
145 
146  virtual int NumGlobalDiagonals() const
147  {
148  return(NumRows_);
149  }
150 #endif
151 
152  virtual long long NumGlobalNonzeros64() const
153  {
154  return(NumNonzeros_);
155  }
156 
157  virtual long long NumGlobalRows64() const
158  {
159  return(NumRows_);
160  }
161 
162  virtual long long NumGlobalCols64() const
163  {
164  return(NumRows_);
165  }
166 
167  virtual long long NumGlobalDiagonals64() const
168  {
169  return(NumRows_);
170  }
171 
172  virtual int NumMyNonzeros() const
173  {
174  return(NumNonzeros_);
175  }
176 
177  virtual int NumMyRows() const
178  {
179  return(NumRows_);
180  }
181 
182  virtual int NumMyCols() const
183  {
184  return(NumRows_);
185  }
186 
187  virtual int NumMyDiagonals() const
188  {
189  return(NumRows_);
190  }
191 
192  virtual bool LowerTriangular() const
193  {
194  return(false);
195  }
196 
197  virtual bool UpperTriangular() const
198  {
199  return(false);
200  }
201 
202  virtual const Epetra_Map & RowMatrixRowMap() const
203  {
204  return(A_->RowMatrixRowMap());
205  }
206 
207  virtual const Epetra_Map & RowMatrixColMap() const
208  {
209  return(A_->RowMatrixColMap());
210  }
211 
212  virtual const Epetra_Import * RowMatrixImporter() const
213  {
214  return(A_->RowMatrixImporter());
215  }
216 
217  int SetUseTranspose(bool useTranspose)
218  {
219  return(A_->SetUseTranspose(useTranspose));
220  }
221 
222  bool UseTranspose() const
223  {
224  return(A_->UseTranspose());
225  }
226 
227  bool HasNormInf() const
228  {
229  return(false);
230  }
231 
232  const Epetra_Comm & Comm() const
233  {
234  return(A_->Comm());
235  }
236 
238  {
239  return(A_->OperatorDomainMap());
240  }
241 
242  const Epetra_Map & OperatorRangeMap() const
243  {
244  return(A_->OperatorRangeMap());
245  }
246 
247  const Epetra_BlockMap& Map() const
248  {
249  return(A_->Map());
250  }
251 
252  const char* Label() const{
253  return(Label_);
254  }
255 
256 private:
257 
259  Teuchos::RefCountPtr<Epetra_RowMatrix> A_;
263 
268 
271 
273  mutable std::vector<int> Indices_;
275  mutable std::vector<double> Values_;
277  char Label_[80];
278 
279  int NumRows_;
280  std::vector<int> NumEntries_;
281 
282 };
283 
284 
285 #endif /* IFPACK_SPARSITYFILTER_H */
virtual int ExtractMyRowCopy(int MyRow, int Length, int &NumEntries, double *Values, int *Indices) const
virtual int NumMyNonzeros() const
int AllowedEntries_
Maximum allowed entries per row.
const Epetra_Comm & Comm() const
virtual int Apply(const Epetra_MultiVector &X, Epetra_MultiVector &Y) const
virtual bool LowerTriangular() const
virtual const Epetra_Map & RowMatrixColMap() const
char Label_[80]
Label for this object.
std::vector< int > Indices_
Used in ExtractMyRowCopy, to avoid allocation each time.
virtual int ExtractDiagonalCopy(Epetra_Vector &Diagonal) const
virtual long long NumGlobalCols64() const
virtual long long NumGlobalNonzeros64() const
virtual const Epetra_Map & RowMatrixRowMap() const
virtual double NormOne() const
virtual int InvRowSums(Epetra_Vector &) const
int MaxNumEntries_
Maximum entries in each row.
virtual int NumGlobalRows() const
virtual bool Filled() const
const Epetra_Map & OperatorRangeMap() const
virtual int ApplyInverse(const Epetra_MultiVector &X, Epetra_MultiVector &Y) const
std::vector< double > Values_
Used in ExtractMyRowCopy, to avoid allocation each time.
const Epetra_Map & OperatorDomainMap() const
virtual int LeftScale(const Epetra_Vector &)
virtual int MaxNumEntries() const
virtual long long NumGlobalRows64() const
virtual int Multiply(bool TransA, const Epetra_MultiVector &X, Epetra_MultiVector &Y) const
virtual int NumMyRowEntries(int MyRow, int &NumEntries) const
Ifpack_SparsityFilter(const Teuchos::RefCountPtr< Epetra_RowMatrix > &Matrix, int AllowedNumEntries, int AllowedBandwidth=-1)
virtual int NumGlobalDiagonals() const
virtual long long NumGlobalDiagonals64() const
virtual int NumMyDiagonals() const
virtual int NumMyCols() const
virtual int InvColSums(Epetra_Vector &) const
virtual int RightScale(const Epetra_Vector &x)
const Epetra_BlockMap & Map() const
virtual int NumGlobalCols() const
virtual bool UpperTriangular() const
virtual const Epetra_Import * RowMatrixImporter() const
virtual double NormInf() const
int SetUseTranspose(bool useTranspose)
std::vector< int > NumEntries_
virtual int NumMyRows() const
int NumNonzeros_
Number of nonzeros for the dropped matrix.
const char * Label() const
Teuchos::RefCountPtr< Epetra_RowMatrix > A_
Pointer to the matrix to be preconditioned.
Ifpack_SparsityFilter: a class to drop based on sparsity.
virtual int NumGlobalNonzeros() const
int AllowedBandwidth_
Maximum allowed bandwidth.
virtual int Solve(bool Upper, bool Trans, bool UnitDiagonal, const Epetra_MultiVector &X, Epetra_MultiVector &Y) const