]> https://gitweb.dealii.org/ - dealii.git/commitdiff
Add scalar product between symmetric tensors.
authorWolfgang Bangerth <bangerth@math.tamu.edu>
Mon, 28 Mar 2005 21:40:01 +0000 (21:40 +0000)
committerWolfgang Bangerth <bangerth@math.tamu.edu>
Mon, 28 Mar 2005 21:40:01 +0000 (21:40 +0000)
git-svn-id: https://svn.dealii.org/trunk@10257 0785d39b-7218-0410-832d-ea1e28bc413d

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

index f2d4986ec3b870785a6e7579b27815edfd9474a5..dbf3239c0f85b8ebd4082c7462f9a8bdafccc681 100644 (file)
@@ -270,7 +270,7 @@ class SymmetricTensor<2,dim>
                                      *  instead since this does not need the
                                      *  creation of a temporary.
                                      */
-    SymmetricTensor   operator + (const SymmetricTensor &) const;
+    SymmetricTensor   operator + (const SymmetricTensor &s) const;
 
                                     /**
                                      *  Subtract two tensors. If possible,
@@ -278,7 +278,7 @@ class SymmetricTensor<2,dim>
                                      *  instead since this does not need the
                                      *  creation of a temporary.
                                      */
-    SymmetricTensor   operator - (const SymmetricTensor &) const;
+    SymmetricTensor   operator - (const SymmetricTensor &s) const;
 
                                     /**
                                      * Unary minus operator. Negate all
@@ -286,6 +286,18 @@ class SymmetricTensor<2,dim>
                                      */
     SymmetricTensor   operator - () const;
 
+                                     /**
+                                      * Scalar product between two symmetric
+                                      * tensors. It is the contraction
+                                      * <tt>a<sub>ij</sub>b<sub>ij</sub></tt>
+                                      * over all indices <tt>i,j</tt>. While
+                                      * it is possible to define other scalar
+                                      * products (and associated induced
+                                      * norms), this one seems to be the most
+                                      * appropriate one.
+                                      */
+    double operator * (const SymmetricTensor &s) const;
+    
                                      /**
                                       * Access the elements of a row of this
                                       * symmetric tensor. This function is
@@ -305,7 +317,9 @@ class SymmetricTensor<2,dim>
                                      /**
                                       * Return the Frobenius-norm of a tensor,
                                       * i.e. the square root of the sum of
-                                      * squares of all entries.
+                                      * squares of all entries. This norm is
+                                      * induced by the scalar product defined
+                                      * above for two symmetric tensors.
                                       */
     double norm () const;
     
@@ -585,6 +599,23 @@ SymmetricTensor<2,dim>::memory_consumption ()
 
 
 
+template <int dim>
+double
+SymmetricTensor<2,dim>::operator * (const SymmetricTensor &s) const
+{
+  double t = 0;
+  unsigned int i=0;
+  for (; i<dim; ++i)
+    t += data[i] * s.data[i];
+
+  for (; i<n_tensor_components; ++i)
+    t += 2 * data[i] * s.data[i];
+
+  return t;
+}
+  
+
+
 template <int dim>
 internal::SymmetricTensor::Rank2Accessors::RowAccessor<dim,true>
 SymmetricTensor<2,dim>::operator [] (const unsigned int row) const

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.