Skip to content

Move from GaussQuadrature.jl to FastGaussQuadrature.jl #2261

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

Draft
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

sriharshakandala
Copy link
Member

Move from using GaussQuadrature to FastGaussQuadrature.jl

  • Code follows the style guidelines OR N/A.
  • Unit tests are included OR N/A.
  • Code is exercised in an integration test OR N/A.
  • Documentation has been added/updated OR N/A.

Copy link

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Hello @sriharshakandala, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

Summary of Changes

This pull request migrates the codebase from using the GaussQuadrature package to FastGaussQuadrature.jl. This involves updating the Project.toml file to remove the dependency on GaussQuadrature and add a dependency on FastGaussQuadrature, as well as modifying the Quadratures.jl file to use the functions from FastGaussQuadrature for calculating quadrature points and weights. The orthonormal_poly function is also commented out.

Highlights

  • Dependency Update: Replaces GaussQuadrature with FastGaussQuadrature.jl in the project dependencies.
  • Code Modernization: Updates the Quadratures.jl file to utilize FastGaussQuadrature for Gauss-Legendre and Gauss-Legendre-Lobatto quadrature calculations.
  • Functionality Change: Comments out the orthonormal_poly function and related code in Quadratures.jl.

Changelog

  • Project.toml
    • Removed GaussQuadrature as a dependency.
    • Added FastGaussQuadrature as a dependency.
    • Updated versions of CubedSphere, DataStructures, FastBroadcast, ForwardDiff, HDF5
  • src/Quadratures/Quadratures.jl
    • Replaced import GaussQuadrature with import FastGaussQuadrature.
    • Modified quadrature_points function for GLL to use FastGaussQuadrature.gausslobatto (line 66).
    • Modified quadrature_points function for GL to use FastGaussQuadrature.gausslegendre (line 82).
    • Commented out the orthonormal_poly function and related code (lines 225-252).
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point in your pull request via creating an issue comment (i.e. comment on the pull request page) using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in issue comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist is currently in preview and may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments to provide feedback.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.


Trivia time!

What is the origin of the term 'quadrature' in mathematics?

Click here for the answer
The term 'quadrature' comes from the problem of 'squaring' a shape, i.e., finding a square with the same area as the given shape. In numerical analysis, it refers to the numerical approximation of definite integrals.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request replaces the GaussQuadrature package with FastGaussQuadrature.jl. The changes look good overall, and the code is clear. Here are a few suggestions for improvement.

Summary of Findings

  • Documentation URL: Consider adding a brief explanation of why the linked mathworld.wolfram.com URL is relevant to the code.
  • Uncommented Code: The commented out code block should be removed, as it's no longer used.

Merge Readiness

The code changes are well-structured and the migration from GaussQuadrature to FastGaussQuadrature.jl seems to be implemented correctly. I recommend addressing the review comments before merging. I am unable to directly approve this pull request, and recommend that others review and approve this code before merging.

Comment on lines 65 to +67
@generated function quadrature_points(::Type{FT}, ::GLL{Nq}) where {FT, Nq}
points, weights = GaussQuadrature.legendre(FT, Nq, GaussQuadrature.both)
:($(SVector{Nq}(points)), $(SVector{Nq}(weights)))
points, weights = FastGaussQuadrature.gausslobatto(Nq)
:($(SVector{Nq, FT}(points)), $(SVector{Nq, FT}(weights)))

Choose a reason for hiding this comment

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

medium

It's good that you're specifying the floating point type FT in the SVector constructor. This ensures type stability and avoids potential performance issues. However, the gausslobatto function from FastGaussQuadrature already returns points and weights of type Float64. You may want to consider converting the output of gausslobatto to FT directly to avoid potential type mismatches or unexpected behavior.

Comment on lines 81 to +83
@generated function quadrature_points(::Type{FT}, ::GL{Nq}) where {FT, Nq}
points, weights = GaussQuadrature.legendre(FT, Nq, GaussQuadrature.neither)
:($(SVector{Nq}(points)), $(SVector{Nq}(weights)))
points, weights = FastGaussQuadrature.gausslegendre(Nq)
:($(SVector{Nq, FT}(points)), $(SVector{Nq, FT}(weights)))

Choose a reason for hiding this comment

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

medium

Similar to the GLL quadrature, it's good that you're specifying the floating point type FT in the SVector constructor. This ensures type stability and avoids potential performance issues. However, the gausslegendre function from FastGaussQuadrature already returns points and weights of type Float64. You may want to consider converting the output of gausslegendre to FT directly to avoid potential type mismatches or unexpected behavior.

@sriharshakandala
Copy link
Member Author

sriharshakandala commented Mar 28, 2025

@szy21 , @akshaysridhar : Please advise if we are currently using the functions orthonormal_poly and spectral_filter_matrix in ClimaCore.jl!

@sriharshakandala sriharshakandala changed the title Move from using GaussQuadrature to FastGaussQuadrature.jl Move from GaussQuadrature.jl to FastGaussQuadrature.jl Mar 28, 2025
@sriharshakandala sriharshakandala force-pushed the sk/move_to_fastgaussquadrature branch from 4b4c349 to ce7e6de Compare March 28, 2025 20:37
@Sbozzolo
Copy link
Member

@szy21 , @akshaysridhar : Please advise if we are currently using the functions orthonormal_poly and spectral_filter_matrix in ClimaCore.jl!

cutoff_filter_matrix calls spectral_filter_matrix and is currently used in the bickleyjet_dg example. As far as I can tell (with grep), that's the only occurence.

@sriharshakandala
Copy link
Member Author

sriharshakandala commented Mar 28, 2025

@szy21 , @akshaysridhar : Please advise if we are currently using the functions orthonormal_poly and spectral_filter_matrix in ClimaCore.jl!

cutoff_filter_matrix calls spectral_filter_matrix and is currently used in the bickleyjet_dg example. As far as I can tell (with grep), that's the only occurence.

Yes. To be specific, do we need these functions in the future or can we remove them (the functions and the bickleyjet_dg example)!

@sriharshakandala sriharshakandala force-pushed the sk/move_to_fastgaussquadrature branch from ce7e6de to f30209b Compare March 28, 2025 20:58
@sriharshakandala sriharshakandala force-pushed the sk/move_to_fastgaussquadrature branch from f30209b to af7fbac Compare March 28, 2025 21:45
@sriharshakandala
Copy link
Member Author

sriharshakandala commented Mar 28, 2025

@Sbozzolo : Do we need to build the benchmarks and lib/ClimaCoreTempestRemap projects in the pipeline here: https://github.com/CliMA/ClimaCore.jl/blob/main/.buildkite/pipeline.yml#L34 ?
We do not seem to be using them! cc: @nefrathenrici

@Sbozzolo
Copy link
Member

@Sbozzolo : Do we need to build the benchmarks and lib/ClimaCoreTempestRemap projects in the pipeline here: https://github.com/CliMA/ClimaCore.jl/blob/main/.buildkite/pipeline.yml#L34 ? We do not seem to be using them! cc: @nefrathenrici

Good catch! We don't need them!

`lib/ClimaCoreTempestRemap` projects from the Buildkite pipeline.
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