10 #ifndef Thyra_AdjointLinearOpWithSolveFactory_hpp
11 #define Thyra_AdjointLinearOpWithSolveFactory_hpp
13 #include "Thyra_LinearOpWithSolveFactoryBase.hpp"
14 #include "Thyra_DefaultScaledAdjointLinearOp.hpp"
15 #include "Thyra_DefaultAdjointLinearOpWithSolve.hpp"
16 #include "Thyra_DefaultLinearOpSource.hpp"
24 template <
class Scalar>
94 const std::string &precFactoryName);
103 std::string *precFactoryName);
107 virtual RCP<LinearOpWithSolveBase<Scalar> >
createOp()
const;
162 template <
class Scalar>
163 RCP<const AdjointLinearOpWithSolveFactory<Scalar> >
167 RCP<AdjointLinearOpWithSolveFactory<Scalar> > alowsf =
169 alowsf->initialize(lowsf);
177 template <
class Scalar>
178 RCP<AdjointLinearOpWithSolveFactory<Scalar> >
182 RCP<AdjointLinearOpWithSolveFactory<Scalar> > alowsf =
184 alowsf->nonconstInitialize(lowsf);
190 template <
class Scalar>
197 lowsf_.initialize(lowsf);
200 template <
class Scalar>
207 lowsf_.initialize(lowsf);
210 template <
class Scalar>
211 RCP<LinearOpWithSolveFactoryBase<Scalar> >
214 return lowsf_.getNonconstObj();
217 template <
class Scalar>
218 RCP<const LinearOpWithSolveFactoryBase<Scalar> >
221 return lowsf_.getConstObj();
226 template <
class Scalar>
229 std::ostringstream oss;
232 if (!
is_null(lowsf_.getConstObj()))
233 oss << lowsf_.getConstObj()->description();
242 template <
class Scalar>
244 RCP<ParameterList>
const ¶mList)
246 lowsf_.getNonconstObj()->setParameterList(paramList);
249 template <
class Scalar>
253 return lowsf_.getNonconstObj()->getNonconstParameterList();
256 template <
class Scalar>
259 return lowsf_.getNonconstObj()->unsetParameterList();
262 template <
class Scalar>
263 RCP<const ParameterList>
266 return lowsf_.getConstObj()->getParameterList();
269 template <
class Scalar>
270 RCP<const ParameterList>
273 return lowsf_.getConstObj()->getValidParameters();
278 template <
class Scalar>
282 return lowsf_.getConstObj()->acceptsPreconditionerFactory();
285 template <
class Scalar>
288 const std::string &precFactoryName)
291 RCP<APF> apf = Teuchos::rcp_dynamic_cast<APF>(precFactory);
292 lowsf_.getNonconstObj()->setPreconditionerFactory(
293 apf->getNonconstPreconditionerFactory(), precFactoryName);
296 template <
class Scalar>
297 RCP<PreconditionerFactoryBase<Scalar> >
300 RCP<PreconditionerFactoryBase<Scalar> > prec_fac =
301 lowsf_.getConstObj()->getPreconditionerFactory();
302 if (prec_fac == Teuchos::null)
303 return Teuchos::null;
305 return nonconstAdjointPreconditionerFactory(prec_fac);
308 template <
class Scalar>
311 std::string *precFactoryName)
313 RCP<PreconditionerFactoryBase<Scalar> > inner_precFactory;
314 lowsf_.getNonconstObj()->unsetPreconditionerFactory(
315 precFactory ? &inner_precFactory : NULL, precFactoryName);
317 *precFactory = nonconstAdjointPreconditionerFactory(inner_precFactory);
320 template <
class Scalar>
326 Teuchos::rcp_dynamic_cast<
const ALO>(fwdOpSrc.
getOp().assert_not_null());
327 RCP<const LinearOpSourceBase<Scalar> > inner_fwdOpSrc =
328 defaultLinearOpSource<Scalar>(alo->getOp());
329 return lowsf_.getConstObj()->isCompatible(*inner_fwdOpSrc);
332 template <
class Scalar>
333 RCP<LinearOpWithSolveBase<Scalar> >
336 return nonconstAdjointLows<Scalar>(lowsf_.getConstObj()->createOp());
339 template <
class Scalar>
346 using Teuchos::rcp_dynamic_cast;
353 lowsf_.getConstObj()->setOStream(this->getOStream());
354 lowsf_.getConstObj()->setVerbLevel(this->getVerbLevel());
358 const RCP<const ALO> alo =
359 rcp_dynamic_cast<
const ALO>(fwdOpSrc->getOp().assert_not_null());
360 ALOWS &alows =
dyn_cast<ALOWS>(*Op);
362 lowsf_.getConstObj()->initializeOp(
363 defaultLinearOpSource<Scalar>(alo->getOrigOp()),
364 alows.getNonconstOp().get(), supportSolveUse);
367 template <
class Scalar>
373 using Teuchos::rcp_dynamic_cast;
380 lowsf_.getConstObj()->setOStream(this->getOStream());
381 lowsf_.getConstObj()->setVerbLevel(this->getVerbLevel());
385 const RCP<const ALO> alo =
386 rcp_dynamic_cast<
const ALO>(fwdOpSrc->getOp().assert_not_null());
387 ALOWS &alows =
dyn_cast<ALOWS>(*Op);
389 lowsf_.getConstObj()->initializeAndReuseOp(
390 defaultLinearOpSource<Scalar>(alo->getOrigOp()),
391 alows.getNonconstOp().get());
394 template <
class Scalar>
408 ALOWS &alowsOp =
dyn_cast<ALOWS>(*Op);
409 RCP<const LinearOpSourceBase<Scalar> > inner_fwdOpSrc;
410 RCP<const PreconditionerBase<Scalar> > inner_prec;
411 RCP<const LinearOpSourceBase<Scalar> > inner_approxFwdOpSrc;
412 lowsf_.getConstObj()->uninitializeOp(
413 alowsOp.getNonconstOp().get(), fwdOpSrc ? &inner_fwdOpSrc : NULL,
414 prec ? &inner_prec : NULL, approxFwdOpSrc ? &inner_approxFwdOpSrc : NULL,
417 *fwdOpSrc = defaultLinearOpSource<Scalar>(adjoint(inner_fwdOpSrc->getOp()));
418 if (prec) *prec = adjointPreconditioner(inner_prec);
421 defaultLinearOpSource<Scalar>(adjoint(inner_approxFwdOpSrc->getOp()));
424 template <
class Scalar>
428 return lowsf_.getConstObj()->supportsPreconditionerInputType(precOpType);
431 template <
class Scalar>
439 using Teuchos::rcp_dynamic_cast;
446 lowsf_.getConstObj()->setOStream(this->getOStream());
447 lowsf_.getConstObj()->setVerbLevel(this->getVerbLevel());
452 const RCP<const ALO> alo =
453 rcp_dynamic_cast<
const ALO>(fwdOpSrc->getOp().assert_not_null());
454 const RCP<const AP> ap = rcp_dynamic_cast<
const AP>(prec);
455 ALOWS &alows =
dyn_cast<ALOWS>(*Op);
457 lowsf_.getConstObj()->initializePreconditionedOp(
458 defaultLinearOpSource<Scalar>(alo->getOp()), ap->getPreconditioner(),
459 alows.getNonconstOp().get(), supportSolveUse);
462 template <
class Scalar>
470 using Teuchos::rcp_dynamic_cast;
477 lowsf_.getConstObj()->setOStream(this->getOStream());
478 lowsf_.getConstObj()->setVerbLevel(this->getVerbLevel());
482 const RCP<const ALO> alo =
483 rcp_dynamic_cast<
const ALO>(fwdOpSrc->getOp().assert_not_null());
484 const RCP<const ALO> aalo =
485 rcp_dynamic_cast<
const ALO>(approxFwdOpSrc->getOp().assert_not_null());
486 ALOWS &alows =
dyn_cast<ALOWS>(*Op);
488 lowsf_.getConstObj()->initializeApproxPreconditionedOp(
489 defaultLinearOpSource<Scalar>(alo->getOp()),
490 defaultLinearOpSource<Scalar>(aalo->getOp()), alows.getNonconstOp().get(),
496 template <
class Scalar>
500 lowsf_.getConstObj()->setVerbLevel(this->getVerbLevel());
501 lowsf_.getConstObj()->setOStream(this->getOStream());
bool is_null(const boost::shared_ptr< T > &p)
Concrete PreconditionerBase subclass that wraps a preconditioner operator in MultiVectorLinearOp.
RCP< ParameterList > unsetParameterList()
virtual void uninitializeOp(LinearOpWithSolveBase< Scalar > *Op, RCP< const LinearOpSourceBase< Scalar > > *fwdOpSrc, RCP< const PreconditionerBase< Scalar > > *prec, RCP< const LinearOpSourceBase< Scalar > > *approxFwdOpSrc, ESupportSolveUse *supportSolveUse) const
RCP< LinearOpWithSolveFactoryBase< Scalar > > getUnderlyingLOWSF()
T_To & dyn_cast(T_From &from)
virtual void initializeApproxPreconditionedOp(const RCP< const LinearOpSourceBase< Scalar > > &fwdOpSrc, const RCP< const LinearOpSourceBase< Scalar > > &approxFwdOpSrc, LinearOpWithSolveBase< Scalar > *Op, const ESupportSolveUse supportSolveUse) const
std::string description() const
Create a LinearOpWithSolveFactory for an adjoint linear op.
RCP< AdjointLinearOpWithSolveFactory< Scalar > > nonconstAdjointLinearOpWithSolveFactory(const RCP< LinearOpWithSolveFactoryBase< Scalar > > &lowsf)
Nonmember constructor.
virtual bool supportsPreconditionerInputType(const EPreconditionerInputType precOpType) const
virtual bool isCompatible(const LinearOpSourceBase< Scalar > &fwdOpSrc) const
Teuchos::ConstNonconstObjectContainer< LinearOpWithSolveFactoryBase< Scalar > > LOWSF_t
virtual void unsetPreconditionerFactory(RCP< PreconditionerFactoryBase< Scalar > > *precFactory, std::string *precFactoryName)
Throws exception.
RCP< const ParameterList > getParameterList() const
TEUCHOS_DEPRECATED RCP< T > rcp(T *p, Dealloc_T dealloc, bool owns_mem)
RCP< ParameterList > getNonconstParameterList()
RCP< const AdjointLinearOpWithSolveFactory< Scalar > > adjointLinearOpWithSolveFactory(const RCP< const LinearOpWithSolveFactoryBase< Scalar > > &lowsf)
Nonmember constructor.
void informUpdatedVerbosityState() const
Overridden from Teuchos::VerboseObjectBase.
void setParameterList(RCP< ParameterList > const ¶mList)
virtual std::string description() const
AdjointLinearOpWithSolveFactory()
Construct to uninitialized.
void initialize(const RCP< const LinearOpWithSolveFactoryBase< Scalar > > &lowsf)
Initialize given a single const LOWSFB object.
virtual bool acceptsPreconditionerFactory() const
returns false.
virtual void setPreconditionerFactory(const RCP< PreconditionerFactoryBase< Scalar > > &precFactory, const std::string &precFactoryName)
Throws exception.
virtual void initializePreconditionedOp(const RCP< const LinearOpSourceBase< Scalar > > &fwdOpSrc, const RCP< const PreconditionerBase< Scalar > > &prec, LinearOpWithSolveBase< Scalar > *Op, const ESupportSolveUse supportSolveUse) const
Concrete PreconditionerFactoryBase subclass that wraps a preconditioner in AdjointPreconditioner.
virtual Teuchos::RCP< const LinearOpBase< Scalar > > getOp() const =0
virtual RCP< PreconditionerFactoryBase< Scalar > > getPreconditionerFactory() const
Returns null .
virtual void initializeOp(const RCP< const LinearOpSourceBase< Scalar > > &fwdOpSrc, LinearOpWithSolveBase< Scalar > *Op, const ESupportSolveUse supportSolveUse) const
#define TEUCHOS_TEST_FOR_EXCEPT(throw_exception_test)
virtual RCP< LinearOpWithSolveBase< Scalar > > createOp() const
virtual void initializeAndReuseOp(const RCP< const LinearOpSourceBase< Scalar > > &fwdOpSrc, LinearOpWithSolveBase< Scalar > *Op) const
void nonconstInitialize(const RCP< LinearOpWithSolveFactoryBase< Scalar > > &lowsf)
Initialize given a single non-const LOWSFB object.
RCP< const ParameterList > getValidParameters() const