FEI  Version of the Day
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
fei_VectorReducer.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_VectorReducer_hpp_
10 #define _fei_VectorReducer_hpp_
11 
12 #include <fei_iosfwd.hpp>
13 #include <fei_VectorSpace.hpp>
14 #include <fei_Reducer.hpp>
15 #include <fei_Vector.hpp>
16 
17 #undef fei_file
18 #define fei_file "fei_VectorReducer.hpp"
19 
20 #include <fei_ErrMacros.hpp>
21 
22 namespace fei {
23 
24  class VectorReducer : public fei::Vector {
25  public:
26 
28  VectorReducer(fei::SharedPtr<fei::Reducer> reducer,
30  bool isSolutionVector=false);
31 
33  virtual ~VectorReducer();
34 
36  fei::SharedPtr<fei::Vector> getTargetVector()
37  { return(target_); }
38 
42  const char* typeName() const { return(target_->typeName()); }
43 
46  int update(double a,
47  const fei::Vector* x,
48  double b);
49 
56  int scatterToOverlap();
57 
58  void setCommSizes() { target_->setCommSizes(); }
59 
63  int gatherFromOverlap(bool accumulate = true);
64 
66  int putScalar(double scalar);
67 
71  int sumIn(int numValues, const int* indices, const double* values,
72  int vectorIndex=0);
73 
77  int copyIn(int numValues, const int* indices, const double* values,
78  int vectorIndex=0);
79 
82  fei::SharedPtr<fei::VectorSpace> getVectorSpace() const
83  { return(target_->getVectorSpace()); }
84 
87  void setVectorSpace(fei::SharedPtr<fei::VectorSpace> vecSpace)
88  { target_->setVectorSpace( vecSpace ); }
89 
96  int sumInFieldData(int fieldID,
97  int idType,
98  int numIDs,
99  const int* IDs,
100  const double* data,
101  int vectorIndex=0);
102 
109  int copyInFieldData(int fieldID,
110  int idType,
111  int numIDs,
112  const int* IDs,
113  const double* data,
114  int vectorIndex=0);
115 
116  int copyInFieldDataLocalIDs(int fieldID,
117  int idType,
118  int numIDs,
119  const int* localIDs,
120  const double* data,
121  int vectorIndex=0);
122 
129  int copyOutFieldData(int fieldID,
130  int idType,
131  int numIDs,
132  const int* IDs,
133  double* data,
134  int vectorIndex=0);
135 
136  int writeToFile(const char* filename,
137  bool matrixMarketFormat=true);
138 
139  int writeToStream(FEI_OSTREAM& ostrm,
140  bool matrixMarketFormat=true);
141 
142  int copyOut(int numValues,
143  const int* indices,
144  double* values,
145  int vectorIndex=0) const;
146 
147  private:
150  int copyOut_FE(int nodeNumber, int dofOffset, double& value);
151 
152  int giveToUnderlyingVector(int numValues,
153  const int* indices,
154  const double* values,
155  bool sumInto=true,
156  int vectorIndex=0);
157 
158  int sumIntoFEVector(int blockID,
159  int connOffset,
160  int numNodes,
161  const int* nodeNumbers,
162  const int* numIndicesPerNode,
163  const double* values);
164 
167  bool isSolution_;
168 
169  int localProc_;
170  int numProcs_;
171  };//class VectorReducer
172 
173 } //namespace fei
174 
175 #endif // _fei_VectorReducer_hpp_
176 
void writeToStream(snl_fei::RaggedTable< MAP_TYPE, SET_TYPE > &table, FEI_OSTREAM &os, const char *lineprefix=NULL)
std::string typeName(const T &t)