Skip to content

Commit

Permalink
Merge pull request #172 from mabarnes/looping-fix-ranges
Browse files Browse the repository at this point in the history
Stop @loop_* ranges being altered from inside loop
  • Loading branch information
johnomotani authored Dec 16, 2023
2 parents 65be0cd + d085da4 commit d9dea96
Show file tree
Hide file tree
Showing 4 changed files with 39 additions and 14 deletions.
18 changes: 13 additions & 5 deletions performance-tests/sound_wave-2xres.jl
Original file line number Diff line number Diff line change
Expand Up @@ -34,15 +34,15 @@ test_input_finite_difference = Dict("n_ion_species" => 1,
"z_IC_upar_amplitude1" => 0.0,
"z_IC_upar_phase1" => 0.0,
"z_IC_temperature_amplitude1" => 0.5,
"z_IC_temperature_phase1" => π,
"z_IC_temperature_phase1" => Float64(π),
"z_IC_option2" => "sinusoid",
"z_IC_density_amplitude2" => 0.5,
"z_IC_density_phase2" => π,
"z_IC_density_phase2" => Float64(π),
"z_IC_upar_amplitude2" => 0.0,
"z_IC_upar_phase2" => 0.0,
"z_IC_temperature_amplitude2" => 0.5,
"z_IC_temperature_phase2" => 0.0,
"charge_exchange_frequency" => 2*π*0.1,
"charge_exchange_frequency" => 2*Float64(π)*0.1,
"ionization_frequency" => 0.0,
"nstep" => 100,
"dt" => 0.0002,
Expand All @@ -60,7 +60,12 @@ test_input_finite_difference = Dict("n_ion_species" => 1,
"vpa_nelement" => 1,
"vpa_L" => vpa_L,
"vpa_bc" => "periodic",
"vpa_discretization" => "finite_difference")
"vpa_discretization" => "finite_difference",
"vz_ngrid" => 481,
"vz_nelement" => 1,
"vz_L" => vpa_L,
"vz_bc" => "periodic",
"vz_discretization" => "finite_difference")

test_input_finite_difference_split_1_moment =
merge(test_input_finite_difference,
Expand All @@ -84,7 +89,10 @@ test_input_chebyshev = merge(test_input_finite_difference,
"z_nelement" => 20,
"vpa_discretization" => "chebyshev_pseudospectral",
"vpa_ngrid" => 34,
"vpa_nelement" => 15))
"vpa_nelement" => 15,
"vz_discretization" => "chebyshev_pseudospectral",
"vz_ngrid" => 34,
"vz_nelement" => 15))

test_input_chebyshev_split_1_moment =
merge(test_input_chebyshev,
Expand Down
18 changes: 13 additions & 5 deletions performance-tests/sound_wave.jl
Original file line number Diff line number Diff line change
Expand Up @@ -34,15 +34,15 @@ test_input_finite_difference = Dict("n_ion_species" => 1,
"z_IC_upar_amplitude1" => 0.0,
"z_IC_upar_phase1" => 0.0,
"z_IC_temperature_amplitude1" => 0.5,
"z_IC_temperature_phase1" => π,
"z_IC_temperature_phase1" => Float64(π),
"z_IC_option2" => "sinusoid",
"z_IC_density_amplitude2" => 0.5,
"z_IC_density_phase2" => π,
"z_IC_density_phase2" => Float64(π),
"z_IC_upar_amplitude2" => 0.0,
"z_IC_upar_phase2" => 0.0,
"z_IC_temperature_amplitude2" => 0.5,
"z_IC_temperature_phase2" => 0.0,
"charge_exchange_frequency" => 2*π*0.1,
"charge_exchange_frequency" => 2*Float64(π)*0.1,
"ionization_frequency" => 0.0,
"nstep" => 100,
"dt" => 0.0005,
Expand All @@ -60,7 +60,12 @@ test_input_finite_difference = Dict("n_ion_species" => 1,
"vpa_nelement" => 1,
"vpa_L" => vpa_L,
"vpa_bc" => "periodic",
"vpa_discretization" => "finite_difference")
"vpa_discretization" => "finite_difference",
"vz_ngrid" => 241,
"vz_nelement" => 1,
"vz_L" => vpa_L,
"vz_bc" => "periodic",
"vz_discretization" => "finite_difference")

test_input_finite_difference_split_1_moment =
merge(test_input_finite_difference,
Expand All @@ -84,7 +89,10 @@ test_input_chebyshev = merge(test_input_finite_difference,
"z_nelement" => 10,
"vpa_discretization" => "chebyshev_pseudospectral",
"vpa_ngrid" => 17,
"vpa_nelement" => 15))
"vpa_nelement" => 15,
"vz_discretization" => "chebyshev_pseudospectral",
"vz_ngrid" => 17,
"vz_nelement" => 15))

test_input_chebyshev_split_1_moment =
merge(test_input_chebyshev,
Expand Down
1 change: 0 additions & 1 deletion src/fokker_planck.jl
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,6 @@ function explicit_fokker_planck_collisions_weak_form!(pdf_out,pdf_in,dSdt,compos
@serial_region begin
dSdt[iz,ir,is] = -get_density(lnfC,vpa,vperp)
end
begin_vperp_vpa_region()
end
end
return nothing
Expand Down
16 changes: 13 additions & 3 deletions src/looping.jl
Original file line number Diff line number Diff line change
Expand Up @@ -407,14 +407,24 @@ for dims ∈ dimension_combinations
function $nested_macro_body_name(body, it_vars...)
ex = Expr(:escape, body)
# Reverse it_vars so final iteration variable is the inner loop
for (it, range) zip(reverse(it_vars), reverse($range_exprs))
this_range = eval(range)
it_vars_vec = collect(reverse(it_vars))
for i 1:length(it_vars_vec)
rangei = Symbol(:range, i)
ex = quote
for $(esc(it)) = $this_range
for $(esc(it_vars_vec[i])) = $rangei
$ex
end
end
end
range_exprs_vec = collect(reverse($range_exprs))
for i 1:length(it_vars_vec)
rangei = Symbol(:range, i)
range_expr = eval(range_exprs_vec[i])
ex = quote
$rangei = $range_expr
$ex
end
end
return ex
end
end
Expand Down

0 comments on commit d9dea96

Please sign in to comment.