Skip to content
Snippets Groups Projects
Commit 48781c29 authored by Elias Pipping's avatar Elias Pipping
Browse files

[Cleanup] Move distance helper to polyhedrondistance

parent a81fe2e3
No related branches found
No related tags found
No related merge requests found
...@@ -188,4 +188,32 @@ double distance(const ConvexPolyhedron<Coordinate> &s1, ...@@ -188,4 +188,32 @@ double distance(const ConvexPolyhedron<Coordinate> &s1,
assert(false); assert(false);
} }
// Point-to-Geometry convenience method
template <class Geometry>
double distance(typename Geometry::GlobalCoordinate const &point,
Geometry const &geo, double valueCorrectionTolerance) {
using Coordinate = typename Geometry::GlobalCoordinate;
ConvexPolyhedron<Coordinate> polyhedron;
polyhedron.vertices.resize(geo.corners());
for (size_t i = 0; i < polyhedron.vertices.size(); ++i)
polyhedron.vertices[i] = geo.corner(i);
return distance(point, polyhedron, valueCorrectionTolerance);
}
// Polyhedron-to-Geometry convenience method
template <class Geometry>
double distance(ConvexPolyhedron<typename Geometry::GlobalCoordinate> const &p1,
Geometry const &geo, double valueCorrectionTolerance) {
using Coordinate = typename Geometry::GlobalCoordinate;
ConvexPolyhedron<Coordinate> p2;
p2.vertices.resize(geo.corners());
for (size_t i = 0; i < p2.vertices.size(); ++i)
p2.vertices[i] = geo.corner(i);
return distance(p2, p1, valueCorrectionTolerance);
}
#endif #endif
#ifndef SRC_DISTANCES_HH #ifndef SRC_DIAMETER_HH
#define SRC_DISTANCES_HH #define SRC_DIAMETER_HH
#include <dune/tectonic/polyhedrondistance.hh>
#include "sand-wedge-data/mygeometry.hh"
template <class Geometry> double diameter(Geometry const &geometry) { template <class Geometry> double diameter(Geometry const &geometry) {
auto const numCorners = geometry.corners(); auto const numCorners = geometry.corners();
...@@ -16,18 +13,4 @@ template <class Geometry> double diameter(Geometry const &geometry) { ...@@ -16,18 +13,4 @@ template <class Geometry> double diameter(Geometry const &geometry) {
} }
return diameter; return diameter;
} }
template <class Geometry>
double distance(
Geometry const &g,
ConvexPolyhedron<typename Geometry::GlobalCoordinate> const &weakPatch) {
using Coordinate = typename Geometry::GlobalCoordinate;
ConvexPolyhedron<Coordinate> bsg;
bsg.vertices.resize(g.corners());
for (size_t i = 0; i < bsg.vertices.size(); ++i)
bsg.vertices[i] = g.corner(i);
return distance(bsg, weakPatch, 1e-6 * MyGeometry::lengthScale);
}
#endif #endif
...@@ -2,9 +2,11 @@ ...@@ -2,9 +2,11 @@
#include "config.h" #include "config.h"
#endif #endif
#include <dune/tectonic/polyhedrondistance.hh>
#include "mygrid.hh" #include "mygrid.hh"
#include "midpoint.hh" #include "midpoint.hh"
#include "../distances.hh" #include "../diameter.hh"
#if MY_DIM == 3 #if MY_DIM == 3
SimplexManager::SimplexManager(unsigned int shift) : shift_(shift) {} SimplexManager::SimplexManager(unsigned int shift) : shift_(shift) {}
...@@ -203,7 +205,8 @@ void refine(Grid &grid, ConvexPolyhedron<LocalVector> const &weakPatch, ...@@ -203,7 +205,8 @@ void refine(Grid &grid, ConvexPolyhedron<LocalVector> const &weakPatch,
it != grid.template leafend<0>(); ++it) { it != grid.template leafend<0>(); ++it) {
auto const geometry = it->geometry(); auto const geometry = it->geometry();
auto const weakeningRegionDistance = distance(geometry, weakPatch); auto const weakeningRegionDistance =
distance(weakPatch, geometry, 1e-6 * MyGeometry::lengthScale);
auto const admissibleDiameter = auto const admissibleDiameter =
computeAdmissibleDiameter(weakeningRegionDistance, smallestDiameter); computeAdmissibleDiameter(weakeningRegionDistance, smallestDiameter);
......
...@@ -5,7 +5,7 @@ ...@@ -5,7 +5,7 @@
#include <dune/common/fvector.hh> #include <dune/common/fvector.hh>
#include <dune/common/parametertree.hh> #include <dune/common/parametertree.hh>
#include <dune/tectonic/convexpolyhedron.hh> #include <dune/tectonic/polyhedrondistance.hh>
class PatchFunction class PatchFunction
: public Dune::VirtualFunction<Dune::FieldVector<double, MY_DIM>, : public Dune::VirtualFunction<Dune::FieldVector<double, MY_DIM>,
......
...@@ -55,7 +55,7 @@ ...@@ -55,7 +55,7 @@
#include "adaptivetimestepper.hh" #include "adaptivetimestepper.hh"
#include "assemblers.hh" #include "assemblers.hh"
#include "distances.hh" #include "diameter.hh"
#include "enumparser.hh" #include "enumparser.hh"
#include "enums.hh" #include "enums.hh"
#include "friction_writer.hh" #include "friction_writer.hh"
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment