00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
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(LHS_.Reshape(NumRows_,NumVectors_));
00187
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 if (NumRows_!=0)
00194 {
00195 IFPACK_CHK_ERR(Solver_.SetVectors(LHS_,RHS_));
00196 }
00197 return(0);
00198 }
00199
00201 virtual double& LHS(const int i, const int Vector = 0);
00202
00204 virtual double& RHS(const int i, const int Vector = 0);
00205
00207
00216 virtual int& ID(const int i);
00217
00219 virtual int SetMatrixElement(const int row, const int col,
00220 const double value);
00221
00223 virtual int SetParameters(Teuchos::ParameterList& List)
00224 {
00225 return(0);
00226 }
00227
00229 virtual bool IsInitialized() const
00230 {
00231 return(IsInitialized_);
00232 }
00233
00235 virtual bool IsComputed() const
00236 {
00237 return(IsComputed_);
00238 }
00239
00241 virtual const char* Label() const
00242 {
00243 return(Label_.c_str());
00244 }
00245
00247 virtual int SetKeepNonFactoredMatrix(const bool flag)
00248 {
00249 KeepNonFactoredMatrix_ = flag;
00250 return(0);
00251 }
00252
00254 virtual bool KeepNonFactoredMatrix() const
00255 {
00256 return(KeepNonFactoredMatrix_);
00257 }
00258
00260 virtual const Epetra_SerialDenseMatrix& LHS() const
00261 {
00262 return(LHS_);
00263 }
00264
00266 virtual const Epetra_SerialDenseMatrix& RHS() const
00267 {
00268 return(RHS_);
00269 }
00270
00272 virtual const Epetra_SerialDenseMatrix& Matrix() const
00273 {
00274 return(Matrix_);
00275 }
00276
00278 virtual const Epetra_SerialDenseMatrix& NonFactoredMatrix() const
00279 {
00280 return(NonFactoredMatrix_);
00281 }
00282
00284 virtual const Epetra_IntSerialDenseVector& ID() const
00285 {
00286 return(ID_);
00287 }
00288
00290
00292
00293 virtual int Initialize();
00294
00296 virtual int Compute(const Epetra_RowMatrix& Matrix_in);
00297
00299 virtual int Apply();
00300
00302 virtual int ApplyInverse();
00303
00305
00306 virtual double InitializeFlops() const
00307 {
00308 return(0.0);
00309 }
00310
00311 virtual double ComputeFlops() const
00312 {
00313 return(ComputeFlops_);
00314 }
00315
00316 virtual double ApplyFlops() const
00317 {
00318 return(ApplyFlops_);
00319 }
00320
00321 virtual double ApplyInverseFlops() const
00322 {
00323 return(ApplyInverseFlops_);
00324 }
00325
00327 virtual ostream& Print(std::ostream& os) const;
00328
00329 private:
00330
00332 virtual int Extract(const Epetra_RowMatrix& Matrix_in);
00333
00335 int NumRows_;
00337 int NumVectors_;
00339 Epetra_SerialDenseMatrix NonFactoredMatrix_;
00341 Epetra_SerialDenseMatrix Matrix_;
00343 Epetra_SerialDenseMatrix LHS_;
00345 Epetra_SerialDenseMatrix RHS_;
00347 Epetra_SerialDenseSolver Solver_;
00349 Epetra_IntSerialDenseVector ID_;
00351 bool KeepNonFactoredMatrix_;
00353 bool IsInitialized_;
00355 bool IsComputed_;
00357 string Label_;
00358
00360 double ComputeFlops_;
00362 double ApplyFlops_;
00364 double ApplyInverseFlops_;
00365 };
00366
00367 #endif