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 
282  using scalar_type = Scalar;
283 
286 
287  // 2010/08/22: rabartl: To properly handle the new SolveCriteria struct with
288  // reduction functionals (bug 4915) the function solveSupports() must be
289  // refactored. Here is how this refactoring can be done incrementally and
290  // safely:
291  //
292  // (*) Create new override solveSupports(transp, solveCriteria) that calls
293  // virtual solveSupportsNewImpl(transp, solveCriteria).
294  //
295  // (*) One by one, refactor existing LOWSB subclasses to implement
296  // solveSupportsNewImpl(transp, solveCriteria). This can be done by
297  // basically copying the existing solveSupportsSolveMeasureTypeImpl()
298  // override. Then have each of the existing
299  // solveSupportsSolveMeasureTypeImpl() overrides call
300  // solveSupportsNewImpl(transp, solveCriteria) to make sure that
301  // solveSupportsNewImpl() is getting tested right away. Also, have the
302  // existing solveSupportsImpl(...) overrides call
303  // solveSupportsNewImpl(transp, null). This will make sure that all
304  // functionality is now going through solveSupportsNewImpl(...) and is
305  // getting tested.
306  //
307  // (*) Refactor Teko software.
308  //
309  // (*) Once all LOWSB subclasses implement solveSupportsNewImpl(transp,
310  // solveCriteria), finish off the refactoring in one shot:
311  //
312  // (-) Remove the function solveSupports(transp), give solveCriteria a
313  // default null in solveSupports(transp, solveCriteria).
314  //
315  // (-) Run all tests.
316  //
317  // (-) Remove all of the solveSupportsImpl(transp) overrides, rename solve
318  // solveSupportsNewImpl() to solveSupportsImpl(), and make
319  // solveSupportsImpl(...) pure virtual.
320  //
321  // (-) Run all tests.
322  //
323  // (-) Change solveSupportsSolveMeasureType(transp, solveMeasureType) to
324  // call solveSupportsImpl(transp, solveCriteria) by setting
325  // solveMeasureType on a temp SolveCriteria object. Also, deprecate the
326  // function solveSupportsSolveMeasureType(...).
327  //
328  // (-) Run all tests.
329  //
330  // (-) Remove all of the existing solveSupportsSolveMeasureTypeImpl()
331  // overrides.
332  //
333  // (-) Run all tests.
334  //
335  // (-) Clean up all deprecated warnings about calling
336  // solveSupportsSolveMeasureType() and instead have them call
337  // solveSupports(...) with a SolveCritera object.
338  //
339  // (*) Enter a release notes item about this breaking backward compatiblilty
340  // for existing subclasses of LOWSB.
341  //
342  // This refactoring will be done by and by has bug 4915 is implemented.
343  //
344 
350  bool solveSupports(EOpTransp transp) const
351  { return solveSupportsImpl(transp); }
352 
358  const Ptr<const SolveCriteria<Scalar> > solveCriteria) const
359  { return solveSupportsNewImpl(transp, solveCriteria); }
360 
368  const SolveMeasureType& solveMeasureType
369  ) const
370  { return solveSupportsSolveMeasureTypeImpl(transp, solveMeasureType); }
371 
421  const EOpTransp A_trans,
422  const MultiVectorBase<Scalar> &B,
423  const Ptr<MultiVectorBase<Scalar> > &X,
424  const Ptr<const SolveCriteria<Scalar> > solveCriteria = Teuchos::null
425  ) const
426  { return solveImpl(A_trans, B, X, solveCriteria); }
427 
429 
430 protected:
431 
434 
436  virtual bool solveSupportsImpl(EOpTransp transp) const;
437 
439  virtual bool solveSupportsNewImpl(EOpTransp /* transp */,
440  const Ptr<const SolveCriteria<Scalar> > /* solveCriteria */
441  ) const
442  {
445  }
446 
448  virtual bool solveSupportsSolveMeasureTypeImpl(EOpTransp transp,
449  const SolveMeasureType& solveMeasureType) const;
450 
453  const EOpTransp transp,
454  const MultiVectorBase<Scalar> &B,
455  const Ptr<MultiVectorBase<Scalar> > &X,
456  const Ptr<const SolveCriteria<Scalar> > solveCriteria
457  ) const = 0;
458 
460 
461 private:
462 
463 private:
464 
465  // Not defined and not to be called
467  operator=(const LinearOpWithSolveBase<Scalar>&);
468 
469 };
470 
471 
476 template<class Scalar>
477 inline
479 {
480  return A.solveSupports(transp);
481 }
482 
483 
488 template<class Scalar>
489 inline
492  const EOpTransp transp,
493  const Ptr<const SolveCriteria<Scalar> > solveCriteria
494  )
495 {
496  return A.solveSupports(transp, solveCriteria);
497 }
498 
499 
505 template<class Scalar>
506 inline
509  const EOpTransp transp,
510  const SolveMeasureType &solveMeasureType
511  )
512 {
513  return A.solveSupportsSolveMeasureType(transp, solveMeasureType);
514 }
515 
516 
521 template<class Scalar>
522 inline
525  const EOpTransp A_trans,
526  const MultiVectorBase<Scalar> &B,
527  const Ptr<MultiVectorBase<Scalar> > &X,
528  const Ptr<const SolveCriteria<Scalar> > solveCriteria = Teuchos::null
529  )
530 {
531  return A.solve(A_trans, B, X, solveCriteria);
532 }
533 
534 
535 
536 } // namespace Thyra
537 
538 
539 #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().