Ifpack Package Browser (Single Doxygen Collection)
Development
Toggle main menu visibility
Loading...
Searching...
No Matches
src
Ifpack_ReorderFilter.cpp
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
#include "
Ifpack_ConfigDefs.h
"
44
#include "
Ifpack_ReorderFilter.h
"
45
#include "
Ifpack_Reordering.h
"
46
#include "
Epetra_ConfigDefs.h
"
47
#include "
Epetra_RowMatrix.h
"
48
#include "
Epetra_Comm.h
"
49
#include "
Epetra_Map.h
"
50
#include "
Epetra_MultiVector.h
"
51
#include "
Epetra_Vector.h
"
52
53
//==============================================================================
54
Ifpack_ReorderFilter::Ifpack_ReorderFilter
(
const
Teuchos::RefCountPtr<Epetra_RowMatrix>& Matrix_in,
55
const
Teuchos::RefCountPtr<Ifpack_Reordering>& Reordering_in) :
56
A_
(Matrix_in),
57
Reordering_
(Reordering_in),
58
NumMyRows_
(Matrix_in->
NumMyRows
()),
59
MaxNumEntries_
(Matrix_in->
MaxNumEntries
())
60
{
61
}
62
63
//==============================================================================
64
Ifpack_ReorderFilter::Ifpack_ReorderFilter
(
const
Ifpack_ReorderFilter
&
RHS
) :
65
A_
(
Matrix
()),
66
Reordering_
(
Reordering
()),
67
NumMyRows_
(
RHS
.
NumMyRows
()),
68
MaxNumEntries_
(
RHS
.
MaxNumEntries
())
69
{
70
strcpy(
Label_
,
RHS
.Label());
71
}
72
73
//==============================================================================
74
Ifpack_ReorderFilter
&
75
Ifpack_ReorderFilter::operator=
(
const
Ifpack_ReorderFilter
&
RHS
)
76
{
77
if
(
this
== &
RHS
)
78
return
(*
this
);
79
80
A_
=
RHS
.Matrix();
81
82
Reordering_
=
RHS
.Reordering();
83
MaxNumEntries_
=
RHS
.MaxNumEntries();
84
NumMyRows_
=
RHS
.NumMyRows();
85
86
strcpy(
Label_
,
RHS
.Label());
87
return
(*
this
);
88
}
89
90
//==============================================================================
91
int
Ifpack_ReorderFilter::
92
ExtractMyRowCopy
(
int
MyRow,
int
/* Length */
,
int
& NumEntries,
93
double
*Values,
int
* Indices)
const
94
{
95
int
MyReorderdRow =
Reordering_
->InvReorder(MyRow);
96
97
IFPACK_CHK_ERR
(
Matrix
()->
ExtractMyRowCopy
(MyReorderdRow,
MaxNumEntries_
,
98
NumEntries, Values,Indices));
99
100
// suppose all elements are local. Note that now
101
// Indices can have indices in non-increasing order.
102
for
(
int
i = 0 ; i < NumEntries ; ++i) {
103
Indices[i] =
Reordering_
->Reorder(Indices[i]);
104
}
105
106
return
(0);
107
}
108
109
//==============================================================================
110
int
Ifpack_ReorderFilter::
111
ExtractDiagonalCopy
(
Epetra_Vector
& Diagonal)
const
112
{
113
Epetra_Vector
DiagonalTilde(Diagonal.
Map
());
114
IFPACK_CHK_ERR
(
Matrix
()->
ExtractDiagonalCopy
(DiagonalTilde));
115
IFPACK_CHK_ERR
((
Reordering_
->P(DiagonalTilde,Diagonal)));
116
return
(0);
117
}
118
119
//==============================================================================
120
int
Ifpack_ReorderFilter::
121
Multiply
(
bool
TransA,
const
Epetra_MultiVector
& X,
122
Epetra_MultiVector
& Y)
const
123
{
124
// need two additional vectors
125
Epetra_MultiVector
Xtilde(X.
Map
(),X.
NumVectors
());
126
Epetra_MultiVector
Ytilde(Y.
Map
(),Y.
NumVectors
());
127
// bring X back to original ordering
128
Reordering_
->Pinv(X,Xtilde);
129
// apply original matrix
130
IFPACK_CHK_ERR
(
Matrix
()->
Multiply
(TransA,Xtilde,Ytilde));
131
// now reorder result
132
Reordering_
->P(Ytilde,Y);
133
134
135
return
(0);
136
}
137
138
//==============================================================================
139
int
Ifpack_ReorderFilter::
140
Solve
(
bool
/* Upper */
,
bool
/* Trans */
,
bool
/* UnitDiagonal */
,
141
const
Epetra_MultiVector
&
/* X */
,
Epetra_MultiVector
&
/* Y */
)
const
142
{
143
IFPACK_CHK_ERR
(-98);
144
}
145
146
//==============================================================================
147
int
Ifpack_ReorderFilter::
148
Apply
(
const
Epetra_MultiVector
& X,
Epetra_MultiVector
& Y)
const
149
{
150
int
ierr =
Multiply
(
UseTranspose
(),X,Y);
151
IFPACK_RETURN
(ierr);
152
}
Epetra_Comm.h
Epetra_ConfigDefs.h
Epetra_Map.h
Epetra_MultiVector.h
Epetra_RowMatrix.h
Epetra_Vector.h
Ifpack_ConfigDefs.h
IFPACK_RETURN
#define IFPACK_RETURN(ifpack_err)
Definition
Ifpack_ConfigDefs.h:139
IFPACK_CHK_ERR
#define IFPACK_CHK_ERR(ifpack_err)
Definition
Ifpack_ConfigDefs.h:125
Ifpack_ReorderFilter.h
Ifpack_Reordering.h
RHS
#define RHS(a)
Definition
MatGenFD.c:60
Epetra_DistObject::Map
const Epetra_BlockMap & Map() const
Epetra_MultiVector
Epetra_MultiVector::NumVectors
int NumVectors() const
Epetra_Vector
Ifpack_ReorderFilter
Ifpack_ReorderFilter: a class for light-weight reorder of local rows and columns of an Epetra_RowMatr...
Definition
Ifpack_ReorderFilter.h:81
Ifpack_ReorderFilter::UseTranspose
bool UseTranspose() const
Returns true if the transpose of this matrix is used.
Definition
Ifpack_ReorderFilter.h:289
Ifpack_ReorderFilter::MaxNumEntries
virtual int MaxNumEntries() const
Returns maximum num entries.
Definition
Ifpack_ReorderFilter.h:104
Ifpack_ReorderFilter::NumMyRows
virtual int NumMyRows() const
Returns the number of local rows.
Definition
Ifpack_ReorderFilter.h:235
Ifpack_ReorderFilter::ExtractMyRowCopy
virtual int ExtractMyRowCopy(int MyRow, int Length, int &NumEntries, double *Values, int *Indices) const
Definition
Ifpack_ReorderFilter.cpp:92
Ifpack_ReorderFilter::Ifpack_ReorderFilter
Ifpack_ReorderFilter(const Teuchos::RefCountPtr< Epetra_RowMatrix > &Matrix_in, const Teuchos::RefCountPtr< Ifpack_Reordering > &Reordering_in)
Definition
Ifpack_ReorderFilter.cpp:54
Ifpack_ReorderFilter::Matrix
Teuchos::RefCountPtr< Epetra_RowMatrix > Matrix() const
Returns a reference-counted pointer to the internally stored pointer to Epetra_RowMatrix.
Definition
Ifpack_ReorderFilter.h:330
Ifpack_ReorderFilter::MaxNumEntries_
int MaxNumEntries_
Maximum number of entries in A_.
Definition
Ifpack_ReorderFilter.h:349
Ifpack_ReorderFilter::Multiply
virtual int Multiply(bool TransA, const Epetra_MultiVector &X, Epetra_MultiVector &Y) const
Multiplies multi-vector X with the reordered matrix, returns result in Y.
Definition
Ifpack_ReorderFilter.cpp:121
Ifpack_ReorderFilter::ExtractDiagonalCopy
virtual int ExtractDiagonalCopy(Epetra_Vector &Diagonal) const
Extracts a copy of the diagonal of the reordered matrix.
Definition
Ifpack_ReorderFilter.cpp:111
Ifpack_ReorderFilter::A_
Teuchos::RefCountPtr< Epetra_RowMatrix > A_
Pointer to the matrix to be preconditioned.
Definition
Ifpack_ReorderFilter.h:342
Ifpack_ReorderFilter::NumMyRows_
int NumMyRows_
Number of local rows of A_.
Definition
Ifpack_ReorderFilter.h:347
Ifpack_ReorderFilter::Apply
virtual int Apply(const Epetra_MultiVector &X, Epetra_MultiVector &Y) const
Applies the reordered matrix to multi-vector X, returns the result in Y.
Definition
Ifpack_ReorderFilter.cpp:148
Ifpack_ReorderFilter::Reordering_
Teuchos::RefCountPtr< Ifpack_Reordering > Reordering_
Pointer to the reordering to be used (already constructed).
Definition
Ifpack_ReorderFilter.h:344
Ifpack_ReorderFilter::Label_
char Label_[80]
Label for this object.
Definition
Ifpack_ReorderFilter.h:351
Ifpack_ReorderFilter::operator=
Ifpack_ReorderFilter & operator=(const Ifpack_ReorderFilter &RHS)
Operator assignment.
Definition
Ifpack_ReorderFilter.cpp:75
Ifpack_ReorderFilter::Reordering
Teuchos::RefCountPtr< Ifpack_Reordering > Reordering() const
Returns a reference-counted pointer to the internally stored pointer to Ifpack_Reordering....
Definition
Ifpack_ReorderFilter.h:335
Ifpack_ReorderFilter::Solve
virtual int Solve(bool Upper, bool Trans, bool UnitDiagonal, const Epetra_MultiVector &X, Epetra_MultiVector &Y) const
Solve, not implemented.
Definition
Ifpack_ReorderFilter.cpp:140
Generated by
1.17.0