Thyra  Version of the Day
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Thyra_PreconditionerFactoryHelpers.hpp
1 // @HEADER
2 // *****************************************************************************
3 // Thyra: Interfaces and Support for Abstract Numerical Algorithms
4 //
5 // Copyright 2004 NTESS and the Thyra contributors.
6 // SPDX-License-Identifier: BSD-3-Clause
7 // *****************************************************************************
8 // @HEADER
9 
10 #ifndef THYRA_PRECONDITIONER_FACTORY_HELPERS_DECL_HPP
11 #define THYRA_PRECONDITIONER_FACTORY_HELPERS_DECL_HPP
12 
13 
14 #include "Thyra_PreconditionerFactoryBase.hpp"
15 #include "Thyra_DefaultLinearOpSource.hpp"
16 #include "Thyra_DefaultPreconditioner.hpp"
17 
18 
19 namespace Thyra {
20 
21 
26 template <class Scalar>
28  const PreconditionerFactoryBase<Scalar> &precFactory,
29  const Teuchos::RCP<const LinearOpBase<Scalar> > &fwdOp,
31  const ESupportSolveUse supportSolveUse = SUPPORT_SOLVE_UNSPECIFIED
32  )
33 {
34  precFactory.initializePrec(defaultLinearOpSource(fwdOp), prec.get(),
35  supportSolveUse);
36 }
37 
38 
44 template <class Scalar>
46  const PreconditionerFactoryBase<Scalar> &precFactory,
48  const Teuchos::Ptr<Teuchos::RCP<const LinearOpBase<Scalar> > > &fwdOp = Teuchos::null,
49  const Teuchos::Ptr<ESupportSolveUse> &supportSolveUse = Teuchos::null
50  )
51 {
53  precFactory.uninitializePrec(prec, Teuchos::outArg(fwdOpSrc), supportSolveUse);
54  if (nonnull(fwdOp)) {*fwdOp = fwdOpSrc->getOp();}
55 }
56 
57 
62 template <class Scalar>
65  const PreconditionerFactoryBase<Scalar> &precFactory,
66  const Teuchos::RCP<const LinearOpBase<Scalar> > &fwdOp,
67  const ESupportSolveUse supportSolveUse = SUPPORT_SOLVE_UNSPECIFIED
68  )
69 {
71  precFactory.createPrec();
72  precFactory.initializePrec(defaultLinearOpSource(fwdOp), &*prec, supportSolveUse);
73  return prec;
74 }
75 
76 
77 } // namespace Thyra
78 
79 
80 #endif // THYRA_PRECONDITIONER_FACTORY_HELPERS_DECL_HPP
How the output LOWSB object will be useded for solves in unspecified.
virtual void uninitializePrec(PreconditionerBase< Scalar > *prec, RCP< const LinearOpSourceBase< Scalar > > *fwdOpSrc=NULL, ESupportSolveUse *supportSolveUse=NULL) const =0
Uninitialize a LinearOpBase preconditioner object and return its remembered forward linear operator...
virtual RCP< PreconditionerBase< Scalar > > createPrec() const =0
Create an (uninitialized) LinearOpBase object to be initialized as the preconditioner later in this-&gt;...
Simple interface class to access a precreated preconditioner as one or more linear operators objects ...
Teuchos::RCP< PreconditionerBase< Scalar > > prec(const PreconditionerFactoryBase< Scalar > &precFactory, const Teuchos::RCP< const LinearOpBase< Scalar > > &fwdOp, const ESupportSolveUse supportSolveUse=SUPPORT_SOLVE_UNSPECIFIED)
Create and initialize a preconditioner from a forward linear operator.
virtual void initializePrec(const RCP< const LinearOpSourceBase< Scalar > > &fwdOpSrc, PreconditionerBase< Scalar > *precOp, const ESupportSolveUse supportSolveUse=SUPPORT_SOLVE_UNSPECIFIED) const =0
Initialize a pre-created LinearOpBase preconditioner object given a &quot;compatible&quot; LinearOpBase object...
void uninitializePrec(const PreconditionerFactoryBase< Scalar > &precFactory, const Teuchos::Ptr< PreconditionerBase< Scalar > > &prec, const Teuchos::Ptr< Teuchos::RCP< const LinearOpBase< Scalar > > > &fwdOp=Teuchos::null, const Teuchos::Ptr< ESupportSolveUse > &supportSolveUse=Teuchos::null)
Uninitialize a preconditioner and optionally extra what was used to create it.
void initializePrec(const PreconditionerFactoryBase< Scalar > &precFactory, const Teuchos::RCP< const LinearOpBase< Scalar > > &fwdOp, const Teuchos::Ptr< PreconditionerBase< Scalar > > &prec, const ESupportSolveUse supportSolveUse=SUPPORT_SOLVE_UNSPECIFIED)
Initialize a preconditioner from a forward linear operator.
Factory interface for creating preconditioner objects from LinearOpBase objects.
Base class for all linear operators.
ESupportSolveUse
Enum that specifies how a LinearOpWithSolveBase object will be used for solves after it is constructe...
bool nonnull(const boost::shared_ptr< T > &p)