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

[Cleanup] Move ConvexPolyhedron to separate header

parent 68c111f6
No related branches found
No related tags found
No related merge requests found
#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
......@@ -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,
......
......@@ -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"
......
......@@ -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>,
......
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