Thyra Package Browser (Single Doxygen Collection) Version of the Day
Thyra_DefaultBlockedLinearOp_decl.hpp
Go to the documentation of this file.
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 
00030 #ifndef THYRA_DEFAULT_BLOCKED_LINEAR_OP_DECL_HPP
00031 #define THYRA_DEFAULT_BLOCKED_LINEAR_OP_DECL_HPP
00032 
00033 
00034 #include "Thyra_PhysicallyBlockedLinearOpBase.hpp"
00035 #include "Thyra_ProductVectorSpaceBase.hpp"
00036 #include "Teuchos_ConstNonconstObjectContainer.hpp"
00037 
00038 
00039 
00040 namespace Thyra {
00041 
00042 
00043 template<class Scalar> class DefaultProductVectorSpace;
00044 
00045 
00071 template<class Scalar>
00072 class DefaultBlockedLinearOp
00073   : virtual public PhysicallyBlockedLinearOpBase<Scalar>
00074 
00075 {
00076 public:
00077 
00080 
00082   DefaultBlockedLinearOp();
00083 
00085 
00088 
00090   void beginBlockFill();
00092   void beginBlockFill(
00093     const int numRowBlocks, const int numColBlocks
00094     );
00096   void beginBlockFill(
00097     const Teuchos::RCP<const ProductVectorSpaceBase<Scalar> > &productRange,
00098     const Teuchos::RCP<const ProductVectorSpaceBase<Scalar> > &productDomain
00099     );
00101   bool blockFillIsActive() const;
00103   bool acceptsBlock(const int i, const int j) const;
00105   void setNonconstBlock(
00106     const int i, const int j,
00107     const Teuchos::RCP<LinearOpBase<Scalar> > &block
00108     );
00110   void setBlock(
00111     const int i, const int j
00112     ,const Teuchos::RCP<const LinearOpBase<Scalar> > &block
00113     );
00115   void endBlockFill();
00117   void uninitialize();
00118 
00120 
00123 
00125   Teuchos::RCP<const ProductVectorSpaceBase<Scalar> >
00126   productRange() const;
00128   Teuchos::RCP<const ProductVectorSpaceBase<Scalar> >
00129   productDomain() const;
00131   bool blockExists(const int i, const int j) const; 
00133   bool blockIsConst(const int i, const int j) const; 
00135   Teuchos::RCP<LinearOpBase<Scalar> >
00136   getNonconstBlock(const int i, const int j); 
00138   Teuchos::RCP<const LinearOpBase<Scalar> >
00139   getBlock(const int i, const int j) const; 
00140 
00142 
00145 
00147   Teuchos::RCP< const VectorSpaceBase<Scalar> > range() const;
00149   Teuchos::RCP< const VectorSpaceBase<Scalar> > domain() const;
00151   Teuchos::RCP<const LinearOpBase<Scalar> > clone() const;
00152 
00154 
00157  
00161   std::string description() const;
00162 
00170   void describe(
00171     Teuchos::FancyOStream &out,
00172     const Teuchos::EVerbosityLevel verbLevel
00173     ) const;
00174 
00176 
00177 protected:
00178 
00181 
00185   bool opSupportedImpl(EOpTransp M_trans) const;
00186 
00188   void applyImpl(
00189     const EOpTransp M_trans,
00190     const MultiVectorBase<Scalar> &X,
00191     const Ptr<MultiVectorBase<Scalar> > &Y,
00192     const Scalar alpha,
00193     const Scalar beta
00194     ) const;
00195  
00197 
00198 private:
00199 
00200   // ///////////////////
00201   // Private types
00202 
00203   typedef Teuchos::ConstNonconstObjectContainer<LinearOpBase<Scalar> > CNCLO;
00204   typedef Teuchos::Array<Teuchos::RCP<const VectorSpaceBase<Scalar> > > vec_array_t;
00205 
00206   template<class Scalar2>
00207   struct BlockEntry {
00208     BlockEntry() : i(-1), j(-1) {}
00209     BlockEntry( const int i_in, const int j_in, const CNCLO &block_in )
00210       :i(i_in),j(j_in),block(block_in)
00211       {}
00212     int i;
00213     int j;
00214     CNCLO block;
00215   };
00216 
00217   // /////////////////////////
00218   // Private data members
00219 
00220   Teuchos::RCP<const ProductVectorSpaceBase<Scalar> > productRange_;
00221   Teuchos::RCP<const ProductVectorSpaceBase<Scalar> > productDomain_;
00222   Teuchos::RCP<const DefaultProductVectorSpace<Scalar> > defaultProductRange_;
00223   Teuchos::RCP<const DefaultProductVectorSpace<Scalar> > defaultProductDomain_;
00224   int numRowBlocks_; // M
00225   int numColBlocks_; // N
00226  
00227   std::vector<CNCLO> Ops_; // Final M x N storage
00228  
00229   vec_array_t rangeBlocks_;
00230   vec_array_t domainBlocks_;
00231   std::vector<BlockEntry<Scalar> > Ops_stack_; // Temp stack of ops begin filled (if Ops_.size()==0).
00232   bool blockFillIsActive_;
00233 
00234   // ///////////////////////////
00235   // Private member functions
00236  
00237   void resetStorage( const int numRowBlocks, const int numColBlocks );
00238   void assertBlockFillIsActive(bool) const;
00239   void assertBlockRowCol(const int i, const int j) const;
00240   void setBlockSpaces(
00241     const int i, const int j, const LinearOpBase<Scalar> &block
00242     );
00243   template<class LinearOpType>
00244   void setBlockImpl(
00245     const int i, const int j,
00246     const Teuchos::RCP<LinearOpType> &block
00247     );
00248   void adjustBlockSpaces();
00249 
00250   // Not defined and not to be called
00251   DefaultBlockedLinearOp(const DefaultBlockedLinearOp&);
00252   DefaultBlockedLinearOp& operator=(const DefaultBlockedLinearOp&);
00253 
00254 };
00255 
00256 
00261 template<class Scalar>
00262 RCP<DefaultBlockedLinearOp<Scalar> > defaultBlockedLinearOp();
00263 
00264 
00269 template<class Scalar>
00270 Teuchos::RCP<const LinearOpBase<Scalar> >
00271 block1x1(
00272   const Teuchos::RCP<const LinearOpBase<Scalar> > &A00,
00273   const std::string &label = ""
00274   );
00275 
00276 
00281 template<class Scalar>
00282 Teuchos::RCP<const LinearOpBase<Scalar> >
00283 block1x2(
00284   const Teuchos::RCP<const LinearOpBase<Scalar> > &A00,
00285   const Teuchos::RCP<const LinearOpBase<Scalar> > &A01,
00286   const std::string &label = ""
00287   );
00288 
00289 
00294 template<class Scalar>
00295 Teuchos::RCP<const LinearOpBase<Scalar> >
00296 block2x1(
00297   const Teuchos::RCP<const LinearOpBase<Scalar> > &A00,
00298   const Teuchos::RCP<const LinearOpBase<Scalar> > &A10,
00299   const std::string &label = ""
00300   );
00301 
00302 
00307 template<class Scalar>
00308 Teuchos::RCP<const LinearOpBase<Scalar> >
00309 block2x2(
00310   const Teuchos::RCP<const LinearOpBase<Scalar> > &A00,
00311   const Teuchos::RCP<const LinearOpBase<Scalar> > &A01,
00312   const Teuchos::RCP<const LinearOpBase<Scalar> > &A10,
00313   const Teuchos::RCP<const LinearOpBase<Scalar> > &A11,
00314   const std::string &label = ""
00315   );
00316 
00317 
00322 template<class Scalar>
00323 Teuchos::RCP<LinearOpBase<Scalar> >
00324 nonconstBlock1x1(
00325   const Teuchos::RCP<LinearOpBase<Scalar> > &A00,
00326   const std::string &label = ""
00327   );
00328 
00329 
00334 template<class Scalar>
00335 Teuchos::RCP<LinearOpBase<Scalar> >
00336 nonconstBlock1x2(
00337   const Teuchos::RCP<LinearOpBase<Scalar> > &A00,
00338   const Teuchos::RCP<LinearOpBase<Scalar> > &A01,
00339   const std::string &label = ""
00340   );
00341 
00342 
00347 template<class Scalar>
00348 Teuchos::RCP<LinearOpBase<Scalar> >
00349 nonconstBlock2x1(
00350   const Teuchos::RCP<LinearOpBase<Scalar> > &A00,
00351   const Teuchos::RCP<LinearOpBase<Scalar> > &A10,
00352   const std::string &label = ""
00353   );
00354 
00355 
00360 template<class Scalar>
00361 Teuchos::RCP<LinearOpBase<Scalar> >
00362 nonconstBlock2x2(
00363   const Teuchos::RCP<LinearOpBase<Scalar> > &A00,
00364   const Teuchos::RCP<LinearOpBase<Scalar> > &A01,
00365   const Teuchos::RCP<LinearOpBase<Scalar> > &A10,
00366   const Teuchos::RCP<LinearOpBase<Scalar> > &A11,
00367   const std::string &label = ""
00368   );
00369 
00370 
00371 } // namespace Thyra
00372 
00373 
00374 #endif  // THYRA_DEFAULT_BLOCKED_LINEAR_OP_DECL_HPP
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines