42 #ifdef AMESOS_SUPERLU_PRE_JULY2005
43 # include "dsp_defs.h"
45 # include "slu_ddefs.h"
58 #ifdef HAVE_AMESOS_SUPERLU5_API
64 A.Store =
B.Store =
X.Store =
L.Store =
U.Store = NULL;
73 using namespace Teuchos;
79 NumGlobalNonzeros_(-1),
81 FactorizationOK_(false),
82 FactorizationDone_(false),
90 SerialMap_(Teuchos::
null),
91 SerialCrsMatrixA_(Teuchos::
null),
92 ImportToSerial_(Teuchos::
null),
103 dCreate_Dense_Matrix( &(
data_->
X),
108 SLU::SLU_DN, SLU::SLU_D, SLU::SLU_GE);
110 dCreate_Dense_Matrix( &(
data_->
B),
115 SLU::SLU_DN, SLU::SLU_D, SLU::SLU_GE);
124 Destroy_SuperMatrix_Store(&
data_->
B);
125 Destroy_SuperMatrix_Store(&
data_->
X);
129 Destroy_SuperMatrix_Store(&
data_->
A);
130 Destroy_SuperNode_Matrix(&
data_->
L);
131 Destroy_CompCol_Matrix(&
data_->
U);
158 if (
GetProblem()->GetOperator()->OperatorRangeMap().NumGlobalPoints64() !=
159 GetProblem()->GetOperator()->OperatorDomainMap().NumGlobalPoints64())
186 int NumMyElements_ = 0;
195 if (
Comm().NumProc() == 1)
201 #if !defined(EPETRA_NO_32BIT_GLOBAL_INDICES)
206 #if !defined(EPETRA_NO_64BIT_GLOBAL_INDICES)
211 throw "Amesos_Superlu::ConvertToSerial: Global indices unknown.";
232 std::cout << __FILE__ <<
"::" << __LINE__
233 <<
" this_res = " << this_res
299 Ap_[MyRow] = Ai_index;
304 Ai_index += NzThisRow;
312 Destroy_SuperMatrix_Store(&
data_->
A);
313 Destroy_SuperNode_Matrix(&
data_->
L);
314 Destroy_CompCol_Matrix(&
data_->
U);
318 dCreate_CompCol_Matrix( &(
data_->
A), NumGlobalRows_, NumGlobalRows_,
320 &
Ai_[0], &
Ap_[0], SLU::SLU_NR, SLU::SLU_D, SLU::SLU_GE );
361 std::vector<int> ColIndicesV_;
362 std::vector<double> RowValuesV_;
366 if ( SuperluCrs == 0 ) {
367 ColIndicesV_.resize(MaxNumEntries_);
368 RowValuesV_.resize(MaxNumEntries_);
371 if ( SuperluCrs != 0 ) {
377 RowValues = &RowValuesV_[0];
378 ColIndices = &ColIndicesV_[0];
381 if (
Ap_[MyRow] != Ai_index)
384 for (
int j = 0; j < NzThisRow; j++) {
385 assert(
Ai_[Ai_index] == ColIndices[j]) ;
386 Aval_[Ai_index] = RowValues[j] ;
390 assert( NumGlobalRows_ == MyRow );
396 Destroy_SuperMatrix_Store(&
data_->
A);
397 Destroy_SuperNode_Matrix(&
data_->
L);
398 Destroy_CompCol_Matrix(&
data_->
U);
400 dCreate_CompCol_Matrix( &(
data_->
A), NumGlobalRows_, NumGlobalRows_,
402 &
Ai_[0], &
Ap_[0], SLU::SLU_NR, SLU::SLU_D, SLU::SLU_GE );
433 set_default_options( &SLUopt ) ;
440 SLUopt.Fact = SLU::DOFACT;
450 assert( SLUopt.Trans == NOTRANS ) ;
452 SLUopt.Trans =
TRANS ;
457 std::cout <<
" SLUopt.ColPerm = " << SLUopt.ColPerm << std::endl ;
458 std::cout <<
" SLUopt.Equil = " << SLUopt.Equil << std::endl ;
459 std::cout <<
" SLUopt.Fact = " << SLUopt.Fact << std::endl ;
460 std::cout <<
" SLUopt.IterRefine = " << SLUopt.IterRefine << std::endl ;
461 std::cout <<
" data_->A.Stype = " <<
data_->
A.Stype
462 <<
" SLU_NC = " << SLU_NC
463 <<
" SLU_NR = " << SLU_NR
465 std::cout <<
" SLUopt.ColPerm = " << SLUopt.ColPerm << std::endl ;
470 SLU::DNformat* Bstore = (SLU::DNformat *) (
data_->
B.Store) ;
475 SLU::DNformat* Xstore = (SLU::DNformat *) (
data_->
X.Store) ;
479 SLU::SuperLUStat_t SLU_stat ;
480 SLU::StatInit( &SLU_stat ) ;
481 assert( SLUopt.Fact == SLU::DOFACT);
482 dgssvx( &(SLUopt), &(
data_->
A),
487 #ifdef HAVE_AMESOS_SUPERLU5_API
491 SLU::StatFree( &SLU_stat ) ;
517 if (vecX == 0 || vecB == 0)
520 int nrhs = vecX->NumVectors();
521 if (nrhs != vecB->NumVectors())
530 double *SerialXvalues ;
531 double *SerialBvalues ;
533 if (
Comm().NumProc() == 1)
564 ierr = SerialX->ExtractView(&SerialXvalues, &SerialXlda);
569 ierr = SerialB->ExtractView(&SerialBvalues, &SerialBlda);
574 SLU::SuperMatrix& dataX = (
data_->
X) ;
578 SLU::DNformat* Xstore = (SLU::DNformat *) (
data_->
X.Store) ;
579 Xstore->lda = SerialXlda;
580 Xstore->nzval = &SerialXvalues[0];
582 SLU::SuperMatrix& dataB = (
data_->
B) ;
586 SLU::DNformat* Bstore = (SLU::DNformat *) (
data_->
B.Store) ;
587 Bstore->lda = SerialBlda;
588 Bstore->nzval = &SerialBvalues[0];
592 char fact, trans, refact;
607 SLU::SuperLUStat_t SLU_stat ;
608 SLU::StatInit( &SLU_stat ) ;
612 SLUopt.Trans = SLU::TRANS;
614 SLUopt.Trans = SLU::NOTRANS;
618 dgssvx( &(SLUopt), &(
data_->
A),
623 #ifdef HAVE_AMESOS_SUPERLU5_API
628 StatFree( &SLU_stat ) ;
638 if (
Comm().NumProc() != 1)
661 if (
Comm().NumProc() != 1)
674 std::string p =
"Amesos_Superlu : ";
680 std::cout << p <<
"Matrix has " << n <<
" rows"
681 <<
" and " << nnz <<
" nonzeros" << std::endl;
682 std::cout << p <<
"Nonzero elements per row = "
683 << 1.0 * nnz / n << std::endl;
684 std::cout << p <<
"Percentage of nonzero elements = "
685 << 100.0 * nnz /(pow(
double(n),
double(2.0))) << std::endl;
686 std::cout << p <<
"Use transpose = " <<
UseTranspose_ << std::endl;
712 std::string p =
"Amesos_Superlu : ";
715 std::cout << p <<
"Time to convert matrix to SuperLU format = " << ConTime <<
" (s)" << std::endl;
716 std::cout << p <<
"Time to redistribute matrix = " << MatTime <<
" (s)" << std::endl;
717 std::cout << p <<
"Time to redistribute vectors = " << VecTime <<
" (s)" << std::endl;
718 std::cout << p <<
"Number of numeric factorizations = " <<
NumNumericFact_ << std::endl;
719 std::cout << p <<
"Time for num fact = "
721 << NumTime <<
" (s)" << std::endl;
722 std::cout << p <<
"Number of solve phases = " <<
NumSolve_ << std::endl;
723 std::cout << p <<
"Time for solve = "
724 << SolTime *
NumSolve_ <<
" (s), avg = " << SolTime <<
" (s)" << std::endl;
728 std::cout << p <<
"Total time spent in Amesos = " << tt <<
" (s) " << std::endl;
729 std::cout << p <<
"Total time spent in the Amesos interface = " << OveTime <<
" (s)" << std::endl;
730 std::cout << p <<
"(the above time does not include SuperLU time)" << std::endl;
731 std::cout << p <<
"Amesos interface time / total time = " << OveTime / tt << std::endl;
void PrintStatus() const
Prints status information.
std::vector< int > etree_
virtual const Epetra_Map & RowMatrixRowMap() const =0
void PrintLine() const
Prints line on std::cout.
Teuchos::RCP< Epetra_Map > SerialMap_
Contains a map with all elements assigned to processor 0.
std::vector< double > Aval_
Epetra_MultiVector * GetLHS() const
int SetParameters(Teuchos::ParameterList &ParameterList)
Updates internal variables.
Epetra_MultiVector * GetRHS() const
bool GlobalIndicesLongLong() const
Epetra_RowMatrix * SerialMatrix_
For parallel runs, stores the matrix defined on SerialMap_.
SLU::fact_t refactor_option
SLU::superlu_options_t SLU_options
int Solve()
Solves A X = B (or AT x = B)
std::vector< int > perm_c_
virtual int InsertGlobalValues(int GlobalRow, int NumEntries, const double *Values, const int *Indices)
std::vector< int > Ap_
stores the matrix in SuperLU format.
virtual int SumIntoGlobalValues(int GlobalRow, int NumEntries, const double *Values, const int *Indices)
const Epetra_Map & SerialMap() const
Returns a reference to the serial map.
void CreateTimer(const Epetra_Comm &Comm, int size=1)
Initializes the Time object.
const Epetra_Import & ImportToSerial() const
Returns a reference to the importer.
bool GlobalIndicesInt() const
int Factor()
Factors the matrix, no previous factorization available.
int MtxConvTime_
Quick access pointer to internal timing data.
bool UseTranspose_
If true, solve the linear system with the transpose of the matrix.
long long NumGlobalNonzeros_
Global number of nonzeros in the matrix.
int NumNumericFact_
Number of numeric factorization phases.
virtual int MyPID() const =0
SLU::mem_usage_t mem_usage
int ReFactor()
Re-factors the matrix.
int FillComplete(bool OptimizeDataStorage=true)
virtual int NumMyCols() const =0
bool UseTranspose() const
Returns the current UseTranspose setting.
int ExtractMyRowView(int MyRow, int &NumEntries, double *&Values, int *&Indices) const
SLU::factor_param_t iparam
int NumSolve_
Number of solves.
virtual int MaxNumEntries() const =0
void SetStatusParameters(const Teuchos::ParameterList &ParameterList)
bool MatrixShapeOK() const
Returns true if the solver can handle this matrix shape.
TEUCHOS_DEPRECATED RCP< T > rcp(T *p, Dealloc_T dealloc, bool owns_mem)
Amesos_Superlu(const Epetra_LinearProblem &LinearProblem)
Amesos_Superlu Constructor.
bool ComputeVectorNorms_
If true, prints the norms of X and B in Solve().
void SetControlParameters(const Teuchos::ParameterList &ParameterList)
const Epetra_LinearProblem * GetProblem() const
Returns the Epetra_LinearProblem.
#define AMESOS_CHK_ERR(a)
int SymbolicFactorization()
Performs SymbolicFactorization on the matrix A.
bool PrintTiming_
If true, prints timing information in the destructor.
virtual int NumMyRows() const =0
std::vector< double > ferr_
bool PrintStatus_
If true, print additional information in the destructor.
#define AMESOS_RETURN(amesos_err)
virtual long long NumGlobalCols64() const =0
int AddTime(const std::string what, int dataID, const int timerID=0)
Adds to field what the time elapsed since last call to ResetTimer().
virtual int Broadcast(double *MyVals, int Count, int Root) const =0
Epetra_RowMatrix * RowMatrixA_
Pointer to the linear system matrix.
virtual long long NumGlobalNonzeros64() const =0
const Epetra_Comm & Comm() const
Returns a pointer to the Epetra_Comm communicator associated with this operator.
double * DummyArray
stores the matrix in SuperLU format.
int ConvertToSerial()
Sets up the matrix on processor 0.
Epetra_RowMatrix * GetMatrix() const
void ComputeTrueResidual(const Epetra_RowMatrix &Matrix, const Epetra_MultiVector &X, const Epetra_MultiVector &B, const bool UseTranspose, const std::string prefix) const
Computes the true residual, B - Matrix * X, and prints the results.
Teuchos::RCP< Epetra_CrsMatrix > SerialCrsMatrixA_
Contains a matrix with all rows assigned to processor 0.
Teuchos::RCP< Epetra_Import > ImportToSerial_
Importer from distributed to SerialMap_.
SLUData * data_
Main structure for SuperLU.
void ResetTimer(const int timerID=0)
Resets the internally stored time object.
~Amesos_Superlu()
Amesos_Superlu Destructor.
std::vector< double > berr_
std::vector< int > perm_r_
bool FactorizationOK_
If true, the factorization has been successfully computed.
virtual int ExtractMyRowCopy(int MyRow, int Length, int &NumEntries, double *Values, int *Indices) const =0
Epetra_Operator * GetOperator() const
int iam_
Process number (i.e. Comm().MyPID()
double GetTime(const std::string what) const
Gets the cumulative time using the string.
void PrintTiming() const
Prints timing information.
long long NumGlobalRows_
Global size of the matrix.
std::vector< int > Ai_
stores the matrix in SuperLU format.
virtual long long NumGlobalRows64() const =0
const Epetra_LinearProblem * Problem_
Pointer to the user's defined linear problem.
void ComputeVectorNorms(const Epetra_MultiVector &X, const Epetra_MultiVector &B, const std::string prefix) const
Computes the norms of X and B and print the results.
int NumericFactorization()
Performs NumericFactorization on the matrix A.
bool ComputeTrueResidual_
If true, computes the true residual in Solve().