Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix Quadrature rule docs and syms #1007

Merged
merged 24 commits into from
Aug 5, 2024
Merged

Fix Quadrature rule docs and syms #1007

merged 24 commits into from
Aug 5, 2024

Conversation

termi-official
Copy link
Member

Following the discussion in #1001 I just noticed that some references for the quadrature roles and the doc strings were not correct. This PR fixes both.

Copy link
Member

@KnutAM KnutAM left a comment

Choose a reason for hiding this comment

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

Nice that you found this!

Since we probably don't want to change the defaults in the future, are these reasonable defaults? Seems strange to switch at order = 8?

(Side-note: Also looks like dispatching on a type would be nicer as @fredrikekre suggested, but that would be a different PR)

src/Quadrature/quadrature.jl Outdated Show resolved Hide resolved
src/Quadrature/quadrature.jl Outdated Show resolved Hide resolved
@termi-official
Copy link
Member Author

Nice that you found this!

Thanks, took me a while to realize too tbh.

Since we probably don't want to change the defaults in the future, are these reasonable defaults? Seems strange to switch at order = 8?

Actually I am really not sure about the rule or why it works in the in first place, because it comes with negative weights. I am pretty sure this can cause some trouble, but I cannot pin down why. See e.g. https://www.math.ntnu.no/emner/TMA4130/2021h/lectures/GaussQuadrature.pdf . But on the other hand rules with positive weights have more points in general.

(Side-note: Also looks like dispatching on a type would be nicer as @fredrikekre suggested, but that would be a different PR)

I am not super sure about this. I think it would also be nice to provide extensions which add new quadrature rules.

Copy link

codecov bot commented Jul 1, 2024

Codecov Report

Attention: Patch coverage is 93.50649% with 5 lines in your changes missing coverage. Please review.

Project coverage is 93.68%. Comparing base (2c8b751) to head (6b3ff91).
Report is 5 commits behind head on master.

Files Patch % Lines
src/Quadrature/gaussquad_tet_table.jl 89.47% 4 Missing ⚠️
src/Quadrature/gaussquad_tri_table.jl 87.50% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #1007      +/-   ##
==========================================
+ Coverage   93.20%   93.68%   +0.47%     
==========================================
  Files          38       39       +1     
  Lines        5816     5936     +120     
==========================================
+ Hits         5421     5561     +140     
+ Misses        395      375      -20     

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

@fredrikekre
Copy link
Member

The triangle ones are from #514 (comment) (unless you found it already).

@termi-official
Copy link
Member Author

The triangle ones are from #514 (comment) (unless you found it already).

Yes, and going into the basics source code tracking down the call graph manually I arrived at a call to Gauss-Jacobi generators.

@termi-official termi-official marked this pull request as draft July 2, 2024 10:50
@termi-official termi-official marked this pull request as ready for review July 2, 2024 11:58
@termi-official
Copy link
Member Author

Someone should verify this independently and then it should be good to go.

@termi-official termi-official added the awaiting review PR is finished from the authors POV, waiting for feedback label Jul 2, 2024
src/Quadrature/quadrature.jl Outdated Show resolved Hide resolved
Copy link
Member

@KnutAM KnutAM left a comment

Choose a reason for hiding this comment

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

OK, started looking through this, and as I understand, we can skip the :jinyun type, as this is covered by :keast.

I've checked that :jinyn matches the reference so far (except for n=4 where it matches :keast), but don't have more time now.

src/Quadrature/gaussquad_tet_table.jl Show resolved Hide resolved
src/Quadrature/gaussquad_tet_table.jl Outdated Show resolved Hide resolved
Comment on lines 6 to 11
# Quadrature rules for orders 9 to 20 have been obtained using the
# basix.make_quadrature(basix.CellType.triangle, n) calls of the
# FEniCS / basix python package
# FEniCS / basix python package, which corresponds to Gauss-Jacobi rules.
#
# see
# https://docs.fenicsproject.org/basix/main/python/_autosummary/basix.html?highlight=quadraturetype#basix.make_quadrature
Copy link
Member

Choose a reason for hiding this comment

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

Move to above _get_gaussjacobi_tridata and add actual ref to Gauss-Jacobi instead of the fenics link?

