@@ -102,7 +102,7 @@ sol::VSMSolution = VSMSolution(): The result of calling [solve!](@ref)
102102
103103 # Nonlin solver fields
104104 prob:: Union{NonlinearProblem, Nothing} = nothing
105- cache :: Union{NonlinearSolve.AbstractNonlinearSolveCache, Nothing} = nothing
105+ nonlin_cache :: Union{NonlinearSolve.AbstractNonlinearSolveCache, Nothing} = nothing
106106 atol:: Float64 = 1e-5
107107
108108 # Damping settings
@@ -118,7 +118,10 @@ sol::VSMSolution = VSMSolution(): The result of calling [solve!](@ref)
118118 # Intermediate results
119119 lr:: LoopResult{P} = LoopResult (P)
120120 br:: BaseResult{P} = BaseResult {P} ()
121-
121+ cache:: Vector{PreallocationTools.LazyBufferCache{typeof(identity), typeof(identity)}} = [LazyBufferCache () for _ in 1 : 11 ]
122+ cache_base:: Vector{PreallocationTools.LazyBufferCache{typeof(identity), typeof(identity)}} = [LazyBufferCache ()]
123+ cache_solve:: Vector{PreallocationTools.LazyBufferCache{typeof(identity), typeof(identity)}} = [LazyBufferCache ()]
124+
122125 # Solution
123126 sol:: VSMSolution{P} = VSMSolution (P)
124127end
@@ -128,10 +131,6 @@ function Solver(body_aero; kwargs...)
128131 return Solver {P} (; kwargs... )
129132end
130133
131- const cache = [LazyBufferCache () for _ in 1 : 11 ]
132- const cache_base = [LazyBufferCache ()]
133- const cache_solve = [LazyBufferCache ()]
134-
135134"""
136135 solve!(solver::Solver, body_aero::BodyAerodynamics, gamma_distribution=solver.sol.gamma_distribution;
137136 log=false, reference_point=zeros(MVec3), moment_frac=0.1)
@@ -171,7 +170,7 @@ function solve!(solver::Solver, body_aero::BodyAerodynamics, gamma_distribution=
171170 cm_array = solver. sol. cm_array
172171 converged = solver. lr. converged
173172 alpha_array = solver. lr. alpha_array
174- alpha_corrected = cache_solve[1 ][alpha_array]
173+ alpha_corrected = solver . cache_solve[1 ][alpha_array]
175174 v_a_array = solver. lr. v_a_array
176175 panels = body_aero. panels
177176
@@ -389,7 +388,7 @@ function solve_base!(solver::Solver, body_aero::BodyAerodynamics, gamma_distribu
389388 solver. br. va_unit_array)
390389
391390 # Initialize gamma distribution
392- gamma_initial = cache_base[1 ][solver. sol. chord_array]
391+ gamma_initial = solver . cache_base[1 ][solver. sol. chord_array]
393392 if isnothing (gamma_distribution)
394393 if solver. type_initial_gamma_distribution == ELLIPTIC
395394 calculate_circulation_distribution_elliptical_wing (gamma_initial, body_aero)
@@ -440,17 +439,17 @@ function gamma_loop!(
440439 solver. lr. alpha_array .= body_aero. alpha_array
441440 solver. lr. v_a_array .= body_aero. v_a_array
442441
443- va_magw_array = cache[1 ][solver. lr. v_a_array]
444- gamma = cache[2 ][solver. lr. gamma_new]
445- abs_gamma_new = cache[3 ][solver. lr. gamma_new]
446- induced_velocity_all = cache[4 ][va_array]
447- relative_velocity_array = cache[5 ][va_array]
448- relative_velocity_crossz = cache[6 ][va_array]
449- v_acrossz_array = cache[7 ][va_array]
450- cl_array = cache[8 ][solver. lr. gamma_new]
451- damp = cache[9 ][solver. lr. gamma_new]
452- v_normal_array = cache[10 ][solver. lr. gamma_new]
453- v_tangential_array = cache[11 ][solver. lr. gamma_new]
442+ va_magw_array = solver . cache[1 ][solver. lr. v_a_array]
443+ gamma = solver . cache[2 ][solver. lr. gamma_new]
444+ abs_gamma_new = solver . cache[3 ][solver. lr. gamma_new]
445+ induced_velocity_all = solver . cache[4 ][va_array]
446+ relative_velocity_array = solver . cache[5 ][va_array]
447+ relative_velocity_crossz = solver . cache[6 ][va_array]
448+ v_acrossz_array = solver . cache[7 ][va_array]
449+ cl_array = solver . cache[8 ][solver. lr. gamma_new]
450+ damp = solver . cache[9 ][solver. lr. gamma_new]
451+ v_normal_array = solver . cache[10 ][solver. lr. gamma_new]
452+ v_tangential_array = solver . cache[11 ][solver. lr. gamma_new]
454453
455454 AIC_x, AIC_y, AIC_z = body_aero. AIC[1 , :, :], body_aero. AIC[2 , :, :], body_aero. AIC[3 , :, :]
456455
@@ -500,10 +499,10 @@ function gamma_loop!(
500499 nothing
501500 end
502501 solver. prob = NonlinearProblem (f_nonlin!, solver. lr. gamma_new, nothing )
503- solver. cache = init (solver. prob, NewtonRaphson (autodiff= AutoFiniteDiff ()); abstol= solver. atol, reltol= solver. rtol)
502+ solver. nonlin_cache = init (solver. prob, NewtonRaphson (autodiff= AutoFiniteDiff ()); abstol= solver. atol, reltol= solver. rtol)
504503 end
505504
506- sol = NonlinearSolve. solve! (solver. cache )
505+ sol = NonlinearSolve. solve! (solver. nonlin_cache )
507506 gamma .= sol. u
508507 solver. lr. gamma_new .= sol. u
509508 solver. lr. converged = SciMLBase. successful_retcode (sol)
@@ -661,7 +660,8 @@ function linearize(solver::Solver, body_aero::BodyAerodynamics, wing::RamAirWing
661660 jac = zeros (length (results), length (y))
662661 backend = AutoFiniteDiff (absstep= 1e-3 , relstep= 1e-3 )
663662 prep = prepare_jacobian (calc_results!, results, backend, y)
664- jacobian! (calc_results!, results, jac, prep, backend, y)
663+ println (" jac" )
664+ @time jacobian! (calc_results!, results, jac, prep, backend, y)
665665
666666 calc_results! (results, y)
667667 return jac, results
0 commit comments