@@ -536,18 +536,21 @@ function solve2!(self::RigidWakeBody{Union{ConstantSource, ConstantDoublet}, 2,
536536 self. strength[:, 2 ] .= 0.0
537537
538538 # calculate potential due to source strengths
539- _phi! (self, CPs, self. potential, backend; include_wake= false , optargs... ) # NOTE: wake is included in the `direct!` function in this line
539+ self. potential .= 0.0
540+ _phi! (self, CPs, self. potential, backend; include_wake= false , optargs... )
540541
541542 # zero source strengths while we solver for the doublet strengths
542543 self. strength[:, 1 ] .= 0.0
543544
544545 # run fgs solver
545546 FastMultipole. solve! (self, solver. fgs;
546- max_iterations= solver. max_iterations,
547+ max_iterations= solver. max_iterations,
548+ inner_iterations= solver. inner_iterations,
547549 tolerance= solver. tolerance,
548550 rlx= solver. rlx,
549551 derivatives_switches= FastMultipole. DerivativesSwitch (true , false , false , to_tuple (_unpack_fmm (self))),
550- reverse_pass= false
552+ reverse_pass= solver. reverse_pass,
553+ verbose= solver. verbose,
551554 )
552555
553556 # update source strength
@@ -2063,7 +2066,6 @@ function FastMultipole.body_to_multipole!(system::RigidWakeBody{Union{ConstantSo
20632066 # which vertices connect to the wake
20642067 idx1 = Int (buffer[end - 7 , i_body])
20652068 if idx1 > 0
2066- println (" wake..." )
20672069 # first vertex and wake
20682070 Dax, Day, Daz = buffer[end - 6 , i_body], buffer[end - 5 , i_body], buffer[end - 4 , i_body]
20692071 Da = FastMultipole. SVector {3} (Dax, Day, Daz)
@@ -2090,7 +2092,6 @@ function FastMultipole.body_to_multipole!(system::RigidWakeBody{Union{ConstantSo
20902092
20912093 # doublet strength
20922094 strength_doublet = FastMultipole. SVector {1,TF} (strength[2 ])
2093- @show Da, Db, v1, v2, v1w, v2w, normal
20942095
20952096 # update values
20962097 element = FastMultipole. Panel{FastMultipole. Dipole}
@@ -2253,7 +2254,7 @@ function additional_source_system_to_buffer!(buffer, i_buffer, system::RigidWake
22532254 end
22542255
22552256 if ! system. semiinfinite_wake
2256- buffer[4 ] += update_radius # conservative update to accomadate wake size
2257+ buffer[4 , i_buffer ] += update_radius # conservative update to accomadate wake size
22572258 end
22582259
22592260 return ilast+ 8
@@ -2585,41 +2586,41 @@ end
25852586
25862587
25872588# #### INTERNAL FUNCTIONS ######################################################
2588- function _get_wakestrength_mu (self:: RigidWakeBody , i; stri= 1 )
2589+ function _get_wakestrength_mu (self:: RigidWakeBody , i, isurf = 1 ; stri= 1 )
25892590 # if self.use_wake_strength
25902591 # return self.wake_strength[i], zero(self.wake_strength[i])
25912592 # else
2592- strength1 = self. strength[self. shedding[1 , i], stri]
2593- strength2 = self. shedding[4 , i] != - 1 ? self. strength[self. shedding[4 , i], stri] : 0.0
2593+ strength1 = self. strength[self. shedding[isurf][ 1 , i], stri]
2594+ strength2 = self. shedding[isurf][ 4 , i] != - 1 ? self. strength[self. shedding[isurf] [4 , i], stri] : 0.0
25942595 return strength1, strength2
25952596 # end
25962597end
2597- function _get_wakestrength_mu (self:: RigidWakeBody{Union{ConstantSource,ConstantDoublet},2,<:Any} , i)
2598+ function _get_wakestrength_mu (self:: RigidWakeBody{Union{ConstantSource,ConstantDoublet},2,<:Any} , i, isurf = 1 )
25982599 # if self.use_wake_strength
25992600 # return self.wake_strength[i], zero(self.wake_strength[i])
26002601 # else
26012602 stri = 2
2602- strength1 = self. strength[self. shedding[1 , i], stri]
2603- strength2 = self. shedding[4 , i] != - 1 ? self. strength[self. shedding[4 , i], stri] : 0.0
2603+ strength1 = self. strength[self. shedding[isurf][ 1 , i], stri]
2604+ strength2 = self. shedding[isurf][ 4 , i] != - 1 ? self. strength[self. shedding[isurf] [4 , i], stri] : 0.0
26042605 return strength1, strength2
26052606 # end
26062607end
2607- function _get_wakestrength_Gamma (self:: RigidWakeBody , i; stri= 1 )
2608+ function _get_wakestrength_Gamma (self:: RigidWakeBody , i, isurf = 1 ; stri= 1 )
26082609 # if self.use_wake_strength
26092610 # return self.wake_strength[i]
26102611 # else
2611- strength1 = self. strength[self. shedding[1 , i], stri]
2612- strength2 = self. shedding[4 , i] != - 1 ? self. strength[self. shedding[4 , i], stri] : 0.0
2612+ strength1 = self. strength[self. shedding[isurf][ 1 , i], stri]
2613+ strength2 = self. shedding[isurf][ 4 , i] != - 1 ? self. strength[self. shedding[isurf] [4 , i], stri] : 0.0
26132614 return strength1 - strength2
26142615 # end
26152616end
2616- function _get_wakestrength_Gamma (self:: RigidWakeBody{Union{ConstantSource,ConstantDoublet},2,<:Any} , i)
2617+ function _get_wakestrength_Gamma (self:: RigidWakeBody{Union{ConstantSource,ConstantDoublet},2,<:Any} , i, isurf = 1 )
26172618 # if self.use_wake_strength
26182619 # return self.wake_strength[i]
26192620 # else
26202621 stri = 2
2621- strength1 = self. strength[self. shedding[1 , i], stri]
2622- strength2 = self. shedding[4 , i] != - 1 ? self. strength[self. shedding[4 , i], stri] : 0.0
2622+ strength1 = self. strength[self. shedding[isurf][ 1 , i], stri]
2623+ strength2 = self. shedding[isurf][ 4 , i] != - 1 ? self. strength[self. shedding[isurf] [4 , i], stri] : 0.0
26232624 return strength1 - strength2
26242625 # end
26252626end
@@ -2733,3 +2734,72 @@ function _savewake(self::RigidWakeBody, filename::String;
27332734 end
27342735end
27352736# ### END OF LIFTING BODY ######################################################
2737+
2738+ function write_vtk (name:: String , body:: RigidWakeBody ; t= 0.0 , overwrite:: Bool = false , semiinfinite_length= 5.0 )
2739+ # set wake length for visualization (if semi-infinite wake is enabled)
2740+ if body. semiinfinite_wake
2741+ for (Das, Dbs) in zip (body. Das, body. Dbs)
2742+ for i in 1 : size (Das, 2 )
2743+ # norm_Da = norm(view(Das, :, i))
2744+ # norm_Db = norm(view(Dbs, :, i))
2745+ Das[:, i] .*= semiinfinite_length # / norm_Da
2746+ Dbs[:, i] .*= semiinfinite_length # / norm_Db
2747+ end
2748+ end
2749+ end
2750+
2751+ WriteVTK. paraview_collection (name; append= ! overwrite) do pvd
2752+ vtm = WriteVTK. vtk_multiblock (name* " _wake" )
2753+ for i_surf in eachindex (body. shedding)
2754+ shedding = body. shedding[i_surf]
2755+ Das = body. Das[i_surf]
2756+ Dbs = body. Dbs[i_surf]
2757+
2758+ n_wakes = size (shedding, 2 )
2759+ points = zeros (typeof (body. grid. _nodes[1 ]), 3 , 4 * n_wakes)
2760+ cells = Vector {WriteVTK.MeshCell} (undef, n_wakes)
2761+ strengths = zeros (typeof (body. strength[1 ]), n_wakes)
2762+
2763+ for i in 1 : n_wakes
2764+ pi = shedding[1 , i]
2765+ nia, nib = shedding[2 , i], shedding[3 , i]
2766+
2767+ idx1 = body. cells[nia, pi ]
2768+ idx2 = body. cells[nib, pi ]
2769+
2770+ p1 = body. grid. _nodes[:, idx1]
2771+ p2 = body. grid. _nodes[:, idx2]
2772+
2773+ p3 = p2 + Dbs[:, i]
2774+ p4 = p1 + Das[:, i]
2775+
2776+ points[:, 1 + 4 * (i- 1 )] = p1
2777+ points[:, 2 + 4 * (i- 1 )] = p2
2778+ points[:, 3 + 4 * (i- 1 )] = p3
2779+ points[:, 4 + 4 * (i- 1 )] = p4
2780+
2781+ cells[i] = WriteVTK. MeshCell (WriteVTK. VTKCellTypes. VTK_QUAD, [1 , 2 , 3 , 4 ] .+ 4 * (i- 1 ))
2782+
2783+ mu_upper, mu_lower = _get_wakestrength_mu (body, i)
2784+ strengths[i] = mu_upper - mu_lower
2785+ end
2786+
2787+ WriteVTK. vtk_grid (vtm, name * " _wake_$i_surf " , points, cells) do vtk
2788+ vtk[" mu" ] = strengths
2789+ end
2790+ end
2791+ pvd[t] = vtm
2792+ end
2793+
2794+ # restore original values of Da and Db if they were modified for visualization
2795+ if body. semiinfinite_wake
2796+ for (Das, Dbs) in zip (body. Das, body. Dbs)
2797+ for i in 1 : size (Das, 2 )
2798+ # norm_Da = norm(view(Das, :, i))
2799+ # norm_Db = norm(view(Dbs, :, i))
2800+ Das[:, i] ./= semiinfinite_length # / norm_Da
2801+ Dbs[:, i] ./= semiinfinite_length # / norm_Db
2802+ end
2803+ end
2804+ end
2805+ end
0 commit comments