From: wolf Date: Mon, 16 May 2005 21:18:01 +0000 (+0000) Subject: Add deviator function. X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=4e13b976cde072bef27d8663b4dc0403c16150f7;p=dealii-svn.git Add deviator function. git-svn-id: https://svn.dealii.org/trunk@10683 0785d39b-7218-0410-832d-ea1e28bc413d --- diff --git a/deal.II/base/include/base/symmetric_tensor.h b/deal.II/base/include/base/symmetric_tensor.h index e2b3d10e9e..fd081f097f 100644 --- a/deal.II/base/include/base/symmetric_tensor.h +++ b/deal.II/base/include/base/symmetric_tensor.h @@ -856,7 +856,11 @@ class SymmetricTensor friend double determinant (const SymmetricTensor<2,2> &t); - friend double determinant (const SymmetricTensor<2,3> &t); + friend double determinant (const SymmetricTensor<2,3> &t); + + template + friend SymmetricTensor<2,dim2> + deviator (const SymmetricTensor<2,dim2> &t); }; @@ -1765,7 +1769,7 @@ SymmetricTensor<4,3>::norm () const inline double determinant (const SymmetricTensor<2,1> &t) { - return t[0][0]; + return t.data[0]; } @@ -1846,6 +1850,32 @@ transpose (const SymmetricTensor &t) +/** + * Compute the deviator of a symmetric tensor, which is defined as dev[s] + * = s - 1/dim*tr[s]*I, where I is the identity operator. This + * quantity equals the original tensor minus its contractive or dilative + * component and refers to the shear in, for example, elasticity. + * + * @relates SymmetricTensor + * @author Wolfgang Bangerth, 2005 + */ +template +inline +SymmetricTensor<2,dim> +deviator (const SymmetricTensor<2,dim> &t) +{ + SymmetricTensor<2,dim> tmp = t; + + // subtract scaled trace from the diagonal + const double tr = trace(t) / dim; + for (unsigned int i=0; i