Repository navigation
Conversation
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## main #645 +/- ##
==========================================
+ Coverage 72.88% 72.98% +0.09%
==========================================
Files 272 275 +3
Lines 40148 40599 +451
Branches 6718 6761 +43
==========================================
+ Hits 29263 29630 +367
- Misses 10663 10748 +85
+ Partials 222 221 -1 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
michelebucelli
left a comment
There was a problem hiding this comment.
Thanks @zasexton! I left some comments below.
Co-authored-by: Michele Bucelli <michelebucelli415@gmail.com>
Propagate nonnegative counts through both generators and test helpers, keeping signed exactness and diagnostic conversions explicit. Addresses SimVascular#645 (comment)
michelebucelli
left a comment
There was a problem hiding this comment.
Thanks @zasexton, I did another pass and left only a few minor comments.
They all relate to avoid using static_cast when the cast would be safely done implicitly anyways: this code is already pretty low-level, so I believe it benefits from being as noiseless as possible, and I feel that many static_casts may hinder readability in a few places (especially when the implicit cast is the one that you would naturally expect to take place).
Other than that, looks good to me.
| const auto [root, weight] = | ||
| generate_interior_root_and_weight( | ||
| num_points, half_root_index, left_index == right_index, | ||
| num_points, static_cast<int>(half_root_index), left_index == right_index, |
There was a problem hiding this comment.
I think the cast from size_t to int is implicit, and we don't need static_cast here.
Having said that, maybe half_root_index can also be made unsigned (seeing as it is an index, as per its name).
| "generated points are not strictly increasing"); | ||
| if (!(spacing > 0.0)) { | ||
| raise_generation_failure( | ||
| num_points, static_cast<int>(point_index), -1, spacing, |
There was a problem hiding this comment.
Same as before, the static_cast can probably be dropped.
| measure_error <= | ||
| static_cast<long double>(kRuleValidationTolerance))) { | ||
| raise_generation_failure( | ||
| num_points, -1, -1, static_cast<double>(measure_error), |
There was a problem hiding this comment.
Same as above for both these static_casts. For the comparison expression, the narrower type (double) will be implicitly converted to the wider one (long double), so the cast adds noise without having any effect, I believe.
| "generated weights do not reproduce the reference measure"); | ||
| } | ||
|
|
||
| const int polynomial_exactness = static_cast<int>(2 * num_points - 3); |
There was a problem hiding this comment.
Same as above, even though here the case is actually a bit more subtle. If you want to be safe against overflow, you can change this to 2 * static_cast<int>(num_points) - 3, but I don't really think it's necessary (I assume that by this point if this number were to come out negative some other exception would have fired).
| const std::size_t right_index = points.size() - 1u - left_index; | ||
| const auto [root, weight] = generate_root_and_weight( | ||
| num_points, root_index, left_index == right_index); | ||
| num_points, static_cast<int>(left_index), left_index == right_index); |
There was a problem hiding this comment.
Similar comment about static_casts here and in the rest of this file.
Current situation
Phase 01 (#593) introduced the concrete
QuadratureRulevalue 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_exactnessand return a completeQuadratureRuleby 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 * epsilonand32 * 128 * epsilon, respectively, whereepsilonisstd::numeric_limits<double>::epsilon(); both are qualified over every supported point count. Invalid exactness requests raiseInvalidArgumentExceptionbeforepoint-count conversion or sample allocation; unsuccessful refinement or numerical validation raises
ConvergenceException. Failed weights are never rescaled to force the reference measure.Release Notes
make_gauss_legendre_rule(int requested_exactness)for requests0..255, using integer divisionn = requested_exactness / 2 + 1to select 1 through 128 interior points with actual exactness2n - 1.make_gauss_lobatto_rule(int requested_exactness)for requests0..253, usingn = requested_exactness / 2 + 2to select 2 through 128 points, including both endpoints exactly, with actual exactness2n - 3.constexpr noexceptcapacity queriesmax_gauss_legendre_exactness()returning 255 andmax_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.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_QuadratureDoxygen 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'ssvmp_fe_quadraturetarget and unit-test discovery include these files without CMake edits.Testing
The eight focused tests cover:
svmp_fe_quadrature,run_all_unit_tests, andsvmultiphysicsbuilt successfully with the revised API.Code of Conduct & Contributing Guidelines