@@ -235,4 +235,70 @@ using Test
235235 @test body_aero. panels[i]. delta ≈ expected_delta atol= 1e-6
236236 end
237237 end
238+
239+ @testset " Smooth vs Non-Smooth Deformation" begin
240+ # Create test wing with 2 unrefined sections, refined to 40 panels
241+ simple_wing_file = test_data_path (" yaml_geometry" , " simple_wing.yaml" )
242+ wing = Wing (simple_wing_file; n_panels= 40 )
243+ @test wing. n_unrefined_sections == 2
244+
245+ # Define varying input angles at unrefined section level
246+ delta_input = deg2rad .([0.0 , 10.0 ])
247+
248+ # Test 1: Non-smooth deformation has step-wise discontinuities
249+ VortexStepMethod. unrefined_deform! (wing, nothing , delta_input; smooth= false )
250+ delta_nonsmooth = copy (wing. delta_dist)
251+
252+ # Verify step-wise pattern: panels in same unrefined section have identical angles
253+ for i in 1 : wing. n_panels
254+ unrefined_idx = wing. refined_panel_mapping[i]
255+ @test delta_nonsmooth[i] ≈ delta_input[unrefined_idx] atol= 1e-10
256+ end
257+
258+ # Verify discontinuities exist at unrefined section boundaries
259+ # Find boundary indices (where panel mapping changes)
260+ max_gradient_nonsmooth = 0.0
261+ for i in 1 : (wing. n_panels- 1 )
262+ if wing. refined_panel_mapping[i] != wing. refined_panel_mapping[i+ 1 ]
263+ gradient = abs (delta_nonsmooth[i+ 1 ] - delta_nonsmooth[i])
264+ max_gradient_nonsmooth = max (max_gradient_nonsmooth, gradient)
265+ end
266+ end
267+ @test max_gradient_nonsmooth > deg2rad (5.0 ) # Should have large jumps
268+
269+ # Test 2: Smooth deformation is continuous
270+ VortexStepMethod. unrefined_deform! (wing, nothing , delta_input; smooth= true )
271+ delta_smooth = copy (wing. delta_dist)
272+
273+ # Verify gradients between adjacent panels are small
274+ max_gradient_smooth = maximum (abs .(diff (delta_smooth)))
275+ @test max_gradient_smooth < deg2rad (3.0 ) # Should be smooth
276+
277+ # Verify no sharp discontinuities
278+ for i in 1 : (wing. n_panels- 1 )
279+ @test abs (delta_smooth[i+ 1 ] - delta_smooth[i]) < deg2rad (3.0 )
280+ end
281+
282+ # Test 3: Smoothing reduces maximum gradient
283+ @test max_gradient_smooth < max_gradient_nonsmooth
284+
285+ # Test 4: Angles match input at unrefined section centers (both modes)
286+ # For non-smooth: extract angle at center panel of each unrefined section
287+ VortexStepMethod. unrefined_deform! (wing, nothing , delta_input; smooth= false )
288+ for i in 1 : wing. n_unrefined_sections
289+ # Find panels belonging to this unrefined section
290+ panel_indices = findall (== (i), wing. refined_panel_mapping)
291+ center_panel_idx = panel_indices[div (length (panel_indices), 2 ) + 1 ]
292+ @test wing. delta_dist[center_panel_idx] ≈ delta_input[i] atol= 1e-10
293+ end
294+
295+ # For smooth: angles at center should be close to input (tolerance larger due to smoothing)
296+ VortexStepMethod. unrefined_deform! (wing, nothing , delta_input; smooth= true )
297+ for i in 1 : wing. n_unrefined_sections
298+ panel_indices = findall (== (i), wing. refined_panel_mapping)
299+ center_panel_idx = panel_indices[div (length (panel_indices), 2 ) + 1 ]
300+ # Smoothing may shift values slightly, use absolute tolerance for small angles
301+ @test wing. delta_dist[center_panel_idx] ≈ delta_input[i] atol= deg2rad (2.0 )
302+ end
303+ end
238304end
0 commit comments