From 2260d903747179778b7dea86a01ca4f07d42a426 Mon Sep 17 00:00:00 2001
From: Jonathan Youett <youett@mi.fu-berlin.de>
Date: Fri, 29 Mar 2013 12:44:22 +0000
Subject: [PATCH] add functions that compute the nonlinear and linearised
 strain tensors

[[Imported from SVN: r11276]]
---
 dune/elasticity/common/elasticityhelpers.hh | 55 +++++++++++++++++++++
 1 file changed, 55 insertions(+)

diff --git a/dune/elasticity/common/elasticityhelpers.hh b/dune/elasticity/common/elasticityhelpers.hh
index 49c2e1b..c5357b6 100644
--- a/dune/elasticity/common/elasticityhelpers.hh
+++ b/dune/elasticity/common/elasticityhelpers.hh
@@ -9,6 +9,61 @@ namespace Dune {
 
     namespace Elasticity {
 
+        /** \brief Compute nonlinear strain tensor from a displacement gradient.
+         *
+         *  \param grad The gradient of the direction in which the linearisation is computed.
+         *  \param strain The tensor to store the strain in. 
+         */
+        template <int dim>
+        void computeNonlinearStrain(const Dune::FieldMatrix<double, dim, dim>& grad, SymmetricTensor<dim>& strain) {
+            strain = 0;
+            for (int i=0; i<dim ; ++i) {
+                strain(i,i) +=grad[i][i];
+
+                for (int k=0;k<dim;++k)
+                    strain(i,i) += 0.5*grad[k][i]*grad[k][i];
+
+                for (int j=i+1; j<dim; ++j) {
+                    strain(i,j) += 0.5*(grad[i][j] + grad[j][i]);
+                    for (int k=0;k<dim;++k)
+                        strain(i,j) += 0.5*grad[k][i]*grad[k][j];
+                }
+            }
+        }
+
+        /** \brief Compute linearised strain at the identity from a given displacement gradient. 
+         *
+         *  \param grad The gradient of the direction in which the linearisation is computed.
+         *  \param strain The tensor to store the strain in. 
+         */
+        template <int dim>
+        void computeLinearisedStrain(const Dune::FieldMatrix<double, dim, dim>& grad, SymmetricTensor<dim>& strain) {
+            for (int i=0; i<dim ; ++i)
+            {
+                strain(i,i) = grad[i][i];
+                for (int j=i+1; j<dim; ++j)
+                    strain(i,j) = 0.5*(grad[i][j] + grad[j][i]);
+            }
+        }
+
+
+        /** \brief Compute linearised strain at a prescribed configuration in the direction of a given displacement gradient. 
+         *
+         *  \param grad The gradient of the direction in which the linearisation is computed.
+         *  \param conf The deformation gradient(!) of the configuration at which the linearisation is evaluated.
+         *  \param strain The tensor to store the strain in. 
+         */
+        template <int dim>
+        void computeLinearisedStrain(const Dune::FieldMatrix<double, dim, dim>& grad, const Dune::FieldMatrix<double, dim, dim>& conf,
+                                     SymmetricTensor<dim>& strain) {
+            strain = 0;
+            for (int i=0;i<dim; i++)
+                for (int j=i;j<dim;j++)
+                    for (int k=0;k<dim;k++)
+                        strain(i,j)+= grad[k][i]*conf[k][j]+conf[k][i]*grad[k][j];
+            strain *= 0.5;
+        }
+
         /** \brief The penalty term \f$ \Gamma \f$ */
         double Gamma(double x) {
             return x*x - std::log(x);
-- 
GitLab