/[escript]/branches/trilinos_from_5897/paso/src/SystemMatrix.h
ViewVC logotype

Diff of /branches/trilinos_from_5897/paso/src/SystemMatrix.h

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 5932 by caltinay, Fri Feb 5 03:37:49 2016 UTC revision 5933 by caltinay, Wed Feb 17 23:53:30 2016 UTC
# Line 31  Line 31 
31    
32  #include "SparseMatrix.h"  #include "SparseMatrix.h"
33  #include "SystemMatrixPattern.h"  #include "SystemMatrixPattern.h"
34  #include "Options.h"  
35    #include <escript/AbstractSystemMatrix.h>
36    
37  namespace paso {  namespace paso {
38    
39  struct SystemMatrix;  class Options;
40    class SystemMatrix;
41  typedef boost::shared_ptr<SystemMatrix> SystemMatrix_ptr;  typedef boost::shared_ptr<SystemMatrix> SystemMatrix_ptr;
42  typedef boost::shared_ptr<const SystemMatrix> const_SystemMatrix_ptr;  typedef boost::shared_ptr<const SystemMatrix> const_SystemMatrix_ptr;
43    
44  typedef int SystemMatrixType;  typedef int SystemMatrixType;
45    
46  //  this struct holds a (distributed) stiffness matrix  /// this class holds a (distributed) stiffness matrix
47  PASO_DLL_API  class SystemMatrix : public escript::AbstractSystemMatrix,
48  struct SystemMatrix : boost::enable_shared_from_this<SystemMatrix>                       public boost::enable_shared_from_this<SystemMatrix>
49  {  {
50      SystemMatrix(SystemMatrixType, SystemMatrixPattern_ptr, dim_t, dim_t,  public:
51                   bool patternIsUnrolled);      /// default constructor - throws exception.
52        SystemMatrix();
53    
54        SystemMatrix(SystemMatrixType type, SystemMatrixPattern_ptr pattern,
55                     dim_t rowBlockSize, dim_t columnBlockSize,
56                     bool patternIsUnrolled, const escript::FunctionSpace& rowFS,
57                     const escript::FunctionSpace& colFS);
58    
59      ~SystemMatrix();      ~SystemMatrix();
60    
# Line 54  struct SystemMatrix : boost::enable_shar Line 62  struct SystemMatrix : boost::enable_shar
62      /// The rows and columns are marked by positive values in mask_row and      /// The rows and columns are marked by positive values in mask_row and
63      /// mask_col. Values on the main diagonal which are marked to set to      /// mask_col. Values on the main diagonal which are marked to set to
64      /// zero by both mask_row and mask_col are set to main_diagonal_value.      /// zero by both mask_row and mask_col are set to main_diagonal_value.
65      void nullifyRowsAndCols(double* mask_row, double* mask_col,      virtual void nullifyRowsAndCols(escript::Data& mask_row,
66                              double main_diagonal_value);                                      escript::Data& mask_col,
67                                        double main_diagonal_value);
68    
69        virtual inline void saveMM(const std::string& filename) const
70        {
71            if (mpi_info->size > 1) {
72                Esys_setError(IO_ERROR, "SystemMatrix::saveMM: Only single rank supported.");
73            } else {
74                mainBlock->saveMM(filename.c_str());
75            }
76        }
77    
78        virtual inline void saveHB(const std::string& filename) const
79        {
80            if (mpi_info->size > 1) {
81                Esys_setError(TYPE_ERROR, "SystemMatrix::saveHB: Only single rank supported.");
82            } else if (!(type & MATRIX_FORMAT_CSC)) {
83                Esys_setError(TYPE_ERROR, "SystemMatrix::saveHB: Only CSC format supported.");
84            } else {
85                mainBlock->saveHB_CSC(filename.c_str());
86            }
87        }
88    
89        virtual void resetValues();
90    
91      /// Nullifies rows in the matrix.      /// Nullifies rows in the matrix.
92      /// The rows are marked by positive values in mask_row. Values on the      /// The rows are marked by positive values in mask_row. Values on the
# Line 118  struct SystemMatrix : boost::enable_shar Line 149  struct SystemMatrix : boost::enable_shar
149    
150      index_t* borrowMainDiagonalPointer() const;      index_t* borrowMainDiagonalPointer() const;
151    
152      inline void startCollect(const double* in)      inline void startCollect(const double* in) const
153      {      {
154          startColCollect(in);          startColCollect(in);
155      }      }
156    
157      inline double* finishCollect()      inline double* finishCollect() const
158      {      {
159          return finishColCollect();          return finishColCollect();
160      }      }
161    
162      inline void startColCollect(const double* in)      inline void startColCollect(const double* in) const
163      {      {
164          col_coupler->startCollect(in);          col_coupler->startCollect(in);
165      }      }
166    
167      inline double* finishColCollect()      inline double* finishColCollect() const
168      {      {
169          return col_coupler->finishCollect();          return col_coupler->finishCollect();
170      }      }
# Line 243  struct SystemMatrix : boost::enable_shar Line 274  struct SystemMatrix : boost::enable_shar
274          is_balanced = false;          is_balanced = false;
275      }      }
276    
     inline void saveMM(const char* filename) const  
     {  
         if (mpi_info->size > 1) {  
             Esys_setError(IO_ERROR, "SystemMatrix::saveMM: Only single rank supported.");  
         } else {  
             mainBlock->saveMM(filename);  
         }  
     }  
   
     inline void saveHB(const char *filename) const  
     {  
         if (mpi_info->size > 1) {  
             Esys_setError(TYPE_ERROR, "SystemMatrix::saveHB: Only single rank supported.");  
         } else if (!(type & MATRIX_FORMAT_CSC)) {  
             Esys_setError(TYPE_ERROR, "SystemMatrix::saveHB: Only CSC format supported.");  
         } else {  
             mainBlock->saveHB_CSC(filename);  
         }  
     }  
   
277      inline void rowSum(double* row_sum) const      inline void rowSum(double* row_sum) const
278      {      {
279          if ((type & MATRIX_FORMAT_CSC) || (type & MATRIX_FORMAT_OFFSET1)) {          if ((type & MATRIX_FORMAT_CSC) || (type & MATRIX_FORMAT_OFFSET1)) {
# Line 279  struct SystemMatrix : boost::enable_shar Line 290  struct SystemMatrix : boost::enable_shar
290          }          }
291      }      }
292    
293        void MatrixVector(double alpha, const double* in, double beta,
294                          double* out) const;
295    
296        void MatrixVector_CSR_OFFSET0(double alpha, const double* in, double beta,
297                                      double* out) const;
298    
299      static SystemMatrix_ptr loadMM_toCSR(const char* filename);      static SystemMatrix_ptr loadMM_toCSR(const char* filename);
300    
301      static SystemMatrix_ptr loadMM_toCSC(const char* filename);      static SystemMatrix_ptr loadMM_toCSC(const char* filename);
302    
303      static index_t getSystemMatrixTypeId(index_t solver,      static int getSystemMatrixTypeId(int solver, int preconditioner,
304                                           index_t preconditioner,                                       int package, bool symmetry,
305                                           index_t package, bool symmetry,                                       const esysUtils::JMPI& mpi_info);
                                          const esysUtils::JMPI& mpi_info);  
306    
307      SystemMatrixType type;      SystemMatrixType type;
308      SystemMatrixPattern_ptr pattern;      SystemMatrixPattern_ptr pattern;
# Line 327  struct SystemMatrix : boost::enable_shar Line 343  struct SystemMatrix : boost::enable_shar
343      mutable index_t* global_id;      mutable index_t* global_id;
344    
345      /// package code controlling the solver pointer      /// package code controlling the solver pointer
346      index_t solver_package;      mutable index_t solver_package;
347    
348      /// pointer to data needed by a solver      /// pointer to data needed by a solver
349      void* solver_p;      void* solver_p;
350    
351      /// this is only used for a trilinos matrix  private:
352      void* trilinos_data;      virtual void setToSolution(escript::Data& out, escript::Data& in,
353  };                                 boost::python::object& options) const;
354    
355        virtual void ypAx(escript::Data& y, escript::Data& x) const;
356    
357  void SystemMatrix_MatrixVector(double alpha, SystemMatrix_ptr A, const double* in, double beta, double* out);      void solve(double* out, double* in, Options* options) const;
358    };
359    
 void SystemMatrix_MatrixVector_CSR_OFFSET0(double alpha, SystemMatrix_ptr A, const double* in, double beta, double* out);  
360    
361  void RHS_loadMM_toCSR(const char* filename, double* b, dim_t size);  void RHS_loadMM_toCSR(const char* filename, double* b, dim_t size);
362    

Legend:
Removed from v.5932  
changed lines
  Added in v.5933

  ViewVC Help
Powered by ViewVC 1.1.26