From: Wolfgang Bangerth Date: Fri, 11 Feb 2011 03:43:51 +0000 (+0000) Subject: Modify the implementation of second_invariant. The old implementation X-Git-Tag: v8.0.0~4369 X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=bb464303fe16a37c4c420baba96326e0adf32856;p=dealii.git Modify the implementation of second_invariant. The old implementation was difficult to understand (thought correct) and certainly not efficient. git-svn-id: https://svn.dealii.org/trunk@23329 0785d39b-7218-0410-832d-ea1e28bc413d --- diff --git a/deal.II/include/deal.II/base/symmetric_tensor.h b/deal.II/include/deal.II/base/symmetric_tensor.h index 85cbed02c5..844d0dd3a5 100644 --- a/deal.II/include/deal.II/base/symmetric_tensor.h +++ b/deal.II/include/deal.II/base/symmetric_tensor.h @@ -969,12 +969,12 @@ class SymmetricTensor static std::size_t memory_consumption (); /** - * Read or write the data of this object to or + * Read or write the data of this object to or * from a stream for the purpose of serialization - */ + */ template void serialize(Archive & ar, const unsigned int version); - + private: /** * A structure that describes @@ -2144,12 +2144,12 @@ SymmetricTensor<2,3>::unrolled_to_component_indices (const unsigned int i) template template -inline -void +inline +void SymmetricTensor::serialize(Archive & ar, const unsigned int) { ar & data; -} +} #endif // DOXYGEN @@ -2278,21 +2278,52 @@ double first_invariant (const SymmetricTensor<2,dim> &t) /** - * Compute the second invariant a tensor or rank 2. The second invariant is + * Compute the second invariant of a tensor of rank 2. The second invariant is * defined as I2 = 1/2[ (trace sigma)^2 - trace (sigma^2) ]. * * @relates SymmetricTensor - * @author Wolfgang Bangerth, 2005 + * @author Wolfgang Bangerth, 2005, 2010 + */ +inline +double second_invariant (const SymmetricTensor<2,1> &t) +{ + return 0; +} + + + +/** + * Compute the second invariant of a tensor of rank 2. The second invariant is + * defined as I2 = 1/2[ (trace sigma)^2 - trace (sigma^2) ]. + * + * @relates SymmetricTensor + * @author Wolfgang Bangerth, 2005, 2010 */ -template inline -double second_invariant (const SymmetricTensor<2,dim> &t) +double second_invariant (const SymmetricTensor<2,2> &t) { - return (trace(t)*trace(t) - t*t) / 2; + return t[0][0]*t[1][1] - t[0][1]*t[0][1]; } +/** + * Compute the second invariant of a tensor of rank 2. The second invariant is + * defined as I2 = 1/2[ (trace sigma)^2 - trace (sigma^2) ]. + * + * @relates SymmetricTensor + * @author Wolfgang Bangerth, 2005, 2010 + */ +inline +double second_invariant (const SymmetricTensor<2,3> &t) +{ + return (t[0][0]*t[1][1] + t[1][1]*t[2][2] + t[2][2]*t[0][0] + - t[0][1]*t[0][1] - t[0][2]*t[0][2] - t[1][2]*t[1][2]); +} + + + + /** * Return the transpose of the given symmetric tensor. Since we are working * with symmetric objects, the transpose is of course the same as the original