Skip to content

Commit

Permalink
the old global loop shadowing problem
Browse files Browse the repository at this point in the history
  • Loading branch information
xtalax committed Mar 3, 2023
1 parent e90cd8a commit 1978de9
Showing 1 changed file with 22 additions and 35 deletions.
57 changes: 22 additions & 35 deletions lib/linear_convection.jl
Original file line number Diff line number Diff line change
Expand Up @@ -260,25 +260,29 @@ function linear_convection_dirichlet3(f, h, ps, name = :linear_convection)
end

funcs = [x -> x, x -> x^2, x -> x^3, sinpi, cospi, x -> 1.0 - abs(x - floor(x + 0.5)), sq]
i = 0
for f in funcs
for h in funcs
conv = linear_convection_dirichlet3(f, h, [rand()], Symbol(:funcconv, i))
push!(all_systems, conv)
i += 1
conv = linear_convection_dirichlet3(f, x -> -2 * h(x), [2 * rand()], Symbol(:funcconv, i))
push!(all_systems, conv)
i += 1
conv = linear_convection_dirichlet3(x -> -10 * f(x), h, [rand()], Symbol(:funcconv, i))
push!(all_systems, conv)
i += 1
conv = linear_convection_dirichlet3(x -> -6 * f(x), x -> -5 * h(x), [rand()],
Symbol(:funcconv, i))
push!(all_systems, conv)
i += 1
function add_systems!(all_systems, funcs, sysconstructor, name)
i = 0
for f in funcs
for h in funcs
conv = sysconstructor(f, h, [rand()], Symbol(name, i))
push!(all_systems, conv)
i += 1
conv = sysconstructor(f, x -> -2 * h(x), [2 * rand()], Symbol(name, i))
push!(all_systems, conv)
i += 1
conv = sysconstructor(x -> -10 * f(x), h, [rand()], Symbol(name, i))
push!(all_systems, conv)
i += 1
conv = sysconstructor(x -> -6 * f(x), x -> -5 * h(x), [rand()],
Symbol(name, i))
push!(all_systems, conv)
i += 1
end
end
end

add_systems!(all_systems, funcs, linear_convection_dirichlet3, "funcconv")

"""
# Linear Convection Equation with Dirichlet Boundary Conditions 4
Expand Down Expand Up @@ -322,25 +326,8 @@ function linear_convection_dirichlet4(f, h, ps, name = :linear_convection)
lin_conv
end

funcs = [x -> x, x -> x^2, x -> x^3, sinpi, cospi, x -> 1.0 - abs(x - floor(x + 0.5)), sq]
i = 0
for f in funcs
for h in funcs
conv = linear_convection_dirichlet4(f, h, [rand()], Symbol(:funcconvneg, i))
push!(all_systems, conv)
i += 1
conv = linear_convection_dirichlet4(f, x -> -2 * h(x), [2 * rand()], Symbol(:funcconvneg, i))
push!(all_systems, conv)
i += 1
conv = linear_convection_dirichlet4(x -> -10 * f(x), h, [rand()], Symbol(:funcconvneg, i))
push!(all_systems, conv)
i += 1
conv = linear_convection_dirichlet4(x -> -6 * f(x), x -> -5 * h(x), [rand()],
Symbol(:funcconvneg, i))
push!(all_systems, conv)
i += 1
end
end
add_systems!(all_systems, funcs, linear_convection_dirichlet4, "funcconvneg")


"""
# Convection Diffusion Equation in 1D
Expand Down

0 comments on commit 1978de9

Please sign in to comment.