Thyra_VectorSpaceBaseDecl.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_SPACE_BASE_DECL_HPP
00030 #define THYRA_VECTOR_SPACE_BASE_DECL_HPP
00031 
00032 #include "Thyra_OperatorVectorTypes.hpp"
00033 #include "Teuchos_Describable.hpp"
00034 
00035 namespace Thyra {
00036 
00048 
00049 
00055 template<class Scalar>
00056 Teuchos::RefCountPtr<const VectorSpaceBase<Scalar> >
00057 makeHaveOwnership( const Teuchos::RefCountPtr<const VectorSpaceBase<Scalar> > &vs );
00058 
00065 template<class Scalar>
00066 Teuchos::RefCountPtr< VectorBase<Scalar> >
00067 createMember( const Teuchos::RefCountPtr<const VectorSpaceBase<Scalar> > &vs );
00068 
00072 template<class Scalar>
00073 Teuchos::RefCountPtr< VectorBase<Scalar> >
00074 createMember( const VectorSpaceBase<Scalar> &vs );
00075 
00082 template<class Scalar>
00083 Teuchos::RefCountPtr< MultiVectorBase<Scalar> >
00084 createMembers( const Teuchos::RefCountPtr<const VectorSpaceBase<Scalar> > &vs, int numMembers );
00085 
00089 template<class Scalar>
00090 Teuchos::RefCountPtr< MultiVectorBase<Scalar> >
00091 createMembers( const VectorSpaceBase<Scalar> &vs, int numMembers );
00092 
00099 template<class Scalar>
00100 Teuchos::RefCountPtr<VectorBase<Scalar> >
00101 createMemberView( const Teuchos::RefCountPtr<const VectorSpaceBase<Scalar> > &vs, const RTOpPack::MutableSubVectorT<Scalar> &raw_v );
00102 
00106 template<class Scalar>
00107 Teuchos::RefCountPtr<VectorBase<Scalar> >
00108 createMemberView( const VectorSpaceBase<Scalar> &vs, const RTOpPack::MutableSubVectorT<Scalar> &raw_v );
00109 
00116 template<class Scalar>
00117 Teuchos::RefCountPtr<const VectorBase<Scalar> >
00118 createMemberView( const Teuchos::RefCountPtr<const VectorSpaceBase<Scalar> > &vs, const RTOpPack::SubVectorT<Scalar> &raw_v );
00119 
00123 template<class Scalar>
00124 Teuchos::RefCountPtr<const VectorBase<Scalar> >
00125 createMemberView( const VectorSpaceBase<Scalar> &vs, const RTOpPack::SubVectorT<Scalar> &raw_v );
00126 
00133 template<class Scalar>
00134 Teuchos::RefCountPtr<MultiVectorBase<Scalar> >
00135 createMembersView( const Teuchos::RefCountPtr<const VectorSpaceBase<Scalar> > &vs, const RTOpPack::MutableSubMultiVectorT<Scalar> &raw_mv );
00136 
00140 template<class Scalar>
00141 Teuchos::RefCountPtr<MultiVectorBase<Scalar> >
00142 createMembersView( const VectorSpaceBase<Scalar> &vs, const RTOpPack::MutableSubMultiVectorT<Scalar> &raw_mv );
00143 
00150 template<class Scalar>
00151 Teuchos::RefCountPtr<const MultiVectorBase<Scalar> >
00152 createMembersView( const Teuchos::RefCountPtr<const VectorSpaceBase<Scalar> > &vs, const RTOpPack::SubMultiVectorT<Scalar> &raw_mv );
00153 
00157 template<class Scalar>
00158 Teuchos::RefCountPtr<const MultiVectorBase<Scalar> >
00159 createMembersView( const VectorSpaceBase<Scalar> &vs, const RTOpPack::SubMultiVectorT<Scalar> &raw_mv );
00160 
00162 
00214 template<class Scalar>
00215 class VectorSpaceBase : virtual public Teuchos::Describable {
00216 public:
00217 
00220 
00226   virtual Index dim() const = 0;
00227 
00246   virtual bool isCompatible( const VectorSpaceBase<Scalar>& vecSpc ) const = 0;
00247 
00255   virtual Teuchos::RefCountPtr< const VectorSpaceFactoryBase<Scalar> > smallVecSpcFcty() const = 0;
00256 
00268   virtual Scalar scalarProd( const VectorBase<Scalar>& x, const VectorBase<Scalar>& y ) const = 0;
00269 
00288   virtual void scalarProds( const MultiVectorBase<Scalar>& X, const MultiVectorBase<Scalar>& Y, Scalar scalar_prods[] ) const = 0;
00289 
00291 
00294 
00304   virtual bool isInCore() const;
00305 
00317   virtual Teuchos::RefCountPtr< const VectorSpaceBase<Scalar> > clone() const;
00318 
00320 
00321 #ifndef DOXYGEN_COMPILE
00322 
00323 #ifndef TEMPLATE_FRIENDS_NOT_SUPPORTED
00324 
00327 
00328   friend Teuchos::RefCountPtr< VectorBase<Scalar> >
00329   createMember<>( const Teuchos::RefCountPtr<const VectorSpaceBase<Scalar> > &vs );
00330 
00331   friend Teuchos::RefCountPtr< MultiVectorBase<Scalar> >
00332   createMembers<>( const Teuchos::RefCountPtr<const VectorSpaceBase<Scalar> > &vs, int numMembers );
00333 
00334   friend Teuchos::RefCountPtr<VectorBase<Scalar> >
00335   createMemberView<>( const Teuchos::RefCountPtr<const VectorSpaceBase<Scalar> > &vs, const RTOpPack::MutableSubVectorT<Scalar> &raw_v );
00336 
00337   friend Teuchos::RefCountPtr<const VectorBase<Scalar> >
00338   createMemberView<>( const Teuchos::RefCountPtr<const VectorSpaceBase<Scalar> > &vs, const RTOpPack::SubVectorT<Scalar> &raw_v );
00339 
00340   friend Teuchos::RefCountPtr<MultiVectorBase<Scalar> >
00341   createMembersView<>( const Teuchos::RefCountPtr<const VectorSpaceBase<Scalar> > &vs, const RTOpPack::MutableSubMultiVectorT<Scalar> &raw_mv );
00342 
00343   friend Teuchos::RefCountPtr<const MultiVectorBase<Scalar> >
00344   createMembersView<>( const Teuchos::RefCountPtr<const VectorSpaceBase<Scalar> > &vs, const RTOpPack::SubMultiVectorT<Scalar> &raw_mv );
00345 
00347 
00348 #endif // DOXYGEN_COMPILE
00349 
00350 #endif // TEMPLATE_FRIENDS_NOT_SUPPORTED
00351 
00352 #ifndef TEMPLATE_FRIENDS_NOT_SUPPORTED
00353 protected:
00354 #endif
00355 
00358 
00380   virtual Teuchos::RefCountPtr< VectorBase<Scalar> > createMember() const = 0;
00381 
00401   virtual Teuchos::RefCountPtr< MultiVectorBase<Scalar> > createMembers(int numMembers) const = 0;
00402 
00428   virtual Teuchos::RefCountPtr<VectorBase<Scalar> > createMemberView( const RTOpPack::MutableSubVectorT<Scalar> &raw_v ) const = 0;
00429 
00450   virtual Teuchos::RefCountPtr<const VectorBase<Scalar> > createMemberView( const RTOpPack::SubVectorT<Scalar> &raw_v ) const = 0;
00451 
00475   virtual Teuchos::RefCountPtr<MultiVectorBase<Scalar> > createMembersView( const RTOpPack::MutableSubMultiVectorT<Scalar> &raw_mv ) const = 0;
00476 
00497   virtual Teuchos::RefCountPtr<const MultiVectorBase<Scalar> > createMembersView( const RTOpPack::SubMultiVectorT<Scalar> &raw_mv ) const = 0;
00498 
00500 
00501 }; // end class VectorSpaceBase
00502 
00503 } // end namespace Thyra
00504 
00505 // Inline members
00506 
00507 template<class Scalar>
00508 inline Teuchos::RefCountPtr<const Thyra::VectorSpaceBase<Scalar> >
00509 Thyra::makeHaveOwnership( const Teuchos::RefCountPtr<const VectorSpaceBase<Scalar> > &vs )
00510 {
00511   if( vs.has_ownership() ) return vs;
00512   Teuchos::RefCountPtr<const Thyra::VectorSpaceBase<Scalar> > _vs = vs->clone();
00513   TEST_FOR_EXCEPTION(
00514     _vs.get() == NULL, std::logic_error
00515     ,"Thyra::makeHaveOwnership(vs): Error, the concrete VectorSpaceBase object identified as \'"
00516     << vs->description() << "\' does not support the clone() function!"
00517     );
00518   return _vs;
00519 }
00520 
00521 template<class Scalar>
00522 inline Teuchos::RefCountPtr< Thyra::VectorBase<Scalar> >
00523 Thyra::createMember( const Teuchos::RefCountPtr<const VectorSpaceBase<Scalar> > &vs )
00524 {
00525   Teuchos::RefCountPtr<VectorBase<Scalar> > v = vs->createMember();
00526   Teuchos::set_extra_data( makeHaveOwnership(vs), "VectorSpaceBase", &v );
00527   return v;
00528 }
00529   
00530 template<class Scalar>
00531 inline Teuchos::RefCountPtr< Thyra::VectorBase<Scalar> >
00532 Thyra::createMember( const VectorSpaceBase<Scalar> &vs )
00533 {
00534   return createMember(Teuchos::rcp(&vs,false));
00535 }
00536 
00537 template<class Scalar>
00538 inline Teuchos::RefCountPtr< Thyra::MultiVectorBase<Scalar> >
00539 Thyra::createMembers( const Teuchos::RefCountPtr<const VectorSpaceBase<Scalar> > &vs, int numMembers )
00540 {
00541   Teuchos::RefCountPtr<MultiVectorBase<Scalar> > mv = vs->createMembers(numMembers);
00542   Teuchos::set_extra_data( makeHaveOwnership(vs), "VectorSpaceBase", &mv );
00543   return mv;
00544 }
00545 
00546 template<class Scalar>
00547 inline Teuchos::RefCountPtr< Thyra::MultiVectorBase<Scalar> >
00548 Thyra::createMembers( const VectorSpaceBase<Scalar> &vs, int numMembers )
00549 {
00550   return createMembers(Teuchos::rcp(&vs,false),numMembers);
00551 }
00552 
00553 template<class Scalar>
00554 inline Teuchos::RefCountPtr<Thyra::VectorBase<Scalar> >
00555 Thyra::createMemberView( const Teuchos::RefCountPtr<const VectorSpaceBase<Scalar> > &vs, const RTOpPack::MutableSubVectorT<Scalar> &raw_v )
00556 {
00557   Teuchos::RefCountPtr<VectorBase<Scalar> > v = vs->createMemberView(raw_v);
00558   Teuchos::set_extra_data( makeHaveOwnership(vs), "VectorSpaceBase", &v );
00559   return v;
00560 }
00561 
00562 template<class Scalar>
00563 inline Teuchos::RefCountPtr<Thyra::VectorBase<Scalar> >
00564 Thyra::createMemberView( const VectorSpaceBase<Scalar> &vs, const RTOpPack::MutableSubVectorT<Scalar> &raw_v )
00565 {
00566   return createMemberView(Teuchos::rcp(&vs,false),raw_v);
00567 }
00568 
00569 template<class Scalar>
00570 inline Teuchos::RefCountPtr<const Thyra::VectorBase<Scalar> >
00571 Thyra::createMemberView( const Teuchos::RefCountPtr<const VectorSpaceBase<Scalar> > &vs, const RTOpPack::SubVectorT<Scalar> &raw_v )
00572 {
00573   Teuchos::RefCountPtr<const VectorBase<Scalar> > v = vs->createMemberView(raw_v);
00574   Teuchos::set_extra_data( makeHaveOwnership(vs), "VectorSpaceBase", &v );
00575   return v;
00576 }
00577 
00578 template<class Scalar>
00579 inline Teuchos::RefCountPtr<const Thyra::VectorBase<Scalar> >
00580 Thyra::createMemberView( const VectorSpaceBase<Scalar> &vs, const RTOpPack::SubVectorT<Scalar> &raw_v )
00581 {
00582   return createMemberView(Teuchos::rcp(&vs,false),raw_v);
00583 }
00584 
00585 template<class Scalar>
00586 inline Teuchos::RefCountPtr<Thyra::MultiVectorBase<Scalar> >
00587 Thyra::createMembersView(  const Teuchos::RefCountPtr<const VectorSpaceBase<Scalar> > &vs, const RTOpPack::MutableSubMultiVectorT<Scalar> &raw_mv )
00588 {
00589   Teuchos::RefCountPtr<MultiVectorBase<Scalar> > mv = vs->createMembersView(raw_mv);
00590   Teuchos::set_extra_data( makeHaveOwnership(vs), "VectorSpaceBase", &mv );
00591   return mv;
00592 }
00593 
00594 template<class Scalar>
00595 inline Teuchos::RefCountPtr<Thyra::MultiVectorBase<Scalar> >
00596 Thyra::createMembersView(  const VectorSpaceBase<Scalar> &vs, const RTOpPack::MutableSubMultiVectorT<Scalar> &raw_mv )
00597 {
00598   return createMembersView(Teuchos::rcp(&vs,false),raw_mv);
00599 }
00600 
00601 template<class Scalar>
00602 inline Teuchos::RefCountPtr<const Thyra::MultiVectorBase<Scalar> >
00603 Thyra::createMembersView( const Teuchos::RefCountPtr<const VectorSpaceBase<Scalar> > &vs, const RTOpPack::SubMultiVectorT<Scalar> &raw_mv )
00604 {
00605   Teuchos::RefCountPtr<const MultiVectorBase<Scalar> > mv = vs->createMembersView(raw_mv);
00606   Teuchos::set_extra_data( makeHaveOwnership(vs), "VectorSpaceBase", &mv );
00607   return mv;
00608 }
00609 
00610 template<class Scalar>
00611 inline Teuchos::RefCountPtr<const Thyra::MultiVectorBase<Scalar> >
00612 Thyra::createMembersView( const VectorSpaceBase<Scalar> &vs, const RTOpPack::SubMultiVectorT<Scalar> &raw_mv )
00613 {
00614   return createMembersView(Teuchos::rcp(&vs,false),raw_mv);
00615 }
00616 
00617 #endif  // THYRA_VECTOR_SPACE_BASE_DECL_HPP

Generated on Thu Sep 18 12:39:53 2008 for Thyra ANA Operator/VectorBase Interfaces and Related Software by doxygen 1.3.9.1