Thyra Version of the Day
Loading...
Searching...
No Matches
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
49namespace Thyra {
50
51
60
61
85template<class Scalar>
86class DefaultInverseLinearOp : virtual public InverseLinearOpBase<Scalar>
87{
88public:
89
92
97
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(
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;
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
265protected:
266
269
273 bool opSupportedImpl(EOpTransp M_trans) const;
274
276 void applyImpl(
277 const EOpTransp M_trans,
279 const Ptr<MultiVectorBase<Scalar> > &Y,
280 const Scalar alpha,
281 const Scalar beta
282 ) const;
283
285
286private:
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
316template<class Scalar>
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
331template<class Scalar>
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
346template<class Scalar>
347inline
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
Concrete LinearOpBase subclass that creates an implicit LinearOpBase object using the inverse action ...
void applyImpl(const EOpTransp M_trans, const MultiVectorBase< Scalar > &X, const Ptr< MultiVectorBase< Scalar > > &Y, const Scalar alpha, const Scalar beta) const
RCP< LinearOpBase< Scalar > > nonconstInverse(const RCP< LinearOpWithSolveBase< Scalar > > &A, const Ptr< const SolveCriteria< Scalar > > &fwdSolveCriteria=Teuchos::null, const EThrowOnSolveFailure throwOnFwdSolveFailure=THROW_ON_SOLVE_FAILURE, const Ptr< const SolveCriteria< Scalar > > &adjSolveCriteria=Teuchos::null, const EThrowOnSolveFailure throwOnAdjSolveFailure=THROW_ON_SOLVE_FAILURE)
Form a non-const implicit inverse operator M = inv(A).
RCP< const LinearOpWithSolveBase< Scalar > > getLows() const
RCP< const LinearOpBase< Scalar > > clone() const
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 .
DefaultInverseLinearOp()
Constructs to uninitialized (see postconditions for uninitialize()).
RCP< const VectorSpaceBase< Scalar > > domain() const
Returns this->getLows()->range() if <t>this->getLows().get()!=NULL and returns Teuchos::null otherwis...
RCP< const VectorSpaceBase< Scalar > > range() const
Returns this->getLows()->domain() if <t>this->getLows().get()!=NULL and returns Teuchos::null otherwi...
void describe(FancyOStream &out, const Teuchos::EVerbosityLevel verbLevel) const
RCP< LinearOpBase< Scalar > > inverse(const RCP< const LinearOpWithSolveBase< Scalar > > &A, const Ptr< const SolveCriteria< Scalar > > &fwdSolveCriteria=Teuchos::null, const EThrowOnSolveFailure throwOnFwdSolveFailure=THROW_ON_SOLVE_FAILURE, const Ptr< const SolveCriteria< Scalar > > &adjSolveCriteria=Teuchos::null, const EThrowOnSolveFailure throwOnAdjSolveFailure=THROW_ON_SOLVE_FAILURE)
Form a const implicit inverse operator M = inv(A).
RCP< LinearOpWithSolveBase< Scalar > > getNonconstLows()
bool opSupportedImpl(EOpTransp M_trans) const
Returns true only if all constituent operators support M_trans.
Base interface for <ttLinearOpBase objects that are implemented in terms of the solve function on a L...
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.
#define TEUCHOS_TEST_FOR_EXCEPT(throw_exception_test)
EThrowOnSolveFailure
Determines what to do if inverse solve fails.
@ THROW_ON_SOLVE_FAILURE
Throw an exception if a solve fails to converge.
@ IGNORE_SOLVE_FAILURE
Don't throw an exception if a solve fails to converge.
EOpTransp
Enumeration for determining how a linear operator is applied. `*.
T_To & dyn_cast(T_From &from)
Simple struct that defines the requested solution criteria for a solve.