9 #ifndef Thyra_BlockedTriangularLinearOpWithSolveFactory_hpp
10 #define Thyra_BlockedTriangularLinearOpWithSolveFactory_hpp
12 #include "Thyra_LinearOpWithSolveBase.hpp"
13 #include "Thyra_DefaultBlockedLinearOp.hpp"
14 #include "Thyra_DefaultBlockedTriangularLinearOpWithSolve.hpp"
15 #include "Thyra_LinearOpSourceBase.hpp"
16 #include "Teuchos_Array.hpp"
60 template<
class Scalar>
62 :
virtual public LinearOpWithSolveFactoryBase<Scalar>
80 const Array< RCP<LinearOpWithSolveFactoryBase<Scalar> > > &lowsf
95 const Array< RCP<
const LinearOpWithSolveFactoryBase<Scalar> > > &lowsf
130 const RCP<PreconditionerFactoryBase<Scalar> > &precFactory,
131 const std::string &precFactoryName
135 virtual RCP<PreconditionerFactoryBase<Scalar> >
140 RCP<PreconditionerFactoryBase<Scalar> > *precFactory,
141 std::string *precFactoryName
145 const LinearOpSourceBase<Scalar> &fwdOpSrc
148 virtual RCP<LinearOpWithSolveBase<Scalar> >
createOp()
const;
151 const RCP<
const LinearOpSourceBase<Scalar> > &fwdOpSrc,
152 LinearOpWithSolveBase<Scalar> *Op,
153 const ESupportSolveUse supportSolveUse
157 const RCP<
const LinearOpSourceBase<Scalar> > &fwdOpSrc,
158 LinearOpWithSolveBase<Scalar> *Op
162 LinearOpWithSolveBase<Scalar> *Op,
163 RCP<
const LinearOpSourceBase<Scalar> > *fwdOpSrc,
164 RCP<
const PreconditionerBase<Scalar> > *prec,
165 RCP<
const LinearOpSourceBase<Scalar> > *approxFwdOpSrc,
166 ESupportSolveUse *supportSolveUse
170 const EPreconditionerInputType precOpType
174 const RCP<
const LinearOpSourceBase<Scalar> > &fwdOpSrc,
175 const RCP<
const PreconditionerBase<Scalar> > &prec,
176 LinearOpWithSolveBase<Scalar> *Op,
177 const ESupportSolveUse supportSolveUse
181 const RCP<
const LinearOpSourceBase<Scalar> > &fwdOpSrc,
182 const RCP<
const LinearOpSourceBase<Scalar> > &approxFwdOpSrc,
183 LinearOpWithSolveBase<Scalar> *Op,
184 const ESupportSolveUse supportSolveUse
200 typedef Teuchos::ConstNonconstObjectContainer<LinearOpWithSolveFactoryBase<Scalar> >
LOWSF_t;
214 template<
class Scalar>
215 RCP<BlockedTriangularLinearOpWithSolveFactory<Scalar> >
217 const Array< RCP<LinearOpWithSolveFactoryBase<Scalar> > > &lowsf
230 template<
class Scalar>
231 RCP<BlockedTriangularLinearOpWithSolveFactory<Scalar> >
233 const Array< RCP<
const LinearOpWithSolveFactoryBase<Scalar> > > &lowsf
243 template<
class Scalar>
246 const Array< RCP<LinearOpWithSolveFactoryBase<Scalar> > > &lowsf
247 ) : lowsf_(lowsf.size())
249 for (Ordinal i=0; i<lowsf.size(); ++i) {
251 TEUCHOS_TEST_FOR_EXCEPT(is_null(lowsf[i]));
253 lowsf_[i].initialize(lowsf[i]);
257 template<
class Scalar>
260 const Array< RCP<
const LinearOpWithSolveFactoryBase<Scalar> > > &lowsf
261 ) : lowsf_(lowsf.size())
263 for (Ordinal i=0; i<lowsf.size(); ++i) {
265 TEUCHOS_TEST_FOR_EXCEPT(is_null(lowsf[i]));
267 lowsf_[i].initialize(lowsf[i]);
271 template<
class Scalar>
272 Array< RCP<LinearOpWithSolveFactoryBase<Scalar> > >
276 Array< RCP<LinearOpWithSolveFactoryBase<Scalar> > > lowsf(lowsf_.size());
277 for (Ordinal i=0; i<lowsf_.size(); ++i) {
278 lowsf[i] = lowsf_[i].getNonconstObj();
283 template<
class Scalar>
284 Array< RCP<const LinearOpWithSolveFactoryBase<Scalar> > >
288 Array< RCP<const LinearOpWithSolveFactoryBase<Scalar> > > lowsf(lowsf_.size());
289 for (Ordinal i=0; i<lowsf_.size(); ++i) {
290 lowsf[i] = lowsf_[i].getConstObj();
297 template<
class Scalar>
302 std::ostringstream oss;
303 oss << this->Teuchos::Describable::description()
305 for (Ordinal i=0; i<lowsf_.size(); ++i) {
307 if (!is_null(lowsf_[i].getConstObj()))
308 oss << lowsf_[i].getConstObj()->description();
320 template<
class Scalar>
324 RCP<ParameterList>
const& paramList
327 for (Ordinal i=0; i<lowsf_.size(); ++i) {
328 lowsf_[i].getNonconstObj()->setParameterList(paramList);
332 template<
class Scalar>
337 return lowsf_[0].getNonconstObj()->getNonconstParameterList();
340 template<
class Scalar>
345 RCP<ParameterList> pl;
346 for (Ordinal i=0; i<lowsf_.size(); ++i) {
347 pl = lowsf_[i].getNonconstObj()->unsetParameterList();
352 template<
class Scalar>
353 RCP<const ParameterList>
357 return lowsf_[0].getConstObj()->getParameterList();
360 template<
class Scalar>
361 RCP<const ParameterList>
365 return lowsf_[0].getConstObj()->getValidParameters();
370 template<
class Scalar>
378 template<
class Scalar>
382 const RCP<PreconditionerFactoryBase<Scalar> > &,
386 TEUCHOS_TEST_FOR_EXCEPTION(
true,std::logic_error,
387 "Error, we don't support a preconditioner factory!");
390 template<
class Scalar>
391 RCP<PreconditionerFactoryBase<Scalar> >
395 return Teuchos::null;
398 template<
class Scalar>
401 RCP<PreconditionerFactoryBase<Scalar> > * ,
405 TEUCHOS_TEST_FOR_EXCEPTION(
true,std::logic_error,
406 "Error, we don't support a preconditioner factory!");
409 template<
class Scalar>
413 const LinearOpSourceBase<Scalar> &
416 TEUCHOS_TEST_FOR_EXCEPT(
true);
417 TEUCHOS_UNREACHABLE_RETURN(
false);
420 template<
class Scalar>
421 RCP<LinearOpWithSolveBase<Scalar> >
425 return defaultBlockedTriangularLinearOpWithSolve<Scalar>();
428 template<
class Scalar>
432 const RCP<
const LinearOpSourceBase<Scalar> > &fwdOpSrc,
433 LinearOpWithSolveBase<Scalar> *Op,
434 const ESupportSolveUse
438 using Teuchos::dyn_cast;
439 using Teuchos::rcp_dynamic_cast;
442 TEUCHOS_TEST_FOR_EXCEPT(0==Op);
446 for (Ordinal i=0; i<lowsf_.size(); ++i) {
447 lowsf_[i].getConstObj()->setOStream(this->getOStream());
448 lowsf_[i].getConstObj()->setVerbLevel(this->getVerbLevel());
452 typedef PhysicallyBlockedLinearOpBase<Scalar> PBLOB;
453 const RCP<const PBLOB> blo =
454 rcp_dynamic_cast<
const PBLOB>(fwdOpSrc->getOp().assert_not_null());
459 typedef DefaultBlockedTriangularLinearOpWithSolve<Scalar> DBTLOWS;
460 DBTLOWS &btlows = dyn_cast<DBTLOWS>(*Op);
465 const bool firstTime = is_null(btlows.range());
470 btlows.beginBlockFill(blo->productRange(),blo->productDomain());
472 const int N = blo->productRange()->numBlocks();
473 for (
int k = 0; k < N; ++k ) {
474 const RCP<const LinearOpBase<Scalar> > fwdOp_k =
475 blo->getBlock(k,k).assert_not_null();
479 btlows.setNonconstLOWSBlock( k, k,
480 linearOpWithSolve<Scalar>(*lowsf_[k].getConstObj(),fwdOp_k)
487 RCP<LinearOpWithSolveBase<Scalar> >
488 invOp_k = btlows.getNonconstLOWSBlock(k,k).assert_not_null();
489 Thyra::initializeOp<Scalar>(*lowsf_[k].getConstObj(), fwdOp_k, invOp_k.ptr());
496 btlows.endBlockFill();
501 btlows.setBlocks(blo);
504 btlows.setOStream(this->getOStream());
505 btlows.setVerbLevel(this->getVerbLevel());
508 template<
class Scalar>
512 const RCP<
const LinearOpSourceBase<Scalar> > &,
513 LinearOpWithSolveBase<Scalar> *
516 TEUCHOS_TEST_FOR_EXCEPT(
true);
519 template<
class Scalar>
523 LinearOpWithSolveBase<Scalar> *Op,
524 RCP<
const LinearOpSourceBase<Scalar> > *fwdOpSrc,
525 RCP<
const PreconditionerBase<Scalar> > *prec,
526 RCP<
const LinearOpSourceBase<Scalar> > *approxFwdOpSrc,
530 using Teuchos::dyn_cast;
531 using Teuchos::rcp_implicit_cast;
532 using Teuchos::rcp_dynamic_cast;
533 typedef DefaultBlockedTriangularLinearOpWithSolve<Scalar> DBTLOWS;
534 TEUCHOS_TEST_FOR_EXCEPT(0==Op);
535 DBTLOWS &btlowsOp = dyn_cast<DBTLOWS>(*Op);
537 const RCP<const LinearOpBase<Scalar> > fwdOp = btlowsOp.getBlocks();
539 *fwdOpSrc = defaultLinearOpSource<Scalar>(fwdOp);
541 *fwdOpSrc = Teuchos::null;
543 if (prec) *prec = Teuchos::null;
544 if (approxFwdOpSrc) *approxFwdOpSrc = Teuchos::null;
547 template<
class Scalar>
551 const EPreconditionerInputType
562 template<
class Scalar>
566 const RCP<
const LinearOpSourceBase<Scalar> > &,
567 const RCP<
const PreconditionerBase<Scalar> > &,
568 LinearOpWithSolveBase<Scalar> * ,
569 const ESupportSolveUse
572 TEUCHOS_TEST_FOR_EXCEPTION(
true,std::logic_error,
573 "Error, we don't support an external preconditioner!");
576 template<
class Scalar>
580 const RCP<
const LinearOpSourceBase<Scalar> > &,
581 const RCP<
const LinearOpSourceBase<Scalar> > &,
582 LinearOpWithSolveBase<Scalar> * ,
583 const ESupportSolveUse
586 TEUCHOS_TEST_FOR_EXCEPTION(
true,std::logic_error,
587 "Error, we don't support an external preconditioner!");
592 template<
class Scalar>
597 for (Ordinal i=0; i<lowsf_.size(); ++i) {
598 lowsf_[i].getConstObj()->setVerbLevel(this->getVerbLevel());
599 lowsf_[i].getConstObj()->setOStream(this->getOStream());
605 #endif // Thyra_BlockedTriangularLinearOpWithSolveFactory_hpp
virtual RCP< PreconditionerFactoryBase< Scalar > > getPreconditionerFactory() const
Returns null .
RCP< const ParameterList > getParameterList() const
void informUpdatedVerbosityState() const
Overridden from Teuchos::VerboseObjectBase.
BlockedTriangularLinearOpWithSolveFactory()
RCP< ParameterList > getNonconstParameterList()
RCP< BlockedTriangularLinearOpWithSolveFactory< Scalar > > blockedTriangularLinearOpWithSolveFactory(const Array< RCP< const LinearOpWithSolveFactoryBase< Scalar > > > &lowsf)
Nonmember constructor.
RCP< ParameterList > unsetParameterList()
Teuchos::ConstNonconstObjectContainer< LinearOpWithSolveFactoryBase< Scalar > > LOWSF_t
virtual bool isCompatible(const LinearOpSourceBase< Scalar > &fwdOpSrc) const
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 initializeOp(const RCP< const LinearOpSourceBase< Scalar > > &fwdOpSrc, LinearOpWithSolveBase< Scalar > *Op, const ESupportSolveUse supportSolveUse) const
RCP< const ParameterList > getValidParameters() const
virtual bool acceptsPreconditionerFactory() const
returns false.
virtual RCP< LinearOpWithSolveBase< Scalar > > createOp() const
virtual void initializePreconditionedOp(const RCP< const LinearOpSourceBase< Scalar > > &fwdOpSrc, const RCP< const PreconditionerBase< Scalar > > &prec, LinearOpWithSolveBase< Scalar > *Op, const ESupportSolveUse supportSolveUse) const
virtual void unsetPreconditionerFactory(RCP< PreconditionerFactoryBase< Scalar > > *precFactory, std::string *precFactoryName)
Throws exception.
virtual void setPreconditionerFactory(const RCP< PreconditionerFactoryBase< Scalar > > &precFactory, const std::string &precFactoryName)
Throws exception.
virtual void initializeAndReuseOp(const RCP< const LinearOpSourceBase< Scalar > > &fwdOpSrc, LinearOpWithSolveBase< Scalar > *Op) const
Array< RCP< LinearOpWithSolveFactoryBase< Scalar > > > getUnderlyingLOWSF()
virtual bool supportsPreconditionerInputType(const EPreconditionerInputType precOpType) const
void setParameterList(RCP< ParameterList > const ¶mList)
virtual void initializeApproxPreconditionedOp(const RCP< const LinearOpSourceBase< Scalar > > &fwdOpSrc, const RCP< const LinearOpSourceBase< Scalar > > &approxFwdOpSrc, LinearOpWithSolveBase< Scalar > *Op, const ESupportSolveUse supportSolveUse) const
RCP< BlockedTriangularLinearOpWithSolveFactory< Scalar > > blockedTriangularLinearOpWithSolveFactory(const Array< RCP< LinearOpWithSolveFactoryBase< Scalar > > > &lowsf)
Nonmember constructor.
Implicit subclass that takes a blocked triangular LOWB object and turns it into a LOWSB object...
std::string description() const