Xpetra  Version of the Day
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
Xpetra_BlockedVector_decl.hpp
Go to the documentation of this file.
1 // @HEADER
2 //
3 // ***********************************************************************
4 //
5 // Xpetra: A linear algebra interface package
6 // Copyright 2012 Sandia Corporation
7 //
8 // Under the terms of Contract DE-AC04-94AL85000 with Sandia Corporation,
9 // the U.S. Government retains certain rights in this software.
10 //
11 // Redistribution and use in source and binary forms, with or without
12 // modification, are permitted provided that the following conditions are
13 // met:
14 //
15 // 1. Redistributions of source code must retain the above copyright
16 // notice, this list of conditions and the following disclaimer.
17 //
18 // 2. Redistributions in binary form must reproduce the above copyright
19 // notice, this list of conditions and the following disclaimer in the
20 // documentation and/or other materials provided with the distribution.
21 //
22 // 3. Neither the name of the Corporation nor the names of the
23 // contributors may be used to endorse or promote products derived from
24 // this software without specific prior written permission.
25 //
26 // THIS SOFTWARE IS PROVIDED BY SANDIA CORPORATION "AS IS" AND ANY
27 // EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
28 // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
29 // PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL SANDIA CORPORATION OR THE
30 // CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
31 // EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
32 // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
33 // PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
34 // LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
35 // NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
36 // SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
37 //
38 // Questions? Contact
39 // Jonathan Hu (jhu@sandia.gov)
40 // Andrey Prokopenko (aprokop@sandia.gov)
41 // Tobias Wiesner (tawiesn@sandia.gov)
42 // Ray Tuminaro (rstumin@sandia.gov)
43 //
44 // ***********************************************************************
45 //
46 // @HEADER
47 #ifndef XPETRA_BLOCKEDVECTOR_DECL_HPP
48 #define XPETRA_BLOCKEDVECTOR_DECL_HPP
49 
50 /* this file is automatically generated - do not edit (see script/interfaces.py) */
51 
52 #include "Xpetra_ConfigDefs.hpp"
53 
56 #include "Xpetra_Map_decl.hpp"
57 #include "Xpetra_Vector.hpp"
58 
59 
60 
61 namespace Xpetra {
62 
63 
64 
65 template<class Scalar,
66  class LocalOrdinal,
67  class GlobalOrdinal,
70  : public virtual Xpetra::Vector<Scalar, LocalOrdinal, GlobalOrdinal, Node>
71  , public virtual Xpetra::BlockedMultiVector<Scalar, LocalOrdinal, GlobalOrdinal, Node>
72 {
73  public:
74  using scalar_type = Scalar;
75  using local_ordinal_type = LocalOrdinal;
76  using global_ordinal_type = GlobalOrdinal;
77  using node_type = Node;
78 
88 
89 
90  private:
91 #undef XPETRA_BLOCKEDVECTOR_SHORT
92 #include "Xpetra_UseShortNames.hpp"
93 
94  public:
96 
97 
99 
100 
108  BlockedVector(const Teuchos::RCP<const BlockedMap>& map, bool zeroOut = true);
109 
110 
124 
125 
139 
140 
142  virtual ~BlockedVector();
143 
144 
154 
155 
157 
159 
160 
162  virtual void replaceGlobalValue(GlobalOrdinal globalRow, size_t vectorIndex, const Scalar& value);
163 
165  virtual void sumIntoGlobalValue(GlobalOrdinal globalRow, size_t vectorIndex, const Scalar& value);
166 
168  virtual void replaceLocalValue(LocalOrdinal myRow, size_t vectorIndex, const Scalar& value);
169 
171  virtual void sumIntoLocalValue(LocalOrdinal myRow, size_t vectorIndex, const Scalar& value);
172 
174  virtual void replaceGlobalValue(GlobalOrdinal globalRow, const Scalar& value);
175 
177  virtual void sumIntoGlobalValue(GlobalOrdinal globalRow, const Scalar& value);
178 
180  virtual void replaceLocalValue(LocalOrdinal myRow, const Scalar& value);
181 
183  virtual void sumIntoLocalValue(LocalOrdinal myRow, const Scalar& value);
184 
185 
187  virtual void putScalar(const Scalar& value);
188 
189 
191 
192 
194 
195 
196 
198  virtual Teuchos::RCP<const Xpetra::Vector<Scalar, LocalOrdinal, GlobalOrdinal, Node>>
199  getVector(size_t j) const;
200 
202  virtual Teuchos::RCP<Xpetra::Vector<Scalar, LocalOrdinal, GlobalOrdinal, Node>>
203  getVectorNonConst(size_t j);
204 
206  virtual Teuchos::ArrayRCP<const Scalar> getData(size_t j) const;
207 
209  virtual Teuchos::ArrayRCP<Scalar> getDataNonConst(size_t j);
210 
212 
214 
215 
218  const Teuchos::ArrayView<Scalar>& dots) const;
219 
220  virtual Scalar dot(const Xpetra::Vector<Scalar, LocalOrdinal, GlobalOrdinal, Node>& A) const;
221 
222 
225 
228 
230  virtual void scale(const Scalar& alpha);
231 
233  virtual void scale(Teuchos::ArrayView<const Scalar> alpha);
234 
235  virtual void update(const Scalar& alpha,
237  const Scalar& beta);
238 
239 
241  virtual void update(const Scalar& alpha,
243  const Scalar& beta,
245  const Scalar& gamma);
246 
248  virtual typename Teuchos::ScalarTraits<Scalar>::magnitudeType norm1() const;
249 
251  virtual typename Teuchos::ScalarTraits<Scalar>::magnitudeType norm2() const;
252 
254  virtual typename Teuchos::ScalarTraits<Scalar>::magnitudeType normInf() const;
255 
257  virtual void norm1(const Teuchos::ArrayView<typename Teuchos::ScalarTraits<Scalar>::magnitudeType>& norms) const;
258 
260  virtual void norm2(const Teuchos::ArrayView<typename Teuchos::ScalarTraits<Scalar>::magnitudeType>& norms) const;
261 
263  virtual void normInf(const Teuchos::ArrayView<typename Teuchos::ScalarTraits<Scalar>::magnitudeType>& norms) const;
264 
267  virtual void meanValue(const Teuchos::ArrayView<Scalar>& /* means */) const;
268 
269  virtual Scalar meanValue() const;
270 
272  virtual void multiply(Teuchos::ETransp /* transA */,
273  Teuchos::ETransp /* transB */,
274  const Scalar& /* alpha */,
277  const Scalar& /* beta */);
278 
279  virtual void multiply(Teuchos::ETransp /* transA */,
280  Teuchos::ETransp /* transB */,
281  const Scalar& /* alpha */,
284  const Scalar& /* beta */);
285 
286 
287  virtual void elementWiseMultiply(Scalar /* scalarAB */,
290  Scalar /* scalarThis */);
291 
293  virtual void elementWiseMultiply(Scalar /* scalarAB */,
296  Scalar /* scalarThis */);
297 
298 
300 
301 
303 
304 
305 
307  virtual size_t getNumVectors() const;
308 
310  virtual size_t getLocalLength() const;
311 
313  virtual global_size_t getGlobalLength() const;
314 
317 
319 
321 
322 
324  virtual std::string description() const;
325 
327  virtual void describe(Teuchos::FancyOStream& out,
328  const Teuchos::EVerbosityLevel verbLevel = Teuchos::Describable::verbLevel_default) const;
329 
330  virtual void replaceMap(const RCP<const Map>& map);
331 
333  virtual void doImport(const DistObject<Scalar, LocalOrdinal, GlobalOrdinal, Node>& /* source */,
334  const Import& /* importer */,
335  CombineMode /* CM */);
336 
339  const Import& /* importer */,
340  CombineMode /* CM */);
341 
343  virtual void doImport(const DistObject<Scalar, LocalOrdinal, GlobalOrdinal, Node>& /* source */,
344  const Export& /* exporter */,
345  CombineMode /* CM */);
346 
349  const Export& /* exporter */,
350  CombineMode /* CM */);
351 
352 
354 
355 
357 
358 
359 
361  virtual void setSeed(unsigned int seed);
362 
363 
364  virtual void randomize(bool bUseXpetraImplementation = false);
365 
367  virtual void Xpetra_randomize();
368 
369 #ifdef HAVE_XPETRA_KOKKOS_REFACTOR
370  typedef typename Kokkos::Details::ArithTraits<Scalar>::val_type impl_scalar_type;
371  typedef Kokkos::DualView<impl_scalar_type**, Kokkos::LayoutStride,
372  typename node_type::execution_space,
373  Kokkos::MemoryUnmanaged> dual_view_type;
374  typedef typename dual_view_type::host_mirror_space host_execution_space;
375  typedef typename dual_view_type::t_dev::execution_space dev_execution_space;
376 
382  template<class TargetDeviceType>
383  typename Kokkos::Impl::if_c<
384  std::is_same<
385  typename dev_execution_space::memory_space,
386  typename TargetDeviceType::memory_space>::value,
387  typename dual_view_type::t_dev_um,
388  typename dual_view_type::t_host_um>::type
389  getLocalView () const
390  {
391  if(std::is_same<typename host_execution_space::memory_space, typename TargetDeviceType::memory_space>::value)
392  {
393  return getHostLocalView();
394  }
395  else
396  {
397  return getDeviceLocalView();
398  }
399  }
400  virtual typename dual_view_type::t_host_um getHostLocalView () const
401  {
402  typename dual_view_type::t_host_um test;
403  return test;
404  }
405  virtual typename dual_view_type::t_dev_um getDeviceLocalView() const
406  {
407  typename dual_view_type::t_dev_um test;
408  return test;
409  }
410 
411 #if 0
412  typedef typename Kokkos::Details::ArithTraits<Scalar>::val_type impl_scalar_type;
413  typedef Kokkos::
414  DualView<impl_scalar_type**, Kokkos::LayoutStride, typename node_type::execution_space, Kokkos::MemoryUnmanaged>
415  dual_view_type;
416  typedef typename dual_view_type::host_mirror_space host_execution_space;
417  typedef typename dual_view_type::t_dev::execution_space dev_execution_space;
418 
424  template<class TargetDeviceType>
425  typename Kokkos::Impl::if_c<std::is_same<typename dev_execution_space::memory_space,
426  typename TargetDeviceType::memory_space>::value,
427  typename dual_view_type::t_dev_um,
428  typename dual_view_type::t_host_um>::type
429  getLocalView() const;
430 
431  virtual typename dual_view_type::t_host_um getHostLocalView () const
432  {
433  typename dual_view_type::t_host_um test;
434  return test;
435  }
436  virtual typename dual_view_type::t_dev_um getDeviceLocalView() const
437  {
438  typename dual_view_type::t_dev_um test;
439  return test;
440  }
441 #endif
442 #endif // HAVE_XPETRA_KOKKOS_REFACTOR
443 
444 
446 
447 
449  Teuchos::RCP<const Map> getMap() const;
450 
452  Teuchos::RCP< Xpetra::MultiVector<Scalar, LocalOrdinal, GlobalOrdinal, Node> >
453  getMultiVector(size_t r) const;
454 
456  Teuchos::RCP< Xpetra::MultiVector<Scalar, LocalOrdinal, GlobalOrdinal, Node> >
457  getMultiVector(size_t r, bool bThyraMode) const;
458 
460  void
461  setMultiVector(size_t r,
463  bool bThyraMode);
464 
466  Teuchos::RCP< Xpetra::MultiVector<Scalar, LocalOrdinal, GlobalOrdinal, Node> >
467  Merge() const;
468 
469 
470  protected:
478 
479  // virtual void assign (const MultiVector& rhs);
480 
481  //private:
482  // Teuchos::RCP<const BlockedMap> map_; ///< blocked map containing the sub block maps (either thyra or xpetra mode)
483  // std::vector<Teuchos::RCP<Vector> > vv_; ///< array containing RCPs of the partial vectors
484 
485 
486 }; // BlockedVector class
487 
488 
489 
490 } // namespace Xpetra
491 
492 #define XPETRA_BLOCKEDVECTOR_SHORT
493 #endif // XPETRA_BLOCKEDVECTOR_DECL_HPP
494 
virtual Teuchos::RCP< Xpetra::Vector< Scalar, LocalOrdinal, GlobalOrdinal, Node > > getVectorNonConst(size_t j)
Return a Vector which is a nonconst view of column j.
virtual Scalar meanValue() const
Compute mean (average) value of this Vector.
virtual void setSeed(unsigned int seed)
Set seed for Random function.
virtual void multiply(Teuchos::ETransp, Teuchos::ETransp, const Scalar &, const Xpetra::Vector< Scalar, LocalOrdinal, GlobalOrdinal, Node > &, const Xpetra::Vector< Scalar, LocalOrdinal, GlobalOrdinal, Node > &, const Scalar &)
Matrix-matrix multiplication: this = beta*this + alpha*op(A)*op(B).
virtual void sumIntoLocalValue(LocalOrdinal myRow, size_t vectorIndex, const Scalar &value)
Add value to existing value, using local (row) index.
virtual void update(const Scalar &alpha, const Xpetra::MultiVector< Scalar, LocalOrdinal, GlobalOrdinal, Node > &A, const Scalar &beta)
Update multi-vector values with scaled values of A, this = beta*this + alpha*A.
virtual Teuchos::RCP< const Xpetra::Vector< Scalar, LocalOrdinal, GlobalOrdinal, Node > > getVector(size_t j) const
Return a Vector which is a const view of column j.
virtual void elementWiseMultiply(Scalar, const Xpetra::Vector< Scalar, LocalOrdinal, GlobalOrdinal, Node > &, const Xpetra::MultiVector< Scalar, LocalOrdinal, GlobalOrdinal, Node > &, Scalar)
Element-wise multiply of a Vector A with a MultiVector B.
virtual void scale(const Scalar &alpha)
Scale the current values of a vector, this = alpha*this.
virtual void replaceMap(const RCP< const Map > &map)
virtual size_t getNumVectors() const
Number of columns in the Vector.
virtual std::string description() const
A simple one-line description of this object.
virtual void abs(const Xpetra::MultiVector< Scalar, LocalOrdinal, GlobalOrdinal, Node > &A)
Put element-wise absolute values of input vector in target: A = abs(this).
virtual void dot(const Xpetra::MultiVector< Scalar, LocalOrdinal, GlobalOrdinal, Node > &A, const Teuchos::ArrayView< Scalar > &dots) const
Compute dot product of each corresponding pair of vectors, dots[i] = this[i].dot(A[i]).
virtual void describe(Teuchos::FancyOStream &out, const Teuchos::EVerbosityLevel verbLevel=Teuchos::Describable::verbLevel_default) const
Print the object with the given verbosity level to a FancyOStream.
virtual void reciprocal(const Xpetra::MultiVector< Scalar, LocalOrdinal, GlobalOrdinal, Node > &A)
Put element-wise reciprocal values of input vector in target, this(i,j) = 1/A(i,j).
virtual bool isSameSize(const Xpetra::MultiVector< Scalar, LocalOrdinal, GlobalOrdinal, Node > &) const
Local number of rows on the calling process.
virtual void assign(const Xpetra::MultiVector< Scalar, LocalOrdinal, GlobalOrdinal, Node > &rhs)
Implementation of the assignment operator (operator=); does a deep copy.
Teuchos::RCP< const Map > getMap() const
Access function for the underlying Map this DistObject was constructed with.
virtual size_t getLocalLength() const
Local number of rows on the calling process.
virtual void randomize(bool bUseXpetraImplementation=false)
Set multi-vector values to random numbers.
virtual ~BlockedVector()
Destructor.
virtual Teuchos::ScalarTraits< Scalar >::magnitudeType norm2() const
Compute 2-norm of vector.
void setMultiVector(size_t r, Teuchos::RCP< const Xpetra::Vector< Scalar, LocalOrdinal, GlobalOrdinal, Node > > v, bool bThyraMode)
set partial Vector associated with block row r
size_t global_size_t
Global size_t object.
BlockedVector(const Teuchos::RCP< const BlockedMap > &map, bool zeroOut=true)
Constructor.
Teuchos::RCP< Xpetra::MultiVector< Scalar, LocalOrdinal, GlobalOrdinal, Node > > Merge() const
merge BlockedVector blocks to a single Vector
virtual Teuchos::ArrayRCP< const Scalar > getData(size_t j) const
Const view of the local values in a particular vector of this vector.
virtual Teuchos::ScalarTraits< Scalar >::magnitudeType norm1() const
Compute 1-norm of vector.
virtual Teuchos::ArrayRCP< Scalar > getDataNonConst(size_t j)
View of the local values in a particular vector of this vector.
virtual global_size_t getGlobalLength() const
Global number of rows in the Vector.
virtual void replaceGlobalValue(GlobalOrdinal globalRow, size_t vectorIndex, const Scalar &value)
Replace value, using global (row) index.
BlockedVector< Scalar, LocalOrdinal, GlobalOrdinal, Node > & operator=(const Xpetra::MultiVector< Scalar, LocalOrdinal, GlobalOrdinal, Node > &rhs)
Assignment operator: Does a deep copy.
CombineMode
Xpetra::Combine Mode enumerable type.
virtual void sumIntoGlobalValue(GlobalOrdinal globalRow, size_t vectorIndex, const Scalar &value)
Add value to existing value, using global (row) index.
virtual Teuchos::ScalarTraits< Scalar >::magnitudeType normInf() const
Compute Inf-norm in vector.
virtual void doImport(const DistObject< Scalar, LocalOrdinal, GlobalOrdinal, Node > &, const Import &, CombineMode)
Import.
virtual void doExport(const DistObject< Scalar, LocalOrdinal, GlobalOrdinal, Node > &, const Import &, CombineMode)
Export.
virtual void putScalar(const Scalar &value)
Set all values in the vector with the given value.
virtual void Xpetra_randomize()
Set vector values to random numbers. XPetra implementation.
Teuchos::RCP< Xpetra::MultiVector< Scalar, LocalOrdinal, GlobalOrdinal, Node > > getMultiVector(size_t r) const
return partial Vector associated with block row r
virtual void replaceLocalValue(LocalOrdinal myRow, size_t vectorIndex, const Scalar &value)
Replace value, using local (row) index.