|
Amesos Package Browser (Single Doxygen Collection)
Development
|
Go to the documentation of this file.
30 #include "Teuchos_ParameterList.hpp"
33 #include "Trilinos_Util.h"
35 #include "Epetra_LocalMap.h"
36 #include "Epetra_Map.h"
37 #include "Epetra_Vector.h"
38 #include "Epetra_Export.h"
39 #include "Epetra_CrsMatrix.h"
40 #include "Epetra_LinearProblem.h"
46 #ifdef HAVE_AMESOS_SUPERLU
49 #ifdef HAVE_AMESOS_SUPERLUDIST
52 #ifdef HAVE_AMESOS_SLUD
55 #ifdef HAVE_AMESOS_SLUS
58 #ifdef HAVE_AMESOS_SLUD2
64 #ifdef HAVE_AMESOS_DSCPACK
67 #ifdef HAVE_AMESOS_LAPACK
70 #ifdef HAVE_AMESOS_UMFPACK
73 #ifdef HAVE_AMESOS_KLU
76 #ifdef HAVE_AMESOS_SCALAPACK
79 #ifdef HAVE_AMESOS_TAUCS
82 #ifdef HAVE_AMESOS_PARDISO
85 #ifdef HAVE_AMESOS_PARAKLETE
88 #if defined(HAVE_AMESOS_MUMPS) && defined(HAVE_MPI)
125 Epetra_Map * readMap;
126 Epetra_CrsMatrix * readA;
127 Epetra_Vector * readx;
128 Epetra_Vector * readb;
129 Epetra_Vector * readxexact;
131 std::string FileName = matrix_file ;
132 int FN_Size = FileName.size() ;
133 std::string LastFiveBytes = FileName.substr( EPETRA_MAX(0,FN_Size-5), FN_Size );
134 std::string LastFourBytes = FileName.substr( EPETRA_MAX(0,FN_Size-4), FN_Size );
135 bool NonContiguousMap =
false;
137 if ( LastFiveBytes ==
".triU" ) {
139 NonContiguousMap =
true;
140 EPETRA_CHK_ERR( Trilinos_Util_ReadTriples2Epetra( matrix_file,
false, Comm, readMap, readA, readx,
141 readb, readxexact, NonContiguousMap ) );
143 if ( LastFiveBytes ==
".triS" ) {
144 NonContiguousMap =
true;
146 EPETRA_CHK_ERR( Trilinos_Util_ReadTriples2Epetra( matrix_file,
true, Comm, readMap, readA, readx,
147 readb, readxexact, NonContiguousMap ) );
149 if ( LastFourBytes ==
".mtx" ) {
150 EPETRA_CHK_ERR( Trilinos_Util_ReadMatrixMarket2Epetra( matrix_file, Comm, readMap,
151 readA, readx, readb, readxexact) );
154 Trilinos_Util_ReadHb2Epetra( matrix_file, Comm, readMap, readA, readx,
160 Epetra_CrsMatrix transposeA(Copy, *readMap, 0);
161 Epetra_CrsMatrix *serialA ;
165 serialA = &transposeA ;
170 Epetra_RowMatrix * passA = 0;
171 Epetra_Vector * passx = 0;
172 Epetra_Vector * passb = 0;
173 Epetra_Vector * passxexact = 0;
174 Epetra_Vector * passresid = 0;
175 Epetra_Vector * passtmp = 0;
178 Epetra_Map map(readMap->NumGlobalElements(), 0, Comm);
181 if( NonContiguousMap ) {
185 int NumGlobalElements = readMap->NumGlobalElements();
186 int NumMyElements = map.NumMyElements();
187 int MyFirstElement = map.MinMyGID();
188 std::vector<int> MapMap_( NumGlobalElements );
189 readMap->MyGlobalElements( &MapMap_[0] ) ;
190 Comm.Broadcast( &MapMap_[0], NumGlobalElements, 0 ) ;
191 map_ =
new Epetra_Map( NumGlobalElements, NumMyElements, &MapMap_[MyFirstElement], 0, Comm);
193 map_ =
new Epetra_Map( map ) ;
197 Epetra_CrsMatrix A(Copy, *map_, 0);
200 const Epetra_Map &OriginalMap = serialA->RowMatrixRowMap() ;
201 assert( OriginalMap.SameAs(*readMap) );
202 Epetra_Export exporter(OriginalMap, *map_);
203 Epetra_Export exporter2(OriginalMap, *map_);
204 Epetra_Export MatrixExporter(OriginalMap, *map_);
205 Epetra_CrsMatrix AwithDiag(Copy, *map_, 0);
207 Epetra_Vector x(*map_);
208 Epetra_Vector b(*map_);
209 Epetra_Vector xexact(*map_);
210 Epetra_Vector resid(*map_);
211 Epetra_Vector readresid(*readMap);
212 Epetra_Vector tmp(*map_);
213 Epetra_Vector readtmp(*readMap);
217 if ( distribute_matrix ) {
222 x.Export(*readx, exporter, Add);
223 b.Export(*readb, exporter, Add);
224 xexact.Export(*readxexact, exporter, Add);
227 A.Export(*serialA, exporter, Add);
228 assert(A.FillComplete()==0);
236 passxexact = &xexact;
245 passxexact = readxexact;
246 passresid = &readresid;
250 Epetra_MultiVector CopyB( *passb ) ;
253 double Anorm = passA->NormInf() ;
256 Epetra_LinearProblem Problem( (Epetra_RowMatrix *) passA,
257 (Epetra_MultiVector *) passx,
258 (Epetra_MultiVector *) passb );
261 for (
int i = 0; i < 1+special ; i++ ) {
262 Epetra_Time TotalTime( Comm ) ;
266 #ifdef HAVE_AMESOS_SUPERLUDIST
268 Teuchos::ParameterList ParamList ;
269 ParamList.set(
"MaxProcs", -3 );
274 Teuchos::ParameterList& SuperludistParams = ParamList.sublist(
"Superludist") ;
275 ParamList.set(
"MaxProcs", -3 );
283 #ifdef HAVE_AMESOS_DSCPACK
284 }
else if ( SparseSolver ==
DSCPACK ) {
286 Teuchos::ParameterList ParamList ;
287 ParamList.set(
"MaxProcs", -3 );
295 #ifdef HAVE_AMESOS_SCALAPACK
296 }
else if ( SparseSolver ==
SCALAPACK ) {
298 Teuchos::ParameterList ParamList ;
300 ParamList.set(
"MaxProcs", -3 );
308 #ifdef HAVE_AMESOS_TAUCS
309 }
else if ( SparseSolver ==
TAUCS ) {
311 Teuchos::ParameterList ParamList ;
313 ParamList.set(
"MaxProcs", -3 );
321 #ifdef HAVE_AMESOS_PARDISO
322 }
else if ( SparseSolver ==
PARDISO ) {
324 Teuchos::ParameterList ParamList ;
326 ParamList.set(
"MaxProcs", -3 );
334 #ifdef HAVE_AMESOS_PARAKLETE
335 }
else if ( SparseSolver ==
PARAKLETE ) {
337 Teuchos::ParameterList ParamList ;
339 ParamList.set(
"MaxProcs", -3 );
347 #if defined(HAVE_AMESOS_MUMPS) && defined(HAVE_MPI)
348 }
else if ( SparseSolver ==
MUMPS ) {
350 Teuchos::ParameterList ParamList ;
352 ParamList.set(
"MaxProcs", -3 );
360 #ifdef HAVE_AMESOS_SUPERLU
361 }
else if ( SparseSolver ==
SUPERLU ) {
363 Teuchos::ParameterList ParamList ;
365 ParamList.set(
"MaxProcs", -3 );
373 #ifdef HAVE_AMESOS_LAPACK
374 }
else if ( SparseSolver ==
LAPACK ) {
376 Teuchos::ParameterList ParamList ;
378 ParamList.set(
"MaxProcs", -3 );
385 #ifdef HAVE_AMESOS_UMFPACK
386 }
else if ( SparseSolver ==
UMFPACK ) {
388 Teuchos::ParameterList ParamList ;
390 ParamList.set(
"MaxProcs", -3 );
397 #ifdef HAVE_AMESOS_KLU
398 }
else if ( SparseSolver ==
KLU ) {
404 int setupTimePtr = -1, symTimePtr = -1, numTimePtr = -1, refacTimePtr = -1, solveTimePtr = -1;
408 Teuchos::ParameterList ParamList ;
411 ParamList.set(
"MaxProcs", -3 );
412 ParamList.set(
"TrustMe",
false );
416 setupTimePtr = AT.
AddTime(
"Setup", setupTimePtr, 0);
418 symTimePtr = AT.
AddTime(
"Symbolic", symTimePtr, 0);
420 numTimePtr = AT.
AddTime(
"Numeric", numTimePtr, 0);
422 refacTimePtr = AT.
AddTime(
"Refactor", refacTimePtr, 0);
425 solveTimePtr = AT.
AddTime(
"Solve", solveTimePtr, 0);
427 double SetupTime = AT.
GetTime(setupTimePtr);
428 double SymbolicTime = AT.
GetTime(symTimePtr);
429 double NumericTime = AT.
GetTime(numTimePtr);
430 double RefactorTime = AT.
GetTime(refacTimePtr);
431 double SolveTime = AT.
GetTime(solveTimePtr);
433 std::cout << __FILE__ <<
"::" << __LINE__ <<
" SetupTime = " << SetupTime << std::endl ;
434 std::cout << __FILE__ <<
"::" << __LINE__ <<
" SymbolicTime = " << SymbolicTime - SetupTime << std::endl ;
435 std::cout << __FILE__ <<
"::" << __LINE__ <<
" NumericTime = " << NumericTime - SymbolicTime<< std::endl ;
436 std::cout << __FILE__ <<
"::" << __LINE__ <<
" RefactorTime = " << RefactorTime - NumericTime << std::endl ;
437 std::cout << __FILE__ <<
"::" << __LINE__ <<
" SolveTime = " << SolveTime - RefactorTime << std::endl ;
442 std::cerr <<
"\n\n#################### Requested solver not available on this platform ##################### ATS\n" << std::endl ;
443 std::cout <<
" SparseSolver = " << SparseSolver << std::endl ;
444 std::cerr <<
" SparseSolver = " << SparseSolver << std::endl ;
454 passresid->Update(1.0, *passx, -1.0, *passxexact, 0.0);
456 passresid->Norm2(&error);
467 passA->Multiply( transpose, *passx, *passtmp);
468 passresid->Update(1.0, *passtmp, -1.0, *passb, 0.0);
470 passresid->Norm2(&residual);
475 passb->Norm2( &bnorm ) ;
479 passx->Norm2( &xnorm ) ;
int NumericFactorization()
Performs NumericFactorization on the matrix A.
#define EPETRA_CHK_ERR(xxx)
int SetParameters(Teuchos::ParameterList &ParameterList)
Set parameters from the input parameters list, returns 0 if successful.
int SetUseTranspose(bool UseTranspose)
Amesos_Superludist does not support transpose at this time.
int SymbolicFactorization()
Performs SymbolicFactorization on the matrix A.
int NumericFactorization()
Performs NumericFactorization on the matrix A.
int NumericFactorization()
Performs NumericFactorization on the matrix A.
int SymbolicFactorization()
Performs SymbolicFactorization on the matrix A.
Amesos_Klu: A serial, unblocked code ideal for getting started and for very sparse matrices,...
int SymbolicFactorization()
Performs SymbolicFactorization on the matrix A.
int Solve()
Solves A X = B (or AT x = B)
int Amesos_TestSolver(Epetra_Comm &Comm, char *matrix_file, SparseSolverType SparseSolver, bool transpose, int special, AMESOS_MatrixType matrix_type)
int NumericFactorization()
Performs NumericFactorization on the matrix A.
int NumericFactorization()
Performs NumericFactorization on the matrix A.
int SetUseTranspose(bool useTheTranspose)
If set true, X will be set to the solution of AT X = B (not A X = B)
int SetUseTranspose(bool UseTranspose_in)
If set true, X will be set to the solution of AT X = B (not A X = B)
double GetTime(const std::string what) const
Gets the cumulative time using the string.
int SetParameters(Teuchos::ParameterList &ParameterList)
Updates internal variables.
int SetParameters(Teuchos::ParameterList &ParameterList)
Updates internal variables.
int AddTime(const std::string what, int dataID, const int timerID=0)
Adds to field what the time elapsed since last call to ResetTimer().
int NumericFactorization()
Performs NumericFactorization on the matrix A.
Class Amesos_Umfpack: An object-oriented wrapper for UMFPACK.
int Solve()
Solves A X = B (or AT x = B)
void Set_Anorm(double anorm_in)
int SymbolicFactorization()
Performs SymbolicFactorization on the matrix A.
int NumericFactorization()
Performs NumericFactorization on the matrix A.
int SetParameters(Teuchos::ParameterList &ParameterList)
Updates internal variables.
void Set_Xnorm(double xnorm_in)
int SetUseTranspose(bool UseTranspose_in)
If set true, X will be set to the solution of AT X = B (not A X = B)
int SymbolicFactorization()
Performs SymbolicFactorization on the matrix A.
Amesos_Scalapack: A serial and parallel dense solver. For now, we implement only the unsymmetric ScaL...
Amesos_Lapack: an interface to LAPACK.
Amesos_Dscpack: An object-oriented wrapper for Dscpack.
int SymbolicFactorization()
Performs SymbolicFactorization on the matrix A.
int SetParameters(Teuchos::ParameterList &ParameterList)
Updates internal variables.
int NumericFactorization()
Performs NumericFactorization on the matrix A.
Amesos_Superludist: An object-oriented wrapper for Superludist.
int SetParameters(Teuchos::ParameterList &ParameterList)
Updates internal variables.
int Solve()
Solves A X = B (or AT x = B)
int Solve()
Solves A X = B (or AT X = B)
int SymbolicFactorization()
Performs SymbolicFactorization on the matrix A.
int SetUseTranspose(bool UseTranspose)
SetUseTranpose()
int SymbolicFactorization()
Performs SymbolicFactorization on the matrix A.
static SparseSolverResult SS_Result
void CreateTimer(const Epetra_Comm &Comm, int size=1)
Initializes the Time object.
int Solve()
Solves A X = B (or AT x = B)
int NumericFactorization()
Performs NumericFactorization on the matrix A.
Amesos_Mumps: An object-oriented wrapper for the double precision version of MUMPS.
int CrsMatrixTranspose(Epetra_CrsMatrix *In, Epetra_CrsMatrix *Out)
Amesos_Taucs: An interface to the TAUCS package.
int SetParameters(Teuchos::ParameterList &ParameterList)
Updates internal variables.
void Set_Total_Time(double Total_Time_in)
int SetParameters(Teuchos::ParameterList &ParameterList)
Deprecated - Sets parameters.
int SetParameters(Teuchos::ParameterList &ParameterList)
Updates internal variables.
int SymbolicFactorization()
Performs SymbolicFactorization on the matrix A.
int Solve()
Solves A X = B (or AT x = B)
int SetUseTranspose(bool UseTranspose)
SetUseTranpose(true) is more efficient in Amesos_Scalapack.
int SetParameters(Teuchos::ParameterList &ParameterList)
Updates internal variables.
int Solve()
Solves A X = B (or AT x = B)
int SetParameters(Teuchos::ParameterList &ParameterList)
Updates internal variables.
int SymbolicFactorization()
Performs SymbolicFactorization on the matrix A.
int SetUseTranspose(bool UseTranspose_in)
If set true, X will be set to the solution of AT X = B (not A X = B)
Amesos_Paraklete: A serial, unblocked code ideal for getting started and for very sparse matrices,...
void Set_Bnorm(double bnorm_in)
static std::ofstream log_file
int NumericFactorization()
Performs NumericFactorization on the matrix A.
int Solve()
Solves A X = B (or AT X = B)
int SetUseTranspose(bool UseTranspose_in)
SetUseTranpose()
void ResetTimer(const int timerID=0)
Resets the internally stored time object.
Amesos_Superlu: Amesos interface to Xioye Li's SuperLU 3.0 serial code.
Amesos_Time: Container for timing information.
int Solve()
Solves A X = B (or AT x = B)
int Solve()
Solves A X = B (or AT x = B)
int SetUseTranspose(bool UseTranspose_in)
SetUseTranpose(true) is more efficient in Amesos_Klu.
int SetUseTranspose(bool UseTranspose)
Amesos_Taucs supports only symmetric matrices, hence transpose is irrelevant, but harmless.
void Set_Error(double error_in)
int SymbolicFactorization()
Performs SymbolicFactorization on the matrix A.
int NumericFactorization()
Performs NumericFactorization on the matrix A.
Amesos_Pardiso: Interface to the PARDISO package.
int Solve()
Solves A X = B (or AT x = B)
void Set_Residual(double residual_in)