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>
26 :
virtual public LinearOpWithSolveFactoryBase<Scalar>
49 const RCP<LinearOpWithSolveFactoryBase<Scalar> > &lowsf,
50 const RCP<
const DefaultMultiVectorProductVectorSpace<Scalar> > &multiVecRange,
51 const RCP<
const DefaultMultiVectorProductVectorSpace<Scalar> > &multiVecDomain
68 const RCP<
const LinearOpWithSolveFactoryBase<Scalar> > &lowsf,
69 const RCP<
const DefaultMultiVectorProductVectorSpace<Scalar> > &multiVecRange,
70 const RCP<
const DefaultMultiVectorProductVectorSpace<Scalar> > &multiVecDomain
105 const RCP<PreconditionerFactoryBase<Scalar> > &precFactory,
106 const std::string &precFactoryName
110 virtual RCP<PreconditionerFactoryBase<Scalar> >
115 RCP<PreconditionerFactoryBase<Scalar> > *precFactory,
116 std::string *precFactoryName
120 const LinearOpSourceBase<Scalar> &fwdOpSrc
123 virtual RCP<LinearOpWithSolveBase<Scalar> >
createOp()
const;
126 const RCP<
const LinearOpSourceBase<Scalar> > &fwdOpSrc,
127 LinearOpWithSolveBase<Scalar> *Op,
128 const ESupportSolveUse supportSolveUse
132 const RCP<
const LinearOpSourceBase<Scalar> > &fwdOpSrc,
133 LinearOpWithSolveBase<Scalar> *Op
137 LinearOpWithSolveBase<Scalar> *Op,
138 RCP<
const LinearOpSourceBase<Scalar> > *fwdOpSrc,
139 RCP<
const PreconditionerBase<Scalar> > *prec,
140 RCP<
const LinearOpSourceBase<Scalar> > *approxFwdOpSrc,
141 ESupportSolveUse *supportSolveUse
145 const EPreconditionerInputType precOpType
149 const RCP<
const LinearOpSourceBase<Scalar> > &fwdOpSrc,
150 const RCP<
const PreconditionerBase<Scalar> > &prec,
151 LinearOpWithSolveBase<Scalar> *Op,
152 const ESupportSolveUse supportSolveUse
156 const RCP<
const LinearOpSourceBase<Scalar> > &fwdOpSrc,
157 const RCP<
const LinearOpSourceBase<Scalar> > &approxFwdOpSrc,
158 LinearOpWithSolveBase<Scalar> *Op,
159 const ESupportSolveUse supportSolveUse
175 typedef Teuchos::ConstNonconstObjectContainer<LinearOpWithSolveFactoryBase<Scalar> >
LOWSF_t;
187 template<
class Scalar>
188 RCP<MultiVectorLinearOpWithSolveFactory<Scalar> >
190 const RCP<LinearOpWithSolveFactoryBase<Scalar> > &lowsf,
191 const RCP<
const DefaultMultiVectorProductVectorSpace<Scalar> > &multiVecRange,
192 const RCP<
const DefaultMultiVectorProductVectorSpace<Scalar> > &multiVecDomain
195 RCP<MultiVectorLinearOpWithSolveFactory<Scalar> > mvlowsf =
197 mvlowsf->nonconstInitialize(lowsf,multiVecRange,multiVecDomain);
205 template<
class Scalar>
206 RCP<MultiVectorLinearOpWithSolveFactory<Scalar> >
208 const RCP<LinearOpWithSolveFactoryBase<Scalar> > &lowsf,
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> >
227 const RCP<
const LinearOpWithSolveFactoryBase<Scalar> > &lowsf,
228 const RCP<
const DefaultMultiVectorProductVectorSpace<Scalar> > &multiVecRange,
229 const RCP<
const DefaultMultiVectorProductVectorSpace<Scalar> > &multiVecDomain
232 RCP<MultiVectorLinearOpWithSolveFactory<Scalar> > mvlowsf =
234 mvlowsf->initialize(lowsf,multiVecRange,multiVecDomain);
242 template<
class Scalar>
243 RCP<MultiVectorLinearOpWithSolveFactory<Scalar> >
245 const RCP<
const LinearOpWithSolveFactoryBase<Scalar> > &lowsf,
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>
263 const RCP<LinearOpWithSolveFactoryBase<Scalar> > &lowsf,
264 const RCP<
const DefaultMultiVectorProductVectorSpace<Scalar> > &multiVecRange,
265 const RCP<
const DefaultMultiVectorProductVectorSpace<Scalar> > &multiVecDomain
269 TEUCHOS_TEST_FOR_EXCEPT(is_null(lowsf));
271 lowsf_.initialize(lowsf);
272 multiVecRange_ = multiVecRange;
273 multiVecDomain_ = multiVecDomain;
276 template<
class Scalar>
280 const RCP<
const LinearOpWithSolveFactoryBase<Scalar> > &lowsf,
281 const RCP<
const DefaultMultiVectorProductVectorSpace<Scalar> > &multiVecRange,
282 const RCP<
const DefaultMultiVectorProductVectorSpace<Scalar> > &multiVecDomain
286 TEUCHOS_TEST_FOR_EXCEPT(is_null(lowsf));
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;
317 oss << this->Teuchos::Describable::description()
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>
386 const RCP<PreconditionerFactoryBase<Scalar> > &precFactory,
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>
415 RCP<PreconditionerFactoryBase<Scalar> > *precFactory,
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>
433 const LinearOpSourceBase<Scalar> &fwdOpSrc
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>
459 const RCP<
const LinearOpSourceBase<Scalar> > &fwdOpSrc,
460 LinearOpWithSolveBase<Scalar> *Op,
461 const ESupportSolveUse supportSolveUse
464 using Teuchos::dyn_cast;
465 using Teuchos::rcp_dynamic_cast;
468 TEUCHOS_TEST_FOR_EXCEPT(0==Op);
472 lowsf_.getConstObj()->setOStream(this->getOStream());
473 lowsf_.getConstObj()->setVerbLevel(this->getVerbLevel());
476 typedef DefaultMultiVectorLinearOpWithSolve<Scalar> MVLOWS;
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>
491 const RCP<
const LinearOpSourceBase<Scalar> > &fwdOpSrc,
492 LinearOpWithSolveBase<Scalar> *Op
495 using Teuchos::dyn_cast;
496 using Teuchos::rcp_dynamic_cast;
499 TEUCHOS_TEST_FOR_EXCEPT(0==Op);
503 lowsf_.getConstObj()->setOStream(this->getOStream());
504 lowsf_.getConstObj()->setVerbLevel(this->getVerbLevel());
507 typedef DefaultMultiVectorLinearOpWithSolve<Scalar> MVLOWS;
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>
521 LinearOpWithSolveBase<Scalar> *Op,
522 RCP<
const LinearOpSourceBase<Scalar> > *fwdOpSrc,
523 RCP<
const PreconditionerBase<Scalar> > *prec,
524 RCP<
const LinearOpSourceBase<Scalar> > *approxFwdOpSrc,
525 ESupportSolveUse *supportSolveUse
528 using Teuchos::dyn_cast;
531 TEUCHOS_TEST_FOR_EXCEPT(0==Op);
533 typedef DefaultMultiVectorLinearOpWithSolve<Scalar> MVLOWS;
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>
564 const EPreconditionerInputType precOpType
567 return lowsf_.getConstObj()->supportsPreconditionerInputType(precOpType);
570 template<
class Scalar>
574 const RCP<
const LinearOpSourceBase<Scalar> > &fwdOpSrc,
575 const RCP<
const PreconditionerBase<Scalar> > &prec,
576 LinearOpWithSolveBase<Scalar> *Op,
577 const ESupportSolveUse supportSolveUse
580 using Teuchos::dyn_cast;
581 using Teuchos::rcp_dynamic_cast;
584 TEUCHOS_TEST_FOR_EXCEPT(0==Op);
588 lowsf_.getConstObj()->setOStream(this->getOStream());
589 lowsf_.getConstObj()->setVerbLevel(this->getVerbLevel());
593 typedef DefaultMultiVectorLinearOpWithSolve<Scalar> MVLOWS;
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>
610 const RCP<
const LinearOpSourceBase<Scalar> > &fwdOpSrc,
611 const RCP<
const LinearOpSourceBase<Scalar> > &approxFwdOpSrc,
612 LinearOpWithSolveBase<Scalar> *Op,
613 const ESupportSolveUse supportSolveUse
616 using Teuchos::dyn_cast;
617 using Teuchos::rcp_dynamic_cast;
620 TEUCHOS_TEST_FOR_EXCEPT(0==Op);
624 lowsf_.getConstObj()->setOStream(this->getOStream());
625 lowsf_.getConstObj()->setVerbLevel(this->getVerbLevel());
628 typedef DefaultMultiVectorLinearOpWithSolve<Scalar> MVLOWS;
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)
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.
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.
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 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.
RCP< const ParameterList > getParameterList() const
void informUpdatedVerbosityState() const
Overridden from Teuchos::VerboseObjectBase.