Debian Codegraph @

packages/thyra/adapters/tpetra/src/Thyra_TpetraVectorSpace_decl.hpp

raw
1 // @HEADER
2 // *****************************************************************************
3 // Thyra: Interfaces and Support for Abstract Numerical Algorithms
4 //
5 // Copyright 2004 NTESS and the Thyra contributors.
6 // SPDX-License-Identifier: BSD-3-Clause
7 // *****************************************************************************
8 // @HEADER
9
10 #ifndef THYRA_TPETRA_VECTOR_SPACE_DECL_HPP
11 #define THYRA_TPETRA_VECTOR_SPACE_DECL_HPP
12
13
14 #include "Thyra_SpmdVectorSpaceDefaultBase.hpp"
15 #include "Tpetra_Map.hpp"
16 #include "Tpetra_MultiVector.hpp"
17
18
19 namespace Thyra {
20
21
22 /** \brief Concrete implementation of an SPMD vector space for Tpetra.
23 *
24 * \ingroup Tpetra_Thyra_Op_Vec_adapters_grp
25 */
26 template <class Scalar, class LocalOrdinal, class GlobalOrdinal, class Node>
27 class TpetraVectorSpace : public SpmdVectorSpaceDefaultBase<Scalar>
28 {
29 public:
30
31 /** \brief . */
32 typedef TpetraVectorSpace<Scalar,LocalOrdinal,GlobalOrdinal,Node> this_t;
33
34 /** @name Constructors and initializers */
35 //@{
36
37 /** \brief Create with weak ownership to self. */
38 static RCP<TpetraVectorSpace<Scalar,LocalOrdinal,GlobalOrdinal,Node> > create();
39
40 /** \brief Initialize a serial space. */
41 void initialize(
42 const RCP<const Tpetra::Map<LocalOrdinal,GlobalOrdinal,Node> > &tpetraMap
43 );
44
45 //@}
46
47 //! \name Utility functions
48 //@{
49
50 /** \brief Create Tpetra locally replicated vector space.
51 *
52 * This vector space forms the domain space of a Thyra::TpetraMultiVector.
53 */
54 RCP<TpetraVectorSpace<Scalar,LocalOrdinal,GlobalOrdinal,Node>>
55 createLocallyReplicatedVectorSpace(int size) const;
56
57 //@}
58
59 /** @name Public overridden from VectorSpaceBase */
60 //@{
61 /** \brief Returns true if all the elements in <tt>rng</tt> are in this
62 * process.
63 */
64 bool hasInCoreView(
65 const Range1D& rng, const EViewType viewType, const EStrideType strideType
66 ) const;
67 /** \brief . */
68 RCP< const VectorSpaceBase<Scalar> > clone() const;
69
70 /** \brief Get the embedded Tpetra::Map. */
71 RCP<const Tpetra::Map<LocalOrdinal,GlobalOrdinal,Node> >
72 getTpetraMap() const;
73
74 //@}
75
76 protected:
77
78 /** @name Protected overridden from VectorSpaceBase */
79 //@{
80
81 /** \brief . */
82 RCP<VectorBase<Scalar> >
83 createMember() const;
84 /** \brief . */
85 RCP<MultiVectorBase<Scalar> >
86 createMembers(int numMembers) const;
87
88 public:
89
90 RCP<MultiVectorBase<Scalar> >
91 createCachedMembersView( const RTOpPack::SubMultiVectorView<Scalar> &raw_mv, bool initialize = true) const;
92
93 RCP<const MultiVectorBase<Scalar> >
94 createCachedMembersView( const RTOpPack::ConstSubMultiVectorView<Scalar> &raw_mv ) const;
95
96 //@}
97
98 public:
99
100 /** @name Public overridden from SpmdVectorSpaceDefaultBase */
101 //@{
102
103 /** \brief . */
104 RCP<const Teuchos::Comm<Ordinal> > getComm() const;
105 /** \brief . */
106 Ordinal localSubDim() const;
107
108 //@}
109
110 private:
111
112 // //////////////////////////////////////
113 // Private data members
114
115 RCP<const Tpetra::Map<LocalOrdinal,GlobalOrdinal,Node> > tpetraMap_;
116 mutable RCP<TpetraVectorSpace<Scalar,LocalOrdinal,GlobalOrdinal,Node> > tpetraDomainSpace_;
117 mutable RCP<Tpetra::MultiVector<Scalar,LocalOrdinal,GlobalOrdinal,Node> > tpetraMV_;
118 // The only reason Thyra needs this comm_ object is because Thyra
119 // uses Ordinal as the Comm template parameter, while Tpetra uses
120 // int. Ordinal is some 64-bit type, which doesn't make any sense,
121 // given that MPI implementations currently only allow 32-bit
122 // process ranks. This is why Thyra does not just use the Map's
123 // stored communicator.
124 RCP<const Teuchos::Comm<Ordinal> > comm_;
125 RCP<this_t> weakSelfPtr_;
126
127 // /////////////////////////////////////
128 // Private member functions
129
130 TpetraVectorSpace();
131
132 }; // end class TpetraVectorSpace
133
134
135 /** \brief Nonmember constructor that creats a serial vector space.
136 *
137 * \relates TpetraVectorSpace
138 */
139 template <class Scalar, class LocalOrdinal, class GlobalOrdinal, class Node>
140 RCP<TpetraVectorSpace<Scalar,LocalOrdinal,GlobalOrdinal,Node> >
141 tpetraVectorSpace(
142 const RCP<const Tpetra::Map<LocalOrdinal,GlobalOrdinal,Node> > &tpetraMap
143 )
144 {
145 RCP<TpetraVectorSpace<Scalar,LocalOrdinal,GlobalOrdinal,Node> > vs =
146 TpetraVectorSpace<Scalar,LocalOrdinal,GlobalOrdinal,Node>::create();
147 vs->initialize(tpetraMap);
148 return vs;
149 }
150
151
152 } // end namespace Thyra
153
154
155 #endif // THYRA_TPETRA_VECTOR_SPACE_DECL_HPP