]> https://gitweb.dealii.org/ - dealii.git/commitdiff
Modify the implementation of second_invariant. The old implementation
authorWolfgang Bangerth <bangerth@math.tamu.edu>
Fri, 11 Feb 2011 03:43:51 +0000 (03:43 +0000)
committerWolfgang Bangerth <bangerth@math.tamu.edu>
Fri, 11 Feb 2011 03:43:51 +0000 (03:43 +0000)
was difficult to understand (thought correct) and certainly not efficient.

git-svn-id: https://svn.dealii.org/trunk@23329 0785d39b-7218-0410-832d-ea1e28bc413d

deal.II/include/deal.II/base/symmetric_tensor.h

index 85cbed02c557ae4cec9d1276f88d7181ba43befe..844d0dd3a5b8651054ce4454f37c1faac837cb50 100644 (file)
@@ -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 <class Archive>
     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 <int rank, int dim>
 template <class Archive>
-inline    
-void 
+inline
+void
 SymmetricTensor<rank,dim>::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 <tt>I2 = 1/2[ (trace sigma)^2 - trace (sigma^2) ]</tt>.
  *
  * @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 <tt>I2 = 1/2[ (trace sigma)^2 - trace (sigma^2) ]</tt>.
+ *
+ * @relates SymmetricTensor
+ * @author Wolfgang Bangerth, 2005, 2010
  */
-template <int dim>
 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 <tt>I2 = 1/2[ (trace sigma)^2 - trace (sigma^2) ]</tt>.
+ *
+ * @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

In the beginning the Universe was created. This has made a lot of people very angry and has been widely regarded as a bad move.

Douglas Adams


Typeset in Trocchi and Trocchi Bold Sans Serif.