fei_MatrixReducer.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_MatrixReducer_hpp_
00010 #define _fei_MatrixReducer_hpp_
00011 
00012 #include <fei_iosfwd.hpp>
00013 #include <fei_mpi.h>
00014 #include <fei_defs.h>
00015 
00016 #include <fei_Matrix.hpp>
00017 #include <fei_Reducer.hpp>
00018 #include <fei_MatrixGraph.hpp>
00019 #include <fei_Matrix_core.hpp>
00020 
00021 #undef fei_file
00022 #define fei_file "fei_MatrixReducer.hpp"
00023 #include <fei_ErrMacros.hpp>
00024 
00025 namespace fei {
00026 
00027   class MatrixReducer : public fei::Matrix {
00028   public:
00030     MatrixReducer(fei::SharedPtr<fei::Reducer> reducer,
00031                   fei::SharedPtr<fei::Matrix> target);
00032 
00034     virtual ~MatrixReducer();
00035 
00037     fei::SharedPtr<fei::Matrix> getTargetMatrix()
00038       { return(target_); }
00039 
00043     const char* typeName() { return(target_->typeName()); }
00044 
00047     int parameters(const fei::ParameterSet& paramset);
00048 
00049     fei::SharedPtr<fei::MatrixGraph> getMatrixGraph() const
00050       {return( target_->getMatrixGraph() ); }
00051 
00053     void setMatrixGraph(fei::SharedPtr<fei::MatrixGraph> matrixGraph);
00054 
00057     int getGlobalNumRows() const;
00058 
00061     int getLocalNumRows() const;
00062 
00064     int putScalar(double scalar);
00065 
00071     int getRowLength(int row, int& length) const;
00072 
00082     int copyOutRow(int row, int len, double* coefs, int* indices) const;
00083 
00095     int sumIn(int numRows, const int* rows,
00096         int numCols, const int* cols,
00097         const double* const* values,
00098         int format=0);
00099 
00111     int copyIn(int numRows, const int* rows,
00112          int numCols, const int* cols,
00113          const double* const* values,
00114          int format=0);
00115 
00131     int sumInFieldData(int fieldID,
00132            int idType,
00133            int rowID,
00134            int colID,
00135            const double* const* data,
00136            int format=0);
00137 
00155     int sumInFieldData(int fieldID,
00156            int idType,
00157            int rowID,
00158            int colID,
00159            const double* data,
00160            int format=0);
00161 
00171     int sumIn(int blockID, int connectivityID,
00172         const double* const* values,
00173         int format=0);
00174 
00179     int globalAssemble();
00180 
00183     int multiply(fei::Vector* x,
00184      fei::Vector* y);
00185 
00191     int gatherFromOverlap(bool accumulate = true);
00192 
00194     int writeToFile(const char* filename,
00195         bool matrixMarketFormat=true);
00196 
00199     int writeToStream(FEI_OSTREAM& ostrm,
00200           bool matrixMarketFormat=true);
00201 
00202     bool usingBlockEntryStorage()
00203       { return(target_->usingBlockEntryStorage()); }
00204 
00206     int giveToUnderlyingMatrix(int numRows, const int* rows,
00207              int numCols, const int* cols,
00208              const double* const* values,
00209              bool sumInto,
00210              int format);
00211 
00213     int giveToUnderlyingBlockMatrix(int row,
00214             int rowDim,
00215             int numCols,
00216             const int* cols,
00217             const int* LDAs,
00218             const int* colDims,
00219             const double* const* values,
00220             bool sumInto);
00221 
00222     void markState();
00223 
00224     bool changedSinceMark();
00225 
00226   private:
00227     int giveToMatrix(int numRows, const int* rows,
00228          int numCols, const int* cols,
00229          const double* const* values,
00230          bool sumInto,
00231          int format);
00232  
00233     int giveToBlockMatrix(int numRows, const int* rows,
00234         int numCols, const int* cols,
00235         const double* const* values,
00236         bool sumInto);
00237 
00238     fei::SharedPtr<fei::Reducer> reducer_;
00239     fei::SharedPtr<fei::Matrix> target_;
00240     bool globalAssembleCalled_;
00241     bool changedSinceMark_;
00242   };//class MatrixReducer
00243 }//namespace fei
00244 
00245 #endif
00246 
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Friends
Generated on Wed Apr 13 10:08:24 2011 for FEI by  doxygen 1.6.3