-
Notifications
You must be signed in to change notification settings - Fork 6
Description
TL;DR
It seems that ParametricBodies struggles with thin bodies.
The issue
We've run into the following issue: for a flapping NACA foil, the lift force is unphysical. We get the same issue if the body is instead an ellipse, but only if the ellipse is thin enough.
Representative result
Here's the lift on a NACA0010 foil. The foil is parallel to the freestream, sinusoidally heaving with a reduced frequency of 5 and amplitude equal to 5% of the foil's length. The Reynolds number is 100, and the length of the foil is 64 grid points.
Observation: the "corners" in the lift curve coincide with the trailing edge moving into a different cell (i.e., they coincide with changes in floor(heave)). Other corners coincide with changes in round(heave).
Here's the same result for a higher resolution (length of foil = 128 grid points). The corners in the lift curve again coincide with the trailing edge moving into a different cell, which occurs more frequently due to the more refined grid.
Notes
- This issue is independent of the Reynolds number.
- For Re = 100, a grid resolution of 64 points per chord should be sufficient to resolve the flow. Even though refining the grid makes the unphysical spikes smaller, I don't think the solution is to simply continue refining the grid until the spikes are gone. Even at a resolution of 192 grid points per chord—which is far above what is typically required for such a problem at a Reynolds number of 100—the lift curve still has unphysical spikes.
- Looking into the force calculation, the output of WaterLily.nds looks reasonable. The issue seems to be with the pressure field.
- The velocity and vorticity fields look reasonable despite the unphysical lift.
- The same issue occurs for a very thin ellipse (e.g., aspect ratio of 10). Thicker ellipses (e.g., aspect ratio of 5) don't have this issue.
Thoughts and minimal working example
We aren't sure if this is a WaterLily issue or a ParametricBodies issue. However, the following test suggests it may be a ParametricBodies issue.
Here's an example identical to the NACA example up top, except the body is a plate with some thickness (same as in the TwoD_Hover example). This allows us to make the body in two ways: using an SDF, and using ParametricBodies. We've found that for most values of the thickness thk, the two ways of creating the body give nearly identical lift curves. However, for the default value in the script below, the body created using ParametricBodies produces unphysical lift, while the one created with an SDF is physical. The two bodies look the same when we plot them.
using WaterLily,StaticArrays
using Plots
using ParametricBodies
# Calculate force due to pressure
function pressure_force(sim;t=WaterLily.time(sim.flow),T=promote_type(Float64,eltype(sim.flow.p)))
sim.flow.f .= zero(eltype(sim.flow.p))
@WaterLily.loop sim.flow.f[I,:] .= sim.flow.p[I]*WaterLily.nds(sim.body,loc(0,I,T),t) over I ∈ WaterLily.inside(sim.flow.p)
sum(T,sim.flow.f,dims=ntuple(i->i,ndims(sim.flow.p)))[:] |> Array
end
# Simulation using SDF
function make_sim(;L=64,Re=1e2,sigma_L=1,U=1,thk=5+√2,n=3,m=2,T=Float64,mem=Array)
nose = SA[L,L]
h₀=T(0.05*L);
ω = T(2*sigma_L/L)
# Line segment SDF
function sdf(x,t)
y = x .- SA[clamp(x[1],0,L),0]
√sum(abs2,y)-thk/2
end
# Oscillating motion
function map(x,t)
h = SA[0, h₀ * sin(ω * t)]
(x - nose - h)
end
Simulation((n*L,m*L),(U,0),L;ν=U*L/Re,body=AutoBody(sdf,map),T,mem)
end
# Simulation using ParametricBodies
function make_sim1(;L=64,Re=1e2,sigma_L=1,U=1,thk=5+√2,n=3,m=2,T=Float64,mem=Array)
# Map from simulation coordinate x to surface coordinate ξ
nose = SA[3*L/2,L]
h₀=T(0.05*L);
ω = T(2*sigma_L/L)
function map(x, t)
h = SA[0, h₀ * sin(ω * t)]
ξ = x - nose - h
return SA[ξ[1], abs(ξ[2])]
end
# Define foil using NACA0010 profile equation: https://tinyurl.com/NACA00xx
foil(s,t) = (s<π/4)*SA[L/2 + thk/2*cos(2*s),thk/2*sin(2*s)] + (s>3*π/4)*SA[-L/2 + thk/2*cos(2*s-π),thk/2*sin(2*s-π)] + (s>=π/4 && s<=3*π/4)*SA[L/2 - L*(s - π/4)*2/π,thk/2]
body = HashedBody(foil,(0,π);map,T,mem)
Simulation((n*L,m*L),(U,0),L;ν=U*L/Re,body,T,mem);
end
# Run and compare the two simulations
res=64;
sigma=5;
thk=5+√2
sim = make_sim(L=res,sigma_L=sigma,thk=thk);
sim1 = make_sim1(L=res,sigma_L=sigma,thk=thk);
nosc=1; tmax=(π/(sigma))*nosc
cycle = range(0,tmax,nosc*50)
p,p1 = [],[]
for t ∈ sim_time(sim).+cycle
sim_step!(sim,t,remeasure=true)
push!(p,pressure_force(sim))
end
for t ∈ sim_time(sim1).+cycle
sim_step!(sim1,t,remeasure=true)
push!(p1,pressure_force(sim1))
end
plot(cycle, 2last.(p)/sim.L, xlabel="tU/L", ylabel="Pressure lift")
plot!(cycle, 2last.(p1)/sim1.L, xlabel="tU/L", ylabel="Pressure lift")


