@@ -302,7 +302,7 @@ function Wing(n_panels::Int;
302302end
303303
304304"""
305- reinit!(wing::AbstractWing; refine_mesh=true, recompute_mapping=true)
305+ reinit!(wing::AbstractWing; refine_mesh=true, recompute_mapping=true, sort_sections=true )
306306
307307Reinitialize wing geometry and panel properties.
308308
@@ -311,11 +311,13 @@ Reinitialize wing geometry and panel properties.
311311 `deform!()` to preserve deformed geometry while updating panel properties.
312312- `recompute_mapping::Bool=true`: Whether to recompute the refined panel mapping.
313313 Set to `false` to skip mapping computation when it hasn't changed.
314+ - `sort_sections::Bool=true`: Whether to sort sections by spanwise position.
315+ Set to `false` for REFINE wings where section order is determined by structural connectivity.
314316"""
315- function reinit! (wing:: AbstractWing ; refine_mesh= true , recompute_mapping= true )
317+ function reinit! (wing:: AbstractWing ; refine_mesh= true , recompute_mapping= true , sort_sections = true )
316318 # Refine mesh unless explicitly disabled (e.g., to preserve deformation)
317319 if refine_mesh
318- refine_aerodynamic_mesh! (wing; recompute_mapping)
320+ refine_aerodynamic_mesh! (wing; recompute_mapping, sort_sections )
319321 end
320322
321323 # Calculate panel properties
@@ -589,19 +591,22 @@ function update_non_deformed_sections!(wing::AbstractWing)
589591end
590592
591593"""
592- refine_aerodynamic_mesh!(wing::AbstractWing; recompute_mapping=true)
594+ refine_aerodynamic_mesh!(wing::AbstractWing; recompute_mapping=true, sort_sections=true )
593595
594596Refine the aerodynamic mesh of the wing based on spanwise panel distribution.
595597
596598# Keyword Arguments
597599- `recompute_mapping::Bool=true`: Whether to recompute the refined panel mapping.
598600 Set to `false` to skip mapping computation when it hasn't changed.
601+ - `sort_sections::Bool=true`: Whether to sort sections by spanwise position (y-coordinate).
602+ Set to `false` for REFINE wings where section order is determined by structural connectivity.
599603
600604Returns:
601605 Vector{Section}: List of refined sections
602606"""
603- function refine_aerodynamic_mesh! (wing:: AbstractWing ; recompute_mapping= true )
604- sort! (wing. sections, by= s -> s. LE_point[2 ], rev= true )
607+ function refine_aerodynamic_mesh! (wing:: AbstractWing ; recompute_mapping= true , sort_sections= true )
608+ # Only sort sections if requested (skip for REFINE wings with fixed structural order)
609+ sort_sections && sort! (wing. sections, by= s -> s. LE_point[2 ], rev= true )
605610 n_sections = wing. n_panels + 1
606611 if length (wing. refined_sections) == 0
607612 if wing. spanwise_distribution == UNCHANGED || length (wing. sections) == n_sections
0 commit comments