From 75b4e26a7abe7d469ecda8c13727edbf0bafeb47 Mon Sep 17 00:00:00 2001
From: Patrick <patrick.jaap@tu-dresden.de>
Date: Mon, 4 May 2020 09:25:49 +0200
Subject: [PATCH] LocalDensity: use `ctype` for `x` entries

---
 dune/elasticity/materials/exphenckydensity.hh         |  4 ++--
 dune/elasticity/materials/henckydensity.hh            |  4 ++--
 dune/elasticity/materials/localdensity.hh             | 10 +++++++---
 dune/elasticity/materials/localintegralenergy.hh      |  4 ++--
 dune/elasticity/materials/mooneyrivlindensity.hh      |  4 ++--
 dune/elasticity/materials/neohookedensity.hh          |  4 ++--
 dune/elasticity/materials/stvenantkirchhoffdensity.hh |  4 ++--
 7 files changed, 19 insertions(+), 15 deletions(-)

diff --git a/dune/elasticity/materials/exphenckydensity.hh b/dune/elasticity/materials/exphenckydensity.hh
index b20a440..9258e57 100644
--- a/dune/elasticity/materials/exphenckydensity.hh
+++ b/dune/elasticity/materials/exphenckydensity.hh
@@ -8,7 +8,7 @@
 
 namespace Dune::Elasticity {
 
-template<int dim, class field_type = double>
+template<int dim, class field_type = double, class ctype = double>
 class ExpHenckyDensity final
   : public LocalDensity<dim,field_type>
 {
@@ -40,7 +40,7 @@ public:
   * \param x Position of the gradient
   * \param gradient Deformation gradient
   */
-  field_type operator() (const FieldVector<field_type,dim>& x, const FieldMatrix<field_type,dim,dim>& gradient) const
+  field_type operator() (const FieldVector<ctype,dim>& x, const FieldMatrix<field_type,dim,dim>& gradient) const
   {
     /////////////////////////////////////////////////////////
     // compute C = F^TF
diff --git a/dune/elasticity/materials/henckydensity.hh b/dune/elasticity/materials/henckydensity.hh
index 81a6956..a4dc90e 100644
--- a/dune/elasticity/materials/henckydensity.hh
+++ b/dune/elasticity/materials/henckydensity.hh
@@ -8,7 +8,7 @@
 
 namespace Dune::Elasticity {
 
-template<int dim, class field_type = double>
+template<int dim, class field_type = double, class ctype = double>
 class HenckyDensity final
   : public LocalDensity<dim,field_type>
 {
@@ -30,7 +30,7 @@ public:
   * \param x Position of the gradient
   * \param gradient Deformation gradient
   */
-  field_type operator() (const FieldVector<field_type,dim>& x, const FieldMatrix<field_type,dim,dim>& gradient) const
+  field_type operator() (const FieldVector<ctype,dim>& x, const FieldMatrix<field_type,dim,dim>& gradient) const
   {
     /////////////////////////////////////////////////////////
     // compute C = F^TF
diff --git a/dune/elasticity/materials/localdensity.hh b/dune/elasticity/materials/localdensity.hh
index c091b4d..80156d9 100644
--- a/dune/elasticity/materials/localdensity.hh
+++ b/dune/elasticity/materials/localdensity.hh
@@ -5,8 +5,12 @@
 
 namespace Dune::Elasticity {
 
-/** \brief A base class for energy densities to be evaluated in an integral energy */
-template<int dim, class field_type = double>
+/** \brief A base class for energy densities to be evaluated in an integral energy
+ *
+ * \tparam field_type type of the gradient entries
+ * \tparam ctype type of the coordinates, i.e., the x entries
+ */
+template<int dim, class field_type = double, class ctype = double>
 class LocalDensity
 {
 
@@ -17,7 +21,7 @@ public:
    * \param x Position of the gradient
    * \param gradient Deformation gradient
    */
-  virtual field_type operator() (const FieldVector<field_type,dim>& x, const FieldMatrix<field_type,dim,dim>& gradient) const = 0;
+  virtual field_type operator() (const FieldVector<ctype,dim>& x, const FieldMatrix<field_type,dim,dim>& gradient) const = 0;
 
 };
 
diff --git a/dune/elasticity/materials/localintegralenergy.hh b/dune/elasticity/materials/localintegralenergy.hh
index 1307c25..ca2e68d 100644
--- a/dune/elasticity/materials/localintegralenergy.hh
+++ b/dune/elasticity/materials/localintegralenergy.hh
@@ -27,7 +27,7 @@ public:
 
   /** \brief Constructor with a local energy density
     */
-  LocalIntegralEnergy(const std::shared_ptr<LocalDensity<dim,field_type>>& ld)
+  LocalIntegralEnergy(const std::shared_ptr<LocalDensity<dim,field_type,DT>>& ld)
   : localDensity_(ld)
   {}
 
@@ -37,7 +37,7 @@ public:
                      const std::vector<Dune::FieldVector<field_type,gridDim> >& localConfiguration) const;
 
 protected:
-  const std::shared_ptr<LocalDensity<dim,field_type>> localDensity_ = nullptr;
+  const std::shared_ptr<LocalDensity<dim,field_type,DT>> localDensity_ = nullptr;
 
 };
 
diff --git a/dune/elasticity/materials/mooneyrivlindensity.hh b/dune/elasticity/materials/mooneyrivlindensity.hh
index 4dcacdc..8069301 100644
--- a/dune/elasticity/materials/mooneyrivlindensity.hh
+++ b/dune/elasticity/materials/mooneyrivlindensity.hh
@@ -8,7 +8,7 @@
 
 namespace Dune::Elasticity {
 
-template<int dim, class field_type = double>
+template<int dim, class field_type = double, class ctype = double>
 class MooneyRivlinDensity final
     : public LocalDensity<dim,field_type>
 {
@@ -43,7 +43,7 @@ public:
   * \param x Position of the gradient
   * \param gradient Deformation gradient
   */
-  field_type operator() (const FieldVector<field_type,dim>& x, const FieldMatrix<field_type,dim,dim>& gradient) const
+  field_type operator() (const FieldVector<ctype,dim>& x, const FieldMatrix<field_type,dim,dim>& gradient) const
   {
     /////////////////////////////////////////////////////////
     // compute C = F^TF
diff --git a/dune/elasticity/materials/neohookedensity.hh b/dune/elasticity/materials/neohookedensity.hh
index 47aa6d6..1541e3c 100644
--- a/dune/elasticity/materials/neohookedensity.hh
+++ b/dune/elasticity/materials/neohookedensity.hh
@@ -8,7 +8,7 @@
 
 namespace Dune::Elasticity {
 
-template<int dim, class field_type = double>
+template<int dim, class field_type = double, class ctype = double>
 class NeoHookeDensity final
   : public LocalDensity<dim,field_type>
 {
@@ -30,7 +30,7 @@ public:
   * \param x Position of the gradient
   * \param gradient Deformation gradient
   */
-  field_type operator() (const FieldVector<field_type,dim>& x, const FieldMatrix<field_type,dim,dim>& gradient) const
+  field_type operator() (const FieldVector<ctype,dim>& x, const FieldMatrix<field_type,dim,dim>& gradient) const
   {
     /////////////////////////////////////////////////////////
     // compute C = F^TF
diff --git a/dune/elasticity/materials/stvenantkirchhoffdensity.hh b/dune/elasticity/materials/stvenantkirchhoffdensity.hh
index 7d7bfbe..31a535a 100644
--- a/dune/elasticity/materials/stvenantkirchhoffdensity.hh
+++ b/dune/elasticity/materials/stvenantkirchhoffdensity.hh
@@ -7,7 +7,7 @@
 
 namespace Dune::Elasticity {
 
-template<int dim, class field_type = double>
+template<int dim, class field_type = double, class ctype = double>
 class StVenantKirchhoffDensity final
   : public LocalDensity<dim,field_type>
 {
@@ -28,7 +28,7 @@ public:
   * \param x Position of the gradient
   * \param gradient Deformation gradient
   */
-  field_type operator() (const FieldVector<field_type,dim>& x, const FieldMatrix<field_type,dim,dim>& gradient) const
+  field_type operator() (const FieldVector<ctype,dim>& x, const FieldMatrix<field_type,dim,dim>& gradient) const
   {
     //////////////////////////////////////////////////////////
     // compute strain E = 1/2 *( F^T F - I)
-- 
GitLab