Stokhos Package Browser (Single Doxygen Collection)  Version of the Day
Stokhos_VectorOrthogPolyTraitsEpetra.hpp
Go to the documentation of this file.
1 // $Id$
2 // $Source$
3 // @HEADER
4 // ***********************************************************************
5 //
6 // Stokhos Package
7 // Copyright (2009) Sandia Corporation
8 //
9 // Under terms of Contract DE-AC04-94AL85000, there is a non-exclusive
10 // license for use of this work by or on behalf of the U.S. Government.
11 //
12 // Redistribution and use in source and binary forms, with or without
13 // modification, are permitted provided that the following conditions are
14 // met:
15 //
16 // 1. Redistributions of source code must retain the above copyright
17 // notice, this list of conditions and the following disclaimer.
18 //
19 // 2. Redistributions in binary form must reproduce the above copyright
20 // notice, this list of conditions and the following disclaimer in the
21 // documentation and/or other materials provided with the distribution.
22 //
23 // 3. Neither the name of the Corporation nor the names of the
24 // contributors may be used to endorse or promote products derived from
25 // this software without specific prior written permission.
26 //
27 // THIS SOFTWARE IS PROVIDED BY SANDIA CORPORATION "AS IS" AND ANY
28 // EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
29 // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
30 // PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL SANDIA CORPORATION OR THE
31 // CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
32 // EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
33 // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
34 // PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
35 // LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
36 // NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
37 // SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
38 //
39 // Questions? Contact Eric T. Phipps (etphipp@sandia.gov).
40 //
41 // ***********************************************************************
42 // @HEADER
43 
44 #ifndef STOKHOS_VECTORORTHOGPOLYTRAITSEPETRA_HPP
45 #define STOKHOS_VECTORORTHOGPOLYTRAITSEPETRA_HPP
46 
47 #include <iostream>
49 #include "Teuchos_RCP.hpp"
50 #include "Epetra_Vector.h"
51 #include "EpetraExt_BlockVector.h"
52 #include "Epetra_Operator.h"
53 #include "Epetra_CrsMatrix.h"
54 
55 namespace Stokhos {
56 
59  public:
61  map(&map_), vec(NULL), block_vec(NULL) {}
63  map(NULL), vec(&vec_), block_vec(NULL) {}
64  EpetraVectorCloner(EpetraExt::BlockVector& block_vec_) :
65  map(NULL), vec(NULL), block_vec(&block_vec_) {}
67  if (map)
68  return Teuchos::rcp(new Epetra_Vector(*map));
69  else if (vec)
70  return Teuchos::rcp(new Epetra_Vector(*vec));
71  else
72  return block_vec->GetBlock(i);
73  }
74  protected:
77  EpetraExt::BlockVector *block_vec;
78  bool view;
79  };
80 
83  public:
85  int num_vectors) :
86  map(&map_), vec(NULL), num_vecs(num_vectors) {}
88  map(NULL), vec(&vec_), num_vecs(vec_.NumVectors()) {}
90  if (map)
92  else
93  return Teuchos::rcp(new Epetra_MultiVector(*vec));
94  }
95  protected:
98  int num_vecs;
99  };
100 
102 
107 
110  public:
113  return Teuchos::rcp(new Epetra_CrsMatrix(mat));
114  }
115  protected:
117  };
118 
120  template <>
122  public:
123 
125  typedef double value_type;
126 
128  typedef int ordinal_type;
129 
132 
134  static void init(Epetra_Vector& vec, double val) { vec.PutScalar(val); }
135 
137  static void update(Epetra_Vector& vec, double a, const Epetra_Vector& x) {
138  vec.Update(a,x,1.0);
139  }
140 
142  static std::ostream& print(std::ostream& os, const Epetra_Vector& vec) {
143  vec.Print(os);
144  return os;
145  }
146 
147  };
148 
150  template <>
152  public:
153 
155  typedef double value_type;
156 
158  typedef int ordinal_type;
159 
162 
164  static void init(Epetra_MultiVector& vec, double val) {
165  vec.PutScalar(val); }
166 
168  static void update(Epetra_MultiVector& vec, double a,
169  const Epetra_MultiVector& x) {
170  vec.Update(a,x,1.0);
171  }
172 
174  static std::ostream& print(std::ostream& os,
175  const Epetra_MultiVector& vec) {
176  vec.Print(os);
177  return os;
178  }
179 
180  };
181 
183  template <>
185  public:
186 
188  typedef double value_type;
189 
191  typedef int ordinal_type;
192 
195 
197  static void init(Epetra_CrsMatrix& mat, double val) { mat.PutScalar(val); }
198 
200  static void update(Epetra_CrsMatrix& mat, double a,
201  const Epetra_CrsMatrix& x) {
202  int num_col;
203  for (int i=0; i<mat.NumMyRows(); i++) {
204  mat.NumMyRowEntries(i, num_col);
205  for (int j=0; j<num_col; j++)
206  mat[i][j] += a*x[i][j];
207  }
208  }
209 
211  static std::ostream& print(std::ostream& os, const Epetra_CrsMatrix& mat) {
212  mat.Print(os);
213  return os;
214  }
215 
216  };
217 
219  template <>
221  public:
222 
224  typedef double value_type;
225 
227  typedef int ordinal_type;
228 
231 
233  static void init(Epetra_Operator& op, double val) {
234  Epetra_CrsMatrix& mat = dynamic_cast<Epetra_CrsMatrix&>(op);
236  }
237 
239  static void update(Epetra_Operator& op, double a,
240  const Epetra_Operator& x_op) {
241  Epetra_CrsMatrix& mat = dynamic_cast<Epetra_CrsMatrix&>(op);
242  const Epetra_CrsMatrix& x = dynamic_cast<const Epetra_CrsMatrix&>(x_op);
244  }
245 
247  static std::ostream& print(std::ostream& os, const Epetra_Operator& op) {
248  os << "Epetra_Operator" << std::endl;
249  const Epetra_CrsMatrix& mat = dynamic_cast<const Epetra_CrsMatrix&>(op);
251  return os;
252  }
253 
254  };
255 
256 }
257 
258 #endif // STOKHOS_VECTORORTHOGPOLYTRAITSEPETRA_HPP
Stokhos::ProductContainerTraits< Epetra_CrsMatrix >::update
static void update(Epetra_CrsMatrix &mat, double a, const Epetra_CrsMatrix &x)
Update matrix.
Definition: Stokhos_VectorOrthogPolyTraitsEpetra.hpp:200
cusp::detail::device::num_vectors
const IndexType num_vectors
Definition: csr_vector.h:277
Epetra_CrsMatrix::NumMyRowEntries
int NumMyRowEntries(int MyRow, int &NumEntries) const
Stokhos::ProductContainerTraits< Epetra_Operator >::ordinal_type
int ordinal_type
Typename of ordinals.
Definition: Stokhos_VectorOrthogPolyTraitsEpetra.hpp:227
Teuchos_RCP.hpp
Stokhos::EpetraCrsMatrixCloner::clone
Teuchos::RCP< Epetra_CrsMatrix > clone(int i) const
Definition: Stokhos_VectorOrthogPolyTraitsEpetra.hpp:112
Stokhos::EpetraVectorCloner::EpetraVectorCloner
EpetraVectorCloner(EpetraExt::BlockVector &block_vec_)
Definition: Stokhos_VectorOrthogPolyTraitsEpetra.hpp:64
Stokhos::ProductContainerTraits< Epetra_Vector >::init
static void init(Epetra_Vector &vec, double val)
Initialize vector.
Definition: Stokhos_VectorOrthogPolyTraitsEpetra.hpp:134
Stokhos::ProductContainerTraits< Epetra_MultiVector >::init
static void init(Epetra_MultiVector &vec, double val)
Initialize vector.
Definition: Stokhos_VectorOrthogPolyTraitsEpetra.hpp:164
Stokhos::ProductContainerTraits< Epetra_Operator >::cloner_type
EpetraOperatorCloner cloner_type
Typename of cloner.
Definition: Stokhos_VectorOrthogPolyTraitsEpetra.hpp:230
Stokhos::EpetraCrsMatrixCloner::mat
const Epetra_CrsMatrix & mat
Definition: Stokhos_VectorOrthogPolyTraitsEpetra.hpp:116
Stokhos::ProductContainerTraits< Epetra_MultiVector >::print
static std::ostream & print(std::ostream &os, const Epetra_MultiVector &vec)
Print vector.
Definition: Stokhos_VectorOrthogPolyTraitsEpetra.hpp:174
Epetra_CrsMatrix::PutScalar
int PutScalar(double ScalarConstant)
Epetra_MultiVector::PutScalar
int PutScalar(double ScalarConstant)
Stokhos::EpetraVectorCloner::view
bool view
Definition: Stokhos_VectorOrthogPolyTraitsEpetra.hpp:78
Stokhos::EpetraVectorCloner::block_vec
EpetraExt::BlockVector * block_vec
Definition: Stokhos_VectorOrthogPolyTraitsEpetra.hpp:77
Stokhos::ProductContainerTraits< Epetra_CrsMatrix >::ordinal_type
int ordinal_type
Typename of ordinals.
Definition: Stokhos_VectorOrthogPolyTraitsEpetra.hpp:191
Epetra_CrsMatrix.h
Teuchos::rcp
TEUCHOS_DEPRECATED RCP< T > rcp(T *p, Dealloc_T dealloc, bool owns_mem)
Stokhos::ProductContainerTraits< Epetra_CrsMatrix >::print
static std::ostream & print(std::ostream &os, const Epetra_CrsMatrix &mat)
Print matrix.
Definition: Stokhos_VectorOrthogPolyTraitsEpetra.hpp:211
Epetra_Vector.h
Stokhos::EpetraMultiVectorCloner::EpetraMultiVectorCloner
EpetraMultiVectorCloner(const Epetra_MultiVector &vec_)
Definition: Stokhos_VectorOrthogPolyTraitsEpetra.hpp:87
Stokhos_VectorOrthogPoly.hpp
Stokhos::ProductContainerTraits< Epetra_MultiVector >::update
static void update(Epetra_MultiVector &vec, double a, const Epetra_MultiVector &x)
Update vector.
Definition: Stokhos_VectorOrthogPolyTraitsEpetra.hpp:168
Epetra_CrsMatrix::NumMyRows
int NumMyRows() const
Stokhos::EpetraMultiVectorCloner
Cloner for Epetra_MultiVector coefficients.
Definition: Stokhos_VectorOrthogPolyTraitsEpetra.hpp:82
Teuchos::map
Teuchos::RCP< Epetra_Vector >
Epetra_MultiVector::Print
virtual void Print(std::ostream &os) const
Epetra_CrsMatrix
Stokhos::EpetraVectorCloner
Cloner for Epetra_Vector coefficients.
Definition: Stokhos_VectorOrthogPolyTraitsEpetra.hpp:58
Stokhos::ProductContainerTraits< Epetra_Operator >::value_type
double value_type
Typename of values.
Definition: Stokhos_VectorOrthogPolyTraitsEpetra.hpp:224
Stokhos::EpetraVectorCloner::map
const Epetra_BlockMap * map
Definition: Stokhos_VectorOrthogPolyTraitsEpetra.hpp:75
Stokhos::ProductContainerTraits< Epetra_Vector >::print
static std::ostream & print(std::ostream &os, const Epetra_Vector &vec)
Print vector.
Definition: Stokhos_VectorOrthogPolyTraitsEpetra.hpp:142
Stokhos::ProductContainerTraits
Base traits definition for ProductContainer.
Definition: Stokhos_ProductContainer.hpp:53
val
expr val()
Stokhos::ProductContainerTraits< Epetra_MultiVector >::value_type
double value_type
Typename of values.
Definition: Stokhos_VectorOrthogPolyTraitsEpetra.hpp:155
Stokhos::ProductContainerTraits< Epetra_Operator >::print
static std::ostream & print(std::ostream &os, const Epetra_Operator &op)
Print operator.
Definition: Stokhos_VectorOrthogPolyTraitsEpetra.hpp:247
Stokhos::EpetraVectorCloner::clone
Teuchos::RCP< Epetra_Vector > clone(int i) const
Definition: Stokhos_VectorOrthogPolyTraitsEpetra.hpp:66
Stokhos::EpetraMultiVectorCloner::clone
Teuchos::RCP< Epetra_MultiVector > clone(int i) const
Definition: Stokhos_VectorOrthogPolyTraitsEpetra.hpp:89
Stokhos::EpetraOperatorCloner
Cloner for Epetra_Operator coefficients.
Definition: Stokhos_VectorOrthogPolyTraitsEpetra.hpp:106
Stokhos::ProductContainerTraits< Epetra_CrsMatrix >::cloner_type
EpetraCrsMatrixCloner cloner_type
Typename of cloner.
Definition: Stokhos_VectorOrthogPolyTraitsEpetra.hpp:194
Stokhos::ProductContainerTraits< Epetra_Operator >::init
static void init(Epetra_Operator &op, double val)
Initialize operator.
Definition: Stokhos_VectorOrthogPolyTraitsEpetra.hpp:233
Stokhos::ProductContainerTraits< Epetra_MultiVector >::cloner_type
EpetraMultiVectorCloner cloner_type
Typename of cloner.
Definition: Stokhos_VectorOrthogPolyTraitsEpetra.hpp:161
Stokhos::ProductContainerTraits< Epetra_Vector >::update
static void update(Epetra_Vector &vec, double a, const Epetra_Vector &x)
Update vector.
Definition: Stokhos_VectorOrthogPolyTraitsEpetra.hpp:137
Stokhos::EpetraVectorCloner::EpetraVectorCloner
EpetraVectorCloner(const Epetra_Vector &vec_)
Definition: Stokhos_VectorOrthogPolyTraitsEpetra.hpp:62
Stokhos::ProductContainerTraits< Epetra_Operator >::update
static void update(Epetra_Operator &op, double a, const Epetra_Operator &x_op)
Update operator.
Definition: Stokhos_VectorOrthogPolyTraitsEpetra.hpp:239
Stokhos::EpetraVectorCloner::EpetraVectorCloner
EpetraVectorCloner(const Epetra_BlockMap &map_)
Definition: Stokhos_VectorOrthogPolyTraitsEpetra.hpp:60
Stokhos
Top-level namespace for Stokhos classes and functions.
Definition: Stokhos_AbstractPreconditionerFactory.hpp:48
Stokhos::EpetraMultiVectorCloner::num_vecs
int num_vecs
Definition: Stokhos_VectorOrthogPolyTraitsEpetra.hpp:98
Stokhos::EpetraMultiVectorCloner::map
const Epetra_BlockMap * map
Definition: Stokhos_VectorOrthogPolyTraitsEpetra.hpp:96
j
j
Definition: Sacado_Fad_Exp_MP_Vector.hpp:527
Epetra_BlockMap
Epetra_Vector
cusp::detail::device::x
const IndexType const IndexType const IndexType const IndexType const ValueType const ValueType * x
Definition: csr_vector.h:260
Epetra_MultiVector
Stokhos::ProductContainerTraits< Epetra_CrsMatrix >::value_type
double value_type
Typename of values.
Definition: Stokhos_VectorOrthogPolyTraitsEpetra.hpp:188
Stokhos::EpetraMultiVectorCloner::EpetraMultiVectorCloner
EpetraMultiVectorCloner(const Epetra_BlockMap &map_, int num_vectors)
Definition: Stokhos_VectorOrthogPolyTraitsEpetra.hpp:84
Stokhos::ProductContainerTraits< Epetra_Vector >::value_type
double value_type
Typename of values.
Definition: Stokhos_VectorOrthogPolyTraitsEpetra.hpp:125
Stokhos::EpetraCrsMatrixCloner
Cloner for Epetra_CrsMatrix coefficients.
Definition: Stokhos_VectorOrthogPolyTraitsEpetra.hpp:109
Stokhos::ProductContainerTraits< Epetra_MultiVector >::ordinal_type
int ordinal_type
Typename of ordinals.
Definition: Stokhos_VectorOrthogPolyTraitsEpetra.hpp:158
Stokhos::EpetraMultiVectorCloner::vec
const Epetra_MultiVector * vec
Definition: Stokhos_VectorOrthogPolyTraitsEpetra.hpp:97
Stokhos::update
void update(const ValueType &alpha, VectorType &x, const ValueType &beta, const VectorType &y)
Definition: Stokhos_Update.hpp:87
Stokhos::ProductContainerTraits< Epetra_Vector >::ordinal_type
int ordinal_type
Typename of ordinals.
Definition: Stokhos_VectorOrthogPolyTraitsEpetra.hpp:128
Stokhos::EpetraVectorCloner::vec
const Epetra_Vector * vec
Definition: Stokhos_VectorOrthogPolyTraitsEpetra.hpp:76
Stokhos::EpetraCrsMatrixCloner::EpetraCrsMatrixCloner
EpetraCrsMatrixCloner(const Epetra_CrsMatrix &mat_)
Definition: Stokhos_VectorOrthogPolyTraitsEpetra.hpp:111
Epetra_Operator
Stokhos::ProductContainerTraits< Epetra_CrsMatrix >::init
static void init(Epetra_CrsMatrix &mat, double val)
Initialize matrix.
Definition: Stokhos_VectorOrthogPolyTraitsEpetra.hpp:197
Epetra_CrsMatrix::Print
virtual void Print(std::ostream &os) const
Stokhos::ProductContainerTraits< Epetra_Vector >::cloner_type
EpetraVectorCloner cloner_type
Typename of cloner.
Definition: Stokhos_VectorOrthogPolyTraitsEpetra.hpp:131
Epetra_Operator.h
Epetra_MultiVector::Update
int Update(double ScalarA, const Epetra_MultiVector &A, double ScalarThis)