9#ifndef DUNE_MMESH_INTERFACE_CURVATUREOPERATOR_HH
10#define DUNE_MMESH_INTERFACE_CURVATUREOPERATOR_HH
35template <
class IGr
idView,
class IGr
idMapper, CurvatureLayout CL = Vertex>
38 static constexpr int dim = IGridView::dimensionworld;
39 using Scalar =
typename IGridView::ctype;
50 : iGridView_(iGridView), iGridMapper_(iGridMapper){};
64 template <
class Curvatures,
class Centers, CurvatureLayout Layout = CL>
66 Centers& centers)
const {
71 for (
const auto& vertex : vertices(iGridView_)) {
72 const int iVertexIdx = iGridMapper_.index(vertex);
74 vertexPoints.
push_back(vertex.geometry().center());
77 vertexPoints.
push_back(incidentVertex.geometry().center());
82 curvatures[iVertexIdx] = 1.0 / getRadius(vertexPoints, center);
83 centers[iVertexIdx] = center;
87 template <
class Curvatures,
class Centers, CurvatureLayout Layout = CL>
89 Centers& centers)
const {
94 for (
const auto& iElem : elements(iGridView_)) {
95 int iElemIdx = iGridMapper_.index(iElem);
98 for (
const auto& intersct : intersections(iGridView_, iElem)) {
99 const auto& neighborGeo = intersct.outside().geometry();
101 for (
int i = 0; i < neighborGeo.corners(); i++) {
103 neighborGeo.corner(i)) == vertexPoints.
end()) {
104 vertexPoints.
push_back(neighborGeo.corner(i));
111 curvatures[iElemIdx] = 1.0 / getRadius(vertexPoints, center);
112 centers[iElemIdx] = center;
127 template <
class Po
ints>
128 double getRadius(
const Points& points,
Vector& center)
const {
134 LargeDynVector b(points.size(), 0.0);
135 DynMatrix A(points.size(),
dim + 1, 0.0);
137 LargeVector ATb(0.0);
140 for (
unsigned int i = 0; i < points.size(); i++) {
141 b[i] = -points[i].two_norm2();
144 for (
int j = 0; j <
dim; j++) {
145 A[i][j + 1] = points[i][j];
151 for (
int i = 0; i <=
dim; i++)
152 for (
int j = 0; j <=
dim; j++)
154 ATA[i][j] += A[k][i] * A[k][j];
156 if (
std::abs(ATA.determinant()) > epsilon) {
160 for (
int j = 1; j <=
dim; j++) {
162 center[j - 1] = -0.5 * x[j];
174 const IGridView& iGridView_;
176 const IGridMapper& iGridMapper_;
auto incidentInterfaceVertices(const Vertex &vertex)
Incident interface vertices.
Definition rangegenerators.hh:94
CurvatureLayout
used as template parameter that determines whether the curvature is approximated at the elemets or th...
Definition curvatureoperator.hh:22
@ Vertex
Definition curvatureoperator.hh:22
@ Element
Definition curvatureoperator.hh:22
Dune::Fem::Double abs(const Dune::Fem::Double &a)
Class defining an operator that assigns a curvature to each element or each vertex of the interface g...
Definition curvatureoperator.hh:36
Dune::FieldVector< Scalar, dim > Vector
Definition curvatureoperator.hh:40
std::enable_if_t< Layout==Vertex, void > operator()(Curvatures &curvatures, Centers ¢ers) const
Operator that assigns a curvature to each element or each vertex of the interface grid....
Definition curvatureoperator.hh:65
static constexpr int dim
Definition curvatureoperator.hh:38
typename IGridView::ctype Scalar
Definition curvatureoperator.hh:39
CurvatureOperator(const IGridView &iGridView, const IGridMapper &iGridMapper)
Constructor.
Definition curvatureoperator.hh:49
std::enable_if_t< Layout==Element, void > operator()(Curvatures &curvatures, Centers ¢ers) const
Definition curvatureoperator.hh:88