From 2a0ffc98c0d88fe7f666bfacec163a2bdd36b8e4 Mon Sep 17 00:00:00 2001
From: Elias Pipping <elias.pipping@fu-berlin.de>
Date: Tue, 7 Apr 2015 14:44:34 +0200
Subject: [PATCH] [Cleanup] Move ConvexPolyhedron to separate header

---
 dune/tectonic/convexpolyhedron.hh    | 31 ++++++++++++++++++++++++++++
 dune/tectonic/polyhedrondistance.hh  | 28 ++-----------------------
 src/sand-wedge-data/mygrid.hh        |  2 +-
 src/sand-wedge-data/patchfunction.hh |  2 +-
 4 files changed, 35 insertions(+), 28 deletions(-)
 create mode 100644 dune/tectonic/convexpolyhedron.hh

diff --git a/dune/tectonic/convexpolyhedron.hh b/dune/tectonic/convexpolyhedron.hh
new file mode 100644
index 00000000..53cab263
--- /dev/null
+++ b/dune/tectonic/convexpolyhedron.hh
@@ -0,0 +1,31 @@
+#ifndef DUNE_TECTONIC_CONVEXPOLYHEDRON_HH
+#define DUNE_TECTONIC_CONVEXPOLYHEDRON_HH
+
+#include <dune/solvers/common/arithmetic.hh>
+
+template <class Coordinate> struct ConvexPolyhedron {
+  std::vector<Coordinate> vertices;
+
+  template <class DynamicVector>
+  Coordinate barycentricToGlobal(DynamicVector const &b) const {
+    assert(b.size() == vertices.size());
+    Coordinate r(0);
+    for (size_t i = 0; i < b.size(); i++)
+      Arithmetic::addProduct(r, b[i], vertices[i]);
+    return r;
+  }
+
+  template <class DynamicVector>
+  void sanityCheck(DynamicVector const &b, double tol) const {
+    double sum = 0;
+    for (size_t i = 0; i < b.size(); i++) {
+      if (b[i] < -tol)
+        DUNE_THROW(Dune::Exception, "No barycentric coords " << b[1] << " nr. "
+                                                             << i);
+      sum += b[i];
+    }
+    if (sum > 1 + tol)
+      DUNE_THROW(Dune::Exception, "No barycentric coords, sum: " << sum);
+  }
+};
+#endif
diff --git a/dune/tectonic/polyhedrondistance.hh b/dune/tectonic/polyhedrondistance.hh
index 1f73c951..a133f296 100644
--- a/dune/tectonic/polyhedrondistance.hh
+++ b/dune/tectonic/polyhedrondistance.hh
@@ -3,34 +3,10 @@
 
 // Based on the closest point projection from dune-contact
 
+#include <dune/common/dynvector.hh>
 #include <dune/common/dynmatrix.hh>
-#include <dune/solvers/common/arithmetic.hh>
-
-template <class Coordinate> struct ConvexPolyhedron {
-  std::vector<Coordinate> vertices;
-
-  template <class DynamicVector>
-  Coordinate barycentricToGlobal(DynamicVector const &b) const {
-    assert(b.size() == vertices.size());
-    Coordinate r(0);
-    for (size_t i = 0; i < b.size(); i++)
-      Arithmetic::addProduct(r, b[i], vertices[i]);
-    return r;
-  }
 
-  template <class DynamicVector>
-  void sanityCheck(DynamicVector const &b, double tol) const {
-    double sum = 0;
-    for (size_t i = 0; i < b.size(); i++) {
-      if (b[i] < -tol)
-        DUNE_THROW(Dune::Exception, "No barycentric coords " << b[1] << " nr. "
-                                                             << i);
-      sum += b[i];
-    }
-    if (sum > 1 + tol)
-      DUNE_THROW(Dune::Exception, "No barycentric coords, sum: " << sum);
-  }
-};
+#include <dune/tectonic/convexpolyhedron.hh>
 
 template <class Coordinate, class Matrix>
 void populateMatrix(ConvexPolyhedron<Coordinate> const &segment,
diff --git a/src/sand-wedge-data/mygrid.hh b/src/sand-wedge-data/mygrid.hh
index e1b387f0..8f581508 100644
--- a/src/sand-wedge-data/mygrid.hh
+++ b/src/sand-wedge-data/mygrid.hh
@@ -11,7 +11,7 @@
 #include <dune/fufem/boundarypatch.hh>
 #pragma clang diagnostic pop
 
-#include <dune/tectonic/polyhedrondistance.hh>
+#include <dune/tectonic/convexpolyhedron.hh>
 
 #include "mygeometry.hh"
 
diff --git a/src/sand-wedge-data/patchfunction.hh b/src/sand-wedge-data/patchfunction.hh
index c3b7b9c5..4fcc1eb1 100644
--- a/src/sand-wedge-data/patchfunction.hh
+++ b/src/sand-wedge-data/patchfunction.hh
@@ -5,7 +5,7 @@
 #include <dune/common/fvector.hh>
 #include <dune/common/parametertree.hh>
 
-#include <dune/tectonic/polyhedrondistance.hh>
+#include <dune/tectonic/convexpolyhedron.hh>
 
 class PatchFunction
     : public Dune::VirtualFunction<Dune::FieldVector<double, MY_DIM>,
-- 
GitLab