10 #include "Teko_InverseFactoryOperator.hpp"
13 #include "Teko_BasicMappingStrategy.hpp"
16 #include "Thyra_EpetraLinearOp.hpp"
20 using Teuchos::rcp_dynamic_cast;
21 using Teuchos::rcpFromRef;
32 InverseFactoryOperator::InverseFactoryOperator(
const Teuchos::RCP<const InverseFactory>& ifp)
33 : inverseFactory_(ifp), firstBuildComplete_(false), setConstFwdOp_(true) {}
48 if (not clearOld)
return;
49 invOperator_ = Teuchos::null;
66 Teko_DEBUG_SCOPE(
"InverseFactoryOperator::buildInverseOperator", 10);
69 RCP<const Thyra::LinearOpBase<double> > thyraA = extractLinearOp(A);
79 SetOperator(invOperator_,
false);
81 firstBuildComplete_ =
true;
83 if (setConstFwdOp_) fwdOp_ = A;
85 setConstFwdOp_ =
true;
87 TEUCHOS_ASSERT(invOperator_ != Teuchos::null);
91 TEUCHOS_ASSERT(firstBuildComplete_ ==
true);
96 setConstFwdOp_ =
false;
102 TEUCHOS_ASSERT(setConstFwdOp_ ==
true);
118 Teko_DEBUG_SCOPE(
"InverseFactoryOperator::rebuildPreconditioner", 10);
121 if (not firstBuildComplete_) {
126 RCP<const Thyra::LinearOpBase<double> > thyraA = extractLinearOp(A);
129 if (setConstFwdOp_) fwdOp_.initialize(A);
131 SetOperator(invOperator_,
false);
133 setConstFwdOp_ =
true;
136 TEUCHOS_ASSERT(invOperator_ != Teuchos::null);
137 TEUCHOS_ASSERT(
getThyraOp() != Teuchos::null);
138 TEUCHOS_ASSERT(firstBuildComplete_ ==
true);
142 setConstFwdOp_ =
false;
144 fwdOp_.initialize(A);
149 TEUCHOS_ASSERT(setConstFwdOp_ ==
true);
152 Teuchos::RCP<const Thyra::LinearOpBase<double> > InverseFactoryOperator::extractLinearOp(
153 const Teuchos::RCP<const Epetra_Operator>& A)
const {
158 if (eow != Teuchos::null)
return eow->
getThyraOp();
161 return Thyra::epetraLinearOp(A);
164 Teuchos::RCP<const MappingStrategy> InverseFactoryOperator::extractMappingStrategy(
165 const Teuchos::RCP<const Epetra_Operator>& A)
const {
167 const RCP<const EpetraOperatorWrapper>& eow = rcp_dynamic_cast<
const EpetraOperatorWrapper>(A);
170 if (eow != Teuchos::null)
return eow->getMapStrategy();
173 RCP<const Epetra_Map> range = rcpFromRef(A->OperatorRangeMap());
174 RCP<const Epetra_Map> domain = rcpFromRef(A->OperatorDomainMap());
175 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.