@@ -15,16 +15,17 @@ import LaTeXStrings: @L_str
1515# LIFTING LINE STRUCT
1616# ###############################################################################
1717struct LiftingLine{ R<: Number ,
18- S<: StripwiseElement ,
18+ S<: StripwiseElement , N,
1919 VectorType<: AbstractVector{R} ,
2020 MatrixType<: AbstractMatrix{R} ,
2121 TensorType<: AbstractArray{R, 3} ,
22- LI<: LinearIndices }
22+ LI<: LinearIndices } <: AbstractBody{S, N}
2323
2424 # Internal properties
2525 grid:: gt.Grid # Flat-geometry grid
2626 linearindices:: LI # Linear indices of grid.nodes where linearindices[i, j]
2727 # is TE (j==1) or LE (j==2) of the i-th row of nodes
28+ fields:: Vector{String} # Available fields (solutions)
2829
2930 ypositions:: Vector{Float64} # Non-dimensional y-position of nodes, 2*y/b
3031
@@ -44,12 +45,13 @@ struct LiftingLine{ R<:Number,
4445 # j-th semi-infinite filament (1==a, 2==b) of the
4546 # n-th horeseshoe
4647
47- midpoints:: MatrixType # Midpoint along bound vortex for probing the velocity
48+ midpoints:: MatrixType # Midpoint along lifting line for probing the velocity
4849 controlpoints:: MatrixType # Control point of each horseshoe
4950 normals:: MatrixType # Normal of each horseshoe
5051
5152 aoas:: VectorType # (deg) angle of attack seen by each stripwise element
5253 Gammas:: VectorType # Circulation of each horseshoe
54+ Us:: MatrixType # Velocity at each midpoint
5355
5456 G:: MatrixType # Geometry matrix in linear system of equations
5557 RHS:: VectorType # Right-hand-side vector in linear system of equations
@@ -116,11 +118,13 @@ struct LiftingLine{ R<:Number,
116118 normals = MatrixType (undef, 3 , nelements)
117119 aoas = VectorType (undef, nelements)
118120 Gammas = VectorType (undef, nelements)
121+ Us = MatrixType (undef, 3 , nelements)
119122 G = MatrixType (undef, nelements, nelements)
120123 RHS = VectorType (undef, nelements)
121124
122125 aoas .= 0
123126 Gammas .= 0
127+ Us .= 0
124128 G .= 0
125129 RHS .= 0
126130
@@ -139,17 +143,17 @@ struct LiftingLine{ R<:Number,
139143
140144 calc_Dinfs! (Dinfs, initial_Uinf, nelements)
141145
142-
146+ S = eltype (elements)
143147 new{R,
144- eltype (elements ),
148+ S, _count (S ),
145149 VectorType, MatrixType, TensorType,
146150 typeof (linearindices)}(
147- grid, linearindices,
151+ grid, linearindices, String[],
148152 ypositions,
149153 nelements, elements,
150154 aerocenters, horseshoes, Dinfs,
151155 midpoints, controlpoints, normals,
152- aoas, Gammas,
156+ aoas, Gammas, Us,
153157 G, RHS,
154158 kerneloffset, kernelcutoff)
155159
@@ -189,10 +193,16 @@ function remorph!(self::LiftingLine, args...;
189193
190194 calc_Dinfs! (self, Uinf)
191195
196+ # Reset solution
197+ self. aoas .= 0
198+ self. Gammas .= 0
199+ self. Us .= 0
200+
192201 return nothing
193202end
194203
195204
205+
196206function save (self:: LiftingLine , filename:: AbstractString ;
197207 format= " vtk" ,
198208 horseshoe_suffix= " _horseshoe" ,
@@ -265,7 +275,11 @@ function save(self::LiftingLine, filename::AbstractString;
265275 midpoints_data = [
266276 Dict ( " field_name" => " angleofattack" ,
267277 " field_type" => " scalar" ,
268- " field_data" => self. aoas)
278+ " field_data" => self. aoas),
279+
280+ Dict ( " field_name" => " U" ,
281+ " field_type" => " vector" ,
282+ " field_data" => eachcol (self. Us))
269283 ]
270284
271285 str *= gt. generateVTK (filename* midpoint_suffix, midpoints;
@@ -288,23 +302,41 @@ function save(self::LiftingLine, filename::AbstractString;
288302 point_data= controlpoints_data, optargs... )
289303
290304 # ------------- OUTPUT PLANAR GEOMETRY ------------------------------------
291- planar_data = [
292- Dict ( " field_name" => " Gamma" ,
293- " field_type" => " scalar" ,
294- " field_data" => self. Gammas)
295-
296- Dict ( " field_name" => " angleofattack" ,
297- " field_type" => " scalar" ,
298- " field_data" => self. aoas)
299- ]
300305
301- str *= gt. save (self. grid, filename* planar_suffix;
302- cell_data= planar_data, format, optargs... )
306+ str *= gt. save (self. grid, filename* planar_suffix; format, optargs... )
303307
304308 return str
305309end
306310
307311
312+ function add_field (self:: LiftingLine , field_name:: String , field_type:: String ,
313+ field_data, entry_type:: String ;
314+ raise_warn= false , collectfield= true )
315+
316+ # Add field to grid
317+ gt. add_field (self. grid, field_name, field_type,
318+ collectfield ? collect (field_data) : field_data, entry_type;
319+ raise_warn= raise_warn)
320+
321+ # Register the field
322+ if ! (field_name in self. fields)
323+ push! (self. fields, field_name)
324+ end
325+
326+ nothing
327+ end
328+
329+ check_field (self:: LiftingLine , field_name:: String ) = field_name in self. fields
330+
331+ function get_field (self:: LiftingLine , field_name:: String )
332+
333+ @assert check_field (self, field_name) " " *
334+ " Field $field_name not found! Available fields: $(self. fields) "
335+
336+ return self. grid. field[field_name]
337+ end
338+
339+
308340function calc_horseshoes! (self:: LiftingLine , args... ; optargs... )
309341 return calc_horseshoes! (self. horseshoes,
310342 self. grid. nodes, self. linearindices,
@@ -552,9 +584,14 @@ function solve_linear(self::LiftingLine, Uinfs::AbstractMatrix;
552584 # Solve system of equations
553585 solver (self. Gammas, self. G, self. RHS; solver_optargs... )
554586
587+ # Calculate velocity at lifting-line midpoints
588+ self. Us .= Uinfs
589+ Uind! (self, self. midpoints, self. Us)
590+
555591 if addfields
556592 gt. add_field (self. grid, " Uinf" , " vector" , collect (eachcol (Uinfs)), " cell" ; raise_warn)
557593 gt. add_field (self. grid, " Gamma" , " scalar" , self. Gammas, " cell" ; raise_warn)
594+ gt. add_field (self. grid, " angleofattack" , " scalar" , self. aoas, " cell" ; raise_warn)
558595 end
559596
560597 return nothing
0 commit comments