10 #ifndef THYRA_DEFAULT_INVERSE_LINEAR_OP_DEF_HPP
11 #define THYRA_DEFAULT_INVERSE_LINEAR_OP_DEF_HPP
13 #include "Thyra_DefaultInverseLinearOp_decl.hpp"
14 #include "Thyra_MultiVectorStdOps.hpp"
15 #include "Thyra_AssertOp.hpp"
16 #include "Teuchos_Utils.hpp"
17 #include "Teuchos_TypeNameTraits.hpp"
26 template<
class Scalar>
31 template<
class Scalar>
41 lows,fwdSolveCriteria,throwOnFwdSolveFailure
42 ,adjSolveCriteria,throwOnAdjSolveFailure
47 template<
class Scalar>
57 lows,fwdSolveCriteria,throwOnFwdSolveFailure
58 ,adjSolveCriteria,throwOnAdjSolveFailure
63 template<
class Scalar>
73 lows,fwdSolveCriteria,throwOnFwdSolveFailure
74 ,adjSolveCriteria,throwOnAdjSolveFailure
79 template<
class Scalar>
89 lows,fwdSolveCriteria,throwOnFwdSolveFailure
90 ,adjSolveCriteria,throwOnAdjSolveFailure
95 template<
class Scalar>
99 fwdSolveCriteria_ = Teuchos::null;
100 adjSolveCriteria_ = Teuchos::null;
107 template<
class Scalar>
110 return lows_.isConst();
114 template<
class Scalar>
118 return lows_.getNonconstObj();
122 template<
class Scalar>
126 return lows_.getConstObj();
133 template<
class Scalar>
138 return lows_.getConstObj()->domain();
142 template<
class Scalar>
147 return lows_.getConstObj()->range();
151 template<
class Scalar>
155 return Teuchos::null;
162 template<
class Scalar>
166 std::ostringstream oss;
169 <<
"lows="<<lows_.getConstObj()->description()
170 <<
",fwdSolveCriteria="<<(fwdSolveCriteria_.get()?
"...":
"DEFAULT")
171 <<
",adjSolveCriteria="<<(adjSolveCriteria_.get()?
"...":
"DEFAULT")
177 template<
class Scalar>
190 out << this->description() << std::endl;
198 <<
"rangeDim=" << this->range()->dim()
199 <<
",domainDim=" << this->domain()->dim() <<
"}:\n";
202 if(!lows_.getConstObj().get()) {
206 out << Teuchos::describe(*lows_.getConstObj(),verbLevel);
222 template<
class Scalar>
226 return solveSupports(*lows_.getConstObj(),M_trans);
232 template<
class Scalar>
253 if(beta==ST::zero()) {
254 T = Teuchos::rcpFromPtr(Y);
257 T = createMembers(Y->range(),Y->domain()->dim());
264 ? fwdSolveCriteria_.ptr()
265 : adjSolveCriteria_.ptr()
267 assign(T.
ptr(), ST::zero());
269 Thyra::solve<Scalar>(*lows_.getConstObj(), M_trans, X, T.
ptr(), solveCriteria);
277 ,
"Error, the LOWS object " << lows_.getConstObj()->description() <<
" returned an unconverged"
278 "status of " <<
toString(solveStatus.solveStatus) <<
" with the message "
279 << solveStatus.message <<
"."
282 if(beta==ST::zero()) {
286 update( alpha, *T, Y );
294 template<
class Scalar>
308 fwdSolveCriteria_ = Teuchos::null;
312 adjSolveCriteria_ = Teuchos::null;
313 throwOnFwdSolveFailure_ = throwOnFwdSolveFailure;
314 throwOnAdjSolveFailure_ = throwOnAdjSolveFailure;
315 const std::string lowsLabel = lows_.getConstObj()->getObjectLabel();
316 if(lowsLabel.length())
317 this->setObjectLabel(
"inv("+lowsLabel+
")" );
327 template<
class Scalar>
329 Thyra::nonconstInverse(
330 const RCP<LinearOpWithSolveBase<Scalar> > &A,
331 const Ptr<
const SolveCriteria<Scalar> > &fwdSolveCriteria,
333 const Ptr<
const SolveCriteria<Scalar> > &adjSolveCriteria,
338 new DefaultInverseLinearOp<Scalar>(
339 A, fwdSolveCriteria.get(), throwOnFwdSolveFailure,
340 adjSolveCriteria.get(), throwOnAdjSolveFailure
345 template<
class Scalar>
348 const RCP<
const LinearOpWithSolveBase<Scalar> > &A,
349 const Ptr<
const SolveCriteria<Scalar> > &fwdSolveCriteria,
351 const Ptr<
const SolveCriteria<Scalar> > &adjSolveCriteria,
356 new DefaultInverseLinearOp<Scalar>(
357 A, fwdSolveCriteria.get(), throwOnFwdSolveFailure,
358 adjSolveCriteria.get(), throwOnAdjSolveFailure
371 #define THYRA_DEFAULT_INVERSE_LINEAR_OP_INSTANT(SCALAR) \
373 template class DefaultInverseLinearOp<SCALAR >; \
375 template RCP<LinearOpBase<SCALAR > > \
377 const RCP<LinearOpWithSolveBase<SCALAR > > &A, \
378 const Ptr<const SolveCriteria<SCALAR > > &fwdSolveCriteria, \
379 const EThrowOnSolveFailure throwOnFwdSolveFailure, \
380 const Ptr<const SolveCriteria<SCALAR > > &adjSolveCriteria, \
381 const EThrowOnSolveFailure throwOnAdjSolveFailure \
384 template RCP<LinearOpBase<SCALAR > > \
386 const RCP<const LinearOpWithSolveBase<SCALAR > > &A, \
387 const Ptr<const SolveCriteria<SCALAR > > &fwdSolveCriteria, \
388 const EThrowOnSolveFailure throwOnFwdSolveFailure, \
389 const Ptr<const SolveCriteria<SCALAR > > &adjSolveCriteria, \
390 const EThrowOnSolveFailure throwOnAdjSolveFailure \
394 #endif // THYRA_DEFAULT_INVERSE_LINEAR_OP_DEF_HPP
Base class for all linear operators that can support a high-level solve operation.
EOpTransp
Enumeration for determining how a linear operator is applied. `*.
void uninitialize()
Set to uninitialized.
basic_OSTab< char > OSTab
RCP< const LinearOpBase< Scalar > > clone() const
DefaultInverseLinearOp()
Constructs to uninitialized (see postconditions for uninitialize()).
bool opSupportedImpl(EOpTransp M_trans) const
Returns true only if all constituent operators support M_trans.
void describe(FancyOStream &out, const Teuchos::EVerbosityLevel verbLevel) const
#define TEUCHOS_TEST_FOR_EXCEPTION(throw_exception_test, Exception, msg)
Use the non-transposed operator.
EOpTransp real_trans(EOpTransp transp)
Return NOTRANS or TRANS for real scalar valued operators and this also is used for determining struct...
RCP< const VectorSpaceBase< Scalar > > range() const
Returns this->getLows()->domain() if <t>this->getLows().get()!=NULL and returns Teuchos::null otherwi...
void applyImpl(const EOpTransp M_trans, const MultiVectorBase< Scalar > &X, const Ptr< MultiVectorBase< Scalar > > &Y, const Scalar alpha, const Scalar beta) const
Throw an exception if a solve fails to converge.
TEUCHOS_DEPRECATED RCP< T > rcp(T *p, Dealloc_T dealloc, bool owns_mem)
Interface for a collection of column vectors called a multi-vector.
std::string description() const
virtual std::string description() const
TEUCHOSCORE_LIB_DLL_EXPORT std::string toString(const EVerbosityLevel verbLevel)
Simple struct for the return status from a solve.
void initialize(const RCP< LinearOpWithSolveBase< Scalar > > &lows, const SolveCriteria< Scalar > *fwdSolveCriteria=NULL, const EThrowOnSolveFailure throwOnFwdSolveFailure=THROW_ON_SOLVE_FAILURE, const SolveCriteria< Scalar > *adjSolveCriteria=NULL, const EThrowOnSolveFailure throwOnAdjSolveFailure=THROW_ON_SOLVE_FAILURE)
Initialize given a non-const LinearOpWithSolveBase object and an optional .
RCP< const VectorSpaceBase< Scalar > > domain() const
Returns this->getLows()->range() if <t>this->getLows().get()!=NULL and returns Teuchos::null otherwis...
bool nonnull(const boost::shared_ptr< T > &p)
EThrowOnSolveFailure
Determines what to do if inverse solve fails.
The requested solution criteria has likely been achieved.
Exception type thrown on an catastrophic solve failure.
Simple struct that defines the requested solution criteria for a solve.
RCP< const LinearOpWithSolveBase< Scalar > > getLows() const
Concrete LinearOpBase subclass that creates an implicit LinearOpBase object using the inverse action ...
#define TEUCHOS_TEST_FOR_EXCEPT(throw_exception_test)
RCP< LinearOpWithSolveBase< Scalar > > getNonconstLows()