Stokhos Package Browser (Single Doxygen Collection)  Version of the Day
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Stokhos_VectorOrthogPolyTraitsEpetra.hpp
Go to the documentation of this file.
1 // @HEADER
2 // *****************************************************************************
3 // Stokhos Package
4 //
5 // Copyright 2009 NTESS and the Stokhos contributors.
6 // SPDX-License-Identifier: BSD-3-Clause
7 // *****************************************************************************
8 // @HEADER
9 
10 #ifndef STOKHOS_VECTORORTHOGPOLYTRAITSEPETRA_HPP
11 #define STOKHOS_VECTORORTHOGPOLYTRAITSEPETRA_HPP
12 
13 #include <iostream>
15 #include "Teuchos_RCP.hpp"
16 #include "Epetra_Vector.h"
17 #include "EpetraExt_BlockVector.h"
18 #include "Epetra_Operator.h"
19 #include "Epetra_CrsMatrix.h"
20 
21 namespace Stokhos {
22 
25  public:
27  map(&map_), vec(NULL), block_vec(NULL) {}
29  map(NULL), vec(&vec_), block_vec(NULL) {}
30  EpetraVectorCloner(EpetraExt::BlockVector& block_vec_) :
31  map(NULL), vec(NULL), block_vec(&block_vec_) {}
33  if (map)
34  return Teuchos::rcp(new Epetra_Vector(*map));
35  else if (vec)
36  return Teuchos::rcp(new Epetra_Vector(*vec));
37  else
38  return block_vec->GetBlock(i);
39  }
40  protected:
43  EpetraExt::BlockVector *block_vec;
44  bool view;
45  };
46 
49  public:
51  int num_vectors) :
52  map(&map_), vec(NULL), num_vecs(num_vectors) {}
54  map(NULL), vec(&vec_), num_vecs(vec_.NumVectors()) {}
56  if (map)
58  else
59  return Teuchos::rcp(new Epetra_MultiVector(*vec));
60  }
61  protected:
64  int num_vecs;
65  };
66 
68 
73 
76  public:
77  EpetraCrsMatrixCloner(const Epetra_CrsMatrix& mat_) : mat(mat_) {}
79  return Teuchos::rcp(new Epetra_CrsMatrix(mat));
80  }
81  protected:
83  };
84 
86  template <>
88  public:
89 
91  typedef double value_type;
92 
94  typedef int ordinal_type;
95 
98 
100  static void init(Epetra_Vector& vec, double val) { vec.PutScalar(val); }
101 
103  static void update(Epetra_Vector& vec, double a, const Epetra_Vector& x) {
104  vec.Update(a,x,1.0);
105  }
106 
108  static std::ostream& print(std::ostream& os, const Epetra_Vector& vec) {
109  vec.Print(os);
110  return os;
111  }
112 
113  };
114 
116  template <>
118  public:
119 
121  typedef double value_type;
122 
124  typedef int ordinal_type;
125 
128 
130  static void init(Epetra_MultiVector& vec, double val) {
131  vec.PutScalar(val); }
132 
134  static void update(Epetra_MultiVector& vec, double a,
135  const Epetra_MultiVector& x) {
136  vec.Update(a,x,1.0);
137  }
138 
140  static std::ostream& print(std::ostream& os,
141  const Epetra_MultiVector& vec) {
142  vec.Print(os);
143  return os;
144  }
145 
146  };
147 
149  template <>
151  public:
152 
154  typedef double value_type;
155 
157  typedef int ordinal_type;
158 
161 
163  static void init(Epetra_CrsMatrix& mat, double val) { mat.PutScalar(val); }
164 
166  static void update(Epetra_CrsMatrix& mat, double a,
167  const Epetra_CrsMatrix& x) {
168  int num_col;
169  for (int i=0; i<mat.NumMyRows(); i++) {
170  mat.NumMyRowEntries(i, num_col);
171  for (int j=0; j<num_col; j++)
172  mat[i][j] += a*x[i][j];
173  }
174  }
175 
177  static std::ostream& print(std::ostream& os, const Epetra_CrsMatrix& mat) {
178  mat.Print(os);
179  return os;
180  }
181 
182  };
183 
185  template <>
187  public:
188 
190  typedef double value_type;
191 
193  typedef int ordinal_type;
194 
197 
199  static void init(Epetra_Operator& op, double val) {
200  Epetra_CrsMatrix& mat = dynamic_cast<Epetra_CrsMatrix&>(op);
202  }
203 
205  static void update(Epetra_Operator& op, double a,
206  const Epetra_Operator& x_op) {
207  Epetra_CrsMatrix& mat = dynamic_cast<Epetra_CrsMatrix&>(op);
208  const Epetra_CrsMatrix& x = dynamic_cast<const Epetra_CrsMatrix&>(x_op);
210  }
211 
213  static std::ostream& print(std::ostream& os, const Epetra_Operator& op) {
214  os << "Epetra_Operator" << std::endl;
215  const Epetra_CrsMatrix& mat = dynamic_cast<const Epetra_CrsMatrix&>(op);
217  return os;
218  }
219 
220  };
221 
222 }
223 
224 #endif // STOKHOS_VECTORORTHOGPOLYTRAITSEPETRA_HPP
int NumMyRowEntries(int MyRow, int &NumEntries) const
static std::ostream & print(std::ostream &os, const Epetra_Vector &vec)
Print vector.
static void init(Epetra_MultiVector &vec, double val)
Initialize vector.
virtual void Print(std::ostream &os) const
static std::ostream & print(std::ostream &os, const Epetra_Operator &op)
Print operator.
Cloner for Epetra_Vector coefficients.
EpetraMultiVectorCloner(const Epetra_BlockMap &map_, int num_vectors)
static std::ostream & print(std::ostream &os, const Epetra_CrsMatrix &mat)
Print matrix.
Cloner for Epetra_CrsMatrix coefficients.
int PutScalar(double ScalarConstant)
Base traits definition for ProductContainer.
Teuchos::RCP< Epetra_MultiVector > clone(int i) const
static void init(Epetra_Vector &vec, double val)
Initialize vector.
Cloner for Epetra_Operator coefficients.
TEUCHOS_DEPRECATED RCP< T > rcp(T *p, Dealloc_T dealloc, bool owns_mem)
static void update(Epetra_Vector &vec, double a, const Epetra_Vector &x)
Update vector.
Teuchos::RCP< Epetra_Vector > clone(int i) const
int NumMyRows() const
static void init(Epetra_CrsMatrix &mat, double val)
Initialize matrix.
static std::ostream & print(std::ostream &os, const Epetra_MultiVector &vec)
Print vector.
virtual void Print(std::ostream &os) const
static void init(Epetra_Operator &op, double val)
Initialize operator.
expr val()
static void update(Epetra_Operator &op, double a, const Epetra_Operator &x_op)
Update operator.
Teuchos::RCP< Epetra_CrsMatrix > clone(int i) const
EpetraVectorCloner(EpetraExt::BlockVector &block_vec_)
EpetraMultiVectorCloner(const Epetra_MultiVector &vec_)
static void update(Epetra_MultiVector &vec, double a, const Epetra_MultiVector &x)
Update vector.
Cloner for Epetra_MultiVector coefficients.
static void update(Epetra_CrsMatrix &mat, double a, const Epetra_CrsMatrix &x)
Update matrix.
void update(const ValueType &alpha, VectorType &x, const ValueType &beta, const VectorType &y)