Thyra_DefaultBlockedTriangularLinearOpWithSolveDecl.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_DEFAULT_BLOCKED_TRIANGULAR_LINEAR_OP_WITH_SOLVE_DECL_HPP
00030 #define THYRA_DEFAULT_BLOCKED_TRIANGULAR_LINEAR_OP_WITH_SOLVE_DECL_HPP
00031 
00032 
00033 #include "Thyra_PhysicallyBlockedLinearOpWithSolveBase.hpp"
00034 #include "Thyra_SingleScalarLinearOpWithSolveBase.hpp"
00035 #include "Thyra_ProductVectorSpaceBase.hpp"
00036 #include "Teuchos_ConstNonconstObjectContainer.hpp"
00037 #include "Teuchos_Array.hpp"
00038 
00039 
00040 namespace Thyra {
00041 
00042 
00051 template<class Scalar>
00052 class DefaultBlockedTriangularLinearOpWithSolve
00053   : virtual public PhysicallyBlockedLinearOpWithSolveBase<Scalar>, // Public interface
00054     virtual protected SingleScalarLinearOpWithSolveBase<Scalar> // Implementation detail
00055 {
00056 public:
00057 
00060 
00062   DefaultBlockedTriangularLinearOpWithSolve();
00063 
00065 
00068   
00070   bool acceptsLOWSBlock(const int i, const int j) const;
00072   void setNonconstLOWSBlock(
00073     const int i, const int j,
00074     const Teuchos::RCP<LinearOpWithSolveBase<Scalar> > &block
00075     );
00077   void setLOWSBlock(
00078     const int i, const int j,
00079     const Teuchos::RCP<const LinearOpWithSolveBase<Scalar> > &block
00080     );
00081 
00083 
00086 
00088   void beginBlockFill();
00090   void beginBlockFill(
00091     const int numRowBlocks, const int numColBlocks
00092     );
00094   void beginBlockFill(
00095     const Teuchos::RCP<const ProductVectorSpaceBase<Scalar> >  &productRange,
00096     const Teuchos::RCP<const ProductVectorSpaceBase<Scalar> > &productDomain
00097     );
00099   bool blockFillIsActive() const;
00101   bool acceptsBlock(const int i, const int j) const;
00103   void setNonconstBlock(
00104     const int i, const int j,
00105     const Teuchos::RCP<LinearOpBase<Scalar> > &block
00106     );
00108   void setBlock(
00109     const int i, const int j,
00110     const Teuchos::RCP<const LinearOpBase<Scalar> > &block
00111     );
00113   void endBlockFill();
00115   void uninitialize();
00116 
00118 
00121 
00123   Teuchos::RCP<LinearOpWithSolveBase<Scalar> >
00124   getNonconstLOWSBlock(const int i, const int j); 
00126   Teuchos::RCP<const LinearOpWithSolveBase<Scalar> >
00127   getLOWSBlock(const int i, const int j) const; 
00128 
00130 
00133 
00135   Teuchos::RCP<const ProductVectorSpaceBase<Scalar> >
00136   productRange() const;
00138   Teuchos::RCP<const ProductVectorSpaceBase<Scalar> >
00139   productDomain() const;
00141   bool blockExists(const int i, const int j) const; 
00143   bool blockIsConst(const int i, const int j) const; 
00145   Teuchos::RCP<LinearOpBase<Scalar> >
00146   getNonconstBlock(const int i, const int j); 
00148   Teuchos::RCP<const LinearOpBase<Scalar> >
00149   getBlock(const int i, const int j) const; 
00150 
00152 
00155 
00157   Teuchos::RCP< const VectorSpaceBase<Scalar> > range() const;
00159   Teuchos::RCP< const VectorSpaceBase<Scalar> > domain() const;
00161   Teuchos::RCP<const LinearOpBase<Scalar> > clone() const;
00162 
00164 
00167                                                 
00171   std::string description() const;
00172 
00180   void describe(
00181     Teuchos::FancyOStream &out,
00182     const Teuchos::EVerbosityLevel verbLevel
00183     ) const;
00184 
00186 
00187 protected:
00188 
00191 
00193   bool solveSupportsTrans(ETransp M_trans) const;
00195   bool solveSupportsSolveMeasureType(
00196     ETransp M_trans, const SolveMeasureType& solveMeasureType ) const;
00198   void solve(
00199     const ETransp M_trans,
00200     const MultiVectorBase<Scalar> &B,
00201     MultiVectorBase<Scalar> *X,
00202     const int numBlocks,
00203     const BlockSolveCriteria<Scalar> blockSolveCriteria[],
00204     SolveStatus<Scalar> blockSolveStatus[]
00205     ) const;
00206   
00208 
00211 
00215   bool opSupported(ETransp M_trans) const;
00216 
00218   void apply(
00219     const ETransp M_trans,
00220     const MultiVectorBase<Scalar> &X,
00221     MultiVectorBase<Scalar> *Y,
00222     const Scalar alpha,
00223     const Scalar beta
00224     ) const;
00225   
00227 
00228 private:
00229 
00230   // //////////////////////////
00231   // Private types
00232 
00233   typedef Teuchos::ConstNonconstObjectContainer<LinearOpWithSolveBase<Scalar> >
00234   CNCLOWS;
00235 
00236   // /////////////////////////
00237   // Private data members
00238   
00239   bool blockFillIsActive_;
00240 
00241   Teuchos::RCP<const ProductVectorSpaceBase<Scalar> > productRange_;
00242   Teuchos::RCP<const ProductVectorSpaceBase<Scalar> > productDomain_;
00243   int numDiagBlocks_;
00244   
00245   Teuchos::Array<CNCLOWS> diagonalBlocks_;
00246 
00247   // ToDo: Add members to support off-diagonal blocks!
00248 
00249   // /////////////////////////
00250   // Private member functions
00251 
00252   void assertBlockFillIsActive(bool) const;
00253 
00254   void assertBlockRowCol(const int i, const int j) const;
00255 
00256   template<class LinearOpWithSolveType>
00257   void setLOWSBlockImpl(
00258     const int i, const int j
00259     ,const Teuchos::RCP<LinearOpWithSolveType> &block
00260     );
00261   
00262   // Not defined and not to be called
00263   DefaultBlockedTriangularLinearOpWithSolve(
00264     const DefaultBlockedTriangularLinearOpWithSolve& );
00265   DefaultBlockedTriangularLinearOpWithSolve&
00266   operator=(const DefaultBlockedTriangularLinearOpWithSolve&);
00267   
00268 };
00269 
00270 
00271 } // namespace Thyra
00272 
00273 
00274 #endif  // THYRA_DEFAULT_BLOCKED_TRIANGULAR_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