Skip to content

Commit

Permalink
Merge pull request #34 from byuflowlab/correct_intep
Browse files Browse the repository at this point in the history
Added reference line and test
  • Loading branch information
BTV25 authored Apr 10, 2024
2 parents c2a4472 + ccd761a commit ed33100
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/geometry.jl
Original file line number Diff line number Diff line change
Expand Up @@ -513,6 +513,8 @@ with dimensions (i, j) containing the generated panels.
- `ns`: number of spanwise panels
- `nc`: number of chordwise panels
- `fc`: (optional) camber line function y=f(x) of each airfoil section
- 'reference_line': 2D array, each row is the x, y coordinate of the reference point of the airfoil.
This allows xle, yle, and zle to be defined about points that are not the leading edge
- `mirror`: mirror the geometry across the X-Z plane?, defaults to `false`
- `fcore`: function for setting the finite core size based on the chord length
(in the x-direction) and/or the panel width (in the y/z directions).
Expand All @@ -523,6 +525,7 @@ with dimensions (i, j) containing the generated panels.
"""
function wing_to_surface_panels(xle, yle, zle, chord, theta, phi, ns, nc;
fc = fill(x->0, length(xle)),
reference_line = zeros(length(xle),2),
mirror = false,
fcore = (c, Δs) -> 1e-3,
spacing_s = Cosine(),
Expand Down Expand Up @@ -558,8 +561,10 @@ function wing_to_surface_panels(xle, yle, zle, chord, theta, phi, ns, nc;
sp, cp = sincos(phi[j])
Rp = @SMatrix [1 0 0; 0 cp -sp; 0 sp cp]

reference_offset = SVector(reference_line[j,1],0.0,reference_line[j,2]) * chord[j]

# location of leading edge
rle = SVector(xle[j], yle[j], zle[j])
rle = SVector(xle[j], yle[j], zle[j]) - (Rt * reference_offset)

# panel edge chordwise locations
for i = 1:nc+1
Expand Down
25 changes: 25 additions & 0 deletions test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1009,6 +1009,31 @@ end
@test isapprox(getproperty(surface1[I], field), getproperty(surface4[I], field))
end
end

# Reference line (use 0.5 * chord as reference so middle chorwise node will have x and z = 0)

xle = zeros(2)
yle = LinRange(0,4,length(xle))
zle = zeros(length(xle))
chord = [2.0, 2.0]
theta = zeros(length(xle))# .+ 30*pi/180#LinRange(0,30*pi/180,length(xle))
phi = zeros(length(xle))
ns = 4
nc = 2
spacing_s = Uniform()
spacing_c = Uniform()

my_ref = zeros(length(xle),2)
my_ref[:,1] .= 0.5

# construct surface
grid, surface = wing_to_surface_panels(xle, yle, zle, chord, theta, phi, ns, nc;spacing_s=spacing_s, spacing_c=spacing_c, reference_line=my_ref)

for p = 1:ns+1
@test grid[1,2,p] == 0.0
@test grid[2,2,p] == p-1
@test grid[3,2,p] == 0.0
end
end

@testset "Grid Input" begin
Expand Down

0 comments on commit ed33100

Please sign in to comment.