Skip to content

Commit

Permalink
Add mesh as parameter of get_boundary_outer_state
Browse files Browse the repository at this point in the history
- Fixes bug that P4estMesh calls the right `characteristic_boundary_state` routine
  • Loading branch information
bennibolm committed Dec 1, 2023
1 parent 0ad2bf9 commit b45e92e
Show file tree
Hide file tree
Showing 9 changed files with 82 additions and 62 deletions.
1 change: 1 addition & 0 deletions examples/structured_2d_dgsem/elixir_euler_double_mach.jl
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ end
@inline function Trixi.get_boundary_outer_state(u_inner, cache, t,
boundary_condition::typeof(boundary_condition_mixed_characteristic_wall),
normal_direction::AbstractVector, direction,
mesh::StructuredMesh{2},
equations::CompressibleEulerEquations2D,
dg, indices...)
x = Trixi.get_node_coords(cache.elements.node_coordinates, equations, dg, indices...)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ end
@inline function Trixi.get_boundary_outer_state(u_inner, cache, t,
boundary_condition::typeof(boundary_condition_mixed_characteristic_wall),
normal_direction::AbstractVector, direction,
mesh::StructuredMesh{2},
equations::CompressibleEulerEquations2D,
dg, indices...)
x = Trixi.get_node_coords(cache.elements.node_coordinates, equations, dg, indices...)
Expand Down
7 changes: 4 additions & 3 deletions src/equations/equations.jl
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,8 @@ end
surface_flux_function,
equations)
u_boundary = boundary_condition.boundary_value_function(boundary_condition.outer_boundary_value_function,
u_inner, orientation_or_normal,
u_inner,
orientation_or_normal,
direction, x, t, equations)

# Calculate boundary flux
Expand All @@ -249,8 +250,8 @@ end
surface_flux_function,
equations)
u_boundary = boundary_condition.boundary_value_function(boundary_condition.outer_boundary_value_function,
u_inner, normal_direction, x, t,
equations)
u_inner, normal_direction,
x, t, equations)

# Calculate boundary flux
flux = surface_flux_function(u_inner, u_boundary, normal_direction, equations)
Expand Down
20 changes: 11 additions & 9 deletions src/solvers/dgsem_p4est/dg_2d_subcell_limiters.jl
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,8 @@
flux_primary = flux(u_primary, normal_direction, equations)
flux_secondary = flux(u_secondary, normal_direction, equations)

bar_state = 0.5 * (u_primary + u_secondary) - 0.5 * (flux_secondary - flux_primary) / lambda
bar_state = 0.5 * (u_primary + u_secondary) -
0.5 * (flux_secondary - flux_primary) / lambda
if primary_direction == 1
set_node_vars!(bar_states1, bar_state, equations, dg,
i_primary, j_primary, primary_element)
Expand Down Expand Up @@ -116,23 +117,24 @@
end
end

calc_lambdas_bar_states_boundary!(u, t, limiter, boundary_conditions, equations, dg,
cache; calc_bar_states = calc_bar_states)
calc_lambdas_bar_states_boundary!(u, t, limiter, boundary_conditions,
mesh, equations, dg, cache;
calc_bar_states = calc_bar_states)

return nothing
end

@inline function calc_lambdas_bar_states_boundary!(u, t, limiter,
boundary_conditions::BoundaryConditionPeriodic,
mesh::P4estMesh, equations, dg, cache;
calc_bar_states = true)
mesh::P4estMesh, equations, dg,
cache; calc_bar_states = true)
return nothing
end

# Calc lambdas and bar states at physical boundaries
@inline function calc_lambdas_bar_states_boundary!(u, t, limiter, boundary_conditions,
mesh::P4estMesh{2}, equations, dg, cache;
calc_bar_states = true)
mesh::P4estMesh{2}, equations, dg,
cache; calc_bar_states = true)
(; boundary_condition_types, boundary_indices) = boundary_conditions
(; contravariant_vectors) = cache.elements

Expand Down Expand Up @@ -166,8 +168,8 @@ end
u_inner = get_node_vars(u, equations, dg, i_node, j_node, element)
u_outer = get_boundary_outer_state(u_inner, cache, t,
boundary_condition, normal_direction,
direction, equations, dg, i_node,
j_node, element)
direction, mesh, equations, dg,
i_node, j_node, element)

lambda = max_abs_speed_naive(u_inner, u_outer, normal_direction,
equations)
Expand Down
24 changes: 13 additions & 11 deletions src/solvers/dgsem_p4est/subcell_limiters_2d.jl
Original file line number Diff line number Diff line change
Expand Up @@ -68,20 +68,21 @@ function calc_bounds_twosided_interface!(var_min, var_max, variable, u, t, semi,
end

calc_bounds_twosided_interface_inner!(var_min, var_max, variable, u, t,
boundary_conditions, equations, dg, cache)
boundary_conditions,
mesh, equations, dg, cache)

