Thyra  Version of the Day
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Thyra_SpmdVectorDefaultBase_decl.hpp
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_SPMD_VECTOR_DEFAULT_BASE_DECL_HPP
43 #define THYRA_SPMD_VECTOR_DEFAULT_BASE_DECL_HPP
44 
45 
46 #include "Thyra_VectorDefaultBase.hpp"
47 #include "Thyra_SpmdVectorBase.hpp"
48 #include "Thyra_SpmdVectorSpaceDefaultBase_decl.hpp"
49 
50 
51 //#define THYRA_SPMD_VECTOR_BASE_DUMP
52 
53 
54 namespace Thyra {
55 
56 
89 template<class Scalar>
91  : virtual public SpmdVectorBase<Scalar>,
92  virtual public VectorDefaultBase<Scalar>
93 {
94 public:
95 
98 
101 
103 
109  virtual void applyOpImplWithComm(
110  const Ptr<const Teuchos::Comm<Ordinal> > &comm,
111  const RTOpPack::RTOpT<Scalar> &op,
112  const ArrayView<const Ptr<const VectorBase<Scalar> > > &vecs,
113  const ArrayView<const Ptr<VectorBase<Scalar> > > &targ_vecs,
114  const Ptr<RTOpPack::ReductTarget> &reduct_obj,
115  const Ordinal global_offset
116  ) const;
117 
119 
123  std::string description() const;
125 
128 
131 
133 
134 protected:
135 
138 
140  void applyOpImpl(
141  const RTOpPack::RTOpT<Scalar> &op,
142  const ArrayView<const Ptr<const VectorBase<Scalar> > > &vecs,
143  const ArrayView<const Ptr<VectorBase<Scalar> > > &targ_vecs,
144  const Ptr<RTOpPack::ReductTarget> &reduct_obj,
145  const Ordinal global_offset
146  ) const;
149  const Range1D& rng, RTOpPack::ConstSubVectorView<Scalar>* sub_vec
150  ) const;
154  ) const;
157  const Range1D& rng, RTOpPack::SubVectorView<Scalar>* sub_vec
158  );
162  );
163 
165 
174  const Ptr<ArrayRCP<Scalar> > &localValues, const Ptr<Ordinal> &leadingDim);
177  const Ptr<ArrayRCP<const Scalar> > &localValues, const Ptr<Ordinal> &leadingDim) const;
179 
187 
190 
194  virtual void updateSpmdSpace();
195 
197 
198 private:
199 
200  // ///////////////////////////////////////
201  // Private data members
202 
203  // Cached (only on vector space!)
204  mutable Ordinal globalDim_;
205  mutable Ordinal localOffset_;
206  mutable Ordinal localSubDim_;
207 
208  // /////////////////////////////////////
209  // Private member functions
210 
211  Range1D validateRange( const Range1D& rng_in ) const;
212 
213 #ifdef THYRA_SPMD_VECTOR_BASE_DUMP
214 public:
215  static bool show_dump;
216 #endif // THYRA_SPMD_VECTOR_BASE_DUMP
217 
218 }; // end class SpmdVectorDefaultBase
219 
220 
221 } // end namespace Thyra
222 
223 
224 #endif // THYRA_SPMD_VECTOR_DEFAULT_BASE_DECL_HPP
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
Calls applyOpImplWithComm(null,op,...).
RTOpPack::SubVectorView< Scalar > getNonconstLocalSubVectorImpl()
Virtual implementation for getNonconstLocalSubVector().
void acquireDetachedVectorViewImpl(const Range1D &rng, RTOpPack::ConstSubVectorView< Scalar > *sub_vec) const
Implemented through this-&gt;getLocalData()
virtual void applyOpImplWithComm(const Ptr< const Teuchos::Comm< Ordinal > > &comm, 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
Implementation of applyOpImpl(...) that uses an input Comm.
Base class for SPMD vectors that can provide views of contiguous elements in a process.
Base class for SPMD vectors that can provide views of contiguous elements in a process.
RTOpPack::SubMultiVectorView< Scalar > getNonconstLocalSubMultiVectorImpl()
virtual void updateSpmdSpace()
Subclasses must call this function whenever the structure of the VectorSpaceBase changes.
Convenient node subclass for concrete VectorBase subclasses that relies on a default MultiVectorBase ...
Teuchos::Ordinal Ordinal
Type for the dimension of a vector space. `*.
Abstract interface for finite-dimensional dense vectors.
Teuchos::RCP< const VectorSpaceBase< Scalar > > space() const
Returns this-&gt;spmdSpace().
RTOpPack::ConstSubMultiVectorView< Scalar > getLocalSubMultiVectorImpl() const
void commitNonconstDetachedVectorViewImpl(RTOpPack::SubVectorView< Scalar > *sub_vec)
Implemented through this-&gt;commitLocalData()
RTOpPack::ConstSubVectorView< Scalar > getLocalSubVectorImpl() const
Virtual implementation for getLocalSubVector().
void getNonconstLocalMultiVectorDataImpl(const Ptr< ArrayRCP< Scalar > > &localValues, const Ptr< Ordinal > &leadingDim)
void getLocalMultiVectorDataImpl(const Ptr< ArrayRCP< const Scalar > > &localValues, const Ptr< Ordinal > &leadingDim) const
void releaseDetachedVectorViewImpl(RTOpPack::ConstSubVectorView< Scalar > *sub_vec) const
Implemented through this-&gt;freeLocalData()
void acquireNonconstDetachedVectorViewImpl(const Range1D &rng, RTOpPack::SubVectorView< Scalar > *sub_vec)
Implemented through this-&gt;getLocalData()