Thyra  Version of the Day
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Thyra_TpetraMultiVector_decl.hpp
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_MULTIVECTOR_DECL_HPP
11 #define THYRA_TPETRA_MULTIVECTOR_DECL_HPP
12 
13 #include "Thyra_SpmdMultiVectorDefaultBase.hpp"
14 #include "Thyra_TpetraVectorSpace_decl.hpp"
15 #include "Tpetra_MultiVector.hpp"
16 #include "Teuchos_ConstNonconstObjectContainer.hpp"
17 
18 
19 namespace Thyra {
20 
21 
29 template <class Scalar, class LocalOrdinal, class GlobalOrdinal, class Node>
31  : virtual public SpmdMultiVectorDefaultBase<Scalar>
32 {
33 public:
34 
37 
40 
43  void initialize(
44  const RCP<const TpetraVectorSpace<Scalar,LocalOrdinal,GlobalOrdinal,Node> > &tpetraVectorSpace,
45  const RCP<const ScalarProdVectorSpaceBase<Scalar> > &domainSpace,
47  );
48 
51  void constInitialize(
52  const RCP<const TpetraVectorSpace<Scalar,LocalOrdinal,GlobalOrdinal,Node> > &tpetraVectorSpace,
53  const RCP<const ScalarProdVectorSpaceBase<Scalar> > &domainSpace,
55  );
56 
60 
64 
66 
71  domainScalarProdVecSpc() const;
73 
74 protected:
75 
79  virtual void assignImpl(Scalar alpha);
80 
82  virtual void assignMultiVecImpl(const MultiVectorBase<Scalar>& mv);
83 
85  virtual void scaleImpl(Scalar alpha);
86 
88  virtual void updateImpl(
89  Scalar alpha,
90  const MultiVectorBase<Scalar>& mv
91  );
92 
94  virtual void linearCombinationImpl(
95  const ArrayView<const Scalar>& alpha,
96  const ArrayView<const Ptr<const MultiVectorBase<Scalar> > >& mv,
97  const Scalar& beta
98  );
99 
101  virtual void dotsImpl(
102  const MultiVectorBase<Scalar>& mv,
103  const ArrayView<Scalar>& prods
104  ) const;
105 
107  virtual void norms1Impl(
109  ) const;
110 
112  virtual void norms2Impl(
114  ) const;
115 
117  virtual void normsInfImpl(
119  ) const;
120 
125 
128  contigSubViewImpl(const Range1D& colRng) const;
131  nonconstContigSubViewImpl(const Range1D& colRng);
134  nonContigSubViewImpl(const ArrayView<const int>& cols_in) const;
138 
140  virtual void mvMultiReductApplyOpImpl(
141  const RTOpPack::RTOpT<Scalar> &primary_op,
142  const ArrayView<const Ptr<const MultiVectorBase<Scalar> > > &multi_vecs,
143  const ArrayView<const Ptr<MultiVectorBase<Scalar> > > &targ_multi_vecs,
144  const ArrayView<const Ptr<RTOpPack::ReductTarget> > &reduct_objs,
145  const Ordinal primary_global_offset
146  ) const;
147 
150  const Range1D &rowRng,
151  const Range1D &colRng,
153  ) const;
154 
157  const Range1D &rowRng,
158  const Range1D &colRng,
160  );
161 
165  );
166 
167 // /** \brief . */
168 // RCP<const MultiVectorBase<Scalar> >
169 // nonContigSubViewImpl( const ArrayView<const int> &cols ) const;
170 // /** \brief . */
171 // RCP<MultiVectorBase<Scalar> >
172 // nonconstNonContigSubViewImpl( const ArrayView<const int> &cols );
174 
181  const Ptr<ArrayRCP<Scalar> > &localValues, const Ptr<Ordinal> &leadingDim
182  );
185  const Ptr<ArrayRCP<const Scalar> > &localValues, const Ptr<Ordinal> &leadingDim
186  ) const;
187 
189 
193  virtual void euclideanApply(
194  const EOpTransp M_trans,
195  const MultiVectorBase<Scalar> &X,
196  const Ptr<MultiVectorBase<Scalar> > &Y,
197  const Scalar alpha,
198  const Scalar beta
199  ) const;
200 
202 
203 private:
204 
205  // ///////////////////////////////////////
206  // Private data members
207 
211  tpetraMultiVector_;
212 
213  // ////////////////////////////////////
214  // Private member functions
215 
216  template<class TpetraMultiVector_t>
217  void initializeImpl(
218  const RCP<const TpetraVectorSpace<Scalar,LocalOrdinal,GlobalOrdinal,Node> > &tpetraVectorSpace,
219  const RCP<const ScalarProdVectorSpaceBase<Scalar> > &domainSpace,
221  );
222 
223  // Non-throwing Tpetra MultiVector extraction methods.
224  // Return null if casting failed.
227 
229  getConstTpetraMultiVector(const RCP<const MultiVectorBase<Scalar> >& mv) const;
230 
231 };
232 
233 
238 template <class Scalar, class LocalOrdinal, class GlobalOrdinal, class Node>
241  const RCP<const TpetraVectorSpace<Scalar,LocalOrdinal,GlobalOrdinal,Node> > &tpetraVectorSpace,
242  const RCP<const ScalarProdVectorSpaceBase<Scalar> > &domainSpace,
244  )
245 {
248  tmv->initialize(tpetraVectorSpace, domainSpace, tpetraMultiVector);
249  return tmv;
250 }
251 
252 
257 template <class Scalar, class LocalOrdinal, class GlobalOrdinal, class Node>
260  const RCP<const TpetraVectorSpace<Scalar,LocalOrdinal,GlobalOrdinal,Node> > &tpetraVectorSpace,
261  const RCP<const ScalarProdVectorSpaceBase<Scalar> > &domainSpace,
263  )
264 {
267  tmv->constInitialize(tpetraVectorSpace, domainSpace, tpetraMultiVector);
268  return tmv;
269 }
270 
271 
272 } // end namespace Thyra
273 
274 
275 #endif // THYRA_TPETRA_MULTIVECTOR_DECL_HPP
virtual void updateImpl(Scalar alpha, const MultiVectorBase< Scalar > &mv)
Concrete implementation of Thyra::MultiVector in terms of Tpetra::MultiVector.
TpetraMultiVector()
Construct to uninitialized.
RCP< const VectorBase< Scalar > > colImpl(Ordinal j) const
void getNonconstLocalMultiVectorDataImpl(const Ptr< ArrayRCP< Scalar > > &localValues, const Ptr< Ordinal > &leadingDim)
Concrete implementation of an SPMD vector space for Tpetra.
RCP< Tpetra::MultiVector< Scalar, LocalOrdinal, GlobalOrdinal, Node > > getTpetraMultiVector()
Extract the underlying non-const Tpetra::MultiVector object.
virtual void assignImpl(Scalar alpha)
EOpTransp
Enumeration for determining how a linear operator is applied. `*.
RCP< MultiVectorBase< Scalar > > nonconstContigSubViewImpl(const Range1D &colRng)
virtual void euclideanApply(const EOpTransp M_trans, const MultiVectorBase< Scalar > &X, const Ptr< MultiVectorBase< Scalar > > &Y, const Scalar alpha, const Scalar beta) const
Base node implementation class for SPMD multi-vectors.
RCP< const MultiVectorBase< Scalar > > nonContigSubViewImpl(const ArrayView< const int > &cols_in) const
RCP< TpetraMultiVector< Scalar, LocalOrdinal, GlobalOrdinal, Node > > tpetraMultiVector(const RCP< const TpetraVectorSpace< Scalar, LocalOrdinal, GlobalOrdinal, Node > > &tpetraVectorSpace, const RCP< const ScalarProdVectorSpaceBase< Scalar > > &domainSpace, const RCP< Tpetra::MultiVector< Scalar, LocalOrdinal, GlobalOrdinal, Node > > &tpetraMultiVector)
Nonmember constructor for non-const TpetraMultiVector.
void initialize(const RCP< const TpetraVectorSpace< Scalar, LocalOrdinal, GlobalOrdinal, Node > > &tpetraVectorSpace, const RCP< const ScalarProdVectorSpaceBase< Scalar > > &domainSpace, const RCP< Tpetra::MultiVector< Scalar, LocalOrdinal, GlobalOrdinal, Node > > &tpetraMultiVector)
Initialize.
virtual void scaleImpl(Scalar alpha)
TEUCHOS_DEPRECATED RCP< T > rcp(T *p, Dealloc_T dealloc, bool owns_mem)
Teuchos::Ordinal Ordinal
Type for the dimension of a vector space. `*.
RCP< const MultiVectorBase< Scalar > > contigSubViewImpl(const Range1D &colRng) const
virtual void mvMultiReductApplyOpImpl(const RTOpPack::RTOpT< Scalar > &primary_op, const ArrayView< const Ptr< const MultiVectorBase< Scalar > > > &multi_vecs, const ArrayView< const Ptr< MultiVectorBase< Scalar > > > &targ_multi_vecs, const ArrayView< const Ptr< RTOpPack::ReductTarget > > &reduct_objs, const Ordinal primary_global_offset) const
Interface for a collection of column vectors called a multi-vector.
RCP< const TpetraMultiVector< Scalar, LocalOrdinal, GlobalOrdinal, Node > > constTpetraMultiVector(const RCP< const TpetraVectorSpace< Scalar, LocalOrdinal, GlobalOrdinal, Node > > &tpetraVectorSpace, const RCP< const ScalarProdVectorSpaceBase< Scalar > > &domainSpace, const RCP< const Tpetra::MultiVector< Scalar, LocalOrdinal, GlobalOrdinal, Node > > &tpetraMultiVector)
Nonmember constructor for const TpetraMultiVector.
RCP< MultiVectorBase< Scalar > > nonconstNonContigSubViewImpl(const ArrayView< const int > &cols_in)
void constInitialize(const RCP< const TpetraVectorSpace< Scalar, LocalOrdinal, GlobalOrdinal, Node > > &tpetraVectorSpace, const RCP< const ScalarProdVectorSpaceBase< Scalar > > &domainSpace, const RCP< const Tpetra::MultiVector< Scalar, LocalOrdinal, GlobalOrdinal, Node > > &tpetraMultiVector)
Initialize.
void norms(const MultiVectorBase< Scalar > &V, const ArrayView< typename ScalarTraits< Scalar >::magnitudeType > &norms)
Column-wise multi-vector natural norm.
virtual void norms2Impl(const ArrayView< typename ScalarTraits< Scalar >::magnitudeType > &norms) const
virtual void linearCombinationImpl(const ArrayView< const Scalar > &alpha, const ArrayView< const Ptr< const MultiVectorBase< Scalar > > > &mv, const Scalar &beta)
virtual void dotsImpl(const MultiVectorBase< Scalar > &mv, const ArrayView< Scalar > &prods) const
RCP< VectorBase< Scalar > > nonconstColImpl(Ordinal j)
void getLocalMultiVectorDataImpl(const Ptr< ArrayRCP< const Scalar > > &localValues, const Ptr< Ordinal > &leadingDim) const
virtual void assignMultiVecImpl(const MultiVectorBase< Scalar > &mv)
virtual void norms1Impl(const ArrayView< typename ScalarTraits< Scalar >::magnitudeType > &norms) const
RCP< const Tpetra::MultiVector< Scalar, LocalOrdinal, GlobalOrdinal, Node > > getConstTpetraMultiVector() const
Extract the underlying const Tpetra::MultiVector object.
RCP< const SpmdVectorSpaceBase< Scalar > > spmdSpaceImpl() const
virtual void normsInfImpl(const ArrayView< typename ScalarTraits< Scalar >::magnitudeType > &norms) const
RCP< const ScalarProdVectorSpaceBase< Scalar > > domainScalarProdVecSpc() const
void acquireNonconstDetachedMultiVectorViewImpl(const Range1D &rowRng, const Range1D &colRng, RTOpPack::SubMultiVectorView< Scalar > *sub_mv)
void acquireDetachedMultiVectorViewImpl(const Range1D &rowRng, const Range1D &colRng, RTOpPack::ConstSubMultiVectorView< Scalar > *sub_mv) const
void commitNonconstDetachedMultiVectorViewImpl(RTOpPack::SubMultiVectorView< Scalar > *sub_mv)