FEI  Version of the Day
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
fei_VectorTraits_LinSysCore.hpp
1 /*--------------------------------------------------------------------*/
2 /* Copyright 2005 Sandia Corporation. */
3 /* Under the terms of Contract DE-AC04-94AL85000, there is a */
4 /* non-exclusive license for use of this work by or on behalf */
5 /* of the U.S. Government. Export of this program may require */
6 /* a license from the United States Government. */
7 /*--------------------------------------------------------------------*/
8 
9 #ifndef _fei_VectorTraits_LinSysCore_hpp_
10 #define _fei_VectorTraits_LinSysCore_hpp_
11 
12 
13 #include <fei_VectorTraits.hpp>
14 #include <fei_LinearSystemCore.hpp>
15 
16 namespace fei {
17 
21  template<>
23 
25  static const char* typeName()
26  { return("LinearSystemCore"); }
27 
30  static int setValues(LinearSystemCore* vec, int firstLocalOffset,
31  double scalar, bool isSolnVector=false)
32  {
33  if (isSolnVector) {
34  //LinearSystemCore doesn't have a 'resetSolnVector()'.
35  return(-1);
36  }
37  int err = vec->resetRHSVector(scalar);
38  return(err);
39  }
40 
44  static int putValuesIn(LinearSystemCore* vec,
45  int firstLocalOffset,
46  int numValues, const int* indices, const double* values,
47  bool sum_into,
48  bool isSolnVector=false,
49  int vectorIndex=0)
50  {
51  int err = 0;
52  if (isSolnVector) {
53  if (sum_into) {
54  return(-97);//LinearSystemCore allows 'put' (overwrite) operations on
55  //the soln-vector, but not 'sumInto'.
56  }
57  else {
58  err = vec->putInitialGuess(indices, values, numValues);
59  }
60  }
61  else {
62  if (sum_into) {
63  err = vec->sumIntoRHSVector(numValues, values, indices);
64  }
65  else {
66  err = vec->putIntoRHSVector(numValues, values, indices);
67  }
68  }
69  return(err);
70  }
71 
75  static int copyOut(LinearSystemCore* vec,
76  int firstLocalOffset,
77  int numValues, const int* indices, double* values,
78  bool isSolnVector=false,
79  int vectorIndex=0)
80  {
81  int err = 0;
82  if (isSolnVector) {
83  for(int i=0; i<numValues; ++i) {
84  if (vec->getSolnEntry(indices[i], values[i]) != 0) return(-1);
85  }
86  }
87  else {
88  err = vec->getFromRHSVector(numValues, values, indices);
89  }
90 
91  return(err);
92  }
93 
96  static int update(LinearSystemCore* vec,
97  double a,
98  const LinearSystemCore* x,
99  double b)
100  { return(-1); }
101 
102  };//struct VectorTraits
103 }//namespace fei
104 
105 #endif // _fei_VectorTraits_LinSysCore_hpp_
static int copyOut(LinearSystemCore *vec, int firstLocalOffset, int numValues, const int *indices, double *values, bool isSolnVector=false, int vectorIndex=0)
virtual int sumIntoRHSVector(int num, const double *values, const int *indices)=0
virtual int getFromRHSVector(int num, double *values, const int *indices)=0
virtual int putIntoRHSVector(int num, const double *values, const int *indices)=0
virtual int resetRHSVector(double s)=0
static int setValues(LinearSystemCore *vec, int firstLocalOffset, double scalar, bool isSolnVector=false)
static int putValuesIn(LinearSystemCore *vec, int firstLocalOffset, int numValues, const int *indices, const double *values, bool sum_into, bool isSolnVector=false, int vectorIndex=0)
static int update(LinearSystemCore *vec, double a, const LinearSystemCore *x, double b)
virtual int putInitialGuess(const int *eqnNumbers, const double *values, int len)=0
virtual int getSolnEntry(int eqnNumber, double &answer)=0