10 #ifndef Thyra_MultiVectorLinearOpWithSolveFactory_hpp
11 #define Thyra_MultiVectorLinearOpWithSolveFactory_hpp
13 #include "Thyra_LinearOpWithSolveFactoryBase.hpp"
17 #include "Thyra_DefaultMultiVectorLinearOpWithSolve.hpp"
18 #include "Thyra_DefaultMultiVectorProductVectorSpace.hpp"
19 #include "Thyra_DefaultLinearOpSource.hpp"
25 template <
class Scalar>
106 const std::string &precFactoryName);
115 std::string *precFactoryName);
119 virtual RCP<LinearOpWithSolveBase<Scalar> >
createOp()
const;
176 template <
class Scalar>
177 RCP<MultiVectorLinearOpWithSolveFactory<Scalar> >
185 RCP<MultiVectorLinearOpWithSolveFactory<Scalar> > mvlowsf =
187 mvlowsf->nonconstInitialize(lowsf, multiVecRange, multiVecDomain);
195 template <
class Scalar>
196 RCP<MultiVectorLinearOpWithSolveFactory<Scalar> >
199 const int num_blocks)
201 RCP<LinearOpWithSolveBase<Scalar> > op = lowsf->createOp();
202 RCP<const Thyra::DefaultMultiVectorProductVectorSpace<Scalar> > mv_domain =
203 Thyra::multiVectorProductVectorSpace(op->domain(), num_blocks);
204 RCP<const Thyra::DefaultMultiVectorProductVectorSpace<Scalar> > mv_range =
205 Thyra::multiVectorProductVectorSpace(op->range(), num_blocks);
206 return nonconstMultiVectorLinearOpWithSolveFactory(lowsf, mv_range,
214 template <
class Scalar>
215 RCP<MultiVectorLinearOpWithSolveFactory<Scalar> >
223 RCP<MultiVectorLinearOpWithSolveFactory<Scalar> > mvlowsf =
225 mvlowsf->initialize(lowsf, multiVecRange, multiVecDomain);
233 template <
class Scalar>
234 RCP<MultiVectorLinearOpWithSolveFactory<Scalar> >
237 const int num_blocks)
239 RCP<LinearOpWithSolveBase<Scalar> > op = lowsf->createOp();
240 RCP<const Thyra::DefaultMultiVectorProductVectorSpace<Scalar> > mv_domain =
241 Thyra::multiVectorProductVectorSpace(op->domain(), num_blocks);
242 RCP<const Thyra::DefaultMultiVectorProductVectorSpace<Scalar> > mv_range =
243 Thyra::multiVectorProductVectorSpace(op->range(), num_blocks);
244 return multiVectorLinearOpWithSolveFactory(lowsf, mv_range, mv_domain);
249 template <
class Scalar>
260 lowsf_.initialize(lowsf);
261 multiVecRange_ = multiVecRange;
262 multiVecDomain_ = multiVecDomain;
265 template <
class Scalar>
276 lowsf_.initialize(lowsf);
277 multiVecRange_ = multiVecRange;
278 multiVecDomain_ = multiVecDomain;
281 template <
class Scalar>
282 RCP<LinearOpWithSolveFactoryBase<Scalar> >
285 return lowsf_.getNonconstObj();
288 template <
class Scalar>
289 RCP<const LinearOpWithSolveFactoryBase<Scalar> >
292 return lowsf_.getConstObj();
297 template <
class Scalar>
300 std::ostringstream oss;
303 if (!
is_null(lowsf_.getConstObj()))
304 oss << lowsf_.getConstObj()->description();
313 template <
class Scalar>
315 RCP<ParameterList>
const ¶mList)
317 lowsf_.getNonconstObj()->setParameterList(paramList);
320 template <
class Scalar>
324 return lowsf_.getNonconstObj()->getNonconstParameterList();
327 template <
class Scalar>
331 return lowsf_.getNonconstObj()->unsetParameterList();
334 template <
class Scalar>
335 RCP<const ParameterList>
338 return lowsf_.getConstObj()->getParameterList();
341 template <
class Scalar>
342 RCP<const ParameterList>
345 return lowsf_.getConstObj()->getValidParameters();
350 template <
class Scalar>
354 return lowsf_.getConstObj()->acceptsPreconditionerFactory();
357 template <
class Scalar>
360 const std::string &precFactoryName)
363 RCP<MVPF> mvpf = Teuchos::rcp_dynamic_cast<MVPF>(precFactory);
364 lowsf_.getNonconstObj()->setPreconditionerFactory(
365 mvpf->getNonconstPreconditionerFactory(), precFactoryName);
368 template <
class Scalar>
369 RCP<PreconditionerFactoryBase<Scalar> >
372 RCP<PreconditionerFactoryBase<Scalar> > prec_fac =
373 lowsf_.getConstObj()->getPreconditionerFactory();
374 if (prec_fac == Teuchos::null)
375 return Teuchos::null;
377 return nonconstMultiVectorPreconditionerFactory(prec_fac, multiVecRange_,
381 template <
class Scalar>
384 std::string *precFactoryName)
386 RCP<PreconditionerFactoryBase<Scalar> > inner_precFactory;
387 lowsf_.getNonconstObj()->unsetPreconditionerFactory(
388 precFactory ? &inner_precFactory : NULL, precFactoryName);
390 *precFactory = nonconstMultiVectorPreconditionerFactory(
391 inner_precFactory, multiVecRange_, multiVecDomain_);
394 template <
class Scalar>
399 RCP<const MVLO> mvlo =
400 Teuchos::rcp_dynamic_cast<
const MVLO>(fwdOpSrc.
getOp().assert_not_null());
401 RCP<const LinearOpSourceBase<Scalar> > inner_fwdOpSrc =
402 defaultLinearOpSource<Scalar>(mvlo->getLinearOp());
403 return lowsf_.getConstObj()->isCompatible(*inner_fwdOpSrc);
406 template <
class Scalar>
407 RCP<LinearOpWithSolveBase<Scalar> >
410 return nonconstMultiVectorLinearOpWithSolve<Scalar>(
411 lowsf_.getConstObj()->createOp(), multiVecRange_, multiVecDomain_);
414 template <
class Scalar>
421 using Teuchos::rcp_dynamic_cast;
428 lowsf_.getConstObj()->setOStream(this->getOStream());
429 lowsf_.getConstObj()->setVerbLevel(this->getVerbLevel());
433 const RCP<const MVLO> mvlo =
434 rcp_dynamic_cast<
const MVLO>(fwdOpSrc->getOp().assert_not_null());
435 MVLOWS &mvlows =
dyn_cast<MVLOWS>(*Op);
437 lowsf_.getConstObj()->initializeOp(
438 defaultLinearOpSource<Scalar>(mvlo->getLinearOp()),
439 mvlows.getNonconstLinearOpWithSolve().get(), supportSolveUse);
442 template <
class Scalar>
448 using Teuchos::rcp_dynamic_cast;
455 lowsf_.getConstObj()->setOStream(this->getOStream());
456 lowsf_.getConstObj()->setVerbLevel(this->getVerbLevel());
460 const RCP<const MVLO> mvlo =
461 rcp_dynamic_cast<
const MVLO>(fwdOpSrc->getOp().assert_not_null());
462 MVLOWS &mvlows =
dyn_cast<MVLOWS>(*Op);
464 lowsf_.getConstObj()->initializeAndReuseOp(
465 defaultLinearOpSource<Scalar>(mvlo->getLinearOp()),
466 mvlows.getNonconstLinearOpWithSolve().get());
469 template <
class Scalar>
483 MVLOWS &mvlowsOp =
dyn_cast<MVLOWS>(*Op);
484 RCP<const LinearOpSourceBase<Scalar> > inner_fwdOpSrc;
485 RCP<const PreconditionerBase<Scalar> > inner_prec;
486 RCP<const LinearOpSourceBase<Scalar> > inner_approxFwdOpSrc;
487 lowsf_.getConstObj()->uninitializeOp(
488 mvlowsOp.getNonconstLinearOpWithSolve().get(),
489 fwdOpSrc ? &inner_fwdOpSrc : NULL, prec ? &inner_prec : NULL,
490 approxFwdOpSrc ? &inner_approxFwdOpSrc : NULL, supportSolveUse);
492 *fwdOpSrc = defaultLinearOpSource<Scalar>(multiVectorLinearOp(
493 inner_fwdOpSrc->getOp(), multiVecRange_, multiVecDomain_));
496 multiVectorPreconditioner(inner_prec, multiVecRange_, multiVecDomain_);
498 *approxFwdOpSrc = defaultLinearOpSource<Scalar>(multiVectorLinearOp(
499 inner_approxFwdOpSrc->getOp(), multiVecRange_, multiVecDomain_));
502 template <
class Scalar>
510 template <
class Scalar>
518 using Teuchos::rcp_dynamic_cast;
525 lowsf_.getConstObj()->setOStream(this->getOStream());
526 lowsf_.getConstObj()->setVerbLevel(this->getVerbLevel());
531 const RCP<const MVLO> mvlo =
532 rcp_dynamic_cast<
const MVLO>(fwdOpSrc->getOp().assert_not_null());
533 const RCP<const MVP> mvp = rcp_dynamic_cast<
const MVP>(prec);
534 MVLOWS &mvlows =
dyn_cast<MVLOWS>(*Op);
536 lowsf_.getConstObj()->initializePreconditionedOp(
537 defaultLinearOpSource<Scalar>(mvlo->getLinearOp()),
538 mvp->getPreconditioner(), mvlows.getNonconstLinearOpWithSolve().get(),
542 template <
class Scalar>
551 using Teuchos::rcp_dynamic_cast;
558 lowsf_.getConstObj()->setOStream(this->getOStream());
559 lowsf_.getConstObj()->setVerbLevel(this->getVerbLevel());
563 const RCP<const MVLO> mvlo =
564 rcp_dynamic_cast<
const MVLO>(fwdOpSrc->getOp().assert_not_null());
565 const RCP<const MVLO> amvlo =
566 rcp_dynamic_cast<
const MVLO>(approxFwdOpSrc->getOp().assert_not_null());
567 MVLOWS &mvlows =
dyn_cast<MVLOWS>(*Op);
569 lowsf_.getConstObj()->initializeApproxPreconditionedOp(
570 defaultLinearOpSource<Scalar>(mvlo->getLinearOp()),
571 defaultLinearOpSource<Scalar>(amvlo->getLinearOp()),
572 mvlows.getNonconstLinearOpWithSolve().get(), supportSolveUse);
577 template <
class Scalar>
581 lowsf_.getConstObj()->setVerbLevel(this->getVerbLevel());
582 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.
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
Teuchos::ConstNonconstObjectContainer< LinearOpWithSolveFactoryBase< Scalar > > LOWSF_t
#define TEUCHOS_TEST_FOR_EXCEPT(throw_exception_test)
void informUpdatedVerbosityState() const
Overridden from Teuchos::VerboseObjectBase.