Skip to content

Commit

Permalink
fixing examples
Browse files Browse the repository at this point in the history
  • Loading branch information
grasingerm committed May 12, 2022
1 parent 93113f9 commit 4f8c9bf
Show file tree
Hide file tree
Showing 7 changed files with 25 additions and 29 deletions.
8 changes: 4 additions & 4 deletions example_sims/free-surface/fill_cavity.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,8 @@ obstacles:
bcs:
- south_bounce_back!
- north_bounce_back!
- FastAnonymous.@anon (sim) -> mass_inlet!(sim, 1, 1:8, 1.0)
- FastAnonymous.@anon (sim) -> west_velocity!(sim.lat, 0.005, 1, 1, 8)
- (sim) -> mass_inlet!(sim, 1, 1:8, 1.0)
- (sim) -> west_velocity!(sim.lat, 0.005, 1, 1, 8)
- east_bounce_back!

# free surface conditions
Expand All @@ -50,7 +50,7 @@ fill_y: { value: 0.25, expr: false }
# callback functions
callbacks:
- print_step_callback(50, "free-surf")
- plot_mass_contours_callback(250, joinpath(datadir, "mass"), [(8, 32, 1/ni, 8/ni)]; levs=[-0.5; 0.0; 0.5; 1.0; 1.5; 2.0])
- pycontour_callback(200, mass_acsr; fname=joinpath(datadir, "mass"), rects=[(8, 32, 1/ni, 8/ni)], levels=[-0.25; 0.0; 0.25; 0.5; 0.75; 1.0])
- write_jld_file_callback(datadir, 5000)

# clean-up, backup, write out
Expand All @@ -75,5 +75,5 @@ finally:
end
print_with_color(:green, "TEST PASSED\n");
end
- plot_mass_contours_callback(1, joinpath(datadir, "mass"))
- pycontour_callback(1, mass_acsr; fname=joinpath(datadir, "mass"), rects=[(8, 32, 1/ni, 8/ni)], levels=[-0.25; 0.0; 0.25; 0.5; 0.75; 1.0])
- write_jld_file_callback(datadir)
8 changes: 4 additions & 4 deletions example_sims/free-surface/fill_cavity2.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,8 @@ obstacles:
bcs:
- south_bounce_back!
- north_bounce_back!
- FastAnonymous.@anon (sim) -> mass_inlet!(sim, 1, 1:8, 1.0)
- FastAnonymous.@anon (sim) -> west_velocity!(sim.lat, 0.005, 1, 1, 8)
- (sim) -> mass_inlet!(sim, 1, 1:8, 1.0)
- (sim) -> west_velocity!(sim.lat, 0.005, 1, 1, 8)
- east_bounce_back!

# free surface conditions
Expand All @@ -50,7 +50,7 @@ fill_y: { value: 0.25, expr: false }
# callback functions
callbacks:
- print_step_callback(50, "free-surf")
- plot_mass_contours_callback(250, joinpath(datadir, "mass"), [(8, 32, 1/ni, 8/ni)]; levs=[-0.5; 0.0; 0.5; 1.0; 1.5; 2.0])
- pycontour_callback(200, mass_acsr; fname=joinpath(datadir, "mass"), rects=[(8, 32, 1/ni, 8/ni)], levels=[-0.25; 0.0; 0.25; 0.5; 0.75; 1.0])
- write_jld_file_callback(datadir, 5000)

