Skip to content

Commit e0894de

Browse files
authored
Improve init!(body_aero) performance (#139)
* Rename panel distribution * Runs with less allocs * Tests pass * Low allocations on updating panels * Remove unimplemented keyword arguments * Non-allocating init pos * Reduce proj area allocs * Non-allocating proj area * Add reinit allocation tests * Fix test * Fix test * Really fix tests * Fix docs
1 parent e657a44 commit e0894de

23 files changed

+301
-378
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ alpha_deg = 30.0 # Angle of attack [degrees]
104104
alpha = deg2rad(alpha_deg)
105105

106106
# Step 2: Create wing geometry with linear panel distribution
107-
wing = Wing(n_panels, spanwise_panel_distribution=LINEAR)
107+
wing = Wing(n_panels, spanwise_distribution=LINEAR)
108108

109109
# Add wing sections - defining only tip sections with inviscid airfoil model
110110
add_section!(wing,

docs/src/examples.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ alpha = deg2rad(alpha_deg)
3737

3838
#### Step 3: Create wing geometry with linear panel distribution
3939
```julia
40-
wing = Wing(n_panels, spanwise_panel_distribution=LINEAR)
40+
wing = Wing(n_panels, spanwise_distribution=LINEAR)
4141
```
4242

4343
##### Add wing sections - defining only tip sections with inviscid airfoil model

docs/src/index.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ alpha_deg = 30.0 # Angle of attack [degrees]
102102
alpha = deg2rad(alpha_deg)
103103

104104
# Step 2: Create wing geometry with linear panel distribution
105-
wing = Wing(n_panels, spanwise_panel_distribution=LINEAR)
105+
wing = Wing(n_panels, spanwise_distribution=LINEAR)
106106

107107
# Add wing sections - defining only tip sections with inviscid airfoil model
108108
add_section!(wing,

docs/src/private_functions.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ CurrentModule = VortexStepMethod
55
## Private Functions
66
```@docs
77
calculate_AIC_matrices!
8-
calculate_panel_properties
8+
update_panel_properties!
99
calculate_inertia_tensor
1010
init!
1111
```

docs/src/types.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,11 +30,11 @@ A Wing/ RamAirWing has one or more sections.
3030
Section
3131
Section(LE_point::Vector{Float64}, TE_point::Vector{Float64}, aero_model=nothing, aero_data=nothing)
3232
Wing
33-
Wing(n_panels::Int; spanwise_panel_distribution::PanelDistribution=LINEAR,
33+
Wing(n_panels::Int; spanwise_distribution::PanelDistribution=LINEAR,
3434
spanwise_direction::PosVector=MVec3([0.0, 1.0, 0.0]))
3535
RamAirWing
3636
RamAirWing(obj_path, dat_path; alpha=0.0, crease_frac=0.75, wind_vel=10., mass=1.0,
37-
n_panels=54, n_sections=n_panels+1, spanwise_panel_distribution=UNCHANGED,
37+
n_panels=54, n_sections=n_panels+1, spanwise_distribution=UNCHANGED,
3838
spanwise_direction=[0.0, 1.0, 0.0])
3939
BodyAerodynamics
4040
```

examples/bench.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ alpha_deg = 30.0 # Angle of attack [degrees]
1919
alpha = deg2rad(alpha_deg)
2020

2121
# Step 2: Create wing geometry with linear panel distribution
22-
wing = Wing(n_panels, spanwise_panel_distribution=LINEAR)
22+
wing = Wing(n_panels, spanwise_distribution=LINEAR)
2323

2424
# Add wing sections - defining only tip sections with inviscid airfoil model
2525
add_section!(wing,

examples/ram_air_kite.jl

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,15 @@ using ControlPlots
22
using VortexStepMethod
33
using LinearAlgebra
44

5-
PLOT = true
5+
PLOT = false
66
USE_TEX = false
7-
DEFORM = false
7+
DEFORM = true
88

99
# Create wing geometry
1010
wing = RamAirWing("data/ram_air_kite_body.obj", "data/ram_air_kite_foil.dat")
1111
body_aero = BodyAerodynamics([wing];)
12+
println("First init")
13+
@time VortexStepMethod.init!(body_aero)
1214

1315
if DEFORM
1416
# Linear interpolation of alpha from 10° at one tip to 0° at the other
@@ -19,8 +21,10 @@ if DEFORM
1921
delta_end = deg2rad(0)
2022
theta_dist = [theta_start - i * (theta_start - theta_end)/(n_panels-1) for i in 0:(n_panels-1)]
2123
delta_dist = [delta_start - i * (delta_start - delta_end)/(n_panels-1) for i in 0:(n_panels-1)]
24+
println("Deform")
2225
@time VortexStepMethod.deform!(wing, theta_dist, delta_dist)
23-
@time VortexStepMethod.init!(body_aero)
26+
println("Deform init")
27+
@time VortexStepMethod.init!(body_aero; init_aero=false)
2428
end
2529

2630
# Create solvers
@@ -86,7 +90,7 @@ PLOT && plot_polars(
8690
angle_of_attack=0,
8791
side_slip=0,
8892
v_a=10,
89-
title="ram_kite_panels_$(wing.n_panels)_distribution_$(wing.spanwise_panel_distribution)",
93+
title="ram_kite_panels_$(wing.n_panels)_distribution_$(wing.spanwise_distribution)",
9094
data_type=".pdf",
9195
is_save=false,
9296
is_show=true,

examples/rectangular_wing.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ alpha_deg = 30.0 # Angle of attack [degrees]
1515
alpha = deg2rad(alpha_deg)
1616

1717
# Step 2: Create wing geometry with linear panel distribution
18-
wing = Wing(n_panels, spanwise_panel_distribution=LINEAR)
18+
wing = Wing(n_panels, spanwise_distribution=LINEAR)
1919

2020
# Add wing sections - defining only tip sections with inviscid airfoil model
2121
add_section!(wing,

examples/stall_model.jl

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ mkpath(save_folder)
1919

2020
# Defining discretisation
2121
n_panels = 54
22-
spanwise_panel_distribution = SPLIT_PROVIDED
22+
spanwise_distribution = SPLIT_PROVIDED
2323

2424
# Load rib data from CSV
2525
csv_file_path = joinpath(
@@ -38,7 +38,7 @@ for row in eachrow(df)
3838
end
3939

4040
# Create wing geometry
41-
CAD_wing = Wing(n_panels; spanwise_panel_distribution)
41+
CAD_wing = Wing(n_panels; spanwise_distribution)
4242
for rib in rib_list
4343
add_section!(CAD_wing, rib[1], rib[2], rib[3], rib[4])
4444
end
@@ -124,7 +124,7 @@ PLOT && plot_polars(
124124
angle_of_attack=0,
125125
side_slip=0,
126126
v_a=10,
127-
title="tutorial_testing_stall_model_n_panels_$(n_panels)_distribution_$(spanwise_panel_distribution)",
127+
title="tutorial_testing_stall_model_n_panels_$(n_panels)_distribution_$(spanwise_distribution)",
128128
data_type=".pdf",
129129
save_path=joinpath(save_folder, "polars"),
130130
is_save=true,

mwes/mwe_03.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ alpha_deg = 30.0 # Angle of attack [degrees]
1515
alpha = deg2rad(alpha_deg)
1616

1717
# Step 2: Create wing geometry with linear panel distribution
18-
wing = Wing(n_panels, spanwise_panel_distribution=LINEAR)
18+
wing = Wing(n_panels, spanwise_distribution=LINEAR)
1919

2020
# Add wing sections - defining only tip sections with inviscid airfoil model
2121
add_section!(wing,

0 commit comments

Comments
 (0)