IFPACK Development
Loading...
Searching...
No Matches
Ifpack_NodeFilter.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_NODEFILTER_H
44#define IFPACK_NODEFILTER_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#ifdef IFPACK_NODE_AWARE_CODE
53
54#include "Ifpack_ConfigDefs.h"
55#ifdef HAVE_MPI
56#include "Epetra_MpiComm.h"
57#else
58#include "Epetra_SerialComm.h"
59#endif
60#include "Epetra_RowMatrix.h"
61#include "Epetra_CrsMatrix.h"
62#include "Epetra_IntVector.h"
63#include "Teuchos_RCP.hpp"
64#include "Ifpack_OverlappingRowMatrix.h"
65class Epetra_Map;
67class Epetra_Vector;
68class Epetra_Import;
69class Epetra_BlockMap;
70
72
106class Ifpack_NodeFilter : public virtual Epetra_RowMatrix {
107
108public:
110
111 Ifpack_NodeFilter(const Teuchos::RCP<const Epetra_RowMatrix>& Matrix, int nodeID);
112 //Ifpack_NodeFilter(const Teuchos::RCP<const Epetra_RowMatrix>& Matrix,const Epetra_Comm *);
113
115
116
117 ~Ifpack_NodeFilter(){
118 if(Ac_LIDMap_) delete [] Ac_LIDMap_;
119 if(Bc_LIDMap_) delete [] Bc_LIDMap_;
120 if(Ar_LIDMap_) delete [] Ar_LIDMap_;
121 if(Br_LIDMap_) delete [] Br_LIDMap_;
122 if(tempX_) delete [] tempX_;
123 if(tempY_) delete [] tempY_;
124 if(ImportVector_) delete ImportVector_;
125
126 };
128
130
132
140 virtual int NumMyRowEntries(int MyRow, int & NumEntries) const
141 {
142 NumEntries = NumEntries_[MyRow];
143 return(0);
144 }
145
147 virtual int MaxNumEntries() const
148 {
149 return(MaxNumEntries_);
150 }
151
153
167 virtual inline int ExtractMyRowCopy(int MyRow, int Length, int & NumEntries, double *Values, int * Indices) const;
168
170
176 virtual int ExtractDiagonalCopy(Epetra_Vector & Diagonal) const;
178
180
182
192 virtual int Multiply(bool TransA, const Epetra_MultiVector& X, Epetra_MultiVector& Y) const
193 {
194 if (TransA == true) {
195 IFPACK_CHK_ERR(-1);
196 }
197
198 IFPACK_CHK_ERR(Apply(X,Y));
199 return(0);
200 }
201
203 virtual int Solve(bool Upper, bool Trans, bool UnitDiagonal, const Epetra_MultiVector& X,
204 Epetra_MultiVector& Y) const
205 {
206 IFPACK_RETURN(-1); // not implemented
207 }
208
209 virtual int Apply(const Epetra_MultiVector& X,
210 Epetra_MultiVector& Y) const;
211
212 virtual int ApplyInverse(const Epetra_MultiVector& X,
213 Epetra_MultiVector& Y) const;
215 virtual int InvRowSums(Epetra_Vector& x) const
216 {
217 IFPACK_RETURN(-1); // not implemented
218 }
219
221 virtual int LeftScale(const Epetra_Vector& x)
222 {
223 IFPACK_RETURN(-1); // not implemented
224 }
225
227 virtual int InvColSums(Epetra_Vector& x) const
228 {
229 IFPACK_RETURN(-1); // not implemented
230 }
231
232
234 virtual int RightScale(const Epetra_Vector& x)
235 {
236 IFPACK_RETURN(-1); // not implemented
237 }
238
240
242
244 virtual bool Filled() const
245 {
246 return true;
247 }
248
250 /* Returns the quantity \f$ \| A \|_\infty\f$ such that
251 \f[\| A \|_\infty = \max_{1\lei\len} \sum_{i=1}^m |a_{ij}| \f].
252 */
253 virtual double NormInf() const
254 {
255 return(-1.0);
256 }
257
259 /* Returns the quantity \f$ \| A \|_1\f$ such that
260 \f[\| A \|_1= \max_{1\lej\len} \sum_{j=1}^n |a_{ij}| \f].
261 */
262 virtual double NormOne() const
263 {
264 IFPACK_RETURN(-1.0);
265 }
266
268 virtual int NumGlobalNonzeros() const
269 {
270 return(NumGlobalNonzeros_);
271 }
272
274 virtual int NumGlobalRows() const
275 {
276 return(NumGlobalRows_);
277 }
278
280 virtual int NumGlobalCols() const
281 {
282 return(NumGlobalRows_);
283 }
284
286 virtual int NumGlobalDiagonals() const
287 {
288 return(NumGlobalRows_);
289 }
290
292 virtual int NumMyNonzeros() const
293 {
294 return(NumMyNonzeros_);
295 }
296
298 virtual int NumMyRows() const
299 {
300 return(NumMyRows_);
301 }
302
304 virtual int NumMyCols() const
305 {
306 return(NumMyCols_);
307 }
308
310 virtual int NumMyDiagonals() const
311 {
312 return(NumMyRows_);
313 }
314
316 virtual bool LowerTriangular() const
317 {
318 return(Matrix_->LowerTriangular());
319 }
320
322 virtual bool UpperTriangular() const
323 {
324 return(Matrix_->UpperTriangular());
325 }
326
328 virtual const Epetra_Map & RowMatrixRowMap() const
329 {
330 return(*Map_);
331 }
332
334 virtual const Epetra_Map & RowMatrixColMap() const
335 {
336 return(*colMap_);
337 }
338
340 virtual const Epetra_Import * RowMatrixImporter() const
341 {
342 return(&*Importer_);
343 }
345
346 virtual const Epetra_Import* Importer() const {return(&*Importer_);}
347
348 virtual const Epetra_Export* Exporter() const {return(&*Exporter_);}
349
350 // following functions are required to derive Epetra_RowMatrix objects.
351
353 int SetOwnership(bool ownership)
354 {
355 IFPACK_RETURN(-1);
356 }
357
359 int SetUseTranspose(bool UseTranspose_in)
360 {
361 UseTranspose_ = UseTranspose_in;
362 return(0);
363 }
364
366 bool UseTranspose() const
367 {
368 return(UseTranspose_);
369 }
370
372 bool HasNormInf() const
373 {
374 return(false);
375 }
376
378 const Epetra_Comm & Comm() const
379 {
380 return(*SubComm_);
381 }
382
384 const Epetra_Map & OperatorDomainMap() const
385 {
386 return(*Map_);
387 }
388
390 const Epetra_Map & OperatorRangeMap() const
391 {
392 return(*Map_);
393 }
395
396const Epetra_BlockMap& Map() const;
397
398const char* Label() const{
399 return(Label_);
400};
401
402private:
403 void UpdateImportVector(int NumVectors) const;
404 void UpdateExportVector(int NumVectors) const;
405
407 Teuchos::RCP<const Epetra_RowMatrix> Matrix_;
408 const Ifpack_OverlappingRowMatrix* ovA_;
409#ifdef HAVE_MPI
411 Teuchos::RCP<Epetra_MpiComm> SubComm_;
412 MPI_Comm nodeMPIComm_;
413#else
415 Teuchos::RCP<Epetra_SerialComm> SubComm_;
416#endif
418 Teuchos::RCP<Epetra_Map> Map_;
420 Teuchos::RCP<Epetra_Map> colMap_;
422 int NumMyRows_;
424 int NumMyCols_;
426 int NumMyNonzeros_;
428 int NumGlobalRows_;
430 int NumGlobalNonzeros_;
432 int MaxNumEntries_;
434 int MaxNumEntriesA_;
436 std::vector<int> NumEntries_;
438 mutable std::vector<int> Indices_;
440 mutable std::vector<double> Values_;
442 bool UseTranspose_;
444 char Label_[80];
445 Teuchos::RCP<Epetra_Vector> Diagonal_;
446 double NormOne_;
447 double NormInf_;
448
450 int* Ac_LIDMap_;
451 int* Bc_LIDMap_;
452 int* Ar_LIDMap_;
453 int* Br_LIDMap_;
454
456 const Epetra_CrsMatrix* Acrs_;
457
458 int NumMyRowsA_;
459 int NumMyColsA_;
460 double *tempX_,*tempY_;
461 int NumMyRowsB_;
462
463 //mutable Teuchos::RCP<Epetra_MultiVector> ImportVector_;
464 //mutable Teuchos::RCP<Epetra_MultiVector> ExportVector_;
465 mutable Epetra_MultiVector* ExportVector_;
466 mutable Epetra_MultiVector* ImportVector_;
467 Teuchos::RCP<Epetra_Import> Importer_;
468 Teuchos::RCP<Epetra_Export> Exporter_;
469
470};
471#endif //ifdef IFPACK_NODE_AWARE_CODE
472#endif /* IFPACK_NODEFILTER_H */
virtual int SetUseTranspose(bool UseTranspose)=0
virtual int Apply(const Epetra_MultiVector &X, Epetra_MultiVector &Y) const=0
virtual const Epetra_Comm & Comm() const=0
virtual const char * Label() const=0
virtual int ApplyInverse(const Epetra_MultiVector &X, Epetra_MultiVector &Y) const=0
virtual const Epetra_Map & OperatorDomainMap() const=0
virtual bool HasNormInf() const=0
virtual const Epetra_Map & OperatorRangeMap() const=0
virtual bool UseTranspose() const=0
virtual int NumMyRows() const=0
virtual int NumMyCols() const=0
virtual int Multiply(bool TransA, const Epetra_MultiVector &X, Epetra_MultiVector &Y) const=0
virtual int ExtractDiagonalCopy(Epetra_Vector &Diagonal) const=0
virtual int NumGlobalCols() const=0
virtual int NumGlobalNonzeros() const=0
virtual const Epetra_Map & RowMatrixColMap() const=0
virtual const Epetra_Map & RowMatrixRowMap() const=0
virtual int NumMyNonzeros() const=0
virtual int NumMyDiagonals() const=0
virtual int NumMyRowEntries(int MyRow, int &NumEntries) const=0
virtual int Solve(bool Upper, bool Trans, bool UnitDiagonal, const Epetra_MultiVector &X, Epetra_MultiVector &Y) const=0
virtual int NumGlobalRows() const=0
virtual bool LowerTriangular() const=0
virtual int NumGlobalDiagonals() const=0
virtual int MaxNumEntries() const=0
virtual int ExtractMyRowCopy(int MyRow, int Length, int &NumEntries, double *Values, int *Indices) const=0
virtual int InvRowSums(Epetra_Vector &x) const=0
virtual const Epetra_Import * RowMatrixImporter() const=0
virtual bool UpperTriangular() const=0
virtual int RightScale(const Epetra_Vector &x)=0
virtual double NormOne() const=0
virtual double NormInf() const=0
virtual bool Filled() const=0
virtual int InvColSums(Epetra_Vector &x) const=0
virtual int LeftScale(const Epetra_Vector &x)=0
virtual const Epetra_BlockMap & Map() const=0
Ifpack_OverlappingRowMatrix: matrix with ghost rows, based on Epetra_RowMatrix.