]> https://gitweb.dealii.org/ - dealii.git/commitdiff
Introduce conversion operators to full tensors.
authorWolfgang Bangerth <bangerth@math.tamu.edu>
Wed, 6 Apr 2005 04:14:45 +0000 (04:14 +0000)
committerWolfgang Bangerth <bangerth@math.tamu.edu>
Wed, 6 Apr 2005 04:14:45 +0000 (04:14 +0000)
git-svn-id: https://svn.dealii.org/trunk@10374 0785d39b-7218-0410-832d-ea1e28bc413d

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

index ba35bee7ee96789d9491ff5fde54e0619b69253a..5af05ade35c7c727a3c3cf193c25f5a0e27d3058 100644 (file)
@@ -615,6 +615,14 @@ class SymmetricTensor
                                      */
     SymmetricTensor & operator = (const SymmetricTensor &);
 
+                                     /**
+                                      * Convert the present symmetric tensor
+                                      * into a full tensor with the same
+                                      * elements, but using the different
+                                      * storage scheme of full tensors.
+                                      */
+    operator Tensor<rank,dim> () const;
+
                                     /**
                                      *  Test for equality of two tensors.
                                      */
@@ -897,6 +905,42 @@ SymmetricTensor<rank,dim>::operator = (const SymmetricTensor<rank,dim> &t)
 
 
 
+template <>
+inline
+SymmetricTensor<2,1>::
+operator Tensor<2,1> () const
+{
+  const double t[1][1] = {{data[0]}};
+  return Tensor<2,1>(t);
+}
+
+
+
+template <>
+inline
+SymmetricTensor<2,2>::
+operator Tensor<2,2> () const
+{
+  const double t[2][2] = {{data[0], data[2]},
+                          {data[2], data[1]}};
+  return Tensor<2,2>(t);
+}
+
+
+
+template <>
+inline
+SymmetricTensor<2,3>::
+operator Tensor<2,3> () const
+{
+  const double t[3][3] = {{data[0], data[3], data[4]},
+                          {data[3], data[1], data[5]},
+                          {data[4], data[5], data[2]}};
+  return Tensor<2,3>(t);
+}
+
+
+
 template <int rank, int dim>
 inline
 bool

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.