Skip to content

make variants of functions computing in ref space#28

Draft
augustfe wants to merge 5 commits intomainfrom
computations-in-reference-domain
Draft

make variants of functions computing in ref space#28
augustfe wants to merge 5 commits intomainfrom
computations-in-reference-domain

Conversation

@augustfe
Copy link
Collaborator

This pull request refactors the mesh evaluation and derivative methods across the Galerkin module to consistently distinguish between true-domain and reference-domain coordinates. It introduces new methods for reference-domain operations, updates existing methods to use these, and ensures that mesh generation and function evaluation are explicit about the domain being used. This improves clarity, correctness, and maintainability, especially for multidomain and tensor-product spaces.

Key changes include:

Consistent Reference vs. True Domain Handling:

  • Added mesh_reference methods to Composite, OrthogonalSpace, and TensorProductSpace classes to generate meshes in the reference domain, and updated existing mesh methods to use these as appropriate. [1] [2] [3] [4]
  • Refactored evaluation methods (evaluate_mesh, evaluate_derivative, etc.) to separate reference-domain and true-domain logic, introducing new evaluate_mesh_reference, evaluate_derivative_reference, and related methods. [1] [2] [3] [4] [5]

Refactoring of Function Evaluation Logic:

  • Updated evaluate_jaxfunction_expr and its usages to consistently use reference-domain coordinates (Xj) instead of true-domain coordinates (xj), and adjusted logic for evaluating derivatives and function values accordingly. [1] [2] [3] [4] [5] [6] [7] [8] [9] [10]

Tensor Product Space Enhancements:

  • Added new methods to TensorProductSpace for evaluating functions and derivatives on reference-domain meshes, and refactored existing methods to call these, ensuring a clear separation between reference and true domain operations. [1] [2] [3] [4] [5]

API and Documentation Updates:

  • Updated docstrings and argument names throughout to clarify the distinction between reference and true domain, and to document the new methods. [1] [2] [3] [4]

Bugfixes and Consistency Improvements:

  • Fixed several places where the wrong domain was used for mesh generation or evaluation, ensuring correctness in quadrature and function application. [1] [2] [3] [4] [5] [6] [7]

These changes make the codebase more robust and easier to extend for future work involving multiple coordinate domains.

@augustfe augustfe requested review from Copilot and mikaem February 27, 2026 14:36
@augustfe
Copy link
Collaborator Author

augustfe commented Feb 27, 2026

fixes floating point error in #27
Test jaxfun

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This pull request refactors the mesh evaluation and derivative computation methods throughout the Galerkin module to establish a clear and consistent distinction between reference-domain and true-domain coordinate systems. The changes introduce new *_reference methods that operate directly in the reference domain, while existing methods are updated to delegate to these after performing appropriate domain transformations.

Changes:

  • Introduced reference-domain methods (mesh_reference, evaluate_mesh_reference, evaluate_derivative_reference, evaluate_reference) across OrthogonalSpace, TensorProductSpace, VectorTensorProductSpace, DirectSum, and Composite classes
  • Refactored existing true-domain methods to call reference-domain variants after coordinate transformation, eliminating code duplication
  • Updated evaluate_jaxfunction_expr to consistently work with reference-domain coordinates, simplifying the logic and reducing coordinate transformation overhead

Reviewed changes

Copilot reviewed 6 out of 6 changed files in this pull request and generated no comments.

Show a summary per file
File Description
tests/galerkin/test_arguments_extras.py Adds comprehensive tests for evaluate_jaxfunction_expr with reference-domain coordinates in 1D and tensor product spaces, including function values, powers, and derivatives
src/jaxfun/galerkin/tensorproductspace.py Introduces mesh_reference, evaluate_mesh_reference, evaluate_reference, and evaluate_derivative_reference methods; refactors existing methods to delegate; adds proper vector evaluation methods to VectorTensorProductSpace; updates DirectSum evaluation methods
src/jaxfun/galerkin/orthogonal.py Adds mesh_reference and evaluate_derivative_reference methods; updates backward method to use reference-domain mesh
src/jaxfun/galerkin/inner.py Updates all calls to evaluate_jaxfunction_expr to pass reference-domain coordinates; renames variables from xj to Xj to indicate reference domain
src/jaxfun/galerkin/composite.py Adds mesh_reference and evaluate_derivative_reference methods to DirectSum class
src/jaxfun/galerkin/arguments.py Refactors evaluate_jaxfunction_expr to work consistently with reference-domain coordinates, simplifying the logic and eliminating redundant coordinate transformations

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@augustfe
Copy link
Collaborator Author

augustfe commented Mar 2, 2026

@mikaem I like the general idea of exposing the reference domain methods, however it feels a bit messy as done here. What do you think?

@mikaem
Copy link
Member

mikaem commented Mar 2, 2026

It's a bit messy. In general only the methods exposed to the public should use physical coordinates. That is evaluate, evaluate_mesh and evaluate_derivative. I don' think these should ever be called on a reference domain, only the true. So I don't really see a dire need for the reference versions, like evaluate_mesh_reference.

It's important to be consistent, though, and right now evaluate is defined for reference X on 1D spaces. That may need to be reconsidered? Perhaps we need evaluate and _evaluate_reference for 1D spaces? The tensorproductspaces just calls these 1D methods, so that's why I don't think we need both evaluate and evaluate_reference for tensors.

Base automatically changed from jaxfunction-mapped-domain to main March 3, 2026 12:30
@augustfe augustfe marked this pull request as draft March 3, 2026 12:30
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.

3 participants