Ifpack Package Browser (Single Doxygen Collection) Development
Loading...
Searching...
No Matches
Ifpack_NodeFilter.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_NODEFILTER_H
44#define IFPACK_NODEFILTER_H
45
46#ifdef IFPACK_NODE_AWARE_CODE
47
48#include "Ifpack_ConfigDefs.h"
49#ifdef HAVE_MPI
50#include "Epetra_MpiComm.h"
51#else
52#include "Epetra_SerialComm.h"
53#endif
54#include "Epetra_RowMatrix.h"
55#include "Epetra_CrsMatrix.h"
56#include "Epetra_IntVector.h"
57#include "Teuchos_RCP.hpp"
59class Epetra_Map;
61class Epetra_Vector;
62class Epetra_Import;
63class Epetra_BlockMap;
64
66
100class Ifpack_NodeFilter : public virtual Epetra_RowMatrix {
101
102public:
104
105 Ifpack_NodeFilter(const Teuchos::RCP<const Epetra_RowMatrix>& Matrix, int nodeID);
106 //Ifpack_NodeFilter(const Teuchos::RCP<const Epetra_RowMatrix>& Matrix,const Epetra_Comm *);
107
109
110
111 ~Ifpack_NodeFilter(){
112 if(Ac_LIDMap_) delete [] Ac_LIDMap_;
113 if(Bc_LIDMap_) delete [] Bc_LIDMap_;
114 if(Ar_LIDMap_) delete [] Ar_LIDMap_;
115 if(Br_LIDMap_) delete [] Br_LIDMap_;
116 if(tempX_) delete [] tempX_;
117 if(tempY_) delete [] tempY_;
118 if(ImportVector_) delete ImportVector_;
119
120 };
122
124
126
134 virtual int NumMyRowEntries(int MyRow, int & NumEntries) const
135 {
136 NumEntries = NumEntries_[MyRow];
137 return(0);
138 }
139
141 virtual int MaxNumEntries() const
142 {
143 return(MaxNumEntries_);
144 }
145
147
161 virtual inline int ExtractMyRowCopy(int MyRow, int Length, int & NumEntries, double *Values, int * Indices) const;
162
164
170 virtual int ExtractDiagonalCopy(Epetra_Vector & Diagonal) const;
172
174
176
186 virtual int Multiply(bool TransA, const Epetra_MultiVector& X, Epetra_MultiVector& Y) const
187 {
188 if (TransA == true) {
189 IFPACK_CHK_ERR(-1);
190 }
191
192 IFPACK_CHK_ERR(Apply(X,Y));
193 return(0);
194 }
195
197 virtual int Solve(bool Upper, bool Trans, bool UnitDiagonal, const Epetra_MultiVector& X,
198 Epetra_MultiVector& Y) const
199 {
200 IFPACK_RETURN(-1); // not implemented
201 }
202
203 virtual int Apply(const Epetra_MultiVector& X,
204 Epetra_MultiVector& Y) const;
205
206 virtual int ApplyInverse(const Epetra_MultiVector& X,
207 Epetra_MultiVector& Y) const;
209 virtual int InvRowSums(Epetra_Vector& x) const
210 {
211 IFPACK_RETURN(-1); // not implemented
212 }
213
215 virtual int LeftScale(const Epetra_Vector& x)
216 {
217 IFPACK_RETURN(-1); // not implemented
218 }
219
221 virtual int InvColSums(Epetra_Vector& x) const
222 {
223 IFPACK_RETURN(-1); // not implemented
224 }
225
226
228 virtual int RightScale(const Epetra_Vector& x)
229 {
230 IFPACK_RETURN(-1); // not implemented
231 }
232
234
236
238 virtual bool Filled() const
239 {
240 return true;
241 }
242
244 /* Returns the quantity \f$ \| A \|_\infty\f$ such that
245 \f[\| A \|_\infty = \max_{1\lei\len} \sum_{i=1}^m |a_{ij}| \f].
246 */
247 virtual double NormInf() const
248 {
249 return(-1.0);
250 }
251
253 /* Returns the quantity \f$ \| A \|_1\f$ such that
254 \f[\| A \|_1= \max_{1\lej\len} \sum_{j=1}^n |a_{ij}| \f].
255 */
256 virtual double NormOne() const
257 {
258 IFPACK_RETURN(-1.0);
259 }
260
262 virtual int NumGlobalNonzeros() const
263 {
264 return(NumGlobalNonzeros_);
265 }
266
268 virtual int NumGlobalRows() const
269 {
270 return(NumGlobalRows_);
271 }
272
274 virtual int NumGlobalCols() const
275 {
276 return(NumGlobalRows_);
277 }
278
280 virtual int NumGlobalDiagonals() const
281 {
282 return(NumGlobalRows_);
283 }
284
286 virtual int NumMyNonzeros() const
287 {
288 return(NumMyNonzeros_);
289 }
290
292 virtual int NumMyRows() const
293 {
294 return(NumMyRows_);
295 }
296
298 virtual int NumMyCols() const
299 {
300 return(NumMyCols_);
301 }
302
304 virtual int NumMyDiagonals() const
305 {
306 return(NumMyRows_);
307 }
308
310 virtual bool LowerTriangular() const
311 {
312 return(Matrix_->LowerTriangular());
313 }
314
316 virtual bool UpperTriangular() const
317 {
318 return(Matrix_->UpperTriangular());
319 }
320
322 virtual const Epetra_Map & RowMatrixRowMap() const
323 {
324 return(*Map_);
325 }
326
328 virtual const Epetra_Map & RowMatrixColMap() const
329 {
330 return(*colMap_);
331 }
332
334 virtual const Epetra_Import * RowMatrixImporter() const
335 {
336 return(&*Importer_);
337 }
339
340 virtual const Epetra_Import* Importer() const {return(&*Importer_);}
341
342 virtual const Epetra_Export* Exporter() const {return(&*Exporter_);}
343
344 // following functions are required to derive Epetra_RowMatrix objects.
345
347 int SetOwnership(bool ownership)
348 {
349 IFPACK_RETURN(-1);
350 }
351
353 int SetUseTranspose(bool UseTranspose_in)
354 {
355 UseTranspose_ = UseTranspose_in;
356 return(0);
357 }
358
360 bool UseTranspose() const
361 {
362 return(UseTranspose_);
363 }
364
366 bool HasNormInf() const
367 {
368 return(false);
369 }
370
372 const Epetra_Comm & Comm() const
373 {
374 return(*SubComm_);
375 }
376
378 const Epetra_Map & OperatorDomainMap() const
379 {
380 return(*Map_);
381 }
382
384 const Epetra_Map & OperatorRangeMap() const
385 {
386 return(*Map_);
387 }
389
390const Epetra_BlockMap& Map() const;
391
392const char* Label() const{
393 return(Label_);
394};
395
396private:
397 void UpdateImportVector(int NumVectors) const;
398 void UpdateExportVector(int NumVectors) const;
399
401 Teuchos::RCP<const Epetra_RowMatrix> Matrix_;
402 const Ifpack_OverlappingRowMatrix* ovA_;
403#ifdef HAVE_MPI
405 Teuchos::RCP<Epetra_MpiComm> SubComm_;
406 MPI_Comm nodeMPIComm_;
407#else
409 Teuchos::RCP<Epetra_SerialComm> SubComm_;
410#endif
412 Teuchos::RCP<Epetra_Map> Map_;
414 Teuchos::RCP<Epetra_Map> colMap_;
416 int NumMyRows_;
418 int NumMyCols_;
420 int NumMyNonzeros_;
422 int NumGlobalRows_;
424 int NumGlobalNonzeros_;
426 int MaxNumEntries_;
428 int MaxNumEntriesA_;
430 std::vector<int> NumEntries_;
432 mutable std::vector<int> Indices_;
434 mutable std::vector<double> Values_;
436 bool UseTranspose_;
438 char Label_[80];
439 Teuchos::RCP<Epetra_Vector> Diagonal_;
440 double NormOne_;
441 double NormInf_;
442
444 int* Ac_LIDMap_;
445 int* Bc_LIDMap_;
446 int* Ar_LIDMap_;
447 int* Br_LIDMap_;
448
450 const Epetra_CrsMatrix* Acrs_;
451
452 int NumMyRowsA_;
453 int NumMyColsA_;
454 double *tempX_,*tempY_;
455 int NumMyRowsB_;
456
457 //mutable Teuchos::RCP<Epetra_MultiVector> ImportVector_;
458 //mutable Teuchos::RCP<Epetra_MultiVector> ExportVector_;
459 mutable Epetra_MultiVector* ExportVector_;
460 mutable Epetra_MultiVector* ImportVector_;
461 Teuchos::RCP<Epetra_Import> Importer_;
462 Teuchos::RCP<Epetra_Export> Exporter_;
463
464};
465#endif //ifdef IFPACK_NODE_AWARE_CODE
466#endif /* IFPACK_NODEFILTER_H */
#define IFPACK_RETURN(ifpack_err)
#define IFPACK_CHK_ERR(ifpack_err)
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.
const int NumVectors
Definition: performance.cpp:71