From: David Wells Date: Tue, 20 Apr 2021 21:00:48 +0000 (-0400) Subject: Improve the scalar assignment exception message. X-Git-Tag: v9.3.0-rc1~203^2 X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=50288d311a61253be0b7b51a83fd2d568fb76361;p=dealii.git Improve the scalar assignment exception message. --- diff --git a/include/deal.II/base/exceptions.h b/include/deal.II/base/exceptions.h index 73d7f8b139..de5d349bf5 100644 --- a/include/deal.II/base/exceptions.h +++ b/include/deal.II/base/exceptions.h @@ -1082,9 +1082,16 @@ namespace StandardExceptions * argument zero. In other cases, this exception is thrown. */ DeclExceptionMsg(ExcScalarAssignmentOnlyForZeroValue, - "You are trying an operation of the form 'vector=s' with " - "a nonzero scalar value 's'. However, such assignments " - "are only allowed if the right hand side is zero."); + "You are trying an operation of the form 'vector = C', " + "'matrix = C', or 'tensor = C' with a nonzero scalar value " + "'C'. However, such assignments are only allowed if the " + "C is zero, since the semantics for assigning any other " + "value are not clear. For example: one could interpret " + "assigning a matrix a value of 1 to mean the matrix has a " + "norm of 1, the matrix is the identity matrix, or the " + "matrix contains only 1s. Similar problems exist with " + "vectors and tensors. Hence, to avoid this ambiguity, such " + "assignments are not permitted."); /** * This function requires support for the LAPACK library. diff --git a/include/deal.II/base/tensor.h b/include/deal.II/base/tensor.h index c5e1e57166..dfbbd3c510 100644 --- a/include/deal.II/base/tensor.h +++ b/include/deal.II/base/tensor.h @@ -1381,8 +1381,7 @@ template DEAL_II_CONSTEXPR inline DEAL_II_ALWAYS_INLINE Tensor & Tensor::operator=(const Number &d) { - Assert(numbers::value_is_zero(d), - ExcMessage("Only assignment with zero is allowed")); + Assert(numbers::value_is_zero(d), ExcScalarAssignmentOnlyForZeroValue()); (void)d; for (unsigned int i = 0; i < dim; ++i)