return nothing
end

@inline function calc_bounds_twosided_interface_inner!(var_min, var_max, variable, u, t,
boundary_conditions::BoundaryConditionPeriodic,
equations, dg, cache)
mesh, equations, dg, cache)
return nothing
end

@inline function calc_bounds_twosided_interface_inner!(var_min, var_max, variable, u, t,
boundary_conditions, equations,
dg, cache)
boundary_conditions,
mesh, equations, dg, cache)
(; boundary_condition_types, boundary_indices) = boundary_conditions
(; contravariant_vectors) = cache.elements

Expand Down Expand Up @@ -110,8 +111,8 @@ end

u_outer = get_boundary_outer_state(u_inner, cache, t,
boundary_condition, normal_direction,
direction, equations, dg, i_node,
j_node, element)
direction, mesh, equations, dg,
i_node, j_node, element)
var_outer = u_outer[variable]

var_min[i_node, j_node, element] = min(var_min[i_node, j_node, element],
Expand Down Expand Up @@ -186,21 +187,22 @@ function calc_bounds_onesided_interface!(var_minmax, minmax, variable, u, t, sem
end

calc_bounds_onesided_interface_inner!(var_minmax, minmax, variable, u, t,
boundary_conditions, equations, dg, cache)
boundary_conditions,
mesh, equations, dg, cache)

return nothing
end

@inline function calc_bounds_onesided_interface_inner!(var_minmax, minmax, variable, u,
t,
boundary_conditions::BoundaryConditionPeriodic,
equations, dg, cache)
mesh, equations, dg, cache)
return nothing
end

@inline function calc_bounds_onesided_interface_inner!(var_minmax, minmax, variable, u,
t, boundary_conditions,
equations, dg, cache)
mesh, equations, dg, cache)
(; boundary_condition_types, boundary_indices) = boundary_conditions
(; contravariant_vectors) = cache.elements

Expand Down Expand Up @@ -229,8 +231,8 @@ end

u_outer = get_boundary_outer_state(u_inner, cache, t,
boundary_condition, normal_direction,
direction, equations, dg, i_node,
j_node, element)
direction, mesh, equations, dg,
i_node, j_node, element)
var_outer = variable(u_outer, equations)

var_minmax[i_node, j_node, element] = minmax(var_minmax[i_node, j_node,
Expand Down
14 changes: 8 additions & 6 deletions src/solvers/dgsem_structured/dg_2d_subcell_limiters.jl
Original file line number Diff line number Diff line change
Expand Up @@ -246,7 +246,8 @@ end
u_inner = get_node_vars(u, equations, dg, 1, j, element)
u_outer = get_boundary_outer_state(u_inner, cache, t,
boundary_conditions[1], Ja1, 1,
equations, dg, 1, j, element)
mesh, equations, dg,
1, j, element)
lambda1[1, j, element] = max_abs_speed_naive(u_inner, u_outer, Ja1,
equations)

Expand All @@ -271,8 +272,8 @@ end
u_inner = get_node_vars(u, equations, dg, nnodes(dg), j, element)
u_outer = get_boundary_outer_state(u_inner, cache, t,
boundary_conditions[2], Ja1, 2,
equations, dg, nnodes(dg), j,
element)
mesh, equations, dg,
nnodes(dg), j, element)
lambda1[nnodes(dg) + 1, j, element] = max_abs_speed_naive(u_inner,
u_outer, Ja1,
equations)
Expand Down Expand Up @@ -302,7 +303,8 @@ end
u_inner = get_node_vars(u, equations, dg, i, 1, element)
u_outer = get_boundary_outer_state(u_inner, cache, t,
boundary_conditions[3], Ja2, 3,
equations, dg, i, 1, element)
mesh, equations, dg,
i, 1, element)
lambda2[i, 1, element] = max_abs_speed_naive(u_inner, u_outer, Ja2,
equations)

