FEI Version of the Day
fei_MatrixReducer.hpp
00001 /*
00002 // @HEADER
00003 // ************************************************************************
00004 //             FEI: Finite Element Interface to Linear Solvers
00005 //                  Copyright (2005) Sandia Corporation.
00006 //
00007 // Under the terms of Contract DE-AC04-94AL85000 with Sandia Corporation, the
00008 // U.S. Government retains certain rights in this software.
00009 //
00010 // Redistribution and use in source and binary forms, with or without
00011 // modification, are permitted provided that the following conditions are
00012 // met:
00013 //
00014 // 1. Redistributions of source code must retain the above copyright
00015 // notice, this list of conditions and the following disclaimer.
00016 //
00017 // 2. Redistributions in binary form must reproduce the above copyright
00018 // notice, this list of conditions and the following disclaimer in the
00019 // documentation and/or other materials provided with the distribution.
00020 //
00021 // 3. Neither the name of the Corporation nor the names of the
00022 // contributors may be used to endorse or promote products derived from
00023 // this software without specific prior written permission.
00024 //
00025 // THIS SOFTWARE IS PROVIDED BY SANDIA CORPORATION "AS IS" AND ANY
00026 // EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
00027 // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
00028 // PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL SANDIA CORPORATION OR THE
00029 // CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
00030 // EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
00031 // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
00032 // PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
00033 // LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
00034 // NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
00035 // SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
00036 //
00037 // Questions? Contact Alan Williams (william@sandia.gov) 
00038 //
00039 // ************************************************************************
00040 // @HEADER
00041 */
00042 
00043 
00044 #ifndef _fei_MatrixReducer_hpp_
00045 #define _fei_MatrixReducer_hpp_
00046 
00047 #include <fei_iosfwd.hpp>
00048 #include <fei_mpi.h>
00049 #include <fei_defs.h>
00050 
00051 #include <fei_Matrix.hpp>
00052 #include <fei_Reducer.hpp>
00053 #include <fei_MatrixGraph.hpp>
00054 #include <fei_Matrix_core.hpp>
00055 
00056 #undef fei_file
00057 #define fei_file "fei_MatrixReducer.hpp"
00058 #include <fei_ErrMacros.hpp>
00059 
00060 namespace fei {
00061 
00062   class MatrixReducer : public fei::Matrix {
00063   public:
00065     MatrixReducer(fei::SharedPtr<fei::Reducer> reducer,
00066                   fei::SharedPtr<fei::Matrix> target);
00067 
00069     virtual ~MatrixReducer();
00070 
00072     fei::SharedPtr<fei::Matrix> getTargetMatrix()
00073       { return(target_); }
00074 
00078     const char* typeName() { return(target_->typeName()); }
00079 
00082     int parameters(const fei::ParameterSet& paramset);
00083 
00084     fei::SharedPtr<fei::MatrixGraph> getMatrixGraph() const
00085       {return( target_->getMatrixGraph() ); }
00086 
00088     void setMatrixGraph(fei::SharedPtr<fei::MatrixGraph> matrixGraph);
00089 
00092     int getGlobalNumRows() const;
00093 
00096     int getLocalNumRows() const;
00097 
00099     int putScalar(double scalar);
00100 
00106     int getRowLength(int row, int& length) const;
00107 
00117     int copyOutRow(int row, int len, double* coefs, int* indices) const;
00118 
00130     int sumIn(int numRows, const int* rows,
00131         int numCols, const int* cols,
00132         const double* const* values,
00133         int format=0);
00134 
00146     int copyIn(int numRows, const int* rows,
00147          int numCols, const int* cols,
00148          const double* const* values,
00149          int format=0);
00150 
00166     int sumInFieldData(int fieldID,
00167            int idType,
00168            int rowID,
00169            int colID,
00170            const double* const* data,
00171            int format=0);
00172 
00190     int sumInFieldData(int fieldID,
00191            int idType,
00192            int rowID,
00193            int colID,
00194            const double* data,
00195            int format=0);
00196 
00206     int sumIn(int blockID, int connectivityID,
00207         const double* const* values,
00208         int format=0);
00209 
00214     int globalAssemble();
00215 
00218     int multiply(fei::Vector* x,
00219      fei::Vector* y);
00220 
00226     int gatherFromOverlap(bool accumulate = true);
00227 
00229     int writeToFile(const char* filename,
00230         bool matrixMarketFormat=true);
00231 
00234     int writeToStream(FEI_OSTREAM& ostrm,
00235           bool matrixMarketFormat=true);
00236 
00237     bool usingBlockEntryStorage()
00238       { return(target_->usingBlockEntryStorage()); }
00239 
00241     int giveToUnderlyingMatrix(int numRows, const int* rows,
00242              int numCols, const int* cols,
00243              const double* const* values,
00244              bool sumInto,
00245              int format);
00246 
00248     int giveToUnderlyingBlockMatrix(int row,
00249             int rowDim,
00250             int numCols,
00251             const int* cols,
00252             const int* LDAs,
00253             const int* colDims,
00254             const double* const* values,
00255             bool sumInto);
00256 
00257     void markState();
00258 
00259     bool changedSinceMark();
00260 
00261   private:
00262     int giveToMatrix(int numRows, const int* rows,
00263          int numCols, const int* cols,
00264          const double* const* values,
00265          bool sumInto,
00266          int format);
00267  
00268     int giveToBlockMatrix(int numRows, const int* rows,
00269         int numCols, const int* cols,
00270         const double* const* values,
00271         bool sumInto);
00272 
00273     fei::SharedPtr<fei::Reducer> reducer_;
00274     fei::SharedPtr<fei::Matrix> target_;
00275     bool globalAssembleCalled_;
00276     bool changedSinceMark_;
00277   };//class MatrixReducer
00278 }//namespace fei
00279 
00280 #endif
00281 
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Friends