[Trilinos-Users] A problem about the performance when using method Epetra_CrsMatrix::ReplaceGlobalValues()

Henian Xia xiahenian at gmail.com
Wed Mar 23 15:14:29 MDT 2011


Hi everyone,

I have a problem with the use of the class "Epetra_CrsMatrix". In my
application, I already have assembled a compressed-row-storage matrix, and I
need to convert this matrix to the data structure of "Epetra_CrsMatrix" so
that I can then use the class Epetra_LinearProblem. To do that, I define an
object equA and insert values to equA at the first time step. Then after the
first step, I use the method "Epetra_CrsMatrix::ReplaceGlobalValues()" to
update the values in the "Epetra_CrsMatrix". Each time I update only one
value of the
Epetra_CrsMatrix, and I will need to call the ReplaceGlobalValues() about 1
million times, and then it costs 5 seconds each time step. I also tried to
update one row of the Epetra_CrsMatrix each time, but that is even slower.

Did I do anything wrong please?

Thank you very much,
Henian

  if( timeStep == 1 )
    equA = new Epetra_CrsMatrix(Copy, *Map, 3);

  if( timeStep == 1 ) {
        for( i = 0 ; i < 4600 ; i++ )
        {
                GlobalRow = (*equA).GRID( i );
                //The variables Matrix_ia, Matrix_ja and matrix_a are
respectively the pointers to the row index vector,
                //the column index vector and the value vector of the
compressed-row-storage matrix.
                //Matrix_ia[ i + 1 ] -Matrix_ia[ i ] is about  200
                for( j = Matrix_ia[ i ] ; j < Matrix_ia[ i + 1 ] ; j ++ )  {
                    (*equA).InsertGlobalValues( GlobalRow , 1 , Matrix_a + j
, Matrix_ja + j );
                }
        }
   }

   if( timeStep > 1 ) {
        for( i = 0 ; i < 4600 ; i++ )
        {
                GlobalRow = (*equA).GRID( i );
                 for( j = Matrix_ia[ i ] ; j < Matrix_ia[ i + 1 ] ; j ++
)  {
                    (*equA).ReplaceGlobalValues( GlobalRow , 1 , Matrix_a +
j , Matrix_ja + j );
                }
        }
   }
   (*equA).FillComplete();

-- 
Henian Xia
Graduate Research Assistant
Department of MABE
University of Tennessee, Knoxville
-------------- next part --------------
An HTML attachment was scrubbed...
URL: https://software.sandia.gov/pipermail/trilinos-users/attachments/20110323/b8c676b1/attachment.html 


More information about the Trilinos-Users mailing list