Skip to content

Commit 3b3c29c

Browse files
authored
Merge pull request #9 from Albatross-Kite-Transport/refactor1
Add types MVec3, PosVector, VelVector
2 parents 37efd5f + 555bffe commit 3b3c29c

File tree

7 files changed

+44
-27
lines changed

7 files changed

+44
-27
lines changed

Project.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,5 +12,6 @@ LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e"
1212
Logging = "56ddb016-857b-54e1-b83d-db4d58db5568"
1313
Measures = "442fdcdd-2543-5da2-b0f3-8c86c306513e"
1414
Plots = "91a5bcdd-55d7-5caf-9e0b-520d859cae80"
15+
StaticArrays = "90137ffa-7385-5640-81b9-e52037218182"
1516
Statistics = "10745b16-79ce-11e8-11f9-7d13ad32a3b2"
1617
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"

src/VortexStepMethod.jl

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
module VortexStepMethod
22

33
using LinearAlgebra
4+
using StaticArrays
45
using Logging
56
using Statistics
67
using Colors
@@ -18,6 +19,21 @@ export add_section!, set_va!
1819
export calculate_span, calculate_projected_area
1920
export plot_wing, plot_circulation_distribution, plot_geometry, plot_distribution, plot_polars
2021

22+
"""
23+
const MVec3 = MVector{3, Float64}
24+
25+
Basic 3-dimensional vector, stack allocated, mutable.
26+
"""
27+
const MVec3 = MVector{3, Float64}
28+
29+
"""
30+
const PosVector=Union{MVec3, Vector}
31+
32+
Position vector, either a `MVec3` or a `Vector` for use in function signatures.
33+
"""
34+
const PosVector=Union{MVec3, Vector}
35+
const VelVector=Union{MVec3, Vector}
36+
2137
# Include core functionality
2238
include("wing_geometry.jl")
2339
include("filament.jl")

src/filament.jl

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ struct BoundFilament <: Filament
1919
length::Float64 # Filament length
2020
r0::Vector{Float64} # Vector from x1 to x2
2121

