Ifpack_DenseContainer.h

00001 /*@HEADER
00002 // ***********************************************************************
00003 //
00004 //       Ifpack: Object-Oriented Algebraic Preconditioner Package
00005 //                 Copyright (2002) Sandia Corporation
00006 //
00007 // Under terms of Contract DE-AC04-94AL85000, there is a non-exclusive
00008 // license for use of this work by or on behalf of the U.S. Government.
00009 //
00010 // This library is free software; you can redistribute it and/or modify
00011 // it under the terms of the GNU Lesser General Public License as
00012 // published by the Free Software Foundation; either version 2.1 of the
00013 // License, or (at your option) any later version.
00014 //
00015 // This library is distributed in the hope that it will be useful, but
00016 // WITHOUT ANY WARRANTY; without even the implied warranty of
00017 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00018 // Lesser General Public License for more details.
00019 //
00020 // You should have received a copy of the GNU Lesser General Public
00021 // License along with this library; if not, write to the Free Software
00022 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
00023 // USA
00024 // Questions? Contact Michael A. Heroux (maherou@sandia.gov)
00025 //
00026 // ***********************************************************************
00027 //@HEADER
00028 */
00029 
00030 #ifndef IFPACK_DENSECONTAINER_H
00031 #define IFPACK_DENSECONTAINER_H
00032 
00033 #include "Ifpack_ConfigDefs.h"
00034 #include "Ifpack_Container.h"
00035 #include "Epetra_SerialDenseMatrix.h"
00036 #include "Epetra_SerialDenseSolver.h"
00037 #include "Epetra_IntSerialDenseVector.h"
00038 class Epetra_RowMatrix;
00039 
00041 
00104 class Ifpack_DenseContainer : public Ifpack_Container {
00105 
00106 public:
00107 
00109 
00111   Ifpack_DenseContainer(const int NumRows_in, const int NumVectors_in = 1) :
00112     NumRows_(NumRows_in),
00113     NumVectors_(NumVectors_in),
00114     KeepNonFactoredMatrix_(false),
00115     IsInitialized_(false),
00116     IsComputed_(false),
00117     ComputeFlops_(0.0),
00118     ApplyFlops_(0.0),
00119     ApplyInverseFlops_(0.0)
00120   {}
00121 
00123   Ifpack_DenseContainer(const Ifpack_DenseContainer& rhs) :
00124     NumRows_(rhs.NumRows()),
00125     NumVectors_(rhs.NumVectors()),
00126     KeepNonFactoredMatrix_(rhs.KeepNonFactoredMatrix()),
00127     IsInitialized_(rhs.IsInitialized()),
00128     IsComputed_(rhs.IsComputed())
00129   {
00130     Matrix_ = rhs.Matrix();
00131     if (KeepNonFactoredMatrix_)
00132       NonFactoredMatrix_ = rhs.NonFactoredMatrix();
00133     LHS_ = rhs.LHS();
00134     RHS_ = rhs.RHS();
00135     ID_ = rhs.ID();
00136   }
00137     
00139   virtual ~Ifpack_DenseContainer()
00140   {}
00142 
00144 
00146   Ifpack_DenseContainer& operator=(const Ifpack_DenseContainer& rhs)
00147   {
00148     if (&rhs == this)
00149       return(*this);
00150 
00151     NumRows_ = rhs.NumRows();
00152     NumVectors_ = rhs.NumVectors();
00153     IsComputed_ = rhs.IsComputed();
00154     KeepNonFactoredMatrix_ = rhs.KeepNonFactoredMatrix();
00155     Matrix_ = rhs.Matrix();
00156     if (KeepNonFactoredMatrix_)
00157       NonFactoredMatrix_ = rhs.NonFactoredMatrix();
00158     LHS_ = rhs.LHS();
00159     RHS_ = rhs.RHS();
00160     ID_ = rhs.ID();
00161 
00162     return(*this);
00163   }
00164 
00166 
00168 
00170   virtual int NumRows() const;
00171 
00173   virtual int NumVectors() const
00174   {
00175     return(NumVectors_);
00176   }
00177 
00179   virtual int SetNumVectors(const int NumVectors_in)
00180   {
00181     if (NumVectors_ == NumVectors_in) 
00182       return(0);
00183 
00184     NumVectors_ = NumVectors_in;
00185     IFPACK_CHK_ERR(RHS_.Reshape(NumRows_,NumVectors_));
00186     IFPACK_CHK_ERR(RHS_.Reshape(NumRows_,NumVectors_));
00187     // zero out vector elements
00188     for (int i = 0 ; i < NumRows_ ; ++i)
00189       for (int j = 0 ; j < NumVectors_ ; ++j) {
00190     LHS_(i,j) = 0.0;
00191     RHS_(i,j) = 0.0;
00192       }
00193 
00194     return(0);
00195   }
00196 
00198   virtual double& LHS(const int i, const int Vector = 0);
00199   
00201   virtual double& RHS(const int i, const int Vector = 0);
00202 
00204 
00213   virtual int& ID(const int i);
00214 
00216   virtual int SetMatrixElement(const int row, const int col,
00217                    const double value);
00218 
00220   virtual int SetParameters(Teuchos::ParameterList& List)
00221   {
00222     return(0);
00223   }
00224 
00226   virtual bool IsInitialized() const
00227   {
00228     return(IsInitialized_);
00229   }
00230 
00232   virtual bool IsComputed() const
00233   {
00234     return(IsComputed_);
00235   }
00236 
00238   virtual const char* Label() const
00239   {
00240     return(Label_.c_str());
00241   }
00242 
00244   virtual int SetKeepNonFactoredMatrix(const bool flag)
00245   {
00246     KeepNonFactoredMatrix_ = flag;
00247     return(0);
00248   }
00249 
00251   virtual bool KeepNonFactoredMatrix() const
00252   {
00253     return(KeepNonFactoredMatrix_);
00254   }
00255 
00257   virtual const Epetra_SerialDenseMatrix& LHS() const
00258   {
00259     return(LHS_);
00260   }
00261 
00263   virtual const Epetra_SerialDenseMatrix& RHS() const
00264   {
00265     return(RHS_);
00266   }
00267 
00269   virtual const Epetra_SerialDenseMatrix& Matrix() const
00270   {
00271     return(Matrix_);
00272   }
00273 
00275   virtual const Epetra_SerialDenseMatrix& NonFactoredMatrix() const
00276   {
00277     return(NonFactoredMatrix_);
00278   }
00279 
00281   virtual const Epetra_IntSerialDenseVector& ID() const
00282   {
00283     return(ID_);
00284   }
00285 
00287 
00289 
00290   virtual int Initialize();
00291 
00293   virtual int Compute(const Epetra_RowMatrix& Matrix_in);
00294 
00296   virtual int Apply();
00297 
00299   virtual int ApplyInverse();
00300 
00302 
00303   virtual double InitializeFlops() const
00304   {
00305     return(0.0);
00306   }
00307 
00308   virtual double ComputeFlops() const
00309   {
00310     return(ComputeFlops_);
00311   }
00312 
00313   virtual double ApplyFlops() const
00314   {
00315     return(ApplyFlops_);
00316   }
00317 
00318   virtual double ApplyInverseFlops() const
00319   {
00320     return(ApplyInverseFlops_);
00321   }
00322 
00324   virtual ostream& Print(std::ostream& os) const;
00325 
00326 private:
00327   
00329   virtual int Extract(const Epetra_RowMatrix& Matrix_in);
00330 
00332   int NumRows_; 
00334   int NumVectors_;
00336   Epetra_SerialDenseMatrix NonFactoredMatrix_;
00338   Epetra_SerialDenseMatrix Matrix_;
00340   Epetra_SerialDenseMatrix LHS_;
00342   Epetra_SerialDenseMatrix RHS_;
00344   Epetra_SerialDenseSolver Solver_;
00346   Epetra_IntSerialDenseVector ID_;
00348   bool KeepNonFactoredMatrix_;
00350   bool IsInitialized_;
00352   bool IsComputed_;
00354   string Label_;
00355 
00357   double ComputeFlops_;
00359   double ApplyFlops_;
00361   double ApplyInverseFlops_;
00362 };
00363 
00364 #endif

Generated on Wed May 12 21:46:03 2010 for IFPACK by  doxygen 1.4.7