Skip to content

Commit 3a3d7fa

Browse files
committed
Add P to VSMSolution and bench2.jl
1 parent 210e13b commit 3a3d7fa

2 files changed

Lines changed: 8 additions & 8 deletions

File tree

src/solver.jl

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ Struct for storing the solution of the [solve!](@ref) function. Must contain all
1414
- moment_coefficient_distribution::Vector{Float64}: Pitching moment coefficient around the spanwise vector of each panel. [-]
1515
- solver_status::SolverStatus: enum, see [SolverStatus](@ref)
1616
"""
17-
mutable struct VSMSolution
17+
mutable struct VSMSolution{P}
1818
gamma_distribution::Union{Nothing, Vector{Float64}}
1919
aero_force::MVec3
2020
aero_moments::MVec3
@@ -25,8 +25,8 @@ mutable struct VSMSolution
2525
solver_status::SolverStatus
2626
end
2727

28-
function VSMSolution()
29-
VSMSolution(nothing, zeros(MVec3), zeros(MVec3), zeros(MVec3), zeros(MVec3), zeros(3), zeros(3), FAILURE)
28+
function VSMSolution(P)
29+
VSMSolution{P}(nothing, zeros(MVec3), zeros(MVec3), zeros(MVec3), zeros(MVec3), zeros(3), zeros(3), FAILURE)
3030
end
3131

3232
"""
@@ -57,7 +57,7 @@ Main solver structure for the Vortex Step Method.See also: [solve](@ref)
5757
## Solution
5858
sol::VSMSolution = VSMSolution(): The result of calling [solve!](@ref)
5959
"""
60-
@with_kw struct Solver
60+
@with_kw struct Solver{P}
6161
# General settings
6262
aerodynamic_model_type::Model = VSM
6363
density::Float64 = 1.225
@@ -77,7 +77,7 @@ sol::VSMSolution = VSMSolution(): The result of calling [solve!](@ref)
7777
is_only_f_and_gamma_output::Bool = false
7878

7979
# Solution
80-
sol::VSMSolution = VSMSolution()
80+
sol::VSMSolution{P} = VSMSolution(P)
8181
end
8282

8383
"""

test/bench2.jl

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,8 @@ vel_app = [cos(alpha), 0.0, sin(alpha)] .* v_a
4040
set_va!(wa, vel_app)
4141

4242
# Step 4: Initialize solvers for both LLT and VSM methods
43-
llt_solver = Solver(aerodynamic_model_type=LLT)
44-
vsm_solver = Solver(aerodynamic_model_type=VSM)
43+
P = length(wa.panels)
44+
vsm_solver = Solver{P}(aerodynamic_model_type=VSM)
4545

4646
# Step 5: Solve using both methods
4747
println("Rectangular wing, solve_base:")
@@ -50,5 +50,5 @@ println("Rectangular wing, solve_base:")
5050
# time Julia: 0.6 ms Ryzen 7950x
5151
# 0.47 ms laptop, performance mode, grid
5252
println("Rectangular wing, solve!:")
53-
@btime sol = solve!($vsm_solver, $wa) # 608 allocations
53+
@btime sol = solve!($vsm_solver, $wa) # 608 allocations
5454
nothing

0 commit comments

Comments
 (0)