From d86d56b2006c03f7f40f94dd96fb4363cf67d28e Mon Sep 17 00:00:00 2001 From: Matthias Maier Date: Wed, 28 Oct 2015 22:47:29 -0500 Subject: [PATCH] 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). --- include/deal.II/base/symmetric_tensor.h | 66 +++++++++++++++++++++++++ 1 file changed, 66 insertions(+) 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. -- 2.39.5