Stokhos Package Browser (Single Doxygen Collection) Version of the Day
Loading...
Searching...
No Matches
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
55namespace 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_) {}
66 Teuchos::RCP<Epetra_Vector> clone(int i) const {
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()) {}
89 Teuchos::RCP<Epetra_MultiVector> clone(int i) const {
90 if (map)
91 return Teuchos::rcp(new Epetra_MultiVector(*map, num_vecs));
92 else
93 return Teuchos::rcp(new Epetra_MultiVector(*vec));
94 }
95 protected:
99 };
100
102
107
110 public:
112 Teuchos::RCP<Epetra_CrsMatrix> clone(int i) const {
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
expr val()
int PutScalar(double ScalarConstant)
virtual void Print(std::ostream &os) const
int NumMyRowEntries(int MyRow, int &NumEntries) const
int NumMyRows() const
virtual void Print(std::ostream &os) const
int Update(double ScalarA, const Epetra_MultiVector &A, double ScalarThis)
int PutScalar(double ScalarConstant)
Cloner for Epetra_CrsMatrix coefficients.
Teuchos::RCP< Epetra_CrsMatrix > clone(int i) const
Cloner for Epetra_MultiVector coefficients.
Teuchos::RCP< Epetra_MultiVector > clone(int i) const
EpetraMultiVectorCloner(const Epetra_BlockMap &map_, int num_vectors)
Cloner for Epetra_Operator coefficients.
Cloner for Epetra_Vector coefficients.
EpetraVectorCloner(EpetraExt::BlockVector &block_vec_)
Teuchos::RCP< Epetra_Vector > clone(int i) const
static void update(Epetra_CrsMatrix &mat, double a, const Epetra_CrsMatrix &x)
Update matrix.
static void init(Epetra_CrsMatrix &mat, double val)
Initialize matrix.
static std::ostream & print(std::ostream &os, const Epetra_CrsMatrix &mat)
Print matrix.
static void init(Epetra_MultiVector &vec, double val)
Initialize vector.
static void update(Epetra_MultiVector &vec, double a, const Epetra_MultiVector &x)
Update vector.
static std::ostream & print(std::ostream &os, const Epetra_MultiVector &vec)
Print vector.
static std::ostream & print(std::ostream &os, const Epetra_Operator &op)
Print operator.
static void update(Epetra_Operator &op, double a, const Epetra_Operator &x_op)
Update operator.
static void init(Epetra_Operator &op, double val)
Initialize operator.
static void update(Epetra_Vector &vec, double a, const Epetra_Vector &x)
Update vector.
static std::ostream & print(std::ostream &os, const Epetra_Vector &vec)
Print vector.
static void init(Epetra_Vector &vec, double val)
Initialize vector.
Base traits definition for ProductContainer.
Top-level namespace for Stokhos classes and functions.