From: Jean-Paul Pelteret Date: Thu, 17 Aug 2017 16:53:36 +0000 (+0200) Subject: Added single contraction operator* for symm tensor and tensor args X-Git-Tag: v9.0.0-rc1~1196^2~2 X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=9db4ee80623b22330d0b56ea97fc49335606bec8;p=dealii.git Added single contraction operator* for symm tensor and tensor args --- diff --git a/include/deal.II/base/symmetric_tensor.h b/include/deal.II/base/symmetric_tensor.h index 328fe8c1ab..eb38cb32b1 100644 --- a/include/deal.II/base/symmetric_tensor.h +++ b/include/deal.II/base/symmetric_tensor.h @@ -3925,6 +3925,75 @@ operator * (const Tensor<1,dim,Number> &src1, } + +/** + * The dot product (single contraction) for tensors: Return a tensor of rank + * $(\text{rank}_1 + \text{rank}_2 - 2)$ that is the contraction of the last + * index of a tensor @p src1 of rank @p rank_1 with the first index of a + * tensor @p src2 of rank @p rank_2: + * @f[ + * \text{result}_{i_1,\ldots,i_{r1},j_1,\ldots,j_{r2}} + * = \sum_{k} + * \text{left}_{i_1,\ldots,i_{r1}, k} + * \text{right}_{k, j_1,\ldots,j_{r2}} + * @f] + * + * @note As one operand is a Tensor, the multiplication operator only performs a + * contraction over a single pair of indices. This is in contrast to the + * multiplication operator for SymmetricTensor, which does the double + * contraction. + * + * @relates SymmetricTensor + * @author Matthias Maier, Jean-Paul Pelteret, 2017 + */ +template +inline DEAL_II_ALWAYS_INLINE +typename Tensor::type>::tensor_type +operator * (const Tensor &src1, + const SymmetricTensor &src2s) +{ + typename Tensor::type>::tensor_type result; + const Tensor src2 (src2s); + return src1*src2; +} + + + +/** + * The dot product (single contraction) for tensors: Return a tensor of rank + * $(\text{rank}_1 + \text{rank}_2 - 2)$ that is the contraction of the last + * index of a tensor @p src1 of rank @p rank_1 with the first index of a + * tensor @p src2 of rank @p rank_2: + * @f[ + * \text{result}_{i_1,\ldots,i_{r1},j_1,\ldots,j_{r2}} + * = \sum_{k} + * \text{left}_{i_1,\ldots,i_{r1}, k} + * \text{right}_{k, j_1,\ldots,j_{r2}} + * @f] + * + * @note As one operand is a Tensor, the multiplication operator only performs a + * contraction over a single pair of indices. This is in contrast to the + * multiplication operator for SymmetricTensor, which does the double + * contraction. + * + * @relates SymmetricTensor + * @author Matthias Maier, Jean-Paul Pelteret, 2017 + */ +template +inline DEAL_II_ALWAYS_INLINE +typename Tensor::type>::tensor_type +operator * (const SymmetricTensor &src1s, + const Tensor &src2) +{ + typename Tensor::type>::tensor_type result; + const Tensor src1 (src1s); + return src1*src2; +} + + + /** * Output operator for symmetric tensors of rank 2. Print the elements * consecutively, with a space in between, two spaces between rank 1