Skip to content

Commit

Permalink
Use reduction for max wave speed computation in max_dt
Browse files Browse the repository at this point in the history
  • Loading branch information
DanielDoehring committed Dec 12, 2024
1 parent ab8ecad commit ef86116
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 12 deletions.
8 changes: 4 additions & 4 deletions src/callbacks_step/stepsize_dg1d.jl
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ function max_dt(u, t, mesh::TreeMesh{1},
# e.g. for steady-state linear advection
max_scaled_speed = nextfloat(zero(t))

for element in eachelement(dg, cache)
@batch reduction=(max, max_scaled_speed) for element in eachelement(dg, cache)
max_lambda1 = zero(max_scaled_speed)
for i in eachnode(dg)
u_node = get_node_vars(u, equations, dg, i, element)
Expand All @@ -31,7 +31,7 @@ function max_dt(u, t, mesh::TreeMesh{1},
# e.g. for steady-state linear advection
max_scaled_speed = nextfloat(zero(t))

for element in eachelement(dg, cache)
@batch reduction=(max, max_scaled_speed) for element in eachelement(dg, cache)
max_lambda1, = max_abs_speeds(equations)
inv_jacobian = cache.elements.inverse_jacobian[element]
max_scaled_speed = max(max_scaled_speed, inv_jacobian * max_lambda1)
Expand All @@ -46,7 +46,7 @@ function max_dt(u, t, mesh::StructuredMesh{1},
# e.g. for steady-state linear advection
max_scaled_speed = nextfloat(zero(t))

for element in eachelement(dg, cache)
@batch reduction=(max, max_scaled_speed) for element in eachelement(dg, cache)
max_lambda1 = zero(max_scaled_speed)

for i in eachnode(dg)
Expand All @@ -70,7 +70,7 @@ function max_dt(u, t, mesh::StructuredMesh{1},
# e.g. for steady-state linear advection
max_scaled_speed = nextfloat(zero(t))

for element in eachelement(dg, cache)
@batch reduction=(max, max_scaled_speed) for element in eachelement(dg, cache)
max_lambda1, = max_abs_speeds(equations)

for i in eachnode(dg)
Expand Down
8 changes: 4 additions & 4 deletions src/callbacks_step/stepsize_dg2d.jl
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ function max_dt(u, t, mesh::TreeMesh{2},
# e.g. for steady-state linear advection
max_scaled_speed = nextfloat(zero(t))

for element in eachelement(dg, cache)
@batch reduction=(max, max_scaled_speed) for element in eachelement(dg, cache)
max_lambda1 = max_lambda2 = zero(max_scaled_speed)
for j in eachnode(dg), i in eachnode(dg)
u_node = get_node_vars(u, equations, dg, i, j, element)
Expand All @@ -33,7 +33,7 @@ function max_dt(u, t, mesh::TreeMesh{2},
# e.g. for steady-state linear advection
max_scaled_speed = nextfloat(zero(t))

for element in eachelement(dg, cache)
@batch reduction=(max, max_scaled_speed) for element in eachelement(dg, cache)
max_lambda1, max_lambda2 = max_abs_speeds(equations)
inv_jacobian = cache.elements.inverse_jacobian[element]
max_scaled_speed = max(max_scaled_speed,
Expand Down Expand Up @@ -87,7 +87,7 @@ function max_dt(u, t,

@unpack contravariant_vectors, inverse_jacobian = cache.elements

for element in eachelement(dg, cache)
@batch reduction=(max, max_scaled_speed) for element in eachelement(dg, cache)
max_lambda1 = max_lambda2 = zero(max_scaled_speed)
for j in eachnode(dg), i in eachnode(dg)
u_node = get_node_vars(u, equations, dg, i, j, element)
Expand Down Expand Up @@ -125,7 +125,7 @@ function max_dt(u, t,

max_lambda1, max_lambda2 = max_abs_speeds(equations)

for element in eachelement(dg, cache)
@batch reduction=(max, max_scaled_speed) for element in eachelement(dg, cache)
for j in eachnode(dg), i in eachnode(dg)
# Local speeds transformed to the reference element
Ja11, Ja12 = get_contravariant_vector(1, contravariant_vectors, i, j,
Expand Down
8 changes: 4 additions & 4 deletions src/callbacks_step/stepsize_dg3d.jl
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ function max_dt(u, t, mesh::TreeMesh{3},
# e.g. for steady-state linear advection
max_scaled_speed = nextfloat(zero(t))

for element in eachelement(dg, cache)
@batch reduction=(max, max_scaled_speed) for element in eachelement(dg, cache)
max_lambda1 = max_lambda2 = max_lambda3 = zero(max_scaled_speed)
for k in eachnode(dg), j in eachnode(dg), i in eachnode(dg)
u_node = get_node_vars(u, equations, dg, i, j, k, element)
Expand All @@ -34,7 +34,7 @@ function max_dt(u, t, mesh::TreeMesh{3},
# e.g. for steady-state linear advection
max_scaled_speed = nextfloat(zero(t))

for element in eachelement(dg, cache)
@batch reduction=(max, max_scaled_speed) for element in eachelement(dg, cache)
max_lambda1, max_lambda2, max_lambda3 = max_abs_speeds(equations)
inv_jacobian = cache.elements.inverse_jacobian[element]
max_scaled_speed = max(max_scaled_speed,
Expand All @@ -52,7 +52,7 @@ function max_dt(u, t, mesh::Union{StructuredMesh{3}, P4estMesh{3}, T8codeMesh{3}

@unpack contravariant_vectors = cache.elements

for element in eachelement(dg, cache)
@batch reduction=(max, max_scaled_speed) for element in eachelement(dg, cache)
max_lambda1 = max_lambda2 = max_lambda3 = zero(max_scaled_speed)
for k in eachnode(dg), j in eachnode(dg), i in eachnode(dg)
u_node = get_node_vars(u, equations, dg, i, j, k, element)
Expand Down Expand Up @@ -92,7 +92,7 @@ function max_dt(u, t, mesh::Union{StructuredMesh{3}, P4estMesh{3}, T8codeMesh{3}

max_lambda1, max_lambda2, max_lambda3 = max_abs_speeds(equations)

for element in eachelement(dg, cache)
@batch reduction=(max, max_scaled_speed) for element in eachelement(dg, cache)
for k in eachnode(dg), j in eachnode(dg), i in eachnode(dg)
Ja11, Ja12, Ja13 = get_contravariant_vector(1, contravariant_vectors, i, j,
k, element)
Expand Down

0 comments on commit ef86116

Please sign in to comment.