|
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_ConfigDefs.h" 00046 #include "Epetra_Object.h" 00047 #include "Epetra_CrsMatrix.h" 00048 #include "Epetra_MapColoring.h" 00049 #include "Epetra_SerialDenseVector.h" 00050 00051 #include "EpetraExt_Transform.h" 00052 #include "Teuchos_RCP.hpp" 00053 00054 class Epetra_LinearProblem; 00055 class Epetra_Map; 00056 class Epetra_MultiVector; 00057 class Epetra_Import; 00058 class Epetra_Export; 00059 class Epetra_IntVector; 00060 00061 namespace EpetraExt { 00062 00064 00120 class LinearProblem_CrsSingletonFilter : public SameTypeTransform<Epetra_LinearProblem> { 00121 00122 public: 00123 00125 00126 LinearProblem_CrsSingletonFilter( bool verbose = false ); 00127 00129 virtual ~LinearProblem_CrsSingletonFilter(); 00131 00133 NewTypeRef operator()( OriginalTypeRef orig ); 00134 00136 bool analyze( OriginalTypeRef orig ); 00137 00139 NewTypeRef construct(); 00140 00142 bool fwd(); 00143 00145 bool rvs(); 00146 00148 00149 00158 int Analyze(Epetra_RowMatrix * FullMatrix); 00159 00161 bool SingletonsDetected() const {if (!AnalysisDone_) return(false); else return(NumSingletons()>0);}; 00163 00165 00166 00171 int ConstructReducedProblem(Epetra_LinearProblem * Problem); 00172 00174 00179 int UpdateReducedProblem(Epetra_LinearProblem * Problem); 00180 00182 00183 00184 00189 int ComputeFullSolution(); 00191 00192 00193 int NumRowSingletons() const {return(NumGlobalRowSingletons_);}; 00194 00196 int NumColSingletons() const {return(NumGlobalColSingletons_);}; 00197 00199 00204 int NumSingletons() const {return(NumColSingletons()+NumRowSingletons());}; 00205 00207 double RatioOfDimensions() const {return(RatioOfDimensions_);}; 00208 00210 double RatioOfNonzeros() const {return(RatioOfNonzeros_);}; 00211 00213 00214 00216 Epetra_LinearProblem * FullProblem() const {return(FullProblem_);}; 00217 00219 Epetra_LinearProblem * ReducedProblem() const {return(ReducedProblem_.get());}; 00220 00222 Epetra_RowMatrix * FullMatrix() const {return(FullMatrix_);}; 00223 00225 Epetra_CrsMatrix * ReducedMatrix() const {return(ReducedMatrix_.get());}; 00226 00228 Epetra_MapColoring * RowMapColors() const {return(RowMapColors_);}; 00229 00231 Epetra_MapColoring * ColMapColors() const {return(ColMapColors_);}; 00232 00234 Epetra_Map * ReducedMatrixRowMap() const {return(ReducedMatrixRowMap_);}; 00235 00237 Epetra_Map * ReducedMatrixColMap() const {return(ReducedMatrixColMap_);}; 00238 00240 Epetra_Map * ReducedMatrixDomainMap() const {return(ReducedMatrixDomainMap_);}; 00241 00243 Epetra_Map * ReducedMatrixRangeMap() const {return(ReducedMatrixRangeMap_);}; 00245 00246 protected: 00247 00248 00249 00250 // This pointer will be zero if full matrix is not a CrsMatrix. 00251 Epetra_CrsMatrix * FullCrsMatrix() const {return(FullCrsMatrix_);}; 00252 00253 const Epetra_Map & FullMatrixRowMap() const {return(FullMatrix()->RowMatrixRowMap());}; 00254 const Epetra_Map & FullMatrixColMap() const {return(FullMatrix()->RowMatrixColMap());}; 00255 const Epetra_Map & FullMatrixDomainMap() const {return((FullMatrix()->OperatorDomainMap()));}; 00256 const Epetra_Map & FullMatrixRangeMap() const {return((FullMatrix()->OperatorRangeMap()));}; 00257 void InitializeDefaults(); 00258 int ComputeEliminateMaps(); 00259 int Setup(Epetra_LinearProblem * Problem); 00260 int InitFullMatrixAccess(); 00261 int GetRow(int Row, int & NumIndices, int * & Indices); 00262 int GetRow(int Row, int & NumIndices, double * & Values, int * & Indices); 00263 #ifndef EPETRA_NO_32BIT_GLOBAL_INDICES 00264 int GetRowGCIDs(int Row, int & NumIndices, double * & Values, int * & GlobalIndices); 00265 #endif 00266 #ifndef EPETRA_NO_64BIT_GLOBAL_INDICES 00267 int GetRowGCIDs(int Row, int & NumIndices, double * & Values, long long * & GlobalIndices); 00268 #endif 00269 int CreatePostSolveArrays(const Epetra_IntVector & RowIDs, 00270 const Epetra_MapColoring & RowMapColors, 00271 const Epetra_IntVector & ColProfiles, 00272 const Epetra_IntVector & NewColProfiles, 00273 const Epetra_IntVector & ColHasRowWithSingleton); 00274 00275 int ConstructRedistributeExporter(Epetra_Map * SourceMap, Epetra_Map * TargetMap, 00276 Epetra_Export * & RedistributeExporter, 00277 Epetra_Map * & RedistributeMap); 00278 00279 Epetra_LinearProblem * FullProblem_; 00280 Teuchos::RCP<Epetra_LinearProblem> ReducedProblem_; 00281 Epetra_RowMatrix * FullMatrix_; 00282 Epetra_CrsMatrix * FullCrsMatrix_; 00283 Teuchos::RCP<Epetra_CrsMatrix> ReducedMatrix_; 00284 Epetra_MultiVector * ReducedRHS_; 00285 Epetra_MultiVector * ReducedLHS_; 00286 00287 Epetra_Map * ReducedMatrixRowMap_; 00288 Epetra_Map * ReducedMatrixColMap_; 00289 Epetra_Map * ReducedMatrixDomainMap_; 00290 Epetra_Map * ReducedMatrixRangeMap_; 00291 Epetra_Map * OrigReducedMatrixDomainMap_; 00292 Epetra_Import * Full2ReducedRHSImporter_; 00293 Epetra_Import * Full2ReducedLHSImporter_; 00294 Epetra_Export * RedistributeDomainExporter_; 00295 00296 int * ColSingletonRowLIDs_; 00297 int * ColSingletonColLIDs_; 00298 int * ColSingletonPivotLIDs_; 00299 double * ColSingletonPivots_; 00300 00301 00302 int AbsoluteThreshold_; 00303 double RelativeThreshold_; 00304 00305 int NumMyRowSingletons_; 00306 int NumMyColSingletons_; 00307 int NumGlobalRowSingletons_; 00308 int NumGlobalColSingletons_; 00309 double RatioOfDimensions_; 00310 double RatioOfNonzeros_; 00311 00312 bool HaveReducedProblem_; 00313 bool UserDefinedEliminateMaps_; 00314 bool AnalysisDone_; 00315 bool SymmetricElimination_; 00316 00317 Epetra_MultiVector * tempExportX_; 00318 Epetra_MultiVector * tempX_; 00319 Epetra_MultiVector * tempB_; 00320 Epetra_MultiVector * RedistributeReducedLHS_; 00321 int * Indices_int_; 00322 #ifndef EPETRA_NO_64BIT_GLOBAL_INDICES 00323 long long * Indices_LL_; 00324 #endif 00325 Epetra_SerialDenseVector Values_; 00326 00327 Epetra_MapColoring * RowMapColors_; 00328 Epetra_MapColoring * ColMapColors_; 00329 bool FullMatrixIsCrsMatrix_; 00330 int MaxNumMyEntries_; 00331 00332 bool verbose_; 00333 00334 00335 private: 00337 LinearProblem_CrsSingletonFilter(const LinearProblem_CrsSingletonFilter & Problem){}; 00338 00339 template<typename int_type> 00340 int TConstructReducedProblem(Epetra_LinearProblem * Problem); 00341 00342 template<typename int_type> 00343 int TUpdateReducedProblem(Epetra_LinearProblem * Problem); 00344 00345 template<typename int_type> 00346 int TConstructRedistributeExporter(Epetra_Map * SourceMap, Epetra_Map * TargetMap, 00347 Epetra_Export * & RedistributeExporter, 00348 Epetra_Map * & RedistributeMap); 00349 }; 00350 00351 } //namespace EpetraExt 00352 00353 #endif /* _EpetraExt_LINEARPROBLEM_CRSSINGLETONFILTER_H_ */
1.7.6.1