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

Add Vioreanu-Rokhlin quadratures #5

Merged
merged 11 commits into from
Oct 10, 2023
Merged

Add Vioreanu-Rokhlin quadratures #5

merged 11 commits into from
Oct 10, 2023

Conversation

tanderson92
Copy link
Member

@tanderson92 tanderson92 commented Oct 9, 2023

These quadratures are imported from a set of rules generated in accordance with the Vioreanu-Rokhlin 2014 SISC paper. The tables are by Gimbutas. They may or may not correspond to those in the "modepy" project.

TODO:

  • Tests currently fail because the order-9 and order-11 quadratures are subtly broken (??!) and don't exactly integrate the highest-order required polynomials. I will have to check if the alternative quadratures in 'modepy' do not suffer this problem, since it's possible that they re-generated the VR quadratures. (Interestingly, there is no `the' VR quadrature, there are various tables people have released following their methodology; VR never released a full set of nodes.)
  • Tetrahedron quadratures (will use modepy)
  • Expose the interpolation order of the associated quadratures in a good way

@tanderson92
Copy link
Member Author

I've added alternative quadratures for the problematic 9th and 11th order rules, taken from the `modepy' package and rescaled for our reference simplex. The quadratures are nearly identical and neither correctly integrate the polynomials as desired. Perhaps it is a numerical stability thing to do with our integrating on [0, 0], [0, 1], [1, 0] rather than over a domain symmetric about the origin?

Not much more I can do here other than reduce the expected accuracies in the tests for those quadratures so tests succeed. (Maybe we should avoid using those orders, too).

- Table 5.1 in Vioreanu-Rokhlin 2014 SISC is incorrect for three
  specific quadratures.
- Also, test all degrees i + j <= p, for both VR and Gauss.
@codecov
Copy link

codecov bot commented Oct 9, 2023

The author of this PR, tanderson92, is not an activated member of this organization on Codecov.
Please activate this user on Codecov to display this PR comment.
Coverage data is still being uploaded to Codecov.io for purposes of overall coverage calculations.
Please don't hesitate to email us at support@codecov.io with any questions.

Actual functionality is a TODO for reference_interpolation.jl.
Copy link
Member

@maltezfaria maltezfaria left a comment

Choose a reason for hiding this comment

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

I left some comments, but nothing major. Feel free to merge it with or without taking into account the comments.

src/quad_rules_tables.jl Show resolved Hide resolved
src/quad_rules_tables_tetrahedron.jl Outdated Show resolved Hide resolved
src/reference_integration.jl Outdated Show resolved Hide resolved
src/reference_integration.jl Outdated Show resolved Hide resolved
src/reference_integration.jl Show resolved Hide resolved
src/reference_integration.jl Show resolved Hide resolved
test/reference_integration_test.jl Show resolved Hide resolved
Comment on lines 55 to 71
@testset "Vioreanu-Rokhlin quad on triangle" begin
d = Inti.ReferenceTriangle()
# exact value for x^a*y^b integrate over reference triangle
exa = (a, b) -> factorial(a) * factorial(b) / factorial(a + b + 2)
# check all quadrature implemented
orders = keys(Inti.TRIANGLE_VR_ORDER_TO_NPTS)
for p in orders
q = Inti.VioreanuRokhlin(; domain=d, order=p)
x, w = q()
@test Inti.domain(q) == d
@test all(qnode ∈ d for qnode in x)
for i in 0:p, j in 0:p
i + j > p && continue
@test Inti.integrate(x -> x[1]^i * x[2]^j, q) ≈ exa(i, j)
end
end
end
Copy link
Member

Choose a reason for hiding this comment

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

Maybe we should also check the quadrature does not integrate monomials of order $p+1$? What do you think? If so, we should probably change the other tests as well.

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 don't think that that makes sense; it isn't a property of being a quadrature of order p that monomials of order p+1 are not integrated. Indeed sometimes due to symmetries some of the monomials of order p+1 are integrated, but not all.

Copy link
Member

Choose a reason for hiding this comment

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

If all monomials of order $p+1$ are integrated, then I would say the quadrature is of order (at least) $p+1$. Otherwise, the order function is ambiguous, since being of order $p$ implies being of order $p-1$. We really mean the maximum order after which things fail, and such a test would help to avoid bugs where we incorrectly coded the expected order given a set of points and weights.

Copy link
Member Author

Choose a reason for hiding this comment

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

Ok I have a commit that implements this. Funnily enough, Fejer is broken!

Copy link
Member Author

Choose a reason for hiding this comment

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

Other than Fejer this is good to go from me.

Copy link
Member

Choose a reason for hiding this comment

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

That is unfortunate. For some reason (symmetry?) Fejer is one order better for odd values of N. Should we fix this?

Copy link
Member

Choose a reason for hiding this comment

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

I can fix it, don't worry.

@maltezfaria
Copy link
Member

I just noticed this branch is failing on nighly. Usually not a big deal, but I wonder why...

@tanderson92
Copy link
Member Author

I just noticed this branch is failing on nighly. Usually not a big deal, but I wonder why...

I noticed this too but the logs don't indicate that it has anything to do with our changes. I blame julia nightly.

- FIXME: Fejer is broken!
@tanderson92 tanderson92 changed the title Add Vioreanu-Rokhlin interpolatory quadratures Add Vioreanu-Rokhlin quadratures Oct 10, 2023
@maltezfaria maltezfaria merged commit 6122361 into main Oct 10, 2023
5 checks passed
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