Copy link
Member Author

Choose a reason for hiding this comment

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

I really struggle with finding the reference here. From what I understand it should be https://www.degruyter.com/document/doi/10.1515/crll.1826.1.301/html but the formula is slightly different ($w(x)=(x-1)^\alpha$?) from the formula I find in modern literature on ($w(x)=(x-1)^\alpha (x+1)^\beta$, e.g. https://epubs.siam.org/doi/pdf/10.1137/120889873).

Copy link
Member

Choose a reason for hiding this comment

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

But these are references for line intervals? Or do I miss something?

Seems like dunavant provides rules up to n=20. (https://onlinelibrary.wiley.com/doi/epdf/10.1002/nme.1620210612) (Although some are based on previous works, as noted on the bottom of page 1131).

Since higher than 7 were added in #514 and probably no one are saving quadrature data for such high orders, I think it could make sense to only use dunavant. But due to the different coordinate systems used in the papers and in the code, I find it hard to check where the points come from.
How did you check this to figure out that starting at n = 9 this is gauss_jacobi?

Copy link
Member Author

Choose a reason for hiding this comment

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

But these are references for line intervals? Or do I miss something?

Yes and from my understanding you make a tensor product over the barycentric space to obtain the rule, but this is where I really got stuck.

Seems like dunavant provides rules up to n=20. (https://onlinelibrary.wiley.com/doi/epdf/10.1002/nme.1620210612) (Although some are based on previous works, as noted on the bottom of page 1131).

Since higher than 7 were added in #514 and probably no one are saving quadrature data for such high orders, I think it could make sense to only use dunavant. But due to the different coordinate systems used in the papers and in the code, I find it hard to check where the points come from.
How did you check this to figure out that starting at n = 9 this is gauss_jacobi?

Git blame and the form of quadrature points is very different (9,10,11 did not match the Dunavant paper and from the referenced PR I concluded that these must be the mentioned Gauss-Jacobi rules from FEniCS).

docs/src/assets/references.bib Outdated Show resolved Hide resolved
src/Quadrature/quadrature.jl Outdated Show resolved Hide resolved
Comment on lines +115 to +116
elseif $dim == 3 && quad_type === :jinyun
data = _get_jinyun_tet_quadrature_data(order)
Copy link
Member

Choose a reason for hiding this comment

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

I think we should delete this option, since the current implementation is "keast" and we don't need to implement all possible quadrature rules. Of course, in the docs, we should acknowledge that keast orders 2 and 3 comes from jinyun.

Copy link
Member Author

Choose a reason for hiding this comment

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

I would leave it for reference, because for me it was not that straight forward to figure out how to get the rules for order 1..3 from the Keast paper. This way it is directly obvious.

Copy link
Member

Choose a reason for hiding this comment

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

IMO, we should make this clear from the docs rather than adding more complexity/options to the code.

src/Quadrature/quadrature.jl Outdated Show resolved Hide resolved
src/Quadrature/quadrature.jl Show resolved Hide resolved
Copy link
Member

@KnutAM KnutAM left a comment

Choose a reason for hiding this comment

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

Checked keast 5 and keast positive 4 as well. They look ok (didn't check all points of course).

I think adding a test that checks that the defaults are actually used would be good.

@KnutAM KnutAM added this to the v1.0.0 milestone Jul 15, 2024
@termi-official
Copy link
Member Author

I think adding a test that checks that the defaults are actually used would be good.

Should we do this separately, as I think we have not yet closed the discussion on the defaults?

@KnutAM
Copy link
Member

KnutAM commented Jul 30, 2024

Should we do this separately, as I think we have not yet closed the discussion on the defaults?

Can be done in a separate PR, but no need to wait until the defaults discussion is closed I'm thinking that such a test is just to ensure that we don't change by mistake, and changing the test makes it clear that it was intended.

@fredrikekre fredrikekre merged commit e1f662c into master Aug 5, 2024
11 checks passed
@fredrikekre fredrikekre deleted the do/tet-qr-reference branch August 5, 2024 23:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
awaiting review PR is finished from the authors POV, waiting for feedback
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants