Ifpack_DenseContainer.h

Go to the documentation of this file.
00001 #ifndef IFPACK_DENSECONTAINER_H
00002 #define IFPACK_DENSECONTAINER_H
00003 
00004 #include "Ifpack_ConfigDefs.h"
00005 #include "Ifpack_Container.h"
00006 #include "Epetra_SerialDenseMatrix.h"
00007 #include "Epetra_SerialDenseSolver.h"
00008 #include "Epetra_IntSerialDenseVector.h"
00009 class Epetra_RowMatrix;
00010 
00012 
00075 class Ifpack_DenseContainer : public Ifpack_Container {
00076 
00077 public:
00078 
00080 
00082   Ifpack_DenseContainer(const int NumRows, const int NumVectors = 1) :
00083     NumRows_(NumRows),
00084     NumVectors_(NumVectors),
00085     KeepNonFactoredMatrix_(false),
00086     IsInitialized_(false),
00087     IsComputed_(false),
00088     ComputeFlops_(0.0),
00089     ApplyFlops_(0.0),
00090     ApplyInverseFlops_(0.0)
00091   {}
00092 
00094   Ifpack_DenseContainer(const Ifpack_DenseContainer& rhs) :
00095     NumRows_(rhs.NumRows()),
00096     NumVectors_(rhs.NumVectors()),
00097     KeepNonFactoredMatrix_(rhs.KeepNonFactoredMatrix()),
00098     IsInitialized_(rhs.IsInitialized()),
00099     IsComputed_(rhs.IsComputed())
00100   {
00101     Matrix_ = rhs.Matrix();
00102     if (KeepNonFactoredMatrix_)
00103       NonFactoredMatrix_ = rhs.NonFactoredMatrix();
00104     LHS_ = rhs.LHS();
00105     RHS_ = rhs.RHS();
00106     ID_ = rhs.ID();
00107   }
00108     
00110   virtual ~Ifpack_DenseContainer()
00111   {}
00113 
00115 
00117   Ifpack_DenseContainer& operator=(const Ifpack_DenseContainer& rhs)
00118   {
00119     if (&rhs == this)
00120       return(*this);
00121 
00122     NumRows_ = rhs.NumRows();
00123     NumVectors_ = rhs.NumVectors();
00124     IsComputed_ = rhs.IsComputed();
00125     KeepNonFactoredMatrix_ = rhs.KeepNonFactoredMatrix();
00126     Matrix_ = rhs.Matrix();
00127     if (KeepNonFactoredMatrix_)
00128       NonFactoredMatrix_ = rhs.NonFactoredMatrix();
00129     LHS_ = rhs.LHS();
00130     RHS_ = rhs.RHS();
00131     ID_ = rhs.ID();
00132 
00133     return(*this);
00134   }
00135 
00137 
00139 
00141   virtual int NumRows() const;
00142 
00144   virtual int NumVectors() const
00145   {
00146     return(NumVectors_);
00147   }
00148 
00150   virtual int SetNumVectors(const int NumVectors)
00151   {
00152     if (NumVectors_ == NumVectors) 
00153       return(0);
00154 
00155     NumVectors_ = NumVectors;
00156     IFPACK_CHK_ERR(RHS_.Reshape(NumRows_,NumVectors_));
00157     IFPACK_CHK_ERR(RHS_.Reshape(NumRows_,NumVectors_));
00158     // zero out vector elements
00159     for (int i = 0 ; i < NumRows_ ; ++i)
00160       for (int j = 0 ; j < NumVectors_ ; ++j) {
00161   LHS_(i,j) = 0.0;
00162   RHS_(i,j) = 0.0;
00163       }
00164 
00165     return(0);
00166   }
00167 
00169   virtual double& LHS(const int i, const int Vector = 0);
00170   
00172   virtual double& RHS(const int i, const int Vector = 0);
00173 
00175 
00184   virtual int& ID(const int i);
00185 
00187   virtual int SetMatrixElement(const int row, const int col,
00188              const double value);
00189 
00191   virtual int SetParameters(Teuchos::ParameterList& List)
00192   {
00193     return(0);
00194   }
00195 
00197   virtual bool IsInitialized() const
00198   {
00199     return(IsInitialized_);
00200   }
00201 
00203   virtual bool IsComputed() const
00204   {
00205     return(IsComputed_);
00206   }
00207 
00209   virtual const char* Label() const
00210   {
00211     return(Label_.c_str());
00212   }
00213 
00215   virtual int SetKeepNonFactoredMatrix(const bool flag)
00216   {
00217     KeepNonFactoredMatrix_ = flag;
00218     return(0);
00219   }
00220 
00222   virtual bool KeepNonFactoredMatrix() const
00223   {
00224     return(KeepNonFactoredMatrix_);
00225   }
00226 
00228   virtual const Epetra_SerialDenseMatrix& LHS() const
00229   {
00230     return(LHS_);
00231   }
00232 
00234   virtual const Epetra_SerialDenseMatrix& RHS() const
00235   {
00236     return(RHS_);
00237   }
00238 
00240   virtual const Epetra_SerialDenseMatrix& Matrix() const
00241   {
00242     return(Matrix_);
00243   }
00244 
00246   virtual const Epetra_SerialDenseMatrix& NonFactoredMatrix() const
00247   {
00248     return(NonFactoredMatrix_);
00249   }
00250 
00252   virtual const Epetra_IntSerialDenseVector& ID() const
00253   {
00254     return(ID_);
00255   }
00256 
00258 
00260 
00261   virtual int Initialize();
00262 
00264   virtual int Compute(const Epetra_RowMatrix& Matrix);
00265 
00267   virtual int Apply();
00268 
00270   virtual int ApplyInverse();
00271 
00273 
00274   virtual double InitializeFlops() const
00275   {
00276     return(0.0);
00277   }
00278 
00279   virtual double ComputeFlops() const
00280   {
00281     return(ComputeFlops_);
00282   }
00283 
00284   virtual double ApplyFlops() const
00285   {
00286     return(ApplyFlops_);
00287   }
00288 
00289   virtual double ApplyInverseFlops() const
00290   {
00291     return(ApplyInverseFlops_);
00292   }
00293 
00295   virtual ostream& Print(std::ostream& os) const;
00296 
00297 private:
00298   
00300   virtual int Extract(const Epetra_RowMatrix& Matrix);
00301 
00303   int NumRows_; 
00305   int NumVectors_;
00307   Epetra_SerialDenseMatrix NonFactoredMatrix_;
00309   Epetra_SerialDenseMatrix Matrix_;
00311   Epetra_SerialDenseMatrix LHS_;
00313   Epetra_SerialDenseMatrix RHS_;
00315   Epetra_SerialDenseSolver Solver_;
00317   Epetra_IntSerialDenseVector ID_;
00319   bool KeepNonFactoredMatrix_;
00321   bool IsInitialized_;
00323   bool IsComputed_;
00325   string Label_;
00326 
00328   double ComputeFlops_;
00330   double ApplyFlops_;
00332   double ApplyInverseFlops_;
00333 };
00334 
00335 #endif

Generated on Thu Sep 18 12:37:21 2008 for Ifpack Package Browser (Single Doxygen Collection) by doxygen 1.3.9.1