Why is the following code allocating:
using VortexStepMethod
# Step 1: Define wing parameters
n_panels = 20 # Number of panels
span = 20.0 # Wing span [m]
chord = 1.0 # Chord length [m]
v_a = 20.0 # Magnitude of inflow velocity [m/s]
density = 1.225 # Air density [kg/m³]
alpha_deg = 30.0 # Angle of attack [degrees]
alpha = deg2rad(alpha_deg)
# Step 2: Create wing geometry with linear panel distribution
wing = Wing(n_panels, spanwise_panel_distribution=LINEAR)
# Add wing sections - defining only tip sections with inviscid airfoil model
add_section!(wing,
[0.0, span/2, 0.0], # Left tip LE
[chord, span/2, 0.0], # Left tip TE
INVISCID)
add_section!(wing,
[0.0, -span/2, 0.0], # Right tip LE
[chord, -span/2, 0.0], # Right tip TE
INVISCID)
# Step 3: Initialize aerodynamics
body_aero::BodyAerodynamics = BodyAerodynamics([wing])
for panel in body_aero.panels end
@time for panel in body_aero.panels end
This gives me as output:
julia> @time for panel in body_aero.panels end
0.000012 seconds (20 allocations: 640 bytes)
It is the second execution of the same line of code, which is for panel in body_aero.panels end
. So I am not doing much, just iterating over all elements of a vector of Panel structs.
Iterating over a vector should not allocate, or what am I missing?