From bbf130f7b6a8883af084522f1777512d22ecb314 Mon Sep 17 00:00:00 2001
From: Oliver Sander <oliver.sander@tu-dresden.de>
Date: Fri, 30 Aug 2019 13:08:39 +0200
Subject: [PATCH] New abstract base class LocalEnergy

This is supposed to the base class for everything that can
integrate energy densities over one grid element.

LocalFEStiffness inherits from the new LocalEnergy.
---
 dune/elasticity/assemblers/CMakeLists.txt     |  1 +
 dune/elasticity/assemblers/localenergy.hh     | 37 +++++++++++++++++++
 .../elasticity/assemblers/localfestiffness.hh |  7 +---
 3 files changed, 40 insertions(+), 5 deletions(-)
 create mode 100644 dune/elasticity/assemblers/localenergy.hh

diff --git a/dune/elasticity/assemblers/CMakeLists.txt b/dune/elasticity/assemblers/CMakeLists.txt
index c8dfa52..fe27d4d 100644
--- a/dune/elasticity/assemblers/CMakeLists.txt
+++ b/dune/elasticity/assemblers/CMakeLists.txt
@@ -1,6 +1,7 @@
 install(FILES
     feassembler.hh
     localadolcstiffness.hh
+    localenergy.hh
     localfestiffness.hh
     neohookefunctionalassembler.hh
     neohookeoperatorassembler.hh
diff --git a/dune/elasticity/assemblers/localenergy.hh b/dune/elasticity/assemblers/localenergy.hh
new file mode 100644
index 0000000..475ed7f
--- /dev/null
+++ b/dune/elasticity/assemblers/localenergy.hh
@@ -0,0 +1,37 @@
+#ifndef DUNE_ELASTICITY_ASSEMBLERS_LOCALENERGY_HH
+#define DUNE_ELASTICITY_ASSEMBLERS_LOCALENERGY_HH
+
+#include <vector>
+
+namespace Dune {
+
+namespace Elasticity {
+
+/** \brief Base class for energies defined by integrating over one grid element */
+template<class GridView, class LocalFiniteElement, class VectorType>
+class LocalEnergy
+{
+    typedef typename VectorType::value_type::field_type RT;
+    typedef typename GridView::template Codim<0>::Entity Element;
+
+public:
+
+  /** \brief Compute the energy
+   *
+   * \param element A grid element
+   * \param LocalFiniteElement A finite element on the reference element
+   * \param localConfiguration The coefficients of a FE function on the current element
+   */
+  /** \brief Compute the energy at the current configuration */
+  virtual RT energy (const Element& element,
+                     const LocalFiniteElement& localFiniteElement,
+                     const VectorType& localConfiguration) const = 0;
+
+};
+
+}  // namespace Elasticity
+
+}  // namespace Dune
+
+#endif  // DUNE_ELASTICITY_ASSEMBLERS_LOCALENERGY_HH
+
diff --git a/dune/elasticity/assemblers/localfestiffness.hh b/dune/elasticity/assemblers/localfestiffness.hh
index abb5c52..f8a62e8 100644
--- a/dune/elasticity/assemblers/localfestiffness.hh
+++ b/dune/elasticity/assemblers/localfestiffness.hh
@@ -4,9 +4,11 @@
 #include <dune/common/fmatrix.hh>
 #include <dune/istl/matrix.hh>
 
+#include <dune/elasticity/assemblers/localenergy.hh>
 
 template<class GridView, class LocalFiniteElement, class VectorType>
 class LocalFEStiffness
+: public Dune::Elasticity::LocalEnergy<GridView, LocalFiniteElement, VectorType>
 {
     // grid types
     typedef typename GridView::Grid::ctype DT;
@@ -28,11 +30,6 @@ public:
                                  const VectorType& localConfiguration,
                                  VectorType& localGradient);
 
-    /** \brief Compute the energy at the current configuration */
-    virtual RT energy (const Entity& e,
-                       const LocalFiniteElement& localFiniteElement,
-                       const VectorType& localConfiguration) const = 0;
-
     // assembled data
     Dune::Matrix<Dune::FieldMatrix<RT,blocksize,blocksize> > A_;
 
-- 
GitLab