svMultiPhysics
Loading...
Searching...
No Matches
TriangleQuadrature.h
Go to the documentation of this file.
1// SPDX-FileCopyrightText: Copyright (c) Stanford University, The Regents of the University of California, and others.
2// SPDX-License-Identifier: BSD-3-Clause
3
4#ifndef SVMP_FE_TRIANGLE_QUADRATURE_H
5#define SVMP_FE_TRIANGLE_QUADRATURE_H
6
7/**
8 * @file TriangleQuadrature.h
9 * @brief Centroid and bounded Duffy quadrature on the unit right triangle.
10 * @ingroup FE_Quadrature
11 */
12
14
15namespace svmp::FE::quadrature {
16
17/** @addtogroup FE_Quadrature
18 * @{
19 */
20
21/**
22 * @brief Return the project bound on requested triangle exactness.
23 * @return 254, permitting a 128-point Gauss factor.
24 */
25[[nodiscard]] constexpr int max_triangle_exactness() noexcept
26{
27 return 254;
28}
29
30/**
31 * @brief Return the degree-one centroid rule: point @f$(1/3,1/3,0)@f$, weight @f$1/2@f$.
32 * @return Owning CellFamily::Triangle rule for constant or linear integration.
33 */
34[[nodiscard]] QuadratureRule make_triangle_centroid_rule();
35
36/**
37 * @brief Compose two canonical line rules into a Duffy triangle rule.
38 *
39 * @details Duffy maps the unit square onto @f$x,y\geq0,\ x+y\leq1@f$ by
40 * @f$(x,y)=(u,(1-u)v)@f$, collapsing the edge @f$u=1@f$ to vertex @f$(1,0)@f$.
41 * For supplied points @f$\xi_i,\eta_j@f$ and weights @f$a_i,b_j@f$,
42 * @f[
43 * u_i=(\xi_i+1)/2,\quad v_j=(\eta_j+1)/2,\quad
44 * \mathbf{x}_{ij}=(u_i,(1-u_i)v_j,0),\quad W_{ij}=a_i b_j(1-u_i)/4.
45 * @f]
46 * Weights include the Jacobian @f$1-u@f$ and both interval scalings.
47 * Including the Jacobian, @f$x^a y^b@f$ becomes @f$u^a(1-u)^{b+1}v^b@f$;
48 * total degree @f$p@f$ therefore requires @f$e_u\geq p+1@f$ and @f$e_v\geq p@f$.
49 *
50 * Factors may come from different line generators and have different point
51 * counts; both are used as supplied. Select make_triangle_centroid_rule()
52 * for the centroid. All samples are kept in input order (i outer, j inner),
53 * including duplicates and collapsed points. Signed/zero weights are allowed.
54 * Duffy rules are not permutation-symmetric triangle tables.
55 *
56 * Each rule requires @f$|\sum w-M|\leq\tau\max(M,\sum|w|)@f$, with @f$M=2@f$
57 * for each line, @f$M=1/2@f$ for the triangle, and @f$\tau=256\epsilon@f$ for
58 * binary64 machine epsilon @f$\epsilon@f$. Mapped points lie in the triangle up
59 * to rounding; no clipping or weight rescaling is performed.
60 *
61 * @param requested_exactness Minimum total degree @f$p@f$; must be in [0, 254],
62 * inclusive (see max_triangle_exactness()).
63 * @param u_rule Nonempty canonical Line rule on @f$[-1,1]@f$ with trusted
64 * @f$e_u\geq p+1@f$.
65 * @param v_rule Nonempty canonical Line rule on @f$[-1,1]@f$ with trusted
66 * @f$e_v\geq p@f$.
67 * @return Owning Triangle rule with exactness @f$\min(e_u-1,e_v)@f$ and
68 * @f$n_u n_v@f$ samples.
69 * @throws InvalidArgumentException If the request or factors violate these
70 * contracts, or @f$n_u n_v@f$ exceeds 16384; checked before product
71 * allocation.
72 * @throws ConvergenceException If the mapped weights do not reproduce measure
73 * @f$1/2@f$, for example after an overflowed product or when @p u_rule
74 * does not integrate linear functions exactly.
75 */
76[[nodiscard]] QuadratureRule make_triangle_rule(
77 int requested_exactness, const QuadratureRule& u_rule, const QuadratureRule& v_rule);
78
79/**
80 * @brief Reuse one line rule in both Duffy directions.
81 * @details Equivalent to make_triangle_rule(requested_exactness, line_rule, line_rule),
82 * with the same validation and sample-preservation contracts.
83 * @param requested_exactness Minimum total degree @f$p@f$; must be in [0, 254],
84 * inclusive (see max_triangle_exactness()).
85 * @param line_rule Canonical Line rule with @f$1\leq n\leq128@f$ points and
86 * trusted exactness @f$e\geq p+1@f$.
87 * @return Owning Triangle rule with exactness @f$e-1@f$ and @f$n^2@f$ samples.
88 */
89[[nodiscard]] QuadratureRule make_triangle_rule(int requested_exactness, const QuadratureRule& line_rule);
90
91/** @} */
92
93} // namespace svmp::FE::quadrature
94
95#endif // SVMP_FE_TRIANGLE_QUADRATURE_H
Value type for reference-space quadrature rules.
QuadratureRule make_triangle_centroid_rule()
Return the degree-one centroid rule: point , weight .
Definition TriangleQuadrature.cpp:71
QuadratureRule make_triangle_rule(int requested_exactness, const QuadratureRule &u_rule, const QuadratureRule &v_rule)
Compose two canonical line rules into a Duffy triangle rule.
Definition TriangleQuadrature.cpp:76
constexpr int max_triangle_exactness() noexcept
Return the project bound on requested triangle exactness.
Definition TriangleQuadrature.h:25