]> https://gitweb.dealii.org/ - dealii-svn.git/commitdiff
Add deviator function.
authorwolf <wolf@0785d39b-7218-0410-832d-ea1e28bc413d>
Mon, 16 May 2005 21:18:01 +0000 (21:18 +0000)
committerwolf <wolf@0785d39b-7218-0410-832d-ea1e28bc413d>
Mon, 16 May 2005 21:18:01 +0000 (21:18 +0000)
git-svn-id: https://svn.dealii.org/trunk@10683 0785d39b-7218-0410-832d-ea1e28bc413d

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

index e2b3d10e9e7b7c5c49cfdef12e5ffb8bf3773c62..fd081f097fdf59966ba1e3d48387c06ba8c132cb 100644 (file)
@@ -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 <int dim2>
+    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<rank,dim> &t)
 
 
 
+/**
+ * Compute the deviator of a symmetric tensor, which is defined as <tt>dev[s]
+ * = s - 1/dim*tr[s]*I</tt>, where <tt>I</tt> 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 <int dim>
+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<dim; ++i)
+    tmp.data[i] -= tr;
+  
+  return tmp;
+}
+
+
+
 /**
  * Return the symmetrized version of the full rank-2 tensor,
  * i.e. (t+transpose(t))/2, as a symmetric rank-2 tensor.

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.