Thyra Version of the Day
Loading...
Searching...
No Matches
Thyra_DelayedLinearOpWithSolveFactory_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_DELAYED_LINEAR_OP_WITH_SOLVE_FACTORY_HPP
43#define THYRA_DELAYED_LINEAR_OP_WITH_SOLVE_FACTORY_HPP
44
45
46#include "Thyra_DelayedLinearOpWithSolveFactory_decl.hpp"
47#include "Thyra_LinearOpWithSolveBase.hpp"
48#include "Thyra_DelayedLinearOpWithSolve.hpp"
49
50
51namespace Thyra {
52
53
54// Overridden from Constructors/Initializers/Accessors
55
56
57template<class Scalar>
60 )
61{
62#ifdef TEUCHOS_DEBUG
63 TEUCHOS_TEST_FOR_EXCEPT(is_null(lowsf));
64#endif
65 lowsf_ = lowsf;
66}
67
68template<class Scalar>
74
75
76template<class Scalar>
82
83
84// Overridden from Teuchos::Describable
85
86
87template<class Scalar>
89{
90 std::ostringstream oss;
92 << "{"
93 << "lowsf=";
94 if (!is_null(lowsf_))
95 oss << lowsf_->description();
96 else
97 oss << "NULL";
98 oss << "}";
99 return oss.str();
100}
101
102
103// Overridden from ParameterListAcceptor
104
105
106template<class Scalar>
108 RCP<ParameterList> const& paramList
109 )
110{
111 lowsf_->setParameterList(paramList);
112}
113
114
115template<class Scalar>
118{
119 return lowsf_->getNonconstParameterList();
120}
121
122
123template<class Scalar>
126{
127 return lowsf_->unsetParameterList();
128}
129
130
131template<class Scalar>
134{
135 return lowsf_->getParameterList();
136}
137
138
139template<class Scalar>
142{
143 return lowsf_->getValidParameters();
144}
145
146
147// Overridden from LinearOpWithSolveFactoyBase
148
149
150template<class Scalar>
152{
153 return lowsf_->acceptsPreconditionerFactory();
154}
155
156
157template<class Scalar>
159 const RCP<PreconditionerFactoryBase<Scalar> > &precFactory,
160 const std::string &precFactoryName
161 )
162{
163 lowsf_->setPreconditionerFactory(precFactory,precFactoryName);
164}
165
166
167template<class Scalar>
170{
171 return lowsf_->getPreconditionerFactory();
172}
173
174
175template<class Scalar>
178 std::string * /* precFactoryName */
179 )
180{
181 lowsf_->unsetPreconditionerFactory(precFactory);
182}
183
184
185template<class Scalar>
187 const LinearOpSourceBase<Scalar> &fwdOpSrc
188 ) const
189{
190 return lowsf_->isCompatible(fwdOpSrc);
191}
192
193
194template<class Scalar>
197{
200 dlows->setVerbLevel(this->getVerbLevel());
201 dlows->setOStream(this->getOStream());
202 return dlows;
203}
204
205
206template<class Scalar>
208 const RCP<const LinearOpSourceBase<Scalar> > &fwdOpSrc,
210 const ESupportSolveUse supportSolveUse
211 ) const
212{
213 using Teuchos::null;
214#ifdef TEUCHOS_DEBUG
215 TEUCHOS_TEST_FOR_EXCEPT(is_null(fwdOpSrc));
217#endif
220 dlows.initialize( fwdOpSrc, null, null, supportSolveUse, lowsf_ );
221}
222
223
224template<class Scalar>
232
233
234template<class Scalar>
237 RCP<const LinearOpSourceBase<Scalar> > *fwdOpSrc,
238 RCP<const PreconditionerBase<Scalar> > *prec,
239 RCP<const LinearOpSourceBase<Scalar> > *approxFwdOpSrc,
240 ESupportSolveUse *supportSolveUse
241 ) const
242{
243
244 using Teuchos::dyn_cast;
245
246#ifdef TEUCHOS_DEBUG
248#endif
249
251 &dlows = dyn_cast<DelayedLinearOpWithSolve<Scalar> >(*Op);
252
253 if (fwdOpSrc)
254 *fwdOpSrc = dlows.getFwdOpSrc();
255 if (prec)
256 *prec = dlows.getPrec();
257 if (approxFwdOpSrc)
258 *approxFwdOpSrc = dlows.getApproxFwdOpSrc();
259 if (supportSolveUse)
260 *supportSolveUse = dlows.getSupportSolveUse();
261
262 // ToDo: 2007/08/16: rabartl: Consider uninitalizing dlows?
263
264}
265
266
267template<class Scalar>
269 const EPreconditionerInputType precOpType
270 ) const
271{
272 return lowsf_->supportsPreconditionerInputType(precOpType);
273}
274
275
276template<class Scalar>
278 const RCP<const LinearOpSourceBase<Scalar> > &fwdOpSrc,
279 const RCP<const PreconditionerBase<Scalar> > &prec,
281 const ESupportSolveUse supportSolveUse
282 ) const
283{
284 using Teuchos::null;
285#ifdef TEUCHOS_DEBUG
286 TEUCHOS_TEST_FOR_EXCEPT(is_null(fwdOpSrc));
288#endif
291 dlows.initialize( fwdOpSrc, prec, null, supportSolveUse, lowsf_ );
292}
293
294
295template<class Scalar>
297 const RCP<const LinearOpSourceBase<Scalar> > &fwdOpSrc,
298 const RCP<const LinearOpSourceBase<Scalar> > &approxFwdOpSrc,
300 const ESupportSolveUse supportSolveUse
301 ) const
302{
303 using Teuchos::null;
304#ifdef TEUCHOS_DEBUG
305 TEUCHOS_TEST_FOR_EXCEPT(is_null(fwdOpSrc));
307#endif
310 dlows.initialize( fwdOpSrc, null, approxFwdOpSrc, supportSolveUse, lowsf_ );
311}
312
313
314// protected
315
316
317template<class Scalar>
319{
320 lowsf_->setVerbLevel(this->getVerbLevel());
321 lowsf_->setOStream(this->getOStream());
322}
323
324
325} // namespace Thyra
326
327
328#endif // THYRA_DELAYED_LINEAR_OP_WITH_SOLVE_FACTORY_HPP
virtual std::string description() const
General delayed construction LinearOpWithSolveFactoryBase subclass.
void setParameterList(RCP< ParameterList > const &paramList)
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 RCP< LinearOpWithSolveBase< Scalar > > createOp() const
virtual void initializeAndReuseOp(const RCP< const LinearOpSourceBase< Scalar > > &fwdOpSrc, LinearOpWithSolveBase< Scalar > *Op) const
virtual bool supportsPreconditionerInputType(const EPreconditionerInputType precOpType) const
void informUpdatedVerbosityState() const
Overridden from Teuchos::VerboseObjectBase.
virtual void initializePreconditionedOp(const RCP< const LinearOpSourceBase< Scalar > > &fwdOpSrc, const RCP< const PreconditionerBase< Scalar > > &prec, LinearOpWithSolveBase< Scalar > *Op, const ESupportSolveUse supportSolveUse) const
virtual RCP< PreconditionerFactoryBase< Scalar > > getPreconditionerFactory() const
virtual void unsetPreconditionerFactory(RCP< PreconditionerFactoryBase< Scalar > > *precFactory, std::string *precFactoryName)
RCP< LinearOpWithSolveFactoryBase< Scalar > > getUnderlyingLOWSF()
virtual bool isCompatible(const LinearOpSourceBase< Scalar > &fwdOpSrc) const
virtual void setPreconditionerFactory(const RCP< PreconditionerFactoryBase< Scalar > > &precFactory, const std::string &precFactoryName)
virtual void initializeOp(const RCP< const LinearOpSourceBase< Scalar > > &fwdOpSrc, LinearOpWithSolveBase< Scalar > *Op, const ESupportSolveUse supportSolveUse) const
Delayed linear solver construction LinearOpWithSolveBase decorator class.
void initialize(const RCP< const LinearOpSourceBase< Scalar > > &fwdOpSrc, const RCP< const PreconditionerBase< Scalar > > &prec, const RCP< const LinearOpSourceBase< Scalar > > &approxFwdOpSrc, const ESupportSolveUse supportSolveUse, const RCP< LinearOpWithSolveFactoryBase< Scalar > > &lowsf)
RCP< const LinearOpSourceBase< Scalar > > getFwdOpSrc() const
RCP< const PreconditionerBase< Scalar > > getPrec() const
RCP< const LinearOpSourceBase< Scalar > > getApproxFwdOpSrc() const
Base interface for objects that can return a linear operator.
Base class for all linear operators that can support a high-level solve operation.
Factory interface for creating LinearOpWithSolveBase objects from compatible LinearOpBase objects.
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(throw_exception_test)
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...
T_To & dyn_cast(T_From &from)
TEUCHOS_DEPRECATED RCP< T > rcp(T *p, Dealloc_T dealloc, bool owns_mem)