Thyra_DefaultMultiVectorLinearOpWithSolveDecl.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 // This library is free software; you can redistribute it and/or modify
00011 // it under the terms of the GNU Lesser General Public License as
00012 // published by the Free Software Foundation; either version 2.1 of the
00013 // License, or (at your option) any later version.
00014 //  
00015 // This library is distributed in the hope that it will be useful, but
00016 // WITHOUT ANY WARRANTY; without even the implied warranty of
00017 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00018 // Lesser General Public License for more details.
00019 //  
00020 // You should have received a copy of the GNU Lesser General Public
00021 // License along with this library; if not, write to the Free Software
00022 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
00023 // USA
00024 // Questions? Contact Michael A. Heroux (maherou@sandia.gov) 
00025 // 
00026 // ***********************************************************************
00027 // @HEADER
00028 
00029 #ifndef THYRA_MULTI_VECTOR_LINEAR_OP_WITH_SOLVE_DECL_HPP
00030 #define THYRA_MULTI_VECTOR_LINEAR_OP_WITH_SOLVE_DECL_HPP
00031 
00032 
00033 #include "Thyra_DefaultDiagonalLinearOpDecl.hpp"
00034 #include "Thyra_LinearOpWithSolveBaseDecl.hpp"
00035 #include "Thyra_SingleRhsLinearOpWithSolveBaseDecl.hpp"
00036 #include "Thyra_DefaultMultiVectorProductVectorSpaceDecl.hpp"
00037 #include "Teuchos_ConstNonconstObjectContainer.hpp"
00038 
00039 
00040 namespace Thyra {
00041 
00042 
00048 template<class Scalar>
00049 class DefaultMultiVectorLinearOpWithSolve
00050   : virtual public LinearOpWithSolveBase<Scalar>, // Public interface
00051     virtual protected SingleRhsLinearOpWithSolveBase<Scalar> // Implementation detail
00052     // 2007/05/24: rabartl: ToDo: We could derive this class just from
00053     // SingleScalarLinearOpWithSolveBase but then that would require that we
00054     // have a multi-vector form Thyra::MultiVectorProductMultiVector which
00055     // does not exist yet and is not needed at this point.
00056 {
00057 public:
00058 
00061 
00063   DefaultMultiVectorLinearOpWithSolve();
00064 
00066   void initialize(
00067     const Teuchos::RCP<LinearOpWithSolveBase<Scalar> > &lows,
00068     const Teuchos::RCP<const DefaultMultiVectorProductVectorSpace<Scalar> > &multiVecRange,
00069     const Teuchos::RCP<const DefaultMultiVectorProductVectorSpace<Scalar> > &multiVecDomain
00070     );
00071 
00073   void initialize(
00074     const Teuchos::RCP<const LinearOpWithSolveBase<Scalar> > &lows,
00075     const Teuchos::RCP<const DefaultMultiVectorProductVectorSpace<Scalar> > &multiVecRange,
00076     const Teuchos::RCP<const DefaultMultiVectorProductVectorSpace<Scalar> > &multiVecDomain
00077     );
00078   
00080   Teuchos::RCP<LinearOpWithSolveBase<Scalar> >
00081   getNonconstLinearOpWithSolve();
00082   
00084   Teuchos::RCP<const LinearOpWithSolveBase<Scalar> >
00085   getLinearOpWithSolve() const;
00086 
00087   // 2007/05/24: rabartl: ToDo: Add a const version of the above function once
00088   // needed
00089 
00091   void uninitialize();
00092 
00094 
00097 
00099   Teuchos::RCP< const VectorSpaceBase<Scalar> > range() const;
00100 
00102   Teuchos::RCP< const VectorSpaceBase<Scalar> > domain() const;
00103 
00105   Teuchos::RCP<const LinearOpBase<Scalar> > clone() const;
00106 
00108 
00109 protected:
00110 
00113 
00115   bool opSupported(ETransp M_trans) const;
00116 
00118 
00121 
00123   void apply(
00124     const ETransp M_trans,
00125     const VectorBase<Scalar> &x,
00126     VectorBase<Scalar> *y,
00127     const Scalar alpha,
00128     const Scalar beta
00129     ) const;
00130 
00132 
00135 
00137   bool solveSupportsTrans(ETransp M_trans) const;
00138 
00140   bool solveSupportsSolveMeasureType(
00141     ETransp M_trans, const SolveMeasureType& solveMeasureType
00142     ) const;
00143 
00145 
00148 
00150   SolveStatus<Scalar> solve(
00151     const ETransp M_trans,
00152     const VectorBase<Scalar> &b,
00153     VectorBase<Scalar> *x,
00154     const SolveCriteria<Scalar> *solveCriteria
00155     ) const;
00156 
00158 
00159 private:
00160 
00161   // //////////////////////////////
00162   // Private types
00163 
00164   typedef Teuchos::ConstNonconstObjectContainer<LinearOpWithSolveBase<Scalar> > CNLOWS;
00165 
00166   // //////////////////////////////
00167   // Private data members
00168 
00169   CNLOWS lows_;
00170   Teuchos::RCP<const DefaultMultiVectorProductVectorSpace<Scalar> > multiVecRange_;
00171   Teuchos::RCP<const DefaultMultiVectorProductVectorSpace<Scalar> > multiVecDomain_;
00172 
00173   // //////////////////////////////
00174   // Private member functions
00175 
00176   static void validateInitialize(
00177     const Teuchos::RCP<const LinearOpWithSolveBase<Scalar> > &lows,
00178     const Teuchos::RCP<const DefaultMultiVectorProductVectorSpace<Scalar> > &multiVecRange,
00179     const Teuchos::RCP<const DefaultMultiVectorProductVectorSpace<Scalar> > &multiVecDomain
00180     );
00181   
00182 
00183 };
00184 
00185 
00190 template<class Scalar>
00191 Teuchos::RCP<DefaultMultiVectorLinearOpWithSolve<Scalar> >
00192 multiVectorLinearOpWithSolve()
00193 {
00194   return Teuchos::rcp(new DefaultMultiVectorLinearOpWithSolve<Scalar>());
00195 }
00196 
00197 
00202 template<class Scalar>
00203 Teuchos::RCP<DefaultMultiVectorLinearOpWithSolve<Scalar> >
00204 multiVectorLinearOpWithSolve(
00205   const Teuchos::RCP<LinearOpWithSolveBase<Scalar> > &lows,
00206   const Teuchos::RCP<const DefaultMultiVectorProductVectorSpace<Scalar> > &multiVecRange,
00207   const Teuchos::RCP<const DefaultMultiVectorProductVectorSpace<Scalar> > &multiVecDomain
00208   )
00209 {
00210   Teuchos::RCP<DefaultMultiVectorLinearOpWithSolve<Scalar> >
00211     mvlows = Teuchos::rcp(new DefaultMultiVectorLinearOpWithSolve<Scalar>());
00212   mvlows->initialize(lows,multiVecRange,multiVecDomain);
00213   return mvlows;
00214 }
00215 
00216 
00221 template<class Scalar>
00222 Teuchos::RCP<DefaultMultiVectorLinearOpWithSolve<Scalar> >
00223 multiVectorLinearOpWithSolve(
00224   const Teuchos::RCP<const LinearOpWithSolveBase<Scalar> > &lows,
00225   const Teuchos::RCP<const DefaultMultiVectorProductVectorSpace<Scalar> > &multiVecRange,
00226   const Teuchos::RCP<const DefaultMultiVectorProductVectorSpace<Scalar> > &multiVecDomain
00227   )
00228 {
00229   Teuchos::RCP<DefaultMultiVectorLinearOpWithSolve<Scalar> >
00230     mvlows = Teuchos::rcp(new DefaultMultiVectorLinearOpWithSolve<Scalar>());
00231   mvlows->initialize(lows,multiVecRange,multiVecDomain);
00232   return mvlows;
00233 }
00234 
00235 
00236 } // end namespace Thyra
00237 
00238 
00239 #endif  // THYRA_MULTI_VECTOR_LINEAR_OP_WITH_SOLVE_DECL_HPP

Generated on Tue Oct 20 12:47:11 2009 for Thyra Operator Solve Support by doxygen 1.4.7