FEI  Version of the Day
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
fei_EqnBuffer.hpp
1 #ifndef _fei_EqnBuffer_hpp_
2 #define _fei_EqnBuffer_hpp_
3 
4 /*--------------------------------------------------------------------*/
5 /* Copyright 2005 Sandia Corporation. */
6 /* Under the terms of Contract DE-AC04-94AL85000, there is a */
7 /* non-exclusive license for use of this work by or on behalf */
8 /* of the U.S. Government. Export of this program may require */
9 /* a license from the United States Government. */
10 /*--------------------------------------------------------------------*/
11 
12 #include "fei_fwd.hpp"
13 
14 #include <vector>
15 
21 class EqnBuffer {
22  public:
24  EqnBuffer();
25 
27  EqnBuffer(const EqnBuffer& src);
28 
30  virtual ~EqnBuffer();
31 
35 
37  EqnBuffer& operator=(const EqnBuffer& src);
38 
40  int getNumEqns() {return(eqnNumbers_.size());};
41 
43  std::vector<int>& eqnNumbers() {return(eqnNumbers_);};
44 
48  std::vector<fei::CSVec*>& eqns() {return(eqns_);};
49 
52  int getNumRHSs() {return(numRHSs_);};
53 
62  void setNumRHSs(int n);
63 
70  int addRHS(int eqnNumber, int rhsIndex, double value, bool accumulate=true);
71 
76  std::vector<std::vector<double>*>* rhsCoefsPtr() {return(&rhsCoefs_);};
77 
83  int getEqnIndex(int eqn);
84 
89  int isInIndices(int eqn);
90 
105  int addEqn(int eqnNumber, const double* coefs, const int* indices,
106  int len, bool accumulate, bool create_indices_union=false);
107 
116  int addEqns(EqnBuffer& inputEqns, bool accumulate);
117 
127  int getCoef(int eqnNumber, int colIndex, double& coef);
128 
134  int removeIndex(int eqnNumber, int colIndex);
135 
141  int getCoefAndRemoveIndex(int eqnNumber, int colIndex, double& coef);
142 
144  void resetCoefs();
145 
147  int addIndices(int eqnNumber, const int* indices, int len);
148 
149  int newCoefData_, newRHSData_;
150 
151  private:
152  void deleteMemory();
153  int insertNewEqn(int eqn, int insertPoint);
154 
155  int internalAddEqn(int index, const double* coefs,
156  const int* indices, int len, bool accumulate);
157 
158  std::vector<int> eqnNumbers_; //list of equation-numbers
159 
160  std::vector<fei::CSVec*> eqns_;
161 
162  std::vector<int> indices_union_; //union of all equation-indices
163 
164  int numRHSs_; //number of right-hand-side coefficients per equation
165  std::vector<std::vector<double>*> rhsCoefs_; //list of vector-pointers, each
166  //vector is of length numRHSs_
167  bool setNumRHSsCalled_;
168  bool rhsCoefsAllocated_;
169 
170  std::vector<double> dummyCoefs_;
171 };
172 
173 std::ostream& operator<<(std::ostream& os, EqnBuffer& eq);
174 
175 #endif
176 
int isInIndices(int eqn)
int addEqn(int eqnNumber, const double *coefs, const int *indices, int len, bool accumulate, bool create_indices_union=false)
std::vector< fei::CSVec * > & eqns()
EqnBuffer & operator=(const EqnBuffer &src)
void setNumRHSs(int n)
std::vector< int > & eqnNumbers()
int addRHS(int eqnNumber, int rhsIndex, double value, bool accumulate=true)
std::vector< std::vector< double > * > * rhsCoefsPtr()
int getNumRHSs()
EqnBuffer * deepCopy()
int getEqnIndex(int eqn)
int getCoefAndRemoveIndex(int eqnNumber, int colIndex, double &coef)
int addEqns(EqnBuffer &inputEqns, bool accumulate)
int addIndices(int eqnNumber, const int *indices, int len)
virtual ~EqnBuffer()
int removeIndex(int eqnNumber, int colIndex)
int getCoef(int eqnNumber, int colIndex, double &coef)
void resetCoefs()
int getNumEqns()
std::ostream & operator<<(std::ostream &out, const SerialBandDenseMatrixPrinter< OrdinalType, ScalarType > printer)