6#ifndef MATH_INTEGRATION_TRIANGLEQUADRATURE_HPP
7#define MATH_INTEGRATION_TRIANGLEQUADRATURE_HPP
13#include "math/Vector2.hpp"
15#include "math/integration/TriangleQuadratureRule.hpp"
34 template<
typename NumericReturnType,
typename T>
45 const std::function<NumericReturnType(
const Vector<T, 2>&)>& f,
56 const std::function<NumericReturnType(
const Vector<T, 3>&)>& f,
60 template<
typename NumericReturnType,
typename T>
62 const std::function<NumericReturnType(
const Vector<T, 2>&)>& f,
65 const std::vector<Vector2<T>>& barycentric_coordinates =
67 const std::vector<T>& weights = rule.
weights();
68 assert(barycentric_coordinates.size() == weights.size());
69 assert(weights.size() >= 1);
80 NumericReturnType integral = f(barycentric_coordinates[0]) * weights[0];
81 for (
int i = 1; i < static_cast<int>(weights.size()); ++i)
82 integral += f(barycentric_coordinates[i]) * weights[i];
84 return integral * area;
87 template<
typename NumericReturnType,
typename T>
89 const std::function<NumericReturnType(
const Vector<T, 3>&)>& f,
93 std::function<NumericReturnType(
const Vector<T, 2>&)> fprime =
95 return f(
Vector3<T>(barycentric_2D[0], barycentric_2D[1],
96 T(1.0) - barycentric_2D[0] - barycentric_2D[1]));
99 return Integrate(fprime, rule, area);
A class for integrating a function using numerical quadrature over triangular domains.
static NumericReturnType Integrate(const std::function< NumericReturnType(const Vector< T, 2 > &)> &f, const TriangleQuadratureRule &rule, const T &area)
Numerically integrates the function f over a triangle using the given quadrature rule and the initial...
A "rule" (weights and quadrature points) for computing quadrature over triangular domains.
const std::vector< RealType > & weights() const
Returns the vector of weights. These sum to 1 and there is one weight for each point returned by quad...
const std::vector< Vector2d > & quadrature_points() const
Returns the vector of quadrature points. These are returned as the first two barycentric coordinates ...
This basic Periodic Table class was originally taken from the data.cpp file in OpenBabel.