]> https://gitweb.dealii.org/ - dealii.git/commitdiff
Improve the scalar assignment exception message. 12068/head
authorDavid Wells <drwells@email.unc.edu>
Tue, 20 Apr 2021 21:00:48 +0000 (17:00 -0400)
committerDavid Wells <drwells@email.unc.edu>
Tue, 20 Apr 2021 21:01:31 +0000 (17:01 -0400)
include/deal.II/base/exceptions.h
include/deal.II/base/tensor.h

index 73d7f8b1399e9a61eb042b3d1d1591ba7ee3bea4..de5d349bf5205d1eb322fcc5f903b9e11ce39ff2 100644 (file)
@@ -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.
index c5e1e571669a8506daa51ee17fc7b5917f438c29..dfbbd3c510e32c58bcfe59af2776a130434356e7 100644 (file)
@@ -1381,8 +1381,7 @@ template <int rank_, int dim, typename Number>
 DEAL_II_CONSTEXPR inline DEAL_II_ALWAYS_INLINE Tensor<rank_, dim, Number> &
 Tensor<rank_, dim, Number>::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)

In the beginning the Universe was created. This has made a lot of people very angry and has been widely regarded as a bad move.

Douglas Adams


Typeset in Trocchi and Trocchi Bold Sans Serif.