Thyra Version of the Day
Loading...
Searching...
No Matches
Thyra_DefaultSerialDenseLinearOpWithSolveFactory_def.hpp
1// @HEADER
2// ***********************************************************************
3//
4// Thyra: Interfaces and Support for Abstract Numerical Algorithms
5// Copyright (2004) Sandia Corporation
6//
7// Under terms of Contract DE-AC04-94AL85000, there is a non-exclusive
8// license for use of this work by or on behalf of the U.S. Government.
9//
10// Redistribution and use in source and binary forms, with or without
11// modification, are permitted provided that the following conditions are
12// met:
13//
14// 1. Redistributions of source code must retain the above copyright
15// notice, this list of conditions and the following disclaimer.
16//
17// 2. Redistributions in binary form must reproduce the above copyright
18// notice, this list of conditions and the following disclaimer in the
19// documentation and/or other materials provided with the distribution.
20//
21// 3. Neither the name of the Corporation nor the names of the
22// contributors may be used to endorse or promote products derived from
23// this software without specific prior written permission.
24//
25// THIS SOFTWARE IS PROVIDED BY SANDIA CORPORATION "AS IS" AND ANY
26// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
27// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
28// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL SANDIA CORPORATION OR THE
29// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
30// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
31// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
32// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
33// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
34// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
35// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
36//
37// Questions? Contact Roscoe A. Bartlett (bartlettra@ornl.gov)
38//
39// ***********************************************************************
40// @HEADER
41
42#ifndef THYRA_DEFAULT_SERIAL_DENSE_LINEAR_OP_WITH_SOLVE_FACTORY_HPP
43#define THYRA_DEFAULT_SERIAL_DENSE_LINEAR_OP_WITH_SOLVE_FACTORY_HPP
44
45
46#include "Thyra_DefaultSerialDenseLinearOpWithSolveFactory_decl.hpp"
47#include "Thyra_DefaultSerialDenseLinearOpWithSolve.hpp"
48#include "Thyra_LinearOpWithSolveFactoryHelpers.hpp"
49#include "Thyra_ScaledAdjointLinearOpBase.hpp"
50#include "Thyra_DefaultLinearOpSource.hpp"
51
52
53namespace Thyra {
54
55
56// Overridden from ParameterListAcceptor
57
58
59template<class Scalar>
61 RCP<ParameterList> const& paramList
62 )
63{
64 paramList->validateParameters(*this->getValidParameters());
65 // Nothing to set because we have not parameters!
66}
67
68
69template<class Scalar>
72{
73 static RCP<const ParameterList> validPL = Teuchos::parameterList();
74 return validPL;
75}
76
77
78// Overridden from LinearOpWithSolveFactoyBase
79
80
81template<class Scalar>
83{
84 return false;
85}
86
87
88template<class Scalar>
90 const RCP<PreconditionerFactoryBase<Scalar> > &/* precFactory */,
91 const std::string &/* precFactoryName */
92 )
93{
94 TEUCHOS_TEST_FOR_EXCEPT_MSG(true, "Error, we don't support a preconditioner factory!");
95}
96
97
98template<class Scalar>
101{
102 return Teuchos::null;
103}
104
105
106template<class Scalar>
108 RCP<PreconditionerFactoryBase<Scalar> > * /* precFactory */,
109 std::string * /* precFactoryName */
110 )
111{
112 TEUCHOS_TEST_FOR_EXCEPT_MSG(true, "Error, we don't support a preconditioner factory!");
113}
114
115
116template<class Scalar>
118 const LinearOpSourceBase<Scalar> &fwdOpSrc
119 ) const
120{
121 return !is_null(
122 Teuchos::rcp_dynamic_cast<const MultiVectorBase<Scalar> >(fwdOpSrc.getOp()));
123}
124
125
126template<class Scalar>
129{
130 return defaultSerialDenseLinearOpWithSolve<Scalar>();
131}
132
133
134template<class Scalar>
136 const RCP<const LinearOpSourceBase<Scalar> > &fwdOpSrc,
138 const ESupportSolveUse /* supportSolveUse */
139 ) const
140{
141
142 using Teuchos::dyn_cast;
143 using Teuchos::rcp_dynamic_cast;
144
145#ifdef TEUCHOS_DEBUG
147#endif
148
149 const RCP<const LinearOpBase<Scalar> > tmpFwdOp = fwdOpSrc->getOp();
151 Scalar fwdOp_scalar = 0.0;
152 EOpTransp fwdOp_transp;
153 unwrap<Scalar>(tmpFwdOp, &fwdOp_scalar, &fwdOp_transp, &fwdOp);
154
156 rcp_dynamic_cast<const MultiVectorBase<Scalar> >(fwdOp, true);
157
158 dyn_cast<DefaultSerialDenseLinearOpWithSolve<Scalar> >(*Op).initialize(fwdMv);
159
160}
161
162
163template<class Scalar>
165 const RCP<const LinearOpSourceBase<Scalar> > &fwdOpSrc,
167 ) const
168{
169 initializeOp(fwdOpSrc, Op, SUPPORT_SOLVE_UNSPECIFIED);
170}
171
172
173template<class Scalar>
176 RCP<const LinearOpSourceBase<Scalar> > *fwdOpSrc,
177 RCP<const PreconditionerBase<Scalar> > *prec,
178 RCP<const LinearOpSourceBase<Scalar> > *approxFwdOpSrc,
179 ESupportSolveUse * /* supportSolveUse */
180 ) const
181{
182 using Teuchos::dyn_cast;
183 using Teuchos::is_null;
184#ifdef TEUCHOS_DEBUG
186#endif // TEUCHOS_DEBUG
188 DSDLOWS &dsdlows = dyn_cast<DSDLOWS>(*Op);
189 if (fwdOpSrc) {
190 // find a valid fwdOp
191 const RCP<const LinearOpBase<Scalar> > fwdOp = dsdlows.getFwdOp();
192 // pass out a valid fwsOpSrc
193 if (!is_null(fwdOp)) {
194 *fwdOpSrc = defaultLinearOpSource<Scalar>(fwdOp);
195 } else {
196 *fwdOpSrc = Teuchos::null;
197 }
198 }
199 if (prec) *prec = Teuchos::null;
200 if (approxFwdOpSrc) *approxFwdOpSrc = Teuchos::null;
201}
202
203
204template<class Scalar>
206 const EPreconditionerInputType /* precOpType */
207 ) const
208{
209 // LAPACK does not support any external preconditioners!
210 return false;
211}
212
213
214template<class Scalar>
216 const RCP<const LinearOpSourceBase<Scalar> > &/* fwdOpSrc */,
217 const RCP<const PreconditionerBase<Scalar> > &/* prec */,
219 const ESupportSolveUse /* supportSolveUse */
220 ) const
221{
222 TEUCHOS_TEST_FOR_EXCEPT_MSG(true, "Error, we don't support an external preconditioner!");
223}
224
225
226template<class Scalar>
228 const RCP<const LinearOpSourceBase<Scalar> > &/* fwdOpSrc */,
229 const RCP<const LinearOpSourceBase<Scalar> > &/* approxFwdOpSrc */,
231 const ESupportSolveUse /* supportSolveUse */
232 ) const
233{
234 TEUCHOS_TEST_FOR_EXCEPT_MSG(true, "Error, we don't support an external preconditioner!");
235}
236
237
238} // namespace Thyra
239
240
241#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)