Skip to content

Commit 7e42124

Browse files
authored
add enum PanelDistribution (#71)
* add comment * add enum PanelDistribution * add enum PanelDistribution * update examples * update docu * fix typos * export enum --------- Co-authored-by: Uwe Fechner <[email protected]>
1 parent a62f903 commit 7e42124

File tree

12 files changed

+59
-43
lines changed

12 files changed

+59
-43
lines changed

docs/src/types.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ CurrentModule = VortexStepMethod
44
## Enumerations
55
```@docs
66
Model
7+
PanelDistribution
78
```
89

910
## Basic Vectors

examples/rectangular_wing.jl

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

1616
# Step 2: Create wing geometry with linear panel distribution
17-
wing = Wing(n_panels, spanwise_panel_distribution=:linear)
17+
wing = Wing(n_panels, spanwise_panel_distribution=LINEAR)
1818

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

examples/stall_model.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ mkpath(save_folder)
1717

1818
# Defining discretisation
1919
n_panels = 54
20-
spanwise_panel_distribution = :split_provided
20+
spanwise_panel_distribution = SPLIT_PROVIDED
2121

2222
# Load rib data from CSV
2323
csv_file_path = joinpath(

src/VortexStepMethod.jl

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ export calculate_span, calculate_projected_area
2525
export plot_wing, plot_circulation_distribution, plot_geometry, plot_distribution, plot_polars
2626
export show_plot, save_plot, menu
2727
export Model, VSM, LLT
28+
export PanelDistribution, LINEAR, COSINE, COSINE_VAN_GARREL, SPLIT_PROVIDED, UNCHANGED
2829

2930
"""
3031
const MVec3 = MVector{3, Float64}
@@ -58,6 +59,26 @@ Enumeration of the implemented model types.
5859
"""
5960
@enum Model VSM LLT
6061

62+
"""
63+
PanelDistribution `LINEAR` `COSINE` `COSINE_VAN_GARREL` `SPLIT_PROVIDED` `UNCHANGED`
64+
65+
Enumeration of the implemented model types.
66+
67+
# Elements
68+
- LINEAR # Linear distribution
69+
- COSINE # Cosine distribution
70+
- `COSINE_VAN_GARREL` # van Garrel cosine distribution
71+
- `SPLIT_PROVIDED` # Split provided sections
72+
- UNCHANGED # Keep original sections
73+
"""
74+
@enum PanelDistribution begin
75+
LINEAR # Linear distribution
76+
COSINE # Cosine distribution
77+
COSINE_VAN_GARREL # van Garrel cosine distribution
78+
SPLIT_PROVIDED # Split provided sections
79+
UNCHANGED # Keep original sections
80+
end
81+
6182
abstract type AbstractWing end
6283

6384
function menu()

src/kite_geometry.jl

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -176,7 +176,7 @@ Represents a curved wing that inherits from Wing with additional geometric prope
176176
# Fields
177177
- All fields from Wing:
178178
- `n_panels::Int`: Number of panels in aerodynamic mesh
179-
- `spanwise_panel_distribution::Symbol`: Panel distribution type
179+
- `spanwise_panel_distribution`::PanelDistribution
180180
- `spanwise_direction::MVec3`: Wing span direction vector
181181
- `sections::Vector{Section}`: List of wing sections
182182
- Additional fields:
@@ -189,7 +189,7 @@ Same as Wing
189189
"""
190190
mutable struct KiteWing <: AbstractWing
191191
n_panels::Int64
192-
spanwise_panel_distribution::Symbol
192+
spanwise_panel_distribution::PanelDistribution
193193
spanwise_direction::MVec3
194194
sections::Vector{Section}
195195

@@ -205,7 +205,7 @@ mutable struct KiteWing <: AbstractWing
205205
area_interp::Extrapolation
206206

207207
function KiteWing(obj_path, dat_path; alpha=0.0, n_sections=20, crease_frac=0.75, wind_vel=10., mass=1.0,
208-
n_panels=54, spanwise_panel_distribution=:linear, spanwise_direction=[0.0, 1.0, 0.0])
208+
n_panels=54, spanwise_panel_distribution=LINEAR, spanwise_direction=[0.0, 1.0, 0.0])
209209

210210
!isapprox(spanwise_direction, [0.0, 1.0, 0.0]) && @error "Spanwise direction has to be [0.0, 1.0, 0.0]"
211211

src/solver.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ struct Solver
4747
aerodynamic_model_type::Model = VSM,
4848
density::Float64 = 1.225,
4949
max_iterations::Int64 = 1500,
50-
allowed_error::Float64 = 1e-5,
50+
allowed_error::Float64 = 1e-5, # rel_err
5151
tol_reference_error::Float64 = 0.001,
5252
relaxation_factor::Float64 = 0.03,
5353
is_with_artificial_damping::Bool = false,

src/wing_geometry.jl

Lines changed: 12 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -30,25 +30,19 @@ Represents a wing composed of multiple sections with aerodynamic properties.
3030
3131
# Fields
3232
- `n_panels::Int64`: Number of panels in aerodynamic mesh
33-
- `spanwise_panel_distribution::Symbol`: Panel distribution type
33+
- `spanwise_panel_distribution`::PanelDistribution: [PanelDistribution](@ref)
3434
- `spanwise_direction::Vector{Float64}`: Wing span direction vector
3535
- `sections::Vector{Section}`: List of wing sections
3636
37-
# Distribution types
38-
- :linear: Linear distribution
39-
- :cosine: Cosine distribution
40-
- :`cosine_van_Garrel`: van Garrel cosine distribution
41-
- :split_provided: Split provided sections
42-
- :unchanged: Keep original sections
4337
"""
4438
mutable struct Wing <: AbstractWing
4539
n_panels::Int64
46-
spanwise_panel_distribution::Symbol
40+
spanwise_panel_distribution::PanelDistribution
4741
spanwise_direction::PosVector
4842
sections::Vector{Section}
4943

5044
function Wing(n_panels::Int;
51-
spanwise_panel_distribution::Symbol=:linear,
45+
spanwise_panel_distribution::PanelDistribution=LINEAR,
5246
spanwise_direction::PosVector=MVec3([0.0, 1.0, 0.0]))
5347
new(n_panels,
5448
spanwise_panel_distribution,
@@ -132,7 +126,7 @@ function refine_aerodynamic_mesh(wing::AbstractWing)
132126
end
133127

134128
# Handle special cases
135-
if wing.spanwise_panel_distribution === :unchanged || length(wing.sections) == n_sections
129+
if wing.spanwise_panel_distribution == UNCHANGED || length(wing.sections) == n_sections
136130
return wing.sections
137131
end
138132

@@ -145,9 +139,9 @@ function refine_aerodynamic_mesh(wing::AbstractWing)
145139
end
146140

147141
# Handle different distribution types
148-
if wing.spanwise_panel_distribution === :split_provided
142+
if wing.spanwise_panel_distribution == SPLIT_PROVIDED
149143
return refine_mesh_by_splitting_provided_sections(wing)
150-
elseif wing.spanwise_panel_distribution in [:linear, :cosine, :cosine_van_Garrel]
144+
elseif wing.spanwise_panel_distribution in (LINEAR, COSINE, COSINE_VAN_GARREL)
151145
return refine_mesh_for_linear_cosine_distribution(
152146
wing.spanwise_panel_distribution,
153147
n_sections,
@@ -239,7 +233,7 @@ end
239233

240234
"""
241235
refine_mesh_for_linear_cosine_distribution(
242-
spanwise_panel_distribution::Symbol,
236+
spanwise_panel_distribution::PanelDistribution,
243237
n_sections::Int,
244238
LE::Matrix{Float64},
245239
TE::Matrix{Float64},
@@ -248,7 +242,7 @@ end
248242
Refine wing mesh using linear or cosine spacing.
249243
250244
# Arguments
251-
- `spanwise_panel_distribution`: Distribution type (:linear, :cosine, or :cosine_van_Garrel)
245+
- `spanwise_panel_distribution`: [PanelDistribution](@ref)
252246
- `n_sections`: Number of sections to generate
253247
- `LE`: Matrix of leading edge points
254248
- `TE`: Matrix of trailing edge points
@@ -258,7 +252,7 @@ Returns:
258252
Vector{Section}: List of refined sections
259253
"""
260254
function refine_mesh_for_linear_cosine_distribution(
261-
spanwise_panel_distribution::Symbol,
255+
spanwise_panel_distribution::PanelDistribution,
262256
n_sections::Int,
263257
LE,
264258
TE,
@@ -273,9 +267,9 @@ function refine_mesh_for_linear_cosine_distribution(
273267
qc_cum_length = vcat(0, cumsum(qc_lengths))
274268

275269
# 2. Define target lengths
276-
target_lengths = if spanwise_panel_distribution === :linear
270+
target_lengths = if spanwise_panel_distribution == LINEAR
277271
range(0, qc_total_length, n_sections)
278-
elseif spanwise_panel_distribution in [:cosine, :cosine_van_Garrel]
272+
elseif spanwise_panel_distribution in (COSINE, COSINE_VAN_GARREL)
279273
theta = range(0, π, n_sections)
280274
qc_total_length .* (1 .- cos.(theta)) ./ 2
281275
else
@@ -464,7 +458,7 @@ function refine_mesh_by_splitting_provided_sections(wing::AbstractWing)
464458

465459
# Generate sections for this pair
466460
new_splitted_sections = refine_mesh_for_linear_cosine_distribution(
467-
:linear,
461+
LINEAR,
468462
num_new_sections + 2, # +2 for endpoints
469463
LE_pair,
470464
TE_pair,

test/bench.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ using LinearAlgebra
2323
alpha_deg = 30.0 # Angle of attack [degrees]
2424
alpha = deg2rad(alpha_deg)
2525

26-
wing = Wing(n_panels, spanwise_panel_distribution=:linear)
26+
wing = Wing(n_panels, spanwise_panel_distribution=LINEAR)
2727
add_section!(wing,
2828
[0.0, span/2, 0.0], # Left tip LE
2929
[chord, span/2, 0.0], # Left tip TE

test/test_body_aerodynamics.jl

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ include("utils.jl")
2323
core_radius_fraction = 1e-20
2424
coord = generate_coordinates_el_wing(max_chord, span, N, dist)
2525
coord_left_to_right = flip_created_coord_in_pairs(deepcopy(coord))
26-
wing = Wing(N; spanwise_panel_distribution=:unchanged)
26+
wing = Wing(N; spanwise_panel_distribution=UNCHANGED)
2727
for idx in 1:2:length(coord_left_to_right[:, 1])
2828
@debug "coord_left_to_right[$idx] = $(coord_left_to_right[idx,:])"
2929
add_section!(
@@ -124,7 +124,7 @@ end
124124
# Create wing geometry
125125
core_radius_fraction = 1e-20
126126
coord_left_to_right = flip_created_coord_in_pairs(deepcopy(coord))
127-
wing = Wing(n_panels; spanwise_panel_distribution=:unchanged)
127+
wing = Wing(n_panels; spanwise_panel_distribution=UNCHANGED)
128128
for idx in 1:2:size(coord_left_to_right, 1)
129129
add_section!(
130130
wing,
@@ -242,7 +242,7 @@ end
242242
end
243243

244244
coord_left_to_right = flip_created_coord_in_pairs(deepcopy(coord))
245-
wing = Wing(N; spanwise_panel_distribution=:unchanged)
245+
wing = Wing(N; spanwise_panel_distribution=UNCHANGED)
246246
for i in 1:2:size(coord_left_to_right, 1)
247247
add_section!(
248248
wing,

test/test_kite_geometry.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,7 @@ using Serialization
141141
wing = KiteWing(test_obj_path, test_dat_path)
142142

143143
@test wing.n_panels == 54 # Default value
144-
@test wing.spanwise_panel_distribution === :linear
144+
@test wing.spanwise_panel_distribution == LINEAR
145145
@test wing.spanwise_direction [0.0, 1.0, 0.0]
146146
@test length(wing.sections) > 0 # Should have sections now
147147
@test wing.mass 1.0

0 commit comments

Comments
 (0)