FEI Version of the Day
fei_Reducer.hpp
00001 /*--------------------------------------------------------------------*/
00002 /*    Copyright 2006 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_Reducer_hpp_
00010 #define _fei_Reducer_hpp_
00011 
00012 #include <fei_macros.hpp>
00013 #include <fei_SharedPtr.hpp>
00014 #include <fei_mpi.h>
00015 #include <fei_Logger.hpp>
00016 #include <fei_CSVec.hpp>
00017 #include <fei_FillableMat.hpp>
00018 #include <fei_CSVec.hpp>
00019 #include <fei_CSRMat.hpp>
00020 
00021 namespace fei {
00022   class MatrixGraph;
00023   class Graph;
00024   class Matrix;
00025   class Vector;
00026 
00027   class Reducer : private fei::Logger {
00028    public:
00030     Reducer(fei::SharedPtr<FillableMat> globalSlaveDependencyMatrix,
00031             fei::SharedPtr<CSVec> g_vector,
00032             MPI_Comm comm);
00033 
00034     Reducer(fei::SharedPtr<fei::MatrixGraph> matrixGraph);
00036 
00038 
00040     virtual ~Reducer();
00041 
00043     void setLocalUnreducedEqns(const std::vector<int>& localUnreducedEqns);
00044 
00045     
00049     void addGraphEntries(fei::SharedPtr<fei::SparseRowGraph> matrixGraph);
00050 
00051     void addGraphIndices(int numRows, const int* rows,
00052                          int numCols, const int* cols,
00053                          fei::Graph& graph);
00054 
00055     void addSymmetricGraphIndices(int numIndices, const int* indices,
00056                                   bool diagonal,
00057                                   fei::Graph& graph);
00058 
00066     int addMatrixValues(int numRows, const int* rows,
00067                         int numCols, const int* cols,
00068                         const double* const* values,
00069                         bool sum_into,
00070                         fei::Matrix& feimat,
00071                         int format);
00072 
00098     int addVectorValues(int numValues,
00099                         const int* globalIndices,
00100                         const double* values,
00101                         bool sum_into,
00102                         bool soln_vector,
00103                         int vectorIndex,
00104                         fei::Vector& feivec);
00105 
00106     int copyOutVectorValues(int numValues,
00107                              const int* globalIndices,
00108                              double* values,
00109                              bool soln_vector,
00110                              int vectorIndex,
00111                              fei::Vector& feivec);
00112 
00113     void getSlaveMasterEqns(int slaveEqn, std::vector<int>& masterEqns);
00114     bool isSlaveEqn(int unreducedEqn) const;
00115     bool isSlaveCol(int unreducedEqn) const;
00116 
00121     int translateToReducedEqn(int unreducedEqn) const;
00122     int translateFromReducedEqn(int reduced_eqn) const;
00123     void assembleReducedGraph(fei::Graph* graph,
00124                               bool global_gather=true);
00125     void assembleReducedGraph(fei::SparseRowGraph* srgraph);
00126     void assembleReducedMatrix(fei::Matrix& matrix);
00127     void assembleReducedVector(bool soln_vector,
00128                                fei::Vector& feivec);
00129 
00130     std::vector<int>& getLocalReducedEqns();
00131 
00132     void initialize();
00133    private:
00134     void expand_work_arrays(int size);
00135 
00136     fei::CSRMat csrD_;
00137     int* slavesPtr_;
00138     fei::FillableMat Kii_, Kid_, Kdi_, Kdd_;
00139     fei::CSRMat csrKii, csrKid, csrKdi, csrKdd;
00140     fei::CSVec fi_, fd_;
00141     fei::CSVec csfi, csvec, csvec_i;
00142     fei::CSRMat tmpMat1_, tmpMat2_;
00143     fei::CSVec tmpVec1_, tmpVec2_;
00144 
00145     fei::CSVec csg_;
00146     bool g_nonzero_;
00147 
00148     std::vector<int> localUnreducedEqns_;
00149     std::vector<int> localReducedEqns_;
00150     std::vector<int> nonslaves_;
00151     std::vector<int> reverse_;
00152     bool* isSlaveEqn_;
00153     int numGlobalSlaves_;
00154     int numLocalSlaves_;
00155     int firstLocalReducedEqn_;
00156     int lastLocalReducedEqn_;
00157     int lowestGlobalSlaveEqn_;
00158     int highestGlobalSlaveEqn_;
00159 
00160     int localProc_;
00161     int numProcs_;
00162     MPI_Comm comm_;
00163     std::string dbgprefix_;
00164     unsigned mat_counter_;
00165     unsigned rhs_vec_counter_;
00166 
00167     bool* bool_array_;
00168     int* int_array_;
00169     double* double_array_;
00170     int array_len_;
00171 
00172     std::vector<double> work_1D_;
00173     std::vector<const double*> work_2D_;
00174   };//class Reducer
00175 
00176 }//namespace fei
00177 
00178 #endif // _fei_Reducer_hpp_
00179 
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Friends