@@ -108,6 +108,8 @@ function update_panel_properties!(panel_props::PanelProperties, section_list::Ve
108108 x_airf = panel_props. x_airf
109109 y_airf = panel_props. y_airf
110110 z_airf = panel_props. z_airf
111+ vec = zeros (MVec3)
112+ vec2 = zeros (MVec3)
111113 @debug " Shape of coordinates: $(size (coords)) "
112114
113115 for i in 1 : n_panels
@@ -122,48 +124,60 @@ function update_panel_properties!(panel_props::PanelProperties, section_list::Ve
122124 for i in 1 : n_panels
123125 # Define panel points
124126 @views begin
125- p1 = coords[2 i- 1 , :] # LE_1
126- p2 = coords[2 i+ 1 , :] # LE_2
127- p3 = coords[2 i+ 2 , :] # TE_2
128- p4 = coords[2 i, :] # TE_1
127+ LE_1 = coords[2 i- 1 , :] # LE_1
128+ LE_2 = coords[2 i+ 1 , :] # LE_2
129+ TE_2 = coords[2 i+ 2 , :] # TE_2
130+ TE_1 = coords[2 i, :] # TE_1
129131 end
130132
131133 # Calculate control point position
132- di = norm (coords[2 i- 1 , :] .* 0.75 .+ coords[2 i, :] .* 0.25 .-
133- (coords[2 i+ 1 , :] .* 0.75 .+ coords[2 i+ 2 , :] .* 0.25 ))
134+ @views @. vec = coords[2 i- 1 , :] * 0.75 + coords[2 i, :] * 0.25 -
135+ (coords[2 i+ 1 , :] * 0.75 + coords[2 i+ 2 , :] * 0.25 )
136+ di = norm (vec)
134137
135138 ncp = if i == 1
136- diplus = norm (coords[2 i+ 1 , :] * 0.75 + coords[2 i+ 2 , :] * 0.25 -
137- (coords[2 i+ 3 , :] * 0.75 + coords[2 i+ 4 , :] * 0.25 ))
139+ @views @. vec = coords[2 i+ 1 , :] * 0.75 + coords[2 i+ 2 , :] * 0.25 -
140+ (coords[2 i+ 3 , :] * 0.75 + coords[2 i+ 4 , :] * 0.25 )
141+ diplus = norm (vec)
138142 di / (di + diplus)
139143 elseif i == n_panels
140- dimin = norm (coords[2 i- 3 , :] * 0.75 + coords[2 i- 2 , :] * 0.25 -
141- (coords[2 i- 1 , :] * 0.75 + coords[2 i, :] * 0.25 ))
144+ @views @. vec = coords[2 i- 3 , :] * 0.75 + coords[2 i- 2 , :] * 0.25 -
145+ (coords[2 i- 1 , :] * 0.75 + coords[2 i, :] * 0.25 )
146+ dimin = norm (vec)
142147 dimin / (dimin + di)
143148 else
144- dimin = norm (coords[2 i- 3 , :] * 0.75 + coords[2 i- 2 , :] * 0.25 -
145- (coords[2 i- 1 , :] * 0.75 + coords[2 i, :] * 0.25 ))
146- diplus = norm (coords[2 i+ 1 , :] * 0.75 + coords[2 i+ 2 , :] * 0.25 -
147- (coords[2 i+ 3 , :] * 0.75 + coords[2 i+ 4 , :] * 0.25 ))
149+ @views @. vec = coords[2 i- 3 , :] * 0.75 + coords[2 i- 2 , :] * 0.25 -
150+ (coords[2 i- 1 , :] * 0.75 + coords[2 i, :] * 0.25 )
151+ dimin = norm (vec)
152+ @views @. vec = coords[2 i+ 1 , :] * 0.75 + coords[2 i+ 2 , :] * 0.25 -
153+ (coords[2 i+ 3 , :] * 0.75 + coords[2 i+ 4 , :] * 0.25 )
154+ diplus = norm (vec)
148155 0.25 * (dimin / (dimin + di) + di / (di + diplus) + 1 )
149156 end
150-
151157 ncp = 1 - ncp
152158
153159 # Calculate points
154- @. aero_centers[i, :] = (p2 * (1 - ncp) + p1 * ncp) * 0.75 +
155- (p3 * (1 - ncp) + p4 * ncp) * 0.25
156-
157- @. control_points[i, :] = (p2 * (1 - ncp) + p1 * ncp) * 0.25 +
158- (p3 * (1 - ncp) + p4 * ncp) * 0.75
159-
160- @. bound_points_1[i, :] = p1 * 0.75 + p4 * 0.25
161- @. bound_points_2[i, :] = p2 * 0.75 + p3 * 0.25
160+ @. begin
161+ aero_centers[i, :] = (LE_2 * (1 - ncp) + LE_1 * ncp) * 0.75 +
162+ (TE_2 * (1 - ncp) + TE_1 * ncp) * 0.25
163+ control_points[i, :] = (LE_2 * (1 - ncp) + LE_1 * ncp) * 0.25 +
164+ (TE_2 * (1 - ncp) + TE_1 * ncp) * 0.75
165+
166+ bound_points_1[i, :] = LE_1 * 0.75 + TE_1 * 0.25
167+ bound_points_2[i, :] = LE_2 * 0.75 + TE_2 * 0.25
168+ end
162169
163170 # Calculate reference frame vectors
164- z_airf[i, :] .= normalize ((control_points[i, :] .- aero_centers[i, :]) × (p1 .- p2))
165- x_airf[i, :] .= normalize (control_points[i, :] .- aero_centers[i, :])
166- y_airf[i, :] .= normalize (bound_points_1[i, :] .- bound_points_2[i, :])
171+ @views begin
172+ @. vec = (control_points[i, :] - aero_centers[i, :])
173+ @. vec2 = (LE_1 - LE_2)
174+ vec .= vec × vec2
175+ z_airf[i, :] .= normalize (vec)
176+ @. vec = control_points[i, :] .- aero_centers[i, :]
177+ x_airf[i, :] .= normalize (vec)
178+ @. vec = bound_points_1[i, :] - bound_points_2[i, :]
179+ y_airf[i, :] .= normalize (vec)
180+ end
167181 end
168182 return nothing
169183end
0 commit comments