TSFHomogeneouslyBlockedLinearOp.hpp
Go to the documentation of this file.
00001 /* @HEADER@ */
00002 /* ***********************************************************************
00003 //
00004 //           TSFExtended: Trilinos Solver Framework Extended
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 TSFHOMOGENEOUSLYBLOCKEDLINEAROP_HPP
00030 #define TSFHOMOGENEOUSLYBLOCKEDLINEAROP_HPP
00031 
00032 #include "SundanceDefs.hpp"
00033 #include "TSFSimplifiedLinearOpBase.hpp"
00034 
00035 namespace TSFExtended
00036 {
00037 using namespace Teuchos;
00038 
00039 /**
00040  * HomogeneouslyBlockedLinearOp is a helper class providing a convenient
00041  * way to build operators having a block structure in which all blocks
00042  * have the same domain and range. Such structures arise in, for example,
00043  * space-time operators or stochastic projection methods.
00044  *
00045  * @author Kevin Long (krlong@sandia.gov)
00046  */
00047 template <class Scalar>
00048 class HomogeneouslyBlockedLinearOp :
00049     public virtual LinearOpBase<Scalar>
00050 {
00051 public:
00052 
00053   /*
00054    * Construct by specifying the domain and range spaces for a single
00055    * block and the number of blocks over which to replicate this.
00056    */
00057   HomogeneouslyBlockedLinearOp(
00058     const VectorSpace<Scalar>& singleBlockDomain, 
00059     int numDomainBlocks,
00060     const VectorSpace<Scalar>& singleBlockRange,
00061     int numRangeBlocks
00062     )
00063     : singleBlockDomain_(singleBlockDomain),
00064       numDomainBlocks_(numDomainBlocks),
00065       singleBlockRange_(singleBlockRange),
00066       numRangeBlocks_(numRangeBlocks),
00067       domain_(),
00068       range_()
00069     {
00070       Array<VectorSpace<Scalar> > d(numDomainBlocks_, singleBlockDomain_);
00071       Array<VectorSpace<Scalar> > r(numRangeBlocks_, singleBlockRange_);
00072       domain_ = productSpace(d);
00073       range_ = productSpace(r);
00074     }      
00075 
00076   /** 
00077    * \brief Return a smart pointer for the range space 
00078    * for <tt>this</tt> operator.
00079    */
00080   Teuchos::RCP< const Thyra::VectorSpaceBase<Scalar> > range() const 
00081     {
00082       return range_;
00083     }
00084 
00085   /** \brief Return a smart pointer for the domain space for <tt>this</tt> operator.
00086    */
00087   Teuchos::RCP< const Thyra::VectorSpaceBase<Scalar> > domain() const 
00088     {
00089       return domain_;
00090     }
00091 
00092 protected:
00093 
00094   /** Return the number of block rows */
00095   int numBlockRows() const {return numRangeBlocks_;}
00096 
00097   /** Return the number of block columns */
00098   int numBlockCols() const {return numDomainBlocks_;}
00099 
00100   /** Return the domain space of a single block. By construction
00101    * this is the same for all blocks.  */
00102   const VectorSpace<Scalar>& singleBlockDomain() const 
00103     {
00104       return singleBlockDomain_;
00105     }
00106 
00107   /** Return the range space of a single block. By construction
00108    * this is the same for all blocks.  */
00109   const VectorSpace<Scalar>& singleBlockRange() const 
00110     {
00111       return singleBlockRange_;
00112     }
00113 
00114 private:
00115   VectorSpace<Scalar> singleBlockDomain_;
00116   int numDomainBlocks_;
00117   VectorSpace<Scalar> singleBlockRange_;
00118   int numRangeBlocks_;
00119   Teuchos::RCP< const Thyra::VectorSpaceBase<Scalar> > domain_;
00120   Teuchos::RCP< const Thyra::VectorSpaceBase<Scalar> > range_;
00121 }; 
00122 }
00123 
00124 #endif

Site Contact