43 #include "Epetra_Vector.h"
44 #include "Epetra_Map.h"
55 ,
const Teuchos::RCP<const Epetra_Operator> op[]
56 ,
const Teuchos::ETransp opTrans[]
65 ,
const Teuchos::RCP<const Epetra_Operator> op[]
66 ,
const Teuchos::ETransp opTrans[]
71 TEUCHOS_TEST_FOR_EXCEPTION(
72 numOp < 1, std::invalid_argument
73 ,
"ProductOperator::initialize(...): Error!"
78 Op_trans_.resize(numOp);
79 Op_inverse_.resize(numOp);
80 std::copy( op, op + numOp, Op_.begin() );
81 std::copy( opTrans, opTrans + numOp, Op_trans_.begin() );
82 std::copy( opInverse, opInverse + numOp, Op_inverse_.begin() );
83 UseTranspose_ =
false;
85 range_vecs_.resize(0);
86 domain_vecs_.resize(0);
91 ,Teuchos::RCP<const Epetra_Operator> op[]
92 ,Teuchos::ETransp opTrans[]
97 TEUCHOS_TEST_FOR_EXCEPTION(
98 (op != NULL || opTrans != NULL || opInverse!=NULL) && numOp==NULL
99 ,std::invalid_argument
100 ,
"ProductOperator::uninitialize(...): Error!"
105 if(op) std::copy( Op_.begin(), Op_.end(), op );
106 if(opTrans) std::copy( Op_trans_.begin(), Op_trans_.end(), opTrans );
107 if(opInverse) std::copy( Op_inverse_.begin(), Op_inverse_.end(), opInverse );
109 UseTranspose_ =
false;
112 Op_inverse_.resize(0);
113 range_vecs_.resize(0);
114 domain_vecs_.resize(0);
119 ,Teuchos::ETransp opTrans
127 Op_k.
SetUseTranspose((opTrans==Teuchos::NO_TRANS) != (Op_trans_[k]==Teuchos::NO_TRANS));
129 const int err = ! applyInverse_k ? Op_[k]->Apply(X_k,*Y_k) : Op_[k]->ApplyInverse(X_k,*Y_k);
131 TEUCHOS_TEST_FOR_EXCEPTION(
132 err!=0, std::runtime_error,
"ProductOperator::applyConstituent(...): Error,"
133 " Op["<<k<<
"]." << (!applyInverse_k?
"Apply":
"ApplyInverse") <<
"(...) "
134 "returned err = " << err <<
" with Op["<<k<<
"].UseTranspose() = "<<
143 UseTranspose_ = useTranspose;
150 const int numOp = this->
num_Op();
152 initializeTempVecs(
false);
154 if( !UseTranspose_ ) {
158 for(
int k = numOp-1; k >= 0; --k ) {
164 else if( UseTranspose_ ) {
168 for(
int k = 0; k <= numOp-1; ++k ) {
180 const int numOp = this->
num_Op();
182 initializeTempVecs(
true);
184 if( !UseTranspose_ ) {
188 for(
int k = 0; k <= numOp-1; ++k ) {
194 else if( UseTranspose_ ) {
198 for(
int k = numOp-1; k >= 0; --k ) {
222 return UseTranspose_;
235 return Op_.front()->OperatorRangeMap().Comm();
242 return ( Op_trans_.back()==Teuchos::NO_TRANS
243 ? Op_.back()->OperatorDomainMap()
244 : Op_.back()->OperatorRangeMap()
252 return ( Op_trans_.front()==Teuchos::NO_TRANS
253 ? Op_.front()->OperatorRangeMap()
254 : Op_.front()->OperatorDomainMap()
260 void ProductOperator::initializeTempVecs(
bool applyInverse)
const
262 const int numOp = this->
num_Op ();
269 if (((! UseTranspose_ && ! applyInverse) || (UseTranspose_ && applyInverse))
270 && range_vecs_.size () == 0) {
282 range_vecs_.resize (numOp - 1);
283 for (
int k = numOp-1; k >= 1; --k) {
294 else if (((UseTranspose_ && ! applyInverse) || (! UseTranspose_ && applyInverse))
295 && domain_vecs_.size () == 0) {
307 domain_vecs_.resize (numOp - 1);
308 for (
int k = 0; k <= numOp - 2; ++k) {
virtual int SetUseTranspose(bool UseTranspose)=0
const Epetra_Map & OperatorDomainMap() const
bool UseTranspose() const
int SetUseTranspose(bool UseTranspose)
void initialize(const int num_Op, const Teuchos::RCP< const Epetra_Operator > Op[], const Teuchos::ETransp Op_trans[], const EApplyMode Op_inverse[])
Setup with constituent operators.
const char * Label() const
int ApplyInverse(const Epetra_MultiVector &X, Epetra_MultiVector &Y) const
ProductOperator()
Construct to uninitialized.
const Epetra_Comm & Comm() const
int num_Op() const
Return the number of aggregate opeators.
const Epetra_Map & OperatorRangeMap() const
virtual bool UseTranspose() const =0
int Apply(const Epetra_MultiVector &X, Epetra_MultiVector &Y) const
void uninitialize(int *num_Op, Teuchos::RCP< 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.