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