Skip to content

Commit

Permalink
Remove all inbounds calls (#39)
Browse files Browse the repository at this point in the history
  • Loading branch information
DanielVandH authored Aug 8, 2023
1 parent 114a3d1 commit 1e25a06
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 26 deletions.
2 changes: 1 addition & 1 deletion Project.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name = "FiniteVolumeMethod"
uuid = "d4f04ab7-4f65-4d72-8a28-7087bc7f46f4"
authors = ["Daniel VandenHeuvel <[email protected]>"]
version = "0.4.8"
version = "0.4.9"

[deps]
ChunkSplitters = "ae650224-84b6-46f8-82ea-d812ca08434e"
Expand Down
30 changes: 15 additions & 15 deletions src/equations.jl
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
@inline getα(shape_coeffs) = @inbounds shape_coeffs[1]
@inline getβ(shape_coeffs) = @inbounds shape_coeffs[2]
@inline getγ(shape_coeffs) = @inbounds shape_coeffs[3]
@inline getα(shape_coeffs) = shape_coeffs[1]
@inline getβ(shape_coeffs) = shape_coeffs[2]
@inline getγ(shape_coeffs) = shape_coeffs[3]

@inline function linear_shape_function_coefficients!(shape_coeffs, u, prob, T)
i, j, k = indices(T)
@muladd @inbounds shape_coeffs[1] = gets(prob, T, 1) * u[i] + gets(prob, T, 2) * u[j] + gets(prob, T, 3) * u[k]
@muladd @inbounds shape_coeffs[2] = gets(prob, T, 4) * u[i] + gets(prob, T, 5) * u[j] + gets(prob, T, 6) * u[k]
@muladd @inbounds shape_coeffs[3] = gets(prob, T, 7) * u[i] + gets(prob, T, 8) * u[j] + gets(prob, T, 9) * u[k]
@muladd shape_coeffs[1] = gets(prob, T, 1) * u[i] + gets(prob, T, 2) * u[j] + gets(prob, T, 3) * u[k]
@muladd shape_coeffs[2] = gets(prob, T, 4) * u[i] + gets(prob, T, 5) * u[j] + gets(prob, T, 6) * u[k]
@muladd shape_coeffs[3] = gets(prob, T, 7) * u[i] + gets(prob, T, 8) * u[j] + gets(prob, T, 9) * u[k]
return nothing
end

Expand All @@ -19,12 +19,12 @@ function fvm_eqs_edge!(du, t, (vj, j), (vjnb, jnb), α, β, γ, prob, flux_cache
else
flux_cache = get_flux(prob, x, y, t, α, β, γ) # Make no assumption that flux_cache is mutable
end
@muladd @inbounds summand = -(getx(flux_cache) * xn + gety(flux_cache) * yn) *
@muladd summand = -(getx(flux_cache) * xn + gety(flux_cache) * yn) *
if is_interior_or_neumann_node(prob, vj)
@inbounds du[vj] += summand
du[vj] += summand
end
if is_interior_or_neumann_node(prob, vjnb)
@inbounds du[vjnb] -= summand
du[vjnb] -= summand
end
return nothing
end
Expand Down Expand Up @@ -72,8 +72,8 @@ end
@inline function fvm_eqs_source_contribution!(du, u, t, j, prob)
x, y = get_point(prob, j)
V = get_volumes(prob, j)
@inbounds R = get_reaction(prob, x, y, t, u[j])
@muladd @inbounds du[j] = du[j] / V + R
R = get_reaction(prob, x, y, t, u[j])
@muladd du[j] = du[j] / V + R
return nothing
end
@inline function fvm_eqs_source_contribution!(du, u, t, prob)
Expand All @@ -86,11 +86,11 @@ end
@inline function evaluate_boundary_function(u, t, j, prob)
segment_number = map_node_to_segment(prob, j)
x, y = get_point(prob, j)
@inbounds val = evaluate_boundary_function(prob, segment_number, x, y, t, u[j])
val = evaluate_boundary_function(prob, segment_number, x, y, t, u[j])
return val
end
@inline function evaluate_boundary_function!(du, u, t, j, prob)
@inbounds du[j] = evaluate_boundary_function(u, t, j, prob)
du[j] = evaluate_boundary_function(u, t, j, prob)
return nothing
end

Expand All @@ -115,11 +115,11 @@ end

function update_dirichlet_nodes!(u, t, prob)
for j in get_dirichlet_nodes(prob)
@inbounds u[j] = evaluate_boundary_function(u, t, j, prob)
u[j] = evaluate_boundary_function(u, t, j, prob)
end
return nothing
end
function update_dirichlet_nodes!(integrator)
@inbounds update_dirichlet_nodes!(integrator.u, integrator.t, integrator.p[1])
update_dirichlet_nodes!(integrator.u, integrator.t, integrator.p[1])
return nothing
end
20 changes: 10 additions & 10 deletions src/parallel_equations.jl
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
@inbounds @muladd getα(prob, T, u) = gets(prob, T, 1) * u[T[1]] + gets(prob, T, 2) * u[T[2]] + gets(prob, T, 3) * u[T[3]]
@inbounds @muladd getβ(prob, T, u) = gets(prob, T, 4) * u[T[1]] + gets(prob, T, 5) * u[T[2]] + gets(prob, T, 6) * u[T[3]]
@inbounds @muladd getγ(prob, T, u) = gets(prob, T, 7) * u[T[1]] + gets(prob, T, 8) * u[T[2]] + gets(prob, T, 9) * u[T[3]]
@muladd getα(prob, T, u) = gets(prob, T, 1) * u[T[1]] + gets(prob, T, 2) * u[T[2]] + gets(prob, T, 3) * u[T[3]]
@muladd getβ(prob, T, u) = gets(prob, T, 4) * u[T[1]] + gets(prob, T, 5) * u[T[2]] + gets(prob, T, 6) * u[T[3]]
@muladd getγ(prob, T, u) = gets(prob, T, 7) * u[T[1]] + gets(prob, T, 8) * u[T[2]] + gets(prob, T, 9) * u[T[3]]

function par_fvm_eqs_edge!(du, t, (vj, j), (vjnb, jnb), α, β, γ, prob, flux_cache, T)
x, y = get_control_volume_edge_midpoints(prob, T, j)
Expand All @@ -11,12 +11,12 @@ function par_fvm_eqs_edge!(du, t, (vj, j), (vjnb, jnb), α, β, γ, prob, flux_c
else
flux_cache = get_flux(prob, x, y, t, α, β, γ) # Make no assumption that flux_cache is mutable
end
@muladd @inbounds summand = -(getx(flux_cache) * xn + gety(flux_cache) * yn) *
@muladd summand = -(getx(flux_cache) * xn + gety(flux_cache) * yn) *
if is_interior_or_neumann_node(prob, vj)
@inbounds du[vj] += summand
du[vj] += summand
end
if is_interior_or_neumann_node(prob, vjnb)
@inbounds du[vjnb] -= summand
du[vjnb] -= summand
end
return nothing
end
Expand Down Expand Up @@ -72,8 +72,8 @@ end
@inline function par_fvm_eqs_source_contribution!(du, u, t, j::Integer, prob)
x, y = get_point(prob, j)
V = get_volumes(prob, j)
@inbounds R = get_reaction(prob, x, y, t, u[j])
@inbounds @muladd du[j] = du[j] / V + R
R = get_reaction(prob, x, y, t, u[j])
@muladd du[j] = du[j] / V + R
return nothing
end
@inline function par_fvm_eqs_source_contribution!(du, u, t, prob, interior_or_neumann_nodes)
Expand Down Expand Up @@ -119,12 +119,12 @@ end

function par_update_dirichlet_nodes!(u, t, prob, dirichlet_nodes)
Threads.@threads for j in dirichlet_nodes
@inbounds u[j] = evaluate_boundary_function(u, t, j, prob)
u[j] = evaluate_boundary_function(u, t, j, prob)
end
return nothing
end
function par_update_dirichlet_nodes!(integrator)
@inbounds par_update_dirichlet_nodes!(integrator.u, integrator.t, integrator.p[1], integrator.p[10])
par_update_dirichlet_nodes!(integrator.u, integrator.t, integrator.p[1], integrator.p[10])
return nothing
end

Expand Down

0 comments on commit 1e25a06

Please sign in to comment.