Expand All @@ -327,8 +329,8 @@ end
u_inner = get_node_vars(u, equations, dg, i, nnodes(dg), element)
u_outer = get_boundary_outer_state(u_inner, cache, t,
boundary_conditions[4], Ja2, 4,
equations, dg, i, nnodes(dg),
element)
mesh, equations, dg,
i, nnodes(dg), element)
lambda2[i, nnodes(dg) + 1, element] = max_abs_speed_naive(u_inner,
u_outer, Ja2,
equations)
Expand Down
28 changes: 16 additions & 12 deletions src/solvers/dgsem_structured/subcell_limiters_2d.jl
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,8 @@ function calc_bounds_twosided_interface!(var_min, var_max, variable, u, t, semi,
u_inner = get_node_vars(u, equations, dg, 1, j, element)
u_outer = get_boundary_outer_state(u_inner, cache, t,
boundary_conditions[1], Ja1, 1,
equations, dg, 1, j, element)
mesh, equations, dg,
1, j, element)
var_outer = u_outer[variable]

var_min[1, j, element] = min(var_min[1, j, element], var_outer)
Expand All @@ -77,8 +78,8 @@ function calc_bounds_twosided_interface!(var_min, var_max, variable, u, t, semi,
u_inner = get_node_vars(u, equations, dg, nnodes(dg), j, element)
u_outer = get_boundary_outer_state(u_inner, cache, t,
boundary_conditions[2], Ja1, 2,
equations, dg, nnodes(dg), j,
element)
mesh, equations, dg,
nnodes(dg), j, element)
var_outer = u_outer[variable]

var_min[nnodes(dg), j, element] = min(var_min[nnodes(dg), j, element],
Expand All @@ -97,7 +98,8 @@ function calc_bounds_twosided_interface!(var_min, var_max, variable, u, t, semi,
u_inner = get_node_vars(u, equations, dg, i, 1, element)
u_outer = get_boundary_outer_state(u_inner, cache, t,
boundary_conditions[3], Ja2, 3,
equations, dg, i, 1, element)
mesh, equations, dg,
i, 1, element)
var_outer = u_outer[variable]

var_min[i, 1, element] = min(var_min[i, 1, element], var_outer)
Expand All @@ -113,8 +115,8 @@ function calc_bounds_twosided_interface!(var_min, var_max, variable, u, t, semi,
u_inner = get_node_vars(u, equations, dg, i, nnodes(dg), element)
u_outer = get_boundary_outer_state(u_inner, cache, t,
boundary_conditions[4], Ja2, 4,
equations, dg, i, nnodes(dg),
element)
mesh, equations, dg,
i, nnodes(dg), element)
var_outer = u_outer[variable]

var_min[i, nnodes(dg), element] = min(var_min[i, nnodes(dg), element],
Expand Down Expand Up @@ -180,7 +182,8 @@ function calc_bounds_onesided_interface!(var_minmax, minmax, variable, u, t, sem
u_inner = get_node_vars(u, equations, dg, 1, j, element)
u_outer = get_boundary_outer_state(u_inner, cache, t,
boundary_conditions[1], Ja1, 1,
equations, dg, 1, j, element)
mesh, equations, dg,
1, j, element)
var_outer = variable(u_outer, equations)

var_minmax[1, j, element] = minmax(var_minmax[1, j, element], var_outer)
Expand All @@ -195,8 +198,8 @@ function calc_bounds_onesided_interface!(var_minmax, minmax, variable, u, t, sem
u_inner = get_node_vars(u, equations, dg, nnodes(dg), j, element)
u_outer = get_boundary_outer_state(u_inner, cache, t,
boundary_conditions[2], Ja1, 2,
equations, dg, nnodes(dg), j,
element)
mesh, equations, dg,
nnodes(dg), j, element)
var_outer = variable(u_outer, equations)

var_minmax[nnodes(dg), j, element] = minmax(var_minmax[nnodes(dg), j,
Expand All @@ -214,7 +217,8 @@ function calc_bounds_onesided_interface!(var_minmax, minmax, variable, u, t, sem
u_inner = get_node_vars(u, equations, dg, i, 1, element)
u_outer = get_boundary_outer_state(u_inner, cache, t,
boundary_conditions[3], Ja2, 3,
equations, dg, i, 1, element)
mesh, equations, dg,
i, 1, element)
var_outer = variable(u_outer, equations)

var_minmax[i, 1, element] = minmax(var_minmax[i, 1, element], var_outer)
Expand All @@ -229,8 +233,8 @@ function calc_bounds_onesided_interface!(var_minmax, minmax, variable, u, t, sem
u_inner = get_node_vars(u, equations, dg, i, nnodes(dg), element)
u_outer = get_boundary_outer_state(u_inner, cache, t,
boundary_conditions[4], Ja2, 4,
equations, dg, i, nnodes(dg),
element)
mesh, equations, dg,
i, nnodes(dg), element)
var_outer = variable(u_outer, equations)

var_minmax[i, nnodes(dg), element] = minmax(var_minmax[i, nnodes(dg),
Expand Down
Loading

0 comments on commit b45e92e

Please sign in to comment.