Thyra_DefaultBlockedLinearOp_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 // 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_SingleScalarLinearOpBase.hpp"
00036 #include "Thyra_ProductVectorSpaceBase.hpp"
00037 #include "Teuchos_ConstNonconstObjectContainer.hpp"
00038 #include "Teuchos_Array.hpp"
00039 #include "Teuchos_Handleable.hpp"
00040 #include "Teuchos_arrayArg.hpp"
00041 
00042 
00043 namespace Thyra {
00044 
00045 
00046 template<class Scalar> class DefaultProductVectorSpace;
00047 
00048 
00074 template<class Scalar>
00075 class DefaultBlockedLinearOp
00076   : virtual public PhysicallyBlockedLinearOpBase<Scalar>  // Public interface
00077   , virtual protected SingleScalarLinearOpBase<Scalar>    // Implementation detail
00078   , virtual public Teuchos::Handleable<LinearOpBase<Scalar, Scalar> >
00079 {
00080 public:
00081 
00082 #ifdef THYRA_INJECT_USING_DECLARATIONS
00083   using SingleScalarLinearOpBase<Scalar>::apply;
00084 #endif
00085 
00086   /* \brief . */
00087   TEUCHOS_GET_RCP(LinearOpBase<Scalar>);
00088 
00091 
00093   DefaultBlockedLinearOp();
00094 
00096 
00099 
00101   void beginBlockFill();
00103   void beginBlockFill(
00104     const int numRowBlocks, const int numColBlocks
00105     );
00107   void beginBlockFill(
00108     const Teuchos::RCP<const ProductVectorSpaceBase<Scalar> > &productRange,
00109     const Teuchos::RCP<const ProductVectorSpaceBase<Scalar> > &productDomain
00110     );
00112   bool blockFillIsActive() const;
00114   bool acceptsBlock(const int i, const int j) const;
00116   void setNonconstBlock(
00117     const int i, const int j,
00118     const Teuchos::RCP<LinearOpBase<Scalar> > &block
00119     );
00121   void setBlock(
00122     const int i, const int j
00123     ,const Teuchos::RCP<const LinearOpBase<Scalar> > &block
00124     );
00126   void endBlockFill();
00128   void uninitialize();
00129 
00131 
00134 
00136   Teuchos::RCP<const ProductVectorSpaceBase<Scalar> >
00137   productRange() const;
00139   Teuchos::RCP<const ProductVectorSpaceBase<Scalar> >
00140   productDomain() const;
00142   bool blockExists(const int i, const int j) const; 
00144   bool blockIsConst(const int i, const int j) const; 
00146   Teuchos::RCP<LinearOpBase<Scalar> >
00147   getNonconstBlock(const int i, const int j); 
00149   Teuchos::RCP<const LinearOpBase<Scalar> >
00150   getBlock(const int i, const int j) const; 
00151 
00153 
00156 
00158   Teuchos::RCP< const VectorSpaceBase<Scalar> > range() const;
00160   Teuchos::RCP< const VectorSpaceBase<Scalar> > domain() const;
00162   Teuchos::RCP<const LinearOpBase<Scalar> > clone() const;
00163 
00165 
00168  
00172   std::string description() const;
00173 
00181   void describe(
00182     Teuchos::FancyOStream &out,
00183     const Teuchos::EVerbosityLevel verbLevel
00184     ) const;
00185 
00187 
00188 protected:
00189 
00192 
00196   bool opSupported(EOpTransp M_trans) const;
00197 
00199   void apply(
00200     const EOpTransp M_trans,
00201     const MultiVectorBase<Scalar> &X,
00202     MultiVectorBase<Scalar> *Y,
00203     const Scalar alpha,
00204     const Scalar beta
00205     ) const;
00206  
00208 
00209 private:
00210 
00211   // ///////////////////
00212   // Private types
00213 
00214   typedef Teuchos::ConstNonconstObjectContainer<LinearOpBase<Scalar> > CNCLO;
00215   typedef Teuchos::Array<Teuchos::RCP<const VectorSpaceBase<Scalar> > > vec_array_t;
00216 
00217   template<class Scalar2>
00218   struct BlockEntry {
00219     BlockEntry() : i(-1), j(-1) {}
00220     BlockEntry( const int i_in, const int j_in, const CNCLO &block_in )
00221       :i(i_in),j(j_in),block(block_in)
00222       {}
00223     int i;
00224     int j;
00225     CNCLO block;
00226   };
00227 
00228   // /////////////////////////
00229   // Private data members
00230 
00231   Teuchos::RCP<const ProductVectorSpaceBase<Scalar> > productRange_;
00232   Teuchos::RCP<const ProductVectorSpaceBase<Scalar> > productDomain_;
00233   Teuchos::RCP<const DefaultProductVectorSpace<Scalar> > defaultProductRange_;
00234   Teuchos::RCP<const DefaultProductVectorSpace<Scalar> > defaultProductDomain_;
00235   int numRowBlocks_; // M
00236   int numColBlocks_; // N
00237  
00238   std::vector<CNCLO> Ops_; // Final M x N storage
00239  
00240   vec_array_t rangeBlocks_;
00241   vec_array_t domainBlocks_;
00242   std::vector<BlockEntry<Scalar> > Ops_stack_; // Temp stack of ops begin filled (if Ops_.size()==0).
00243   bool blockFillIsActive_;
00244 
00245   // ///////////////////////////
00246   // Private member functions
00247  
00248   void resetStorage( const int numRowBlocks, const int numColBlocks );
00249   void assertBlockFillIsActive(bool) const;
00250   void assertBlockRowCol(const int i, const int j) const;
00251   void setBlockSpaces(
00252     const int i, const int j, const LinearOpBase<Scalar> &block
00253     );
00254   template<class LinearOpType>
00255   void setBlockImpl(
00256     const int i, const int j,
00257     const Teuchos::RCP<LinearOpType> &block
00258     );
00259   void adjustBlockSpaces();
00260 
00261   // Not defined and not to be called
00262   DefaultBlockedLinearOp(const DefaultBlockedLinearOp&);
00263   DefaultBlockedLinearOp& operator=(const DefaultBlockedLinearOp&);
00264 
00265 };
00266 
00267 
00272 template<class Scalar>
00273 RCP<DefaultBlockedLinearOp<Scalar> > defaultBlockedLinearOp();
00274 
00275 
00280 template<class Scalar>
00281 Teuchos::RCP<const LinearOpBase<Scalar> >
00282 block1x1(
00283   const Teuchos::RCP<const LinearOpBase<Scalar> > &A00,
00284   const std::string &label = ""
00285   );
00286 
00287 
00292 template<class Scalar>
00293 Teuchos::RCP<const LinearOpBase<Scalar> >
00294 block1x2(
00295   const Teuchos::RCP<const LinearOpBase<Scalar> > &A00,
00296   const Teuchos::RCP<const LinearOpBase<Scalar> > &A01,
00297   const std::string &label = ""
00298   );
00299 
00300 
00305 template<class Scalar>
00306 Teuchos::RCP<const LinearOpBase<Scalar> >
00307 block2x1(
00308   const Teuchos::RCP<const LinearOpBase<Scalar> > &A00,
00309   const Teuchos::RCP<const LinearOpBase<Scalar> > &A10,
00310   const std::string &label = ""
00311   );
00312 
00313 
00318 template<class Scalar>
00319 Teuchos::RCP<const LinearOpBase<Scalar> >
00320 block2x2(
00321   const Teuchos::RCP<const LinearOpBase<Scalar> > &A00,
00322   const Teuchos::RCP<const LinearOpBase<Scalar> > &A01,
00323   const Teuchos::RCP<const LinearOpBase<Scalar> > &A10,
00324   const Teuchos::RCP<const LinearOpBase<Scalar> > &A11,
00325   const std::string &label = ""
00326   );
00327 
00328 
00333 template<class Scalar>
00334 Teuchos::RCP<LinearOpBase<Scalar> >
00335 nonconstBlock1x1(
00336   const Teuchos::RCP<LinearOpBase<Scalar> > &A00,
00337   const std::string &label = ""
00338   );
00339 
00340 
00345 template<class Scalar>
00346 Teuchos::RCP<LinearOpBase<Scalar> >
00347 nonconstBlock1x2(
00348   const Teuchos::RCP<LinearOpBase<Scalar> > &A00,
00349   const Teuchos::RCP<LinearOpBase<Scalar> > &A01,
00350   const std::string &label = ""
00351   );
00352 
00353 
00358 template<class Scalar>
00359 Teuchos::RCP<LinearOpBase<Scalar> >
00360 nonconstBlock2x1(
00361   const Teuchos::RCP<LinearOpBase<Scalar> > &A00,
00362   const Teuchos::RCP<LinearOpBase<Scalar> > &A10,
00363   const std::string &label = ""
00364   );
00365 
00366 
00371 template<class Scalar>
00372 Teuchos::RCP<LinearOpBase<Scalar> >
00373 nonconstBlock2x2(
00374   const Teuchos::RCP<LinearOpBase<Scalar> > &A00,
00375   const Teuchos::RCP<LinearOpBase<Scalar> > &A01,
00376   const Teuchos::RCP<LinearOpBase<Scalar> > &A10,
00377   const Teuchos::RCP<LinearOpBase<Scalar> > &A11,
00378   const std::string &label = ""
00379   );
00380 
00381 
00382 } // namespace Thyra
00383 
00384 
00385 #endif  // THYRA_DEFAULT_BLOCKED_LINEAR_OP_DECL_HPP

Generated on Wed May 12 21:26:53 2010 for Thyra Operator/Vector Support by  doxygen 1.4.7