template <int rank, int dim> class SymmetricTensor;
template <int dim> SymmetricTensor<2,dim> unit_symmetric_tensor ();
+template <int dim> SymmetricTensor<4,dim> deviator_tensor ();
namespace internal
{
template <int dim2>
friend SymmetricTensor<2,dim2> unit_symmetric_tensor ();
+
+ template <int dim2>
+ friend SymmetricTensor<4,dim2> deviator_tensor ();
};
+
+/**
+ * Return a unit symmetric tensor of rank 2 and dimension 2.
+ *
+ * @relates SymmetricTensor
+ * @author Wolfgang Bangerth, 2005
+ */
+template <int dim>
+inline
+SymmetricTensor<4,dim>
+deviator_tensor ()
+{
+ SymmetricTensor<4,dim> tmp;
+ for (unsigned int i=0; i<dim; ++i)
+ for (unsigned int j=0; j<dim; ++j)
+ tmp.data[i][j] = (i==j ? 1 : 0) - 1./dim;
+ for (unsigned int i=dim;
+ i<internal::SymmetricTensorAccessors::StorageType<4,dim>::n_rank2_components; ++i)
+ tmp.data[i][i] = 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.