From 280c52af49859920a5e7da91fa3fa0c208b5724c Mon Sep 17 00:00:00 2001 From: Martin Kronbichler Date: Mon, 29 Sep 2014 16:35:54 +0200 Subject: [PATCH] Circumvent a bug in Trilinos 11.10 If we avoid calling GlobalAssemble when copying from an Epetra_FECrsMatrix that uses a non-local matrix (enabled for Trilinos 11.9 and greater), we do not run into some bad code in Trilinos causing a segfault. At this point of the code, it is enough if we only call FillComplete because there should be no communication after all. --- source/lac/trilinos_sparse_matrix.cc | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/source/lac/trilinos_sparse_matrix.cc b/source/lac/trilinos_sparse_matrix.cc index 76667226c3..aaebb8ea13 100644 --- a/source/lac/trilinos_sparse_matrix.cc +++ b/source/lac/trilinos_sparse_matrix.cc @@ -392,12 +392,13 @@ namespace TrilinosWrappers nonlocal_matrix.reset(); nonlocal_matrix_exporter.reset(); - // check whether we need to update the - // partitioner or can just copy the data: - // in case we have the same distribution, - // we can just copy the data. - if (local_range() == m.local_range()) - *matrix = *m.matrix; + // check whether we need to update the partitioner or can just copy the + // data: in case we have the same distribution, we can just copy the data. + if (&matrix->Graph() == &m.matrix->Graph() && m.matrix->Filled()) + { + std::memcpy(matrix->ExpertExtractValues(), m.matrix->ExpertExtractValues(), + matrix->NumMyNonzeros()*sizeof(*matrix->ExpertExtractValues())); + } else { column_space_map.reset (new Epetra_Map (m.domain_partitioner())); @@ -410,7 +411,7 @@ namespace TrilinosWrappers if (m.nonlocal_matrix.get() != 0) nonlocal_matrix.reset(new Epetra_CrsMatrix(Copy, m.nonlocal_matrix->Graph())); - compress(); + matrix->FillComplete(*column_space_map, matrix->RowMap()); } -- 2.39.5