Xpetra_EpetraVector.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 // Ray Tuminaro (rstumin@sandia.gov)
42 //
43 // ***********************************************************************
44 //
45 // @HEADER
46 #ifndef XPETRA_EPETRAVECTOR_HPP
47 #define XPETRA_EPETRAVECTOR_HPP
48 
49 /* this file is automatically generated - do not edit (see script/epetra.py) */
50 
52 
53 #include "Xpetra_Vector.hpp"
55 #include "Xpetra_EpetraMap.hpp" //TMP
56 #include "Xpetra_Utils.hpp"
57 #include "Xpetra_EpetraImport.hpp"
58 #include "Xpetra_EpetraExport.hpp"
59 #include "Xpetra_Exceptions.hpp"
60 
61 #include <Epetra_Vector.h>
62 
63 namespace Xpetra {
64 
65  // TODO: move that elsewhere
66  template<class GlobalOrdinal>
67  Epetra_Vector & toEpetra(Vector<double, int, GlobalOrdinal> &);
68 
69  template<class GlobalOrdinal>
70  const Epetra_Vector & toEpetra(const Vector<double, int, GlobalOrdinal> &);
71  //
72 
73  template<class EpetraGlobalOrdinal>
74  class EpetraVectorT
75  : public virtual Vector<double,int,EpetraGlobalOrdinal>, public EpetraMultiVectorT<EpetraGlobalOrdinal>
76  {
77 
78  typedef double Scalar;
79  typedef int LocalOrdinal;
80  typedef EpetraGlobalOrdinal GlobalOrdinal;
82 
83  public:
84 
85  using EpetraMultiVectorT<GlobalOrdinal>::dot; // overloading, not hiding
86  using EpetraMultiVectorT<GlobalOrdinal>::norm1; // overloading, not hiding
87  using EpetraMultiVectorT<GlobalOrdinal>::norm2; // overloading, not hiding
88  using EpetraMultiVectorT<GlobalOrdinal>::normInf; // overloading, not hiding
89  using EpetraMultiVectorT<GlobalOrdinal>::normWeighted; // overloading, not hiding
90  using EpetraMultiVectorT<GlobalOrdinal>::meanValue; // overloading, not hiding
91  using EpetraMultiVectorT<GlobalOrdinal>::replaceGlobalValue; // overloading, not hiding
92  using EpetraMultiVectorT<GlobalOrdinal>::sumIntoGlobalValue; // overloading, not hiding
93  using EpetraMultiVectorT<GlobalOrdinal>::replaceLocalValue; // overloading, not hiding
94  using EpetraMultiVectorT<GlobalOrdinal>::sumIntoLocalValue; // overloading, not hiding
95 
97 
98 
100  explicit EpetraVectorT(const RCP< const Map< LocalOrdinal, GlobalOrdinal, Node > > &map, bool zeroOut=true);
101 
102  // Commenting out since no definition provided in cpp.
104  // EpetraVectorT(const Vector< Scalar, LocalOrdinal, GlobalOrdinal, Node > &source);
105 
107  virtual ~EpetraVectorT() { }
108 
110 
112 
113 
115  void replaceGlobalValue(GlobalOrdinal globalRow, const Scalar &value);
116 
118  void sumIntoGlobalValue(GlobalOrdinal globalRow, const Scalar &value);
119 
121  void replaceLocalValue(LocalOrdinal myRow, const Scalar &value);
122 
124  void sumIntoLocalValue(LocalOrdinal myRow, const Scalar &value);
125 
127 
129 
130 
133 
136 
139 
142 
145 
147  Scalar meanValue() const;
148 
150 
152 
153 
155  std::string description() const;
156 
159 
161 
163 
164 
166  EpetraVectorT(const Teuchos::RCP<Epetra_Vector> &vec) : EpetraMultiVectorT<GlobalOrdinal>(vec) { } // TODO: removed const of Epetra::Vector
167 
169  Epetra_Vector * getEpetra_Vector() const { return (*this->EpetraMultiVectorT<GlobalOrdinal>::getEpetra_MultiVector())(0); }
170  //RCP<Epetra_Vector> getEpetra_Vector() const { return this->EpetraMultiVectorT<GlobalOrdinal>::getEpetra_MultiVector()->getVectorNonConst(0); }
171 
175  EpetraVectorT(const RCP<Epetra_MultiVector> &mv, size_t j);
176 
177 #ifdef HAVE_XPETRA_KOKKOS_REFACTOR
179 
180  typename dual_view_type::t_host_um getHostLocalView () const {
182  }
183 
184  typename dual_view_type::t_dev_um getDeviceLocalView() const {
185  throw std::runtime_error("Epetra does not support device views!");
186  typename dual_view_type::t_dev ret;
187  return ret; // make compiler happy
188  }
189 
200  template<class TargetDeviceType>
201  typename Kokkos::Impl::if_c<
202  Kokkos::Impl::is_same<
203  typename dual_view_type::t_dev_um::execution_space::memory_space,
204  typename TargetDeviceType::memory_space>::value,
205  typename dual_view_type::t_dev_um,
206  typename dual_view_type::t_host_um>::type
207  getLocalView () const {
208  return this->MultiVector< Scalar, LocalOrdinal, GlobalOrdinal, Node >::template getLocalView<TargetDeviceType>();
209  }
210 #endif
211 
213 
214  private:
215 
216  // This private member is only used by the constructor EpetraVectorT(const RCP<EpetraMultiVectorT<GlobalOrdinal> > &mv, size_t j). The actual private member holding the Epetra vector (vec_) is in the base class (Xpetra:EpetraMultiVectorT)
218 
219  }; // EpetraVectorT class
220 
221 #ifndef XPETRA_EPETRA_NO_32BIT_GLOBAL_INDICES
223 #endif
224 
225 #ifdef HAVE_XPETRA_INT_LONG_LONG
226  typedef EpetraVectorT<long long> EpetraVector64;
227 #endif
228 
229 } // Xpetra namespace
230 
231 #endif // XPETRA_EPETRAVECTOR_HPP
void sumIntoGlobalValue(GlobalOrdinal globalRow, const Scalar &value)
Adds specified value to existing value at the specified location.
Epetra_Vector * getEpetra_Vector() const
Get the underlying Epetra vector.
Scalar dot(const Vector< Scalar, LocalOrdinal, GlobalOrdinal, Node > &a) const
Computes dot product of this Vector against input Vector x.
const Epetra_CrsGraph & toEpetra(const RCP< const CrsGraph< int, GlobalOrdinal > > &graph)
EpetraVectorT(const Teuchos::RCP< Epetra_Vector > &vec)
EpetraMultiVectorT constructor to wrap a Epetra_Vector object.
Teuchos::ScalarTraits< Scalar >::magnitudeType normWeighted(const Vector< Scalar, LocalOrdinal, GlobalOrdinal, Node > &weights) const
Compute Weighted 2-norm (RMS Norm) of this Vector.
const RCP< const Epetra_MultiVector > internalRefToBaseMV_
EpetraGlobalOrdinal GlobalOrdinal
void replaceLocalValue(LocalOrdinal myRow, const Scalar &value)
Replace current value at the specified location with specified values.
Xpetra namespace
void sumIntoLocalValue(LocalOrdinal myRow, const Scalar &value)
Adds specified value to existing value at the specified location.
Teuchos::ScalarTraits< Scalar >::magnitudeType norm2() const
Compute 2-norm of this Vector.
EpetraVectorT(const RCP< const Map< LocalOrdinal, GlobalOrdinal, Node > > &map, bool zeroOut=true)
Sets all vector entries to zero.
void describe(Teuchos::FancyOStream &out, const Teuchos::EVerbosityLevel verbLevel=Teuchos::Describable::verbLevel_default) const
Print the object with some verbosity level to an FancyOStream object.
Teuchos::ScalarTraits< Scalar >::magnitudeType norm1() const
Return 1-norm of this Vector.
EpetraVectorT< int > EpetraVector
std::string description() const
Return a simple one-line description of this object.
Scalar meanValue() const
Compute mean (average) value of this Vector.
static const EVerbosityLevel verbLevel_default
void replaceGlobalValue(GlobalOrdinal globalRow, const Scalar &value)
Replace current value at the specified location with specified value.
KokkosClassic::DefaultNode::DefaultNodeType Node
Teuchos::ScalarTraits< Scalar >::magnitudeType normInf() const
Compute Inf-norm of this Vector.
virtual ~EpetraVectorT()
Vector copy constructor.