Thyra  Version of the Day
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
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 
51 namespace Thyra {
52 
53 
54 // Overridden from Constructors/Initializers/Accessors
55 
56 
57 template<class Scalar>
60  )
61 {
62 #ifdef TEUCHOS_DEBUG
64 #endif
65  lowsf_ = lowsf;
66 }
67 
68 template<class Scalar>
71 {
72  return lowsf_;
73 }
74 
75 
76 template<class Scalar>
79 {
80  return lowsf_;
81 }
82 
83 
84 // Overridden from Teuchos::Describable
85 
86 
87 template<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 
106 template<class Scalar>
108  RCP<ParameterList> const& paramList
109  )
110 {
111  lowsf_->setParameterList(paramList);
112 }
113 
114 
115 template<class Scalar>
118 {
119  return lowsf_->getNonconstParameterList();
120 }
121 
122 
123 template<class Scalar>
126 {
127  return lowsf_->unsetParameterList();
128 }
129 
130 
131 template<class Scalar>
134 {
135  return lowsf_->getParameterList();
136 }
137 
138 
139 template<class Scalar>
142 {
143  return lowsf_->getValidParameters();
144 }
145 
146 
147 // Overridden from LinearOpWithSolveFactoyBase
148 
149 
150 template<class Scalar>
152 {
153  return lowsf_->acceptsPreconditionerFactory();
154 }
155 
156 
157 template<class Scalar>
159  const RCP<PreconditionerFactoryBase<Scalar> > &precFactory,
160  const std::string &precFactoryName
161  )
162 {
163  lowsf_->setPreconditionerFactory(precFactory,precFactoryName);
164 }
165 
166 
167 template<class Scalar>
170 {
171  return lowsf_->getPreconditionerFactory();
172 }
173 
174 
175 template<class Scalar>
177  RCP<PreconditionerFactoryBase<Scalar> > *precFactory,
178  std::string * /* precFactoryName */
179  )
180 {
181  lowsf_->unsetPreconditionerFactory(precFactory);
182 }
183 
184 
185 template<class Scalar>
187  const LinearOpSourceBase<Scalar> &fwdOpSrc
188  ) const
189 {
190  return lowsf_->isCompatible(fwdOpSrc);
191 }
192 
193 
194 template<class Scalar>
197 {
200  dlows->setVerbLevel(this->getVerbLevel());
201  dlows->setOStream(this->getOStream());
202  return dlows;
203 }
204 
205 
206 template<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 
224 template<class Scalar>
226  const RCP<const LinearOpSourceBase<Scalar> > &/* fwdOpSrc */,
228  ) const
229 {
231 }
232 
233 
234 template<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 
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 
267 template<class Scalar>
269  const EPreconditionerInputType precOpType
270  ) const
271 {
272  return lowsf_->supportsPreconditionerInputType(precOpType);
273 }
274 
275 
276 template<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 
295 template<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 
317 template<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
RCP< const PreconditionerBase< Scalar > > getPrec() const
Base class for all linear operators that can support a high-level solve operation.
bool is_null(const boost::shared_ptr< T > &p)
virtual bool supportsPreconditionerInputType(const EPreconditionerInputType precOpType) const
virtual bool isCompatible(const LinearOpSourceBase< Scalar > &fwdOpSrc) const
virtual RCP< LinearOpWithSolveBase< Scalar > > createOp() const
virtual RCP< PreconditionerFactoryBase< Scalar > > getPreconditionerFactory() const
virtual void setPreconditionerFactory(const RCP< PreconditionerFactoryBase< Scalar > > &precFactory, const std::string &precFactoryName)
virtual void initializeApproxPreconditionedOp(const RCP< const LinearOpSourceBase< Scalar > > &fwdOpSrc, const RCP< const LinearOpSourceBase< Scalar > > &approxFwdOpSrc, LinearOpWithSolveBase< Scalar > *Op, const ESupportSolveUse supportSolveUse) const
T_To & dyn_cast(T_From &from)
virtual void unsetPreconditionerFactory(RCP< PreconditionerFactoryBase< Scalar > > *precFactory, std::string *precFactoryName)
Simple interface class to access a precreated preconditioner as one or more linear operators objects ...
virtual void initializePreconditionedOp(const RCP< const LinearOpSourceBase< Scalar > > &fwdOpSrc, const RCP< const PreconditionerBase< Scalar > > &prec, LinearOpWithSolveBase< Scalar > *Op, const ESupportSolveUse supportSolveUse) const
TEUCHOS_DEPRECATED RCP< T > rcp(T *p, Dealloc_T dealloc, bool owns_mem)
RCP< const LinearOpSourceBase< Scalar > > getFwdOpSrc() const
Factory interface for creating LinearOpWithSolveBase objects from compatible LinearOpBase objects...
virtual void initializeOp(const RCP< const LinearOpSourceBase< Scalar > > &fwdOpSrc, LinearOpWithSolveBase< Scalar > *Op, const ESupportSolveUse supportSolveUse) const
virtual std::string description() const
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)
Factory interface for creating preconditioner objects from LinearOpBase objects.
Base interface for objects that can return a linear operator.
RCP< const LinearOpSourceBase< Scalar > > getApproxFwdOpSrc() const
General delayed construction LinearOpWithSolveFactoryBase subclass.
ESupportSolveUse
Enum that specifies how a LinearOpWithSolveBase object will be used for solves after it is constructe...
void informUpdatedVerbosityState() const
Overridden from Teuchos::VerboseObjectBase.
RCP< LinearOpWithSolveFactoryBase< Scalar > > getUnderlyingLOWSF()
virtual void initializeAndReuseOp(const RCP< const LinearOpSourceBase< Scalar > > &fwdOpSrc, LinearOpWithSolveBase< Scalar > *Op) const
EPreconditionerInputType
Enum defining the status of a preconditioner object.
void setParameterList(RCP< ParameterList > const &paramList)
virtual void uninitializeOp(LinearOpWithSolveBase< Scalar > *Op, RCP< const LinearOpSourceBase< Scalar > > *fwdOpSrc, RCP< const PreconditionerBase< Scalar > > *prec, RCP< const LinearOpSourceBase< Scalar > > *approxFwdOpSrc, ESupportSolveUse *supportSolveUse) const
Delayed linear solver construction LinearOpWithSolveBase decorator class.
#define TEUCHOS_TEST_FOR_EXCEPT(throw_exception_test)