Skip to content

Commit

Permalink
add meshing routine
Browse files Browse the repository at this point in the history
  • Loading branch information
Gabe Weymouth committed May 19, 2023
1 parent af00631 commit 1efb14e
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 2 deletions.
2 changes: 2 additions & 0 deletions examples/Project.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
[deps]
GLMakie = "e9467ef8-e4e7-5192-8a1a-b1aee30e663a"
GR = "28b8d3ca-fb5f-59d9-8090-bfdbd6d07a71"
GeometryBasics = "5c1252a2-5f33-56bf-86c9-59e7332b4326"
Makie = "ee78f7c6-11fb-53f2-987a-cfe4a2b5a57a"
Meshing = "e6723b4c-ebff-59f1-b4b7-d97aa5274f73"
Plots = "91a5bcdd-55d7-5caf-9e0b-520d859cae80"
UnicodePlots = "b8865327-cd53-5732-bb35-84acbb429228"
WaterLily = "ed894a53-35f9-47f1-b17f-85db9237eebd"
22 changes: 20 additions & 2 deletions examples/ThreeD_Plots.jl
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
using GLMakie
GLMakie.activate!()
function makie_video!(makie_plot,sim,dat,obs_update!;remeasure=false,name="file.mp4",duration=1,step=0.1,framerate=30,compression=20)
# Set up viz data and figure
obs = obs_update!(dat,sim) |> Observable;
fig, _, _ = makie_plot(obs)
f = makie_plot(obs)

# Run simulation and update figure data
t₀ = round(sim_time(sim))
Expand All @@ -12,5 +13,22 @@ function makie_video!(makie_plot,sim,dat,obs_update!;remeasure=false,name="file.
obs[] = obs_update!(dat,sim)
println("simulation ",round(Int,(tᵢ-t₀)/duration*100),"% complete")
end
return fig
return f
end

using Meshing, GeometryBasics
function body_mesh(sim,t=0)
a = sim.flow.σ; R = inside(a)
WaterLily.measure_sdf!(a,sim.body,t)
normal_mesh(GeometryBasics.Mesh(a[R]|>Array,MarchingCubes(),origin=Vec(0,0,0),widths=size(R)))
end;
function flow_λ₂!(dat,sim)
a = sim.flow.σ
@inside a[I] = max(0,log10(-min(-1e-6,WaterLily.λ₂(I,sim.flow.u)*(sim.L/sim.U)^2))+.25)
copyto!(dat,a[inside(a)]) # copy to CPU
end
function flow_λ₂(sim)
dat = sim.flow.σ[inside(sim.flow.σ)] |> Array
flow_λ₂!(dat,sim)
dat
end

0 comments on commit 1efb14e

Please sign in to comment.