42 #ifndef THYRA_LINEAR_OP_WITH_SOLVE_FACTORY_HELPERS_HPP
43 #define THYRA_LINEAR_OP_WITH_SOLVE_FACTORY_HELPERS_HPP
45 #include "Thyra_LinearOpWithSolveFactoryBase.hpp"
46 #include "Thyra_DefaultLinearOpSource.hpp"
47 #include "Thyra_DefaultPreconditioner.hpp"
48 #include "Thyra_DefaultInverseLinearOp.hpp"
59 template<
class Scalar>
65 return lowsFactory.
isCompatible(*defaultLinearOpSource(fwdOp));
73 template<
class Scalar>
79 const std::string OpLabel = Op->getObjectLabel();
81 if ( !OpLabel.length() && fwdOpLabel.length() )
82 Op->setObjectLabel(fwdOpLabel);
90 template<
class Scalar>
98 lowsFactory.
initializeOp(defaultLinearOpSource(fwdOp), &*Op, supportSolveUse);
99 setDefaultObjectLabel(*fwdOp, Op);
108 template<
class Scalar>
116 setDefaultObjectLabel(*fwdOp, Op);
125 template<
class Scalar>
135 prec, &*Op, supportSolveUse);
136 setDefaultObjectLabel(*fwdOp ,Op);
145 template<
class Scalar>
155 defaultLinearOpSource(approxFwdOp), &*Op, supportSolveUse);
156 setDefaultObjectLabel(*fwdOp,Op);
164 template<
class Scalar>
173 Thyra::initializeOp<Scalar>( lowsFactory, fwdOp, Op.
ptr(), supportSolveUse);
183 template<
class Scalar>
195 return inverse<Scalar>(linearOpWithSolve<Scalar>(LOWSF, fwdOp, supportSolveUse),
196 fwdSolveCriteria, throwOnFwdSolveFailure, adjSolveCriteria, throwOnAdjSolveFailure);
205 template<
class Scalar>
218 supportSolveUse.
get());
220 *fwdOp = (
nonnull(fwdOpSrc) ? fwdOpSrc->getOp() : Teuchos::null );
223 *approxFwdOp = (
nonnull(approxFwdOpSrc) ? approxFwdOpSrc->getOp() : Teuchos::null );
231 #endif // THYRA_LINEAR_OP_WITH_SOLVE_FACTORY_HELPERS_HPP
How the output LOWSB object will be useded for solves in unspecified.
virtual std::string getObjectLabel() const
Base class for all linear operators that can support a high-level solve operation.
virtual void initializePreconditionedOp(const RCP< const LinearOpSourceBase< Scalar > > &fwdOpSrc, const RCP< const PreconditionerBase< Scalar > > &prec, LinearOpWithSolveBase< Scalar > *Op, const ESupportSolveUse supportSolveUse=SUPPORT_SOLVE_UNSPECIFIED) const
Initialize a pre-created LinearOpWithSolveBase object given a "compatible" LinearOpBase object and an...
virtual void initializeOp(const RCP< const LinearOpSourceBase< Scalar > > &fwdOpSrc, LinearOpWithSolveBase< Scalar > *Op, const ESupportSolveUse supportSolveUse=SUPPORT_SOLVE_UNSPECIFIED) const =0
Initialize a pre-created LinearOpWithSolveBase object given a "compatible" LinearOpBase object...
void initializeAndReuseOp(const LinearOpWithSolveFactoryBase< Scalar > &lowsFactory, const RCP< const LinearOpBase< Scalar > > &fwdOp, const Ptr< LinearOpWithSolveBase< Scalar > > &Op)
Reinitialize a pre-created LOWSB object given a forward operator, reusing a much as possible from the...
void uninitializeOp(const LinearOpWithSolveFactoryBase< Scalar > &lowsFactory, const Ptr< LinearOpWithSolveBase< Scalar > > &Op, const Ptr< RCP< const LinearOpBase< Scalar > > > &fwdOp=Teuchos::null, const Ptr< RCP< const PreconditionerBase< Scalar > > > &prec=Teuchos::null, const Ptr< RCP< const LinearOpBase< Scalar > > > &approxFwdOp=Teuchos::null, const Ptr< ESupportSolveUse > &supportSolveUse=Teuchos::null)
Uninitialized a pre-created LOWSB object, returning input objects used to initialize it...
Simple interface class to access a precreated preconditioner as one or more linear operators objects ...
virtual void initializeAndReuseOp(const RCP< const LinearOpSourceBase< Scalar > > &fwdOpSrc, LinearOpWithSolveBase< Scalar > *Op) const
Initialize a pre-created LinearOpWithSolveBase object given a "compatible" LinearOpBase object but al...
virtual void initializeApproxPreconditionedOp(const RCP< const LinearOpSourceBase< Scalar > > &fwdOpSrc, const RCP< const LinearOpSourceBase< Scalar > > &approxFwdOpSrc, LinearOpWithSolveBase< Scalar > *Op, const ESupportSolveUse supportSolveUse=SUPPORT_SOLVE_UNSPECIFIED) const
Initialize a pre-created LinearOpWithSolveBase object given a "compatible" forward LinearOpBase objec...
virtual RCP< LinearOpWithSolveBase< Scalar > > createOp() const =0
Create an (uninitialized) LinearOpWithSolveBase object to be initialized later in this->initializeOp(...
void setDefaultObjectLabel(const LinearOpBase< Scalar > &fwdOp, const Ptr< LinearOpWithSolveBase< Scalar > > &Op)
Set default label on a LOWSB object.
Throw an exception if a solve fails to converge.
Factory interface for creating LinearOpWithSolveBase objects from compatible LinearOpBase objects...
void initializeApproxPreconditionedOp(const LinearOpWithSolveFactoryBase< Scalar > &lowsFactory, const RCP< const LinearOpBase< Scalar > > &fwdOp, const RCP< const LinearOpBase< Scalar > > &approxFwdOp, const Ptr< LinearOpWithSolveBase< Scalar > > &Op, const ESupportSolveUse supportSolveUse=SUPPORT_SOLVE_UNSPECIFIED)
Initialize a preconditioned LOWSB object given an external operator to be used to generate the precon...
void initializePreconditionedOp(const LinearOpWithSolveFactoryBase< Scalar > &lowsFactory, const RCP< const LinearOpBase< Scalar > > &fwdOp, const RCP< const PreconditionerBase< Scalar > > &prec, const Ptr< LinearOpWithSolveBase< Scalar > > &Op, const ESupportSolveUse supportSolveUse=SUPPORT_SOLVE_UNSPECIFIED)
Initialize a preconditioned LOWSB object given an external preconditioner.
Base class for all linear operators.
ESupportSolveUse
Enum that specifies how a LinearOpWithSolveBase object will be used for solves after it is constructe...
virtual bool isCompatible(const LinearOpSourceBase< Scalar > &fwdOpSrc) const =0
Check that a LinearOpBase object is compatible with *this factory object.
bool nonnull(const boost::shared_ptr< T > &p)
void initializeOp(const LinearOpWithSolveFactoryBase< Scalar > &lowsFactory, const RCP< const LinearOpBase< Scalar > > &fwdOp, const Ptr< LinearOpWithSolveBase< Scalar > > &Op, const ESupportSolveUse supportSolveUse=SUPPORT_SOLVE_UNSPECIFIED)
Initialize a pre-created LOWSB object given a forward operator.
virtual void uninitializeOp(LinearOpWithSolveBase< Scalar > *Op, RCP< const LinearOpSourceBase< Scalar > > *fwdOpSrc=NULL, RCP< const PreconditionerBase< Scalar > > *prec=NULL, RCP< const LinearOpSourceBase< Scalar > > *approxFwdOpSrc=NULL, ESupportSolveUse *supportSolveUse=NULL) const =0
Uninitialize a LinearOpWithSolveBase object and return its remembered forward linear operator and pot...
EThrowOnSolveFailure
Determines what to do if inverse solve fails.
RCP< LinearOpWithSolveBase< Scalar > > linearOpWithSolve(const LinearOpWithSolveFactoryBase< Scalar > &lowsFactory, const RCP< const LinearOpBase< Scalar > > &fwdOp, const ESupportSolveUse supportSolveUse=SUPPORT_SOLVE_UNSPECIFIED)
Create and initialize a LinearOpWithSolveBase object from a LinearOpBase object using a LinearOpWithS...
Simple struct that defines the requested solution criteria for a solve.
RCP< LinearOpBase< Scalar > > inverse(const LinearOpWithSolveFactoryBase< Scalar > &LOWSF, const RCP< const LinearOpBase< Scalar > > &fwdOp, const ESupportSolveUse supportSolveUse=SUPPORT_SOLVE_UNSPECIFIED, const Ptr< const SolveCriteria< Scalar > > &fwdSolveCriteria=Teuchos::null, const EThrowOnSolveFailure throwOnFwdSolveFailure=THROW_ON_SOLVE_FAILURE, const Ptr< const SolveCriteria< Scalar > > &adjSolveCriteria=Teuchos::null, const EThrowOnSolveFailure throwOnAdjSolveFailure=THROW_ON_SOLVE_FAILURE)
Form a const implicit inverse operator M = inv(A) given a factory.
bool isCompatible(const LinearOpWithSolveFactoryBase< Scalar > &lowsFactory, const LinearOpBase< Scalar > &fwdOp)
Return if the forward operator is a compatible source for a LOWSFB object.