Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use reduction for max wave speed computation in max_dt #2207

Merged
merged 2 commits into from
Dec 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading