Skip to content

Commit 429f5d3

Browse files
committed
Down to 590 allocations
1 parent 706c21f commit 429f5d3

1 file changed

Lines changed: 7 additions & 4 deletions

File tree

src/solver.jl

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,9 @@ Struct for storing the solution of the [solve!](@ref) function. Must contain all
1919
cl_array::Vector{Float64} = zeros(P)
2020
cd_array::Vector{Float64} = zeros(P)
2121
cm_array::Vector{Float64} = zeros(P)
22+
lift::Matrix{Float64} = zeros(P,1)
23+
drag::Matrix{Float64} = zeros(P,1)
24+
moment::Matrix{Float64} = zeros(P,1)
2225
gamma_distribution::Union{Nothing, Vector{Float64}} = nothing
2326
aero_force::MVec3 = zeros(MVec3)
2427
aero_moments::MVec3 = zeros(MVec3)
@@ -137,10 +140,10 @@ function solve!(solver::Solver, body_aero::BodyAerodynamics, gamma_distribution=
137140
panel_width_array[i] = panel.width
138141
end
139142

140-
# Pre-allocate output matrices
141-
lift = similar(cl_array, length(cl_array), 1)
142-
drag = similar(lift)
143-
moment = similar(lift)
143+
# create an alias for the three vertical output vectors
144+
lift = solver.sol.lift
145+
drag = solver.sol.drag
146+
moment = solver.sol.moment
144147

145148
# Compute using fused broadcasting (no intermediate allocations)
146149
@. lift = cl_array * 0.5 * density * v_a_array^2 * chord_array

0 commit comments

Comments
 (0)