From: Wolfgang Bangerth Date: Wed, 11 Jul 2018 19:26:03 +0000 (-0600) Subject: Better document TrilinosWrappers::SparsityPattern::row_length(). X-Git-Tag: v9.1.0-rc1~922^2 X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=refs%2Fpull%2F6916%2Fhead;p=dealii.git Better document TrilinosWrappers::SparsityPattern::row_length(). --- 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); }