Thyra Version of the Day
Loading...
Searching...
No Matches
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
19namespace Thyra {
20
21
26template <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
44template <class Scalar>
46 const PreconditionerFactoryBase<Scalar> &precFactory,
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
62template <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
Base class for all linear operators.
Simple interface class to access a precreated preconditioner as one or more linear operators objects ...
Factory interface for creating preconditioner objects from LinearOpBase objects.
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.
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.
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.
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.
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 "compatible" LinearOpBase object.
virtual RCP< PreconditionerBase< Scalar > > createPrec() const =0
Create an (uninitialized) LinearOpBase object to be initialized as the preconditioner later in this->...
ESupportSolveUse
Enum that specifies how a LinearOpWithSolveBase object will be used for solves after it is constructe...
@ SUPPORT_SOLVE_UNSPECIFIED
How the output LOWSB object will be useded for solves in unspecified.
T_To & dyn_cast(T_From &from)