From: kronbichler Date: Thu, 5 Mar 2009 00:31:56 +0000 (+0000) Subject: Fix two issues with copy operation. X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=180d7bc91ca7e327416f6d8792f758916fd79f17;p=dealii-svn.git Fix two issues with copy operation. git-svn-id: https://svn.dealii.org/trunk@18453 0785d39b-7218-0410-832d-ea1e28bc413d --- diff --git a/deal.II/lac/source/trilinos_sparse_matrix.cc b/deal.II/lac/source/trilinos_sparse_matrix.cc index bdd7c77a2b..3773d939a2 100755 --- a/deal.II/lac/source/trilinos_sparse_matrix.cc +++ b/deal.II/lac/source/trilinos_sparse_matrix.cc @@ -253,7 +253,8 @@ namespace TrilinosWrappers { row_map = m.row_map; col_map = m.col_map; - *matrix = *m.matrix; + matrix = std::auto_ptr + (new Epetra_FECrsMatrix(*m.matrix)); compress(); return *this; } @@ -1261,15 +1262,6 @@ namespace TrilinosWrappers const std::pair local_range = rhs.local_range(); - unsigned int max_row_length = 0; - for (unsigned int row=local_range.first; - row < local_range.second; ++row) - max_row_length - = std::max (max_row_length, - static_cast(rhs.matrix->NumGlobalEntries(row))); - - std::vector column_indices (max_row_length); - std::vector values (max_row_length); int ierr; // If both matrices have been transformed @@ -1340,47 +1332,61 @@ namespace TrilinosWrappers // data, multiply it by the factor and // then add it to the matrix using the // respective add() function. - else if (matrix->Filled() == true && rhs.matrix->Filled() == true && - this->local_range() == local_range) - for (unsigned int row=local_range.first; + else + { + unsigned int max_row_length = 0; + for (unsigned int row=local_range.first; row < local_range.second; ++row) - { - const int row_local = matrix->RowMap().LID(row); - int n_entries; + max_row_length + = std::max (max_row_length, + static_cast(rhs.matrix->NumGlobalEntries(row))); + + std::vector column_indices (max_row_length); + std::vector values (max_row_length); + + if (matrix->Filled() == true && rhs.matrix->Filled() == true && + this->local_range() == local_range) + for (unsigned int row=local_range.first; + row < local_range.second; ++row) + { + const int row_local = matrix->RowMap().LID(row); + int n_entries; - ierr = rhs.matrix->ExtractMyRowCopy (row_local, max_row_length, - n_entries, - &values[0], - &column_indices[0]); - Assert (ierr == 0, ExcTrilinosError(ierr)); + ierr = rhs.matrix->ExtractMyRowCopy (row_local, max_row_length, + n_entries, + &values[0], + &column_indices[0]); + Assert (ierr == 0, ExcTrilinosError(ierr)); - for (int i=0; iSumIntoMyValues (row_local, n_entries, value_ptr, - &column_indices[0]); - Assert (ierr == 0, ExcTrilinosError(ierr)); - } - else - { - for (unsigned int row=local_range.first; - row < local_range.second; ++row) + ierr = matrix->SumIntoMyValues (row_local, n_entries, value_ptr, + &column_indices[0]); + Assert (ierr == 0, ExcTrilinosError(ierr)); + } + else { - int n_entries; - ierr = rhs.matrix->Epetra_CrsMatrix::ExtractGlobalRowCopy - ((int)row, max_row_length, n_entries, &values[0], &column_indices[0]); - Assert (ierr == 0, ExcTrilinosError(ierr)); - - for (int i=0; iEpetra_CrsMatrix::ExtractGlobalRowCopy + ((int)row, max_row_length, n_entries, &values[0], &column_indices[0]); + Assert (ierr == 0, ExcTrilinosError(ierr)); + + for (int i=0; iEpetra_CrsMatrix::SumIntoGlobalValues + ((int)row, n_entries, &values[0], &column_indices[0]); + Assert (ierr == 0, ExcTrilinosError(ierr)); + } + compress (); - ierr = matrix->Epetra_CrsMatrix::SumIntoGlobalValues - ((int)row, n_entries, &values[0], &column_indices[0]); - Assert (ierr == 0, ExcTrilinosError(ierr)); } - compress (); } }