33 This code cannot be compiled without mpi.h.
34 #include
"Epetra_Comm.h"
44 #include "supermatrix.h"
45 #include "superlu_ddefs.h"
50 #include "Comm_assert_equal.h"
53 #ifdef EPETRA_CRSMATRIX_CONSTRUCT_FROM_ROWMATRIX
54 #include "ExtractCrsFromRowMatrix.h"
69 for ( i = 1; i*i <= NumProcs; i++ )
72 for ( numrows = i-1 ; done == false ; ) {
73 int NumCols = NumProcs / numrows ;
74 if ( numrows * NumCols == NumProcs )
109 SUPERLU_FREE(
A.Store);
176 bool CheckExtraction =
false;
184 #ifdef EPETRA_CRSMATRIX_CONSTRUCT_FROM_ROWMATRIX
190 int iam = Comm.
MyPID() ;
196 if ( iam == 0 ) cin >> hatever ;
206 if ( CastCrsMatrixA != 0 && ! CheckExtraction ) {
207 Phase2Mat = CastCrsMatrixA ;
209 #ifdef EPETRA_CRSMATRIX_CONSTRUCT_FROM_ROWMATRIX
212 Phase2Mat = ExtractCrsMatrixA ;
214 if ( CheckExtraction )
215 assert( CrsMatricesAreIdentical( CastCrsMatrixA, ExtractCrsMatrixA ) ) ;
222 assert( Phase2Mat != NULL ) ;
229 MPI_Comm MPIC = comm1.
Comm() ;
235 assert( Comm_assert_equal( &Comm, IsLocal ) );
244 int NumMyElements_ = 0 ;
245 if (iam==0) NumMyElements_ = NumGlobalElements_;
246 Epetra_Map SerialMap( NumGlobalElements_, NumMyElements_, 0, Comm );
251 Phase3Mat = Phase2Mat ;
256 SerialCrsMatrixA.Export( *Phase2Mat, export_to_serial,
Add );
259 Phase3Mat = &SerialCrsMatrixA ;
279 Phase4Mat = Phase3Mat ;
282 Phase4Mat = &Phase3MatTrans ;
289 int * AllIDs =
new int[
numrows];
290 for (
int i = 0; i <
numrows ; i++ ) AllIDs[i] = i ;
293 Epetra_Map ReplicatedMap( -1, numrows, AllIDs, 0, Comm);
317 nrhs = vecX->NumVectors() ;
324 #ifdef ONE_VECTOR_ONLY
325 assert( vecX->NumVectors() == 1 ) ;
326 assert( vecB->NumVectors() == 1 ) ;
331 assert( vecXvector != 0 ) ;
332 assert( vecBvector != 0 ) ;
344 Epetra_Import ImportToReplicated( ReplicatedMap, Phase2Matmap);
346 vecXreplicated.Import( *vecXvector, ImportToReplicated,
Insert ) ;
347 vecBreplicated.Import( *vecBvector, ImportToReplicated,
Insert ) ;
349 assert( nArows == vecXreplicated.MyLength() ) ;
350 assert( nAcols == vecBreplicated.MyLength() ) ;
356 assert( vecBreplicated.ExtractView( &bValues, &bLda ) == 0 ) ;
357 assert( vecXreplicated.ExtractView( &xValues, &xLda ) == 0 ) ;
363 Ap.resize( numrows+1 );
372 for ( MyRow = 0; MyRow <
numrows; MyRow++ ) {
373 int status = Phase5Mat.
ExtractMyRowView( MyRow, NumEntries, RowValues, ColIndices ) ;
374 assert( status == 0 ) ;
375 Ap[MyRow] = Ai_index ;
376 for (
int j = 0; j < NumEntries; j++ ) {
377 Ai[Ai_index] = ColIndices[j] ;
378 Aval[Ai_index] = RowValues[j] ;
382 assert( numrows == MyRow );
401 assert( Comm_assert_equal( &Comm, numentries ) );
402 assert( Comm_assert_equal( &Comm, numrows ) );
403 assert( Comm_assert_equal( &Comm, numcols ) );
419 for (
int ii = 0; ii < min( numentries, 10 ) ; ii++ ) {
420 assert( Comm_assert_equal( &Comm,
Aval[ii] ) ) ;
422 for (
int ii = 0; ii < min( numcols+1, 10 ) ; ii++ ) {
423 assert( Comm_assert_equal( &Comm,
Ai[ii] ) );
424 assert( Comm_assert_equal( &Comm,
Ap[ii] ) );
426 for (
int ii = 0; ii < min( numrows, 10 ) ; ii++ ) {
427 assert( Comm_assert_equal( &Comm, bValues[ii] ) );
434 if ( !(
berr = doubleMalloc_dist(nrhs)) )
438 dCreate_CompCol_Matrix_dist(&
A, numrows, numcols,
439 numentries, &
Aval[0], &
Ai[0],
440 &
Ap[0], SLU_NC, SLU_D, SLU_GE);
444 cout <<
" Here is A " << endl ;
445 dPrint_CompCol_Matrix_dist( &
A );
446 cout <<
" That was A " <<
"numrows = " << numrows << endl ;
447 cout <<
"numcols = " << numcols << endl ;
452 LUstructInit(numrows, numcols, &
LUstruct);
454 assert(
options.Fact == DOFACT );
466 for (
int j = 0 ; j < nrhs; j++ )
467 for (
int i = 0 ; i <
numrows; i++ ) xValues[i+j*xLda] = bValues[i+j*xLda];
488 for (
int i = 0 ; i <
numrows; i++ ) {
490 lid[0] = Phase2Matmap.
LID( i ) ;
492 for (
int j = 0 ; j < nrhs; j++ ) {
493 vecXvector->ReplaceMyValue( lid[0], j, xValues[i + ldb * j] ) ;
const Epetra_LinearProblem * Problem_
int NumGlobalElements() const
int SLU_NumRows(int NumProcs)
Epetra_MultiVector * GetLHS() const
Epetra_MultiVector * GetRHS() const
superlu_options_t options
int NumGlobalRows() const
int CrsMatrixTranspose(Epetra_CrsMatrix *In, Epetra_CrsMatrix *Out)
bool GetTrans() const
Return the transpose flag.
ScalePermstruct_t ScalePermstruct
virtual void Barrier() const =0
virtual int MyPID() const =0
int FillComplete(bool OptimizeDataStorage=true)
SuperludistOO(const Epetra_LinearProblem &LinearProblem)
SuperludistOO Constructor.
int ExtractMyRowView(int MyRow, int &NumEntries, double *&Values, int *&Indices) const
virtual ~SuperludistOO(void)
SuperludistOO Destructor.
const Epetra_Map & RowMap() const
int NumMyElements() const
virtual const Epetra_Comm & Comm() const =0
int Solve(bool Factor)
All computation is performed during the call to Solve()
#define EPETRA_CHK_ERR(xxx)
int NumGlobalNonzeros() const
int NumGlobalCols() const
virtual int Broadcast(double *MyVals, int Count, int Root) const =0
virtual int NumProc() const =0
Epetra_Operator * GetOperator() const