Repository navigation
Faster setup of the Hiptmair-Xu preconditioner (TAE example): exact stiffness diagonal, preconditioners built in the setup - #796
Merged
Merged
Conversation
…onMatrix LocalProjectionMatrix called the component functions 18 times (twice per entry), LocalRotationMatrix 6 times; equilibrium callables are expensive (weights eval for M2para_Bn: 1 s/rank in the TAE test run). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The diagonal scaling of StiffnessPreconditioner probed the core operator with colored unit vectors (about 160 colors per block, each a full operator application). _stiffness_local_diagonal computes it from the band of the mid mass matrix and the 1d factors of the derivative (rows owned by the neighbouring process via ghost regions); probing remains the fallback for matrix-free mass operators. TAE --test-run (ShearAlfvenCurlCurl, 2 ranks): HX build 3.8 s -> 0.5 s, same PCG iterations. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
… if needed
mass_mid_default = M{k+1} was assembled even when mid is given (e.g. mid='M2gyro' in the Hiptmair-Xu
smoother assembled M2, 0.17 s/rank in the TAE test run); the domain check uses the coefficient space.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…epare_time_step) New optional hook Propagator.prepare_time_step(dt), called by Simulation.run after allocate (profiling region 'setup: prepare time step') with the dt each propagator receives in integrate (dt/2 for all but the last one with Strang). ShearAlfvenCurlCurlPropagator builds Hiptmair-Xu there and ShearAlfvenPropagator its multigrid / Kronecker preconditioner, instead of in the first time step; __call__ still rebuilds them when dt changes. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…_propagators Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
spossann
enabled auto-merge (squash)
October 19, 2026 15:11
spossann
disabled auto-merge
October 19, 2026 15:12
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.
Shortens the setup of the ITPA TAE example with
ShearAlfvenCurlCurl(Hiptmair-Xu preconditioner). Bottlenecks were found with scope-profiler regions in the HX setup (first two commits).TAE
--test-run, 2 ranks, one time step: profiled session per rank 7.6 s → 3.0 s; HX build 3.8 s → 0.5 s, same PCG iterations.Changes
LocalProjectionMatrix/LocalRotationMatrixevaluate each component once (were 18× / 6×). Weight evaluation ofM2para_Bn: 0.97 → 0.18 s/rank._stiffness_local_diagonalinfeec/preconditioner.py), used for the diagonal scaling ofStiffnessPreconditioner, instead of probing with colored unit vectors (about 160 colors per block, each a full operator application). It is read from the band of the mid mass matrix and the 1d factors of the derivative; rows owned by the neighbouring process come from ghost regions, and band entries wrapping around in short periodic directions are summed. Probing remains the fallback for matrix-free mass operators. Without diagonal scaling HX needs 10–25 % more iterations (6 vs 8 at dt = 0.1, 24 vs 26 at dt = 1), so the scaling is kept.StiffnessPreconditionerresolves the default midM{k+1}only ifmidis not given (the HX smoother no longer assembles M2).Propagator.prepare_time_step(dt), called bySimulation.runafterallocate(profiling regionsetup: prepare time step) with the dt each propagator gets fromintegrate(dt/2 for all but the last with Strang).ShearAlfvenCurlCurlPropagatorbuilds HX there andShearAlfvenPropagatorits multigrid / Kronecker preconditioner, instead of in the first time step.__call__still rebuilds when dt changes.Tests
test_stiffness_local_diagonal: exact vs probed diagonal for grad/curl/div on a HollowTorus, a sum of mass terms, Dirichlet bcs and short periodic directions with p = 3.test_prepare_time_step: HX is built ahead of time, reused for the same dt and rebuilt for a new one.Not included: assembling
M2gyroin one pass instead ofM2_Bn - M2para_Bn. Mass matrix assembly (about 1.2 s/rank) is now the largest remaining setup cost.🤖 Generated with Claude Code