Thyra_VectorSpaceBase.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_HPP
00030 #define THYRA_VECTOR_SPACE_BASE_HPP
00031 
00032 #include "Thyra_VectorSpaceBaseDecl.hpp"
00033 #include "Thyra_VectorBase.hpp"
00034 #include "Thyra_VectorStdOps.hpp"
00035 #include "Thyra_MultiVectorStdOps.hpp"
00036 
00037 namespace Thyra {
00038 
00039 // Virtual functions with default implementations
00040 
00041 template<class Scalar>
00042 bool VectorSpaceBase<Scalar>::isEuclidean() const
00043 {
00044   return false;
00045 }
00046 
00047 template<class Scalar>
00048 bool VectorSpaceBase<Scalar>::hasInCoreView(const Range1D& rng, const EViewType viewType, const EStrideType strideType) const
00049 {
00050   return false;
00051 }
00052 
00053 template<class Scalar>
00054 Teuchos::RefCountPtr< const VectorSpaceBase<Scalar> >
00055 VectorSpaceBase<Scalar>::clone() const
00056 {
00057   return Teuchos::null;
00058 }
00059 
00060 } // end namespace Thyra
00061 
00062 // Nonmember functions
00063 
00064 template<class Scalar>
00065 Teuchos::RefCountPtr<const Thyra::VectorSpaceBase<Scalar> >
00066 Thyra::makeHaveOwnership( const Teuchos::RefCountPtr<const VectorSpaceBase<Scalar> > &vs )
00067 {
00068   if( vs.has_ownership() ) return vs;
00069   Teuchos::RefCountPtr<const Thyra::VectorSpaceBase<Scalar> > _vs = vs->clone();
00070   TEST_FOR_EXCEPTION(
00071     _vs.get() == NULL, std::logic_error
00072     ,"Thyra::makeHaveOwnership(vs): Error, the concrete VectorSpaceBase object identified as \'"
00073     << vs->description() << "\' does not support the clone() function!"
00074     );
00075   return _vs;
00076 }
00077 
00078 template<class Scalar>
00079 Teuchos::RefCountPtr< Thyra::VectorBase<Scalar> >
00080 Thyra::createMember( const Teuchos::RefCountPtr<const VectorSpaceBase<Scalar> > &vs )
00081 {
00082   Teuchos::RefCountPtr<VectorBase<Scalar> > v = vs->createMember();
00083 #ifdef THYRA_INITIALIZE_VECS_MULTIVECS_WITH_NANS
00084   assign(&*v,Teuchos::ScalarTraits<Scalar>::nan());
00085 #endif  
00086   Teuchos::set_extra_data( makeHaveOwnership(vs), "VectorSpaceBase", &v );
00087   return v;
00088 }
00089   
00090 template<class Scalar>
00091 Teuchos::RefCountPtr< Thyra::VectorBase<Scalar> >
00092 Thyra::createMember( const VectorSpaceBase<Scalar> &vs )
00093 {
00094   return createMember(Teuchos::rcp(&vs,false));
00095 }
00096 
00097 template<class Scalar>
00098 Teuchos::RefCountPtr< Thyra::MultiVectorBase<Scalar> >
00099 Thyra::createMembers( const Teuchos::RefCountPtr<const VectorSpaceBase<Scalar> > &vs, int numMembers )
00100 {
00101   Teuchos::RefCountPtr<MultiVectorBase<Scalar> > mv = vs->createMembers(numMembers);
00102 #ifdef THYRA_INITIALIZE_VECS_MULTIVECS_WITH_NANS
00103   assign(&*mv,Teuchos::ScalarTraits<Scalar>::nan());
00104 #endif  
00105   Teuchos::set_extra_data( makeHaveOwnership(vs), "VectorSpaceBase", &mv );
00106   return mv;
00107 }
00108 
00109 template<class Scalar>
00110 Teuchos::RefCountPtr< Thyra::MultiVectorBase<Scalar> >
00111 Thyra::createMembers( const VectorSpaceBase<Scalar> &vs, int numMembers )
00112 {
00113   return createMembers(Teuchos::rcp(&vs,false),numMembers);
00114 }
00115 
00116 template<class Scalar>
00117 Teuchos::RefCountPtr<Thyra::VectorBase<Scalar> >
00118 Thyra::createMemberView( const Teuchos::RefCountPtr<const VectorSpaceBase<Scalar> > &vs, const RTOpPack::SubVectorView<Scalar> &raw_v )
00119 {
00120   Teuchos::RefCountPtr<VectorBase<Scalar> > v = vs->createMemberView(raw_v);
00121   Teuchos::set_extra_data( makeHaveOwnership(vs), "VectorSpaceBase", &v );
00122   return v;
00123 }
00124 
00125 template<class Scalar>
00126 Teuchos::RefCountPtr<Thyra::VectorBase<Scalar> >
00127 Thyra::createMemberView( const VectorSpaceBase<Scalar> &vs, const RTOpPack::SubVectorView<Scalar> &raw_v )
00128 {
00129   return createMemberView(Teuchos::rcp(&vs,false),raw_v);
00130 }
00131 
00132 template<class Scalar>
00133 Teuchos::RefCountPtr<const Thyra::VectorBase<Scalar> >
00134 Thyra::createMemberView( const Teuchos::RefCountPtr<const VectorSpaceBase<Scalar> > &vs, const RTOpPack::ConstSubVectorView<Scalar> &raw_v )
00135 {
00136   Teuchos::RefCountPtr<const VectorBase<Scalar> > v = vs->createMemberView(raw_v);
00137   Teuchos::set_extra_data( makeHaveOwnership(vs), "VectorSpaceBase", &v );
00138   return v;
00139 }
00140 
00141 template<class Scalar>
00142 Teuchos::RefCountPtr<const Thyra::VectorBase<Scalar> >
00143 Thyra::createMemberView( const VectorSpaceBase<Scalar> &vs, const RTOpPack::ConstSubVectorView<Scalar> &raw_v )
00144 {
00145   return createMemberView(Teuchos::rcp(&vs,false),raw_v);
00146 }
00147 
00148 template<class Scalar>
00149 Teuchos::RefCountPtr<Thyra::MultiVectorBase<Scalar> >
00150 Thyra::createMembersView(  const Teuchos::RefCountPtr<const VectorSpaceBase<Scalar> > &vs, const RTOpPack::SubMultiVectorView<Scalar> &raw_mv )
00151 {
00152   Teuchos::RefCountPtr<MultiVectorBase<Scalar> > mv = vs->createMembersView(raw_mv);
00153   Teuchos::set_extra_data( makeHaveOwnership(vs), "VectorSpaceBase", &mv );
00154   return mv;
00155 }
00156 
00157 template<class Scalar>
00158 Teuchos::RefCountPtr<Thyra::MultiVectorBase<Scalar> >
00159 Thyra::createMembersView(  const VectorSpaceBase<Scalar> &vs, const RTOpPack::SubMultiVectorView<Scalar> &raw_mv )
00160 {
00161   return createMembersView(Teuchos::rcp(&vs,false),raw_mv);
00162 }
00163 
00164 template<class Scalar>
00165 Teuchos::RefCountPtr<const Thyra::MultiVectorBase<Scalar> >
00166 Thyra::createMembersView( const Teuchos::RefCountPtr<const VectorSpaceBase<Scalar> > &vs, const RTOpPack::ConstSubMultiVectorView<Scalar> &raw_mv )
00167 {
00168   Teuchos::RefCountPtr<const MultiVectorBase<Scalar> > mv = vs->createMembersView(raw_mv);
00169   Teuchos::set_extra_data( makeHaveOwnership(vs), "VectorSpaceBase", &mv );
00170   return mv;
00171 }
00172 
00173 template<class Scalar>
00174 Teuchos::RefCountPtr<const Thyra::MultiVectorBase<Scalar> >
00175 Thyra::createMembersView( const VectorSpaceBase<Scalar> &vs, const RTOpPack::ConstSubMultiVectorView<Scalar> &raw_mv )
00176 {
00177   return createMembersView(Teuchos::rcp(&vs,false),raw_mv);
00178 }
00179 
00180 #endif // THYRA_VECTOR_SPACE_BASE_HPP

Generated on Thu Sep 18 12:32:11 2008 for Fundamental Thyra ANA Operator/Vector Interfaces by doxygen 1.3.9.1