22-
function BoundFilament(x1::Vector{Float64}, x2::Vector{Float64})
22+
function BoundFilament(x1::PosVector, x2::PosVector)
2323
new(x1, x2, norm(x2 - x1), x2 - x1)
2424
end
2525
end
@@ -31,9 +31,9 @@ end
3131
Calculate induced velocity by a bound vortex filament at a point in space.
3232
"""
3333
function velocity_3D_bound_vortex!(
34-
vel::Vector{Float64},
34+
vel::VelVector,
3535
filament::BoundFilament,
36-
XVP::Vector{Float64},
36+
XVP::PosVector,
3737
gamma::Float64,
3838
core_radius_fraction::Float64,
3939
work_vectors::NTuple{10, Vector{Float64}}
@@ -95,9 +95,9 @@ Reference: Rick Damiani et al. "A vortex step method for nonlinear airfoil polar
9595
as implemented in KiteAeroDyn".
9696
"""
9797
function velocity_3D_trailing_vortex!(
98-
vel::Vector{Float64},
98+
vel::VelVector,
9999
filament::BoundFilament,
100-
XVP::Vector{Float64},
100+
XVP::PosVector,
101101
gamma::Float64,
102102
Uinf::Float64,
103103
work_vectors::NTuple{10,Vector{Float64}}
@@ -162,10 +162,10 @@ end
162162
Calculate induced velocity by a semi-infinite trailing vortex filament.
163163
"""
164164
function velocity_3D_trailing_vortex_semiinfinite!(
165-
vel::Vector{Float64},
165+
vel::VelVector,
166166
filament::SemiInfiniteFilament,
167-
Vf::Vector{Float64},
168-
XVP::Vector{Float64},
167+
Vf::VelVector,
168+
XVP::PosVector,
169169
GAMMA::Float64,
170170
Uinf::Float64,
171171
work_vectors::NTuple{10,Vector{Float64}}

src/panel.jl

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -50,10 +50,10 @@ mutable struct Panel
5050
function Panel(
5151
section_1::Section,
5252
section_2::Section,
53-
aerodynamic_center::Vector{Float64},
54-
control_point::Vector{Float64},
55-
bound_point_1::Vector{Float64},
56-
bound_point_2::Vector{Float64},
53+
aerodynamic_center::PosVector,
54+
control_point::PosVector,
55+
bound_point_1::PosVector,
56+
bound_point_2::PosVector,
5757
x_airf::Vector{Float64},
5858
y_airf::Vector{Float64},
5959
z_airf::Vector{Float64}
@@ -352,10 +352,10 @@ Calculate the velocity induced by a vortex ring at a control point.
352352
"""
353353
function calculate_velocity_induced_single_ring_semiinfinite(
354354
panel::Panel,
355-
evaluation_point::Vector{Float64},
355+
evaluation_point::PosVector,
356356
evaluation_point_on_bound::Bool,
357357
va_norm::Float64,
358-
va_unit::Vector{Float64},
358+
va_unit::VelVector,
359359
gamma::Float64,
360360
core_radius_fraction::Float64,
361361
work_vectors::NTuple{10,Vector{Float64}}
@@ -421,7 +421,7 @@ Only needed for VSM, as LLT bound and filament align, thus no induced velocity.
421421
"""
422422
function calculate_velocity_induced_bound_2D(
423423
panel::Panel,
424-
evaluation_point::Vector{Float64}
424+
evaluation_point::PosVector
425425
)
426426
# r3 perpendicular to the bound vortex
427427
r3 = evaluation_point - (panel.bound_point_1 + panel.bound_point_2) / 2

src/wing_aerodynamics.jl

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -83,10 +83,10 @@ end
8383
Structure to hold calculated panel properties.
8484
"""
8585
struct PanelProperties
86-
aero_centers::Vector{Vector{Float64}}
87-
control_points::Vector{Vector{Float64}}
88-
bound_points_1::Vector{Vector{Float64}}
89-
bound_points_2::Vector{Vector{Float64}}
86+
aero_centers::Vector{PosVector}
87+
control_points::Vector{PosVector}
88+
bound_points_1::Vector{PosVector}
89+
bound_points_2::Vector{PosVector}
9090
x_airf::Vector{Vector{Float64}}
9191
y_airf::Vector{Vector{Float64}}
9292
z_airf::Vector{Vector{Float64}}

src/wing_geometry.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,8 +62,8 @@ mutable struct Wing
6262
end
6363

6464
"""
65-
add_section!(wing::Wing, LE_point::Vector{Float64},
66-
TE_point::Vector{Float64}, aero_input::Vector{Any})
65+
add_section!(wing::Wing, LE_point::PosVector,
66+
TE_point::PosVector, aero_input::Vector{Any})
6767
6868
Add a new section to the wing.
6969
"""

test/test_semi_infinite_filament.jl

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ using LinearAlgebra
33
using Test
44
using BenchmarkTools
55

6-
function create_test_filament()
6+
function create_test_filament2()
77
x1 = [0.0, 0.0, 0.0]
88
direction = [1.0, 0.0, 0.0]
99
filament_direction = 1
@@ -41,7 +41,7 @@ end
4141
work_vectors = ntuple(_ -> Vector{Float64}(undef, 3), 10)
4242

4343
@testset "Allocation Tests" begin
44-
filament = create_test_filament()
44+
filament = create_test_filament2()
4545
control_point = [0.5, 0.5, 2.0]
4646
induced_velocity = zeros(3)
4747

@@ -60,7 +60,7 @@ end
6060
end
6161

6262
@testset "Calculate Induced Velocity" begin
63-
filament = create_test_filament()
63+
filament = create_test_filament2()
6464
control_point = [0.5, 0.5, 2.0]
6565
induced_velocity = zeros(3)
6666

@@ -83,7 +83,7 @@ end
8383
end
8484

8585
@testset "Point on Filament" begin
86-
filament = create_test_filament()
86+
filament = create_test_filament2()
8787
test_points = [
8888
[0.0, 0.0, 0.0], # Start point
8989
[0.5, 0.0, 0.0], # Along filament
@@ -106,7 +106,7 @@ end
106106
end
107107

108108
@testset "Different Gamma Values" begin
109-
filament = create_test_filament()
109+
filament = create_test_filament2()
110110
control_point = [0.5, 1.0, 0.0]
111111
v1 = zeros(3)
112112
v2 = zeros(3)
@@ -121,7 +121,7 @@ end
121121
end
122122

123123
@testset "Symmetry" begin
124-
filament = create_test_filament()
124+
filament = create_test_filament2()
125125
vel_pos = zeros(3)
126126
vel_neg = zeros(3)
127127

0 commit comments

Comments
 (0)