FEI  Version of the Day
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
fei_Vector_Local.hpp
1 /*--------------------------------------------------------------------*/
2 /* Copyright 2007 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_Vector_Local_hpp_
10 #define _fei_Vector_Local_hpp_
11 
12 #include <fei_iosfwd.hpp>
13 #include <fei_SharedPtr.hpp>
14 #include <fei_VectorSpace.hpp>
15 #include <fei_Vector.hpp>
16 
17 namespace fei {
18 
19 class Vector_Local : public fei::Vector {
20  public:
21  Vector_Local(fei::SharedPtr<fei::VectorSpace> vecSpace);
22 
23  virtual ~Vector_Local();
24 
25  const char* typeName() const { return("fei::Vector_Local"); }
26 
29  int update(double a,
30  const fei::Vector* x,
31  double b);
32 
39  int scatterToOverlap();
40 
41  void setCommSizes();
42 
46  int gatherFromOverlap(bool accumulate = true);
47 
49  int putScalar(double scalar);
50 
54  int sumIn(int numValues, const int* indices, const double* values,
55  int vectorIndex=0);
56 
60  int copyIn(int numValues, const int* indices, const double* values,
61  int vectorIndex=0);
62 
65  fei::SharedPtr<fei::VectorSpace> getVectorSpace() const;
66 
69  void setVectorSpace(fei::SharedPtr<fei::VectorSpace> vecSpace);
70 
77  int sumInFieldData(int fieldID,
78  int idType,
79  int numIDs,
80  const int* IDs,
81  const double* data,
82  int vectorIndex=0);
83 
90  int copyInFieldData(int fieldID,
91  int idType,
92  int numIDs,
93  const int* IDs,
94  const double* data,
95  int vectorIndex=0);
96 
97  int copyInFieldDataLocalIDs(int fieldID,
98  int idType,
99  int numIDs,
100  const int* localIDs,
101  const double* data,
102  int vectorIndex=0);
103 
110  int copyOutFieldData(int fieldID,
111  int idType,
112  int numIDs,
113  const int* IDs,
114  double* data,
115  int vectorIndex=0);
116 
117  int copyOut(int numValues, const int* indices,
118  double* values, int vectorIndex=0) const;
119 
120  int writeToFile(const char* filename,
121  bool matrixMarketFormat=true);
122 
123  int writeToStream(FEI_OSTREAM& ostrm,
124  bool matrixMarketFormat=true);
125 
126  std::vector<double>& getCoefs();
127 
128  private:
129  int giveToVector(int numValues, const int* indices,
130  const double* values,
131  bool sumInto, int vectorIndex);
132 
133  int assembleFieldData(int fieldID,
134  int idType,
135  int numIDs,
136  const int* IDs,
137  const double* data,
138  bool sumInto,
139  int vectorIndex);
140 
141  int assembleFieldDataLocalIDs(int fieldID,
142  int idType,
143  int numIDs,
144  const int* localIDs,
145  const double* data,
146  bool sumInto,
147  int vectorIndex);
148 
150  std::vector<double> coefs_;
151  std::map<int,int> global_to_local_;
152  std::vector<int> work_indices_;
153 };//class Vector_Local
154 
155 }//namespace fei
156 
157 #endif
158 
void writeToStream(snl_fei::RaggedTable< MAP_TYPE, SET_TYPE > &table, FEI_OSTREAM &os, const char *lineprefix=NULL)
std::string typeName(const T &t)