From: Wolfgang Bangerth Date: Wed, 13 Jan 2021 17:28:14 +0000 (-0700) Subject: Improve error message when accessing vector elements in parallel. X-Git-Tag: v9.3.0-rc1~639^2 X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=30508ee25b41aaab2f8b876c132505d684fbda31;p=dealii.git Improve error message when accessing vector elements in parallel. --- diff --git a/include/deal.II/lac/la_parallel_vector.h b/include/deal.II/lac/la_parallel_vector.h index 09d25ee218..0b23cc11dd 100644 --- a/include/deal.II/lac/la_parallel_vector.h +++ b/include/deal.II/lac/la_parallel_vector.h @@ -1209,17 +1209,26 @@ namespace LinearAlgebra /** * Exception */ - DeclException4(ExcAccessToNonLocalElement, - size_type, - size_type, - size_type, - size_type, - << "You tried to access element " << arg1 - << " of a distributed vector, but this element is not " - << "stored on the current processor. Note: The range of " - << "locally owned elements is " << arg2 << " to " << arg3 - << ", and there are " << arg4 << " ghost elements " - << "that this vector can access."); + DeclException4( + ExcAccessToNonLocalElement, + size_type, + size_type, + size_type, + size_type, + << "You tried to access element " << arg1 + << " of a distributed vector, but this element is not " + << "stored on the current processor. Note: The range of " + << "locally owned elements is " << arg2 << " to " << arg3 + << ", and there are " << arg4 << " ghost elements " + << "that this vector can access." + << "\n\n" + << "A common source for this kind of problem is that you " + << "are passing a 'fully distributed' vector into a function " + << "that needs read access to vector elements that correspond " + << "to degrees of freedom on ghost cells (or at least to " + << "'locally active' degrees of freedom that are not also " + << "'locally owned'). You need to pass a vector that has these " + << "elements as ghost entries."); private: /** diff --git a/include/deal.II/lac/petsc_vector_base.h b/include/deal.II/lac/petsc_vector_base.h index 296e757ce9..f9fa79f012 100644 --- a/include/deal.II/lac/petsc_vector_base.h +++ b/include/deal.II/lac/petsc_vector_base.h @@ -173,14 +173,22 @@ namespace PETScWrappers /** * Exception */ - DeclException3(ExcAccessToNonlocalElement, - int, - int, - int, - << "You tried to access element " << arg1 - << " of a distributed vector, but only elements " << arg2 - << " through " << arg3 - << " are stored locally and can be accessed."); + DeclException3( + ExcAccessToNonlocalElement, + int, + int, + int, + << "You tried to access element " << arg1 + << " of a distributed vector, but only elements " << arg2 << " through " + << arg3 << " are stored locally and can be accessed." + << "\n\n" + << "A common source for this kind of problem is that you " + << "are passing a 'fully distributed' vector into a function " + << "that needs read access to vector elements that correspond " + << "to degrees of freedom on ghost cells (or at least to " + << "'locally active' degrees of freedom that are not also " + << "'locally owned'). You need to pass a vector that has these " + << "elements as ghost entries."); /** * Exception. */ diff --git a/include/deal.II/lac/trilinos_vector.h b/include/deal.II/lac/trilinos_vector.h index c5871b32e2..dfb0eeb925 100644 --- a/include/deal.II/lac/trilinos_vector.h +++ b/include/deal.II/lac/trilinos_vector.h @@ -1274,7 +1274,7 @@ namespace TrilinosWrappers size_type, size_type, size_type, - << "You tried to access element " << arg1 + << "You are trying to access element " << arg1 << " of a distributed vector, but this element is not stored " << "on the current processor. Note: There are " << arg2 << " elements stored " @@ -1282,7 +1282,15 @@ namespace TrilinosWrappers << " through " << arg4 << " but Trilinos vectors need not store contiguous " << "ranges on each processor, and not every element in " - << "this range may in fact be stored locally."); + << "this range may in fact be stored locally." + << "\n\n" + << "A common source for this kind of problem is that you " + << "are passing a 'fully distributed' vector into a function " + << "that needs read access to vector elements that correspond " + << "to degrees of freedom on ghost cells (or at least to " + << "'locally active' degrees of freedom that are not also " + << "'locally owned'). You need to pass a vector that has these " + << "elements as ghost entries."); private: /**