Repository navigation
Add Tensor product tau basis and fix Robin conditions - #70
Merged
Merged
Conversation
split_transient_terms ran sp.expand_trig on every time-dependent term, which also rewrote its spatial factors: cos(n*acos(x)) became its power-basis Chebyshev polynomial. A source built from K Chebyshev modes then separated into monomials x^j with O(K^2) scalar time terms, so compile time grew steeply with K (more than 10 minutes at K = 48), and the assembled source lost accuracy to cancellation, already from K ~ 20 in float32. The new separate_time_in_angles applies only the angle-addition formula to sin, cos, sinh and cosh whose argument mixes time with a non-number, and leaves every other factor as written. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…l matrices in intermediate steps of derivation
Contributor
There was a problem hiding this comment.
🟡 Changes recommended
The Heinrichs stencil produces incorrect basis coefficients, while keyword collisions and incomplete span checks cause Galerkin test-space construction to fail.
3 open issues
What changed in this PR
This PR extends tau test spaces to tensor and Cartesian products, enabling configurable test bases in the channel-flow solvers. It also corrects boundary-condition scaling and reduces memory use in test-space construction.
Changes:
- Propagate callable tau-basis definitions through space APIs and solver configuration.
- Correct Robin and weighted boundary scaling, revise lifting-space sizing, and use sparse PG/GR construction.
- Add the Heinrichs verification basis, improve transient-source handling and eigenvalue solving, and expand regression coverage.
| File | Description |
|---|---|
tests/integrators/test_integrator_skeleton.py |
Tests time separation without rewriting spatial modes. |
tests/galerkin/test_tau_testspaces.py |
Adapts tests to callable tau-basis definitions. |
tests/galerkin/test_inner_source.py |
Clarifies the angle-splitting comment. |
tests/galerkin/test_get_testspace.py |
Tests tau bases on product spaces. |
tests/galerkin/test_galerkin_recombined.py |
Adds a construction-memory regression test. |
tests/galerkin/test_composite.py |
Tests boundary scaling, lifting, and sparse stencils. |
src/jaxfun/typing.py |
Defines the shared TauBasis type. |
src/jaxfun/integrators/_utils.py |
Separates mixed time-space angles selectively. |
src/jaxfun/galerkin/tensorproductspace.py |
Passes tau bases to each axis. |
src/jaxfun/galerkin/orthogonal.py |
Accepts unused tau-basis arguments for compatibility. |
src/jaxfun/galerkin/Jacobi.py |
Aligns the test-space API with tau arguments. |
src/jaxfun/galerkin/functionspace.py |
Updates boundary-lifting construction. |
src/jaxfun/galerkin/composite.py |
Fixes boundary scaling and revises sparse test-space assembly. |
src/jaxfun/galerkin/Chebyshev.py |
Adds the Heinrichs verification space. |
src/jaxfun/galerkin/cartesianproductspace.py |
Passes tau bases to each component. |
sandbox/poisson2D_polygon.py |
Switches to an MLP space and adjusts training. |
examples/navierstokes/OrrSommerfeld_eigs.py |
Adds generalized and shift-invert eigenvalue solving. |
examples/navierstokes/3D/TurbulentChannel3D.py |
Applies configured tau-polynomial choices. |
examples/navierstokes/3D/OrrSommerfeld3D.py |
Uses the short GR enum alias. |
examples/navierstokes/3D/ChannelFlow3D.py |
Enables PG and configurable tau test spaces. |
examples/navierstokes/3D/channel_case.py |
Adds tau-polynomial configuration. |
examples/navierstokes/3D/cases/re180.toml |
Documents the tau-polynomial setting. |
examples/navierstokes/2D/OrrSommerfeld.py |
Exposes tau-polynomial selection. |
examples/navierstokes/2D/ChannelFlow2D.py |
Enables PG and configurable tau test spaces. |
examples/curvilinear/sphere_helmholtz.py |
Updates assembly, metric handling, and example parameters. |
Review effort: Balanced
Comment on lines
+1669
to
+1673
| i = np.setdiff1d(np.arange(S_pg.shape[0]), replaced) | ||
| a = np.arange(s + 1) | ||
| w = np.arange(s + t + 1) | ||
| B = _band_strip(S_trial, i, a, w) # (rows, s + 1, s + t + 1) | ||
| rows = _band_strip(S_pg, i, np.zeros(1, dtype=int), w)[:, 0, :] |
Member
Author
There was a problem hiding this comment.
Decided to not allow GR for Heinrichs, but now throwing a correct error message
mikaem
marked this pull request as ready for review
November 17, 2026 09:41
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

Summary
Tau test spaces (
TauRecombined) could not yet be used on tensor-product or Cartesian-product spaces, so the channel-flow solvers and the Orr–Sommerfeld eigenvalue solver could not choose a tau basis per problem. This PR threads atau_basisargument throughget_testspaceon every space type. It also adds aHeinrichsChebyshev space (for verification purpose) and fixes Robin and weighted boundary conditions on non-reference domains. The Petrov–Galerkin (PG) and Galerkin-recombined (GR) test-space construction now stays in sparse diagonal storage throughout.Types of Changes
Related Issues
Fixes #
Refs #
Description of Changes
Tau basis on product spaces
get_testspace(kind, tau_basis=...)is now accepted byOrthogonalSpace,Jacobi,Composite,TensorProductSpaceandCartesianBaseSpace.tau_basiscan be passed to a whole tensor product, and the axes with boundary conditions use it.TauBasistype alias in typing.py.TauRecombinednow takes each tau polynomial as(S, k).Sis a class or callable that builds an orthogonal space fromN, for exampleChebyshevUorpartial(Ultraspherical, lambda_=2).tau_basistherefore works for anyN.Boundary conditions
BoundaryConditionsnow converts Robin (R) and weighted (W) conditions from physical units to the reference domain, as it already did for Neumann. Before, they were wrong on any domain other than [-1, 1].nsimplify, so round-off terms don't make a regular stencil row look singular.R: u + alpha u' = value.BCGenericno longer takes a redundantN. It derives its size from the lifting basis.Sparse PG/GR construction (composite.py)
Stencil.matrix,PGComposite,GalerkinRecombinedand_replace_rowsno longer build dense(N, N)intermediates.New
Heinrichsspace in Chebyshev.py: a Dirichlet basisphi_k = 4(1 - x^2) T_k, with stencil{-2: -1, 0: 2, 2: -1}plus two overridden rows. Used only for verification.Examples
ChannelFlow2D,ChannelFlow3D,TurbulentChannel3Dand the channel case config can select the test-space kind and tau basis.OrrSommerfeld,OrrSommerfeld3DandOrrSommerfeld_eigsare updated to match.sphere_helmholtzis updated for the changed API.Screenshots / Logs (if applicable)
N/A
Breaking Changes
Yes (describe below)
No
BCGeneric(N, orthogonal, bcs, ...)becomesBCGeneric(orthogonal, bcs, ...). Remove the leadingN.Robin and weighted conditions passed as a dict on a non-reference domain now give different (correct) results. Pass a
BoundaryConditionsinstance to keep values that are already in reference units.TauRecombinedtau_basisentries must be a class or callable that builds a space fromN, not an instantiated space.Checklist
pre-commit run --all-files)uv run pytest)Additional Notes
test_composite.py,test_galerkin_recombined.py,test_get_testspace.pyandtest_tau_testspaces.py.