From aa0e934fe30468f2e98abb5cd305e7d54f46d746 Mon Sep 17 00:00:00 2001 From: Wolfgang Bangerth Date: Wed, 6 Apr 2005 18:52:36 +0000 Subject: [PATCH] Add symmetrize function git-svn-id: https://svn.dealii.org/trunk@10398 0785d39b-7218-0410-832d-ea1e28bc413d --- deal.II/base/include/base/symmetric_tensor.h | 26 ++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/deal.II/base/include/base/symmetric_tensor.h b/deal.II/base/include/base/symmetric_tensor.h index 59dfd96463..dfb0a1b2fe 100644 --- a/deal.II/base/include/base/symmetric_tensor.h +++ b/deal.II/base/include/base/symmetric_tensor.h @@ -1834,6 +1834,32 @@ transpose (const SymmetricTensor &t) } + +/** + * Return the symmetrized version of the full rank-2 tensor, + * i.e. (t+transpose(t))/2, as a symmetric rank-2 tensor. + * + * @relates SymmetricTensor + * @author Wolfgang Bangerth, 2005 + */ +template +inline +SymmetricTensor<2,dim> +symmetrize (const Tensor<2,dim> &t) +{ + SymmetricTensor<2,dim> s; + for (unsigned int i=0; i(i,i)) = t[i][i]; + + for (unsigned int j=i+1; j(i,j)) + = (t[i][j] + t[j][i])/2; + } + return s; +} + + /** * Multiplication of a symmetric tensor of general rank with a scalar double * from the right. -- 2.39.5