Thyra Version of the Day
Loading...
Searching...
No Matches
Thyra_DefaultSerialDenseLinearOpWithSolveFactory_def.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_DEFAULT_SERIAL_DENSE_LINEAR_OP_WITH_SOLVE_FACTORY_HPP
11#define THYRA_DEFAULT_SERIAL_DENSE_LINEAR_OP_WITH_SOLVE_FACTORY_HPP
12
13
14#include "Thyra_DefaultSerialDenseLinearOpWithSolveFactory_decl.hpp"
15#include "Thyra_DefaultSerialDenseLinearOpWithSolve.hpp"
16#include "Thyra_LinearOpWithSolveFactoryHelpers.hpp"
17#include "Thyra_ScaledAdjointLinearOpBase.hpp"
18#include "Thyra_DefaultLinearOpSource.hpp"
19
20
21namespace Thyra {
22
23
24// Overridden from ParameterListAcceptor
25
26
27template<class Scalar>
29 RCP<ParameterList> const& paramList
30 )
31{
32 paramList->validateParameters(*this->getValidParameters());
33 // Nothing to set because we have not parameters!
34}
35
36
37template<class Scalar>
40{
41 static RCP<const ParameterList> validPL = Teuchos::parameterList();
42 return validPL;
43}
44
45
46// Overridden from LinearOpWithSolveFactoyBase
47
48
49template<class Scalar>
54
55
56template<class Scalar>
58 const RCP<PreconditionerFactoryBase<Scalar> > &/* precFactory */,
59 const std::string &/* precFactoryName */
60 )
61{
62 TEUCHOS_TEST_FOR_EXCEPT_MSG(true, "Error, we don't support a preconditioner factory!");
63}
64
65
66template<class Scalar>
72
73
74template<class Scalar>
76 RCP<PreconditionerFactoryBase<Scalar> > * /* precFactory */,
77 std::string * /* precFactoryName */
78 )
79{
80 TEUCHOS_TEST_FOR_EXCEPT_MSG(true, "Error, we don't support a preconditioner factory!");
81}
82
83
84template<class Scalar>
86 const LinearOpSourceBase<Scalar> &fwdOpSrc
87 ) const
88{
89 return !is_null(
90 Teuchos::rcp_dynamic_cast<const MultiVectorBase<Scalar> >(fwdOpSrc.getOp()));
91}
92
93
94template<class Scalar>
97{
98 return defaultSerialDenseLinearOpWithSolve<Scalar>();
99}
100
101
102template<class Scalar>
104 const RCP<const LinearOpSourceBase<Scalar> > &fwdOpSrc,
106 const ESupportSolveUse /* supportSolveUse */
107 ) const
108{
109
110 using Teuchos::dyn_cast;
111 using Teuchos::rcp_dynamic_cast;
112
113#ifdef TEUCHOS_DEBUG
115#endif
116
117 const RCP<const LinearOpBase<Scalar> > tmpFwdOp = fwdOpSrc->getOp();
119 Scalar fwdOp_scalar = 0.0;
120 EOpTransp fwdOp_transp;
121 unwrap<Scalar>(tmpFwdOp, &fwdOp_scalar, &fwdOp_transp, &fwdOp);
122
124 rcp_dynamic_cast<const MultiVectorBase<Scalar> >(fwdOp, true);
125
126 dyn_cast<DefaultSerialDenseLinearOpWithSolve<Scalar> >(*Op).initialize(fwdMv);
127
128}
129
130
131template<class Scalar>
139
140
141template<class Scalar>
144 RCP<const LinearOpSourceBase<Scalar> > *fwdOpSrc,
145 RCP<const PreconditionerBase<Scalar> > *prec,
146 RCP<const LinearOpSourceBase<Scalar> > *approxFwdOpSrc,
147 ESupportSolveUse * /* supportSolveUse */
148 ) const
149{
150 using Teuchos::dyn_cast;
151 using Teuchos::is_null;
152#ifdef TEUCHOS_DEBUG
154#endif // TEUCHOS_DEBUG
156 DSDLOWS &dsdlows = dyn_cast<DSDLOWS>(*Op);
157 if (fwdOpSrc) {
158 // find a valid fwdOp
159 const RCP<const LinearOpBase<Scalar> > fwdOp = dsdlows.getFwdOp();
160 // pass out a valid fwsOpSrc
161 if (!is_null(fwdOp)) {
162 *fwdOpSrc = defaultLinearOpSource<Scalar>(fwdOp);
163 } else {
164 *fwdOpSrc = Teuchos::null;
165 }
166 }
167 if (prec) *prec = Teuchos::null;
168 if (approxFwdOpSrc) *approxFwdOpSrc = Teuchos::null;
169}
170
171
172template<class Scalar>
174 const EPreconditionerInputType /* precOpType */
175 ) const
176{
177 // LAPACK does not support any external preconditioners!
178 return false;
179}
180
181
182template<class Scalar>
184 const RCP<const LinearOpSourceBase<Scalar> > &/* fwdOpSrc */,
185 const RCP<const PreconditionerBase<Scalar> > &/* prec */,
187 const ESupportSolveUse /* supportSolveUse */
188 ) const
189{
190 TEUCHOS_TEST_FOR_EXCEPT_MSG(true, "Error, we don't support an external preconditioner!");
191}
192
193
194template<class Scalar>
196 const RCP<const LinearOpSourceBase<Scalar> > &/* fwdOpSrc */,
197 const RCP<const LinearOpSourceBase<Scalar> > &/* approxFwdOpSrc */,
199 const ESupportSolveUse /* supportSolveUse */
200 ) const
201{
202 TEUCHOS_TEST_FOR_EXCEPT_MSG(true, "Error, we don't support an external preconditioner!");
203}
204
205
206} // namespace Thyra
207
208
209#endif // THYRA_DEFAULT_SERIAL_DENSE_LINEAR_OP_WITH_SOLVE_FACTORY_HPP
virtual void setPreconditionerFactory(const RCP< PreconditionerFactoryBase< Scalar > > &precFactory, const std::string &precFactoryName)
Throws exception.
virtual RCP< LinearOpWithSolveBase< Scalar > > createOp() const
Returns a DefaultSerialDenseLinearOpWithSolve object .
virtual RCP< PreconditionerFactoryBase< Scalar > > getPreconditionerFactory() const
Returns null .
virtual void initializePreconditionedOp(const RCP< const LinearOpSourceBase< Scalar > > &fwdOpSrc, const RCP< const PreconditionerBase< Scalar > > &prec, LinearOpWithSolveBase< Scalar > *Op, const ESupportSolveUse supportSolveUse) const
virtual void initializeOp(const RCP< const LinearOpSourceBase< Scalar > > &fwdOpSrc, LinearOpWithSolveBase< Scalar > *Op, const ESupportSolveUse supportSolveUse) 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 bool supportsPreconditionerInputType(const EPreconditionerInputType precOpType) const
virtual void unsetPreconditionerFactory(RCP< PreconditionerFactoryBase< Scalar > > *precFactory, std::string *precFactoryName)
Throws exception.
virtual void initializeApproxPreconditionedOp(const RCP< const LinearOpSourceBase< Scalar > > &fwdOpSrc, const RCP< const LinearOpSourceBase< Scalar > > &approxFwdOpSrc, LinearOpWithSolveBase< Scalar > *Op, const ESupportSolveUse supportSolveUse) const
virtual void initializeAndReuseOp(const RCP< const LinearOpSourceBase< Scalar > > &fwdOpSrc, LinearOpWithSolveBase< Scalar > *Op) const
virtual bool isCompatible(const LinearOpSourceBase< Scalar > &fwdOpSrc) const
Simple concreate subclass of LinearOpWithSolveBase for serial dense matrices implemented using LAPACK...
Base interface for objects that can return a linear operator.
virtual Teuchos::RCP< const LinearOpBase< Scalar > > getOp() const =0
Return a const left preconditioner linear operator if one is designed or targeted to be applied on th...
Base class for all linear operators that can support a high-level solve operation.
Interface for a collection of column vectors called a multi-vector.
Simple interface class to access a precreated preconditioner as one or more linear operators objects ...
Factory interface for creating preconditioner objects from LinearOpBase objects.
#define TEUCHOS_TEST_FOR_EXCEPT_MSG(throw_exception_test, msg)
#define TEUCHOS_TEST_FOR_EXCEPT(throw_exception_test)
bool is_null(const std::shared_ptr< T > &p)
EPreconditionerInputType
Enum defining the status of a preconditioner object.
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.
EOpTransp
Enumeration for determining how a linear operator is applied. `*.
T_To & dyn_cast(T_From &from)