|
EpetraExt Development
|
Implements Epetra_Operator as a product of one or more Epetra_Operator objects.
More...
#include <EpetraExt_ProductOperator.h>
Public types | |
| enum | EApplyMode { APPLY_MODE_APPLY, APPLY_MODE_APPLY_INVERSE } |
| More... | |
Constructors / initializers / accessors | |
| ProductOperator () | |
| Construct to uninitialized. | |
| ProductOperator (const int num_Op, const Teuchos::RefCountPtr< const Epetra_Operator > Op[], const Teuchos::ETransp Op_trans[], const EApplyMode Op_inverse[]) | |
Calls initialize(). | |
| void | initialize (const int num_Op, const Teuchos::RefCountPtr< const Epetra_Operator > Op[], const Teuchos::ETransp Op_trans[], const EApplyMode Op_inverse[]) |
| Setup with constituent operators. | |
| void | uninitialize (int *num_Op, Teuchos::RefCountPtr< const Epetra_Operator > Op[], Teuchos::ETransp Op_trans[], EApplyMode p_inverse[]) |
| Set to an uninitialized state and wipe out memory. | |
| void | applyConstituent (const int k, Teuchos::ETransp Op_trans, EApplyMode Op_inverse, const Epetra_MultiVector &X_k, Epetra_MultiVector *Y_k) const |
| Apply the kth aggregate operator M[k] correctly. | |
| int | num_Op () const |
| Return the number of aggregate opeators. | |
| Teuchos::RefCountPtr< const Epetra_Operator > | Op (int k) const |
| Access the kth operator (zero-based). | |
| Teuchos::ETransp | Op_trans (int k) const |
| Access the transpose mode of the kth operator (zero-based). | |
| EApplyMode | Op_inverse (int k) const |
| Access the inverse mode of the kth operator (zero-based). | |
Overridden from Epetra_Operator | |
| int | SetUseTranspose (bool UseTranspose) |
| | |
| int | Apply (const Epetra_MultiVector &X, Epetra_MultiVector &Y) const |
| | |
| int | ApplyInverse (const Epetra_MultiVector &X, Epetra_MultiVector &Y) const |
| | |
| double | NormInf () const |
| | |
| const char * | Label () const |
| | |
| bool | UseTranspose () const |
| | |
| bool | HasNormInf () const |
| | |
| const Epetra_Comm & | Comm () const |
| | |
| const Epetra_Map & | OperatorDomainMap () const |
| | |
| const Epetra_Map & | OperatorRangeMap () const |
| | |
Implements Epetra_Operator as a product of one or more Epetra_Operator objects.
This class implements a product operator of the form:
M = M[0]*M[1]*...*M[num_Op-1]
and operator applications are performed one constituent operator at a time as:
Forward Mat-vec: Y = M * X
T[k-1] = M[k]*T[k]
for k = num_Op-1...0
where: T[num_Op-1] = X (input vector)
where: T[-1] = Y (output vector)
Adjoint Mat-vec: Y = M' * X
T[k] = M[k]'*T[k-1]
for k = 0...num_Op-1
where: T[-1] = X (input vector)
where: T[num_Op-1] = Y (output vector)
Likewise, the inverse can also be applied (if all of the constituent operators support the inverse operation) as:
Forward Inverse Mat-vec: Y = inv(M) * X
T[k] = inv(M[k])*T[k-1]
for k = 0...num_Op-1
for k = 0...num_Op-1
where: T[-1] = X (input vector)
where: T[num_Op-1] = Y (output vector)
Adjoint Inverse Mat-vec: Y = inv(M') * X
T[k] = inv(M[k]')*T[k-1]
for k = num_Op-1...0
where: T[num_Op-1] = X (input vector)
where: T[-1] = Y (output vector)
Note that maps for the result of the inverse of an operator is the same as the result of the adjoint of the operator and the map for the result of the inverse of the adjoint is the same as for the result the non-inverse forward opeator.
The client constructs this object with a list of Epetra_Operator objects an how the non-transposed operator is to be viewed and if it is to be views as its inverse or not (see initialize()).
Note: The Epetra_Map objects returned from OperatorDomainMap() and OperatorRangeMap() must always be with respect to the non-transposed operator! This is very strange behavior and is totally undocumented in the Epetra_Operator interface but it seems to be the case.
Definition at line 119 of file EpetraExt_ProductOperator.h.
Definition at line 126 of file EpetraExt_ProductOperator.h.
| EpetraExt::ProductOperator::ProductOperator | ( | ) |
Construct to uninitialized.
Definition at line 37 of file EpetraExt_ProductOperator.cpp.
| EpetraExt::ProductOperator::ProductOperator | ( | const int | num_Op, |
| const Teuchos::RefCountPtr< const Epetra_Operator > | Op[], | ||
| const Teuchos::ETransp | Op_trans[], | ||
| const EApplyMode | Op_inverse[] | ||
| ) |
Calls initialize().
Definition at line 40 of file EpetraExt_ProductOperator.cpp.
| void EpetraExt::ProductOperator::initialize | ( | const int | num_Op, |
| const Teuchos::RefCountPtr< const Epetra_Operator > | Op[], | ||
| const Teuchos::ETransp | Op_trans[], | ||
| const EApplyMode | Op_inverse[] | ||
| ) |
Setup with constituent operators.
| num_Op | [in] Number of constinuent operators. |
| Op | [in] Array (length num_Op) of smart pointers to Epetra_Operator objects that implement each constituent operator. |
| Op_trans | [in] Array (length |
| Op_inverse | [in] Array (length |
Preconditions:
num_Op > 0 Op!=NULL Op[k].get()!=NULL, for k=0...num_Op-1 Op_trans!=NULL Op_inverse!=NULL Postconditions:
this->num_Op()==num_Op this->Op(k).get()==Op[k].get(), for k=0...num_Op-1 this->Op_trans(k)==Op_trans[k], for k=0...num_Op-1 this->Op_inverse(k)==Op_inverse[k], for k=0...num_Op-1 The forward constituent operator T[k-1] = M[k]*T[k] described in the main documenatation above is defined as follows:
Op[k]->SetUseTranspose( Op_trans[k]!=Teuchos::NO_TRANS );
if( Op_inverse[k]==APPLY_MODE_APPLY )
Op[k]->Apply( T[k], T[k-1] );
else
Op[k]->ApplyInverse( T[k], T[k-1] );
The inverse constituent operator T[k] = inv(M[k])*T[k-1] described in the main documenatation above is defined as follows:
Op[k]->SetUseTranspose( Op_trans[k]!=Teuchos::NO_TRANS );
if( Op_inverse[k]==APPLY_MODE_APPLY )
Op[k]->ApplyInverse( T[k-1], T[k] );
else
Op[k]->Apply( T[k-1], T[k] );
The other transposed constituent operators M[k]' and inv(M[k]') are defined by simply changing the value of the transpose as Op[k]->SetUseTranspose( Op_trans[k]==Teuchos::NO_TRANS );. Note, that Op[k]->SetUseTranspose(...) is called immediately before Op[k]->Apply(...) or Op[k]->ApplyInverse(...) is called to avoid tricky problems that could occur with multiple uses of the same operator.
Definition at line 50 of file EpetraExt_ProductOperator.cpp.
| void EpetraExt::ProductOperator::uninitialize | ( | int * | num_Op, |
| Teuchos::RefCountPtr< const Epetra_Operator > | Op[], | ||
| Teuchos::ETransp | Op_trans[], | ||
| EApplyMode | p_inverse[] | ||
| ) |
Set to an uninitialized state and wipe out memory.
Postconditions:
this->num_Op()==0 Definition at line 76 of file EpetraExt_ProductOperator.cpp.
| void EpetraExt::ProductOperator::applyConstituent | ( | const int | k, |
| Teuchos::ETransp | Op_trans, | ||
| EApplyMode | Op_inverse, | ||
| const Epetra_MultiVector & | X_k, | ||
| Epetra_MultiVector * | Y_k | ||
| ) | const |
Apply the kth aggregate operator M[k] correctly.
| k | [in] Gives the index (zero-based) of the constituent operator to apply. |
| Op_trans | [in] Determines if the transpose of the constituent operator is to be applied. |
| Op_inverse | [in] Determines if the operator or its inverse (if supported) should be applied. |
| X_k | [in] The input vector. |
| Y_k | [out] The output vector. |
Clients should call this function to correctly apply a constitient operator!
Definition at line 104 of file EpetraExt_ProductOperator.cpp.
| int EpetraExt::ProductOperator::num_Op | ( | ) | const [inline] |
Return the number of aggregate opeators.
A return value of 0 is a flag that this is not initialized yet.
Definition at line 352 of file EpetraExt_ProductOperator.h.
| Teuchos::RefCountPtr< const Epetra_Operator > EpetraExt::ProductOperator::Op | ( | int | k | ) | const [inline] |
Access the kth operator (zero-based).
Preconditions:
0 <= k <= this->num_Op()-1 Warning! This is the raw opeator passed into initialize(...). In order to apply the constituent operator M[k] you must call ApplyConstituent().
Definition at line 359 of file EpetraExt_ProductOperator.h.
| Teuchos::ETransp EpetraExt::ProductOperator::Op_trans | ( | int | k | ) | const [inline] |
Access the transpose mode of the kth operator (zero-based).
Preconditions:
0 <= k <= this->num_Op()-1 Definition at line 367 of file EpetraExt_ProductOperator.h.
| ProductOperator::EApplyMode EpetraExt::ProductOperator::Op_inverse | ( | int | k | ) | const [inline] |
Access the inverse mode of the kth operator (zero-based).
Preconditions:
0 <= k <= this->num_Op()-1 Definition at line 375 of file EpetraExt_ProductOperator.h.
| int EpetraExt::ProductOperator::SetUseTranspose | ( | bool | UseTranspose | ) |
Definition at line 128 of file EpetraExt_ProductOperator.cpp.
| int EpetraExt::ProductOperator::Apply | ( | const Epetra_MultiVector & | X, |
| Epetra_MultiVector & | Y | ||
| ) | const |
Definition at line 135 of file EpetraExt_ProductOperator.cpp.
| int EpetraExt::ProductOperator::ApplyInverse | ( | const Epetra_MultiVector & | X, |
| Epetra_MultiVector & | Y | ||
| ) | const |
Definition at line 165 of file EpetraExt_ProductOperator.cpp.
| double EpetraExt::ProductOperator::NormInf | ( | ) | const |
Definition at line 195 of file EpetraExt_ProductOperator.cpp.
| const char * EpetraExt::ProductOperator::Label | ( | ) | const |
Definition at line 201 of file EpetraExt_ProductOperator.cpp.
| bool EpetraExt::ProductOperator::UseTranspose | ( | ) | const |
Definition at line 207 of file EpetraExt_ProductOperator.cpp.
| bool EpetraExt::ProductOperator::HasNormInf | ( | ) | const |
Definition at line 213 of file EpetraExt_ProductOperator.cpp.
| const Epetra_Comm & EpetraExt::ProductOperator::Comm | ( | ) | const |
Definition at line 220 of file EpetraExt_ProductOperator.cpp.
| const Epetra_Map & EpetraExt::ProductOperator::OperatorDomainMap | ( | ) | const |
Definition at line 227 of file EpetraExt_ProductOperator.cpp.
| const Epetra_Map & EpetraExt::ProductOperator::OperatorRangeMap | ( | ) | const |
Definition at line 237 of file EpetraExt_ProductOperator.cpp.
1.7.4