|
EpetraExt
Development
|
00001 //@HEADER 00002 // *********************************************************************** 00003 // 00004 // EpetraExt: Epetra Extended - Linear Algebra Services Package 00005 // Copyright (2011) Sandia Corporation 00006 // 00007 // Under the terms of Contract DE-AC04-94AL85000 with Sandia Corporation, 00008 // the U.S. Government retains certain rights in this software. 00009 // 00010 // Redistribution and use in source and binary forms, with or without 00011 // modification, are permitted provided that the following conditions are 00012 // met: 00013 // 00014 // 1. Redistributions of source code must retain the above copyright 00015 // notice, this list of conditions and the following disclaimer. 00016 // 00017 // 2. Redistributions in binary form must reproduce the above copyright 00018 // notice, this list of conditions and the following disclaimer in the 00019 // documentation and/or other materials provided with the distribution. 00020 // 00021 // 3. Neither the name of the Corporation nor the names of the 00022 // contributors may be used to endorse or promote products derived from 00023 // this software without specific prior written permission. 00024 // 00025 // THIS SOFTWARE IS PROVIDED BY SANDIA CORPORATION "AS IS" AND ANY 00026 // EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 00027 // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 00028 // PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL SANDIA CORPORATION OR THE 00029 // CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 00030 // EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 00031 // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 00032 // PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 00033 // LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 00034 // NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 00035 // SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 00036 // 00037 // Questions? Contact Michael A. Heroux (maherou@sandia.gov) 00038 // 00039 // *********************************************************************** 00040 //@HEADER 00041 00042 #ifndef _EpetraExt_LINEARPROBLEM_CRSSINGLETONFILTER_H_ 00043 #define _EpetraExt_LINEARPROBLEM_CRSSINGLETONFILTER_H_ 00044 00045 #include "Epetra_Object.h" 00046 #include "Epetra_CrsMatrix.h" 00047 #include "Epetra_MapColoring.h" 00048 #include "Epetra_SerialDenseVector.h" 00049 00050 #include "EpetraExt_Transform.h" 00051 00052 class Epetra_LinearProblem; 00053 class Epetra_Map; 00054 class Epetra_MultiVector; 00055 class Epetra_Import; 00056 class Epetra_Export; 00057 class Epetra_IntVector; 00058 00059 namespace EpetraExt { 00060 00062 00118 class LinearProblem_CrsSingletonFilter : public SameTypeTransform<Epetra_LinearProblem> { 00119 00120 public: 00121 00123 00124 LinearProblem_CrsSingletonFilter( bool verbose = false ); 00125 00127 virtual ~LinearProblem_CrsSingletonFilter(); 00129 00131 NewTypeRef operator()( OriginalTypeRef orig ); 00132 00134 bool analyze( OriginalTypeRef orig ); 00135 00137 NewTypeRef construct(); 00138 00140 bool fwd(); 00141 00143 bool rvs(); 00144 00146 00147 00156 int Analyze(Epetra_RowMatrix * FullMatrix); 00157 00159 bool SingletonsDetected() const {if (!AnalysisDone_) return(false); else return(RowMapColors_->MaxNumColors()>1);}; 00161 00163 00164 00169 int ConstructReducedProblem(Epetra_LinearProblem * Problem); 00170 00172 00177 int UpdateReducedProblem(Epetra_LinearProblem * Problem); 00178 00180 00181 00182 00187 int ComputeFullSolution(); 00189 00190 00191 int NumRowSingletons() const {return(NumGlobalRowSingletons_);}; 00192 00194 int NumColSingletons() const {return(NumGlobalColSingletons_);}; 00195 00197 00202 int NumSingletons() const {return(NumColSingletons()+NumRowSingletons());}; 00203 00205 double RatioOfDimensions() const {return(RatioOfDimensions_);}; 00206 00208 double RatioOfNonzeros() const {return(RatioOfNonzeros_);}; 00209 00211 00212 00214 Epetra_LinearProblem * FullProblem() const {return(FullProblem_);}; 00215 00217 Epetra_LinearProblem * ReducedProblem() const {return(ReducedProblem_);}; 00218 00220 Epetra_RowMatrix * FullMatrix() const {return(FullMatrix_);}; 00221 00223 Epetra_CrsMatrix * ReducedMatrix() const {return(ReducedMatrix_);}; 00224 00226 Epetra_MapColoring * RowMapColors() const {return(RowMapColors_);}; 00227 00229 Epetra_MapColoring * ColMapColors() const {return(ColMapColors_);}; 00230 00232 Epetra_Map * ReducedMatrixRowMap() const {return(ReducedMatrixRowMap_);}; 00233 00235 Epetra_Map * ReducedMatrixColMap() const {return(ReducedMatrixColMap_);}; 00236 00238 Epetra_Map * ReducedMatrixDomainMap() const {return(ReducedMatrixDomainMap_);}; 00239 00241 Epetra_Map * ReducedMatrixRangeMap() const {return(ReducedMatrixRangeMap_);}; 00243 00244 protected: 00245 00246 00247 00248 // This pointer will be zero if full matrix is not a CrsMatrix. 00249 Epetra_CrsMatrix * FullCrsMatrix() const {return(FullCrsMatrix_);}; 00250 00251 const Epetra_Map & FullMatrixRowMap() const {return(FullMatrix()->RowMatrixRowMap());}; 00252 const Epetra_Map & FullMatrixColMap() const {return(FullMatrix()->RowMatrixColMap());}; 00253 const Epetra_Map & FullMatrixDomainMap() const {return((FullMatrix()->OperatorDomainMap()));}; 00254 const Epetra_Map & FullMatrixRangeMap() const {return((FullMatrix()->OperatorRangeMap()));}; 00255 void InitializeDefaults(); 00256 int ComputeEliminateMaps(); 00257 int Setup(Epetra_LinearProblem * Problem); 00258 int InitFullMatrixAccess(); 00259 int GetRow(int Row, int & NumIndices, int * & Indices); 00260 int GetRowGCIDs(int Row, int & NumIndices, double * & Values, int * & GlobalIndices); 00261 int GetRow(int Row, int & NumIndices, double * & Values, int * & Indices); 00262 int CreatePostSolveArrays(const Epetra_IntVector & RowIDs, 00263 const Epetra_MapColoring & RowMapColors, 00264 const Epetra_IntVector & ColProfiles, 00265 const Epetra_IntVector & NewColProfiles, 00266 const Epetra_IntVector & ColHasRowWithSingleton); 00267 00268 int ConstructRedistributeExporter(Epetra_Map * SourceMap, Epetra_Map * TargetMap, 00269 Epetra_Export * & RedistributeExporter, 00270 Epetra_Map * & RedistributeMap); 00271 00272 Epetra_LinearProblem * FullProblem_; 00273 Epetra_LinearProblem * ReducedProblem_; 00274 Epetra_RowMatrix * FullMatrix_; 00275 Epetra_CrsMatrix * FullCrsMatrix_; 00276 Epetra_CrsMatrix * ReducedMatrix_; 00277 Epetra_MultiVector * ReducedRHS_; 00278 Epetra_MultiVector * ReducedLHS_; 00279 00280 Epetra_Map * ReducedMatrixRowMap_; 00281 Epetra_Map * ReducedMatrixColMap_; 00282 Epetra_Map * ReducedMatrixDomainMap_; 00283 Epetra_Map * ReducedMatrixRangeMap_; 00284 Epetra_Map * OrigReducedMatrixDomainMap_; 00285 Epetra_Import * Full2ReducedRHSImporter_; 00286 Epetra_Import * Full2ReducedLHSImporter_; 00287 Epetra_Export * RedistributeDomainExporter_; 00288 00289 int * ColSingletonRowLIDs_; 00290 int * ColSingletonColLIDs_; 00291 int * ColSingletonPivotLIDs_; 00292 double * ColSingletonPivots_; 00293 00294 00295 int AbsoluteThreshold_; 00296 double RelativeThreshold_; 00297 00298 int NumMyRowSingletons_; 00299 int NumMyColSingletons_; 00300 int NumGlobalRowSingletons_; 00301 int NumGlobalColSingletons_; 00302 double RatioOfDimensions_; 00303 double RatioOfNonzeros_; 00304 00305 bool HaveReducedProblem_; 00306 bool UserDefinedEliminateMaps_; 00307 bool AnalysisDone_; 00308 bool SymmetricElimination_; 00309 00310 Epetra_MultiVector * tempExportX_; 00311 Epetra_MultiVector * tempX_; 00312 Epetra_MultiVector * tempB_; 00313 Epetra_MultiVector * RedistributeReducedLHS_; 00314 int * Indices_; 00315 Epetra_SerialDenseVector Values_; 00316 00317 Epetra_MapColoring * RowMapColors_; 00318 Epetra_MapColoring * ColMapColors_; 00319 bool FullMatrixIsCrsMatrix_; 00320 int MaxNumMyEntries_; 00321 00322 bool verbose_; 00323 00324 00325 private: 00327 LinearProblem_CrsSingletonFilter(const LinearProblem_CrsSingletonFilter & Problem){}; 00328 }; 00329 00330 } //namespace EpetraExt 00331 00332 #endif /* _EpetraExt_LINEARPROBLEM_CRSSINGLETONFILTER_H_ */
1.7.6.1