Thyra  Version of the Day
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Thyra_DefaultSpmdVector_def.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_DEFAULT_SPMD_VECTOR_DEF_HPP
11 #define THYRA_DEFAULT_SPMD_VECTOR_DEF_HPP
12 
13 
14 #include "Thyra_DefaultSpmdVector_decl.hpp"
15 #include "Thyra_SpmdVectorDefaultBase.hpp"
16 #include "Thyra_SpmdVectorSpaceDefaultBase.hpp"
17 
18 
19 namespace Thyra {
20 
21 
22 // Constructors/initializers/accessors
23 
24 
25 template<class Scalar>
27  :stride_(0)
28 {}
29 
30 
31 template<class Scalar>
33  const RCP<const SpmdVectorSpaceBase<Scalar> > &spmdSpace_in,
34  const ArrayRCP<Scalar> &localValues,
35  const Ordinal stride
36  )
37 {
38  initialize(spmdSpace_in, localValues, stride);
39 }
40 
41 
42 template<class Scalar>
44  const RCP<const SpmdVectorSpaceBase<Scalar> > &spmdSpace_in
45  ,const ArrayRCP<Scalar> &localValues
46  ,const Ordinal stride
47  )
48 {
49 #ifdef TEUCHOS_DEBUG
50  TEUCHOS_TEST_FOR_EXCEPT(is_null(spmdSpace_in));
51  TEUCHOS_TEST_FOR_EXCEPT(spmdSpace_in->localSubDim() > 0 && localValues.get()==NULL);
52  TEUCHOS_TEST_FOR_EXCEPT(stride==0);
53 #endif
54  spmdSpace_ = spmdSpace_in;
55  localValues_ = localValues;
56  stride_ = stride;
57  this->updateSpmdSpace();
58 }
59 
60 
61 template<class Scalar>
63  RCP<const SpmdVectorSpaceBase<Scalar> > *spmdSpace_in
64  ,ArrayRCP<Scalar> *localValues
65  ,Ordinal *stride
66  )
67 {
68  if(spmdSpace_in) *spmdSpace_in = spmdSpace_;
69  if(localValues) *localValues = localValues_;
70  if(stride) *stride = stride_;
71 
72  spmdSpace_ = Teuchos::null;
73  localValues_ = Teuchos::null;
74  stride_ = 0;
75 
76  this->updateSpmdSpace();
77 }
78 
79 
80 // Overridden from SpmdMultiVectorBase
81 
82 
83 template<class Scalar>
86 {
87  return spmdSpace_;
88 }
89 
90 
91 // Overridden from SpmdVectorBase
92 
93 
94 template<class Scalar>
96  const Ptr<ArrayRCP<Scalar> > &localValues )
97 {
98  *localValues = localValues_;
99 }
100 
101 
102 template<class Scalar>
104  const Ptr<ArrayRCP<const Scalar> > &localValues ) const
105 {
106  *localValues = localValues_;
107 }
108 
109 
110 } // end namespace Thyra
111 
112 
113 #endif // THYRA_DEFAULT_SPMD_VECTOR_DEF_HPP
RCP< const SpmdVectorSpaceBase< Scalar > > spmdSpaceImpl() const
void initialize(int *argc, char ***argv)
bool is_null(const boost::shared_ptr< T > &p)
void uninitialize(RCP< const SpmdVectorSpaceBase< Scalar > > *spmdSpace=NULL, ArrayRCP< Scalar > *localValues=NULL, Ordinal *stride=NULL)
Set to an uninitialized state.
void initialize(const RCP< const SpmdVectorSpaceBase< Scalar > > &spmdSpace, const ArrayRCP< Scalar > &localValues, const Ordinal stride)
Initialize.
void getNonconstLocalVectorDataImpl(const Ptr< ArrayRCP< Scalar > > &localValues)
Teuchos::Ordinal Ordinal
Type for the dimension of a vector space. `*.
void getLocalVectorDataImpl(const Ptr< ArrayRCP< const Scalar > > &localValues) const
DefaultSpmdVector()
Construct to uninitialized.
T * get() const
Base abstract VectorSpaceBase class for all SPMD-based vector spaces.
#define TEUCHOS_TEST_FOR_EXCEPT(throw_exception_test)