30 #include "Teuchos_ParameterList.hpp" 33 #include "Trilinos_Util.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) 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,
165 serialA = &transposeA ;
181 if( NonContiguousMap ) {
186 int NumMyElements = map.NumMyElements();
187 int MyFirstElement = map.MinMyGID();
188 std::vector<int> MapMap_( NumGlobalElements );
190 Comm.
Broadcast( &MapMap_[0], NumGlobalElements, 0 ) ;
191 map_ =
new Epetra_Map( NumGlobalElements, NumMyElements, &MapMap_[MyFirstElement], 0, Comm);
201 assert( OriginalMap.
SameAs(*readMap) );
217 if ( distribute_matrix ) {
224 xexact.
Export(*readxexact, exporter,
Add);
236 passxexact = &xexact;
245 passxexact = readxexact;
246 passresid = &readresid;
253 double Anorm = passA->
NormInf() ;
261 for (
int i = 0; i < 1+special ; i++ ) {
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 Norm2(double *Result) const
int SetUseTranspose(bool UseTranspose)
SetUseTranpose(true) is more efficient in Amesos_Scalapack.
Amesos_Klu: A serial, unblocked code ideal for getting started and for very sparse matrices...
double GetTime(const std::string what) const
Gets the cumulative time using the string.
int MyGlobalElements(int *MyGlobalElementList) const
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)
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 NumericFactorization()
Performs NumericFactorization on the matrix A.
int SetParameters(Teuchos::ParameterList &ParameterList)
Updates internal variables.
Amesos_Paraklete: A serial, unblocked code ideal for getting started and for very sparse matrices...
int SymbolicFactorization()
Performs SymbolicFactorization on the matrix A.
Amesos_Superludist: An object-oriented wrapper for Superludist.
int Solve()
Solves A X = B (or AT x = B)
Amesos_Mumps: An object-oriented wrapper for the double precision version of MUMPS.
int Solve()
Solves A X = B (or AT x = B)
int SymbolicFactorization()
Performs SymbolicFactorization on the matrix A.
bool SameAs(const Epetra_BlockMap &Map) const
int Solve()
Solves A X = B (or AT x = B)
void Set_Total_Time(double Total_Time_in)
Amesos_Dscpack: An object-oriented wrapper for Dscpack.
void Set_Anorm(double anorm_in)
int SetUseTranspose(bool UseTranspose)
SetUseTranpose()
int CrsMatrixTranspose(Epetra_CrsMatrix *In, Epetra_CrsMatrix *Out)
int SymbolicFactorization()
Performs SymbolicFactorization on the matrix A.
int SetParameters(Teuchos::ParameterList &ParameterList)
Updates internal variables.
void CreateTimer(const Epetra_Comm &Comm, int size=1)
Initializes the Time object.
int SymbolicFactorization()
Performs SymbolicFactorization on the matrix A.
int SetParameters(Teuchos::ParameterList &ParameterList)
Updates internal variables.
virtual void Barrier() const=0
Amesos_Pardiso: Interface to the PARDISO package.
Amesos_Superlu: Amesos interface to Xioye Li's SuperLU 3.0 serial code.
int Solve()
Solves A X = B (or AT X = B)
const Epetra_Map & RowMatrixRowMap() const
int FillComplete(bool OptimizeDataStorage=true)
int SetParameters(Teuchos::ParameterList &ParameterList)
Updates internal variables.
void Set_Error(double error_in)
int SymbolicFactorization()
Performs SymbolicFactorization on the matrix A.
int SetUseTranspose(bool UseTranspose_in)
SetUseTranpose()
int Export(const Epetra_SrcDistObject &A, const Epetra_Import &Importer, Epetra_CombineMode CombineMode, const Epetra_OffsetIndex *Indexor=0)
int NumericFactorization()
Performs NumericFactorization 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)
int SymbolicFactorization()
Performs SymbolicFactorization on the matrix A.
int Amesos_TestSolver(Epetra_Comm &Comm, char *matrix_file, SparseSolverType SparseSolver, bool transpose, int special, AMESOS_MatrixType matrix_type)
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.
int SetParameters(Teuchos::ParameterList &ParameterList)
Set parameters from the input parameters list, returns 0 if successful.
int SymbolicFactorization()
Performs SymbolicFactorization on the matrix A.
int SetParameters(Teuchos::ParameterList &ParameterList)
Updates internal variables.
virtual double NormInf() const=0
int NumericFactorization()
Performs NumericFactorization on the matrix A.
int NumericFactorization()
Performs NumericFactorization on the matrix A.
#define EPETRA_CHK_ERR(xxx)
int NumericFactorization()
Performs NumericFactorization on the matrix A.
void Set_Xnorm(double xnorm_in)
Amesos_Time: Container for timing information.
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 SetUseTranspose(bool useTheTranspose)
If set true, X will be set to the solution of AT X = B (not A X = B)
int Solve()
Solves A X = B (or AT x = B)
virtual int Broadcast(double *MyVals, int Count, int Root) const=0
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...
virtual int Multiply(bool TransA, const Epetra_MultiVector &X, Epetra_MultiVector &Y) const=0
Amesos_Lapack: an interface to LAPACK.
int SymbolicFactorization()
Performs SymbolicFactorization on the matrix A.
int NumericFactorization()
Performs NumericFactorization on the matrix A.
int SetParameters(Teuchos::ParameterList &ParameterList)
Deprecated - Sets parameters.
int SetUseTranspose(bool UseTranspose)
Amesos_Superludist does not support transpose at this time.
int Solve()
Solves A X = B (or AT x = B)
int Update(double ScalarA, const Epetra_MultiVector &A, double ScalarThis)
int NumericFactorization()
Performs NumericFactorization on the matrix A.
int NumericFactorization()
Performs NumericFactorization on the matrix A.
int SetParameters(Teuchos::ParameterList &ParameterList)
Updates internal variables.
void Set_Residual(double residual_in)
int Solve()
Solves A X = B (or AT x = B)
int NumGlobalElements() const
int SetParameters(Teuchos::ParameterList &ParameterList)
Updates internal variables.
int NumericFactorization()
Performs NumericFactorization on the matrix A.
void ResetTimer(const int timerID=0)
Resets the internally stored time object.
static std::ofstream log_file
int NumericFactorization()
Performs NumericFactorization on the matrix A.
static SparseSolverResult SS_Result
int Solve()
Solves A X = B (or AT X = B)
int SetParameters(Teuchos::ParameterList &ParameterList)
Updates internal variables.
Class Amesos_Umfpack: An object-oriented wrapper for UMFPACK.
int Solve()
Solves A X = B (or AT x = B)
int SetParameters(Teuchos::ParameterList &ParameterList)
Updates internal variables.
void Set_Bnorm(double bnorm_in)
Amesos_Scalapack: A serial and parallel dense solver. For now, we implement only the unsymmetric ScaL...
Amesos_Taucs: An interface to the TAUCS package.
double ElapsedTime(void) const
int NumericFactorization()
Performs NumericFactorization on the matrix A.