fei_EqnBuffer.hpp

00001 #ifndef _fei_EqnBuffer_hpp_
00002 #define _fei_EqnBuffer_hpp_
00003 
00004 /*--------------------------------------------------------------------*/
00005 /*    Copyright 2005 Sandia Corporation.                              */
00006 /*    Under the terms of Contract DE-AC04-94AL85000, there is a       */
00007 /*    non-exclusive license for use of this work by or on behalf      */
00008 /*    of the U.S. Government.  Export of this program may require     */
00009 /*    a license from the United States Government.                    */
00010 /*--------------------------------------------------------------------*/
00011 
00012 #include "fei_fwd.hpp"
00013 
00014 #include <vector>
00015 
00021 class EqnBuffer {
00022  public:
00024   EqnBuffer();
00025 
00027   EqnBuffer(const EqnBuffer& src);
00028 
00030   virtual ~EqnBuffer();
00031 
00034    EqnBuffer* deepCopy();
00035 
00037    EqnBuffer& operator=(const EqnBuffer& src);
00038 
00040    int getNumEqns() {return(eqnNumbers_.size());};
00041 
00043    std::vector<int>& eqnNumbers() {return(eqnNumbers_);};
00044 
00048    std::vector<fei::CSVec*>& eqns() {return(eqns_);};
00049 
00052    int getNumRHSs() {return(numRHSs_);};
00053 
00062    void setNumRHSs(int n);
00063 
00070    int addRHS(int eqnNumber, int rhsIndex, double value, bool accumulate=true);
00071 
00076    std::vector<std::vector<double>*>* rhsCoefsPtr() {return(&rhsCoefs_);};
00077 
00083    int getEqnIndex(int eqn);
00084 
00089    int isInIndices(int eqn);
00090 
00105    int addEqn(int eqnNumber, const double* coefs, const int* indices,
00106                int len, bool accumulate, bool create_indices_union=false);
00107 
00116    int addEqns(EqnBuffer& inputEqns, bool accumulate);
00117 
00127    int getCoef(int eqnNumber, int colIndex, double& coef);
00128 
00134    int removeIndex(int eqnNumber, int colIndex);
00135 
00141    int getCoefAndRemoveIndex(int eqnNumber, int colIndex, double& coef);
00142 
00144    void resetCoefs();
00145 
00147    int addIndices(int eqnNumber, const int* indices, int len);
00148 
00149    int newCoefData_, newRHSData_;
00150 
00151  private:
00152    void deleteMemory();
00153    int insertNewEqn(int eqn, int insertPoint);
00154 
00155    int internalAddEqn(int index, const double* coefs,
00156                        const int* indices, int len, bool accumulate);
00157 
00158    std::vector<int> eqnNumbers_; //list of equation-numbers
00159 
00160    std::vector<fei::CSVec*> eqns_;
00161 
00162    std::vector<int> indices_union_; //union of all equation-indices
00163 
00164    int numRHSs_;     //number of right-hand-side coefficients per equation
00165    std::vector<std::vector<double>*> rhsCoefs_; //list of vector-pointers, each 
00166                                           //vector is of length numRHSs_
00167    bool setNumRHSsCalled_;
00168    bool rhsCoefsAllocated_;
00169 
00170    std::vector<double> dummyCoefs_;
00171 };
00172 
00173 std::ostream& operator<<(std::ostream& os, EqnBuffer& eq);
00174 
00175 #endif
00176 

Generated on Wed May 12 21:30:41 2010 for FEI by  doxygen 1.4.7