FEI  Version of the Day
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
fei_MatrixReducer.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_MatrixReducer_hpp_
10 #define _fei_MatrixReducer_hpp_
11 
12 #include <fei_iosfwd.hpp>
13 #include <fei_mpi.h>
14 #include <fei_defs.h>
15 
16 #include <fei_Matrix.hpp>
17 #include <fei_Reducer.hpp>
18 #include <fei_MatrixGraph.hpp>
19 #include <fei_Matrix_core.hpp>
20 
21 #undef fei_file
22 #define fei_file "fei_MatrixReducer.hpp"
23 #include <fei_ErrMacros.hpp>
24 
25 namespace fei {
26 
27  class MatrixReducer : public fei::Matrix {
28  public:
30  MatrixReducer(fei::SharedPtr<fei::Reducer> reducer,
32 
34  virtual ~MatrixReducer();
35 
37  fei::SharedPtr<fei::Matrix> getTargetMatrix()
38  { return(target_); }
39 
43  const char* typeName() { return(target_->typeName()); }
44 
47  int parameters(const fei::ParameterSet& paramset);
48 
49  fei::SharedPtr<fei::MatrixGraph> getMatrixGraph() const
50  {return( target_->getMatrixGraph() ); }
51 
53  void setMatrixGraph(fei::SharedPtr<fei::MatrixGraph> matrixGraph);
54 
57  int getGlobalNumRows() const;
58 
61  int getLocalNumRows() const;
62 
64  int putScalar(double scalar);
65 
71  int getRowLength(int row, int& length) const;
72 
82  int copyOutRow(int row, int len, double* coefs, int* indices) const;
83 
95  int sumIn(int numRows, const int* rows,
96  int numCols, const int* cols,
97  const double* const* values,
98  int format=0);
99 
111  int copyIn(int numRows, const int* rows,
112  int numCols, const int* cols,
113  const double* const* values,
114  int format=0);
115 
131  int sumInFieldData(int fieldID,
132  int idType,
133  int rowID,
134  int colID,
135  const double* const* data,
136  int format=0);
137 
155  int sumInFieldData(int fieldID,
156  int idType,
157  int rowID,
158  int colID,
159  const double* data,
160  int format=0);
161 
171  int sumIn(int blockID, int connectivityID,
172  const double* const* values,
173  int format=0);
174 
179  int globalAssemble();
180 
183  int multiply(fei::Vector* x,
184  fei::Vector* y);
185 
186  void setCommSizes() { target_->setCommSizes(); }
187 
193  int gatherFromOverlap(bool accumulate = true);
194 
196  int writeToFile(const char* filename,
197  bool matrixMarketFormat=true);
198 
201  int writeToStream(FEI_OSTREAM& ostrm,
202  bool matrixMarketFormat=true);
203 
204  bool usingBlockEntryStorage()
205  { return(target_->usingBlockEntryStorage()); }
206 
208  int giveToUnderlyingMatrix(int numRows, const int* rows,
209  int numCols, const int* cols,
210  const double* const* values,
211  bool sumInto,
212  int format);
213 
215  int giveToUnderlyingBlockMatrix(int row,
216  int rowDim,
217  int numCols,
218  const int* cols,
219  const int* LDAs,
220  const int* colDims,
221  const double* const* values,
222  bool sumInto);
223 
224  void markState();
225 
226  bool changedSinceMark();
227 
228  private:
229  int giveToMatrix(int numRows, const int* rows,
230  int numCols, const int* cols,
231  const double* const* values,
232  bool sumInto,
233  int format);
234 
235  int giveToBlockMatrix(int numRows, const int* rows,
236  int numCols, const int* cols,
237  const double* const* values,
238  bool sumInto);
239 
242  bool globalAssembleCalled_;
243  bool changedSinceMark_;
244  };//class MatrixReducer
245 }//namespace fei
246 
247 #endif
248 
void writeToStream(snl_fei::RaggedTable< MAP_TYPE, SET_TYPE > &table, FEI_OSTREAM &os, const char *lineprefix=NULL)
std::string typeName(const T &t)