Thyra Package Browser (Single Doxygen Collection)  Version of the Day
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Thyra_TpetraVector_decl.hpp
Go to the documentation of this file.
1 // @HEADER
2 // ***********************************************************************
3 //
4 // Thyra: Interfaces and Support for Abstract Numerical Algorithms
5 // Copyright (2004) Sandia Corporation
6 //
7 // Under terms of Contract DE-AC04-94AL85000, there is a non-exclusive
8 // license for use of this work by or on behalf of the U.S. Government.
9 //
10 // Redistribution and use in source and binary forms, with or without
11 // modification, are permitted provided that the following conditions are
12 // met:
13 //
14 // 1. Redistributions of source code must retain the above copyright
15 // notice, this list of conditions and the following disclaimer.
16 //
17 // 2. Redistributions in binary form must reproduce the above copyright
18 // notice, this list of conditions and the following disclaimer in the
19 // documentation and/or other materials provided with the distribution.
20 //
21 // 3. Neither the name of the Corporation nor the names of the
22 // contributors may be used to endorse or promote products derived from
23 // this software without specific prior written permission.
24 //
25 // THIS SOFTWARE IS PROVIDED BY SANDIA CORPORATION "AS IS" AND ANY
26 // EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
27 // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
28 // PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL SANDIA CORPORATION OR THE
29 // CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
30 // EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
31 // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
32 // PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
33 // LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
34 // NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
35 // SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
36 //
37 // Questions? Contact Roscoe A. Bartlett (bartlettra@ornl.gov)
38 //
39 // ***********************************************************************
40 // @HEADER
41 
42 #ifndef THYRA_TPETRA_VECTOR_DECL_HPP
43 #define THYRA_TPETRA_VECTOR_DECL_HPP
44 
45 
46 #include "Thyra_SpmdVectorDefaultBase.hpp"
48 #include "Tpetra_Vector.hpp"
50 
51 
52 namespace Thyra {
53 
54 
59 template <class Scalar, class LocalOrdinal, class GlobalOrdinal, class Node>
61  : virtual public SpmdVectorDefaultBase<Scalar>
62 {
63 public:
64 
67 
69  TpetraVector();
70 
72  void initialize(
73  const RCP<const TpetraVectorSpace<Scalar,LocalOrdinal,GlobalOrdinal,Node> > &tpetraVectorSpace,
74  const RCP<Tpetra::Vector<Scalar,LocalOrdinal,GlobalOrdinal,Node> > &tpetraVector
75  );
76 
78  void constInitialize(
79  const RCP<const TpetraVectorSpace<Scalar,LocalOrdinal,GlobalOrdinal,Node> > &tpetraVectorSpace,
80  const RCP<const Tpetra::Vector<Scalar,LocalOrdinal,GlobalOrdinal,Node> > &tpetraVector
81  );
82 
86 
89  getConstTpetraVector() const;
90 
92 
98 
99  // Should these Impl functions should alsp be protected???
100 //protected:
101 
107 
111  void getNonconstLocalVectorDataImpl(const Ptr<ArrayRCP<Scalar> > &localValues);
113  void getLocalVectorDataImpl(const Ptr<ArrayRCP<const Scalar> > &localValues) const;
115 
116 protected:
117 
120 
122  virtual void randomizeImpl(Scalar l, Scalar u);
123 
125  virtual void absImpl(const VectorBase<Scalar>& x);
126 
128  virtual void reciprocalImpl(const VectorBase<Scalar>& x);
129 
131  virtual void eleWiseScaleImpl(const VectorBase<Scalar>& x);
132 
135  norm2WeightedImpl(const VectorBase<Scalar>& x) const;
136 
138  virtual void applyOpImpl(
139  const RTOpPack::RTOpT<Scalar> &op,
140  const ArrayView<const Ptr<const VectorBase<Scalar> > > &vecs,
141  const ArrayView<const Ptr<VectorBase<Scalar> > > &targ_vecs,
142  const Ptr<RTOpPack::ReductTarget> &reduct_obj,
143  const Ordinal global_offset
144  ) const;
145 
148  const Range1D& rng,
150  ) const;
151 
154  const Range1D& rng,
156  );
157 
161  );
162 
164 
168  virtual void assignImpl(Scalar alpha);
169 
171  virtual void assignMultiVecImpl(const MultiVectorBase<Scalar>& mv);
172 
174  virtual void scaleImpl(Scalar alpha);
175 
177  virtual void updateImpl(
178  Scalar alpha,
179  const MultiVectorBase<Scalar>& mv
180  );
181 
183  virtual void linearCombinationImpl(
184  const ArrayView<const Scalar>& alpha,
185  const ArrayView<const Ptr<const MultiVectorBase<Scalar> > >& mv,
186  const Scalar& beta
187  );
188 
190  virtual void dotsImpl(
191  const MultiVectorBase<Scalar>& mv,
192  const ArrayView<Scalar>& prods
193  ) const;
194 
196  virtual void norms1Impl(
197  const ArrayView<typename ScalarTraits<Scalar>::magnitudeType>& norms
198  ) const;
199 
201  virtual void norms2Impl(
202  const ArrayView<typename ScalarTraits<Scalar>::magnitudeType>& norms
203  ) const;
204 
206  virtual void normsInfImpl(
207  const ArrayView<typename ScalarTraits<Scalar>::magnitudeType>& norms
208  ) const;
209 
211 
214 
216  void applyImpl(
217  const EOpTransp M_trans,
218  const MultiVectorBase<Scalar> &X,
219  const Ptr<MultiVectorBase<Scalar> > &Y,
220  const Scalar alpha,
221  const Scalar beta
222  ) const;
223 
225 
226 private:
227 
228  // ///////////////////////////////////////
229  // Private data members
230 
233 
236 
239 
240  typedef Tpetra::MultiVector<Scalar, LocalOrdinal,GlobalOrdinal,Node> TpetraMultiVector_t;
241 
242  // ////////////////////////////////////
243  // Private member functions
244 
245  template<class TpetraVector_t>
246  void initializeImpl(
247  const RCP<const TpetraVectorSpace<Scalar,LocalOrdinal,GlobalOrdinal,Node> > &tpetraVectorSpace,
249  );
250 
251  // Non-throwing Tpetra Vector/MultiVector extraction methods.
252  // Return null if casting failed.
254  getTpetraMultiVector(const RCP<MultiVectorBase<Scalar> >& mv) const;
255 
257  getConstTpetraMultiVector(const RCP<const MultiVectorBase<Scalar> >& mv) const;
258 
260  getTpetraVector(const RCP<VectorBase<Scalar> >& v) const;
261 
263  getConstTpetraVector(const RCP<const VectorBase<Scalar> >& v) const;
264 
265 };
266 
267 
272 template <class Scalar, class LocalOrdinal, class GlobalOrdinal, class Node>
273 inline
276  const RCP<const TpetraVectorSpace<Scalar,LocalOrdinal,GlobalOrdinal,Node> > &tpetraVectorSpace,
277  const RCP<Tpetra::Vector<Scalar,LocalOrdinal,GlobalOrdinal,Node> > &tpetraVector
278  )
279 {
282  v->initialize(tpetraVectorSpace, tpetraVector);
283  return v;
284 }
285 
286 
291 template <class Scalar, class LocalOrdinal, class GlobalOrdinal, class Node>
292 inline
295  const RCP<const TpetraVectorSpace<Scalar,LocalOrdinal,GlobalOrdinal,Node> > &tpetraVectorSpace,
296  const RCP<const Tpetra::Vector<Scalar,LocalOrdinal,GlobalOrdinal,Node> > &tpetraVector
297  )
298 {
301  v->constInitialize(tpetraVectorSpace, tpetraVector);
302  return v;
303 }
304 
305 
306 } // end namespace Thyra
307 
308 
309 #endif // THYRA_TPETRA_VECTOR_DECL_HPP
void constInitialize(const RCP< const TpetraVectorSpace< Scalar, LocalOrdinal, GlobalOrdinal, Node > > &tpetraVectorSpace, const RCP< const Tpetra::Vector< Scalar, LocalOrdinal, GlobalOrdinal, Node > > &tpetraVector)
Initialize.
RCP< Tpetra::MultiVector< Scalar, LocalOrdinal, GlobalOrdinal, Node > > getTpetraMultiVector(const RCP< MultiVectorBase< Scalar > > &mv) const
void applyImpl(const EOpTransp M_trans, const MultiVectorBase< Scalar > &X, const Ptr< MultiVectorBase< Scalar > > &Y, const Scalar alpha, const Scalar beta) const
Concrete implementation of an SPMD vector space for Tpetra.
void commitNonconstDetachedVectorViewImpl(RTOpPack::SubVectorView< Scalar > *sub_vec)
RCP< const TpetraVectorSpace< Scalar, LocalOrdinal, GlobalOrdinal, Node > > tpetraVectorSpace_
RCP< const TpetraVectorSpace< Scalar, LocalOrdinal, GlobalOrdinal, Node > > domainSpace_
void initialize(const RCP< const TpetraVectorSpace< Scalar, LocalOrdinal, GlobalOrdinal, Node > > &tpetraVectorSpace, const RCP< Tpetra::Vector< Scalar, LocalOrdinal, GlobalOrdinal, Node > > &tpetraVector)
Initialize.
RCP< const Tpetra::MultiVector< Scalar, LocalOrdinal, GlobalOrdinal, Node > > getConstTpetraMultiVector(const RCP< const MultiVectorBase< Scalar > > &mv) const
TpetraVector()
Construct to uninitialized.
virtual void norms1Impl(const ArrayView< typename ScalarTraits< Scalar >::magnitudeType > &norms) const
virtual void applyOpImpl(const RTOpPack::RTOpT< Scalar > &op, const ArrayView< const Ptr< const VectorBase< Scalar > > > &vecs, const ArrayView< const Ptr< VectorBase< Scalar > > > &targ_vecs, const Ptr< RTOpPack::ReductTarget > &reduct_obj, const Ordinal global_offset) const
virtual void norms2Impl(const ArrayView< typename ScalarTraits< Scalar >::magnitudeType > &norms) const
void getLocalVectorDataImpl(const Ptr< ArrayRCP< const Scalar > > &localValues) const
virtual void assignMultiVecImpl(const MultiVectorBase< Scalar > &mv)
void acquireNonconstDetachedVectorViewImpl(const Range1D &rng, RTOpPack::SubVectorView< Scalar > *sub_vec)
RCP< const Tpetra::Vector< Scalar, LocalOrdinal, GlobalOrdinal, Node > > getConstTpetraVector() const
Get the embedded non-const Tpetra::Vector.
virtual void reciprocalImpl(const VectorBase< Scalar > &x)
void acquireDetachedVectorViewImpl(const Range1D &rng, RTOpPack::ConstSubVectorView< Scalar > *sub_vec) const
TEUCHOS_DEPRECATED RCP< T > rcp(T *p, Dealloc_T dealloc, bool owns_mem)
virtual Teuchos::ScalarTraits< Scalar >::magnitudeType norm2WeightedImpl(const VectorBase< Scalar > &x) const
virtual void linearCombinationImpl(const ArrayView< const Scalar > &alpha, const ArrayView< const Ptr< const MultiVectorBase< Scalar > > > &mv, const Scalar &beta)
virtual void absImpl(const VectorBase< Scalar > &x)
Teuchos::ConstNonconstObjectContainer< Tpetra::Vector< Scalar, LocalOrdinal, GlobalOrdinal, Node > > tpetraVector_
void getNonconstLocalVectorDataImpl(const Ptr< ArrayRCP< Scalar > > &localValues)
Tpetra::MultiVector< Scalar, LocalOrdinal, GlobalOrdinal, Node > TpetraMultiVector_t
RCP< const SpmdVectorSpaceBase< Scalar > > spmdSpaceImpl() const
void initializeImpl(const RCP< const TpetraVectorSpace< Scalar, LocalOrdinal, GlobalOrdinal, Node > > &tpetraVectorSpace, const RCP< TpetraVector_t > &tpetraVector)
Concrete Thyra::SpmdVectorBase using Tpetra::Vector.
RCP< TpetraVector< Scalar, LocalOrdinal, GlobalOrdinal, Node > > tpetraVector(const RCP< const TpetraVectorSpace< Scalar, LocalOrdinal, GlobalOrdinal, Node > > &tpetraVectorSpace, const RCP< Tpetra::Vector< Scalar, LocalOrdinal, GlobalOrdinal, Node > > &tpetraVector)
Nonmember constructor for TpetraVector.
virtual void dotsImpl(const MultiVectorBase< Scalar > &mv, const ArrayView< Scalar > &prods) const
RCP< Tpetra::Vector< Scalar, LocalOrdinal, GlobalOrdinal, Node > > getTpetraVector()
Get the embedded non-const Tpetra::Vector.
RCP< const TpetraVector< Scalar, LocalOrdinal, GlobalOrdinal, Node > > constTpetraVector(const RCP< const TpetraVectorSpace< Scalar, LocalOrdinal, GlobalOrdinal, Node > > &tpetraVectorSpace, const RCP< const Tpetra::Vector< Scalar, LocalOrdinal, GlobalOrdinal, Node > > &tpetraVector)
Nonmember constructor for TpetraVector.
virtual void assignImpl(Scalar alpha)
virtual void eleWiseScaleImpl(const VectorBase< Scalar > &x)
virtual void normsInfImpl(const ArrayView< typename ScalarTraits< Scalar >::magnitudeType > &norms) const
RCP< const VectorSpaceBase< Scalar > > domain() const
virtual void randomizeImpl(Scalar l, Scalar u)
virtual void updateImpl(Scalar alpha, const MultiVectorBase< Scalar > &mv)
virtual void scaleImpl(Scalar alpha)
Teuchos_Ordinal Ordinal