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 #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
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 }
00318
00319 #endif