diff --git a/dumux/common/geometry/grahamconvexhull.hh b/dumux/common/geometry/grahamconvexhull.hh index 463b61f90714689ac3069ea1f9132aa165d69e47..9fff6845c7784592ee1996594967b8a13bcf48b3 100644 --- a/dumux/common/geometry/grahamconvexhull.hh +++ b/dumux/common/geometry/grahamconvexhull.hh @@ -175,6 +175,31 @@ grahamConvexHull2d3d(std::vector<Dune::FieldVector<ctype, 3>>& points) return convexHull; } +/*! + * \ingroup Geometry + * \brief Compute the points making up the convex hull around the given set of unordered points + * \note This is the specialization for 2d space. Here, we make use of the generic implementation + * for the case of coplanar points in 3d space (a more efficient implementation could be provided). + */ +template<class ctype> +std::vector<Dune::FieldVector<ctype, 2>> +grahamConvexHull(const std::vector<Dune::FieldVector<ctype, 2>>& points) +{ + std::vector<Dune::FieldVector<ctype, 3>> tmp; + tmp.reserve(points.size()); + for (const auto& p : points) + tmp.emplace_back( Dune::FieldVector<ctype, 3>({p[0], p[1], 0.0}) ); + + auto result3d = grahamConvexHull2d3d(tmp); + + std::vector<Dune::FieldVector<ctype, 2>> result; + result.reserve(result3d.size()); + for (const auto& p : result3d) + result.emplace_back( Dune::FieldVector<ctype, 2>({p[0], p[1]}) ); + + return result; +} + /*! * \ingroup Geometry * \brief Triangulate area given points of the convex hull