47 #include "Teko_TpetraInverseFactoryOperator.hpp"
50 #include "Teko_TpetraBasicMappingStrategy.hpp"
53 #include "Thyra_TpetraLinearOp.hpp"
57 using Teuchos::rcpFromRef;
58 using Teuchos::rcp_dynamic_cast;
61 namespace TpetraHelpers {
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<ST> > 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<ST> > 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<ST> > InverseFactoryOperator::extractLinearOp(
const Teuchos::RCP<
const Tpetra::Operator<ST,LO,GO,NT> > & A)
const
203 if(eow!=Teuchos::null)
207 return Thyra::constTpetraLinearOp<ST,LO,GO,NT>(Thyra::tpetraVectorSpace<ST,LO,GO,NT>(A->getRangeMap()),Thyra::tpetraVectorSpace<ST,LO,GO,NT>(A->getDomainMap()),A);
210 Teuchos::RCP<const MappingStrategy> InverseFactoryOperator::extractMappingStrategy(
const Teuchos::RCP<
const Tpetra::Operator<ST,LO,GO,NT> > & A)
const
213 const RCP<const TpetraOperatorWrapper> & eow = rcp_dynamic_cast<
const TpetraOperatorWrapper>(A);
216 if(eow!=Teuchos::null)
217 return eow->getMapStrategy();
220 RCP<const Tpetra::Map<LO,GO,NT> > range = A->getRangeMap();
221 RCP<const Tpetra::Map<LO,GO,NT> > domain = A->getDomainMap();
222 return rcp(
new BasicMappingStrategy(range,domain,*Thyra::convertTpetraToThyraComm(range->getComm())));
void rebuildInverse(const InverseFactory &factory, const LinearOp &A, InverseLinearOp &invA)
virtual void initInverse(bool clearOld=false)
Build the underlying data structure for the inverse operator.
virtual void buildInverseOperator(const Teuchos::RCP< const Tpetra::Operator< ST, LO, GO, NT > > &A, bool clear=true)
Build this inverse operator from an Epetra_Operator passed in to this object.
const RCP< const Thyra::LinearOpBase< ST > > getThyraOp() const
Return the thyra operator associated with this wrapper.
Flip a mapping strategy object around to give the "inverse" mapping strategy.
InverseLinearOp buildInverse(const InverseFactory &factory, const LinearOp &A)
Build an inverse operator using a factory and a linear operator.
const RCP< const MappingStrategy > getMapStrategy() const
Get the mapping strategy for this wrapper (translate between Thyra and Epetra)
Teuchos::RCP< const Tpetra::Operator< ST, LO, GO, NT > > getForwardOp() const
virtual void rebuildInverseOperator(const Teuchos::RCP< const Tpetra::Operator< ST, LO, GO, NT > > &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...