FEI Package Browser (Single Doxygen Collection)  Version of the Day
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
fei_VectorTraits_Aztec.hpp
Go to the documentation of this file.
1 /*
2 // @HEADER
3 // ************************************************************************
4 // FEI: Finite Element Interface to Linear Solvers
5 // Copyright (2005) Sandia Corporation.
6 //
7 // Under the terms of Contract DE-AC04-94AL85000 with Sandia Corporation, the
8 // U.S. Government retains certain rights in this software.
9 //
10 // Redistribution and use in source and binary forms, with or without
11 // modification, are permitted provided that the following conditions are
12 // met:
13 //
14 // 1. Redistributions of source code must retain the above copyright
15 // notice, this list of conditions and the following disclaimer.
16 //
17 // 2. Redistributions in binary form must reproduce the above copyright
18 // notice, this list of conditions and the following disclaimer in the
19 // documentation and/or other materials provided with the distribution.
20 //
21 // 3. Neither the name of the Corporation nor the names of the
22 // contributors may be used to endorse or promote products derived from
23 // this software without specific prior written permission.
24 //
25 // THIS SOFTWARE IS PROVIDED BY SANDIA CORPORATION "AS IS" AND ANY
26 // EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
27 // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
28 // PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL SANDIA CORPORATION OR THE
29 // CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
30 // EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
31 // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
32 // PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
33 // LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
34 // NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
35 // SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
36 //
37 // Questions? Contact Alan Williams (william@sandia.gov)
38 //
39 // ************************************************************************
40 // @HEADER
41 */
42 
43 
44 #ifndef _fei_VectorTraits_Aztec_h_
45 #define _fei_VectorTraits_Aztec_h_
46 
47 #ifdef HAVE_FEI_AZTECOO
48 
49 //
50 //IMPORTANT NOTE: Make sure that wherever this file is included from, it
51 //appears BEFORE any include of fei_base.hpp or fei_Vector.hpp !!!
52 //
53 #include <fei_VectorTraits.hpp>
54 #include <fei_Include_Trilinos.hpp>
55 
56 namespace fei {
63  template<>
64  struct VectorTraits<Aztec_LSVector> {
65  static const char* typeName()
66  { return("fei::Aztec_LSVector"); }
67 
68  static int setValues(Aztec_LSVector* vec, int firstLocalOffset,
69  double scalar, bool isSolnVector=false)
70  {
71  return( vec->put(scalar) );
72  }
73 
74  //note that incoming indices are point-entry indices, not block-indices.
75  static int putValuesIn(Aztec_LSVector* vec,
76  int firstLocalOffset,
77  int numValues,
78  const int* indices,
79  const double* values,
80  bool sum_into,
81  bool isSolnVector=false,
82  int /*vectorIndex=0*/)
83  {
84  double* localVecValues = vec->startPointer();
85  if (sum_into) {
86  for(int i=0; i<numValues; ++i) {
87  localVecValues[indices[i]-firstLocalOffset] += values[i];
88  }
89  }
90  else {
91  for(int i=0; i<numValues; ++i) {
92  localVecValues[indices[i]-firstLocalOffset] = values[i];
93  }
94  }
95  return(0);
96  }
97 
98  //note that incoming indices are point-entry indices, not block-indices.
99  static int copyOut(Aztec_LSVector* vec,
100  int firstLocalOffset,
101  int numValues, const int* indices, double* values,
102  bool isSolnVector=false,
103  int vectorIndex=0)
104  {
105  double* localVecValues = vec->startPointer();
106  for(int i=0; i<numValues; ++i) {
107  values[i] = localVecValues[indices[i]-firstLocalOffset];
108  }
109 
110  return(0);
111  }
112 
113  static double* getLocalCoefsPtr(Aztec_LSVector* vec,
114  bool isSolnVector=false,
115  int vectorIndex=0)
116  {
117  return(vec->startPointer());
118  }
119 
120  static int update(Aztec_LSVector* vec,
121  double a,
122  const Aztec_LSVector* x,
123  double b)
124  {
125  vec->scale(b);
126  vec->addVec(a, x);
127  return(0);
128  }
129 
130  };//struct VectorTraits<Aztec_LSVector>
131 }//namespace fei
132 
133 #endif //HAVE_FEI_AZTECOO
134 
135 #endif // _fei_VectorTraits_Aztec_hpp_
static int putValuesIn(T *vec, int firstLocalOffset, int numValues, const int *indices, const double *values, bool sum_into, bool isSolnVector=false, int vectorIndex=0)
static int update(T *vec, double a, const T *x, double b)
static int setValues(T *vec, int firstLocalOffset, double scalar, bool isSolnVector=false)
static double * getLocalCoefsPtr(T *vec, bool isSolnVector=false, int vectorIndex=0)
static int copyOut(T *vec, int firstLocalOffset, int numValues, const int *indices, double *values, bool isSolnVector=false, int vectorIndex=0)
static const char * typeName()