# clean-up, backup, write out
Expand All @@ -75,5 +75,5 @@ finally:
end
print_with_color(:green, "TEST PASSED\n");
end
- plot_mass_contours_callback(1, joinpath(datadir, "mass"))
- pycontour_callback(1, mass_acsr; fname=joinpath(datadir, "mass"), rects=[(8, 32, 1/ni, 8/ni)], levels=[-0.25; 0.0; 0.25; 0.5; 0.75; 1.0])
- write_jld_file_callback(datadir)
4 changes: 2 additions & 2 deletions example_sims/free-surface/fill_cavity3.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ fill_y: { value: 0.25, expr: false }
# callback functions
callbacks:
- print_step_callback(50, "free-surf")
- plot_mass_contours_callback(250, joinpath(datadir, "mass"), [(8, 32, 1/ni, 8/ni)]; levs=[-0.5; 0.0; 0.5; 1.0; 1.5; 2.0])
- pycontour_callback(200, mass_acsr; fname=joinpath(datadir, "mass"), rects=[(8, 32, 1/ni, 8/ni), levels=[-0.25; 0.0; 0.25; 0.5; 0.75; 1.0])
- write_jld_file_callback(datadir, 5000)

# clean-up, backup, write out
Expand All @@ -75,5 +75,5 @@ finally:
end
print_with_color(:green, "TEST PASSED\n");
end
- plot_mass_contours_callback(1, joinpath(datadir, "mass"))
- pycontour_callback(1, mass_acsr; fname=joinpath(datadir, "mass"), rects=[(8, 32, 1/ni, 8/ni), levels=[-0.25; 0.0; 0.25; 0.5; 0.75; 1.0])
- write_jld_file_callback(datadir)
8 changes: 4 additions & 4 deletions example_sims/free-surface/fill_cavity4.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,8 @@ obstacles:
bcs:
- south_bounce_back!
- north_bounce_back!
- FastAnonymous.@anon (sim) -> mass_inlet!(sim, 1, 1:8, 1.0)
- FastAnonymous.@anon (sim) -> west_velocity!(sim.lat, 0.005, 1, 1, 8)
- (sim) -> mass_inlet!(sim, 1, 1:8, 1.0)
- (sim) -> west_velocity!(sim.lat, 0.005, 1, 1, 8)
- east_bounce_back!

# free surface conditions
Expand All @@ -50,7 +50,7 @@ fill_y: { value: 0.25, expr: false }
# callback functions
callbacks:
- print_step_callback(50, "free-surf")
- plot_mass_contours_callback(250, joinpath(datadir, "mass"), [(1, 24, 32/ni, 40/ni), (8, 32, 1/ni, 8/ni)]; levs=[-0.5; 0.0; 0.5; 1.0; 1.5; 2.0])
- pycontour_callback(200, mass_acsr; fname=joinpath(datadir, "mass"), rects=[(1, 24, 32/ni, 40/ni), (8, 32, 1/ni, 8/ni)], levels=[-0.25; 0.0; 0.25; 0.5; 0.75; 1.0])
- write_jld_file_callback(datadir, 5000)

# clean-up, backup, write out
Expand All @@ -75,5 +75,5 @@ finally:
end
print_with_color(:green, "TEST PASSED\n");
end
- plot_mass_contours_callback(1, joinpath(datadir, "mass"))
- pycontour_callback(1, mass_acsr; fname=joinpath(datadir, "mass"), rects=[(1, 24, 32/ni, 40/ni), (8, 32, 1/ni, 8/ni)], levels=[-0.25; 0.0; 0.25; 0.5; 0.75; 1.0])
- write_jld_file_callback(datadir)
2 changes: 1 addition & 1 deletion inc/io/animate.jl
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ end
#! \param rcolor Rectangle color
#! \return Anonymous callback function for visualization
function pycontour_callback(stepout::Real, accessor::LBXFunction;
showfig::Bool=true, filled=false, colorbar=false,
showfig::Bool=true, filled=true, colorbar=false,
levels=false, fname::AbstractString="",
title::AbstractString="", xlabel::AbstractString="",
ylabel::AbstractString="", xlim=false, ylim=false,
Expand Down
2 changes: 1 addition & 1 deletion inc/obstacle.jl
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ function _add_obstacle_bounce_back!(active_cells::Matrix{Bool},
bcs!::Vector{LBXFunction},
i_min::Int, i_max::Int, j_min::Int,
j_max::Int)
active_cells[i_min+1:i_max-1, j_min+1:j_max-1] = false;
active_cells[i_min+1:i_max-1, j_min+1:j_max-1] .= false;
push!(bcs!, sim -> north_bounce_back!(sim.lat, i_min, i_max, j_min));
push!(bcs!, sim -> south_bounce_back!(sim.lat, i_min, i_max, j_max));
push!(bcs!, sim -> east_bounce_back!(sim.lat, i_min, j_min, j_max));
Expand Down
22 changes: 9 additions & 13 deletions inc/sim/simulate.jl
Original file line number Diff line number Diff line change
Expand Up @@ -262,37 +262,33 @@ function sim_step!(sim::FreeSurfSim,
t = sim.tracker;
unorms = Dict{Tuple{Int, Int}, Vector{Float64}}();

@_checkdebug_mass_cons("whole step", t.M, begin
# Algorithm should be:
# 1. mass transfer
@_checkdebug_mass_cons("masstransfer!", t.M, masstransfer!(sim, active_cells), 1e-9);
masstransfer!(sim, active_cells);

# 2. stream
@_checkdebug_mass_cons("stream!", t.M, stream!(lat, temp_f, active_cells, t), 1e-9);
stream!(lat, temp_f, active_cells, t);

# 3. reconstruct distribution functions from empty cells
# 4. reconstruct distribution functions along interface normal
@_checkdebug_mass_cons("f_reconst!", t.M,
for (i, j) in t.interfacels #TODO maybe abstract out interface list...
unorms[(i, j)] = f_reconst!(sim, t, (i, j), collision_f!.feq_f, sim.rho_g);
end, 1e-9);
end

# 5. particle collisions
@_checkdebug_mass_cons("collision_f!", t.M, collision_f!(sim, active_cells), 1e-9);
collision_f!(sim, active_cells);

# 6. enforce boundary conditions
@_checkdebug_mass_cons("bcs!", t.M, for bc! in bcs!
bc!(sim);
end, 1e-9);
for bc! in bcs!
@eval $bc!($sim);
end

# 7. calculate macroscopic variables
@_checkdebug_mass_cons("map_to_macro!", t.M, map_to_macro!(lat, msm), 1e-9);
map_to_macro!(lat, msm);

# 8. update fluid fractions
# 9. update cell states
@_checkdebug_mass_cons("update!", t.M,
update!(sim, collision_f!.feq_f, unorms), 1e-9);
end, 1e-9);
update!(sim, collision_f!.feq_f, unorms);
end

# Adaptive time step simulation step
Expand Down

0 comments on commit 4f8c9bf

Please sign in to comment.