9 #ifndef Thyra_MultiVectorLinearOpWithSolveFactory_hpp
10 #define Thyra_MultiVectorLinearOpWithSolveFactory_hpp
12 #include "Thyra_LinearOpWithSolveFactoryBase.hpp"
16 #include "Thyra_DefaultMultiVectorLinearOpWithSolve.hpp"
17 #include "Thyra_DefaultMultiVectorProductVectorSpace.hpp"
18 #include "Thyra_DefaultLinearOpSource.hpp"
24 template<
class Scalar>
106 const std::string &precFactoryName
110 virtual RCP<PreconditionerFactoryBase<Scalar> >
116 std::string *precFactoryName
123 virtual RCP<LinearOpWithSolveBase<Scalar> >
createOp()
const;
187 template<
class Scalar>
188 RCP<MultiVectorLinearOpWithSolveFactory<Scalar> >
195 RCP<MultiVectorLinearOpWithSolveFactory<Scalar> > mvlowsf =
197 mvlowsf->nonconstInitialize(lowsf,multiVecRange,multiVecDomain);
205 template<
class Scalar>
206 RCP<MultiVectorLinearOpWithSolveFactory<Scalar> >
212 RCP< LinearOpWithSolveBase<Scalar> > op = lowsf->createOp();
213 RCP<const Thyra::DefaultMultiVectorProductVectorSpace<Scalar> > mv_domain =
214 Thyra::multiVectorProductVectorSpace(op->domain(), num_blocks);
215 RCP<const Thyra::DefaultMultiVectorProductVectorSpace<Scalar> > mv_range =
216 Thyra::multiVectorProductVectorSpace(op->range(), num_blocks);
217 return nonconstMultiVectorLinearOpWithSolveFactory(lowsf, mv_range, mv_domain);
224 template<
class Scalar>
225 RCP<MultiVectorLinearOpWithSolveFactory<Scalar> >
232 RCP<MultiVectorLinearOpWithSolveFactory<Scalar> > mvlowsf =
234 mvlowsf->initialize(lowsf,multiVecRange,multiVecDomain);
242 template<
class Scalar>
243 RCP<MultiVectorLinearOpWithSolveFactory<Scalar> >
249 RCP< LinearOpWithSolveBase<Scalar> > op = lowsf->createOp();
250 RCP<const Thyra::DefaultMultiVectorProductVectorSpace<Scalar> > mv_domain =
251 Thyra::multiVectorProductVectorSpace(op->domain(), num_blocks);
252 RCP<const Thyra::DefaultMultiVectorProductVectorSpace<Scalar> > mv_range =
253 Thyra::multiVectorProductVectorSpace(op->range(), num_blocks);
254 return multiVectorLinearOpWithSolveFactory(lowsf, mv_range, mv_domain);
259 template<
class Scalar>
271 lowsf_.initialize(lowsf);
272 multiVecRange_ = multiVecRange;
273 multiVecDomain_ = multiVecDomain;
276 template<
class Scalar>
288 lowsf_.initialize(lowsf);
289 multiVecRange_ = multiVecRange;
290 multiVecDomain_ = multiVecDomain;
293 template<
class Scalar>
294 RCP<LinearOpWithSolveFactoryBase<Scalar> >
298 return lowsf_.getNonconstObj();
301 template<
class Scalar>
302 RCP<const LinearOpWithSolveFactoryBase<Scalar> >
306 return lowsf_.getConstObj();
311 template<
class Scalar>
316 std::ostringstream oss;
320 if (!
is_null(lowsf_.getConstObj()))
321 oss << lowsf_.getConstObj()->description();
330 template<
class Scalar>
334 RCP<ParameterList>
const& paramList
337 lowsf_.getNonconstObj()->setParameterList(paramList);
340 template<
class Scalar>
345 return lowsf_.getNonconstObj()->getNonconstParameterList();
348 template<
class Scalar>
353 return lowsf_.getNonconstObj()->unsetParameterList();
356 template<
class Scalar>
357 RCP<const ParameterList>
361 return lowsf_.getConstObj()->getParameterList();
364 template<
class Scalar>
365 RCP<const ParameterList>
369 return lowsf_.getConstObj()->getValidParameters();
374 template<
class Scalar>
379 return lowsf_.getConstObj()->acceptsPreconditionerFactory();
382 template<
class Scalar>
387 const std::string &precFactoryName
391 RCP<MVPF> mvpf = Teuchos::rcp_dynamic_cast<MVPF>(precFactory);
392 lowsf_.getNonconstObj()->setPreconditionerFactory(
393 mvpf->getNonconstPreconditionerFactory(),
397 template<
class Scalar>
398 RCP<PreconditionerFactoryBase<Scalar> >
402 RCP<PreconditionerFactoryBase<Scalar> > prec_fac =
403 lowsf_.getConstObj()->getPreconditionerFactory();
404 if (prec_fac == Teuchos::null)
405 return Teuchos::null;
407 return nonconstMultiVectorPreconditionerFactory(
409 multiVecRange_, multiVecDomain_);
412 template<
class Scalar>
416 std::string *precFactoryName
419 RCP<PreconditionerFactoryBase<Scalar> > inner_precFactory;
420 lowsf_.getNonconstObj()->unsetPreconditionerFactory(
421 precFactory ? &inner_precFactory : NULL,
424 *precFactory = nonconstMultiVectorPreconditionerFactory(inner_precFactory,
429 template<
class Scalar>
437 RCP<const MVLO> mvlo =
438 Teuchos::rcp_dynamic_cast<
const MVLO>(fwdOpSrc.
getOp().assert_not_null());
439 RCP<const LinearOpSourceBase<Scalar> > inner_fwdOpSrc =
440 defaultLinearOpSource<Scalar>(mvlo->getLinearOp());
441 return lowsf_.getConstObj()->isCompatible(*inner_fwdOpSrc);
444 template<
class Scalar>
445 RCP<LinearOpWithSolveBase<Scalar> >
449 return nonconstMultiVectorLinearOpWithSolve<Scalar>(
450 lowsf_.getConstObj()->createOp(),
455 template<
class Scalar>
465 using Teuchos::rcp_dynamic_cast;
472 lowsf_.getConstObj()->setOStream(this->getOStream());
473 lowsf_.getConstObj()->setVerbLevel(this->getVerbLevel());
477 const RCP<const MVLO> mvlo =
478 rcp_dynamic_cast<
const MVLO>(fwdOpSrc->getOp().assert_not_null());
479 MVLOWS &mvlows =
dyn_cast<MVLOWS>(*Op);
481 lowsf_.getConstObj()->initializeOp(
482 defaultLinearOpSource<Scalar>(mvlo->getLinearOp()),
483 mvlows.getNonconstLinearOpWithSolve().get(),
487 template<
class Scalar>
496 using Teuchos::rcp_dynamic_cast;
503 lowsf_.getConstObj()->setOStream(this->getOStream());
504 lowsf_.getConstObj()->setVerbLevel(this->getVerbLevel());
508 const RCP<const MVLO> mvlo =
509 rcp_dynamic_cast<
const MVLO>(fwdOpSrc->getOp().assert_not_null());
510 MVLOWS &mvlows =
dyn_cast<MVLOWS>(*Op);
512 lowsf_.getConstObj()->initializeAndReuseOp(
513 defaultLinearOpSource<Scalar>(mvlo->getLinearOp()),
514 mvlows.getNonconstLinearOpWithSolve().get());
517 template<
class Scalar>
534 MVLOWS &mvlowsOp =
dyn_cast<MVLOWS>(*Op);
535 RCP<const LinearOpSourceBase<Scalar> > inner_fwdOpSrc;
536 RCP<const PreconditionerBase<Scalar> > inner_prec;
537 RCP<const LinearOpSourceBase<Scalar> > inner_approxFwdOpSrc;
538 lowsf_.getConstObj()->uninitializeOp(
539 mvlowsOp.getNonconstLinearOpWithSolve().get(),
540 fwdOpSrc ? &inner_fwdOpSrc : NULL,
541 prec ? &inner_prec : NULL,
542 approxFwdOpSrc ? &inner_approxFwdOpSrc : NULL,
546 defaultLinearOpSource<Scalar>(multiVectorLinearOp(inner_fwdOpSrc->getOp(),
550 *prec = multiVectorPreconditioner(inner_prec,
555 defaultLinearOpSource<Scalar>(multiVectorLinearOp(inner_approxFwdOpSrc->getOp(),
560 template<
class Scalar>
567 return lowsf_.getConstObj()->supportsPreconditionerInputType(precOpType);
570 template<
class Scalar>
581 using Teuchos::rcp_dynamic_cast;
588 lowsf_.getConstObj()->setOStream(this->getOStream());
589 lowsf_.getConstObj()->setVerbLevel(this->getVerbLevel());
594 const RCP<const MVLO> mvlo =
595 rcp_dynamic_cast<
const MVLO>(fwdOpSrc->getOp().assert_not_null());
596 const RCP<const MVP> mvp = rcp_dynamic_cast<
const MVP>(prec);
597 MVLOWS &mvlows =
dyn_cast<MVLOWS>(*Op);
599 lowsf_.getConstObj()->initializePreconditionedOp(
600 defaultLinearOpSource<Scalar>(mvlo->getLinearOp()),
601 mvp->getPreconditioner(),
602 mvlows.getNonconstLinearOpWithSolve().get(),
606 template<
class Scalar>
617 using Teuchos::rcp_dynamic_cast;
624 lowsf_.getConstObj()->setOStream(this->getOStream());
625 lowsf_.getConstObj()->setVerbLevel(this->getVerbLevel());
629 const RCP<const MVLO> mvlo =
630 rcp_dynamic_cast<
const MVLO>(fwdOpSrc->getOp().assert_not_null());
631 const RCP<const MVLO> amvlo =
632 rcp_dynamic_cast<
const MVLO>(approxFwdOpSrc->getOp().assert_not_null());
633 MVLOWS &mvlows =
dyn_cast<MVLOWS>(*Op);
635 lowsf_.getConstObj()->initializeApproxPreconditionedOp(
636 defaultLinearOpSource<Scalar>(mvlo->getLinearOp()),
637 defaultLinearOpSource<Scalar>(amvlo->getLinearOp()),
638 mvlows.getNonconstLinearOpWithSolve().get(),
644 template<
class Scalar>
649 lowsf_.getConstObj()->setVerbLevel(this->getVerbLevel());
650 lowsf_.getConstObj()->setOStream(this->getOStream());
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 MultiVectorPreconditioner...
RCP< const DefaultMultiVectorProductVectorSpace< Scalar > > multiVecRange_
void setParameterList(RCP< ParameterList > const ¶mList)
bool is_null(const boost::shared_ptr< T > &p)
RCP< const DefaultMultiVectorProductVectorSpace< Scalar > > multiVecDomain_
virtual bool supportsPreconditionerInputType(const EPreconditionerInputType precOpType) const
RCP< const ParameterList > getValidParameters() const
virtual void initializeOp(const RCP< const LinearOpSourceBase< Scalar > > &fwdOpSrc, LinearOpWithSolveBase< Scalar > *Op, const ESupportSolveUse supportSolveUse) const
RCP< MultiVectorLinearOpWithSolveFactory< Scalar > > multiVectorLinearOpWithSolveFactory(const RCP< const LinearOpWithSolveFactoryBase< Scalar > > &lowsf, const RCP< const DefaultMultiVectorProductVectorSpace< Scalar > > &multiVecRange, const RCP< const DefaultMultiVectorProductVectorSpace< Scalar > > &multiVecDomain)
Nonmember constructor.
T_To & dyn_cast(T_From &from)
virtual RCP< LinearOpWithSolveBase< Scalar > > createOp() const
Create a LinearOpWithSolveFactory for a flattened-out multi-vector.
RCP< LinearOpWithSolveFactoryBase< Scalar > > getUnderlyingLOWSF()
virtual void setPreconditionerFactory(const RCP< PreconditionerFactoryBase< Scalar > > &precFactory, const std::string &precFactoryName)
Throws exception.
RCP< MultiVectorLinearOpWithSolveFactory< Scalar > > nonconstMultiVectorLinearOpWithSolveFactory(const RCP< LinearOpWithSolveFactoryBase< Scalar > > &lowsf, const RCP< const DefaultMultiVectorProductVectorSpace< Scalar > > &multiVecRange, const RCP< const DefaultMultiVectorProductVectorSpace< Scalar > > &multiVecDomain)
Nonmember constructor.
virtual RCP< PreconditionerFactoryBase< Scalar > > getPreconditionerFactory() const
Returns null .
MultiVectorLinearOpWithSolveFactory()
Construct to uninitialized.
TEUCHOS_DEPRECATED RCP< T > rcp(T *p, Dealloc_T dealloc, bool owns_mem)
RCP< MultiVectorLinearOpWithSolveFactory< Scalar > > nonconstMultiVectorLinearOpWithSolveFactory(const RCP< LinearOpWithSolveFactoryBase< Scalar > > &lowsf, const int num_blocks)
Nonmember constructor.
void nonconstInitialize(const RCP< LinearOpWithSolveFactoryBase< Scalar > > &lowsf, const RCP< const DefaultMultiVectorProductVectorSpace< Scalar > > &multiVecRange, const RCP< const DefaultMultiVectorProductVectorSpace< Scalar > > &multiVecDomain)
Initialize given a single non-const LOWSFB object.
virtual std::string description() const
virtual void initializeAndReuseOp(const RCP< const LinearOpSourceBase< Scalar > > &fwdOpSrc, LinearOpWithSolveBase< Scalar > *Op) const
virtual bool acceptsPreconditionerFactory() const
returns false.
void initialize(const RCP< const LinearOpWithSolveFactoryBase< Scalar > > &lowsf, const RCP< const DefaultMultiVectorProductVectorSpace< Scalar > > &multiVecRange, const RCP< const DefaultMultiVectorProductVectorSpace< Scalar > > &multiVecDomain)
Initialize given a single const LOWSFB object.
virtual void unsetPreconditionerFactory(RCP< PreconditionerFactoryBase< Scalar > > *precFactory, std::string *precFactoryName)
Throws exception.
Teuchos::ConstNonconstObjectContainer< LinearOpWithSolveFactoryBase< Scalar > > LOWSF_t
Implicit concrete LinearOpBase subclass that takes a flattended out multi-vector and performs a multi...
RCP< ParameterList > getNonconstParameterList()
Concrete PreconditionerBase subclass that wraps a preconditioner operator in MultiVectorLinearOp.
virtual bool isCompatible(const LinearOpSourceBase< Scalar > &fwdOpSrc) const
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
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
RCP< MultiVectorLinearOpWithSolveFactory< Scalar > > multiVectorLinearOpWithSolveFactory(const RCP< const LinearOpWithSolveFactoryBase< Scalar > > &lowsf, const int num_blocks)
Nonmember constructor.
virtual Teuchos::RCP< const LinearOpBase< Scalar > > getOp() const =0
RCP< const ParameterList > getParameterList() const
#define TEUCHOS_TEST_FOR_EXCEPT(throw_exception_test)
void informUpdatedVerbosityState() const
Overridden from Teuchos::VerboseObjectBase.