From 39699e8381cd3dc9573a1bf018ef2dbc3bdff483 Mon Sep 17 00:00:00 2001 From: Wolfgang Bangerth Date: Wed, 11 Jul 2018 13:26:03 -0600 Subject: [PATCH] Better document TrilinosWrappers::SparsityPattern::row_length(). --- include/deal.II/lac/trilinos_sparsity_pattern.h | 7 ++++++- source/lac/trilinos_sparsity_pattern.cc | 16 +++++++--------- 2 files changed, 13 insertions(+), 10 deletions(-) diff --git a/include/deal.II/lac/trilinos_sparsity_pattern.h b/include/deal.II/lac/trilinos_sparsity_pattern.h index a61b358c21..1d053e9068 100644 --- a/include/deal.II/lac/trilinos_sparsity_pattern.h +++ b/include/deal.II/lac/trilinos_sparsity_pattern.h @@ -910,7 +910,12 @@ namespace TrilinosWrappers n_nonzero_elements() const; /** - * Number of entries in a specific row. + * Return the number of entries in the given row. + * + * In a parallel context, the row in question may of course not be + * stored on the current processor, and in that case it is not + * possible to query the number of entries in it. In that case, + * the returned value is `static_cast(-1)`. */ size_type row_length(const size_type row) const; diff --git a/source/lac/trilinos_sparsity_pattern.cc b/source/lac/trilinos_sparsity_pattern.cc index 6960fc94d7..7f698138eb 100644 --- a/source/lac/trilinos_sparsity_pattern.cc +++ b/source/lac/trilinos_sparsity_pattern.cc @@ -1020,19 +1020,17 @@ namespace TrilinosWrappers { Assert(row < n_rows(), ExcInternalError()); - // get a representation of the - // present row - TrilinosWrappers::types::int_type ncols = -1; + // Get a representation of the where the present row is located on + // the current processor TrilinosWrappers::types::int_type local_row = graph->LRID(static_cast(row)); - // on the processor who owns this - // row, we'll have a non-negative - // value. + // On the processor who owns this row, we'll have a non-negative + // value for `local_row` and can ask for the length of the row. if (local_row >= 0) - ncols = graph->NumMyIndices(local_row); - - return static_cast(ncols); + return graph->NumMyIndices(local_row); + else + return static_cast(-1); } -- 2.39.5