fei_EqnCommMgr.hpp

00001 #ifndef _fei_EqnCommMgr_hpp_
00002 #define _fei_EqnCommMgr_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 #include "fei_mpi.h"
00014 
00015 #include "snl_fei_PointBlockMap.hpp"
00016 
00017 #include <fei_CSRMat.hpp>
00018 #include <fei_CSVec.hpp>
00019 #include <fei_CommUtils.hpp>
00020 #include "fei_ProcEqns.hpp"
00021 #include "fei_EqnBuffer.hpp"
00022 
00104 class EqnCommMgr {
00105  public:
00109    EqnCommMgr(MPI_Comm comm, bool accumulate = true);
00110 
00112    EqnCommMgr(const EqnCommMgr& src);
00113 
00115    EqnCommMgr& operator=(const EqnCommMgr& src);
00116 
00118    virtual ~EqnCommMgr();
00119 
00121    EqnCommMgr* deepCopy();
00122 
00126    size_t getNumSharingProcs() {return(recvProcEqns_->getNumProcs());};
00127    std::vector<int>& sharingProcsPtr() {return(recvProcEqns_->procsPtr());};
00128 
00132    size_t getNumOwnerProcs() {return(sendProcEqns_->getNumProcs());};
00133    std::vector<int>& ownerProcsPtr() {return(sendProcEqns_->procsPtr());};
00134 
00136    void addLocalEqn(int eqnNumber, int srcProc);
00137 
00138    void addSolnValues(int* eqnNumbers, double* values, int num);
00139 
00140 #ifdef FEI_HAVE_IOSFWD
00141    int exchangeIndices(std::ostream* dbgOut=NULL);
00142    int exchangeEqns(std::ostream* dbgOut=NULL);
00143 #else
00144    int exchangeIndices(ostream* dbgOut=NULL);
00145    int exchangeEqns(ostream* dbgOut=NULL);
00146 #endif
00147 
00148    void exchangeSoln();
00149 
00173    int mirrorProcEqns(ProcEqns& inProcEqns, ProcEqns& outProcEqns);
00174 
00187    int mirrorProcEqnLengths(ProcEqns& inProcEqns,
00188           ProcEqns& outProcEqns);
00189 
00190 
00191    static int exchangeEqnBuffers(MPI_Comm comm, ProcEqns* sendProcEqns,
00192          EqnBuffer* sendEqns, ProcEqns* recvProcEqns,
00193          EqnBuffer* recvEqns, bool accumulate);
00194 
00195    int getNumLocalEqns() {return(recvEqns_->getNumEqns());};
00196 
00197    std::vector<int>& localEqnNumbers() {return(recvEqns_->eqnNumbers());};
00198    std::vector<fei::CSVec*>& localEqns(){return(recvEqns_->eqns());};
00199    std::vector<std::vector<double>*>* localRHSsPtr()
00200      {return(recvEqns_->rhsCoefsPtr());};
00201 
00202    int addRemoteEqn(int eqnNumber, int destProc, const double* coefs,
00203                    const int* indices, int num);
00204 
00205    int addRemoteEqn(int eqnNumber, const double* coefs,
00206         const int* indices, int num);
00207 
00208    int addRemoteEqns(fei::CSRMat& mat, bool onlyIndices);
00209    int addRemoteRHS(fei::CSVec& vec, int rhsIndex);
00210 
00211    void setNumRHSs(int numRHSs);
00212 
00213    int addRemoteRHS(int eqnNumber, int destProc, int rhsIndex, double value);
00214 
00215    int addRemoteRHS(int eqnNumber, int rhsIndex, double value);
00216 
00217    void addRemoteIndices(int eqnNumber, int destProc, int* indices, int num);
00218 
00219    int getNumRemoteEqns() {return(sendEqns_->getNumEqns());};
00220 
00221    std::vector<int>& sendEqnNumbersPtr() {return(sendEqns_->eqnNumbers());};
00222 
00223    double* sendEqnSolnPtr() {return(sendEqnSoln_.size()>0? &sendEqnSoln_[0] : NULL);};
00224 
00225    void resetCoefs();
00226 
00227    int gatherSharedBCs(EqnBuffer& bcEqns);
00228 
00229    int exchangeRemEssBCs(int* essEqns, int numEssEqns, double* essAlpha,
00230        double* essGamma, MPI_Comm comm,
00231        std::ostream* dbgOut = NULL);
00232 
00233    int getNumRemEssBCEqns() {return(essBCEqns_->getNumEqns());};
00234    std::vector<int>& remEssBCEqnNumbersPtr() {return(essBCEqns_->eqnNumbers());};
00235    std::vector<fei::CSVec*>& remEssBCEqns() {return(essBCEqns_->eqns());};
00236 
00237    int exchangePtToBlkInfo(snl_fei::PointBlockMap& blkEqnMapper);
00238 
00239    bool newCoefData() {if (recvEqns_->newCoefData_>0) return(true);
00240                        else return(false);}
00241    bool newRHSData() {if (recvEqns_->newRHSData_>0) return(true);
00242                       else return(false);}
00243 
00244    bool accumulate_;
00245 
00246    EqnBuffer* getRecvEqns() { return( recvEqns_ ); }
00247    EqnBuffer* getSendEqns() { return( sendEqns_ ); }
00248    ProcEqns* getRecvProcEqns() { return( recvProcEqns_ ); }
00249    ProcEqns* getSendProcEqns() { return( sendProcEqns_ ); }
00250 
00251  private:
00252    void deleteEssBCs();
00253    int getSendProcNumber(int eqn);
00254 
00255    int consistencyCheck(const char* caller,
00256       std::vector<int>& recvProcs,
00257       std::vector<int>& recvProcTotalLengths,
00258       std::vector<int>& sendProcs,
00259       std::vector<int>& sendProcTotalLengths);
00260 
00261    int localProc_;
00262 
00263    ProcEqns* recvProcEqns_;
00264 
00265    bool exchangeIndicesCalled_; //whether or not the exchangeIndices function
00266                                 //has been called yet.
00267 
00268    EqnBuffer* recvEqns_;
00269 
00270    std::vector<double> solnValues_; //solution values we'll need to return to the
00271                               //processors that contribute to our equations
00272 
00273    ProcEqns* sendProcEqns_;
00274 
00275    EqnBuffer* sendEqns_;
00276 
00277    std::vector<double> sendEqnSoln_; 
00278                           //the solution values for the send equations. i.e.,
00279                           //we'll recv these solution values for the equations
00280                           //that we contributed to (sent) for other processors.
00281 
00282    EqnBuffer* essBCEqns_;
00283 
00284    MPI_Comm comm_;
00285 };
00286 
00287 #endif
00288 

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