sparseblockmatrix.h

Go to the documentation of this file.
00001 #ifndef __sparseblockmatrix_h
00002 #define __sparseblockmatrix_h
00003 
00004 #include  "sparsestructure.h"
00005 #include  "columndiagstencil.h"
00006 #include  "matrixinterface.h"
00007 #include  "gascoigne.h"
00008 
00009 using namespace std;
00010 
00011 /*-------------------------------------------------------------*/
00012 
00013 namespace Gascoigne
00014 {
00015 template<class B>
00016 class SparseBlockMatrix : public MatrixInterface
00017 {
00018  protected:
00019 
00020   typedef typename vector<B>::const_iterator      const_iterator;
00021   typedef typename vector<B>::iterator            iterator;
00022   typedef typename std::pair<int,int>                  IntPair;
00023   
00024   ColumnDiagStencil  US;
00025   vector<B>      smat;
00026   int            nc;
00027   
00028   void matrix_vector_trans(int p, double* yp, const double* xp, double s=1.) const;
00029   
00030   int size() const { return smat.size();}
00031 
00032  public:
00033 
00034   SparseBlockMatrix<B>();
00035   SparseBlockMatrix<B>(const SparseBlockMatrix<B>& A);
00036   virtual ~SparseBlockMatrix<B>() {}
00037   
00038   void transpose();
00039 
00040   string GetName() const {return "SparseBlockMatrix";}
00041 
00043 
00044   const_iterator  mat(int pos)            const { assert(pos<smat.size()); return smat.begin()+pos; }
00045         iterator  mat(int pos)                  { assert(pos<smat.size()); return smat.begin()+pos; }
00046 
00047   const StencilInterface* GetStencil() const { return &US;}
00048 
00049   int   n()          const { return US.n();};
00050   int   nentries()   const { return US.nentries();};
00051   int   ntotal()     const { return smat.size();};
00052 
00053   int  rowsize(int i)     const { return US.start(i+1)-US.start(i);}
00054   const vector<B>& mat()  const { return smat; }
00055 
00057 
00058   void AddMassWithDifferentStencil(const MatrixInterface* M, 
00059                                    const TimePattern& TP, double s=1.);
00060   void copy_entries(const MatrixInterface& S);
00061 
00062   SparseBlockMatrix& operator=(const SparseBlockMatrix<B>& S); 
00063 
00064   void ReInit   (const SparseStructureInterface*);
00065   void dirichlet(int i, const vector<int>& cv);
00066   void dirichlet_only_row(int i, const vector<int>& cv);
00067 
00068   void zero();
00069   void entry(nvector<int>::const_iterator start1, nvector<int>::const_iterator stop1,
00070              nvector<int>::const_iterator start2, nvector<int>::const_iterator stop2,
00071              const EntryMatrix& M, double s=1.);
00072   void entry(nvector<int>::const_iterator start, nvector<int>::const_iterator stop, const EntryMatrix& M, double s=1.);
00073   void entrydual(nvector<int>::const_iterator start, nvector<int>::const_iterator stop, const EntryMatrix& M, double s=1.);
00074 
00075   void GaussSeidel      (GlobalVector& y, const GlobalVector& x) const;
00076   void Jacobi           (GlobalVector& x) const;
00077 
00078   void vmult(GlobalVector& y, const GlobalVector& x, double s=1.) const;
00079   void vmult(GlobalVector& y, const GlobalVector& x, const TimePattern& TP, double s=1.)const;
00080   void entry_diag(int i, const nmatrix<double>& M);
00081  
00082             /*-----------------------------------------------*/
00083 
00084   void FillInterfaceList(const nvector<int>& elements,nvector<int>& start, nvector<float>& values) const;
00085   void FurbishInterface (double d, const nvector<int>&   elements, const nvector<int>&   start, const nvector<float>& values);
00086 
00087             /*-----------------------------------------------*/
00088 
00089   ostream& Write(ostream &s) const;
00090   friend   ostream& operator<<(ostream &s, const SparseBlockMatrix<B>& A) {assert(0); return s;}
00091 };
00092 }
00093 
00094 #endif

Generated on Thu Sep 14 10:34:37 2006 for Gascoigne by  doxygen 1.4.7