]> https://gitweb.dealii.org/ - dealii-svn.git/commitdiff
Have a function that generates a unit tensor.
authorwolf <wolf@0785d39b-7218-0410-832d-ea1e28bc413d>
Mon, 23 May 2005 19:30:08 +0000 (19:30 +0000)
committerwolf <wolf@0785d39b-7218-0410-832d-ea1e28bc413d>
Mon, 23 May 2005 19:30:08 +0000 (19:30 +0000)
git-svn-id: https://svn.dealii.org/trunk@10700 0785d39b-7218-0410-832d-ea1e28bc413d

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

index 57a843aa5f8401e36c70439a83d4db7ef0744d60..5e90df4723bc174185bfc36591c777d23b4ad45a 100644 (file)
@@ -20,7 +20,6 @@
 
 template <int rank, int dim> class SymmetricTensor;
 
-
 namespace internal
 {
                                    /**
@@ -859,10 +858,13 @@ class SymmetricTensor
     friend double determinant (const SymmetricTensor<2,2> &t);
 
     friend double determinant (const SymmetricTensor<2,3> &t);
-
+    
     template <int dim2>
     friend SymmetricTensor<2,dim2>
     deviator (const SymmetricTensor<2,dim2> &t);
+    
+    template <int dim2>
+    friend SymmetricTensor<2,dim2> unit_symmetric_tensor ();
 };
 
 
@@ -1964,6 +1966,60 @@ deviator (const SymmetricTensor<2,dim> &t)
 
 
 
+/**
+ * Return a unit symmetric tensor of rank 2 and dimension 1.
+ * 
+ * @relates SymmetricTensor
+ * @author Wolfgang Bangerth, 2005
+ */
+template <>
+inline
+SymmetricTensor<2,1>
+unit_symmetric_tensor<1> () 
+{
+  SymmetricTensor<2,1> tmp;
+  tmp.data[0] = 1;
+  return tmp;
+}
+
+
+
+/**
+ * Return a unit symmetric tensor of rank 2 and dimension 2.
+ * 
+ * @relates SymmetricTensor
+ * @author Wolfgang Bangerth, 2005
+ */
+template <>
+inline
+SymmetricTensor<2,2>
+unit_symmetric_tensor<2> () 
+{
+  SymmetricTensor<2,2> tmp;
+  tmp.data[0] = tmp.data[1] = 1;
+  return tmp;
+}
+
+
+
+/**
+ * Return a unit symmetric tensor of rank 2 and dimension 3.
+ * 
+ * @relates SymmetricTensor
+ * @author Wolfgang Bangerth, 2005
+ */
+template <>
+inline
+SymmetricTensor<2,3>
+unit_symmetric_tensor<3> () 
+{
+  SymmetricTensor<2,3> tmp;
+  tmp.data[0] = tmp.data[1] = tmp.data[2] = 1;
+  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.