EpetraExt_CrsSingletonFilter_LinearProblem.h

Go to the documentation of this file.
00001 //@HEADER
00002 // ***********************************************************************
00003 // 
00004 //     EpetraExt: Epetra Extended - Linear Algebra Services Package
00005 //                 Copyright (2001) 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 #ifndef _EpetraExt_LINEARPROBLEM_CRSSINGLETONFILTER_H_
00030 #define _EpetraExt_LINEARPROBLEM_CRSSINGLETONFILTER_H_
00031 
00032 #include "Epetra_Object.h"
00033 #include "Epetra_CrsMatrix.h"
00034 #include "Epetra_MapColoring.h"
00035 #include "Epetra_SerialDenseVector.h"
00036 
00037 #include "EpetraExt_Transform.h"
00038 
00039 class Epetra_LinearProblem;
00040 class Epetra_Map;
00041 class Epetra_MultiVector;
00042 class Epetra_Import;
00043 class Epetra_Export;
00044 class Epetra_IntVector;
00045 
00046 namespace EpetraExt {
00047 
00049 
00105 class LinearProblem_CrsSingletonFilter : public SameTypeTransform<Epetra_LinearProblem> {
00106       
00107  public:
00108 
00110 
00111   LinearProblem_CrsSingletonFilter( bool verbose = false );
00112 
00114   virtual ~LinearProblem_CrsSingletonFilter();
00116 
00118   NewTypeRef operator()( OriginalTypeRef orig );
00119 
00121   bool analyze( OriginalTypeRef orig );
00122 
00124   NewTypeRef construct();
00125 
00127   bool fwd();
00128 
00130   bool rvs();
00131 
00133 
00134 
00143   int Analyze(Epetra_RowMatrix * FullMatrix);
00144 
00146   bool SingletonsDetected() const {if (!AnalysisDone_) return(false); else return(RowMapColors_->MaxNumColors()>1);};
00148 
00150 
00151 
00156   int ConstructReducedProblem(Epetra_LinearProblem * Problem);
00157 
00159 
00164   int UpdateReducedProblem(Epetra_LinearProblem * Problem);
00165 
00167 
00168 
00169 
00174   int ComputeFullSolution();
00176 
00177 
00178   int NumRowSingletons() const {return(NumGlobalRowSingletons_);};
00179 
00181   int NumColSingletons() const {return(NumGlobalColSingletons_);};
00182 
00184 
00189   int NumSingletons() const {return(NumColSingletons()+NumRowSingletons());};
00190 
00192   double RatioOfDimensions() const {return(RatioOfDimensions_);};
00193 
00195   double RatioOfNonzeros() const {return(RatioOfNonzeros_);};
00196 
00198 
00199 
00201   Epetra_LinearProblem * FullProblem() const {return(FullProblem_);};
00202 
00204   Epetra_LinearProblem * ReducedProblem() const {return(ReducedProblem_);};
00205 
00207   Epetra_RowMatrix * FullMatrix() const {return(FullMatrix_);};
00208 
00210   Epetra_CrsMatrix * ReducedMatrix() const {return(ReducedMatrix_);};
00211 
00213   Epetra_MapColoring * RowMapColors() const {return(RowMapColors_);};
00214 
00216   Epetra_MapColoring * ColMapColors() const {return(ColMapColors_);};
00217 
00219   Epetra_Map * ReducedMatrixRowMap() const {return(ReducedMatrixRowMap_);};
00220 
00222   Epetra_Map * ReducedMatrixColMap() const {return(ReducedMatrixColMap_);};
00223 
00225   Epetra_Map * ReducedMatrixDomainMap() const {return(ReducedMatrixDomainMap_);};
00226 
00228   Epetra_Map * ReducedMatrixRangeMap() const {return(ReducedMatrixRangeMap_);};
00230 
00231  protected:
00232 
00233  
00234 
00235   //  This pointer will be zero if full matrix is not a CrsMatrix.
00236   Epetra_CrsMatrix * FullCrsMatrix() const {return(FullCrsMatrix_);};
00237 
00238   const Epetra_Map & FullMatrixRowMap() const {return(FullMatrix()->RowMatrixRowMap());};
00239   const Epetra_Map & FullMatrixColMap() const {return(FullMatrix()->RowMatrixColMap());};
00240   const Epetra_Map & FullMatrixDomainMap() const {return((FullMatrix()->OperatorDomainMap()));};
00241   const Epetra_Map & FullMatrixRangeMap() const {return((FullMatrix()->OperatorRangeMap()));};
00242   void InitializeDefaults();
00243   int ComputeEliminateMaps();
00244   int Setup(Epetra_LinearProblem * Problem);
00245   int InitFullMatrixAccess();
00246   int GetRow(int Row, int & NumIndices, int * & Indices);
00247   int GetRowGCIDs(int Row, int & NumIndices, double * & Values, int * & GlobalIndices);
00248   int GetRow(int Row, int & NumIndices, double * & Values, int * & Indices);
00249   int CreatePostSolveArrays(const Epetra_IntVector & RowIDs,
00250           const Epetra_MapColoring & RowMapColors,
00251           const Epetra_IntVector & ColProfiles,
00252           const Epetra_IntVector & NewColProfiles,
00253           const Epetra_IntVector & ColHasRowWithSingleton);
00254   
00255   int ConstructRedistributeExporter(Epetra_Map * SourceMap, Epetra_Map * TargetMap,
00256             Epetra_Export * & RedistributeExporter,
00257             Epetra_Map * & RedistributeMap);
00258   
00259   Epetra_LinearProblem * FullProblem_;
00260   Epetra_LinearProblem * ReducedProblem_;
00261   Epetra_RowMatrix * FullMatrix_;
00262   Epetra_CrsMatrix * FullCrsMatrix_;
00263   Epetra_CrsMatrix * ReducedMatrix_;
00264   Epetra_MultiVector * ReducedRHS_;
00265   Epetra_MultiVector * ReducedLHS_;
00266   
00267   Epetra_Map * ReducedMatrixRowMap_;
00268   Epetra_Map * ReducedMatrixColMap_;
00269   Epetra_Map * ReducedMatrixDomainMap_;
00270   Epetra_Map * ReducedMatrixRangeMap_;
00271   Epetra_Map * OrigReducedMatrixDomainMap_;
00272   Epetra_Import * Full2ReducedRHSImporter_;
00273   Epetra_Import * Full2ReducedLHSImporter_;
00274   Epetra_Export * RedistributeDomainExporter_;
00275   
00276   int * ColSingletonRowLIDs_;
00277   int * ColSingletonColLIDs_;
00278   int * ColSingletonPivotLIDs_;
00279   double * ColSingletonPivots_;
00280   
00281   
00282   int AbsoluteThreshold_;
00283   double RelativeThreshold_;
00284 
00285   int NumMyRowSingletons_;
00286   int NumMyColSingletons_;
00287   int NumGlobalRowSingletons_;
00288   int NumGlobalColSingletons_;
00289   double RatioOfDimensions_;
00290   double RatioOfNonzeros_;
00291   
00292   bool HaveReducedProblem_;
00293   bool UserDefinedEliminateMaps_;
00294   bool AnalysisDone_;
00295   bool SymmetricElimination_;
00296   
00297   Epetra_MultiVector * tempExportX_;
00298   Epetra_MultiVector * tempX_;
00299   Epetra_MultiVector * tempB_;
00300   Epetra_MultiVector * RedistributeReducedLHS_;
00301   int * Indices_;
00302   Epetra_SerialDenseVector Values_;
00303   
00304   Epetra_MapColoring * RowMapColors_;
00305   Epetra_MapColoring * ColMapColors_;
00306   bool FullMatrixIsCrsMatrix_;
00307   int MaxNumMyEntries_;
00308 
00309   bool verbose_;
00310   
00311   
00312  private:
00314   LinearProblem_CrsSingletonFilter(const LinearProblem_CrsSingletonFilter & Problem){};
00315 };
00316 
00317 } //namespace EpetraExt
00318 
00319 #endif /* _EpetraExt_LINEARPROBLEM_CRSSINGLETONFILTER_H_ */

Generated on Wed May 12 21:24:45 2010 for EpetraExt by  doxygen 1.4.7