Thyra Version of the Day
Thyra_LinearOpWithSolveBase_decl.hpp
00001 // @HEADER
00002 // ***********************************************************************
00003 // 
00004 //    Thyra: Interfaces and Support for Abstract Numerical Algorithms
00005 //                 Copyright (2004) Sandia Corporation
00006 // 
00007 // Under terms of Contract DE-AC04-94AL85000, there is a non-exclusive
00008 // license for use of this work by or on behalf of the U.S. Government.
00009 // 
00010 // Redistribution and use in source and binary forms, with or without
00011 // modification, are permitted provided that the following conditions are
00012 // met:
00013 //
00014 // 1. Redistributions of source code must retain the above copyright
00015 // notice, this list of conditions and the following disclaimer.
00016 //
00017 // 2. Redistributions in binary form must reproduce the above copyright
00018 // notice, this list of conditions and the following disclaimer in the
00019 // documentation and/or other materials provided with the distribution.
00020 //
00021 // 3. Neither the name of the Corporation nor the names of the
00022 // contributors may be used to endorse or promote products derived from
00023 // this software without specific prior written permission.
00024 //
00025 // THIS SOFTWARE IS PROVIDED BY SANDIA CORPORATION "AS IS" AND ANY
00026 // EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
00027 // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
00028 // PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL SANDIA CORPORATION OR THE
00029 // CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
00030 // EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
00031 // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
00032 // PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
00033 // LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
00034 // NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
00035 // SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
00036 //
00037 // Questions? Contact Roscoe A. Bartlett (bartlettra@ornl.gov) 
00038 // 
00039 // ***********************************************************************
00040 // @HEADER
00041 
00042 #ifndef THYRA_LINEAR_OP_WITH_SOLVE_BASE_DECL_HPP
00043 #define THYRA_LINEAR_OP_WITH_SOLVE_BASE_DECL_HPP
00044 
00045 #include "Thyra_OperatorSolveTypes.hpp"
00046 #include "Thyra_LinearOpBase.hpp"
00047 #include "Thyra_MultiVectorBase.hpp"
00048 #include "Thyra_VectorSpaceBase.hpp"
00049 #include "Thyra_SolveSupportTypes.hpp"
00050 #include "Teuchos_VerboseObject.hpp"
00051 
00052 
00053 namespace Thyra {
00054 
00055 
00307 template<class Scalar>
00308 class LinearOpWithSolveBase
00309   : virtual public LinearOpBase<Scalar>
00310   , virtual public Teuchos::VerboseObject<LinearOpWithSolveBase<Scalar> >
00311 {
00312 public:
00313 
00316 
00317   // 2010/08/22: rabartl: To properly handle the new SolveCriteria struct with
00318   // reduction functionals (bug 4915) the function solveSupports() must be
00319   // refactored.  Here is how this refactoring can be done incrementally and
00320   // safely:
00321   //
00322   // (*) Create new override solveSupports(transp, solveCriteria) that calls
00323   // virtual solveSupportsNewImpl(transp, solveCriteria).
00324   //
00325   // (*) One by one, refactor existing LOWSB subclasses to implement
00326   // solveSupportsNewImpl(transp, solveCriteria).  This can be done by
00327   // basically copying the existing solveSupportsSolveMeasureTypeImpl()
00328   // override.  Then have each of the existing
00329   // solveSupportsSolveMeasureTypeImpl() overrides call
00330   // solveSupportsNewImpl(transp, solveCriteria) to make sure that
00331   // solveSupportsNewImpl() is getting tested right away.  Also, have the
00332   // existing solveSupportsImpl(...) overrides call
00333   // solveSupportsNewImpl(transp, null).  This will make sure that all
00334   // functionality is now going through solveSupportsNewImpl(...) and is
00335   // getting tested.
00336   //
00337   // (*) Refactor Teko software.
00338   //
00339   // (*) Once all LOWSB subclasses implement solveSupportsNewImpl(transp,
00340   // solveCriteria), finish off the refactoring in one shot:
00341   //
00342   //   (-) Remove the function solveSupports(transp), give solveCriteria a
00343   //   default null in solveSupports(transp, solveCriteria).
00344   //
00345   //   (-) Run all tests.
00346   //
00347   //   (-) Remove all of the solveSupportsImpl(transp) overrides, rename solve
00348   //   solveSupportsNewImpl() to solveSupportsImpl(), and make
00349   //   solveSupportsImpl(...) pure virtual.
00350   //
00351   //   (-) Run all tests.
00352   //
00353   //   (-) Change solveSupportsSolveMeasureType(transp, solveMeasureType) to
00354   //   call solveSupportsImpl(transp, solveCriteria) by setting
00355   //   solveMeasureType on a temp SolveCriteria object.  Also, deprecate the
00356   //   function solveSupportsSolveMeasureType(...).
00357   //
00358   //   (-) Run all tests.
00359   //
00360   //   (-) Remove all of the existing solveSupportsSolveMeasureTypeImpl()
00361   //   overrides.
00362   //
00363   //   (-) Run all tests.
00364   //
00365   //   (-) Clean up all deprecated warnings about calling
00366   //   solveSupportsSolveMeasureType() and instead have them call
00367   //   solveSupports(...) with a SolveCritera object.
00368   //
00369   // (*) Enter a release notes item about this breaking backward compatiblilty
00370   // for existing subclasses of LOWSB.
00371   //
00372   // This refactoring will be done by and by has bug 4915 is implemented.
00373   // 
00374 
00380   bool solveSupports(EOpTransp transp) const
00381     { return solveSupportsImpl(transp); }
00382 
00387   bool solveSupports(EOpTransp transp,
00388     const Ptr<const SolveCriteria<Scalar> > solveCriteria) const
00389     { return solveSupportsNewImpl(transp, solveCriteria); }
00390 
00397   bool solveSupportsSolveMeasureType(EOpTransp transp,
00398     const SolveMeasureType& solveMeasureType
00399     ) const
00400     { return solveSupportsSolveMeasureTypeImpl(transp, solveMeasureType); }
00401 
00450   SolveStatus<Scalar> solve(
00451     const EOpTransp A_trans,
00452     const MultiVectorBase<Scalar> &B,
00453     const Ptr<MultiVectorBase<Scalar> > &X,
00454     const Ptr<const SolveCriteria<Scalar> > solveCriteria = Teuchos::null
00455     ) const 
00456     { return solveImpl(A_trans, B, X, solveCriteria); }
00457 
00459 
00460 protected:
00461 
00464 
00466   virtual bool solveSupportsImpl(EOpTransp transp) const;
00467 
00469   virtual bool solveSupportsNewImpl(EOpTransp transp,
00470     const Ptr<const SolveCriteria<Scalar> > solveCriteria
00471     ) const
00472     {
00473       TEUCHOS_TEST_FOR_EXCEPT(true);
00474       return(false);
00475     }
00476 
00478   virtual bool solveSupportsSolveMeasureTypeImpl(EOpTransp transp,
00479     const SolveMeasureType& solveMeasureType) const;
00480 
00482   virtual SolveStatus<Scalar> solveImpl(
00483     const EOpTransp transp,
00484     const MultiVectorBase<Scalar> &B,
00485     const Ptr<MultiVectorBase<Scalar> > &X,
00486     const Ptr<const SolveCriteria<Scalar> > solveCriteria
00487     ) const = 0;
00488 
00490 
00491 private:
00492 
00493 private:
00494   
00495   // Not defined and not to be called
00496   LinearOpWithSolveBase<Scalar>&
00497   operator=(const LinearOpWithSolveBase<Scalar>&);
00498 
00499 };
00500 
00501 
00506 template<class Scalar>
00507 inline
00508 bool solveSupports(const LinearOpWithSolveBase<Scalar> &A, const EOpTransp transp)
00509 {
00510   return A.solveSupports(transp);
00511 }
00512 
00513 
00518 template<class Scalar>
00519 inline
00520 bool solveSupports(
00521   const LinearOpWithSolveBase<Scalar> &A,
00522   const EOpTransp transp,
00523   const Ptr<const SolveCriteria<Scalar> > solveCriteria
00524   )
00525 {
00526   return A.solveSupports(transp, solveCriteria);
00527 }
00528 
00529 
00535 template<class Scalar>
00536 inline
00537 bool solveSupportsSolveMeasureType(
00538   const LinearOpWithSolveBase<Scalar> &A,
00539   const EOpTransp transp,
00540   const SolveMeasureType &solveMeasureType
00541   )
00542 {
00543   return A.solveSupportsSolveMeasureType(transp, solveMeasureType);
00544 }
00545 
00546 
00551 template<class Scalar>
00552 inline
00553 SolveStatus<Scalar> solve(
00554   const LinearOpWithSolveBase<Scalar> &A,
00555   const EOpTransp A_trans,
00556   const MultiVectorBase<Scalar> &B,
00557   const Ptr<MultiVectorBase<Scalar> > &X,
00558   const Ptr<const SolveCriteria<Scalar> > solveCriteria = Teuchos::null
00559   )
00560 {
00561   return A.solve(A_trans, B, X, solveCriteria);
00562 }
00563 
00564 
00565 
00566 } // namespace Thyra
00567 
00568 
00569 #endif // THYRA_LINEAR_OP_WITH_SOLVE_BASE_DECL_HPP
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines