From 75e96f021c49a7f700e0d7704f9f9e58c853230a Mon Sep 17 00:00:00 2001 From: Wolfgang Bangerth Date: Tue, 29 Mar 2005 22:48:47 +0000 Subject: [PATCH] Add a few double_contract functions. git-svn-id: https://svn.dealii.org/trunk@10309 0785d39b-7218-0410-832d-ea1e28bc413d --- deal.II/base/include/base/symmetric_tensor.h | 167 +++++++++++++++++++ 1 file changed, 167 insertions(+) diff --git a/deal.II/base/include/base/symmetric_tensor.h b/deal.II/base/include/base/symmetric_tensor.h index 4fc1e7c9c7..56bce57852 100644 --- a/deal.II/base/include/base/symmetric_tensor.h +++ b/deal.II/base/include/base/symmetric_tensor.h @@ -1802,4 +1802,171 @@ operator * (const SymmetricTensor<2,3> &s, +/** + * Double contraction between a rank-4 and a rank-2 symmetric tensor, + * resulting in the symmetric tensor of rank 2 that is given as first + * argument to this function. This operation is the symmetric tensor + * analogon of a matrix-vector multiplication. + * + * This function does the same as a respective operator*, but it avoid + * a temporary object (that the compiler can optimize away in many + * cases, however). + * + * @related SymmetricTensor + * @author Wolfgang Bangerth, 2005 + */ +void +double_contract (SymmetricTensor<2,1> &tmp, + const SymmetricTensor<4,1> &t, + const SymmetricTensor<2,1> &s) +{ + tmp[0][0] = t[0][0][0][0] * s[0][0]; +} + + + +/** + * Double contraction between a rank-4 and a rank-2 symmetric tensor, + * resulting in the symmetric tensor of rank 2 that is given as first + * argument to this function. This operation is the symmetric tensor + * analogon of a matrix-vector multiplication. + * + * This function does the same as a respective operator*, but it avoid + * a temporary object (that the compiler can optimize away in many + * cases, however). + * + * @related SymmetricTensor + * @author Wolfgang Bangerth, 2005 + */ +void +double_contract (SymmetricTensor<2,1> &tmp, + const SymmetricTensor<2,1> &s, + const SymmetricTensor<4,1> &t) +{ + tmp[0][0] = t[0][0][0][0] * s[0][0]; +} + + + +/** + * Double contraction between a rank-4 and a rank-2 symmetric tensor, + * resulting in the symmetric tensor of rank 2 that is given as first + * argument to this function. This operation is the symmetric tensor + * analogon of a matrix-vector multiplication. + * + * This function does the same as a respective operator*, but it avoid + * a temporary object (that the compiler can optimize away in many + * cases, however). + * + * @related SymmetricTensor @author Wolfgang Bangerth, 2005 + */ +void +double_contract (SymmetricTensor<2,2> &tmp, + const SymmetricTensor<4,2> &t, + const SymmetricTensor<2,2> &s) +{ + const unsigned int dim = 2; + + for (unsigned int i=0; i &tmp, + const SymmetricTensor<2,2> &s, + const SymmetricTensor<4,2> &t) +{ + const unsigned int dim = 2; + + for (unsigned int i=0; i &tmp, + const SymmetricTensor<4,3> &t, + const SymmetricTensor<2,3> &s) +{ + const unsigned int dim = 3; + + for (unsigned int i=0; i &tmp, + const SymmetricTensor<2,3> &s, + const SymmetricTensor<4,3> &t) +{ + const unsigned int dim = 3; + + for (unsigned int i=0; i