FEI Version of the Day
fei_Matrix_core.hpp
00001 #ifndef _fei_Matrix_core_hpp_
00002 #define _fei_Matrix_core_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_macros.hpp>
00013 #include <fei_mpi.h>
00014 #include <fei_EqnComm.hpp>
00015 #include <fei_fwd.hpp>
00016 #include <fei_Vector.hpp>
00017 #include <fei_CommUtils.hpp>
00018 #include <fei_FillableMat.hpp>
00019 #include <fei_MatrixGraph.hpp>
00020 #include <fei_Logger.hpp>
00021 
00022 #include <vector>
00023 
00024 namespace fei {
00025 class Matrix_core : protected fei::Logger {
00026  public:
00027 
00028   Matrix_core(fei::SharedPtr<fei::MatrixGraph> matrixGraph, int numLocalEqns);
00029 
00030   virtual ~Matrix_core();
00031 
00032   virtual int giveToMatrix(int numRows, const int* rows,
00033                            int numCols, const int* cols,
00034                            const double* const* values,
00035                            bool sumInto,
00036                            int format) = 0;
00037 
00062   static void copyTransposeToWorkArrays(int numRows, int numCols,
00063                                        const double*const* values,
00064                                        std::vector<double>& work_1D,
00065                                        std::vector<const double*>& work_2D);
00066 
00073   void setRHS(fei::SharedPtr<fei::Vector> rhsvector);
00074 
00079   void setSlaveInfo(fei::SharedPtr<fei::MatrixGraph> matrixGraph);
00080 
00081   fei::SharedPtr<fei::MatrixGraph> getMatrixGraph() const { return( matrixGraph_ ); }
00082 
00083   std::vector<FillableMat*>& getRemotelyOwnedMatrix() { return( remotelyOwned_ ); }
00084 
00085   void setEqnComm(fei::SharedPtr<fei::EqnComm> eqnComm);
00086 
00087  protected:
00088   void parameters(const fei::ParameterSet& paramset);
00089 
00090   virtual int giveToUnderlyingMatrix(int numRows, const int* rows,
00091                                      int numCols, const int* cols,
00092                                      const double* const* values,
00093                                      bool sumInto,
00094                                      int format) = 0;
00095 
00096   virtual int giveToBlockMatrix(int numRows, const int* rows,
00097                                           int numCols, const int* cols,
00098                                           const double* const* values,
00099                                           bool sumInto) = 0;
00100 
00101   virtual int giveToUnderlyingBlockMatrix(int row,
00102                                           int rowDim,
00103                                           int numCols,
00104                                           const int* cols,
00105                                           const int* LDAs,
00106                                           const int* colDims,
00107                                           const double* const* values,
00108                                           bool sumInto) = 0;
00109 
00110   void setName(const char* name);
00111 
00112   int gatherFromOverlap(bool accumulate);
00113 
00114   void setMatrixGraph(fei::SharedPtr<fei::MatrixGraph> matrixGraph);
00115 
00125   int copyPointRowsToBlockRow(int numPtRows,
00126                               int numPtCols,
00127                               const double*const* ptValues,
00128                               int numBlkCols,
00129                               const int* blkColDims,
00130                               double** blkValues);
00131 
00132   int convertPtToBlk(int numRows,
00133                        const int* rows,
00134                        int numCols,
00135                        const int* cols,
00136                        int* blkRows,
00137                        int* blkRowOffsets,
00138                        int* blkCols,
00139                        int* blkColOffsets);
00140 
00141   MPI_Comm getCommunicator() const { return( comm_ ); }
00142 
00143   const fei::SharedPtr<fei::VectorSpace> vecSpace() const { return( vecSpace_ ); }
00144   fei::SharedPtr<fei::VectorSpace> vecSpace() { return( vecSpace_ ); }
00145 
00146   std::vector<int>& globalOffsets() { return( globalOffsets_ ); }
00147   const std::vector<int>& globalOffsets() const { return( globalOffsets_ ); }
00148 
00149   int firstLocalOffset() const { return( firstLocalOffset_ ); }
00150   int lastLocalOffset() const  { return( lastLocalOffset_ ); }
00151 
00152   int numProcs() const { return( numProcs_ ); }
00153   int localProc() const { return( localProc_ ); }
00154 
00155   bool haveBlockMatrix() const { return( haveBlockMatrix_ ); }
00156   void setBlockMatrix(bool flag) {haveBlockMatrix_ = flag; }
00157 
00158   bool haveFEMatrix() const { return( haveFEMatrix_ ); }
00159   void setFEMatrix(bool flag) {haveFEMatrix_ = flag; }
00160 
00161   int getOwnerProc(int globalEqn);
00162 
00163   std::string name_;
00164 
00165   std::vector<int> work_indices_;
00166   std::vector<int> work_indices2_;
00167 
00168   std::vector<int> work_ints_;
00169 
00170   std::vector<double> work_data1D_;
00171   std::vector<const double*> work_data2D_;
00172 
00173  protected:
00174   fei::SharedPtr<fei::EqnComm> eqnComm_;
00175 
00176  private:
00177   fei::SharedPtr<fei::Vector> rhsVector_;
00178 
00179   MPI_Comm comm_;
00180 
00181   int localProc_, numProcs_;
00182 
00183   fei::SharedPtr<fei::VectorSpace> vecSpace_;
00184   fei::SharedPtr<fei::MatrixGraph> matrixGraph_;
00185 
00186   std::vector<FillableMat*> remotelyOwned_;
00187 
00188   bool haveBlockMatrix_;
00189   bool haveFEMatrix_;
00190 
00191   std::vector<int> globalOffsets_;
00192   int firstLocalOffset_, lastLocalOffset_;
00193 };//class Matrix_core
00194 }//namespace fei
00195 
00196 #endif
00197 
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Friends