From: Matthias Maier Date: Thu, 29 Oct 2015 03:47:29 +0000 (-0500) Subject: Bugfix: Provide missing operator+ and operator- variants X-Git-Tag: v8.4.0-rc2~267^2~1 X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=d86d56b2006c03f7f40f94dd96fb4363cf67d28e;p=dealii.git Bugfix: Provide missing operator+ and operator- variants Unfortunately, it is not possible any more to exploit an implicit conversion from SymmetricTensor to Tensor due to the heavily templated operator variants for Tensor. Thus, provide mixed operator types. (And clean up symmetric_tensor.h later). --- diff --git a/include/deal.II/base/symmetric_tensor.h b/include/deal.II/base/symmetric_tensor.h index e1de217faf..fc31e576ad 100644 --- a/include/deal.II/base/symmetric_tensor.h +++ b/include/deal.II/base/symmetric_tensor.h @@ -1994,6 +1994,72 @@ SymmetricTensor::serialize(Archive &ar, const unsigned int) /* ----------------- Non-member functions operating on tensors. ------------ */ + +/** + * Addition of a SymmetricTensor and a general Tensor of equal rank. The + * result is a general Tensor. + * + * @relates SymmetricTensor + */ +template +inline +Tensor::type> +operator+(const SymmetricTensor &left, + const Tensor &right) +{ + return Tensor(left) + right; +} + + +/** + * Addition of a general Tensor with a SymmetricTensor of equal rank. The + * result is a general Tensor. + * + * @relates SymmetricTensor + */ +template +inline +Tensor::type> +operator+(const Tensor &left, + const SymmetricTensor &right) +{ + return left + Tensor(right); +} + + +/** + * Subtraction of a SymmetricTensor and a general Tensor of equal rank. The + * result is a general Tensor. + * + * @relates SymmetricTensor + */ +template +inline +Tensor::type> +operator-(const SymmetricTensor &left, + const Tensor &right) +{ + return Tensor(left) - right; +} + + +/** + * Subtraction of a general Tensor with a SymmetricTensor of equal rank. + * The result is a general Tensor. + * + * @relates SymmetricTensor + */ +template +inline +Tensor::type> +operator-(const Tensor &left, + const SymmetricTensor &right) +{ + return left - Tensor(right); +} + + + /** * Compute the determinant of a tensor or rank 2. The determinant is also * commonly referred to as the third invariant of rank-2 tensors.