Epetra Package Browser (Single Doxygen Collection) Development
Epetra_CrsSingletonFilter.h
Go to the documentation of this file.
00001 /*
00002 //@HEADER
00003 // ************************************************************************
00004 // 
00005 //               Epetra: Linear Algebra Services Package 
00006 //                 Copyright 2001 Sandia Corporation
00007 // 
00008 // Under the terms of Contract DE-AC04-94AL85000 with Sandia Corporation,
00009 // the U.S. Government retains certain rights in this software.
00010 //
00011 // Redistribution and use in source and binary forms, with or without
00012 // modification, are permitted provided that the following conditions are
00013 // met:
00014 //
00015 // 1. Redistributions of source code must retain the above copyright
00016 // notice, this list of conditions and the following disclaimer.
00017 //
00018 // 2. Redistributions in binary form must reproduce the above copyright
00019 // notice, this list of conditions and the following disclaimer in the
00020 // documentation and/or other materials provided with the distribution.
00021 //
00022 // 3. Neither the name of the Corporation nor the names of the
00023 // contributors may be used to endorse or promote products derived from
00024 // this software without specific prior written permission.
00025 //
00026 // THIS SOFTWARE IS PROVIDED BY SANDIA CORPORATION "AS IS" AND ANY
00027 // EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
00028 // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
00029 // PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL SANDIA CORPORATION OR THE
00030 // CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
00031 // EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
00032 // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
00033 // PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
00034 // LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
00035 // NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
00036 // SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
00037 //
00038 // Questions? Contact Michael A. Heroux (maherou@sandia.gov) 
00039 // 
00040 // ************************************************************************
00041 //@HEADER
00042 */
00043 
00044 #ifndef EPETRA_CRSSINGLETONFILTER_H
00045 #define EPETRA_CRSSINGLETONFILTER_H
00046 
00047 #include "Epetra_Object.h"
00048 #include "Epetra_CrsMatrix.h"
00049 #include "Epetra_MapColoring.h"
00050 #include "Epetra_SerialDenseVector.h"
00051 class Epetra_LinearProblem;
00052 class Epetra_Map;
00053 class Epetra_MultiVector;
00054 class Epetra_Import;
00055 class Epetra_Export;
00056 class Epetra_IntVector;
00057 
00059 
00115 class Epetra_CrsSingletonFilter {
00116       
00117  public:
00118 
00120 
00121 
00122   Epetra_CrsSingletonFilter();
00123 
00125   virtual ~Epetra_CrsSingletonFilter();
00127 
00128 
00129 
00130 
00139   int Analyze(Epetra_RowMatrix * FullMatrix);
00140 
00142   bool SingletonsDetected() const {if (!AnalysisDone_) return(false); else return(RowMapColors_->MaxNumColors()>1);};
00144 
00146 
00147 
00148 
00153   int ConstructReducedProblem(Epetra_LinearProblem * Problem);
00154 
00156 
00161   int UpdateReducedProblem(Epetra_LinearProblem * Problem);
00162 
00164 
00165 
00166 
00167 
00172   int ComputeFullSolution();
00174 
00175 
00176 
00177   int NumRowSingletons() const {return(NumGlobalRowSingletons_);};
00178 
00180   int NumColSingletons() const {return(NumGlobalColSingletons_);};
00181 
00183 
00188   int NumSingletons() const {return(NumColSingletons()+NumRowSingletons());};
00189 
00191   double RatioOfDimensions() const {return(RatioOfDimensions_);};
00192 
00194   double RatioOfNonzeros() const {return(RatioOfNonzeros_);};
00195 
00197 
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   
00310  private:
00312   Epetra_CrsSingletonFilter(const Epetra_CrsSingletonFilter & Problem);
00313   Epetra_CrsSingletonFilter & operator=(const Epetra_CrsSingletonFilter & Problem);
00314 };
00315 #endif /* EPETRA_CRSSINGLETONFILTER_H */
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines