FEI Version of the Day
fei_Vector_core.hpp
00001 /*--------------------------------------------------------------------*/
00002 /*    Copyright 2005 Sandia Corporation.                              */
00003 /*    Under the terms of Contract DE-AC04-94AL85000, there is a       */
00004 /*    non-exclusive license for use of this work by or on behalf      */
00005 /*    of the U.S. Government.  Export of this program may require     */
00006 /*    a license from the United States Government.                    */
00007 /*--------------------------------------------------------------------*/
00008 
00009 #ifndef _fei_Vector_core_hpp_
00010 #define _fei_Vector_core_hpp_
00011 
00012 #include <fei_iosfwd.hpp>
00013 #include <fei_CSVec.hpp>
00014 #include <fei_VectorSpace.hpp>
00015 #include <fei_Reducer.hpp>
00016 #include <fei_Logger.hpp>
00017 #include <fei_SharedPtr.hpp>
00018 #include <fei_EqnComm.hpp>
00019 
00020 namespace fei {
00021 
00023 class Vector_core : protected fei::Logger {
00024  public:
00026   Vector_core(fei::SharedPtr<fei::VectorSpace> vecSpace, int numLocalEqns);
00027 
00029   virtual ~Vector_core();
00030 
00036   int copyOut(int numValues,
00037         const int* indices,
00038         double* values,
00039         int vectorIndex=0) const;
00040 
00042   virtual int sumIntoFEVector(int blockID,
00043             int connOffset,
00044             int numNodes,
00045             const int* nodeNumbers,
00046             const int* numIndicesPerNode,
00047             const int* dof_ids,
00048             const double* values) = 0;
00049 
00051   virtual int copyOut_FE(int nodeNumber, int dofOffset, double& value) = 0;
00052 
00054   int giveToVector(int numValues,
00055        const int* indices,
00056        const double* values,
00057        bool sumInto=true,
00058        int vectorIndex=0);
00059 
00061   virtual int scatterToOverlap();
00062 
00066   void setOverlap(int numRemoteEqns=0, const int* remoteEqns=NULL);
00067 
00068  protected:
00070   int assembleFieldData(int fieldID,
00071       int idType,
00072       int numIDs,
00073       const int* IDs,
00074       const double* data,
00075       bool sumInto=true,
00076       int vectorIndex=0);
00077 
00079   virtual int gatherFromOverlap(bool accumulate = true);
00080 
00082   virtual int copyOutFieldData(int fieldID,
00083              int idType,
00084              int numIDs,
00085              const int* IDs,
00086              double* data,
00087              int vectorIndex=0);
00088 
00090   virtual int giveToUnderlyingVector(int numValues,
00091              const int* indices,
00092              const double* values,
00093              bool sumInto=true,
00094              int vectorIndex=0) = 0;
00095 
00097   virtual int copyOutOfUnderlyingVector(int numValues,
00098           const int* indices,
00099           double* values,
00100           int vectorIndex=0) const = 0;
00101 
00104   virtual int writeToFile(const char* filename,
00105         bool matrixMarketFormat=true);
00106 
00108   virtual int writeToStream(FEI_OSTREAM& ostrm,
00109           bool matrixMarketFormat=true);
00110 
00112   fei::SharedPtr<fei::VectorSpace> get_vector_space() const
00113     {
00114       return( vecSpace_ );
00115     }
00116 
00118   void set_vector_space(fei::SharedPtr<fei::VectorSpace> vspace)
00119     {
00120       vecSpace_ = vspace;
00121     }
00122 
00124   int firstLocalOffset() const { return( firstLocalOffset_ ); }
00125 
00127   int lastLocalOffset() const { return( lastLocalOffset_ ); }
00128 
00130   std::vector<int>& work_indices() { return( work_indices_ ); }
00132   std::vector<int>& work_indices2(){ return( work_indices2_); }
00133 
00135   bool haveFEVector() { return( haveFEVector_ ); }
00137   void setFEVector(bool flag) {haveFEVector_ = flag; }
00138 
00140   std::vector<CSVec*>& remotelyOwned() { return( remotelyOwned_ ); }
00141   const std::vector<CSVec*>& remotelyOwned() const { return( remotelyOwned_ ); }
00142 
00143  protected:
00144   fei::SharedPtr<fei::EqnComm> eqnComm_;
00145 
00146  private:
00147   fei::SharedPtr<fei::VectorSpace> vecSpace_;
00148 
00149   MPI_Comm comm_;
00150 
00151   int firstLocalOffset_, lastLocalOffset_, numLocal_;
00152 
00153   std::vector<int> work_indices_;
00154   std::vector<int> work_indices2_;
00155 
00156   bool haveFEVector_;
00157 
00158   std::vector<CSVec*> remotelyOwned_;
00159   std::vector<int> sendProcs_;
00160   std::vector<int> recvProcs_;
00161   std::vector<int> recv_sizes_;
00162   bool sendRecvProcsNeedUpdated_;
00163 
00164   bool overlapAlreadySet_;
00165   std::string dbgprefix_;
00166 };//class Vector_core
00167 
00168 }//namespace fei
00169 
00170 #endif
00171 
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Friends