|
IFPACK Development
|
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 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
1.7.4