@@ -104,21 +104,23 @@ points = hcat(xs, ys)
104104# Generate body of revolution
105105body = pnl. generate_revolution_liftbody (bodytype, points, NDIVS_theta;
106106 bodyoptargs = (
107- CPoffset= 1e-14 ,
107+ CPoffset= 1e-10 ,
108108 kerneloffset= 1e-8 ,
109109 kernelcutoff= 1e-14 ,
110110 characteristiclength= (args... )-> d* aspectratio,
111- semiinfinite_wake= true
111+ semiinfinite_wake= false
112112 )
113113 )
114114
115- # body.shedding = body.shedding[:,1:1]
115+ # body.shedding[1] = body.shedding[1] [:,1:1]
116116# body.nsheddings = 1
117117# body.shedding_full .= -1
118118# idx_shed = body.shedding[1, 1]
119- # body.shedding_full[:, idx_shed] .= view(body.shedding, 2:3, 1)
120- # idx_shed = body.shedding[4, 1]
121- # body.shedding_full[:, idx_shed] .= view(body.shedding, 5:6, 1)
119+ # body.shedding_full[1:2, idx_shed] .= view(body.shedding[1], 2:3, 1)
120+ # body.shedding_full[3:4, idx_shed] .= 1
121+ # idx_shed = body.shedding[1][4, 1]
122+ # body.shedding_full[1:2, idx_shed] .= view(body.shedding[1], 5:6, 1)
123+ # body.shedding_full[3:4, idx_shed] .= 1
122124
123125println (" Number of panels:\t $(body. ncells) " )
124126
@@ -141,19 +143,19 @@ AOA = AOAs[i]
141143
142144 # Unitary direction of semi-infinite vortex at points `a` and `b` of each
143145 # trailing edge panel
144- body. Das[1 ] .= repeat (Vinf/ magVinf, 1 , body. nsheddings )
145- body. Dbs[1 ] .= repeat (Vinf/ magVinf, 1 , body. nsheddings )
146+ body. Das[1 ] .= repeat (Vinf/ magVinf, 1 , size ( body. Das[ 1 ], 2 ) )
147+ body. Dbs[1 ] .= repeat (Vinf/ magVinf, 1 , size ( body. Dbs[ 1 ], 2 ) )
146148
147149 # Solve body (panel strengths) giving `Uinfs` as boundary conditions and
148150 # `Das` and `Dbs` as trailing edge rigid wake direction
149151 # @time pnl.solve(body, Uinfs, Das, Dbs)
150- leaf_size = 50
152+ leaf_size = 100
151153 expansion_order = 10
152154 multipole_acceptance = 0.4
153155 backend = pnl. FastMultipoleBackend (;
154156 expansion_order,
155157 multipole_acceptance,
156- leaf_size
158+ leaf_size= 20
157159 )
158160 # backend = pnl.DirectBackend()
159161 # global solver = pnl.Backslash(body; least_squares=true)
@@ -169,65 +171,62 @@ AOA = AOAs[i]
169171 # leaf_size=10
170172 # )
171173 # )
172- println (" Initializaing solver..." )
173- @time solver = pnl. FGSSolver (body;
174- max_iterations= 500 , # Maximum number of iterations
175- tolerance= 1.0e-6 , # Convergence tolerance
176- rlx= 1.0 , # Relaxation factor
177- expansion_order,
178- multipole_acceptance,
179- leaf_size,
180- shrink= true ,
181- recenter= false ,
182- )
183- # solver = pnl.BackslashDirichlet(body)
184-
185- println (" \n Solving..." )
186-
187- # profile
188- # using Profile, PProf
189-
190- pnl. solve2! (body, Uinfs, solver; backend)
191- # @profile pnl.solve2!(body, Uinfs, solver; backend)
192- # Profile.clear()
193- # @profile pnl.solve2!(body, Uinfs, solver; backend)
194- # pprof()
174+ # function test_solver(inner_iterations, reverse_pass)
175+ # println("Initializing solver with inner_iterations=$inner_iterations, reverse_pass=$reverse_pass...")
176+ println (" Initializaing solver..." )
177+ @time solver = pnl. FGSSolver (body;
178+ max_iterations= 500 , # Maximum number of iterations
179+ tolerance= 1.0e-6 , # Convergence tolerance
180+ rlx= 1.0 , # Relaxation factor
181+ expansion_order,
182+ multipole_acceptance,
183+ leaf_size,
184+ shrink= true ,
185+ recenter= false ,
186+ inner_iterations= 20 ,
187+ reverse_pass= false ,
188+ verbose= false
189+ )
190+ # solver = pnl.BackslashDirichlet(body)
191+
192+ println (" \n Solving..." )
193+
194+ # profile
195+ # using Profile, PProf
196+
197+ @time pnl. solve2! (body, Uinfs, solver; backend)
198+ # @profile pnl.solve2!(body, Uinfs, solver; backend)
199+ # Profile.clear()
200+ # @profile pnl.solve2!(body, Uinfs, solver; backend)
201+ # pprof()
202+
203+ # end
204+
205+ # for reverse_pass in [true, false]
206+ # for inner_iterations in [1, 2, 4, 8, 16, 32]
207+ # test_solver(inner_iterations, reverse_pass)
208+ # end
209+ # end
195210
196211 # ----------------- POST PROCESSING ----------------------------------------
197212 println (" \n Post processing..." )
198213
199214 # Calculate surface velocity U on the body
200- @time Us = pnl. calcfield_U (body, body; backend)
215+ @time Us = pnl. calcfield_U! (body, body; backend)
216+ pnl. apply_freestream! (body, Uinfs[:,1 ])
201217
202- # NOTE: Since the boundary integral equation of the potential flow has a
203- # discontinuity at the boundary, we need to add the gradient of the
204- # doublet strength to get an accurate surface velocity
205-
206- # Calculate surface velocity U_∇μ due to the gradient of the doublet strength
207- Gammai = kernel == pnl. VortexRing ? 1 : kernel == Union{pnl. ConstantSource, pnl. ConstantDoublet} ? 2 : 0
208- UDeltaGamma = pnl. calcfield_Ugradmu (body; Gammai)
209- # UDeltaGamma = pnl.calcfield_Ugradmu(body; sharpTE=true, force_cellTE=false)
210-
211- # Add both velocities together
212- pnl. addfields (body, " Ugradmu" , " U" )
213-
214- # Calculate pressure coefficient (based on U + U_∇μ)
215- @time Cps = pnl. calcfield_Cp (body, magVinf)
218+ # Calculate pressure coefficient (based on body.velocity)
219+ @time Cps = pnl. calcfield_Cp! (body. Cp, body, magVinf; correct_kuttacondition= true )
216220
217221 # Calculate the force of each panel (based on Cp)
218- @time Fs = pnl. calcfield_F (body, magVinf, rho)
222+ @time Fs = pnl. calcfield_F! (body, magVinf, rho)
219223
220224 # check normal flow condition
221- Us_tot = pnl. get_field (body, " U" )[" field_data" ] # total velocity
222- Us_tot = [Us_tot[j][i] for i= 1 : 3 , j= 1 : size (Us_tot,1 )]
223- normals = pnl. _calc_normals (body)
225+ Us_tot = body. velocity
224226 Udotn = sum (Us_tot .* normals, dims= 1 )
225227 resid = maximum (abs .(Udotn))
226228 println (" Max flow tangency residual: $resid " )
227229
228- normals = pnl. calc_normals (body)
229- CPs_inside = pnl. _calc_controlpoints (body, normals; off= - 1e-10 )
230-
231230 # ----------------- COMPARISON TO EXPERIMENTAL DATA ------------------------
232231 # Plot surface pressure along slices of the duct
233232 fig, axs = plot_Cp (body, AOA)
@@ -250,8 +249,7 @@ AOA = AOAs[i]
250249 name *= kernel == pnl. VortexRing ? " _vortexring" :
251250 kernel == Union{pnl. ConstantSource, pnl. ConstantDoublet} ? " _source_doublet" :
252251 " "
253- global vtks *= pnl. save (body, name; path= save_path, num= i,
254- wake_panel= false , debug= false , out_wake= false )
252+ global vtks *= pnl. write_vtk (name, body, i, 0.0 ; overwrite= true )
255253 end
256254
257255# end
0 commit comments