diff --git a/dune-solvers/computeenergy.hh b/dune-solvers/computeenergy.hh
new file mode 100644
index 0000000000000000000000000000000000000000..a35959899d7bb44eae1dfa331f6c9e255e5ad007
--- /dev/null
+++ b/dune-solvers/computeenergy.hh
@@ -0,0 +1,26 @@
+#ifndef CONTACT_COMPUTE_ENERGY_HH
+#define CONTACT_COMPUTE_ENERGY_HH
+
+template <class M, class V>
+double computeEnergy(const M& mat, const V& x, const V& rhs)
+{
+    V tmp(x.size());
+    tmp = 0;
+    mat.umv(x, tmp);
+
+//     std::cout << "tmp*x: " << (tmp*x) << "    rhs*x: " << (rhs*x) << std::endl;
+//     exit(0);
+    return 0.5*(tmp*x) - rhs*x;
+}
+
+template <class M, class V>
+double computeEnergy(const M& mat, const V& x)
+{
+    V tmp(x.size());
+    tmp = 0;
+    mat.umv(x, tmp);
+    
+    return 0.5*(tmp*x);
+}
+
+#endif