47 #include "Teko_InverseFactoryOperator.hpp"
50 #include "Teko_BasicMappingStrategy.hpp"
53 #include "Thyra_EpetraLinearOp.hpp"
57 using Teuchos::rcp_dynamic_cast;
58 using Teuchos::rcpFromRef;
69 InverseFactoryOperator::InverseFactoryOperator(
const Teuchos::RCP<const InverseFactory>& ifp)
70 : inverseFactory_(ifp), firstBuildComplete_(false), setConstFwdOp_(true) {}
85 if (not clearOld)
return;
86 invOperator_ = Teuchos::null;
103 Teko_DEBUG_SCOPE(
"InverseFactoryOperator::buildInverseOperator", 10);
106 RCP<const Thyra::LinearOpBase<double> > thyraA = extractLinearOp(A);
116 SetOperator(invOperator_,
false);
118 firstBuildComplete_ =
true;
120 if (setConstFwdOp_) fwdOp_ = A;
122 setConstFwdOp_ =
true;
124 TEUCHOS_ASSERT(invOperator_ != Teuchos::null);
126 TEUCHOS_ASSERT(
getThyraOp() != Teuchos::null);
128 TEUCHOS_ASSERT(firstBuildComplete_ ==
true);
133 setConstFwdOp_ =
false;
135 fwdOp_.initialize(A);
139 TEUCHOS_ASSERT(setConstFwdOp_ ==
true);
155 Teko_DEBUG_SCOPE(
"InverseFactoryOperator::rebuildPreconditioner", 10);
158 if (not firstBuildComplete_) {
163 RCP<const Thyra::LinearOpBase<double> > thyraA = extractLinearOp(A);
166 if (setConstFwdOp_) fwdOp_.initialize(A);
168 SetOperator(invOperator_,
false);
170 setConstFwdOp_ =
true;
173 TEUCHOS_ASSERT(invOperator_ != Teuchos::null);
174 TEUCHOS_ASSERT(
getThyraOp() != Teuchos::null);
175 TEUCHOS_ASSERT(firstBuildComplete_ ==
true);
179 setConstFwdOp_ =
false;
181 fwdOp_.initialize(A);
186 TEUCHOS_ASSERT(setConstFwdOp_ ==
true);
189 Teuchos::RCP<const Thyra::LinearOpBase<double> > InverseFactoryOperator::extractLinearOp(
190 const Teuchos::RCP<const Epetra_Operator>& A)
const {
195 if (eow != Teuchos::null)
return eow->
getThyraOp();
198 return Thyra::epetraLinearOp(A);
201 Teuchos::RCP<const MappingStrategy> InverseFactoryOperator::extractMappingStrategy(
202 const Teuchos::RCP<const Epetra_Operator>& A)
const {
204 const RCP<const EpetraOperatorWrapper>& eow = rcp_dynamic_cast<
const EpetraOperatorWrapper>(A);
207 if (eow != Teuchos::null)
return eow->getMapStrategy();
210 RCP<const Epetra_Map> range = rcpFromRef(A->OperatorRangeMap());
211 RCP<const Epetra_Map> domain = rcpFromRef(A->OperatorDomainMap());
212 return rcp(
new BasicMappingStrategy(range, domain, A->Comm()));
void rebuildInverse(const InverseFactory &factory, const LinearOp &A, InverseLinearOp &invA)
Teuchos::RCP< const Epetra_Operator > getForwardOp() const
virtual void rebuildInverseOperator(const Teuchos::RCP< const Epetra_Operator > &A)
Rebuild this inverse from an Epetra_Operator passed in this to object.
Implements the Epetra_Operator interface with a Thyra LinearOperator. This enables the use of absrtac...
virtual void initInverse(bool clearOld=false)
Build the underlying data structure for the inverse operator.
Flip a mapping strategy object around to give the "inverse" mapping strategy.
const RCP< const MappingStrategy > getMapStrategy() const
Get the mapping strategy for this wrapper (translate between Thyra and Epetra)
InverseLinearOp buildInverse(const InverseFactory &factory, const LinearOp &A)
Build an inverse operator using a factory and a linear operator.
const RCP< const Thyra::LinearOpBase< double > > getThyraOp() const
Return the thyra operator associated with this wrapper.
virtual void buildInverseOperator(const Teuchos::RCP< const Epetra_Operator > &A, bool clear=true)
Build this inverse operator from an Epetra_Operator passed in to this object.