Thyra_VectorBaseDecl.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_VECTOR_BASE_DECL_HPP
00030 #define THYRA_VECTOR_BASE_DECL_HPP
00031 
00032 #include "Thyra_OperatorVectorTypes.hpp"
00033 #include "Thyra_MultiVectorBaseDecl.hpp"
00034 #include "RTOpPack_RTOpT.hpp"
00035 
00036 namespace Thyra {
00037 
00128 template<class Scalar>
00129 class VectorBase : virtual public MultiVectorBase<Scalar>
00130 {
00131 public:
00132 
00134   using MultiVectorBase<Scalar>::col;
00135 
00138 
00155   virtual RCP< const VectorSpaceBase<Scalar> > space() const = 0;
00156 
00158 
00161 
00178   virtual void applyOp(
00179     const RTOpPack::RTOpT<Scalar> &op,
00180     const int num_vecs,
00181     const VectorBase<Scalar>*const vecs[],
00182     const int num_targ_vecs,
00183     VectorBase<Scalar>*const targ_vecs[],
00184     RTOpPack::ReductTarget *reduct_obj,
00185     const Index first_ele_offset,
00186     const Index sub_dim,
00187     const Index global_offset
00188     ) const = 0;
00189 
00191 
00194 
00209   virtual RCP<VectorBase<Scalar> > clone_v() const = 0;
00210 
00212 
00214   void acquireDetachedView(
00215     const Range1D& rng, RTOpPack::ConstSubVectorView<Scalar>* sub_vec
00216     ) const
00217     {
00218       acquireDetachedVectorViewImpl(rng,sub_vec);
00219     }
00220 
00223 
00264   virtual void acquireDetachedVectorViewImpl(
00265     const Range1D& rng, RTOpPack::ConstSubVectorView<Scalar>* sub_vec
00266     ) const = 0;
00267 
00269   void releaseDetachedView(
00270     RTOpPack::ConstSubVectorView<Scalar>* sub_vec
00271     ) const
00272     {
00273       releaseDetachedVectorViewImpl(sub_vec);
00274     }
00275 
00295   virtual void releaseDetachedVectorViewImpl(
00296     RTOpPack::ConstSubVectorView<Scalar>* sub_vec
00297     ) const = 0;
00298 
00300   void acquireDetachedView(
00301     const Range1D& rng, RTOpPack::SubVectorView<Scalar>* sub_vec
00302     )
00303     {
00304       acquireNonconstDetachedVectorViewImpl(rng,sub_vec);
00305     }
00306 
00354   virtual void acquireNonconstDetachedVectorViewImpl(
00355     const Range1D& rng, RTOpPack::SubVectorView<Scalar>* sub_vec
00356     ) = 0;
00357 
00359   void commitDetachedView(
00360     RTOpPack::SubVectorView<Scalar>* sub_vec
00361     )
00362     {
00363       commitNonconstDetachedVectorViewImpl(sub_vec);
00364     }
00365 
00389   virtual void commitNonconstDetachedVectorViewImpl(
00390     RTOpPack::SubVectorView<Scalar>* sub_vec
00391     ) = 0;
00392 
00416   virtual void setSubVector(
00417     const RTOpPack::SparseSubVectorT<Scalar>& sub_vec
00418     ) = 0;
00419 
00421 
00422 }; // end class VectorBase
00423 
00508 template<class Scalar>
00509 inline
00510 void applyOp(
00511   const RTOpPack::RTOpT<Scalar> &op,
00512   const int num_vecs,
00513   const VectorBase<Scalar>*const vecs[],
00514   const int num_targ_vecs,
00515   VectorBase<Scalar>*const targ_vecs[],
00516   RTOpPack::ReductTarget *reduct_obj,
00517   const Index first_ele_offset = 0,
00518   const Index sub_dim = -1,
00519   const Index global_offset = 0
00520   )
00521 {
00522   if(num_vecs)
00523     vecs[0]->applyOp(
00524       op,num_vecs,vecs,num_targ_vecs,targ_vecs,reduct_obj,
00525       first_ele_offset,sub_dim,global_offset);
00526   else if (num_targ_vecs)
00527     targ_vecs[0]->applyOp(op,num_vecs,vecs,num_targ_vecs,targ_vecs,
00528       reduct_obj,first_ele_offset,sub_dim,global_offset);
00529 }
00530 
00531 } // end namespace Thyra
00532 
00533 #endif  // THYRA_VECTOR_BASE_DECL_HPP

Generated on Tue Oct 20 12:46:45 2009 for Fundamental Thyra ANA Operator/Vector Interfaces by doxygen 1.4.7