FEI Version of the Day
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 
00186     void setCommSizes() { target_->setCommSizes(); }
00187 
00193     int gatherFromOverlap(bool accumulate = true);
00194 
00196     int writeToFile(const char* filename,
00197         bool matrixMarketFormat=true);
00198 
00201     int writeToStream(FEI_OSTREAM& ostrm,
00202           bool matrixMarketFormat=true);
00203 
00204     bool usingBlockEntryStorage()
00205       { return(target_->usingBlockEntryStorage()); }
00206 
00208     int giveToUnderlyingMatrix(int numRows, const int* rows,
00209              int numCols, const int* cols,
00210              const double* const* values,
00211              bool sumInto,
00212              int format);
00213 
00215     int giveToUnderlyingBlockMatrix(int row,
00216             int rowDim,
00217             int numCols,
00218             const int* cols,
00219             const int* LDAs,
00220             const int* colDims,
00221             const double* const* values,
00222             bool sumInto);
00223 
00224     void markState();
00225 
00226     bool changedSinceMark();
00227 
00228   private:
00229     int giveToMatrix(int numRows, const int* rows,
00230          int numCols, const int* cols,
00231          const double* const* values,
00232          bool sumInto,
00233          int format);
00234  
00235     int giveToBlockMatrix(int numRows, const int* rows,
00236         int numCols, const int* cols,
00237         const double* const* values,
00238         bool sumInto);
00239 
00240     fei::SharedPtr<fei::Reducer> reducer_;
00241     fei::SharedPtr<fei::Matrix> target_;
00242     bool globalAssembleCalled_;
00243     bool changedSinceMark_;
00244   };//class MatrixReducer
00245 }//namespace fei
00246 
00247 #endif
00248 
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Friends