10 #ifndef THYRA_LINEAR_OP_WITH_SOLVE_FACTORY_HELPERS_HPP
11 #define THYRA_LINEAR_OP_WITH_SOLVE_FACTORY_HELPERS_HPP
13 #include "Thyra_LinearOpWithSolveFactoryBase.hpp"
14 #include "Thyra_DefaultLinearOpSource.hpp"
15 #include "Thyra_DefaultPreconditioner.hpp"
16 #include "Thyra_DefaultInverseLinearOp.hpp"
27 template<
class Scalar>
33 return lowsFactory.
isCompatible(*defaultLinearOpSource(fwdOp));
41 template<
class Scalar>
47 const std::string OpLabel = Op->getObjectLabel();
49 if ( !OpLabel.length() && fwdOpLabel.length() )
50 Op->setObjectLabel(fwdOpLabel);
58 template<
class Scalar>
66 lowsFactory.
initializeOp(defaultLinearOpSource(fwdOp), &*Op, supportSolveUse);
67 setDefaultObjectLabel(*fwdOp, Op);
76 template<
class Scalar>
84 setDefaultObjectLabel(*fwdOp, Op);
93 template<
class Scalar>
103 prec, &*Op, supportSolveUse);
104 setDefaultObjectLabel(*fwdOp ,Op);
113 template<
class Scalar>
123 defaultLinearOpSource(approxFwdOp), &*Op, supportSolveUse);
124 setDefaultObjectLabel(*fwdOp,Op);
132 template<
class Scalar>
141 Thyra::initializeOp<Scalar>( lowsFactory, fwdOp, Op.
ptr(), supportSolveUse);
151 template<
class Scalar>
163 return inverse<Scalar>(linearOpWithSolve<Scalar>(LOWSF, fwdOp, supportSolveUse),
164 fwdSolveCriteria, throwOnFwdSolveFailure, adjSolveCriteria, throwOnAdjSolveFailure);
173 template<
class Scalar>
186 supportSolveUse.
get());
188 *fwdOp = (
nonnull(fwdOpSrc) ? fwdOpSrc->getOp() : Teuchos::null );
191 *approxFwdOp = (
nonnull(approxFwdOpSrc) ? approxFwdOpSrc->getOp() : Teuchos::null );
199 #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.