22 typedef Point TrianglePoints[3];
24 static unsigned safe_order(
const unsigned n) {
27 std::cout <<
"Unavailable Gauss order " << n <<
": min is 1, max is 3" << std::endl;
45 template <
typename Function>
56 template <
typename Function>
57 decltype(
auto) triangle_integration(
const Function&
function,
const TrianglePoints& triangle)
const {
60 for (
unsigned i=0;
i<nbPts[order];++
i) {
62 for (
unsigned j=0;
j<3; ++
j)
63 v.multadd(rules[order][
i].barycentric_coordinates[
j],triangle[
j]);
69 const double area2 =
crossprod(triangle[1]-triangle[0],triangle[2]-triangle[0]).
norm();
74 template <
typename T,
typename Function>
76 const Point
midpoints[] = { 0.5*(triangle[1]+triangle[2]), 0.5*(triangle[2]+triangle[0]), 0.5*(triangle[0]+triangle[1]) };
84 for (
unsigned i=0;
i<4; ++
i) {
93 for (
unsigned i=0;
i<4; ++
i)
98 static constexpr unsigned nbPts[4] = { 3, 6, 7, 16 };
100 const unsigned order;
101 const double tolerance;
102 const unsigned max_depth;
106 struct QuadratureRule {
107 double barycentric_coordinates[3];
111 static constexpr QuadratureRule rules[4][16] = {
113 {{ 0.166666666666667, 0.166666666666667, 0.666666666666667 }, 0.166666666666667 },
114 {{ 0.166666666666667, 0.666666666666667, 0.166666666666667 }, 0.166666666666667 },
115 {{ 0.666666666666667, 0.166666666666667, 0.166666666666667 }, 0.166666666666667 },
116 {{ 0.0, 0.0, 0.0 }, 0.0 }, {{ 0.0, 0.0, 0.0 }, 0.0 }, {{ 0.0, 0.0, 0.0 }, 0.0 }, {{ 0.0, 0.0, 0.0 }, 0.0 },
117 {{ 0.0, 0.0, 0.0 }, 0.0 }, {{ 0.0, 0.0, 0.0 }, 0.0 }, {{ 0.0, 0.0, 0.0 }, 0.0 }, {{ 0.0, 0.0, 0.0 }, 0.0 },
118 {{ 0.0, 0.0, 0.0 }, 0.0 }, {{ 0.0, 0.0, 0.0 }, 0.0 }, {{ 0.0, 0.0, 0.0 }, 0.0 }, {{ 0.0, 0.0, 0.0 }, 0.0 },
119 {{ 0.0, 0.0, 0.0 }, 0.0 }
122 {{ 0.445948490915965, 0.445948490915965, 0.108103018168070 }, 0.111690794839005 },
123 {{ 0.445948490915965, 0.108103018168070, 0.445948490915965 }, 0.111690794839005 },
124 {{ 0.108103018168070, 0.445948490915965, 0.445948490915965 }, 0.111690794839005 },
125 {{ 0.091576213509771, 0.091576213509771, 0.816847572980458 }, 0.054975871827661 },
126 {{ 0.091576213509771, 0.816847572980458, 0.091576213509771 }, 0.054975871827661 },
127 {{ 0.816847572980458, 0.091576213509771, 0.091576213509771 }, 0.054975871827661 },
128 {{ 0.0, 0.0, 0.0 }, 0.0 }, {{ 0.0, 0.0, 0.0 }, 0.0 }, {{ 0.0, 0.0, 0.0 }, 0.0 }, {{ 0.0, 0.0, 0.0 }, 0.0 },
129 {{ 0.0, 0.0, 0.0 }, 0.0 }, {{ 0.0, 0.0, 0.0 }, 0.0 }, {{ 0.0, 0.0, 0.0 }, 0.0 }, {{ 0.0, 0.0, 0.0 }, 0.0 },
130 {{ 0.0, 0.0, 0.0 }, 0.0 }, {{ 0.0, 0.0, 0.0 }, 0.0 }
133 {{ 0.333333333333333, 0.333333333333333, 0.333333333333333 }, 0.1125 },
134 {{ 0.470142064105115, 0.470142064105115, 0.059715871789770 }, 0.066197076394253 },
135 {{ 0.470142064105115, 0.059715871789770, 0.470142064105115 }, 0.066197076394253 },
136 {{ 0.059715871789770, 0.470142064105115, 0.470142064105115 }, 0.066197076394253 },
137 {{ 0.101286507323456, 0.101286507323456, 0.797426985353088 }, 0.062969590272414 },
138 {{ 0.101286507323456, 0.797426985353088, 0.101286507323456 }, 0.062969590272414 },
139 {{ 0.797426985353088, 0.101286507323456, 0.101286507323456 }, 0.062969590272414 },
140 {{ 0.0, 0.0, 0.0 }, 0.0 }, {{ 0.0, 0.0, 0.0 }, 0.0 }, {{ 0.0, 0.0, 0.0 }, 0.0 }, {{ 0.0, 0.0, 0.0 }, 0.0 },
141 {{ 0.0, 0.0, 0.0 }, 0.0 }, {{ 0.0, 0.0, 0.0 }, 0.0 }, {{ 0.0, 0.0, 0.0 }, 0.0 }, {{ 0.0, 0.0, 0.0 }, 0.0 },
142 {{ 0.0, 0.0, 0.0 }, 0.0 }
145 {{ 0.333333333333333, 0.333333333333333, 0.333333333333333 }, 0.072157803838893 },
146 {{ 0.081414823414554, 0.459292588292722, 0.459292588292722 }, 0.047545817133642 },
147 {{ 0.459292588292722, 0.081414823414554, 0.459292588292722 }, 0.047545817133642 },
148 {{ 0.459292588292722, 0.459292588292722, 0.081414823414554 }, 0.047545817133642 },
149 {{ 0.898905543365937, 0.050547228317031, 0.050547228317031 }, 0.016229248811599 },
150 {{ 0.050547228317031, 0.898905543365937, 0.050547228317031 }, 0.016229248811599 },
151 {{ 0.050547228317031, 0.050547228317031, 0.898905543365937 }, 0.016229248811599 },
152 {{ 0.658861384496479, 0.170569307751760, 0.170569307751761 }, 0.051608685267359 },
153 {{ 0.170569307751760, 0.658861384496479, 0.170569307751761 }, 0.051608685267359 },
154 {{ 0.170569307751760, 0.170569307751761, 0.658861384496479 }, 0.051608685267359 },
155 {{ 0.008394777409957, 0.728492392955404, 0.263112829634639 }, 0.013615157087217 },
156 {{ 0.728492392955404, 0.008394777409957, 0.263112829634639 }, 0.013615157087217 },
157 {{ 0.728492392955404, 0.263112829634639, 0.008394777409957 }, 0.013615157087217 },
158 {{ 0.008394777409957, 0.263112829634639, 0.728492392955404 }, 0.013615157087217 },
159 {{ 0.263112829634639, 0.008394777409957, 0.728492392955404 }, 0.013615157087217 },
160 {{ 0.263112829634639, 0.728492392955404, 0.008394777409957 }, 0.013615157087217 }