34 #include "Trilinos_Util.h"
47 #ifdef HAVE_AMESOS_SUPERLU
50 #ifdef HAVE_AMESOS_SUPERLUDIST
53 #ifdef HAVE_AMESOS_SLUD
56 #ifdef HAVE_AMESOS_SLUS
59 #ifdef HAVE_AMESOS_SLUD2
65 #ifdef HAVE_AMESOS_DSCPACK
68 #ifdef HAVE_AMESOS_LAPACK
71 #ifdef HAVE_AMESOS_UMFPACK
74 #ifdef HAVE_AMESOS_KLU
77 #ifdef HAVE_AMESOS_SCALAPACK
80 #ifdef HAVE_AMESOS_TAUCS
83 #if defined(HAVE_AMESOS_PARDISO) || defined(HAVE_AMESOS_PARDISO_MKL)
86 #ifdef HAVE_AMESOS_CSS_MKL
89 #ifdef HAVE_AMESOS_PARAKLETE
92 #if defined(HAVE_AMESOS_MUMPS) && defined(HAVE_MPI)
135 std::string FileName = matrix_file ;
136 int FN_Size = FileName.size() ;
137 std::string LastFiveBytes = FileName.substr(
EPETRA_MAX(0,FN_Size-5), FN_Size );
138 std::string LastFourBytes = FileName.substr(
EPETRA_MAX(0,FN_Size-4), FN_Size );
139 bool NonContiguousMap =
false;
143 if ( LastFiveBytes ==
".triU" ) {
145 NonContiguousMap =
true;
146 EPETRA_CHK_ERR( Trilinos_Util_ReadTriples2Epetra( matrix_file,
false, Comm, readMap, serialA, readx,
147 readb, readxexact, NonContiguousMap ) );
149 if ( LastFiveBytes ==
".triS" ) {
150 NonContiguousMap =
true;
152 EPETRA_CHK_ERR( Trilinos_Util_ReadTriples2Epetra( matrix_file,
true, Comm, readMap, serialA, readx,
153 readb, readxexact, NonContiguousMap ) );
155 if ( LastFourBytes ==
".mtx" ) {
156 EPETRA_CHK_ERR( Trilinos_Util_ReadMatrixMarket2Epetra( matrix_file, Comm, readMap,
157 serialA, readx, readb, readxexact) );
160 Trilinos_Util_ReadHb2Epetra( matrix_file, Comm, readMap, serialA, readx,
171 serialA = &transposeA;
185 if( NonContiguousMap ) {
190 int NumMyElements = map.NumMyElements();
191 int MyFirstElement = map.MinMyGID();
192 std::vector<int> MapMap_( NumGlobalElements );
194 Comm.
Broadcast( &MapMap_[0], NumGlobalElements, 0 ) ;
195 map_ =
new Epetra_Map( NumGlobalElements, NumMyElements, &MapMap_[MyFirstElement], 0, Comm);
205 assert( OriginalMap.
SameAs(*readMap) );
221 if ( distribute_matrix ) {
228 x.Export(*readx, exporter,
Add);
229 b.Export(*readb, exporter,
Add);
230 xexact.Export(*readxexact, exporter,
Add);
233 A.Export(*serialA, exporter,
Add);
246 passxexact = &xexact;
253 passxexact = readxexact;
254 passresid = &readresid;
261 double Anorm = passA->
NormInf() ;
269 for (
int i = 0; i < 1+special ; i++ ) {
274 #ifdef HAVE_AMESOS_SUPERLUDIST
277 ParamList.
set(
"MaxProcs", -3 );
283 ParamList.
set(
"MaxProcs", -3 );
291 #ifdef HAVE_AMESOS_DSCPACK
292 }
else if ( SparseSolver ==
DSCPACK ) {
295 ParamList.
set(
"MaxProcs", -3 );
303 #ifdef HAVE_AMESOS_SCALAPACK
304 }
else if ( SparseSolver ==
SCALAPACK ) {
308 ParamList.
set(
"MaxProcs", -3 );
316 #ifdef HAVE_AMESOS_TAUCS
317 }
else if ( SparseSolver ==
TAUCS ) {
321 ParamList.
set(
"MaxProcs", -3 );
329 #if defined(HAVE_AMESOS_PARDISO) || defined(HAVE_AMESOS_PARDISO_MKL)
330 }
else if ( SparseSolver ==
PARDISO ) {
334 ParamList.
set(
"MaxProcs", -3 );
342 #ifdef HAVE_AMESOS_CSS_MKL
343 }
else if ( SparseSolver ==
CSS ) {
347 ParamList.
set(
"MaxProcs", -3 );
365 bool printTime =
true;
368 TimeMonitor::summarize();
371 #ifdef HAVE_AMESOS_PARAKLETE
372 }
else if ( SparseSolver ==
PARAKLETE ) {
376 ParamList.
set(
"MaxProcs", -3 );
384 #if defined(HAVE_AMESOS_MUMPS) && defined(HAVE_MPI)
385 }
else if ( SparseSolver ==
MUMPS ) {
389 ParamList.
set(
"MaxProcs", -3 );
397 #ifdef HAVE_AMESOS_SUPERLU
398 }
else if ( SparseSolver ==
SUPERLU ) {
402 ParamList.
set(
"MaxProcs", -3 );
410 #ifdef HAVE_AMESOS_LAPACK
411 }
else if ( SparseSolver ==
LAPACK ) {
415 ParamList.
set(
"MaxProcs", -3 );
422 #ifdef HAVE_AMESOS_UMFPACK
423 }
else if ( SparseSolver ==
UMFPACK ) {
427 ParamList.
set(
"MaxProcs", -3 );
434 #ifdef HAVE_AMESOS_KLU
435 }
else if ( SparseSolver ==
KLU ) {
438 using namespace Teuchos;
441 int setupTimePtr = -1, symTimePtr = -1, numTimePtr = -1, refacTimePtr = -1, solveTimePtr = -1;
448 ParamList.set(
"MaxProcs", -3 );
449 ParamList.set(
"TrustMe",
false );
453 setupTimePtr = AT.AddTime(
"Setup", setupTimePtr, 0);
455 symTimePtr = AT.AddTime(
"Symbolic", symTimePtr, 0);
457 numTimePtr = AT.AddTime(
"Numeric", numTimePtr, 0);
459 refacTimePtr = AT.AddTime(
"Refactor", refacTimePtr, 0);
462 solveTimePtr = AT.AddTime(
"Solve", solveTimePtr, 0);
464 double SetupTime = AT.GetTime(setupTimePtr);
465 double SymbolicTime = AT.GetTime(symTimePtr);
466 double NumericTime = AT.GetTime(numTimePtr);
467 double RefactorTime = AT.GetTime(refacTimePtr);
468 double SolveTime = AT.GetTime(solveTimePtr);
470 std::cout << __FILE__ <<
"::" << __LINE__ <<
" SetupTime = " << SetupTime << std::endl ;
471 std::cout << __FILE__ <<
"::" << __LINE__ <<
" SymbolicTime = " << SymbolicTime - SetupTime << std::endl ;
472 std::cout << __FILE__ <<
"::" << __LINE__ <<
" NumericTime = " << NumericTime - SymbolicTime<< std::endl ;
473 std::cout << __FILE__ <<
"::" << __LINE__ <<
" RefactorTime = " << RefactorTime - NumericTime << std::endl ;
474 std::cout << __FILE__ <<
"::" << __LINE__ <<
" SolveTime = " << SolveTime - RefactorTime << std::endl ;
479 std::cerr <<
"\n\n#################### Requested solver not available on this platform ##################### ATS\n" << std::endl ;
480 std::cout <<
" SparseSolver = " << SparseSolver << std::endl ;
481 std::cerr <<
" SparseSolver = " << SparseSolver << std::endl ;
491 passresid->Update(1.0, *passx, -1.0, *passxexact, 0.0);
493 passresid->Norm2(&error);
504 passA->
Multiply( transpose, *passx, *passtmp);
505 passresid->Update(1.0, *passtmp, -1.0, *passb, 0.0);
507 passresid->Norm2(&residual);
512 passb->Norm2( &bnorm ) ;
516 passx->Norm2( &xnorm ) ;
521 if ( !distribute_matrix ) {
int SetUseTranspose(bool UseTranspose)
SetUseTranpose(true) is more efficient in Amesos_Scalapack.
int NumGlobalElements() const
Amesos_Klu: A serial, unblocked code ideal for getting started and for very sparse matrices...
int SymbolicFactorization()
Performs SymbolicFactorization on the matrix A.
void PrintTiming() const
Prints timing information.
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.
bool SameAs(const Epetra_BlockMap &Map) const
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.
int MyGlobalElements(int *MyGlobalElementList) const
int Solve()
Solves A X = B (or AT x = B)
void Set_Total_Time(double Total_Time_in)
double ElapsedTime(void) const
Amesos_Dscpack: An object-oriented wrapper for Dscpack.
void Set_Anorm(double anorm_in)
int Solve()
Solves A X = B (or AT X = B)
int SetUseTranspose(bool UseTranspose)
SetUseTranpose()
const Epetra_Map & RowMatrixRowMap() const
RCP< ParameterList > sublist(const RCP< ParameterList > ¶mList, const std::string &name, bool mustAlreadyExist=false, const std::string &docString="")
int CrsMatrixTranspose(Epetra_CrsMatrix *In, Epetra_CrsMatrix *Out)
int SymbolicFactorization()
Performs SymbolicFactorization on the matrix A.
int SetParameters(Teuchos::ParameterList &ParameterList)
Updates internal variables.
ParameterList & set(std::string const &name, T &&value, std::string const &docString="", RCP< const ParameterEntryValidator > const &validator=null)
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)
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 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 SetUseTranspose(bool UseTranspose)
SetUseTranpose()
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 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 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 NumericFactorization()
Performs NumericFactorization on the matrix A.
int Solve()
Solves A X = B (or AT x = B)
int SetParameters(Teuchos::ParameterList &ParameterList)
Set parameters from the input parameters list, returns 0 if successful.
int SetParameters(Teuchos::ParameterList &ParameterList)
Updates internal variables.
int NumericFactorization()
Performs NumericFactorization on the matrix A.
Amesos_CssMKL: Interface to the CSSMKL package.
static std::ofstream log_file
int NumericFactorization()
Performs NumericFactorization on the matrix A.
static SparseSolverResult SS_Result
int SymbolicFactorization()
Performs SymbolicFactorization on the matrix A.
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.
int NumericFactorization()
Performs NumericFactorization on the matrix A.