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 // Thyra: Interfaces and Support for Abstract Numerical Algorithms
4 //
5 // Copyright 2004 NTESS and the Thyra contributors.
6 // SPDX-License-Identifier: BSD-3-Clause
7 // *****************************************************************************
8 // @HEADER
9 
10 #ifndef THYRA_DEFAULT_INVERSE_LINEAR_OP_DECL_HPP
11 #define THYRA_DEFAULT_INVERSE_LINEAR_OP_DECL_HPP
12 
13 #include "Thyra_InverseLinearOpBase.hpp"
14 #include "Teuchos_ConstNonconstObjectContainer.hpp"
15 
16 
17 namespace Thyra {
18 
19 
27 };
28 
29 
53 template<class Scalar>
54 class DefaultInverseLinearOp : virtual public InverseLinearOpBase<Scalar>
55 {
56 public:
57 
60 
65 
69  const RCP<LinearOpWithSolveBase<Scalar> > &lows,
70  const SolveCriteria<Scalar> *fwdSolveCriteria = NULL,
71  const EThrowOnSolveFailure throwOnFwdSolveFailure = THROW_ON_SOLVE_FAILURE,
72  const SolveCriteria<Scalar> *adjSolveCriteria = NULL,
73  const EThrowOnSolveFailure throwOnAdjSolveFailure = THROW_ON_SOLVE_FAILURE
74  );
75 
82  const RCP<const LinearOpWithSolveBase<Scalar> > &lows,
83  const SolveCriteria<Scalar> *fwdSolveCriteria = NULL,
84  const EThrowOnSolveFailure throwOnFwdSolveFailure = THROW_ON_SOLVE_FAILURE,
85  const SolveCriteria<Scalar> *adjSolveCriteria = NULL,
86  const EThrowOnSolveFailure throwOnAdjSolveFailure = THROW_ON_SOLVE_FAILURE
87  );
88 
123  void initialize(
124  const RCP<LinearOpWithSolveBase<Scalar> > &lows,
125  const SolveCriteria<Scalar> *fwdSolveCriteria = NULL,
126  const EThrowOnSolveFailure throwOnFwdSolveFailure = THROW_ON_SOLVE_FAILURE,
127  const SolveCriteria<Scalar> *adjSolveCriteria = NULL,
128  const EThrowOnSolveFailure throwOnAdjSolveFailure = THROW_ON_SOLVE_FAILURE
129  );
130 
165  void initialize(
166  const RCP<const LinearOpWithSolveBase<Scalar> > &lows,
167  const SolveCriteria<Scalar> *fwdSolveCriteria = NULL,
168  const EThrowOnSolveFailure throwOnFwdSolveFailure = THROW_ON_SOLVE_FAILURE,
169  const SolveCriteria<Scalar> *adjSolveCriteria = NULL,
170  const EThrowOnSolveFailure throwOnAdjSolveFailure = THROW_ON_SOLVE_FAILURE
171  );
172 
181  void uninitialize();
182 
184 
187 
189  bool isLowsConst() const;
192  getNonconstLows();
195  getLows() const;
196 
198 
201 
207 
213 
216 
218 
221 
223  std::string description() const;
224 
226  void describe(
227  FancyOStream &out,
228  const Teuchos::EVerbosityLevel verbLevel
229  ) const;
230 
232 
233 protected:
234 
237 
241  bool opSupportedImpl(EOpTransp M_trans) const;
242 
244  void applyImpl(
245  const EOpTransp M_trans,
246  const MultiVectorBase<Scalar> &X,
247  const Ptr<MultiVectorBase<Scalar> > &Y,
248  const Scalar alpha,
249  const Scalar beta
250  ) const;
251 
253 
254 private:
255 
257  RCP<SolveCriteria<Scalar> > fwdSolveCriteria_;
258  EThrowOnSolveFailure throwOnFwdSolveFailure_;
259  RCP<SolveCriteria<Scalar> > adjSolveCriteria_;
260  EThrowOnSolveFailure throwOnAdjSolveFailure_;
261 
262  void assertInitialized() const;
263 
264  template<class LOWS>
265  void initializeImpl(
266  const RCP<LOWS> &lows,
267  const SolveCriteria<Scalar> *fwdSolveCriteria,
268  const EThrowOnSolveFailure throwOnFwdSolveFailure,
269  const SolveCriteria<Scalar> *adjSolveCriteria,
270  const EThrowOnSolveFailure throwOnAdjSolveFailure
271  );
272 
273  // Not defined and not to be called
276 
277 };
278 
279 
284 template<class Scalar>
286 nonconstInverse(
288  const Ptr<const SolveCriteria<Scalar> > &fwdSolveCriteria = Teuchos::null,
289  const EThrowOnSolveFailure throwOnFwdSolveFailure = THROW_ON_SOLVE_FAILURE,
290  const Ptr<const SolveCriteria<Scalar> > &adjSolveCriteria = Teuchos::null,
291  const EThrowOnSolveFailure throwOnAdjSolveFailure = THROW_ON_SOLVE_FAILURE
292  );
293 
294 
299 template<class Scalar>
301 inverse(
302  const RCP<const LinearOpWithSolveBase<Scalar> > &A,
303  const Ptr<const SolveCriteria<Scalar> > &fwdSolveCriteria = Teuchos::null,
304  const EThrowOnSolveFailure throwOnFwdSolveFailure = THROW_ON_SOLVE_FAILURE,
305  const Ptr<const SolveCriteria<Scalar> > &adjSolveCriteria = Teuchos::null,
306  const EThrowOnSolveFailure throwOnAdjSolveFailure = THROW_ON_SOLVE_FAILURE
307  );
308 
309 
310 // /////////////////////////////////
311 // Inline members
312 
313 
314 template<class Scalar>
315 inline
317 {
318 #ifdef TEUCHOS_DEBUG
319  TEUCHOS_TEST_FOR_EXCEPT( !lows_.getConstObj().get() );
320 #endif
321 }
322 
323 
324 } // end namespace Thyra
325 
326 
327 #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()