Skip to content

FE Quadrature Phase 02: bounded Gaussian line generators - #645

Open
zasexton wants to merge 32 commits into
SimVascular:mainfrom
zasexton:phase-02
Open

zasexton wants to merge 32 commits into
SimVascular:mainfrom
zasexton:phase-02

Conversation

@zasexton

@zasexton zasexton commented Sep 14, 2026 •

Copy link
Copy Markdown
Collaborator

Current situation

Phase 01 (#593) introduced the concrete QuadratureRule value type, but the module does not yet provide generators for Gaussian line rules. This PR implements Phase 02 of
#580 by adding Gauss-Legendre and Gauss-Lobatto-Legendre generators on [-1, 1].

Both functions accept signed int requested_exactness and return a complete QuadratureRule by value with at least that exactness. Each family owns its conversion to the smallest sufficient point count; future selectors do not need to duplicate these formulas or infer exactness limits from point limits. These line rules provide factors for later element generators. Existing solver quadrature tables and consumers are unchanged.

Newton refinement computes the Legendre polynomial roots or stationary points needed to support each requested size. The implementation uses a three-term recurrence and analytic derivatives, computes one half of the samples, and
mirrors them into increasing order. Refinement has a defensive 100-iteration bound. Correction and measure tolerances are 64 * epsilon and 32 * 128 * epsilon, respectively, where epsilon is std::numeric_limits<double>::epsilon(); both are qualified over every supported point count. Invalid exactness requests raise InvalidArgumentException before
point-count conversion or sample allocation; unsuccessful refinement or numerical validation raises ConvergenceException. Failed weights are never rescaled to force the reference measure.

Release Notes

  • Add make_gauss_legendre_rule(int requested_exactness) for requests 0..255, using integer division n = requested_exactness / 2 + 1 to select 1 through 128 interior points with actual exactness 2n - 1.
  • Add make_gauss_lobatto_rule(int requested_exactness) for requests 0..253, using n = requested_exactness / 2 + 2 to select 2 through 128 points, including both endpoints exactly, with actual exactness 2n - 3.
  • Accept degree zero and preserve actual returned exactness: requests 4 and 5 both produce degree-5 rules, using three Gauss points or four Lobatto points.
  • Expose constexpr noexcept capacity queries max_gauss_legendre_exactness() returning 255 and max_gauss_lobatto_exactness() returning 253. The internal 128-point ceiling is a project support bound that limits construction cost and downstream product-rule growth, not a mathematical or convergence limit.
  • Return ordered, symmetric samples with positive weights, exact odd-rule centers, and the correct reference measure within the documented tolerance.

Documentation

The two public headers document supported request ranges, integer-division conversion formulas, at-least-requested semantics, degree-zero behavior, actual metadata, ordering, endpoints, capacity rationale, and exception semantics in
the existing FE_Quadrature Doxygen group. Implementation and test comments explain the numerical tolerances and qualification strategy.

The PR contains only the two generator headers, their implementations, and test_QuadratureGenerators.cpp. Current upstream's svmp_fe_quadrature target and unit-test discovery include these files without CMake edits.

Testing

The eight focused tests cover:

  • Canonical low-order fixtures, degree-zero minimum counts, and returned exactness greater than an even request.
  • Every supported request: all 256 Gauss-Legendre degrees and all 254 Lobatto degrees, selecting 128 and 127 distinct rules respectively. Both even and odd requests check point counts, actual metadata, ordering, containment, symmetry, positive weights, exact assigned coordinates, and reference measure.
  • All advertised analytic monomial moments for both request parities: 65,536 checks using compensated long-double accumulation, plus first-unadvertised-degree checks for small rules.
  • Supported upper boundaries, first unsupported degrees, negative requests, integer extremes, and exception diagnostics.
  • Representative Lobatto node comparisons with the independent Basis implementation, with the cross-module dependency confined to test code.
  • svmp_fe_quadrature, run_all_unit_tests, and svmultiphysics built successfully with the revised API.
  • All eight generator tests passed across four suites.
  • All 17 Quadrature tests passed across seven suites.
  • All 260 unit tests passed across 35 suites.

Code of Conduct & Contributing Guidelines

@codecov

codecov Bot commented Sep 14, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 86.75799% with 58 lines in your changes missing coverage. Please review.
✅ Project coverage is 73.52%. Comparing base (c9838bd) to head (0dcf5f9).

Files with missing lines Patch % Lines
...ce/solver/FE/Quadrature/GaussLobattoQuadrature.cpp 81.98% 20 Missing ⚠️
...tTests/FE/Quadrature/test_QuadratureGenerators.cpp 91.34% 20 Missing ⚠️
...de/Source/solver/FE/Quadrature/GaussQuadrature.cpp 81.25% 18 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #645      +/-   ##
==========================================
+ Coverage   73.41%   73.52%   +0.11%     
==========================================
  Files         269      272       +3     
  Lines       40337    40789     +452     
  Branches     6755     6796      +41     
==========================================
+ Hits        29612    29992     +380     
- Misses      10482    10554      +72     
  Partials      243      243              

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@zasexton zasexton self-assigned this Sep 14, 2026

@michelebucelli michelebucelli left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @zasexton! I left some comments below.

Comment thread tests/unitTests/FE/Quadrature/test_QuadratureGenerators.cpp
Comment thread Code/Source/solver/FE/Quadrature/GaussQuadrature.h Outdated
Comment thread Code/Source/solver/FE/Quadrature/GaussQuadrature.cpp Outdated
Comment thread Code/Source/solver/FE/Quadrature/GaussQuadrature.cpp Outdated
Comment thread Code/Source/solver/FE/Quadrature/GaussQuadrature.cpp
Comment thread Code/Source/solver/FE/Quadrature/GaussQuadrature.cpp
Comment thread Code/Source/solver/FE/Quadrature/GaussQuadrature.cpp Outdated
Comment thread Code/Source/solver/FE/Quadrature/GaussQuadrature.cpp Outdated
Comment thread Code/Source/solver/FE/Quadrature/GaussQuadrature.h
Comment thread Code/Source/solver/FE/Quadrature/GaussLobattoQuadrature.h
@zasexton
zasexton marked this pull request as ready for review September 24, 2026 23:10

@claude claude Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Claude Code Review

This pull request is from a fork — automated review is disabled. A repository maintainer can comment @claude review to run a one-time review.

Propagate nonnegative counts through both generators and test helpers,
keeping signed exactness and diagnostic conversions explicit.

Addresses SimVascular#645 (comment)

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants