From: Peter Munch Date: Sat, 6 Jan 2024 12:30:38 +0000 (+0100) Subject: Fix allocation in TrilinosWrappers::SparseMatrix::AccessorBase X-Git-Tag: relicensing~197^2 X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=refs%2Fpull%2F16416%2Fhead;p=dealii.git Fix allocation in TrilinosWrappers::SparseMatrix::AccessorBase --- diff --git a/source/lac/trilinos_sparse_matrix.cc b/source/lac/trilinos_sparse_matrix.cc index 971f37be54..f36ab6f8d1 100644 --- a/source/lac/trilinos_sparse_matrix.cc +++ b/source/lac/trilinos_sparse_matrix.cc @@ -158,28 +158,27 @@ namespace TrilinosWrappers // get a representation of the present row int ncols; - TrilinosWrappers::types::int_type colnums = matrix->n(); + TrilinosWrappers::types::int_type colnums = + matrix->row_length(this->a_row); if (value_cache.get() == nullptr) { - value_cache = - std::make_shared>(matrix->n()); - colnum_cache = std::make_shared>(matrix->n()); + value_cache = std::make_shared>(colnums); + colnum_cache = std::make_shared>(colnums); } else { - value_cache->resize(matrix->n()); - colnum_cache->resize(matrix->n()); + value_cache->resize(colnums); + colnum_cache->resize(colnums); } - int ierr = matrix->trilinos_matrix().ExtractGlobalRowCopy( + const int ierr = matrix->trilinos_matrix().ExtractGlobalRowCopy( this->a_row, colnums, ncols, value_cache->data(), reinterpret_cast( colnum_cache->data())); - value_cache->resize(ncols); - colnum_cache->resize(ncols); + AssertDimension(ncols, colnums); AssertThrow(ierr == 0, ExcTrilinosError(ierr)); // copy it into our caches if the