Thyra Version of the Day
Thyra_DefaultBlockedTriangularLinearOpWithSolve_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_DEFAULT_BLOCKED_TRIANGULAR_LINEAR_OP_WITH_SOLVE_DECL_HPP
00043 #define THYRA_DEFAULT_BLOCKED_TRIANGULAR_LINEAR_OP_WITH_SOLVE_DECL_HPP
00044 
00045 
00046 #include "Thyra_PhysicallyBlockedLinearOpWithSolveBase.hpp"
00047 #include "Thyra_PhysicallyBlockedLinearOpBase.hpp"
00048 #include "Thyra_ProductVectorSpaceBase.hpp"
00049 #include "Teuchos_ConstNonconstObjectContainer.hpp"
00050 #include "Teuchos_Array.hpp"
00051 
00052 
00053 namespace Thyra {
00054 
00055 
00111 template<class Scalar>
00112 class DefaultBlockedTriangularLinearOpWithSolve
00113   : virtual public PhysicallyBlockedLinearOpWithSolveBase<Scalar>
00114 {
00115 public:
00116 
00119 
00121   DefaultBlockedTriangularLinearOpWithSolve();
00122 
00124   void setNonconstBlocks( const RCP<PhysicallyBlockedLinearOpBase<Scalar> > &blocks );
00125 
00127   void setBlocks( const RCP<const PhysicallyBlockedLinearOpBase<Scalar> > &blocks );
00128 
00130   RCP<PhysicallyBlockedLinearOpBase<Scalar> > getNonconstBlocks();
00131 
00133   RCP<const PhysicallyBlockedLinearOpBase<Scalar> > getBlocks();
00134 
00136 
00139   
00141   bool acceptsLOWSBlock(const int i, const int j) const;
00143   void setNonconstLOWSBlock(
00144     const int i, const int j,
00145     const RCP<LinearOpWithSolveBase<Scalar> > &block
00146     );
00148   void setLOWSBlock(
00149     const int i, const int j,
00150     const RCP<const LinearOpWithSolveBase<Scalar> > &block
00151     );
00152 
00154 
00157 
00159   void beginBlockFill();
00161   void beginBlockFill(
00162     const int numRowBlocks, const int numColBlocks
00163     );
00165   void beginBlockFill(
00166     const RCP<const ProductVectorSpaceBase<Scalar> > &productRange,
00167     const RCP<const ProductVectorSpaceBase<Scalar> > &productDomain
00168     );
00170   bool blockFillIsActive() const;
00172   bool acceptsBlock(const int i, const int j) const;
00174   void setNonconstBlock(
00175     const int i, const int j,
00176     const RCP<LinearOpBase<Scalar> > &block
00177     );
00179   void setBlock(
00180     const int i, const int j,
00181     const RCP<const LinearOpBase<Scalar> > &block
00182     );
00184   void endBlockFill();
00186   void uninitialize();
00187 
00189 
00192 
00194   RCP<LinearOpWithSolveBase<Scalar> >
00195   getNonconstLOWSBlock(const int i, const int j); 
00197   RCP<const LinearOpWithSolveBase<Scalar> >
00198   getLOWSBlock(const int i, const int j) const; 
00199 
00201 
00204 
00206   RCP<const ProductVectorSpaceBase<Scalar> >
00207   productRange() const;
00209   RCP<const ProductVectorSpaceBase<Scalar> >
00210   productDomain() const;
00212   bool blockExists(const int i, const int j) const; 
00214   bool blockIsConst(const int i, const int j) const; 
00216   RCP<LinearOpBase<Scalar> >
00217   getNonconstBlock(const int i, const int j); 
00219   RCP<const LinearOpBase<Scalar> >
00220   getBlock(const int i, const int j) const; 
00221 
00223 
00226 
00228   RCP<const VectorSpaceBase<Scalar> > range() const;
00230   RCP<const VectorSpaceBase<Scalar> > domain() const;
00232   RCP<const LinearOpBase<Scalar> > clone() const;
00233 
00235 
00238                                                 
00243   std::string description() const;
00244 
00252   void describe(
00253     Teuchos::FancyOStream &out,
00254     const Teuchos::EVerbosityLevel verbLevel
00255     ) const;
00256 
00258 
00259 protected:
00260   
00264   bool opSupportedImpl(EOpTransp M_trans) const;
00266  void applyImpl(
00267    const EOpTransp M_trans,
00268    const MultiVectorBase<Scalar> &X,
00269    const Ptr<MultiVectorBase<Scalar> > &Y,
00270    const Scalar alpha,
00271    const Scalar beta
00272    ) const;
00274 
00278   bool solveSupportsImpl(EOpTransp M_trans) const;
00280   bool solveSupportsSolveMeasureTypeImpl(
00281     EOpTransp M_trans, const SolveMeasureType& solveMeasureType) const;
00283   SolveStatus<Scalar> solveImpl(
00284     const EOpTransp transp,
00285     const MultiVectorBase<Scalar> &B,
00286     const Ptr<MultiVectorBase<Scalar> > &X,
00287     const Ptr<const SolveCriteria<Scalar> > solveCriteria
00288     ) const;
00290 
00291 private:
00292 
00293   // //////////////////////////
00294   // Private types
00295 
00296   typedef Teuchos::ConstNonconstObjectContainer<LinearOpWithSolveBase<Scalar> >
00297   CNCLOWS;
00298 
00299   typedef Teuchos::ConstNonconstObjectContainer<PhysicallyBlockedLinearOpBase<Scalar> >
00300   CNCPBLOB;
00301 
00302   // /////////////////////////
00303   // Private data members
00304   
00305   bool blockFillIsActive_;
00306 
00307   RCP<const ProductVectorSpaceBase<Scalar> > productRange_;
00308   RCP<const ProductVectorSpaceBase<Scalar> > productDomain_;
00309   int numDiagBlocks_;
00310   
00311   Array<CNCLOWS> diagonalBlocks_;
00312 
00313   // All blocks (including LOB form of diagonals)
00314   CNCPBLOB blocks_;
00315 
00316   // /////////////////////////
00317   // Private member functions
00318 
00319   void assertBlockFillIsActive(bool) const;
00320 
00321   void assertBlockRowCol(const int i, const int j) const;
00322 
00323   template<class LinearOpWithSolveType>
00324   void setLOWSBlockImpl( const int i, const int j,
00325     const RCP<LinearOpWithSolveType> &block );
00326 
00327   void assertAndSetBlockStructure(const PhysicallyBlockedLinearOpBase<Scalar>& blocks);
00328   
00329   // Not defined and not to be called
00330 
00331   DefaultBlockedTriangularLinearOpWithSolve(
00332     const DefaultBlockedTriangularLinearOpWithSolve&);
00333 
00334   DefaultBlockedTriangularLinearOpWithSolve&
00335   operator=(const DefaultBlockedTriangularLinearOpWithSolve&);
00336   
00337 };
00338 
00339 
00344 template<class Scalar>
00345 RCP<DefaultBlockedTriangularLinearOpWithSolve<Scalar> >
00346 defaultBlockedTriangularLinearOpWithSolve()
00347 {
00348   return Teuchos::rcp(new DefaultBlockedTriangularLinearOpWithSolve<Scalar>);
00349 }
00350 
00351 
00352 } // namespace Thyra
00353 
00354 
00355 #endif  // THYRA_DEFAULT_BLOCKED_TRIANGULAR_LINEAR_OP_WITH_SOLVE_DECL_HPP
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines