IFPACK  Development
 All Classes Namespaces Files Functions Variables Enumerations Friends Pages
Ifpack_SingletonFilter.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_SINGLETONFILTER_H
44 #define IFPACK_SINGLETONFILTER_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_SingletonFilter : public virtual Epetra_RowMatrix {
59 
60 public:
62  Ifpack_SingletonFilter(const Teuchos::RefCountPtr<Epetra_RowMatrix>& Matrix);
63 
66 
68  virtual inline int NumMyRowEntries(int MyRow, int & /* NumEntries */) const
69  {
70  return(NumEntries_[MyRow]);
71  }
72 
74  virtual int MaxNumEntries() const
75  {
76  return(MaxNumEntries_);
77  }
78 
79  virtual int ExtractMyRowCopy(int MyRow, int Length, int & NumEntries, double *Values, int * Indices) const;
80 
81  virtual int ExtractDiagonalCopy(Epetra_Vector & Diagonal) const;
82 
83  virtual int Multiply(bool TransA, const Epetra_MultiVector& X,
84  Epetra_MultiVector& Y) const;
85 
86  virtual int Solve(bool Upper, bool Trans, bool UnitDiagonal,
87  const Epetra_MultiVector& X,
88  Epetra_MultiVector& Y) const;
89 
90  virtual int Apply(const Epetra_MultiVector& X,
91  Epetra_MultiVector& Y) const;
92 
93  virtual int ApplyInverse(const Epetra_MultiVector& X,
94  Epetra_MultiVector& Y) const;
95 
96  virtual int InvRowSums(Epetra_Vector& /* x */) const
97  {
98  return(-98); // NOT IMPLEMENTED
99  }
100 
101  virtual int LeftScale(const Epetra_Vector& /* x */)
102  {
103  return(-98); // NOT IMPLEMENTED
104  }
105 
106  virtual int InvColSums(Epetra_Vector& /* x */) const
107  {
108  return(-98); // NOT IMPLEMENTED
109  }
110 
111  virtual int RightScale(const Epetra_Vector& /* x */)
112  {
113  return(-98); // NOT IMPLEMENTED
114  }
115 
116  virtual bool Filled() const
117  {
118  return(A_->Filled());
119  }
120 
121  virtual double NormInf() const
122  {
123  return(-1.0);
124  }
125 
126  virtual double NormOne() const
127  {
128  return(-1.0);
129  }
130 
131 #ifndef EPETRA_NO_32BIT_GLOBAL_INDICES
132  virtual int NumGlobalNonzeros() const
133  {
134  return(NumNonzeros_);
135  }
136 
137  virtual int NumGlobalRows() const
138  {
139  return(NumRows_);
140  }
141 
142  virtual int NumGlobalCols() const
143  {
144  return(NumRows_);
145  }
146 
147  virtual int NumGlobalDiagonals() const
148  {
149  return(NumRows_);
150  }
151 #endif
152 
153  virtual long long NumGlobalNonzeros64() const
154  {
155  return(NumNonzeros_);
156  }
157 
158  virtual long long NumGlobalRows64() const
159  {
160  return(NumRows_);
161  }
162 
163  virtual long long NumGlobalCols64() const
164  {
165  return(NumRows_);
166  }
167 
168  virtual long long NumGlobalDiagonals64() const
169  {
170  return(NumRows_);
171  }
172 
173  virtual int NumMyNonzeros() const
174  {
175  return(NumNonzeros_);
176  }
177 
178  virtual int NumMyRows() const
179  {
180  return(NumRows_);
181  }
182 
183  virtual int NumMyCols() const
184  {
185  return(NumRows_);
186  }
187 
188  virtual int NumMyDiagonals() const
189  {
190  return(NumRows_);
191  }
192 
193  virtual bool LowerTriangular() const
194  {
195  return(false);
196  }
197 
198  virtual bool UpperTriangular() const
199  {
200  return(false);
201  }
202 
203  virtual const Epetra_Map & RowMatrixRowMap() const
204  {
205  return(*Map_);
206  }
207 
208  virtual const Epetra_Map & RowMatrixColMap() const
209  {
210  return(*Map_);
211  }
212 
213  virtual const Epetra_Import * RowMatrixImporter() const
214  {
215  return(A_->RowMatrixImporter());
216  }
217 
218  int SetUseTranspose(bool UseTranspose_in)
219  {
220  return(A_->SetUseTranspose(UseTranspose_in));
221  }
222 
223  bool UseTranspose() const
224  {
225  return(A_->UseTranspose());
226  }
227 
228  bool HasNormInf() const
229  {
230  return(false);
231  }
232 
233  const Epetra_Comm & Comm() const
234  {
235  return(A_->Comm());
236  }
237 
238  const Epetra_Map & OperatorDomainMap() const
239  {
240  return(*Map_);
241  }
242 
243  const Epetra_Map & OperatorRangeMap() const
244  {
245  return(*Map_);
246  }
247 
248  const Epetra_BlockMap& Map() const
249  {
250  return(*(const Epetra_BlockMap*)(&*Map_));
251  }
252 
253  const char* Label() const{
254  return(Label_);
255  }
256 
257  int SolveSingletons(const Epetra_MultiVector& RHS,
258  Epetra_MultiVector& LHS);
259 
260  int CreateReducedRHS(const Epetra_MultiVector& LHS,
261  const Epetra_MultiVector& RHS,
262  Epetra_MultiVector& ReducedRHS);
263 
264  int UpdateLHS(const Epetra_MultiVector& ReducedLHS,
265  Epetra_MultiVector& LHS);
266 
267 private:
268 
270  Teuchos::RefCountPtr<Epetra_RowMatrix> A_;
271 
273  mutable std::vector<int> Indices_;
275  mutable std::vector<double> Values_;
277  char Label_[80];
278 
279  int NumSingletons_;
280  std::vector<int> SingletonIndex_;
281 
282  std::vector<int> Reorder_;
283  std::vector<int> InvReorder_;
284 
285  std::vector<int> NumEntries_;
286 
287  int NumRows_;
288  int NumRowsA_;
289  int MaxNumEntries_;
290  int MaxNumEntriesA_;
291  int NumNonzeros_;
292  Teuchos::RefCountPtr<Epetra_Map> Map_;
293 
294  Teuchos::RefCountPtr<Epetra_Vector> Diagonal_;
295 
296 };
297 
298 #endif /* IFPACK_SINGLETONFILTER_H */
Ifpack_SingletonFilter(const Teuchos::RefCountPtr< Epetra_RowMatrix > &Matrix)
Constructor.
virtual int NumMyRowEntries(int MyRow, int &) const
Returns the number of entries in MyRow.
virtual ~Ifpack_SingletonFilter()
Destructor.
Ifpack_SingletonFilter: Filter based on matrix entries.
virtual int MaxNumEntries() const
Returns the maximum number of entries.