make variants of functions computing in ref space#28
Conversation
|
fixes floating point error in #27 |
There was a problem hiding this comment.
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) acrossOrthogonalSpace,TensorProductSpace,VectorTensorProductSpace,DirectSum, andCompositeclasses - Refactored existing true-domain methods to call reference-domain variants after coordinate transformation, eliminating code duplication
- Updated
evaluate_jaxfunction_exprto 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.
|
@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? |
|
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. |
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:
mesh_referencemethods toComposite,OrthogonalSpace, andTensorProductSpaceclasses to generate meshes in the reference domain, and updated existingmeshmethods to use these as appropriate. [1] [2] [3] [4]evaluate_mesh,evaluate_derivative, etc.) to separate reference-domain and true-domain logic, introducing newevaluate_mesh_reference,evaluate_derivative_reference, and related methods. [1] [2] [3] [4] [5]Refactoring of Function Evaluation Logic:
evaluate_jaxfunction_exprand 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:
TensorProductSpacefor 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:
Bugfixes and Consistency Improvements:
These changes make the codebase more robust and easier to extend for future work involving multiple coordinate domains.