From a1cfc0ddcde50934a512fb5d50e3038b27de8080 Mon Sep 17 00:00:00 2001
From: Oliver Sander <sander@igpm.rwth-aachen.de>
Date: Tue, 24 Mar 2015 09:16:01 +0000
Subject: [PATCH] New energy functional that simply sums up two existing ones

[[Imported from SVN: r10115]]
---
 dune/gfe/sumenergy.hh | 60 +++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 60 insertions(+)
 create mode 100644 dune/gfe/sumenergy.hh

diff --git a/dune/gfe/sumenergy.hh b/dune/gfe/sumenergy.hh
new file mode 100644
index 00000000..c0a5671e
--- /dev/null
+++ b/dune/gfe/sumenergy.hh
@@ -0,0 +1,60 @@
+#ifndef DUNE_GFE_SUMENERGY_HH
+#define DUNE_GFE_SUMENERGY_HH
+
+#include <dune/common/fmatrix.hh>
+#include <dune/common/fmatrixev.hh>
+
+#include <dune/geometry/quadraturerules.hh>
+
+#include <dune/fufem/functions/virtualgridfunction.hh>
+#include <dune/fufem/boundarypatch.hh>
+
+#include <dune/gfe/localgeodesicfestiffness.hh>
+#include <dune/gfe/localfestiffness.hh>
+#include <dune/gfe/localgeodesicfefunction.hh>
+#include <dune/gfe/realtuple.hh>
+
+namespace Dune {
+
+template<class GridView, class LocalFiniteElement, class field_type=double>
+class SumEnergy
+: public LocalFEStiffness<GridView,LocalFiniteElement,std::vector<Dune::FieldVector<field_type,3> > >
+{
+ // grid types
+  typedef typename GridView::ctype ctype;
+  typedef typename GridView::template Codim<0>::Entity Entity;
+
+  enum {dim=GridView::dimension};
+
+public:
+
+  /** \brief Constructor with a set of material parameters
+   * \param parameters The material parameters
+   */
+  SumEnergy(std::shared_ptr<LocalFEStiffness<GridView,LocalFiniteElement,std::vector<Dune::FieldVector<field_type,3> > > > a,
+                std::shared_ptr<LocalFEStiffness<GridView,LocalFiniteElement,std::vector<Dune::FieldVector<field_type,3> > > > b)
+  : a_(a),
+    b_(b)
+  {}
+
+  /** \brief Assemble the energy for a single element */
+  field_type energy (const Entity& element,
+                     const LocalFiniteElement& localFiniteElement,
+                     const std::vector<Dune::FieldVector<field_type,dim> >& localConfiguration) const
+  {
+    return a_->energy(element, localFiniteElement, localConfiguration)
+         + b_->energy(element, localFiniteElement, localConfiguration);
+  }
+
+private:
+
+  std::shared_ptr<LocalFEStiffness<GridView,LocalFiniteElement,std::vector<Dune::FieldVector<field_type,3> > > > a_;
+
+  std::shared_ptr<LocalFEStiffness<GridView,LocalFiniteElement,std::vector<Dune::FieldVector<field_type,3> > > > b_;
+};
+
+}
+
+#endif   //#ifndef DUNE_GFE_SUMENERGY_HH
+
+
-- 
GitLab