From bb7208599bc1e55169c6e868fd2cf40a0acb3d18 Mon Sep 17 00:00:00 2001 From: juddmehr Date: Sat, 9 Nov 2024 08:15:35 -0700 Subject: [PATCH] add progress bars to animation generation functions --- Project.toml | 3 ++- src/DuctAPE.jl | 1 + src/visualization/convenience_plots.jl | 23 +++++++++++++++++++++++ 3 files changed, 26 insertions(+), 1 deletion(-) diff --git a/Project.toml b/Project.toml index c3a375f..e422a1b 100644 --- a/Project.toml +++ b/Project.toml @@ -1,7 +1,7 @@ name = "DuctAPE" uuid = "ad8e49fd-fab7-444e-af4a-0daba3b8bf11" authors = ["Judd Mehr"] -version = "0.6" +version = "0.6.0" [deps] BenchmarkTools = "6e4b80f9-dd63-53aa-95a3-0cdb28fa8baf" @@ -19,6 +19,7 @@ MINPACK = "4854310b-de5a-5eb6-a2a5-c1dee2bd17f9" NLsolve = "2774e3e8-f4cf-5e23-947b-6d7e65073b56" PreallocationTools = "d236fae5-4411-538c-8e31-a6e3d9e00b46" Printf = "de0858da-6303-5e67-8744-51eddeeeb8d7" +ProgressMeter = "92933f4c-e287-5a05-a399-4b506db050ca" QuadGK = "1fd47b50-473d-5c70-9696-f719f8f3bcdc" RecipesBase = "3cdcf5f2-1ef4-517c-9805-6587b60abb01" Roots = "f2b01f46-fcfa-551c-844a-d8ac1e96c665" diff --git a/src/DuctAPE.jl b/src/DuctAPE.jl index 67e4c82..9dc4236 100644 --- a/src/DuctAPE.jl +++ b/src/DuctAPE.jl @@ -53,6 +53,7 @@ using RecipesBase # for plotting # - Visualization Packages - # import Colors.RGB using LaTeXStrings +using ProgressMeter #---------------------------------# # EXPORTS # diff --git a/src/visualization/convenience_plots.jl b/src/visualization/convenience_plots.jl index 88890a2..5e1e5ef 100644 --- a/src/visualization/convenience_plots.jl +++ b/src/visualization/convenience_plots.jl @@ -195,6 +195,7 @@ function generate_plots( markerstrokecolor=2, kwargs..., ) + Plots.savefig(save_path * "streamlines" * i * static_file_type) end end @@ -240,6 +241,9 @@ function generate_plots( if plot_pressure verbose && println("Animating Surface Pressure") anim = Plots.Animation() + if verbose + pbar = Progress(length(outs); desc="Generating Frames...", showspeed=true) + end for out in outs # underlay geometry first @@ -260,7 +264,9 @@ function generate_plots( ) Plots.frame(anim, plt) + verbose && next!(pbar) end + verbose && println("Saving $(save_path)surface_pressure.gif") Plots.gif(anim, save_path * "surface_pressure.gif") end @@ -268,6 +274,9 @@ function generate_plots( if plot_velocity verbose && println("Animating Surface Velocity") anim = Plots.Animation() + if verbose + pbar = Progress(length(outs); desc="Generating Frames...", showspeed=true) + end for out in outs # underlay geometry first plt = Plots.plot( @@ -287,7 +296,9 @@ function generate_plots( (; kwargs..., background_color=:white)..., ) Plots.frame(anim, plt) + verbose && next!(pbar) end + verbose && println("Saving $(save_path)surface_velocity.gif") Plots.gif(anim, save_path * "surface_velocity.gif") end @@ -295,6 +306,9 @@ function generate_plots( if plot_boundary_layer verbose && println("Animating Boundary Layer") anim = Plots.Animation() + if verbose + pbar = Progress(length(outs); desc="Generating Frames...", showspeed=true) + end for out in outs # Plots.plot momentum thicknesses on top plt = Plots.plot( @@ -319,13 +333,18 @@ function generate_plots( (; kwargs..., background_color=:white)..., ) Plots.frame(anim, plt) + verbose && next!(pbar) end + verbose && println("Saving $(save_path)boundary_layer.gif") Plots.gif(anim, save_path * "boundary_layer.gif") end # - Streamlines - # if plot_streamlines verbose && println("Animating Streamlines") + if verbose + pbar = Progress(length(outs); desc="Generating Frames...", showspeed=true) + end anim = Plots.Animation() for out in outs plt = Plots.plot(plotBodyGeometry(), body_vortex_panels; kwargs...) @@ -357,8 +376,12 @@ function generate_plots( markerstrokecolor=2, (; kwargs..., background_color=:white)..., ) + Plots.frame(anim, plt) + + verbose && next!(pbar) end + verbose && println("Saving $(save_path)streamlines.gif") Plots.gif(anim, save_path * "streamlines.gif") end