34 This code cannot be compiled without mpi.h.
35 #include
"Epetra_Comm.h" 49 #include "Comm_assert_equal.h" 52 #ifdef EPETRA_CRSMATRIX_CONSTRUCT_FROM_ROWMATRIX 53 #include "ExtractCrsFromRowMatrix.h" 68 for ( i = 1; i*i <= NumProcs; i++ )
71 for ( NumProcRows = i-1 ; done == false ; ) {
72 int NumCols = NumProcs / NumProcRows ;
73 if ( NumProcRows * NumCols == NumProcs )
108 SUPERLU_FREE(
A.Store );
112 if (
options.SolveInitialized ) {
115 superlu_gridexit(&
grid);
173 #undef EPETRA_CHK_ERR 174 #define EPETRA_CHK_ERR(xxx) assert( (xxx) == 0 ) 183 bool CheckExtraction =
false;
193 #ifdef EPETRA_CRSMATRIX_CONSTRUCT_FROM_ROWMATRIX 199 int iam = Comm.
MyPID() ;
205 if ( iam == 0 ) cin >> hatever ;
216 if ( CastCrsMatrixA != 0 && ! CheckExtraction ) {
217 Phase2Mat = CastCrsMatrixA ;
219 #ifdef EPETRA_CRSMATRIX_CONSTRUCT_FROM_ROWMATRIX 222 Phase2Mat = ExtractCrsMatrixA ;
224 if ( CheckExtraction )
225 assert( CrsMatricesAreIdentical( CastCrsMatrixA, ExtractCrsMatrixA ) ) ;
231 assert( Phase2Mat !=
NULL ) ;
247 cout <<
" A Comm.NumProc() = " << Comm.
NumProc() << endl ;
249 cout <<
" true = " <<
true <<
" LInMap = " << Phase2Matmap.
LinearMap() << endl ;
266 int MyFirstElement = iam * m_per_p +
EPETRA_MIN( iam, remainder );
267 int MyFirstNonElement = (iam+1) * m_per_p +
EPETRA_MIN( iam+1, remainder );
268 int NumExpectedElements = MyFirstNonElement - MyFirstElement ;
281 bool redistribute = true ;
282 if ( redistribute ) {
286 DistCrsMatrixA.Export( *Phase2Mat, export_to_dist,
Add );
288 DistCrsMatrixA.FillComplete() ;
289 Phase3Mat = &DistCrsMatrixA ;
300 vector <int> MyRows( Phase2NumElements ) ;
302 for (
int row = 0 ; row < Phase2NumElements ; row++ ) {
306 Phase3Mat = Phase2Mat ;
312 assert( MyFirstElement+NumExpectedElements-1 == Phase3Mat->
RowMap().
MaxMyGID() ) ;
316 int NumMyElements = Phase3Mat->
NumMyRows() ;
317 vector <int> MyRowPtr( NumMyElements+1 ) ;
322 int CurrentRowPtr = 0 ;
323 for (
int i = 0; i < NumMyElements ; i++ ) {
325 MyRowPtr[i+1] = CurrentRowPtr ;
337 Ap.resize( NumMyElements+1 );
346 int num_my_cols = Phase3Mat->
NumMyCols() ;
347 vector <int>Global_Columns( num_my_cols ) ;
348 for (
int i = 0 ; i < num_my_cols ; i ++ ) {
349 Global_Columns[i] = Phase3Mat->
GCID( i ) ;
352 for ( MyRow = 0; MyRow < NumMyElements ; MyRow++ ) {
353 int status = Phase3Mat->
ExtractMyRowView( MyRow, NzThisRow, RowValues, ColIndices ) ;
354 assert( status == 0 ) ;
355 Ap[MyRow] = Ai_index ;
356 assert(
Ap[MyRow] == MyRowPtr[MyRow] ) ;
357 for (
int j = 0; j < NzThisRow; j++ ) {
358 Ai[Ai_index] = Global_Columns[ColIndices[j]] ;
359 Aval[Ai_index] = RowValues[j] ;
363 assert( NumMyElements == MyRow );
364 Ap[ NumMyElements ] = Ai_index ;
394 if ( redistribute ) {
397 vecXdistributed.
Import( *vecX, ImportToDistributed,
Insert ) ;
398 vecBdistributed.
Import( *vecB, ImportToDistributed,
Insert ) ;
400 vecXptr = &vecXdistributed ;
401 vecBptr = &vecBdistributed ;
421 MPI_Comm MPIC = comm1.
Comm() ;
441 dCreate_CompRowLoc_Matrix_dist( &
A,
numrows, numcols,
442 nnz_loc, NumMyElements, MyActualFirstElement,
444 SLU_NR_loc, SLU_D, SLU_GE );
452 assert(
options.Fact == DOFACT );
464 for (
int j = 0 ; j < nrhs; j++ )
465 for (
int i = 0 ; i < NumMyElements; i++ ) xValues[i+j*ldx] = bValues[i+j*ldb];
470 vector<double>berr(nrhs);
479 if ( redistribute ) {
482 vecX->
Import( *vecXptr, ImportBackToOriginal,
Insert ) ;
const Epetra_Map & RowMap() const
int MyGlobalElements(int *MyGlobalElementList) const
SOLVEstruct_t SOLVEstruct
virtual ~Superludist2_OO(void)
Superludist2_OO Destructor.
int NumMyEntries(int Row) const
int NumGlobalCols() const
virtual void Barrier() const=0
int ExtractMyRowView(int MyRow, int &NumEntries, double *&Values, int *&Indices) const
virtual int MyPID() const=0
virtual const Epetra_Comm & Comm() const=0
int NumMyElements() const
#define EPETRA_CHK_ERR(xxx)
superlu_options_t options
int GCID(int LCID_in) const
bool GetTrans() const
Return the transpose flag.
virtual int Broadcast(double *MyVals, int Count, int Root) const=0
ScalePermstruct_t ScalePermstruct
int NumMyNonzeros() const
Epetra_MultiVector * GetRHS() const
virtual int NumProc() const=0
Superludist2_OO(const Epetra_LinearProblem &LinearProblem)
Superludist2_OO Constructor.
const Epetra_LinearProblem * Problem_
static int GetTracebackMode()
int Solve(bool Factor)
All computation is performed during the call to Solve()
int SLU_NumProcRows(int NumProcs)
int NumGlobalElements() const
Epetra_MultiVector * GetLHS() const
int ExtractView(double **A, int *MyLDA) const
int NumGlobalRows() const
Epetra_Operator * GetOperator() const
int Import(const Epetra_SrcDistObject &A, const Epetra_Import &Importer, Epetra_CombineMode CombineMode, const Epetra_OffsetIndex *Indexor=0)