Thyra  Version of the Day
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
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 
21 namespace Thyra {
22 
23 
24 // Overridden from ParameterListAcceptor
25 
26 
27 template<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 
37 template<class Scalar>
40 {
41  static RCP<const ParameterList> validPL = Teuchos::parameterList();
42  return validPL;
43 }
44 
45 
46 // Overridden from LinearOpWithSolveFactoyBase
47 
48 
49 template<class Scalar>
51 {
52  return false;
53 }
54 
55 
56 template<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 
66 template<class Scalar>
69 {
70  return Teuchos::null;
71 }
72 
73 
74 template<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 
84 template<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 
94 template<class Scalar>
97 {
98  return defaultSerialDenseLinearOpWithSolve<Scalar>();
99 }
100 
101 
102 template<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 
123  const RCP<const MultiVectorBase<Scalar> > fwdMv =
124  rcp_dynamic_cast<const MultiVectorBase<Scalar> >(fwdOp, true);
125 
127 
128 }
129 
130 
131 template<class Scalar>
133  const RCP<const LinearOpSourceBase<Scalar> > &fwdOpSrc,
135  ) const
136 {
137  initializeOp(fwdOpSrc, Op, SUPPORT_SOLVE_UNSPECIFIED);
138 }
139 
140 
141 template<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 
172 template<class Scalar>
174  const EPreconditionerInputType /* precOpType */
175  ) const
176 {
177  // LAPACK does not support any external preconditioners!
178  return false;
179 }
180 
181 
182 template<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 
194 template<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
How the output LOWSB object will be useded for solves in unspecified.
Base class for all linear operators that can support a high-level solve operation.
bool is_null(const boost::shared_ptr< T > &p)
EOpTransp
Enumeration for determining how a linear operator is applied. `*.
Simple concreate subclass of LinearOpWithSolveBase for serial dense matrices implemented using LAPACK...
bool is_null(const std::shared_ptr< T > &p)
T_To & dyn_cast(T_From &from)
virtual void initializeOp(const RCP< const LinearOpSourceBase< Scalar > > &fwdOpSrc, LinearOpWithSolveBase< Scalar > *Op, const ESupportSolveUse supportSolveUse) const
Simple interface class to access a precreated preconditioner as one or more linear operators objects ...
void initialize(const RCP< const MultiVectorBase< Scalar > > &M)
virtual void setPreconditionerFactory(const RCP< PreconditionerFactoryBase< Scalar > > &precFactory, const std::string &precFactoryName)
Throws exception.
#define TEUCHOS_TEST_FOR_EXCEPT_MSG(throw_exception_test, msg)
Interface for a collection of column vectors called a multi-vector.
virtual void initializeAndReuseOp(const RCP< const LinearOpSourceBase< Scalar > > &fwdOpSrc, LinearOpWithSolveBase< Scalar > *Op) const
virtual RCP< LinearOpWithSolveBase< Scalar > > createOp() const
Returns a DefaultSerialDenseLinearOpWithSolve object .
virtual void unsetPreconditionerFactory(RCP< PreconditionerFactoryBase< Scalar > > *precFactory, std::string *precFactoryName)
Throws exception.
virtual bool isCompatible(const LinearOpSourceBase< Scalar > &fwdOpSrc) const
Factory interface for creating preconditioner objects from LinearOpBase objects.
Base interface for objects that can return a linear operator.
void validateParameters(ParameterList const &validParamList, int const depth=1000, EValidateUsed const validateUsed=VALIDATE_USED_ENABLED, EValidateDefaults const validateDefaults=VALIDATE_DEFAULTS_ENABLED) const
ESupportSolveUse
Enum that specifies how a LinearOpWithSolveBase object will be used for solves after it is constructe...
virtual void initializePreconditionedOp(const RCP< const LinearOpSourceBase< Scalar > > &fwdOpSrc, const RCP< const PreconditionerBase< Scalar > > &prec, LinearOpWithSolveBase< Scalar > *Op, const ESupportSolveUse supportSolveUse) const
EPreconditionerInputType
Enum defining the status of a preconditioner object.
virtual void initializeApproxPreconditionedOp(const RCP< const LinearOpSourceBase< Scalar > > &fwdOpSrc, const RCP< const LinearOpSourceBase< Scalar > > &approxFwdOpSrc, 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 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...
virtual RCP< PreconditionerFactoryBase< Scalar > > getPreconditionerFactory() const
Returns null .
#define TEUCHOS_TEST_FOR_EXCEPT(throw_exception_test)
virtual bool supportsPreconditionerInputType(const EPreconditionerInputType precOpType) const