diff --git a/dune/tectonic/convexpolyhedron.hh b/dune/tectonic/convexpolyhedron.hh new file mode 100644 index 0000000000000000000000000000000000000000..53cab2638d542a269febacaf566be283201f57b5 --- /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 1f73c9517c05ac6536ca68cef9e7fc3175d036ea..a133f296a2841cb8bd8ee4c13683d701bab5e722 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 e1b387f0027ceab585e13d16771c740db16735e3..8f5815087c35c4f493d552f1c0d96510df42d437 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 c3b7b9c51401fbf14415adb709439de54b9ccd67..4fcc1eb1f423db84c05a30480ec39083831ae04a 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>,