Thyra  Version of the Day
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Thyra_LinearOpWithSolveBase_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_LINEAR_OP_WITH_SOLVE_BASE_DECL_HPP
11 #define THYRA_LINEAR_OP_WITH_SOLVE_BASE_DECL_HPP
12 
13 #include "Thyra_OperatorSolveTypes.hpp"
14 #include "Thyra_LinearOpBase.hpp"
15 #include "Thyra_MultiVectorBase.hpp"
16 #include "Thyra_VectorSpaceBase.hpp"
17 #include "Thyra_SolveSupportTypes.hpp"
18 #include "Teuchos_VerboseObject.hpp"
19 
20 
21 namespace Thyra {
22 
23 
275 template<class Scalar>
277  : virtual public LinearOpBase<Scalar>
278  , virtual public Teuchos::VerboseObject<LinearOpWithSolveBase<Scalar> >
279 {
280 public:
281 
284 
285  // 2010/08/22: rabartl: To properly handle the new SolveCriteria struct with
286  // reduction functionals (bug 4915) the function solveSupports() must be
287  // refactored. Here is how this refactoring can be done incrementally and
288  // safely:
289  //
290  // (*) Create new override solveSupports(transp, solveCriteria) that calls
291  // virtual solveSupportsNewImpl(transp, solveCriteria).
292  //
293  // (*) One by one, refactor existing LOWSB subclasses to implement
294  // solveSupportsNewImpl(transp, solveCriteria). This can be done by
295  // basically copying the existing solveSupportsSolveMeasureTypeImpl()
296  // override. Then have each of the existing
297  // solveSupportsSolveMeasureTypeImpl() overrides call
298  // solveSupportsNewImpl(transp, solveCriteria) to make sure that
299  // solveSupportsNewImpl() is getting tested right away. Also, have the
300  // existing solveSupportsImpl(...) overrides call
301  // solveSupportsNewImpl(transp, null). This will make sure that all
302  // functionality is now going through solveSupportsNewImpl(...) and is
303  // getting tested.
304  //
305  // (*) Refactor Teko software.
306  //
307  // (*) Once all LOWSB subclasses implement solveSupportsNewImpl(transp,
308  // solveCriteria), finish off the refactoring in one shot:
309  //
310  // (-) Remove the function solveSupports(transp), give solveCriteria a
311  // default null in solveSupports(transp, solveCriteria).
312  //
313  // (-) Run all tests.
314  //
315  // (-) Remove all of the solveSupportsImpl(transp) overrides, rename solve
316  // solveSupportsNewImpl() to solveSupportsImpl(), and make
317  // solveSupportsImpl(...) pure virtual.
318  //
319  // (-) Run all tests.
320  //
321  // (-) Change solveSupportsSolveMeasureType(transp, solveMeasureType) to
322  // call solveSupportsImpl(transp, solveCriteria) by setting
323  // solveMeasureType on a temp SolveCriteria object. Also, deprecate the
324  // function solveSupportsSolveMeasureType(...).
325  //
326  // (-) Run all tests.
327  //
328  // (-) Remove all of the existing solveSupportsSolveMeasureTypeImpl()
329  // overrides.
330  //
331  // (-) Run all tests.
332  //
333  // (-) Clean up all deprecated warnings about calling
334  // solveSupportsSolveMeasureType() and instead have them call
335  // solveSupports(...) with a SolveCritera object.
336  //
337  // (*) Enter a release notes item about this breaking backward compatiblilty
338  // for existing subclasses of LOWSB.
339  //
340  // This refactoring will be done by and by has bug 4915 is implemented.
341  //
342 
348  bool solveSupports(EOpTransp transp) const
349  { return solveSupportsImpl(transp); }
350 
356  const Ptr<const SolveCriteria<Scalar> > solveCriteria) const
357  { return solveSupportsNewImpl(transp, solveCriteria); }
358 
366  const SolveMeasureType& solveMeasureType
367  ) const
368  { return solveSupportsSolveMeasureTypeImpl(transp, solveMeasureType); }
369 
419  const EOpTransp A_trans,
420  const MultiVectorBase<Scalar> &B,
421  const Ptr<MultiVectorBase<Scalar> > &X,
422  const Ptr<const SolveCriteria<Scalar> > solveCriteria = Teuchos::null
423  ) const
424  { return solveImpl(A_trans, B, X, solveCriteria); }
425 
427 
428 protected:
429 
432 
434  virtual bool solveSupportsImpl(EOpTransp transp) const;
435 
437  virtual bool solveSupportsNewImpl(EOpTransp /* transp */,
438  const Ptr<const SolveCriteria<Scalar> > /* solveCriteria */
439  ) const
440  {
443  }
444 
446  virtual bool solveSupportsSolveMeasureTypeImpl(EOpTransp transp,
447  const SolveMeasureType& solveMeasureType) const;
448 
451  const EOpTransp transp,
452  const MultiVectorBase<Scalar> &B,
453  const Ptr<MultiVectorBase<Scalar> > &X,
454  const Ptr<const SolveCriteria<Scalar> > solveCriteria
455  ) const = 0;
456 
458 
459 private:
460 
461 private:
462 
463  // Not defined and not to be called
465  operator=(const LinearOpWithSolveBase<Scalar>&);
466 
467 };
468 
469 
474 template<class Scalar>
475 inline
477 {
478  return A.solveSupports(transp);
479 }
480 
481 
486 template<class Scalar>
487 inline
490  const EOpTransp transp,
491  const Ptr<const SolveCriteria<Scalar> > solveCriteria
492  )
493 {
494  return A.solveSupports(transp, solveCriteria);
495 }
496 
497 
503 template<class Scalar>
504 inline
507  const EOpTransp transp,
508  const SolveMeasureType &solveMeasureType
509  )
510 {
511  return A.solveSupportsSolveMeasureType(transp, solveMeasureType);
512 }
513 
514 
519 template<class Scalar>
520 inline
523  const EOpTransp A_trans,
524  const MultiVectorBase<Scalar> &B,
525  const Ptr<MultiVectorBase<Scalar> > &X,
526  const Ptr<const SolveCriteria<Scalar> > solveCriteria = Teuchos::null
527  )
528 {
529  return A.solve(A_trans, B, X, solveCriteria);
530 }
531 
532 
533 
534 } // namespace Thyra
535 
536 
537 #endif // THYRA_LINEAR_OP_WITH_SOLVE_BASE_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. `*.
bool solveSupports(const LinearOpWithSolveBase< Scalar > &A, const EOpTransp transp, const Ptr< const SolveCriteria< Scalar > > solveCriteria)
Call solveSupports() as a non-member function.
virtual bool solveSupportsSolveMeasureTypeImpl(EOpTransp transp, const SolveMeasureType &solveMeasureType) const
Virtual implementation for solveSupportsSolveMeasureType().
virtual bool solveSupportsImpl(EOpTransp transp) const
Virtual implementation for solveSupports().
SolveStatus< Scalar > solve(const EOpTransp A_trans, const MultiVectorBase< Scalar > &B, const Ptr< MultiVectorBase< Scalar > > &X, const Ptr< const SolveCriteria< Scalar > > solveCriteria=Teuchos::null) const
Request the solution of a block linear system.
bool solveSupportsSolveMeasureType(const LinearOpWithSolveBase< Scalar > &A, const EOpTransp transp, const SolveMeasureType &solveMeasureType)
Call solveSupportsSolveMeasureType() as a non-member function.
Interface for a collection of column vectors called a multi-vector.
virtual SolveStatus< Scalar > solveImpl(const EOpTransp transp, const MultiVectorBase< Scalar > &B, const Ptr< MultiVectorBase< Scalar > > &X, const Ptr< const SolveCriteria< Scalar > > solveCriteria) const =0
Virtual implementation for solve().
Simple struct for the return status from a solve.
Base class for all linear operators.
SolveStatus< Scalar > solve(const LinearOpWithSolveBase< Scalar > &A, const EOpTransp A_trans, const MultiVectorBase< Scalar > &B, const Ptr< MultiVectorBase< Scalar > > &X, const Ptr< const SolveCriteria< Scalar > > solveCriteria=Teuchos::null)
Call solve() as a non-member function.
bool solveSupportsSolveMeasureType(EOpTransp transp, const SolveMeasureType &solveMeasureType) const
Return if solve() supports the given the solve measure type.
#define TEUCHOS_UNREACHABLE_RETURN(dummyReturnVal)
bool solveSupports(EOpTransp transp) const
Return if solve() supports the argument transp.
bool solveSupports(EOpTransp transp, const Ptr< const SolveCriteria< Scalar > > solveCriteria) const
Return if solve() supports a given transpose and solve criteria specification.
bool solveSupports(const LinearOpWithSolveBase< Scalar > &A, const EOpTransp transp)
Call solveSupports() as a non-member function.
Simple struct that defines the requested solution criteria for a solve.
#define TEUCHOS_TEST_FOR_EXCEPT(throw_exception_test)
virtual bool solveSupportsNewImpl(EOpTransp, const Ptr< const SolveCriteria< Scalar > >) const
Virtual implementation of solveSupports().