47 #include "Teko_InverseFactoryOperator.hpp"
50 #include "Teko_BasicMappingStrategy.hpp"
53 #include "Thyra_EpetraLinearOp.hpp"
57 using Teuchos::rcpFromRef;
58 using Teuchos::rcp_dynamic_cast;
69 InverseFactoryOperator::InverseFactoryOperator(
const Teuchos::RCP<const InverseFactory> & ifp)
70 : inverseFactory_(ifp), firstBuildComplete_(false), setConstFwdOp_(true)
90 invOperator_ = Teuchos::null;
107 Teko_DEBUG_SCOPE(
"InverseFactoryOperator::buildInverseOperator",10);
110 RCP<const Thyra::LinearOpBase<double> > thyraA = extractLinearOp(A);
120 SetOperator(invOperator_,
false);
122 firstBuildComplete_ =
true;
127 setConstFwdOp_ =
true;
129 TEUCHOS_ASSERT(invOperator_!=Teuchos::null);
133 TEUCHOS_ASSERT(firstBuildComplete_==
true);
138 setConstFwdOp_ =
false;
140 fwdOp_.initialize(A);
144 TEUCHOS_ASSERT(setConstFwdOp_==
true);
161 Teko_DEBUG_SCOPE(
"InverseFactoryOperator::rebuildPreconditioner",10);
164 if(not firstBuildComplete_) {
169 RCP<const Thyra::LinearOpBase<double> > thyraA = extractLinearOp(A);
173 fwdOp_.initialize(A);
175 SetOperator(invOperator_,
false);
177 setConstFwdOp_ =
true;
180 TEUCHOS_ASSERT(invOperator_!=Teuchos::null);
182 TEUCHOS_ASSERT(firstBuildComplete_==
true);
187 setConstFwdOp_ =
false;
189 fwdOp_.initialize(A);
194 TEUCHOS_ASSERT(setConstFwdOp_==
true);
197 Teuchos::RCP<const Thyra::LinearOpBase<double> > InverseFactoryOperator::extractLinearOp(
const Teuchos::RCP<const Epetra_Operator> & A)
const
203 if(eow!=Teuchos::null)
207 return Thyra::epetraLinearOp(A);
210 Teuchos::RCP<const MappingStrategy> InverseFactoryOperator::extractMappingStrategy(
const Teuchos::RCP<const Epetra_Operator> & A)
const
213 const RCP<const EpetraOperatorWrapper> & eow = rcp_dynamic_cast<
const EpetraOperatorWrapper>(A);
216 if(eow!=Teuchos::null)
217 return eow->getMapStrategy();
220 RCP<const Epetra_Map> range = rcpFromRef(A->OperatorRangeMap());
221 RCP<const Epetra_Map> domain = rcpFromRef(A->OperatorDomainMap());
222 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.