FEI Version of the Day
fei_EqnBuffer.hpp
00001 /*
00002 // @HEADER
00003 // ************************************************************************
00004 //             FEI: Finite Element Interface to Linear Solvers
00005 //                  Copyright (2005) Sandia Corporation.
00006 //
00007 // Under the terms of Contract DE-AC04-94AL85000 with Sandia Corporation, the
00008 // U.S. Government retains certain rights in this software.
00009 //
00010 // Redistribution and use in source and binary forms, with or without
00011 // modification, are permitted provided that the following conditions are
00012 // met:
00013 //
00014 // 1. Redistributions of source code must retain the above copyright
00015 // notice, this list of conditions and the following disclaimer.
00016 //
00017 // 2. Redistributions in binary form must reproduce the above copyright
00018 // notice, this list of conditions and the following disclaimer in the
00019 // documentation and/or other materials provided with the distribution.
00020 //
00021 // 3. Neither the name of the Corporation nor the names of the
00022 // contributors may be used to endorse or promote products derived from
00023 // this software without specific prior written permission.
00024 //
00025 // THIS SOFTWARE IS PROVIDED BY SANDIA CORPORATION "AS IS" AND ANY
00026 // EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
00027 // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
00028 // PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL SANDIA CORPORATION OR THE
00029 // CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
00030 // EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
00031 // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
00032 // PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
00033 // LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
00034 // NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
00035 // SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
00036 //
00037 // Questions? Contact Alan Williams (william@sandia.gov) 
00038 //
00039 // ************************************************************************
00040 // @HEADER
00041 */
00042 
00043 #ifndef _fei_EqnBuffer_hpp_
00044 #define _fei_EqnBuffer_hpp_
00045 
00046 
00047 #include "fei_fwd.hpp"
00048 
00049 #include <vector>
00050 
00056 class EqnBuffer {
00057  public:
00059   EqnBuffer();
00060 
00062   EqnBuffer(const EqnBuffer& src);
00063 
00065   virtual ~EqnBuffer();
00066 
00069    EqnBuffer* deepCopy();
00070 
00072    EqnBuffer& operator=(const EqnBuffer& src);
00073 
00075    int getNumEqns() {return(eqnNumbers_.size());};
00076 
00078    std::vector<int>& eqnNumbers() {return(eqnNumbers_);};
00079 
00083    std::vector<fei::CSVec*>& eqns() {return(eqns_);};
00084 
00087    int getNumRHSs() {return(numRHSs_);};
00088 
00097    void setNumRHSs(int n);
00098 
00105    int addRHS(int eqnNumber, int rhsIndex, double value, bool accumulate=true);
00106 
00111    std::vector<std::vector<double>*>* rhsCoefsPtr() {return(&rhsCoefs_);};
00112 
00118    int getEqnIndex(int eqn);
00119 
00124    int isInIndices(int eqn);
00125 
00140    int addEqn(int eqnNumber, const double* coefs, const int* indices,
00141                int len, bool accumulate, bool create_indices_union=false);
00142 
00151    int addEqns(EqnBuffer& inputEqns, bool accumulate);
00152 
00162    int getCoef(int eqnNumber, int colIndex, double& coef);
00163 
00169    int removeIndex(int eqnNumber, int colIndex);
00170 
00176    int getCoefAndRemoveIndex(int eqnNumber, int colIndex, double& coef);
00177 
00179    void resetCoefs();
00180 
00182    int addIndices(int eqnNumber, const int* indices, int len);
00183 
00184    int newCoefData_, newRHSData_;
00185 
00186  private:
00187    void deleteMemory();
00188    int insertNewEqn(int eqn, int insertPoint);
00189 
00190    int internalAddEqn(int index, const double* coefs,
00191                        const int* indices, int len, bool accumulate);
00192 
00193    std::vector<int> eqnNumbers_; //list of equation-numbers
00194 
00195    std::vector<fei::CSVec*> eqns_;
00196 
00197    std::vector<int> indices_union_; //union of all equation-indices
00198 
00199    int numRHSs_;     //number of right-hand-side coefficients per equation
00200    std::vector<std::vector<double>*> rhsCoefs_; //list of vector-pointers, each 
00201                                           //vector is of length numRHSs_
00202    bool setNumRHSsCalled_;
00203    bool rhsCoefsAllocated_;
00204 
00205    std::vector<double> dummyCoefs_;
00206 };
00207 
00208 std::ostream& operator<<(std::ostream& os, EqnBuffer& eq);
00209 
00210 #endif
00211 
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Friends