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_FillableVec.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                                bool sum_into=true);
00130 
00131     std::vector<int>& getLocalReducedEqns();
00132 
00133     void initialize();
00134    private:
00135     void expand_work_arrays(int size);
00136 
00137     fei::CSRMat csrD_;
00138     int* slavesPtr_;
00139     fei::FillableMat Kii_, Kid_, Kdi_, Kdd_;
00140     fei::CSRMat csrKii, csrKid, csrKdi, csrKdd;
00141     fei::FillableVec fi_, fd_;
00142     fei::CSVec csfi, csvec, csvec_i;
00143     fei::CSRMat tmpMat1_, tmpMat2_;
00144     fei::CSVec tmpVec1_, tmpVec2_;
00145 
00146     fei::CSVec csg_;
00147     bool g_nonzero_;
00148 
00149     std::vector<int> localUnreducedEqns_;
00150     std::vector<int> localReducedEqns_;
00151     std::vector<int> nonslaves_;
00152     std::vector<int> reverse_;
00153     bool* isSlaveEqn_;
00154     int numGlobalSlaves_;
00155     int numLocalSlaves_;
00156     int firstLocalReducedEqn_;
00157     int lastLocalReducedEqn_;
00158     int lowestGlobalSlaveEqn_;
00159     int highestGlobalSlaveEqn_;
00160 
00161     int localProc_;
00162     int numProcs_;
00163     MPI_Comm comm_;
00164     std::string dbgprefix_;
00165     unsigned mat_counter_;
00166     unsigned rhs_vec_counter_;
00167 
00168     bool* bool_array_;
00169     int* int_array_;
00170     double* double_array_;
00171     int array_len_;
00172 
00173     std::vector<double> work_1D_;
00174     std::vector<const double*> work_2D_;
00175   };//class Reducer
00176 
00177 }//namespace fei
00178 
00179 #endif // _fei_Reducer_hpp_
00180 
 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