Thyra  Version of the Day
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Thyra_DefaultInverseLinearOp_decl.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_INVERSE_LINEAR_OP_DECL_HPP
43 #define THYRA_DEFAULT_INVERSE_LINEAR_OP_DECL_HPP
44 
45 #include "Thyra_InverseLinearOpBase.hpp"
46 #include "Teuchos_ConstNonconstObjectContainer.hpp"
47 
48 
49 namespace Thyra {
50 
51 
59 };
60 
61 
85 template<class Scalar>
86 class DefaultInverseLinearOp : virtual public InverseLinearOpBase<Scalar>
87 {
88 public:
89 
92 
97 
101  const RCP<LinearOpWithSolveBase<Scalar> > &lows,
102  const SolveCriteria<Scalar> *fwdSolveCriteria = NULL,
103  const EThrowOnSolveFailure throwOnFwdSolveFailure = THROW_ON_SOLVE_FAILURE,
104  const SolveCriteria<Scalar> *adjSolveCriteria = NULL,
105  const EThrowOnSolveFailure throwOnAdjSolveFailure = THROW_ON_SOLVE_FAILURE
106  );
107 
114  const RCP<const LinearOpWithSolveBase<Scalar> > &lows,
115  const SolveCriteria<Scalar> *fwdSolveCriteria = NULL,
116  const EThrowOnSolveFailure throwOnFwdSolveFailure = THROW_ON_SOLVE_FAILURE,
117  const SolveCriteria<Scalar> *adjSolveCriteria = NULL,
118  const EThrowOnSolveFailure throwOnAdjSolveFailure = THROW_ON_SOLVE_FAILURE
119  );
120 
155  void initialize(
156  const RCP<LinearOpWithSolveBase<Scalar> > &lows,
157  const SolveCriteria<Scalar> *fwdSolveCriteria = NULL,
158  const EThrowOnSolveFailure throwOnFwdSolveFailure = THROW_ON_SOLVE_FAILURE,
159  const SolveCriteria<Scalar> *adjSolveCriteria = NULL,
160  const EThrowOnSolveFailure throwOnAdjSolveFailure = THROW_ON_SOLVE_FAILURE
161  );
162 
197  void initialize(
198  const RCP<const LinearOpWithSolveBase<Scalar> > &lows,
199  const SolveCriteria<Scalar> *fwdSolveCriteria = NULL,
200  const EThrowOnSolveFailure throwOnFwdSolveFailure = THROW_ON_SOLVE_FAILURE,
201  const SolveCriteria<Scalar> *adjSolveCriteria = NULL,
202  const EThrowOnSolveFailure throwOnAdjSolveFailure = THROW_ON_SOLVE_FAILURE
203  );
204 
213  void uninitialize();
214 
216 
219 
221  bool isLowsConst() const;
224  getNonconstLows();
227  getLows() const;
228 
230 
233 
239 
245 
248 
250 
253 
255  std::string description() const;
256 
258  void describe(
259  FancyOStream &out,
260  const Teuchos::EVerbosityLevel verbLevel
261  ) const;
262 
264 
265 protected:
266 
269 
273  bool opSupportedImpl(EOpTransp M_trans) const;
274 
276  void applyImpl(
277  const EOpTransp M_trans,
278  const MultiVectorBase<Scalar> &X,
279  const Ptr<MultiVectorBase<Scalar> > &Y,
280  const Scalar alpha,
281  const Scalar beta
282  ) const;
283 
285 
286 private:
287 
289  RCP<SolveCriteria<Scalar> > fwdSolveCriteria_;
290  EThrowOnSolveFailure throwOnFwdSolveFailure_;
291  RCP<SolveCriteria<Scalar> > adjSolveCriteria_;
292  EThrowOnSolveFailure throwOnAdjSolveFailure_;
293 
294  void assertInitialized() const;
295 
296  template<class LOWS>
297  void initializeImpl(
298  const RCP<LOWS> &lows,
299  const SolveCriteria<Scalar> *fwdSolveCriteria,
300  const EThrowOnSolveFailure throwOnFwdSolveFailure,
301  const SolveCriteria<Scalar> *adjSolveCriteria,
302  const EThrowOnSolveFailure throwOnAdjSolveFailure
303  );
304 
305  // Not defined and not to be called
308 
309 };
310 
311 
316 template<class Scalar>
318 nonconstInverse(
320  const Ptr<const SolveCriteria<Scalar> > &fwdSolveCriteria = Teuchos::null,
321  const EThrowOnSolveFailure throwOnFwdSolveFailure = THROW_ON_SOLVE_FAILURE,
322  const Ptr<const SolveCriteria<Scalar> > &adjSolveCriteria = Teuchos::null,
323  const EThrowOnSolveFailure throwOnAdjSolveFailure = THROW_ON_SOLVE_FAILURE
324  );
325 
326 
331 template<class Scalar>
333 inverse(
334  const RCP<const LinearOpWithSolveBase<Scalar> > &A,
335  const Ptr<const SolveCriteria<Scalar> > &fwdSolveCriteria = Teuchos::null,
336  const EThrowOnSolveFailure throwOnFwdSolveFailure = THROW_ON_SOLVE_FAILURE,
337  const Ptr<const SolveCriteria<Scalar> > &adjSolveCriteria = Teuchos::null,
338  const EThrowOnSolveFailure throwOnAdjSolveFailure = THROW_ON_SOLVE_FAILURE
339  );
340 
341 
342 // /////////////////////////////////
343 // Inline members
344 
345 
346 template<class Scalar>
347 inline
349 {
350 #ifdef TEUCHOS_DEBUG
351  TEUCHOS_TEST_FOR_EXCEPT( !lows_.getConstObj().get() );
352 #endif
353 }
354 
355 
356 } // end namespace Thyra
357 
358 
359 #endif // THYRA_DEFAULT_INVERSE_LINEAR_OP_DECL_HPP
Base class for all linear operators that can support a high-level solve operation.
EOpTransp
Enumeration for determining how a linear operator is applied. `*.
RCP< const LinearOpBase< Scalar > > clone() const
DefaultInverseLinearOp()
Constructs to uninitialized (see postconditions for uninitialize()).
bool opSupportedImpl(EOpTransp M_trans) const
Returns true only if all constituent operators support M_trans.
void describe(FancyOStream &out, const Teuchos::EVerbosityLevel verbLevel) const
basic_FancyOStream< char > FancyOStream
RCP< const VectorSpaceBase< Scalar > > range() const
Returns this-&gt;getLows()-&gt;domain() if &lt;t&gt;this-&gt;getLows().get()!=NULL and returns Teuchos::null otherwi...
void applyImpl(const EOpTransp M_trans, const MultiVectorBase< Scalar > &X, const Ptr< MultiVectorBase< Scalar > > &Y, const Scalar alpha, const Scalar beta) const
Throw an exception if a solve fails to converge.
Interface for a collection of column vectors called a multi-vector.
void initialize(const RCP< LinearOpWithSolveBase< Scalar > > &lows, const SolveCriteria< Scalar > *fwdSolveCriteria=NULL, const EThrowOnSolveFailure throwOnFwdSolveFailure=THROW_ON_SOLVE_FAILURE, const SolveCriteria< Scalar > *adjSolveCriteria=NULL, const EThrowOnSolveFailure throwOnAdjSolveFailure=THROW_ON_SOLVE_FAILURE)
Initialize given a non-const LinearOpWithSolveBase object and an optional .
RCP< const VectorSpaceBase< Scalar > > domain() const
Returns this-&gt;getLows()-&gt;range() if &lt;t&gt;this-&gt;getLows().get()!=NULL and returns Teuchos::null otherwis...
Base interface for &lt;ttLinearOpBase objects that are implemented in terms of the solve function on a L...
EThrowOnSolveFailure
Determines what to do if inverse solve fails.
Don&#39;t throw an exception if a solve fails to converge.
Simple struct that defines the requested solution criteria for a solve.
RCP< const LinearOpWithSolveBase< Scalar > > getLows() const
Concrete LinearOpBase subclass that creates an implicit LinearOpBase object using the inverse action ...
#define TEUCHOS_TEST_FOR_EXCEPT(throw_exception_test)
RCP< LinearOpWithSolveBase< Scalar > > getNonconstLows()