Split calc_forces! out of solve! and make it zero-alloc#245
Open
1-Bart-1 wants to merge 2 commits into
Open
Conversation
Extract the force/moment assembly (everything after the circulation solve) from solve! into a standalone exported calc_forces!(solver, body_aero). solve! is now solve_base! + calc_forces!; behavior is unchanged. This lets a frozen circulation be mapped to forces without re-running the nonlinear gamma solve. Make calc_forces! allocation-free for the per-step hot path: - preallocate panel_area_dist buffer (was zeros(T, n) each call) - preallocate unrefined_count_dist buffer (was zeros(Int, n) each call) - rewrite _compute_reference_velocity_from_distribution to drop its ones()/T.() copies Add a function-barrier zero-alloc test for calc_forces!. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Codecov Report❌ Patch coverage is
📢 Thoughts on this report? Let us know! |
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.
What
Extract the force/moment assembly (everything after the circulation solve) from
solve!into a standalone exportedcalc_forces!(solver, body_aero).solve!is nowsolve_base!+calc_forces!, with behavior unchanged.This creates a clean seam: a frozen circulation can be mapped to forces via
calc_forces!without re-running the nonlinear gamma solve. It's the backend kernel for an upcominggeometry → forcesaero interface in SymbolicAWEModels.jl.Zero-alloc
calc_forces!is the per-step hot path, so it's now allocation-free:panel_area_distbuffer (waszeros(T, n)each call)unrefined_count_distbuffer (waszeros(Int, n)each call)_compute_reference_velocity_from_distributionto drop itsones()/T.()copiesAdded a function-barrier zero-alloc test for
calc_forces!.Verification
Full solver suite green, behavior-preserving:
calc_forces!is zero-alloc 1/1norm_fwd ≈ norm_fd)🤖 Generated with Claude Code