template <int dim> SymmetricTensor<2,dim> unit_symmetric_tensor ();
template <int dim> SymmetricTensor<4,dim> deviator_tensor ();
+template <int dim> SymmetricTensor<4,dim> identity_tensor ();
namespace internal
{
template <int dim2>
friend SymmetricTensor<4,dim2> deviator_tensor ();
+
+ template <int dim2>
+ friend SymmetricTensor<4,dim2> identity_tensor ();
};
/**
- * Return a unit symmetric tensor of rank 2 and dimension 2.
+ * Return the tensor of rank 4 that, when multiplied by a symmetric rank 2
+ * tensor <tt>t</tt> returns the deviator <tt>dev t</tt>. It is the operator
+ * representation of the linear deviator operator.
+ *
+ * For every tensor <tt>t</tt>, there holds the identity
+ * <tt>deviator(t)==deviator_tensor<dim>()*t</tt>, up to numerical
+ * round-off. The reason this operator representation is provided since one
+ * sometimes needs to invert operators like <tt>identity_tensor<dim>() +
+ * delta_t*deviator_tensor<dim>()</tt> or similar.
*
* @relates SymmetricTensor
* @author Wolfgang Bangerth, 2005
+/**
+ * Return the tensor of rank 4 that, when multiplied by a symmetric rank 2
+ * tensor <tt>t</tt> returns the deviator <tt>dev t</tt>. It is the operator
+ * representation of the linear deviator operator.
+ *
+ * For every tensor <tt>t</tt>, there holds the identity
+ * <tt>deviator(t)==deviator_tensor<dim>()*t</tt>, up to numerical
+ * round-off. The reason this operator representation is provided since one
+ * sometimes needs to invert operators like <tt>identity_tensor<dim>() +
+ * delta_t*deviator_tensor<dim>()</tt> or similar.
+ *
+ * @relates SymmetricTensor
+ * @author Wolfgang Bangerth, 2005
+ */
+template <int dim>
+inline
+SymmetricTensor<4,dim>
+identity_tensor ()
+{
+ SymmetricTensor<4,dim> tmp;
+
+ // fill the elements treating the diagonal
+ for (unsigned int i=0; i<dim; ++i)
+ tmp.data[i][i] = 1;
+
+ // then fill the ones that copy over the
+ // non-diagonal elements. note that during
+ // the double-contraction, we handle the
+ // off-diagonal elements twice, so simply
+ // copying requires a weight of 1/2
+ for (unsigned int i=dim;
+ i<internal::SymmetricTensorAccessors::StorageType<4,dim>
+ ::n_rank2_components;
+ ++i)
+ tmp.data[i][i] = 0.5;
+
+ return tmp;
+}
+
+
+
/**
* Return the symmetrized version of the full rank-2 tensor,
* i.e. (t+transpose(t))/2, as a symmetric rank-2 tensor.
--- /dev/null
+//---------------------------- symmetric_tensor_14.cc ---------------------------
+// $Id$
+// Version: $Name$
+//
+// Copyright (C) 2005 by the deal.II authors
+//
+// This file is subject to QPL and may not be distributed
+// without copyright and license information. Please refer
+// to the file deal.II/doc/license.html for the text and
+// further information on this license.
+//
+//---------------------------- symmetric_tensor_14.cc ---------------------------
+
+// test identity_tensor
+
+#include "../tests.h"
+#include <base/symmetric_tensor.h>
+#include <base/logstream.h>
+#include <fstream>
+#include <iostream>
+
+
+template <int dim>
+void test ()
+{
+ deallog << "dim=" << dim << std::endl;
+
+ SymmetricTensor<2,dim> t;
+ for (unsigned int i=0; i<dim; ++i)
+ for (unsigned int j=i; j<dim; ++j)
+ t[i][j] = (1.+(i+1)*(j*2));
+
+ SymmetricTensor<2,dim> x = identity_tensor<dim>() * t;
+ Assert ((x-t).norm() < 1e-15*t.norm(), ExcInternalError());
+
+ deallog << "x=" << std::endl;
+ for (unsigned int i=0; i<dim; ++i)
+ for (unsigned int j=0; j<dim; ++j)
+ deallog << i << ' ' << j << ' ' << x[i][j] << std::endl;
+}
+
+
+
+
+int main ()
+{
+ std::ofstream logfile("symmetric_tensor_14.output");
+ logfile.precision(3);
+ deallog.attach(logfile);
+ deallog.depth_console(0);
+ deallog.threshold_double(1.e-10);
+
+ test<1> ();
+ test<2> ();
+ test<3> ();
+
+ deallog << "OK" << std::endl;
+}