|
665 | 665 | return all(_has_initialized_section_aero_data, wing.refined_sections) |
666 | 666 | end |
667 | 667 |
|
| 668 | +""" |
| 669 | + copy_sections_to_refined!(wing; reuse_aero_data=false) |
| 670 | +
|
| 671 | +Copy unrefined sections to refined sections 1:1 (no interpolation). |
| 672 | +If `refined_sections` is empty, allocates via `copy`; otherwise |
| 673 | +reinitialises in-place. Warns if billowing was requested but there |
| 674 | +are no intermediate sections to billow. |
| 675 | +""" |
| 676 | +function copy_sections_to_refined!( |
| 677 | + wing::AbstractWing; reuse_aero_data::Bool=false |
| 678 | +) |
| 679 | + if wing.spanwise_distribution == BILLOWING && |
| 680 | + wing.billowing_percentage > 0 |
| 681 | + @warn "Billowing requested but n_panels " * |
| 682 | + "($(wing.n_panels)) == n_provided; no " * |
| 683 | + "intermediate sections to billow. " * |
| 684 | + "Increase n_panels." |
| 685 | + end |
| 686 | + if length(wing.refined_sections) == 0 |
| 687 | + wing.refined_sections = copy(wing.unrefined_sections) |
| 688 | + else |
| 689 | + for (refined, unrefined) in zip( |
| 690 | + wing.refined_sections, wing.unrefined_sections) |
| 691 | + if reuse_aero_data |
| 692 | + reinit!(refined, unrefined.LE_point, |
| 693 | + unrefined.TE_point, unrefined.aero_model) |
| 694 | + else |
| 695 | + reinit!(refined, unrefined) |
| 696 | + end |
| 697 | + end |
| 698 | + end |
| 699 | + return nothing |
| 700 | +end |
| 701 | + |
668 | 702 | """ |
669 | 703 | refine!(wing::AbstractWing; recompute_mapping=true, sort_sections=true) |
670 | 704 |
|
@@ -728,14 +762,7 @@ function refine!(wing::AbstractWing; recompute_mapping=true, sort_sections=true) |
728 | 762 | if length(wing.refined_sections) == 0 |
729 | 763 | if wing.spanwise_distribution == UNCHANGED || |
730 | 764 | length(wing.unrefined_sections) == n_sections |
731 | | - if wing.spanwise_distribution == BILLOWING && |
732 | | - wing.billowing_percentage > 0 |
733 | | - @warn "Billowing requested but n_panels " * |
734 | | - "($(wing.n_panels)) == n_provided; no " * |
735 | | - "intermediate sections to billow. " * |
736 | | - "Increase n_panels." |
737 | | - end |
738 | | - wing.refined_sections = copy(wing.unrefined_sections) |
| 765 | + copy_sections_to_refined!(wing; reuse_aero_data) |
739 | 766 | recompute_mapping && compute_refined_panel_mapping!(wing) |
740 | 767 | update_non_deformed_sections!(wing) |
741 | 768 | return nothing |
@@ -765,22 +792,7 @@ function refine!(wing::AbstractWing; recompute_mapping=true, sort_sections=true) |
765 | 792 |
|
766 | 793 | # Handle special cases |
767 | 794 | if wing.spanwise_distribution == UNCHANGED || length(wing.unrefined_sections) == n_sections |
768 | | - for i in eachindex(wing.unrefined_sections) |
769 | | - if reuse_aero_data |
770 | | - section = wing.unrefined_sections[i] |
771 | | - reinit!( |
772 | | - wing.refined_sections[i], |
773 | | - section.LE_point, |
774 | | - section.TE_point, |
775 | | - section.aero_model |
776 | | - ) |
777 | | - else |
778 | | - reinit!(wing.refined_sections[i], wing.unrefined_sections[i]) |
779 | | - end |
780 | | - end |
781 | | - if wing.spanwise_distribution == BILLOWING && wing.billowing_percentage > 0 |
782 | | - @warn "Billowing requested but n_panels ($(wing.n_panels)) == n_provided; no intermediate sections to billow. Increase n_panels." |
783 | | - end |
| 795 | + copy_sections_to_refined!(wing; reuse_aero_data) |
784 | 796 | recompute_mapping && compute_refined_panel_mapping!(wing) |
785 | 797 | update_non_deformed_sections!(wing) |
786 | 798 | return nothing |
@@ -1146,15 +1158,7 @@ function refine_mesh_by_splitting_provided_sections!( |
1146 | 1158 |
|
1147 | 1159 | # Check if refinement is needed |
1148 | 1160 | if n_panels_provided == n_panels_desired |
1149 | | - for (refined_section, section) in zip( |
1150 | | - wing.refined_sections, wing.unrefined_sections) |
1151 | | - if reuse_aero_data |
1152 | | - reinit!(refined_section, section.LE_point, |
1153 | | - section.TE_point, section.aero_model) |
1154 | | - else |
1155 | | - reinit!(refined_section, section) |
1156 | | - end |
1157 | | - end |
| 1161 | + copy_sections_to_refined!(wing; reuse_aero_data) |
1158 | 1162 | return nothing |
1159 | 1163 | end |
1160 | 1164 |
|
|
0 commit comments