Ifpack Package Browser (Single Doxygen Collection)  Development
Ifpack_DiagonalFilter.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_DIAGONALFILTER_H
44 #define IFPACK_DIAGONALFILTER_H
45 
46 #include "Ifpack_ConfigDefs.h"
47 #include "Epetra_ConfigDefs.h"
48 #include "Epetra_RowMatrix.h"
49 #include "Epetra_Time.h"
50 #include "Teuchos_RefCountPtr.hpp"
51 
52 class Epetra_Comm;
53 class Epetra_Map;
54 class Epetra_MultiVector;
55 class Epetra_Import;
56 class Epetra_BlockMap;
57 
59 
80 class Ifpack_DiagonalFilter : public virtual Epetra_RowMatrix {
81 
82 public:
84  Ifpack_DiagonalFilter(const Teuchos::RefCountPtr<Epetra_RowMatrix>& Matrix,
85  double AbsoluteThreshold,
86  double RelativeThreshold);
87 
89  virtual ~Ifpack_DiagonalFilter() {};
90 
92  virtual int NumMyRowEntries(int MyRow, int& NumEntries) const
93  {
94  return(A_->NumMyRowEntries(MyRow, NumEntries));
95  }
96 
98  virtual int MaxNumEntries() const
99  {
100  return(A_->MaxNumEntries());
101  }
102 
103  inline virtual int ExtractMyRowCopy(int MyRow, int Length, int& NumEntries,
104  double* Values, int* Indices) const;
105 
106  virtual int ExtractDiagonalCopy(Epetra_Vector & Diagonal) const
107  {
108  int ierr = A_->ExtractDiagonalCopy(Diagonal);
109  IFPACK_RETURN(ierr);
110  }
111 
112  virtual int Multiply(bool TransA, const Epetra_MultiVector& X,
113  Epetra_MultiVector& Y) const;
114 
115  virtual int Solve(bool Upper, bool Trans, bool UnitDiagonal,
116  const Epetra_MultiVector& X,
117  Epetra_MultiVector& Y) const
118  {
119  IFPACK_CHK_ERR(-1);
120  }
121 
122  virtual int Apply(const Epetra_MultiVector& X,
123  Epetra_MultiVector& Y) const
124  {
125  int ierr = Multiply(UseTranspose(),X,Y);
126  IFPACK_RETURN(ierr);
127  }
128 
129  virtual int ApplyInverse(const Epetra_MultiVector& X,
130  Epetra_MultiVector& Y) const
131  {
132  IFPACK_CHK_ERR(-1);
133  }
134 
135  virtual int InvRowSums(Epetra_Vector& x) const
136  {
137  IFPACK_CHK_ERR(-1);
138  }
139 
140  virtual int LeftScale(const Epetra_Vector& x)
141  {
142  return(A_->LeftScale(x));
143  }
144 
145  virtual int InvColSums(Epetra_Vector& x) const
146  {
147  IFPACK_CHK_ERR(-1);;
148  }
149 
150  virtual int RightScale(const Epetra_Vector& x)
151  {
152  return(A_->RightScale(x));
153  }
154 
155  virtual bool Filled() const
156  {
157  return(A_->Filled());
158  }
159 
161  virtual double NormInf() const
162  {
163  return(-1.0);
164  }
165 
167  virtual double NormOne() const
168  {
169  return(-1.0);
170  }
171 
172 #ifndef EPETRA_NO_32BIT_GLOBAL_INDICES
173  virtual int NumGlobalNonzeros() const
174  {
175  return(A_->NumGlobalNonzeros());
176  }
177 
178  virtual int NumGlobalRows() const
179  {
180  return(A_->NumGlobalRows());
181  }
182 
183  virtual int NumGlobalCols() const
184  {
185  return(A_->NumGlobalCols());
186  }
187 
188  virtual int NumGlobalDiagonals() const
189  {
190  return(A_->NumGlobalDiagonals());
191  }
192 #endif
193 
194  virtual long long NumGlobalNonzeros64() const
195  {
196  return(A_->NumGlobalNonzeros64());
197  }
198 
199  virtual long long NumGlobalRows64() const
200  {
201  return(A_->NumGlobalRows64());
202  }
203 
204  virtual long long NumGlobalCols64() const
205  {
206  return(A_->NumGlobalCols64());
207  }
208 
209  virtual long long NumGlobalDiagonals64() const
210  {
211  return(A_->NumGlobalDiagonals64());
212  }
213 
214  virtual int NumMyNonzeros() const
215  {
216  return(A_->NumMyNonzeros());
217  }
218 
219  virtual int NumMyRows() const
220  {
221  return(A_->NumMyRows());
222  }
223 
224  virtual int NumMyCols() const
225  {
226  return(A_->NumMyCols());
227  }
228 
229  virtual int NumMyDiagonals() const
230  {
231  return(A_->NumMyDiagonals());
232  }
233 
234  virtual bool LowerTriangular() const
235  {
236  return(A_->LowerTriangular());
237  }
238 
239  virtual bool UpperTriangular() const
240  {
241  return(A_->UpperTriangular());
242  }
243 
244  virtual const Epetra_Map& RowMatrixRowMap() const
245  {
246  return(A_->RowMatrixRowMap());
247  }
248 
249  virtual const Epetra_Map& RowMatrixColMap() const
250  {
251  return(A_->RowMatrixColMap());
252  }
253 
254  virtual const Epetra_Import* RowMatrixImporter() const
255  {
256  return(A_->RowMatrixImporter());
257  }
258 
259  int SetUseTranspose(bool UseTranspose_in)
260  {
261  return(A_->SetUseTranspose(UseTranspose_in));
262  }
263 
264  bool UseTranspose() const
265  {
266  return(A_->UseTranspose());
267  }
268 
270  bool HasNormInf() const
271  {
272  return(false);
273  }
274 
275  const Epetra_Comm& Comm() const
276  {
277  return(A_->Comm());
278  }
279 
281  {
282  return(A_->OperatorDomainMap());
283  }
284 
285  const Epetra_Map& OperatorRangeMap() const
286  {
287  return(A_->OperatorRangeMap());
288  }
289 
290  const Epetra_BlockMap& Map() const
291  {
292  return(A_->Map());
293  }
294 
295  const char* Label() const{
296  return(A_->Label());
297  }
298 
299 private:
300 
302  Teuchos::RefCountPtr<Epetra_RowMatrix> A_;
308  std::vector<int> pos_;
310  std::vector<double> val_;
311 
312 };
313 
314 
315 #endif /* IFPACK_DIAGONALFILTER_H */
std::vector< int > pos_
Stores the position of the diagonal element, or -1 if not present.
virtual bool Filled() const
virtual int InvColSums(Epetra_Vector &x) const
virtual long long NumGlobalNonzeros64() const
Teuchos::RefCountPtr< Epetra_RowMatrix > A_
Pointer to the matrix to be filtered.
virtual long long NumGlobalRows64() const
virtual int MaxNumEntries() const
Returns the maximum number of entries.
virtual int NumGlobalCols() const
virtual int NumMyNonzeros() const
virtual int ExtractDiagonalCopy(Epetra_Vector &Diagonal) const
int SetUseTranspose(bool UseTranspose_in)
virtual int RightScale(const Epetra_Vector &x)
double RelativeThreshold_
Multiplies A(i,i) by this value.
Ifpack_DiagonalFilter: Filter to modify the diagonal entries of a given Epetra_RowMatrix.
virtual int ApplyInverse(const Epetra_MultiVector &X, Epetra_MultiVector &Y) const
virtual int Multiply(bool TransA, const Epetra_MultiVector &X, Epetra_MultiVector &Y) const
virtual bool LowerTriangular() const
virtual int ExtractMyRowCopy(int MyRow, int Length, int &NumEntries, double *Values, int *Indices) const
virtual int NumMyRowEntries(int MyRow, int &NumEntries) const
Returns the number of entries in MyRow.
virtual int NumGlobalNonzeros() const
virtual int NumMyRows() const
virtual double NormInf() const
Not implemented for efficiency reasons.
const Epetra_Map & OperatorRangeMap() const
bool HasNormInf() const
Not implemented for efficiency reasons.
const Epetra_BlockMap & Map() const
virtual int Apply(const Epetra_MultiVector &X, Epetra_MultiVector &Y) const
const Epetra_Comm & Comm() const
virtual ~Ifpack_DiagonalFilter()
Destructor.
virtual int Solve(bool Upper, bool Trans, bool UnitDiagonal, const Epetra_MultiVector &X, Epetra_MultiVector &Y) const
virtual int NumGlobalRows() const
virtual int NumMyCols() const
virtual const Epetra_Import * RowMatrixImporter() const
virtual int LeftScale(const Epetra_Vector &x)
Ifpack_DiagonalFilter(const Teuchos::RefCountPtr< Epetra_RowMatrix > &Matrix, double AbsoluteThreshold, double RelativeThreshold)
Constructor.
virtual const Epetra_Map & RowMatrixRowMap() const
#define IFPACK_RETURN(ifpack_err)
virtual const Epetra_Map & RowMatrixColMap() const
virtual int InvRowSums(Epetra_Vector &x) const
virtual long long NumGlobalDiagonals64() const
const Epetra_Map & OperatorDomainMap() const
virtual long long NumGlobalCols64() const
double AbsoluteThreshold_
This value (times the sgn(A(i,i)) is added to the diagonal elements.
virtual bool UpperTriangular() const
virtual double NormOne() const
Not implemented for efficiency reasons.
virtual int NumMyDiagonals() const
const char * Label() const
#define IFPACK_CHK_ERR(ifpack_err)
std::vector< double > val_
Stores as additional diagonal contribution due to the filter.
virtual int NumGlobalDiagonals() const