// @HEADER // ***************************************************************************** // Thyra: Interfaces and Support for Abstract Numerical Algorithms // // Copyright 2004 NTESS and the Thyra contributors. // SPDX-License-Identifier: BSD-3-Clause // ***************************************************************************** // @HEADER #ifndef THYRA_TPETRA_VECTOR_DECL_HPP #define THYRA_TPETRA_VECTOR_DECL_HPP #include "Thyra_SpmdVectorDefaultBase.hpp" #include "Thyra_TpetraVectorSpace_decl.hpp" #include "Tpetra_Vector.hpp" #include "Teuchos_ConstNonconstObjectContainer.hpp" namespace Thyra { /** \brief Concrete Thyra::SpmdVectorBase using Tpetra::Vector. * * \ingroup Tpetra_Thyra_Op_Vec_adapters_grp */ template class TpetraVector : virtual public SpmdVectorDefaultBase { public: /** @name Constructors/initializers */ //@{ /** \brief Construct to uninitialized. */ TpetraVector(); /** \brief Initialize. */ void initialize( const RCP > &tpetraVectorSpace, const RCP > &tpetraVector ); /** \brief Initialize. */ void constInitialize( const RCP > &tpetraVectorSpace, const RCP > &tpetraVector ); /** \brief Get the embedded non-const Tpetra::Vector. */ RCP > getTpetraVector(); /** \brief Get the embedded non-const Tpetra::Vector. */ RCP > getConstTpetraVector() const; //@} /** @name Overridden from VectorDefaultBase */ //@{ /** \brief . */ RCP > domain() const; //@} // Should these Impl functions should alsp be protected??? //protected: /** @name Overridden from SpmdMultiVectorBase */ //@{ /** \brief . */ RCP > spmdSpaceImpl() const; //@} /** @name Overridden from SpmdVectorBase */ //@{ /** \brief . */ void getNonconstLocalVectorDataImpl(const Ptr > &localValues); /** \brief . */ void getLocalVectorDataImpl(const Ptr > &localValues) const; //@} protected: /** @name Overridden protected functions from VectorBase */ //@{ /** \brief . */ virtual void randomizeImpl(Scalar l, Scalar u); /** \brief . */ virtual void absImpl(const VectorBase& x); /** \brief . */ virtual void reciprocalImpl(const VectorBase& x); /** \brief . */ virtual void eleWiseScaleImpl(const VectorBase& x); /** \brief . */ virtual typename Teuchos::ScalarTraits::magnitudeType norm2WeightedImpl(const VectorBase& x) const; /** \brief . */ virtual void applyOpImpl( const RTOpPack::RTOpT &op, const ArrayView > > &vecs, const ArrayView > > &targ_vecs, const Ptr &reduct_obj, const Ordinal global_offset ) const; /** \brief . */ void acquireDetachedVectorViewImpl( const Range1D& rng, RTOpPack::ConstSubVectorView* sub_vec ) const; /** \brief . */ void acquireNonconstDetachedVectorViewImpl( const Range1D& rng, RTOpPack::SubVectorView* sub_vec ); /** \brief . */ void commitNonconstDetachedVectorViewImpl( RTOpPack::SubVectorView* sub_vec ); //@} /** @name Overridden protected functions from MultiVectorBase */ //@{ /** \brief . */ virtual void assignImpl(Scalar alpha); /** \brief . */ virtual void assignMultiVecImpl(const MultiVectorBase& mv); /** \brief . */ virtual void scaleImpl(Scalar alpha); /** \brief . */ virtual void updateImpl( Scalar alpha, const MultiVectorBase& mv ); /** \brief . */ virtual void linearCombinationImpl( const ArrayView& alpha, const ArrayView > >& mv, const Scalar& beta ); /** \brief . */ virtual void dotsImpl( const MultiVectorBase& mv, const ArrayView& prods ) const; /** \brief . */ virtual void norms1Impl( const ArrayView::magnitudeType>& norms ) const; /** \brief . */ virtual void norms2Impl( const ArrayView::magnitudeType>& norms ) const; /** \brief . */ virtual void normsInfImpl( const ArrayView::magnitudeType>& norms ) const; //@} /** @name Overridden protected functions from LinearOpBase */ //@{ /** \brief . */ void applyImpl( const EOpTransp M_trans, const MultiVectorBase &X, const Ptr > &Y, const Scalar alpha, const Scalar beta ) const; //@} private: // /////////////////////////////////////// // Private data members RCP > tpetraVectorSpace_; mutable RCP > domainSpace_; Teuchos::ConstNonconstObjectContainer > tpetraVector_; typedef Tpetra::MultiVector TpetraMultiVector_t; // //////////////////////////////////// // Private member functions template void initializeImpl( const RCP > &tpetraVectorSpace, const RCP &tpetraVector ); // Non-throwing Tpetra Vector/MultiVector extraction methods. // Return null if casting failed. RCP > getTpetraMultiVector(const RCP >& mv) const; RCP > getConstTpetraMultiVector(const RCP >& mv) const; RCP > getTpetraVector(const RCP >& v) const; RCP > getConstTpetraVector(const RCP >& v) const; }; /** \brief Nonmember constructor for TpetraVector. * * \relates TpetraVector */ template inline RCP > tpetraVector( const RCP > &tpetraVectorSpace, const RCP > &tpetraVector ) { RCP > v = Teuchos::rcp(new TpetraVector); v->initialize(tpetraVectorSpace, tpetraVector); return v; } /** \brief Nonmember constructor for TpetraVector. * * \relates TpetraVector */ template inline RCP > constTpetraVector( const RCP > &tpetraVectorSpace, const RCP > &tpetraVector ) { RCP > v = Teuchos::rcp(new TpetraVector); v->constInitialize(tpetraVectorSpace, tpetraVector); return v; } } // end namespace Thyra #endif // THYRA_TPETRA_VECTOR_DECL_HPP