// @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_SPACE_DECL_HPP #define THYRA_TPETRA_VECTOR_SPACE_DECL_HPP #include "Thyra_SpmdVectorSpaceDefaultBase.hpp" #include "Tpetra_Map.hpp" #include "Tpetra_MultiVector.hpp" namespace Thyra { /** \brief Concrete implementation of an SPMD vector space for Tpetra. * * \ingroup Tpetra_Thyra_Op_Vec_adapters_grp */ template class TpetraVectorSpace : public SpmdVectorSpaceDefaultBase { public: /** \brief . */ typedef TpetraVectorSpace this_t; /** @name Constructors and initializers */ //@{ /** \brief Create with weak ownership to self. */ static RCP > create(); /** \brief Initialize a serial space. */ void initialize( const RCP > &tpetraMap ); //@} //! \name Utility functions //@{ /** \brief Create Tpetra locally replicated vector space. * * This vector space forms the domain space of a Thyra::TpetraMultiVector. */ RCP> createLocallyReplicatedVectorSpace(int size) const; //@} /** @name Public overridden from VectorSpaceBase */ //@{ /** \brief Returns true if all the elements in rng are in this * process. */ bool hasInCoreView( const Range1D& rng, const EViewType viewType, const EStrideType strideType ) const; /** \brief . */ RCP< const VectorSpaceBase > clone() const; /** \brief Get the embedded Tpetra::Map. */ RCP > getTpetraMap() const; //@} protected: /** @name Protected overridden from VectorSpaceBase */ //@{ /** \brief . */ RCP > createMember() const; /** \brief . */ RCP > createMembers(int numMembers) const; public: RCP > createCachedMembersView( const RTOpPack::SubMultiVectorView &raw_mv, bool initialize = true) const; RCP > createCachedMembersView( const RTOpPack::ConstSubMultiVectorView &raw_mv ) const; //@} public: /** @name Public overridden from SpmdVectorSpaceDefaultBase */ //@{ /** \brief . */ RCP > getComm() const; /** \brief . */ Ordinal localSubDim() const; //@} private: // ////////////////////////////////////// // Private data members RCP > tpetraMap_; mutable RCP > tpetraDomainSpace_; mutable RCP > tpetraMV_; // The only reason Thyra needs this comm_ object is because Thyra // uses Ordinal as the Comm template parameter, while Tpetra uses // int. Ordinal is some 64-bit type, which doesn't make any sense, // given that MPI implementations currently only allow 32-bit // process ranks. This is why Thyra does not just use the Map's // stored communicator. RCP > comm_; RCP weakSelfPtr_; // ///////////////////////////////////// // Private member functions TpetraVectorSpace(); }; // end class TpetraVectorSpace /** \brief Nonmember constructor that creats a serial vector space. * * \relates TpetraVectorSpace */ template RCP > tpetraVectorSpace( const RCP > &tpetraMap ) { RCP > vs = TpetraVectorSpace::create(); vs->initialize(tpetraMap); return vs; } } // end namespace Thyra #endif // THYRA_TPETRA_VECTOR_SPACE_DECL_HPP